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