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 179C5A0563; Wed, 15 Apr 2020 22:05:01 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id CDFDD1DA16; Wed, 15 Apr 2020 22:04:45 +0200 (CEST) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by dpdk.org (Postfix) with ESMTP id 732AC1DA09 for ; Wed, 15 Apr 2020 22:04:43 +0200 (CEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20200415200442euoutp0175af58e9e3894421b084bea0a3222e3e~GFuL-wwzO2184721847euoutp018 for ; Wed, 15 Apr 2020 20:04:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20200415200442euoutp0175af58e9e3894421b084bea0a3222e3e~GFuL-wwzO2184721847euoutp018 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1586981082; bh=K7Mh/Yk74ODK2aSKPKJtcnVsJ6EOdbU5DTdVk7Usf7A=; h=From:To:Subject:Date:In-Reply-To:References:From; b=cqBcVQcodAbDEGes4YgxYQ/hDkts/QqaSs5Srj+/bBqilRXqmy3XA1kKvzk0fKIrd 0Fc25EcS7Gwo5+bsMp3n5rVfH82mZivh4HYOg4DtyDdZKMo5Vzp9kNMFK0cP6G6awu fAp8uX28UjzszQS7x7Py6ee3p711Ej6rV/y9gYXs= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20200415200442eucas1p190d7b7654dbe07c777690322e97f9ea7~GFuLvrvq41271912719eucas1p1O; Wed, 15 Apr 2020 20:04:42 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id CE.49.60698.AD8679E5; Wed, 15 Apr 2020 21:04:42 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20200415200441eucas1p2e08269b40c2bfbda7a1c44e1cf984248~GFuK5Ku8A1479414794eucas1p2b; Wed, 15 Apr 2020 20:04:41 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200415200441eusmtrp1a9c9214664d1f4d4c504af554b88840f~GFuK4kyqy2198521985eusmtrp1j; Wed, 15 Apr 2020 20:04:41 +0000 (GMT) X-AuditID: cbfec7f5-a0fff7000001ed1a-18-5e9768daaec1 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id BA.C8.08375.9D8679E5; Wed, 15 Apr 2020 21:04:41 +0100 (BST) Received: from idyukov.rnd.samsung.ru (unknown [106.109.129.29]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200415200441eusmtip14167655a66ce2037492192b9bc5ffbcc~GFuKWDOKW1865818658eusmtip1K; Wed, 15 Apr 2020 20:04:41 +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: Wed, 15 Apr 2020 23:03:54 +0300 Message-Id: <20200415200423.6410-3-i.dyukov@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200415200423.6410-1-i.dyukov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrMIsWRmVeSWpSXmKPExsWy7djPc7q3MqbHGTRuVrRo3fGAxeLdp+1M FrMuNbFbHOvcw2LR9+sqo8Xpm5vZLf68MbXYfHESkwOHx68FS1k9Fu95yeTxft9VNo++LasY PU496mYOYI3isklJzc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 10+YIWqEJf5c62KDqPnMKDH/9Q8mkASbgIbE6Y55YM0iAscZJXpn/QdLCAvYSmx9MResm0VA VWJv0yawOK+AhcT8PXNYIabKS6zecACshlPAUmLbpUNsILaQQLrEku4epgmMvAsYGVYxiqSW Fuem5xYb6hUn5haX5qXrJefnbmIEhum2Yz8372C8tDH4EKMAB6MSD2/H62lxQqyJZcWVuYcY JTiYlUR4d/hPjxPiTUmsrEotyo8vKs1JLT7EaAp01ERmKdHkfGAM5ZXEG5oamltYGpobmxub WSiJ83YIHIwBOiOxJDU7NbUgtQimj4mDU6qBUWit9rPOnINnfNqfvi2MtMn34lulvfjdrk9/ g2u9A0WUa/X+X2RXbZHg8ov7/VZO8cLV/6pfV3iGZKrxeuxi5drPu1ep+MZ328+OX2R6+Hab 7Fkdc3OJkKjXvSeVXoGH7GQqun0Cgwo7ldeLzZT8+ahHWynFooAz9tiMAJu/vDaM8gq3Z3or sRRnJBpqMRcVJwIAaCa+1mkCAAA= X-CMS-MailID: 20200415200441eucas1p2e08269b40c2bfbda7a1c44e1cf984248 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200415200441eucas1p2e08269b40c2bfbda7a1c44e1cf984248 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200415200441eucas1p2e08269b40c2bfbda7a1c44e1cf984248 References: <20191212085012.9170-1-i.dyukov@samsung.com> <20200415200423.6410-1-i.dyukov@samsung.com> Subject: [dpdk-dev] [PATCH v10 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