diff --git a/core/mac/src/pe/lim/lim_process_mlm_rsp_messages.c b/core/mac/src/pe/lim/lim_process_mlm_rsp_messages.c index 2da52592cd75..526ed64ee95a 100644 --- a/core/mac/src/pe/lim/lim_process_mlm_rsp_messages.c +++ b/core/mac/src/pe/lim/lim_process_mlm_rsp_messages.c @@ -2320,7 +2320,8 @@ void lim_handle_add_bss_rsp(struct mac_context *mac_ctx, } tx_ops = wlan_reg_get_tx_ops(mac_ctx->psoc); - lim_calculate_tpc(mac_ctx, session_entry, false); + lim_calculate_tpc(mac_ctx, session_entry, false, 0, + false); if (tx_ops->set_tpc_power) tx_ops->set_tpc_power(mac_ctx->psoc, @@ -2805,7 +2806,7 @@ static void lim_process_switch_channel_join_req( goto error; } - lim_calculate_tpc(mac_ctx, session_entry, false); + lim_calculate_tpc(mac_ctx, session_entry, false, 0, false); if (tx_ops->set_tpc_power) tx_ops->set_tpc_power(mac_ctx->psoc, diff --git a/core/mac/src/pe/lim/lim_process_sme_req_messages.c b/core/mac/src/pe/lim/lim_process_sme_req_messages.c index 203172c67fee..4abe07b5f966 100644 --- a/core/mac/src/pe/lim/lim_process_sme_req_messages.c +++ b/core/mac/src/pe/lim/lim_process_sme_req_messages.c @@ -1957,7 +1957,9 @@ uint8_t lim_get_max_tx_power(struct mac_context *mac, void lim_calculate_tpc(struct mac_context *mac, struct pe_session *session, - bool is_pwr_constraint_absolute) + bool is_pwr_constraint_absolute, + uint8_t ap_pwr_type, + bool ctry_code_match) { bool is_psd_power = false; bool is_tpe_present = false, is_6ghz_freq = false; @@ -1972,11 +1974,6 @@ void lim_calculate_tpc(struct mac_context *mac, uint8_t tpe_power; bool skip_tpe = false; - if (LIM_IS_STA_ROLE(session) && !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"); @@ -2002,12 +1999,17 @@ void lim_calculate_tpc(struct mac_context *mac, } else { is_6ghz_freq = true; is_psd_power = wlan_reg_is_6g_psd_power(mac->pdev); + /* Power mode calculation for 6G*/ + ap_power_type_6g = session->ap_power_type; 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 = + if (!session->lim_join_req) { + if (!ctry_code_match) + ap_power_type_6g = ap_pwr_type; + } else { + if (!session->lim_join_req->same_ctry_code) + ap_power_type_6g = session->lim_join_req->ap_power_type_6g; + } } } diff --git a/core/mac/src/pe/lim/lim_utils.h b/core/mac/src/pe/lim/lim_utils.h index 3881283f355a..9cabe1372570 100644 --- a/core/mac/src/pe/lim/lim_utils.h +++ b/core/mac/src/pe/lim/lim_utils.h @@ -183,6 +183,8 @@ uint8_t lim_get_max_tx_power(struct mac_context *mac, * @session: PE Session Entry * @is_pwr_constraint_absolute: If local power constraint is an absolute * value or an offset value. + * @ap_pwr_type: Ap power type for 6G + * @ctry_code_match: check for country IE and sta programmed ctry match * * This function is used to get the maximum possible tx power from the list * of tx powers mentioned in @attr. @@ -191,7 +193,9 @@ uint8_t lim_get_max_tx_power(struct mac_context *mac, */ void lim_calculate_tpc(struct mac_context *mac, struct pe_session *session, - bool is_pwr_constraint_absolute); + bool is_pwr_constraint_absolute, + uint8_t ap_pwr_type, + bool ctry_code_match); /* AID pool management functions */ void lim_init_peer_idxpool(struct mac_context *, struct pe_session *); diff --git a/core/mac/src/pe/rrm/rrm_api.c b/core/mac/src/pe/rrm/rrm_api.c index 2a0426bbc7f7..f9e9670fe4e2 100644 --- a/core/mac/src/pe/rrm/rrm_api.c +++ b/core/mac/src/pe/rrm/rrm_api.c @@ -270,7 +270,7 @@ rrm_process_link_measurement_request(struct mac_context *mac, ap_pwr_constraint = mlme_obj->reg_tpc_obj.ap_constraint_power; mlme_obj->reg_tpc_obj.ap_constraint_power = pLinkReq->MaxTxPower.maxTxPower; - lim_calculate_tpc(mac, pe_session, true); + lim_calculate_tpc(mac, pe_session, true, 0, false); LinkReport.txPower = mlme_obj->reg_tpc_obj.chan_power_info[0].tx_power; diff --git a/core/mac/src/pe/sch/sch_beacon_process.c b/core/mac/src/pe/sch/sch_beacon_process.c index eedc03c27be8..2e4481e2f9a3 100644 --- a/core/mac/src/pe/sch/sch_beacon_process.c +++ b/core/mac/src/pe/sch/sch_beacon_process.c @@ -713,6 +713,9 @@ static void __sch_beacon_process_for_session(struct mac_context *mac_ctx, int8_t regMax = 0, maxTxPower = 0; QDF_STATUS status; bool skip_tpe = false; + uint8_t programmed_country[REG_ALPHA2_LEN + 1]; + enum reg_6g_ap_type pwr_type_6g = REG_INDOOR_AP; + bool ctry_code_match = false; qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams)); beaconParams.paramChangeBitmap = 0; @@ -744,8 +747,22 @@ static void __sch_beacon_process_for_session(struct mac_context *mac_ctx, return; } - if (!wlan_reg_is_6ghz_chan_freq(bcn->chan_freq)) + if (!wlan_reg_is_6ghz_chan_freq(bcn->chan_freq)) { skip_tpe = wlan_mlme_skip_tpe(mac_ctx->psoc); + } else { + if (!bcn->countryInfoParam.countryString[0]) { + pe_err("Channel is 6G but country IE not present"); + return; + } + wlan_reg_read_current_country(mac_ctx->psoc, + programmed_country); + status = wlan_reg_get_6g_power_type_for_ctry( + bcn->countryInfoParam.countryString, + programmed_country, &pwr_type_6g, + &ctry_code_match); + if (QDF_IS_STATUS_ERROR(status)) + return; + } if (wlan_reg_is_ext_tpc_supported(mac_ctx->psoc)) { tx_ops = wlan_reg_get_tx_ops(mac_ctx->psoc); @@ -773,7 +790,8 @@ static void __sch_beacon_process_for_session(struct mac_context *mac_ctx, if ((ap_constraint_change && local_constraint) || (tpe_change && !skip_tpe)) { - lim_calculate_tpc(mac_ctx, session, false); + lim_calculate_tpc(mac_ctx, session, false, pwr_type_6g, + ctry_code_match); if (tx_ops->set_tpc_power) tx_ops->set_tpc_power(mac_ctx->psoc, diff --git a/core/sme/src/csr/csr_api_roam.c b/core/sme/src/csr/csr_api_roam.c index 658e1a977afc..a8ab83053570 100644 --- a/core/sme/src/csr/csr_api_roam.c +++ b/core/sme/src/csr/csr_api_roam.c @@ -14792,6 +14792,8 @@ QDF_STATUS csr_send_join_req_msg(struct mac_context *mac, uint32_t sessionId, bool follow_ap_edca; bool reconn_after_assoc_timeout = false; uint8_t programmed_country[REG_ALPHA2_LEN + 1]; + enum reg_6g_ap_type power_type_6g; + bool ctry_code_match; if (!pSession) { sme_err("session %d not found", sessionId); @@ -15558,30 +15560,15 @@ 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)) { - 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; - break; - } - 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 = wlan_reg_get_6g_power_type_for_ctry( + pIes->Country.country, + programmed_country, &power_type_6g, + &ctry_code_match); + if (QDF_IS_STATUS_ERROR(status)) + break; + csr_join_req->ap_power_type_6g = power_type_6g; + csr_join_req->same_ctry_code = ctry_code_match; + status = csr_iterate_triplets(pIes->Country); }