From ca8373cf310dc56446db206c4fb8063e5dd29cfe Mon Sep 17 00:00:00 2001 From: Lakhan Shiva Kamireddy Date: Fri, 20 Jul 2018 12:01:23 +0530 Subject: [PATCH 01/12] Add PNP info to PCI attachments of LE driver Reviewed by: imp, chuck Submitted by: Lakhan Shiva Kamireddy Sponsored by: Google, Inc. (GSoC 2018) Pull Request: https://github.com/bsdimp/freebsd/pull/11 Url: https://reviews.freebsd.org/D16363 --- sys/dev/le/if_le_pci.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/sys/dev/le/if_le_pci.c b/sys/dev/le/if_le_pci.c index 4dd5b2310ca9b6..a141f04fed5b2d 100644 --- a/sys/dev/le/if_le_pci.c +++ b/sys/dev/le/if_le_pci.c @@ -122,6 +122,13 @@ static device_detach_t le_pci_detach; static device_resume_t le_pci_resume; static device_suspend_t le_pci_suspend; +struct pci_device_table le_devs[] = { + {PCI_DEV(AMD_VENDOR, AMD_PCNET_PCI), + PCI_DESCR("AMD PCnet-PCI")}, + {PCI_DEV(AMD_VENDOR, AMD_PCNET_HOME), + PCI_DESCR("AMD PCnet-Home")} +}; + static device_method_t le_pci_methods[] = { /* Device interface */ DEVMETHOD(device_probe, le_pci_probe), @@ -137,6 +144,7 @@ static device_method_t le_pci_methods[] = { DEFINE_CLASS_0(le, le_pci_driver, le_pci_methods, sizeof(struct le_pci_softc)); DRIVER_MODULE(le, pci, le_pci_driver, le_devclass, 0, 0); +PCI_PNP_INFO(le_devs); MODULE_DEPEND(le, ether, 1, 1, 1); static const int le_home_supmedia[] = { @@ -276,22 +284,13 @@ le_pci_dma_callback(void *xsc, bus_dma_segment_t *segs, int nsegs, int error) static int le_pci_probe(device_t dev) { + const struct pci_device_table *led; - if (pci_get_vendor(dev) != AMD_VENDOR) - return (ENXIO); - - switch (pci_get_device(dev)) { - case AMD_PCNET_PCI: - device_set_desc(dev, "AMD PCnet-PCI"); - /* Let pcn(4) win. */ - return (BUS_PROBE_LOW_PRIORITY); - case AMD_PCNET_HOME: - device_set_desc(dev, "AMD PCnet-Home"); - /* Let pcn(4) win. */ - return (BUS_PROBE_LOW_PRIORITY); - default: + led = PCI_MATCH(dev, le_devs); + if (led == NULL) return (ENXIO); - } + device_set_desc(dev, led->descr); + return (BUS_PROBE_LOW_PRIORITY); } static int From e7cdf71b912cef0d808b9d7a86ce43abe5f061db Mon Sep 17 00:00:00 2001 From: Lakhan Shiva Kamireddy Date: Fri, 20 Jul 2018 12:19:14 +0530 Subject: [PATCH 02/12] Add PNP info to PCI attachment of LIO driver Reviewed by: imp, chuck Submitted by: Lakhan Shiva Kamireddy Sponsored by: Google, Inc. (GSoC 2018) Pull Request: https://github.com/bsdimp/freebsd/pull/11 Url: https://reviews.freebsd.org/D16363 --- sys/dev/liquidio/lio_main.c | 71 +++++++++++++++---------------------- 1 file changed, 29 insertions(+), 42 deletions(-) diff --git a/sys/dev/liquidio/lio_main.c b/sys/dev/liquidio/lio_main.c index a7c1308c10d9e5..f1229eca08d5ad 100644 --- a/sys/dev/liquidio/lio_main.c +++ b/sys/dev/liquidio/lio_main.c @@ -145,28 +145,36 @@ struct lio_vendor_info { uint8_t index; }; -static struct lio_vendor_info lio_pci_tbl[] = { +struct pci_device_table lio_pci_tbl[] = { /* CN2350 10G */ - {PCI_VENDOR_ID_CAVIUM, LIO_CN23XX_PF_VID, LIO_CN2350_10G_SUBDEVICE, - 0x02, 0}, + {PCI_DEV(PCI_VENDOR_ID_CAVIUM, LIO_CN23XX_PF_VID), + PCI_SUBDEVCE(LIO_CN2350_10G_SUBDEVICE), + PCI_REVID(0x02), .driver_data (0), + PCI_DESCR("LiquidIO 2350 10GbE Server Adapter")}, /* CN2350 10G */ - {PCI_VENDOR_ID_CAVIUM, LIO_CN23XX_PF_VID, LIO_CN2350_10G_SUBDEVICE1, - 0x02, 0}, + {PCI_DEV(PCI_VENDOR_ID_CAVIUM, LIO_CN23XX_PF_VID), + PCI_SUBDEVICE(LIO_CN2350_10G_SUBDEVICE1), + PCI_REVID(0x02), .driver_data (0), + PCI_DESCR("LiquidIO 2350 10GbE Server Adapter")}, /* CN2360 10G */ - {PCI_VENDOR_ID_CAVIUM, LIO_CN23XX_PF_VID, LIO_CN2360_10G_SUBDEVICE, - 0x02, 1}, + {PCI_DEV(PCI_VENDOR_ID_CAVIUM, LIO_CN23XX_PF_VID), + PCI_SUBDEVICE(LIO_CN2360_10G_SUBDEVICE), + PCI_REVID(0x02), .driver_data (1), + PCI_DESCR("LiquidIO 2360 10GbE Server Adapter")}, /* CN2350 25G */ - {PCI_VENDOR_ID_CAVIUM, LIO_CN23XX_PF_VID, LIO_CN2350_25G_SUBDEVICE, - 0x02, 2}, + {PCI_DEV(PCI_VENDOR_ID_CAVIUM, LIO_CN23XX_PF_VID), + PCI_SUBDEVICE(LIO_CN2350_25G_SUBDEVICE), + PCI_REVID(0x02), .driver_data (2), + PCI_DESCR("LiquidIO 2350 25GbE Server Adapter")}, /* CN2360 25G */ - {PCI_VENDOR_ID_CAVIUM, LIO_CN23XX_PF_VID, LIO_CN2360_25G_SUBDEVICE, - 0x02, 3}, - - {0, 0, 0, 0, 0} + {PCI_DEV(PCI_VENDOR_ID_CAVIUM, LIO_CN23XX_PF_VID), + PCI_SUBDEVICE(LIO_CN2360_25G_SUBDEVICE), + PCI_REVID(0x02), .driver_data (3), + PCI_DESCR("LiquidIO 2360 25GbE Server Adapter")} }; static char *lio_strings[] = { @@ -195,38 +203,16 @@ struct lio_rx_ctl_context { static int lio_probe(device_t dev) { - struct lio_vendor_info *tbl; - - uint16_t vendor_id; - uint16_t device_id; - uint16_t subdevice_id; - uint8_t revision_id; + const struct pci_device_table *liod; char device_ver[256]; - vendor_id = pci_get_vendor(dev); - if (vendor_id != PCI_VENDOR_ID_CAVIUM) + liod = PCI_MATCH(dev, lio_pci_tbl); + if (liod == NULL) return (ENXIO); - - device_id = pci_get_device(dev); - subdevice_id = pci_get_subdevice(dev); - revision_id = pci_get_revid(dev); - - tbl = lio_pci_tbl; - while (tbl->vendor_id) { - if ((vendor_id == tbl->vendor_id) && - (device_id == tbl->device_id) && - (subdevice_id == tbl->subdevice_id) && - (revision_id == tbl->revision_id)) { - sprintf(device_ver, "%s, Version - %s", - lio_strings[tbl->index], LIO_VERSION); - device_set_desc_copy(dev, device_ver); - return (BUS_PROBE_DEFAULT); - } - - tbl++; - } - - return (ENXIO); + sprintf(device_ver, "%s, Version - %s", + lio_strings[liod->driver_data], LIO_VERSION); + device_set_desc_copy(dev, device_ver); + return (BUS_PROBE_DEFAULT); } static int @@ -414,6 +400,7 @@ static driver_t lio_driver = { devclass_t lio_devclass; DRIVER_MODULE(lio, pci, lio_driver, lio_devclass, lio_event, 0); +PCI_PNP_INFO(lio_pci_tbl); MODULE_DEPEND(lio, pci, 1, 1, 1); MODULE_DEPEND(lio, ether, 1, 1, 1); From 7774023dc20dfd1bd303de21ddc66187297efb8f Mon Sep 17 00:00:00 2001 From: Lakhan Shiva Kamireddy Date: Fri, 20 Jul 2018 13:21:58 +0530 Subject: [PATCH 03/12] Add PNP info to PCI attachments of MPR driver Reviewed by: imp, chuck Submitted by: Lakhan Shiva Kamireddy Sponsored by: Google, Inc. (GSoC 2018) Pull Request: https://github.com/bsdimp/freebsd/pull/11 Url: https://reviews.freebsd.org/D16363 --- sys/dev/mpr/mpr_pci.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/sys/dev/mpr/mpr_pci.c b/sys/dev/mpr/mpr_pci.c index 03f3143040c2f0..9ef93ebf201813 100644 --- a/sys/dev/mpr/mpr_pci.c +++ b/sys/dev/mpr/mpr_pci.c @@ -88,9 +88,6 @@ static driver_t mpr_pci_driver = { sizeof(struct mpr_softc) }; -static devclass_t mpr_devclass; -DRIVER_MODULE(mpr, pci, mpr_pci_driver, mpr_devclass, 0, 0); -MODULE_DEPEND(mpr, cam, 1, 1, 1); struct mpr_ident { uint16_t vendor; @@ -154,6 +151,14 @@ struct mpr_ident { { 0, 0, 0, 0, 0, NULL } }; + +static devclass_t mpr_devclass; +DRIVER_MODULE(mpr, pci, mpr_pci_driver, mpr_devclass, 0, 0); +MODULE_PNP_INFO("U16:vendor;U16:device;U16:subvendor;U16:subdevice;D:#", pci, mpr, + mpr_identifiers, sizeof(mpr_identifiers[0]), nitems(mpr_identifiers) - 1); + +MODULE_DEPEND(mpr, cam, 1, 1, 1); + static struct mpr_ident * mpr_find_ident(device_t dev) { From 6b8e5b09fee860e708e5faeede5ae27fa1325bef Mon Sep 17 00:00:00 2001 From: Lakhan Shiva Kamireddy Date: Fri, 20 Jul 2018 13:37:02 +0530 Subject: [PATCH 04/12] Add PNP info to PCI attachment of MVS driver Reviewed by: imp, chuck Submitted by: Lakhan Shiva Kamireddy Sponsored by: Google, Inc. (GSoC 2018) Pull Request: https://github.com/bsdimp/freebsd/pull/11 Url: https://reviews.freebsd.org/D16363 --- sys/dev/mvs/mvs_pci.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/dev/mvs/mvs_pci.c b/sys/dev/mvs/mvs_pci.c index cd6afce40f5c92..6c8362839133ae 100644 --- a/sys/dev/mvs/mvs_pci.c +++ b/sys/dev/mvs/mvs_pci.c @@ -521,6 +521,8 @@ static driver_t mvs_driver = { sizeof(struct mvs_controller) }; DRIVER_MODULE(mvs, pci, mvs_driver, mvs_devclass, 0, 0); +MODULE_PNP_INFO("W32:vendor/device", pci, mvs, mvs_ids, + sizeof(mvs_ids[0]), nitems(mvs_ids) - 1); MODULE_VERSION(mvs, 1); MODULE_DEPEND(mvs, cam, 1, 1, 1); From c1cfaf121737f6a101b6e602358cc4fcee19849e Mon Sep 17 00:00:00 2001 From: Lakhan Shiva Kamireddy Date: Fri, 20 Jul 2018 13:55:41 +0530 Subject: [PATCH 05/12] Add PNP info to PCI attachments of MY driver Reviewed by: imp, chuck Submitted by: Lakhan Shiva Kamireddy Sponsored by: Google, Inc. (GSoC 2018) Pull Request: https://github.com/bsdimp/freebsd/pull/11 Url: https://reviews.freebsd.org/D16363 --- sys/dev/my/if_my.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/dev/my/if_my.c b/sys/dev/my/if_my.c index b1d5e3586c9dab..64bc5088fc1606 100644 --- a/sys/dev/my/if_my.c +++ b/sys/dev/my/if_my.c @@ -163,6 +163,8 @@ static driver_t my_driver = { static devclass_t my_devclass; DRIVER_MODULE(my, pci, my_driver, my_devclass, 0, 0); +MODULE_PNP_INFO("U16:vendor;U16:device;D:#", pci, my, my_devs, + sizeof(my_devs[0]), nitems(my_devs) - 1); MODULE_DEPEND(my, pci, 1, 1, 1); MODULE_DEPEND(my, ether, 1, 1, 1); From 4767f1fac8e9524e1c019bef2818952b971e5110 Mon Sep 17 00:00:00 2001 From: Lakhan Shiva Kamireddy Date: Sun, 22 Jul 2018 16:14:51 +0530 Subject: [PATCH 06/12] Add PNP info to PCI attachment of MLY driver Reviewed by: imp, chuck Submitted by: Lakhan Shiva Kamireddy Sponsored by: Google, Inc. (GSoC 2018) Pull Request: https://github.com/bsdimp/freebsd/pull/11 Url: https://reviews.freebsd.org/D16363 --- sys/dev/mly/mly.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/sys/dev/mly/mly.c b/sys/dev/mly/mly.c index 33a3997663bea5..9ca1f252982e5c 100644 --- a/sys/dev/mly/mly.c +++ b/sys/dev/mly/mly.c @@ -147,10 +147,6 @@ static driver_t mly_pci_driver = { sizeof(struct mly_softc) }; -static devclass_t mly_devclass; -DRIVER_MODULE(mly, pci, mly_pci_driver, mly_devclass, 0, 0); -MODULE_DEPEND(mly, pci, 1, 1, 1); -MODULE_DEPEND(mly, cam, 1, 1, 1); static struct cdevsw mly_cdevsw = { .d_version = D_VERSION, @@ -183,6 +179,15 @@ static struct mly_ident {0, 0, 0, 0, 0, 0} }; + +static devclass_t mly_devclass; +DRIVER_MODULE(mly, pci, mly_pci_driver, mly_devclass, 0, 0); +MODULE_PNP_INFO("U16:vendor;U16:device;U16:subvendor;U16:subdevice", pci, mly, + mly_identifiers, sizeof(mly_identifiers[0]), nitems(mly_identifiers) - 1); +MODULE_DEPEND(mly, pci, 1, 1, 1); +MODULE_DEPEND(mly, cam, 1, 1, 1); + + /******************************************************************************** * Compare the provided PCI device with the list we support. */ From 96a1ebd5e92654476369266ca69b87b54ce3ed80 Mon Sep 17 00:00:00 2001 From: Lakhan Shiva Kamireddy Date: Sun, 22 Jul 2018 16:18:42 +0530 Subject: [PATCH 07/12] Add PNP info to PCI attachment of MPS driver Reviewed by: imp, chuck Submitted by: Lakhan Shiva Kamireddy Sponsored by: Google, Inc. (GSoC 2018) Pull Request: https://github.com/bsdimp/freebsd/pull/11 Url: https://reviews.freebsd.org/D16363 --- sys/dev/mps/mps_pci.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/dev/mps/mps_pci.c b/sys/dev/mps/mps_pci.c index a81fe8a7300f74..c00a4a2c8051b7 100644 --- a/sys/dev/mps/mps_pci.c +++ b/sys/dev/mps/mps_pci.c @@ -88,10 +88,6 @@ static driver_t mps_pci_driver = { sizeof(struct mps_softc) }; -static devclass_t mps_devclass; -DRIVER_MODULE(mps, pci, mps_pci_driver, mps_devclass, 0, 0); -MODULE_DEPEND(mps, cam, 1, 1, 1); - struct mps_ident { uint16_t vendor; uint16_t device; @@ -147,6 +143,10 @@ struct mps_ident { { 0, 0, 0, 0, 0, NULL } }; +static devclass_t mps_devclass; +DRIVER_MODULE(mps, pci, mps_pci_driver, mps_devclass, 0, 0); +MODULE_PNP_INFO("U16:vendor;U16:device;U16:subvendor;U16:subdevice", pci, mps, + mps_identifiers, sizeof(mps_identifiers[0]), nitems(mps_identifiers) - 1); static struct mps_ident * mps_find_ident(device_t dev) { From b95036c49d063a36274766cdc3d7050971d1a6cf Mon Sep 17 00:00:00 2001 From: Lakhan Shiva Kamireddy Date: Sun, 22 Jul 2018 17:41:40 +0530 Subject: [PATCH 08/12] Add PNP info to PCI attachment of MSKC driver Reviewed by: imp, chuck Submitted by: Lakhan Shiva Kamireddy Sponsored by: Google, Inc. (GSoC 2018) Pull Request: https://github.com/bsdimp/freebsd/pull/11 Url: https://reviews.freebsd.org/D16363 --- sys/dev/msk/if_msk.c | 163 ++++++++++++++++++++----------------------- 1 file changed, 76 insertions(+), 87 deletions(-) diff --git a/sys/dev/msk/if_msk.c b/sys/dev/msk/if_msk.c index 91b6e15ad13871..67cc0bdc2ae95e 100644 --- a/sys/dev/msk/if_msk.c +++ b/sys/dev/msk/if_msk.c @@ -165,79 +165,75 @@ TUNABLE_INT("hw.msk.jumbo_disable", &jumbo_disable); /* * Devices supported by this driver. */ -static const struct msk_product { - uint16_t msk_vendorid; - uint16_t msk_deviceid; - const char *msk_name; -} msk_products[] = { - { VENDORID_SK, DEVICEID_SK_YUKON2, - "SK-9Sxx Gigabit Ethernet" }, - { VENDORID_SK, DEVICEID_SK_YUKON2_EXPR, - "SK-9Exx Gigabit Ethernet"}, - { VENDORID_MARVELL, DEVICEID_MRVL_8021CU, - "Marvell Yukon 88E8021CU Gigabit Ethernet" }, - { VENDORID_MARVELL, DEVICEID_MRVL_8021X, - "Marvell Yukon 88E8021 SX/LX Gigabit Ethernet" }, - { VENDORID_MARVELL, DEVICEID_MRVL_8022CU, - "Marvell Yukon 88E8022CU Gigabit Ethernet" }, - { VENDORID_MARVELL, DEVICEID_MRVL_8022X, - "Marvell Yukon 88E8022 SX/LX Gigabit Ethernet" }, - { VENDORID_MARVELL, DEVICEID_MRVL_8061CU, - "Marvell Yukon 88E8061CU Gigabit Ethernet" }, - { VENDORID_MARVELL, DEVICEID_MRVL_8061X, - "Marvell Yukon 88E8061 SX/LX Gigabit Ethernet" }, - { VENDORID_MARVELL, DEVICEID_MRVL_8062CU, - "Marvell Yukon 88E8062CU Gigabit Ethernet" }, - { VENDORID_MARVELL, DEVICEID_MRVL_8062X, - "Marvell Yukon 88E8062 SX/LX Gigabit Ethernet" }, - { VENDORID_MARVELL, DEVICEID_MRVL_8035, - "Marvell Yukon 88E8035 Fast Ethernet" }, - { VENDORID_MARVELL, DEVICEID_MRVL_8036, - "Marvell Yukon 88E8036 Fast Ethernet" }, - { VENDORID_MARVELL, DEVICEID_MRVL_8038, - "Marvell Yukon 88E8038 Fast Ethernet" }, - { VENDORID_MARVELL, DEVICEID_MRVL_8039, - "Marvell Yukon 88E8039 Fast Ethernet" }, - { VENDORID_MARVELL, DEVICEID_MRVL_8040, - "Marvell Yukon 88E8040 Fast Ethernet" }, - { VENDORID_MARVELL, DEVICEID_MRVL_8040T, - "Marvell Yukon 88E8040T Fast Ethernet" }, - { VENDORID_MARVELL, DEVICEID_MRVL_8042, - "Marvell Yukon 88E8042 Fast Ethernet" }, - { VENDORID_MARVELL, DEVICEID_MRVL_8048, - "Marvell Yukon 88E8048 Fast Ethernet" }, - { VENDORID_MARVELL, DEVICEID_MRVL_4361, - "Marvell Yukon 88E8050 Gigabit Ethernet" }, - { VENDORID_MARVELL, DEVICEID_MRVL_4360, - "Marvell Yukon 88E8052 Gigabit Ethernet" }, - { VENDORID_MARVELL, DEVICEID_MRVL_4362, - "Marvell Yukon 88E8053 Gigabit Ethernet" }, - { VENDORID_MARVELL, DEVICEID_MRVL_4363, - "Marvell Yukon 88E8055 Gigabit Ethernet" }, - { VENDORID_MARVELL, DEVICEID_MRVL_4364, - "Marvell Yukon 88E8056 Gigabit Ethernet" }, - { VENDORID_MARVELL, DEVICEID_MRVL_4365, - "Marvell Yukon 88E8070 Gigabit Ethernet" }, - { VENDORID_MARVELL, DEVICEID_MRVL_436A, - "Marvell Yukon 88E8058 Gigabit Ethernet" }, - { VENDORID_MARVELL, DEVICEID_MRVL_436B, - "Marvell Yukon 88E8071 Gigabit Ethernet" }, - { VENDORID_MARVELL, DEVICEID_MRVL_436C, - "Marvell Yukon 88E8072 Gigabit Ethernet" }, - { VENDORID_MARVELL, DEVICEID_MRVL_436D, - "Marvell Yukon 88E8055 Gigabit Ethernet" }, - { VENDORID_MARVELL, DEVICEID_MRVL_4370, - "Marvell Yukon 88E8075 Gigabit Ethernet" }, - { VENDORID_MARVELL, DEVICEID_MRVL_4380, - "Marvell Yukon 88E8057 Gigabit Ethernet" }, - { VENDORID_MARVELL, DEVICEID_MRVL_4381, - "Marvell Yukon 88E8059 Gigabit Ethernet" }, - { VENDORID_DLINK, DEVICEID_DLINK_DGE550SX, - "D-Link 550SX Gigabit Ethernet" }, - { VENDORID_DLINK, DEVICEID_DLINK_DGE560SX, - "D-Link 560SX Gigabit Ethernet" }, - { VENDORID_DLINK, DEVICEID_DLINK_DGE560T, - "D-Link 560T Gigabit Ethernet" } +struct pci_device_table msk_devs[] = { + {PCI_DEV(VENDORID_SK, DEVICEID_SK_YUKON2), + PCI_DESCR("SK-9Sxx Gigabit Ethernet")}, + {PCI_DEV(VENDORID_SK, DEVICEID_SK_YUKON2_EXPR), + PCI_DESCR("SK-9Exx Gigabit Ethernet")}, + {PCI_DEV(VENDORID_MARVELL, DEVICEID_MRVL_8021CU), + PCI_DESCR("Marvell Yukon 88E8021CU Gigabit Ethernet")}, + {PCI_DEV(VENDORID_MARVELL, DEVICEID_MRVL_8021X), + PCI_DESCR("Marvell Yukon 88E8021 SX/LX Gigabit Ethernet")}, + {PCI_DEV(VENDORID_MARVELL, DEVICEID_MRVL_8022CU), + PCI_DESCR("Marvell Yukon 88E8022CU Gigabit Ethernet")}, + {PCI_DEV(VENDORID_MARVELL, DEVICEID_MRVL_8022X), + PCI_DESCR("Marvell Yukon 88E8022 SX/LX Gigabit Ethernet")}, + {PCI_DEV(VENDORID_MARVELL, DEVICEID_MRVL_8061CU), + PCI_DESCR("Marvell Yukon 88E8061CU Gigabit Ethernet")}, + {PCI_DEV(VENDORID_MARVELL, DEVICEID_MRVL_8061X), + PCI_DESCR("Marvell Yukon 88E8061 SX/LX Gigabit Ethernet")}, + {PCI_DEV(VENDORID_MARVELL, DEVICEID_MRVL_8062CU), + PCI_DESCR("Marvell Yukon 88E8062CU Gigabit Ethernet")}, + {PCI_DEV(VENDORID_MARVELL, DEVICEID_MRVL_8062X), + PCI_DESCR("Marvell Yukon 88E8062 SX/LX Gigabit Ethernet")}, + {PCI_DEV(VENDORID_MARVELL, DEVICEID_MRVL_8035), + PCI_DESCR("Marvell Yukon 88E8035 Fast Ethernet")}, + {PCI_DEV(VENDORID_MARVELL, DEVICEID_MRVL_8036), + PCI_DESCR("Marvell Yukon 88E8036 Fast Ethernet")}, + {PCI_DEV(VENDORID_MARVELL, DEVICEID_MRVL_8038), + PCI_DESCR("Marvell Yukon 88E8038 Fast Ethernet")}, + {PCI_DEV(VENDORID_MARVELL, DEVICEID_MRVL_8039), + PCI_DESCR("Marvell Yukon 88E8039 Fast Ethernet")}, + {PCI_DEV(VENDORID_MARVELL, DEVICEID_MRVL_8040), + PCI_DESCR("Marvell Yukon 88E8040 Fast Ethernet")}, + {PCI_DEV(VENDORID_MARVELL, DEVICEID_MRVL_8040T), + PCI_DESCR("Marvell Yukon 88E8040T Fast Ethernet")}, + {PCI_DEV(VENDORID_MARVELL, DEVICEID_MRVL_8042), + PCI_DESCR("Marvell Yukon 88E8042 Fast Ethernet")}, + {PCI_DEV(VENDORID_MARVELL, DEVICEID_MRVL_8048), + PCI_DESCR("Marvell Yukon 88E8048 Fast Ethernet")}, + {PCI_DEV(VENDORID_MARVELL, DEVICEID_MRVL_4361), + PCI_DESCR("Marvell Yukon 88E8050 Gigabit Ethernet")}, + {PCI_DEV(VENDORID_MARVELL, DEVICEID_MRVL_4360), + PCI_DESCR("Marvell Yukon 88E8052 Gigabit Ethernet")}, + {PCI_DEV(VENDORID_MARVELL, DEVICEID_MRVL_4362), + PCI_DESCR("Marvell Yukon 88E8053 Gigabit Ethernet")}, + {PCI_DEV(VENDORID_MARVELL, DEVICEID_MRVL_4363), + PCI_DESCR("Marvell Yukon 88E8055 Gigabit Ethernet")}, + {PCI_DEV(VENDORID_MARVELL, DEVICEID_MRVL_4364), + PCI_DESCR("Marvell Yukon 88E8056 Gigabit Ethernet")}, + {PCI_DEV(VENDORID_MARVELL, DEVICEID_MRVL_4365), + PCI_DESCR("Marvell Yukon 88E8070 Gigabit Ethernet")}, + {PCI_DEV(VENDORID_MARVELL, DEVICEID_MRVL_436A), + PCI_DESCR("Marvell Yukon 88E8058 Gigabit Ethernet")}, + {PCI_DEV(VENDORID_MARVELL, DEVICEID_MRVL_436B), + PCI_DESCR("Marvell Yukon 88E8071 Gigabit Ethernet")}, + {PCI_DEV(VENDORID_MARVELL, DEVICEID_MRVL_436C), + PCI_DESCR("Marvell Yukon 88E8072 Gigabit Ethernet")}, + {PCI_DEV(VENDORID_MARVELL, DEVICEID_MRVL_436D), + PCI_DESCR("Marvell Yukon 88E8055 Gigabit Ethernet")}, + {PCI_DEV(VENDORID_MARVELL, DEVICEID_MRVL_4370), + PCI_DESCR("Marvell Yukon 88E8075 Gigabit Ethernet")}, + {PCI_DEV(VENDORID_MARVELL, DEVICEID_MRVL_4380), + PCI_DESCR("Marvell Yukon 88E8057 Gigabit Ethernet")}, + {PCI_DEV(VENDORID_MARVELL, DEVICEID_MRVL_4381), + PCI_DESCR("Marvell Yukon 88E8059 Gigabit Ethernet")}, + {PCI_DEV(VENDORID_DLINK, DEVICEID_DLINK_DGE550SX), + PCI_DESCR("D-Link 550SX Gigabit Ethernet")}, + {PCI_DEV(VENDORID_DLINK, DEVICEID_DLINK_DGE560SX), + PCI_DESCR("D-Link 560SX Gigabit Ethernet")}, + {PCI_DEV(VENDORID_DLINK, DEVICEID_DLINK_DGE560T), + PCI_DESCR("D-Link 560T Gigabit Ethernet")} }; static const char *model_name[] = { @@ -375,6 +371,7 @@ static driver_t msk_driver = { static devclass_t msk_devclass; DRIVER_MODULE(mskc, pci, mskc_driver, mskc_devclass, NULL, NULL); +PCI_PNP_INFO(msk_devs); DRIVER_MODULE(msk, mskc, msk_driver, msk_devclass, NULL, NULL); DRIVER_MODULE(miibus, msk, miibus_driver, miibus_devclass, NULL, NULL); @@ -1182,21 +1179,13 @@ msk_ioctl(struct ifnet *ifp, u_long command, caddr_t data) static int mskc_probe(device_t dev) { - const struct msk_product *mp; - uint16_t vendor, devid; - int i; - - vendor = pci_get_vendor(dev); - devid = pci_get_device(dev); - mp = msk_products; - for (i = 0; i < nitems(msk_products); i++, mp++) { - if (vendor == mp->msk_vendorid && devid == mp->msk_deviceid) { - device_set_desc(dev, mp->msk_name); - return (BUS_PROBE_DEFAULT); - } - } + const struct pci_device_table *mskd; - return (ENXIO); + mskd = PCI_MATCH(dev, msk_devs); + if (mskd == NULL) + return (ENXIO); + device_set_desc(dev, mskd->descr); + return (BUS_PROBE_DEFAULT); } static int From 7e997f7fc776a198f385ce8494104315c09fec7a Mon Sep 17 00:00:00 2001 From: Lakhan Shiva Kamireddy Date: Sun, 22 Jul 2018 18:09:30 +0530 Subject: [PATCH 09/12] Add PNP info to PCI attachment of MN driver Reviewed by: imp, chuck Submitted by: Lakhan Shiva Kamireddy Sponsored by: Google, Inc. (GSoC 2018) Pull Request: https://github.com/bsdimp/freebsd/pull/11 Url: https://reviews.freebsd.org/D16363 --- sys/dev/mn/if_mn.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/sys/dev/mn/if_mn.c b/sys/dev/mn/if_mn.c index 028de7d6c6ffb8..67b6c54415a348 100644 --- a/sys/dev/mn/if_mn.c +++ b/sys/dev/mn/if_mn.c @@ -73,6 +73,8 @@ SYSCTL_INT(_debug, OID_AUTO, mn_maxlatency, CTLFLAG_RW, #define NMN 4 #endif +#define SIEMENS_VENDOR_ID 0x110a + /* From: PEB 20321 data sheet, p187, table 22 */ struct m32xreg { u_int32_t conf, cmd, stat, imask; @@ -190,6 +192,11 @@ static ng_connect_t ngmn_connect; static ng_rcvdata_t ngmn_rcvdata; static ng_disconnect_t ngmn_disconnect; +struct pci_device_table mn_devs[] = { + {PCI_DEV(SIEMENS_VENDOR_ID, 0x2101), + PCI_DESCR("Munich32X E1/T1 HDLC Controller")} +}; + static struct ng_type mntypestruct = { .version = NG_ABI_VERSION, .name = NG_MN_NODE_TYPE, @@ -1262,7 +1269,7 @@ mn_intr(void *xsc) static int mn_probe (device_t self) { - u_int id = pci_get_devid(self); + const struct pci_device_table *mnd; if (sizeof (struct m32xreg) != 256) { printf("MN: sizeof(struct m32xreg) = %zd, should have been 256\n", sizeof (struct m32xreg)); @@ -1277,10 +1284,10 @@ mn_probe (device_t self) return (ENXIO); } - if (id != 0x2101110a) + mnd = PCI_MATCH(self, mn_devs); + if (mnd == NULL) return (ENXIO); - - device_set_desc_copy(self, "Munich32X E1/T1 HDLC Controller"); + device_set_desc_copy(self, mnd->descr); return (BUS_PROBE_DEFAULT); } @@ -1431,3 +1438,5 @@ static driver_t mn_driver = { static devclass_t mn_devclass; DRIVER_MODULE(mn, pci, mn_driver, mn_devclass, 0, 0); +PCI_PNP_INFO(mn_devs); + From 33772cc06dca112d92bb52cefd47277fbc9f5e33 Mon Sep 17 00:00:00 2001 From: Lakhan Shiva Kamireddy Date: Sun, 22 Jul 2018 19:03:57 +0530 Subject: [PATCH 10/12] Add PNP info to PCI attachment of MRSAS driver Reviewed by: imp, chuck Submitted by: Lakhan Shiva Kamireddy Sponsored by: Google, Inc. (GSoC 2018) Pull Request: https://github.com/bsdimp/freebsd/pull/11 Url: https://reviews.freebsd.org/D16363 --- sys/dev/mrsas/mrsas.c | 74 ++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 46 deletions(-) diff --git a/sys/dev/mrsas/mrsas.c b/sys/dev/mrsas/mrsas.c index d5e83494284eee..e0317d0d899a65 100644 --- a/sys/dev/mrsas/mrsas.c +++ b/sys/dev/mrsas/mrsas.c @@ -66,7 +66,6 @@ static d_poll_t mrsas_poll; static void mrsas_ich_startup(void *arg); static struct mrsas_mgmt_info mrsas_mgmt_info; -static struct mrsas_ident *mrsas_find_ident(device_t); static int mrsas_setup_msix(struct mrsas_softc *sc); static int mrsas_allocate_msix(struct mrsas_softc *sc); static void mrsas_shutdown_ctlr(struct mrsas_softc *sc, u_int32_t opcode); @@ -174,23 +173,21 @@ SYSCTL_NODE(_hw, OID_AUTO, mrsas, CTLFLAG_RD, 0, "MRSAS Driver Parameters"); * PCI device struct and table * */ -typedef struct mrsas_ident { - uint16_t vendor; - uint16_t device; - uint16_t subvendor; - uint16_t subdevice; - const char *desc; -} MRSAS_CTLR_ID; - -MRSAS_CTLR_ID device_table[] = { - {0x1000, MRSAS_TBOLT, 0xffff, 0xffff, "AVAGO Thunderbolt SAS Controller"}, - {0x1000, MRSAS_INVADER, 0xffff, 0xffff, "AVAGO Invader SAS Controller"}, - {0x1000, MRSAS_FURY, 0xffff, 0xffff, "AVAGO Fury SAS Controller"}, - {0x1000, MRSAS_INTRUDER, 0xffff, 0xffff, "AVAGO Intruder SAS Controller"}, - {0x1000, MRSAS_INTRUDER_24, 0xffff, 0xffff, "AVAGO Intruder_24 SAS Controller"}, - {0x1000, MRSAS_CUTLASS_52, 0xffff, 0xffff, "AVAGO Cutlass_52 SAS Controller"}, - {0x1000, MRSAS_CUTLASS_53, 0xffff, 0xffff, "AVAGO Cutlass_53 SAS Controller"}, - {0, 0, 0, 0, NULL} +struct pci_device_table mrsas_devs[] = { + {PCI_DEV(0x1000, MRSAS_TBOLT), PCI_SUBDEV(0xffff, 0xffff), + PCI_DESCR("AVAGO Thunderbolt SAS Controller")}, + {PCI_DEV(0x1000, MRSAS_INVADER), PCI_SUBDEV(0xffff, 0xffff), + PCI_DESCR("AVAGO Invader SAS Controller")}, + {PCI_DEV(0x1000, MRSAS_FURY), PCI_SUBDEV(0xffff, 0xffff), + PCI_DESCR("AVAGO Fury SAS Controller")}, + {PCI_DEV(0x1000, MRSAS_INTRUDER), PCI_SUBDEV(0xffff, 0xffff), + PCI_DESCR("AVAGO Intruder SAS Controller")}, + {PCI_DEV(0x1000, MRSAS_INTRUDER_24), PCI_SUBDEV(0xffff, 0xffff), + PCI_DESCR("AVAGO Intruder_24 SAS Controller")}, + {PCI_DEV(0x1000, MRSAS_CUTLASS_52), PCI_SUBDEV(0xffff, 0xffff), + PCI_DESCR("AVAGO Cutlass_52 SAS Controller")}, + {PCI_DEV(0x1000, MRSAS_CUTLASS_53), PCI_SUBDEV(0xffff, 0xffff), + PCI_DESCR("AVAGO Cutlass_53 SAS Controller")} }; /* @@ -324,40 +321,24 @@ mrsas_clear_intr(struct mrsas_softc *sc) * PCI Support Functions * */ -static struct mrsas_ident * -mrsas_find_ident(device_t dev) -{ - struct mrsas_ident *pci_device; - - for (pci_device = device_table; pci_device->vendor != 0; pci_device++) { - if ((pci_device->vendor == pci_get_vendor(dev)) && - (pci_device->device == pci_get_device(dev)) && - ((pci_device->subvendor == pci_get_subvendor(dev)) || - (pci_device->subvendor == 0xffff)) && - ((pci_device->subdevice == pci_get_subdevice(dev)) || - (pci_device->subdevice == 0xffff))) - return (pci_device); - } - return (NULL); -} static int mrsas_probe(device_t dev) { static u_int8_t first_ctrl = 1; - struct mrsas_ident *id; + const struct pci_device_table *mrsd; - if ((id = mrsas_find_ident(dev)) != NULL) { - if (first_ctrl) { - printf("AVAGO MegaRAID SAS FreeBSD mrsas driver version: %s\n", - MRSAS_VERSION); - first_ctrl = 0; - } - device_set_desc(dev, id->desc); - /* between BUS_PROBE_DEFAULT and BUS_PROBE_LOW_PRIORITY */ - return (-30); - } - return (ENXIO); + mrsd = PCI_MATCH(dev, mrsas_devs); + if (mrsd == NULL) + return (ENXIO); + if (first_ctrl) { + printf("AVAGO MegaRAID SAS FreeBSD mrsas driver version: %s\n", + MRSAS_VERSION); + first_ctrl = 0; + } + device_set_desc(dev, mrsd->descr); + /* between BUS_PROBE_DEFAULT and BUS_PROBE_LOW_PRIORITY */ + return (-30); } /* @@ -4598,4 +4579,5 @@ static driver_t mrsas_driver = { static devclass_t mrsas_devclass; DRIVER_MODULE(mrsas, pci, mrsas_driver, mrsas_devclass, 0, 0); +PCI_PNP_INFO(mrsas_devs); MODULE_DEPEND(mrsas, cam, 1, 1, 1); From 85d6c1e6ac26b800446d4d8b19cff72ac7ec9def Mon Sep 17 00:00:00 2001 From: Lakhan Shiva Kamireddy Date: Sun, 22 Jul 2018 19:17:42 +0530 Subject: [PATCH 11/12] Add PNP info to PCI attachment of MXGE driver Reviewed by: imp, chuck Submitted by: Lakhan Shiva Kamireddy Sponsored by: Google, Inc. (GSoC 2018) Pull Request: https://github.com/bsdimp/freebsd/pull/11 Url: https://reviews.freebsd.org/D16363 --- sys/dev/mxge/if_mxge.c | 47 +++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/sys/dev/mxge/if_mxge.c b/sys/dev/mxge/if_mxge.c index 5ffba31d51bed3..3c4ce037a1dfd1 100644 --- a/sys/dev/mxge/if_mxge.c +++ b/sys/dev/mxge/if_mxge.c @@ -133,6 +133,21 @@ static device_method_t mxge_methods[] = DEVMETHOD_END }; +struct pci_device_table mxge_devs[] = { + {PCI_DEV(MXGE_PCI_VENDOR_MYRICOM, MXGE_PCI_DEVICE_Z8E), + PCI_REVID(MXGE_PCI_REV_Z8E), PCI_DESCR("Myri10G-PCIE-8A")}, + {PCI_DEV(MXGE_PCI_VENDOR_MYRICOM, MXGE_PCI_DEVICE_Z8E), + PCI_REVID(MXGE_PCI_REV_Z8ES), PCI_DESCR("Myri10G-PCIE-8B")}, + {PCI_DEV(MXGE_PCI_VENDOR_MYRICOM, MXGE_PCI_DEVICE_Z8E_9), + PCI_REVID(MXGE_PCI_REV_Z8E), PCI_DESCR("Myri10G-PCIE-8A")}, + {PCI_DEV(MXGE_PCI_VENDOR_MYRICOM, MXGE_PCI_DEVICE_Z8E_9), + PCI_REVID(MXGE_PCI_REV_Z8ES), PCI_DESCR("Myri10G-PCIE-8B")}, + {PCI_DEV(MXGE_PCI_VENDOR_MYRICOM, MXGE_PCI_DEVICE_Z8E), + PCI_DESCR("Myri10G-PCIE-8??")}, + {PCI_DEV(MXGE_PCI_VENDOR_MYRICOM, MXGE_PCI_DEVICE_Z8E_9), + PCI_DESCR("Myri10G-PCIE-8??")}, +} + static driver_t mxge_driver = { "mxge", @@ -144,6 +159,7 @@ static devclass_t mxge_devclass; /* Declare ourselves to be a child of the PCI bus.*/ DRIVER_MODULE(mxge, pci, mxge_driver, mxge_devclass, 0, 0); +PCI_PNP_INFO(mxge_devs); MODULE_DEPEND(mxge, firmware, 1, 1, 1); MODULE_DEPEND(mxge, zlib, 1, 1, 1); @@ -156,29 +172,18 @@ static void mxge_tick(void *arg); static int mxge_probe(device_t dev) { + const struct pci_device_table *mxgd; int rev; - - if ((pci_get_vendor(dev) == MXGE_PCI_VENDOR_MYRICOM) && - ((pci_get_device(dev) == MXGE_PCI_DEVICE_Z8E) || - (pci_get_device(dev) == MXGE_PCI_DEVICE_Z8E_9))) { - rev = pci_get_revid(dev); - switch (rev) { - case MXGE_PCI_REV_Z8E: - device_set_desc(dev, "Myri10G-PCIE-8A"); - break; - case MXGE_PCI_REV_Z8ES: - device_set_desc(dev, "Myri10G-PCIE-8B"); - break; - default: - device_set_desc(dev, "Myri10G-PCIE-8??"); - device_printf(dev, "Unrecognized rev %d NIC\n", - rev); - break; - } - return 0; - } - return ENXIO; + mxgd = PCI_MATCH(dev, mxge_devs); + if (mxgd == NULL) + return (ENXIO); + rev = pci_get_revid(dev); + device_set_desc(dev, mxgd->descr); + if !(rev == MXGE_PCI_REV_Z8E || MXGE_PCI_REV_Z8ES) + device_printf(dev, "Unrecognized rev %d NIC\n", + rev); + return 0; } static void From 73cf7579bf5e17fdc4514ab6ce1491af1f5fe08a Mon Sep 17 00:00:00 2001 From: Lakhan Shiva Kamireddy Date: Mon, 30 Jul 2018 12:16:20 -0600 Subject: [PATCH 12/12] Add PCI_SUBDEVICE macro Reviewed by: imp, chuck Only subdevice is matched (not subvendor) Submitted by: Lakhan Shiva Kamireddy Sponsored by: Google, Inc. (GSoC 2018) Pull Request: https://github.com/bsdimp/freebsd/pull/11 Url: https://reviews.freebsd.org/D16363 --- sys/dev/pci/pcivar.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/dev/pci/pcivar.h b/sys/dev/pci/pcivar.h index 71191ca91b8aea..e0f78be7364381 100644 --- a/sys/dev/pci/pcivar.h +++ b/sys/dev/pci/pcivar.h @@ -299,6 +299,8 @@ struct pci_device_table { #define PCI_SUBDEV(sv, sd) \ .match_flag_subvendor = 1, .subvendor = (sv), \ .match_flag_subdevice = 1, .subdevice = (sd) +#define PCI_SUBDEVICE(sd) \ + .match_flag_subdevice = 1, .subdevice = (sd) #define PCI_DEVID(did) \ PCI_DEV((uint16_t)did, (uint16_t)(did >> 16)) #define PCI_CLASS(x) \