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 1/2] net/virtio: refactor devargs parsing
Date: Mon, 20 Jan 2020 17:16:02 +0300 [thread overview]
Message-ID: <20200120141603.18719-2-i.dyukov@samsung.com> (raw)
In-Reply-To: <20200120141603.18719-1-i.dyukov@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 | 32 +++++++++++++++++++++---------
1 file changed, 23 insertions(+), 9 deletions(-)
diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index 044eb10a7..d6ccbd7b2 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,15 @@ 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) {
+ 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 +2000,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
next prev parent reply other threads:[~2020-01-20 14:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20200120141733eucas1p230624b7ac81aab9347cd1aec9cc059e0@eucas1p2.samsung.com>
2020-01-20 14:16 ` [dpdk-dev] net/virtio: add link speed devarg Ivan Dyukov
[not found] ` <CGME20200120141757eucas1p268f4c94063dfe05186314ed9ee00e10a@eucas1p2.samsung.com>
2020-01-20 14:16 ` Ivan Dyukov [this message]
[not found] ` <CGME20200120141803eucas1p237734f0e71549561006618f4c8ee637e@eucas1p2.samsung.com>
2020-01-20 14:16 ` [dpdk-dev] [PATCH 2/2] " 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=20200120141603.18719-2-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).