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