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