From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 98C04A0588; Thu, 16 Apr 2020 07:53:45 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 570281DAA3; Thu, 16 Apr 2020 07:53:30 +0200 (CEST) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by dpdk.org (Postfix) with ESMTP id 9CA841DAAF for ; Thu, 16 Apr 2020 07:53:28 +0200 (CEST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20200416055327euoutp0177efd6473ad97bcb1432400c1cf45205~GNwO2uDXU2038620386euoutp01h for ; Thu, 16 Apr 2020 05:53:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20200416055327euoutp0177efd6473ad97bcb1432400c1cf45205~GNwO2uDXU2038620386euoutp01h DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1587016407; bh=K7Mh/Yk74ODK2aSKPKJtcnVsJ6EOdbU5DTdVk7Usf7A=; h=From:To:Subject:Date:In-Reply-To:References:From; b=t2iQ/sZpzczOWFAYdo6HtM7r/wisykRZ1nH0HiN2h6GavKBfFBriQlOkjlmh4c4FI QeLTuhYEq0Fa7S4jG8l5ZA0yiiXXr3l/ahQUIwafC5kdH3/mRCvJKvlJmkxYYba061 XuS0/yp2Jaw8f6SCYFZMbAdWoCxXn4ejoYElI5PA= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20200416055327eucas1p12f9657076ef50f370c343acb5b3de8bb~GNwOZXXl51679516795eucas1p10; Thu, 16 Apr 2020 05:53:27 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 8D.91.61286.7D2F79E5; Thu, 16 Apr 2020 06:53:27 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20200416055326eucas1p266592b624ab220d6b259210b5e413e01~GNwOB62CF1938419384eucas1p2P; Thu, 16 Apr 2020 05:53:26 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200416055326eusmtrp18bfeabf934e713dbb3526035606ac399~GNwOBRj1Z2642726427eusmtrp1f; Thu, 16 Apr 2020 05:53:26 +0000 (GMT) X-AuditID: cbfec7f2-ef1ff7000001ef66-19-5e97f2d78f41 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 81.FE.08375.6D2F79E5; Thu, 16 Apr 2020 06:53:26 +0100 (BST) Received: from idyukov.rnd.samsung.ru (unknown [106.109.129.29]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200416055326eusmtip24677ce1fd5c03a3991ddff3a2623df77~GNwNcf4UA2328223282eusmtip29; Thu, 16 Apr 2020 05:53:26 +0000 (GMT) From: Ivan Dyukov To: dev@dpdk.org, maxime.coquelin@redhat.com, i.dyukov@samsung.com, v.kuramshin@samsung.com, amorenoz@redhat.com, zhihong.wang@intel.com, xiaolong.ye@intel.com, mb@smartsharesystems.com Date: Thu, 16 Apr 2020 08:53:02 +0300 Message-Id: <20200416055309.19679-3-i.dyukov@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200416055309.19679-1-i.dyukov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrMIsWRmVeSWpSXmKPExsWy7djP87rXP02PM9j8k9+idccDFot3n7Yz Wcy61MRucaxzD4tF36+rjBanb25mt/jzxtRi88VJTA4cHr8WLGX1WLznJZPH+31X2Tz6tqxi 9Dj1qJs5gDWKyyYlNSezLLV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bRM1nRokry2eBJdgENCROd8xjAkmICBxnlOid9Z8JJCEsYCsx484bdhCb RUBVYt3jpWANvAKWElf2/GaCmCovsXrDAbA4p4CVxIHuM2BxIYEMicaOY0wTGHkXMDKsYhRJ LS3OTc8tNtQrTswtLs1L10vOz93ECAzTbcd+bt7BeGlj8CFGAQ5GJR7ejtfT4oRYE8uKK3MP MUpwMCuJ8O7wnx4nxJuSWFmVWpQfX1Sak1p8iNEU6KiJzFKiyfnAGMoriTc0NTS3sDQ0NzY3 NrNQEuftEDgYIySQnliSmp2aWpBaBNPHxMEp1cAo/nKXvE6cmUzbguYNS/bo/MxO6vnoHNr4 4GXbBHZZwaZMi1nMDKxZXnvffTR8xlL6TuHMIoZ/Mb9ZTxbddc7f9XuqsHrDymc/JnPP2n1/ leAq7nML+Q5tLsyam3Hr3F32iTb8sd90uSSnL7patl5hy/3yL+0quZqySabq7T6fwn/fVl0l eTBdiaU4I9FQi7moOBEA2KaWTGkCAAA= X-CMS-MailID: 20200416055326eucas1p266592b624ab220d6b259210b5e413e01 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200416055326eucas1p266592b624ab220d6b259210b5e413e01 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200416055326eucas1p266592b624ab220d6b259210b5e413e01 References: <20191212085012.9170-1-i.dyukov@samsung.com> <20200416055309.19679-1-i.dyukov@samsung.com> Subject: [dpdk-dev] [PATCH v11 2/6] net/virtio: refactor devargs parsing X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" refactor vdpa specific devargs parsing to more generic way Signed-off-by: Ivan Dyukov --- drivers/net/virtio/virtio_ethdev.c | 34 +++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index e98a76ea2..60195ab3c 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -1957,16 +1957,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"; @@ -1982,12 +1984,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); @@ -1997,8 +2003,16 @@ 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_INIT_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