Kaynağa Gözat

qcacld-3.0: Recalculate TPC power during country change

Add support to invoke TPC power calculation API for
following cases.
1) If there is a country code change but the Host remains on
the same channel. There is a possibility of regulatory channel
power value to change causing overall TPC power change.
2) If set fcc constraint is set. In this case, the tx power of
channels 12 and 13 are updated and if the operating frequency
is one among the two, then TPC power needs to be determined
based on the new regulatory channel power.

Change-Id: I7db368678127ae95709698202c96b72167a57f0d
CRs-Fixed: 3292444
Gururaj Pandurangi 2 yıl önce
ebeveyn
işleme
03ac35eb11

+ 19 - 7
core/hdd/src/wlan_hdd_regulatory.c

@@ -1624,15 +1624,23 @@ static void hdd_country_change_update_sta(struct hdd_context *hdd_ctx)
 								    adapter,
 								    oper_freq);
 
-			if (hdd_is_vdev_in_conn_state(adapter) &&
-			    (phy_changed || freq_changed || width_changed)) {
-				hdd_debug("changed: phy %d, freq %d, width %d",
-					  phy_changed, freq_changed,
-					  width_changed);
-				wlan_hdd_cm_issue_disconnect(adapter,
+			if (hdd_is_vdev_in_conn_state(adapter)) {
+				if (phy_changed || freq_changed ||
+				    width_changed) {
+					hdd_debug("changed: phy %d, freq %d, width %d",
+						  phy_changed, freq_changed,
+						  width_changed);
+					wlan_hdd_cm_issue_disconnect(
+							adapter,
 							REASON_UNSPEC_FAILURE,
 							false);
-				sta_ctx->reg_phymode = csr_phy_mode;
+					sta_ctx->reg_phymode = csr_phy_mode;
+				} else {
+					hdd_debug("Remain on current channel but update tx power");
+					wlan_reg_update_tx_power_on_ctry_change(
+							pdev,
+							adapter->vdev_id);
+				}
 			}
 			break;
 		default:
@@ -1768,6 +1776,10 @@ static void hdd_country_change_update_sap(struct hdd_context *hdd_ctx)
 			else
 				policy_mgr_check_sap_restart(hdd_ctx->psoc,
 							     adapter->vdev_id);
+				hdd_debug("Update tx power due to ctry change");
+				wlan_reg_update_tx_power_on_ctry_change(
+							pdev,
+							adapter->vdev_id);
 			break;
 		default:
 			break;

+ 7 - 0
core/mac/src/pe/lim/lim_api.c

@@ -851,6 +851,10 @@ QDF_STATUS pe_open(struct mac_context *mac, struct cds_config_info *cds_cfg)
 	lim_nan_register_callbacks(mac);
 	p2p_register_callbacks(mac);
 	lim_register_sap_bcn_callback(mac);
+	wlan_reg_register_ctry_change_callback(
+					mac->psoc,
+					lim_update_tx_pwr_on_ctry_change_cb);
+
 	if (mac->mlme_cfg->edca_params.enable_edca_params)
 		lim_register_policy_mgr_callback(mac->psoc);
 
@@ -893,6 +897,9 @@ QDF_STATUS pe_close(struct mac_context *mac)
 	qdf_hang_event_unregister_notifier(&pe_hang_event_notifier);
 	lim_cleanup(mac);
 	lim_unregister_sap_bcn_callback(mac);
+	wlan_reg_unregister_ctry_change_callback(
+					mac->psoc,
+					lim_update_tx_pwr_on_ctry_change_cb);
 
 	if (mac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq) {
 		qdf_mem_free(mac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq);

+ 21 - 0
core/mac/src/pe/lim/lim_utils.c

@@ -10959,3 +10959,24 @@ lim_cleanup_power_change(struct mac_context *mac_ctx,
 
 	wlan_set_tpc_update_required_for_sta(sap_session->vdev, false);
 }
+
+void
+lim_update_tx_pwr_on_ctry_change_cb(uint8_t vdev_id)
+{
+	struct mac_context *mac_ctx;
+	struct pe_session *session;
+
+	mac_ctx = cds_get_context(QDF_MODULE_ID_PE);
+	if (!mac_ctx) {
+		pe_err("mac ctx is null");
+		return;
+	}
+
+	session = pe_find_session_by_vdev_id(mac_ctx, vdev_id);
+	if (!session) {
+		pe_err("Unable to find session");
+		return;
+	}
+
+	lim_set_tpc_power(mac_ctx, session);
+}

+ 12 - 0
core/mac/src/pe/lim/lim_utils.h

@@ -3160,4 +3160,16 @@ bool
 lim_is_power_change_required_for_sta(struct mac_context *mac_ctx,
 				     struct pe_session *sta_session,
 				     struct pe_session *sap_session);
+
+/**
+ * lim_update_tx_pwr_on_ctry_change_cb() - Callback to be invoked by regulatory
+ * module when country code changes (without channel change) OR if fcc
+ * constraint is set to true.
+ * This API calls TPC calculation API to recalculate and update the TX power.
+ * @vdev_id: vdev id
+ *
+ * Return: None
+ */
+void
+lim_update_tx_pwr_on_ctry_change_cb(uint8_t vdev_id);
 #endif /* __LIM_UTILS_H */