wifi: iwlwifi: cfg: add ucode API min/max to MAC config
authorJohannes Berg <johannes.berg@intel.com>
Fri, 9 May 2025 10:44:40 +0000 (13:44 +0300)
committerMiri Korenblit <miriam.rachel.korenblit@intel.com>
Sat, 10 May 2025 18:41:51 +0000 (21:41 +0300)
In some older devices, the min/max firmware API supported by
the driver depends on the specific device, when sharing the
the same MAC (config). For most newer devices, it really is
dependent on the MAC instead, since the firmware was frozen
for certain MAC types. However, in the future we expect also
freezes for RF types there.

To handle this most generally, add an API min/max to the MAC
config and then use the narrowest range prescribed by both,
if set.

For the newer MACs since 9000, move the configuration, there
was only a freeze on MAC+RF lines so far.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Link: https://patch.msgid.link/20250509104454.2582160-2-miriam.rachel.korenblit@intel.com
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
drivers/net/wireless/intel/iwlwifi/cfg/22000.c
drivers/net/wireless/intel/iwlwifi/cfg/9000.c
drivers/net/wireless/intel/iwlwifi/cfg/ax210.c
drivers/net/wireless/intel/iwlwifi/cfg/bz.c
drivers/net/wireless/intel/iwlwifi/cfg/dr.c
drivers/net/wireless/intel/iwlwifi/cfg/sc.c
drivers/net/wireless/intel/iwlwifi/iwl-config.h
drivers/net/wireless/intel/iwlwifi/iwl-drv.c

index 42f2e2ede7746a3d34b77c2d9d0edce8a67eac15..92ae336405fdaad14fe4e2d95ee8de60761a468e 100644 (file)
@@ -83,11 +83,11 @@ static const struct iwl_family_base_params iwl_22000_base = {
                        .mask = 0xffffffff,
                },
        },
+       .ucode_api_min = IWL_22000_UCODE_API_MIN,
+       .ucode_api_max = IWL_22000_UCODE_API_MAX,
 };
 
 #define IWL_DEVICE_22500                                               \
-       .ucode_api_min = IWL_22000_UCODE_API_MIN,                       \
-       .ucode_api_max = IWL_22000_UCODE_API_MAX,                       \
        .led_mode = IWL_LED_RF_STATE,                                   \
        .non_shared_ant = ANT_B,                                        \
        .vht_mu_mimo_supported = true,                                  \
index bc497abd07c17d9dbf3180ffa2b8ca796ed277e4..5424133fae1dc1e6b4ce9e96b630f959c9d2a99f 100644 (file)
@@ -72,6 +72,8 @@ static const struct iwl_family_base_params iwl9000_base = {
                        .mask = 0xffffffff,
                },
        },
+       .ucode_api_max = IWL9000_UCODE_API_MAX,
+       .ucode_api_min = IWL9000_UCODE_API_MIN,
 };
 
 static const struct iwl_tt_params iwl9000_tt_params = {
@@ -96,8 +98,6 @@ static const struct iwl_tt_params iwl9000_tt_params = {
 };
 
 #define IWL_DEVICE_9000                                                        \
-       .ucode_api_max = IWL9000_UCODE_API_MAX,                         \
-       .ucode_api_min = IWL9000_UCODE_API_MIN,                         \
        .led_mode = IWL_LED_RF_STATE,                                   \
        .non_shared_ant = ANT_B,                                        \
        .dccm_offset = IWL9000_DCCM_OFFSET,                             \
index 748c1f1f73a2cb7e1b57e531be31755a8f694289..d0a8069196b2f8b0da48fbda2ff1e6954b02a6fe 100644 (file)
@@ -87,11 +87,11 @@ static const struct iwl_family_base_params iwl_ax210_base = {
                        .mask = DBGC_CUR_DBGBUF_STATUS_IDX_MSK,
                },
        },
+       .ucode_api_min = IWL_AX210_UCODE_API_MIN,
+       .ucode_api_max = IWL_AX210_UCODE_API_MAX,
 };
 
 #define IWL_DEVICE_AX210                                               \
-       .ucode_api_min = IWL_AX210_UCODE_API_MIN,                       \
-       .ucode_api_max = IWL_AX210_UCODE_API_MAX,                       \
        .led_mode = IWL_LED_RF_STATE,                                   \
        .non_shared_ant = ANT_B,                                        \
        .vht_mu_mimo_supported = true,                                  \
index 3c632b8c7650cabe74a8de51c166549fa22f158d..86871b0431b1ef6c63cab5e45c49534969087373 100644 (file)
@@ -89,11 +89,11 @@ static const struct iwl_family_base_params iwl_bz_base = {
                },
        },
        .features = IWL_TX_CSUM_NETIF_FLAGS | NETIF_F_RXCSUM,
+       .ucode_api_max = IWL_BZ_UCODE_API_MAX,
+       .ucode_api_min = IWL_BZ_UCODE_API_MIN,
 };
 
 #define IWL_DEVICE_BZ                                                  \
-       .ucode_api_max = IWL_BZ_UCODE_API_MAX,                          \
-       .ucode_api_min = IWL_BZ_UCODE_API_MIN,                          \
        .ht_params = {                                                  \
                .stbc = true,                                           \
                .ldpc = true,                                           \
index d7f0797c32317d255c4d78775bbec0c61d6022ae..6696c30ed7b66584ffd319f5df28b13aad09def5 100644 (file)
@@ -82,11 +82,11 @@ static const struct iwl_family_base_params iwl_dr_base = {
                },
        },
        .features = IWL_TX_CSUM_NETIF_FLAGS | NETIF_F_RXCSUM,
+       .ucode_api_max = IWL_DR_UCODE_API_MAX,
+       .ucode_api_min = IWL_DR_UCODE_API_MIN,
 };
 
 #define IWL_DEVICE_DR                                                  \
-       .ucode_api_max = IWL_DR_UCODE_API_MAX,                          \
-       .ucode_api_min = IWL_DR_UCODE_API_MIN,                          \
        .led_mode = IWL_LED_RF_STATE,                                   \
        .non_shared_ant = ANT_B,                                        \
        .vht_mu_mimo_supported = true,                                  \
index e9a94d4c7d4d840e9c883a7b405a063e7cb47732..6669dc3160193f9fbf9fdaafa125f242d309afdd 100644 (file)
@@ -89,11 +89,11 @@ static const struct iwl_family_base_params iwl_sc_base = {
                },
        },
        .features = IWL_TX_CSUM_NETIF_FLAGS | NETIF_F_RXCSUM,
+       .ucode_api_max = IWL_SC_UCODE_API_MAX,
+       .ucode_api_min = IWL_SC_UCODE_API_MIN,
 };
 
 #define IWL_DEVICE_SC                                                  \
-       .ucode_api_max = IWL_SC_UCODE_API_MAX,                          \
-       .ucode_api_min = IWL_SC_UCODE_API_MIN,                          \
        .led_mode = IWL_LED_RF_STATE,                                   \
        .non_shared_ant = ANT_B,                                        \
        .vht_mu_mimo_supported = true,                                  \
index b5cfaad6a0370e0c8ef3bee9f36afc53385c7aa9..9e6c9650fbae67c866affa7efdeff684f95e62ff 100644 (file)
@@ -170,6 +170,8 @@ struct iwl_fw_mon_regs {
  * @mon_dbgi_regs: monitor DBGI registers
  * @mon_dram_regs: monitor DRAM registers
  * @mon_smem_regs: monitor SMEM registers
+ * @ucode_api_max: Highest version of uCode API supported by driver.
+ * @ucode_api_min: Lowest version of uCode API supported by driver.
  */
 struct iwl_family_base_params {
        unsigned int wd_timeout;
@@ -190,6 +192,8 @@ struct iwl_family_base_params {
 
        u8 max_ll_items;
        u8 led_compensation;
+       u8 ucode_api_max;
+       u8 ucode_api_min;
        u32 mac_addr_from_csr:10;
        u8 nvm_hw_section_num;
        netdev_features_t features;
index d300b7a12ed74efe39431fcc7e6d54504a8f42ff..8734c7913b2fd3d04beefab2ab6d367298fb74c7 100644 (file)
@@ -291,12 +291,37 @@ IWL_EXPORT_SYMBOL(iwl_drv_get_fwname_pre);
 static void iwl_req_fw_callback(const struct firmware *ucode_raw,
                                void *context);
 
+static void iwl_get_ucode_api_versions(struct iwl_trans *trans,
+                                      unsigned int *api_min,
+                                      unsigned int *api_max)
+{
+       const struct iwl_family_base_params *base = trans->mac_cfg->base;
+       const struct iwl_cfg *cfg = trans->cfg;
+
+       if (!base->ucode_api_max) {
+               *api_min = cfg->ucode_api_min;
+               *api_max = cfg->ucode_api_max;
+               return;
+       }
+
+       if (!cfg->ucode_api_max) {
+               *api_min = base->ucode_api_min;
+               *api_max = base->ucode_api_max;
+               return;
+       }
+
+       *api_min = max(cfg->ucode_api_min, base->ucode_api_min);
+       *api_max = min(cfg->ucode_api_max, base->ucode_api_max);
+}
+
 static int iwl_request_firmware(struct iwl_drv *drv, bool first)
 {
-       const struct iwl_cfg *cfg = drv->trans->cfg;
        char _fw_name_pre[FW_NAME_PRE_BUFSIZE];
+       unsigned int ucode_api_max, ucode_api_min;
        const char *fw_name_pre;
 
+       iwl_get_ucode_api_versions(drv->trans, &ucode_api_min, &ucode_api_max);
+
        if (drv->trans->mac_cfg->device_family == IWL_DEVICE_FAMILY_9000 &&
            (drv->trans->info.hw_rev_step != SILICON_B_STEP &&
             drv->trans->info.hw_rev_step != SILICON_C_STEP)) {
@@ -309,21 +334,21 @@ static int iwl_request_firmware(struct iwl_drv *drv, bool first)
        fw_name_pre = iwl_drv_get_fwname_pre(drv->trans, _fw_name_pre);
 
        if (first)
-               drv->fw_index = cfg->ucode_api_max;
+               drv->fw_index = ucode_api_max;
        else
                drv->fw_index--;
 
-       if (drv->fw_index < cfg->ucode_api_min) {
+       if (drv->fw_index < ucode_api_min) {
                IWL_ERR(drv, "no suitable firmware found!\n");
 
-               if (cfg->ucode_api_min == cfg->ucode_api_max) {
+               if (ucode_api_min == ucode_api_max) {
                        IWL_ERR(drv, "%s-%d is required\n", fw_name_pre,
-                               cfg->ucode_api_max);
+                               ucode_api_max);
                } else {
                        IWL_ERR(drv, "minimum version required: %s-%d\n",
-                               fw_name_pre, cfg->ucode_api_min);
+                               fw_name_pre, ucode_api_min);
                        IWL_ERR(drv, "maximum version supported: %s-%d\n",
-                               fw_name_pre, cfg->ucode_api_max);
+                               fw_name_pre, ucode_api_max);
                }
 
                IWL_ERR(drv,
@@ -1554,14 +1579,15 @@ static void iwl_req_fw_callback(const struct firmware *ucode_raw, void *context)
        struct iwlwifi_opmode_table *op;
        int err;
        struct iwl_firmware_pieces *pieces;
-       const unsigned int api_max = drv->trans->cfg->ucode_api_max;
-       const unsigned int api_min = drv->trans->cfg->ucode_api_min;
+       unsigned int api_min, api_max;
        size_t trigger_tlv_sz[FW_DBG_TRIGGER_MAX];
        u32 api_ver;
        int i;
        bool usniffer_images = false;
        bool failure = true;
 
+       iwl_get_ucode_api_versions(drv->trans, &api_min, &api_max);
+
        fw->ucode_capa.max_probe_length = IWL_DEFAULT_MAX_PROBE_LENGTH;
        fw->ucode_capa.standard_phy_calibration_size =
                        IWL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE;