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 AC68BA0577; Mon, 6 Apr 2020 10:59:21 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C4CE31BEE3; Mon, 6 Apr 2020 10:59:16 +0200 (CEST) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by dpdk.org (Postfix) with ESMTP id A97151BEE1 for ; Mon, 6 Apr 2020 10:59:15 +0200 (CEST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20200406085915euoutp02fcbe0e14ea0b67ab514a4157945889dc~DL1l4I8rj1702017020euoutp02A for ; Mon, 6 Apr 2020 08:59:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20200406085915euoutp02fcbe0e14ea0b67ab514a4157945889dc~DL1l4I8rj1702017020euoutp02A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1586163555; bh=mHhQ03gcfc8lc4HgXNspAnL6+ptFrufucmW+PD+kjK4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=kfCo4/GCuHzudWxeisYIBp9itdRvEKj4RdaYZ0l62ecV/8mIx6VmtVzyg0KOcVrIF ZWJJGEfjKe7ZUMn5aZeqmLuhSKiBW+JL7mACpmrrdWv6TsUpH8bFY6kvXZAEdN9W/1 8H5hWP+tGwxvnM8DHCx7CxqGkxiFdHpjsoL6y7z4= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20200406085914eucas1p2d28fbdf29191ebdccb922064cce5dbfc~DL1lqM9LR2195221952eucas1p2T; Mon, 6 Apr 2020 08:59:14 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 7F.27.61286.26FEA8E5; Mon, 6 Apr 2020 09:59:14 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20200406085914eucas1p2e20a40d2cf7a3536fff12f44a75164bb~DL1lSUGnm2043520435eucas1p2a; Mon, 6 Apr 2020 08:59:14 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200406085914eusmtrp1756c345d2fc51ed13520a9146cf521a0~DL1lRtNH51258512585eusmtrp1A; Mon, 6 Apr 2020 08:59:14 +0000 (GMT) X-AuditID: cbfec7f2-f0bff7000001ef66-c1-5e8aef62ce71 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 9A.FC.08375.26FEA8E5; Mon, 6 Apr 2020 09:59:14 +0100 (BST) Received: from idyukov.rnd.samsung.ru (unknown [106.109.129.29]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200406085913eusmtip2c9a583456d7f1fcac0ff8b0c6a3ad991~DL1kve0qN3064030640eusmtip2b; Mon, 6 Apr 2020 08:59:13 +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: Mon, 6 Apr 2020 11:57:59 +0300 Message-Id: <20200406085855.25773-2-i.dyukov@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200406085855.25773-1-i.dyukov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrAIsWRmVeSWpSXmKPExsWy7djP87pJ77viDDa/N7Ro3fGAxeLdp+1M FrMuNbFbHOvcw2LR9+sqo8Xpm5vZLf68MbXYfHESkwOHx68FS1k9Fu95yeTxft9VNo++LasY PU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L1E+Yu Rk4gU1jiz7UuNoiaz4wSu87MZQdJsAloSJzumMcEkhAROM4o0TvrPxNIs7CAjcTzuVogNSwC qhKHP78Eq+cVsJRY86CJDWKovMTqDQfAFnAKWElM2fOXBaRVSCBDYuPDvAmMvAsYGVYxiqSW Fuem5xYb6hUn5haX5qXrJefnbmIEBui2Yz8372C8tDH4EKMAB6MSDy/D7c44IdbEsuLK3EOM EhzMSiK8Ur1AId6UxMqq1KL8+KLSnNTiQ4ymQDdNZJYSTc4HRk9eSbyhqaG5haWhubG5sZmF kjhvh8DBGCGB9MSS1OzU1ILUIpg+Jg5OqQZG7TU29a/NvSx/qfKmXlTIfXZqcs4JYyO5dRP+ WDAafL5dv0np5Fn79M1beW7czf9iklA2daXFi0NulrtuqGjvPKb52GST7I4n8Ul2P+VYNd4X r5X8fFZ05R6Z60tdigLF5jBsay04bW/Lef++2R93u2B2x57bV+Q5LvC+/NCV7+Iie2PhTcWl SizFGYmGWsxFxYkAwWVrn2YCAAA= X-CMS-MailID: 20200406085914eucas1p2e20a40d2cf7a3536fff12f44a75164bb X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200406085914eucas1p2e20a40d2cf7a3536fff12f44a75164bb X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200406085914eucas1p2e20a40d2cf7a3536fff12f44a75164bb References: <20191212085012.9170-1-i.dyukov@samsung.com> <20200406085855.25773-1-i.dyukov@samsung.com> Subject: [dpdk-dev] [PATCH v9 1/5] 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 f9d0ea70d..870ff7801 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