]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: iwlwifi: move lari helper functions to the op_mode
authorEmmanuel Grumbach <emmanuel.grumbach@intel.com>
Sun, 11 Jan 2026 17:39:17 +0000 (19:39 +0200)
committerMiri Korenblit <miriam.rachel.korenblit@intel.com>
Wed, 21 Jan 2026 12:23:02 +0000 (14:23 +0200)
iwlmvm is the only op_mode that uses the lari helper functions. iwlmld
has its own version to avoid introducing regressions.
Move all those functions to iwlmvm, as they are more related to the
op_mode.
iwl_get_lari_config_bitmap will move in the next patch.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://patch.msgid.link/20260111193638.4bb241e436cb.I3d80796d4722376ce24a847419d34723083baaa8@changeid
drivers/net/wireless/intel/iwlwifi/fw/regulatory.c
drivers/net/wireless/intel/iwlwifi/fw/regulatory.h
drivers/net/wireless/intel/iwlwifi/mvm/fw.c

index d2ad169ae880f868d9cd1c729f651c51645d5dea..7e7af2b81181a3b975d7934ad42edb93869a752d 100644 (file)
@@ -537,157 +537,6 @@ __le32 iwl_get_lari_config_bitmap(struct iwl_fw_runtime *fwrt)
 }
 IWL_EXPORT_SYMBOL(iwl_get_lari_config_bitmap);
 
-static size_t iwl_get_lari_config_cmd_size(u8 cmd_ver)
-{
-       size_t cmd_size;
-
-       switch (cmd_ver) {
-       case 12:
-               cmd_size = sizeof(struct iwl_lari_config_change_cmd);
-               break;
-       case 8:
-               cmd_size = sizeof(struct iwl_lari_config_change_cmd_v8);
-               break;
-       case 6:
-               cmd_size = sizeof(struct iwl_lari_config_change_cmd_v6);
-               break;
-       default:
-               cmd_size = sizeof(struct iwl_lari_config_change_cmd_v1);
-               break;
-       }
-       return cmd_size;
-}
-
-int iwl_fill_lari_config(struct iwl_fw_runtime *fwrt,
-                        struct iwl_lari_config_change_cmd *cmd,
-                        size_t *cmd_size)
-{
-       int ret;
-       u32 value;
-       bool has_raw_dsm_capa = fw_has_capa(&fwrt->fw->ucode_capa,
-                                           IWL_UCODE_TLV_CAPA_FW_ACCEPTS_RAW_DSM_TABLE);
-       u8 cmd_ver = iwl_fw_lookup_cmd_ver(fwrt->fw,
-                                          WIDE_ID(REGULATORY_AND_NVM_GROUP,
-                                                  LARI_CONFIG_CHANGE), 1);
-
-       if (WARN_ONCE(cmd_ver > 12,
-                     "Don't add newer versions to this function\n"))
-               return -EINVAL;
-
-       memset(cmd, 0, sizeof(*cmd));
-       *cmd_size = iwl_get_lari_config_cmd_size(cmd_ver);
-
-       cmd->config_bitmap = iwl_get_lari_config_bitmap(fwrt);
-
-       ret = iwl_bios_get_dsm(fwrt, DSM_FUNC_11AX_ENABLEMENT, &value);
-       if (!ret) {
-               if (!has_raw_dsm_capa)
-                       value &= DSM_11AX_ALLOW_BITMAP;
-               cmd->oem_11ax_allow_bitmap = cpu_to_le32(value);
-       }
-
-       ret = iwl_bios_get_dsm(fwrt, DSM_FUNC_ENABLE_UNII4_CHAN, &value);
-       if (!ret) {
-               if (!has_raw_dsm_capa)
-                       value &= DSM_UNII4_ALLOW_BITMAP;
-
-               /* Since version 12, bits 4 and 5 are supported
-                * regardless of this capability, By pass this masking
-                * if firmware has capability of accepting raw DSM table.
-                */
-               if (!has_raw_dsm_capa && cmd_ver < 12 &&
-                   !fw_has_capa(&fwrt->fw->ucode_capa,
-                                IWL_UCODE_TLV_CAPA_BIOS_OVERRIDE_5G9_FOR_CA))
-                       value &= ~(DSM_VALUE_UNII4_CANADA_OVERRIDE_MSK |
-                                  DSM_VALUE_UNII4_CANADA_EN_MSK);
-
-               cmd->oem_unii4_allow_bitmap = cpu_to_le32(value);
-       }
-
-       ret = iwl_bios_get_dsm(fwrt, DSM_FUNC_ACTIVATE_CHANNEL, &value);
-       if (!ret) {
-               if (!has_raw_dsm_capa)
-                       value &= CHAN_STATE_ACTIVE_BITMAP_CMD_V12;
-
-               if (!has_raw_dsm_capa && cmd_ver < 8)
-                       value &= ~ACTIVATE_5G2_IN_WW_MASK;
-
-               /* Since version 12, bits 5 and 6 are supported
-                * regardless of this capability, By pass this masking
-                * if firmware has capability of accepting raw DSM table.
-                */
-               if (!has_raw_dsm_capa && cmd_ver < 12 &&
-                   !fw_has_capa(&fwrt->fw->ucode_capa,
-                                IWL_UCODE_TLV_CAPA_BIOS_OVERRIDE_UNII4_US_CA))
-                       value &= CHAN_STATE_ACTIVE_BITMAP_CMD_V8;
-
-               cmd->chan_state_active_bitmap = cpu_to_le32(value);
-       }
-
-       ret = iwl_bios_get_dsm(fwrt, DSM_FUNC_ENABLE_6E, &value);
-       if (!ret)
-               cmd->oem_uhb_allow_bitmap = cpu_to_le32(value);
-
-       ret = iwl_bios_get_dsm(fwrt, DSM_FUNC_FORCE_DISABLE_CHANNELS, &value);
-       if (!ret) {
-               if (!has_raw_dsm_capa)
-                       value &= DSM_FORCE_DISABLE_CHANNELS_ALLOWED_BITMAP;
-               cmd->force_disable_channels_bitmap = cpu_to_le32(value);
-       }
-
-       ret = iwl_bios_get_dsm(fwrt, DSM_FUNC_ENERGY_DETECTION_THRESHOLD,
-                              &value);
-       if (!ret) {
-               if (!has_raw_dsm_capa)
-                       value &= DSM_EDT_ALLOWED_BITMAP;
-               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);
-
-       ret = iwl_bios_get_dsm(fwrt, DSM_FUNC_ENABLE_11BE, &value);
-       if (!ret)
-               cmd->oem_11be_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->oem_320mhz_allow_bitmap ||
-           cmd->oem_11be_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),
-                               le32_to_cpu(cmd->oem_11ax_allow_bitmap));
-               IWL_DEBUG_RADIO(fwrt,
-                               "sending LARI_CONFIG_CHANGE, oem_unii4_allow_bitmap=0x%x, chan_state_active_bitmap=0x%x, cmd_ver=%d\n",
-                               le32_to_cpu(cmd->oem_unii4_allow_bitmap),
-                               le32_to_cpu(cmd->chan_state_active_bitmap),
-                               cmd_ver);
-               IWL_DEBUG_RADIO(fwrt,
-                               "sending LARI_CONFIG_CHANGE, oem_uhb_allow_bitmap=0x%x, force_disable_channels_bitmap=0x%x\n",
-                               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, oem_320mhz_allow_bitmap=0x%x\n",
-                               le32_to_cpu(cmd->edt_bitmap),
-                               le32_to_cpu(cmd->oem_320mhz_allow_bitmap));
-               IWL_DEBUG_RADIO(fwrt,
-                               "sending LARI_CONFIG_CHANGE, oem_11be_allow_bitmap=0x%x\n",
-                               le32_to_cpu(cmd->oem_11be_allow_bitmap));
-       } else {
-               return 1;
-       }
-
-       return 0;
-}
-IWL_EXPORT_SYMBOL(iwl_fill_lari_config);
-
 int iwl_bios_get_dsm(struct iwl_fw_runtime *fwrt, enum iwl_dsm_funcs func,
                     u32 *value)
 {
index 735482e7adf56044e4291d9f94699ca08a74eaca..859cb303f81392f4ab2a91f2bee0f4f894468163 100644 (file)
@@ -219,9 +219,6 @@ 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);
 
 __le32 iwl_get_lari_config_bitmap(struct iwl_fw_runtime *fwrt);
-int iwl_fill_lari_config(struct iwl_fw_runtime *fwrt,
-                        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,
                     u32 *value);
index edae13755ee61fb08b58e7701515c092a382612e..d04f5d408ec39114ad2d5537568b59de7ad34ac7 100644 (file)
@@ -1165,13 +1165,159 @@ static void iwl_mvm_tas_init(struct iwl_mvm *mvm)
                IWL_DEBUG_RADIO(mvm, "failed to send TAS_CONFIG (%d)\n", ret);
 }
 
+static size_t iwl_mvm_get_lari_config_cmd_size(u8 cmd_ver)
+{
+       size_t cmd_size;
+
+       switch (cmd_ver) {
+       case 12:
+               cmd_size = sizeof(struct iwl_lari_config_change_cmd);
+               break;
+       case 8:
+               cmd_size = sizeof(struct iwl_lari_config_change_cmd_v8);
+               break;
+       case 6:
+               cmd_size = sizeof(struct iwl_lari_config_change_cmd_v6);
+               break;
+       default:
+               cmd_size = sizeof(struct iwl_lari_config_change_cmd_v1);
+               break;
+       }
+       return cmd_size;
+}
+
+static int iwl_mvm_fill_lari_config(struct iwl_fw_runtime *fwrt,
+                                   struct iwl_lari_config_change_cmd *cmd,
+                                   size_t *cmd_size)
+{
+       int ret;
+       u32 value;
+       bool has_raw_dsm_capa = fw_has_capa(&fwrt->fw->ucode_capa,
+                                           IWL_UCODE_TLV_CAPA_FW_ACCEPTS_RAW_DSM_TABLE);
+       u8 cmd_ver = iwl_fw_lookup_cmd_ver(fwrt->fw,
+                                          WIDE_ID(REGULATORY_AND_NVM_GROUP,
+                                                  LARI_CONFIG_CHANGE), 1);
+
+       memset(cmd, 0, sizeof(*cmd));
+       *cmd_size = iwl_mvm_get_lari_config_cmd_size(cmd_ver);
+
+       cmd->config_bitmap = iwl_get_lari_config_bitmap(fwrt);
+
+       ret = iwl_bios_get_dsm(fwrt, DSM_FUNC_11AX_ENABLEMENT, &value);
+       if (!ret) {
+               if (!has_raw_dsm_capa)
+                       value &= DSM_11AX_ALLOW_BITMAP;
+               cmd->oem_11ax_allow_bitmap = cpu_to_le32(value);
+       }
+
+       ret = iwl_bios_get_dsm(fwrt, DSM_FUNC_ENABLE_UNII4_CHAN, &value);
+       if (!ret) {
+               if (!has_raw_dsm_capa)
+                       value &= DSM_UNII4_ALLOW_BITMAP;
+
+               /* Since version 12, bits 4 and 5 are supported
+                * regardless of this capability, By pass this masking
+                * if firmware has capability of accepting raw DSM table.
+                */
+               if (!has_raw_dsm_capa && cmd_ver < 12 &&
+                   !fw_has_capa(&fwrt->fw->ucode_capa,
+                                IWL_UCODE_TLV_CAPA_BIOS_OVERRIDE_5G9_FOR_CA))
+                       value &= ~(DSM_VALUE_UNII4_CANADA_OVERRIDE_MSK |
+                                  DSM_VALUE_UNII4_CANADA_EN_MSK);
+
+               cmd->oem_unii4_allow_bitmap = cpu_to_le32(value);
+       }
+
+       ret = iwl_bios_get_dsm(fwrt, DSM_FUNC_ACTIVATE_CHANNEL, &value);
+       if (!ret) {
+               if (!has_raw_dsm_capa)
+                       value &= CHAN_STATE_ACTIVE_BITMAP_CMD_V12;
+
+               if (!has_raw_dsm_capa && cmd_ver < 8)
+                       value &= ~ACTIVATE_5G2_IN_WW_MASK;
+
+               /* Since version 12, bits 5 and 6 are supported
+                * regardless of this capability, By pass this masking
+                * if firmware has capability of accepting raw DSM table.
+                */
+               if (!has_raw_dsm_capa && cmd_ver < 12 &&
+                   !fw_has_capa(&fwrt->fw->ucode_capa,
+                                IWL_UCODE_TLV_CAPA_BIOS_OVERRIDE_UNII4_US_CA))
+                       value &= CHAN_STATE_ACTIVE_BITMAP_CMD_V8;
+
+               cmd->chan_state_active_bitmap = cpu_to_le32(value);
+       }
+
+       ret = iwl_bios_get_dsm(fwrt, DSM_FUNC_ENABLE_6E, &value);
+       if (!ret)
+               cmd->oem_uhb_allow_bitmap = cpu_to_le32(value);
+
+       ret = iwl_bios_get_dsm(fwrt, DSM_FUNC_FORCE_DISABLE_CHANNELS, &value);
+       if (!ret) {
+               if (!has_raw_dsm_capa)
+                       value &= DSM_FORCE_DISABLE_CHANNELS_ALLOWED_BITMAP;
+               cmd->force_disable_channels_bitmap = cpu_to_le32(value);
+       }
+
+       ret = iwl_bios_get_dsm(fwrt, DSM_FUNC_ENERGY_DETECTION_THRESHOLD,
+                              &value);
+       if (!ret) {
+               if (!has_raw_dsm_capa)
+                       value &= DSM_EDT_ALLOWED_BITMAP;
+               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);
+
+       ret = iwl_bios_get_dsm(fwrt, DSM_FUNC_ENABLE_11BE, &value);
+       if (!ret)
+               cmd->oem_11be_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->oem_320mhz_allow_bitmap ||
+           cmd->oem_11be_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),
+                               le32_to_cpu(cmd->oem_11ax_allow_bitmap));
+               IWL_DEBUG_RADIO(fwrt,
+                               "sending LARI_CONFIG_CHANGE, oem_unii4_allow_bitmap=0x%x, chan_state_active_bitmap=0x%x, cmd_ver=%d\n",
+                               le32_to_cpu(cmd->oem_unii4_allow_bitmap),
+                               le32_to_cpu(cmd->chan_state_active_bitmap),
+                               cmd_ver);
+               IWL_DEBUG_RADIO(fwrt,
+                               "sending LARI_CONFIG_CHANGE, oem_uhb_allow_bitmap=0x%x, force_disable_channels_bitmap=0x%x\n",
+                               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, oem_320mhz_allow_bitmap=0x%x\n",
+                               le32_to_cpu(cmd->edt_bitmap),
+                               le32_to_cpu(cmd->oem_320mhz_allow_bitmap));
+               IWL_DEBUG_RADIO(fwrt,
+                               "sending LARI_CONFIG_CHANGE, oem_11be_allow_bitmap=0x%x\n",
+                               le32_to_cpu(cmd->oem_11be_allow_bitmap));
+       } else {
+               return 1;
+       }
+
+       return 0;
+}
+
 static void iwl_mvm_lari_cfg(struct iwl_mvm *mvm)
 {
        struct iwl_lari_config_change_cmd cmd;
        size_t cmd_size;
        int ret;
 
-       ret = iwl_fill_lari_config(&mvm->fwrt, &cmd, &cmd_size);
+       ret = iwl_mvm_fill_lari_config(&mvm->fwrt, &cmd, &cmd_size);
        if (!ret) {
                ret = iwl_mvm_send_cmd_pdu(mvm,
                                           WIDE_ID(REGULATORY_AND_NVM_GROUP,