[dpdk-dev] [PATCH v5 7/7] devargs: parse bus info
Gaetan Rivet
gaetan.rivet at 6wind.com
Wed Jun 21 01:30:36 CEST 2017
Signed-off-by: Gaetan Rivet <gaetan.rivet at 6wind.com>
---
lib/librte_eal/common/eal_common_devargs.c | 15 ++++++++++++++-
lib/librte_eal/common/eal_common_vdev.c | 6 ++++--
lib/librte_eal/common/include/rte_devargs.h | 3 +++
3 files changed, 21 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..d5f297d 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -83,6 +83,8 @@ 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;
int ret;
@@ -94,7 +96,18 @@ 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) {
+ dev += strlen(bus->name) + 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 221146e..7cc3c6c 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
More information about the dev
mailing list