]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
wifi: iwlwifi: match discrete/integrated to fix some names
authorJohannes Berg <johannes.berg@intel.com>
Wed, 9 Jul 2025 05:16:29 +0000 (08:16 +0300)
committerMiri Korenblit <miriam.rachel.korenblit@intel.com>
Wed, 9 Jul 2025 08:43:16 +0000 (11:43 +0300)
Some device names were wrong because our internal data suggested
that discrete Ga devices have B-step RF, when they actually have
C-step. However, matching the step for them is bad anyway.

Change the code to be able to find the devinfo depending on the
device being integrated or discrete. This is only for the names,
since the RF config cannot be different for the same RF because
it's discrete or integrated, so add a kunit test that ensures
both (a) the RF config is the same and (b) the name is different
(the latter really only because that's the whole point of having
a match on the discrete/integrated bit.)

Remove the RF step matching since it's no longer needed now.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://patch.msgid.link/20250709081300.e048a94659f1.Ie5919c70e9d8e3a28152aaf3cdffd19ed3d4f5c7@changeid
drivers/net/wireless/intel/iwlwifi/iwl-config.h
drivers/net/wireless/intel/iwlwifi/pcie/drv.c
drivers/net/wireless/intel/iwlwifi/pcie/gen1_2/trans.c
drivers/net/wireless/intel/iwlwifi/tests/devinfo.c

index 08c4f79f8335de72cf8848faa5a7b4faeaa9db74..30e5f5a5cd8978dec53ca4bd6e7318b975d50fd1 100644 (file)
@@ -488,8 +488,8 @@ struct iwl_dev_info {
            rf_type:9,
            match_bw_limit:1,
            bw_limit:1,
-           match_rf_step:1,
-           rf_step:4,
+           match_discrete:1,
+           discrete:1,
            match_rf_id:1,
            rf_id:4,
            match_cdb:1,
@@ -504,7 +504,7 @@ extern const struct pci_device_id iwl_hw_card_ids[];
 
 const struct iwl_dev_info *
 iwl_pci_find_dev_info(u16 device, u16 subsystem_device, u16 rf_type, u8 cdb,
-                     u8 rf_id, u8 bw_limit, u8 rf_step);
+                     u8 rf_id, u8 bw_limit, bool discrete);
 
 /*
  * This list declares the config structures for all devices.
index 02a031433b234791045aa2747be805d116b8b239..0bd9b44d295b959b714b76fa487bbfda15720d91 100644 (file)
@@ -577,8 +577,10 @@ EXPORT_SYMBOL_IF_IWLWIFI_KUNIT(iwl_hw_card_ids);
                                .subdevice_m_h = _HIGHEST_BIT(m)
 #define RF_TYPE(n)             .match_rf_type = 1,                     \
                                .rf_type = IWL_CFG_RF_TYPE_##n
-#define RF_STEP(n)             .match_rf_step = 1,                     \
-                               .rf_step = SILICON_##n##_STEP
+#define DISCRETE               .match_discrete = 1,                    \
+                               .discrete = 1
+#define INTEGRATED             .match_discrete = 1,                    \
+                               .discrete = 0
 #define RF_ID(n)               .match_rf_id = 1,                       \
                                .rf_id = IWL_CFG_RF_ID_##n
 #define NO_CDB                 .match_cdb = 1, .cdb = 0
@@ -1032,9 +1034,8 @@ VISIBLE_IF_IWLWIFI_KUNIT const struct iwl_dev_info iwl_dev_info_table[] = {
 /* FM RF */
        IWL_DEV_INFO(iwl_rf_fm, iwl_be201_name, RF_TYPE(FM)),
        IWL_DEV_INFO(iwl_rf_fm, iwl_be401_name, RF_TYPE(FM), CDB),
-       /* the discrete NICs got the RF B0, it's only for the name anyway */
        IWL_DEV_INFO(iwl_rf_fm, iwl_be200_name, RF_TYPE(FM),
-                    DEVICE(0x272B), RF_STEP(B)),
+                    DEVICE(0x272B), DISCRETE),
        IWL_DEV_INFO(iwl_rf_fm_160mhz, iwl_be202_name,
                     RF_TYPE(FM), BW_LIMITED),
 
@@ -1079,7 +1080,7 @@ EXPORT_SYMBOL_IF_IWLWIFI_KUNIT(iwl_dev_info_table_size);
 
 const struct iwl_dev_info *
 iwl_pci_find_dev_info(u16 device, u16 subsystem_device, u16 rf_type, u8 cdb,
-                     u8 rf_id, u8 bw_limit, u8 rf_step)
+                     u8 rf_id, u8 bw_limit, bool discrete)
 {
        int num_devices = ARRAY_SIZE(iwl_dev_info_table);
        int i;
@@ -1114,7 +1115,7 @@ iwl_pci_find_dev_info(u16 device, u16 subsystem_device, u16 rf_type, u8 cdb,
                if (dev_info->match_bw_limit && dev_info->bw_limit != bw_limit)
                        continue;
 
-               if (dev_info->match_rf_step && dev_info->rf_step != rf_step)
+               if (dev_info->match_discrete && dev_info->discrete != discrete)
                        continue;
 
                return dev_info;
index 2262c1e96e8d8936880525688e42e36ac042518f..8440f0c8a78e45bdaabde3208ccbd6aafb587741 100644 (file)
@@ -4198,7 +4198,7 @@ int iwl_pci_gen1_2_probe(struct pci_dev *pdev,
                                         CSR_HW_RFID_IS_CDB(info.hw_rf_id),
                                         IWL_SUBDEVICE_RF_ID(pdev->subsystem_device),
                                         IWL_SUBDEVICE_BW_LIM(pdev->subsystem_device),
-                                        CSR_HW_RFID_STEP(info.hw_rf_id));
+                                        !iwl_trans->mac_cfg->integrated);
        if (dev_info) {
                iwl_trans->cfg = dev_info->cfg;
                info.name = dev_info->name;
index 784433bb246a6126f974454622cc9c07b9165e5b..4d660cef3de9774aba436fc7311bf479cb591b6e 100644 (file)
@@ -31,15 +31,6 @@ static void iwl_pci_print_dev_info(const char *pfx, const struct iwl_dev_info *d
                pos += scnprintf(buf + pos, sizeof(buf) - pos,
                                 " bw_limit=*");
 
-       if (di->match_rf_step)
-               pos += scnprintf(buf + pos, sizeof(buf) - pos,
-                                " rf_step=%c",
-                                di->rf_step == SILICON_Z_STEP ? 'Z' :
-                                       'A' + di->rf_step);
-       else
-               pos += scnprintf(buf + pos, sizeof(buf) - pos,
-                                " rf_step=*");
-
        if (di->match_rf_id)
                pos += scnprintf(buf + pos, sizeof(buf) - pos,
                                 " rf_id=0x%x", di->rf_id);
@@ -54,6 +45,13 @@ static void iwl_pci_print_dev_info(const char *pfx, const struct iwl_dev_info *d
                pos += scnprintf(buf + pos, sizeof(buf) - pos,
                                 " cdb=*");
 
+       if (di->match_discrete)
+               pos += scnprintf(buf + pos, sizeof(buf) - pos,
+                                " discrete=%d",
+                                di->discrete);
+       else
+               pos += scnprintf(buf + pos, sizeof(buf) - pos,
+                                " discrete=*");
 
        printk(KERN_DEBUG "%sdev=%04x subdev=%04x/%04x%s\n",
               pfx, di->device, di->subdevice, subdevice_mask, buf);
@@ -70,7 +68,7 @@ static void devinfo_table_order(struct kunit *test)
                ret = iwl_pci_find_dev_info(di->device, di->subdevice,
                                            di->rf_type, di->cdb,
                                            di->rf_id, di->bw_limit,
-                                           di->rf_step);
+                                           di->discrete);
                if (!ret) {
                        iwl_pci_print_dev_info("No entry found for: ", di);
                        KUNIT_FAIL(test,
@@ -85,6 +83,32 @@ static void devinfo_table_order(struct kunit *test)
        }
 }
 
+static void devinfo_discrete_match(struct kunit *test)
+{
+       /*
+        * Validate that any entries with discrete/integrated match have
+        * the same config with the value inverted (if they match at all.)
+        */
+
+       for (int idx = 0; idx < iwl_dev_info_table_size; idx++) {
+               const struct iwl_dev_info *di = &iwl_dev_info_table[idx];
+               const struct iwl_dev_info *ret;
+
+               if (!di->match_discrete)
+                       continue;
+
+               ret = iwl_pci_find_dev_info(di->device, di->subdevice,
+                                           di->rf_type, di->cdb,
+                                           di->rf_id, di->bw_limit,
+                                           !di->discrete);
+               if (!ret)
+                       continue;
+               KUNIT_EXPECT_PTR_EQ(test, di->cfg, ret->cfg);
+               /* and check the name is different, that'd be the point of it */
+               KUNIT_EXPECT_NE(test, strcmp(di->name, ret->name), 0);
+       }
+}
+
 static void devinfo_names(struct kunit *test)
 {
        int idx;
@@ -216,6 +240,7 @@ static void devinfo_no_mac_cfg_dups(struct kunit *test)
 
 static struct kunit_case devinfo_test_cases[] = {
        KUNIT_CASE(devinfo_table_order),
+       KUNIT_CASE(devinfo_discrete_match),
        KUNIT_CASE(devinfo_names),
        KUNIT_CASE(devinfo_no_cfg_dups),
        KUNIT_CASE(devinfo_no_name_dups),