1 /* 2 * Copyright (c) 2017-2021 The Linux Foundation. All rights reserved. 3 * Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved. 4 * 5 * Permission to use, copy, modify, and/or distribute this software for 6 * any purpose with or without fee is hereby granted, provided that the 7 * above copyright notice and this permission notice appear in all 8 * copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 11 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 12 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 13 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 14 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 15 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 16 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 17 * PERFORMANCE OF THIS SOFTWARE. 18 */ 19 20 /* 21 * DOC: Defines scan utility functions 22 */ 23 24 #include <wlan_cmn.h> 25 #include <wlan_scan_ucfg_api.h> 26 #include <wlan_scan_utils_api.h> 27 #include <../../core/src/wlan_scan_cache_db.h> 28 #include <../../core/src/wlan_scan_main.h> 29 #include <wlan_reg_services_api.h> 30 #if defined(WLAN_SAE_SINGLE_PMK) && defined(WLAN_FEATURE_ROAM_OFFLOAD) 31 #include <wlan_mlme_api.h> 32 #endif 33 #ifdef WLAN_FEATURE_11BE_MLO 34 #include <wlan_utility.h> 35 #include "wlan_mlo_mgr_public_structs.h" 36 #include <utils_mlo.h> 37 #endif 38 #include "wlan_psoc_mlme_api.h" 39 #include "reg_services_public_struct.h" 40 #ifdef WLAN_FEATURE_ACTION_OUI 41 #include <wlan_action_oui_main.h> 42 #include <wlan_action_oui_public_struct.h> 43 #endif 44 #include <wlan_crypto_global_api.h> 45 46 #define MAX_IE_LEN 1024 47 #define SHORT_SSID_LEN 4 48 #define NEIGHBOR_AP_LEN 1 49 #define BSS_PARAMS_LEN 1 50 51 const char* 52 util_scan_get_ev_type_name(enum scan_event_type type) 53 { 54 static const char * const event_name[] = { 55 [SCAN_EVENT_TYPE_STARTED] = "STARTED", 56 [SCAN_EVENT_TYPE_COMPLETED] = "COMPLETED", 57 [SCAN_EVENT_TYPE_BSS_CHANNEL] = "HOME_CHANNEL", 58 [SCAN_EVENT_TYPE_FOREIGN_CHANNEL] = "FOREIGN_CHANNEL", 59 [SCAN_EVENT_TYPE_DEQUEUED] = "DEQUEUED", 60 [SCAN_EVENT_TYPE_PREEMPTED] = "PREEMPTED", 61 [SCAN_EVENT_TYPE_START_FAILED] = "START_FAILED", 62 [SCAN_EVENT_TYPE_RESTARTED] = "RESTARTED", 63 [SCAN_EVENT_TYPE_FOREIGN_CHANNEL_EXIT] = "FOREIGN_CHANNEL_EXIT", 64 [SCAN_EVENT_TYPE_SUSPENDED] = "SUSPENDED", 65 [SCAN_EVENT_TYPE_RESUMED] = "RESUMED", 66 [SCAN_EVENT_TYPE_NLO_COMPLETE] = "NLO_COMPLETE", 67 [SCAN_EVENT_TYPE_NLO_MATCH] = "NLO_MATCH", 68 [SCAN_EVENT_TYPE_INVALID] = "INVALID", 69 [SCAN_EVENT_TYPE_GPIO_TIMEOUT] = "GPIO_TIMEOUT", 70 [SCAN_EVENT_TYPE_RADIO_MEASUREMENT_START] = 71 "RADIO_MEASUREMENT_START", 72 [SCAN_EVENT_TYPE_RADIO_MEASUREMENT_END] = 73 "RADIO_MEASUREMENT_END", 74 [SCAN_EVENT_TYPE_BSSID_MATCH] = "BSSID_MATCH", 75 [SCAN_EVENT_TYPE_FOREIGN_CHANNEL_GET_NF] = 76 "FOREIGN_CHANNEL_GET_NF", 77 }; 78 79 if (type >= SCAN_EVENT_TYPE_MAX) 80 return "UNKNOWN"; 81 82 return event_name[type]; 83 } 84 85 86 const char* 87 util_scan_get_ev_reason_name(enum scan_completion_reason reason) 88 { 89 static const char * const reason_name[] = { 90 [SCAN_REASON_NONE] = "NONE", 91 [SCAN_REASON_COMPLETED] = "COMPLETED", 92 [SCAN_REASON_CANCELLED] = "CANCELLED", 93 [SCAN_REASON_PREEMPTED] = "PREEMPTED", 94 [SCAN_REASON_TIMEDOUT] = "TIMEDOUT", 95 [SCAN_REASON_INTERNAL_FAILURE] = "INTERNAL_FAILURE", 96 [SCAN_REASON_SUSPENDED] = "SUSPENDED", 97 [SCAN_REASON_RUN_FAILED] = "RUN_FAILED", 98 [SCAN_REASON_TERMINATION_FUNCTION] = "TERMINATION_FUNCTION", 99 [SCAN_REASON_MAX_OFFCHAN_RETRIES] = "MAX_OFFCHAN_RETRIES", 100 [SCAN_REASON_DFS_VIOLATION] = "DFS_NOL_VIOLATION", 101 }; 102 103 if (reason >= SCAN_REASON_MAX) 104 return "UNKNOWN"; 105 106 return reason_name[reason]; 107 } 108 109 qdf_time_t 110 util_get_last_scan_time(struct wlan_objmgr_vdev *vdev) 111 { 112 uint8_t pdev_id; 113 struct wlan_scan_obj *scan_obj; 114 115 if (!vdev) { 116 scm_warn("null vdev"); 117 QDF_ASSERT(0); 118 return 0; 119 } 120 pdev_id = wlan_scan_vdev_get_pdev_id(vdev); 121 scan_obj = wlan_vdev_get_scan_obj(vdev); 122 123 if (scan_obj) 124 return scan_obj->pdev_info[pdev_id].last_scan_time; 125 else 126 return 0; 127 } 128 129 #ifdef WLAN_FEATURE_11BE_MLO 130 uint32_t util_scan_entry_t2lm_len(struct scan_cache_entry *scan_entry) 131 { 132 int i = 0; 133 uint32_t len = 0; 134 135 if (!scan_entry || !scan_entry->ie_list.t2lm[0]) 136 return 0; 137 138 for (i = 0; i < WLAN_MAX_T2LM_IE; i++) { 139 if (scan_entry->ie_list.t2lm[i]) 140 len += scan_entry->ie_list.t2lm[i][TAG_LEN_POS] + 141 sizeof(struct ie_header); 142 } 143 144 return len; 145 } 146 #endif 147 148 bool util_is_rsnxe_h2e_capable(const uint8_t *rsnxe) 149 { 150 const uint8_t *rsnxe_caps; 151 uint8_t cap_len; 152 153 if (!rsnxe) 154 return false; 155 156 rsnxe_caps = wlan_crypto_parse_rsnxe_ie(rsnxe, &cap_len); 157 if (!rsnxe_caps) 158 return false; 159 160 return *rsnxe_caps & WLAN_CRYPTO_RSNX_CAP_SAE_H2E; 161 } 162 163 bool util_scan_entry_sae_h2e_capable(struct scan_cache_entry *scan_entry) 164 { 165 const uint8_t *rsnxe; 166 167 /* If RSN caps are not there, then return false */ 168 if (!util_scan_entry_rsn(scan_entry)) 169 return false; 170 171 /* If not SAE AKM no need to check H2E capability */ 172 if (!WLAN_CRYPTO_IS_AKM_SAE(scan_entry->neg_sec_info.key_mgmt)) 173 return false; 174 175 rsnxe = util_scan_entry_rsnxe(scan_entry); 176 return util_is_rsnxe_h2e_capable(rsnxe); 177 } 178 179 enum wlan_band util_scan_scm_freq_to_band(uint16_t freq) 180 { 181 if (WLAN_REG_IS_24GHZ_CH_FREQ(freq)) 182 return WLAN_BAND_2_4_GHZ; 183 184 return WLAN_BAND_5_GHZ; 185 } 186 187 bool util_is_scan_entry_match( 188 struct scan_cache_entry *entry1, 189 struct scan_cache_entry *entry2) 190 { 191 192 if (entry1->cap_info.wlan_caps.ess != 193 entry2->cap_info.wlan_caps.ess) 194 return false; 195 196 if (entry1->cap_info.wlan_caps.ess && 197 !qdf_mem_cmp(entry1->bssid.bytes, 198 entry2->bssid.bytes, QDF_MAC_ADDR_SIZE)) { 199 /* Check for BSS */ 200 if (util_is_ssid_match(&entry1->ssid, &entry2->ssid) || 201 util_scan_is_null_ssid(&entry1->ssid) || 202 util_scan_is_null_ssid(&entry2->ssid)) 203 return true; 204 } else if (entry1->cap_info.wlan_caps.ibss && 205 (entry1->channel.chan_freq == 206 entry2->channel.chan_freq)) { 207 /* 208 * Same channel cannot have same SSID for 209 * different IBSS, so no need to check BSSID 210 */ 211 if (util_is_ssid_match( 212 &entry1->ssid, &entry2->ssid)) 213 return true; 214 } else if (!entry1->cap_info.wlan_caps.ibss && 215 !entry1->cap_info.wlan_caps.ess && 216 !qdf_mem_cmp(entry1->bssid.bytes, 217 entry2->bssid.bytes, QDF_MAC_ADDR_SIZE)) { 218 /* In case of P2P devices, ess and ibss will be set to zero */ 219 return true; 220 } 221 222 return false; 223 } 224 225 static bool util_is_pureg_rate(uint8_t *rates, uint8_t nrates) 226 { 227 static const uint8_t g_rates[] = {12, 18, 24, 36, 48, 72, 96, 108}; 228 bool pureg = false; 229 uint8_t i, j; 230 231 for (i = 0; i < nrates; i++) { 232 for (j = 0; j < QDF_ARRAY_SIZE(g_rates); j++) { 233 if (WLAN_RV(rates[i]) == g_rates[j]) { 234 pureg = true; 235 break; 236 } 237 } 238 if (pureg) 239 break; 240 } 241 242 return pureg; 243 } 244 245 #ifdef WLAN_FEATURE_11BE 246 static enum wlan_phymode 247 util_scan_get_phymode_11be(struct wlan_objmgr_pdev *pdev, 248 struct scan_cache_entry *scan_params, 249 enum wlan_phymode phymode, 250 uint8_t band_mask) 251 { 252 struct wlan_ie_ehtops *eht_ops; 253 uint8_t width; 254 255 eht_ops = (struct wlan_ie_ehtops *)util_scan_entry_ehtop(scan_params); 256 if (!util_scan_entry_ehtcap(scan_params) || !eht_ops) 257 return phymode; 258 259 if (QDF_GET_BITS(eht_ops->ehtop_param, 260 EHTOP_INFO_PRESENT_IDX, EHTOP_INFO_PRESENT_BITS)) { 261 width = QDF_GET_BITS(eht_ops->control, 262 EHTOP_INFO_CHAN_WIDTH_IDX, 263 EHTOP_INFO_CHAN_WIDTH_BITS); 264 switch (width) { 265 case WLAN_EHT_CHWIDTH_20: 266 phymode = WLAN_PHYMODE_11BEA_EHT20; 267 break; 268 case WLAN_EHT_CHWIDTH_40: 269 phymode = WLAN_PHYMODE_11BEA_EHT40; 270 break; 271 case WLAN_EHT_CHWIDTH_80: 272 phymode = WLAN_PHYMODE_11BEA_EHT80; 273 break; 274 case WLAN_EHT_CHWIDTH_160: 275 phymode = WLAN_PHYMODE_11BEA_EHT160; 276 break; 277 case WLAN_EHT_CHWIDTH_320: 278 phymode = WLAN_PHYMODE_11BEA_EHT320; 279 break; 280 default: 281 scm_debug("Invalid eht_ops width: %d", width); 282 phymode = WLAN_PHYMODE_11BEA_EHT20; 283 break; 284 } 285 } else { 286 switch (phymode) { 287 case WLAN_PHYMODE_11AXA_HE20: 288 phymode = WLAN_PHYMODE_11BEA_EHT20; 289 break; 290 case WLAN_PHYMODE_11AXG_HE20: 291 phymode = WLAN_PHYMODE_11BEG_EHT20; 292 break; 293 case WLAN_PHYMODE_11AXA_HE40: 294 phymode = WLAN_PHYMODE_11BEA_EHT40; 295 break; 296 case WLAN_PHYMODE_11AXG_HE40: 297 phymode = WLAN_PHYMODE_11BEG_EHT40; 298 break; 299 case WLAN_PHYMODE_11AXA_HE80: 300 phymode = WLAN_PHYMODE_11BEA_EHT80; 301 break; 302 case WLAN_PHYMODE_11AXA_HE160: 303 phymode = WLAN_PHYMODE_11BEA_EHT160; 304 break; 305 default: 306 break; 307 } 308 } 309 310 if (QDF_GET_BITS(eht_ops->ehtop_param, 311 EHTOP_INFO_PRESENT_IDX, EHTOP_INFO_PRESENT_BITS)) { 312 scan_params->channel.cfreq0 = 313 wlan_reg_chan_band_to_freq(pdev, 314 eht_ops->ccfs0, 315 band_mask); 316 scan_params->channel.cfreq1 = 317 wlan_reg_chan_band_to_freq(pdev, 318 eht_ops->ccfs1, 319 band_mask); 320 } 321 322 if (QDF_GET_BITS(eht_ops->ehtop_param, 323 EHTOP_PARAM_DISABLED_SC_BITMAP_PRESENT_IDX, 324 EHTOP_PARAM_DISABLED_SC_BITMAP_PRESENT_BITS)) { 325 scan_params->channel.puncture_bitmap = 326 QDF_GET_BITS(eht_ops->disabled_sub_chan_bitmap[0], 327 0, 8); 328 scan_params->channel.puncture_bitmap |= 329 QDF_GET_BITS(eht_ops->disabled_sub_chan_bitmap[1], 330 0, 8) << 8; 331 } else { 332 scan_params->channel.puncture_bitmap = 0; 333 } 334 335 return phymode; 336 } 337 #else 338 static enum wlan_phymode 339 util_scan_get_phymode_11be(struct wlan_objmgr_pdev *pdev, 340 struct scan_cache_entry *scan_params, 341 enum wlan_phymode phymode, 342 uint8_t band_mask) 343 { 344 return phymode; 345 } 346 #endif 347 348 #ifdef CONFIG_BAND_6GHZ 349 static struct he_oper_6g_param *util_scan_get_he_6g_params(uint8_t *he_ops) 350 { 351 uint8_t len; 352 uint32_t he_oper_params; 353 354 if (!he_ops) 355 return NULL; 356 357 len = he_ops[1]; 358 he_ops += sizeof(struct ie_header); 359 360 if (len < WLAN_HEOP_FIXED_PARAM_LENGTH) 361 return NULL; 362 363 /* element id extension */ 364 he_ops++; 365 len--; 366 367 he_oper_params = LE_READ_4(he_ops); 368 if (!(he_oper_params & WLAN_HEOP_6GHZ_INFO_PRESENT_MASK)) 369 return NULL; 370 371 /* fixed params - element id extension */ 372 he_ops += WLAN_HEOP_FIXED_PARAM_LENGTH - 1; 373 len -= WLAN_HEOP_FIXED_PARAM_LENGTH - 1; 374 375 if (!len) 376 return NULL; 377 378 /* vht oper params */ 379 if (he_oper_params & WLAN_HEOP_VHTOP_PRESENT_MASK) { 380 if (len < WLAN_HEOP_VHTOP_LENGTH) 381 return NULL; 382 he_ops += WLAN_HEOP_VHTOP_LENGTH; 383 len -= WLAN_HEOP_VHTOP_LENGTH; 384 } 385 386 if (!len) 387 return NULL; 388 389 if (he_oper_params & WLAN_HEOP_CO_LOCATED_BSS_MASK) { 390 he_ops += WLAN_HEOP_CO_LOCATED_BSS_LENGTH; 391 len -= WLAN_HEOP_CO_LOCATED_BSS_LENGTH; 392 } 393 394 if (len < sizeof(struct he_oper_6g_param)) 395 return NULL; 396 397 return (struct he_oper_6g_param *)he_ops; 398 } 399 400 #ifdef WLAN_FEATURE_11BE 401 /* 402 * util_scan_is_out_of_band_leak_eht() - Check if eht beacon out of BSS BW 403 * @pdev: pointer to pdev. 404 * @scan_params: scan entry generated by beacon/probe rsp 405 * @band_mask: band mask of frequency beacon/probe rsp received 406 * @current_freq: frequency beacon/probe rsp received 407 * 408 * 1. If BSS BW <= 80MHz 409 * If Absolute value of (Current Channel Channel Center Frequency Segment 0) <= 410 * BSS BW/2 then eht beacon in BSS operating BW 411 * else eht beacon out of BSS operating BW 412 * 413 * 2. If BSS BW > 80MHz 414 * If Absolute value of (Current Channel Channel Center Frequency Segment 1) <= 415 * BSS BW/2 then eht beacon in BSS operating BW 416 * else eht beacon out of BSS operating BW 417 * 418 * Return: bool, whether eht beacon out of BSS operating BW 419 */ 420 static bool 421 util_scan_is_out_of_band_leak_eht(struct wlan_objmgr_pdev *pdev, 422 struct scan_cache_entry *scan_params, 423 uint8_t band_mask, 424 qdf_freq_t current_freq) 425 { 426 struct wlan_ie_ehtops *eht_ops; 427 uint8_t ch_width; 428 uint32_t bw; 429 uint32_t freq_diff; 430 qdf_freq_t freq_seg0; 431 qdf_freq_t freq_seg1; 432 433 eht_ops = (struct wlan_ie_ehtops *)util_scan_entry_ehtop(scan_params); 434 if (!util_scan_entry_ehtcap(scan_params) || !eht_ops) 435 return false; 436 437 if (!QDF_GET_BITS(eht_ops->ehtop_param, 438 EHTOP_INFO_PRESENT_IDX, EHTOP_INFO_PRESENT_BITS)) 439 return false; 440 441 ch_width = QDF_GET_BITS(eht_ops->control, 442 EHTOP_INFO_CHAN_WIDTH_IDX, 443 EHTOP_INFO_CHAN_WIDTH_BITS); 444 freq_seg0 = wlan_reg_chan_band_to_freq(pdev, eht_ops->ccfs0, 445 band_mask); 446 freq_seg1 = wlan_reg_chan_band_to_freq(pdev, eht_ops->ccfs1, 447 band_mask); 448 if (ch_width == WLAN_EHT_CHWIDTH_320) 449 bw = BW_320_MHZ; 450 else if (ch_width == WLAN_EHT_CHWIDTH_160) 451 bw = BW_160_MHZ; 452 else if (ch_width == WLAN_EHT_CHWIDTH_80) 453 bw = BW_80_MHZ; 454 else if (ch_width == WLAN_EHT_CHWIDTH_40) 455 bw = BW_40_MHZ; 456 else if (ch_width == WLAN_EHT_CHWIDTH_20) 457 bw = BW_20_MHZ; 458 else 459 bw = BW_20_MHZ; 460 461 if (bw <= BW_80_MHZ) 462 freq_diff = abs(freq_seg0 - current_freq); 463 else 464 freq_diff = abs(freq_seg1 - current_freq); 465 if (freq_diff <= bw / 2) 466 return false; 467 468 scm_debug("Leaked freq:%u ch width:%u freq0:%u freq1:%u", 469 current_freq, bw, freq_seg0, freq_seg1); 470 return true; 471 } 472 #else 473 static bool 474 util_scan_is_out_of_band_leak_eht(struct wlan_objmgr_pdev *pdev, 475 struct scan_cache_entry *scan_params, 476 uint8_t band_mask, 477 qdf_freq_t current_freq) 478 { 479 return false; 480 } 481 #endif 482 483 /* 484 * util_scan_is_out_of_band_leak_he() - Check if HE beacon out of BSS BW 485 * @pdev: pointer to pdev. 486 * @he_6g_params: HE 6 GHz params 487 * @band_mask: band mask of frequency beacon/probe rsp received 488 * @current_freq: frequency beacon/probe rsp received 489 * 490 * 1. If BSS BW <= 80MHz 491 * If Absolute value of (Current Channel Channel Center Frequency Segment 0) <= 492 * BSS BW/2 then HE beacon in BSS operating BW 493 * 494 * 2. If BSS BW is 160MHz 495 * If Absolute value of (Current Channel Channel Center Frequency Segment 1) <= 496 * BSS BW/2 then HE beacon in BSS operating BW 497 * 498 * 3. If BSS BW is 80+80MHz 499 * If absolute value of (Current Channel - Channel Center Frequency Segment 0) 500 * <= 40 or absolute value of (Current Channel - Channel Center Frequency 501 * Segment 1) <= 40, then HE beacon in BSS operating BW 502 * 503 * Return: bool, whether HE beacon out of BSS operating BW 504 */ 505 static bool 506 util_scan_is_out_of_band_leak_he(struct wlan_objmgr_pdev *pdev, 507 struct he_oper_6g_param *he_6g_params, 508 uint8_t band_mask, 509 qdf_freq_t current_freq) 510 { 511 uint8_t ch_width; 512 uint32_t bw; 513 uint32_t freq_diff; 514 qdf_freq_t freq_seg0; 515 qdf_freq_t freq_seg1; 516 517 ch_width = he_6g_params->width; 518 freq_seg0 = wlan_reg_chan_band_to_freq(pdev, 519 he_6g_params->chan_freq_seg0, 520 band_mask); 521 freq_seg1 = wlan_reg_chan_band_to_freq(pdev, 522 he_6g_params->chan_freq_seg1, 523 band_mask); 524 if (ch_width == WLAN_HE_6GHZ_CHWIDTH_160_80_80) 525 bw = BW_160_MHZ; 526 else if (ch_width == WLAN_HE_6GHZ_CHWIDTH_80) 527 bw = BW_80_MHZ; 528 else if (ch_width == WLAN_HE_6GHZ_CHWIDTH_40) 529 bw = BW_40_MHZ; 530 else if (ch_width == WLAN_HE_6GHZ_CHWIDTH_20) 531 bw = BW_20_MHZ; 532 else 533 bw = BW_20_MHZ; 534 535 if (bw <= BW_80_MHZ) { 536 freq_diff = abs(freq_seg0 - current_freq); 537 if (freq_diff <= bw / 2) 538 return false; 539 } else if (WLAN_IS_HE160(he_6g_params)) { 540 freq_diff = abs(freq_seg1 - current_freq); 541 if (freq_diff <= bw / 2) 542 return false; 543 } else if (WLAN_IS_HE80_80(he_6g_params)) { 544 freq_diff = abs(freq_seg0 - current_freq); 545 if (freq_diff <= BW_40_MHZ) 546 return false; 547 freq_diff = abs(freq_seg1 - current_freq); 548 if (freq_diff <= BW_40_MHZ) 549 return false; 550 } 551 552 scm_debug("Leaked freq:%u ch width:%u freq0:%u freq1:%u", 553 current_freq, bw, freq_seg0, freq_seg1); 554 555 return true; 556 } 557 558 /* 559 * util_scan_get_chan_from_he_6g_params() - Get chan info from 6 GHz param 560 * @pdev: pointer to pdev. 561 * @scan_params: scan entry generated by beacon/probe rsp 562 * @chan_freq: output parameter, primary freq from 6 GHz he params 563 * @is_6g_dup_bcon: output parameter, bool, if false, invalid 6g duplicated 564 beacon out of BSS operating BW or not duplicated beacon, can drop if 565 channel mismatch 566 * @band_mask: band mask of frequency beacon/probe rsp received 567 * @current_freq: frequency beacon/probe rsp received 568 * 569 * Return: QDF_STATUS 570 */ 571 static QDF_STATUS 572 util_scan_get_chan_from_he_6g_params(struct wlan_objmgr_pdev *pdev, 573 struct scan_cache_entry *scan_params, 574 qdf_freq_t *chan_freq, 575 bool *is_6g_dup_bcon, uint8_t band_mask, 576 qdf_freq_t current_freq) 577 { 578 struct he_oper_6g_param *he_6g_params; 579 uint8_t *he_ops; 580 struct wlan_scan_obj *scan_obj; 581 struct wlan_objmgr_psoc *psoc; 582 bool is_out_of_band_leak = true; 583 584 psoc = wlan_pdev_get_psoc(pdev); 585 if (!psoc) { 586 scm_err("psoc is NULL"); 587 return QDF_STATUS_E_INVAL; 588 } 589 590 scan_obj = wlan_psoc_get_scan_obj(psoc); 591 if (!scan_obj) { 592 scm_err("scan_obj is NULL"); 593 return QDF_STATUS_E_INVAL; 594 } 595 596 *is_6g_dup_bcon = false; 597 598 he_ops = util_scan_entry_heop(scan_params); 599 if (!util_scan_entry_hecap(scan_params) || !he_ops) 600 return QDF_STATUS_SUCCESS; 601 602 he_6g_params = util_scan_get_he_6g_params(he_ops); 603 if (!he_6g_params) 604 return QDF_STATUS_SUCCESS; 605 606 *chan_freq = wlan_reg_chan_band_to_freq(pdev, 607 he_6g_params->primary_channel, 608 band_mask); 609 if (scan_obj->drop_bcn_on_invalid_freq && 610 !wlan_reg_is_freq_enabled(pdev, *chan_freq, REG_BEST_PWR_MODE)) { 611 scm_debug_rl(QDF_MAC_ADDR_FMT": Drop as invalid channel %d freq %d in HE 6Ghz params", 612 QDF_MAC_ADDR_REF(scan_params->bssid.bytes), 613 he_6g_params->primary_channel, *chan_freq); 614 return QDF_STATUS_E_INVAL; 615 } 616 617 if (!he_6g_params->duplicate_beacon) { 618 *is_6g_dup_bcon = false; 619 return QDF_STATUS_SUCCESS; 620 } 621 is_out_of_band_leak = 622 util_scan_is_out_of_band_leak_eht(pdev, scan_params, band_mask, 623 current_freq); 624 if (is_out_of_band_leak) { 625 *is_6g_dup_bcon = false; 626 return QDF_STATUS_SUCCESS; 627 } 628 is_out_of_band_leak = 629 util_scan_is_out_of_band_leak_he(pdev, he_6g_params, band_mask, 630 current_freq); 631 if (is_out_of_band_leak) { 632 *is_6g_dup_bcon = false; 633 return QDF_STATUS_SUCCESS; 634 } 635 636 *is_6g_dup_bcon = true; 637 638 return QDF_STATUS_SUCCESS; 639 } 640 641 static enum wlan_phymode 642 util_scan_get_phymode_6g(struct wlan_objmgr_pdev *pdev, 643 struct scan_cache_entry *scan_params) 644 { 645 struct he_oper_6g_param *he_6g_params; 646 enum wlan_phymode phymode = WLAN_PHYMODE_11AXA_HE20; 647 uint8_t *he_ops; 648 uint8_t band_mask = BIT(REG_BAND_6G); 649 650 he_ops = util_scan_entry_heop(scan_params); 651 if (!util_scan_entry_hecap(scan_params) || !he_ops) 652 return phymode; 653 654 he_6g_params = util_scan_get_he_6g_params(he_ops); 655 if (!he_6g_params) 656 return phymode; 657 658 switch (he_6g_params->width) { 659 case WLAN_HE_6GHZ_CHWIDTH_20: 660 phymode = WLAN_PHYMODE_11AXA_HE20; 661 break; 662 case WLAN_HE_6GHZ_CHWIDTH_40: 663 phymode = WLAN_PHYMODE_11AXA_HE40; 664 break; 665 case WLAN_HE_6GHZ_CHWIDTH_80: 666 phymode = WLAN_PHYMODE_11AXA_HE80; 667 break; 668 case WLAN_HE_6GHZ_CHWIDTH_160_80_80: 669 if (WLAN_IS_HE80_80(he_6g_params)) 670 phymode = WLAN_PHYMODE_11AXA_HE80_80; 671 else if (WLAN_IS_HE160(he_6g_params)) 672 phymode = WLAN_PHYMODE_11AXA_HE160; 673 else 674 phymode = WLAN_PHYMODE_11AXA_HE80; 675 break; 676 default: 677 scm_err("Invalid he_6g_params width: %d", he_6g_params->width); 678 phymode = WLAN_PHYMODE_11AXA_HE20; 679 break; 680 } 681 682 if (he_6g_params->chan_freq_seg0) 683 scan_params->channel.cfreq0 = 684 wlan_reg_chan_band_to_freq(pdev, 685 he_6g_params->chan_freq_seg0, 686 band_mask); 687 if (he_6g_params->chan_freq_seg1) 688 scan_params->channel.cfreq1 = 689 wlan_reg_chan_band_to_freq(pdev, 690 he_6g_params->chan_freq_seg1, 691 band_mask); 692 693 phymode = util_scan_get_phymode_11be(pdev, scan_params, 694 phymode, band_mask); 695 696 return phymode; 697 } 698 699 uint8_t 700 util_scan_get_6g_oper_channel(uint8_t *he_op_ie) 701 { 702 struct he_oper_6g_param *he_6g_params; 703 704 he_6g_params = util_scan_get_he_6g_params(he_op_ie); 705 if (!he_6g_params) 706 return 0; 707 708 return he_6g_params->primary_channel; 709 } 710 711 #else 712 static QDF_STATUS 713 util_scan_get_chan_from_he_6g_params(struct wlan_objmgr_pdev *pdev, 714 struct scan_cache_entry *scan_params, 715 qdf_freq_t *chan_freq, 716 bool *is_6g_dup_bcon, 717 uint8_t band_mask, 718 qdf_freq_t current_freq) 719 { 720 return QDF_STATUS_SUCCESS; 721 } 722 static inline enum wlan_phymode 723 util_scan_get_phymode_6g(struct wlan_objmgr_pdev *pdev, 724 struct scan_cache_entry *scan_params) 725 { 726 return WLAN_PHYMODE_AUTO; 727 } 728 #endif 729 730 static inline 731 uint32_t util_scan_ccfs0_from_htinfo(struct wlan_ie_htinfo_cmn *htinfo, 732 uint32_t primary_chan_freq) 733 { 734 if (htinfo->hi_extchoff == WLAN_HTINFO_EXTOFFSET_ABOVE) 735 return primary_chan_freq + WLAN_CHAN_SPACING_20MHZ / 2; 736 else if (htinfo->hi_extchoff == WLAN_HTINFO_EXTOFFSET_BELOW) 737 return primary_chan_freq - WLAN_CHAN_SPACING_20MHZ / 2; 738 739 return 0; 740 } 741 742 static enum wlan_phymode 743 util_scan_get_phymode_5g(struct wlan_objmgr_pdev *pdev, 744 struct scan_cache_entry *scan_params) 745 { 746 enum wlan_phymode phymode = WLAN_PHYMODE_AUTO; 747 uint16_t ht_cap = 0; 748 struct htcap_cmn_ie *htcap; 749 struct wlan_ie_htinfo_cmn *htinfo; 750 struct wlan_ie_vhtop *vhtop; 751 uint8_t band_mask = BIT(REG_BAND_5G); 752 753 htcap = (struct htcap_cmn_ie *) 754 util_scan_entry_htcap(scan_params); 755 htinfo = (struct wlan_ie_htinfo_cmn *) 756 util_scan_entry_htinfo(scan_params); 757 vhtop = (struct wlan_ie_vhtop *) 758 util_scan_entry_vhtop(scan_params); 759 760 if (!(htcap && htinfo)) 761 return WLAN_PHYMODE_11A; 762 763 if (htcap) 764 ht_cap = le16toh(htcap->hc_cap); 765 766 if ((ht_cap & WLAN_HTCAP_C_CHWIDTH40) && 767 (htinfo->hi_extchoff == WLAN_HTINFO_EXTOFFSET_ABOVE || 768 htinfo->hi_extchoff == WLAN_HTINFO_EXTOFFSET_BELOW)) 769 phymode = WLAN_PHYMODE_11NA_HT40; 770 else 771 phymode = WLAN_PHYMODE_11NA_HT20; 772 773 scan_params->channel.cfreq0 = 774 util_scan_ccfs0_from_htinfo(htinfo, 775 scan_params->channel.chan_freq); 776 777 if (util_scan_entry_vhtcap(scan_params) && vhtop) { 778 switch (vhtop->vht_op_chwidth) { 779 case WLAN_VHTOP_CHWIDTH_2040: 780 if (phymode == WLAN_PHYMODE_11NA_HT40) 781 phymode = WLAN_PHYMODE_11AC_VHT40; 782 else 783 phymode = WLAN_PHYMODE_11AC_VHT20; 784 break; 785 case WLAN_VHTOP_CHWIDTH_80: 786 if (WLAN_IS_REVSIG_VHT80_80(vhtop)) 787 phymode = WLAN_PHYMODE_11AC_VHT80_80; 788 else if (WLAN_IS_REVSIG_VHT160(vhtop)) 789 phymode = WLAN_PHYMODE_11AC_VHT160; 790 else 791 phymode = WLAN_PHYMODE_11AC_VHT80; 792 break; 793 case WLAN_VHTOP_CHWIDTH_160: 794 phymode = WLAN_PHYMODE_11AC_VHT160; 795 break; 796 case WLAN_VHTOP_CHWIDTH_80_80: 797 phymode = WLAN_PHYMODE_11AC_VHT80_80; 798 break; 799 default: 800 scm_debug("bad channel: %d", 801 vhtop->vht_op_chwidth); 802 phymode = WLAN_PHYMODE_11AC_VHT20; 803 break; 804 } 805 if (vhtop->vht_op_ch_freq_seg1) 806 scan_params->channel.cfreq0 = 807 wlan_reg_chan_band_to_freq(pdev, 808 vhtop->vht_op_ch_freq_seg1, 809 band_mask); 810 if (vhtop->vht_op_ch_freq_seg2) 811 scan_params->channel.cfreq1 = 812 wlan_reg_chan_band_to_freq(pdev, 813 vhtop->vht_op_ch_freq_seg2, 814 band_mask); 815 } 816 817 if (!util_scan_entry_hecap(scan_params)) 818 return phymode; 819 820 /* for 5Ghz Check for HE, only if VHT cap and HE cap are present */ 821 if (!IS_WLAN_PHYMODE_VHT(phymode)) 822 return phymode; 823 824 switch (phymode) { 825 case WLAN_PHYMODE_11AC_VHT20: 826 phymode = WLAN_PHYMODE_11AXA_HE20; 827 break; 828 case WLAN_PHYMODE_11AC_VHT40: 829 phymode = WLAN_PHYMODE_11AXA_HE40; 830 break; 831 case WLAN_PHYMODE_11AC_VHT80: 832 phymode = WLAN_PHYMODE_11AXA_HE80; 833 break; 834 case WLAN_PHYMODE_11AC_VHT160: 835 phymode = WLAN_PHYMODE_11AXA_HE160; 836 break; 837 case WLAN_PHYMODE_11AC_VHT80_80: 838 phymode = WLAN_PHYMODE_11AXA_HE80_80; 839 break; 840 default: 841 phymode = WLAN_PHYMODE_11AXA_HE20; 842 break; 843 } 844 845 phymode = util_scan_get_phymode_11be(pdev, scan_params, 846 phymode, band_mask); 847 848 return phymode; 849 } 850 851 #ifdef WLAN_FEATURE_11BE 852 static enum wlan_phymode 853 util_scan_get_phymode_2g_11be(struct scan_cache_entry *scan_params, 854 enum wlan_phymode phymode) 855 { 856 if (!util_scan_entry_ehtcap(scan_params)) 857 return phymode; 858 859 if (phymode == WLAN_PHYMODE_11AXG_HE40PLUS) 860 phymode = WLAN_PHYMODE_11BEG_EHT40PLUS; 861 else if (phymode == WLAN_PHYMODE_11AXG_HE40MINUS) 862 phymode = WLAN_PHYMODE_11BEG_EHT40MINUS; 863 else 864 phymode = WLAN_PHYMODE_11BEG_EHT20; 865 866 return phymode; 867 } 868 #else 869 static enum wlan_phymode 870 util_scan_get_phymode_2g_11be(struct scan_cache_entry *scan_params, 871 enum wlan_phymode phymode) 872 { 873 return phymode; 874 } 875 #endif 876 877 static enum wlan_phymode 878 util_scan_get_phymode_2g(struct scan_cache_entry *scan_params) 879 { 880 enum wlan_phymode phymode = WLAN_PHYMODE_AUTO; 881 uint16_t ht_cap = 0; 882 struct htcap_cmn_ie *htcap; 883 struct wlan_ie_htinfo_cmn *htinfo; 884 struct wlan_ie_vhtop *vhtop; 885 886 htcap = (struct htcap_cmn_ie *) 887 util_scan_entry_htcap(scan_params); 888 htinfo = (struct wlan_ie_htinfo_cmn *) 889 util_scan_entry_htinfo(scan_params); 890 vhtop = (struct wlan_ie_vhtop *) 891 util_scan_entry_vhtop(scan_params); 892 893 if (htcap) 894 ht_cap = le16toh(htcap->hc_cap); 895 896 if (htcap && htinfo) { 897 if ((ht_cap & WLAN_HTCAP_C_CHWIDTH40) && 898 (htinfo->hi_extchoff == WLAN_HTINFO_EXTOFFSET_ABOVE)) 899 phymode = WLAN_PHYMODE_11NG_HT40PLUS; 900 else if ((ht_cap & WLAN_HTCAP_C_CHWIDTH40) && 901 (htinfo->hi_extchoff == WLAN_HTINFO_EXTOFFSET_BELOW)) 902 phymode = WLAN_PHYMODE_11NG_HT40MINUS; 903 else 904 phymode = WLAN_PHYMODE_11NG_HT20; 905 } else if (util_scan_entry_xrates(scan_params)) { 906 /* only 11G stations will have more than 8 rates */ 907 phymode = WLAN_PHYMODE_11G; 908 } else { 909 /* Some mischievous g-only APs do not set extended rates */ 910 if (util_scan_entry_rates(scan_params)) { 911 if (util_is_pureg_rate(&scan_params->ie_list.rates[2], 912 scan_params->ie_list.rates[1])) 913 phymode = WLAN_PHYMODE_11G; 914 else 915 phymode = WLAN_PHYMODE_11B; 916 } else { 917 phymode = WLAN_PHYMODE_11B; 918 } 919 } 920 921 /* Check for VHT only if HT cap is present */ 922 if (!IS_WLAN_PHYMODE_HT(phymode)) 923 return phymode; 924 925 scan_params->channel.cfreq0 = 926 util_scan_ccfs0_from_htinfo(htinfo, 927 scan_params->channel.chan_freq); 928 929 if (util_scan_entry_vhtcap(scan_params) && vhtop) { 930 switch (vhtop->vht_op_chwidth) { 931 case WLAN_VHTOP_CHWIDTH_2040: 932 if (phymode == WLAN_PHYMODE_11NG_HT40PLUS) 933 phymode = WLAN_PHYMODE_11AC_VHT40PLUS_2G; 934 else if (phymode == WLAN_PHYMODE_11NG_HT40MINUS) 935 phymode = WLAN_PHYMODE_11AC_VHT40MINUS_2G; 936 else 937 phymode = WLAN_PHYMODE_11AC_VHT20_2G; 938 939 break; 940 default: 941 scm_info("bad vht_op_chwidth: %d", 942 vhtop->vht_op_chwidth); 943 phymode = WLAN_PHYMODE_11AC_VHT20_2G; 944 break; 945 } 946 } 947 948 if (!util_scan_entry_hecap(scan_params)) 949 return phymode; 950 951 if (phymode == WLAN_PHYMODE_11AC_VHT40PLUS_2G || 952 phymode == WLAN_PHYMODE_11NG_HT40PLUS) 953 phymode = WLAN_PHYMODE_11AXG_HE40PLUS; 954 else if (phymode == WLAN_PHYMODE_11AC_VHT40MINUS_2G || 955 phymode == WLAN_PHYMODE_11NG_HT40MINUS) 956 phymode = WLAN_PHYMODE_11AXG_HE40MINUS; 957 else 958 phymode = WLAN_PHYMODE_11AXG_HE20; 959 960 phymode = util_scan_get_phymode_2g_11be(scan_params, phymode); 961 962 return phymode; 963 } 964 965 static enum wlan_phymode 966 util_scan_get_phymode(struct wlan_objmgr_pdev *pdev, 967 struct scan_cache_entry *scan_params) 968 { 969 if (WLAN_REG_IS_24GHZ_CH_FREQ(scan_params->channel.chan_freq)) 970 return util_scan_get_phymode_2g(scan_params); 971 else if (WLAN_REG_IS_6GHZ_CHAN_FREQ(scan_params->channel.chan_freq)) 972 return util_scan_get_phymode_6g(pdev, scan_params); 973 else 974 return util_scan_get_phymode_5g(pdev, scan_params); 975 } 976 977 static QDF_STATUS 978 util_scan_parse_chan_switch_wrapper_ie(struct scan_cache_entry *scan_params, 979 struct ie_header *sub_ie, qdf_size_t sub_ie_len) 980 { 981 /* Walk through to check nothing is malformed */ 982 while (sub_ie_len >= sizeof(struct ie_header)) { 983 /* At least one more header is present */ 984 sub_ie_len -= sizeof(struct ie_header); 985 986 if (sub_ie->ie_len == 0) { 987 sub_ie += 1; 988 continue; 989 } 990 if (sub_ie_len < sub_ie->ie_len) { 991 scm_debug_rl(QDF_MAC_ADDR_FMT": Incomplete corrupted IE:%x", 992 QDF_MAC_ADDR_REF(scan_params->bssid.bytes), 993 WLAN_ELEMID_CHAN_SWITCH_WRAP); 994 return QDF_STATUS_E_INVAL; 995 } 996 switch (sub_ie->ie_id) { 997 case WLAN_ELEMID_COUNTRY: 998 if (sub_ie->ie_len < WLAN_COUNTRY_IE_MIN_LEN) 999 return QDF_STATUS_E_INVAL; 1000 scan_params->ie_list.country = (uint8_t *)sub_ie; 1001 break; 1002 case WLAN_ELEMID_WIDE_BAND_CHAN_SWITCH: 1003 if (sub_ie->ie_len < WLAN_WIDE_BW_CHAN_SWITCH_IE_LEN) 1004 return QDF_STATUS_E_INVAL; 1005 scan_params->ie_list.widebw = (uint8_t *)sub_ie; 1006 break; 1007 case WLAN_ELEMID_VHT_TX_PWR_ENVLP: 1008 if (sub_ie->ie_len > WLAN_TPE_IE_MAX_LEN) 1009 return QDF_STATUS_E_INVAL; 1010 scan_params->ie_list.txpwrenvlp = (uint8_t *)sub_ie; 1011 break; 1012 #ifdef WLAN_FEATURE_11BE 1013 case WLAN_EXTN_ELEMID_BW_IND: 1014 if (sub_ie->ie_len > WLAN_BW_IND_IE_MAX_LEN) 1015 return QDF_STATUS_E_INVAL; 1016 scan_params->ie_list.bw_ind = (uint8_t *)sub_ie; 1017 break; 1018 #endif 1019 } 1020 /* Consume sub info element */ 1021 sub_ie_len -= sub_ie->ie_len; 1022 /* go to next Sub IE */ 1023 sub_ie = (struct ie_header *) 1024 (((uint8_t *) sub_ie) + 1025 sizeof(struct ie_header) + sub_ie->ie_len); 1026 } 1027 1028 return QDF_STATUS_SUCCESS; 1029 } 1030 1031 bool 1032 util_scan_is_hidden_ssid(struct ie_ssid *ssid) 1033 { 1034 uint8_t i; 1035 1036 /* 1037 * We flag this as Hidden SSID if the Length is 0 1038 * of the SSID only contains 0's 1039 */ 1040 if (!ssid || !ssid->ssid_len) 1041 return true; 1042 1043 for (i = 0; i < ssid->ssid_len; i++) 1044 if (ssid->ssid[i] != 0) 1045 return false; 1046 1047 /* All 0's */ 1048 return true; 1049 } 1050 1051 #ifdef WLAN_FEATURE_11BE_MLO 1052 static void util_scan_update_rnr_mld(struct rnr_bss_info *rnr, uint8_t *data, 1053 uint8_t tbtt_info_length) 1054 { 1055 bool mld_info_present = false; 1056 1057 switch (tbtt_info_length) { 1058 case TBTT_NEIGHBOR_AP_BSSID_S_SSID_BSS_PARAM_20MHZ_PSD_MLD_PARAM: 1059 qdf_mem_copy(&rnr->mld_info, &data[13], 1060 sizeof(struct rnr_mld_info)); 1061 mld_info_present = true; 1062 break; 1063 }; 1064 1065 rnr->mld_info_valid = mld_info_present; 1066 } 1067 #else 1068 static inline void 1069 util_scan_update_rnr_mld(struct rnr_bss_info *rnr, uint8_t *data, 1070 uint8_t tbtt_info_length) 1071 { 1072 } 1073 #endif 1074 1075 static QDF_STATUS 1076 util_scan_update_rnr(struct rnr_bss_info *rnr, 1077 struct neighbor_ap_info_field *ap_info, 1078 uint8_t *data) 1079 { 1080 uint8_t tbtt_info_length; 1081 1082 tbtt_info_length = ap_info->tbtt_header.tbtt_info_length; 1083 1084 /* 1085 * Max TBTT sub-element length in RNR IE is 255 bytes and AP can send 1086 * data above defined length and the bytes in excess to this length 1087 * shall be treated as reserved. 1088 * 1089 * Limit the TBTT sub-element read operation to current supported 1090 * length i.e TBTT_NEIGHBOR_AP_PARAM_MAX 1091 */ 1092 if (tbtt_info_length > TBTT_NEIGHBOR_AP_PARAM_MAX) 1093 tbtt_info_length = TBTT_NEIGHBOR_AP_PARAM_MAX; 1094 1095 switch (tbtt_info_length) { 1096 case TBTT_NEIGHBOR_AP_OFFSET_ONLY: 1097 /* Dont store it skip*/ 1098 break; 1099 1100 case TBTT_NEIGHBOR_AP_BSS_PARAM: 1101 /* Dont store it skip*/ 1102 break; 1103 1104 case TBTT_NEIGHBOR_AP_S_SSID_BSS_PARAM: 1105 rnr->bss_params = data[5]; 1106 fallthrough; 1107 case TBTT_NEIGHBOR_AP_SHORTSSID: 1108 rnr->channel_number = ap_info->channel_number; 1109 rnr->operating_class = ap_info->operting_class; 1110 qdf_mem_copy(&rnr->short_ssid, &data[1], SHORT_SSID_LEN); 1111 break; 1112 1113 case TBTT_NEIGHBOR_AP_BSSID_BSS_PARAM_20MHZ_PSD: 1114 rnr->psd_20mhz = data[8]; 1115 fallthrough; 1116 case TBTT_NEIGHBOR_AP_BSSID_BSS_PARAM: 1117 rnr->bss_params = data[7]; 1118 fallthrough; 1119 case TBTT_NEIGHBOR_AP_BSSID: 1120 rnr->channel_number = ap_info->channel_number; 1121 rnr->operating_class = ap_info->operting_class; 1122 qdf_mem_copy(&rnr->bssid, &data[1], QDF_MAC_ADDR_SIZE); 1123 break; 1124 1125 case TBTT_NEIGHBOR_AP_BSSID_S_SSID_BSS_PARAM_20MHZ_PSD_MLD_PARAM: 1126 util_scan_update_rnr_mld(rnr, data, tbtt_info_length); 1127 fallthrough; 1128 case TBTT_NEIGHBOR_AP_BSSID_S_SSID_BSS_PARAM_20MHZ_PSD: 1129 rnr->psd_20mhz = data[12]; 1130 fallthrough; 1131 case TBTT_NEIGHBOR_AP_BSSID_S_SSID_BSS_PARAM: 1132 rnr->bss_params = data[11]; 1133 fallthrough; 1134 case TBTT_NEIGHBOR_AP_BSSSID_S_SSID: 1135 rnr->channel_number = ap_info->channel_number; 1136 rnr->operating_class = ap_info->operting_class; 1137 qdf_mem_copy(&rnr->bssid, &data[1], QDF_MAC_ADDR_SIZE); 1138 qdf_mem_copy(&rnr->short_ssid, &data[7], SHORT_SSID_LEN); 1139 break; 1140 1141 default: 1142 scm_debug("Wrong fieldtype"); 1143 } 1144 1145 return QDF_STATUS_SUCCESS; 1146 } 1147 1148 static QDF_STATUS 1149 util_scan_parse_rnr_ie(struct scan_cache_entry *scan_entry, 1150 struct ie_header *ie) 1151 { 1152 uint32_t rnr_ie_len; 1153 uint16_t tbtt_count, tbtt_length, i, fieldtype, idx; 1154 uint8_t *data; 1155 struct neighbor_ap_info_field *neighbor_ap_info; 1156 1157 rnr_ie_len = ie->ie_len; 1158 data = (uint8_t *)ie + sizeof(struct ie_header); 1159 idx = scan_entry->rnr.count; 1160 1161 while ((data + sizeof(struct neighbor_ap_info_field)) <= 1162 ((uint8_t *)ie + rnr_ie_len + 2)) { 1163 neighbor_ap_info = (struct neighbor_ap_info_field *)data; 1164 tbtt_count = neighbor_ap_info->tbtt_header.tbtt_info_count; 1165 tbtt_length = neighbor_ap_info->tbtt_header.tbtt_info_length; 1166 fieldtype = neighbor_ap_info->tbtt_header.tbbt_info_fieldtype; 1167 scm_debug("chan %d, opclass %d tbtt_cnt %d, tbtt_len %d, fieldtype %d", 1168 neighbor_ap_info->channel_number, 1169 neighbor_ap_info->operting_class, 1170 tbtt_count, tbtt_length, fieldtype); 1171 data += sizeof(struct neighbor_ap_info_field); 1172 1173 if (tbtt_count > TBTT_INFO_COUNT) 1174 break; 1175 1176 for (i = 0; i < (tbtt_count + 1) && 1177 (data + tbtt_length) <= 1178 ((uint8_t *)ie + rnr_ie_len + 2); i++) { 1179 if ((i < MAX_RNR_BSS) && (idx < MAX_RNR_BSS)) 1180 util_scan_update_rnr( 1181 &scan_entry->rnr.bss_info[idx++], 1182 neighbor_ap_info, 1183 data); 1184 data += tbtt_length; 1185 } 1186 } 1187 1188 scan_entry->rnr.count = idx; 1189 1190 return QDF_STATUS_SUCCESS; 1191 } 1192 1193 #ifdef WLAN_FEATURE_11BE_MLO 1194 static void 1195 util_scan_parse_t2lm_ie(struct scan_cache_entry *scan_params, 1196 struct extn_ie_header *extn_ie) 1197 { 1198 uint8_t t2lm_idx = 0; 1199 1200 if (extn_ie->ie_extn_id == WLAN_EXTN_ELEMID_T2LM) 1201 for (t2lm_idx = 0; t2lm_idx < WLAN_MAX_T2LM_IE; t2lm_idx++) { 1202 if (!scan_params->ie_list.t2lm[t2lm_idx]) { 1203 scan_params->ie_list.t2lm[t2lm_idx] = 1204 (uint8_t *)extn_ie; 1205 return; 1206 } 1207 } 1208 } 1209 #endif 1210 1211 #ifdef WLAN_FEATURE_11BE 1212 #ifdef WLAN_FEATURE_11BE_MLO 1213 static void util_scan_parse_ml_ie(struct scan_cache_entry *scan_params, 1214 struct extn_ie_header *extn_ie) 1215 { 1216 uint8_t *ml_ie; 1217 uint32_t ml_ie_len; 1218 enum wlan_ml_variant ml_variant; 1219 QDF_STATUS ret; 1220 1221 if (extn_ie->ie_extn_id != WLAN_EXTN_ELEMID_MULTI_LINK) 1222 return; 1223 1224 ml_ie = (uint8_t *)extn_ie; 1225 ml_ie_len = ml_ie[TAG_LEN_POS]; 1226 1227 /* Adding the size of IE header to ML IE length */ 1228 ml_ie_len += sizeof(struct ie_header); 1229 ret = util_get_mlie_variant(ml_ie, ml_ie_len, (int *)&ml_variant); 1230 if (ret) { 1231 scm_err("Unable to get ml variant"); 1232 return; 1233 } 1234 1235 switch (ml_variant) { 1236 case WLAN_ML_VARIANT_BASIC: 1237 scan_params->ie_list.multi_link_bv = (uint8_t *)extn_ie; 1238 break; 1239 case WLAN_ML_VARIANT_RECONFIG: 1240 scan_params->ie_list.multi_link_rv = (uint8_t *)extn_ie; 1241 break; 1242 default: 1243 break; 1244 } 1245 } 1246 #else 1247 static void util_scan_parse_ml_ie(struct scan_cache_entry *scan_params, 1248 struct extn_ie_header *extn_ie) 1249 { 1250 } 1251 #endif 1252 static void util_scan_parse_eht_ie(struct scan_cache_entry *scan_params, 1253 struct extn_ie_header *extn_ie) 1254 { 1255 switch (extn_ie->ie_extn_id) { 1256 case WLAN_EXTN_ELEMID_EHTCAP: 1257 scan_params->ie_list.ehtcap = (uint8_t *)extn_ie; 1258 break; 1259 case WLAN_EXTN_ELEMID_EHTOP: 1260 scan_params->ie_list.ehtop = (uint8_t *)extn_ie; 1261 break; 1262 default: 1263 break; 1264 } 1265 1266 util_scan_parse_ml_ie(scan_params, extn_ie); 1267 util_scan_parse_t2lm_ie(scan_params, extn_ie); 1268 } 1269 #else 1270 static void util_scan_parse_eht_ie(struct scan_cache_entry *scan_params, 1271 struct extn_ie_header *extn_ie) 1272 { 1273 } 1274 #endif 1275 1276 static QDF_STATUS 1277 util_scan_parse_extn_ie(struct scan_cache_entry *scan_params, 1278 struct ie_header *ie) 1279 { 1280 struct extn_ie_header *extn_ie = (struct extn_ie_header *) ie; 1281 1282 switch (extn_ie->ie_extn_id) { 1283 case WLAN_EXTN_ELEMID_MAX_CHAN_SWITCH_TIME: 1284 if (extn_ie->ie_len != WLAN_MAX_CHAN_SWITCH_TIME_IE_LEN) 1285 return QDF_STATUS_E_INVAL; 1286 scan_params->ie_list.mcst = (uint8_t *)ie; 1287 break; 1288 case WLAN_EXTN_ELEMID_SRP: 1289 if (extn_ie->ie_len > WLAN_MAX_SRP_IE_LEN) 1290 return QDF_STATUS_E_INVAL; 1291 scan_params->ie_list.srp = (uint8_t *)ie; 1292 break; 1293 case WLAN_EXTN_ELEMID_HECAP: 1294 if ((extn_ie->ie_len < WLAN_MIN_HECAP_IE_LEN) || 1295 (extn_ie->ie_len > WLAN_MAX_HECAP_IE_LEN)) 1296 return QDF_STATUS_E_INVAL; 1297 scan_params->ie_list.hecap = (uint8_t *)ie; 1298 break; 1299 case WLAN_EXTN_ELEMID_HEOP: 1300 if (extn_ie->ie_len > WLAN_MAX_HEOP_IE_LEN) 1301 return QDF_STATUS_E_INVAL; 1302 scan_params->ie_list.heop = (uint8_t *)ie; 1303 break; 1304 case WLAN_EXTN_ELEMID_ESP: 1305 scan_params->ie_list.esp = (uint8_t *)ie; 1306 break; 1307 case WLAN_EXTN_ELEMID_MUEDCA: 1308 if (extn_ie->ie_len > WLAN_MAX_MUEDCA_IE_LEN) 1309 return QDF_STATUS_E_INVAL; 1310 scan_params->ie_list.muedca = (uint8_t *)ie; 1311 break; 1312 case WLAN_EXTN_ELEMID_HE_6G_CAP: 1313 if (extn_ie->ie_len > WLAN_MAX_HE_6G_CAP_IE_LEN) 1314 return QDF_STATUS_E_INVAL; 1315 scan_params->ie_list.hecap_6g = (uint8_t *)ie; 1316 break; 1317 default: 1318 break; 1319 } 1320 util_scan_parse_eht_ie(scan_params, extn_ie); 1321 1322 return QDF_STATUS_SUCCESS; 1323 } 1324 1325 static QDF_STATUS 1326 util_scan_parse_vendor_ie(struct scan_cache_entry *scan_params, 1327 struct ie_header *ie) 1328 { 1329 if (!scan_params->ie_list.vendor) 1330 scan_params->ie_list.vendor = (uint8_t *)ie; 1331 1332 if (is_wpa_oui((uint8_t *)ie)) { 1333 scan_params->ie_list.wpa = (uint8_t *)ie; 1334 } else if (is_wps_oui((uint8_t *)ie)) { 1335 scan_params->ie_list.wps = (uint8_t *)ie; 1336 /* WCN IE should be a subset of WPS IE */ 1337 if (is_wcn_oui((uint8_t *)ie)) 1338 scan_params->ie_list.wcn = (uint8_t *)ie; 1339 } else if (is_wme_param((uint8_t *)ie)) { 1340 if (ie->ie_len > WLAN_VENDOR_WME_IE_LEN) 1341 return QDF_STATUS_E_INVAL; 1342 1343 scan_params->ie_list.wmeparam = (uint8_t *)ie; 1344 } else if (is_wme_info((uint8_t *)ie)) { 1345 scan_params->ie_list.wmeinfo = (uint8_t *)ie; 1346 } else if (is_atheros_oui((uint8_t *)ie)) { 1347 if (ie->ie_len > WLAN_VENDOR_ATHCAPS_IE_LEN) 1348 return QDF_STATUS_E_INVAL; 1349 1350 scan_params->ie_list.athcaps = (uint8_t *)ie; 1351 } else if (is_atheros_extcap_oui((uint8_t *)ie)) { 1352 if (ie->ie_len > WLAN_VENDOR_ATH_EXTCAP_IE_LEN) 1353 return QDF_STATUS_E_INVAL; 1354 1355 scan_params->ie_list.athextcaps = (uint8_t *)ie; 1356 } else if (is_sfa_oui((uint8_t *)ie)) { 1357 if (ie->ie_len > WLAN_VENDOR_SFA_IE_LEN) 1358 return QDF_STATUS_E_INVAL; 1359 1360 scan_params->ie_list.sfa = (uint8_t *)ie; 1361 } else if (is_p2p_oui((uint8_t *)ie)) { 1362 scan_params->ie_list.p2p = (uint8_t *)ie; 1363 } else if (is_qca_son_oui((uint8_t *)ie, 1364 QCA_OUI_WHC_AP_INFO_SUBTYPE)) { 1365 1366 scan_params->ie_list.sonadv = (uint8_t *)ie; 1367 } else if (is_ht_cap((uint8_t *)ie)) { 1368 /* we only care if there isn't already an HT IE (ANA) */ 1369 if (!scan_params->ie_list.htcap) { 1370 if (ie->ie_len != (WLAN_VENDOR_HT_IE_OFFSET_LEN + 1371 sizeof(struct htcap_cmn_ie))) 1372 return QDF_STATUS_E_INVAL; 1373 scan_params->ie_list.htcap = 1374 (uint8_t *)&(((struct wlan_vendor_ie_htcap *)ie)->ie); 1375 } 1376 } else if (is_ht_info((uint8_t *)ie)) { 1377 /* we only care if there isn't already an HT IE (ANA) */ 1378 if (!scan_params->ie_list.htinfo) { 1379 if (ie->ie_len != WLAN_VENDOR_HT_IE_OFFSET_LEN + 1380 sizeof(struct wlan_ie_htinfo_cmn)) 1381 return QDF_STATUS_E_INVAL; 1382 scan_params->ie_list.htinfo = 1383 (uint8_t *)&(((struct wlan_vendor_ie_htinfo *) 1384 ie)->hi_ie); 1385 } 1386 } else if (is_interop_vht((uint8_t *)ie) && 1387 !(scan_params->ie_list.vhtcap)) { 1388 uint8_t *vendor_ie = (uint8_t *)(ie); 1389 1390 if (ie->ie_len < ((WLAN_VENDOR_VHTCAP_IE_OFFSET + 1391 sizeof(struct wlan_ie_vhtcaps)) - 1392 sizeof(struct ie_header))) 1393 return QDF_STATUS_E_INVAL; 1394 vendor_ie = ((uint8_t *)(ie)) + WLAN_VENDOR_VHTCAP_IE_OFFSET; 1395 if (vendor_ie[1] != (sizeof(struct wlan_ie_vhtcaps)) - 1396 sizeof(struct ie_header)) 1397 return QDF_STATUS_E_INVAL; 1398 /* location where Interop Vht Cap IE and VHT OP IE Present */ 1399 scan_params->ie_list.vhtcap = (((uint8_t *)(ie)) + 1400 WLAN_VENDOR_VHTCAP_IE_OFFSET); 1401 if (ie->ie_len > ((WLAN_VENDOR_VHTCAP_IE_OFFSET + 1402 sizeof(struct wlan_ie_vhtcaps)) - 1403 sizeof(struct ie_header))) { 1404 if (ie->ie_len < ((WLAN_VENDOR_VHTOP_IE_OFFSET + 1405 sizeof(struct wlan_ie_vhtop)) - 1406 sizeof(struct ie_header))) 1407 return QDF_STATUS_E_INVAL; 1408 vendor_ie = ((uint8_t *)(ie)) + 1409 WLAN_VENDOR_VHTOP_IE_OFFSET; 1410 if (vendor_ie[1] != (sizeof(struct wlan_ie_vhtop) - 1411 sizeof(struct ie_header))) 1412 return QDF_STATUS_E_INVAL; 1413 scan_params->ie_list.vhtop = (((uint8_t *)(ie)) + 1414 WLAN_VENDOR_VHTOP_IE_OFFSET); 1415 } 1416 } else if (is_bwnss_oui((uint8_t *)ie)) { 1417 /* 1418 * Bandwidth-NSS map has sub-type & version. 1419 * hence copy data just after version byte 1420 */ 1421 if (ie->ie_len > WLAN_BWNSS_MAP_OFFSET) 1422 scan_params->ie_list.bwnss_map = (((uint8_t *)ie) + 8); 1423 } else if (is_mbo_oce_oui((uint8_t *)ie)) { 1424 scan_params->ie_list.mbo_oce = (uint8_t *)ie; 1425 } else if (is_extender_oui((uint8_t *)ie)) { 1426 scan_params->ie_list.extender = (uint8_t *)ie; 1427 } else if (is_adaptive_11r_oui((uint8_t *)ie)) { 1428 if ((ie->ie_len < OUI_LENGTH) || 1429 (ie->ie_len > MAX_ADAPTIVE_11R_IE_LEN)) 1430 return QDF_STATUS_E_INVAL; 1431 1432 scan_params->ie_list.adaptive_11r = (uint8_t *)ie + 1433 sizeof(struct ie_header); 1434 } else if (is_sae_single_pmk_oui((uint8_t *)ie)) { 1435 if ((ie->ie_len < OUI_LENGTH) || 1436 (ie->ie_len > MAX_SAE_SINGLE_PMK_IE_LEN)) { 1437 scm_debug("Invalid sae single pmk OUI"); 1438 return QDF_STATUS_E_INVAL; 1439 } 1440 scan_params->ie_list.single_pmk = (uint8_t *)ie + 1441 sizeof(struct ie_header); 1442 } else if (is_qcn_oui((uint8_t *)ie)) { 1443 scan_params->ie_list.qcn = (uint8_t *)ie; 1444 } 1445 1446 return QDF_STATUS_SUCCESS; 1447 } 1448 1449 static QDF_STATUS 1450 util_scan_populate_bcn_ie_list(struct wlan_objmgr_pdev *pdev, 1451 struct scan_cache_entry *scan_params, 1452 qdf_freq_t *chan_freq, uint8_t band_mask) 1453 { 1454 struct ie_header *ie, *sub_ie; 1455 uint32_t ie_len, sub_ie_len; 1456 QDF_STATUS status; 1457 uint8_t chan_idx; 1458 struct wlan_scan_obj *scan_obj; 1459 struct wlan_objmgr_psoc *psoc; 1460 uint8_t tpe_idx = 0; 1461 1462 psoc = wlan_pdev_get_psoc(pdev); 1463 if (!psoc) { 1464 scm_err("psoc is NULL"); 1465 return QDF_STATUS_E_INVAL; 1466 } 1467 1468 scan_obj = wlan_psoc_get_scan_obj(psoc); 1469 if (!scan_obj) { 1470 scm_err("scan_obj is NULL"); 1471 return QDF_STATUS_E_INVAL; 1472 } 1473 1474 ie_len = util_scan_entry_ie_len(scan_params); 1475 ie = (struct ie_header *) 1476 util_scan_entry_ie_data(scan_params); 1477 1478 while (ie_len >= sizeof(struct ie_header)) { 1479 ie_len -= sizeof(struct ie_header); 1480 1481 if (!ie->ie_len) { 1482 ie += 1; 1483 continue; 1484 } 1485 1486 if (ie_len < ie->ie_len) { 1487 if (scan_obj->allow_bss_with_incomplete_ie) { 1488 scm_debug(QDF_MAC_ADDR_FMT": Scan allowed with incomplete corrupted IE:%x, ie_len: %d, ie->ie_len: %d, stop processing further", 1489 QDF_MAC_ADDR_REF(scan_params->bssid.bytes), 1490 ie->ie_id, ie_len, ie->ie_len); 1491 break; 1492 } 1493 scm_debug(QDF_MAC_ADDR_FMT": Scan not allowed with incomplete corrupted IE:%x, ie_len: %d, ie->ie_len: %d, stop processing further", 1494 QDF_MAC_ADDR_REF(scan_params->bssid.bytes), 1495 ie->ie_id, ie_len, ie->ie_len); 1496 return QDF_STATUS_E_INVAL; 1497 } 1498 1499 switch (ie->ie_id) { 1500 case WLAN_ELEMID_SSID: 1501 if (ie->ie_len > (sizeof(struct ie_ssid) - 1502 sizeof(struct ie_header))) 1503 goto err; 1504 scan_params->ie_list.ssid = (uint8_t *)ie; 1505 break; 1506 case WLAN_ELEMID_RATES: 1507 if (ie->ie_len > WLAN_SUPPORTED_RATES_IE_MAX_LEN) 1508 goto err; 1509 scan_params->ie_list.rates = (uint8_t *)ie; 1510 break; 1511 case WLAN_ELEMID_DSPARMS: 1512 if (ie->ie_len != WLAN_DS_PARAM_IE_MAX_LEN) 1513 return QDF_STATUS_E_INVAL; 1514 scan_params->ie_list.ds_param = (uint8_t *)ie; 1515 chan_idx = ((struct ds_ie *)ie)->cur_chan; 1516 *chan_freq = wlan_reg_chan_band_to_freq(pdev, chan_idx, 1517 band_mask); 1518 /* Drop if invalid freq */ 1519 if (scan_obj->drop_bcn_on_invalid_freq && 1520 !wlan_reg_is_freq_enabled(pdev, 1521 *chan_freq, 1522 REG_CURRENT_PWR_MODE)) { 1523 scm_debug(QDF_MAC_ADDR_FMT": Drop as invalid chan %d in DS IE, freq %d, band_mask %d", 1524 QDF_MAC_ADDR_REF( 1525 scan_params->bssid.bytes), 1526 chan_idx, *chan_freq, band_mask); 1527 return QDF_STATUS_E_INVAL; 1528 } 1529 break; 1530 case WLAN_ELEMID_TIM: 1531 if (ie->ie_len < WLAN_TIM_IE_MIN_LENGTH) 1532 goto err; 1533 scan_params->ie_list.tim = (uint8_t *)ie; 1534 scan_params->dtim_period = 1535 ((struct wlan_tim_ie *)ie)->tim_period; 1536 break; 1537 case WLAN_ELEMID_COUNTRY: 1538 if (ie->ie_len < WLAN_COUNTRY_IE_MIN_LEN) 1539 goto err; 1540 scan_params->ie_list.country = (uint8_t *)ie; 1541 break; 1542 case WLAN_ELEMID_QBSS_LOAD: 1543 if (ie->ie_len != sizeof(struct qbss_load_ie) - 1544 sizeof(struct ie_header)) { 1545 /* 1546 * Expected QBSS IE length is 5Bytes; For some 1547 * old cisco AP, QBSS IE length is 4Bytes, which 1548 * doesn't match with latest spec, So ignore 1549 * QBSS IE in such case. 1550 */ 1551 break; 1552 } 1553 scan_params->ie_list.qbssload = (uint8_t *)ie; 1554 break; 1555 case WLAN_ELEMID_CHANSWITCHANN: 1556 if (ie->ie_len != WLAN_CSA_IE_MAX_LEN) 1557 goto err; 1558 scan_params->ie_list.csa = (uint8_t *)ie; 1559 break; 1560 case WLAN_ELEMID_IBSSDFS: 1561 if (ie->ie_len < WLAN_IBSSDFS_IE_MIN_LEN) 1562 goto err; 1563 scan_params->ie_list.ibssdfs = (uint8_t *)ie; 1564 break; 1565 case WLAN_ELEMID_QUIET: 1566 if (ie->ie_len != WLAN_QUIET_IE_MAX_LEN) 1567 goto err; 1568 scan_params->ie_list.quiet = (uint8_t *)ie; 1569 break; 1570 case WLAN_ELEMID_ERP: 1571 if (ie->ie_len != (sizeof(struct erp_ie) - 1572 sizeof(struct ie_header))) 1573 goto err; 1574 scan_params->erp = ((struct erp_ie *)ie)->value; 1575 break; 1576 case WLAN_ELEMID_HTCAP_ANA: 1577 if (ie->ie_len == sizeof(struct htcap_cmn_ie)) { 1578 scan_params->ie_list.htcap = 1579 (uint8_t *)&(((struct htcap_ie *)ie)->ie); 1580 } 1581 break; 1582 case WLAN_ELEMID_RSN: 1583 /* 1584 * For security cert TC, RSNIE length can be 1 but if 1585 * beacon is dropped, old entry will remain in scan 1586 * cache and cause cert TC failure as connection with 1587 * old entry with valid RSN IE will pass. 1588 * So instead of dropping the frame, do not store the 1589 * RSN pointer so that old entry is overwritten. 1590 */ 1591 if (ie->ie_len >= WLAN_RSN_IE_MIN_LEN) 1592 scan_params->ie_list.rsn = (uint8_t *)ie; 1593 break; 1594 case WLAN_ELEMID_XRATES: 1595 if (ie->ie_len > WLAN_EXT_SUPPORTED_RATES_IE_MAX_LEN) 1596 goto err; 1597 scan_params->ie_list.xrates = (uint8_t *)ie; 1598 break; 1599 case WLAN_ELEMID_EXTCHANSWITCHANN: 1600 if (ie->ie_len != WLAN_XCSA_IE_MAX_LEN) 1601 goto err; 1602 scan_params->ie_list.xcsa = (uint8_t *)ie; 1603 break; 1604 case WLAN_ELEMID_SECCHANOFFSET: 1605 if (ie->ie_len != WLAN_SECCHANOFF_IE_MAX_LEN) 1606 goto err; 1607 scan_params->ie_list.secchanoff = (uint8_t *)ie; 1608 break; 1609 case WLAN_ELEMID_HTINFO_ANA: 1610 if (ie->ie_len != sizeof(struct wlan_ie_htinfo_cmn)) 1611 goto err; 1612 scan_params->ie_list.htinfo = 1613 (uint8_t *)&(((struct wlan_ie_htinfo *) ie)->hi_ie); 1614 chan_idx = ((struct wlan_ie_htinfo_cmn *) 1615 (scan_params->ie_list.htinfo))->hi_ctrlchannel; 1616 *chan_freq = wlan_reg_chan_band_to_freq(pdev, chan_idx, 1617 band_mask); 1618 /* Drop if invalid freq */ 1619 if (scan_obj->drop_bcn_on_invalid_freq && 1620 !wlan_reg_is_freq_enabled(pdev, 1621 *chan_freq, 1622 REG_CURRENT_PWR_MODE)) { 1623 scm_debug_rl(QDF_MAC_ADDR_FMT": Drop as invalid channel %d freq %d in HT_INFO IE", 1624 QDF_MAC_ADDR_REF(scan_params->bssid.bytes), 1625 chan_idx, *chan_freq); 1626 return QDF_STATUS_E_INVAL; 1627 } 1628 break; 1629 case WLAN_ELEMID_WAPI: 1630 if (ie->ie_len < WLAN_WAPI_IE_MIN_LEN) 1631 goto err; 1632 scan_params->ie_list.wapi = (uint8_t *)ie; 1633 break; 1634 case WLAN_ELEMID_XCAPS: 1635 if (ie->ie_len > WLAN_EXTCAP_IE_MAX_LEN) 1636 goto err; 1637 scan_params->ie_list.extcaps = (uint8_t *)ie; 1638 break; 1639 case WLAN_ELEMID_VHTCAP: 1640 if (ie->ie_len != (sizeof(struct wlan_ie_vhtcaps) - 1641 sizeof(struct ie_header))) 1642 goto err; 1643 scan_params->ie_list.vhtcap = (uint8_t *)ie; 1644 break; 1645 case WLAN_ELEMID_VHTOP: 1646 if (ie->ie_len != (sizeof(struct wlan_ie_vhtop) - 1647 sizeof(struct ie_header))) 1648 goto err; 1649 scan_params->ie_list.vhtop = (uint8_t *)ie; 1650 break; 1651 case WLAN_ELEMID_OP_MODE_NOTIFY: 1652 if (ie->ie_len != WLAN_OPMODE_IE_MAX_LEN) 1653 goto err; 1654 scan_params->ie_list.opmode = (uint8_t *)ie; 1655 break; 1656 case WLAN_ELEMID_MOBILITY_DOMAIN: 1657 if (ie->ie_len != WLAN_MOBILITY_DOMAIN_IE_MAX_LEN) 1658 goto err; 1659 scan_params->ie_list.mdie = (uint8_t *)ie; 1660 break; 1661 case WLAN_ELEMID_VENDOR: 1662 status = util_scan_parse_vendor_ie(scan_params, 1663 ie); 1664 if (QDF_IS_STATUS_ERROR(status)) 1665 goto err_status; 1666 break; 1667 case WLAN_ELEMID_VHT_TX_PWR_ENVLP: 1668 if (ie->ie_len < WLAN_TPE_IE_MIN_LEN) 1669 goto err; 1670 if (tpe_idx >= WLAN_MAX_NUM_TPE_IE) 1671 goto err; 1672 scan_params->ie_list.tpe[tpe_idx++] = (uint8_t *)ie; 1673 break; 1674 case WLAN_ELEMID_CHAN_SWITCH_WRAP: 1675 scan_params->ie_list.cswrp = (uint8_t *)ie; 1676 /* Go to next sub IE */ 1677 sub_ie = (struct ie_header *) 1678 (((uint8_t *)ie) + sizeof(struct ie_header)); 1679 sub_ie_len = ie->ie_len; 1680 status = 1681 util_scan_parse_chan_switch_wrapper_ie( 1682 scan_params, sub_ie, sub_ie_len); 1683 if (QDF_IS_STATUS_ERROR(status)) { 1684 goto err_status; 1685 } 1686 break; 1687 case WLAN_ELEMID_FILS_INDICATION: 1688 if (ie->ie_len < WLAN_FILS_INDICATION_IE_MIN_LEN) 1689 goto err; 1690 scan_params->ie_list.fils_indication = (uint8_t *)ie; 1691 break; 1692 case WLAN_ELEMID_RSNXE: 1693 if (!ie->ie_len) 1694 goto err; 1695 scan_params->ie_list.rsnxe = (uint8_t *)ie; 1696 break; 1697 case WLAN_ELEMID_EXTN_ELEM: 1698 status = util_scan_parse_extn_ie(scan_params, ie); 1699 if (QDF_IS_STATUS_ERROR(status)) 1700 goto err_status; 1701 break; 1702 case WLAN_ELEMID_REDUCED_NEIGHBOR_REPORT: 1703 if (ie->ie_len < WLAN_RNR_IE_MIN_LEN) 1704 goto err; 1705 scan_params->ie_list.rnrie = (uint8_t *)ie; 1706 status = util_scan_parse_rnr_ie(scan_params, ie); 1707 if (QDF_IS_STATUS_ERROR(status)) 1708 goto err_status; 1709 break; 1710 default: 1711 break; 1712 } 1713 1714 /* Consume info element */ 1715 ie_len -= ie->ie_len; 1716 /* Go to next IE */ 1717 ie = (struct ie_header *) 1718 (((uint8_t *) ie) + 1719 sizeof(struct ie_header) + 1720 ie->ie_len); 1721 } 1722 1723 return QDF_STATUS_SUCCESS; 1724 1725 err: 1726 status = QDF_STATUS_E_INVAL; 1727 err_status: 1728 scm_debug(QDF_MAC_ADDR_FMT ": failed to parse IE - id: %d, len: %d", 1729 QDF_MAC_ADDR_REF(scan_params->bssid.bytes), 1730 ie->ie_id, ie->ie_len); 1731 1732 return status; 1733 } 1734 1735 /** 1736 * util_scan_update_esp_data: update ESP params from beacon/probe response 1737 * @esp_information: pointer to wlan_esp_information 1738 * @scan_entry: new received entry 1739 * 1740 * The Estimated Service Parameters element is 1741 * used by a AP to provide information to another STA which 1742 * can then use the information as input to an algorithm to 1743 * generate an estimate of throughput between the two STAs. 1744 * The ESP Information List field contains from 1 to 4 ESP 1745 * Information fields(each field 24 bits), each corresponding 1746 * to an access category for which estimated service parameters 1747 * information is provided. 1748 * 1749 * Return: None 1750 */ 1751 static void util_scan_update_esp_data(struct wlan_esp_ie *esp_information, 1752 struct scan_cache_entry *scan_entry) 1753 { 1754 1755 uint8_t *data; 1756 int i = 0; 1757 uint64_t total_elements; 1758 struct wlan_esp_info *esp_info; 1759 struct wlan_esp_ie *esp_ie; 1760 1761 esp_ie = (struct wlan_esp_ie *) 1762 util_scan_entry_esp_info(scan_entry); 1763 1764 // Ignore ESP_ID_EXTN element 1765 total_elements = esp_ie->esp_len - 1; 1766 data = (uint8_t *)esp_ie + 3; 1767 do_div(total_elements, ESP_INFORMATION_LIST_LENGTH); 1768 1769 if (total_elements > MAX_ESP_INFORMATION_FIELD) { 1770 scm_err("No of Air time fractions are greater than supported"); 1771 return; 1772 } 1773 1774 for (i = 0; i < total_elements && 1775 data < ((uint8_t *)esp_ie + esp_ie->esp_len); i++) { 1776 esp_info = (struct wlan_esp_info *)data; 1777 if (esp_info->access_category == ESP_AC_BK) { 1778 qdf_mem_copy(&esp_information->esp_info_AC_BK, 1779 data, 3); 1780 data = data + ESP_INFORMATION_LIST_LENGTH; 1781 continue; 1782 } 1783 if (esp_info->access_category == ESP_AC_BE) { 1784 qdf_mem_copy(&esp_information->esp_info_AC_BE, 1785 data, 3); 1786 data = data + ESP_INFORMATION_LIST_LENGTH; 1787 continue; 1788 } 1789 if (esp_info->access_category == ESP_AC_VI) { 1790 qdf_mem_copy(&esp_information->esp_info_AC_VI, 1791 data, 3); 1792 data = data + ESP_INFORMATION_LIST_LENGTH; 1793 continue; 1794 } 1795 if (esp_info->access_category == ESP_AC_VO) { 1796 qdf_mem_copy(&esp_information->esp_info_AC_VO, 1797 data, 3); 1798 data = data + ESP_INFORMATION_LIST_LENGTH; 1799 break; 1800 } 1801 } 1802 } 1803 1804 /** 1805 * util_scan_scm_update_bss_with_esp_data: calculate estimated air time 1806 * fraction 1807 * @scan_entry: new received entry 1808 * 1809 * This function process all Access category ESP params and provide 1810 * best effort air time fraction. 1811 * If best effort is not available, it will choose VI, VO and BK in sequence 1812 * 1813 */ 1814 static void util_scan_scm_update_bss_with_esp_data( 1815 struct scan_cache_entry *scan_entry) 1816 { 1817 uint8_t air_time_fraction = 0; 1818 struct wlan_esp_ie esp_information; 1819 1820 if (!scan_entry->ie_list.esp) 1821 return; 1822 1823 util_scan_update_esp_data(&esp_information, scan_entry); 1824 1825 /* 1826 * If the ESP metric is transmitting multiple airtime fractions, then 1827 * follow the sequence AC_BE, AC_VI, AC_VO, AC_BK and pick whichever is 1828 * the first one available 1829 */ 1830 if (esp_information.esp_info_AC_BE.access_category 1831 == ESP_AC_BE) 1832 air_time_fraction = 1833 esp_information.esp_info_AC_BE. 1834 estimated_air_fraction; 1835 else if (esp_information.esp_info_AC_VI.access_category 1836 == ESP_AC_VI) 1837 air_time_fraction = 1838 esp_information.esp_info_AC_VI. 1839 estimated_air_fraction; 1840 else if (esp_information.esp_info_AC_VO.access_category 1841 == ESP_AC_VO) 1842 air_time_fraction = 1843 esp_information.esp_info_AC_VO. 1844 estimated_air_fraction; 1845 else if (esp_information.esp_info_AC_BK.access_category 1846 == ESP_AC_BK) 1847 air_time_fraction = 1848 esp_information.esp_info_AC_BK. 1849 estimated_air_fraction; 1850 scan_entry->air_time_fraction = air_time_fraction; 1851 } 1852 1853 /** 1854 * util_scan_scm_calc_nss_supported_by_ap() - finds out nss from AP 1855 * @scan_params: new received entry 1856 * 1857 * Return: number of nss advertised by AP 1858 */ 1859 static int util_scan_scm_calc_nss_supported_by_ap( 1860 struct scan_cache_entry *scan_params) 1861 { 1862 struct htcap_cmn_ie *htcap; 1863 struct wlan_ie_vhtcaps *vhtcaps; 1864 uint8_t *he_cap; 1865 uint8_t *end_ptr = NULL; 1866 uint16_t rx_mcs_map = 0; 1867 uint8_t *mcs_map_offset; 1868 1869 htcap = (struct htcap_cmn_ie *) 1870 util_scan_entry_htcap(scan_params); 1871 vhtcaps = (struct wlan_ie_vhtcaps *) 1872 util_scan_entry_vhtcap(scan_params); 1873 he_cap = util_scan_entry_hecap(scan_params); 1874 1875 if (he_cap) { 1876 /* Using rx mcs map related to 80MHz or lower as in some 1877 * cases higher mcs may support lesser NSS than that 1878 * of lowe mcs. Thus giving max NSS capability. 1879 */ 1880 end_ptr = he_cap + he_cap[1] + sizeof(struct ie_header); 1881 mcs_map_offset = (he_cap + sizeof(struct extn_ie_header) + 1882 WLAN_HE_MACCAP_LEN + WLAN_HE_PHYCAP_LEN); 1883 if ((mcs_map_offset + WLAN_HE_MCS_MAP_LEN) <= end_ptr) { 1884 rx_mcs_map = *(uint16_t *)mcs_map_offset; 1885 } else { 1886 rx_mcs_map = WLAN_INVALID_RX_MCS_MAP; 1887 scm_debug("mcs_map_offset exceeds he cap len"); 1888 } 1889 } else if (vhtcaps) { 1890 rx_mcs_map = vhtcaps->rx_mcs_map; 1891 } 1892 1893 if (he_cap || vhtcaps) { 1894 if ((rx_mcs_map & 0xC000) != 0xC000) 1895 return 8; 1896 1897 if ((rx_mcs_map & 0x3000) != 0x3000) 1898 return 7; 1899 1900 if ((rx_mcs_map & 0x0C00) != 0x0C00) 1901 return 6; 1902 1903 if ((rx_mcs_map & 0x0300) != 0x0300) 1904 return 5; 1905 1906 if ((rx_mcs_map & 0x00C0) != 0x00C0) 1907 return 4; 1908 1909 if ((rx_mcs_map & 0x0030) != 0x0030) 1910 return 3; 1911 1912 if ((rx_mcs_map & 0x000C) != 0x000C) 1913 return 2; 1914 } else if (htcap) { 1915 if (htcap->mcsset[3]) 1916 return 4; 1917 1918 if (htcap->mcsset[2]) 1919 return 3; 1920 1921 if (htcap->mcsset[1]) 1922 return 2; 1923 1924 } 1925 return 1; 1926 } 1927 1928 #ifdef WLAN_DFS_CHAN_HIDDEN_SSID 1929 QDF_STATUS 1930 util_scan_add_hidden_ssid(struct wlan_objmgr_pdev *pdev, qdf_nbuf_t bcnbuf) 1931 { 1932 struct wlan_frame_hdr *hdr; 1933 struct wlan_bcn_frame *bcn; 1934 struct wlan_scan_obj *scan_obj; 1935 struct wlan_ssid *conf_ssid; 1936 struct ie_header *ie; 1937 uint32_t frame_len = qdf_nbuf_len(bcnbuf); 1938 uint16_t bcn_ie_offset, ssid_ie_start_offset, ssid_ie_end_offset; 1939 uint16_t tmplen, ie_length; 1940 uint8_t *pbeacon, *tmp; 1941 bool set_ssid_flag = false; 1942 struct ie_ssid ssid = {0}; 1943 uint8_t pdev_id; 1944 1945 if (!pdev) { 1946 scm_warn("pdev: 0x%pK is NULL", pdev); 1947 return QDF_STATUS_E_NULL_VALUE; 1948 } 1949 pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev); 1950 scan_obj = wlan_pdev_get_scan_obj(pdev); 1951 if (!scan_obj) { 1952 scm_warn("null scan_obj"); 1953 return QDF_STATUS_E_NULL_VALUE; 1954 } 1955 1956 conf_ssid = &scan_obj->pdev_info[pdev_id].conf_ssid; 1957 1958 hdr = (struct wlan_frame_hdr *)qdf_nbuf_data(bcnbuf); 1959 1960 /* received bssid does not match configured bssid */ 1961 if (qdf_mem_cmp(hdr->i_addr3, scan_obj->pdev_info[pdev_id].conf_bssid, 1962 QDF_MAC_ADDR_SIZE) || 1963 conf_ssid->length == 0) { 1964 return QDF_STATUS_SUCCESS; 1965 } 1966 1967 bcn = (struct wlan_bcn_frame *)(qdf_nbuf_data(bcnbuf) + sizeof(*hdr)); 1968 pbeacon = (uint8_t *)bcn; 1969 1970 ie = (struct ie_header *)(pbeacon + 1971 offsetof(struct wlan_bcn_frame, ie)); 1972 1973 bcn_ie_offset = offsetof(struct wlan_bcn_frame, ie); 1974 ie_length = (uint16_t)(frame_len - sizeof(*hdr) - 1975 bcn_ie_offset); 1976 1977 while (ie_length >= sizeof(struct ie_header)) { 1978 ie_length -= sizeof(struct ie_header); 1979 1980 bcn_ie_offset += sizeof(struct ie_header); 1981 1982 if (ie_length < ie->ie_len) { 1983 scm_debug("Incomplete corrupted IE:%x", ie->ie_id); 1984 return QDF_STATUS_E_INVAL; 1985 } 1986 if (ie->ie_id == WLAN_ELEMID_SSID) { 1987 if (ie->ie_len > (sizeof(struct ie_ssid) - 1988 sizeof(struct ie_header))) { 1989 return QDF_STATUS_E_INVAL; 1990 } 1991 ssid.ssid_id = ie->ie_id; 1992 ssid.ssid_len = ie->ie_len; 1993 1994 if (ssid.ssid_len) 1995 qdf_mem_copy(ssid.ssid, 1996 ie + sizeof(struct ie_header), 1997 ssid.ssid_len); 1998 1999 if (util_scan_is_hidden_ssid(&ssid)) { 2000 set_ssid_flag = true; 2001 ssid_ie_start_offset = bcn_ie_offset - 2002 sizeof(struct ie_header); 2003 ssid_ie_end_offset = bcn_ie_offset + 2004 ie->ie_len; 2005 } 2006 } 2007 if (ie->ie_len == 0) { 2008 ie += 1; /* next IE */ 2009 continue; 2010 } 2011 if (ie->ie_id == WLAN_ELEMID_VENDOR && 2012 is_wps_oui((uint8_t *)ie)) { 2013 set_ssid_flag = false; 2014 break; 2015 } 2016 /* Consume info element */ 2017 ie_length -= ie->ie_len; 2018 /* Go to next IE */ 2019 ie = (struct ie_header *)(((uint8_t *)ie) + 2020 sizeof(struct ie_header) + 2021 ie->ie_len); 2022 } 2023 2024 if (set_ssid_flag) { 2025 /* Hidden SSID if the Length is 0 */ 2026 if (!ssid.ssid_len) { 2027 /* increase the taillength by length of ssid */ 2028 if (qdf_nbuf_put_tail(bcnbuf, 2029 conf_ssid->length) == NULL) { 2030 scm_debug("No enough tailroom"); 2031 return QDF_STATUS_E_NOMEM; 2032 } 2033 /* 2034 * "qdf_nbuf_put_tail" might change the data pointer of 2035 * the skb. Therefore use the new data area. 2036 */ 2037 pbeacon = (qdf_nbuf_data(bcnbuf) + sizeof(*hdr)); 2038 /* length of the buffer to be copied */ 2039 tmplen = frame_len - 2040 sizeof(*hdr) - ssid_ie_end_offset; 2041 /* 2042 * tmp memory to copy the beacon info 2043 * after ssid ie. 2044 */ 2045 tmp = qdf_mem_malloc(tmplen * sizeof(u_int8_t)); 2046 if (!tmp) 2047 return QDF_STATUS_E_NOMEM; 2048 2049 /* Copy beacon data after ssid ie to tmp */ 2050 qdf_nbuf_copy_bits(bcnbuf, (sizeof(*hdr) + 2051 ssid_ie_end_offset), tmplen, tmp); 2052 /* Add ssid length */ 2053 *(pbeacon + (ssid_ie_start_offset + 1)) 2054 = conf_ssid->length; 2055 /* Insert the SSID string */ 2056 qdf_mem_copy((pbeacon + ssid_ie_end_offset), 2057 conf_ssid->ssid, conf_ssid->length); 2058 /* Copy rest of the beacon data */ 2059 qdf_mem_copy((pbeacon + ssid_ie_end_offset + 2060 conf_ssid->length), tmp, tmplen); 2061 qdf_mem_free(tmp); 2062 2063 /* Hidden ssid with all 0's */ 2064 } else if (ssid.ssid_len == conf_ssid->length) { 2065 /* Insert the SSID string */ 2066 qdf_mem_copy((pbeacon + ssid_ie_start_offset + 2067 sizeof(struct ie_header)), 2068 conf_ssid->ssid, conf_ssid->length); 2069 } else { 2070 scm_debug("mismatch in hidden ssid length"); 2071 return QDF_STATUS_E_INVAL; 2072 } 2073 } 2074 return QDF_STATUS_SUCCESS; 2075 } 2076 #endif /* WLAN_DFS_CHAN_HIDDEN_SSID */ 2077 2078 #ifdef WLAN_ADAPTIVE_11R 2079 /** 2080 * scm_fill_adaptive_11r_cap() - Check if the AP supports adaptive 11r 2081 * @scan_entry: Pointer to the scan entry 2082 * 2083 * Return: true if adaptive 11r is advertised else false 2084 */ 2085 static void scm_fill_adaptive_11r_cap(struct scan_cache_entry *scan_entry) 2086 { 2087 uint8_t *ie; 2088 uint8_t data; 2089 bool adaptive_11r; 2090 2091 ie = util_scan_entry_adaptive_11r(scan_entry); 2092 if (!ie) 2093 return; 2094 2095 data = *(ie + OUI_LENGTH); 2096 adaptive_11r = (data & 0x1) ? true : false; 2097 2098 scan_entry->adaptive_11r_ap = adaptive_11r; 2099 } 2100 #else 2101 static void scm_fill_adaptive_11r_cap(struct scan_cache_entry *scan_entry) 2102 { 2103 scan_entry->adaptive_11r_ap = false; 2104 } 2105 #endif 2106 2107 static void util_scan_set_security(struct scan_cache_entry *scan_params) 2108 { 2109 if (util_scan_entry_wpa(scan_params)) 2110 scan_params->security_type |= SCAN_SECURITY_TYPE_WPA; 2111 2112 if (util_scan_entry_rsn(scan_params)) 2113 scan_params->security_type |= SCAN_SECURITY_TYPE_RSN; 2114 if (util_scan_entry_wapi(scan_params)) 2115 scan_params->security_type |= SCAN_SECURITY_TYPE_WAPI; 2116 2117 if (!scan_params->security_type && 2118 scan_params->cap_info.wlan_caps.privacy) 2119 scan_params->security_type |= SCAN_SECURITY_TYPE_WEP; 2120 } 2121 2122 #ifdef WLAN_FEATURE_11BE_MLO 2123 /* 2124 * Multi link IE field offsets 2125 * ------------------------------------------------------------------------ 2126 * | EID(1) | Len (1) | EID_EXT (1) | ML_CONTROL (2) | CMN_INFO (var) | ... | 2127 * ------------------------------------------------------------------------ 2128 */ 2129 #define ML_CONTROL_OFFSET 3 2130 #define ML_CMN_INFO_OFFSET ML_CONTROL_OFFSET + 2 2131 2132 #define CMN_INFO_LINK_ID_PRESENT_BIT BIT(4) 2133 #define LINK_INFO_MAC_ADDR_PRESENT_BIT BIT(5) 2134 2135 /* This function is implemented as per IEEE802.11be D1.0, there is no difference 2136 * in presence bitmap for beacon, probe response and probe request frames. 2137 * This code is to be revisited for future drafts if the presence bitmap values 2138 * changes for the beacon, probe response and probe request frames. 2139 */ 2140 static uint8_t util_get_link_info_offset(uint8_t *ml_ie, bool *is_ml_ie_valid) 2141 { 2142 qdf_size_t ml_ie_len = 0; 2143 qdf_size_t parsed_ie_len = 0; 2144 struct wlan_ie_multilink *mlie_fixed; 2145 uint16_t mlcontrol; 2146 uint16_t presencebm; 2147 qdf_size_t actual_len; 2148 2149 if (!ml_ie) { 2150 scm_err("ml_ie is null"); 2151 return 0; 2152 } 2153 2154 if (!is_ml_ie_valid) { 2155 scm_err_rl("is_ml_ie_valid is null"); 2156 return 0; 2157 } 2158 2159 ml_ie_len = ml_ie[TAG_LEN_POS]; 2160 if (!ml_ie_len) { 2161 scm_err("ml_ie_len is zero"); 2162 return 0; 2163 } 2164 2165 if (ml_ie_len < sizeof(struct wlan_ie_multilink)) { 2166 scm_err_rl("Length %zu octets is smaller than required for the fixed portion of Multi-Link element (%zu octets)", 2167 ml_ie_len, sizeof(struct wlan_ie_multilink)); 2168 return 0; 2169 } 2170 2171 mlie_fixed = (struct wlan_ie_multilink *)ml_ie; 2172 mlcontrol = le16toh(mlie_fixed->mlcontrol); 2173 presencebm = QDF_GET_BITS(mlcontrol, WLAN_ML_CTRL_PBM_IDX, 2174 WLAN_ML_CTRL_PBM_BITS); 2175 2176 parsed_ie_len += sizeof(*mlie_fixed); 2177 2178 parsed_ie_len += WLAN_ML_BV_CINFO_LENGTH_SIZE; 2179 parsed_ie_len += QDF_MAC_ADDR_SIZE; 2180 2181 /* Check if Link ID info is present */ 2182 if (presencebm & WLAN_ML_BV_CTRL_PBM_LINKIDINFO_P) 2183 parsed_ie_len += WLAN_ML_BV_CINFO_LINKIDINFO_SIZE; 2184 2185 /* Check if BSS parameter change count is present */ 2186 if (presencebm & WLAN_ML_BV_CTRL_PBM_BSSPARAMCHANGECNT_P) 2187 parsed_ie_len += WLAN_ML_BSSPARAMCHNGCNT_SIZE; 2188 2189 /* Check if Medium Sync Delay Info is present */ 2190 if (presencebm & WLAN_ML_BV_CTRL_PBM_MEDIUMSYNCDELAYINFO_P) 2191 parsed_ie_len += WLAN_ML_BV_CINFO_MEDMSYNCDELAYINFO_SIZE; 2192 2193 /* Check if EML cap is present */ 2194 if (presencebm & WLAN_ML_BV_CTRL_PBM_EMLCAP_P) 2195 parsed_ie_len += WLAN_ML_BV_CINFO_EMLCAP_SIZE; 2196 2197 /* Check if MLD cap and op is present */ 2198 if (presencebm & WLAN_ML_BV_CTRL_PBM_MLDCAPANDOP_P) 2199 parsed_ie_len += WLAN_ML_BV_CINFO_MLDCAPANDOP_SIZE; 2200 2201 /* Check if MLD ID is present */ 2202 if (presencebm & WLAN_ML_BV_CTRL_PBM_MLDID_P) 2203 parsed_ie_len += WLAN_ML_BV_CINFO_MLDID_SIZE; 2204 2205 /* Check if Extended MLD Cap and Op is present */ 2206 if (presencebm & WLAN_ML_BV_CTRL_PBM_EXT_MLDCAPANDOP_P) 2207 parsed_ie_len += WLAN_ML_BV_CINFO_EXT_MLDCAPANDOP_SIZE; 2208 2209 /* Offset calculation starts from the beginning of the ML IE (including 2210 * EID) hence, adding the size of IE header to ML IE length. 2211 */ 2212 actual_len = ml_ie_len + sizeof(struct ie_header); 2213 if (parsed_ie_len <= actual_len) { 2214 *is_ml_ie_valid = true; 2215 } else { 2216 *is_ml_ie_valid = false; 2217 scm_err("Invalid ML IE, expect min len: %zu, actual len: %zu", 2218 parsed_ie_len, actual_len); 2219 } 2220 if (parsed_ie_len < actual_len) 2221 return parsed_ie_len; 2222 2223 return 0; 2224 } 2225 2226 static void 2227 util_get_ml_bv_partner_link_info(struct wlan_objmgr_pdev *pdev, 2228 struct scan_cache_entry *scan_entry) 2229 { 2230 uint8_t *ml_ie = scan_entry->ie_list.multi_link_bv; 2231 uint8_t *end_ptr = NULL; 2232 bool is_ml_ie_valid; 2233 uint8_t offset = util_get_link_info_offset(ml_ie, &is_ml_ie_valid); 2234 uint16_t sta_ctrl; 2235 uint8_t *stactrl_offset = NULL, *ielist_offset; 2236 uint8_t perstaprof_len = 0, perstaprof_stainfo_len = 0, ielist_len = 0; 2237 struct partner_link_info *link_info = NULL; 2238 uint8_t eid = 0; 2239 uint8_t link_idx = 0; 2240 uint8_t rnr_idx = 0; 2241 struct rnr_bss_info *rnr = NULL; 2242 qdf_size_t ml_ie_len = ml_ie[TAG_LEN_POS] + sizeof(struct ie_header); 2243 2244 /* Update partner info from RNR IE */ 2245 while ((rnr_idx < MAX_RNR_BSS) && (rnr_idx < scan_entry->rnr.count)) { 2246 if (link_idx >= (MLD_MAX_LINKS - 1)) 2247 break; 2248 rnr = &scan_entry->rnr.bss_info[rnr_idx]; 2249 if (rnr->mld_info_valid && !rnr->mld_info.mld_id) { 2250 link_info = &scan_entry->ml_info.link_info[link_idx]; 2251 qdf_mem_copy(&link_info->link_addr, 2252 &rnr->bssid, QDF_MAC_ADDR_SIZE); 2253 2254 link_info->link_id = rnr->mld_info.link_id; 2255 link_info->freq = 2256 wlan_reg_chan_opclass_to_freq(rnr->channel_number, 2257 rnr->operating_class, 2258 true); 2259 2260 if (!link_info->freq) 2261 scm_debug("freq 0 rnr channel %u op_class %u", 2262 rnr->channel_number, 2263 rnr->operating_class); 2264 link_info->op_class = rnr->operating_class; 2265 link_idx++; 2266 } 2267 rnr_idx++; 2268 } 2269 2270 scan_entry->ml_info.num_links = link_idx; 2271 if (!offset || 2272 (offset + sizeof(struct wlan_ml_bv_linfo_perstaprof) >= ml_ie_len)) { 2273 scm_err_rl("incorrect offset value %d", offset); 2274 return; 2275 } 2276 2277 /* TODO: loop through all the STA info fields */ 2278 2279 /* 2280 * Per-STA Profile subelement format of the Basic Multi-Link element 2281 * 2282 * |---------------|--------|-------------|----------|-------------| 2283 * | Subelement ID | Length | STA control | STA info | STA profile | 2284 * |---------------|--------|-------------|----------|-------------| 2285 * Octets: 1 1 2 variable variable 2286 */ 2287 2288 /* Sub element ID 0 represents Per-STA Profile */ 2289 if (ml_ie[offset] == 0) { 2290 perstaprof_len = ml_ie[offset + 1]; 2291 stactrl_offset = &ml_ie[offset + 2]; 2292 end_ptr = &ml_ie[offset] + perstaprof_len + 2; 2293 2294 if (!(end_ptr <= (ml_ie + ml_ie_len))) { 2295 if (ml_ie[TAG_LEN_POS] >= 255) 2296 scm_debug("Possible fragmentation in ml_ie. Ignore the processing"); 2297 else 2298 scm_debug("perstaprof exceeds ML IE boundary. Ignore the processing"); 2299 return; 2300 } 2301 2302 /* Skip sub element ID and length fields */ 2303 offset += 2; 2304 2305 sta_ctrl = *(uint16_t *)(ml_ie + offset); 2306 2307 /* Skip STA control field */ 2308 offset += 2; 2309 2310 /* 2311 * offset points to the beginning of the STA Info field which 2312 * indicates the number of octets in the STA Info field, 2313 * including one octet for the STA Info Length subfield. 2314 */ 2315 perstaprof_stainfo_len = ml_ie[offset]; 2316 2317 /* Skip STA Info Length field */ 2318 offset += perstaprof_stainfo_len; 2319 if (offset >= ml_ie_len) { 2320 scm_err_rl("incorrect offset value %d", offset); 2321 return; 2322 } 2323 2324 /* 2325 * To point to the ie_list offset move past the STA Info 2326 * field. 2327 */ 2328 ielist_offset = &ml_ie[offset]; 2329 2330 /* 2331 * Ensure that the STA Control Field + STA Info Field 2332 * is smaller than the per-STA profile when incrementing 2333 * the pointer to avoid underflow during subtraction. 2334 */ 2335 if ((perstaprof_stainfo_len + 2336 WLAN_ML_BV_LINFO_PERSTAPROF_STACTRL_SIZE) < 2337 perstaprof_len) { 2338 if (!(ielist_offset <= end_ptr)) 2339 ielist_len = 0; 2340 else 2341 ielist_len = perstaprof_len - 2342 (WLAN_ML_BV_LINFO_PERSTAPROF_STACTRL_SIZE + 2343 perstaprof_stainfo_len); 2344 } else { 2345 scm_debug("No STA profile IE list found"); 2346 ielist_len = 0; 2347 } 2348 2349 link_info = NULL; 2350 for (link_idx = 0; link_idx < scan_entry->ml_info.num_links; 2351 link_idx++) { 2352 if (scan_entry->ml_info.link_info[link_idx].link_id == 2353 (sta_ctrl & 0xF)) { 2354 link_info = &scan_entry->ml_info.link_info[link_idx]; 2355 } 2356 } 2357 2358 /* Get the pointers to CSA, ECSA, Max Channel Switch Time IE. */ 2359 if (link_info) { 2360 link_info->csa_ie = wlan_get_ie_ptr_from_eid 2361 (WLAN_ELEMID_CHANSWITCHANN, ielist_offset, 2362 ielist_len); 2363 2364 link_info->ecsa_ie = wlan_get_ie_ptr_from_eid 2365 (WLAN_ELEMID_EXTCHANSWITCHANN, ielist_offset, 2366 ielist_len); 2367 2368 eid = WLAN_EXTN_ELEMID_MAX_CHAN_SWITCH_TIME; 2369 link_info->max_cst_ie = wlan_get_ext_ie_ptr_from_ext_id 2370 (&eid, 1, ielist_offset, ielist_len); 2371 } 2372 } 2373 } 2374 2375 static void util_scan_update_ml_info(struct wlan_objmgr_pdev *pdev, 2376 struct scan_cache_entry *scan_entry) 2377 { 2378 uint8_t *ml_ie = scan_entry->ie_list.multi_link_bv; 2379 uint16_t multi_link_ctrl; 2380 uint8_t offset; 2381 uint8_t mlie_min_len; 2382 bool is_ml_ie_valid = true; 2383 uint8_t *end_ptr = NULL; 2384 2385 if (!scan_entry->ie_list.ehtcap && scan_entry->ie_list.multi_link_bv) { 2386 scan_entry->ie_list.multi_link_bv = NULL; 2387 return; 2388 } 2389 if (!scan_entry->ie_list.multi_link_bv) 2390 return; 2391 2392 mlie_min_len = util_get_link_info_offset(ml_ie, &is_ml_ie_valid); 2393 if (!is_ml_ie_valid) { 2394 scan_entry->ie_list.multi_link_bv = NULL; 2395 return; 2396 } 2397 2398 end_ptr = ml_ie + ml_ie[TAG_LEN_POS] + sizeof(struct ie_header); 2399 2400 multi_link_ctrl = *(uint16_t *)(ml_ie + ML_CONTROL_OFFSET); 2401 2402 /* TODO: update ml_info based on ML IE */ 2403 2404 offset = ML_CMN_INFO_OFFSET; 2405 2406 /* Increment the offset to account for the Common Info Length */ 2407 offset += WLAN_ML_BV_CINFO_LENGTH_SIZE; 2408 2409 if ((ml_ie + offset + QDF_MAC_ADDR_SIZE) <= end_ptr) { 2410 qdf_mem_copy(&scan_entry->ml_info.mld_mac_addr, 2411 ml_ie + offset, QDF_MAC_ADDR_SIZE); 2412 offset += QDF_MAC_ADDR_SIZE; 2413 } 2414 2415 /* TODO: Decode it from ML IE */ 2416 scan_entry->ml_info.num_links = 0; 2417 2418 /** 2419 * Copy Link ID & MAC address of the scan cache entry as first entry 2420 * in the partner info list 2421 */ 2422 if (multi_link_ctrl & CMN_INFO_LINK_ID_PRESENT_BIT) { 2423 if (&ml_ie[offset] < end_ptr) 2424 scan_entry->ml_info.self_link_id = ml_ie[offset] & 0x0F; 2425 } 2426 2427 util_get_ml_bv_partner_link_info(pdev, scan_entry); 2428 } 2429 #else 2430 static void util_scan_update_ml_info(struct wlan_objmgr_pdev *pdev, 2431 struct scan_cache_entry *scan_entry) 2432 { 2433 } 2434 #endif 2435 2436 static QDF_STATUS 2437 util_scan_gen_scan_entry(struct wlan_objmgr_pdev *pdev, 2438 uint8_t *frame, qdf_size_t frame_len, 2439 uint32_t frm_subtype, 2440 struct mgmt_rx_event_params *rx_param, 2441 struct scan_mbssid_info *mbssid_info, 2442 qdf_list_t *scan_list) 2443 { 2444 struct wlan_frame_hdr *hdr; 2445 struct wlan_bcn_frame *bcn; 2446 QDF_STATUS status = QDF_STATUS_SUCCESS; 2447 struct ie_ssid *ssid; 2448 struct scan_cache_entry *scan_entry; 2449 struct qbss_load_ie *qbss_load; 2450 struct scan_cache_node *scan_node; 2451 uint8_t i; 2452 qdf_freq_t chan_freq = 0; 2453 bool is_6g_dup_bcon = false; 2454 uint8_t band_mask; 2455 qdf_freq_t recv_freq = 0; 2456 2457 scan_entry = qdf_mem_malloc_atomic(sizeof(*scan_entry)); 2458 if (!scan_entry) { 2459 scm_err("failed to allocate memory for scan_entry"); 2460 return QDF_STATUS_E_NOMEM; 2461 } 2462 2463 scan_entry->raw_frame.ptr = 2464 qdf_mem_malloc_atomic(frame_len); 2465 if (!scan_entry->raw_frame.ptr) { 2466 scm_err("failed to allocate memory for frame"); 2467 qdf_mem_free(scan_entry); 2468 return QDF_STATUS_E_NOMEM; 2469 } 2470 2471 bcn = (struct wlan_bcn_frame *) 2472 (frame + sizeof(*hdr)); 2473 hdr = (struct wlan_frame_hdr *)frame; 2474 2475 /* update timestamp in nanoseconds needed by kernel layers */ 2476 scan_entry->boottime_ns = qdf_get_bootbased_boottime_ns(); 2477 2478 scan_entry->frm_subtype = frm_subtype; 2479 qdf_mem_copy(scan_entry->bssid.bytes, 2480 hdr->i_addr3, QDF_MAC_ADDR_SIZE); 2481 /* Scr addr */ 2482 qdf_mem_copy(scan_entry->mac_addr.bytes, 2483 hdr->i_addr2, QDF_MAC_ADDR_SIZE); 2484 scan_entry->seq_num = 2485 (le16toh(*(uint16_t *)hdr->i_seq) >> WLAN_SEQ_SEQ_SHIFT); 2486 2487 scan_entry->snr = rx_param->snr; 2488 scan_entry->avg_snr = WLAN_SNR_IN(scan_entry->snr); 2489 scan_entry->rssi_raw = rx_param->rssi; 2490 scan_entry->avg_rssi = WLAN_RSSI_IN(scan_entry->rssi_raw); 2491 scan_entry->tsf_delta = rx_param->tsf_delta; 2492 scan_entry->pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev); 2493 2494 recv_freq = rx_param->chan_freq; 2495 /* Copy per chain rssi to scan entry */ 2496 qdf_mem_copy(scan_entry->per_chain_rssi, rx_param->rssi_ctl, 2497 WLAN_MGMT_TXRX_HOST_MAX_ANTENNA); 2498 band_mask = BIT(wlan_reg_freq_to_band(recv_freq)); 2499 2500 if (!wlan_psoc_nif_fw_ext_cap_get(wlan_pdev_get_psoc(pdev), 2501 WLAN_SOC_CEXT_HW_DB2DBM)) { 2502 for (i = 0; i < WLAN_MGMT_TXRX_HOST_MAX_ANTENNA; i++) { 2503 if (scan_entry->per_chain_rssi[i] != 2504 WLAN_INVALID_PER_CHAIN_SNR) 2505 scan_entry->per_chain_rssi[i] += 2506 WLAN_NOISE_FLOOR_DBM_DEFAULT; 2507 else 2508 scan_entry->per_chain_rssi[i] = 2509 WLAN_INVALID_PER_CHAIN_RSSI; 2510 } 2511 } 2512 2513 /* store jiffies */ 2514 scan_entry->rrm_parent_tsf = (uint32_t)qdf_system_ticks(); 2515 2516 scan_entry->bcn_int = le16toh(bcn->beacon_interval); 2517 2518 /* 2519 * In case if the beacon doesn't have 2520 * valid beacon interval falback to def 2521 */ 2522 if (!scan_entry->bcn_int) 2523 scan_entry->bcn_int = 100; 2524 scan_entry->cap_info.value = le16toh(bcn->capability.value); 2525 qdf_mem_copy(scan_entry->tsf_info.data, 2526 bcn->timestamp, 8); 2527 scan_entry->erp = ERP_NON_ERP_PRESENT; 2528 2529 scan_entry->scan_entry_time = 2530 qdf_mc_timer_get_system_time(); 2531 2532 scan_entry->raw_frame.len = frame_len; 2533 qdf_mem_copy(scan_entry->raw_frame.ptr, 2534 frame, frame_len); 2535 status = util_scan_populate_bcn_ie_list(pdev, scan_entry, &chan_freq, 2536 band_mask); 2537 if (QDF_IS_STATUS_ERROR(status)) { 2538 qdf_mem_free(scan_entry->raw_frame.ptr); 2539 qdf_mem_free(scan_entry); 2540 return QDF_STATUS_E_FAILURE; 2541 } 2542 2543 ssid = (struct ie_ssid *) 2544 scan_entry->ie_list.ssid; 2545 2546 if (ssid && (ssid->ssid_len > WLAN_SSID_MAX_LEN)) { 2547 qdf_mem_free(scan_entry->raw_frame.ptr); 2548 qdf_mem_free(scan_entry); 2549 return QDF_STATUS_E_FAILURE; 2550 } 2551 2552 if (scan_entry->ie_list.p2p) 2553 scan_entry->is_p2p = true; 2554 2555 if (!chan_freq && util_scan_entry_hecap(scan_entry)) { 2556 status = util_scan_get_chan_from_he_6g_params(pdev, scan_entry, 2557 &chan_freq, 2558 &is_6g_dup_bcon, 2559 band_mask, 2560 recv_freq); 2561 if (QDF_IS_STATUS_ERROR(status)) { 2562 qdf_mem_free(scan_entry->raw_frame.ptr); 2563 qdf_mem_free(scan_entry); 2564 return QDF_STATUS_E_FAILURE; 2565 } 2566 } 2567 2568 if (chan_freq) 2569 scan_entry->channel.chan_freq = chan_freq; 2570 2571 /* If no channel info is present in beacon use meta channel */ 2572 if (!scan_entry->channel.chan_freq) { 2573 scan_entry->channel.chan_freq = recv_freq; 2574 } else if (recv_freq != 2575 scan_entry->channel.chan_freq) { 2576 if (!wlan_reg_is_49ghz_freq(scan_entry->channel.chan_freq) && 2577 !is_6g_dup_bcon) 2578 scan_entry->channel_mismatch = true; 2579 } 2580 2581 if (util_scan_is_hidden_ssid(ssid)) { 2582 scan_entry->ie_list.ssid = NULL; 2583 scan_entry->is_hidden_ssid = true; 2584 } else { 2585 qdf_mem_copy(scan_entry->ssid.ssid, 2586 ssid->ssid, ssid->ssid_len); 2587 scan_entry->ssid.length = ssid->ssid_len; 2588 scan_entry->hidden_ssid_timestamp = 2589 scan_entry->scan_entry_time; 2590 } 2591 qdf_mem_copy(&scan_entry->mbssid_info, mbssid_info, 2592 sizeof(scan_entry->mbssid_info)); 2593 2594 scan_entry->phy_mode = util_scan_get_phymode(pdev, scan_entry); 2595 2596 scan_entry->nss = util_scan_scm_calc_nss_supported_by_ap(scan_entry); 2597 scm_fill_adaptive_11r_cap(scan_entry); 2598 util_scan_set_security(scan_entry); 2599 2600 util_scan_scm_update_bss_with_esp_data(scan_entry); 2601 qbss_load = (struct qbss_load_ie *) 2602 util_scan_entry_qbssload(scan_entry); 2603 if (qbss_load) 2604 scan_entry->qbss_chan_load = qbss_load->qbss_chan_load; 2605 2606 scan_node = qdf_mem_malloc_atomic(sizeof(*scan_node)); 2607 if (!scan_node) { 2608 qdf_mem_free(scan_entry->raw_frame.ptr); 2609 qdf_mem_free(scan_entry); 2610 scm_err("failed to allocate memory for scan_node"); 2611 return QDF_STATUS_E_FAILURE; 2612 } 2613 2614 util_scan_update_ml_info(pdev, scan_entry); 2615 2616 scan_node->entry = scan_entry; 2617 qdf_list_insert_front(scan_list, &scan_node->node); 2618 2619 return status; 2620 } 2621 2622 #ifdef WLAN_FEATURE_MBSSID 2623 /* 2624 * util_is_noninh_ie() - find the noninhertance information element 2625 * in the received frame's IE list, so that we can stop inheriting that IE 2626 * in the caller function. 2627 * 2628 * @elem_id: Element ID in the received frame's IE, which is being processed. 2629 * @non_inh_list: pointer to the non inherited list of element IDs or 2630 * list of extension element IDs. 2631 * @len: Length of non inheritance IE list 2632 * 2633 * Return: False if the element ID is not found or else return true 2634 */ 2635 static bool util_is_noninh_ie(uint8_t elem_id, 2636 uint8_t *non_inh_list, 2637 int8_t len) 2638 { 2639 int count; 2640 2641 for (count = 0; count < len; count++) { 2642 if (elem_id == non_inh_list[count]) 2643 return true; 2644 } 2645 2646 return false; 2647 } 2648 2649 /* 2650 * util_scan_find_noninheritance_ie() - find noninheritance information element 2651 * This block of code is to identify if there is any non-inheritance element 2652 * present as part of the nontransmitted BSSID profile. 2653 * @elem_id: element id 2654 * @ies: pointer consisting of IEs 2655 * @len: IE length 2656 * 2657 * Return: NULL if the element ID is not found or if IE pointer is NULL else 2658 * pointer to the first byte of the requested element 2659 */ 2660 static uint8_t 2661 *util_scan_find_noninheritance_ie(uint8_t elem_id, uint8_t *ies, 2662 int32_t len) 2663 { 2664 if (!ies) 2665 return NULL; 2666 2667 while ((len >= MIN_IE_LEN + 1) && len >= ies[TAG_LEN_POS] + MIN_IE_LEN) 2668 { 2669 if ((ies[ID_POS] == elem_id) && 2670 (ies[ELEM_ID_EXTN_POS] == 2671 WLAN_EXTN_ELEMID_NONINHERITANCE)) { 2672 return ies; 2673 } 2674 len -= ies[TAG_LEN_POS] + MIN_IE_LEN; 2675 ies += ies[TAG_LEN_POS] + MIN_IE_LEN; 2676 } 2677 2678 return NULL; 2679 } 2680 #endif 2681 2682 /* 2683 * util_scan_find_ie() - find information element 2684 * @eid: element id 2685 * @ies: pointer consisting of IEs 2686 * @len: IE length 2687 * 2688 * Return: NULL if the element ID is not found or if IE pointer is NULL else 2689 * pointer to the first byte of the requested element 2690 */ 2691 static uint8_t *util_scan_find_ie(uint8_t eid, uint8_t *ies, 2692 int32_t len) 2693 { 2694 if (!ies) 2695 return NULL; 2696 2697 while (len >= 2 && len >= ies[1] + 2) { 2698 if (ies[0] == eid) 2699 return ies; 2700 len -= ies[1] + 2; 2701 ies += ies[1] + 2; 2702 } 2703 2704 return NULL; 2705 } 2706 2707 #ifdef WLAN_FEATURE_MBSSID 2708 static void util_gen_new_bssid(uint8_t *bssid, uint8_t max_bssid, 2709 uint8_t mbssid_index, 2710 uint8_t *new_bssid_addr) 2711 { 2712 uint8_t lsb_n; 2713 int i; 2714 2715 for (i = 0; i < QDF_MAC_ADDR_SIZE; i++) 2716 new_bssid_addr[i] = bssid[i]; 2717 2718 lsb_n = new_bssid_addr[5] & ((1 << max_bssid) - 1); 2719 2720 new_bssid_addr[5] &= ~((1 << max_bssid) - 1); 2721 new_bssid_addr[5] |= (lsb_n + mbssid_index) % (1 << max_bssid); 2722 } 2723 2724 /* 2725 * util_parse_noninheritance_list() - This block of code will be executed only 2726 * if there is a valid non inheritance IE present in the nontx profile. 2727 * Host need not inherit those list of element IDs and list of element ID 2728 * extensions from the transmitted BSSID profile. 2729 * Since non-inheritance element is an element ID extension, it should 2730 * be part of extension element. So first we need to find if there are 2731 * any extension element present in the nontransmitted BSSID profile. 2732 * @extn_elem: If valid, it points to the element ID field of 2733 * extension element tag in the nontransmitted BSSID profile. 2734 * It may or may not have non inheritance tag present. 2735 * _____________________________________________ 2736 * | | | |List of|List of | 2737 * | Element |Length |Element|Element|Element ID | 2738 * | ID | |ID extn| IDs |Extension | 2739 * |_________|_______|_______|_______|___________| 2740 * List of Element IDs: 2741 * __________________ 2742 * | | | 2743 * | Length |Element | 2744 * | |ID List | 2745 * |_________|________| 2746 * List of Element ID Extensions: 2747 * __________________________ 2748 * | | | 2749 * | Length |Element ID | 2750 * | |extension List | 2751 * |_________|________________| 2752 * @elem_list: Element ID list 2753 * @extn_elem_list: Element ID exiension list 2754 * @non_inheritance_ie: Non inheritance IE information 2755 */ 2756 2757 static void util_parse_noninheritance_list(uint8_t *extn_elem, 2758 uint8_t **elem_list, 2759 uint8_t **extn_elem_list, 2760 struct non_inheritance_ie *ninh) 2761 { 2762 int8_t extn_rem_len = 0; 2763 2764 if (extn_elem[ELEM_ID_LIST_LEN_POS] < extn_elem[TAG_LEN_POS]) { 2765 /* 2766 * extn_rem_len represents the number of bytes after 2767 * the length subfield of list of Element IDs. 2768 * So here, extn_rem_len should be equal to 2769 * Element ID list + Length subfield of Element ID 2770 * extension list + Element ID extension list. 2771 * 2772 * Here we have taken two pointers pointing to the 2773 * element ID list and element ID extension list 2774 * which we will use to detect the same elements 2775 * in the transmitted BSSID profile and choose not 2776 * to inherit those elements while constructing the 2777 * frame for nontransmitted BSSID profile. 2778 */ 2779 extn_rem_len = extn_elem[TAG_LEN_POS] - MIN_IE_LEN; 2780 ninh->non_inherit = true; 2781 2782 if (extn_rem_len && extn_elem[ELEM_ID_LIST_LEN_POS]) { 2783 if (extn_rem_len >= extn_elem[ELEM_ID_LIST_LEN_POS]) { 2784 ninh->list_len = 2785 extn_elem[ELEM_ID_LIST_LEN_POS]; 2786 *elem_list = extn_elem + ELEM_ID_LIST_POS; 2787 extn_rem_len -= ninh->list_len; 2788 } else { 2789 /* 2790 * Corrupt frame. length subfield of 2791 * element ID list is greater than 2792 * what it should be. Go ahead with 2793 * frame generation but do not honour 2794 * the non inheritance part. Also, mark 2795 * the element ID in subcopy as 0, so 2796 * that this element info will not 2797 * be copied. 2798 */ 2799 ninh->non_inherit = false; 2800 extn_elem[0] = 0; 2801 } 2802 } 2803 2804 extn_rem_len--; 2805 if (extn_rem_len > 0) { 2806 if (!ninh->list_len) { 2807 ninh->extn_len = 2808 extn_elem[ELEM_ID_LIST_LEN_POS + 1]; 2809 } else { 2810 ninh->extn_len = 2811 extn_elem[ELEM_ID_LIST_POS + 2812 ninh->list_len]; 2813 } 2814 2815 if (extn_rem_len != ninh->extn_len) { 2816 /* 2817 * Corrupt frame. length subfield of 2818 * element ID extn list is not 2819 * what it should be. Go ahead with 2820 * frame generation but do not honour 2821 * the non inheritance part. Also, mark 2822 * the element ID in subcopy as 0, so 2823 * that this element info will not 2824 * be copied. 2825 */ 2826 ninh->non_inherit = false; 2827 extn_elem[0] = 0; 2828 } 2829 2830 if (ninh->extn_len) { 2831 *extn_elem_list = 2832 (extn_elem + ninh->list_len + 2833 ELEM_ID_LIST_POS + 1); 2834 } 2835 } 2836 } 2837 } 2838 2839 #ifdef WLAN_FEATURE_11BE_MLO 2840 /** 2841 * util_handle_rnr_ie_for_mbssid() - parse and modify RNR IE for MBSSID feature 2842 * @rnr: The pointer to RNR IE 2843 * @bssid_index: BSSID index from MBSSID index IE 2844 * @pos: The buffer pointer to save the transformed RNR IE, caller is expected 2845 * to supply a buffer that is at least as big as @rnr 2846 * 2847 * Per the description about Neighbor AP Information field about MLD 2848 * parameters subfield in section 9.4.2.170.2 of Draft P802.11be_D1.4. 2849 * If the reported AP is affiliated with the same MLD of the reporting AP, 2850 * the TBTT information is skipped; If the reported AP is affiliated with 2851 * the same MLD of the nontransmitted BSSID, the TBTT information is 2852 * copied and the MLD ID is changed to 0. 2853 * 2854 * Return: Length of the element written to @pos 2855 */ 2856 static int util_handle_rnr_ie_for_mbssid(const uint8_t *rnr, 2857 uint8_t bssid_index, uint8_t *pos) 2858 { 2859 size_t rnr_len; 2860 const uint8_t *data, *rnr_end; 2861 uint8_t *rnr_new; 2862 struct neighbor_ap_info_field *neighbor_ap_info; 2863 struct rnr_mld_info *mld_param; 2864 uint8_t tbtt_type, tbtt_len, tbtt_count; 2865 uint8_t mld_pos, mld_id; 2866 int32_t i, copy_len; 2867 /* The count of TBTT info field whose MLD ID equals to 0 in a neighbor 2868 * AP information field. 2869 */ 2870 uint32_t tbtt_info_field_count; 2871 /* The total bytes of TBTT info fields whose MLD ID equals to 0 in 2872 * current RNR IE. 2873 */ 2874 uint32_t tbtt_info_field_len = 0; 2875 uint8_t nbr_ap_info_len = sizeof(struct neighbor_ap_info_field); 2876 2877 rnr_len = rnr[TAG_LEN_POS]; 2878 rnr_end = rnr + rnr_len + MIN_IE_LEN; 2879 rnr_new = pos; 2880 qdf_mem_copy(pos, rnr, MIN_IE_LEN); 2881 pos += MIN_IE_LEN; 2882 2883 data = rnr + PAYLOAD_START_POS; 2884 while (data + sizeof(struct neighbor_ap_info_field) <= rnr_end) { 2885 neighbor_ap_info = (struct neighbor_ap_info_field *)data; 2886 tbtt_count = neighbor_ap_info->tbtt_header.tbtt_info_count; 2887 tbtt_len = neighbor_ap_info->tbtt_header.tbtt_info_length; 2888 tbtt_type = neighbor_ap_info->tbtt_header.tbbt_info_fieldtype; 2889 scm_debug("channel number %d, op class %d, bssid_index %d", 2890 neighbor_ap_info->channel_number, 2891 neighbor_ap_info->operting_class, bssid_index); 2892 scm_debug("tbtt_count %d, tbtt_length %d, tbtt_type %d", 2893 tbtt_count, tbtt_len, tbtt_type); 2894 2895 copy_len = tbtt_len * (tbtt_count + 1) + 2896 nbr_ap_info_len; 2897 if (data + copy_len > rnr_end) 2898 return 0; 2899 2900 if (tbtt_len >= 2901 TBTT_NEIGHBOR_AP_BSSID_S_SSID_BSS_PARAM_20MHZ_PSD_MLD_PARAM) 2902 mld_pos = 2903 TBTT_NEIGHBOR_AP_BSSID_S_SSID_BSS_PARAM_20MHZ_PSD; 2904 else 2905 mld_pos = 0; 2906 2907 /* If MLD params do not exist, copy this neighbor AP 2908 * information field. 2909 * Per Draft P802.11be_D1.4, tbtt_type value 1, 2 and 3 2910 * are reserved, 2911 */ 2912 if (mld_pos == 0 || tbtt_type != 0) { 2913 scm_debug("no MLD params, tbtt_type %d", tbtt_type); 2914 qdf_mem_copy(pos, data, copy_len); 2915 pos += copy_len; 2916 data += copy_len; 2917 continue; 2918 } 2919 2920 qdf_mem_copy(pos, data, nbr_ap_info_len); 2921 neighbor_ap_info = (struct neighbor_ap_info_field *)pos; 2922 pos += nbr_ap_info_len; 2923 data += nbr_ap_info_len; 2924 2925 tbtt_info_field_count = 0; 2926 for (i = 0; i < tbtt_count + 1; i++) { 2927 mld_param = (struct rnr_mld_info *)&data[mld_pos]; 2928 mld_id = mld_param->mld_id; 2929 2930 /* Refer to Draft P802.11be_D1.4 2931 * 9.4.2.170.2 Neighbor AP Information field about 2932 * MLD parameters subfield 2933 */ 2934 if (mld_id == 0) { 2935 /* Skip this TBTT information since this 2936 * reported AP is affiliated with the same MLD 2937 * of the reporting AP who sending the frame 2938 * carrying this element. 2939 */ 2940 tbtt_info_field_len += tbtt_len; 2941 data += tbtt_len; 2942 tbtt_info_field_count++; 2943 } else if (mld_id == bssid_index) { 2944 /* Copy this TBTT information and change MLD 2945 * to 0 as this reported AP is affiliated with 2946 * the same MLD of the nontransmitted BSSID. 2947 */ 2948 qdf_mem_copy(pos, data, tbtt_len); 2949 mld_param = 2950 (struct rnr_mld_info *)&pos[mld_pos]; 2951 scm_debug("change MLD ID from %d to 0", 2952 mld_param->mld_id); 2953 mld_param->mld_id = 0; 2954 data += tbtt_len; 2955 pos += tbtt_len; 2956 } else { 2957 qdf_mem_copy(pos, data, tbtt_len); 2958 data += tbtt_len; 2959 pos += tbtt_len; 2960 } 2961 } 2962 2963 scm_debug("skip %d neighbor info", tbtt_info_field_count); 2964 if (tbtt_info_field_count == (tbtt_count + 1)) { 2965 /* If all the TBTT information are skipped, then also 2966 * revert the neighbor AP info which has been copied. 2967 */ 2968 pos -= nbr_ap_info_len; 2969 tbtt_info_field_len += nbr_ap_info_len; 2970 } else { 2971 neighbor_ap_info->tbtt_header.tbtt_info_count -= 2972 tbtt_info_field_count; 2973 } 2974 } 2975 2976 rnr_new[TAG_LEN_POS] = rnr_len - tbtt_info_field_len; 2977 if (rnr_new[TAG_LEN_POS] > 0) 2978 rnr_len = rnr_new[TAG_LEN_POS] + MIN_IE_LEN; 2979 else 2980 rnr_len = 0; 2981 2982 return rnr_len; 2983 } 2984 #else 2985 static int util_handle_rnr_ie_for_mbssid(const uint8_t *rnr, 2986 uint8_t bssid_index, uint8_t *pos) 2987 { 2988 return 0; 2989 } 2990 #endif 2991 2992 #ifdef WLAN_FEATURE_ACTION_OUI 2993 static uint8_t *util_copy_reporting_ap_vendor_ies(struct wlan_objmgr_psoc *psoc, 2994 const uint8_t *ie, 2995 uint32_t ie_len, 2996 uint8_t *buf_ie) 2997 { 2998 struct action_oui_search_attr attr; 2999 enum action_oui_id oui_id = ACTION_OUI_RESTRICT_MAX_MLO_LINKS; 3000 3001 attr.ie_data = (uint8_t *)ie; 3002 attr.ie_length = ie_len; 3003 3004 if (wlan_action_oui_search(psoc, &attr, oui_id)) { 3005 qdf_mem_copy(buf_ie, ie, ie_len); 3006 buf_ie += ie_len; 3007 } 3008 3009 return buf_ie; 3010 } 3011 #else 3012 static inline uint8_t * 3013 util_copy_reporting_ap_vendor_ies(struct wlan_objmgr_psoc *psoc, 3014 const uint8_t *ie, uint32_t ie_len, 3015 uint8_t *buf_ie) 3016 { 3017 return buf_ie; 3018 } 3019 #endif 3020 3021 static uint32_t util_gen_new_ie(struct wlan_objmgr_pdev *pdev, 3022 uint8_t *ie, uint32_t ielen, 3023 uint8_t *subelement, 3024 size_t subie_len, uint8_t *new_ie, 3025 uint8_t bssid_index) 3026 { 3027 struct wlan_objmgr_psoc *psoc; 3028 uint8_t *pos, *tmp; 3029 const uint8_t *tmp_old, *tmp_new; 3030 uint8_t *sub_copy, *extn_elem = NULL; 3031 struct non_inheritance_ie ninh = {0}; 3032 uint8_t *elem_list = NULL, *extn_elem_list = NULL; 3033 size_t tmp_rem_len; 3034 3035 psoc = wlan_pdev_get_psoc(pdev); 3036 if (!psoc) { 3037 scm_err("NULL PSOC"); 3038 return 0; 3039 } 3040 3041 /* copy subelement as we need to change its content to 3042 * mark an ie after it is processed. 3043 */ 3044 sub_copy = qdf_mem_malloc(subie_len); 3045 if (!sub_copy) 3046 return 0; 3047 qdf_mem_copy(sub_copy, subelement, subie_len); 3048 3049 pos = &new_ie[0]; 3050 3051 /* new ssid */ 3052 tmp_new = util_scan_find_ie(WLAN_ELEMID_SSID, sub_copy, subie_len); 3053 if (tmp_new) { 3054 scm_debug(" SSID " QDF_SSID_FMT, 3055 QDF_SSID_REF(tmp_new[1], 3056 &tmp_new[PAYLOAD_START_POS])); 3057 if ((pos + tmp_new[1] + MIN_IE_LEN) <= 3058 (new_ie + ielen)) { 3059 qdf_mem_copy(pos, tmp_new, 3060 (tmp_new[1] + MIN_IE_LEN)); 3061 pos += (tmp_new[1] + MIN_IE_LEN); 3062 } 3063 } 3064 3065 extn_elem = util_scan_find_noninheritance_ie(WLAN_ELEMID_EXTN_ELEM, 3066 sub_copy, subie_len); 3067 3068 if (extn_elem && extn_elem[TAG_LEN_POS] >= VALID_ELEM_LEAST_LEN) { 3069 if (((extn_elem + extn_elem[1] + MIN_IE_LEN) - sub_copy) 3070 < subie_len) 3071 util_parse_noninheritance_list(extn_elem, &elem_list, 3072 &extn_elem_list, &ninh); 3073 } 3074 3075 /* go through IEs in ie (skip SSID) and subelement, 3076 * merge them into new_ie 3077 */ 3078 tmp_old = util_scan_find_ie(WLAN_ELEMID_SSID, ie, ielen); 3079 tmp_old = (tmp_old) ? tmp_old + tmp_old[1] + MIN_IE_LEN : ie; 3080 3081 if (((tmp_old + MIN_IE_LEN) - ie) >= ielen) { 3082 qdf_mem_free(sub_copy); 3083 return 0; 3084 } 3085 3086 while (((tmp_old + tmp_old[1] + MIN_IE_LEN) - ie) <= ielen) { 3087 ninh.non_inh_ie_found = 0; 3088 if (ninh.non_inherit) { 3089 if (ninh.list_len) { 3090 ninh.non_inh_ie_found = 3091 util_is_noninh_ie(tmp_old[0], 3092 elem_list, 3093 ninh.list_len); 3094 } 3095 3096 if (!ninh.non_inh_ie_found && 3097 ninh.extn_len && 3098 (tmp_old[0] == WLAN_ELEMID_EXTN_ELEM)) { 3099 ninh.non_inh_ie_found = 3100 util_is_noninh_ie(tmp_old[2], 3101 extn_elem_list, 3102 ninh.extn_len); 3103 } 3104 } 3105 3106 if (ninh.non_inh_ie_found || (tmp_old[0] == 0)) { 3107 if (((tmp_old + tmp_old[1] + MIN_IE_LEN) - ie) >= 3108 (ielen - MIN_IE_LEN)) 3109 break; 3110 tmp_old += tmp_old[1] + MIN_IE_LEN; 3111 continue; 3112 } 3113 3114 tmp = (uint8_t *)util_scan_find_ie(tmp_old[0], sub_copy, 3115 subie_len); 3116 if (!tmp) { 3117 /* ie in old ie but not in subelement */ 3118 if (tmp_old[0] == WLAN_ELEMID_REDUCED_NEIGHBOR_REPORT) { 3119 /* handle rnr ie for mbssid*/ 3120 pos += 3121 util_handle_rnr_ie_for_mbssid(tmp_old, 3122 bssid_index, 3123 pos); 3124 } else if (tmp_old[0] != WLAN_ELEMID_MULTIPLE_BSSID) { 3125 if ((pos + tmp_old[1] + MIN_IE_LEN) <= 3126 (new_ie + ielen)) { 3127 qdf_mem_copy(pos, tmp_old, 3128 (tmp_old[1] + 3129 MIN_IE_LEN)); 3130 pos += tmp_old[1] + MIN_IE_LEN; 3131 } 3132 } 3133 } else { 3134 /* ie in transmitting ie also in subelement, 3135 * copy from subelement and flag the ie in subelement 3136 * as copied (by setting eid field to 0xff). 3137 * To determine if the vendor ies are same: 3138 * 1. For Cisco OUI, compare only OUI + type 3139 * 2. For other OUI, compare OUI + type + subType 3140 */ 3141 tmp_rem_len = subie_len - (tmp - sub_copy); 3142 if (tmp_old[0] == WLAN_ELEMID_VENDOR && 3143 tmp_rem_len >= MIN_VENDOR_TAG_LEN) { 3144 /* 3145 * In order to identify few Vendor APs the 3146 * generated frame should contain the reporting 3147 * APs matching VSIE or else the entry generated 3148 * will not have this VSIE and logic kept to 3149 * take certain action on specific Vendor APs 3150 * will fail. 3151 */ 3152 pos = util_copy_reporting_ap_vendor_ies(psoc, 3153 tmp_old, 3154 tmp_old[1] + MIN_IE_LEN, 3155 pos); 3156 /* If Vendor IE also presents in STA profile, 3157 * then ignore the Vendor IE which is for 3158 * reporting STA. It only needs to copy Vendor 3159 * IE from STA profile for reported BSSID. 3160 * The copy happens when going through the 3161 * remaining IEs. 3162 */ 3163 } else if (tmp_old[0] == WLAN_ELEMID_EXTN_ELEM && 3164 tmp_rem_len >= (MIN_IE_LEN + 1)) { 3165 if (tmp_old[PAYLOAD_START_POS] == 3166 tmp[PAYLOAD_START_POS]) { 3167 /* same ie, copy from subelement */ 3168 if ((pos + tmp[1] + MIN_IE_LEN) <= 3169 (new_ie + ielen)) { 3170 qdf_mem_copy(pos, tmp, 3171 tmp[1] + 3172 MIN_IE_LEN); 3173 pos += tmp[1] + MIN_IE_LEN; 3174 tmp[0] = 0; 3175 } 3176 } else { 3177 if ((pos + tmp_old[1] + MIN_IE_LEN) <= 3178 (new_ie + ielen)) { 3179 qdf_mem_copy(pos, tmp_old, 3180 tmp_old[1] + 3181 MIN_IE_LEN); 3182 pos += tmp_old[1] + 3183 MIN_IE_LEN; 3184 } 3185 } 3186 3187 } else { 3188 /* copy ie from subelement into new ie */ 3189 if ((pos + tmp[1] + MIN_IE_LEN) <= 3190 (new_ie + ielen)) { 3191 qdf_mem_copy(pos, tmp, 3192 tmp[1] + MIN_IE_LEN); 3193 pos += tmp[1] + MIN_IE_LEN; 3194 tmp[0] = 0; 3195 } 3196 } 3197 } 3198 3199 if (((tmp_old + tmp_old[1] + MIN_IE_LEN) - ie) >= 3200 (ielen - MIN_IE_LEN)) 3201 break; 3202 3203 tmp_old += tmp_old[1] + MIN_IE_LEN; 3204 } 3205 3206 /* go through subelement again to check if there is any ie not 3207 * copied to new ie, skip ssid, capability, bssid-index ie 3208 */ 3209 tmp_new = sub_copy; 3210 while ((subie_len > 0) && 3211 (((tmp_new + tmp_new[1] + MIN_IE_LEN) - sub_copy) <= 3212 subie_len)) { 3213 if (!(tmp_new[0] == WLAN_ELEMID_NONTX_BSSID_CAP || 3214 tmp_new[0] == WLAN_ELEMID_SSID || 3215 tmp_new[0] == WLAN_ELEMID_MULTI_BSSID_IDX || 3216 ((tmp_new[0] == WLAN_ELEMID_EXTN_ELEM) && 3217 (tmp_new[2] == WLAN_EXTN_ELEMID_NONINHERITANCE)))) { 3218 if ((pos + tmp_new[1] + MIN_IE_LEN) <= 3219 (new_ie + ielen)) { 3220 qdf_mem_copy(pos, tmp_new, 3221 tmp_new[1] + MIN_IE_LEN); 3222 pos += tmp_new[1] + MIN_IE_LEN; 3223 } 3224 } 3225 if (((tmp_new + tmp_new[1] + MIN_IE_LEN) - sub_copy) >= 3226 (subie_len - 1)) 3227 break; 3228 tmp_new += tmp_new[1] + MIN_IE_LEN; 3229 } 3230 3231 qdf_mem_free(sub_copy); 3232 3233 if (pos > new_ie) 3234 return pos - new_ie; 3235 else 3236 return 0; 3237 } 3238 3239 static enum nontx_profile_reasoncode 3240 util_handle_nontx_prof(uint8_t *mbssid_elem, uint8_t *subelement, 3241 uint8_t *next_subelement, 3242 struct scan_mbssid_info *mbssid_info, 3243 char *bssid, char *new_bssid) 3244 { 3245 uint8_t *mbssid_index_ie; 3246 uint32_t prof_len; 3247 3248 prof_len = subelement[TAG_LEN_POS]; 3249 /* 3250 * If we are executing the split portion of the nontx 3251 * profile present in the subsequent MBSSID, then there 3252 * is no need of any sanity check for valid BSS profile 3253 */ 3254 3255 if (mbssid_info->split_prof_continue) { 3256 if ((subelement[ID_POS] != 0) || 3257 (subelement[TAG_LEN_POS] < SPLIT_PROF_DATA_LEAST_LEN)) { 3258 return INVALID_SPLIT_PROF; 3259 } 3260 } else { 3261 if ((subelement[ID_POS] != 0) || 3262 (subelement[TAG_LEN_POS] < VALID_ELEM_LEAST_LEN)) { 3263 /* not a valid BSS profile */ 3264 return INVALID_NONTX_PROF; 3265 } 3266 } 3267 3268 if (mbssid_info->split_profile) { 3269 if (next_subelement[PAYLOAD_START_POS] != 3270 WLAN_ELEMID_NONTX_BSSID_CAP) { 3271 mbssid_info->prof_residue = true; 3272 } 3273 } 3274 3275 if (!mbssid_info->split_prof_continue && 3276 ((subelement[PAYLOAD_START_POS] != WLAN_ELEMID_NONTX_BSSID_CAP) || 3277 (subelement[NONTX_BSSID_CAP_TAG_LEN_POS] != CAP_INFO_LEN))) { 3278 /* The first element within the Nontransmitted 3279 * BSSID Profile is not the Nontransmitted 3280 * BSSID Capability element. 3281 */ 3282 return INVALID_NONTX_PROF; 3283 } 3284 3285 /* found a Nontransmitted BSSID Profile */ 3286 mbssid_index_ie = 3287 util_scan_find_ie(WLAN_ELEMID_MULTI_BSSID_IDX, 3288 (subelement + PAYLOAD_START_POS), prof_len); 3289 3290 if (!mbssid_index_ie) { 3291 if (!mbssid_info->prof_residue) 3292 return INVALID_NONTX_PROF; 3293 3294 mbssid_info->skip_bssid_copy = true; 3295 } else if ((mbssid_index_ie[TAG_LEN_POS] < 1) || 3296 (mbssid_index_ie[BSS_INDEX_POS] == 0)) { 3297 /* No valid Multiple BSSID-Index element */ 3298 return INVALID_NONTX_PROF; 3299 } 3300 3301 if (!mbssid_info->skip_bssid_copy) { 3302 qdf_mem_copy(mbssid_info->trans_bssid, 3303 bssid, QDF_MAC_ADDR_SIZE); 3304 mbssid_info->profile_num = 3305 mbssid_index_ie[BSS_INDEX_POS]; 3306 util_gen_new_bssid(bssid, 3307 mbssid_elem[MBSSID_INDICATOR_POS], 3308 mbssid_index_ie[BSS_INDEX_POS], 3309 new_bssid); 3310 qdf_mem_copy(mbssid_info->non_trans_bssid, new_bssid, 3311 QDF_MAC_ADDR_SIZE); 3312 } 3313 /* In single MBSS IE, there could be subelement holding 3314 * remaining vendor IEs of non tx profile from last MBSS IE 3315 * [split profile] and new non tx profile, hence reset 3316 * skip_bssid_copy flag after each subelement processing 3317 */ 3318 mbssid_info->skip_bssid_copy = false; 3319 return VALID_NONTX_PROF; 3320 } 3321 3322 /* 3323 * What's split profile: 3324 * If any nontransmitted BSSID profile is fragmented across 3325 * multiple MBSSID elements, then it is called split profile. 3326 * For a split profile to exist we need to have at least two 3327 * MBSSID elements as part of the RX beacon or probe response 3328 * Hence, first we need to identify the next MBSSID element 3329 * and check for the 5th bit from the starting of the next 3330 * MBSSID IE and if it does not have Nontransmitted BSSID 3331 * capability element, then it's a split profile case. 3332 */ 3333 static bool util_scan_is_split_prof_found(uint8_t *next_elem, 3334 uint8_t *ie, uint32_t ielen) 3335 { 3336 uint8_t *next_mbssid_elem; 3337 3338 if ((next_elem + MIN_IE_LEN + VALID_ELEM_LEAST_LEN) > (ie + ielen)) 3339 return false; 3340 3341 if (next_elem[0] == WLAN_ELEMID_MULTIPLE_BSSID) { 3342 if ((next_elem[TAG_LEN_POS] >= VALID_ELEM_LEAST_LEN) && 3343 (next_elem[SUBELEM_DATA_POS_FROM_MBSSID] != 3344 WLAN_ELEMID_NONTX_BSSID_CAP)) { 3345 return true; 3346 } 3347 } else { 3348 next_mbssid_elem = 3349 util_scan_find_ie(WLAN_ELEMID_MULTIPLE_BSSID, 3350 next_elem, 3351 ielen - (next_elem - ie)); 3352 if (!next_mbssid_elem) 3353 return false; 3354 3355 if ((next_mbssid_elem[TAG_LEN_POS] >= VALID_ELEM_LEAST_LEN) && 3356 (next_mbssid_elem[SUBELEM_DATA_POS_FROM_MBSSID] != 3357 WLAN_ELEMID_NONTX_BSSID_CAP)) { 3358 return true; 3359 } 3360 } 3361 3362 return false; 3363 } 3364 3365 static QDF_STATUS util_scan_parse_mbssid(struct wlan_objmgr_pdev *pdev, 3366 uint8_t *frame, qdf_size_t frame_len, 3367 uint32_t frm_subtype, 3368 struct mgmt_rx_event_params *rx_param, 3369 qdf_list_t *scan_list) 3370 { 3371 struct wlan_scan_obj *scan_obj; 3372 struct wlan_bcn_frame *bcn; 3373 struct wlan_frame_hdr *hdr; 3374 struct scan_mbssid_info mbssid_info = {0}; 3375 QDF_STATUS status; 3376 uint8_t *pos, *subelement, *next_elem; 3377 uint8_t *mbssid_elem; 3378 uint32_t subie_len, new_ie_len, ielen; 3379 uint8_t *next_subelement = NULL; 3380 uint8_t new_bssid[QDF_MAC_ADDR_SIZE], bssid[QDF_MAC_ADDR_SIZE]; 3381 uint8_t *new_ie, *split_prof_start = NULL, *split_prof_end = NULL; 3382 uint8_t *ie, *new_frame = NULL; 3383 int new_frame_len = 0, split_prof_len = 0; 3384 enum nontx_profile_reasoncode retval; 3385 uint8_t *nontx_profile = NULL; 3386 3387 scan_obj = wlan_pdev_get_scan_obj(pdev); 3388 if (!scan_obj) 3389 return QDF_STATUS_E_INVAL; 3390 3391 hdr = (struct wlan_frame_hdr *)frame; 3392 bcn = (struct wlan_bcn_frame *)(frame + sizeof(struct wlan_frame_hdr)); 3393 ie = (uint8_t *)&bcn->ie; 3394 ielen = (uint16_t)(frame_len - 3395 sizeof(struct wlan_frame_hdr) - 3396 offsetof(struct wlan_bcn_frame, ie)); 3397 qdf_mem_copy(bssid, hdr->i_addr3, QDF_MAC_ADDR_SIZE); 3398 3399 if (!util_scan_find_ie(WLAN_ELEMID_MULTIPLE_BSSID, ie, ielen)) 3400 return QDF_STATUS_E_FAILURE; 3401 3402 pos = ie; 3403 3404 new_ie = qdf_mem_malloc(ielen); 3405 if (!new_ie) 3406 return QDF_STATUS_E_NOMEM; 3407 3408 while (pos < (ie + ielen + MIN_IE_LEN)) { 3409 mbssid_elem = 3410 util_scan_find_ie(WLAN_ELEMID_MULTIPLE_BSSID, pos, 3411 ielen - (pos - ie)); 3412 if (!mbssid_elem) 3413 break; 3414 3415 /* 3416 * The max_bssid_indicator field is mandatory, therefore the 3417 * length of the MBSSID element should atleast be 1. 3418 */ 3419 if (!mbssid_elem[TAG_LEN_POS]) { 3420 scm_debug_rl("MBSSID IE is of length zero"); 3421 break; 3422 } 3423 3424 mbssid_info.profile_count = 3425 (1 << mbssid_elem[MBSSID_INDICATOR_POS]); 3426 3427 next_elem = 3428 mbssid_elem + mbssid_elem[TAG_LEN_POS] + MIN_IE_LEN; 3429 3430 /* Skip Element ID, Len, MaxBSSID Indicator */ 3431 if (!mbssid_info.split_profile && 3432 (mbssid_elem[TAG_LEN_POS] < VALID_ELEM_LEAST_LEN)) { 3433 break; 3434 } 3435 3436 /* 3437 * Find if the next IE is MBSSID, if not, then scan through 3438 * the IE list and find the next MBSSID tag, if present. 3439 * Once we find the MBSSID tag, check if this MBSSID tag has 3440 * the other fragmented part of the non Tx profile. 3441 */ 3442 3443 mbssid_info.split_profile = 3444 util_scan_is_split_prof_found(next_elem, ie, ielen); 3445 3446 for (subelement = mbssid_elem + SUBELEMENT_START_POS; 3447 subelement < (next_elem - 1); 3448 subelement += MIN_IE_LEN + subelement[TAG_LEN_POS]) { 3449 subie_len = subelement[TAG_LEN_POS]; 3450 3451 /* 3452 * if prof_residue is true, that means we are 3453 * in the continuation of the fragmented profile part, 3454 * present in the next MBSSD IE else this profile 3455 * is a non fragmented non tx BSSID profile. 3456 */ 3457 3458 if (mbssid_info.prof_residue) 3459 mbssid_info.split_prof_continue = true; 3460 else 3461 mbssid_info.split_prof_continue = false; 3462 3463 if (subie_len > MAX_SUBELEM_LEN) { 3464 scm_debug_rl("Corrupt frame with subie_len: %d " 3465 "split_prof_continue: %d,prof_residue: %d", 3466 subie_len, 3467 mbssid_info.split_prof_continue, 3468 mbssid_info.prof_residue); 3469 if (mbssid_info.split_prof_continue) { 3470 qdf_mem_free(split_prof_start); 3471 split_prof_start = NULL; 3472 } 3473 3474 qdf_mem_free(new_ie); 3475 return QDF_STATUS_E_INVAL; 3476 } 3477 3478 if ((next_elem - subelement) < 3479 (MIN_IE_LEN + subie_len)) 3480 break; 3481 3482 next_subelement = subelement + subie_len + MIN_IE_LEN; 3483 retval = util_handle_nontx_prof(mbssid_elem, subelement, 3484 next_subelement, 3485 &mbssid_info, 3486 bssid, new_bssid); 3487 3488 if (retval == INVALID_SPLIT_PROF) { 3489 scm_debug_rl("Corrupt frame with ID_POS: %d,TAG_LEN_POS: %d", 3490 subelement[ID_POS], 3491 subelement[TAG_LEN_POS]); 3492 qdf_mem_free(split_prof_start); 3493 split_prof_start = NULL; 3494 qdf_mem_free(new_ie); 3495 return QDF_STATUS_E_INVAL; 3496 } else if (retval == INVALID_NONTX_PROF) { 3497 continue; 3498 } 3499 3500 /* 3501 * Merging parts of nontx profile- 3502 * Just for understanding, let's make an assumption 3503 * that nontx profile is fragmented across MBSSIE1 3504 * and MBSSIE2. 3505 * mbssid_info.prof_residue being set indicates 3506 * that the ongoing nontx profile is part of split 3507 * profile, whose other fragmented part is present 3508 * in MBSSIE2. 3509 * So once prof_residue is set, we need to 3510 * identify whether we are accessing the split 3511 * profile in MBSSIE1 or MBSSIE2. 3512 * If we are in MBSSIE1, then copy the part of split 3513 * profile from MBSSIE1 into a new buffer and then 3514 * move to the next part of the split profile which 3515 * is present in MBSSIE2 and append that part into 3516 * the new buffer. 3517 * Once the full profile is accumulated, go ahead with 3518 * the ie generation and length calculation of the 3519 * new frame. 3520 */ 3521 3522 if (mbssid_info.prof_residue) { 3523 if (!mbssid_info.split_prof_continue) { 3524 split_prof_start = 3525 qdf_mem_malloc(ielen); 3526 if (!split_prof_start) { 3527 scm_err_rl("Malloc failed"); 3528 qdf_mem_free(new_ie); 3529 return QDF_STATUS_E_NOMEM; 3530 } 3531 3532 qdf_mem_copy(split_prof_start, 3533 subelement, 3534 (subie_len + 3535 MIN_IE_LEN)); 3536 split_prof_end = (split_prof_start + 3537 subie_len + 3538 MIN_IE_LEN); 3539 break; 3540 } 3541 3542 /* 3543 * Currently we are accessing other part of the 3544 * split profile present in the subsequent 3545 * MBSSIE. There is a possibility that one 3546 * non tx profile is spread across more than 3547 * two MBSSID tag as well. This code will 3548 * handle such scenario. 3549 */ 3550 3551 if (split_prof_end) { 3552 qdf_mem_copy(split_prof_end, 3553 (subelement + MIN_IE_LEN), 3554 subie_len); 3555 split_prof_end += subie_len; 3556 } 3557 3558 /* 3559 * When to stop the process of accumulating 3560 * parts of split profile, is decided by 3561 * mbssid_info.prof_residue. prof_residue 3562 * could be made false if there is not any 3563 * continuation of the split profile. 3564 * which could be identified by two factors 3565 * 1. By checking if the next MBSSIE's first 3566 * non tx profile is not a fragmented one or 3567 * 2. there is a probability that first 3568 * subelement of MBSSIE2 is end if split 3569 * profile and the next subelement of MBSSIE2 3570 * is a non split one. 3571 */ 3572 3573 if (!mbssid_info.split_profile || 3574 (next_subelement[PAYLOAD_START_POS] == 3575 WLAN_ELEMID_NONTX_BSSID_CAP)) { 3576 mbssid_info.prof_residue = false; 3577 } 3578 3579 /* 3580 * Until above mentioned conditions are met, 3581 * we need to iterate and keep accumulating 3582 * the split profile contents. 3583 */ 3584 3585 if (mbssid_info.prof_residue) 3586 break; 3587 3588 if (split_prof_end) { 3589 split_prof_len = 3590 (split_prof_end - 3591 split_prof_start - MIN_IE_LEN); 3592 } 3593 } 3594 3595 if (mbssid_info.split_prof_continue) { 3596 if (!split_prof_start) 3597 break; 3598 nontx_profile = split_prof_start; 3599 subie_len = split_prof_len; 3600 } else { 3601 nontx_profile = subelement; 3602 } 3603 3604 new_ie_len = 3605 util_gen_new_ie(pdev, ie, ielen, 3606 (nontx_profile + 3607 PAYLOAD_START_POS), 3608 subie_len, new_ie, 3609 mbssid_info.profile_num); 3610 3611 if (!new_ie_len) { 3612 if (mbssid_info.split_prof_continue) { 3613 qdf_mem_free(split_prof_start); 3614 split_prof_start = NULL; 3615 split_prof_end = NULL; 3616 split_prof_len = 0; 3617 } 3618 continue; 3619 } 3620 3621 new_frame_len = frame_len - ielen + new_ie_len; 3622 3623 if (new_frame_len < 0 || new_frame_len > frame_len) { 3624 if (mbssid_info.split_prof_continue) { 3625 qdf_mem_free(split_prof_start); 3626 split_prof_start = NULL; 3627 } 3628 qdf_mem_free(new_ie); 3629 scm_debug_rl("Invalid frame:Stop MBSSIE parsing, Frame_len: %zu " 3630 "ielen:%u,new_ie_len:%u", 3631 frame_len, ielen, new_ie_len); 3632 return QDF_STATUS_E_INVAL; 3633 } 3634 3635 new_frame = qdf_mem_malloc(new_frame_len); 3636 if (!new_frame) { 3637 if (mbssid_info.split_prof_continue) { 3638 qdf_mem_free(split_prof_start); 3639 split_prof_start = NULL; 3640 } 3641 qdf_mem_free(new_ie); 3642 scm_err_rl("Malloc for new_frame failed"); 3643 scm_err_rl("split_prof_continue: %d", 3644 mbssid_info.split_prof_continue); 3645 return QDF_STATUS_E_NOMEM; 3646 } 3647 3648 /* 3649 * Copy the header(24byte), timestamp(8 byte), 3650 * beaconinterval(2byte) and capability(2byte) 3651 */ 3652 qdf_mem_copy(new_frame, frame, FIXED_LENGTH); 3653 /* Copy the new ie generated from MBSSID profile*/ 3654 hdr = (struct wlan_frame_hdr *)new_frame; 3655 qdf_mem_copy(hdr->i_addr2, new_bssid, 3656 QDF_MAC_ADDR_SIZE); 3657 qdf_mem_copy(hdr->i_addr3, new_bssid, 3658 QDF_MAC_ADDR_SIZE); 3659 bcn = (struct wlan_bcn_frame *) 3660 (new_frame + sizeof(struct wlan_frame_hdr)); 3661 /* update the non-tx capability */ 3662 qdf_mem_copy(&bcn->capability, 3663 nontx_profile + CAP_INFO_POS, 3664 CAP_INFO_LEN); 3665 3666 /* Copy the new ie generated from MBSSID profile*/ 3667 qdf_mem_copy(new_frame + 3668 offsetof(struct wlan_bcn_frame, ie) + 3669 sizeof(struct wlan_frame_hdr), 3670 new_ie, new_ie_len); 3671 if (scan_obj->cb.inform_mbssid_bcn_prb_rsp) 3672 scan_obj->cb.inform_mbssid_bcn_prb_rsp( 3673 new_frame, new_frame_len, 3674 frm_subtype, new_bssid); 3675 3676 status = util_scan_gen_scan_entry(pdev, new_frame, 3677 new_frame_len, 3678 frm_subtype, 3679 rx_param, 3680 &mbssid_info, 3681 scan_list); 3682 if (QDF_IS_STATUS_ERROR(status)) { 3683 if (mbssid_info.split_prof_continue) { 3684 qdf_mem_free(split_prof_start); 3685 split_prof_start = NULL; 3686 split_prof_end = NULL; 3687 split_prof_len = 0; 3688 qdf_mem_zero(&mbssid_info, 3689 sizeof(mbssid_info)); 3690 } 3691 qdf_mem_free(new_frame); 3692 scm_debug_rl("failed to generate a scan entry " 3693 "split_prof_continue: %d", 3694 mbssid_info.split_prof_continue); 3695 break; 3696 } 3697 /* scan entry makes its own copy so free the frame*/ 3698 if (mbssid_info.split_prof_continue) { 3699 qdf_mem_free(split_prof_start); 3700 split_prof_start = NULL; 3701 split_prof_end = NULL; 3702 split_prof_len = 0; 3703 } 3704 qdf_mem_free(new_frame); 3705 } 3706 3707 pos = next_elem; 3708 } 3709 qdf_mem_free(new_ie); 3710 3711 if (split_prof_start) 3712 qdf_mem_free(split_prof_start); 3713 3714 return QDF_STATUS_SUCCESS; 3715 } 3716 #else 3717 static QDF_STATUS util_scan_parse_mbssid(struct wlan_objmgr_pdev *pdev, 3718 uint8_t *frame, qdf_size_t frame_len, 3719 uint32_t frm_subtype, 3720 struct mgmt_rx_event_params *rx_param, 3721 qdf_list_t *scan_list) 3722 { 3723 return QDF_STATUS_SUCCESS; 3724 } 3725 #endif 3726 3727 #if defined(WLAN_FEATURE_11BE) && defined(WLAN_FEATURE_11BE_MLO_MBSSID) 3728 /* 3729 * util_scan_gen_txvap_scan_entry() - Strip out the MBSSID tag from the received 3730 * frame and update the modified frame length before generating a scan entry. 3731 * It is redundant to have MBSSID information as part of the TX vap/ profile 3732 * specific scan entry. 3733 * 3734 * @pdev: pdev context 3735 * @frame: Unsoiled frame passed from util_scan_parse_beacon_frame() 3736 * @frame_len: Length of the unsoiled frame 3737 * @ie_list: Points to the start of IE list in parent/ unsoiled frame 3738 * @ielen: Length of the complete IE list from parent/ unsoiled frame 3739 * @frm_subtype: Frame subtype 3740 * @rx_param: host mgmt header params 3741 * @scan_list: Scan entry list of bss candidates after filtering 3742 * @mbssid_info: Data structure to carry MBSSID information 3743 * 3744 * Return: False if the scan entry generation is not successful 3745 */ 3746 static QDF_STATUS 3747 util_scan_gen_txvap_scan_entry(struct wlan_objmgr_pdev *pdev, 3748 uint8_t *frame, qdf_size_t frame_len, 3749 uint8_t *ie_list, uint32_t ielen, 3750 uint32_t frm_subtype, 3751 struct mgmt_rx_event_params *rx_param, 3752 qdf_list_t *scan_list, 3753 struct scan_mbssid_info *mbssid_info) 3754 { 3755 uint8_t *src_ie, *dest_ptr, *container; 3756 uint16_t new_frame_len, new_ie_len = 0; 3757 uint8_t *trimmed_frame, fixed_len = 0; 3758 QDF_STATUS status = QDF_STATUS_SUCCESS; 3759 3760 /* 3761 * Allocate a buffer to copy only the TX VAP information after 3762 * stripping out the MBSSID IE from the parent beacon. 3763 * The allocation size should be the size of a frame as at 3764 * this point it is unknown what would be the new frame length 3765 * after stripping the MBSSID IE. 3766 */ 3767 container = qdf_mem_malloc(frame_len); 3768 if (!container) { 3769 scm_err_rl("Malloc for container failed"); 3770 return QDF_STATUS_E_NOMEM; 3771 } 3772 3773 dest_ptr = &container[0]; 3774 fixed_len = sizeof(struct wlan_frame_hdr) + 3775 offsetof(struct wlan_bcn_frame, ie); 3776 3777 /*Copy the data till IE list before procesisng the IE one by one*/ 3778 qdf_mem_copy(dest_ptr, frame, fixed_len); 3779 3780 dest_ptr += fixed_len; 3781 src_ie = ie_list; 3782 3783 /* 3784 * Go through the IE list from the parent beacon and copy one by one. 3785 * Skip copying it to the container if it's an MBSSID tag. 3786 */ 3787 while (((src_ie + src_ie[TAG_LEN_POS] + MIN_IE_LEN) - 3788 ie_list) <= ielen) { 3789 if (src_ie[ID_POS] == WLAN_ELEMID_MULTIPLE_BSSID) { 3790 src_ie += src_ie[TAG_LEN_POS] + MIN_IE_LEN; 3791 continue; 3792 } 3793 3794 qdf_mem_copy(dest_ptr, src_ie, 3795 (src_ie[TAG_LEN_POS] + MIN_IE_LEN)); 3796 3797 dest_ptr += src_ie[TAG_LEN_POS] + MIN_IE_LEN; 3798 if (((src_ie + src_ie[TAG_LEN_POS] + 3799 MIN_IE_LEN) - ie_list) >= ielen) 3800 break; 3801 3802 src_ie += src_ie[TAG_LEN_POS] + MIN_IE_LEN; 3803 } 3804 3805 if (dest_ptr > container) 3806 new_ie_len = dest_ptr - (container + fixed_len); 3807 3808 new_frame_len = frame_len - ielen + new_ie_len; 3809 3810 /* 3811 * At the start of this handler, we have allocated a memory block 3812 * of size same as a full beacon frame size, as we are not sure 3813 * of what would be the size of the new frame. After stripping out 3814 * the MBSSID tag from the parent beacon, there are some unused 3815 * memory. Hence do another malloc of the new frame length 3816 * (length of the new frame which has only TX VAP information) 3817 * and copy the needed data from the container, then free the 3818 * memory corresponds to container. 3819 * Post copy, use the trimmed frame and the new frame length 3820 * to generate scan entry for the TX profile. 3821 */ 3822 trimmed_frame = qdf_mem_malloc(new_frame_len); 3823 if (!trimmed_frame) { 3824 scm_err_rl("Malloc for trimmed frame failed"); 3825 qdf_mem_free(container); 3826 return QDF_STATUS_E_NOMEM; 3827 } 3828 3829 qdf_mem_copy(trimmed_frame, container, new_frame_len); 3830 qdf_mem_free(container); 3831 3832 status = util_scan_gen_scan_entry(pdev, trimmed_frame, 3833 new_frame_len, 3834 frm_subtype, 3835 rx_param, 3836 mbssid_info, 3837 scan_list); 3838 3839 if (QDF_IS_STATUS_ERROR(status)) 3840 scm_debug_rl("Failed to create a scan entry"); 3841 3842 qdf_mem_free(trimmed_frame); 3843 return status; 3844 } 3845 3846 /* 3847 * util_scan_parse_eht_beacon() : This API will be executed 3848 * only for 11BE platforms as per current design. 3849 * IF MBSSID IE is present in the beacon then 3850 * scan component will create a new entry for 3851 * each BSSID found in the MBSSID 3852 * util_scan_parse_mbssid() takes care of creating 3853 * scan entries for every non tx profile present in 3854 * the MBSSID tag. 3855 * util_scan_gen_txvap_scan_entry() helps in generating 3856 * scan entry for the tx profile. 3857 */ 3858 static QDF_STATUS 3859 util_scan_parse_eht_beacon(struct wlan_objmgr_pdev *pdev, 3860 uint8_t *frame, qdf_size_t frame_len, 3861 uint8_t *ie_list, uint32_t ielen, 3862 uint32_t frm_subtype, 3863 struct mgmt_rx_event_params *rx_param, 3864 qdf_list_t *scan_list, 3865 struct scan_mbssid_info *mbssid_info, 3866 uint8_t *mbssid_ie) 3867 { 3868 QDF_STATUS status = QDF_STATUS_SUCCESS; 3869 3870 if (mbssid_ie && ie_list) { 3871 if (ie_list[TAG_LEN_POS] <= 0) { 3872 scm_debug_rl("Corrupt IE"); 3873 return QDF_STATUS_E_INVAL; 3874 } 3875 3876 status = util_scan_parse_mbssid(pdev, frame, frame_len, 3877 frm_subtype, rx_param, 3878 scan_list); 3879 3880 if (QDF_IS_STATUS_ERROR(status)) { 3881 scm_debug_rl("NonTx prof: Failed to create scan entry"); 3882 return status; 3883 } 3884 3885 status = util_scan_gen_txvap_scan_entry(pdev, frame, 3886 frame_len, ie_list, 3887 ielen, frm_subtype, 3888 rx_param, scan_list, 3889 mbssid_info); 3890 3891 if (QDF_IS_STATUS_ERROR(status)) 3892 scm_debug_rl("TX prof: Failed to create scan entry"); 3893 3894 return status; 3895 } 3896 3897 /*For Non MBSSIE case*/ 3898 status = util_scan_gen_scan_entry(pdev, frame, frame_len, 3899 frm_subtype, rx_param, 3900 mbssid_info, scan_list); 3901 3902 if (QDF_IS_STATUS_ERROR(status)) 3903 scm_debug_rl("Non-MBSSIE frame: Failed to create scan entry"); 3904 3905 return status; 3906 } 3907 3908 static bool 3909 util_scan_is_platform_eht_capable(struct wlan_objmgr_pdev *pdev) 3910 { 3911 struct wlan_objmgr_psoc *psoc = NULL; 3912 struct wlan_lmac_if_tx_ops *tx_ops = NULL; 3913 struct wlan_lmac_if_scan_tx_ops *scan_ops = NULL; 3914 uint8_t pdev_id; 3915 3916 psoc = wlan_pdev_get_psoc(pdev); 3917 if (!psoc) { 3918 scm_debug_rl("psoc is null"); 3919 return false; 3920 } 3921 tx_ops = wlan_psoc_get_lmac_if_txops(psoc); 3922 if (!tx_ops) { 3923 scm_debug_rl("tx_ops is null"); 3924 return false; 3925 } 3926 scan_ops = &tx_ops->scan; 3927 if (!scan_ops) { 3928 scm_debug_rl("scan_ops is null"); 3929 return false; 3930 } 3931 pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev); 3932 3933 if (scan_ops->is_platform_eht_capable) 3934 return scan_ops->is_platform_eht_capable(psoc, pdev_id); 3935 3936 return false; 3937 } 3938 #else 3939 static QDF_STATUS 3940 util_scan_parse_eht_beacon(struct wlan_objmgr_pdev *pdev, 3941 uint8_t *frame, qdf_size_t frame_len, 3942 uint8_t *ie_list, uint32_t ielen, 3943 uint32_t frm_subtype, 3944 struct mgmt_rx_event_params *rx_param, 3945 qdf_list_t *scan_list, 3946 struct scan_mbssid_info *mbssid_info, 3947 uint8_t *mbssid_ie) 3948 { 3949 return QDF_STATUS_SUCCESS; 3950 } 3951 3952 static bool 3953 util_scan_is_platform_eht_capable(struct wlan_objmgr_pdev *pdev) 3954 { 3955 return false; 3956 } 3957 #endif 3958 3959 static QDF_STATUS 3960 util_scan_parse_beacon_frame(struct wlan_objmgr_pdev *pdev, 3961 uint8_t *frame, 3962 qdf_size_t frame_len, 3963 uint32_t frm_subtype, 3964 struct mgmt_rx_event_params *rx_param, 3965 qdf_list_t *scan_list) 3966 { 3967 struct wlan_bcn_frame *bcn; 3968 struct wlan_frame_hdr *hdr; 3969 uint8_t *mbssid_ie = NULL, *extcap_ie; 3970 uint32_t ie_len = 0; 3971 QDF_STATUS status = QDF_STATUS_E_FAILURE; 3972 struct scan_mbssid_info mbssid_info = { 0 }; 3973 uint8_t *ie_list; 3974 bool eht_support = false; 3975 3976 hdr = (struct wlan_frame_hdr *)frame; 3977 bcn = (struct wlan_bcn_frame *) 3978 (frame + sizeof(struct wlan_frame_hdr)); 3979 ie_list = (uint8_t *)&bcn->ie; 3980 ie_len = (uint16_t)(frame_len - 3981 sizeof(struct wlan_frame_hdr) - 3982 offsetof(struct wlan_bcn_frame, ie)); 3983 3984 extcap_ie = util_scan_find_ie(WLAN_ELEMID_XCAPS, 3985 (uint8_t *)&bcn->ie, ie_len); 3986 /* Process MBSSID when Multiple BSSID (Bit 22) is set in Ext Caps */ 3987 if (extcap_ie && 3988 extcap_ie[1] >= 3 && extcap_ie[1] <= WLAN_EXTCAP_IE_MAX_LEN && 3989 (extcap_ie[4] & 0x40)) { 3990 mbssid_ie = util_scan_find_ie(WLAN_ELEMID_MULTIPLE_BSSID, 3991 (uint8_t *)&bcn->ie, ie_len); 3992 if (mbssid_ie) { 3993 /* some APs announce the MBSSID ie_len as 1 */ 3994 if (mbssid_ie[TAG_LEN_POS] < 1) { 3995 scm_debug("MBSSID IE length is wrong %d", 3996 mbssid_ie[TAG_LEN_POS]); 3997 return status; 3998 } 3999 qdf_mem_copy(&mbssid_info.trans_bssid, 4000 hdr->i_addr3, QDF_MAC_ADDR_SIZE); 4001 mbssid_info.profile_count = 1 << mbssid_ie[2]; 4002 } 4003 } 4004 4005 eht_support = util_scan_is_platform_eht_capable(pdev); 4006 4007 if (eht_support) { 4008 status = util_scan_parse_eht_beacon(pdev, frame, frame_len, 4009 ie_list, ie_len, 4010 frm_subtype, rx_param, 4011 scan_list, &mbssid_info, 4012 mbssid_ie); 4013 return status; 4014 } 4015 4016 status = util_scan_gen_scan_entry(pdev, frame, frame_len, 4017 frm_subtype, rx_param, 4018 &mbssid_info, 4019 scan_list); 4020 4021 if (mbssid_ie) 4022 status = util_scan_parse_mbssid(pdev, frame, frame_len, 4023 frm_subtype, rx_param, 4024 scan_list); 4025 4026 if (QDF_IS_STATUS_ERROR(status)) 4027 scm_debug_rl("Failed to create scan entry"); 4028 4029 return status; 4030 } 4031 4032 qdf_list_t * 4033 util_scan_unpack_beacon_frame(struct wlan_objmgr_pdev *pdev, uint8_t *frame, 4034 qdf_size_t frame_len, uint32_t frm_subtype, 4035 struct mgmt_rx_event_params *rx_param) 4036 { 4037 qdf_list_t *scan_list; 4038 QDF_STATUS status; 4039 4040 scan_list = qdf_mem_malloc_atomic(sizeof(*scan_list)); 4041 if (!scan_list) { 4042 scm_err("failed to allocate scan_list"); 4043 return NULL; 4044 } 4045 qdf_list_create(scan_list, MAX_SCAN_CACHE_SIZE); 4046 4047 status = util_scan_parse_beacon_frame(pdev, frame, frame_len, 4048 frm_subtype, rx_param, 4049 scan_list); 4050 if (QDF_IS_STATUS_ERROR(status)) { 4051 ucfg_scan_purge_results(scan_list); 4052 return NULL; 4053 } 4054 4055 return scan_list; 4056 } 4057 4058 QDF_STATUS 4059 util_scan_entry_update_mlme_info(struct wlan_objmgr_pdev *pdev, 4060 struct scan_cache_entry *scan_entry) 4061 { 4062 4063 if (!pdev || !scan_entry) { 4064 scm_err("pdev 0x%pK, scan_entry: 0x%pK", pdev, scan_entry); 4065 return QDF_STATUS_E_INVAL; 4066 } 4067 4068 return scm_update_scan_mlme_info(pdev, scan_entry); 4069 } 4070 4071 bool util_is_scan_completed(struct scan_event *event, bool *success) 4072 { 4073 if ((event->type == SCAN_EVENT_TYPE_COMPLETED) || 4074 (event->type == SCAN_EVENT_TYPE_DEQUEUED) || 4075 (event->type == SCAN_EVENT_TYPE_START_FAILED)) { 4076 if ((event->type == SCAN_EVENT_TYPE_COMPLETED) && 4077 (event->reason == SCAN_REASON_COMPLETED)) 4078 *success = true; 4079 else 4080 *success = false; 4081 4082 return true; 4083 } 4084 4085 *success = false; 4086 return false; 4087 } 4088 4089 #if defined(WLAN_SAE_SINGLE_PMK) && defined(WLAN_FEATURE_ROAM_OFFLOAD) 4090 bool 4091 util_scan_entry_single_pmk(struct wlan_objmgr_psoc *psoc, 4092 struct scan_cache_entry *scan_entry) 4093 { 4094 if (scan_entry->ie_list.single_pmk && 4095 wlan_mlme_is_sae_single_pmk_enabled(psoc)) 4096 return true; 4097 4098 return false; 4099 } 4100 #endif 4101 4102 bool util_is_bssid_non_tx(struct wlan_objmgr_psoc *psoc, 4103 struct qdf_mac_addr *bssid, qdf_freq_t freq) 4104 { 4105 int i; 4106 qdf_list_node_t *cur_node, *next_node; 4107 struct meta_rnr_channel *channel; 4108 struct scan_rnr_node *rnr_node; 4109 struct channel_list_db *rnr_channel_db; 4110 bool ret = false; 4111 4112 if (!psoc) 4113 return false; 4114 4115 rnr_channel_db = scm_get_rnr_channel_db(psoc); 4116 if (!rnr_channel_db) 4117 return false; 4118 4119 for (i = 0; i < QDF_ARRAY_SIZE(rnr_channel_db->channel); i++) { 4120 channel = &rnr_channel_db->channel[i]; 4121 if (channel->chan_freq != freq) 4122 continue; 4123 4124 cur_node = NULL; 4125 qdf_list_peek_front(&channel->rnr_list, &cur_node); 4126 4127 while (cur_node) { 4128 next_node = NULL; 4129 qdf_list_peek_next(&channel->rnr_list, cur_node, 4130 &next_node); 4131 rnr_node = qdf_container_of(cur_node, 4132 struct scan_rnr_node, 4133 node); 4134 if (qdf_is_macaddr_equal(&rnr_node->entry.bssid, bssid) && 4135 (rnr_node->entry.bss_params & 4136 TBTT_BSS_PARAM_MBSSID_TX_MASK) == 4137 TBTT_BSS_PARAM_MBSSID_NONTX_MASK) { 4138 ret = true; 4139 break; 4140 } 4141 cur_node = next_node; 4142 } 4143 } 4144 4145 return ret; 4146 } 4147