Thread (209 messages) 209 messages, 11 authors, 2021-04-12

[dpdk-dev] [PATCH v3 9/9] eal: probe devices of same PCI but different devargs

From: Xueming Li <hidden>
Date: 2021-01-13 13:46:14
Subsystem: library code, the rest · Maintainers: Andrew Morton, Linus Torvalds

When probing same PCI device with different representor arguments, PCI
bus only probed first devargs, ignored other allowed devices with
different representor arguments.

This patch iterates all devargs and try them all after bus scan.

Signed-off-by: Xueming Li <redacted>
---
 lib/librte_eal/common/eal_common_bus.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c
index baa5b532af..9f88a0fe6e 100644
--- a/lib/librte_eal/common/eal_common_bus.c
+++ b/lib/librte_eal/common/eal_common_bus.c
@@ -10,6 +10,7 @@
 #include <rte_debug.h>
 #include <rte_string_fns.h>
 #include <rte_errno.h>
+#include <rte_devargs.h>
 
 #include "eal_private.h"
 
@@ -56,12 +57,22 @@ rte_bus_scan(void)
 	return 0;
 }
 
+static int
+cmp_dev_name(const struct rte_device *dev, const void *_name)
+{
+	const char *name = _name;
+
+	return strcmp(dev->name, name);
+}
+
 /* Probe all devices of all buses */
 int
 rte_bus_probe(void)
 {
 	int ret;
 	struct rte_bus *bus, *vbus = NULL;
+	struct rte_devargs *da;
+	struct rte_device *dev;
 
 	TAILQ_FOREACH(bus, &rte_bus_list, next) {
 		if (!strcmp(bus->name, "vdev")) {
@@ -82,6 +93,18 @@ rte_bus_probe(void)
 				vbus->name);
 	}
 
+	/* For devargs with same name but different arguments, try them all. */
+	RTE_EAL_DEVARGS_FOREACH(NULL, da) {
+		dev = da->bus->find_device(NULL, cmp_dev_name, da->name);
+		if (!dev || !rte_dev_is_probed(dev) || dev->devargs == da)
+			continue;
+		dev->devargs = da;
+		ret = dev->bus->plug(dev);
+		if (ret == 0)
+			RTE_LOG(DEBUG, EAL, "device probed %s %s", da->name,
+				da->args);
+	}
+
 	return 0;
 }
 
-- 
2.25.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help