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 181BAA0562; Mon, 30 Mar 2020 09:58:35 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 893791C065; Mon, 30 Mar 2020 09:58:30 +0200 (CEST) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by dpdk.org (Postfix) with ESMTP id 367322C15 for ; Mon, 30 Mar 2020 09:58:29 +0200 (CEST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20200330075828euoutp02de3614b160cc8b3c49d55f4f7bf448f1~BBfh6WOpt0127201272euoutp02C for ; Mon, 30 Mar 2020 07:58:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20200330075828euoutp02de3614b160cc8b3c49d55f4f7bf448f1~BBfh6WOpt0127201272euoutp02C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1585555108; bh=mHhQ03gcfc8lc4HgXNspAnL6+ptFrufucmW+PD+kjK4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=mBYi22ehSRlurWDKbhvOXfvKOCAK/9gH5WMaBqOCUxG8Y5Y9koX9IGIywYngbt/z7 /z+85OK13jEsPUcsVJJwFKie0Rn9rGLPwcSRQl2zngxVnzeJmXrhUuFgkfJENw0MHe 28CbrGfjC3hTKzePkdByAIRacSFfHumb4aJ6x1Qw= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20200330075828eucas1p23897ee1eb088c143c2d8a3ba144013be~BBfhneVwI0503405034eucas1p29; Mon, 30 Mar 2020 07:58:28 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id F5.3B.60698.4A6A18E5; Mon, 30 Mar 2020 08:58:28 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20200330075827eucas1p2b4718ecf08cc7d20227befb4ce3a5675~BBfhUtNOl3250232502eucas1p2k; Mon, 30 Mar 2020 07:58:27 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200330075827eusmtrp1a054e43566b76f20476da7f26b303be0~BBfhUB-Ad2812428124eusmtrp1U; Mon, 30 Mar 2020 07:58:27 +0000 (GMT) X-AuditID: cbfec7f5-a0fff7000001ed1a-b4-5e81a6a4e207 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id A3.DF.07950.3A6A18E5; Mon, 30 Mar 2020 08:58:27 +0100 (BST) Received: from idyukov.rnd.samsung.ru (unknown [106.109.129.29]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200330075827eusmtip2dcdbd5753d7d0a6ab95e675f6b16cab3~BBfg1Bz0n0188301883eusmtip2x; Mon, 30 Mar 2020 07:58:27 +0000 (GMT) From: Ivan Dyukov To: dev@dpdk.org, maxime.coquelin@redhat.com, i.dyukov@samsung.com, tiwei.bie@intel.com, amorenoz@redhat.com, zhihong.wang@intel.com, xiaolong.ye@intel.com Date: Mon, 30 Mar 2020 10:57:58 +0300 Message-Id: <20200330075814.6857-2-i.dyukov@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200330075814.6857-1-i.dyukov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrBIsWRmVeSWpSXmKPExsWy7djP87pLljXGGez6zGvRuuMBi8W7T9uZ LGZdamK3ONa5h8Via8N/Jos/b0wtNl+cxOTA7vFrwVJWj8V7XjJ5vN93lc2jb8sqxgCWKC6b lNSczLLUIn27BK6MNwd+MxYsF6xoX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BL9l1vZQBLCAjYSe+e0sYLYLAKqEtP+PAOzeQUs JG5PeQM1VV5i9YYDYDangKXEmYlbmUBsIYF0icbbHUwTGHkXMDKsYhRJLS3OTc8tNtIrTswt Ls1L10vOz93ECAzIbcd+btnB2PUu+BCjAAejEg/vjK0NcUKsiWXFlbmHGCU4mJVEeNn8gUK8 KYmVValF+fFFpTmpxYcYTYGOmsgsJZqcD4yWvJJ4Q1NDcwtLQ3Njc2MzCyVx3g6BgzFAZySW pGanphakFsH0MXFwSjUwKqol2n0Is/Oy/fencvmOqOSQ+fpbgoTkmZVzL3WcTVI2Fu/TVC29 fULchYefhWvtjbVM/o9mbd/G/y+uUyN2Qqa+YrK17TbRLutui4P1y17MN7Uoyw1a4W92cf2/ 0h1buJXuCwiv+ZCk/+ywwncrbcnYSr/+bP5L87j3aVaLqGlcXVG2wVGJpTgj0VCLuag4EQB+ oAF8XgIAAA== X-CMS-MailID: 20200330075827eucas1p2b4718ecf08cc7d20227befb4ce3a5675 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200330075827eucas1p2b4718ecf08cc7d20227befb4ce3a5675 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200330075827eucas1p2b4718ecf08cc7d20227befb4ce3a5675 References: <20191212085012.9170-1-i.dyukov@samsung.com> <20200330075814.6857-1-i.dyukov@samsung.com> Subject: [dpdk-dev] [PATCH v8 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