From 5e9f6d1340ffa33d2c70c66e041f5efdaeb14feb Mon Sep 17 00:00:00 2001 From: Adrien Mazarguil Date: Mon, 30 Jul 2012 09:47:28 +0000 Subject: [PATCH] pci: reference driver structure for each device Add a driver reference (if available) to every PCI devices, even when blacklisted. This information is made available in the global device_list variable so users know which network devices are managed or ignored. Signed-off-by: Adrien Mazarguil Acked-by: Ivan Boule Acked-by: Damien Millescamps --- lib/librte_eal/common/eal_common_pci.c | 3 +-- lib/librte_eal/common/include/rte_pci.h | 2 ++ lib/librte_eal/linuxapp/eal/eal_pci.c | 11 ++++++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c index 02ea211141..e5e9b85f1f 100644 --- a/lib/librte_eal/common/eal_common_pci.c +++ b/lib/librte_eal/common/eal_common_pci.c @@ -80,9 +80,8 @@ pci_probe_all_drivers(struct rte_pci_device *dev) { struct rte_pci_driver *dr = NULL; + dev->blacklisted = !!is_blacklisted(dev); TAILQ_FOREACH(dr, &driver_list, next) { - if (is_blacklisted(dev)) - return -1; if (rte_eal_pci_probe_one_driver(dr, dev) == 0) return 0; } diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h index acd43a55bb..4be38d22c8 100644 --- a/lib/librte_eal/common/include/rte_pci.h +++ b/lib/librte_eal/common/include/rte_pci.h @@ -110,6 +110,8 @@ struct rte_pci_device { struct rte_pci_id id; /**< PCI ID. */ struct rte_pci_resource mem_resource; /**< PCI Memory Resource */ struct rte_intr_handle intr_handle; /**< Interrupt handle */ + const struct rte_pci_driver *driver; /**< Associated driver */ + unsigned int blacklisted:1; /**< Device is blacklisted */ }; /** Any PCI device identifier (vendor, device, ...) */ diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linuxapp/eal/eal_pci.c index f989799f93..7370335b00 100644 --- a/lib/librte_eal/linuxapp/eal/eal_pci.c +++ b/lib/librte_eal/linuxapp/eal/eal_pci.c @@ -700,7 +700,8 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device *d dev->id.vendor_id, dev->id.device_id, dr->name); /* Unbind PCI devices if needed */ - if (module_name != NULL) { + if ((!dev->blacklisted) && + (module_name != NULL)) { if (rte_eal_process_type() == RTE_PROC_PRIMARY) { /* unbind current driver, bind ours */ if (pci_unbind_kernel_driver(dev) < 0) @@ -712,6 +713,14 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device *d if (pci_uio_map_resource(dev) < 0) return -1; } + + /* reference driver structure */ + dev->driver = dr; + + /* no initialization when blacklisted */ + if (dev->blacklisted) + return -1; + /* call the driver devinit() function */ return dr->devinit(dr, dev); -- 2.20.1