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 8BF48A0524; Tue, 25 Feb 2020 08:31:06 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9C1D71BFB6; Tue, 25 Feb 2020 08:31:03 +0100 (CET) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by dpdk.org (Postfix) with ESMTP id A357F1BFB5 for ; Tue, 25 Feb 2020 08:31:01 +0100 (CET) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20200225073100euoutp01195632f3584df82c67d7da1f6524d924~2lL16tHe22036720367euoutp01z for ; Tue, 25 Feb 2020 07:31:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20200225073100euoutp01195632f3584df82c67d7da1f6524d924~2lL16tHe22036720367euoutp01z DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1582615860; bh=0XjvQCEiVj60+UBTAarvishZLNeMmePERL7qVRhbsj8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ev1p3AIWHIZgFlmjrdUigN0wq+x2rr/Bwjm8xQzdv60UdPyMx88uZwbSiAWG8rjRP hO1jpryoAeH2OgVIzoeF0Mg/tCCV5fvWujbyXyDOIGPCCW8FoeYG9oKpGLwPkySC+P b3PUM95qaEuPpiCK9wQK1esQwiVgjb0nVAejzdwc= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20200225073100eucas1p1b782263e64927fa5416a01941a661a0a~2lL1xjupS0295602956eucas1p1N; Tue, 25 Feb 2020 07:31:00 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 1D.54.60679.43DC45E5; Tue, 25 Feb 2020 07:31:00 +0000 (GMT) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20200225073100eucas1p19097473ba40bb36c69b42e0479e42a00~2lL1YRBUu1977219772eucas1p1O; Tue, 25 Feb 2020 07:31:00 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200225073100eusmtrp1fe50022e755503bff3fe213e1d1f82e2~2lL1XmGdn2163421634eusmtrp12; Tue, 25 Feb 2020 07:31:00 +0000 (GMT) X-AuditID: cbfec7f4-0e5ff7000001ed07-46-5e54cd34308d Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 09.DA.08375.33DC45E5; Tue, 25 Feb 2020 07:30:59 +0000 (GMT) Received: from idyukov.rnd.samsung.ru (unknown [106.109.129.29]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200225073059eusmtip241bb1415a96380b2cbf6dd1637617f43~2lL05GWIy2085020850eusmtip2L; Tue, 25 Feb 2020 07:30:59 +0000 (GMT) From: Ivan Dyukov To: dev@dpdk.org, maxime.coquelin@redhat.com, tiwei.bie@intel.com, amorenoz@redhat.com, zhihong.wang@intel.com Cc: Ivan Dyukov Date: Tue, 25 Feb 2020 10:28:10 +0300 Message-Id: <20200225072813.9385-2-i.dyukov@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200225072813.9385-1-i.dyukov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrAIsWRmVeSWpSXmKPExsWy7djPc7omZ0PiDC4ekbBo3fGAxeLdp+1M FrMuNbFbHOvcw2KxteE/k8Xmi5OYHNg8fi1YyuqxeM9LJo/3+66yefRtWcUYwBLFZZOSmpNZ llqkb5fAlXFv7n7WgjWCFZv3fmBuYGzk62Lk5JAQMJH4d/c+cxcjF4eQw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ear7CA2s4CaxIee9ywgtrCAjUTLtRZWEJtFQFVi8Z67 YHFeAQuJD9N62SAWyEus3nAAbBmngKXE5meTwWwhgRyJFw+2sk1g5FvAyLCKUSS1tDg3PbfY UK84Mbe4NC9dLzk/dxMjMDy3Hfu5eQfjpY3BhxgFOBiVeHgl9gbHCbEmlhVX5h5ilOBgVhLh 9WYMihPiTUmsrEotyo8vKs1JLT7EaAp01ERmKdHkfGDs5JXEG5oamltYGpobmxubWSiJ83YI HIwREkhPLEnNTk0tSC2C6WPi4JRqYExtkXe/lrho87FfUUsPdjT9vPViQ0Zw65pasQfOr26z qh09Y7xj+lUZr6l5mxY08tV9Cz/wvT5J6Onhb5155QfXlPZOFrSVumE0/ZzAhDPVt+Z/ssk6 7Wh+TLzU1Gnt6U1ZV56VPv20gvUiT+uu2fmLjL+sXrcg8AuzCVctR6mNwf3SNsuMKw+UWIoz Eg21mIuKEwGx6jXJZQIAAA== X-CMS-MailID: 20200225073100eucas1p19097473ba40bb36c69b42e0479e42a00 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200225073100eucas1p19097473ba40bb36c69b42e0479e42a00 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200225073100eucas1p19097473ba40bb36c69b42e0479e42a00 References: <20200225072813.9385-1-i.dyukov@samsung.com> Subject: [dpdk-dev] [PATCH v4 1/4] 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 | 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