Thread (123 messages) 123 messages, 7 authors, 2017-07-08
STALE3306d
Revisions (4)
  1. v1 [diff vs current]
  2. v2 [diff vs current]
  3. v3 current
  4. v4 [diff vs current]

[PATCH v3 9/9] devargs: parse bus info

From: Gaetan Rivet <hidden>
Date: 2017-06-01 10:09:19
Subsystem: library code, the rest · Maintainers: Andrew Morton, Linus Torvalds

Signed-off-by: Gaetan Rivet <redacted>
---
 lib/librte_eal/common/eal_common_devargs.c  | 17 ++++++++++++++++-
 lib/librte_eal/common/eal_common_vdev.c     |  6 ++++--
 lib/librte_eal/common/include/rte_devargs.h |  3 +++
 3 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c
index ffa8ad9..8bb72a2 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -83,7 +83,10 @@ int
 rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)
 {
 	struct rte_devargs *devargs = NULL;
+	const char *dev = devargs_str;
+	struct rte_bus *bus;
 	char *buf = NULL;
+	size_t i;
 	int ret;
 
 	/* use malloc instead of rte_malloc as it's called early at init */
@@ -94,7 +97,19 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)
 	memset(devargs, 0, sizeof(*devargs));
 	devargs->type = devtype;
 
-	if (rte_eal_parse_devargs_str(devargs_str, &buf, &devargs->args))
+	bus = rte_bus_from_name(dev);
+	if (bus) {
+		i = rte_bus_name_valid(dev);
+		dev += i + 1;
+	} else {
+		bus = rte_bus_from_dev(dev);
+		if (!bus) {
+			fprintf(stderr, "ERROR: failed to parse bus info from device declaration\n");
+			goto fail;
+		}
+	}
+	devargs->bus = bus;
+	if (rte_eal_parse_devargs_str(dev, &buf, &devargs->args))
 		goto fail;
 
 	switch (devargs->type) {
diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c
index 452f60f..ea58706 100644
--- a/lib/librte_eal/common/eal_common_vdev.c
+++ b/lib/librte_eal/common/eal_common_vdev.c
@@ -182,6 +182,7 @@ alloc_devargs(const char *name, const char *args)
 		return NULL;
 
 	devargs->type = RTE_DEVTYPE_VIRTUAL;
+	devargs->bus = rte_bus_from_name(VIRTUAL_BUS_NAME);
 	if (args)
 		devargs->args = strdup(args);
 
@@ -294,12 +295,13 @@ vdev_scan(void)
 {
 	struct rte_vdev_device *dev;
 	struct rte_devargs *devargs;
+	struct rte_bus *vbus;
 
 	/* for virtual devices we scan the devargs_list populated via cmdline */
-
+	vbus = rte_bus_from_name(VIRTUAL_BUS_NAME);
 	TAILQ_FOREACH(devargs, &devargs_list, next) {
 
-		if (devargs->type != RTE_DEVTYPE_VIRTUAL)
+		if (devargs->bus != vbus)
 			continue;
 
 		dev = find_vdev(devargs->virt.drv_name);
diff --git a/lib/librte_eal/common/include/rte_devargs.h b/lib/librte_eal/common/include/rte_devargs.h
index 88120a1..1f50a24 100644
--- a/lib/librte_eal/common/include/rte_devargs.h
+++ b/lib/librte_eal/common/include/rte_devargs.h
@@ -51,6 +51,7 @@ extern "C" {
 #include <stdio.h>
 #include <sys/queue.h>
 #include <rte_pci.h>
+#include <rte_bus.h>
 
 /**
  * Type of generic device
@@ -89,6 +90,8 @@ struct rte_devargs {
 			char drv_name[32];
 		} virt;
 	};
+	/** Bus handle for the device. */
+	struct rte_bus *bus;
 	/** Arguments string as given by user or "" for no argument. */
 	char *args;
 };
-- 
2.1.4
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help