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