Signed-off-by: Gaetan Rivet <gaetan.ri...@6wind.com> --- drivers/bus/vdev/Makefile | 2 +- drivers/bus/vdev/vdev.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-)
diff --git a/drivers/bus/vdev/Makefile b/drivers/bus/vdev/Makefile index 24d424a38..52728833c 100644 --- a/drivers/bus/vdev/Makefile +++ b/drivers/bus/vdev/Makefile @@ -19,7 +19,7 @@ LIBABIVER := 1 SRCS-y += vdev.c -LDLIBS += -lrte_eal +LDLIBS += -lrte_eal -lrte_kvargs # # Export include files diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c index 68306f4eb..699ce01e6 100644 --- a/drivers/bus/vdev/vdev.c +++ b/drivers/bus/vdev/vdev.c @@ -43,6 +43,7 @@ #include <rte_bus.h> #include <rte_common.h> #include <rte_devargs.h> +#include <rte_kvargs.h> #include <rte_memory.h> #include <rte_tailq.h> #include <rte_spinlock.h> @@ -415,6 +416,38 @@ vdev_unplug(struct rte_device *dev) return rte_vdev_uninit(dev->name); } +static int +vdev_dev_match(const struct rte_device *dev, + const void *_kvlist) +{ + const struct rte_kvargs *kvlist = _kvlist; + + (void) kvlist; + (void) dev; + return 0; +} + +static void * +vdev_dev_iterate(const void *start, + const char *str, + const struct rte_dev_iterator *it __rte_unused) +{ + struct rte_kvargs *kvargs = NULL; + struct rte_device *dev; + + if (str != NULL) { + kvargs = rte_kvargs_parse(str, NULL); + if (kvargs == NULL) { + VDEV_LOG(ERR, "cannot parse argument list\n"); + rte_errno = EINVAL; + return NULL; + } + } + dev = vdev_find_device(start, vdev_dev_match, kvargs); + rte_kvargs_free(kvargs); + return dev; +} + static struct rte_bus rte_vdev_bus = { .scan = vdev_scan, .probe = vdev_probe, @@ -422,6 +455,7 @@ static struct rte_bus rte_vdev_bus = { .plug = vdev_plug, .unplug = vdev_unplug, .parse = vdev_parse, + .dev_iterate = vdev_dev_iterate, }; RTE_REGISTER_BUS(vdev, rte_vdev_bus); -- 2.11.0