wifi: iwlwifi: Add support for LARI_CONFIG_CHANGE_CMD v10
authorAnjaneyulu <pagadala.yesu.anjaneyulu@intel.com>
Mon, 15 Apr 2024 08:54:42 +0000 (11:54 +0300)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 19 Apr 2024 08:15:44 +0000 (10:15 +0200)
Add support for enable/disable 320 MHz for Japan and South Korea
by reading WBEM (WiFi Bandwidth Enablement per MCC) variable from
UEFI or ACPI and sending it to the FW.

Signed-off-by: Anjaneyulu <pagadala.yesu.anjaneyulu@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://msgid.link/20240415114847.7946c3befbe1.I453c33f7ea48156ea2a3961f50a9003103fca5a5@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
drivers/net/wireless/intel/iwlwifi/fw/acpi.c
drivers/net/wireless/intel/iwlwifi/fw/acpi.h
drivers/net/wireless/intel/iwlwifi/fw/api/nvm-reg.h
drivers/net/wireless/intel/iwlwifi/fw/regulatory.c
drivers/net/wireless/intel/iwlwifi/fw/regulatory.h
drivers/net/wireless/intel/iwlwifi/fw/uefi.c
drivers/net/wireless/intel/iwlwifi/fw/uefi.h
drivers/net/wireless/intel/iwlwifi/mvm/fw.c

index 4caf2e25a29730da3757f1a720861620a81250b0..fa339791223b8fe5cd1616e598cd9416b7954d2a 100644 (file)
@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
 /*
  * Copyright (C) 2017 Intel Deutschland GmbH
- * Copyright (C) 2019-2023 Intel Corporation
+ * Copyright (C) 2019-2024 Intel Corporation
  */
 #include <linux/uuid.h>
 #include "iwl-drv.h"
@@ -960,3 +960,37 @@ out_free:
        kfree(data);
 }
 IWL_EXPORT_SYMBOL(iwl_acpi_get_guid_lock_status);
+
+int iwl_acpi_get_wbem(struct iwl_fw_runtime *fwrt, u32 *value)
+{
+       union acpi_object *wifi_pkg, *data;
+       int ret = -ENOENT;
+       int tbl_rev;
+
+       data = iwl_acpi_get_object(fwrt->dev, ACPI_WBEM_METHOD);
+       if (IS_ERR(data))
+               return ret;
+
+       wifi_pkg = iwl_acpi_get_wifi_pkg(fwrt->dev, data,
+                                        ACPI_WBEM_WIFI_DATA_SIZE,
+                                        &tbl_rev);
+       if (IS_ERR(wifi_pkg))
+               goto out_free;
+
+       if (tbl_rev != IWL_ACPI_WBEM_REVISION) {
+               IWL_DEBUG_RADIO(fwrt, "Unsupported ACPI WBEM revision:%d\n",
+                               tbl_rev);
+               goto out_free;
+       }
+
+       if (wifi_pkg->package.elements[1].type != ACPI_TYPE_INTEGER)
+               goto out_free;
+
+       *value = wifi_pkg->package.elements[1].integer.value &
+                IWL_ACPI_WBEM_REV0_MASK;
+       IWL_DEBUG_RADIO(fwrt, "Loaded WBEM config from ACPI\n");
+       ret = 0;
+out_free:
+       kfree(data);
+       return ret;
+}
index 1d32b82f73db3c2811db2504f3d54d66696e5bab..bb88398a69876435c227c911ab0882224911f978 100644 (file)
@@ -27,6 +27,7 @@
 #define ACPI_WTAS_METHOD       "WTAS"
 #define ACPI_WPFC_METHOD       "WPFC"
 #define ACPI_GLAI_METHOD       "GLAI"
+#define ACPI_WBEM_METHOD       "WBEM"
 
 #define ACPI_WIFI_DOMAIN       (0x07)
 
 #define ACPI_WRDD_WIFI_DATA_SIZE       2
 #define ACPI_SPLC_WIFI_DATA_SIZE       2
 #define ACPI_ECKV_WIFI_DATA_SIZE       2
+
+/*
+ * One element for domain type,
+ * and one for enablement of Wi-Fi 320MHz per MCC
+ */
+#define ACPI_WBEM_WIFI_DATA_SIZE       2
 /*
  * One element for domain type,
  * and one for the status
 
 #define ACPI_DSM_REV 0
 
+#define IWL_ACPI_WBEM_REV0_MASK (BIT(0) | BIT(1))
+#define IWL_ACPI_WBEM_REVISION 0
+
 #ifdef CONFIG_ACPI
 
 struct iwl_fw_runtime;
@@ -142,6 +152,7 @@ void iwl_acpi_get_guid_lock_status(struct iwl_fw_runtime *fwrt);
 int iwl_acpi_get_dsm(struct iwl_fw_runtime *fwrt,
                     enum iwl_dsm_funcs func, u32 *value);
 
+int iwl_acpi_get_wbem(struct iwl_fw_runtime *fwrt, u32 *value);
 #else /* CONFIG_ACPI */
 
 static inline void *iwl_acpi_get_dsm_object(struct device *dev, int rev,
@@ -205,6 +216,11 @@ static inline int iwl_acpi_get_dsm(struct iwl_fw_runtime *fwrt,
 {
        return -ENOENT;
 }
+
+static inline int iwl_acpi_get_wbem(struct iwl_fw_runtime *fwrt, u32 *value)
+{
+       return -ENOENT;
+}
 #endif /* CONFIG_ACPI */
 
 #endif /* __iwl_fw_acpi__ */
index 6f16d0d3d8e539a8da8e60213f272cddb62d1578..c9c0329f5778991c5b6b29b5db8eb6feefb864cf 100644 (file)
@@ -22,8 +22,9 @@ enum iwl_regulatory_and_nvm_subcmd_ids {
         *      &struct iwl_lari_config_change_cmd_v3,
         *      &struct iwl_lari_config_change_cmd_v4,
         *      &struct iwl_lari_config_change_cmd_v5,
-        *      &struct iwl_lari_config_change_cmd_v6 or
-        *      &struct iwl_lari_config_change_cmd_v7
+        *      &struct iwl_lari_config_change_cmd_v6,
+        *      &struct iwl_lari_config_change_cmd_v7 or
+        *      &struct iwl_lari_config_change_cmd
         */
        LARI_CONFIG_CHANGE = 0x1,
 
@@ -646,6 +647,45 @@ struct iwl_lari_config_change_cmd_v7 {
 /* LARI_CHANGE_CONF_CMD_S_VER_8 */
 /* LARI_CHANGE_CONF_CMD_S_VER_9 */
 
+/**
+ * struct iwl_lari_config_change_cmd - change LARI configuration
+ * @config_bitmap: Bitmap of the config commands. Each bit will trigger a
+ *     different predefined FW config operation.
+ * @oem_uhb_allow_bitmap: Bitmap of UHB enabled MCC sets.
+ * @oem_11ax_allow_bitmap: Bitmap of 11ax allowed MCCs. There are two bits
+ *     per country, one to indicate whether to override and the other to
+ *     indicate the value to use.
+ * @oem_unii4_allow_bitmap: Bitmap of unii4 allowed MCCs.There are two bits
+ *     per country, one to indicate whether to override and the other to
+ *     indicate allow/disallow unii4 channels.
+ *     For LARI cmd version 10 - bits 0:5 are supported.
+ * @chan_state_active_bitmap: Bitmap to enable different bands per country
+ *     or region.
+ *     Each bit represents a country or region, and a band to activate
+ *     according to the BIOS definitions.
+ *     For LARI cmd version 10 - bits 0:4 are supported.
+ * @force_disable_channels_bitmap: Bitmap of disabled bands/channels.
+ *     Each bit represents a set of channels in a specific band that should be
+ *     disabled
+ * @edt_bitmap: Bitmap of energy detection threshold table.
+ *     Disable/enable the EDT optimization method for different band.
+ * @oem_320mhz_allow_bitmap: 320Mhz bandwidth enablement bitmap per MCC.
+ *     bit0: enable 320Mhz in Japan.
+ *     bit1: enable 320Mhz in South Korea.
+ *     bit 2 - 31: reserved.
+ */
+struct iwl_lari_config_change_cmd {
+       __le32 config_bitmap;
+       __le32 oem_uhb_allow_bitmap;
+       __le32 oem_11ax_allow_bitmap;
+       __le32 oem_unii4_allow_bitmap;
+       __le32 chan_state_active_bitmap;
+       __le32 force_disable_channels_bitmap;
+       __le32 edt_bitmap;
+       __le32 oem_320mhz_allow_bitmap;
+} __packed;
+/* LARI_CHANGE_CONF_CMD_S_VER_10 */
+
 /* Activate UNII-1 (5.2GHz) for World Wide */
 #define ACTIVATE_5G2_IN_WW_MASK        BIT(4)
 
index 6d4b9334702ea37f984db7905fc1e95e91cdd694..b9bb3636e88f0342e534173a9be0983849b97326 100644 (file)
@@ -38,6 +38,7 @@ IWL_BIOS_TABLE_LOADER_DATA(tas_table, struct iwl_tas_data);
 IWL_BIOS_TABLE_LOADER_DATA(pwr_limit, u64);
 IWL_BIOS_TABLE_LOADER_DATA(mcc, char);
 IWL_BIOS_TABLE_LOADER_DATA(eckv, u32);
+IWL_BIOS_TABLE_LOADER_DATA(wbem, u32);
 
 
 static const struct dmi_system_id dmi_ppag_approved_list[] = {
@@ -496,6 +497,9 @@ static size_t iwl_get_lari_config_cmd_size(u8 cmd_ver)
        size_t cmd_size;
 
        switch (cmd_ver) {
+       case 10:
+               cmd_size = sizeof(struct iwl_lari_config_change_cmd);
+               break;
        case 9:
        case 8:
        case 7:
@@ -524,7 +528,7 @@ static size_t iwl_get_lari_config_cmd_size(u8 cmd_ver)
 }
 
 int iwl_fill_lari_config(struct iwl_fw_runtime *fwrt,
-                        struct iwl_lari_config_change_cmd_v7 *cmd,
+                        struct iwl_lari_config_change_cmd *cmd,
                         size_t *cmd_size)
 {
        int ret;
@@ -572,13 +576,18 @@ int iwl_fill_lari_config(struct iwl_fw_runtime *fwrt,
        if (!ret)
                cmd->edt_bitmap = cpu_to_le32(value);
 
+       ret = iwl_bios_get_wbem(fwrt, &value);
+       if (!ret)
+               cmd->oem_320mhz_allow_bitmap = cpu_to_le32(value);
+
        if (cmd->config_bitmap ||
            cmd->oem_uhb_allow_bitmap ||
            cmd->oem_11ax_allow_bitmap ||
            cmd->oem_unii4_allow_bitmap ||
            cmd->chan_state_active_bitmap ||
            cmd->force_disable_channels_bitmap ||
-           cmd->edt_bitmap) {
+           cmd->edt_bitmap ||
+           cmd->oem_320mhz_allow_bitmap) {
                IWL_DEBUG_RADIO(fwrt,
                                "sending LARI_CONFIG_CHANGE, config_bitmap=0x%x, oem_11ax_allow_bitmap=0x%x\n",
                                le32_to_cpu(cmd->config_bitmap),
@@ -593,8 +602,9 @@ int iwl_fill_lari_config(struct iwl_fw_runtime *fwrt,
                                le32_to_cpu(cmd->oem_uhb_allow_bitmap),
                                le32_to_cpu(cmd->force_disable_channels_bitmap));
                IWL_DEBUG_RADIO(fwrt,
-                               "sending LARI_CONFIG_CHANGE, edt_bitmap=0x%x\n",
-                               le32_to_cpu(cmd->edt_bitmap));
+                               "sending LARI_CONFIG_CHANGE, edt_bitmap=0x%x, oem_320mhz_allow_bitmap=0x%x\n",
+                               le32_to_cpu(cmd->edt_bitmap),
+                               le32_to_cpu(cmd->oem_320mhz_allow_bitmap));
        } else {
                return 1;
        }
index eea04d2934ab9c7222eecbe508f1abd4fe717a67..633c9ad9af841e39fb7ceb096b28a1fd500fb608 100644 (file)
@@ -201,9 +201,10 @@ int iwl_bios_get_pwr_limit(struct iwl_fw_runtime *fwrt,
 
 int iwl_bios_get_mcc(struct iwl_fw_runtime *fwrt, char *mcc);
 int iwl_bios_get_eckv(struct iwl_fw_runtime *fwrt, u32 *ext_clk);
+int iwl_bios_get_wbem(struct iwl_fw_runtime *fwrt, u32 *value);
 
 int iwl_fill_lari_config(struct iwl_fw_runtime *fwrt,
-                        struct iwl_lari_config_change_cmd_v7 *cmd,
+                        struct iwl_lari_config_change_cmd *cmd,
                         size_t *cmd_size);
 
 int iwl_bios_get_dsm(struct iwl_fw_runtime *fwrt, enum iwl_dsm_funcs func,
index e81fc0129b9d7cfe660bf559769177fd1136c892..fb982d4fe85100973be4ac1a87b0c7f7184599f3 100644 (file)
@@ -674,6 +674,29 @@ out:
        return ret;
 }
 
+int iwl_uefi_get_wbem(struct iwl_fw_runtime *fwrt, u32 *value)
+{
+       struct uefi_cnv_wlan_wbem_data *data;
+       int ret = 0;
+
+       data = iwl_uefi_get_verified_variable(fwrt->trans, IWL_UEFI_WBEM_NAME,
+                                             "WBEM", sizeof(*data), NULL);
+       if (IS_ERR(data))
+               return -EINVAL;
+
+       if (data->revision != IWL_UEFI_WBEM_REVISION) {
+               ret = -EINVAL;
+               IWL_DEBUG_RADIO(fwrt, "Unsupported UEFI WBEM revision:%d\n",
+                               data->revision);
+               goto out;
+       }
+       *value = data->wbem_320mhz_per_mcc & IWL_UEFI_WBEM_REV0_MASK;
+       IWL_DEBUG_RADIO(fwrt, "Loaded WBEM config from UEFI\n");
+out:
+       kfree(data);
+       return ret;
+}
+
 int iwl_uefi_get_dsm(struct iwl_fw_runtime *fwrt, enum iwl_dsm_funcs func,
                     u32 *value)
 {
index 303cc299d1bcb0450cac52c365a6480e98f245bd..1f8884ca8997c4476bb9b3276e671163058b2b2f 100644 (file)
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
 /*
- * Copyright(c) 2021-2023 Intel Corporation
+ * Copyright(c) 2021-2024 Intel Corporation
  */
 #ifndef __iwl_fw_uefi__
 #define __iwl_fw_uefi__
@@ -21,6 +21,7 @@
 #define IWL_UEFI_WRDD_NAME             L"UefiCnvWlanWRDD"
 #define IWL_UEFI_ECKV_NAME             L"UefiCnvWlanECKV"
 #define IWL_UEFI_DSM_NAME              L"UefiCnvWlanGeneralCfg"
+#define IWL_UEFI_WBEM_NAME             L"UefiCnvWlanWBEM"
 
 
 #define IWL_SGOM_MAP_SIZE              339
@@ -35,6 +36,7 @@
 #define IWL_UEFI_SPLC_REVISION         0
 #define IWL_UEFI_WRDD_REVISION         0
 #define IWL_UEFI_ECKV_REVISION         0
+#define IWL_UEFI_WBEM_REVISION         0
 #define IWL_UEFI_DSM_REVISION          4
 
 struct pnvm_sku_package {
@@ -178,6 +180,20 @@ struct uefi_cnv_var_general_cfg {
        u32 functions[UEFI_MAX_DSM_FUNCS];
 } __packed;
 
+#define IWL_UEFI_WBEM_REV0_MASK (BIT(0) | BIT(1))
+/* struct uefi_cnv_wlan_wbem_data - Bandwidth enablement per MCC as defined
+ *     in UEFI
+ * @revision: the revision of the table
+ * @wbem_320mhz_per_mcc: enablement of 320MHz bandwidth per MCC
+ *     bit 0 - if set, 320MHz is enabled for Japan
+ *     bit 1 - if set, 320MHz is enabled for South Korea
+ *     bit 2- 31, Reserved
+ */
+struct uefi_cnv_wlan_wbem_data {
+       u8 revision;
+       u32 wbem_320mhz_per_mcc;
+} __packed;
+
 /*
  * This is known to be broken on v4.19 and to work on v5.4.  Until we
  * figure out why this is the case and how to make it work, simply
@@ -202,6 +218,7 @@ int iwl_uefi_get_pwr_limit(struct iwl_fw_runtime *fwrt,
                           u64 *dflt_pwr_limit);
 int iwl_uefi_get_mcc(struct iwl_fw_runtime *fwrt, char *mcc);
 int iwl_uefi_get_eckv(struct iwl_fw_runtime *fwrt, u32 *extl_clk);
+int iwl_uefi_get_wbem(struct iwl_fw_runtime *fwrt, u32 *value);
 int iwl_uefi_get_dsm(struct iwl_fw_runtime *fwrt, enum iwl_dsm_funcs func,
                     u32 *value);
 void iwl_uefi_get_sgom_table(struct iwl_trans *trans, struct iwl_fw_runtime *fwrt);
@@ -281,6 +298,11 @@ static inline int iwl_uefi_get_eckv(struct iwl_fw_runtime *fwrt, u32 *extl_clk)
        return -ENOENT;
 }
 
+static inline int iwl_uefi_get_wbem(struct iwl_fw_runtime *fwrt, u32 *value)
+{
+       return -ENOENT;
+}
+
 static inline int iwl_uefi_get_dsm(struct iwl_fw_runtime *fwrt,
                                   enum iwl_dsm_funcs func, u32 *value)
 {
index 243eeccc7ef67fe9d2a238d472ce048a27defd72..74b299139391f856c053ecbb618bc1eb041eca5e 100644 (file)
@@ -1225,9 +1225,9 @@ static bool iwl_mvm_eval_dsm_rfi(struct iwl_mvm *mvm)
 
 static void iwl_mvm_lari_cfg(struct iwl_mvm *mvm)
 {
-       int ret;
+       struct iwl_lari_config_change_cmd cmd;
        size_t cmd_size;
-       struct iwl_lari_config_change_cmd_v7 cmd;
+       int ret;
 
        ret = iwl_fill_lari_config(&mvm->fwrt, &cmd, &cmd_size);
        if (!ret) {