Browse Source

qcacld-3.0: Add country IE check to determine STA's power type for 6G

If STA Country Code is US and if AP Country IE has a different
county code, STA should not allow connection to this AP as VLP
mode is not implemented yet in the US.
If STA Country Code is GB and if AP Country IE has a different
county code, STA will use VLP mode.

Change-Id: I7d247ae9fc83d7b578b01ec664247c807f7834fc
CRs-Fixed: 2933632
Gururaj Pandurangi 4 years ago
parent
commit
7fded8ebb8

+ 3 - 0
core/mac/inc/sir_api.h

@@ -1055,6 +1055,9 @@ struct join_req {
 #endif
 	struct supported_channels supportedChannels;
 	bool force_rsne_override;
+	bool same_ctry_code;  /* If AP Country IE has same country code as */
+	/* STA programmed country */
+	uint8_t ap_power_type_6g;  /* AP power type for 6G (LPI, SP, or VLP) */
 	/* Pls make this as last variable in struct */
 	struct bss_description bssDescription;
 	/*

+ 12 - 3
core/mac/src/pe/lim/lim_process_sme_req_messages.c

@@ -4347,6 +4347,11 @@ void lim_calculate_tpc(struct mac_context *mac,
 	struct vdev_mlme_obj *mlme_obj;
 	uint8_t tpe_power;
 
+	if (!session->lim_join_req) {
+		pe_err("Join Request is NULL");
+		return;
+	}
+
 	mlme_obj = wlan_vdev_mlme_get_cmpt_obj(session->vdev);
 	if (!mlme_obj) {
 		pe_err("vdev component object is NULL");
@@ -4371,6 +4376,13 @@ void lim_calculate_tpc(struct mac_context *mac,
 	} else {
 		is_6ghz_freq = true;
 		is_psd_power = wlan_reg_is_6g_psd_power(mac->pdev);
+		if (LIM_IS_STA_ROLE(session)) {
+			if (session->lim_join_req->same_ctry_code)
+				ap_power_type_6g = session->ap_power_type;
+			else
+				ap_power_type_6g =
+					session->lim_join_req->ap_power_type_6g;
+		}
 	}
 
 	if (mlme_obj->reg_tpc_obj.num_pwr_levels) {
@@ -4386,7 +4398,6 @@ void lim_calculate_tpc(struct mac_context *mac,
 	for (i = 0; i < num_pwr_levels; i++) {
 		if (is_tpe_present) {
 			if (is_6ghz_freq) {
-				ap_power_type_6g = session->ap_power_type;
 				wlan_reg_get_client_power_for_connecting_ap(
 				mac->pdev, ap_power_type_6g,
 				mlme_obj->reg_tpc_obj.frequency[i],
@@ -4407,8 +4418,6 @@ void lim_calculate_tpc(struct mac_context *mac,
 			}
 			if (is_6ghz_freq) {
 				if (LIM_IS_STA_ROLE(session)) {
-					ap_power_type_6g =
-							session->ap_power_type;
 					wlan_reg_get_client_power_for_connecting_ap
 					(mac->pdev, ap_power_type_6g,
 					 mlme_obj->reg_tpc_obj.frequency[i],

+ 24 - 4
core/sme/src/csr/csr_api_roam.c

@@ -13352,10 +13352,30 @@ QDF_STATUS csr_send_join_req_msg(struct mac_context *mac, uint32_t sessionId,
 				sme_debug("Channel is 6G but country IE not present");
 			wlan_reg_read_current_country(mac->psoc,
 						      programmed_country);
-			if (!qdf_mem_cmp(pIes->Country.country,
-					 programmed_country,
-					 REG_ALPHA2_LEN + 1))
-				sme_debug("Country IE does not match country stored in regulatory");
+			if (qdf_mem_cmp(pIes->Country.country,
+					programmed_country,
+					REG_ALPHA2_LEN)) {
+				sme_debug("Country IE:%c%c, STA country:%c%c",
+					  pIes->Country.country[0],
+					  pIes->Country.country[1],
+					  programmed_country[0],
+					  programmed_country[1]);
+				csr_join_req->same_ctry_code = false;
+				if (wlan_reg_is_us(programmed_country)) {
+					sme_err("US VLP not in place yet, connection not allowed");
+					status = QDF_STATUS_E_NOSUPPORT;
+					return status;
+				}
+				if (wlan_reg_is_etsi(programmed_country)) {
+					sme_debug("STA ctry:%c%c, doesn't match with AP ctry, switch to VLP",
+						  programmed_country[0],
+						  programmed_country[1]);
+					csr_join_req->ap_power_type_6g =
+							REG_VERY_LOW_POWER_AP;
+				}
+			} else {
+				csr_join_req->same_ctry_code = true;
+			}
 			status = csr_iterate_triplets(pIes->Country);
 		}