DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ivan Dyukov <i.dyukov@samsung.com>
To: dev@dpdk.org, maxime.coquelin@redhat.com, tiwei.bie@intel.com
Cc: Ivan Dyukov <i.dyukov@samsung.com>
Subject: [dpdk-dev] [PATCH v2 1/2] net/virtio: refactor devargs parsing
Date: Mon, 20 Jan 2020 20:05:19 +0300	[thread overview]
Message-ID: <20200120170520.24192-1-i.dyukov@samsung.com> (raw)
In-Reply-To: <CGME20200120170529eucas1p2d319a567923ee26ba0bd34a122127fac@eucas1p2.samsung.com>

refactor vdpa specific devargs parsing to more generic way

Signed-off-by: Ivan Dyukov <i.dyukov@samsung.com>
---
 drivers/net/virtio/virtio_ethdev.c | 35 +++++++++++++++++++++---------
 1 file changed, 25 insertions(+), 10 deletions(-)

diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index 044eb10a7..22323d9a5 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -1955,16 +1955,18 @@ eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev)
 }
 
 static int vdpa_check_handler(__rte_unused const char *key,
-		const char *value, __rte_unused void *opaque)
+		const char *value, void *ret_val)
 {
-	if (strcmp(value, "1"))
-		return -1;
+	if (strcmp(value, "1") == 0)
+		*(int *)ret_val = 1;
+	else
+		*(int *)ret_val = 0;
 
 	return 0;
 }
 
 static int
-vdpa_mode_selected(struct rte_devargs *devargs)
+virtio_dev_devargs_parse(struct rte_devargs *devargs, int *vdpa)
 {
 	struct rte_kvargs *kvlist;
 	const char *key = "vdpa";
@@ -1980,12 +1982,16 @@ vdpa_mode_selected(struct rte_devargs *devargs)
 	if (!rte_kvargs_count(kvlist, key))
 		goto exit;
 
-	/* vdpa mode selected when there's a key-value pair: vdpa=1 */
-	if (rte_kvargs_process(kvlist, key,
-				vdpa_check_handler, NULL) < 0) {
-		goto exit;
+	if (vdpa) {
+		/* vdpa mode selected when there's a key-value pair:
+		 * vdpa=1
+		 */
+		ret = rte_kvargs_process(kvlist, key,
+				vdpa_check_handler, vdpa);
+		if (ret  < 0)
+			goto exit;
 	}
-	ret = 1;
+
 
 exit:
 	rte_kvargs_free(kvlist);
@@ -1995,8 +2001,17 @@ vdpa_mode_selected(struct rte_devargs *devargs)
 static int eth_virtio_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 	struct rte_pci_device *pci_dev)
 {
+	int vdpa = 0;
+	int ret = 0;
+
+	ret = virtio_dev_devargs_parse(pci_dev->device.devargs, &vdpa);
+	if (ret < 0) {
+		PMD_DRV_LOG(ERR,
+			"devargs parsing is failed");
+		return ret;
+	}
 	/* virtio pmd skips probe if device needs to work in vdpa mode */
-	if (vdpa_mode_selected(pci_dev->device.devargs))
+	if (vdpa == 1)
 		return 1;
 
 	return rte_eth_dev_pci_generic_probe(pci_dev, sizeof(struct virtio_hw),
-- 
2.17.1


       reply	other threads:[~2020-01-20 17:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20200120170529eucas1p2d319a567923ee26ba0bd34a122127fac@eucas1p2.samsung.com>
2020-01-20 17:05 ` Ivan Dyukov [this message]
     [not found]   ` <CGME20200120170531eucas1p218252a80fbf9252baf21921f8c72fe82@eucas1p2.samsung.com>
2020-01-20 17:05     ` [dpdk-dev] [PATCH v2 2/2] net/virtio: add link speed devarg Ivan Dyukov
2020-01-29 10:10       ` Adrian Moreno
2020-02-06 14:22         ` Maxime Coquelin
2020-02-06 14:26           ` Adrian Moreno
2020-02-07 11:34             ` Ivan Dyukov

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=20200120170520.24192-1-i.dyukov@samsung.com \
    --to=i.dyukov@samsung.com \
    --cc=dev@dpdk.org \
    --cc=maxime.coquelin@redhat.com \
    --cc=tiwei.bie@intel.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).