Signed-off-by: Gaetan Rivet <gaetan.ri...@6wind.com>
---
 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

Reply via email to