iwlwifi: acpi: evaluate dsm to disable 5.8GHz channels
authorGil Adam <gil.adam@intel.com>
Fri, 11 Sep 2020 17:44:35 +0000 (20:44 +0300)
committerLuca Coelho <luciano.coelho@intel.com>
Thu, 1 Oct 2020 18:53:01 +0000 (21:53 +0300)
Evaluate the appropriate DSM from ACPI to set ETSI SRD 5.8GHz
channels to passive or disabled, default behaviour is enabled.
Add enums and refactor evaluation of DSM functions for better
readablity and more informative debug prints.

Signed-off-by: Gil Adam <gil.adam@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20200911204056.816130ee75e0.I727a217be7c967a97960b197a816fc053d10c48a@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
drivers/net/wireless/intel/iwlwifi/fw/acpi.h
drivers/net/wireless/intel/iwlwifi/mvm/fw.c

index 0ada9eddb8b1709a95d88d2af25fc71fce45f71c..bff0260012ecf6e790b8effa2fa56231c2e25286 100644 (file)
@@ -133,6 +133,20 @@ enum iwl_dsm_funcs_rev_0 {
        DSM_FUNC_ENABLE_INDONESIA_5G2 = 2,
 };
 
+enum iwl_dsm_values_srd {
+       DSM_VALUE_SRD_ACTIVE,
+       DSM_VALUE_SRD_PASSIVE,
+       DSM_VALUE_SRD_DISABLE,
+       DSM_VALUE_SRD_MAX
+};
+
+enum iwl_dsm_values_indonesia {
+       DSM_VALUE_INDONESIA_DISABLE,
+       DSM_VALUE_INDONESIA_ENABLE,
+       DSM_VALUE_INDONESIA_RESERVED,
+       DSM_VALUE_INDONESIA_MAX
+};
+
 #ifdef CONFIG_ACPI
 
 struct iwl_fw_runtime;
index 95a6135370476cb133eec1f6c36d8dbf8b91cdf1..4467359aaa203823f01f8dac7a670520a490caa9 100644 (file)
@@ -989,41 +989,90 @@ static void iwl_mvm_tas_init(struct iwl_mvm *mvm)
                IWL_DEBUG_RADIO(mvm, "failed to send TAS_CONFIG (%d)\n", ret);
 }
 
-static bool iwl_mvm_eval_dsm_indonesia_5g2(struct iwl_mvm *mvm)
+static u8 iwl_mvm_eval_dsm_indonesia_5g2(struct iwl_mvm *mvm)
 {
        int ret = iwl_acpi_get_dsm_u8((&mvm->fwrt)->dev, 0,
                                      DSM_FUNC_ENABLE_INDONESIA_5G2);
 
-       IWL_DEBUG_RADIO(mvm,
-                       "Evaluated DSM function ENABLE_INDONESIA_5G2, ret=%d\n",
-                       ret);
+       if (ret < 0)
+               IWL_DEBUG_RADIO(mvm,
+                               "Failed to evaluate DSM function ENABLE_INDONESIA_5G2, ret=%d\n",
+                               ret);
 
-       return ret == 1;
+       else if (ret >= DSM_VALUE_INDONESIA_MAX)
+               IWL_DEBUG_RADIO(mvm,
+                               "DSM function ENABLE_INDONESIA_5G2 return invalid value, ret=%d\n",
+                               ret);
+
+       else if (ret == DSM_VALUE_INDONESIA_ENABLE) {
+               IWL_DEBUG_RADIO(mvm,
+                               "Evaluated DSM function ENABLE_INDONESIA_5G2: Enabling 5g2\n");
+               return DSM_VALUE_INDONESIA_ENABLE;
+       }
+       /* default behaviour is disabled */
+       return DSM_VALUE_INDONESIA_DISABLE;
+}
+
+static u8 iwl_mvm_eval_dsm_disable_srd(struct iwl_mvm *mvm)
+{
+       int ret = iwl_acpi_get_dsm_u8((&mvm->fwrt)->dev, 0,
+                                     DSM_FUNC_DISABLE_SRD);
+
+       if (ret < 0)
+               IWL_DEBUG_RADIO(mvm,
+                               "Failed to evaluate DSM function DISABLE_SRD, ret=%d\n",
+                               ret);
+
+       else if (ret >= DSM_VALUE_SRD_MAX)
+               IWL_DEBUG_RADIO(mvm,
+                               "DSM function DISABLE_SRD return invalid value, ret=%d\n",
+                               ret);
+
+       else if (ret == DSM_VALUE_SRD_PASSIVE) {
+               IWL_DEBUG_RADIO(mvm,
+                               "Evaluated DSM function DISABLE_SRD: setting SRD to passive\n");
+               return DSM_VALUE_SRD_PASSIVE;
+
+       } else if (ret == DSM_VALUE_SRD_DISABLE) {
+               IWL_DEBUG_RADIO(mvm,
+                               "Evaluated DSM function DISABLE_SRD: disabling SRD\n");
+               return DSM_VALUE_SRD_DISABLE;
+       }
+       /* default behaviour is active */
+       return DSM_VALUE_SRD_ACTIVE;
 }
 
 static void iwl_mvm_lari_cfg(struct iwl_mvm *mvm)
 {
-       int ret;
+       u8 ret;
+       int cmd_ret;
        struct iwl_lari_config_change_cmd cmd = {};
 
-       if (iwl_mvm_eval_dsm_indonesia_5g2(mvm))
+       if (iwl_mvm_eval_dsm_indonesia_5g2(mvm) == DSM_VALUE_INDONESIA_ENABLE)
                cmd.config_bitmap |=
                        cpu_to_le32(LARI_CONFIG_ENABLE_5G2_IN_INDONESIA_MSK);
 
+       ret = iwl_mvm_eval_dsm_disable_srd(mvm);
+       if (ret == DSM_VALUE_SRD_PASSIVE)
+               cmd.config_bitmap |=
+                       cpu_to_le32(LARI_CONFIG_CHANGE_ETSI_TO_PASSIVE_MSK);
+
+       else if (ret == DSM_VALUE_SRD_DISABLE)
+               cmd.config_bitmap |=
+                       cpu_to_le32(LARI_CONFIG_CHANGE_ETSI_TO_DISABLED_MSK);
+
        /* apply more config masks here */
 
        if (cmd.config_bitmap) {
-               IWL_DEBUG_RADIO(mvm,
-                               "sending LARI_CONFIG_CHANGE, config_bitmap=0x%x\n",
-                               le32_to_cpu(cmd.config_bitmap));
-               ret = iwl_mvm_send_cmd_pdu(mvm,
-                                          WIDE_ID(REGULATORY_AND_NVM_GROUP,
-                                                  LARI_CONFIG_CHANGE),
-                                          0, sizeof(cmd), &cmd);
-               if (ret < 0)
+               IWL_DEBUG_RADIO(mvm, "sending LARI_CONFIG_CHANGE\n");
+               cmd_ret = iwl_mvm_send_cmd_pdu(mvm,
+                                              WIDE_ID(REGULATORY_AND_NVM_GROUP,
+                                                      LARI_CONFIG_CHANGE),
+                                              0, sizeof(cmd), &cmd);
+               if (cmd_ret < 0)
                        IWL_DEBUG_RADIO(mvm,
                                        "Failed to send LARI_CONFIG_CHANGE (%d)\n",
-                                       ret);
+                                       cmd_ret);
        }
 }
 #else /* CONFIG_ACPI */