[dpdk-dev] [PATCH v6 18/22] bus/vdev: add device matching field driver
Gaetan Rivet
gaetan.rivet at 6wind.com
Fri Apr 13 15:22:33 CEST 2018
The vdev bus parses a field "driver", matching
a vdev driver name with one passed as follows:
"bus=vdev,driver=xxxx"
Signed-off-by: Gaetan Rivet <gaetan.rivet at 6wind.com>
---
drivers/bus/vdev/Makefile | 1 +
drivers/bus/vdev/vdev.c | 14 ++++++++++++--
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/bus/vdev/Makefile b/drivers/bus/vdev/Makefile
index 52728833c..db6bee98a 100644
--- a/drivers/bus/vdev/Makefile
+++ b/drivers/bus/vdev/Makefile
@@ -10,6 +10,7 @@ LIB = librte_bus_vdev.a
CFLAGS += -O3
CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -DALLOW_EXPERIMENTAL_API
# versioning export map
EXPORT_MAP := rte_bus_vdev_version.map
diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c
index 5bb87af28..84192d79b 100644
--- a/drivers/bus/vdev/vdev.c
+++ b/drivers/bus/vdev/vdev.c
@@ -389,10 +389,12 @@ vdev_unplug(struct rte_device *dev)
}
enum vdev_params {
+ RTE_VDEV_PARAMS_DRIVER,
RTE_VDEV_PARAMS_MAX,
};
static const char * const vdev_params_keys[] = {
+ [RTE_VDEV_PARAMS_DRIVER] = "driver",
[RTE_VDEV_PARAMS_MAX] = NULL,
};
@@ -401,9 +403,17 @@ vdev_dev_match(const struct rte_device *dev,
const void *_kvlist)
{
const struct rte_kvargs *kvlist = _kvlist;
+ const struct rte_vdev_device *vdev;
- (void) kvlist;
- (void) dev;
+ if (kvlist == NULL)
+ /* Empty string matches everything. */
+ return 0;
+ vdev = RTE_DEV_TO_VDEV_CONST(dev);
+ /* if any field does not match. */
+ if (rte_kvargs_process(kvlist, "driver",
+ rte_kvargs_strcmp,
+ (void *)(intptr_t)vdev->device.driver->name))
+ return -1;
return 0;
}
--
2.11.0
More information about the dev
mailing list