test: avoid hang if queues are full and Tx fails
[dpdk.git] / drivers / bus / vdev / vdev_params.c
index da270f2..3969faf 100644 (file)
@@ -2,6 +2,8 @@
  * Copyright 2018 GaĆ«tan Rivet
  */
 
+#include <string.h>
+
 #include <rte_dev.h>
 #include <rte_bus.h>
 #include <rte_kvargs.h>
 #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,
 };
 
@@ -23,9 +27,18 @@ vdev_dev_match(const struct rte_device *dev,
               const void *_kvlist)
 {
        const struct rte_kvargs *kvlist = _kvlist;
+       const char *key = vdev_params_keys[RTE_VDEV_PARAM_NAME];
+       const char *name;
+
+       /* no kvlist arg, all devices match */
+       if (kvlist == NULL)
+               return 0;
+
+       /* if key is present in kvlist and does not match, filter device */
+       name = rte_kvargs_get(kvlist, key);
+       if (name != NULL && strcmp(name, dev->name))
+               return -1;
 
-       (void) kvlist;
-       (void) dev;
        return 0;
 }