[dpdk-dev,v4,9/9] devargs: parse bus info
Checks
Commit Message
Signed-off-by: Gaetan Rivet <gaetan.rivet@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(-)
@@ -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) {
@@ -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);
@@ -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;
};