xref: /wlan-dirver/qca-wifi-host-cmn/umac/scan/dispatcher/inc/wlan_scan_utils_api.h (revision 6e4b9c54b687e18b0132e53b73b6cc7445a0ba3d)
1 /*
2  * Copyright (c) 2017-2018 The Linux Foundation. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for
5  * any purpose with or without fee is hereby granted, provided that the
6  * above copyright notice and this permission notice appear in all
7  * copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16  * PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 /*
20  * DOC: contains scan public utility functions
21  */
22 
23 #ifndef _WLAN_SCAN_UTILS_H_
24 #define _WLAN_SCAN_UTILS_H_
25 
26 #include <wlan_objmgr_cmn.h>
27 #include <qdf_mc_timer.h>
28 #include <wlan_objmgr_psoc_obj.h>
29 #include <wlan_objmgr_pdev_obj.h>
30 #include <wlan_objmgr_vdev_obj.h>
31 #include <wlan_scan_public_structs.h>
32 #include<wlan_mgmt_txrx_utils_api.h>
33 
34 /**
35  * util_is_scan_entry_match() - func to check if both scan entry
36  * are from same AP
37  * @entry1: scan entry 1
38  * @entry2: scan entry 2
39  *
40  * match the two scan entries
41  *
42  * Return: true if entry match else false.
43  */
44 bool util_is_scan_entry_match(
45 	struct scan_cache_entry *entry1,
46 	struct scan_cache_entry *entry2);
47 
48 /**
49  * util_scan_unpack_beacon_frame() - func to unpack beacon frame to scan entry
50  * @pdev: pdev pointer
51  * @frame: beacon/probe frame
52  * @frame_len: beacon frame len
53  * @frm_subtype: beacon or probe
54  * @rx_param: rx meta data
55  *
56  * get the defaults scan params
57  *
58  * Return: unpacked list of scan entries.
59  */
60 qdf_list_t *util_scan_unpack_beacon_frame(
61 	struct wlan_objmgr_pdev *pdev,
62 	uint8_t *frame, qdf_size_t frame_len, uint32_t frm_subtype,
63 	struct mgmt_rx_event_params *rx_param);
64 
65 /**
66  * util_scan_add_hidden_ssid() - func to add hidden ssid
67  * @pdev: pdev pointer
68  * @frame: beacon buf
69  *
70  * Return:
71  */
72 #ifdef WLAN_DFS_CHAN_HIDDEN_SSID
73 QDF_STATUS
74 util_scan_add_hidden_ssid(struct wlan_objmgr_pdev *pdev, qdf_nbuf_t bcnbuf);
75 #else
76 static inline QDF_STATUS
77 util_scan_add_hidden_ssid(struct wlan_objmgr_pdev *pdev, qdf_nbuf_t bcnbuf)
78 {
79 	return  QDF_STATUS_SUCCESS;
80 }
81 #endif /* WLAN_DFS_CHAN_HIDDEN_SSID */
82 
83 /**
84  * util_scan_get_ev_type_name() - converts enum event to printable string
85  * @event:      event of type scan_event_type
86  *
87  * API, converts enum event to printable character string
88  *
89  * Return:      pointer to printable string
90  */
91 const char *util_scan_get_ev_type_name(enum scan_event_type event);
92 
93 /**
94  * util_scan_get_ev_reason_name() - converts enum reason to printable string
95  * @reason      enum of scan completion reason
96  *
97  * API, converts enum event to printable character string
98  *
99  * Return:      pointer to printable string
100  */
101 const char *util_scan_get_ev_reason_name(enum scan_completion_reason reason);
102 
103 /**
104  * util_scan_entry_macaddr() - function to read transmitter address
105  * @scan_entry: scan entry
106  *
107  * API, function to read transmitter address of scan entry
108  *
109  * Return:      pointer to mac address
110  */
111 static inline uint8_t*
112 util_scan_entry_macaddr(struct scan_cache_entry *scan_entry)
113 {
114 	return &(scan_entry->mac_addr.bytes[0]);
115 }
116 
117 /**
118  * util_scan_entry_bssid() - function to read bssid
119  * @scan_entry: scan entry
120  *
121  * API, function to read bssid of scan entry
122  *
123  * Return: pointer to mac address
124  */
125 static inline uint8_t*
126 util_scan_entry_bssid(struct scan_cache_entry *scan_entry)
127 {
128 	return &(scan_entry->bssid.bytes[0]);
129 }
130 
131 /**
132  * util_scan_entry_capinfo() - function to read capibility info
133  * @scan_entry: scan entry
134  *
135  * API, function to read capibility info of scan entry
136  *
137  * Return: capability info
138  */
139 static inline union wlan_capability
140 util_scan_entry_capinfo(struct scan_cache_entry *scan_entry)
141 {
142 	return scan_entry->cap_info;
143 }
144 
145 /**
146  * util_scan_entry_beacon_interval() - function to read beacon interval
147  * @scan_entry: scan entry
148  *
149  * API, function to read beacon interval of scan entry
150  *
151  * Return: beacon interval
152  */
153 static inline uint16_t
154 util_scan_entry_beacon_interval(struct scan_cache_entry *scan_entry)
155 {
156 	return scan_entry->bcn_int;
157 }
158 
159 /**
160  * util_scan_entry_sequence_number() - function to read sequence number
161  * @scan_entry: scan entry
162  *
163  * API, function to read sequence number of scan entry
164  *
165  * Return: sequence number
166  */
167 static inline uint16_t
168 util_scan_entry_sequence_number(struct scan_cache_entry *scan_entry)
169 {
170 	return scan_entry->seq_num;
171 }
172 
173 /**
174  * util_scan_entry_tsf() - function to read tsf
175  * @scan_entry: scan entry
176  *
177  * API, function to read tsf of scan entry
178  *
179  * Return: tsf
180  */
181 static inline uint8_t*
182 util_scan_entry_tsf(struct scan_cache_entry *scan_entry)
183 {
184 	return scan_entry->tsf_info.data;
185 }
186 
187 /**
188  * util_scan_entry_reset_timestamp() - function to reset bcn receive timestamp
189  * @scan_entry: scan entry
190  *
191  * API, function to reset bcn receive timestamp of scan entry
192  *
193  * Return: void
194  */
195 static inline void
196 util_scan_entry_reset_timestamp(struct scan_cache_entry *scan_entry)
197 {
198 	scan_entry->scan_entry_time = 0;
199 }
200 
201 /*
202  * Macros used for RSSI calculation.
203  */
204 #define WLAN_RSSI_AVERAGING_TIME (5 * 1000) /* 5 seconds */
205 
206 #define WLAN_RSSI_EP_MULTIPLIER (1<<7)  /* pow2 to optimize out * and / */
207 
208 #define WLAN_RSSI_LPF_LEN       10
209 #define WLAN_RSSI_DUMMY_MARKER  0x127
210 
211 #define WLAN_EP_MUL(x, mul) ((x) * (mul))
212 
213 #define WLAN_EP_RND(x, mul) ((((x)%(mul)) >= ((mul)/2)) ?\
214 	((x) + ((mul) - 1)) / (mul) : (x)/(mul))
215 
216 #define WLAN_RSSI_GET(x) WLAN_EP_RND(x, WLAN_RSSI_EP_MULTIPLIER)
217 
218 #define RSSI_LPF_THRESHOLD      -20
219 
220 
221 #define WLAN_RSSI_OUT(x) (((x) != WLAN_RSSI_DUMMY_MARKER) ?     \
222 	(WLAN_EP_RND((x), WLAN_RSSI_EP_MULTIPLIER)) :  WLAN_RSSI_DUMMY_MARKER)
223 
224 
225 #define WLAN_RSSI_IN(x)         (WLAN_EP_MUL((x), WLAN_RSSI_EP_MULTIPLIER))
226 
227 #define WLAN_LPF_RSSI(x, y, len) \
228 	((x != WLAN_RSSI_DUMMY_MARKER) ? ((((x) << 3) + (y) - (x)) >> 3) : (y))
229 
230 #define WLAN_RSSI_LPF(x, y) do { \
231 	if ((y) >= RSSI_LPF_THRESHOLD) \
232 		x = WLAN_LPF_RSSI((x), WLAN_RSSI_IN((y)), WLAN_RSSI_LPF_LEN); \
233 	} while (0)
234 
235 #define WLAN_ABS_RSSI_LPF(x, y) do { \
236 	if ((y) >= (RSSI_LPF_THRESHOLD + WLAN_DEFAULT_NOISE_FLOOR)) \
237 		x = WLAN_LPF_RSSI((x), WLAN_RSSI_IN((y)), WLAN_RSSI_LPF_LEN); \
238 	} while (0)
239 
240 /**
241  * util_scan_entry_rssi() - function to read rssi of scan entry
242  * @scan_entry: scan entry
243  *
244  * API, function to read rssi value of scan entry
245  *
246  * Return: rssi
247  */
248 static inline uint8_t
249 util_scan_entry_rssi(struct scan_cache_entry *scan_entry)
250 {
251 	uint32_t rssi = WLAN_RSSI_OUT(scan_entry->avg_rssi);
252 	/*
253 	 * An entry is in the BSS list means we've received at least one beacon
254 	 * from the corresponding AP, so the rssi must be initialized.
255 	 *
256 	 * If the RSSI is not initialized, return 0 (i.e. RSSI == Noise Floor).
257 	 * Once se_avgrssi field has been initialized, ATH_RSSI_OUT always
258 	 * returns values that fit in an 8-bit variable
259 	 * (RSSI values are typically 0-90).
260 	 */
261 	return (rssi >= WLAN_RSSI_DUMMY_MARKER) ? 0 : (uint8_t) rssi;
262 }
263 
264 /**
265  * util_scan_entry_phymode() - function to read phymode of scan entry
266  * @scan_entry: scan entry
267  *
268  * API, function to read phymode of scan entry
269  *
270  * Return: phymode
271  */
272 static inline enum wlan_phymode
273 util_scan_entry_phymode(struct scan_cache_entry *scan_entry)
274 {
275 	return scan_entry->phy_mode;
276 }
277 
278 /**
279  * util_is_ssid_match() - to check if ssid match
280  * @ssid1: ssid 1
281  * @ssid2: ssid 2
282  *
283  * Return: true if ssid match
284  */
285 static inline bool
286 util_is_ssid_match(struct wlan_ssid *ssid1,
287 		struct wlan_ssid *ssid2)
288 {
289 
290 	if (ssid1->length == 0)
291 		return true;
292 
293 	if (ssid1->length != ssid2->length)
294 		return false;
295 
296 	if (!qdf_mem_cmp(ssid1->ssid,
297 	   ssid2->ssid, ssid1->length))
298 		return true;
299 
300 	return false;
301 }
302 
303 /**
304  * util_is_bssid_match() - to check if bssid match
305  * @bssid1: bssid 1
306  * @bssid2: bssid 2
307  *
308  * Return: true if bssid match
309  */
310 static inline bool util_is_bssid_match(struct qdf_mac_addr *bssid1,
311 	struct qdf_mac_addr *bssid2)
312 {
313 
314 	if (qdf_is_macaddr_zero(bssid1) ||
315 	   qdf_is_macaddr_broadcast(bssid1))
316 		return true;
317 
318 	if (qdf_is_macaddr_equal(bssid1, bssid2))
319 		return true;
320 
321 	return false;
322 }
323 
324 /**
325  * util_is_bss_type_match() - to check if bss type
326  * @bss_type: bss type
327  * @cap: capability
328  *
329  * Return: true if bss type match
330  */
331 static inline bool util_is_bss_type_match(enum wlan_bss_type bss_type,
332 	union wlan_capability cap)
333 {
334 	bool match = true;
335 
336 	switch (bss_type) {
337 	case WLAN_TYPE_ANY:
338 		break;
339 	case WLAN_TYPE_IBSS:
340 		if (!cap.wlan_caps.ibss)
341 			match = false;
342 		break;
343 	case WLAN_TYPE_BSS:
344 		if (!cap.wlan_caps.ess)
345 			match = false;
346 		break;
347 	default:
348 		match = false;
349 	}
350 
351 	return match;
352 }
353 
354 /**
355  * util_country_code_match() - to check if country match
356  * @country: country code pointer
357  * @country_ie: country IE in beacon
358  *
359  * Return: true if country match
360  */
361 static inline bool util_country_code_match(uint8_t *country,
362 					   struct wlan_country_ie *cc)
363 {
364 	if (!country || !country[0])
365 		return true;
366 
367 	if (!cc)
368 		return false;
369 
370 	if (cc->cc[0] == country[0] &&
371 	    cc->cc[1] == country[1])
372 		return true;
373 
374 	return false;
375 }
376 
377 /**
378  * util_mdie_match() - to check if mdie match
379  * @mobility_domain: mobility domain
380  * @mdie: mobility domain ie
381  *
382  * Return: true if country match
383  */
384 static inline bool util_mdie_match(uint16_t mobility_domain,
385 	struct rsn_mdie *mdie)
386 {
387 	uint16_t md;
388 
389 	if (!mobility_domain)
390 		return true;
391 
392 	if (!mdie)
393 		return false;
394 
395 	md =
396 	  (mdie->mobility_domain[1] << 8) |
397 	   mdie->mobility_domain[0];
398 
399 	if (md == mobility_domain)
400 		return true;
401 
402 	return false;
403 }
404 
405 /**
406  * util_scan_entry_ssid() - function to read ssid of scan entry
407  * @scan_entry: scan entry
408  *
409  * API, function to read ssid of scan entry
410  *
411  * Return: ssid
412  */
413 static inline struct wlan_ssid*
414 util_scan_entry_ssid(struct scan_cache_entry *scan_entry)
415 {
416 	return &(scan_entry->ssid);
417 }
418 
419 /**
420  * util_scan_entry_dtimperiod() - function to read dtim period of scan entry
421  * @scan_entry: scan entry
422  *
423  * API, function to read dtim period of scan entry
424  *
425  * Return: dtim period
426  */
427 static inline uint8_t
428 util_scan_entry_dtimperiod(struct scan_cache_entry *scan_entry)
429 {
430 	return scan_entry->dtim_period;
431 }
432 
433 /**
434  * util_scan_entry_tim() - function to read tim ie of scan entry
435  * @scan_entry: scan entry
436  *
437  * API, function to read tim ie of scan entry
438  *
439  * Return: timie or NULL if ie is not present
440  */
441 static inline uint8_t*
442 util_scan_entry_tim(struct scan_cache_entry *scan_entry)
443 {
444 	return scan_entry->ie_list.tim;
445 }
446 
447 /**
448  * util_scan_entry_beacon_frame() - function to read full beacon or
449  * probe resp frame
450  * @scan_entry: scan entry
451  *
452  * API, function to read full beacon or probe resp frame including frame header
453  *
454  * Return: beacon/probe resp frame
455  */
456 static inline struct element_info
457 util_scan_entry_beacon_frame(struct scan_cache_entry *scan_entry)
458 {
459 	/* util_scan_entry_beacon_data */
460 	return scan_entry->raw_frame;
461 }
462 
463 /**
464  * util_scan_entry_ie_data() - function to read tagged IEs
465  * @scan_entry: scan entry
466  *
467  * API, function to read beacon/probe response frames starting from tagged IEs
468  * (excluding frame header and fixed parameters)
469  *
470  * Return: tagged IES of beacon/probe resp frame
471  */
472 static inline uint8_t*
473 util_scan_entry_ie_data(struct scan_cache_entry *scan_entry)
474 {
475 	struct element_info bcn_frm;
476 	uint8_t *ie_data = NULL;
477 
478 	bcn_frm = util_scan_entry_beacon_frame(scan_entry);
479 	ie_data = (uint8_t *) (bcn_frm.ptr +
480 		 sizeof(struct wlan_frame_hdr) +
481 		 offsetof(struct wlan_bcn_frame, ie));
482 	return ie_data;
483 }
484 
485 /**
486  * util_scan_entry_ie_len() - function to read length of all tagged IEs
487  * @scan_entry: scan entry
488  *
489  * API, function to read length of all tagged IEs
490  *
491  * Return: length of all tagged IEs
492  */
493 static inline uint16_t
494 util_scan_entry_ie_len(struct scan_cache_entry *scan_entry)
495 {
496 	struct element_info bcn_frm;
497 	uint16_t ie_len = 0;
498 
499 	bcn_frm = util_scan_entry_beacon_frame(scan_entry);
500 	ie_len = (uint16_t) (bcn_frm.len -
501 		sizeof(struct wlan_frame_hdr) -
502 		offsetof(struct wlan_bcn_frame, ie));
503 	return ie_len;
504 }
505 
506 /**
507  * util_scan_entry_frame_len() - function to frame length
508  * @scan_entry: scan entry
509  *
510  * API, function to read frame length
511  *
512  * Return: frame length
513  */
514 static inline uint32_t
515 util_scan_entry_frame_len(struct scan_cache_entry *scan_entry)
516 {
517 	return scan_entry->raw_frame.len;
518 }
519 
520 /**
521  * util_scan_entry_frame_ptr() - function to get frame ptr
522  * @scan_entry: scan entry
523  *
524  * API, function to read frame ptr
525  *
526  * Return: frame ptr
527  */
528 static inline uint8_t*
529 util_scan_entry_frame_ptr(struct scan_cache_entry *scan_entry)
530 {
531 	return scan_entry->raw_frame.ptr;
532 }
533 
534 /**
535  * util_scan_entry_copy_ie_data() - function to get a copy of all tagged IEs
536  * @scan_entry: scan entry
537  *
538  * API, function to get a copy of all tagged IEs in passed memory
539  *
540  * Return: QDF_STATUS_SUCCESS if tagged IEs copied successfully
541  *         QDF_STATUS_E_NOMEM if passed memory/length can't hold all tagged IEs
542  */
543 static inline QDF_STATUS
544 util_scan_entry_copy_ie_data(struct scan_cache_entry *scan_entry,
545 	uint8_t *iebuf, uint16_t *ie_len)
546 {
547 	u_int8_t     *buff;
548 	u_int16_t    buff_len;
549 
550 	/* iebuf can be NULL, ie_len must be a valid pointer. */
551 	QDF_ASSERT(ie_len != NULL);
552 	if (!ie_len)
553 		return QDF_STATUS_E_NULL_VALUE;
554 
555 	buff = util_scan_entry_ie_data(scan_entry);
556 	buff_len = util_scan_entry_ie_len(scan_entry);
557 	/*
558 	 * If caller passed a buffer, check the length to make sure
559 	 * it's large enough.
560 	 * If no buffer is passed, just return the length of the IE blob.
561 	 */
562 	if (iebuf != NULL) {
563 		if (*ie_len >= buff_len) {
564 			qdf_mem_copy(iebuf, buff, buff_len);
565 			*ie_len = buff_len;
566 			return QDF_STATUS_SUCCESS;
567 		}
568 	}
569 
570 	*ie_len = buff_len;
571 	return QDF_STATUS_E_NOMEM;
572 }
573 
574 /**
575  * util_scan_free_cache_entry() - function to free scan
576  * cache entry
577  * @scan_entry: scan entry
578  *
579  * API, function to free scan cache entry
580  *
581  * Return: void
582  */
583 static inline void
584 util_scan_free_cache_entry(struct scan_cache_entry *scan_entry)
585 {
586 	if (!scan_entry)
587 		return;
588 	if (scan_entry->alt_wcn_ie.ptr)
589 		qdf_mem_free(scan_entry->alt_wcn_ie.ptr);
590 	if (scan_entry->raw_frame.ptr)
591 		qdf_mem_free(scan_entry->raw_frame.ptr);
592 	qdf_mem_free(scan_entry);
593 }
594 
595 #define conv_ptr(_address, _base1, _base2) \
596 	((_address != NULL) ? (((u_int8_t *) (_address) - \
597 	(u_int8_t *) (_base1)) + (u_int8_t *) (_base2)) : NULL)
598 
599 /**
600  * util_scan_copy_beacon_data() - copy beacon and update ie ptrs
601  * cache entry
602  * @new_entry: new scan entry
603  * @scan_entry: entry from where data is copied
604  *
605  * API, function to copy beacon and update ie ptrs
606  *
607  * Return: QDF_STATUS
608  */
609 static inline QDF_STATUS
610 util_scan_copy_beacon_data(struct scan_cache_entry *new_entry,
611 	struct scan_cache_entry *scan_entry)
612 {
613 	u_int8_t *new_ptr, *old_ptr;
614 	struct ie_list *ie_lst;
615 
616 	new_entry->raw_frame.ptr =
617 		qdf_mem_malloc_atomic(scan_entry->raw_frame.len);
618 	if (!new_entry->raw_frame.ptr)
619 		return QDF_STATUS_E_NOMEM;
620 
621 	qdf_mem_copy(new_entry->raw_frame.ptr,
622 		scan_entry->raw_frame.ptr,
623 		scan_entry->raw_frame.len);
624 	new_entry->raw_frame.len = scan_entry->raw_frame.len;
625 	new_ptr = new_entry->raw_frame.ptr;
626 	old_ptr = scan_entry->raw_frame.ptr;
627 
628 	new_entry->ie_list = scan_entry->ie_list;
629 
630 	ie_lst = &new_entry->ie_list;
631 
632 	/* New info_element needs also be added in ieee80211_parse_beacon */
633 	ie_lst->tim = conv_ptr(ie_lst->tim, old_ptr, new_ptr);
634 	ie_lst->country = conv_ptr(ie_lst->country, old_ptr, new_ptr);
635 	ie_lst->ssid = conv_ptr(ie_lst->ssid, old_ptr, new_ptr);
636 	ie_lst->rates = conv_ptr(ie_lst->rates, old_ptr, new_ptr);
637 	ie_lst->xrates = conv_ptr(ie_lst->xrates, old_ptr, new_ptr);
638 	ie_lst->ds_param = conv_ptr(ie_lst->ds_param, old_ptr, new_ptr);
639 	ie_lst->csa = conv_ptr(ie_lst->csa, old_ptr, new_ptr);
640 	ie_lst->xcsa = conv_ptr(ie_lst->xcsa, old_ptr, new_ptr);
641 	ie_lst->secchanoff = conv_ptr(ie_lst->secchanoff, old_ptr, new_ptr);
642 	ie_lst->wpa = conv_ptr(ie_lst->wpa, old_ptr, new_ptr);
643 	ie_lst->wcn = conv_ptr(ie_lst->wcn, old_ptr, new_ptr);
644 	ie_lst->rsn = conv_ptr(ie_lst->rsn, old_ptr, new_ptr);
645 	ie_lst->wps = conv_ptr(ie_lst->wps, old_ptr, new_ptr);
646 	ie_lst->wmeinfo = conv_ptr(ie_lst->wmeinfo, old_ptr, new_ptr);
647 	ie_lst->wmeparam = conv_ptr(ie_lst->wmeparam, old_ptr, new_ptr);
648 	ie_lst->quiet = conv_ptr(ie_lst->quiet, old_ptr, new_ptr);
649 	ie_lst->htcap = conv_ptr(ie_lst->htcap, old_ptr, new_ptr);
650 	ie_lst->htinfo = conv_ptr(ie_lst->htinfo, old_ptr, new_ptr);
651 	ie_lst->athcaps = conv_ptr(ie_lst->athcaps, old_ptr, new_ptr);
652 	ie_lst->athextcaps = conv_ptr(ie_lst->athextcaps, old_ptr, new_ptr);
653 	ie_lst->sfa = conv_ptr(ie_lst->sfa, old_ptr, new_ptr);
654 	ie_lst->vendor = conv_ptr(ie_lst->vendor, old_ptr, new_ptr);
655 	ie_lst->qbssload = conv_ptr(ie_lst->qbssload, old_ptr, new_ptr);
656 	ie_lst->wapi = conv_ptr(ie_lst->wapi, old_ptr, new_ptr);
657 	ie_lst->p2p = conv_ptr(ie_lst->p2p, old_ptr, new_ptr);
658 	ie_lst->alt_wcn = conv_ptr(ie_lst->alt_wcn, old_ptr, new_ptr);
659 	ie_lst->extcaps = conv_ptr(ie_lst->extcaps, old_ptr, new_ptr);
660 	ie_lst->ibssdfs = conv_ptr(ie_lst->ibssdfs, old_ptr, new_ptr);
661 	ie_lst->sonadv = conv_ptr(ie_lst->sonadv, old_ptr, new_ptr);
662 	ie_lst->vhtcap = conv_ptr(ie_lst->vhtcap, old_ptr, new_ptr);
663 	ie_lst->vhtop = conv_ptr(ie_lst->vhtop, old_ptr, new_ptr);
664 	ie_lst->opmode = conv_ptr(ie_lst->opmode, old_ptr, new_ptr);
665 	ie_lst->cswrp = conv_ptr(ie_lst->cswrp, old_ptr, new_ptr);
666 	ie_lst->widebw = conv_ptr(ie_lst->widebw, old_ptr, new_ptr);
667 	ie_lst->txpwrenvlp = conv_ptr(ie_lst->txpwrenvlp, old_ptr, new_ptr);
668 	ie_lst->bwnss_map = conv_ptr(ie_lst->bwnss_map, old_ptr, new_ptr);
669 	ie_lst->mdie = conv_ptr(ie_lst->mdie, old_ptr, new_ptr);
670 	ie_lst->hecap = conv_ptr(ie_lst->hecap, old_ptr, new_ptr);
671 	ie_lst->heop = conv_ptr(ie_lst->heop, old_ptr, new_ptr);
672 	ie_lst->fils_indication = conv_ptr(ie_lst->fils_indication,
673 					   old_ptr, new_ptr);
674 	ie_lst->esp = conv_ptr(ie_lst->esp, old_ptr, new_ptr);
675 	ie_lst->mbo_oce = conv_ptr(ie_lst->mbo_oce, old_ptr, new_ptr);
676 	ie_lst->extender = conv_ptr(ie_lst->extender, old_ptr, new_ptr);
677 
678 	return QDF_STATUS_SUCCESS;
679 }
680 /**
681  * util_scan_copy_cache_entry() - function to create a copy
682  * of scan cache entry
683  * @scan_entry: scan entry
684  *
685  * API, function to create a copy of scan cache entry
686  *
687  * Return: copy of scan_entry
688  */
689 static inline struct scan_cache_entry *
690 util_scan_copy_cache_entry(struct scan_cache_entry *scan_entry)
691 {
692 	struct scan_cache_entry *new_entry;
693 	QDF_STATUS status;
694 
695 	if (!scan_entry)
696 		return NULL;
697 
698 	new_entry =
699 	   qdf_mem_malloc_atomic(sizeof(*scan_entry));
700 	if (!new_entry)
701 		return NULL;
702 
703 	qdf_mem_copy(new_entry,
704 		scan_entry, sizeof(*scan_entry));
705 
706 	if (scan_entry->alt_wcn_ie.ptr) {
707 		new_entry->alt_wcn_ie.ptr =
708 		    qdf_mem_malloc_atomic(scan_entry->alt_wcn_ie.len);
709 		if (!new_entry->alt_wcn_ie.ptr) {
710 			qdf_mem_free(new_entry);
711 			return NULL;
712 		}
713 		qdf_mem_copy(new_entry->alt_wcn_ie.ptr,
714 		   scan_entry->alt_wcn_ie.ptr,
715 		   scan_entry->alt_wcn_ie.len);
716 		new_entry->alt_wcn_ie.len =
717 			scan_entry->alt_wcn_ie.len;
718 	}
719 
720 	status = util_scan_copy_beacon_data(new_entry, scan_entry);
721 	if (QDF_IS_STATUS_ERROR(status)) {
722 		util_scan_free_cache_entry(new_entry);
723 		return NULL;
724 	}
725 
726 	return new_entry;
727 }
728 
729 /**
730  * util_scan_entry_channel() - function to read channel info
731  * @scan_entry: scan entry
732  *
733  * API, function to read channel info
734  *
735  * Return: channel info
736  */
737 static inline struct channel_info*
738 util_scan_entry_channel(struct scan_cache_entry *scan_entry)
739 {
740 	return &(scan_entry->channel);
741 }
742 
743 /**
744  * util_scan_entry_channel_num() - function to read channel number
745  * @scan_entry: scan entry
746  *
747  * API, function to read channel number
748  *
749  * Return: channel number
750  */
751 static inline uint8_t
752 util_scan_entry_channel_num(struct scan_cache_entry *scan_entry)
753 {
754 	return scan_entry->channel.chan_idx;
755 }
756 
757 /**
758  * util_scan_entry_erpinfo() - function to read erp info
759  * @scan_entry: scan entry
760  *
761  * API, function to read erp info
762  *
763  * Return: erp info
764  */
765 static inline uint8_t
766 util_scan_entry_erpinfo(struct scan_cache_entry *scan_entry)
767 {
768 	return scan_entry->erp;
769 }
770 
771 /**
772  * util_scan_entry_rates() - function to read supported rates IE
773  * @scan_entry: scan entry
774  *
775  * API, function to read supported rates IE
776  *
777  * Return: basic ratesie or NULL if ie is not present
778  */
779 static inline uint8_t*
780 util_scan_entry_rates(struct scan_cache_entry *scan_entry)
781 {
782 	return scan_entry->ie_list.rates;
783 }
784 
785 /**
786  * util_scan_entry_xrates()- function to read extended supported rates IE
787  * @scan_entry: scan entry
788  *
789  * API, function to read extended supported rates IE
790  *
791  * Return: extended supported ratesie or NULL if ie is not present
792  */
793 static inline uint8_t*
794 util_scan_entry_xrates(struct scan_cache_entry *scan_entry)
795 {
796 	return scan_entry->ie_list.xrates;
797 }
798 
799 /**
800  * util_scan_entry_rsn()- function to read rsn IE
801  * @scan_entry: scan entry
802  *
803  * API, function to read rsn IE
804  *
805  * Return: rsnie or NULL if ie is not present
806  */
807 static inline uint8_t*
808 util_scan_entry_rsn(struct scan_cache_entry *scan_entry)
809 {
810 	return scan_entry->ie_list.rsn;
811 }
812 
813 /**
814  * util_scan_get_rsn_len()- function to read rsn IE length if present
815  * @scan_entry: scan entry
816  *
817  * API, function to read rsn length if present
818  *
819  * Return: rsnie length
820  */
821 static inline uint8_t
822 util_scan_get_rsn_len(struct scan_cache_entry *scan_entry)
823 {
824 	if (scan_entry && scan_entry->ie_list.rsn)
825 		return scan_entry->ie_list.rsn[1] + 2;
826 	else
827 		return 0;
828 }
829 
830 
831 /**
832  * util_scan_entry_wpa() - function to read wpa IE
833  * @scan_entry: scan entry
834  *
835  * API, function to read wpa IE
836  *
837  * Return: wpaie or NULL if ie is not present
838  */
839 static inline uint8_t*
840 util_scan_entry_wpa(struct scan_cache_entry *scan_entry)
841 {
842 	return scan_entry->ie_list.wpa;
843 }
844 
845 /**
846  * util_scan_get_wpa_len()- function to read wpa IE length if present
847  * @scan_entry: scan entry
848  *
849  * API, function to read wpa ie length if present
850  *
851  * Return: wpa ie length
852  */
853 static inline uint8_t
854 util_scan_get_wpa_len(struct scan_cache_entry *scan_entry)
855 {
856 	if (scan_entry && scan_entry->ie_list.wpa)
857 		return scan_entry->ie_list.wpa[1] + 2;
858 	else
859 		return 0;
860 }
861 
862 
863 /**
864  * util_scan_entry_wapi() - function to read wapi IE
865  * @scan_entry: scan entry
866  *
867  * API, function to read wapi IE
868  *
869  * Return: wapiie or NULL if ie is not present
870  */
871 static inline uint8_t*
872 util_scan_entry_wapi(struct scan_cache_entry *scan_entry)
873 {
874 	return scan_entry->ie_list.wapi;
875 }
876 
877 /**
878  * util_scan_entry_wps() - function to read wps IE
879  * @scan_entry: scan entry
880  *
881  * API, function to read wps IE
882  *
883  * Return: wpsie or NULL if ie is not present
884  */
885 static inline uint8_t*
886 util_scan_entry_wps(struct scan_cache_entry *scan_entry)
887 {
888 	return scan_entry->ie_list.wps;
889 }
890 
891 /**
892  * util_scan_entry_sfa() - function to read sfa IE
893  * @scan_entry: scan entry
894  *
895  * API, function to read sfa IE
896  *
897  * Return: sfaie or NULL if ie is not present
898  */
899 static inline uint8_t*
900 util_scan_entry_sfa(struct scan_cache_entry *scan_entry)
901 {
902 	return scan_entry->ie_list.sfa;
903 }
904 
905 /**
906  * util_scan_entry_ds_param() - function to read ds params
907  * @scan_entry: scan entry
908  *
909  * API, function to read ds params
910  *
911  * Return: ds params or NULL if ie is not present
912  */
913 static inline uint8_t*
914 util_scan_entry_ds_param(struct scan_cache_entry *scan_entry)
915 {
916 	if (scan_entry)
917 		return scan_entry->ie_list.ds_param;
918 	else
919 		return NULL;
920 }
921 
922 /**
923  * util_scan_entry_csa() - function to read csa IE
924  * @scan_entry: scan entry
925  *
926  * API, function to read csa IE
927  *
928  * Return: csaie or NULL if ie is not present
929  */
930 static inline uint8_t*
931 util_scan_entry_csa(struct scan_cache_entry *scan_entry)
932 {
933 	return scan_entry->ie_list.csa;
934 }
935 
936 /**
937  * util_scan_entry_xcsa() - function to read extended csa IE
938  * @scan_entry: scan entry
939  *
940  * API, function to read extended csa IE
941  *
942  * Return: extended csaie or NULL if ie is not present
943  */
944 static inline uint8_t*
945 util_scan_entry_xcsa(struct scan_cache_entry *scan_entry)
946 {
947 	return scan_entry->ie_list.xcsa;
948 }
949 
950 /**
951  * util_scan_entry_htinfo() - function to read htinfo IE
952  * @scan_entry: scan entry
953  *
954  * API, function to read htinfo IE
955  *
956  * Return: htinfoie or NULL if ie is not present
957  */
958 static inline uint8_t*
959 util_scan_entry_htinfo(struct scan_cache_entry *scan_entry)
960 {
961 	return scan_entry->ie_list.htinfo;
962 }
963 
964 
965 /**
966  * util_scan_entry_htcap() - function to read htcap IE
967  * @scan_entry: scan entry
968  *
969  * API, function to read htcap IE
970  *
971  * Return: htcapie or NULL if ie is not present
972  */
973 static inline uint8_t*
974 util_scan_entry_htcap(struct scan_cache_entry *scan_entry)
975 {
976 	return scan_entry->ie_list.htcap;
977 }
978 
979 /**
980  * util_scan_entry_vhtcap() - function to read vhtcap IE
981  * @scan_entry: scan entry
982  *
983  * API, function to read vhtcap IE
984  *
985  * Return: vhtcapie or NULL if ie is not present
986  */
987 static inline uint8_t*
988 util_scan_entry_vhtcap(struct scan_cache_entry *scan_entry)
989 {
990 	return scan_entry->ie_list.vhtcap;
991 }
992 
993 /**
994  * util_scan_entry_vhtop() - function to read vhtop IE
995  * @scan_entry: scan entry
996  *
997  * API, function to read vhtop IE
998  *
999  * Return: vhtopie or NULL if ie is not present
1000  */
1001 static inline uint8_t*
1002 util_scan_entry_vhtop(struct scan_cache_entry *scan_entry)
1003 {
1004 	return scan_entry->ie_list.vhtop;
1005 }
1006 
1007 /**
1008  * util_scan_entry_quiet() - function to read quiet IE
1009  * @scan_entry: scan entry
1010  *
1011  * API, function to read quiet IE
1012  *
1013  * Return: quietie or NULL if ie is not present
1014  */
1015 static inline uint8_t*
1016 util_scan_entry_quiet(struct scan_cache_entry *scan_entry)
1017 {
1018 	return scan_entry->ie_list.quiet;
1019 }
1020 
1021 /**
1022  * util_scan_entry_qbssload() - function to read qbss load IE
1023  * @scan_entry: scan entry
1024  *
1025  * API, function to read qbss load IE
1026  *
1027  * Return: qbss loadie or NULL if ie is not present
1028  */
1029 static inline uint8_t*
1030 util_scan_entry_qbssload(struct scan_cache_entry *scan_entry)
1031 {
1032 	return scan_entry->ie_list.qbssload;
1033 }
1034 
1035 /**
1036  * util_scan_entry_vendor() - function to read vendor IE
1037  * @scan_entry: scan entry
1038  *
1039  * API, function to read vendor IE
1040  *
1041  * Return: vendorie or NULL if ie is not present
1042  */
1043 static inline uint8_t*
1044 util_scan_entry_vendor(struct scan_cache_entry *scan_entry)
1045 {
1046 	return scan_entry->ie_list.vendor;
1047 }
1048 
1049 /**
1050  * util_scan_entry_country() - function to read country IE
1051  * @scan_entry: scan entry
1052  *
1053  * API, function to read country IE
1054  *
1055  * Return: countryie or NULL if ie is not present
1056  */
1057 static inline struct wlan_country_ie*
1058 util_scan_entry_country(struct scan_cache_entry *scan_entry)
1059 {
1060 	return (struct wlan_country_ie *)scan_entry->ie_list.country;
1061 }
1062 
1063 /**
1064  * util_scan_entry_copy_country() - function to copy country name
1065  * @scan_entry: scan entry
1066  * @cntry:      out buffer
1067  *
1068  * API, function to copy country name code string in given memory @centry
1069  *
1070  * Return: QDF_STATUS_SUCCESS if successfully copied country name
1071  *         QDF_STATUS_E_INVAL if passed buffer is null
1072  *         QDF_STATUS_E_NOMEM if scan entry dont have country IE
1073  */
1074 static inline QDF_STATUS
1075 util_scan_entry_copy_country(struct scan_cache_entry *scan_entry,
1076 	uint8_t *cntry)
1077 {
1078 	struct wlan_country_ie *country_ie;
1079 
1080 	if (!cntry)
1081 		return QDF_STATUS_E_INVAL;
1082 
1083 	country_ie = util_scan_entry_country(scan_entry);
1084 
1085 	if (!country_ie)
1086 		return QDF_STATUS_E_NOMEM;
1087 
1088 	qdf_mem_copy(cntry, country_ie->cc, 3);
1089 
1090 	return QDF_STATUS_SUCCESS;
1091 }
1092 
1093 /**
1094  * util_scan_entry_wmeinfo() - function to read wme info ie
1095  * @scan_entry: scan entry
1096  *
1097  * API, function to read wme info ie
1098  *
1099  * Return: wme infoie or NULL if ie is not present
1100  */
1101 static inline uint8_t*
1102 util_scan_entry_wmeinfo(struct scan_cache_entry *scan_entry)
1103 {
1104 	return scan_entry->ie_list.wmeinfo;
1105 }
1106 
1107 /**
1108  * util_scan_entry_wmeparam() - function to read wme param ie
1109  * @scan_entry: scan entry
1110  *
1111  * API, function to read wme param ie
1112  *
1113  * Return: wme paramie or NULL if ie is not present
1114  */
1115 static inline uint8_t*
1116 util_scan_entry_wmeparam(struct scan_cache_entry *scan_entry)
1117 {
1118 	return scan_entry->ie_list.wmeparam;
1119 }
1120 
1121 /**
1122  * util_scan_entry_age() - function to read age of scan entry
1123  * @scan_entry: scan entry
1124  *
1125  * API, function to read age of scan entry
1126  *
1127  * Return: age in ms
1128  */
1129 static inline uint32_t
1130 util_scan_entry_age(struct scan_cache_entry *scan_entry)
1131 {
1132 	unsigned long ts = scan_entry->scan_entry_time;
1133 
1134 	return qdf_mc_timer_get_system_time() - ts;
1135 }
1136 
1137 /**
1138  * util_scan_mlme_info() - function to read mlme info struct
1139  * @scan_entry: scan entry
1140  *
1141  * API, function to read mlme info struct
1142  *
1143  * Return: mlme info
1144  */
1145 static inline struct mlme_info*
1146 util_scan_mlme_info(struct scan_cache_entry *scan_entry)
1147 {
1148 	return &scan_entry->mlme_info;
1149 }
1150 
1151 /**
1152  * util_scan_entry_bss_type() - function to read bss type
1153  * @scan_entry: scan entry
1154  *
1155  * API, function to read bss type
1156  *
1157  * Return: bss type
1158  */
1159 static inline enum wlan_bss_type
1160 util_scan_entry_bss_type(struct scan_cache_entry *scan_entry)
1161 {
1162 	if (scan_entry->cap_info.value & WLAN_CAPINFO_ESS)
1163 		return WLAN_TYPE_BSS;
1164 	else if (scan_entry->cap_info.value & WLAN_CAPINFO_IBSS)
1165 		return WLAN_TYPE_IBSS;
1166 	else
1167 		return WLAN_TYPE_ANY;
1168 }
1169 
1170 /**
1171  * util_scan_entry_privacy() - function to check if privacy is enebled
1172  * @scan_entry: scan entry
1173  *
1174  * API, function to check if privacy is enebled
1175  *
1176  * Return: true if privacy is enabled, false other wise
1177  */
1178 static inline bool
1179 util_scan_entry_privacy(struct scan_cache_entry *scan_entry)
1180 {
1181 	return (scan_entry->cap_info.value &
1182 		WLAN_CAPINFO_PRIVACY) ? true : false;
1183 }
1184 
1185 /**
1186  * util_scan_entry_athcaps() - function to read ath caps vendor ie
1187  * @scan_entry: scan entry
1188  *
1189  * API, function to read ath caps vendor ie
1190  *
1191  * Return: ath caps vendorie or NULL if ie is not present
1192  */
1193 static inline uint8_t*
1194 util_scan_entry_athcaps(struct scan_cache_entry *scan_entry)
1195 {
1196 	return scan_entry->ie_list.athcaps;
1197 }
1198 
1199 /**
1200  * util_scan_entry_athextcaps() - function to read ath extcaps vendor ie
1201  * @scan_entry: scan entry
1202  *
1203  * API, function to read ath extcaps vendor ie
1204  *
1205  * Return: ath extcaps vendorie or NULL if ie is not present
1206  */
1207 static inline uint8_t*
1208 util_scan_entry_athextcaps(struct scan_cache_entry *scan_entry)
1209 {
1210 	return scan_entry->ie_list.athextcaps;
1211 }
1212 
1213 /**
1214  * util_scan_entry_bwnss_map() - function to read bwnss_map ie
1215  * @scan_entry: scan entry
1216  *
1217  * API, function to read bwnss_map ie
1218  *
1219  * Return: bwnss_map ie or NULL if ie is not present
1220  */
1221 static inline uint8_t*
1222 util_scan_entry_bwnss_map(struct scan_cache_entry *scan_entry)
1223 {
1224 	return scan_entry->ie_list.bwnss_map;
1225 }
1226 
1227 /**
1228  * util_scan_entry_sonie() - function to read son ie
1229  * @scan_entry: scan entry
1230  *
1231  * API, function to read son ie
1232  *
1233  * Return: son ie or NULL if ie is not present
1234  */
1235 static inline uint8_t*
1236 util_scan_entry_sonie(struct scan_cache_entry *scan_entry)
1237 {
1238 	return scan_entry->ie_list.sonadv;
1239 }
1240 
1241 /**
1242  * util_scan_entry_widebw() - function to read wide band chan switch sub elem ie
1243  * @scan_entry: scan entry
1244  *
1245  * API, function to read wide band chan switch sub elem ie
1246  *
1247  * Return: wide band chan switch sub elem or NULL if ie is not present
1248  */
1249 static inline uint8_t*
1250 util_scan_entry_widebw(struct scan_cache_entry *scan_entry)
1251 {
1252 	return scan_entry->ie_list.widebw;
1253 }
1254 
1255 /**
1256  * util_scan_entry_secchanoff() - function to read secondary channel offset ie
1257  * @scan_entry: scan entry
1258  *
1259  * API, function to read secondary channel offset ie
1260  *
1261  * Return: secondary channel offset element or NULL if ie is not present
1262  */
1263 static inline uint8_t*
1264 util_scan_entry_secchanoff(struct scan_cache_entry *scan_entry)
1265 {
1266 	return scan_entry->ie_list.secchanoff;
1267 }
1268 
1269 /**
1270  * util_scan_entry_cswrp() - function to read channel switch wrapper ie
1271  * @scan_entry: scan entry
1272  *
1273  * API, function to read channel switch wrapper ie
1274  *
1275  * Return: channel switch wrapper element or NULL if ie is not present
1276  */
1277 static inline uint8_t*
1278 util_scan_entry_cswrp(struct scan_cache_entry *scan_entry)
1279 {
1280 	return scan_entry->ie_list.cswrp;
1281 }
1282 
1283 /**
1284  * util_scan_entry_omn() - function to read operating mode notification ie
1285  * @scan_entry: scan entry
1286  *
1287  * API, function to read operating mode notification
1288  *
1289  * Return: operating mode notification element or NULL if ie is not present
1290  */
1291 static inline uint8_t*
1292 util_scan_entry_omn(struct scan_cache_entry *scan_entry)
1293 {
1294 	return scan_entry->ie_list.opmode;
1295 }
1296 
1297 /**
1298  * util_scan_entry_extcaps() - function to read extcap ie
1299  * @scan_entry: scan entry
1300  *
1301  * API, function to read extcap ie
1302  *
1303  * Return: extcap element or NULL if ie is not present
1304  */
1305 static inline uint8_t*
1306 util_scan_entry_extcaps(struct scan_cache_entry *scan_entry)
1307 {
1308 	return scan_entry->ie_list.extcaps;
1309 }
1310 
1311 /**
1312  * util_scan_entry_get_extcap() - function to read extended capability field ie
1313  * @scan_entry: scan entry
1314  * @extcap_bit_field: extended capability bit field
1315  * @extcap_value: pointer to fill extended capability field value
1316  *
1317  * API, function to read extended capability field
1318  *
1319  * Return: QDF_STATUS_SUCCESS if extended capability field is found
1320  *         QDF_STATUS_E_NOMEM if extended capability field is not found
1321  */
1322 static inline QDF_STATUS
1323 util_scan_entry_get_extcap(struct scan_cache_entry *scan_entry,
1324 			   enum ext_cap_bit_field extcap_bit_field,
1325 			   uint8_t *extcap_value)
1326 {
1327 	struct wlan_ext_cap_ie *ext_cap =
1328 		(struct wlan_ext_cap_ie *)util_scan_entry_extcaps(scan_entry);
1329 
1330 	uint8_t ext_caps_byte = (extcap_bit_field >> 3);
1331 	uint8_t ext_caps_bit_pos = extcap_bit_field & 0x7;
1332 
1333 	*extcap_value = 0;
1334 
1335 	if (!ext_cap)
1336 		return QDF_STATUS_E_NULL_VALUE;
1337 
1338 	if (ext_cap->ext_cap_len < ext_caps_byte)
1339 		return QDF_STATUS_E_NULL_VALUE;
1340 
1341 	*extcap_value =
1342 		((ext_cap->ext_caps[ext_caps_byte] >> ext_caps_bit_pos) & 0x1);
1343 
1344 	return QDF_STATUS_SUCCESS;
1345 }
1346 
1347 /**
1348  * util_scan_entry_athcaps() - function to read ath caps vendor ie
1349  * @scan_entry: scan entry
1350  *
1351  * API, function to read ath caps vendor ie
1352  *
1353  * Return: ath caps vendorie or NULL if ie is not present
1354  */
1355 static inline struct mlme_info*
1356 util_scan_entry_mlme_info(struct scan_cache_entry *scan_entry)
1357 {
1358 	return &(scan_entry->mlme_info);
1359 }
1360 
1361 /**
1362  * util_scan_entry_hecap() - function to read he caps vendor ie
1363  * @scan_entry: scan entry
1364  *
1365  * API, function to read he caps vendor ie
1366  *
1367  * Return: he caps vendorie or NULL if ie is not present
1368  */
1369 static inline uint8_t*
1370 util_scan_entry_hecap(struct scan_cache_entry *scan_entry)
1371 {
1372 	return scan_entry->ie_list.hecap;
1373 }
1374 
1375 
1376 /**
1377  * util_scan_entry_heop() - function to read heop vendor ie
1378  * @scan_entry: scan entry
1379  *
1380  * API, function to read heop vendor ie
1381  *
1382  * Return, heop vendorie or NULL if ie is not present
1383  */
1384 static inline uint8_t*
1385 util_scan_entry_heop(struct scan_cache_entry *scan_entry)
1386 {
1387 	return scan_entry->ie_list.heop;
1388 }
1389 
1390 /**
1391  * util_scan_entry_muedca() - function to read MU-EDCA IE
1392  * @scan_entry: scan entry
1393  *
1394  * API, function to read MU-EDCA IE
1395  *
1396  * Return, MUEDCA IE or NULL if IE is not present
1397  */
1398 static inline uint8_t*
1399 util_scan_entry_muedca(struct scan_cache_entry *scan_entry)
1400 {
1401 	return scan_entry->ie_list.muedca;
1402 }
1403 
1404 /**
1405  * util_scan_entry_spatial_reuse_parameter() - function to read spatial reuse
1406  *                                             parameter ie
1407  * @scan_entry: scan entry
1408  *
1409  * API, function to read scan_entry reuse parameter ie
1410  *
1411  * Return, spatial reuse parameter ie or NULL if ie is not present
1412  */
1413 static inline uint8_t*
1414 util_scan_entry_spatial_reuse_parameter(struct scan_cache_entry *scan_entry)
1415 {
1416 	return scan_entry->ie_list.srp;
1417 }
1418 
1419 /**
1420  * util_scan_entry_fils_indication() - function to read FILS indication ie
1421  * @scan_entry: scan entry
1422  *
1423  * API, function to read FILS indication ie
1424  *
1425  * Return, FILS indication ie or NULL if ie is not present
1426  */
1427 static inline uint8_t*
1428 util_scan_entry_fils_indication(struct scan_cache_entry *scan_entry)
1429 {
1430 	return scan_entry->ie_list.fils_indication;
1431 }
1432 
1433 /**
1434  * util_get_last_scan_time() - function to get last scan time on this pdev
1435  * @vdev: vdev object
1436  *
1437  * API, function to read last scan time on this pdev
1438  *
1439  * Return: qdf_time_t
1440  */
1441 qdf_time_t
1442 util_get_last_scan_time(struct wlan_objmgr_vdev *vdev);
1443 
1444 /**
1445  * util_scan_entry_update_mlme_info() - function to update mlme info
1446  * @scan_entry: scan entry object
1447  *
1448  * API, function to update mlme info in scan DB
1449  *
1450  * Return: QDF_STATUS
1451  */
1452 QDF_STATUS
1453 util_scan_entry_update_mlme_info(struct wlan_objmgr_pdev *pdev,
1454 	struct scan_cache_entry *scan_entry);
1455 
1456 /**
1457  * util_scan_is_hidden_ssid() - function to check if ssid is hidden
1458  * @ssid: struct ie_ssid object
1459  *
1460  * API, function to check if ssid is hidden
1461  *
1462  * Return: true if ap is hidden, false otherwise
1463  */
1464 bool
1465 util_scan_is_hidden_ssid(struct ie_ssid *ssid);
1466 
1467 /**
1468  * util_scan_entry_is_hidden_ap() - function to check if ap is hidden
1469  * @scan_entry: scan entry
1470  *
1471  * API, function to check if ap is hidden
1472  *
1473  * Return: true if ap is hidden, false otherwise
1474  */
1475 static inline bool
1476 util_scan_entry_is_hidden_ap(struct scan_cache_entry *scan_entry)
1477 {
1478     return util_scan_is_hidden_ssid(
1479 			(struct ie_ssid *)scan_entry->ie_list.ssid);
1480 }
1481 
1482 /**
1483  * util_scan_entry_espinfo() - function to read ESP info
1484  * @scan_entry: scan entry
1485  *
1486  * API, function to read ESP info
1487  *
1488  * Return: erp info
1489  */
1490 static inline uint8_t *
1491 util_scan_entry_esp_info(struct scan_cache_entry *scan_entry)
1492 {
1493 	return scan_entry->ie_list.esp;
1494 }
1495 
1496 /**
1497  * util_scan_entry_mbo_oce() - function to read MBO/OCE ie
1498  * @scan_entry: scan entry
1499  *
1500  * API, function to read MBO/OCE ie
1501  *
1502  * Return: MBO/OCE ie
1503  */
1504 static inline uint8_t *
1505 util_scan_entry_mbo_oce(struct scan_cache_entry *scan_entry)
1506 {
1507 	return scan_entry->ie_list.mbo_oce;
1508 }
1509 
1510 /**
1511  * util_scan_scm_chan_to_band() - function to tell band for channel number
1512  * @chan: Channel number
1513  *
1514  * Return: Band information as per channel
1515  */
1516 enum wlan_band util_scan_scm_chan_to_band(uint32_t chan);
1517 
1518 /**
1519  * util_scan_scm_freq_to_band() - API to get band from frequency
1520  * @freq: Channel frequency
1521  *
1522  * Return: Band information as per frequency
1523  */
1524 enum wlan_band util_scan_scm_freq_to_band(uint16_t freq);
1525 
1526 /**
1527  * util_is_scan_completed() - function to get scan complete status
1528  * @event: scan event
1529  * @success: true if scan complete success, false otherwise
1530  *
1531  * API, function to get the scan result
1532  *
1533  * Return: true if scan complete, false otherwise
1534  */
1535 bool util_is_scan_completed(struct scan_event *event, bool *success);
1536 
1537 /**
1538  * util_scan_entry_extenderie() - function to read extender IE
1539  * @scan_entry: scan entry
1540  *
1541  * API, function to read extender IE
1542  *
1543  * Return: extenderie or NULL if ie is not present
1544  */
1545 static inline uint8_t*
1546 util_scan_entry_extenderie(struct scan_cache_entry *scan_entry)
1547 {
1548 	return scan_entry->ie_list.extender;
1549 }
1550 
1551 #endif
1552