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