wifi: iwlwifi: implement enable/disable for China 2022 regulatory
authorAnjaneyulu <pagadala.yesu.anjaneyulu@intel.com>
Thu, 21 Sep 2023 08:58:02 +0000 (11:58 +0300)
committerJohannes Berg <johannes.berg@intel.com>
Mon, 25 Sep 2023 07:14:59 +0000 (09:14 +0200)
China 2022 regulations are enabled by default. Disable only when
disabled in BIOS or the firmware don't support this capability. If the
firmware has this capability, read BIOS configuration data in
function 4 using ACPI API and send GRP_REGULATORY_LARI_CONFIG_CHANGE_CMD
to the firmware. Any error while reading BIOS data results in enablement
of china 2022 regulations.

Signed-off-by: Anjaneyulu <pagadala.yesu.anjaneyulu@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20230921110726.ba7cb3003e53.If5a180a59ee85ed4a4c9146cfeff841c25b81066@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/debugfs.c
drivers/net/wireless/intel/iwlwifi/fw/file.h

index b26f90e522564f6e4cf757f88c0949b083f1dee5..e83ce797a68b120269f0167259d2618e9a645a88 100644 (file)
@@ -1011,6 +1011,7 @@ __le32 iwl_acpi_get_lari_config_bitmap(struct iwl_fw_runtime *fwrt)
 {
        int ret;
        u8 value;
+       u32 val;
        __le32 config_bitmap = 0;
 
        /*
@@ -1039,6 +1040,23 @@ __le32 iwl_acpi_get_lari_config_bitmap(struct iwl_fw_runtime *fwrt)
                                cpu_to_le32(LARI_CONFIG_CHANGE_ETSI_TO_DISABLED_MSK);
        }
 
+       if (fw_has_capa(&fwrt->fw->ucode_capa,
+                       IWL_UCODE_TLV_CAPA_CHINA_22_REG_SUPPORT)) {
+               /*
+                ** Evaluate func 'DSM_FUNC_REGULATORY_CONFIG'
+                */
+               ret = iwl_acpi_get_dsm_u32(fwrt->dev, 0,
+                                          DSM_FUNC_REGULATORY_CONFIG,
+                                          &iwl_guid, &val);
+               /*
+                * China 2022 enable if the BIOS object does not exist or
+                * if it is enabled in BIOS.
+                */
+               if (ret < 0 || val & DSM_MASK_CHINA_22_REG)
+                       config_bitmap |=
+                               cpu_to_le32(LARI_CONFIG_ENABLE_CHINA_22_REG_SUPPORT_MSK);
+       }
+
        return config_bitmap;
 }
 IWL_EXPORT_SYMBOL(iwl_acpi_get_lari_config_bitmap);
index c36c62d6414de888d4e915a67185cdd2987ab722..d129fc66d8bbe61092ba2613c685830fb8afff61 100644 (file)
@@ -134,6 +134,7 @@ enum iwl_dsm_funcs_rev_0 {
        DSM_FUNC_DISABLE_SRD = 1,
        DSM_FUNC_ENABLE_INDONESIA_5G2 = 2,
        DSM_FUNC_ENABLE_6E = 3,
+       DSM_FUNC_REGULATORY_CONFIG = 4,
        DSM_FUNC_11AX_ENABLEMENT = 6,
        DSM_FUNC_ENABLE_UNII4_CHAN = 7,
        DSM_FUNC_ACTIVATE_CHANNEL = 8,
@@ -164,6 +165,10 @@ enum iwl_dsm_values_rfi {
        DSM_VALUE_RFI_MAX
 };
 
+enum iwl_dsm_masks_reg {
+       DSM_MASK_CHINA_22_REG = BIT(2)
+};
+
 #ifdef CONFIG_ACPI
 
 struct iwl_fw_runtime;
index 28bfabb399b2f0b7e4dade4c7d4eb591b1f73994..c4577219c5015651d09d4d1a59330935e12f11d7 100644 (file)
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
 /*
- * Copyright (C) 2012-2014, 2018-2022 Intel Corporation
+ * Copyright (C) 2012-2014, 2018-2023 Intel Corporation
  * Copyright (C) 2013-2015 Intel Mobile Communications GmbH
  * Copyright (C) 2016-2017 Intel Deutschland GmbH
  */
@@ -480,18 +480,20 @@ union iwl_tas_config_cmd {
        struct iwl_tas_config_cmd_v4 v4;
 };
 /**
- * enum iwl_lari_configs - bit masks for the various LARI config operations
+ * enum iwl_lari_config_masks - bit masks for the various LARI config operations
  * @LARI_CONFIG_DISABLE_11AC_UKRAINE_MSK: disable 11ac in ukraine
  * @LARI_CONFIG_CHANGE_ETSI_TO_PASSIVE_MSK: ETSI 5.8GHz SRD passive scan
  * @LARI_CONFIG_CHANGE_ETSI_TO_DISABLED_MSK: ETSI 5.8GHz SRD disabled
  * @LARI_CONFIG_ENABLE_5G2_IN_INDONESIA_MSK: enable 5.15/5.35GHz bands in
  *     Indonesia
+ * @LARI_CONFIG_ENABLE_CHINA_22_REG_SUPPORT_MSK: enable 2022 china regulatory
  */
 enum iwl_lari_config_masks {
        LARI_CONFIG_DISABLE_11AC_UKRAINE_MSK            = BIT(0),
        LARI_CONFIG_CHANGE_ETSI_TO_PASSIVE_MSK          = BIT(1),
        LARI_CONFIG_CHANGE_ETSI_TO_DISABLED_MSK         = BIT(2),
        LARI_CONFIG_ENABLE_5G2_IN_INDONESIA_MSK         = BIT(3),
+       LARI_CONFIG_ENABLE_CHINA_22_REG_SUPPORT_MSK     = BIT(7),
 };
 
 #define IWL_11AX_UKRAINE_MASK 3
index 3cdbc6ac7ae5d62282a4f071ae204df413d92e5e..b8d4a4d571e774fc0cd172dd7fc12e008700cc15 100644 (file)
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
 /*
- * Copyright (C) 2012-2014, 2018-2020 Intel Corporation
+ * Copyright (C) 2012-2014, 2018-2023 Intel Corporation
  * Copyright (C) 2013-2015 Intel Mobile Communications GmbH
  * Copyright (C) 2016-2017 Intel Deutschland GmbH
  */
@@ -342,6 +342,12 @@ static int iwl_dbgfs_fw_info_seq_show(struct seq_file *seq, void *v)
                           "    %d: %d\n",
                           IWL_UCODE_TLV_CAPA_PPAG_CHINA_BIOS_SUPPORT,
                           has_capa);
+               has_capa = fw_has_capa(&fw->ucode_capa,
+                                      IWL_UCODE_TLV_CAPA_CHINA_22_REG_SUPPORT) ? 1 : 0;
+               seq_printf(seq,
+                          "    %d: %d\n",
+                          IWL_UCODE_TLV_CAPA_CHINA_22_REG_SUPPORT,
+                          has_capa);
                seq_puts(seq, "fw_api_ver:\n");
        }
 
index 41841524f983f2d0ca421f907692fb604a0d0aa0..7e0894ea1005d5c346573942c088fb4f0624c503 100644 (file)
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
 /*
- * Copyright (C) 2008-2014, 2018-2021 Intel Corporation
+ * Copyright (C) 2008-2014, 2018-2023 Intel Corporation
  * Copyright (C) 2013-2015 Intel Mobile Communications GmbH
  * Copyright (C) 2016-2017 Intel Deutschland GmbH
  */
@@ -472,6 +472,7 @@ enum iwl_ucode_tlv_capa {
        IWL_UCODE_TLV_CAPA_OFFLOAD_BTM_SUPPORT          = (__force iwl_ucode_tlv_capa_t)113,
        IWL_UCODE_TLV_CAPA_STA_EXP_MFP_SUPPORT          = (__force iwl_ucode_tlv_capa_t)114,
        IWL_UCODE_TLV_CAPA_SNIFF_VALIDATE_SUPPORT       = (__force iwl_ucode_tlv_capa_t)116,
+       IWL_UCODE_TLV_CAPA_CHINA_22_REG_SUPPORT         = (__force iwl_ucode_tlv_capa_t)117,
 
        NUM_IWL_UCODE_TLV_CAPA
 /*