wifi: iwlwifi: mvm: send ap_tx_power_constraints cmd to FW in AP mode
authorMukesh Sisodiya <mukesh.sisodiya@intel.com>
Tue, 16 Apr 2024 10:53:57 +0000 (13:53 +0300)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 19 Apr 2024 08:16:32 +0000 (10:16 +0200)
Send AP_TX_POWER_CONSTRAINTS_CMD with no local maximum transmit
power constraint to FW and FW will update the TPE element with
required tx power limits.

Signed-off-by: Mukesh Sisodiya <mukesh.sisodiya@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://msgid.link/20240416134215.b6af4ecfcfe8.I07e8db349190e0c58c468c18477d8551288ac069@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
drivers/net/wireless/intel/iwlwifi/fw/api/phy.h
drivers/net/wireless/intel/iwlwifi/fw/api/power.h
drivers/net/wireless/intel/iwlwifi/mvm/mld-mac80211.c
drivers/net/wireless/intel/iwlwifi/mvm/ops.c

index 5a3f30e5e06d76899aac5a8c634f95257d5daa87..92e4b62c119f942c6e6ff70fc1c10ce2575e22c8 100644 (file)
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
 /*
- * Copyright (C) 2012-2014, 2019-2022 Intel Corporation
+ * Copyright (C) 2012-2014, 2019-2022, 2024 Intel Corporation
  * Copyright (C) 2013-2015 Intel Mobile Communications GmbH
  * Copyright (C) 2016-2017 Intel Deutschland GmbH
  */
@@ -42,6 +42,11 @@ enum iwl_phy_ops_subcmd_ids {
         */
        PER_PLATFORM_ANT_GAIN_CMD = 0x07,
 
+       /**
+        * @AP_TX_POWER_CONSTRAINTS_CMD: &struct iwl_txpower_constraints_cmd
+        */
+       AP_TX_POWER_CONSTRAINTS_CMD = 0x0C,
+
        /**
         * @CT_KILL_NOTIFICATION: &struct ct_kill_notif
         */
index 8f84d4733b63f6e22e987bb8ee49533d9b762e61..532d5cfa916295c40acbc853ab94b321eb81582c 100644 (file)
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
 /*
- * Copyright (C) 2012-2014, 2018-2023 Intel Corporation
+ * Copyright (C) 2012-2014, 2018-2024 Intel Corporation
  * Copyright (C) 2013-2014 Intel Mobile Communications GmbH
  * Copyright (C) 2015-2017 Intel Deutschland GmbH
  */
@@ -732,4 +732,44 @@ struct iwl_beacon_filter_cmd {
 
 #define IWL_BF_CMD_CONFIG_DEFAULTS IWL_BF_CMD_CONFIG(_DEFAULT)
 #define IWL_BF_CMD_CONFIG_D0I3 IWL_BF_CMD_CONFIG(_D0I3)
+
+#define DEFAULT_TPE_TX_POWER 0x7F
+
+/*
+ *  Bandwidth: 20/40/80/(160/80+80)/320
+ */
+#define IWL_MAX_TX_EIRP_PWR_MAX_SIZE 5
+#define IWL_MAX_TX_EIRP_PSD_PWR_MAX_SIZE 16
+
+enum iwl_6ghz_ap_type {
+       IWL_6GHZ_AP_TYPE_LPI,
+       IWL_6GHZ_AP_TYPE_SP,
+       IWL_6GHZ_AP_TYPE_VLP,
+}; /* PHY_AP_TYPE_API_E_VER_1 */
+
+/**
+ * struct iwl_txpower_constraints_cmd
+ * AP_TX_POWER_CONSTRAINTS_CMD
+ * Used for VLP/LPI/AFC Access Point power constraints for 6GHz channels
+ * @link_id: linkId
+ * @ap_type: see &enum iwl_ap_type
+ * @eirp_pwr: 8-bit 2s complement signed integer in the range
+ *     -64 dBm to 63 dBm with a 0.5 dB step
+ *     default &DEFAULT_TPE_TX_POWER (no maximum limit)
+ * @psd_pwr: 8-bit 2s complement signed integer in the range
+ *     -63.5 to +63 dBm/MHz with a 0.5 step
+ *     value - 128 indicates that the corresponding 20
+ *     MHz channel cannot be used for transmission.
+ *     value +127 indicates that no maximum PSD limit
+ *     is specified for the corresponding 20 MHz channel
+ *     default &DEFAULT_TPE_TX_POWER (no maximum limit)
+ * @reserved: reserved (padding)
+ */
+struct iwl_txpower_constraints_cmd {
+       __le16 link_id;
+       __le16 ap_type;
+       __s8 eirp_pwr[IWL_MAX_TX_EIRP_PWR_MAX_SIZE];
+       __s8 psd_pwr[IWL_MAX_TX_EIRP_PSD_PWR_MAX_SIZE];
+       u8 reserved[3];
+} __packed; /* PHY_AP_TX_POWER_CONSTRAINTS_CMD_API_S_VER_1 */
 #endif /* __iwl_fw_api_power_h__ */
index 7a2a18f8b86e2f03b87f164da5a186cd420c8314..bcf2fd23300ffe23d15ed7bb7773a1bc58b70397 100644 (file)
@@ -468,6 +468,52 @@ static void iwl_mvm_mld_unassign_vif_chanctx(struct ieee80211_hw *hw,
        mutex_unlock(&mvm->mutex);
 }
 
+static void
+iwl_mvm_send_ap_tx_power_constraint_cmd(struct iwl_mvm *mvm,
+                                       struct ieee80211_vif *vif,
+                                       struct ieee80211_bss_conf *bss_conf)
+{
+       struct iwl_txpower_constraints_cmd cmd = {};
+       struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
+       struct iwl_mvm_vif_link_info *link_info =
+                       mvmvif->link[bss_conf->link_id];
+       u32 cmd_id = WIDE_ID(PHY_OPS_GROUP, AP_TX_POWER_CONSTRAINTS_CMD);
+       u32 cmd_ver = iwl_fw_lookup_cmd_ver(mvm->fw, cmd_id,
+                                           IWL_FW_CMD_VER_UNKNOWN);
+       int ret;
+
+       lockdep_assert_held(&mvm->mutex);
+
+       if (cmd_ver == IWL_FW_CMD_VER_UNKNOWN)
+               return;
+
+       if (!link_info->active ||
+           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)
+               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));
+
+       ret = iwl_mvm_send_cmd_pdu(mvm,
+                                  WIDE_ID(PHY_OPS_GROUP,
+                                          AP_TX_POWER_CONSTRAINTS_CMD),
+                                  0, sizeof(cmd), &cmd);
+       if (ret)
+               IWL_ERR(mvm,
+                       "failed to send AP_TX_POWER_CONSTRAINTS_CMD (%d)\n",
+                       ret);
+}
+
 static int iwl_mvm_mld_start_ap_ibss(struct ieee80211_hw *hw,
                                     struct ieee80211_vif *vif,
                                     struct ieee80211_bss_conf *link_conf)
@@ -477,6 +523,10 @@ static int iwl_mvm_mld_start_ap_ibss(struct ieee80211_hw *hw,
        int ret;
 
        mutex_lock(&mvm->mutex);
+
+       if (vif->type == NL80211_IFTYPE_AP)
+               iwl_mvm_send_ap_tx_power_constraint_cmd(mvm, vif, link_conf);
+
        /* Send the beacon template */
        ret = iwl_mvm_mac_ctxt_beacon_changed(mvm, vif, link_conf);
        if (ret)
index a93981cb9714ff989e990306ad2be5a0394d2479..5cdad4dfa6994f1e72a28a820399abf4d0d67a7c 100644 (file)
@@ -586,6 +586,7 @@ static const struct iwl_hcmd_names iwl_mvm_phy_names[] = {
        HCMD_NAME(CTDP_CONFIG_CMD),
        HCMD_NAME(TEMP_REPORTING_THRESHOLDS_CMD),
        HCMD_NAME(PER_CHAIN_LIMIT_OFFSET_CMD),
+       HCMD_NAME(AP_TX_POWER_CONSTRAINTS_CMD),
        HCMD_NAME(CT_KILL_NOTIFICATION),
        HCMD_NAME(DTS_MEASUREMENT_NOTIF_WIDE),
 };