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 76FF5A055F; Thu, 27 Feb 2020 15:20:21 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 51ACD1BFCC; Thu, 27 Feb 2020 15:20:21 +0100 (CET) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by dpdk.org (Postfix) with ESMTP id 9D7FB1F1C for ; Thu, 27 Feb 2020 15:20:19 +0100 (CET) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20200227142019euoutp01c064624e03148adabd545f726937787b~3SDyT8war1458814588euoutp01P for ; Thu, 27 Feb 2020 14:20:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20200227142019euoutp01c064624e03148adabd545f726937787b~3SDyT8war1458814588euoutp01P DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1582813219; bh=RQMv9cuuvP5u8e0+uNl+O6QooxHPW/YCpJsvHBfzTqw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Bc/WmQkuolL1BnOSqT4Vf65AWBSQ61+i/1HG0hAPIxPGPzdMiEqdLpRFmAj0+G/+6 OEN0Y6fphELAhw1fTwTRAAyxwmPlA11I8DQC//8auDjWyoCK2BMwJii6/A7Jp/P6Pu xN2MBy/3JUfP67ReiUzkkG1B/KMmmH6e3RuDovFI= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20200227142018eucas1p278922e489e4bd5bb14cd77dfac6f3784~3SDyGiSLQ1636516365eucas1p2M; Thu, 27 Feb 2020 14:20:18 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 56.2B.60698.220D75E5; Thu, 27 Feb 2020 14:20:18 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20200227142018eucas1p1fd60eac2a28295736ee07a3730cb5a53~3SDxdI2IW1839018390eucas1p1G; Thu, 27 Feb 2020 14:20:18 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200227142018eusmtrp25fc6bd582d8db1b3429a86727474812a~3SDxbWuEQ2814228142eusmtrp2N; Thu, 27 Feb 2020 14:20:18 +0000 (GMT) X-AuditID: cbfec7f5-a0fff7000001ed1a-5e-5e57d022aae8 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 20.69.07950.220D75E5; Thu, 27 Feb 2020 14:20:18 +0000 (GMT) Received: from idyukov.rnd.samsung.ru (unknown [106.109.129.29]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200227142017eusmtip2335c0f8668d76194d1d24c72fec2587f~3SDw8JZGN0759407594eusmtip22; Thu, 27 Feb 2020 14:20:17 +0000 (GMT) From: Ivan Dyukov To: dev@dpdk.org, maxime.coquelin@redhat.com, tiwei.bie@intel.com, amorenoz@redhat.com, zhihong.wang@intel.com, xiaolong.ye@intel.com Cc: Ivan Dyukov Date: Thu, 27 Feb 2020 17:16:13 +0300 Message-Id: <20200227141840.15835-2-i.dyukov@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200227141840.15835-1-i.dyukov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrGIsWRmVeSWpSXmKPExsWy7djP87pKF8LjDL6t0bNo3fGAxeLdp+1M FrMuNbFbHOvcw2KxteE/k8WfN6YWmy9OYnJg9/i1YCmrx+I9L5k83u+7yubRt2UVYwBLFJdN SmpOZllqkb5dAlfG8k8T2QuWC1Z8n/GMsYGxka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Yx5Yr4hAP6PExl+/wRqYBdQkPvS8ZwGxhQVsJA49XwBmswio Siw9+wZsEK+ApUTrn79QC+QlVm84AGZzClhJzG95xwixLF7i4/fz7BMY+RYwMqxiFEktLc5N zy020itOzC0uzUvXS87P3cQIDNRtx35u2cHY9S74EKMAB6MSD6/HtvA4IdbEsuLK3EOMEhzM SiK8G7+GxgnxpiRWVqUW5ccXleakFh9iNAU6aiKzlGhyPjCK8kriDU0NzS0sDc2NzY3NLJTE eTsEDsYICaQnlqRmp6YWpBbB9DFxcEo1MKqE+rrOStrcXrWJWVleuLr8v/QGzkUPlLnnfZ4T /sd+nlbR79oZvhF/c/4v4nu9x/xG4IM3x3sWLWoV2/LtrL/E34WznL1NOybe9hdfGtwx6Vsf j67pTAWjHLulec/cXp553uh793CoQr2IHMOH92UrFkn9V7gedGF7o5r8Z0fBQkFHlc5IDiWW 4oxEQy3mouJEAI9vofZqAgAA X-CMS-MailID: 20200227142018eucas1p1fd60eac2a28295736ee07a3730cb5a53 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200227142018eucas1p1fd60eac2a28295736ee07a3730cb5a53 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200227142018eucas1p1fd60eac2a28295736ee07a3730cb5a53 References: <20200226075503.GA108150@intel.com> <20200227141840.15835-1-i.dyukov@samsung.com> Subject: [dpdk-dev] [PATCH v5 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 | 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 044eb10a7..d2c7f8c61 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,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_INIG_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