[dpdk-dev] [PATCH v7 14/17] ethdev: do not scan all pci devices on attach

Shreyansh Jain shreyansh.jain at nxp.com
Mon Aug 1 12:45:29 CEST 2016


No need to scan all devices, we only need to update the device being
attached.

Signed-off-by: David Marchand <david.marchand at 6wind.com>
Signed-off-by: Shreyansh Jain <shreyansh.jain at nxp.com>
---
 lib/librte_eal/common/eal_common_pci.c | 11 ++++++++---
 lib/librte_ether/rte_ethdev.c          |  3 ---
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c
index 6a0f6ac..da0038f 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -341,6 +341,11 @@ rte_eal_pci_probe_one(const struct rte_pci_addr *addr)
 	if (addr == NULL)
 		return -1;
 
+	/* update current pci device in global list, kernel bindings might have
+	 * changed since last time we looked at it */
+	if (pci_update_device(addr) < 0)
+		goto err_return;
+
 	TAILQ_FOREACH(dev, &pci_device_list, next) {
 		if (rte_eal_compare_pci_addr(&dev->addr, addr))
 			continue;
@@ -353,9 +358,9 @@ rte_eal_pci_probe_one(const struct rte_pci_addr *addr)
 	return -1;
 
 err_return:
-	RTE_LOG(WARNING, EAL, "Requested device " PCI_PRI_FMT
-			" cannot be used\n", dev->addr.domain, dev->addr.bus,
-			dev->addr.devid, dev->addr.function);
+	RTE_LOG(WARNING, EAL,
+		"Requested device " PCI_PRI_FMT " cannot be used\n",
+		addr->domain, addr->bus, addr->devid, addr->function);
 	return -1;
 }
 
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index a1bb043..fdeac86 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -469,9 +469,6 @@ rte_eth_dev_is_detachable(uint8_t port_id)
 static int
 rte_eth_dev_attach_pdev(struct rte_pci_addr *addr, uint8_t *port_id)
 {
-	/* re-construct pci_device_list */
-	if (rte_eal_pci_scan())
-		goto err;
 	/* Invoke probe func of the driver can handle the new device. */
 	if (rte_eal_pci_probe_one(addr))
 		goto err;
-- 
2.7.4



More information about the dev mailing list