]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: iwlwifi: mvm: handle TPE advertised by AP
authorJohannes Berg <johannes.berg@intel.com>
Mon, 27 May 2024 16:06:01 +0000 (19:06 +0300)
committerJohannes Berg <johannes.berg@intel.com>
Wed, 29 May 2024 08:33:33 +0000 (10:33 +0200)
6 GHz BSS SP client shall respect TX power limits advertised
by the AP in TPE elements, send the data to the firmware using
the AP_TX_POWER_CONSTRAINTS_CMD command, so do that.

Co-developed-by: Mukesh Sisodiya <mukesh.sisodiya@intel.com>
Signed-off-by: Mukesh Sisodiya <mukesh.sisodiya@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://msgid.link/20240527190228.32f1e2e1447c.I58ac91c38585362aa42bb4a8a59c7d88e67bc40b@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
drivers/net/wireless/intel/iwlwifi/mvm/mld-mac80211.c
drivers/net/wireless/intel/iwlwifi/mvm/mvm.h

index 28540fd4a8da081a86d2a511af413e54a738789e..7b030995a6a497a32fa295e3b963f10acffa3503 100644 (file)
@@ -2731,6 +2731,13 @@ iwl_mvm_bss_info_changed_station_common(struct iwl_mvm *mvm,
 
        if (changes & BSS_CHANGED_BANDWIDTH)
                iwl_mvm_update_link_smps(vif, link_conf);
+
+       if (changes & BSS_CHANGED_TPE) {
+               IWL_DEBUG_CALIB(mvm, "Changing TPE\n");
+               iwl_mvm_send_ap_tx_power_constraint_cmd(mvm, vif,
+                                                       link_conf,
+                                                       false);
+       }
 }
 
 static void iwl_mvm_bss_info_changed_station(struct iwl_mvm *mvm,
@@ -5085,6 +5092,10 @@ static int __iwl_mvm_assign_vif_chanctx(struct iwl_mvm *mvm,
                }
 
                iwl_mvm_update_quotas(mvm, false, NULL);
+
+               iwl_mvm_send_ap_tx_power_constraint_cmd(mvm, vif,
+                                                       link_conf,
+                                                       false);
        }
 
        goto out;
index f69f7df40a6dd7a8dfa851a4da59864267a2df24..3a1504e95b0f796fba6275e6392e0e82892e7b41 100644 (file)
@@ -347,6 +347,11 @@ __iwl_mvm_mld_assign_vif_chanctx(struct iwl_mvm *mvm,
                rcu_read_unlock();
        }
 
+       if (vif->type == NL80211_IFTYPE_STATION)
+               iwl_mvm_send_ap_tx_power_constraint_cmd(mvm, vif,
+                                                       link_conf,
+                                                       false);
+
        /* then activate */
        ret = iwl_mvm_link_changed(mvm, vif, link_conf,
                                   LINK_CONTEXT_MODIFY_ACTIVE |
@@ -526,9 +531,37 @@ static void iwl_mvm_mld_unassign_vif_chanctx(struct ieee80211_hw *hw,
 }
 
 static void
+iwl_mvm_tpe_sta_cmd_data(struct iwl_txpower_constraints_cmd *cmd,
+                        const struct ieee80211_bss_conf *bss_info)
+{
+       u8 i;
+
+       /*
+        * NOTE: the 0 here is IEEE80211_TPE_CAT_6GHZ_DEFAULT,
+        * we fully ignore IEEE80211_TPE_CAT_6GHZ_SUBORDINATE
+        */
+
+       BUILD_BUG_ON(ARRAY_SIZE(cmd->psd_pwr) !=
+                    ARRAY_SIZE(bss_info->tpe.psd_local[0].power));
+
+       /* if not valid, mac80211 puts default (max value) */
+       for (i = 0; i < ARRAY_SIZE(cmd->psd_pwr); i++)
+               cmd->psd_pwr[i] = min(bss_info->tpe.psd_local[0].power[i],
+                                     bss_info->tpe.psd_reg_client[0].power[i]);
+
+       BUILD_BUG_ON(ARRAY_SIZE(cmd->eirp_pwr) !=
+                    ARRAY_SIZE(bss_info->tpe.max_local[0].power));
+
+       for (i = 0; i < ARRAY_SIZE(cmd->eirp_pwr); i++)
+               cmd->eirp_pwr[i] = min(bss_info->tpe.max_local[0].power[i],
+                                      bss_info->tpe.max_reg_client[0].power[i]);
+}
+
+void
 iwl_mvm_send_ap_tx_power_constraint_cmd(struct iwl_mvm *mvm,
                                        struct ieee80211_vif *vif,
-                                       struct ieee80211_bss_conf *bss_conf)
+                                       struct ieee80211_bss_conf *bss_conf,
+                                       bool is_ap)
 {
        struct iwl_txpower_constraints_cmd cmd = {};
        struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
@@ -548,19 +581,22 @@ iwl_mvm_send_ap_tx_power_constraint_cmd(struct iwl_mvm *mvm,
            link_info->fw_link_id == IWL_MVM_FW_LINK_ID_INVALID)
                return;
 
-       if (bss_conf->chanreq.oper.chan->band != NL80211_BAND_6GHZ ||
-           bss_conf->chanreq.oper.chan->flags &
-                   IEEE80211_CHAN_NO_6GHZ_VLP_CLIENT)
+       if (bss_conf->chanreq.oper.chan->band != NL80211_BAND_6GHZ)
                return;
 
        cmd.link_id = cpu_to_le16(link_info->fw_link_id);
-       /*
-        * Currently supporting VLP Soft AP only.
-        */
-       cmd.ap_type = cpu_to_le16(IWL_6GHZ_AP_TYPE_VLP);
        memset(cmd.psd_pwr, DEFAULT_TPE_TX_POWER, sizeof(cmd.psd_pwr));
        memset(cmd.eirp_pwr, DEFAULT_TPE_TX_POWER, sizeof(cmd.eirp_pwr));
 
+       if (is_ap) {
+               cmd.ap_type = cpu_to_le16(IWL_6GHZ_AP_TYPE_VLP);
+       } else if (bss_conf->power_type == IEEE80211_REG_UNSET_AP) {
+               return;
+       } else {
+               cmd.ap_type = cpu_to_le16(bss_conf->power_type - 1);
+               iwl_mvm_tpe_sta_cmd_data(&cmd, bss_conf);
+       }
+
        ret = iwl_mvm_send_cmd_pdu(mvm,
                                   WIDE_ID(PHY_OPS_GROUP,
                                           AP_TX_POWER_CONSTRAINTS_CMD),
@@ -582,7 +618,8 @@ static int iwl_mvm_mld_start_ap_ibss(struct ieee80211_hw *hw,
        guard(mvm)(mvm);
 
        if (vif->type == NL80211_IFTYPE_AP)
-               iwl_mvm_send_ap_tx_power_constraint_cmd(mvm, vif, link_conf);
+               iwl_mvm_send_ap_tx_power_constraint_cmd(mvm, vif,
+                                                       link_conf, true);
 
        /* Send the beacon template */
        ret = iwl_mvm_mac_ctxt_beacon_changed(mvm, vif, link_conf);
index 879fa1065bec5749ce42eb938a65f53b66cde9ec..82080d920d5905ffffc822d35cd1426c7e104e60 100644 (file)
@@ -2961,4 +2961,10 @@ iwl_mvm_bt_coex_calculate_esr_mode(struct iwl_mvm *mvm,
                                   bool primary);
 int iwl_mvm_esr_non_bss_link(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
                             unsigned int link_id, bool active);
+
+void
+iwl_mvm_send_ap_tx_power_constraint_cmd(struct iwl_mvm *mvm,
+                                       struct ieee80211_vif *vif,
+                                       struct ieee80211_bss_conf *bss_conf,
+                                       bool is_ap);
 #endif /* __IWL_MVM_H__ */