xref: /wlan-dirver/qca-wifi-host-cmn/umac/scan/dispatcher/inc/wlan_scan_utils_api.h (revision 45a38684b07295822dc8eba39e293408f203eec8)
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 
660 	new_entry->raw_frame.ptr =
661 		qdf_mem_malloc_atomic(scan_entry->raw_frame.len);
662 	if (!new_entry->raw_frame.ptr)
663 		return QDF_STATUS_E_NOMEM;
664 
665 	qdf_mem_copy(new_entry->raw_frame.ptr,
666 		scan_entry->raw_frame.ptr,
667 		scan_entry->raw_frame.len);
668 	new_entry->raw_frame.len = scan_entry->raw_frame.len;
669 	new_ptr = new_entry->raw_frame.ptr;
670 	old_ptr = scan_entry->raw_frame.ptr;
671 
672 	new_entry->ie_list = scan_entry->ie_list;
673 
674 	ie_lst = &new_entry->ie_list;
675 
676 	/* New info_element needs also be added in ieee80211_parse_beacon */
677 	ie_lst->tim = conv_ptr(ie_lst->tim, old_ptr, new_ptr);
678 	ie_lst->country = conv_ptr(ie_lst->country, old_ptr, new_ptr);
679 	ie_lst->ssid = conv_ptr(ie_lst->ssid, old_ptr, new_ptr);
680 	ie_lst->rates = conv_ptr(ie_lst->rates, old_ptr, new_ptr);
681 	ie_lst->xrates = conv_ptr(ie_lst->xrates, old_ptr, new_ptr);
682 	ie_lst->ds_param = conv_ptr(ie_lst->ds_param, old_ptr, new_ptr);
683 	ie_lst->csa = conv_ptr(ie_lst->csa, old_ptr, new_ptr);
684 	ie_lst->xcsa = conv_ptr(ie_lst->xcsa, old_ptr, new_ptr);
685 	ie_lst->mcst = conv_ptr(ie_lst->mcst, old_ptr, new_ptr);
686 	ie_lst->secchanoff = conv_ptr(ie_lst->secchanoff, old_ptr, new_ptr);
687 	ie_lst->wpa = conv_ptr(ie_lst->wpa, old_ptr, new_ptr);
688 	ie_lst->wcn = conv_ptr(ie_lst->wcn, old_ptr, new_ptr);
689 	ie_lst->rsn = conv_ptr(ie_lst->rsn, old_ptr, new_ptr);
690 	ie_lst->wps = conv_ptr(ie_lst->wps, old_ptr, new_ptr);
691 	ie_lst->wmeinfo = conv_ptr(ie_lst->wmeinfo, old_ptr, new_ptr);
692 	ie_lst->wmeparam = conv_ptr(ie_lst->wmeparam, old_ptr, new_ptr);
693 	ie_lst->quiet = conv_ptr(ie_lst->quiet, old_ptr, new_ptr);
694 	ie_lst->htcap = conv_ptr(ie_lst->htcap, old_ptr, new_ptr);
695 	ie_lst->htinfo = conv_ptr(ie_lst->htinfo, old_ptr, new_ptr);
696 	ie_lst->athcaps = conv_ptr(ie_lst->athcaps, old_ptr, new_ptr);
697 	ie_lst->athextcaps = conv_ptr(ie_lst->athextcaps, old_ptr, new_ptr);
698 	ie_lst->sfa = conv_ptr(ie_lst->sfa, old_ptr, new_ptr);
699 	ie_lst->vendor = conv_ptr(ie_lst->vendor, old_ptr, new_ptr);
700 	ie_lst->qbssload = conv_ptr(ie_lst->qbssload, old_ptr, new_ptr);
701 	ie_lst->wapi = conv_ptr(ie_lst->wapi, old_ptr, new_ptr);
702 	ie_lst->p2p = conv_ptr(ie_lst->p2p, old_ptr, new_ptr);
703 	ie_lst->alt_wcn = conv_ptr(ie_lst->alt_wcn, old_ptr, new_ptr);
704 	ie_lst->extcaps = conv_ptr(ie_lst->extcaps, old_ptr, new_ptr);
705 	ie_lst->ibssdfs = conv_ptr(ie_lst->ibssdfs, old_ptr, new_ptr);
706 	ie_lst->sonadv = conv_ptr(ie_lst->sonadv, old_ptr, new_ptr);
707 	ie_lst->vhtcap = conv_ptr(ie_lst->vhtcap, old_ptr, new_ptr);
708 	ie_lst->vhtop = conv_ptr(ie_lst->vhtop, old_ptr, new_ptr);
709 	ie_lst->opmode = conv_ptr(ie_lst->opmode, old_ptr, new_ptr);
710 	ie_lst->cswrp = conv_ptr(ie_lst->cswrp, old_ptr, new_ptr);
711 	ie_lst->widebw = conv_ptr(ie_lst->widebw, old_ptr, new_ptr);
712 	ie_lst->txpwrenvlp = conv_ptr(ie_lst->txpwrenvlp, old_ptr, new_ptr);
713 	ie_lst->bwnss_map = conv_ptr(ie_lst->bwnss_map, old_ptr, new_ptr);
714 	ie_lst->mdie = conv_ptr(ie_lst->mdie, old_ptr, new_ptr);
715 	ie_lst->hecap = conv_ptr(ie_lst->hecap, old_ptr, new_ptr);
716 	ie_lst->heop = conv_ptr(ie_lst->heop, old_ptr, new_ptr);
717 	ie_lst->fils_indication = conv_ptr(ie_lst->fils_indication,
718 					   old_ptr, new_ptr);
719 	ie_lst->esp = conv_ptr(ie_lst->esp, old_ptr, new_ptr);
720 	ie_lst->mbo_oce = conv_ptr(ie_lst->mbo_oce, old_ptr, new_ptr);
721 	ie_lst->muedca = conv_ptr(ie_lst->muedca, old_ptr, new_ptr);
722 	ie_lst->rnrie = conv_ptr(ie_lst->rnrie, old_ptr, new_ptr);
723 	ie_lst->extender = conv_ptr(ie_lst->extender, old_ptr, new_ptr);
724 	ie_lst->adaptive_11r = conv_ptr(ie_lst->adaptive_11r, old_ptr, new_ptr);
725 	ie_lst->single_pmk = conv_ptr(ie_lst->single_pmk, old_ptr, new_ptr);
726 
727 	return QDF_STATUS_SUCCESS;
728 }
729 /**
730  * util_scan_copy_cache_entry() - function to create a copy
731  * of scan cache entry
732  * @scan_entry: scan entry
733  *
734  * API, function to create a copy of scan cache entry
735  *
736  * Return: copy of scan_entry
737  */
738 static inline struct scan_cache_entry *
739 util_scan_copy_cache_entry(struct scan_cache_entry *scan_entry)
740 {
741 	struct scan_cache_entry *new_entry;
742 	QDF_STATUS status;
743 
744 	if (!scan_entry)
745 		return NULL;
746 
747 	new_entry =
748 	   qdf_mem_malloc_atomic(sizeof(*scan_entry));
749 	if (!new_entry)
750 		return NULL;
751 
752 	qdf_mem_copy(new_entry,
753 		scan_entry, sizeof(*scan_entry));
754 
755 	if (scan_entry->alt_wcn_ie.ptr) {
756 		new_entry->alt_wcn_ie.ptr =
757 		    qdf_mem_malloc_atomic(scan_entry->alt_wcn_ie.len);
758 		if (!new_entry->alt_wcn_ie.ptr) {
759 			qdf_mem_free(new_entry);
760 			return NULL;
761 		}
762 		qdf_mem_copy(new_entry->alt_wcn_ie.ptr,
763 		   scan_entry->alt_wcn_ie.ptr,
764 		   scan_entry->alt_wcn_ie.len);
765 		new_entry->alt_wcn_ie.len =
766 			scan_entry->alt_wcn_ie.len;
767 	}
768 
769 	status = util_scan_copy_beacon_data(new_entry, scan_entry);
770 	if (QDF_IS_STATUS_ERROR(status)) {
771 		util_scan_free_cache_entry(new_entry);
772 		return NULL;
773 	}
774 
775 	return new_entry;
776 }
777 
778 /**
779  * util_scan_entry_channel() - function to read channel info
780  * @scan_entry: scan entry
781  *
782  * API, function to read channel info
783  *
784  * Return: channel info
785  */
786 static inline struct channel_info*
787 util_scan_entry_channel(struct scan_cache_entry *scan_entry)
788 {
789 	return &(scan_entry->channel);
790 }
791 
792 /**
793  * util_scan_entry_channel_frequency() - function to read channel number
794  * @scan_entry: scan entry
795  *
796  * API, function to read channel number
797  *
798  * Return: channel number
799  */
800 static inline uint32_t
801 util_scan_entry_channel_frequency(struct scan_cache_entry *scan_entry)
802 {
803 	return scan_entry->channel.chan_freq;
804 }
805 
806 /**
807  * util_scan_entry_erpinfo() - function to read erp info
808  * @scan_entry: scan entry
809  *
810  * API, function to read erp info
811  *
812  * Return: erp info
813  */
814 static inline uint8_t
815 util_scan_entry_erpinfo(struct scan_cache_entry *scan_entry)
816 {
817 	return scan_entry->erp;
818 }
819 
820 /**
821  * util_scan_entry_rates() - function to read supported rates IE
822  * @scan_entry: scan entry
823  *
824  * API, function to read supported rates IE
825  *
826  * Return: basic ratesie or NULL if ie is not present
827  */
828 static inline uint8_t*
829 util_scan_entry_rates(struct scan_cache_entry *scan_entry)
830 {
831 	return scan_entry->ie_list.rates;
832 }
833 
834 /**
835  * util_scan_entry_xrates()- function to read extended supported rates IE
836  * @scan_entry: scan entry
837  *
838  * API, function to read extended supported rates IE
839  *
840  * Return: extended supported ratesie or NULL if ie is not present
841  */
842 static inline uint8_t*
843 util_scan_entry_xrates(struct scan_cache_entry *scan_entry)
844 {
845 	return scan_entry->ie_list.xrates;
846 }
847 
848 /**
849  * util_scan_entry_rsn()- function to read rsn IE
850  * @scan_entry: scan entry
851  *
852  * API, function to read rsn IE
853  *
854  * Return: rsnie or NULL if ie is not present
855  */
856 static inline uint8_t*
857 util_scan_entry_rsn(struct scan_cache_entry *scan_entry)
858 {
859 	return scan_entry->ie_list.rsn;
860 }
861 
862 /**
863  * util_scan_entry_adaptive_11r()- function to read adaptive 11r Vendor IE
864  * @scan_entry: scan entry
865  *
866  * API, function to read adaptive 11r IE
867  *
868  * Return:  apaptive 11r ie or NULL if ie is not present
869  */
870 static inline uint8_t*
871 util_scan_entry_adaptive_11r(struct scan_cache_entry *scan_entry)
872 {
873 	return scan_entry->ie_list.adaptive_11r;
874 }
875 
876 /**
877  * util_scan_entry_single_pmk()- function to read single pmk Vendor IE
878  * @scan_entry: scan entry
879  *
880  * API, function to read sae single pmk IE
881  *
882  * Return: true if single_pmk ie is present or false if ie is not present
883  */
884 static inline bool
885 util_scan_entry_single_pmk(struct scan_cache_entry *scan_entry)
886 {
887 	if (scan_entry->ie_list.single_pmk)
888 		return true;
889 
890 	return false;
891 }
892 
893 /**
894  * util_scan_get_rsn_len()- function to read rsn IE length if present
895  * @scan_entry: scan entry
896  *
897  * API, function to read rsn length if present
898  *
899  * Return: rsnie length
900  */
901 static inline uint8_t
902 util_scan_get_rsn_len(struct scan_cache_entry *scan_entry)
903 {
904 	if (scan_entry && scan_entry->ie_list.rsn)
905 		return scan_entry->ie_list.rsn[1] + 2;
906 	else
907 		return 0;
908 }
909 
910 
911 /**
912  * util_scan_entry_wpa() - function to read wpa IE
913  * @scan_entry: scan entry
914  *
915  * API, function to read wpa IE
916  *
917  * Return: wpaie or NULL if ie is not present
918  */
919 static inline uint8_t*
920 util_scan_entry_wpa(struct scan_cache_entry *scan_entry)
921 {
922 	return scan_entry->ie_list.wpa;
923 }
924 
925 /**
926  * util_scan_get_wpa_len()- function to read wpa IE length if present
927  * @scan_entry: scan entry
928  *
929  * API, function to read wpa ie length if present
930  *
931  * Return: wpa ie length
932  */
933 static inline uint8_t
934 util_scan_get_wpa_len(struct scan_cache_entry *scan_entry)
935 {
936 	if (scan_entry && scan_entry->ie_list.wpa)
937 		return scan_entry->ie_list.wpa[1] + 2;
938 	else
939 		return 0;
940 }
941 
942 
943 /**
944  * util_scan_entry_wapi() - function to read wapi IE
945  * @scan_entry: scan entry
946  *
947  * API, function to read wapi IE
948  *
949  * Return: wapiie or NULL if ie is not present
950  */
951 static inline uint8_t*
952 util_scan_entry_wapi(struct scan_cache_entry *scan_entry)
953 {
954 	return scan_entry->ie_list.wapi;
955 }
956 
957 /**
958  * util_scan_entry_wps() - function to read wps IE
959  * @scan_entry: scan entry
960  *
961  * API, function to read wps IE
962  *
963  * Return: wpsie or NULL if ie is not present
964  */
965 static inline uint8_t*
966 util_scan_entry_wps(struct scan_cache_entry *scan_entry)
967 {
968 	return scan_entry->ie_list.wps;
969 }
970 
971 /**
972  * util_scan_entry_sfa() - function to read sfa IE
973  * @scan_entry: scan entry
974  *
975  * API, function to read sfa IE
976  *
977  * Return: sfaie or NULL if ie is not present
978  */
979 static inline uint8_t*
980 util_scan_entry_sfa(struct scan_cache_entry *scan_entry)
981 {
982 	return scan_entry->ie_list.sfa;
983 }
984 
985 /**
986  * util_scan_entry_ds_param() - function to read ds params
987  * @scan_entry: scan entry
988  *
989  * API, function to read ds params
990  *
991  * Return: ds params or NULL if ie is not present
992  */
993 static inline uint8_t*
994 util_scan_entry_ds_param(struct scan_cache_entry *scan_entry)
995 {
996 	if (scan_entry)
997 		return scan_entry->ie_list.ds_param;
998 	else
999 		return NULL;
1000 }
1001 
1002 /**
1003  * util_scan_entry_csa() - function to read csa IE
1004  * @scan_entry: scan entry
1005  *
1006  * API, function to read csa IE
1007  *
1008  * Return: csaie or NULL if ie is not present
1009  */
1010 static inline uint8_t*
1011 util_scan_entry_csa(struct scan_cache_entry *scan_entry)
1012 {
1013 	return scan_entry->ie_list.csa;
1014 }
1015 
1016 /**
1017  * util_scan_entry_xcsa() - function to read extended csa IE
1018  * @scan_entry: scan entry
1019  *
1020  * API, function to read extended csa IE
1021  *
1022  * Return: extended csaie or NULL if ie is not present
1023  */
1024 static inline uint8_t*
1025 util_scan_entry_xcsa(struct scan_cache_entry *scan_entry)
1026 {
1027 	return scan_entry->ie_list.xcsa;
1028 }
1029 
1030 /**
1031  * util_scan_entry_htinfo() - function to read htinfo IE
1032  * @scan_entry: scan entry
1033  *
1034  * API, function to read htinfo IE
1035  *
1036  * Return: htinfoie or NULL if ie is not present
1037  */
1038 static inline uint8_t*
1039 util_scan_entry_htinfo(struct scan_cache_entry *scan_entry)
1040 {
1041 	return scan_entry->ie_list.htinfo;
1042 }
1043 
1044 
1045 /**
1046  * util_scan_entry_htcap() - function to read htcap IE
1047  * @scan_entry: scan entry
1048  *
1049  * API, function to read htcap IE
1050  *
1051  * Return: htcapie or NULL if ie is not present
1052  */
1053 static inline uint8_t*
1054 util_scan_entry_htcap(struct scan_cache_entry *scan_entry)
1055 {
1056 	return scan_entry->ie_list.htcap;
1057 }
1058 
1059 /**
1060  * util_scan_entry_vhtcap() - function to read vhtcap IE
1061  * @scan_entry: scan entry
1062  *
1063  * API, function to read vhtcap IE
1064  *
1065  * Return: vhtcapie or NULL if ie is not present
1066  */
1067 static inline uint8_t*
1068 util_scan_entry_vhtcap(struct scan_cache_entry *scan_entry)
1069 {
1070 	return scan_entry->ie_list.vhtcap;
1071 }
1072 
1073 /**
1074  * util_scan_entry_vhtop() - function to read vhtop IE
1075  * @scan_entry: scan entry
1076  *
1077  * API, function to read vhtop IE
1078  *
1079  * Return: vhtopie or NULL if ie is not present
1080  */
1081 static inline uint8_t*
1082 util_scan_entry_vhtop(struct scan_cache_entry *scan_entry)
1083 {
1084 	return scan_entry->ie_list.vhtop;
1085 }
1086 
1087 /**
1088  * util_scan_entry_quiet() - function to read quiet IE
1089  * @scan_entry: scan entry
1090  *
1091  * API, function to read quiet IE
1092  *
1093  * Return: quietie or NULL if ie is not present
1094  */
1095 static inline uint8_t*
1096 util_scan_entry_quiet(struct scan_cache_entry *scan_entry)
1097 {
1098 	return scan_entry->ie_list.quiet;
1099 }
1100 
1101 /**
1102  * util_scan_entry_qbssload() - function to read qbss load IE
1103  * @scan_entry: scan entry
1104  *
1105  * API, function to read qbss load IE
1106  *
1107  * Return: qbss loadie or NULL if ie is not present
1108  */
1109 static inline uint8_t*
1110 util_scan_entry_qbssload(struct scan_cache_entry *scan_entry)
1111 {
1112 	return scan_entry->ie_list.qbssload;
1113 }
1114 
1115 /**
1116  * util_scan_entry_vendor() - function to read vendor IE
1117  * @scan_entry: scan entry
1118  *
1119  * API, function to read vendor IE
1120  *
1121  * Return: vendorie or NULL if ie is not present
1122  */
1123 static inline uint8_t*
1124 util_scan_entry_vendor(struct scan_cache_entry *scan_entry)
1125 {
1126 	return scan_entry->ie_list.vendor;
1127 }
1128 
1129 /**
1130  * util_scan_entry_country() - function to read country IE
1131  * @scan_entry: scan entry
1132  *
1133  * API, function to read country IE
1134  *
1135  * Return: countryie or NULL if ie is not present
1136  */
1137 static inline struct wlan_country_ie*
1138 util_scan_entry_country(struct scan_cache_entry *scan_entry)
1139 {
1140 	return (struct wlan_country_ie *)scan_entry->ie_list.country;
1141 }
1142 
1143 /**
1144  * util_scan_entry_copy_country() - function to copy country name
1145  * @scan_entry: scan entry
1146  * @cntry:      out buffer
1147  *
1148  * API, function to copy country name code string in given memory @centry
1149  *
1150  * Return: QDF_STATUS_SUCCESS if successfully copied country name
1151  *         QDF_STATUS_E_INVAL if passed buffer is null
1152  *         QDF_STATUS_E_NOMEM if scan entry dont have country IE
1153  */
1154 static inline QDF_STATUS
1155 util_scan_entry_copy_country(struct scan_cache_entry *scan_entry,
1156 	uint8_t *cntry)
1157 {
1158 	struct wlan_country_ie *country_ie;
1159 
1160 	if (!cntry)
1161 		return QDF_STATUS_E_INVAL;
1162 
1163 	country_ie = util_scan_entry_country(scan_entry);
1164 
1165 	if (!country_ie)
1166 		return QDF_STATUS_E_NOMEM;
1167 
1168 	qdf_mem_copy(cntry, country_ie->cc, 3);
1169 
1170 	return QDF_STATUS_SUCCESS;
1171 }
1172 
1173 /**
1174  * util_scan_entry_wmeinfo() - function to read wme info ie
1175  * @scan_entry: scan entry
1176  *
1177  * API, function to read wme info ie
1178  *
1179  * Return: wme infoie or NULL if ie is not present
1180  */
1181 static inline uint8_t*
1182 util_scan_entry_wmeinfo(struct scan_cache_entry *scan_entry)
1183 {
1184 	return scan_entry->ie_list.wmeinfo;
1185 }
1186 
1187 /**
1188  * util_scan_entry_wmeparam() - function to read wme param ie
1189  * @scan_entry: scan entry
1190  *
1191  * API, function to read wme param ie
1192  *
1193  * Return: wme paramie or NULL if ie is not present
1194  */
1195 static inline uint8_t*
1196 util_scan_entry_wmeparam(struct scan_cache_entry *scan_entry)
1197 {
1198 	return scan_entry->ie_list.wmeparam;
1199 }
1200 
1201 /**
1202  * util_scan_entry_age() - function to read age of scan entry
1203  * @scan_entry: scan entry
1204  *
1205  * API, function to read age of scan entry
1206  *
1207  * Return: age in ms
1208  */
1209 static inline qdf_time_t
1210 util_scan_entry_age(struct scan_cache_entry *scan_entry)
1211 {
1212 	qdf_time_t ts = scan_entry->scan_entry_time;
1213 
1214 	return qdf_mc_timer_get_system_time() - ts;
1215 }
1216 
1217 /**
1218  * util_scan_mlme_info() - function to read mlme info struct
1219  * @scan_entry: scan entry
1220  *
1221  * API, function to read mlme info struct
1222  *
1223  * Return: mlme info
1224  */
1225 static inline struct mlme_info*
1226 util_scan_mlme_info(struct scan_cache_entry *scan_entry)
1227 {
1228 	return &scan_entry->mlme_info;
1229 }
1230 
1231 /**
1232  * util_scan_entry_bss_type() - function to read bss type
1233  * @scan_entry: scan entry
1234  *
1235  * API, function to read bss type
1236  *
1237  * Return: bss type
1238  */
1239 static inline enum wlan_bss_type
1240 util_scan_entry_bss_type(struct scan_cache_entry *scan_entry)
1241 {
1242 	if (scan_entry->cap_info.value & WLAN_CAPINFO_ESS)
1243 		return WLAN_TYPE_BSS;
1244 	else if (scan_entry->cap_info.value & WLAN_CAPINFO_IBSS)
1245 		return WLAN_TYPE_IBSS;
1246 	else
1247 		return WLAN_TYPE_ANY;
1248 }
1249 
1250 /**
1251  * util_scan_entry_privacy() - function to check if privacy is enebled
1252  * @scan_entry: scan entry
1253  *
1254  * API, function to check if privacy is enebled
1255  *
1256  * Return: true if privacy is enabled, false other wise
1257  */
1258 static inline bool
1259 util_scan_entry_privacy(struct scan_cache_entry *scan_entry)
1260 {
1261 	return (scan_entry->cap_info.value &
1262 		WLAN_CAPINFO_PRIVACY) ? true : false;
1263 }
1264 
1265 /**
1266  * util_scan_entry_athcaps() - function to read ath caps vendor ie
1267  * @scan_entry: scan entry
1268  *
1269  * API, function to read ath caps vendor ie
1270  *
1271  * Return: ath caps vendorie or NULL if ie is not present
1272  */
1273 static inline uint8_t*
1274 util_scan_entry_athcaps(struct scan_cache_entry *scan_entry)
1275 {
1276 	return scan_entry->ie_list.athcaps;
1277 }
1278 
1279 /**
1280  * util_scan_entry_athextcaps() - function to read ath extcaps vendor ie
1281  * @scan_entry: scan entry
1282  *
1283  * API, function to read ath extcaps vendor ie
1284  *
1285  * Return: ath extcaps vendorie or NULL if ie is not present
1286  */
1287 static inline uint8_t*
1288 util_scan_entry_athextcaps(struct scan_cache_entry *scan_entry)
1289 {
1290 	return scan_entry->ie_list.athextcaps;
1291 }
1292 
1293 /**
1294  * util_scan_entry_bwnss_map() - function to read bwnss_map ie
1295  * @scan_entry: scan entry
1296  *
1297  * API, function to read bwnss_map ie
1298  *
1299  * Return: bwnss_map ie or NULL if ie is not present
1300  */
1301 static inline uint8_t*
1302 util_scan_entry_bwnss_map(struct scan_cache_entry *scan_entry)
1303 {
1304 	return scan_entry->ie_list.bwnss_map;
1305 }
1306 
1307 /**
1308  * util_scan_entry_sonie() - function to read son ie
1309  * @scan_entry: scan entry
1310  *
1311  * API, function to read son ie
1312  *
1313  * Return: son ie or NULL if ie is not present
1314  */
1315 static inline uint8_t*
1316 util_scan_entry_sonie(struct scan_cache_entry *scan_entry)
1317 {
1318 	return scan_entry->ie_list.sonadv;
1319 }
1320 
1321 /**
1322  * util_scan_entry_widebw() - function to read wide band chan switch sub elem ie
1323  * @scan_entry: scan entry
1324  *
1325  * API, function to read wide band chan switch sub elem ie
1326  *
1327  * Return: wide band chan switch sub elem or NULL if ie is not present
1328  */
1329 static inline uint8_t*
1330 util_scan_entry_widebw(struct scan_cache_entry *scan_entry)
1331 {
1332 	return scan_entry->ie_list.widebw;
1333 }
1334 
1335 /**
1336  * util_scan_entry_secchanoff() - function to read secondary channel offset ie
1337  * @scan_entry: scan entry
1338  *
1339  * API, function to read secondary channel offset ie
1340  *
1341  * Return: secondary channel offset element or NULL if ie is not present
1342  */
1343 static inline uint8_t*
1344 util_scan_entry_secchanoff(struct scan_cache_entry *scan_entry)
1345 {
1346 	return scan_entry->ie_list.secchanoff;
1347 }
1348 
1349 /**
1350  * util_scan_entry_cswrp() - function to read channel switch wrapper ie
1351  * @scan_entry: scan entry
1352  *
1353  * API, function to read channel switch wrapper ie
1354  *
1355  * Return: channel switch wrapper element or NULL if ie is not present
1356  */
1357 static inline uint8_t*
1358 util_scan_entry_cswrp(struct scan_cache_entry *scan_entry)
1359 {
1360 	return scan_entry->ie_list.cswrp;
1361 }
1362 
1363 /**
1364  * util_scan_entry_omn() - function to read operating mode notification ie
1365  * @scan_entry: scan entry
1366  *
1367  * API, function to read operating mode notification
1368  *
1369  * Return: operating mode notification element or NULL if ie is not present
1370  */
1371 static inline uint8_t*
1372 util_scan_entry_omn(struct scan_cache_entry *scan_entry)
1373 {
1374 	return scan_entry->ie_list.opmode;
1375 }
1376 
1377 /**
1378  * util_scan_entry_extcaps() - function to read extcap ie
1379  * @scan_entry: scan entry
1380  *
1381  * API, function to read extcap ie
1382  *
1383  * Return: extcap element or NULL if ie is not present
1384  */
1385 static inline uint8_t*
1386 util_scan_entry_extcaps(struct scan_cache_entry *scan_entry)
1387 {
1388 	return scan_entry->ie_list.extcaps;
1389 }
1390 
1391 /**
1392  * util_scan_entry_get_extcap() - function to read extended capability field ie
1393  * @scan_entry: scan entry
1394  * @extcap_bit_field: extended capability bit field
1395  * @extcap_value: pointer to fill extended capability field value
1396  *
1397  * API, function to read extended capability field
1398  *
1399  * Return: QDF_STATUS_SUCCESS if extended capability field is found
1400  *         QDF_STATUS_E_NOMEM if extended capability field is not found
1401  */
1402 static inline QDF_STATUS
1403 util_scan_entry_get_extcap(struct scan_cache_entry *scan_entry,
1404 			   enum ext_cap_bit_field extcap_bit_field,
1405 			   uint8_t *extcap_value)
1406 {
1407 	struct wlan_ext_cap_ie *ext_cap =
1408 		(struct wlan_ext_cap_ie *)util_scan_entry_extcaps(scan_entry);
1409 
1410 	uint8_t ext_caps_byte = (extcap_bit_field >> 3);
1411 	uint8_t ext_caps_bit_pos = extcap_bit_field & 0x7;
1412 
1413 	*extcap_value = 0;
1414 
1415 	if (!ext_cap)
1416 		return QDF_STATUS_E_NULL_VALUE;
1417 
1418 	if (ext_cap->ext_cap_len < ext_caps_byte)
1419 		return QDF_STATUS_E_NULL_VALUE;
1420 
1421 	*extcap_value =
1422 		((ext_cap->ext_caps[ext_caps_byte] >> ext_caps_bit_pos) & 0x1);
1423 
1424 	return QDF_STATUS_SUCCESS;
1425 }
1426 
1427 /**
1428  * util_scan_entry_athcaps() - function to read ath caps vendor ie
1429  * @scan_entry: scan entry
1430  *
1431  * API, function to read ath caps vendor ie
1432  *
1433  * Return: ath caps vendorie or NULL if ie is not present
1434  */
1435 static inline struct mlme_info*
1436 util_scan_entry_mlme_info(struct scan_cache_entry *scan_entry)
1437 {
1438 	return &(scan_entry->mlme_info);
1439 }
1440 
1441 /**
1442 * util_scan_entry_mcst() - function to read mcst IE
1443 * @scan_entry:scan entry
1444 *
1445 * API, function to read mcst IE
1446 *
1447 * Return: mcst or NULL if ie is not present
1448 */
1449 static inline uint8_t*
1450 util_scan_entry_mcst(struct scan_cache_entry *scan_entry)
1451 {
1452 	return scan_entry->ie_list.mcst;
1453 }
1454 
1455 /**
1456  * util_scan_entry_hecap() - function to read he caps vendor ie
1457  * @scan_entry: scan entry
1458  *
1459  * API, function to read he caps vendor ie
1460  *
1461  * Return: he caps vendorie or NULL if ie is not present
1462  */
1463 static inline uint8_t*
1464 util_scan_entry_hecap(struct scan_cache_entry *scan_entry)
1465 {
1466 	return scan_entry->ie_list.hecap;
1467 }
1468 
1469 /**
1470  * util_scan_entry_he_6g_cap() - function to read  he 6GHz caps vendor ie
1471  * @scan_entry: scan entry
1472  *
1473  * API, function to read he 6GHz caps vendor ie
1474  *
1475  * Return: he caps vendorie or NULL if ie is not present
1476  */
1477 static inline uint8_t*
1478 util_scan_entry_he_6g_cap(struct scan_cache_entry *scan_entry)
1479 {
1480 	return scan_entry->ie_list.hecap_6g;
1481 }
1482 
1483 /**
1484  * util_scan_entry_heop() - function to read heop vendor ie
1485  * @scan_entry: scan entry
1486  *
1487  * API, function to read heop vendor ie
1488  *
1489  * Return, heop vendorie or NULL if ie is not present
1490  */
1491 static inline uint8_t*
1492 util_scan_entry_heop(struct scan_cache_entry *scan_entry)
1493 {
1494 	return scan_entry->ie_list.heop;
1495 }
1496 
1497 /**
1498  * util_scan_entry_muedca() - function to read MU-EDCA IE
1499  * @scan_entry: scan entry
1500  *
1501  * API, function to read MU-EDCA IE
1502  *
1503  * Return, MUEDCA IE or NULL if IE is not present
1504  */
1505 static inline uint8_t*
1506 util_scan_entry_muedca(struct scan_cache_entry *scan_entry)
1507 {
1508 	return scan_entry->ie_list.muedca;
1509 }
1510 
1511 /**
1512  * util_scan_entry_spatial_reuse_parameter() - function to read spatial reuse
1513  *                                             parameter ie
1514  * @scan_entry: scan entry
1515  *
1516  * API, function to read scan_entry reuse parameter ie
1517  *
1518  * Return, spatial reuse parameter ie or NULL if ie is not present
1519  */
1520 static inline uint8_t*
1521 util_scan_entry_spatial_reuse_parameter(struct scan_cache_entry *scan_entry)
1522 {
1523 	return scan_entry->ie_list.srp;
1524 }
1525 
1526 /**
1527  * util_scan_entry_fils_indication() - function to read FILS indication ie
1528  * @scan_entry: scan entry
1529  *
1530  * API, function to read FILS indication ie
1531  *
1532  * Return, FILS indication ie or NULL if ie is not present
1533  */
1534 static inline uint8_t*
1535 util_scan_entry_fils_indication(struct scan_cache_entry *scan_entry)
1536 {
1537 	return scan_entry->ie_list.fils_indication;
1538 }
1539 
1540 /**
1541  * util_get_last_scan_time() - function to get last scan time on this pdev
1542  * @vdev: vdev object
1543  *
1544  * API, function to read last scan time on this pdev
1545  *
1546  * Return: qdf_time_t
1547  */
1548 qdf_time_t
1549 util_get_last_scan_time(struct wlan_objmgr_vdev *vdev);
1550 
1551 /**
1552  * util_scan_entry_update_mlme_info() - function to update mlme info
1553  * @scan_entry: scan entry object
1554  *
1555  * API, function to update mlme info in scan DB
1556  *
1557  * Return: QDF_STATUS
1558  */
1559 QDF_STATUS
1560 util_scan_entry_update_mlme_info(struct wlan_objmgr_pdev *pdev,
1561 	struct scan_cache_entry *scan_entry);
1562 
1563 /**
1564  * util_scan_is_hidden_ssid() - function to check if ssid is hidden
1565  * @ssid: struct ie_ssid object
1566  *
1567  * API, function to check if ssid is hidden
1568  *
1569  * Return: true if ap is hidden, false otherwise
1570  */
1571 bool
1572 util_scan_is_hidden_ssid(struct ie_ssid *ssid);
1573 
1574 /**
1575  * util_scan_entry_is_hidden_ap() - function to check if ap is hidden
1576  * @scan_entry: scan entry
1577  *
1578  * API, function to check if ap is hidden
1579  *
1580  * Return: true if ap is hidden, false otherwise
1581  */
1582 static inline bool
1583 util_scan_entry_is_hidden_ap(struct scan_cache_entry *scan_entry)
1584 {
1585     return util_scan_is_hidden_ssid(
1586 			(struct ie_ssid *)scan_entry->ie_list.ssid);
1587 }
1588 
1589 /**
1590  * util_scan_entry_espinfo() - function to read ESP info
1591  * @scan_entry: scan entry
1592  *
1593  * API, function to read ESP info
1594  *
1595  * Return: erp info
1596  */
1597 static inline uint8_t *
1598 util_scan_entry_esp_info(struct scan_cache_entry *scan_entry)
1599 {
1600 	return scan_entry->ie_list.esp;
1601 }
1602 
1603 /**
1604  * util_scan_entry_mbo_oce() - function to read MBO/OCE ie
1605  * @scan_entry: scan entry
1606  *
1607  * API, function to read MBO/OCE ie
1608  *
1609  * Return: MBO/OCE ie
1610  */
1611 static inline uint8_t *
1612 util_scan_entry_mbo_oce(struct scan_cache_entry *scan_entry)
1613 {
1614 	return scan_entry->ie_list.mbo_oce;
1615 }
1616 
1617 /**
1618  * util_scan_scm_chan_to_band() - function to tell band for channel number
1619  * @chan: Channel number
1620  *
1621  * Return: Band information as per channel
1622  */
1623 enum wlan_band util_scan_scm_chan_to_band(uint32_t chan);
1624 
1625 /**
1626  * util_scan_scm_freq_to_band() - API to get band from frequency
1627  * @freq: Channel frequency
1628  *
1629  * Return: Band information as per frequency
1630  */
1631 enum wlan_band util_scan_scm_freq_to_band(uint16_t freq);
1632 
1633 /**
1634  * util_is_scan_completed() - function to get scan complete status
1635  * @event: scan event
1636  * @success: true if scan complete success, false otherwise
1637  *
1638  * API, function to get the scan result
1639  *
1640  * Return: true if scan complete, false otherwise
1641  */
1642 bool util_is_scan_completed(struct scan_event *event, bool *success);
1643 
1644 /**
1645  * util_scan_entry_extenderie() - function to read extender IE
1646  * @scan_entry: scan entry
1647  *
1648  * API, function to read extender IE
1649  *
1650  * Return: extenderie or NULL if ie is not present
1651  */
1652 static inline uint8_t*
1653 util_scan_entry_extenderie(struct scan_cache_entry *scan_entry)
1654 {
1655 	return scan_entry->ie_list.extender;
1656 }
1657 
1658 /**
1659  * util_scan_entry_mdie() - function to read Mobility Domain IE
1660  * @scan_entry: scan entry
1661  *
1662  * API, function to read Mobility Domain IE
1663  *
1664  * Return: MDIE or NULL if IE is not present
1665  */
1666 static inline uint8_t*
1667 util_scan_entry_mdie(struct scan_cache_entry *scan_entry)
1668 {
1669 	return scan_entry->ie_list.mdie;
1670 }
1671 
1672 /**
1673  * util_scan_is_null_ssid() - to check for NULL ssid
1674  * @ssid: ssid
1675  *
1676  * Return: true if NULL ssid else false
1677  */
1678 static inline bool util_scan_is_null_ssid(struct wlan_ssid *ssid)
1679 {
1680 	uint32_t ssid_length;
1681 	uint8_t *ssid_str;
1682 
1683 	if (ssid->length == 0)
1684 		return true;
1685 
1686 	/* Consider 0 or space for hidden SSID */
1687 	if (0 == ssid->ssid[0])
1688 		return true;
1689 
1690 	ssid_length = ssid->length;
1691 	ssid_str = ssid->ssid;
1692 
1693 	while (ssid_length) {
1694 		if (*ssid_str != ASCII_SPACE_CHARACTER &&
1695 		    *ssid_str)
1696 			break;
1697 		ssid_str++;
1698 		ssid_length--;
1699 	}
1700 
1701 	if (ssid_length == 0)
1702 		return true;
1703 
1704 	return false;
1705 }
1706 
1707 #endif
1708