xref: /wlan-dirver/qca-wifi-host-cmn/umac/scan/dispatcher/inc/wlan_scan_utils_api.h (revision a86b23ee68a2491aede2e03991f3fb37046f4e41)
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_is_ssid_match() - to check if ssid match
314  * @ssid1: ssid 1
315  * @ssid2: ssid 2
316  *
317  * Return: true if ssid match
318  */
319 static inline bool
320 util_is_ssid_match(struct wlan_ssid *ssid1,
321 		struct wlan_ssid *ssid2)
322 {
323 	if (ssid1->length != ssid2->length)
324 		return false;
325 
326 	if (!qdf_mem_cmp(ssid1->ssid,
327 	   ssid2->ssid, ssid1->length))
328 		return true;
329 
330 	return false;
331 }
332 
333 /**
334  * util_is_bssid_match() - to check if bssid match
335  * @bssid1: bssid 1
336  * @bssid2: bssid 2
337  *
338  * Return: true if bssid match
339  */
340 static inline bool util_is_bssid_match(struct qdf_mac_addr *bssid1,
341 	struct qdf_mac_addr *bssid2)
342 {
343 
344 	if (qdf_is_macaddr_zero(bssid1) ||
345 	   qdf_is_macaddr_broadcast(bssid1))
346 		return true;
347 
348 	if (qdf_is_macaddr_equal(bssid1, bssid2))
349 		return true;
350 
351 	return false;
352 }
353 
354 /**
355  * util_is_bss_type_match() - to check if bss type
356  * @bss_type: bss type
357  * @cap: capability
358  *
359  * Return: true if bss type match
360  */
361 static inline bool util_is_bss_type_match(enum wlan_bss_type bss_type,
362 	union wlan_capability cap)
363 {
364 	bool match = true;
365 
366 	switch (bss_type) {
367 	case WLAN_TYPE_ANY:
368 		break;
369 	case WLAN_TYPE_IBSS:
370 		if (!cap.wlan_caps.ibss)
371 			match = false;
372 		break;
373 	case WLAN_TYPE_BSS:
374 		if (!cap.wlan_caps.ess)
375 			match = false;
376 		break;
377 	default:
378 		match = false;
379 	}
380 
381 	return match;
382 }
383 
384 /**
385  * util_country_code_match() - to check if country match
386  * @country: country code pointer
387  * @country_ie: country IE in beacon
388  *
389  * Return: true if country match
390  */
391 static inline bool util_country_code_match(uint8_t *country,
392 					   struct wlan_country_ie *cc)
393 {
394 	if (!country || !country[0])
395 		return true;
396 
397 	if (!cc)
398 		return false;
399 
400 	if (cc->cc[0] == country[0] &&
401 	    cc->cc[1] == country[1])
402 		return true;
403 
404 	return false;
405 }
406 
407 /**
408  * util_mdie_match() - to check if mdie match
409  * @mobility_domain: mobility domain
410  * @mdie: mobility domain ie
411  *
412  * Return: true if country match
413  */
414 static inline bool util_mdie_match(uint16_t mobility_domain,
415 	struct rsn_mdie *mdie)
416 {
417 	uint16_t md;
418 
419 	if (!mobility_domain)
420 		return true;
421 
422 	if (!mdie)
423 		return false;
424 
425 	md =
426 	  (mdie->mobility_domain[1] << 8) |
427 	   mdie->mobility_domain[0];
428 
429 	if (md == mobility_domain)
430 		return true;
431 
432 	return false;
433 }
434 
435 /**
436  * util_scan_entry_ssid() - function to read ssid of scan entry
437  * @scan_entry: scan entry
438  *
439  * API, function to read ssid of scan entry
440  *
441  * Return: ssid
442  */
443 static inline struct wlan_ssid*
444 util_scan_entry_ssid(struct scan_cache_entry *scan_entry)
445 {
446 	return &(scan_entry->ssid);
447 }
448 
449 /**
450  * util_scan_entry_dtimperiod() - function to read dtim period of scan entry
451  * @scan_entry: scan entry
452  *
453  * API, function to read dtim period of scan entry
454  *
455  * Return: dtim period
456  */
457 static inline uint8_t
458 util_scan_entry_dtimperiod(struct scan_cache_entry *scan_entry)
459 {
460 	return scan_entry->dtim_period;
461 }
462 
463 /**
464  * util_scan_entry_tim() - function to read tim ie of scan entry
465  * @scan_entry: scan entry
466  *
467  * API, function to read tim ie of scan entry
468  *
469  * Return: timie or NULL if ie is not present
470  */
471 static inline uint8_t*
472 util_scan_entry_tim(struct scan_cache_entry *scan_entry)
473 {
474 	return scan_entry->ie_list.tim;
475 }
476 
477 /**
478  * util_scan_entry_beacon_frame() - function to read full beacon or
479  * probe resp frame
480  * @scan_entry: scan entry
481  *
482  * API, function to read full beacon or probe resp frame including frame header
483  *
484  * Return: beacon/probe resp frame
485  */
486 static inline struct element_info
487 util_scan_entry_beacon_frame(struct scan_cache_entry *scan_entry)
488 {
489 	/* util_scan_entry_beacon_data */
490 	return scan_entry->raw_frame;
491 }
492 
493 /**
494  * util_scan_entry_ie_data() - function to read tagged IEs
495  * @scan_entry: scan entry
496  *
497  * API, function to read beacon/probe response frames starting from tagged IEs
498  * (excluding frame header and fixed parameters)
499  *
500  * Return: tagged IES of beacon/probe resp frame
501  */
502 static inline uint8_t*
503 util_scan_entry_ie_data(struct scan_cache_entry *scan_entry)
504 {
505 	struct element_info bcn_frm;
506 	uint8_t *ie_data = NULL;
507 
508 	bcn_frm = util_scan_entry_beacon_frame(scan_entry);
509 	ie_data = (uint8_t *) (bcn_frm.ptr +
510 		 sizeof(struct wlan_frame_hdr) +
511 		 offsetof(struct wlan_bcn_frame, ie));
512 	return ie_data;
513 }
514 
515 /**
516  * util_scan_entry_ie_len() - function to read length of all tagged IEs
517  * @scan_entry: scan entry
518  *
519  * API, function to read length of all tagged IEs
520  *
521  * Return: length of all tagged IEs
522  */
523 static inline uint16_t
524 util_scan_entry_ie_len(struct scan_cache_entry *scan_entry)
525 {
526 	struct element_info bcn_frm;
527 	uint16_t ie_len = 0;
528 
529 	bcn_frm = util_scan_entry_beacon_frame(scan_entry);
530 	ie_len = (uint16_t) (bcn_frm.len -
531 		sizeof(struct wlan_frame_hdr) -
532 		offsetof(struct wlan_bcn_frame, ie));
533 	return ie_len;
534 }
535 
536 /**
537  * util_scan_entry_frame_len() - function to frame length
538  * @scan_entry: scan entry
539  *
540  * API, function to read frame length
541  *
542  * Return: frame length
543  */
544 static inline uint32_t
545 util_scan_entry_frame_len(struct scan_cache_entry *scan_entry)
546 {
547 	return scan_entry->raw_frame.len;
548 }
549 
550 /**
551  * util_scan_entry_frame_ptr() - function to get frame ptr
552  * @scan_entry: scan entry
553  *
554  * API, function to read frame ptr
555  *
556  * Return: frame ptr
557  */
558 static inline uint8_t*
559 util_scan_entry_frame_ptr(struct scan_cache_entry *scan_entry)
560 {
561 	return scan_entry->raw_frame.ptr;
562 }
563 
564 /**
565  * util_scan_entry_copy_ie_data() - function to get a copy of all tagged IEs
566  * @scan_entry: scan entry
567  *
568  * API, function to get a copy of all tagged IEs in passed memory
569  *
570  * Return: QDF_STATUS_SUCCESS if tagged IEs copied successfully
571  *         QDF_STATUS_E_NOMEM if passed memory/length can't hold all tagged IEs
572  */
573 static inline QDF_STATUS
574 util_scan_entry_copy_ie_data(struct scan_cache_entry *scan_entry,
575 	uint8_t *iebuf, uint16_t *ie_len)
576 {
577 	u_int8_t     *buff;
578 	u_int16_t    buff_len;
579 
580 	/* iebuf can be NULL, ie_len must be a valid pointer. */
581 	QDF_ASSERT(ie_len);
582 	if (!ie_len)
583 		return QDF_STATUS_E_NULL_VALUE;
584 
585 	buff = util_scan_entry_ie_data(scan_entry);
586 	buff_len = util_scan_entry_ie_len(scan_entry);
587 	/*
588 	 * If caller passed a buffer, check the length to make sure
589 	 * it's large enough.
590 	 * If no buffer is passed, just return the length of the IE blob.
591 	 */
592 	if (iebuf) {
593 		if (*ie_len >= buff_len) {
594 			qdf_mem_copy(iebuf, buff, buff_len);
595 			*ie_len = buff_len;
596 			return QDF_STATUS_SUCCESS;
597 		}
598 	}
599 
600 	*ie_len = buff_len;
601 	return QDF_STATUS_E_NOMEM;
602 }
603 
604 /**
605  * util_scan_free_cache_entry() - function to free scan
606  * cache entry
607  * @scan_entry: scan entry
608  *
609  * API, function to free scan cache entry
610  *
611  * Return: void
612  */
613 static inline void
614 util_scan_free_cache_entry(struct scan_cache_entry *scan_entry)
615 {
616 	if (!scan_entry)
617 		return;
618 	if (scan_entry->alt_wcn_ie.ptr)
619 		qdf_mem_free(scan_entry->alt_wcn_ie.ptr);
620 	if (scan_entry->raw_frame.ptr)
621 		qdf_mem_free(scan_entry->raw_frame.ptr);
622 	qdf_mem_free(scan_entry);
623 }
624 
625 #define conv_ptr(_address, _base1, _base2) \
626 	((_address) ? (((u_int8_t *) (_address) - \
627 	(u_int8_t *) (_base1)) + (u_int8_t *) (_base2)) : NULL)
628 
629 /**
630  * util_scan_copy_beacon_data() - copy beacon and update ie ptrs
631  * cache entry
632  * @new_entry: new scan entry
633  * @scan_entry: entry from where data is copied
634  *
635  * API, function to copy beacon and update ie ptrs
636  *
637  * Return: QDF_STATUS
638  */
639 static inline QDF_STATUS
640 util_scan_copy_beacon_data(struct scan_cache_entry *new_entry,
641 	struct scan_cache_entry *scan_entry)
642 {
643 	u_int8_t *new_ptr, *old_ptr;
644 	struct ie_list *ie_lst;
645 
646 	new_entry->raw_frame.ptr =
647 		qdf_mem_malloc_atomic(scan_entry->raw_frame.len);
648 	if (!new_entry->raw_frame.ptr)
649 		return QDF_STATUS_E_NOMEM;
650 
651 	qdf_mem_copy(new_entry->raw_frame.ptr,
652 		scan_entry->raw_frame.ptr,
653 		scan_entry->raw_frame.len);
654 	new_entry->raw_frame.len = scan_entry->raw_frame.len;
655 	new_ptr = new_entry->raw_frame.ptr;
656 	old_ptr = scan_entry->raw_frame.ptr;
657 
658 	new_entry->ie_list = scan_entry->ie_list;
659 
660 	ie_lst = &new_entry->ie_list;
661 
662 	/* New info_element needs also be added in ieee80211_parse_beacon */
663 	ie_lst->tim = conv_ptr(ie_lst->tim, old_ptr, new_ptr);
664 	ie_lst->country = conv_ptr(ie_lst->country, old_ptr, new_ptr);
665 	ie_lst->ssid = conv_ptr(ie_lst->ssid, old_ptr, new_ptr);
666 	ie_lst->rates = conv_ptr(ie_lst->rates, old_ptr, new_ptr);
667 	ie_lst->xrates = conv_ptr(ie_lst->xrates, old_ptr, new_ptr);
668 	ie_lst->ds_param = conv_ptr(ie_lst->ds_param, old_ptr, new_ptr);
669 	ie_lst->csa = conv_ptr(ie_lst->csa, old_ptr, new_ptr);
670 	ie_lst->xcsa = conv_ptr(ie_lst->xcsa, old_ptr, new_ptr);
671 	ie_lst->mcst = conv_ptr(ie_lst->mcst, old_ptr, new_ptr);
672 	ie_lst->secchanoff = conv_ptr(ie_lst->secchanoff, old_ptr, new_ptr);
673 	ie_lst->wpa = conv_ptr(ie_lst->wpa, old_ptr, new_ptr);
674 	ie_lst->wcn = conv_ptr(ie_lst->wcn, old_ptr, new_ptr);
675 	ie_lst->rsn = conv_ptr(ie_lst->rsn, old_ptr, new_ptr);
676 	ie_lst->wps = conv_ptr(ie_lst->wps, old_ptr, new_ptr);
677 	ie_lst->wmeinfo = conv_ptr(ie_lst->wmeinfo, old_ptr, new_ptr);
678 	ie_lst->wmeparam = conv_ptr(ie_lst->wmeparam, old_ptr, new_ptr);
679 	ie_lst->quiet = conv_ptr(ie_lst->quiet, old_ptr, new_ptr);
680 	ie_lst->htcap = conv_ptr(ie_lst->htcap, old_ptr, new_ptr);
681 	ie_lst->htinfo = conv_ptr(ie_lst->htinfo, old_ptr, new_ptr);
682 	ie_lst->athcaps = conv_ptr(ie_lst->athcaps, old_ptr, new_ptr);
683 	ie_lst->athextcaps = conv_ptr(ie_lst->athextcaps, old_ptr, new_ptr);
684 	ie_lst->sfa = conv_ptr(ie_lst->sfa, old_ptr, new_ptr);
685 	ie_lst->vendor = conv_ptr(ie_lst->vendor, old_ptr, new_ptr);
686 	ie_lst->qbssload = conv_ptr(ie_lst->qbssload, old_ptr, new_ptr);
687 	ie_lst->wapi = conv_ptr(ie_lst->wapi, old_ptr, new_ptr);
688 	ie_lst->p2p = conv_ptr(ie_lst->p2p, old_ptr, new_ptr);
689 	ie_lst->alt_wcn = conv_ptr(ie_lst->alt_wcn, old_ptr, new_ptr);
690 	ie_lst->extcaps = conv_ptr(ie_lst->extcaps, old_ptr, new_ptr);
691 	ie_lst->ibssdfs = conv_ptr(ie_lst->ibssdfs, old_ptr, new_ptr);
692 	ie_lst->sonadv = conv_ptr(ie_lst->sonadv, old_ptr, new_ptr);
693 	ie_lst->vhtcap = conv_ptr(ie_lst->vhtcap, old_ptr, new_ptr);
694 	ie_lst->vhtop = conv_ptr(ie_lst->vhtop, old_ptr, new_ptr);
695 	ie_lst->opmode = conv_ptr(ie_lst->opmode, old_ptr, new_ptr);
696 	ie_lst->cswrp = conv_ptr(ie_lst->cswrp, old_ptr, new_ptr);
697 	ie_lst->widebw = conv_ptr(ie_lst->widebw, old_ptr, new_ptr);
698 	ie_lst->txpwrenvlp = conv_ptr(ie_lst->txpwrenvlp, old_ptr, new_ptr);
699 	ie_lst->bwnss_map = conv_ptr(ie_lst->bwnss_map, old_ptr, new_ptr);
700 	ie_lst->mdie = conv_ptr(ie_lst->mdie, old_ptr, new_ptr);
701 	ie_lst->hecap = conv_ptr(ie_lst->hecap, old_ptr, new_ptr);
702 	ie_lst->heop = conv_ptr(ie_lst->heop, old_ptr, new_ptr);
703 	ie_lst->fils_indication = conv_ptr(ie_lst->fils_indication,
704 					   old_ptr, new_ptr);
705 	ie_lst->esp = conv_ptr(ie_lst->esp, old_ptr, new_ptr);
706 	ie_lst->mbo_oce = conv_ptr(ie_lst->mbo_oce, old_ptr, new_ptr);
707 	ie_lst->muedca = conv_ptr(ie_lst->muedca, old_ptr, new_ptr);
708 	ie_lst->rnrie = conv_ptr(ie_lst->rnrie, old_ptr, new_ptr);
709 	ie_lst->extender = conv_ptr(ie_lst->extender, old_ptr, new_ptr);
710 	ie_lst->adaptive_11r = conv_ptr(ie_lst->adaptive_11r, old_ptr, new_ptr);
711 	ie_lst->single_pmk = conv_ptr(ie_lst->single_pmk, old_ptr, new_ptr);
712 
713 	return QDF_STATUS_SUCCESS;
714 }
715 /**
716  * util_scan_copy_cache_entry() - function to create a copy
717  * of scan cache entry
718  * @scan_entry: scan entry
719  *
720  * API, function to create a copy of scan cache entry
721  *
722  * Return: copy of scan_entry
723  */
724 static inline struct scan_cache_entry *
725 util_scan_copy_cache_entry(struct scan_cache_entry *scan_entry)
726 {
727 	struct scan_cache_entry *new_entry;
728 	QDF_STATUS status;
729 
730 	if (!scan_entry)
731 		return NULL;
732 
733 	new_entry =
734 	   qdf_mem_malloc_atomic(sizeof(*scan_entry));
735 	if (!new_entry)
736 		return NULL;
737 
738 	qdf_mem_copy(new_entry,
739 		scan_entry, sizeof(*scan_entry));
740 
741 	if (scan_entry->alt_wcn_ie.ptr) {
742 		new_entry->alt_wcn_ie.ptr =
743 		    qdf_mem_malloc_atomic(scan_entry->alt_wcn_ie.len);
744 		if (!new_entry->alt_wcn_ie.ptr) {
745 			qdf_mem_free(new_entry);
746 			return NULL;
747 		}
748 		qdf_mem_copy(new_entry->alt_wcn_ie.ptr,
749 		   scan_entry->alt_wcn_ie.ptr,
750 		   scan_entry->alt_wcn_ie.len);
751 		new_entry->alt_wcn_ie.len =
752 			scan_entry->alt_wcn_ie.len;
753 	}
754 
755 	status = util_scan_copy_beacon_data(new_entry, scan_entry);
756 	if (QDF_IS_STATUS_ERROR(status)) {
757 		util_scan_free_cache_entry(new_entry);
758 		return NULL;
759 	}
760 
761 	return new_entry;
762 }
763 
764 /**
765  * util_scan_entry_channel() - function to read channel info
766  * @scan_entry: scan entry
767  *
768  * API, function to read channel info
769  *
770  * Return: channel info
771  */
772 static inline struct channel_info*
773 util_scan_entry_channel(struct scan_cache_entry *scan_entry)
774 {
775 	return &(scan_entry->channel);
776 }
777 
778 /**
779  * util_scan_entry_channel_frequency() - function to read channel number
780  * @scan_entry: scan entry
781  *
782  * API, function to read channel number
783  *
784  * Return: channel number
785  */
786 static inline uint32_t
787 util_scan_entry_channel_frequency(struct scan_cache_entry *scan_entry)
788 {
789 	return scan_entry->channel.chan_freq;
790 }
791 
792 /**
793  * util_scan_entry_erpinfo() - function to read erp info
794  * @scan_entry: scan entry
795  *
796  * API, function to read erp info
797  *
798  * Return: erp info
799  */
800 static inline uint8_t
801 util_scan_entry_erpinfo(struct scan_cache_entry *scan_entry)
802 {
803 	return scan_entry->erp;
804 }
805 
806 /**
807  * util_scan_entry_rates() - function to read supported rates IE
808  * @scan_entry: scan entry
809  *
810  * API, function to read supported rates IE
811  *
812  * Return: basic ratesie or NULL if ie is not present
813  */
814 static inline uint8_t*
815 util_scan_entry_rates(struct scan_cache_entry *scan_entry)
816 {
817 	return scan_entry->ie_list.rates;
818 }
819 
820 /**
821  * util_scan_entry_xrates()- function to read extended supported rates IE
822  * @scan_entry: scan entry
823  *
824  * API, function to read extended supported rates IE
825  *
826  * Return: extended supported ratesie or NULL if ie is not present
827  */
828 static inline uint8_t*
829 util_scan_entry_xrates(struct scan_cache_entry *scan_entry)
830 {
831 	return scan_entry->ie_list.xrates;
832 }
833 
834 /**
835  * util_scan_entry_rsn()- function to read rsn IE
836  * @scan_entry: scan entry
837  *
838  * API, function to read rsn IE
839  *
840  * Return: rsnie or NULL if ie is not present
841  */
842 static inline uint8_t*
843 util_scan_entry_rsn(struct scan_cache_entry *scan_entry)
844 {
845 	return scan_entry->ie_list.rsn;
846 }
847 
848 /**
849  * util_scan_entry_adaptive_11r()- function to read adaptive 11r Vendor IE
850  * @scan_entry: scan entry
851  *
852  * API, function to read adaptive 11r IE
853  *
854  * Return:  apaptive 11r ie or NULL if ie is not present
855  */
856 static inline uint8_t*
857 util_scan_entry_adaptive_11r(struct scan_cache_entry *scan_entry)
858 {
859 	return scan_entry->ie_list.adaptive_11r;
860 }
861 
862 /**
863  * util_scan_entry_single_pmk()- function to read single pmk Vendor IE
864  * @scan_entry: scan entry
865  *
866  * API, function to read sae single pmk IE
867  *
868  * Return: true if single_pmk ie is present or false if ie is not present
869  */
870 static inline bool
871 util_scan_entry_single_pmk(struct scan_cache_entry *scan_entry)
872 {
873 	if (scan_entry->ie_list.single_pmk)
874 		return true;
875 
876 	return false;
877 }
878 
879 /**
880  * util_scan_get_rsn_len()- function to read rsn IE length if present
881  * @scan_entry: scan entry
882  *
883  * API, function to read rsn length if present
884  *
885  * Return: rsnie length
886  */
887 static inline uint8_t
888 util_scan_get_rsn_len(struct scan_cache_entry *scan_entry)
889 {
890 	if (scan_entry && scan_entry->ie_list.rsn)
891 		return scan_entry->ie_list.rsn[1] + 2;
892 	else
893 		return 0;
894 }
895 
896 
897 /**
898  * util_scan_entry_wpa() - function to read wpa IE
899  * @scan_entry: scan entry
900  *
901  * API, function to read wpa IE
902  *
903  * Return: wpaie or NULL if ie is not present
904  */
905 static inline uint8_t*
906 util_scan_entry_wpa(struct scan_cache_entry *scan_entry)
907 {
908 	return scan_entry->ie_list.wpa;
909 }
910 
911 /**
912  * util_scan_get_wpa_len()- function to read wpa IE length if present
913  * @scan_entry: scan entry
914  *
915  * API, function to read wpa ie length if present
916  *
917  * Return: wpa ie length
918  */
919 static inline uint8_t
920 util_scan_get_wpa_len(struct scan_cache_entry *scan_entry)
921 {
922 	if (scan_entry && scan_entry->ie_list.wpa)
923 		return scan_entry->ie_list.wpa[1] + 2;
924 	else
925 		return 0;
926 }
927 
928 
929 /**
930  * util_scan_entry_wapi() - function to read wapi IE
931  * @scan_entry: scan entry
932  *
933  * API, function to read wapi IE
934  *
935  * Return: wapiie or NULL if ie is not present
936  */
937 static inline uint8_t*
938 util_scan_entry_wapi(struct scan_cache_entry *scan_entry)
939 {
940 	return scan_entry->ie_list.wapi;
941 }
942 
943 /**
944  * util_scan_entry_wps() - function to read wps IE
945  * @scan_entry: scan entry
946  *
947  * API, function to read wps IE
948  *
949  * Return: wpsie or NULL if ie is not present
950  */
951 static inline uint8_t*
952 util_scan_entry_wps(struct scan_cache_entry *scan_entry)
953 {
954 	return scan_entry->ie_list.wps;
955 }
956 
957 /**
958  * util_scan_entry_sfa() - function to read sfa IE
959  * @scan_entry: scan entry
960  *
961  * API, function to read sfa IE
962  *
963  * Return: sfaie or NULL if ie is not present
964  */
965 static inline uint8_t*
966 util_scan_entry_sfa(struct scan_cache_entry *scan_entry)
967 {
968 	return scan_entry->ie_list.sfa;
969 }
970 
971 /**
972  * util_scan_entry_ds_param() - function to read ds params
973  * @scan_entry: scan entry
974  *
975  * API, function to read ds params
976  *
977  * Return: ds params or NULL if ie is not present
978  */
979 static inline uint8_t*
980 util_scan_entry_ds_param(struct scan_cache_entry *scan_entry)
981 {
982 	if (scan_entry)
983 		return scan_entry->ie_list.ds_param;
984 	else
985 		return NULL;
986 }
987 
988 /**
989  * util_scan_entry_csa() - function to read csa IE
990  * @scan_entry: scan entry
991  *
992  * API, function to read csa IE
993  *
994  * Return: csaie or NULL if ie is not present
995  */
996 static inline uint8_t*
997 util_scan_entry_csa(struct scan_cache_entry *scan_entry)
998 {
999 	return scan_entry->ie_list.csa;
1000 }
1001 
1002 /**
1003  * util_scan_entry_xcsa() - function to read extended csa IE
1004  * @scan_entry: scan entry
1005  *
1006  * API, function to read extended csa IE
1007  *
1008  * Return: extended csaie or NULL if ie is not present
1009  */
1010 static inline uint8_t*
1011 util_scan_entry_xcsa(struct scan_cache_entry *scan_entry)
1012 {
1013 	return scan_entry->ie_list.xcsa;
1014 }
1015 
1016 /**
1017  * util_scan_entry_htinfo() - function to read htinfo IE
1018  * @scan_entry: scan entry
1019  *
1020  * API, function to read htinfo IE
1021  *
1022  * Return: htinfoie or NULL if ie is not present
1023  */
1024 static inline uint8_t*
1025 util_scan_entry_htinfo(struct scan_cache_entry *scan_entry)
1026 {
1027 	return scan_entry->ie_list.htinfo;
1028 }
1029 
1030 
1031 /**
1032  * util_scan_entry_htcap() - function to read htcap IE
1033  * @scan_entry: scan entry
1034  *
1035  * API, function to read htcap IE
1036  *
1037  * Return: htcapie or NULL if ie is not present
1038  */
1039 static inline uint8_t*
1040 util_scan_entry_htcap(struct scan_cache_entry *scan_entry)
1041 {
1042 	return scan_entry->ie_list.htcap;
1043 }
1044 
1045 /**
1046  * util_scan_entry_vhtcap() - function to read vhtcap IE
1047  * @scan_entry: scan entry
1048  *
1049  * API, function to read vhtcap IE
1050  *
1051  * Return: vhtcapie or NULL if ie is not present
1052  */
1053 static inline uint8_t*
1054 util_scan_entry_vhtcap(struct scan_cache_entry *scan_entry)
1055 {
1056 	return scan_entry->ie_list.vhtcap;
1057 }
1058 
1059 /**
1060  * util_scan_entry_vhtop() - function to read vhtop IE
1061  * @scan_entry: scan entry
1062  *
1063  * API, function to read vhtop IE
1064  *
1065  * Return: vhtopie or NULL if ie is not present
1066  */
1067 static inline uint8_t*
1068 util_scan_entry_vhtop(struct scan_cache_entry *scan_entry)
1069 {
1070 	return scan_entry->ie_list.vhtop;
1071 }
1072 
1073 /**
1074  * util_scan_entry_quiet() - function to read quiet IE
1075  * @scan_entry: scan entry
1076  *
1077  * API, function to read quiet IE
1078  *
1079  * Return: quietie or NULL if ie is not present
1080  */
1081 static inline uint8_t*
1082 util_scan_entry_quiet(struct scan_cache_entry *scan_entry)
1083 {
1084 	return scan_entry->ie_list.quiet;
1085 }
1086 
1087 /**
1088  * util_scan_entry_qbssload() - function to read qbss load IE
1089  * @scan_entry: scan entry
1090  *
1091  * API, function to read qbss load IE
1092  *
1093  * Return: qbss loadie or NULL if ie is not present
1094  */
1095 static inline uint8_t*
1096 util_scan_entry_qbssload(struct scan_cache_entry *scan_entry)
1097 {
1098 	return scan_entry->ie_list.qbssload;
1099 }
1100 
1101 /**
1102  * util_scan_entry_vendor() - function to read vendor IE
1103  * @scan_entry: scan entry
1104  *
1105  * API, function to read vendor IE
1106  *
1107  * Return: vendorie or NULL if ie is not present
1108  */
1109 static inline uint8_t*
1110 util_scan_entry_vendor(struct scan_cache_entry *scan_entry)
1111 {
1112 	return scan_entry->ie_list.vendor;
1113 }
1114 
1115 /**
1116  * util_scan_entry_country() - function to read country IE
1117  * @scan_entry: scan entry
1118  *
1119  * API, function to read country IE
1120  *
1121  * Return: countryie or NULL if ie is not present
1122  */
1123 static inline struct wlan_country_ie*
1124 util_scan_entry_country(struct scan_cache_entry *scan_entry)
1125 {
1126 	return (struct wlan_country_ie *)scan_entry->ie_list.country;
1127 }
1128 
1129 /**
1130  * util_scan_entry_copy_country() - function to copy country name
1131  * @scan_entry: scan entry
1132  * @cntry:      out buffer
1133  *
1134  * API, function to copy country name code string in given memory @centry
1135  *
1136  * Return: QDF_STATUS_SUCCESS if successfully copied country name
1137  *         QDF_STATUS_E_INVAL if passed buffer is null
1138  *         QDF_STATUS_E_NOMEM if scan entry dont have country IE
1139  */
1140 static inline QDF_STATUS
1141 util_scan_entry_copy_country(struct scan_cache_entry *scan_entry,
1142 	uint8_t *cntry)
1143 {
1144 	struct wlan_country_ie *country_ie;
1145 
1146 	if (!cntry)
1147 		return QDF_STATUS_E_INVAL;
1148 
1149 	country_ie = util_scan_entry_country(scan_entry);
1150 
1151 	if (!country_ie)
1152 		return QDF_STATUS_E_NOMEM;
1153 
1154 	qdf_mem_copy(cntry, country_ie->cc, 3);
1155 
1156 	return QDF_STATUS_SUCCESS;
1157 }
1158 
1159 /**
1160  * util_scan_entry_wmeinfo() - function to read wme info ie
1161  * @scan_entry: scan entry
1162  *
1163  * API, function to read wme info ie
1164  *
1165  * Return: wme infoie or NULL if ie is not present
1166  */
1167 static inline uint8_t*
1168 util_scan_entry_wmeinfo(struct scan_cache_entry *scan_entry)
1169 {
1170 	return scan_entry->ie_list.wmeinfo;
1171 }
1172 
1173 /**
1174  * util_scan_entry_wmeparam() - function to read wme param ie
1175  * @scan_entry: scan entry
1176  *
1177  * API, function to read wme param ie
1178  *
1179  * Return: wme paramie or NULL if ie is not present
1180  */
1181 static inline uint8_t*
1182 util_scan_entry_wmeparam(struct scan_cache_entry *scan_entry)
1183 {
1184 	return scan_entry->ie_list.wmeparam;
1185 }
1186 
1187 /**
1188  * util_scan_entry_age() - function to read age of scan entry
1189  * @scan_entry: scan entry
1190  *
1191  * API, function to read age of scan entry
1192  *
1193  * Return: age in ms
1194  */
1195 static inline qdf_time_t
1196 util_scan_entry_age(struct scan_cache_entry *scan_entry)
1197 {
1198 	qdf_time_t ts = scan_entry->scan_entry_time;
1199 
1200 	return qdf_mc_timer_get_system_time() - ts;
1201 }
1202 
1203 /**
1204  * util_scan_mlme_info() - function to read mlme info struct
1205  * @scan_entry: scan entry
1206  *
1207  * API, function to read mlme info struct
1208  *
1209  * Return: mlme info
1210  */
1211 static inline struct mlme_info*
1212 util_scan_mlme_info(struct scan_cache_entry *scan_entry)
1213 {
1214 	return &scan_entry->mlme_info;
1215 }
1216 
1217 /**
1218  * util_scan_entry_bss_type() - function to read bss type
1219  * @scan_entry: scan entry
1220  *
1221  * API, function to read bss type
1222  *
1223  * Return: bss type
1224  */
1225 static inline enum wlan_bss_type
1226 util_scan_entry_bss_type(struct scan_cache_entry *scan_entry)
1227 {
1228 	if (scan_entry->cap_info.value & WLAN_CAPINFO_ESS)
1229 		return WLAN_TYPE_BSS;
1230 	else if (scan_entry->cap_info.value & WLAN_CAPINFO_IBSS)
1231 		return WLAN_TYPE_IBSS;
1232 	else
1233 		return WLAN_TYPE_ANY;
1234 }
1235 
1236 /**
1237  * util_scan_entry_privacy() - function to check if privacy is enebled
1238  * @scan_entry: scan entry
1239  *
1240  * API, function to check if privacy is enebled
1241  *
1242  * Return: true if privacy is enabled, false other wise
1243  */
1244 static inline bool
1245 util_scan_entry_privacy(struct scan_cache_entry *scan_entry)
1246 {
1247 	return (scan_entry->cap_info.value &
1248 		WLAN_CAPINFO_PRIVACY) ? true : false;
1249 }
1250 
1251 /**
1252  * util_scan_entry_athcaps() - function to read ath caps vendor ie
1253  * @scan_entry: scan entry
1254  *
1255  * API, function to read ath caps vendor ie
1256  *
1257  * Return: ath caps vendorie or NULL if ie is not present
1258  */
1259 static inline uint8_t*
1260 util_scan_entry_athcaps(struct scan_cache_entry *scan_entry)
1261 {
1262 	return scan_entry->ie_list.athcaps;
1263 }
1264 
1265 /**
1266  * util_scan_entry_athextcaps() - function to read ath extcaps vendor ie
1267  * @scan_entry: scan entry
1268  *
1269  * API, function to read ath extcaps vendor ie
1270  *
1271  * Return: ath extcaps vendorie or NULL if ie is not present
1272  */
1273 static inline uint8_t*
1274 util_scan_entry_athextcaps(struct scan_cache_entry *scan_entry)
1275 {
1276 	return scan_entry->ie_list.athextcaps;
1277 }
1278 
1279 /**
1280  * util_scan_entry_bwnss_map() - function to read bwnss_map ie
1281  * @scan_entry: scan entry
1282  *
1283  * API, function to read bwnss_map ie
1284  *
1285  * Return: bwnss_map ie or NULL if ie is not present
1286  */
1287 static inline uint8_t*
1288 util_scan_entry_bwnss_map(struct scan_cache_entry *scan_entry)
1289 {
1290 	return scan_entry->ie_list.bwnss_map;
1291 }
1292 
1293 /**
1294  * util_scan_entry_sonie() - function to read son ie
1295  * @scan_entry: scan entry
1296  *
1297  * API, function to read son ie
1298  *
1299  * Return: son ie or NULL if ie is not present
1300  */
1301 static inline uint8_t*
1302 util_scan_entry_sonie(struct scan_cache_entry *scan_entry)
1303 {
1304 	return scan_entry->ie_list.sonadv;
1305 }
1306 
1307 /**
1308  * util_scan_entry_widebw() - function to read wide band chan switch sub elem ie
1309  * @scan_entry: scan entry
1310  *
1311  * API, function to read wide band chan switch sub elem ie
1312  *
1313  * Return: wide band chan switch sub elem or NULL if ie is not present
1314  */
1315 static inline uint8_t*
1316 util_scan_entry_widebw(struct scan_cache_entry *scan_entry)
1317 {
1318 	return scan_entry->ie_list.widebw;
1319 }
1320 
1321 /**
1322  * util_scan_entry_secchanoff() - function to read secondary channel offset ie
1323  * @scan_entry: scan entry
1324  *
1325  * API, function to read secondary channel offset ie
1326  *
1327  * Return: secondary channel offset element or NULL if ie is not present
1328  */
1329 static inline uint8_t*
1330 util_scan_entry_secchanoff(struct scan_cache_entry *scan_entry)
1331 {
1332 	return scan_entry->ie_list.secchanoff;
1333 }
1334 
1335 /**
1336  * util_scan_entry_cswrp() - function to read channel switch wrapper ie
1337  * @scan_entry: scan entry
1338  *
1339  * API, function to read channel switch wrapper ie
1340  *
1341  * Return: channel switch wrapper element or NULL if ie is not present
1342  */
1343 static inline uint8_t*
1344 util_scan_entry_cswrp(struct scan_cache_entry *scan_entry)
1345 {
1346 	return scan_entry->ie_list.cswrp;
1347 }
1348 
1349 /**
1350  * util_scan_entry_omn() - function to read operating mode notification ie
1351  * @scan_entry: scan entry
1352  *
1353  * API, function to read operating mode notification
1354  *
1355  * Return: operating mode notification element or NULL if ie is not present
1356  */
1357 static inline uint8_t*
1358 util_scan_entry_omn(struct scan_cache_entry *scan_entry)
1359 {
1360 	return scan_entry->ie_list.opmode;
1361 }
1362 
1363 /**
1364  * util_scan_entry_extcaps() - function to read extcap ie
1365  * @scan_entry: scan entry
1366  *
1367  * API, function to read extcap ie
1368  *
1369  * Return: extcap element or NULL if ie is not present
1370  */
1371 static inline uint8_t*
1372 util_scan_entry_extcaps(struct scan_cache_entry *scan_entry)
1373 {
1374 	return scan_entry->ie_list.extcaps;
1375 }
1376 
1377 /**
1378  * util_scan_entry_get_extcap() - function to read extended capability field ie
1379  * @scan_entry: scan entry
1380  * @extcap_bit_field: extended capability bit field
1381  * @extcap_value: pointer to fill extended capability field value
1382  *
1383  * API, function to read extended capability field
1384  *
1385  * Return: QDF_STATUS_SUCCESS if extended capability field is found
1386  *         QDF_STATUS_E_NOMEM if extended capability field is not found
1387  */
1388 static inline QDF_STATUS
1389 util_scan_entry_get_extcap(struct scan_cache_entry *scan_entry,
1390 			   enum ext_cap_bit_field extcap_bit_field,
1391 			   uint8_t *extcap_value)
1392 {
1393 	struct wlan_ext_cap_ie *ext_cap =
1394 		(struct wlan_ext_cap_ie *)util_scan_entry_extcaps(scan_entry);
1395 
1396 	uint8_t ext_caps_byte = (extcap_bit_field >> 3);
1397 	uint8_t ext_caps_bit_pos = extcap_bit_field & 0x7;
1398 
1399 	*extcap_value = 0;
1400 
1401 	if (!ext_cap)
1402 		return QDF_STATUS_E_NULL_VALUE;
1403 
1404 	if (ext_cap->ext_cap_len < ext_caps_byte)
1405 		return QDF_STATUS_E_NULL_VALUE;
1406 
1407 	*extcap_value =
1408 		((ext_cap->ext_caps[ext_caps_byte] >> ext_caps_bit_pos) & 0x1);
1409 
1410 	return QDF_STATUS_SUCCESS;
1411 }
1412 
1413 /**
1414  * util_scan_entry_athcaps() - function to read ath caps vendor ie
1415  * @scan_entry: scan entry
1416  *
1417  * API, function to read ath caps vendor ie
1418  *
1419  * Return: ath caps vendorie or NULL if ie is not present
1420  */
1421 static inline struct mlme_info*
1422 util_scan_entry_mlme_info(struct scan_cache_entry *scan_entry)
1423 {
1424 	return &(scan_entry->mlme_info);
1425 }
1426 
1427 /**
1428 * util_scan_entry_mcst() - function to read mcst IE
1429 * @scan_entry:scan entry
1430 *
1431 * API, function to read mcst IE
1432 *
1433 * Return: mcst or NULL if ie is not present
1434 */
1435 static inline uint8_t*
1436 util_scan_entry_mcst(struct scan_cache_entry *scan_entry)
1437 {
1438 	return scan_entry->ie_list.mcst;
1439 }
1440 
1441 /**
1442  * util_scan_entry_hecap() - function to read he caps vendor ie
1443  * @scan_entry: scan entry
1444  *
1445  * API, function to read he caps vendor ie
1446  *
1447  * Return: he caps vendorie or NULL if ie is not present
1448  */
1449 static inline uint8_t*
1450 util_scan_entry_hecap(struct scan_cache_entry *scan_entry)
1451 {
1452 	return scan_entry->ie_list.hecap;
1453 }
1454 
1455 /**
1456  * util_scan_entry_he_6g_cap() - function to read  he 6GHz caps vendor ie
1457  * @scan_entry: scan entry
1458  *
1459  * API, function to read he 6GHz 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_he_6g_cap(struct scan_cache_entry *scan_entry)
1465 {
1466 	return scan_entry->ie_list.hecap_6g;
1467 }
1468 
1469 /**
1470  * util_scan_entry_heop() - function to read heop vendor ie
1471  * @scan_entry: scan entry
1472  *
1473  * API, function to read heop vendor ie
1474  *
1475  * Return, heop vendorie or NULL if ie is not present
1476  */
1477 static inline uint8_t*
1478 util_scan_entry_heop(struct scan_cache_entry *scan_entry)
1479 {
1480 	return scan_entry->ie_list.heop;
1481 }
1482 
1483 /**
1484  * util_scan_entry_muedca() - function to read MU-EDCA IE
1485  * @scan_entry: scan entry
1486  *
1487  * API, function to read MU-EDCA IE
1488  *
1489  * Return, MUEDCA IE or NULL if IE is not present
1490  */
1491 static inline uint8_t*
1492 util_scan_entry_muedca(struct scan_cache_entry *scan_entry)
1493 {
1494 	return scan_entry->ie_list.muedca;
1495 }
1496 
1497 /**
1498  * util_scan_entry_spatial_reuse_parameter() - function to read spatial reuse
1499  *                                             parameter ie
1500  * @scan_entry: scan entry
1501  *
1502  * API, function to read scan_entry reuse parameter ie
1503  *
1504  * Return, spatial reuse parameter ie or NULL if ie is not present
1505  */
1506 static inline uint8_t*
1507 util_scan_entry_spatial_reuse_parameter(struct scan_cache_entry *scan_entry)
1508 {
1509 	return scan_entry->ie_list.srp;
1510 }
1511 
1512 /**
1513  * util_scan_entry_fils_indication() - function to read FILS indication ie
1514  * @scan_entry: scan entry
1515  *
1516  * API, function to read FILS indication ie
1517  *
1518  * Return, FILS indication ie or NULL if ie is not present
1519  */
1520 static inline uint8_t*
1521 util_scan_entry_fils_indication(struct scan_cache_entry *scan_entry)
1522 {
1523 	return scan_entry->ie_list.fils_indication;
1524 }
1525 
1526 /**
1527  * util_get_last_scan_time() - function to get last scan time on this pdev
1528  * @vdev: vdev object
1529  *
1530  * API, function to read last scan time on this pdev
1531  *
1532  * Return: qdf_time_t
1533  */
1534 qdf_time_t
1535 util_get_last_scan_time(struct wlan_objmgr_vdev *vdev);
1536 
1537 /**
1538  * util_scan_entry_update_mlme_info() - function to update mlme info
1539  * @scan_entry: scan entry object
1540  *
1541  * API, function to update mlme info in scan DB
1542  *
1543  * Return: QDF_STATUS
1544  */
1545 QDF_STATUS
1546 util_scan_entry_update_mlme_info(struct wlan_objmgr_pdev *pdev,
1547 	struct scan_cache_entry *scan_entry);
1548 
1549 /**
1550  * util_scan_is_hidden_ssid() - function to check if ssid is hidden
1551  * @ssid: struct ie_ssid object
1552  *
1553  * API, function to check if ssid is hidden
1554  *
1555  * Return: true if ap is hidden, false otherwise
1556  */
1557 bool
1558 util_scan_is_hidden_ssid(struct ie_ssid *ssid);
1559 
1560 /**
1561  * util_scan_entry_is_hidden_ap() - function to check if ap is hidden
1562  * @scan_entry: scan entry
1563  *
1564  * API, function to check if ap is hidden
1565  *
1566  * Return: true if ap is hidden, false otherwise
1567  */
1568 static inline bool
1569 util_scan_entry_is_hidden_ap(struct scan_cache_entry *scan_entry)
1570 {
1571     return util_scan_is_hidden_ssid(
1572 			(struct ie_ssid *)scan_entry->ie_list.ssid);
1573 }
1574 
1575 /**
1576  * util_scan_entry_espinfo() - function to read ESP info
1577  * @scan_entry: scan entry
1578  *
1579  * API, function to read ESP info
1580  *
1581  * Return: erp info
1582  */
1583 static inline uint8_t *
1584 util_scan_entry_esp_info(struct scan_cache_entry *scan_entry)
1585 {
1586 	return scan_entry->ie_list.esp;
1587 }
1588 
1589 /**
1590  * util_scan_entry_mbo_oce() - function to read MBO/OCE ie
1591  * @scan_entry: scan entry
1592  *
1593  * API, function to read MBO/OCE ie
1594  *
1595  * Return: MBO/OCE ie
1596  */
1597 static inline uint8_t *
1598 util_scan_entry_mbo_oce(struct scan_cache_entry *scan_entry)
1599 {
1600 	return scan_entry->ie_list.mbo_oce;
1601 }
1602 
1603 /**
1604  * util_scan_scm_chan_to_band() - function to tell band for channel number
1605  * @chan: Channel number
1606  *
1607  * Return: Band information as per channel
1608  */
1609 enum wlan_band util_scan_scm_chan_to_band(uint32_t chan);
1610 
1611 /**
1612  * util_scan_scm_freq_to_band() - API to get band from frequency
1613  * @freq: Channel frequency
1614  *
1615  * Return: Band information as per frequency
1616  */
1617 enum wlan_band util_scan_scm_freq_to_band(uint16_t freq);
1618 
1619 /**
1620  * util_is_scan_completed() - function to get scan complete status
1621  * @event: scan event
1622  * @success: true if scan complete success, false otherwise
1623  *
1624  * API, function to get the scan result
1625  *
1626  * Return: true if scan complete, false otherwise
1627  */
1628 bool util_is_scan_completed(struct scan_event *event, bool *success);
1629 
1630 /**
1631  * util_scan_entry_extenderie() - function to read extender IE
1632  * @scan_entry: scan entry
1633  *
1634  * API, function to read extender IE
1635  *
1636  * Return: extenderie or NULL if ie is not present
1637  */
1638 static inline uint8_t*
1639 util_scan_entry_extenderie(struct scan_cache_entry *scan_entry)
1640 {
1641 	return scan_entry->ie_list.extender;
1642 }
1643 
1644 /**
1645  * util_scan_entry_mdie() - function to read Mobility Domain IE
1646  * @scan_entry: scan entry
1647  *
1648  * API, function to read Mobility Domain IE
1649  *
1650  * Return: MDIE or NULL if IE is not present
1651  */
1652 static inline uint8_t*
1653 util_scan_entry_mdie(struct scan_cache_entry *scan_entry)
1654 {
1655 	return scan_entry->ie_list.mdie;
1656 }
1657 
1658 /**
1659  * util_scan_is_null_ssid() - to check for NULL ssid
1660  * @ssid: ssid
1661  *
1662  * Return: true if NULL ssid else false
1663  */
1664 static inline bool util_scan_is_null_ssid(struct wlan_ssid *ssid)
1665 {
1666 	uint32_t ssid_length;
1667 	uint8_t *ssid_str;
1668 
1669 	if (ssid->length == 0)
1670 		return true;
1671 
1672 	/* Consider 0 or space for hidden SSID */
1673 	if (0 == ssid->ssid[0])
1674 		return true;
1675 
1676 	ssid_length = ssid->length;
1677 	ssid_str = ssid->ssid;
1678 
1679 	while (ssid_length) {
1680 		if (*ssid_str != ASCII_SPACE_CHARACTER &&
1681 		    *ssid_str)
1682 			break;
1683 		ssid_str++;
1684 		ssid_length--;
1685 	}
1686 
1687 	if (ssid_length == 0)
1688 		return true;
1689 
1690 	return false;
1691 }
1692 
1693 #endif
1694