1 /* 2 * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved. 3 * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved. 4 * 5 * Permission to use, copy, modify, and/or distribute this software for any 6 * purpose with or without fee is hereby granted, provided that the above 7 * copyright notice and this permission notice appear in all copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 */ 17 18 /** 19 * DOC: contains bss scoring logic 20 */ 21 22 #ifdef WLAN_POLICY_MGR_ENABLE 23 #include "wlan_policy_mgr_api.h" 24 #endif 25 #include <include/wlan_psoc_mlme.h> 26 #include "wlan_psoc_mlme_api.h" 27 #include "cfg_ucfg_api.h" 28 #include "wlan_cm_bss_score_param.h" 29 #include "wlan_scan_api.h" 30 #include "wlan_crypto_global_api.h" 31 #include "wlan_mgmt_txrx_utils_api.h" 32 #ifdef CONN_MGR_ADV_FEATURE 33 #include "wlan_mlme_api.h" 34 #include "wlan_wfa_tgt_if_tx_api.h" 35 #endif 36 37 #define CM_PCL_RSSI_THRESHOLD -75 38 39 #define CM_BAND_2G_INDEX 0 40 #define CM_BAND_5G_INDEX 1 41 #define CM_BAND_6G_INDEX 2 42 /* 3 is reserved */ 43 #define CM_MAX_BAND_INDEX 4 44 45 #define CM_SCORE_INDEX_0 0 46 #define CM_SCORE_INDEX_3 3 47 #define CM_SCORE_INDEX_7 7 48 #define CM_SCORE_OFFSET_INDEX_7_4 4 49 #define CM_SCORE_INDEX_11 11 50 #define CM_SCORE_OFFSET_INDEX_11_8 8 51 #define CM_SCORE_MAX_INDEX 15 52 #define CM_SCORE_OFFSET_INDEX_15_12 12 53 54 #define CM_MAX_OCE_WAN_DL_CAP 16 55 56 #define CM_MAX_CHANNEL_WEIGHT 100 57 #define CM_MAX_CHANNEL_UTILIZATION 100 58 #define CM_MAX_ESTIMATED_AIR_TIME_FRACTION 255 59 #define CM_MAX_AP_LOAD 255 60 61 #define CM_MAX_WEIGHT_OF_PCL_CHANNELS 255 62 #define CM_PCL_GROUPS_WEIGHT_DIFFERENCE 20 63 64 /* Congestion threshold (channel load %) to consider band and OCE WAN score */ 65 #define CM_CONGESTION_THRSHOLD_FOR_BAND_OCE_SCORE 75 66 67 #define CM_RSSI_WEIGHTAGE 20 68 #define CM_HT_CAPABILITY_WEIGHTAGE 2 69 #define CM_VHT_CAP_WEIGHTAGE 1 70 #define CM_HE_CAP_WEIGHTAGE 2 71 #define CM_CHAN_WIDTH_WEIGHTAGE 12 72 #define CM_CHAN_BAND_WEIGHTAGE 2 73 #define CM_NSS_WEIGHTAGE 20 74 #define CM_SECURITY_WEIGHTAGE 4 75 #define CM_BEAMFORMING_CAP_WEIGHTAGE 2 76 #define CM_PCL_WEIGHT 10 77 #define CM_CHANNEL_CONGESTION_WEIGHTAGE 5 78 #define CM_OCE_WAN_WEIGHTAGE 2 79 #define CM_OCE_AP_TX_POWER_WEIGHTAGE 5 80 #define CM_OCE_SUBNET_ID_WEIGHTAGE 3 81 #define CM_SAE_PK_AP_WEIGHTAGE 30 82 #define CM_BEST_CANDIDATE_MAX_WEIGHT 200 83 #define CM_MAX_PCT_SCORE 100 84 #define CM_MAX_INDEX_PER_INI 4 85 #define CM_SLO_CONGESTION_MAX_SCORE 80 86 #define CM_ASSOC_INK_BEST_BOOST 20 87 88 /* 89 * This macro give percentage value of security_weightage to be used as per 90 * security Eg if AP security is WPA 10% will be given for AP. 91 * 92 * Indexes are defined in this way. 93 * 0 Index (BITS 0-7): WPA - Def 25% 94 * 1 Index (BITS 8-15): WPA2- Def 50% 95 * 2 Index (BITS 16-23): WPA3- Def 100% 96 * 3 Index (BITS 24-31): reserved 97 * 98 * if AP security is Open/WEP 0% will be given for AP 99 * These percentage values are stored in HEX. For any index max value, can be 64 100 */ 101 #define CM_SECURITY_INDEX_WEIGHTAGE 0x00643219 102 103 #define CM_BEST_CANDIDATE_MAX_BSS_SCORE (CM_BEST_CANDIDATE_MAX_WEIGHT * 100) 104 #define CM_AVOID_CANDIDATE_MIN_SCORE 1 105 106 #define CM_GET_SCORE_PERCENTAGE(value32, bw_index) \ 107 QDF_GET_BITS(value32, (8 * (bw_index)), 8) 108 #define CM_SET_SCORE_PERCENTAGE(value32, score_pcnt, bw_index) \ 109 QDF_SET_BITS(value32, (8 * (bw_index)), 8, score_pcnt) 110 111 #ifdef CONN_MGR_ADV_FEATURE 112 /* 3.2 us + 0.8 us(GI) */ 113 #define PPDU_PAYLOAD_SYMBOL_DUR_US 4 114 /* 12.8 us + (0.8 + 1.6)/2 us(GI) */ 115 #define HE_PPDU_PAYLOAD_SYMBOL_DUR_US 14 116 #define MAC_HEADER_LEN 26 117 /* Minimum snrDb supported by LUT */ 118 #define SNR_DB_TO_BIT_PER_TONE_LUT_MIN -10 119 /* Maximum snrDb supported by LUT */ 120 #define SNR_DB_TO_BIT_PER_TONE_LUT_MAX 9 121 #define DB_NUM 20 122 /* 123 * A fudge factor to represent HW implementation margin in dB. 124 * Predicted throughput matches pretty well with OTA throughput with this 125 * fudge factor. 126 */ 127 #define SNR_MARGIN_DB 16 128 #define TWO_IN_DB 3 129 static int32_t 130 SNR_DB_TO_BIT_PER_TONE_LUT[DB_NUM] = {0, 171, 212, 262, 323, 396, 484, 131 586, 706, 844, 1000, 1176, 1370, 1583, 1812, 2058, 2317, 2588, 2870, 3161}; 132 #endif 133 134 /* MLO link types */ 135 enum MLO_TYPE { 136 SLO, 137 MLSR, 138 MLMR, 139 MLO_TYPE_MAX 140 }; 141 142 static bool cm_is_better_bss(struct scan_cache_entry *bss1, 143 struct scan_cache_entry *bss2) 144 { 145 if (bss1->bss_score > bss2->bss_score) 146 return true; 147 else if (bss1->bss_score == bss2->bss_score) 148 if (bss1->rssi_raw > bss2->rssi_raw) 149 return true; 150 151 return false; 152 } 153 154 /** 155 * cm_get_rssi_pcnt_for_slot() - calculate rssi % score based on the slot 156 * index between the high rssi and low rssi threshold 157 * @high_rssi_threshold: High rssi of the window 158 * @low_rssi_threshold: low rssi of the window 159 * @high_rssi_pcnt: % score for the high rssi 160 * @low_rssi_pcnt: %score for the low rssi 161 * @bucket_size: bucket size of the window 162 * @bss_rssi: Input rssi for which value need to be calculated 163 * 164 * Return: rssi pct to use for the given rssi 165 */ 166 static inline 167 int8_t cm_get_rssi_pcnt_for_slot(int32_t high_rssi_threshold, 168 int32_t low_rssi_threshold, 169 uint32_t high_rssi_pcnt, 170 uint32_t low_rssi_pcnt, 171 uint32_t bucket_size, int8_t bss_rssi) 172 { 173 int8_t slot_index, slot_size, rssi_diff, num_slot, rssi_pcnt; 174 175 num_slot = ((high_rssi_threshold - 176 low_rssi_threshold) / bucket_size) + 1; 177 slot_size = ((high_rssi_pcnt - low_rssi_pcnt) + 178 (num_slot / 2)) / (num_slot); 179 rssi_diff = high_rssi_threshold - bss_rssi; 180 slot_index = (rssi_diff / bucket_size) + 1; 181 rssi_pcnt = high_rssi_pcnt - (slot_size * slot_index); 182 if (rssi_pcnt < low_rssi_pcnt) 183 rssi_pcnt = low_rssi_pcnt; 184 185 mlme_debug("Window %d -> %d pcnt range %d -> %d bucket_size %d bss_rssi %d num_slot %d slot_size %d rssi_diff %d slot_index %d rssi_pcnt %d", 186 high_rssi_threshold, low_rssi_threshold, high_rssi_pcnt, 187 low_rssi_pcnt, bucket_size, bss_rssi, num_slot, slot_size, 188 rssi_diff, slot_index, rssi_pcnt); 189 190 return rssi_pcnt; 191 } 192 193 /** 194 * cm_calculate_rssi_score() - Calculate RSSI score based on AP RSSI 195 * @score_param: rssi score params 196 * @rssi: rssi of the AP 197 * @rssi_weightage: rssi_weightage out of total weightage 198 * 199 * Return: rssi score 200 */ 201 static int32_t cm_calculate_rssi_score(struct rssi_config_score *score_param, 202 int32_t rssi, uint8_t rssi_weightage) 203 { 204 int8_t rssi_pcnt; 205 int32_t total_rssi_score; 206 int32_t best_rssi_threshold; 207 int32_t good_rssi_threshold; 208 int32_t bad_rssi_threshold; 209 uint32_t good_rssi_pcnt; 210 uint32_t bad_rssi_pcnt; 211 uint32_t good_bucket_size; 212 uint32_t bad_bucket_size; 213 214 best_rssi_threshold = score_param->best_rssi_threshold * (-1); 215 good_rssi_threshold = score_param->good_rssi_threshold * (-1); 216 bad_rssi_threshold = score_param->bad_rssi_threshold * (-1); 217 good_rssi_pcnt = score_param->good_rssi_pcnt; 218 bad_rssi_pcnt = score_param->bad_rssi_pcnt; 219 good_bucket_size = score_param->good_rssi_bucket_size; 220 bad_bucket_size = score_param->bad_rssi_bucket_size; 221 222 total_rssi_score = (CM_MAX_PCT_SCORE * rssi_weightage); 223 224 /* 225 * If RSSI is better than the best rssi threshold then it return full 226 * score. 227 */ 228 if (rssi > best_rssi_threshold) 229 return total_rssi_score; 230 /* 231 * If RSSI is less or equal to bad rssi threshold then it return 232 * least score. 233 */ 234 if (rssi <= bad_rssi_threshold) 235 return (total_rssi_score * bad_rssi_pcnt) / 100; 236 237 /* RSSI lies between best to good rssi threshold */ 238 if (rssi > good_rssi_threshold) 239 rssi_pcnt = cm_get_rssi_pcnt_for_slot(best_rssi_threshold, 240 good_rssi_threshold, 100, good_rssi_pcnt, 241 good_bucket_size, rssi); 242 else 243 rssi_pcnt = cm_get_rssi_pcnt_for_slot(good_rssi_threshold, 244 bad_rssi_threshold, good_rssi_pcnt, 245 bad_rssi_pcnt, bad_bucket_size, 246 rssi); 247 248 return (total_rssi_score * rssi_pcnt) / 100; 249 } 250 251 /** 252 * cm_rssi_is_same_bucket() - check if both rssi fall in same bucket 253 * @rssi_top_thresh: high rssi threshold of the the window 254 * @rssi_ref1: rssi ref one 255 * @rssi_ref2: rssi ref two 256 * @bucket_size: bucket size of the window 257 * 258 * Return: true if both fall in same window 259 */ 260 static inline bool cm_rssi_is_same_bucket(int8_t rssi_top_thresh, 261 int8_t rssi_ref1, int8_t rssi_ref2, 262 int8_t bucket_size) 263 { 264 int8_t rssi_diff1 = 0; 265 int8_t rssi_diff2 = 0; 266 267 rssi_diff1 = rssi_top_thresh - rssi_ref1; 268 rssi_diff2 = rssi_top_thresh - rssi_ref2; 269 270 return (rssi_diff1 / bucket_size) == (rssi_diff2 / bucket_size); 271 } 272 273 /** 274 * cm_get_rssi_prorate_pct() - Calculate prorated RSSI score 275 * based on AP RSSI. This will be used to determine HT VHT score 276 * @score_param: rssi score params 277 * @rssi: bss rssi 278 * @rssi_weightage: rssi_weightage out of total weightage 279 * 280 * If rssi is greater than good threshold return 100, if less than bad return 0, 281 * if between good and bad, return prorated rssi score for the index. 282 * 283 * Return: rssi prorated score 284 */ 285 static int8_t 286 cm_get_rssi_prorate_pct(struct rssi_config_score *score_param, 287 int32_t rssi, uint8_t rssi_weightage) 288 { 289 int32_t good_rssi_threshold; 290 int32_t bad_rssi_threshold; 291 int8_t rssi_pref_5g_rssi_thresh; 292 bool same_bucket; 293 294 good_rssi_threshold = score_param->good_rssi_threshold * (-1); 295 bad_rssi_threshold = score_param->bad_rssi_threshold * (-1); 296 rssi_pref_5g_rssi_thresh = score_param->rssi_pref_5g_rssi_thresh * (-1); 297 298 /* If RSSI is greater than good rssi return full weight */ 299 if (rssi > good_rssi_threshold) 300 return CM_MAX_PCT_SCORE; 301 302 same_bucket = cm_rssi_is_same_bucket(good_rssi_threshold, rssi, 303 rssi_pref_5g_rssi_thresh, 304 score_param->bad_rssi_bucket_size); 305 if (same_bucket || (rssi < rssi_pref_5g_rssi_thresh)) 306 return 0; 307 /* If RSSI is less or equal to bad rssi threshold then it return 0 */ 308 if (rssi <= bad_rssi_threshold) 309 return 0; 310 311 /* If RSSI is between good and bad threshold */ 312 return cm_get_rssi_pcnt_for_slot(good_rssi_threshold, 313 bad_rssi_threshold, 314 score_param->good_rssi_pcnt, 315 score_param->bad_rssi_pcnt, 316 score_param->bad_rssi_bucket_size, 317 rssi); 318 } 319 320 /** 321 * cm_get_score_for_index() - get score for the given index 322 * @index: index for which we need the score 323 * @weightage: weigtage for the param 324 * @score: per slot score 325 * 326 * Return: score for the index 327 */ 328 static int32_t cm_get_score_for_index(uint8_t index, 329 uint8_t weightage, 330 struct per_slot_score *score) 331 { 332 if (index <= CM_SCORE_INDEX_3) 333 return weightage * CM_GET_SCORE_PERCENTAGE( 334 score->score_pcnt3_to_0, 335 index); 336 else if (index <= CM_SCORE_INDEX_7) 337 return weightage * CM_GET_SCORE_PERCENTAGE( 338 score->score_pcnt7_to_4, 339 index - CM_SCORE_OFFSET_INDEX_7_4); 340 else if (index <= CM_SCORE_INDEX_11) 341 return weightage * CM_GET_SCORE_PERCENTAGE( 342 score->score_pcnt11_to_8, 343 index - CM_SCORE_OFFSET_INDEX_11_8); 344 else 345 return weightage * CM_GET_SCORE_PERCENTAGE( 346 score->score_pcnt15_to_12, 347 index - CM_SCORE_OFFSET_INDEX_15_12); 348 } 349 350 /** 351 * cm_get_congestion_pct() - Calculate congestion pct from esp/qbss load 352 * @entry: bss information 353 * 354 * Return: congestion pct 355 */ 356 static int32_t cm_get_congestion_pct(struct scan_cache_entry *entry) 357 { 358 uint32_t ap_load = 0; 359 uint32_t est_air_time_percentage = 0; 360 uint32_t congestion = 0; 361 362 if (entry->air_time_fraction) { 363 /* Convert 0-255 range to percentage */ 364 est_air_time_percentage = entry->air_time_fraction * 365 CM_MAX_CHANNEL_WEIGHT; 366 est_air_time_percentage = qdf_do_div(est_air_time_percentage, 367 CM_MAX_ESTIMATED_AIR_TIME_FRACTION); 368 /* 369 * Calculate channel congestion from estimated air time 370 * fraction. 371 */ 372 congestion = CM_MAX_CHANNEL_UTILIZATION - 373 est_air_time_percentage; 374 if (!congestion) 375 congestion = 1; 376 } else if (util_scan_entry_qbssload(entry)) { 377 ap_load = (entry->qbss_chan_load * CM_MAX_PCT_SCORE); 378 /* 379 * Calculate ap_load in % from qbss channel load from 380 * 0-255 range 381 */ 382 congestion = qdf_do_div(ap_load, CM_MAX_AP_LOAD); 383 if (!congestion) 384 congestion = 1; 385 } 386 387 return congestion; 388 } 389 390 /** 391 * cm_calculate_congestion_score() - Calculate congestion score 392 * @entry: bss information 393 * @score_params: bss score params 394 * @congestion_pct: congestion pct 395 * @rssi_bad_zone: 396 * 397 * Return: congestion score 398 */ 399 static int32_t cm_calculate_congestion_score(struct scan_cache_entry *entry, 400 struct scoring_cfg *score_params, 401 uint32_t *congestion_pct, 402 bool rssi_bad_zone) 403 { 404 uint32_t window_size; 405 uint8_t index; 406 int32_t good_rssi_threshold; 407 uint8_t chan_congestion_weight; 408 409 chan_congestion_weight = 410 score_params->weight_config.channel_congestion_weightage; 411 412 if (!entry) 413 return chan_congestion_weight * 414 CM_GET_SCORE_PERCENTAGE( 415 score_params->esp_qbss_scoring.score_pcnt3_to_0, 416 CM_SCORE_INDEX_0); 417 418 *congestion_pct = cm_get_congestion_pct(entry); 419 420 if (!score_params->esp_qbss_scoring.num_slot) 421 return 0; 422 423 if (score_params->esp_qbss_scoring.num_slot > 424 CM_SCORE_MAX_INDEX) 425 score_params->esp_qbss_scoring.num_slot = 426 CM_SCORE_MAX_INDEX; 427 428 good_rssi_threshold = 429 score_params->rssi_score.good_rssi_threshold * (-1); 430 431 /* For bad zone rssi get score from last index */ 432 if (rssi_bad_zone || entry->rssi_raw <= good_rssi_threshold) 433 return cm_get_score_for_index( 434 score_params->esp_qbss_scoring.num_slot, 435 chan_congestion_weight, 436 &score_params->esp_qbss_scoring); 437 438 if (!*congestion_pct) 439 return chan_congestion_weight * 440 CM_GET_SCORE_PERCENTAGE( 441 score_params->esp_qbss_scoring.score_pcnt3_to_0, 442 CM_SCORE_INDEX_0); 443 444 window_size = CM_MAX_PCT_SCORE / 445 score_params->esp_qbss_scoring.num_slot; 446 447 /* Desired values are from 1 to 15, as 0 is for not present. so do +1 */ 448 index = qdf_do_div(*congestion_pct, window_size) + 1; 449 450 if (index > score_params->esp_qbss_scoring.num_slot) 451 index = score_params->esp_qbss_scoring.num_slot; 452 453 return cm_get_score_for_index(index, 454 chan_congestion_weight, 455 &score_params->esp_qbss_scoring); 456 } 457 458 /** 459 * cm_calculate_nss_score() - Calculate congestion score 460 * @psoc: psoc ptr 461 * @score_config: scoring config 462 * @ap_nss: ap nss 463 * @prorated_pct: prorated % to return dependent on RSSI 464 * @sta_nss: Sta NSS 465 * 466 * Return: nss score 467 */ 468 static int32_t cm_calculate_nss_score(struct wlan_objmgr_psoc *psoc, 469 struct scoring_cfg *score_config, 470 uint8_t ap_nss, uint8_t prorated_pct, 471 uint32_t sta_nss) 472 { 473 uint8_t nss; 474 uint8_t score_pct; 475 476 nss = ap_nss; 477 if (sta_nss < nss) 478 nss = sta_nss; 479 480 if (nss == 8) 481 score_pct = CM_MAX_PCT_SCORE; 482 if (nss == 4) 483 score_pct = CM_GET_SCORE_PERCENTAGE( 484 score_config->nss_weight_per_index[0], 485 CM_NSS_4x4_INDEX); 486 else if (nss == 3) 487 score_pct = CM_GET_SCORE_PERCENTAGE( 488 score_config->nss_weight_per_index[0], 489 CM_NSS_3x3_INDEX); 490 else if (nss == 2) 491 score_pct = CM_GET_SCORE_PERCENTAGE( 492 score_config->nss_weight_per_index[0], 493 CM_NSS_2x2_INDEX); 494 else 495 score_pct = CM_GET_SCORE_PERCENTAGE( 496 score_config->nss_weight_per_index[0], 497 CM_NSS_1x1_INDEX); 498 499 return (score_config->weight_config.nss_weightage * score_pct * 500 prorated_pct) / CM_MAX_PCT_SCORE; 501 } 502 503 static int32_t cm_calculate_security_score(struct scoring_cfg *score_config, 504 struct security_info neg_sec_info) 505 { 506 uint32_t authmode, key_mgmt, ucastcipherset; 507 uint8_t score_pct = 0; 508 509 authmode = neg_sec_info.authmodeset; 510 key_mgmt = neg_sec_info.key_mgmt; 511 ucastcipherset = neg_sec_info.ucastcipherset; 512 513 if (QDF_HAS_PARAM(authmode, WLAN_CRYPTO_AUTH_FILS_SK) || 514 QDF_HAS_PARAM(authmode, WLAN_CRYPTO_AUTH_SAE) || 515 QDF_HAS_PARAM(authmode, WLAN_CRYPTO_AUTH_CCKM) || 516 QDF_HAS_PARAM(authmode, WLAN_CRYPTO_AUTH_RSNA) || 517 QDF_HAS_PARAM(authmode, WLAN_CRYPTO_AUTH_8021X)) { 518 if (QDF_HAS_PARAM(key_mgmt, WLAN_CRYPTO_KEY_MGMT_SAE) || 519 QDF_HAS_PARAM(key_mgmt, WLAN_CRYPTO_KEY_MGMT_FT_SAE) || 520 QDF_HAS_PARAM(key_mgmt, 521 WLAN_CRYPTO_KEY_MGMT_IEEE8021X_SUITE_B) || 522 QDF_HAS_PARAM(key_mgmt, 523 WLAN_CRYPTO_KEY_MGMT_IEEE8021X_SUITE_B_192) || 524 QDF_HAS_PARAM(key_mgmt, WLAN_CRYPTO_KEY_MGMT_FILS_SHA256) || 525 QDF_HAS_PARAM(key_mgmt, WLAN_CRYPTO_KEY_MGMT_FILS_SHA384) || 526 QDF_HAS_PARAM(key_mgmt, 527 WLAN_CRYPTO_KEY_MGMT_FT_FILS_SHA256) || 528 QDF_HAS_PARAM(key_mgmt, 529 WLAN_CRYPTO_KEY_MGMT_FT_FILS_SHA384) || 530 QDF_HAS_PARAM(key_mgmt, WLAN_CRYPTO_KEY_MGMT_OWE) || 531 QDF_HAS_PARAM(key_mgmt, WLAN_CRYPTO_KEY_MGMT_DPP) || 532 QDF_HAS_PARAM(key_mgmt, 533 WLAN_CRYPTO_KEY_MGMT_FT_IEEE8021X_SHA384) || 534 QDF_HAS_PARAM(key_mgmt, WLAN_CRYPTO_KEY_MGMT_SAE_EXT_KEY) || 535 QDF_HAS_PARAM(key_mgmt, 536 WLAN_CRYPTO_KEY_MGMT_FT_SAE_EXT_KEY)) { 537 /*If security is WPA3, consider score_pct = 100%*/ 538 score_pct = CM_GET_SCORE_PERCENTAGE( 539 score_config->security_weight_per_index, 540 CM_SECURITY_WPA3_INDEX); 541 } else if (QDF_HAS_PARAM(key_mgmt, WLAN_CRYPTO_KEY_MGMT_PSK) || 542 QDF_HAS_PARAM(key_mgmt, 543 WLAN_CRYPTO_KEY_MGMT_FT_IEEE8021X) || 544 QDF_HAS_PARAM(key_mgmt, 545 WLAN_CRYPTO_KEY_MGMT_FT_PSK) || 546 QDF_HAS_PARAM(key_mgmt, 547 WLAN_CRYPTO_KEY_MGMT_IEEE8021X_SHA256) || 548 QDF_HAS_PARAM(key_mgmt, 549 WLAN_CRYPTO_KEY_MGMT_PSK_SHA256)) { 550 /*If security is WPA2, consider score_pct = 50%*/ 551 score_pct = CM_GET_SCORE_PERCENTAGE( 552 score_config->security_weight_per_index, 553 CM_SECURITY_WPA2_INDEX); 554 } 555 } else if (QDF_HAS_PARAM(authmode, WLAN_CRYPTO_AUTH_SHARED) || 556 QDF_HAS_PARAM(authmode, WLAN_CRYPTO_AUTH_WPA) || 557 QDF_HAS_PARAM(authmode, WLAN_CRYPTO_AUTH_WAPI)) { 558 /*If security is WPA, consider score_pct = 25%*/ 559 score_pct = CM_GET_SCORE_PERCENTAGE( 560 score_config->security_weight_per_index, 561 CM_SECURITY_WPA_INDEX); 562 } 563 564 return (score_config->weight_config.security_weightage * score_pct) / 565 CM_MAX_PCT_SCORE; 566 } 567 568 #ifdef WLAN_POLICY_MGR_ENABLE 569 static uint32_t cm_get_sta_nss(struct wlan_objmgr_psoc *psoc, 570 qdf_freq_t bss_channel_freq, 571 uint8_t vdev_nss_2g, uint8_t vdev_nss_5g) 572 { 573 /* 574 * If station support nss as 2*2 but AP support NSS as 1*1, 575 * this AP will be given half weight compare to AP which are having 576 * NSS as 2*2. 577 */ 578 579 if (policy_mgr_is_chnl_in_diff_band( 580 psoc, bss_channel_freq) && 581 policy_mgr_is_hw_dbs_capable(psoc) && 582 !(policy_mgr_is_hw_dbs_2x2_capable(psoc))) 583 return 1; 584 585 return (WLAN_REG_IS_24GHZ_CH_FREQ(bss_channel_freq) ? 586 vdev_nss_2g : 587 vdev_nss_5g); 588 } 589 #else 590 static uint32_t cm_get_sta_nss(struct wlan_objmgr_psoc *psoc, 591 qdf_freq_t bss_channel_freq, 592 uint8_t vdev_nss_2g, uint8_t vdev_nss_5g) 593 { 594 return (WLAN_REG_IS_24GHZ_CH_FREQ(bss_channel_freq) ? 595 vdev_nss_2g : 596 vdev_nss_5g); 597 } 598 #endif 599 600 #ifdef CONN_MGR_ADV_FEATURE 601 static bool 602 cm_get_pcl_weight_of_channel(uint32_t chan_freq, 603 struct pcl_freq_weight_list *pcl_lst, 604 int *pcl_chan_weight) 605 { 606 int i; 607 bool found = false; 608 609 if (!pcl_lst) 610 return found; 611 612 for (i = 0; i < pcl_lst->num_of_pcl_channels; i++) { 613 if (pcl_lst->pcl_freq_list[i] == chan_freq) { 614 *pcl_chan_weight = pcl_lst->pcl_weight_list[i]; 615 found = true; 616 break; 617 } 618 } 619 620 return found; 621 } 622 623 /** 624 * cm_calculate_pcl_score() - Calculate PCL score based on PCL weightage 625 * @psoc: psoc ptr 626 * @pcl_chan_weight: pcl weight of BSS channel 627 * @pcl_weightage: PCL _weightage out of total weightage 628 * 629 * Return: pcl score 630 */ 631 static int32_t cm_calculate_pcl_score(struct wlan_objmgr_psoc *psoc, 632 int pcl_chan_weight, 633 uint8_t pcl_weightage) 634 { 635 int32_t pcl_score = 0; 636 int32_t temp_pcl_chan_weight = 0; 637 638 /* 639 * Don’t consider pcl weightage for STA connection, 640 * if primary interface is configured. 641 */ 642 if (!policy_mgr_is_pcl_weightage_required(psoc)) 643 return 0; 644 645 if (pcl_chan_weight) { 646 temp_pcl_chan_weight = 647 (CM_MAX_WEIGHT_OF_PCL_CHANNELS - pcl_chan_weight); 648 temp_pcl_chan_weight = qdf_do_div( 649 temp_pcl_chan_weight, 650 CM_PCL_GROUPS_WEIGHT_DIFFERENCE); 651 pcl_score = pcl_weightage - temp_pcl_chan_weight; 652 if (pcl_score < 0) 653 pcl_score = 0; 654 } 655 656 return pcl_score * CM_MAX_PCT_SCORE; 657 } 658 659 /** 660 * cm_calculate_oce_wan_score() - Calculate oce wan score 661 * @entry: bss information 662 * @score_params: bss score params 663 * 664 * Return: oce wan score 665 */ 666 static int32_t cm_calculate_oce_wan_score( 667 struct scan_cache_entry *entry, 668 struct scoring_cfg *score_params) 669 { 670 uint32_t window_size; 671 uint8_t index; 672 struct oce_reduced_wan_metrics wan_metrics; 673 uint8_t *mbo_oce_ie; 674 675 if (!score_params->oce_wan_scoring.num_slot) 676 return 0; 677 678 if (score_params->oce_wan_scoring.num_slot > 679 CM_SCORE_MAX_INDEX) 680 score_params->oce_wan_scoring.num_slot = 681 CM_SCORE_MAX_INDEX; 682 683 window_size = CM_SCORE_MAX_INDEX / 684 score_params->oce_wan_scoring.num_slot; 685 mbo_oce_ie = util_scan_entry_mbo_oce(entry); 686 if (wlan_parse_oce_reduced_wan_metrics_ie(mbo_oce_ie, &wan_metrics)) { 687 mlme_err("downlink_av_cap %d", wan_metrics.downlink_av_cap); 688 /* if capacity is 0 return 0 score */ 689 if (!wan_metrics.downlink_av_cap) 690 return 0; 691 /* Desired values are from 1 to WLAN_SCORE_MAX_INDEX */ 692 index = qdf_do_div(wan_metrics.downlink_av_cap, 693 window_size); 694 } else { 695 index = CM_SCORE_INDEX_0; 696 } 697 698 if (index > score_params->oce_wan_scoring.num_slot) 699 index = score_params->oce_wan_scoring.num_slot; 700 701 return cm_get_score_for_index(index, 702 score_params->weight_config.oce_wan_weightage, 703 &score_params->oce_wan_scoring); 704 } 705 706 /** 707 * cm_calculate_oce_subnet_id_weightage() - Calculate oce subnet id weightage 708 * @entry: bss entry 709 * @score_params: bss score params 710 * @oce_subnet_id_present: check if subnet id subelement is present in OCE IE 711 * 712 * Return: oce subnet id score 713 */ 714 static uint32_t 715 cm_calculate_oce_subnet_id_weightage(struct scan_cache_entry *entry, 716 struct scoring_cfg *score_params, 717 bool *oce_subnet_id_present) 718 { 719 uint32_t score = 0; 720 uint8_t *mbo_oce_ie; 721 722 mbo_oce_ie = util_scan_entry_mbo_oce(entry); 723 *oce_subnet_id_present = wlan_parse_oce_subnet_id_ie(mbo_oce_ie); 724 725 /* Consider 50% weightage if subnet id sub element is present */ 726 if (*oce_subnet_id_present) 727 score = score_params->weight_config.oce_subnet_id_weightage * 728 (CM_MAX_PCT_SCORE / 2); 729 730 return score; 731 } 732 733 /** 734 * cm_calculate_sae_pk_ap_weightage() - Calculate SAE-PK AP weightage 735 * @entry: bss entry 736 * @score_params: bss score params 737 * @sae_pk_cap_present: sae_pk cap presetn in RSNXE capability field 738 * 739 * Return: SAE-PK AP weightage score 740 */ 741 static uint32_t 742 cm_calculate_sae_pk_ap_weightage(struct scan_cache_entry *entry, 743 struct scoring_cfg *score_params, 744 bool *sae_pk_cap_present) 745 { 746 const uint8_t *rsnxe_ie; 747 const uint8_t *rsnxe_cap; 748 uint8_t cap_len; 749 750 rsnxe_ie = util_scan_entry_rsnxe(entry); 751 752 rsnxe_cap = wlan_crypto_parse_rsnxe_ie(rsnxe_ie, &cap_len); 753 754 if (!rsnxe_cap) 755 return 0; 756 757 *sae_pk_cap_present = *rsnxe_cap & WLAN_CRYPTO_RSNX_CAP_SAE_PK; 758 if (*sae_pk_cap_present) 759 return score_params->weight_config.sae_pk_ap_weightage * 760 CM_MAX_PCT_SCORE; 761 762 return 0; 763 } 764 765 /** 766 * cm_calculate_oce_ap_tx_pwr_weightage() - Calculate oce ap tx pwr weightage 767 * @entry: bss entry 768 * @score_params: bss score params 769 * @ap_tx_pwr_dbm: pointer to hold ap tx power 770 * 771 * Return: oce ap tx power score 772 */ 773 static uint32_t 774 cm_calculate_oce_ap_tx_pwr_weightage(struct scan_cache_entry *entry, 775 struct scoring_cfg *score_params, 776 int8_t *ap_tx_pwr_dbm) 777 { 778 uint8_t *mbo_oce_ie, ap_tx_pwr_factor; 779 struct rssi_config_score *rssi_score_param; 780 int32_t best_rssi_threshold, good_rssi_threshold, bad_rssi_threshold; 781 uint32_t good_rssi_pcnt, bad_rssi_pcnt, good_bucket_size; 782 uint32_t score, normalized_ap_tx_pwr, bad_bucket_size; 783 bool ap_tx_pwr_cap_present = true; 784 785 mbo_oce_ie = util_scan_entry_mbo_oce(entry); 786 if (!wlan_parse_oce_ap_tx_pwr_ie(mbo_oce_ie, ap_tx_pwr_dbm)) { 787 ap_tx_pwr_cap_present = false; 788 /* If no OCE AP TX pwr, consider Uplink RSSI = Downlink RSSI */ 789 normalized_ap_tx_pwr = entry->rssi_raw; 790 } else { 791 /* 792 * Normalized ap_tx_pwr = 793 * Uplink RSSI = (STA TX Power - * (AP TX power - RSSI)) in dBm. 794 * Currently assuming STA Tx Power to be 20dBm, though later it 795 * need to fetched from hal-phy API. 796 */ 797 normalized_ap_tx_pwr = 798 (20 - (*ap_tx_pwr_dbm - entry->rssi_raw)); 799 } 800 801 rssi_score_param = &score_params->rssi_score; 802 803 best_rssi_threshold = rssi_score_param->best_rssi_threshold * (-1); 804 good_rssi_threshold = rssi_score_param->good_rssi_threshold * (-1); 805 bad_rssi_threshold = rssi_score_param->bad_rssi_threshold * (-1); 806 good_rssi_pcnt = rssi_score_param->good_rssi_pcnt; 807 bad_rssi_pcnt = rssi_score_param->bad_rssi_pcnt; 808 good_bucket_size = rssi_score_param->good_rssi_bucket_size; 809 bad_bucket_size = rssi_score_param->bad_rssi_bucket_size; 810 811 /* Uplink RSSI is better than best rssi threshold */ 812 if (normalized_ap_tx_pwr > best_rssi_threshold) { 813 ap_tx_pwr_factor = CM_MAX_PCT_SCORE; 814 } else if (normalized_ap_tx_pwr <= bad_rssi_threshold) { 815 /* Uplink RSSI is less or equal to bad rssi threshold */ 816 ap_tx_pwr_factor = rssi_score_param->bad_rssi_pcnt; 817 } else if (normalized_ap_tx_pwr > good_rssi_threshold) { 818 /* Uplink RSSI lies between best to good rssi threshold */ 819 ap_tx_pwr_factor = 820 cm_get_rssi_pcnt_for_slot( 821 best_rssi_threshold, 822 good_rssi_threshold, 100, 823 good_rssi_pcnt, 824 good_bucket_size, normalized_ap_tx_pwr); 825 } else { 826 /* Uplink RSSI lies between good to best rssi threshold */ 827 ap_tx_pwr_factor = 828 cm_get_rssi_pcnt_for_slot( 829 good_rssi_threshold, 830 bad_rssi_threshold, good_rssi_pcnt, 831 bad_rssi_pcnt, bad_bucket_size, 832 normalized_ap_tx_pwr); 833 } 834 835 score = score_params->weight_config.oce_ap_tx_pwr_weightage * 836 ap_tx_pwr_factor; 837 838 return score; 839 } 840 841 static bool cm_is_assoc_allowed(struct psoc_mlme_obj *mlme_psoc_obj, 842 struct scan_cache_entry *entry) 843 { 844 uint8_t reason; 845 uint8_t *mbo_oce; 846 bool check_assoc_disallowed; 847 848 mbo_oce = util_scan_entry_mbo_oce(entry); 849 850 check_assoc_disallowed = 851 mlme_psoc_obj->psoc_cfg.score_config.check_assoc_disallowed; 852 853 if (check_assoc_disallowed && 854 wlan_parse_oce_assoc_disallowed_ie(mbo_oce, &reason)) { 855 mlme_nofl_debug("Candidate("QDF_MAC_ADDR_FMT" freq %d): rssi %d, assoc disallowed set in MBO/OCE IE reason %d", 856 QDF_MAC_ADDR_REF(entry->bssid.bytes), 857 entry->channel.chan_freq, 858 entry->rssi_raw, reason); 859 return false; 860 } 861 862 return true; 863 } 864 865 void wlan_cm_set_check_assoc_disallowed(struct wlan_objmgr_psoc *psoc, 866 bool value) 867 { 868 struct psoc_mlme_obj *mlme_psoc_obj; 869 870 mlme_psoc_obj = wlan_psoc_mlme_get_cmpt_obj(psoc); 871 if (!mlme_psoc_obj) 872 return; 873 874 mlme_psoc_obj->psoc_cfg.score_config.check_assoc_disallowed = value; 875 } 876 877 void wlan_cm_get_check_assoc_disallowed(struct wlan_objmgr_psoc *psoc, 878 bool *value) 879 { 880 struct psoc_mlme_obj *mlme_psoc_obj; 881 882 mlme_psoc_obj = wlan_psoc_mlme_get_cmpt_obj(psoc); 883 if (!mlme_psoc_obj) { 884 *value = false; 885 return; 886 } 887 888 *value = mlme_psoc_obj->psoc_cfg.score_config.check_assoc_disallowed; 889 } 890 891 static enum phy_ch_width 892 cm_calculate_bandwidth(struct scan_cache_entry *entry, 893 struct psoc_phy_config *phy_config) 894 { 895 uint8_t bw_above_20 = 0; 896 bool is_vht = false; 897 enum phy_ch_width ch_width; 898 899 if (WLAN_REG_IS_24GHZ_CH_FREQ(entry->channel.chan_freq)) { 900 bw_above_20 = phy_config->bw_above_20_24ghz; 901 if (phy_config->vht_24G_cap) 902 is_vht = true; 903 } else if (phy_config->vht_cap) { 904 is_vht = true; 905 bw_above_20 = phy_config->bw_above_20_5ghz; 906 } 907 908 if (IS_WLAN_PHYMODE_160MHZ(entry->phy_mode)) 909 ch_width = CH_WIDTH_160MHZ; 910 else if (IS_WLAN_PHYMODE_80MHZ(entry->phy_mode)) 911 ch_width = CH_WIDTH_80MHZ; 912 else if (IS_WLAN_PHYMODE_40MHZ(entry->phy_mode)) 913 ch_width = CH_WIDTH_40MHZ; 914 else 915 ch_width = CH_WIDTH_20MHZ; 916 917 if (!phy_config->ht_cap && 918 ch_width >= CH_WIDTH_20MHZ) 919 ch_width = CH_WIDTH_20MHZ; 920 921 if (!is_vht && ch_width > CH_WIDTH_40MHZ) 922 ch_width = CH_WIDTH_40MHZ; 923 924 if (!bw_above_20) 925 ch_width = CH_WIDTH_20MHZ; 926 927 return ch_width; 928 } 929 930 static uint8_t cm_etp_get_ba_win_size_from_esp(uint8_t esp_ba_win_size) 931 { 932 /* 933 * BA Window Size subfield is three bits in length and indicates the 934 * size of the Block Ack window that is. 935 * 802.11-2016.pdf Table 9-262 BA Window Size subfield encoding 936 */ 937 switch (esp_ba_win_size) { 938 case 1: return 2; 939 case 2: return 4; 940 case 3: return 6; 941 case 4: return 8; 942 case 5: return 16; 943 case 6: return 32; 944 case 7: return 64; 945 default: return 1; 946 } 947 } 948 949 static uint16_t cm_get_etp_ntone(bool is_ht, bool is_vht, 950 enum phy_ch_width ch_width) 951 { 952 uint16_t n_sd = 52, n_seg = 1; 953 954 if (is_vht) { 955 /* Refer Table 21-5 in IEEE80211-2016 Spec */ 956 if (ch_width == CH_WIDTH_20MHZ) 957 n_sd = 52; 958 else if (ch_width == CH_WIDTH_40MHZ) 959 n_sd = 108; 960 else if (ch_width == CH_WIDTH_80MHZ) 961 n_sd = 234; 962 else if (ch_width == CH_WIDTH_80P80MHZ) 963 n_sd = 234, n_seg = 2; 964 else if (ch_width == CH_WIDTH_160MHZ) 965 n_sd = 468; 966 } else if (is_ht) { 967 /* Refer Table 19-6 in IEEE80211-2016 Spec */ 968 if (ch_width == CH_WIDTH_20MHZ) 969 n_sd = 52; 970 if (ch_width == CH_WIDTH_40MHZ) 971 n_sd = 108; 972 } else { 973 n_sd = 48; 974 } 975 976 return (n_sd * n_seg); 977 } 978 979 /* Refer Table 27-64 etc in Draft P802.11ax_D7.0.txt */ 980 static uint16_t cm_get_etp_he_ntone(enum phy_ch_width ch_width) 981 { 982 uint16_t n_sd = 234, n_seg = 1; 983 984 if (ch_width == CH_WIDTH_20MHZ) 985 n_sd = 234; 986 else if (ch_width == CH_WIDTH_40MHZ) 987 n_sd = 468; 988 else if (ch_width == CH_WIDTH_80MHZ) 989 n_sd = 980; 990 else if (ch_width == CH_WIDTH_80P80MHZ) 991 n_sd = 980, n_seg = 2; 992 else if (ch_width == CH_WIDTH_160MHZ) 993 n_sd = 1960; 994 995 return (n_sd * n_seg); 996 } 997 998 static uint16_t cm_get_etp_phy_header_dur_us(bool is_ht, bool is_vht, 999 uint8_t nss) 1000 { 1001 uint16_t dur_us = 0; 1002 1003 if (is_vht) { 1004 /* 1005 * Refer Figure 21-4 in 80211-2016 Spec 1006 * 8 (L-STF) + 8 (L-LTF) + 4 (L-SIG) + 1007 * 8 (VHT-SIG-A) + 4 (VHT-STF) + 4 (VHT-SIG-B) 1008 */ 1009 dur_us = 36; 1010 /* (nss * VHT-LTF) = (nss * 4) */ 1011 dur_us += (nss << 2); 1012 } else if (is_ht) { 1013 /* 1014 * Refer Figure 19-1 in 80211-2016 Spec 1015 * 8 (L-STF) + 8 (L-LTF) + 4 (L-SIG) + 8 (HT-SIG) + 1016 * 4 (HT-STF) 1017 */ 1018 dur_us = 32; 1019 /* (nss * HT-LTF = nss * 4) */ 1020 dur_us += (nss << 2); 1021 } else { 1022 /* 1023 * non-HT 1024 * Refer Figure 19-1 in 80211-2016 Spec 1025 * 8 (L-STF) + 8 (L-LTF) + 4 (L-SIG) 1026 */ 1027 dur_us = 20; 1028 } 1029 return dur_us; 1030 } 1031 1032 static uint32_t 1033 cm_get_etp_max_bits_per_sc_1000x_for_nss(struct wlan_objmgr_psoc *psoc, 1034 struct scan_cache_entry *entry, 1035 uint8_t nss, 1036 struct psoc_phy_config *phy_config) 1037 { 1038 uint32_t max_bits_per_sc_1000x = 5000; /* 5 * 1000 */ 1039 uint8_t mcs_map; 1040 struct wlan_ie_vhtcaps *bss_vht_cap; 1041 struct wlan_ie_hecaps *bss_he_cap; 1042 uint32_t self_rx_mcs_map; 1043 QDF_STATUS status; 1044 1045 bss_vht_cap = (struct wlan_ie_vhtcaps *)util_scan_entry_vhtcap(entry); 1046 bss_he_cap = (struct wlan_ie_hecaps *)util_scan_entry_hecap(entry); 1047 if (!phy_config->vht_cap || !bss_vht_cap) { 1048 mlme_err("vht unsupported"); 1049 return max_bits_per_sc_1000x; 1050 } 1051 1052 status = wlan_mlme_cfg_get_vht_rx_mcs_map(psoc, &self_rx_mcs_map); 1053 if (QDF_IS_STATUS_ERROR(status)) 1054 return max_bits_per_sc_1000x; 1055 1056 if (nss == 4) { 1057 mcs_map = (self_rx_mcs_map & 0xC0) >> 6; 1058 mcs_map = QDF_MIN(mcs_map, 1059 (bss_vht_cap->rx_mcs_map & 0xC0) >> 6); 1060 } else if (nss == 3) { 1061 mcs_map = (self_rx_mcs_map & 0x30) >> 4; 1062 mcs_map = QDF_MIN(mcs_map, 1063 (bss_vht_cap->rx_mcs_map & 0x30) >> 4); 1064 } else if (nss == 2) { 1065 mcs_map = (self_rx_mcs_map & 0x0C) >> 2; 1066 mcs_map = QDF_MIN(mcs_map, 1067 (bss_vht_cap->rx_mcs_map & 0x0C) >> 2); 1068 } else { 1069 mcs_map = (self_rx_mcs_map & 0x03); 1070 mcs_map = QDF_MIN(mcs_map, (bss_vht_cap->rx_mcs_map & 0x03)); 1071 } 1072 if (bss_he_cap) { 1073 if (mcs_map == 2) 1074 max_bits_per_sc_1000x = 8333; /* 10 *5/6 * 1000 */ 1075 else if (mcs_map == 1) 1076 max_bits_per_sc_1000x = 7500; /* 10 * 3/4 * 1000 */ 1077 } else { 1078 if (mcs_map == 2) 1079 max_bits_per_sc_1000x = 6667; /* 8 * 5/6 * 1000 */ 1080 else if (mcs_map == 1) 1081 max_bits_per_sc_1000x = 6000; /* 8 * 3/4 * 1000 */ 1082 } 1083 return max_bits_per_sc_1000x; 1084 } 1085 1086 /* Refer Table 9-163 in 80211-2016 Spec */ 1087 static uint32_t cm_etp_get_min_mpdu_ss_us_100x(struct htcap_cmn_ie *htcap) 1088 { 1089 tSirMacHTParametersInfo *ampdu_param; 1090 uint8_t ampdu_density; 1091 1092 ampdu_param = (tSirMacHTParametersInfo *)&htcap->ampdu_param; 1093 ampdu_density = ampdu_param->mpduDensity; 1094 1095 if (ampdu_density == 1) 1096 return 25; /* (1/4) * 100 */ 1097 else if (ampdu_density == 2) 1098 return 50; /* (1/2) * 100 */ 1099 else if (ampdu_density == 3) 1100 return 100; /* 1 * 100 */ 1101 else if (ampdu_density == 4) 1102 return 200; /* 2 * 100 */ 1103 else if (ampdu_density == 5) 1104 return 400; /* 4 * 100 */ 1105 else if (ampdu_density == 6) 1106 return 800; /* 8 * 100 */ 1107 else if (ampdu_density == 7) 1108 return 1600; /* 16 * 100 */ 1109 else 1110 return 100; 1111 } 1112 1113 /* Refer Table 9-162 in 80211-2016 Spec */ 1114 static uint32_t cm_etp_get_max_amsdu_len(struct wlan_objmgr_psoc *psoc, 1115 struct htcap_cmn_ie *htcap) 1116 { 1117 uint8_t bss_max_amsdu; 1118 uint32_t bss_max_amsdu_len; 1119 QDF_STATUS status; 1120 1121 status = wlan_mlme_get_max_amsdu_num(psoc, &bss_max_amsdu); 1122 if (QDF_IS_STATUS_ERROR(status)) 1123 bss_max_amsdu_len = 3839; 1124 else if (bss_max_amsdu == 1) 1125 bss_max_amsdu_len = 7935; 1126 else 1127 bss_max_amsdu_len = 3839; 1128 1129 return bss_max_amsdu_len; 1130 } 1131 1132 // Calculate the number of bits per tone based on the input of SNR in dB 1133 // The output is scaled up by BIT_PER_TONE_SCALE for integer representation 1134 static uint32_t 1135 calculate_bit_per_tone(int32_t rssi, enum phy_ch_width ch_width) 1136 { 1137 int32_t noise_floor_db_boost; 1138 int32_t noise_floor_dbm; 1139 int32_t snr_db; 1140 int32_t bit_per_tone; 1141 int32_t lut_in_idx; 1142 1143 noise_floor_db_boost = TWO_IN_DB * ch_width; 1144 noise_floor_dbm = WLAN_NOISE_FLOOR_DBM_DEFAULT + noise_floor_db_boost + 1145 SNR_MARGIN_DB; 1146 snr_db = rssi - noise_floor_dbm; 1147 if (snr_db <= SNR_DB_TO_BIT_PER_TONE_LUT_MAX) { 1148 lut_in_idx = QDF_MAX(snr_db, SNR_DB_TO_BIT_PER_TONE_LUT_MIN) 1149 - SNR_DB_TO_BIT_PER_TONE_LUT_MIN; 1150 lut_in_idx = QDF_MIN(lut_in_idx, DB_NUM - 1); 1151 bit_per_tone = SNR_DB_TO_BIT_PER_TONE_LUT[lut_in_idx]; 1152 } else { 1153 /* 1154 * SNR_tone = 10^(SNR/10) 1155 * log2(1+SNR_tone) ~= log2(SNR_tone) = 1156 * log10(SNR_tone)/log10(2) = log10(10^(SNR/10)) / 0.3 1157 * = (SNR/10) / 0.3 = SNR/3 1158 * So log2(1+SNR_tone) = SNR/3. 1000x for this is SNR*334 1159 */ 1160 bit_per_tone = snr_db * 334; 1161 } 1162 1163 return bit_per_tone; 1164 } 1165 1166 static uint32_t 1167 cm_calculate_etp(struct wlan_objmgr_psoc *psoc, 1168 struct scan_cache_entry *entry, 1169 struct etp_params *etp_param, 1170 uint8_t max_nss, enum phy_ch_width ch_width, 1171 bool is_ht, bool is_vht, bool is_he, 1172 int8_t rssi, 1173 struct psoc_phy_config *phy_config) 1174 { 1175 uint16_t ntone; 1176 uint16_t phy_hdr_dur_us, max_amsdu_len = 1500, min_mpdu_ss_us_100x = 0; 1177 uint32_t max_bits_per_sc_1000x, log_2_snr_tone_1000x; 1178 uint32_t ppdu_payload_dur_us = 0, mpdu_per_ampdu, mpdu_per_ppdu; 1179 uint32_t single_ppdu_dur_us, estimated_throughput_mbps, data_rate_kbps; 1180 struct htcap_cmn_ie *htcap; 1181 1182 htcap = (struct htcap_cmn_ie *)util_scan_entry_htcap(entry); 1183 if (ch_width > CH_WIDTH_160MHZ) 1184 return CM_AVOID_CANDIDATE_MIN_SCORE; 1185 1186 if (is_he) 1187 ntone = cm_get_etp_he_ntone(ch_width); 1188 else 1189 ntone = cm_get_etp_ntone(is_ht, is_vht, ch_width); 1190 phy_hdr_dur_us = cm_get_etp_phy_header_dur_us(is_ht, is_vht, max_nss); 1191 1192 max_bits_per_sc_1000x = 1193 cm_get_etp_max_bits_per_sc_1000x_for_nss(psoc, entry, 1194 max_nss, phy_config); 1195 if (rssi < WLAN_NOISE_FLOOR_DBM_DEFAULT) 1196 return CM_AVOID_CANDIDATE_MIN_SCORE; 1197 1198 log_2_snr_tone_1000x = calculate_bit_per_tone(rssi, ch_width); 1199 1200 /* Eq. R-2 Pg:3508 in 80211-2016 Spec */ 1201 if (is_he) 1202 data_rate_kbps = 1203 QDF_MIN(log_2_snr_tone_1000x, max_bits_per_sc_1000x) * 1204 (max_nss * ntone) / HE_PPDU_PAYLOAD_SYMBOL_DUR_US; 1205 else 1206 data_rate_kbps = 1207 QDF_MIN(log_2_snr_tone_1000x, max_bits_per_sc_1000x) * 1208 (max_nss * ntone) / PPDU_PAYLOAD_SYMBOL_DUR_US; 1209 mlme_debug("data_rate_kbps: %d", data_rate_kbps); 1210 if (data_rate_kbps < 1000) { 1211 /* Return ETP as 1 since datarate is not even 1 Mbps */ 1212 return CM_AVOID_CANDIDATE_MIN_SCORE; 1213 } 1214 /* compute MPDU_p_PPDU */ 1215 if (is_ht) { 1216 min_mpdu_ss_us_100x = 1217 cm_etp_get_min_mpdu_ss_us_100x(htcap); 1218 max_amsdu_len = 1219 cm_etp_get_max_amsdu_len(psoc, htcap); 1220 ppdu_payload_dur_us = 1221 etp_param->data_ppdu_dur_target_us - phy_hdr_dur_us; 1222 mpdu_per_ampdu = 1223 QDF_MIN(qdf_ceil(ppdu_payload_dur_us * 100, 1224 min_mpdu_ss_us_100x), 1225 qdf_ceil(ppdu_payload_dur_us * 1226 (data_rate_kbps / 1000), 1227 (MAC_HEADER_LEN + max_amsdu_len) * 8)); 1228 mpdu_per_ppdu = QDF_MIN(etp_param->ba_window_size, 1229 QDF_MAX(1, mpdu_per_ampdu)); 1230 } else { 1231 mpdu_per_ppdu = 1; 1232 } 1233 1234 /* compute PPDU_Dur */ 1235 single_ppdu_dur_us = 1236 qdf_ceil((MAC_HEADER_LEN + max_amsdu_len) * mpdu_per_ppdu * 8, 1237 (data_rate_kbps / 1000) * PPDU_PAYLOAD_SYMBOL_DUR_US); 1238 single_ppdu_dur_us *= PPDU_PAYLOAD_SYMBOL_DUR_US; 1239 single_ppdu_dur_us += phy_hdr_dur_us; 1240 1241 estimated_throughput_mbps = 1242 qdf_ceil(mpdu_per_ppdu * max_amsdu_len * 8, single_ppdu_dur_us); 1243 estimated_throughput_mbps = 1244 (estimated_throughput_mbps * 1245 etp_param->airtime_fraction) / 1246 CM_MAX_ESTIMATED_AIR_TIME_FRACTION; 1247 1248 if (estimated_throughput_mbps < CM_AVOID_CANDIDATE_MIN_SCORE) 1249 estimated_throughput_mbps = CM_AVOID_CANDIDATE_MIN_SCORE; 1250 if (estimated_throughput_mbps > CM_BEST_CANDIDATE_MAX_BSS_SCORE) 1251 estimated_throughput_mbps = CM_BEST_CANDIDATE_MAX_BSS_SCORE; 1252 1253 mlme_nofl_debug("Candidate("QDF_MAC_ADDR_FMT" freq %d): rssi %d HT %d VHT %d HE %d ATF: %d NSS %d, ch_width: %d", 1254 QDF_MAC_ADDR_REF(entry->bssid.bytes), 1255 entry->channel.chan_freq, 1256 entry->rssi_raw, is_ht, is_vht, is_he, 1257 etp_param->airtime_fraction, 1258 entry->nss, ch_width); 1259 if (is_ht) 1260 mlme_nofl_debug("min_mpdu_ss_us_100x = %d, max_amsdu_len = %d, ppdu_payload_dur_us = %d, mpdu_per_ampdu = %d, mpdu_per_ppdu = %d, ba_window_size = %d", 1261 min_mpdu_ss_us_100x, max_amsdu_len, 1262 ppdu_payload_dur_us, mpdu_per_ampdu, 1263 mpdu_per_ppdu, etp_param->ba_window_size); 1264 mlme_nofl_debug("ETP score params: ntone: %d, phy_hdr_dur_us: %d, max_bits_per_sc_1000x: %d, log_2_snr_tone_1000x: %d mpdu_p_ppdu = %d, max_amsdu_len = %d, ppdu_dur_us = %d, total score = %d", 1265 ntone, phy_hdr_dur_us, max_bits_per_sc_1000x, 1266 log_2_snr_tone_1000x, mpdu_per_ppdu, max_amsdu_len, 1267 single_ppdu_dur_us, estimated_throughput_mbps); 1268 1269 return estimated_throughput_mbps; 1270 } 1271 1272 static uint32_t 1273 cm_calculate_etp_score(struct wlan_objmgr_psoc *psoc, 1274 struct scan_cache_entry *entry, 1275 struct psoc_phy_config *phy_config, 1276 enum MLO_TYPE bss_mlo_type) 1277 { 1278 enum phy_ch_width ch_width; 1279 uint32_t nss; 1280 bool is_he_intersect = false; 1281 bool is_vht_intersect = false; 1282 bool is_ht_intersect = false; 1283 struct wlan_esp_info *esp; 1284 struct wlan_esp_ie *esp_ie; 1285 struct etp_params etp_param; 1286 int8_t mlo_prefer_percentage = 0; 1287 uint32_t score; 1288 int32_t mlo_score = 0; 1289 1290 if (phy_config->he_cap && entry->ie_list.hecap) 1291 is_he_intersect = true; 1292 if ((phy_config->vht_cap || phy_config->vht_24G_cap) && 1293 (entry->ie_list.vhtcap || 1294 WLAN_REG_IS_6GHZ_CHAN_FREQ(entry->channel.chan_freq))) 1295 is_vht_intersect = true; 1296 if (phy_config->ht_cap && entry->ie_list.htcap) 1297 is_ht_intersect = true; 1298 nss = cm_get_sta_nss(psoc, entry->channel.chan_freq, 1299 phy_config->vdev_nss_24g, 1300 phy_config->vdev_nss_5g); 1301 nss = QDF_MIN(nss, entry->nss); 1302 ch_width = cm_calculate_bandwidth(entry, phy_config); 1303 1304 /* Initialize default ETP params */ 1305 etp_param.airtime_fraction = 255 / 2; 1306 etp_param.ba_window_size = 32; 1307 etp_param.data_ppdu_dur_target_us = 5000; /* 5 msec */ 1308 1309 if (entry->air_time_fraction) { 1310 etp_param.airtime_fraction = entry->air_time_fraction; 1311 esp_ie = (struct wlan_esp_ie *) 1312 util_scan_entry_esp_info(entry); 1313 if (esp_ie) { 1314 esp = &esp_ie->esp_info_AC_BE; 1315 etp_param.ba_window_size = 1316 cm_etp_get_ba_win_size_from_esp(esp->ba_window_size); 1317 etp_param.data_ppdu_dur_target_us = 1318 50 * esp->ppdu_duration; 1319 mlme_debug("esp ba_window_size: %d, ppdu_duration: %d", 1320 esp->ba_window_size, esp->ppdu_duration); 1321 } 1322 } else if (entry->qbss_chan_load) { 1323 mlme_debug("qbss_chan_load: %d", entry->qbss_chan_load); 1324 etp_param.airtime_fraction = 1325 CM_MAX_ESTIMATED_AIR_TIME_FRACTION - 1326 entry->qbss_chan_load; 1327 } 1328 /* If ini vendor_roam_score_algorithm=1, just calculate ETP of all 1329 * bssid of ssid selected by high layer, and try to connect AP by 1330 * order of ETP, legacy algorithm with following Parameters/Weightage 1331 * becomes useless. ETP should be [1Mbps, 20000Mbps],matches score 1332 * range: [1, 20000] 1333 */ 1334 score = cm_calculate_etp(psoc, entry, 1335 &etp_param, 1336 nss, 1337 ch_width, 1338 is_ht_intersect, 1339 is_vht_intersect, 1340 is_he_intersect, 1341 entry->rssi_raw, 1342 phy_config); 1343 if (bss_mlo_type == SLO) 1344 return score; 1345 wlan_mlme_get_mlo_prefer_percentage(psoc, &mlo_prefer_percentage); 1346 if (mlo_prefer_percentage) { 1347 mlo_score = score; 1348 mlo_score = mlo_score + 1349 (mlo_score * mlo_prefer_percentage) / 100; 1350 score = mlo_score; 1351 } 1352 return score; 1353 } 1354 #else 1355 static bool 1356 cm_get_pcl_weight_of_channel(uint32_t chan_freq, 1357 struct pcl_freq_weight_list *pcl_lst, 1358 int *pcl_chan_weight) 1359 { 1360 return false; 1361 } 1362 1363 static int32_t cm_calculate_pcl_score(struct wlan_objmgr_psoc *psoc, 1364 int pcl_chan_weight, 1365 uint8_t pcl_weightage) 1366 { 1367 return 0; 1368 } 1369 1370 static int32_t cm_calculate_oce_wan_score(struct scan_cache_entry *entry, 1371 struct scoring_cfg *score_params) 1372 { 1373 return 0; 1374 } 1375 1376 static uint32_t 1377 cm_calculate_oce_subnet_id_weightage(struct scan_cache_entry *entry, 1378 struct scoring_cfg *score_params, 1379 bool *oce_subnet_id_present) 1380 { 1381 return 0; 1382 } 1383 1384 static uint32_t 1385 cm_calculate_sae_pk_ap_weightage(struct scan_cache_entry *entry, 1386 struct scoring_cfg *score_params, 1387 bool *sae_pk_cap_present) 1388 { 1389 return 0; 1390 } 1391 1392 static uint32_t 1393 cm_calculate_oce_ap_tx_pwr_weightage(struct scan_cache_entry *entry, 1394 struct scoring_cfg *score_params, 1395 int8_t *ap_tx_pwr_dbm) 1396 { 1397 return 0; 1398 } 1399 1400 static inline bool cm_is_assoc_allowed(struct psoc_mlme_obj *mlme_psoc_obj, 1401 struct scan_cache_entry *entry) 1402 { 1403 return true; 1404 } 1405 1406 static uint32_t 1407 cm_calculate_etp_score(struct wlan_objmgr_psoc *psoc, 1408 struct scan_cache_entry *entry, 1409 struct psoc_phy_config *phy_config, 1410 enum MLO_TYPE bss_mlo_type) 1411 { 1412 return 0; 1413 } 1414 #endif 1415 1416 /** 1417 * cm_get_band_score() - Get band preference weightage 1418 * @freq: Operating frequency of the AP 1419 * @score_config: Score configuration 1420 * 1421 * Return: Band score for AP. 1422 */ 1423 static int 1424 cm_get_band_score(uint32_t freq, struct scoring_cfg *score_config) 1425 { 1426 uint8_t band_index; 1427 struct weight_cfg *weight_config; 1428 1429 weight_config = &score_config->weight_config; 1430 1431 if (WLAN_REG_IS_5GHZ_CH_FREQ(freq)) 1432 band_index = CM_BAND_5G_INDEX; 1433 else if (WLAN_REG_IS_24GHZ_CH_FREQ(freq)) 1434 band_index = CM_BAND_2G_INDEX; 1435 else if (WLAN_REG_IS_6GHZ_CHAN_FREQ(freq)) 1436 band_index = CM_BAND_6G_INDEX; 1437 else 1438 return 0; 1439 1440 return weight_config->chan_band_weightage * 1441 CM_GET_SCORE_PERCENTAGE(score_config->band_weight_per_index, 1442 band_index); 1443 } 1444 1445 #ifdef WLAN_FEATURE_11BE 1446 static int cm_calculate_eht_score(struct scan_cache_entry *entry, 1447 struct scoring_cfg *score_config, 1448 struct psoc_phy_config *phy_config, 1449 uint8_t prorated_pcnt) 1450 { 1451 uint32_t eht_caps_score; 1452 struct weight_cfg *weight_config; 1453 1454 if (!phy_config->eht_cap || !entry->ie_list.ehtcap) 1455 return 0; 1456 1457 weight_config = &score_config->weight_config; 1458 eht_caps_score = prorated_pcnt * weight_config->eht_caps_weightage; 1459 1460 return eht_caps_score; 1461 } 1462 1463 /** 1464 * cm_get_puncture_bw() - Get puncture band width 1465 * @entry: Bss scan entry 1466 * 1467 * Return: Total bandwidth of punctured subchannels (unit: MHz) 1468 */ 1469 static uint16_t cm_get_puncture_bw(struct scan_cache_entry *entry) 1470 { 1471 uint16_t puncture_bitmap; 1472 uint8_t num_puncture_bw = 0; 1473 1474 puncture_bitmap = entry->channel.puncture_bitmap; 1475 while (puncture_bitmap) { 1476 if (puncture_bitmap & 1) 1477 ++num_puncture_bw; 1478 puncture_bitmap >>= 1; 1479 } 1480 return num_puncture_bw * 20; 1481 } 1482 1483 static bool cm_get_su_beam_former(struct scan_cache_entry *entry) 1484 { 1485 struct wlan_ie_ehtcaps *eht_cap; 1486 struct wlan_eht_cap_info *eht_cap_info; 1487 1488 eht_cap = (struct wlan_ie_ehtcaps *)util_scan_entry_ehtcap(entry); 1489 if (eht_cap) { 1490 eht_cap_info = (struct wlan_eht_cap_info *)eht_cap->eht_mac_cap; 1491 if (eht_cap_info->su_beamformer) 1492 return true; 1493 } 1494 1495 return false; 1496 } 1497 #else 1498 static int cm_calculate_eht_score(struct scan_cache_entry *entry, 1499 struct scoring_cfg *score_config, 1500 struct psoc_phy_config *phy_config, 1501 uint8_t prorated_pcnt) 1502 { 1503 return 0; 1504 } 1505 1506 static uint16_t cm_get_puncture_bw(struct scan_cache_entry *entry) 1507 { 1508 return 0; 1509 } 1510 1511 static bool cm_get_su_beam_former(struct scan_cache_entry *entry) 1512 { 1513 return false; 1514 } 1515 #endif 1516 1517 #define CM_BAND_WIDTH_NUM 16 1518 #define CM_BAND_WIDTH_UNIT 20 1519 uint16_t link_bw_score[CM_BAND_WIDTH_NUM] = { 1520 9, 18, 27, 35, 44, 53, 56, 67, 74, 80, 86, 90, 93, 96, 98, 100}; 1521 1522 static uint32_t cm_get_bw_score(uint8_t bw_weightage, uint16_t bw, 1523 uint8_t prorated_pcnt) 1524 { 1525 uint32_t score; 1526 uint8_t index; 1527 1528 index = bw / CM_BAND_WIDTH_UNIT - 1; 1529 if (index >= CM_BAND_WIDTH_NUM) 1530 index = CM_BAND_WIDTH_NUM - 1; 1531 score = bw_weightage * link_bw_score[index] 1532 * prorated_pcnt / CM_MAX_PCT_SCORE; 1533 1534 return score; 1535 } 1536 1537 /** 1538 * cm_get_ch_width() - Get channel width of bss scan entry 1539 * @entry: Bss scan entry 1540 * @phy_config: Phy config 1541 * 1542 * Return: Channel width (unit: MHz) 1543 */ 1544 static uint16_t cm_get_ch_width(struct scan_cache_entry *entry, 1545 struct psoc_phy_config *phy_config) 1546 { 1547 uint16_t bw, total_bw = 0; 1548 uint8_t bw_above_20 = 0; 1549 bool is_vht = false; 1550 1551 if (WLAN_REG_IS_24GHZ_CH_FREQ(entry->channel.chan_freq)) { 1552 bw_above_20 = phy_config->bw_above_20_24ghz; 1553 if (phy_config->vht_24G_cap) 1554 is_vht = true; 1555 } else if (phy_config->vht_cap) { 1556 is_vht = true; 1557 bw_above_20 = phy_config->bw_above_20_5ghz; 1558 } 1559 if (IS_WLAN_PHYMODE_320MHZ(entry->phy_mode)) 1560 bw = 320; 1561 else if (IS_WLAN_PHYMODE_160MHZ(entry->phy_mode)) 1562 bw = 160; 1563 else if (IS_WLAN_PHYMODE_80MHZ(entry->phy_mode)) 1564 bw = 80; 1565 else if (IS_WLAN_PHYMODE_40MHZ(entry->phy_mode)) 1566 bw = 40; 1567 else 1568 bw = 20; 1569 if (!phy_config->ht_cap && bw > 20) 1570 bw = 20; 1571 1572 if (!is_vht && bw > 40) 1573 bw = 40; 1574 1575 total_bw = bw - cm_get_puncture_bw(entry); 1576 1577 return total_bw; 1578 } 1579 1580 #ifdef WLAN_FEATURE_11BE_MLO 1581 #define CM_MLO_BAD_RSSI_PCT 61 1582 #define CM_MLO_CONGESTION_PCT_BAD_RSSI 6 1583 1584 static uint8_t mlo_boost_pct[MLO_TYPE_MAX] = {0, 10, CM_MAX_PCT_SCORE}; 1585 1586 /** 1587 * struct mlo_rssi_pct: MLO AP rssi joint factor and score percent 1588 * @joint_factor: rssi joint factor (0 - 100) 1589 * @rssi_pcnt: Rssi score percent (0 - 100) 1590 * @prorate_pcnt: RSSI prorated percent 1591 */ 1592 struct mlo_rssi_pct { 1593 uint16_t joint_factor; 1594 uint16_t rssi_pcnt; 1595 uint16_t prorate_pcnt; 1596 }; 1597 1598 #define CM_RSSI_BUCKET_NUM 7 1599 static struct mlo_rssi_pct mlo_rssi_pcnt[CM_RSSI_BUCKET_NUM] = { 1600 {80, 100, 100}, {60, 87, 100}, {44, 74, 100}, {30, 61, 100}, {20, 48, 54}, 1601 {10, 35, 28}, {0, 22, 1} }; 1602 1603 /** 1604 * cm_get_mlo_rssi_score() - Calculate joint rssi score for MLO AP 1605 * @rssi_weightage: rssi weightage 1606 * @link1_rssi: link1 rssi 1607 * @link2_rssi: link2 rssi 1608 * @prorate_pcnt: pointer to store RSSI prorated percent 1609 * 1610 * Return: MLO AP joint rssi score 1611 */ 1612 static uint32_t cm_get_mlo_rssi_score(uint8_t rssi_weightage, int8_t link1_rssi, 1613 int8_t link2_rssi, uint16_t *prorate_pcnt) 1614 { 1615 int8_t link1_factor = 0, link2_factor = 0; 1616 int32_t joint_factor = 0; 1617 int16_t rssi_pcnt = 0; 1618 int8_t i; 1619 1620 /* Calculate RSSI score -- using joint rssi, but limit to 2 links */ 1621 link1_factor = QDF_MAX(QDF_MIN(link1_rssi, -50), -95) + 95; 1622 link2_factor = QDF_MAX(QDF_MIN(link2_rssi, -50), -95) + 95; 1623 joint_factor = QDF_MIN((link1_factor * link1_factor + 1624 link2_factor * link2_factor) * 100 / (2 * 45 * 45), 1625 100); 1626 for (i = 0; i < CM_RSSI_BUCKET_NUM; i++) 1627 if (joint_factor > mlo_rssi_pcnt[i].joint_factor) { 1628 rssi_pcnt = mlo_rssi_pcnt[i].rssi_pcnt; 1629 *prorate_pcnt = mlo_rssi_pcnt[i].prorate_pcnt; 1630 break; 1631 } 1632 1633 return (rssi_weightage * rssi_pcnt); 1634 } 1635 1636 static inline int cm_calculate_emlsr_score(struct weight_cfg *weight_config) 1637 { 1638 return weight_config->emlsr_weightage * mlo_boost_pct[MLSR]; 1639 } 1640 1641 /** 1642 * cm_get_entry() - Get bss scan entry by link mac address 1643 * @scan_list: Scan entry list of bss candidates after filtering 1644 * @link_addr: link mac address 1645 * 1646 * Return: Pointer to bss scan entry 1647 */ 1648 static struct scan_cache_entry *cm_get_entry(qdf_list_t *scan_list, 1649 struct qdf_mac_addr *link_addr) 1650 { 1651 qdf_list_node_t *cur_node = NULL, *next_node = NULL; 1652 struct scan_cache_node *curr_entry = NULL; 1653 1654 qdf_list_peek_front(scan_list, &cur_node); 1655 while (cur_node) { 1656 curr_entry = qdf_container_of(cur_node, struct scan_cache_node, 1657 node); 1658 if (!qdf_mem_cmp(&curr_entry->entry->mac_addr, 1659 link_addr, QDF_MAC_ADDR_SIZE)) 1660 return curr_entry->entry; 1661 1662 qdf_list_peek_next(scan_list, cur_node, &next_node); 1663 cur_node = next_node; 1664 next_node = NULL; 1665 } 1666 1667 return NULL; 1668 } 1669 1670 #ifdef CONN_MGR_ADV_FEATURE 1671 static uint8_t cm_get_sta_mlo_conn_max_num(struct wlan_objmgr_psoc *psoc) 1672 { 1673 return wlan_mlme_get_sta_mlo_conn_max_num(psoc); 1674 } 1675 1676 static bool is_freq_dbs_or_sbs(struct wlan_objmgr_psoc *psoc, 1677 qdf_freq_t freq_1, 1678 qdf_freq_t freq_2) 1679 { 1680 if ((policy_mgr_is_hw_sbs_capable(psoc) && 1681 policy_mgr_are_sbs_chan(psoc, freq_1, freq_2)) || 1682 (policy_mgr_is_hw_dbs_capable(psoc) && 1683 !wlan_reg_is_same_band_freqs(freq_1, freq_2))) { 1684 return true; 1685 } 1686 1687 return false; 1688 } 1689 1690 #else 1691 static inline 1692 uint8_t cm_get_sta_mlo_conn_max_num(struct wlan_objmgr_psoc *psoc) 1693 { 1694 return WLAN_UMAC_MLO_MAX_DEV; 1695 } 1696 1697 static inline bool is_freq_dbs_or_sbs(struct wlan_objmgr_psoc *psoc, 1698 qdf_freq_t freq_1, 1699 qdf_freq_t freq_2) 1700 { 1701 return false; 1702 } 1703 #endif 1704 1705 /** 1706 * cm_bss_mlo_type() - Get mlo type of bss scan entry 1707 * @psoc: Pointer of psoc object 1708 * @entry: Bss scan entry 1709 * @scan_list: 1710 * 1711 * Return: MLO AP type: SLO, MLMR or EMLSR. 1712 */ 1713 static enum MLO_TYPE cm_bss_mlo_type(struct wlan_objmgr_psoc *psoc, 1714 struct scan_cache_entry *entry, 1715 qdf_list_t *scan_list) 1716 { 1717 uint8_t mlo_link_num; 1718 uint8_t i; 1719 uint32_t freq_entry; 1720 uint32_t freq[MLD_MAX_LINKS - 1]; 1721 struct scan_cache_entry *entry_partner[MLD_MAX_LINKS - 1]; 1722 bool multi_link = false; 1723 1724 mlo_link_num = cm_get_sta_mlo_conn_max_num(psoc); 1725 if (!entry->ie_list.multi_link_bv) 1726 return SLO; 1727 else if (!entry->ml_info.num_links) 1728 return SLO; 1729 else if (mlo_link_num == 1) 1730 return SLO; 1731 1732 for (i = 0; i < entry->ml_info.num_links; i++) { 1733 if (!entry->ml_info.link_info[i].is_valid_link) 1734 continue; 1735 multi_link = true; 1736 freq_entry = entry->channel.chan_freq; 1737 freq[i] = entry->ml_info.link_info[i].freq; 1738 entry_partner[i] = 1739 cm_get_entry(scan_list, 1740 &entry->ml_info.link_info[i].link_addr); 1741 if (entry_partner[i]) 1742 freq[i] = entry_partner[i]->channel.chan_freq; 1743 if (is_freq_dbs_or_sbs(psoc, freq[i], freq_entry)) 1744 return MLMR; 1745 } 1746 1747 if (multi_link) 1748 return MLSR; 1749 else 1750 return SLO; 1751 } 1752 1753 /** 1754 * cm_get_mlo_congestion_score() - Get mlo jointer congestion percent 1755 * @bw1: channel width of link1 1756 * @bw2: channel width of link2 1757 * @congestion_score1: congestion score of link1 1758 * @congestion_score2: congestion score of link2 1759 * @score_params: score param 1760 * 1761 * Return: Mlo jointer congestion percent 1762 */ 1763 static uint32_t 1764 cm_get_mlo_congestion_score(uint16_t bw1, 1765 uint16_t bw2, 1766 uint32_t congestion_score1, 1767 uint32_t congestion_score2, 1768 struct scoring_cfg *score_params) 1769 { 1770 uint32_t congestion_best; 1771 uint32_t congestion_worst; 1772 uint32_t congestion_weight; 1773 1774 congestion_weight = 1775 score_params->weight_config.channel_congestion_weightage; 1776 if (congestion_score1 > congestion_score2) { 1777 congestion_best = congestion_score1; 1778 congestion_worst = congestion_score2 * bw1 / (bw1 + bw2); 1779 } else if (congestion_score1 < congestion_score2) { 1780 congestion_best = congestion_score2; 1781 congestion_worst = congestion_score1 * bw2 / (bw1 + bw2); 1782 } else { 1783 congestion_best = congestion_score1; 1784 congestion_worst = congestion_score2 / 2; 1785 } 1786 congestion_best = congestion_best * CM_SLO_CONGESTION_MAX_SCORE / 1787 CM_MAX_PCT_SCORE; 1788 congestion_worst = congestion_worst * CM_SLO_CONGESTION_MAX_SCORE / 1789 CM_MAX_PCT_SCORE; 1790 congestion_worst = QDF_MIN(congestion_worst, 20 * congestion_weight); 1791 1792 return congestion_best + congestion_worst; 1793 } 1794 1795 /** 1796 * cm_estimate_rssi() - Get estimated rssi by frequency 1797 * @rssi_entry: Rssi of bss scan entry 1798 * @freq_entry: Frequency of bss scan entry 1799 * @freq_partner: Frequency of partner link of MLO 1800 * 1801 * Estimated equation: RSSI(2G) = RSSI(5G) + 7 = RSSI(6G) + 8 1802 * 1803 * Return: Estimated rssi of partner link of MLO 1804 */ 1805 static int8_t cm_estimate_rssi(int8_t rssi_entry, uint32_t freq_entry, 1806 uint32_t freq_partner) 1807 { 1808 if (wlan_reg_is_24ghz_ch_freq(freq_entry)) { 1809 if (wlan_reg_is_5ghz_ch_freq(freq_partner)) 1810 return rssi_entry - 7; 1811 else if (wlan_reg_is_6ghz_chan_freq(freq_partner)) 1812 return rssi_entry - 8; 1813 } else if (wlan_reg_is_5ghz_ch_freq(freq_entry)) { 1814 if (wlan_reg_is_24ghz_ch_freq(freq_partner)) 1815 return rssi_entry + 7; 1816 else if (wlan_reg_is_6ghz_chan_freq(freq_partner)) 1817 return rssi_entry - 1; 1818 } else if (wlan_reg_is_6ghz_chan_freq(freq_entry)) { 1819 if (wlan_reg_is_24ghz_ch_freq(freq_partner)) 1820 return rssi_entry + 8; 1821 else if (wlan_reg_is_5ghz_ch_freq(freq_partner)) 1822 return rssi_entry + 1; 1823 } 1824 1825 return rssi_entry; 1826 } 1827 1828 static int cm_calculate_bss_score(struct wlan_objmgr_psoc *psoc, 1829 struct scan_cache_entry *entry, 1830 int pcl_chan_weight, 1831 struct qdf_mac_addr *bssid_hint, 1832 qdf_list_t *scan_list, 1833 bool is_link_score); 1834 1835 /** 1836 * cm_calculate_mlo_bss_score() - Calculate mlo bss score 1837 * @psoc: Pointer to psoc object 1838 * @entry: Bss scan entry 1839 * @score_params: score parameters 1840 * @phy_config: Phy config 1841 * @scan_list: Scan entry list of bss candidates after filtering 1842 * @rssi_prorated_pct: Rssi prorated percent 1843 * @pcl_chan_weight: PCL chan weight 1844 * 1845 * For MLMR case, besides adding MLMR boost score, 1846 * calculate joint RSSI/band width/congestion score for combination of 1847 * scan entry + each partner link, select highest total score as candidate 1848 * combination, only activate that partner link. 1849 * 1850 * Return: MLO AP joint total score 1851 */ 1852 static int cm_calculate_mlo_bss_score(struct wlan_objmgr_psoc *psoc, 1853 struct scan_cache_entry *entry, 1854 struct scoring_cfg *score_params, 1855 struct psoc_phy_config *phy_config, 1856 qdf_list_t *scan_list, 1857 uint8_t *rssi_prorated_pct, 1858 int pcl_chan_weight) 1859 { 1860 struct scan_cache_entry *entry_partner[MLD_MAX_LINKS - 1]; 1861 int32_t rssi[MLD_MAX_LINKS - 1]; 1862 uint32_t rssi_score[MLD_MAX_LINKS - 1] = {}; 1863 uint16_t prorated_pct[MLD_MAX_LINKS - 1] = {}; 1864 uint32_t freq[MLD_MAX_LINKS - 1]; 1865 uint16_t ch_width[MLD_MAX_LINKS - 1]; 1866 uint32_t bandwidth_score[MLD_MAX_LINKS - 1] = {}; 1867 uint32_t congestion_pct[MLD_MAX_LINKS - 1] = {}; 1868 uint32_t congestion_score[MLD_MAX_LINKS - 1] = {}; 1869 uint32_t cong_total_score[MLD_MAX_LINKS - 1] = {}; 1870 uint32_t total_score[MLD_MAX_LINKS - 1] = {}; 1871 uint8_t i, j; 1872 uint16_t chan_width; 1873 uint32_t best_total_score = 0; 1874 uint8_t best_partner_index = 0; 1875 uint32_t cong_pct = 0; 1876 uint32_t cong_score = 0; 1877 uint32_t freq_entry; 1878 struct weight_cfg *weight_config; 1879 struct partner_link_info *link; 1880 struct wlan_objmgr_pdev *pdev; 1881 bool rssi_bad_zone; 1882 bool eht_capab; 1883 struct partner_link_info tmp_link_info; 1884 uint32_t tmp_total_score = 0; 1885 uint32_t assoc_score = 0; 1886 uint32_t link_score[MLD_MAX_LINKS - 1] = {0}; 1887 bool is_assoc_link_best = true; 1888 uint32_t assoc_band_score; 1889 uint32_t link_band_score[MLD_MAX_LINKS - 1] = {0}; 1890 uint32_t total_band_score[MLD_MAX_LINKS - 1] = {0}; 1891 1892 1893 wlan_psoc_mlme_get_11be_capab(psoc, &eht_capab); 1894 if (!eht_capab) 1895 return 0; 1896 1897 weight_config = &score_params->weight_config; 1898 freq_entry = entry->channel.chan_freq; 1899 chan_width = cm_get_ch_width(entry, phy_config); 1900 cong_score = cm_calculate_congestion_score(entry, 1901 score_params, 1902 &cong_pct, false); 1903 1904 assoc_score = 1905 cm_calculate_bss_score(psoc, entry, pcl_chan_weight, 1906 NULL, scan_list, true); 1907 entry->ml_info.link_score = assoc_score; 1908 1909 assoc_band_score = cm_get_band_score(entry->channel.chan_freq, 1910 score_params); 1911 1912 link = &entry->ml_info.link_info[0]; 1913 for (i = 0; i < entry->ml_info.num_links; i++) { 1914 if (!link[i].is_valid_link) 1915 continue; 1916 entry_partner[i] = cm_get_entry(scan_list, &link[i].link_addr); 1917 if (entry_partner[i]) 1918 freq[i] = entry_partner[i]->channel.chan_freq; 1919 else 1920 freq[i] = link[i].freq; 1921 if (!is_freq_dbs_or_sbs(psoc, freq[i], freq_entry)) { 1922 mlme_nofl_debug("freq %d and %d can't be MLMR", 1923 freq[i], freq_entry); 1924 continue; 1925 } 1926 1927 if (entry_partner[i]) { 1928 link_score[i] = 1929 cm_calculate_bss_score(psoc, entry_partner[i], 1930 pcl_chan_weight, 1931 NULL, scan_list, true); 1932 entry_partner[i]->ml_info.link_score = link_score[i]; 1933 1934 rssi[i] = entry_partner[i]->rssi_raw; 1935 ch_width[i] = cm_get_ch_width(entry_partner[i], 1936 phy_config); 1937 } else { 1938 rssi[i] = cm_estimate_rssi(entry->rssi_raw, 1939 freq_entry, 1940 freq[i]); 1941 pdev = psoc->soc_objmgr.wlan_pdev_list[0]; 1942 ch_width[i] = 1943 wlan_reg_get_op_class_width(pdev, 1944 link[i].op_class, 1945 true); 1946 mlme_nofl_debug("No entry for partner, estimate with rnr"); 1947 } 1948 rssi_score[i] = 1949 cm_get_mlo_rssi_score(weight_config->rssi_weightage, 1950 entry->rssi_raw, rssi[i], 1951 &prorated_pct[i]); 1952 1953 bandwidth_score[i] = 1954 cm_get_bw_score(weight_config->chan_width_weightage, 1955 chan_width + ch_width[i], 1956 prorated_pct[i]); 1957 1958 rssi_bad_zone = prorated_pct[i] < CM_MAX_PCT_SCORE; 1959 congestion_score[i] = 1960 cm_calculate_congestion_score(entry_partner[i], 1961 score_params, 1962 &congestion_pct[i], 1963 rssi_bad_zone); 1964 cong_total_score[i] = 1965 cm_get_mlo_congestion_score(chan_width, 1966 ch_width[i], 1967 cong_score, 1968 congestion_score[i], 1969 score_params); 1970 1971 link_band_score[i] = cm_get_band_score(freq[i], score_params); 1972 total_band_score[i] = 1973 (assoc_band_score + link_band_score[i]) / 2; 1974 1975 total_score[i] = rssi_score[i] + bandwidth_score[i] + 1976 cong_total_score[i] + total_band_score[i]; 1977 if (total_score[i] > best_total_score) { 1978 best_total_score = total_score[i]; 1979 best_partner_index = i; 1980 } 1981 1982 mlme_nofl_debug("ML score: link index %u rssi %d %d rssi score %u pror %u freq %u %u bw %u %u, bw score %u congest score %u %u %u, band score: %u %u, total %u", 1983 i, entry->rssi_raw, rssi[i], rssi_score[i], 1984 prorated_pct[i], freq_entry, freq[i], 1985 chan_width, ch_width[i], bandwidth_score[i], 1986 cong_score, congestion_score[i], 1987 cong_total_score[i], 1988 assoc_band_score, link_band_score[i], 1989 total_score[i]); 1990 } 1991 1992 *rssi_prorated_pct = prorated_pct[best_partner_index]; 1993 1994 /* reorder the link idx per score */ 1995 for (j = 0; j < entry->ml_info.num_links; j++) { 1996 tmp_total_score = total_score[j]; 1997 best_partner_index = j; 1998 for (i = j + 1; i < entry->ml_info.num_links; i++) { 1999 if (tmp_total_score < total_score[i]) { 2000 tmp_total_score = total_score[i]; 2001 best_partner_index = i; 2002 } 2003 } 2004 2005 if (best_partner_index != j) { 2006 tmp_link_info = entry->ml_info.link_info[j]; 2007 entry->ml_info.link_info[j] = 2008 entry->ml_info.link_info[best_partner_index]; 2009 entry->ml_info.link_info[best_partner_index] = 2010 tmp_link_info; 2011 total_score[best_partner_index] = total_score[j]; 2012 } 2013 total_score[j] = 0; 2014 } 2015 2016 for (i = 0; i < entry->ml_info.num_links; i++) { 2017 if (link_score[i] > assoc_score) { 2018 is_assoc_link_best = false; 2019 break; 2020 } 2021 } 2022 if (is_assoc_link_best) { 2023 mlme_nofl_debug("asoc link is best, boost %d", 2024 CM_ASSOC_INK_BEST_BOOST); 2025 best_total_score += CM_ASSOC_INK_BEST_BOOST; 2026 } 2027 2028 best_total_score += weight_config->mlo_weightage * 2029 mlo_boost_pct[MLMR]; 2030 entry->ml_info.ml_bss_score = best_total_score; 2031 2032 return best_total_score; 2033 } 2034 2035 #else 2036 static inline int cm_calculate_emlsr_score(struct weight_cfg *weight_config) 2037 { 2038 return 0; 2039 } 2040 2041 static enum MLO_TYPE cm_bss_mlo_type(struct wlan_objmgr_psoc *psoc, 2042 struct scan_cache_entry *entry, 2043 qdf_list_t *scan_list) 2044 { 2045 return SLO; 2046 } 2047 2048 static int cm_calculate_mlo_bss_score(struct wlan_objmgr_psoc *psoc, 2049 struct scan_cache_entry *entry, 2050 struct scoring_cfg *score_params, 2051 struct psoc_phy_config *phy_config, 2052 qdf_list_t *scan_list, 2053 uint8_t *rssi_prorated_pct, 2054 int pcl_chan_weight) 2055 { 2056 return 0; 2057 } 2058 #endif 2059 2060 #if defined(WLAN_FEATURE_11BE_MLO) && defined(CONN_MGR_ADV_FEATURE) 2061 static void 2062 cm_sort_vendor_algo_mlo_bss_entry(struct wlan_objmgr_psoc *psoc, 2063 struct scan_cache_entry *entry, 2064 struct psoc_phy_config *phy_config, 2065 qdf_list_t *scan_list, 2066 enum MLO_TYPE bss_mlo_type) 2067 { 2068 struct scan_cache_entry *entry_partner[MLD_MAX_LINKS - 1]; 2069 uint32_t freq[MLD_MAX_LINKS - 1]; 2070 uint32_t etp_score[MLD_MAX_LINKS - 1] = {0}; 2071 uint32_t total_score[MLD_MAX_LINKS - 1] = {0}; 2072 uint8_t i, j; 2073 uint32_t best_total_score = 0; 2074 uint8_t best_partner_index = 0; 2075 uint32_t freq_entry; 2076 struct partner_link_info *link; 2077 bool eht_capab; 2078 struct partner_link_info tmp_link_info; 2079 uint32_t tmp_total_score = 0; 2080 2081 wlan_psoc_mlme_get_11be_capab(psoc, &eht_capab); 2082 if (!eht_capab) 2083 return; 2084 2085 link = &entry->ml_info.link_info[0]; 2086 freq_entry = entry->channel.chan_freq; 2087 for (i = 0; i < entry->ml_info.num_links; i++) { 2088 mlme_debug("freq: %d, link id: %d is valid %d "QDF_MAC_ADDR_FMT, 2089 link[i].freq, link[i].link_id, 2090 link[i].is_valid_link, 2091 QDF_MAC_ADDR_REF(link[i].link_addr.bytes)); 2092 if (!link[i].is_valid_link) 2093 continue; 2094 2095 entry_partner[i] = cm_get_entry(scan_list, &link[i].link_addr); 2096 if (entry_partner[i]) 2097 freq[i] = entry_partner[i]->channel.chan_freq; 2098 else 2099 freq[i] = link[i].freq; 2100 2101 if (policy_mgr_are_2_freq_on_same_mac(psoc, freq[i], 2102 freq_entry)) { 2103 link[i].is_valid_link = false; 2104 total_score[i] = 0; 2105 mlme_nofl_debug("freq %d and %d can't be MLMR", 2106 freq[i], freq_entry); 2107 continue; 2108 } 2109 2110 if (!entry_partner[i]) 2111 continue; 2112 2113 etp_score[i] = cm_calculate_etp_score(psoc, entry_partner[i], 2114 phy_config, bss_mlo_type); 2115 2116 total_score[i] = etp_score[i]; 2117 if (total_score[i] > best_total_score) { 2118 best_total_score = total_score[i]; 2119 best_partner_index = i; 2120 } 2121 } 2122 2123 /* reorder the link idx per score */ 2124 for (j = 0; j < entry->ml_info.num_links; j++) { 2125 tmp_total_score = total_score[j]; 2126 best_partner_index = j; 2127 for (i = j + 1; i < entry->ml_info.num_links; i++) { 2128 if (tmp_total_score < total_score[i]) { 2129 tmp_total_score = total_score[i]; 2130 best_partner_index = i; 2131 } 2132 } 2133 2134 if (best_partner_index != j) { 2135 tmp_link_info = entry->ml_info.link_info[j]; 2136 entry->ml_info.link_info[j] = 2137 entry->ml_info.link_info[best_partner_index]; 2138 entry->ml_info.link_info[best_partner_index] = 2139 tmp_link_info; 2140 total_score[best_partner_index] = total_score[j]; 2141 } 2142 total_score[j] = 0; 2143 } 2144 } 2145 #else 2146 static void 2147 cm_sort_vendor_algo_mlo_bss_entry(struct wlan_objmgr_psoc *psoc, 2148 struct scan_cache_entry *entry, 2149 struct psoc_phy_config *phy_config, 2150 qdf_list_t *scan_list, 2151 enum MLO_TYPE bss_mlo_type) 2152 {} 2153 #endif 2154 2155 /** 2156 * cm_calculate_bss_score() - Calculate score of AP or 1 link of MLO AP 2157 * @psoc: Pointer to psoc object 2158 * @entry: Bss scan entry 2159 * @pcl_chan_weight: pcl chan weight 2160 * @bssid_hint: bssid hint 2161 * @scan_list: Scan entry list of bss candidates after filtering 2162 * @is_link_score: true: calculate 1 link score of MLO AP 2163 * 2164 * For MLO AP, consider partner link to calculate combined score, prefer to 2165 * select best link as assoc link. 2166 * For legacy AP or 1 link of MLO AP, just consider single link. 2167 * Prefer to select AP of higher score to connect by sort AP by score. 2168 * 2169 * Return: score of AP or 1 link of MLO AP 2170 */ 2171 static int cm_calculate_bss_score(struct wlan_objmgr_psoc *psoc, 2172 struct scan_cache_entry *entry, 2173 int pcl_chan_weight, 2174 struct qdf_mac_addr *bssid_hint, 2175 qdf_list_t *scan_list, 2176 bool is_link_score) 2177 { 2178 int32_t score = 0; 2179 int32_t rssi_score = 0; 2180 int32_t pcl_score = 0; 2181 int32_t ht_score = 0; 2182 int32_t vht_score = 0; 2183 int32_t he_score = 0; 2184 int32_t bandwidth_score = 0; 2185 int32_t beamformee_score = 0; 2186 int32_t band_score = 0; 2187 int32_t nss_score = 0; 2188 int32_t security_score = 0; 2189 int32_t congestion_score = 0; 2190 int32_t congestion_pct = 0; 2191 int32_t oce_wan_score = 0; 2192 uint8_t oce_ap_tx_pwr_score = 0; 2193 uint8_t oce_subnet_id_score = 0; 2194 uint32_t sae_pk_score = 0; 2195 bool oce_subnet_id_present = 0; 2196 bool sae_pk_cap_present = 0; 2197 int8_t ap_tx_pwr_dbm = 0; 2198 uint8_t prorated_pcnt; 2199 bool is_vht = false; 2200 int8_t good_rssi_threshold; 2201 int8_t rssi_pref_5g_rssi_thresh; 2202 bool same_bucket = false; 2203 bool ap_su_beam_former = false; 2204 struct wlan_ie_vhtcaps *vht_cap; 2205 struct wlan_ie_hecaps *he_cap; 2206 struct scoring_cfg *score_config; 2207 struct weight_cfg *weight_config; 2208 uint32_t sta_nss; 2209 struct psoc_mlme_obj *mlme_psoc_obj; 2210 struct psoc_phy_config *phy_config; 2211 uint32_t eht_score; 2212 enum MLO_TYPE bss_mlo_type; 2213 2214 mlme_psoc_obj = wlan_psoc_mlme_get_cmpt_obj(psoc); 2215 if (!mlme_psoc_obj) 2216 return 0; 2217 2218 phy_config = &mlme_psoc_obj->psoc_cfg.phy_config; 2219 score_config = &mlme_psoc_obj->psoc_cfg.score_config; 2220 weight_config = &score_config->weight_config; 2221 2222 if (score_config->is_bssid_hint_priority && bssid_hint && 2223 qdf_is_macaddr_equal(bssid_hint, &entry->bssid)) { 2224 entry->bss_score = CM_BEST_CANDIDATE_MAX_BSS_SCORE; 2225 mlme_nofl_debug("Candidate("QDF_MAC_ADDR_FMT" freq %d): rssi %d BSSID hint given, give max score %d", 2226 QDF_MAC_ADDR_REF(entry->bssid.bytes), 2227 entry->channel.chan_freq, 2228 entry->rssi_raw, 2229 CM_BEST_CANDIDATE_MAX_BSS_SCORE); 2230 return CM_BEST_CANDIDATE_MAX_BSS_SCORE; 2231 } 2232 2233 bss_mlo_type = cm_bss_mlo_type(psoc, entry, scan_list); 2234 if (score_config->vendor_roam_score_algorithm) { 2235 score = cm_calculate_etp_score(psoc, entry, phy_config, 2236 bss_mlo_type); 2237 entry->bss_score = score; 2238 if (bss_mlo_type == MLMR) { 2239 cm_sort_vendor_algo_mlo_bss_entry(psoc, entry, 2240 phy_config, scan_list, 2241 bss_mlo_type); 2242 } 2243 mlme_nofl_debug("Candidate("QDF_MAC_ADDR_FMT" freq %d): rssi %d score %d", 2244 QDF_MAC_ADDR_REF(entry->bssid.bytes), 2245 entry->channel.chan_freq, 2246 entry->rssi_raw, entry->bss_score); 2247 return score; 2248 } 2249 2250 if (is_link_score || bss_mlo_type == SLO || bss_mlo_type == MLSR) { 2251 rssi_score = 2252 cm_calculate_rssi_score(&score_config->rssi_score, 2253 entry->rssi_raw, 2254 weight_config->rssi_weightage); 2255 prorated_pcnt = 2256 cm_get_rssi_prorate_pct(&score_config->rssi_score, 2257 entry->rssi_raw, 2258 weight_config->rssi_weightage); 2259 score += rssi_score; 2260 bandwidth_score = 2261 cm_get_bw_score(weight_config->chan_width_weightage, 2262 cm_get_ch_width(entry, phy_config), 2263 prorated_pcnt); 2264 score += bandwidth_score; 2265 2266 congestion_score = 2267 cm_calculate_congestion_score(entry, 2268 score_config, 2269 &congestion_pct, 0); 2270 score += congestion_score * CM_SLO_CONGESTION_MAX_SCORE / 2271 CM_MAX_PCT_SCORE; 2272 2273 band_score = cm_get_band_score(entry->channel.chan_freq, 2274 score_config); 2275 score += band_score; 2276 2277 if (bss_mlo_type == MLSR) 2278 score += cm_calculate_emlsr_score(weight_config); 2279 } else { 2280 score += cm_calculate_mlo_bss_score(psoc, entry, score_config, 2281 phy_config, scan_list, 2282 &prorated_pcnt, 2283 pcl_chan_weight); 2284 } 2285 2286 pcl_score = cm_calculate_pcl_score(psoc, pcl_chan_weight, 2287 weight_config->pcl_weightage); 2288 score += pcl_score; 2289 2290 /* 2291 * Add HT weight if HT is supported by the AP. In case 2292 * of 6 GHZ AP, HT and VHT won't be supported so that 2293 * these weightage to the same by default to match 2294 * with 2.4/5 GHZ APs where HT, VHT is supported 2295 */ 2296 if (phy_config->ht_cap && (entry->ie_list.htcap || 2297 WLAN_REG_IS_6GHZ_CHAN_FREQ(entry->channel.chan_freq))) 2298 ht_score = prorated_pcnt * 2299 weight_config->ht_caps_weightage; 2300 score += ht_score; 2301 2302 if (WLAN_REG_IS_24GHZ_CH_FREQ(entry->channel.chan_freq)) { 2303 if (phy_config->vht_24G_cap) 2304 is_vht = true; 2305 } else if (phy_config->vht_cap) { 2306 is_vht = true; 2307 } 2308 2309 /* Add VHT score to 6 GHZ AP to match with 2.4/5 GHZ APs */ 2310 if (is_vht && (entry->ie_list.vhtcap || 2311 WLAN_REG_IS_6GHZ_CHAN_FREQ(entry->channel.chan_freq))) 2312 vht_score = prorated_pcnt * 2313 weight_config->vht_caps_weightage; 2314 score += vht_score; 2315 2316 if (phy_config->he_cap && entry->ie_list.hecap) 2317 he_score = prorated_pcnt * 2318 weight_config->he_caps_weightage; 2319 score += he_score; 2320 2321 good_rssi_threshold = 2322 score_config->rssi_score.good_rssi_threshold * (-1); 2323 rssi_pref_5g_rssi_thresh = 2324 score_config->rssi_score.rssi_pref_5g_rssi_thresh * (-1); 2325 if (entry->rssi_raw < good_rssi_threshold) 2326 same_bucket = cm_rssi_is_same_bucket(good_rssi_threshold, 2327 entry->rssi_raw, rssi_pref_5g_rssi_thresh, 2328 score_config->rssi_score.bad_rssi_bucket_size); 2329 2330 vht_cap = (struct wlan_ie_vhtcaps *)util_scan_entry_vhtcap(entry); 2331 he_cap = (struct wlan_ie_hecaps *)util_scan_entry_hecap(entry); 2332 2333 if (vht_cap && vht_cap->su_beam_former) { 2334 ap_su_beam_former = true; 2335 } else if (he_cap && QDF_GET_BITS(*(he_cap->he_phy_cap.phy_cap_bytes + 2336 WLAN_HE_PHYCAP_SU_BFER_OFFSET), WLAN_HE_PHYCAP_SU_BFER_IDX, 2337 WLAN_HE_PHYCAP_SU_BFER_BITS)) { 2338 ap_su_beam_former = true; 2339 } else { 2340 ap_su_beam_former = cm_get_su_beam_former(entry); 2341 } 2342 2343 if (phy_config->beamformee_cap && is_vht && 2344 ap_su_beam_former && 2345 (entry->rssi_raw > rssi_pref_5g_rssi_thresh) && !same_bucket) 2346 beamformee_score = CM_MAX_PCT_SCORE * 2347 weight_config->beamforming_cap_weightage; 2348 score += beamformee_score; 2349 2350 /* 2351 * Consider OCE WAN score score only if 2352 * congestion_pct is greater than CONGESTION_THRSHOLD_FOR_BAND_OCE_SCORE 2353 */ 2354 if (congestion_pct < CM_CONGESTION_THRSHOLD_FOR_BAND_OCE_SCORE) { 2355 oce_wan_score = cm_calculate_oce_wan_score(entry, score_config); 2356 score += oce_wan_score; 2357 } 2358 2359 oce_ap_tx_pwr_score = 2360 cm_calculate_oce_ap_tx_pwr_weightage(entry, score_config, 2361 &ap_tx_pwr_dbm); 2362 score += oce_ap_tx_pwr_score; 2363 2364 oce_subnet_id_score = cm_calculate_oce_subnet_id_weightage(entry, 2365 score_config, 2366 &oce_subnet_id_present); 2367 score += oce_subnet_id_score; 2368 2369 sae_pk_score = cm_calculate_sae_pk_ap_weightage(entry, score_config, 2370 &sae_pk_cap_present); 2371 score += sae_pk_score; 2372 2373 sta_nss = cm_get_sta_nss(psoc, entry->channel.chan_freq, 2374 phy_config->vdev_nss_24g, 2375 phy_config->vdev_nss_5g); 2376 2377 /* 2378 * If station support nss as 2*2 but AP support NSS as 1*1, 2379 * this AP will be given half weight compare to AP which are having 2380 * NSS as 2*2. 2381 */ 2382 nss_score = cm_calculate_nss_score(psoc, score_config, entry->nss, 2383 prorated_pcnt, sta_nss); 2384 score += nss_score; 2385 2386 /* 2387 * Since older FW will stick to the single AKM for roaming, 2388 * no need to check the fw capability. 2389 */ 2390 security_score = cm_calculate_security_score(score_config, 2391 entry->neg_sec_info); 2392 score += security_score; 2393 2394 eht_score = cm_calculate_eht_score(entry, score_config, phy_config, 2395 prorated_pcnt); 2396 score += eht_score; 2397 2398 if (!is_link_score) 2399 entry->bss_score = score; 2400 2401 mlme_nofl_debug("Candidate("QDF_MAC_ADDR_FMT" freq %d): rssi %d HT %d VHT %d HE %d EHT %d su bfer %d phy %d air time frac %d qbss %d cong_pct %d NSS %d ap_tx_pwr_dbm %d oce_subnet_id_present %d sae_pk_cap_present %d prorated_pcnt %d keymgmt 0x%x mlo type %d", 2402 QDF_MAC_ADDR_REF(entry->bssid.bytes), 2403 entry->channel.chan_freq, 2404 entry->rssi_raw, util_scan_entry_htcap(entry) ? 1 : 0, 2405 util_scan_entry_vhtcap(entry) ? 1 : 0, 2406 util_scan_entry_hecap(entry) ? 1 : 0, 2407 util_scan_entry_ehtcap(entry) ? 1 : 0, 2408 ap_su_beam_former, 2409 entry->phy_mode, entry->air_time_fraction, 2410 entry->qbss_chan_load, congestion_pct, entry->nss, 2411 ap_tx_pwr_dbm, oce_subnet_id_present, 2412 sae_pk_cap_present, prorated_pcnt, 2413 entry->neg_sec_info.key_mgmt, bss_mlo_type); 2414 2415 mlme_nofl_debug("%s score: rssi %d pcl %d ht %d vht %d he %d bfee %d bw %d band %d congestion %d nss %d oce wan %d oce ap tx pwr %d subnet %d sae_pk %d eht %d security %d TOTAL %d", 2416 is_link_score ? "Link" : "AP", 2417 rssi_score, pcl_score, ht_score, 2418 vht_score, he_score, beamformee_score, bandwidth_score, 2419 band_score, congestion_score, nss_score, oce_wan_score, 2420 oce_ap_tx_pwr_score, oce_subnet_id_score, 2421 sae_pk_score, eht_score, security_score, score); 2422 2423 return score; 2424 } 2425 2426 static void cm_list_insert_sorted(qdf_list_t *scan_list, 2427 struct scan_cache_node *scan_entry) 2428 { 2429 qdf_list_node_t *cur_node = NULL, *next_node = NULL; 2430 struct scan_cache_node *curr_entry; 2431 2432 qdf_list_peek_front(scan_list, &cur_node); 2433 while (cur_node) { 2434 curr_entry = qdf_container_of(cur_node, struct scan_cache_node, 2435 node); 2436 if (cm_is_better_bss(scan_entry->entry, curr_entry->entry)) { 2437 qdf_list_insert_before(scan_list, &scan_entry->node, 2438 &curr_entry->node); 2439 break; 2440 } 2441 qdf_list_peek_next(scan_list, cur_node, &next_node); 2442 cur_node = next_node; 2443 next_node = NULL; 2444 } 2445 2446 if (!cur_node) 2447 qdf_list_insert_back(scan_list, &scan_entry->node); 2448 } 2449 2450 #ifdef CONN_MGR_ADV_FEATURE 2451 /** 2452 * cm_is_bad_rssi_entry() - check the entry have rssi value, if rssi is lower 2453 * than threshold limit, then it is considered ad bad rssi value. 2454 * @scan_entry: pointer to scan cache entry 2455 * @score_config: pointer to score config structure 2456 * @bssid_hint: bssid hint 2457 * 2458 * Return: true if rssi is lower than threshold 2459 */ 2460 static 2461 bool cm_is_bad_rssi_entry(struct scan_cache_entry *scan_entry, 2462 struct scoring_cfg *score_config, 2463 struct qdf_mac_addr *bssid_hint) 2464 { 2465 int8_t rssi_threshold = 2466 score_config->rssi_score.con_non_hint_target_rssi_threshold; 2467 2468 /* do not need to consider BSSID hint if it is invalid entry(zero) */ 2469 if (qdf_is_macaddr_zero(bssid_hint)) 2470 return false; 2471 2472 if (score_config->is_bssid_hint_priority && 2473 !qdf_is_macaddr_equal(bssid_hint, &scan_entry->bssid) && 2474 scan_entry->rssi_raw < rssi_threshold) { 2475 mlme_nofl_debug("Candidate( " QDF_MAC_ADDR_FMT " freq %d): remove entry, rssi %d lower than rssi_threshold %d", 2476 QDF_MAC_ADDR_REF(scan_entry->bssid.bytes), 2477 scan_entry->channel.chan_freq, 2478 scan_entry->rssi_raw, rssi_threshold); 2479 return true; 2480 } 2481 2482 return false; 2483 } 2484 2485 /** 2486 * cm_update_bss_score_for_mac_addr_matching() - boost score based on mac 2487 * address matching 2488 * @scan_entry: pointer to scan cache entry 2489 * @self_mac: pointer to bssid to be matched 2490 * 2491 * Some IOT APs only allow to connect if last 3 bytes of BSSID 2492 * and self MAC is same. They create a new bssid on receiving 2493 * unicast probe/auth req from STA and allow STA to connect to 2494 * this matching BSSID only. So boost the matching BSSID to try 2495 * to connect to this BSSID. 2496 * 2497 * Return: void 2498 */ 2499 static void 2500 cm_update_bss_score_for_mac_addr_matching(struct scan_cache_node *scan_entry, 2501 struct qdf_mac_addr *self_mac) 2502 { 2503 struct qdf_mac_addr *scan_entry_bssid; 2504 2505 if (!self_mac) 2506 return; 2507 scan_entry_bssid = &scan_entry->entry->bssid; 2508 if (QDF_IS_LAST_3_BYTES_OF_MAC_SAME( 2509 self_mac, scan_entry_bssid)) { 2510 mlme_nofl_debug("Candidate("QDF_MAC_ADDR_FMT" freq %d): boost bss score due to same last 3 byte match", 2511 QDF_MAC_ADDR_REF( 2512 scan_entry_bssid->bytes), 2513 scan_entry->entry->channel.chan_freq); 2514 scan_entry->entry->bss_score = 2515 CM_BEST_CANDIDATE_MAX_BSS_SCORE; 2516 } 2517 } 2518 #else 2519 static inline 2520 bool cm_is_bad_rssi_entry(struct scan_cache_entry *scan_entry, 2521 struct scoring_cfg *score_config, 2522 struct qdf_mac_addr *bssid_hint) 2523 2524 { 2525 return false; 2526 } 2527 2528 static void 2529 cm_update_bss_score_for_mac_addr_matching(struct scan_cache_node *scan_entry, 2530 struct qdf_mac_addr *self_mac) 2531 { 2532 } 2533 #endif 2534 2535 void wlan_cm_calculate_bss_score(struct wlan_objmgr_pdev *pdev, 2536 struct pcl_freq_weight_list *pcl_lst, 2537 qdf_list_t *scan_list, 2538 struct qdf_mac_addr *bssid_hint, 2539 struct qdf_mac_addr *self_mac) 2540 { 2541 struct scan_cache_node *scan_entry; 2542 qdf_list_node_t *cur_node = NULL, *next_node = NULL; 2543 struct psoc_mlme_obj *mlme_psoc_obj; 2544 struct scoring_cfg *score_config; 2545 int pcl_chan_weight; 2546 QDF_STATUS status; 2547 struct psoc_phy_config *config; 2548 enum cm_denylist_action denylist_action; 2549 struct wlan_objmgr_psoc *psoc; 2550 bool assoc_allowed; 2551 struct scan_cache_node *force_connect_candidate = NULL; 2552 bool are_all_candidate_denylisted = true; 2553 bool is_rssi_bad = false; 2554 2555 psoc = wlan_pdev_get_psoc(pdev); 2556 2557 if (!psoc) { 2558 mlme_err("psoc NULL"); 2559 return; 2560 } 2561 if (!scan_list) { 2562 mlme_err("Scan list NULL"); 2563 return; 2564 } 2565 2566 mlme_psoc_obj = wlan_psoc_mlme_get_cmpt_obj(psoc); 2567 if (!mlme_psoc_obj) 2568 return; 2569 2570 score_config = &mlme_psoc_obj->psoc_cfg.score_config; 2571 config = &mlme_psoc_obj->psoc_cfg.phy_config; 2572 2573 mlme_nofl_debug("Self caps: HT %d VHT %d HE %d EHT %d VHT_24Ghz %d BF cap %d bw_above_20_24ghz %d bw_above_20_5ghz %d 2.4G NSS %d 5G NSS %d", 2574 config->ht_cap, config->vht_cap, 2575 config->he_cap, config->eht_cap, config->vht_24G_cap, 2576 config->beamformee_cap, config->bw_above_20_24ghz, 2577 config->bw_above_20_5ghz, config->vdev_nss_24g, 2578 config->vdev_nss_5g); 2579 2580 /* calculate score for each AP */ 2581 if (qdf_list_peek_front(scan_list, &cur_node) != QDF_STATUS_SUCCESS) { 2582 mlme_err("failed to peer front of scan list"); 2583 return; 2584 } 2585 2586 while (cur_node) { 2587 qdf_list_peek_next(scan_list, cur_node, &next_node); 2588 pcl_chan_weight = 0; 2589 scan_entry = qdf_container_of(cur_node, struct scan_cache_node, 2590 node); 2591 2592 is_rssi_bad = cm_is_bad_rssi_entry(scan_entry->entry, 2593 score_config, bssid_hint); 2594 2595 assoc_allowed = cm_is_assoc_allowed(mlme_psoc_obj, 2596 scan_entry->entry); 2597 2598 if (assoc_allowed && !is_rssi_bad) 2599 denylist_action = wlan_denylist_action_on_bssid(pdev, 2600 scan_entry->entry); 2601 else 2602 denylist_action = CM_DLM_FORCE_REMOVE; 2603 2604 if (denylist_action == CM_DLM_NO_ACTION || 2605 denylist_action == CM_DLM_AVOID) 2606 are_all_candidate_denylisted = false; 2607 2608 if (denylist_action == CM_DLM_NO_ACTION && 2609 pcl_lst && pcl_lst->num_of_pcl_channels && 2610 scan_entry->entry->rssi_raw > CM_PCL_RSSI_THRESHOLD && 2611 score_config->weight_config.pcl_weightage) { 2612 if (cm_get_pcl_weight_of_channel( 2613 scan_entry->entry->channel.chan_freq, 2614 pcl_lst, &pcl_chan_weight)) { 2615 mlme_debug("pcl freq %d pcl_chan_weight %d", 2616 scan_entry->entry->channel.chan_freq, 2617 pcl_chan_weight); 2618 } 2619 } 2620 2621 if (denylist_action == CM_DLM_NO_ACTION || 2622 (are_all_candidate_denylisted && denylist_action == 2623 CM_DLM_REMOVE)) { 2624 cm_calculate_bss_score(psoc, scan_entry->entry, 2625 pcl_chan_weight, bssid_hint, 2626 scan_list, false); 2627 } else if (denylist_action == CM_DLM_AVOID) { 2628 /* add min score so that it is added back in the end */ 2629 scan_entry->entry->bss_score = 2630 CM_AVOID_CANDIDATE_MIN_SCORE; 2631 mlme_nofl_debug("Candidate("QDF_MAC_ADDR_FMT" freq %d): rssi %d, is in Avoidlist, give min score %d", 2632 QDF_MAC_ADDR_REF(scan_entry->entry->bssid.bytes), 2633 scan_entry->entry->channel.chan_freq, 2634 scan_entry->entry->rssi_raw, 2635 scan_entry->entry->bss_score); 2636 } else { 2637 mlme_nofl_debug("Candidate("QDF_MAC_ADDR_FMT" freq %d): denylist_action %d", 2638 QDF_MAC_ADDR_REF(scan_entry->entry->bssid.bytes), 2639 scan_entry->entry->channel.chan_freq, 2640 denylist_action); 2641 } 2642 2643 cm_update_bss_score_for_mac_addr_matching(scan_entry, self_mac); 2644 /* 2645 * The below logic is added to select the best candidate 2646 * amongst the denylisted candidates. This is done to 2647 * handle a case where all the BSSIDs become denylisted 2648 * and hence there are continuous connection failures. 2649 * With the below logic if the action on BSSID is to remove 2650 * then we keep a backup node and restore the candidate 2651 * list. 2652 */ 2653 if (denylist_action == CM_DLM_REMOVE && 2654 are_all_candidate_denylisted) { 2655 if (!force_connect_candidate) { 2656 force_connect_candidate = 2657 qdf_mem_malloc( 2658 sizeof(*force_connect_candidate)); 2659 if (!force_connect_candidate) 2660 return; 2661 force_connect_candidate->entry = 2662 util_scan_copy_cache_entry(scan_entry->entry); 2663 if (!force_connect_candidate->entry) 2664 return; 2665 } else if (cm_is_better_bss( 2666 scan_entry->entry, 2667 force_connect_candidate->entry)) { 2668 util_scan_free_cache_entry( 2669 force_connect_candidate->entry); 2670 force_connect_candidate->entry = 2671 util_scan_copy_cache_entry(scan_entry->entry); 2672 if (!force_connect_candidate->entry) 2673 return; 2674 } 2675 } 2676 2677 /* Remove node from current location to add node back sorted */ 2678 status = qdf_list_remove_node(scan_list, cur_node); 2679 if (QDF_IS_STATUS_ERROR(status)) { 2680 mlme_err("failed to remove node for BSS "QDF_MAC_ADDR_FMT" from scan list", 2681 QDF_MAC_ADDR_REF(scan_entry->entry->bssid.bytes)); 2682 return; 2683 } 2684 2685 /* 2686 * If CM_DLM_REMOVE ie denylisted or assoc not allowed then 2687 * free the entry else add back to the list sorted 2688 */ 2689 if (denylist_action == CM_DLM_REMOVE || 2690 denylist_action == CM_DLM_FORCE_REMOVE) { 2691 if (assoc_allowed && !is_rssi_bad) 2692 mlme_nofl_debug("Candidate( " QDF_MAC_ADDR_FMT " freq %d): rssi %d, dlm action %d is in Denylist, remove entry", 2693 QDF_MAC_ADDR_REF(scan_entry->entry->bssid.bytes), 2694 scan_entry->entry->channel.chan_freq, 2695 scan_entry->entry->rssi_raw, 2696 denylist_action); 2697 util_scan_free_cache_entry(scan_entry->entry); 2698 qdf_mem_free(scan_entry); 2699 } else { 2700 cm_list_insert_sorted(scan_list, scan_entry); 2701 } 2702 2703 cur_node = next_node; 2704 next_node = NULL; 2705 } 2706 2707 if (are_all_candidate_denylisted && force_connect_candidate) { 2708 mlme_nofl_debug("All candidates in denylist, Candidate( " QDF_MAC_ADDR_FMT " freq %d): rssi %d, selected for connection", 2709 QDF_MAC_ADDR_REF(force_connect_candidate->entry->bssid.bytes), 2710 force_connect_candidate->entry->channel.chan_freq, 2711 force_connect_candidate->entry->rssi_raw); 2712 cm_list_insert_sorted(scan_list, force_connect_candidate); 2713 } else if (force_connect_candidate) { 2714 util_scan_free_cache_entry(force_connect_candidate->entry); 2715 qdf_mem_free(force_connect_candidate); 2716 } 2717 } 2718 2719 #ifdef CONFIG_BAND_6GHZ 2720 static bool cm_check_h2e_support(const uint8_t *rsnxe) 2721 { 2722 const uint8_t *rsnxe_cap; 2723 uint8_t cap_len; 2724 2725 rsnxe_cap = wlan_crypto_parse_rsnxe_ie(rsnxe, &cap_len); 2726 if (!rsnxe_cap) { 2727 mlme_debug("RSNXE caps not present"); 2728 return false; 2729 } 2730 2731 if (*rsnxe_cap & WLAN_CRYPTO_RSNX_CAP_SAE_H2E) 2732 return true; 2733 2734 mlme_debug("RSNXE caps %x dont have H2E support", *rsnxe_cap); 2735 2736 return false; 2737 } 2738 2739 #ifdef CONN_MGR_ADV_FEATURE 2740 static bool wlan_cm_wfa_get_test_feature_flags(struct wlan_objmgr_psoc *psoc) 2741 { 2742 return wlan_wfa_get_test_feature_flags(psoc, WFA_TEST_IGNORE_RSNXE); 2743 } 2744 #else 2745 static bool wlan_cm_wfa_get_test_feature_flags(struct wlan_objmgr_psoc *psoc) 2746 { 2747 return false; 2748 } 2749 #endif 2750 2751 bool wlan_cm_6ghz_allowed_for_akm(struct wlan_objmgr_psoc *psoc, 2752 uint32_t key_mgmt, uint16_t rsn_caps, 2753 const uint8_t *rsnxe, uint8_t sae_pwe, 2754 bool is_wps) 2755 { 2756 struct psoc_mlme_obj *mlme_psoc_obj; 2757 struct scoring_cfg *config; 2758 2759 /* Allow connection for WPS security */ 2760 if (is_wps) 2761 return true; 2762 2763 mlme_psoc_obj = wlan_psoc_mlme_get_cmpt_obj(psoc); 2764 if (!mlme_psoc_obj) 2765 return false; 2766 2767 config = &mlme_psoc_obj->psoc_cfg.score_config; 2768 /* 2769 * if check_6ghz_security is not set check if key_mgmt_mask_6ghz is set 2770 * if key_mgmt_mask_6ghz is set check if AKM matches the user configured 2771 * 6Ghz security 2772 */ 2773 if (!config->check_6ghz_security) { 2774 if (!config->key_mgmt_mask_6ghz) 2775 return true; 2776 /* 2777 * Check if any AKM is allowed as per user 6Ghz allowed AKM mask 2778 */ 2779 if (!(config->key_mgmt_mask_6ghz & key_mgmt)) { 2780 mlme_debug("user configured mask %x didn't match AKM %x", 2781 config->key_mgmt_mask_6ghz , key_mgmt); 2782 return false; 2783 } 2784 2785 return true; 2786 } 2787 2788 /* Check if any AKM is allowed as per the 6Ghz allowed AKM mask */ 2789 if (!(key_mgmt & ALLOWED_KEYMGMT_6G_MASK)) { 2790 mlme_debug("AKM 0x%x didn't match with allowed 6ghz AKM 0x%x", 2791 key_mgmt, ALLOWED_KEYMGMT_6G_MASK); 2792 return false; 2793 } 2794 2795 /* if check_6ghz_security is set validate all checks for 6Ghz */ 2796 if (!(rsn_caps & WLAN_CRYPTO_RSN_CAP_MFP_ENABLED)) { 2797 mlme_debug("PMF not enabled for 6GHz AP"); 2798 return false; 2799 } 2800 2801 /* for SAE we need to check H2E support */ 2802 if (!(QDF_HAS_PARAM(key_mgmt, WLAN_CRYPTO_KEY_MGMT_SAE) || 2803 QDF_HAS_PARAM(key_mgmt, WLAN_CRYPTO_KEY_MGMT_FT_SAE) || 2804 QDF_HAS_PARAM(key_mgmt, WLAN_CRYPTO_KEY_MGMT_SAE_EXT_KEY) || 2805 QDF_HAS_PARAM(key_mgmt, WLAN_CRYPTO_KEY_MGMT_FT_SAE_EXT_KEY))) 2806 return true; 2807 2808 return (cm_check_h2e_support(rsnxe) || 2809 wlan_cm_wfa_get_test_feature_flags(psoc)); 2810 } 2811 2812 void wlan_cm_set_check_6ghz_security(struct wlan_objmgr_psoc *psoc, 2813 bool value) 2814 { 2815 struct psoc_mlme_obj *mlme_psoc_obj; 2816 2817 mlme_psoc_obj = wlan_psoc_mlme_get_cmpt_obj(psoc); 2818 if (!mlme_psoc_obj) 2819 return; 2820 2821 mlme_debug("6ghz security check val %x", value); 2822 mlme_psoc_obj->psoc_cfg.score_config.check_6ghz_security = value; 2823 } 2824 2825 void wlan_cm_reset_check_6ghz_security(struct wlan_objmgr_psoc *psoc) 2826 { 2827 struct psoc_mlme_obj *mlme_psoc_obj; 2828 2829 mlme_psoc_obj = wlan_psoc_mlme_get_cmpt_obj(psoc); 2830 if (!mlme_psoc_obj) 2831 return; 2832 2833 mlme_psoc_obj->psoc_cfg.score_config.check_6ghz_security = 2834 cfg_get(psoc, CFG_CHECK_6GHZ_SECURITY); 2835 } 2836 2837 bool wlan_cm_get_check_6ghz_security(struct wlan_objmgr_psoc *psoc) 2838 { 2839 struct psoc_mlme_obj *mlme_psoc_obj; 2840 2841 mlme_psoc_obj = wlan_psoc_mlme_get_cmpt_obj(psoc); 2842 if (!mlme_psoc_obj) 2843 return false; 2844 2845 return mlme_psoc_obj->psoc_cfg.score_config.check_6ghz_security; 2846 } 2847 2848 void wlan_cm_set_standard_6ghz_conn_policy(struct wlan_objmgr_psoc *psoc, 2849 bool value) 2850 { 2851 struct psoc_mlme_obj *mlme_psoc_obj; 2852 2853 mlme_psoc_obj = wlan_psoc_mlme_get_cmpt_obj(psoc); 2854 if (!mlme_psoc_obj) 2855 return; 2856 2857 mlme_debug("6ghz standard connection policy val %x", value); 2858 mlme_psoc_obj->psoc_cfg.score_config.standard_6ghz_conn_policy = value; 2859 } 2860 2861 bool wlan_cm_get_standard_6ghz_conn_policy(struct wlan_objmgr_psoc *psoc) 2862 { 2863 struct psoc_mlme_obj *mlme_psoc_obj; 2864 2865 mlme_psoc_obj = wlan_psoc_mlme_get_cmpt_obj(psoc); 2866 if (!mlme_psoc_obj) 2867 return false; 2868 2869 return mlme_psoc_obj->psoc_cfg.score_config.standard_6ghz_conn_policy; 2870 } 2871 2872 void wlan_cm_set_disable_vlp_sta_conn_to_sp_ap(struct wlan_objmgr_psoc *psoc, 2873 bool value) 2874 { 2875 struct psoc_mlme_obj *mlme_psoc_obj; 2876 2877 mlme_psoc_obj = wlan_psoc_mlme_get_cmpt_obj(psoc); 2878 if (!mlme_psoc_obj) 2879 return; 2880 2881 mlme_debug("disable_vlp_sta_conn_to_sp_ap val %x", value); 2882 mlme_psoc_obj->psoc_cfg.score_config.disable_vlp_sta_conn_to_sp_ap = value; 2883 } 2884 2885 bool wlan_cm_get_disable_vlp_sta_conn_to_sp_ap(struct wlan_objmgr_psoc *psoc) 2886 { 2887 struct psoc_mlme_obj *mlme_psoc_obj; 2888 2889 mlme_psoc_obj = wlan_psoc_mlme_get_cmpt_obj(psoc); 2890 if (!mlme_psoc_obj) 2891 return false; 2892 2893 return mlme_psoc_obj->psoc_cfg.score_config.disable_vlp_sta_conn_to_sp_ap; 2894 } 2895 2896 void wlan_cm_set_6ghz_key_mgmt_mask(struct wlan_objmgr_psoc *psoc, 2897 uint32_t value) 2898 { 2899 struct psoc_mlme_obj *mlme_psoc_obj; 2900 2901 mlme_psoc_obj = wlan_psoc_mlme_get_cmpt_obj(psoc); 2902 if (!mlme_psoc_obj) 2903 return; 2904 2905 mlme_debug("key_mgmt_mask_6ghz %x", value); 2906 mlme_psoc_obj->psoc_cfg.score_config.key_mgmt_mask_6ghz = value; 2907 } 2908 2909 uint32_t wlan_cm_get_6ghz_key_mgmt_mask(struct wlan_objmgr_psoc *psoc) 2910 { 2911 struct psoc_mlme_obj *mlme_psoc_obj; 2912 2913 mlme_psoc_obj = wlan_psoc_mlme_get_cmpt_obj(psoc); 2914 if (!mlme_psoc_obj) 2915 return DEFAULT_KEYMGMT_6G_MASK; 2916 2917 return mlme_psoc_obj->psoc_cfg.score_config.key_mgmt_mask_6ghz; 2918 } 2919 2920 static void cm_fill_6ghz_params(struct wlan_objmgr_psoc *psoc, 2921 struct scoring_cfg *score_cfg) 2922 { 2923 /* Allow all security in 6Ghz by default */ 2924 score_cfg->check_6ghz_security = cfg_get(psoc, CFG_CHECK_6GHZ_SECURITY); 2925 score_cfg->key_mgmt_mask_6ghz = 2926 cfg_get(psoc, CFG_6GHZ_ALLOWED_AKM_MASK); 2927 } 2928 #else 2929 static inline void cm_fill_6ghz_params(struct wlan_objmgr_psoc *psoc, 2930 struct scoring_cfg *score_cfg) 2931 { 2932 } 2933 #endif 2934 2935 static uint32_t 2936 cm_limit_max_per_index_score(uint32_t per_index_score) 2937 { 2938 uint8_t i, score; 2939 2940 for (i = 0; i < CM_MAX_INDEX_PER_INI; i++) { 2941 score = CM_GET_SCORE_PERCENTAGE(per_index_score, i); 2942 if (score > CM_MAX_PCT_SCORE) 2943 CM_SET_SCORE_PERCENTAGE(per_index_score, 2944 CM_MAX_PCT_SCORE, i); 2945 } 2946 2947 return per_index_score; 2948 } 2949 2950 #ifdef WLAN_FEATURE_11BE_MLO 2951 2952 #define CM_EHT_CAP_WEIGHTAGE 2 2953 #define CM_MLO_WEIGHTAGE 3 2954 #define CM_WLM_INDICATION_WEIGHTAGE 2 2955 #define CM_EMLSR_WEIGHTAGE 3 2956 static void cm_init_mlo_score_config(struct wlan_objmgr_psoc *psoc, 2957 struct scoring_cfg *score_cfg, 2958 uint32_t *total_weight) 2959 { 2960 score_cfg->weight_config.eht_caps_weightage = 2961 cfg_get(psoc, CFG_SCORING_EHT_CAPS_WEIGHTAGE); 2962 2963 score_cfg->weight_config.mlo_weightage = 2964 cfg_get(psoc, CFG_SCORING_MLO_WEIGHTAGE); 2965 2966 score_cfg->weight_config.wlm_indication_weightage = 2967 cfg_get(psoc, CFG_SCORING_WLM_INDICATION_WEIGHTAGE); 2968 2969 score_cfg->weight_config.joint_rssi_alpha = 2970 cfg_get(psoc, CFG_SCORING_JOINT_RSSI_ALPHA); 2971 2972 score_cfg->weight_config.low_band_rssi_boost = 2973 cfg_get(psoc, CFG_SCORING_LOW_BAND_RSSI_BOOST); 2974 2975 score_cfg->weight_config.joint_esp_alpha = 2976 cfg_get(psoc, CFG_SCORING_JOINT_ESP_ALPHA); 2977 2978 score_cfg->weight_config.low_band_esp_boost = 2979 cfg_get(psoc, CFG_SCORING_LOW_BAND_ESP_BOOST); 2980 2981 score_cfg->weight_config.joint_oce_alpha = 2982 cfg_get(psoc, CFG_SCORING_JOINT_OCE_ALPHA); 2983 2984 score_cfg->weight_config.low_band_oce_boost = 2985 cfg_get(psoc, CFG_SCORING_LOW_BAND_OCE_BOOST); 2986 2987 score_cfg->weight_config.emlsr_weightage = 2988 cfg_get(psoc, CFG_SCORING_EMLSR_WEIGHTAGE); 2989 2990 score_cfg->mlsr_link_selection = 2991 cfg_get(psoc, CFG_SCORING_MLSR_LINK_SELECTION); 2992 2993 *total_weight += score_cfg->weight_config.eht_caps_weightage + 2994 score_cfg->weight_config.mlo_weightage + 2995 score_cfg->weight_config.wlm_indication_weightage + 2996 score_cfg->weight_config.emlsr_weightage; 2997 } 2998 2999 static void cm_set_default_mlo_weights(struct scoring_cfg *score_cfg) 3000 { 3001 score_cfg->weight_config.eht_caps_weightage = CM_EHT_CAP_WEIGHTAGE; 3002 score_cfg->weight_config.mlo_weightage = CM_MLO_WEIGHTAGE; 3003 score_cfg->weight_config.wlm_indication_weightage = 3004 CM_WLM_INDICATION_WEIGHTAGE; 3005 score_cfg->weight_config.emlsr_weightage = CM_EMLSR_WEIGHTAGE; 3006 } 3007 3008 static void cm_init_bw_weight_per_index(struct wlan_objmgr_psoc *psoc, 3009 struct scoring_cfg *score_cfg) 3010 { 3011 score_cfg->bandwidth_weight_per_index[0] = 3012 cm_limit_max_per_index_score( 3013 cfg_get(psoc, CFG_SCORING_BW_WEIGHT_PER_IDX)); 3014 3015 score_cfg->bandwidth_weight_per_index[1] = 3016 cm_limit_max_per_index_score( 3017 cfg_get(psoc, CFG_SCORING_BW_WEIGHT_PER_IDX_4_TO_7)); 3018 3019 score_cfg->bandwidth_weight_per_index[2] = 3020 cm_limit_max_per_index_score( 3021 cfg_get(psoc, CFG_SCORING_BW_WEIGHT_PER_IDX_8_TO_11)); 3022 3023 score_cfg->bandwidth_weight_per_index[3] = 3024 cm_limit_max_per_index_score( 3025 cfg_get(psoc, CFG_SCORING_BW_WEIGHT_PER_IDX_12_TO_15)); 3026 3027 score_cfg->bandwidth_weight_per_index[4] = 3028 cm_limit_max_per_index_score( 3029 cfg_get(psoc, CFG_SCORING_BW_WEIGHT_PER_IDX_16_TO_19)); 3030 3031 score_cfg->bandwidth_weight_per_index[5] = 3032 cm_limit_max_per_index_score( 3033 cfg_get(psoc, CFG_SCORING_BW_WEIGHT_PER_IDX_20_TO_23)); 3034 3035 score_cfg->bandwidth_weight_per_index[6] = 3036 cm_limit_max_per_index_score( 3037 cfg_get(psoc, CFG_SCORING_BW_WEIGHT_PER_IDX_24_TO_27)); 3038 3039 score_cfg->bandwidth_weight_per_index[7] = 3040 cm_limit_max_per_index_score( 3041 cfg_get(psoc, CFG_SCORING_BW_WEIGHT_PER_IDX_28_TO_31)); 3042 3043 score_cfg->bandwidth_weight_per_index[8] = 3044 cm_limit_max_per_index_score( 3045 cfg_get(psoc, CFG_SCORING_BW_WEIGHT_PER_IDX_32_TO_35)); 3046 } 3047 3048 static void cm_init_nss_weight_per_index(struct wlan_objmgr_psoc *psoc, 3049 struct scoring_cfg *score_cfg) 3050 { 3051 score_cfg->nss_weight_per_index[0] = 3052 cm_limit_max_per_index_score( 3053 cfg_get(psoc, CFG_SCORING_NSS_WEIGHT_PER_IDX)); 3054 3055 score_cfg->nss_weight_per_index[1] = 3056 cm_limit_max_per_index_score( 3057 cfg_get(psoc, CFG_SCORING_ML_NSS_WEIGHT_PER_IDX_4_TO_7)); 3058 } 3059 #else 3060 static void cm_init_mlo_score_config(struct wlan_objmgr_psoc *psoc, 3061 struct scoring_cfg *score_cfg, 3062 uint32_t *total_weight) 3063 { 3064 } 3065 3066 static void cm_set_default_mlo_weights(struct scoring_cfg *score_cfg) 3067 { 3068 } 3069 3070 #ifdef WLAN_FEATURE_11BE 3071 static void cm_init_bw_weight_per_index(struct wlan_objmgr_psoc *psoc, 3072 struct scoring_cfg *score_cfg) 3073 { 3074 score_cfg->bandwidth_weight_per_index[0] = 3075 cm_limit_max_per_index_score( 3076 cfg_get(psoc, CFG_SCORING_BW_WEIGHT_PER_IDX)); 3077 3078 score_cfg->bandwidth_weight_per_index[1] = 3079 cm_limit_max_per_index_score( 3080 cfg_get(psoc, CFG_SCORING_BW_WEIGHT_PER_IDX_4_TO_7)); 3081 3082 score_cfg->bandwidth_weight_per_index[2] = 3083 cm_limit_max_per_index_score( 3084 cfg_get(psoc, CFG_SCORING_BW_WEIGHT_PER_IDX_8_TO_11)); 3085 } 3086 #else 3087 static void cm_init_bw_weight_per_index(struct wlan_objmgr_psoc *psoc, 3088 struct scoring_cfg *score_cfg) 3089 { 3090 score_cfg->bandwidth_weight_per_index[0] = 3091 cm_limit_max_per_index_score( 3092 cfg_get(psoc, CFG_SCORING_BW_WEIGHT_PER_IDX)); 3093 } 3094 #endif 3095 3096 static void cm_init_nss_weight_per_index(struct wlan_objmgr_psoc *psoc, 3097 struct scoring_cfg *score_cfg) 3098 { 3099 score_cfg->nss_weight_per_index[0] = 3100 cm_limit_max_per_index_score( 3101 cfg_get(psoc, CFG_SCORING_NSS_WEIGHT_PER_IDX)); 3102 } 3103 #endif 3104 3105 void wlan_cm_init_score_config(struct wlan_objmgr_psoc *psoc, 3106 struct scoring_cfg *score_cfg) 3107 { 3108 uint32_t total_weight; 3109 3110 score_cfg->weight_config.rssi_weightage = 3111 cfg_get(psoc, CFG_SCORING_RSSI_WEIGHTAGE); 3112 score_cfg->weight_config.ht_caps_weightage = 3113 cfg_get(psoc, CFG_SCORING_HT_CAPS_WEIGHTAGE); 3114 score_cfg->weight_config.vht_caps_weightage = 3115 cfg_get(psoc, CFG_SCORING_VHT_CAPS_WEIGHTAGE); 3116 score_cfg->weight_config.he_caps_weightage = 3117 cfg_get(psoc, CFG_SCORING_HE_CAPS_WEIGHTAGE); 3118 score_cfg->weight_config.chan_width_weightage = 3119 cfg_get(psoc, CFG_SCORING_CHAN_WIDTH_WEIGHTAGE); 3120 score_cfg->weight_config.chan_band_weightage = 3121 cfg_get(psoc, CFG_SCORING_CHAN_BAND_WEIGHTAGE); 3122 score_cfg->weight_config.nss_weightage = 3123 cfg_get(psoc, CFG_SCORING_NSS_WEIGHTAGE); 3124 score_cfg->weight_config.beamforming_cap_weightage = 3125 cfg_get(psoc, CFG_SCORING_BEAMFORM_CAP_WEIGHTAGE); 3126 score_cfg->weight_config.pcl_weightage = 3127 cfg_get(psoc, CFG_SCORING_PCL_WEIGHTAGE); 3128 score_cfg->weight_config.channel_congestion_weightage = 3129 cfg_get(psoc, CFG_SCORING_CHAN_CONGESTION_WEIGHTAGE); 3130 score_cfg->weight_config.oce_wan_weightage = 3131 cfg_get(psoc, CFG_SCORING_OCE_WAN_WEIGHTAGE); 3132 score_cfg->weight_config.oce_ap_tx_pwr_weightage = 3133 cfg_get(psoc, CFG_OCE_AP_TX_PWR_WEIGHTAGE); 3134 score_cfg->weight_config.oce_subnet_id_weightage = 3135 cfg_get(psoc, CFG_OCE_SUBNET_ID_WEIGHTAGE); 3136 score_cfg->weight_config.sae_pk_ap_weightage = 3137 cfg_get(psoc, CFG_SAE_PK_AP_WEIGHTAGE); 3138 score_cfg->weight_config.security_weightage = CM_SECURITY_WEIGHTAGE; 3139 3140 total_weight = score_cfg->weight_config.rssi_weightage + 3141 score_cfg->weight_config.ht_caps_weightage + 3142 score_cfg->weight_config.vht_caps_weightage + 3143 score_cfg->weight_config.he_caps_weightage + 3144 score_cfg->weight_config.chan_width_weightage + 3145 score_cfg->weight_config.chan_band_weightage + 3146 score_cfg->weight_config.nss_weightage + 3147 score_cfg->weight_config.beamforming_cap_weightage + 3148 score_cfg->weight_config.pcl_weightage + 3149 score_cfg->weight_config.channel_congestion_weightage + 3150 score_cfg->weight_config.oce_wan_weightage + 3151 score_cfg->weight_config.oce_ap_tx_pwr_weightage + 3152 score_cfg->weight_config.oce_subnet_id_weightage + 3153 score_cfg->weight_config.sae_pk_ap_weightage + 3154 score_cfg->weight_config.security_weightage; 3155 3156 cm_init_mlo_score_config(psoc, score_cfg, &total_weight); 3157 3158 /* 3159 * If configured weights are greater than max weight, 3160 * fallback to default weights 3161 */ 3162 if (total_weight > CM_BEST_CANDIDATE_MAX_WEIGHT) { 3163 mlme_err("Total weight greater than %d, using default weights", 3164 CM_BEST_CANDIDATE_MAX_WEIGHT); 3165 score_cfg->weight_config.rssi_weightage = CM_RSSI_WEIGHTAGE; 3166 score_cfg->weight_config.ht_caps_weightage = 3167 CM_HT_CAPABILITY_WEIGHTAGE; 3168 score_cfg->weight_config.vht_caps_weightage = 3169 CM_VHT_CAP_WEIGHTAGE; 3170 score_cfg->weight_config.he_caps_weightage = 3171 CM_HE_CAP_WEIGHTAGE; 3172 score_cfg->weight_config.chan_width_weightage = 3173 CM_CHAN_WIDTH_WEIGHTAGE; 3174 score_cfg->weight_config.chan_band_weightage = 3175 CM_CHAN_BAND_WEIGHTAGE; 3176 score_cfg->weight_config.nss_weightage = CM_NSS_WEIGHTAGE; 3177 score_cfg->weight_config.beamforming_cap_weightage = 3178 CM_BEAMFORMING_CAP_WEIGHTAGE; 3179 score_cfg->weight_config.pcl_weightage = CM_PCL_WEIGHT; 3180 score_cfg->weight_config.channel_congestion_weightage = 3181 CM_CHANNEL_CONGESTION_WEIGHTAGE; 3182 score_cfg->weight_config.oce_wan_weightage = 3183 CM_OCE_WAN_WEIGHTAGE; 3184 score_cfg->weight_config.oce_ap_tx_pwr_weightage = 3185 CM_OCE_AP_TX_POWER_WEIGHTAGE; 3186 score_cfg->weight_config.oce_subnet_id_weightage = 3187 CM_OCE_SUBNET_ID_WEIGHTAGE; 3188 score_cfg->weight_config.sae_pk_ap_weightage = 3189 CM_SAE_PK_AP_WEIGHTAGE; 3190 cm_set_default_mlo_weights(score_cfg); 3191 } 3192 3193 score_cfg->rssi_score.best_rssi_threshold = 3194 cfg_get(psoc, CFG_SCORING_BEST_RSSI_THRESHOLD); 3195 score_cfg->rssi_score.good_rssi_threshold = 3196 cfg_get(psoc, CFG_SCORING_GOOD_RSSI_THRESHOLD); 3197 score_cfg->rssi_score.bad_rssi_threshold = 3198 cfg_get(psoc, CFG_SCORING_BAD_RSSI_THRESHOLD); 3199 3200 score_cfg->rssi_score.good_rssi_pcnt = 3201 cfg_get(psoc, CFG_SCORING_GOOD_RSSI_PERCENT); 3202 score_cfg->rssi_score.bad_rssi_pcnt = 3203 cfg_get(psoc, CFG_SCORING_BAD_RSSI_PERCENT); 3204 3205 score_cfg->rssi_score.good_rssi_bucket_size = 3206 cfg_get(psoc, CFG_SCORING_GOOD_RSSI_BUCKET_SIZE); 3207 score_cfg->rssi_score.bad_rssi_bucket_size = 3208 cfg_get(psoc, CFG_SCORING_BAD_RSSI_BUCKET_SIZE); 3209 3210 score_cfg->rssi_score.rssi_pref_5g_rssi_thresh = 3211 cfg_get(psoc, CFG_SCORING_RSSI_PREF_5G_THRESHOLD); 3212 3213 score_cfg->rssi_score.con_non_hint_target_rssi_threshold = 3214 cfg_get(psoc, CFG_CON_NON_HINT_TARGET_MIN_RSSI); 3215 3216 score_cfg->esp_qbss_scoring.num_slot = 3217 cfg_get(psoc, CFG_SCORING_NUM_ESP_QBSS_SLOTS); 3218 score_cfg->esp_qbss_scoring.score_pcnt3_to_0 = 3219 cm_limit_max_per_index_score( 3220 cfg_get(psoc, CFG_SCORING_ESP_QBSS_SCORE_IDX_3_TO_0)); 3221 score_cfg->esp_qbss_scoring.score_pcnt7_to_4 = 3222 cm_limit_max_per_index_score( 3223 cfg_get(psoc, CFG_SCORING_ESP_QBSS_SCORE_IDX_7_TO_4)); 3224 score_cfg->esp_qbss_scoring.score_pcnt11_to_8 = 3225 cm_limit_max_per_index_score( 3226 cfg_get(psoc, CFG_SCORING_ESP_QBSS_SCORE_IDX_11_TO_8)); 3227 score_cfg->esp_qbss_scoring.score_pcnt15_to_12 = 3228 cm_limit_max_per_index_score( 3229 cfg_get(psoc, CFG_SCORING_ESP_QBSS_SCORE_IDX_15_TO_12)); 3230 3231 score_cfg->oce_wan_scoring.num_slot = 3232 cfg_get(psoc, CFG_SCORING_NUM_OCE_WAN_SLOTS); 3233 score_cfg->oce_wan_scoring.score_pcnt3_to_0 = 3234 cm_limit_max_per_index_score( 3235 cfg_get(psoc, CFG_SCORING_OCE_WAN_SCORE_IDX_3_TO_0)); 3236 score_cfg->oce_wan_scoring.score_pcnt7_to_4 = 3237 cm_limit_max_per_index_score( 3238 cfg_get(psoc, CFG_SCORING_OCE_WAN_SCORE_IDX_7_TO_4)); 3239 score_cfg->oce_wan_scoring.score_pcnt11_to_8 = 3240 cm_limit_max_per_index_score( 3241 cfg_get(psoc, CFG_SCORING_OCE_WAN_SCORE_IDX_11_TO_8)); 3242 score_cfg->oce_wan_scoring.score_pcnt15_to_12 = 3243 cm_limit_max_per_index_score( 3244 cfg_get(psoc, CFG_SCORING_OCE_WAN_SCORE_IDX_15_TO_12)); 3245 3246 score_cfg->band_weight_per_index = 3247 cm_limit_max_per_index_score( 3248 cfg_get(psoc, CFG_SCORING_BAND_WEIGHT_PER_IDX)); 3249 score_cfg->is_bssid_hint_priority = 3250 cfg_get(psoc, CFG_IS_BSSID_HINT_PRIORITY); 3251 score_cfg->vendor_roam_score_algorithm = 3252 cfg_get(psoc, CFG_VENDOR_ROAM_SCORE_ALGORITHM); 3253 score_cfg->check_assoc_disallowed = true; 3254 cm_fill_6ghz_params(psoc, score_cfg); 3255 3256 cm_init_bw_weight_per_index(psoc, score_cfg); 3257 cm_init_nss_weight_per_index(psoc, score_cfg); 3258 score_cfg->security_weight_per_index = CM_SECURITY_INDEX_WEIGHTAGE; 3259 } 3260