[dpdk-dev] [PATCH 9/9] pci: blacklist only in global probe function

David Marchand david.marchand at 6wind.com
Fri Jan 22 16:27:44 CET 2016


Move blacklist evaluation to rte_eal_pci_probe().
This way, rte_eal_pci_probe_one() (used by hotplug when attaching) now
accepts to probe devices that were blacklisted initially.

A new debug trace is added when skipping a device not part of a given
whitelist.

Signed-off-by: David Marchand <david.marchand at 6wind.com>
---
 lib/librte_eal/common/eal_common_pci.c | 56 ++++++++++++++++++++--------------
 1 file changed, 33 insertions(+), 23 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c
index 71222a5..52d4594 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -209,21 +209,6 @@ static int
 pci_probe_device(struct rte_pci_driver *dr, struct rte_pci_device *dev)
 {
 	int ret;
-	struct rte_pci_addr *loc = &dev->addr;
-
-	RTE_LOG(DEBUG, EAL, "PCI device "PCI_PRI_FMT" on NUMA socket %i\n",
-		loc->domain, loc->bus, loc->devid, loc->function,
-		dev->numa_node);
-
-	RTE_LOG(DEBUG, EAL, "  probe driver: %x:%x %s\n", dev->id.vendor_id,
-		dev->id.device_id, dr->name);
-
-	/* no initialization when blacklisted, return without error */
-	if (dev->devargs != NULL &&
-		dev->devargs->type == RTE_DEVTYPE_BLACKLISTED_PCI) {
-		RTE_LOG(DEBUG, EAL, "  Device is blacklisted, not initializing\n");
-		return 1;
-	}
 
 	if (dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) {
 #ifdef RTE_PCI_CONFIG
@@ -306,6 +291,14 @@ rte_eal_pci_probe_one(const struct rte_pci_addr *addr)
 	if (!dr)
 		goto err_return;
 
+	RTE_LOG(DEBUG, EAL, "PCI device "PCI_PRI_FMT" on NUMA socket %i\n",
+		dev->addr.domain, dev->addr.bus,
+		dev->addr.devid, dev->addr.function,
+		dev->numa_node);
+
+	RTE_LOG(DEBUG, EAL, "  probe driver: %x:%x %s\n", dev->id.vendor_id,
+		dev->id.device_id, dr->name);
+
 	if (pci_probe_device(dr, dev) < 0)
 		goto err_return;
 
@@ -364,10 +357,8 @@ rte_eal_pci_probe(void)
 	struct rte_pci_device *dev;
 	struct rte_pci_driver *dr;
 	struct rte_devargs *devargs;
-	int probe_all = 0;
-
-	if (rte_eal_devargs_type_count(RTE_DEVTYPE_WHITELISTED_PCI) == 0)
-		probe_all = 1;
+	int whitelist = rte_eal_devargs_type_count(RTE_DEVTYPE_WHITELISTED_PCI);
+	int blacklist = rte_eal_devargs_type_count(RTE_DEVTYPE_BLACKLISTED_PCI);
 
 	TAILQ_FOREACH(dev, &pci_device_list, next) {
 
@@ -381,11 +372,30 @@ rte_eal_pci_probe(void)
 		if (devargs != NULL)
 			dev->devargs = devargs;
 
-		/* skip if not probing all and device is not whitelisted */
-		if (!probe_all &&
-		    (devargs == NULL ||
-		     devargs->type != RTE_DEVTYPE_WHITELISTED_PCI))
+		RTE_LOG(DEBUG, EAL,
+			"PCI device "PCI_PRI_FMT" on NUMA socket %i\n",
+			dev->addr.domain, dev->addr.bus,
+			dev->addr.devid, dev->addr.function,
+			dev->numa_node);
+
+		RTE_LOG(DEBUG, EAL, "  probe driver: %x:%x %s\n",
+			dev->id.vendor_id, dev->id.device_id, dr->name);
+
+		/*
+		 * We want to probe this device when:
+		 * - there is no whitelist/blacklist,
+		 * - there is a whitelist, and device is part of it,
+		 * - there is a blacklist, and device is not part of it.
+		 */
+		if (whitelist && !devargs) {
+			RTE_LOG(DEBUG, EAL, "  Device is not whitelisted, not initializing\n");
+			continue;
+		}
+
+		if (blacklist && devargs) {
+			RTE_LOG(DEBUG, EAL, "  Device is blacklisted, not initializing\n");
 			continue;
+		}
 
 		if (pci_probe_device(dr, dev) < 0)
 			rte_exit(EXIT_FAILURE, "Requested device " PCI_PRI_FMT
-- 
1.9.1



More information about the dev mailing list