DPDK patches and discussions
 help / color / mirror / Atom feed
From: Xueming Li <xuemingl@nvidia.com>
To: <dev@dpdk.org>
Cc: <xuemingl@nvidia.com>, Lior Margalit <lmargalit@nvidia.com>,
	<olivier.matz@6wind.com>, Parav Pandit <parav@nvidia.com>,
	David Marchand <david.marchand@redhat.com>,
	Ray Kinsella <mdr@ashroe.eu>
Subject: [PATCH v2] kvargs: fix device iterator match from arguments
Date: Wed, 24 Nov 2021 18:17:40 +0800	[thread overview]
Message-ID: <20211124101740.3479061-1-xuemingl@nvidia.com> (raw)
In-Reply-To: <20211122061250.3220823-1-xuemingl@nvidia.com>

Device iterator RTE_DEV_FOREACH() failed to return devices from
classifier like "class=vdpa", because matching name from empty kvargs
returns no result. If device name not specified in kvargs, the function
should iterate all devices.

This patch allows empty devargs or devargs without name specified.

Fixes: 6aebb942907d ("kvargs: add function to get from key and value")
Cc: olivier.matz@6wind.com

Signed-off-by: Xueming Li <xuemingl@nvidia.com>
---
21.11 specific bug, no copy to stable.org
---
 drivers/bus/auxiliary/auxiliary_params.c | 14 +++++++++-----
 drivers/bus/vdev/vdev_params.c           | 14 +++++++++-----
 2 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/drivers/bus/auxiliary/auxiliary_params.c b/drivers/bus/auxiliary/auxiliary_params.c
index a9c7853ed1d..9cbc1f7c777 100644
--- a/drivers/bus/auxiliary/auxiliary_params.c
+++ b/drivers/bus/auxiliary/auxiliary_params.c
@@ -26,11 +26,15 @@ auxiliary_dev_match(const struct rte_device *dev,
 {
 	const struct rte_kvargs *kvlist = _kvlist;
 	const char *key = auxiliary_params_keys[RTE_AUXILIARY_PARAM_NAME];
-
-	if (rte_kvargs_get_with_value(kvlist, key, dev->name) == NULL)
-		return -1;
-
-	return 0;
+	const char *name;
+
+	if (kvlist == NULL)
+		return 0;
+	name = rte_kvargs_get(kvlist, key);
+	if (name == NULL)
+		/* Iterate all devices if name not specified. */
+		return 0;
+	return strcmp(name, dev->name);
 }
 
 void *
diff --git a/drivers/bus/vdev/vdev_params.c b/drivers/bus/vdev/vdev_params.c
index 37d95395e7a..b4baecb7c0d 100644
--- a/drivers/bus/vdev/vdev_params.c
+++ b/drivers/bus/vdev/vdev_params.c
@@ -28,11 +28,15 @@ vdev_dev_match(const struct rte_device *dev,
 {
 	const struct rte_kvargs *kvlist = _kvlist;
 	const char *key = vdev_params_keys[RTE_VDEV_PARAM_NAME];
-
-	if (rte_kvargs_get_with_value(kvlist, key, dev->name) == NULL)
-		return -1;
-
-	return 0;
+	const char *name;
+
+	if (kvlist == NULL)
+		return 0;
+	name = rte_kvargs_get(kvlist, key);
+	if (name == NULL)
+		/* Iterate all devices if name not specified. */
+		return 0;
+	return strcmp(name, dev->name);
 }
 
 void *
-- 
2.34.0


  parent reply	other threads:[~2021-11-24 10:18 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-22  6:12 [PATCH] " Xueming Li
2021-11-23 10:25 ` Olivier Matz
2021-11-23 11:25   ` Xueming(Steven) Li
2021-11-23 12:31     ` Olivier Matz
2021-11-23 12:49       ` Xueming(Steven) Li
2021-11-23 20:02         ` Olivier Matz
2021-11-24 10:21           ` Xueming(Steven) Li
2021-11-24 10:17 ` Xueming Li [this message]
2021-11-24 11:07   ` [PATCH v2] " Olivier Matz
2021-11-24 11:19     ` Xueming(Steven) Li
2021-11-24 11:02 ` [PATCH v3] bus: " Olivier Matz
2021-11-24 11:31   ` Xueming(Steven) Li
2021-11-24 11:43     ` Xueming(Steven) Li
2021-11-24 12:14       ` Olivier Matz
2021-11-24 12:45 ` [PATCH v4] " Olivier Matz
2021-11-24 13:00   ` Xueming(Steven) Li
2021-11-24 13:44     ` David Marchand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211124101740.3479061-1-xuemingl@nvidia.com \
    --to=xuemingl@nvidia.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=lmargalit@nvidia.com \
    --cc=mdr@ashroe.eu \
    --cc=olivier.matz@6wind.com \
    --cc=parav@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).