From: Thomas Monjalon Date: Tue, 23 Oct 2018 08:28:36 +0000 (+0200) Subject: bus/vdev: add iteration filter on name X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=2c29f879f2e06a792b5ee280cb0fe522d924f5b0;p=dpdk.git bus/vdev: add iteration filter on name A virtual device can be matched with following syntax: bus=vdev,name=X Signed-off-by: Thomas Monjalon Reviewed-by: Andrew Rybchenko --- diff --git a/drivers/bus/vdev/vdev_params.c b/drivers/bus/vdev/vdev_params.c index da270f2ec1..6f74704d1c 100644 --- a/drivers/bus/vdev/vdev_params.c +++ b/drivers/bus/vdev/vdev_params.c @@ -2,6 +2,8 @@ * Copyright 2018 Gaëtan Rivet */ +#include + #include #include #include @@ -11,10 +13,12 @@ #include "vdev_private.h" enum vdev_params { + RTE_VDEV_PARAM_NAME, RTE_VDEV_PARAM_MAX, }; static const char * const vdev_params_keys[] = { + [RTE_VDEV_PARAM_NAME] = "name", [RTE_VDEV_PARAM_MAX] = NULL, }; @@ -22,10 +26,21 @@ static int vdev_dev_match(const struct rte_device *dev, const void *_kvlist) { + int ret; const struct rte_kvargs *kvlist = _kvlist; + char *name; + + /* cannot pass const dev->name to rte_kvargs_process() */ + name = strdup(dev->name); + if (name == NULL) + return -1; + ret = rte_kvargs_process(kvlist, + vdev_params_keys[RTE_VDEV_PARAM_NAME], + rte_kvargs_strcmp, name); + free(name); + if (ret != 0) + return -1; - (void) kvlist; - (void) dev; return 0; }