From b4c8f251d65fa99601da000e586933a6df662839 Mon Sep 17 00:00:00 2001 From: "Bjoern A. Zeeb" Date: Thu, 16 May 2024 21:48:41 +0000 Subject: [PATCH] iwlwifi: FreeBSD specific sysctl export update Update the sysctl export (also adding a mapping function) to also print (1) for all lines the "flavor" (device_family) name and (2) also print lines where we only have the trans cfg and not iwl cfg as with the flavor we can match PCI IDs to firmware package and so we can have an increased number of matches. A side effect is that we can also have fwget(8) PCI ID matches for firmware (flavors) not yet (publicly) existing. That will allow us to add them at a later point while a previous release already supports the chipsets and knows how to get the firmware for them. Sponsored by: The FreeBSD Foundation MFC after: 3 days --- sys/contrib/dev/iwlwifi/iwl-config.h | 36 ++++++++++++++++++++++++++++ sys/contrib/dev/iwlwifi/pcie/drv.c | 22 ++++++++++++----- 2 files changed, 52 insertions(+), 6 deletions(-) diff --git a/sys/contrib/dev/iwlwifi/iwl-config.h b/sys/contrib/dev/iwlwifi/iwl-config.h index 241a9e3f2a1..4ea32259592 100644 --- a/sys/contrib/dev/iwlwifi/iwl-config.h +++ b/sys/contrib/dev/iwlwifi/iwl-config.h @@ -38,6 +38,42 @@ enum iwl_device_family { IWL_DEVICE_FAMILY_SC, }; +#if defined(__FreeBSD__) +static const char *iwl_device_family_str[] = { + [IWL_DEVICE_FAMILY_UNDEFINED] = "undefined", + [IWL_DEVICE_FAMILY_1000] = "1000", + [IWL_DEVICE_FAMILY_100] = "100", + [IWL_DEVICE_FAMILY_2000] = "2000", + [IWL_DEVICE_FAMILY_2030] = "2030", + [IWL_DEVICE_FAMILY_105] = "105", + [IWL_DEVICE_FAMILY_135] = "135", + [IWL_DEVICE_FAMILY_5000] = "5000", + [IWL_DEVICE_FAMILY_5150] = "5150", + [IWL_DEVICE_FAMILY_6000] = "6000", + [IWL_DEVICE_FAMILY_6000i] = "6000i", + [IWL_DEVICE_FAMILY_6005] = "6005", + [IWL_DEVICE_FAMILY_6030] = "6030", + [IWL_DEVICE_FAMILY_6050] = "6050", + [IWL_DEVICE_FAMILY_6150] = "6150", + [IWL_DEVICE_FAMILY_7000] = "7000", + [IWL_DEVICE_FAMILY_8000] = "8000", + [IWL_DEVICE_FAMILY_9000] = "9000", + [IWL_DEVICE_FAMILY_22000] = "22000", + [IWL_DEVICE_FAMILY_AX210] = "AX210", + [IWL_DEVICE_FAMILY_BZ] = "BZ", + [IWL_DEVICE_FAMILY_SC] = "SC", +}; + +static inline const char * +iwl_device_family_name(enum iwl_device_family devive_family) +{ + if (devive_family < 0 || + devive_family >= ARRAY_SIZE(iwl_device_family_str)) + return "unknown"; + return (iwl_device_family_str[devive_family]); +} +#endif + /* * LED mode * IWL_LED_DEFAULT: use device default diff --git a/sys/contrib/dev/iwlwifi/pcie/drv.c b/sys/contrib/dev/iwlwifi/pcie/drv.c index 0aab7a1fdc8..8780d77b704 100644 --- a/sys/contrib/dev/iwlwifi/pcie/drv.c +++ b/sys/contrib/dev/iwlwifi/pcie/drv.c @@ -1628,18 +1628,27 @@ sysctl_iwlwifi_pci_ids_name(SYSCTL_HANDLER_ARGS) if ((id->driver_data & TRANS_CFG_MARKER) != 0) { /* Skip and print them below. */ + struct iwl_cfg_trans_params *trans; + + trans = (void *)(id->driver_data & ~TRANS_CFG_MARKER); + sbuf_printf(sb, "%#06x/%#06x/%#06x/%#06x\t%s\t%s\t%d\t%s\n", + id->vendor, id->device, id->subvendor, id->subdevice, + "", "", trans->device_family, + iwl_device_family_name(trans->device_family)); } else if (id->driver_data != 0) { const struct iwl_cfg *cfg; cfg = (void *)(id->driver_data & ~TRANS_CFG_MARKER); - sbuf_printf(sb, "%#06x/%#06x/%#06x/%#06x\t%s\t%s\n", + sbuf_printf(sb, "%#06x/%#06x/%#06x/%#06x\t%s\t%s\t%d\t%s\n", id->vendor, id->device, id->subvendor, id->subdevice, - cfg->name, cfg->fw_name_pre); + cfg->name, cfg->fw_name_pre, cfg->trans.device_family, + iwl_device_family_name(cfg->trans.device_family)); } else { - sbuf_printf(sb, "%#06x/%#06x/%#06x/%#06x\t%s\t%s\n", + sbuf_printf(sb, "%#06x/%#06x/%#06x/%#06x\t%s\t%s\t%d\t%s\n", id->vendor, id->device, id->subvendor, id->subdevice, - "",""); + "","", IWL_DEVICE_FAMILY_UNDEFINED, + iwl_device_family_name(IWL_DEVICE_FAMILY_UNDEFINED)); } id++; } @@ -1655,9 +1664,10 @@ sysctl_iwlwifi_pci_ids_name(SYSCTL_HANDLER_ARGS) else name = ""; - sbuf_printf(sb, "%#06x/%#06x/%#06x/%#06x\t%s\t%s\n", + sbuf_printf(sb, "%#06x/%#06x/%#06x/%#06x\t%s\t%s\t%d\t%s\n", PCI_VENDOR_ID_INTEL, dev_info->device, PCI_ANY_ID, dev_info->subdevice, - name, dev_info->cfg->fw_name_pre); + name, dev_info->cfg->fw_name_pre, dev_info->cfg->trans.device_family, + iwl_device_family_name(dev_info->cfg->trans.device_family)); } error = sbuf_finish(sb);