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