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