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 17467A0526; Mon, 20 Jan 2020 18:11:13 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 85AA61BFC9; Mon, 20 Jan 2020 18:05:32 +0100 (CET) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by dpdk.org (Postfix) with ESMTP id D8B611BF80 for ; Mon, 20 Jan 2020 18:05:30 +0100 (CET) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20200120170530euoutp02e30a1485438ea110d8884b8291772e3d~rpzKoBQNX0444104441euoutp021 for ; Mon, 20 Jan 2020 17:05:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20200120170530euoutp02e30a1485438ea110d8884b8291772e3d~rpzKoBQNX0444104441euoutp021 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1579539930; bh=0XjvQCEiVj60+UBTAarvishZLNeMmePERL7qVRhbsj8=; h=From:To:Cc:Subject:Date:References:From; b=ffwzYGigcnU9QBz/mbhCljFR7PPOMlxD94+VQCYAI2kaGDpDLlYMO/yMSjxiOZJam qt6ya+Awq1GOArrslepA9W+2xWT+0WP3wCcGQ8bxW+9I9JZ7ypeBUhTun50m67K1nc BJQ1Dm+62pfu82hxdsyW63O/L5P/H6f+XmJ+e/u0= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20200120170529eucas1p2c21e3e62258e2f4dd409fcda94acdea3~rpzKBag5X1067410674eucas1p2X; Mon, 20 Jan 2020 17:05:29 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 1A.EE.60698.9DDD52E5; Mon, 20 Jan 2020 17:05:29 +0000 (GMT) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20200120170529eucas1p2d319a567923ee26ba0bd34a122127fac~rpzJxpGeh1067010670eucas1p22; Mon, 20 Jan 2020 17:05:29 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200120170529eusmtrp1a8cab6ea93b9374fb4155d4d7dfa7eb3~rpzJxE7lA3138331383eusmtrp1j; Mon, 20 Jan 2020 17:05:29 +0000 (GMT) X-AuditID: cbfec7f5-a0fff7000001ed1a-11-5e25ddd9b60d Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 5A.66.08375.9DDD52E5; Mon, 20 Jan 2020 17:05:29 +0000 (GMT) Received: from idyukov.rnd.samsung.ru (unknown [106.109.129.29]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200120170529eusmtip234b8cd76c1629d0ba31f03b24255adad~rpzJcEjeN2293622936eusmtip27; Mon, 20 Jan 2020 17:05:29 +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 20:05:19 +0300 Message-Id: <20200120170520.24192-1-i.dyukov@samsung.com> X-Mailer: git-send-email 2.17.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrGIsWRmVeSWpSXmKPExsWy7djP87o376rGGfw/qGHx7tN2JotZl5rY LY517mGx2Nrwn8mBxePXgqWsHov3vGTyeL/vKptH35ZVjAEsUVw2Kak5mWWpRfp2CVwZ9+bu Zy1YI1ixee8H5gbGRr4uRg4OCQETiU09ZV2MnBxCAisYJQ5c8+1i5AKyvzBKTFjbxQrhfGaU aN7zmxGkCqThW+cUZojEckaJ69MXskA4XxklPm5dywRSxSagIX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9tDD7E KMDBqMTD6zBNNU6INbGsuDL3EKMEB7OSCO+CJqAQb0piZVVqUX58UWlOavEhRlOg5ROZpUST 84Ehn1cSb2hqaG5haWhubG5sZqEkztshcDBGSCA9sSQ1OzW1ILUIpo+Jg1OqgXFO97p/rzUc nt7NnVN92vIfy8SCz147uW5G/RQV+Gw3I7/dwe3M2qUfVhu2LCo8bWl1wpzplmZ2yGnrBLvH ed+53BjmCTsxfPhz+oaf68r8TzNfqviaVWtGzxROMn/ud5r/sICHUd6bqNPGBrxCrQHqntv8 6zWY9RK3ymvLrX4zM4bp0925ekosxRmJhlrMRcWJAMvt+wpBAgAA X-CMS-MailID: 20200120170529eucas1p2d319a567923ee26ba0bd34a122127fac X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200120170529eucas1p2d319a567923ee26ba0bd34a122127fac X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200120170529eucas1p2d319a567923ee26ba0bd34a122127fac References: Subject: [dpdk-dev] [PATCH v2 1/2] 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