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