git: 645886d028c8 - main - iwlwifi: add sysctl to dump PCI IDs/ names / firmware-prefixes
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 03 Jun 2022 14:52:08 UTC
The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=645886d028c85b3cb9fb36e96b1edc661cf4c0d8 commit 645886d028c85b3cb9fb36e96b1edc661cf4c0d8 Author: Bjoern A. Zeeb <bz@FreeBSD.org> AuthorDate: 2022-05-18 16:05:49 +0000 Commit: Bjoern A. Zeeb <bz@FreeBSD.org> CommitDate: 2022-06-03 14:50:15 +0000 iwlwifi: add sysctl to dump PCI IDs/ names / firmware-prefixes Add a FreeBSD-specifc SYSCTL_PROC to dump the list of PCI IDs / name / firmware-prefix which can be post-processed for man pages (iwlwifi.4 and iwlwififw.4) or the wiki. The output still yields duplicates depending on by what information you need so one may wants to filter them out (try not to use sort/uniq). Sponsored by: The FreeBSD Foundation MFC after: 3 days --- sys/contrib/dev/iwlwifi/pcie/drv.c | 62 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/sys/contrib/dev/iwlwifi/pcie/drv.c b/sys/contrib/dev/iwlwifi/pcie/drv.c index 536a40f1e5cc..6b9ce03850ec 100644 --- a/sys/contrib/dev/iwlwifi/pcie/drv.c +++ b/sys/contrib/dev/iwlwifi/pcie/drv.c @@ -1767,3 +1767,65 @@ void iwl_pci_unregister_driver(void) { pci_unregister_driver(&iwl_pci_driver); } + +#if defined(__FreeBSD__) +static int +sysctl_iwlwifi_pci_ids_name(SYSCTL_HANDLER_ARGS) +{ + const struct pci_device_id *id; + struct sbuf *sb; + int error, i; + + error = sysctl_wire_old_buffer(req, 0); + if (error != 0) + return (error); + sb = sbuf_new_for_sysctl(NULL, NULL, 512, req); + if (sb == NULL) + return (ENOMEM); + + id = iwl_hw_card_ids; + while (id != NULL && id->vendor != 0) { + + if ((id->driver_data & TRANS_CFG_MARKER) != 0) { + /* Skip and print them below. */ + + } 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", + id->vendor, id->device, id->subvendor, id->subdevice, + cfg->name, cfg->fw_name_pre); + } else { + sbuf_printf(sb, "%#06x/%#06x/%#06x/%#06x\t%s\t%s\n", + id->vendor, id->device, id->subvendor, id->subdevice, + "",""); + } + id++; + } + + for (i = 0; i < ARRAY_SIZE(iwl_dev_info_table); i++) { + const struct iwl_dev_info *dev_info = &iwl_dev_info_table[i]; + const char *name; + + if (dev_info->name) + name = dev_info->name; + else if (dev_info->cfg && dev_info->cfg->name) + name = dev_info->cfg->name; + else + name = ""; + + sbuf_printf(sb, "%#06x/%#06x/%#06x/%#06x\t%s\t%s\n", + PCI_VENDOR_ID_INTEL, dev_info->device, PCI_ANY_ID, dev_info->subdevice, + name, dev_info->cfg->fw_name_pre); + } + + error = sbuf_finish(sb); + sbuf_delete(sb); + + return (error); +} +SYSCTL_PROC(LINUXKPI_PARAM_PARENT, OID_AUTO, LINUXKPI_PARAM_NAME(pci_ids_name), + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_SKIP | CTLFLAG_MPSAFE, NULL, 0, + sysctl_iwlwifi_pci_ids_name, "", "iwlwifi PCI IDs and names"); +#endif