pci: reference driver structure for each device
authorAdrien Mazarguil <adrien.mazarguil@6wind.com>
Mon, 30 Jul 2012 09:47:28 +0000 (09:47 +0000)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Thu, 25 Jul 2013 13:23:28 +0000 (15:23 +0200)
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 <adrien.mazarguil@6wind.com>
Acked-by: Ivan Boule <ivan.boule@6wind.com>
Acked-by: Damien Millescamps <damien.millescamps@6wind.com>
lib/librte_eal/common/eal_common_pci.c
lib/librte_eal/common/include/rte_pci.h
lib/librte_eal/linuxapp/eal/eal_pci.c

index 02ea211..e5e9b85 100644 (file)
@@ -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;
        }
index acd43a5..4be38d2 100644 (file)
@@ -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, ...) */
index f989799..7370335 100644 (file)
@@ -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);