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 3D1B3A052A; Mon, 20 Jan 2020 15:18:02 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 086BE4C8B; Mon, 20 Jan 2020 15:18:02 +0100 (CET) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by dpdk.org (Postfix) with ESMTP id 0AE474C7B for ; Mon, 20 Jan 2020 15:18:00 +0100 (CET) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20200120141758euoutp01233f77d966266f54f0ff4b47edcf7caa~rng5GpPEw2454224542euoutp01S for ; Mon, 20 Jan 2020 14:17:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20200120141758euoutp01233f77d966266f54f0ff4b47edcf7caa~rng5GpPEw2454224542euoutp01S DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1579529878; bh=ZvgwGc/hgrRf1yhDWaK7m5NXU0jZ39n9Ps1RZ12I4sI=; h=From:To:Cc:Subject:Date:In-Reply-To:Reply-To:References:From; b=vjocyp+mfaLVAEkvFIJZ4ceN5FD19Q4OvoTDnE95Vtwy9G7GK7C+1MQtqKui9F/nM gu8tGhC/lrNlSp2YEW96RfHyWk9/xdN3mtoW/vEW37GqWViXOZ2xmw5VzmmuTpD6nV 4amat/+VRUFRmPSlydwEMjFLfEjyZm7cHse1EnzU= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20200120141758eucas1p27ddbc50dae965660dae07bd84ab21e1c~rng45MOLB1193711937eucas1p22; Mon, 20 Jan 2020 14:17:58 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id A6.B9.60698.696B52E5; Mon, 20 Jan 2020 14:17:58 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20200120141757eucas1p268f4c94063dfe05186314ed9ee00e10a~rng4gYt8a1194411944eucas1p2f; Mon, 20 Jan 2020 14:17:57 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200120141757eusmtrp29702878f73568bae43f23ea503538d8a~rng4f01UA2867528675eusmtrp2U; Mon, 20 Jan 2020 14:17:57 +0000 (GMT) X-AuditID: cbfec7f5-a0fff7000001ed1a-6b-5e25b696e848 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 9B.B1.07950.596B52E5; Mon, 20 Jan 2020 14:17:57 +0000 (GMT) Received: from idyukov.rnd.samsung.ru (unknown [106.109.129.29]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200120141757eusmtip24b7be511d25b22a93ae39d0f29b28f81~rng4GOlph1267412674eusmtip2c; Mon, 20 Jan 2020 14:17:57 +0000 (GMT) From: Ivan Dyukov To: dev@dpdk.org, maxime.coquelin@redhat.com, tiwei.bie@intel.com Cc: Ivan Dyukov Date: Mon, 20 Jan 2020 17:16:02 +0300 Message-Id: <20200120141603.18719-2-i.dyukov@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200120141603.18719-1-i.dyukov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrIIsWRmVeSWpSXmKPExsWy7djP87rTtqnGGUw6yWHx7tN2JotZl5rY LY517mGx2Nrwn8mBxePXgqWsHov3vGTyeL/vKptH35ZVjAEsUVw2Kak5mWWpRfp2CVwZd9b9 ZyqYIFgxt2s5UwPjZ94uRg4OCQETibtrkrsYuTiEBFYwShz/O5kZwvnCKPHu2UUWCOczo8S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vj38xQJi8wKFX176xwIx Xl5i9YYDYKs4Bawktsy/CmYLAdXcX72GBcKWk7g+/wvTBEb+BYwMqxhFUkuLc9Nzi430ihNz i0vz0vWS83M3MQIDdNuxn1t2MHa9Cz7EKMDBqMTD6zBNNU6INbGsuDL3EKMEB7OSCO+CJqAQ b0piZVVqUX58UWlOavEhRlOgAycyS4km5wOjJ68k3tDU0NzC0tDc2NzYzEJJnLdD4GCMkEB6 YklqdmpqQWoRTB8TB6dUA2OXhF1LRHHRx0X+V9Zp2XIV/giw/TDpQWnntVoNvmkXFdvCVVXZ UhcqvlgQfIn5Tpqy4eWkDQUdXAfCpUWYH3q+Slmn96DrwK2n66xkV0TMbVN3Ouuw+5HsFP19 rote2lQ9ddLxlrbbuX3JhNU+Fy4wqHwvyvy2mWt9stT8Y1rFNbFi3OfvJyuxFGckGmoxFxUn AgD920oYZgIAAA== X-CMS-MailID: 20200120141757eucas1p268f4c94063dfe05186314ed9ee00e10a X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200120141757eucas1p268f4c94063dfe05186314ed9ee00e10a X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200120141757eucas1p268f4c94063dfe05186314ed9ee00e10a References: <20200120141603.18719-1-i.dyukov@samsung.com> Subject: [dpdk-dev] [PATCH 1/2] net/virtio: refactor devargs parsing X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: i.dyukov@samsung.com 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 | 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