Browse Source

qcacmn: Downgrade connection to HE mode

STA is not able to connect to 11be non-WPA3 mode AP.

STA need to decide whether to connect in EHT or not at
the time of connection to AP based on security configuration.

Change-Id: I812f5c322d36ba44f63d4e27b5ec65a2846b3265
CRs-Fixed: 3404747
Aravind Kishore Sukla 2 years ago
parent
commit
db33c1e902

+ 11 - 0
umac/cmn_services/crypto/inc/wlan_crypto_global_def.h

@@ -623,4 +623,15 @@ struct wlan_lmac_if_crypto_rx_ops {
 	 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_SAE_EXT_KEY) || \
 	 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_FT_SAE_EXT_KEY))
 
+#define WLAN_CRYPTO_IS_AKM_WPA2_PSK(akm) \
+	(QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_PSK) || \
+	 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_PSK_SHA256) || \
+	 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_FT_PSK) || \
+	 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_FT_PSK_SHA384))
+
+#define WLAN_CRYPTO_IS_AKM_SAE(akm) \
+	(QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_SAE) || \
+	 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_FT_SAE) || \
+	 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_SAE_EXT_KEY) || \
+	 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_FT_SAE_EXT_KEY))
 #endif /* end of _WLAN_CRYPTO_GLOBAL_DEF_H_ */

+ 98 - 36
umac/mlme/connection_mgr/core/src/wlan_cm_bss_scoring.c

@@ -1443,6 +1443,38 @@ cm_get_band_score(uint32_t freq, struct scoring_cfg *score_config)
 }
 
 #ifdef WLAN_FEATURE_11BE
+bool cm_is_eht_allowed_for_current_security(struct scan_cache_entry *scan_entry)
+{
+	const uint8_t *rsnxe, *rsnxe_caps;
+	uint8_t cap_len;
+
+	if (!scan_entry->ie_list.rsn)
+		return false;
+
+	/* check AKM chosen for connection is PSK */
+	if (WLAN_CRYPTO_IS_AKM_WPA2_PSK(scan_entry->neg_sec_info.key_mgmt))
+		return false;
+
+	/*
+	 * check AKM chosen for connection is SAE or not
+	 * if not connect with EHT enabled for all other AKMs
+	 */
+	if (!WLAN_CRYPTO_IS_AKM_SAE(scan_entry->neg_sec_info.key_mgmt))
+		return true;
+	rsnxe = util_scan_entry_rsnxe(scan_entry);
+	if (!rsnxe)
+		return false;
+	rsnxe_caps = wlan_crypto_parse_rsnxe_ie(rsnxe, &cap_len);
+	if (!rsnxe_caps) {
+		mlme_debug("RSNXE caps not present");
+		return false;
+	}
+	/* check if H2E bit is enabled in RSNXE */
+	if (*rsnxe_caps & WLAN_CRYPTO_RSNX_CAP_SAE_H2E)
+		return true;
+	return false;
+}
+
 static int cm_calculate_eht_score(struct scan_cache_entry *entry,
 				  struct scoring_cfg *score_config,
 				  struct psoc_phy_config *phy_config,
@@ -1454,6 +1486,9 @@ static int cm_calculate_eht_score(struct scan_cache_entry *entry,
 	if (!phy_config->eht_cap || !entry->ie_list.ehtcap)
 		return 0;
 
+	if (!cm_is_eht_allowed_for_current_security(entry))
+		return 0;
+
 	weight_config = &score_config->weight_config;
 	eht_caps_score = prorated_pcnt * weight_config->eht_caps_weightage;
 
@@ -2152,6 +2187,63 @@ cm_sort_vendor_algo_mlo_bss_entry(struct wlan_objmgr_psoc *psoc,
 {}
 #endif
 
+static int cm_calculate_ml_scores(struct wlan_objmgr_psoc *psoc,
+				  struct scan_cache_entry *entry,
+				  struct scoring_cfg *score_config,
+				  struct psoc_phy_config *phy_config,
+				  qdf_list_t *scan_list, bool is_link_score,
+				  enum MLO_TYPE bss_mlo_type,
+				  int pcl_chan_weight)
+{
+	int32_t score = 0;
+	int32_t rssi_score = 0;
+	int32_t congestion_pct = 0;
+	int32_t bandwidth_score = 0;
+	int32_t congestion_score = 0;
+	uint8_t prorated_pcnt = 0;
+	int32_t band_score = 0;
+	struct weight_cfg *weight_config;
+
+	weight_config = &score_config->weight_config;
+	if (is_link_score || bss_mlo_type == SLO || bss_mlo_type == MLSR) {
+		rssi_score =
+			cm_calculate_rssi_score(&score_config->rssi_score,
+						entry->rssi_raw,
+						weight_config->rssi_weightage);
+		prorated_pcnt =
+			cm_get_rssi_prorate_pct(&score_config->rssi_score,
+						entry->rssi_raw,
+						weight_config->rssi_weightage);
+		score += rssi_score;
+		bandwidth_score =
+			cm_get_bw_score(weight_config->chan_width_weightage,
+					cm_get_ch_width(entry, phy_config),
+					prorated_pcnt);
+		score += bandwidth_score;
+
+		congestion_score =
+			cm_calculate_congestion_score(entry,
+						      score_config,
+						      &congestion_pct, 0);
+		score += congestion_score * CM_SLO_CONGESTION_MAX_SCORE /
+			 CM_MAX_PCT_SCORE;
+
+		band_score = cm_get_band_score(entry->channel.chan_freq,
+					       score_config);
+		score += band_score;
+
+		if (bss_mlo_type == MLSR)
+			score += cm_calculate_emlsr_score(weight_config);
+	} else {
+		score += cm_calculate_mlo_bss_score(psoc, entry, score_config,
+						    phy_config, scan_list,
+						    &prorated_pcnt,
+						    pcl_chan_weight);
+		return score;
+	}
+	return score;
+}
+
 /**
  * cm_calculate_bss_score() - Calculate score of AP or 1 link of MLO AP
  * @psoc: Pointer to psoc object
@@ -2195,7 +2287,7 @@ static int cm_calculate_bss_score(struct wlan_objmgr_psoc *psoc,
 	bool oce_subnet_id_present = 0;
 	bool sae_pk_cap_present = 0;
 	int8_t ap_tx_pwr_dbm = 0;
-	uint8_t prorated_pcnt;
+	uint8_t prorated_pcnt = 0;
 	bool is_vht = false;
 	int8_t good_rssi_threshold;
 	int8_t rssi_pref_5g_rssi_thresh;
@@ -2247,41 +2339,11 @@ static int cm_calculate_bss_score(struct wlan_objmgr_psoc *psoc,
 		return score;
 	}
 
-	if (is_link_score || bss_mlo_type == SLO || bss_mlo_type == MLSR) {
-		rssi_score =
-			cm_calculate_rssi_score(&score_config->rssi_score,
-						entry->rssi_raw,
-						weight_config->rssi_weightage);
-		prorated_pcnt =
-			cm_get_rssi_prorate_pct(&score_config->rssi_score,
-						entry->rssi_raw,
-						weight_config->rssi_weightage);
-		score += rssi_score;
-		bandwidth_score =
-			cm_get_bw_score(weight_config->chan_width_weightage,
-					cm_get_ch_width(entry, phy_config),
-					prorated_pcnt);
-		score += bandwidth_score;
-
-		congestion_score =
-			cm_calculate_congestion_score(entry,
-						      score_config,
-						      &congestion_pct, 0);
-		score += congestion_score * CM_SLO_CONGESTION_MAX_SCORE /
-			 CM_MAX_PCT_SCORE;
-
-		band_score = cm_get_band_score(entry->channel.chan_freq,
-					       score_config);
-		score += band_score;
-
-		if (bss_mlo_type == MLSR)
-			score += cm_calculate_emlsr_score(weight_config);
-	} else {
-		score += cm_calculate_mlo_bss_score(psoc, entry, score_config,
-						    phy_config, scan_list,
-						    &prorated_pcnt,
-						    pcl_chan_weight);
-	}
+	if (cm_is_eht_allowed_for_current_security(entry))
+		score += cm_calculate_ml_scores(psoc, entry, score_config,
+						phy_config, scan_list,
+						is_link_score, bss_mlo_type,
+						pcl_chan_weight);
 
 	pcl_score = cm_calculate_pcl_score(psoc, pcl_chan_weight,
 					   weight_config->pcl_weightage);

+ 4 - 2
umac/mlme/connection_mgr/core/src/wlan_cm_connect.c

@@ -482,7 +482,8 @@ static QDF_STATUS cm_update_vdev_mlme_macaddr(struct cnx_mgr *cm_ctx,
 	mac = (struct qdf_mac_addr *)wlan_vdev_mlme_get_mldaddr(cm_ctx->vdev);
 
 	if (req->cur_candidate->entry->ie_list.multi_link_bv &&
-	    !qdf_is_macaddr_zero(mac)) {
+	    !qdf_is_macaddr_zero(mac) &&
+	    cm_is_eht_allowed_for_current_security(req->cur_candidate->entry)) {
 		wlan_vdev_obj_lock(cm_ctx->vdev);
 		/* Use link address for ML connection */
 		wlan_vdev_mlme_set_macaddr(cm_ctx->vdev,
@@ -617,7 +618,8 @@ static void cm_create_bss_peer(struct cnx_mgr *cm_ctx,
 
 	wlan_psoc_mlme_get_11be_capab(wlan_vdev_get_psoc(cm_ctx->vdev),
 				      &eht_capab);
-	if (eht_capab && wlan_vdev_mlme_is_mlo_vdev(cm_ctx->vdev)) {
+	if (eht_capab && wlan_vdev_mlme_is_mlo_vdev(cm_ctx->vdev) &&
+	    cm_is_eht_allowed_for_current_security(req->cur_candidate->entry)) {
 		cm_set_vdev_link_id(cm_ctx, req);
 		wlan_mlo_init_cu_bpcc(cm_ctx->vdev);
 		mld_mac = cm_get_bss_peer_mld_addr(req);

+ 18 - 0
umac/mlme/connection_mgr/dispatcher/inc/wlan_cm_bss_score_param.h

@@ -339,6 +339,24 @@ void wlan_cm_calculate_bss_score(struct wlan_objmgr_pdev *pdev,
 				 struct qdf_mac_addr *bssid_hint,
 				 struct qdf_mac_addr *self_mac);
 
+#ifdef WLAN_FEATURE_11BE
+/**
+ * cm_is_eht_allowed_for_current_security() - checks the current security, if
+ * eht allowed or not.
+ * @scan_entry: pointer to scan cache entry
+ *
+ * Return: true if eht allowed for current security
+ **/
+bool cm_is_eht_allowed_for_current_security(
+			struct scan_cache_entry *scan_entry);
+#else
+static inline bool cm_is_eht_allowed_for_current_security(
+			struct scan_cache_entry *scan_entry)
+{
+	return false;
+}
+#endif
+
 /**
  * wlan_cm_init_score_config() - Init score INI and config
  * @psoc: pointer to psoc object