wifi: iwlwifi: mvm: add UHB canada support in TAS_CONFIG cmd
authorAnjaneyulu <pagadala.yesu.anjaneyulu@intel.com>
Thu, 26 Dec 2024 15:44:55 +0000 (17:44 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Mon, 13 Jan 2025 13:00:55 +0000 (14:00 +0100)
extend TAS table support to revision 2 for getting UHB canada
enablement from BIOS and send to firmware via TAS_CONFIG cmd
based on firmware capability. While on it fixed kernel-doc for
struct iwl_tas_config_cmd_v4.

Signed-off-by: Anjaneyulu <pagadala.yesu.anjaneyulu@intel.com>
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://patch.msgid.link/20241226174257.0b1d92ad59b8.Ib80f8514a64fc2800a2a20131e730c2bd9c4c4af@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
drivers/net/wireless/intel/iwlwifi/fw/acpi.c
drivers/net/wireless/intel/iwlwifi/fw/api/nvm-reg.h
drivers/net/wireless/intel/iwlwifi/fw/file.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 0bc3229..7d6e6c8 100644 (file)
@@ -274,13 +274,13 @@ int iwl_acpi_get_tas_table(struct iwl_fw_runtime *fwrt,
                goto out_free;
        }
 
-       if (tbl_rev == 1 && wifi_pkg->package.elements[1].type ==
-               ACPI_TYPE_INTEGER) {
+       if ((tbl_rev == 2 || tbl_rev == 1) &&
+           wifi_pkg->package.elements[1].type == ACPI_TYPE_INTEGER) {
                u32 tas_selection =
                        (u32)wifi_pkg->package.elements[1].integer.value;
 
                enabled = iwl_parse_tas_selection(fwrt, tas_data,
-                                                 tas_selection);
+                                                 tas_selection, tbl_rev);
 
        } else if (tbl_rev == 0 &&
                wifi_pkg->package.elements[1].type == ACPI_TYPE_INTEGER) {
index d424d01..1bf5497 100644 (file)
@@ -463,19 +463,28 @@ struct iwl_tas_config_cmd_v3 {
        __le16 enable_tas_iec;
 } __packed; /* TAS_CONFIG_CMD_API_S_VER_3 */
 
+/**
+ * enum iwl_tas_uhb_allowed_flags - per country TAS UHB allowed flags.
+ * @TAS_UHB_ALLOWED_CANADA: TAS UHB is allowed in Canada. This flag is valid
+ *     only when fw has %IWL_UCODE_TLV_CAPA_UHB_CANADA_TAS_SUPPORT capability.
+ */
+enum iwl_tas_uhb_allowed_flags {
+       TAS_UHB_ALLOWED_CANADA  = BIT(0),
+};
+
 /**
  * struct iwl_tas_config_cmd_v4 - configures the TAS
  * @override_tas_iec: indicates whether to override default value of IEC regulatory
  * @enable_tas_iec: in case override_tas_iec is set -
  *     indicates whether IEC regulatory is enabled or disabled
  * @usa_tas_uhb_allowed: if set, allow TAS UHB in the USA
- * @reserved: reserved
-*/
+ * @uhb_allowed_flags: see &enum iwl_tas_uhb_allowed_flags.
+ */
 struct iwl_tas_config_cmd_v4 {
        u8 override_tas_iec;
        u8 enable_tas_iec;
        u8 usa_tas_uhb_allowed;
-       u8 reserved;
+       u8 uhb_allowed_flags;
 } __packed; /* TAS_CONFIG_CMD_API_S_VER_4 */
 
 struct iwl_tas_config_cmd {
index f5fbe76..dce6186 100644 (file)
@@ -400,6 +400,7 @@ typedef unsigned int __bitwise iwl_ucode_tlv_capa_t;
  *     passive channels
  * @IWL_UCODE_TLV_CAPA_BIOS_OVERRIDE_5G9_FOR_CA: supports (de)activating 5G9
  *     for CA from BIOS.
+ * @IWL_UCODE_TLV_CAPA_UHB_CANADA_TAS_SUPPORT: supports %TAS_UHB_ALLOWED_CANADA
  *
  * @NUM_IWL_UCODE_TLV_CAPA: number of bits used
  */
@@ -501,6 +502,7 @@ enum iwl_ucode_tlv_capa {
        IWL_UCODE_TLV_CAPA_SECURE_LTF_SUPPORT           = (__force iwl_ucode_tlv_capa_t)121,
        IWL_UCODE_TLV_CAPA_MONITOR_PASSIVE_CHANS        = (__force iwl_ucode_tlv_capa_t)122,
        IWL_UCODE_TLV_CAPA_BIOS_OVERRIDE_5G9_FOR_CA     = (__force iwl_ucode_tlv_capa_t)123,
+       IWL_UCODE_TLV_CAPA_UHB_CANADA_TAS_SUPPORT       = (__force iwl_ucode_tlv_capa_t)124,
        NUM_IWL_UCODE_TLV_CAPA
 /*
  * This construction make both sparse (which cannot increment the previous
index 4b5eeff..c89ff38 100644 (file)
@@ -426,10 +426,12 @@ IWL_EXPORT_SYMBOL(iwl_is_tas_approved);
 
 int iwl_parse_tas_selection(struct iwl_fw_runtime *fwrt,
                            struct iwl_tas_data *tas_data,
-                           const u32 tas_selection)
+                           const u32 tas_selection, u8 tbl_rev)
 {
        u8 override_iec = u32_get_bits(tas_selection,
                                       IWL_WTAS_OVERRIDE_IEC_MSK);
+       u8 canada_tas_uhb = u32_get_bits(tas_selection,
+                                        IWL_WTAS_CANADA_UHB_MSK);
        u8 enabled_iec = u32_get_bits(tas_selection, IWL_WTAS_ENABLE_IEC_MSK);
        u8 usa_tas_uhb = u32_get_bits(tas_selection, IWL_WTAS_USA_UHB_MSK);
        int enabled = tas_selection & IWL_WTAS_ENABLED_MSK;
@@ -441,6 +443,9 @@ int iwl_parse_tas_selection(struct iwl_fw_runtime *fwrt,
        tas_data->override_tas_iec = override_iec;
        tas_data->enable_tas_iec = enabled_iec;
 
+       if (tbl_rev > 1)
+               tas_data->canada_tas_uhb_allowed = canada_tas_uhb;
+
        return enabled;
 }
 
index 4ced171..f247d31 100644 (file)
@@ -43,6 +43,7 @@
 #define IWL_WTAS_ENABLED_MSK           0x1
 #define IWL_WTAS_OVERRIDE_IEC_MSK      0x2
 #define IWL_WTAS_ENABLE_IEC_MSK        0x4
+#define IWL_WTAS_CANADA_UHB_MSK                BIT(15)
 #define IWL_WTAS_USA_UHB_MSK           BIT(16)
 
 #define BIOS_MCC_CHINA 0x434e
@@ -99,9 +100,10 @@ struct iwl_ppag_chain {
 struct iwl_tas_data {
        __le32 block_list_size;
        __le32 block_list_array[IWL_WTAS_BLACK_LIST_MAX];
-       u8 override_tas_iec;
-       u8 enable_tas_iec;
-       u8 usa_tas_uhb_allowed;
+       u8 override_tas_iec:1,
+          enable_tas_iec:1,
+          usa_tas_uhb_allowed:1,
+          canada_tas_uhb_allowed:1;
 };
 
 /* For DSM revision 0 and 4 */
@@ -185,7 +187,7 @@ bool iwl_is_tas_approved(void);
 
 int iwl_parse_tas_selection(struct iwl_fw_runtime *fwrt,
                            struct iwl_tas_data *tas_data,
-                           const u32 tas_selection);
+                           const u32 tas_selection, u8 tbl_rev);
 
 int iwl_bios_get_wrds_table(struct iwl_fw_runtime *fwrt);
 
index 091fb6f..dcbb3c3 100644 (file)
@@ -561,7 +561,8 @@ int iwl_uefi_get_tas_table(struct iwl_fw_runtime *fwrt,
        if (IS_ERR(uefi_tas))
                return -EINVAL;
 
-       if (uefi_tas->revision != IWL_UEFI_WTAS_REVISION) {
+       if (uefi_tas->revision < IWL_UEFI_MIN_WTAS_REVISION ||
+           uefi_tas->revision > IWL_UEFI_MAX_WTAS_REVISION) {
                ret = -EINVAL;
                IWL_DEBUG_RADIO(fwrt, "Unsupported UEFI WTAS revision:%d\n",
                                uefi_tas->revision);
@@ -569,7 +570,9 @@ int iwl_uefi_get_tas_table(struct iwl_fw_runtime *fwrt,
        }
 
        enabled = iwl_parse_tas_selection(fwrt, tas_data,
-                                         uefi_tas->tas_selection);
+                                         uefi_tas->tas_selection,
+                                         uefi_tas->revision);
+
        if (!enabled) {
                IWL_DEBUG_RADIO(fwrt, "TAS not enabled\n");
                ret = 0;
index e525d44..4e98f75 100644 (file)
@@ -33,7 +33,8 @@
 #define IWL_UEFI_WGDS_REVISION         3
 #define IWL_UEFI_MIN_PPAG_REV          1
 #define IWL_UEFI_MAX_PPAG_REV          3
-#define IWL_UEFI_WTAS_REVISION         1
+#define IWL_UEFI_MIN_WTAS_REVISION     1
+#define IWL_UEFI_MAX_WTAS_REVISION     2
 #define IWL_UEFI_SPLC_REVISION         0
 #define IWL_UEFI_WRDD_REVISION         0
 #define IWL_UEFI_ECKV_REVISION         0
index 5ea6848..029347b 100644 (file)
@@ -1171,6 +1171,10 @@ static void iwl_mvm_tas_init(struct iwl_mvm *mvm)
                cmd.v4.override_tas_iec = data.override_tas_iec;
                cmd.v4.enable_tas_iec = data.enable_tas_iec;
                cmd.v4.usa_tas_uhb_allowed = data.usa_tas_uhb_allowed;
+               if (fw_has_capa(&mvm->fw->ucode_capa,
+                               IWL_UCODE_TLV_CAPA_UHB_CANADA_TAS_SUPPORT) &&
+                   data.canada_tas_uhb_allowed)
+                       cmd.v4.uhb_allowed_flags = TAS_UHB_ALLOWED_CANADA;
        } else {
                cmd.v3.override_tas_iec = cpu_to_le16(data.override_tas_iec);
                cmd.v3.enable_tas_iec = cpu_to_le16(data.enable_tas_iec);