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 5533DA0562; Sun, 29 Mar 2020 16:43:55 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 846FC1B949; Sun, 29 Mar 2020 16:43:37 +0200 (CEST) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by dpdk.org (Postfix) with ESMTP id 818A51BF9D for ; Sun, 29 Mar 2020 16:43:35 +0200 (CEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20200329144334euoutp017e3d2c67804fd90ad7833b0bceef9919~AzX8eYudk0271602716euoutp01Z for ; Sun, 29 Mar 2020 14:43:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20200329144334euoutp017e3d2c67804fd90ad7833b0bceef9919~AzX8eYudk0271602716euoutp01Z DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1585493014; bh=mHhQ03gcfc8lc4HgXNspAnL6+ptFrufucmW+PD+kjK4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=WQwmm+Klfh4EyJs+YD9V1UWa39f9kcEz9n1rPqQBmEtoTQlVPBx3ST2QqceMZ4PX0 /DykAWiEgpPIgPbVR9mo9lr6NrYTw3sEwkGtSal+ly/k8ABZ6y0BMpC4E/cAZvMv5D /2nkAMS7tFDCO/zt1iaVZtZxQrh1DyFmnbk2fSd8= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20200329144334eucas1p12d50fe8a686a82bfb9549fd17dda5fdd~AzX74CTc41538815388eucas1p1s; Sun, 29 Mar 2020 14:43:34 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 80.A3.60679.514B08E5; Sun, 29 Mar 2020 15:43:33 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20200329144333eucas1p2aa754e8de8f2ba01da656821c76eae9f~AzX7jhgxK0989809898eucas1p2m; Sun, 29 Mar 2020 14:43:33 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200329144333eusmtrp2ff7192be3230d62faa3b96aedde5fa67~AzX7i8FWW1656816568eusmtrp2T; Sun, 29 Mar 2020 14:43:33 +0000 (GMT) X-AuditID: cbfec7f4-0cbff7000001ed07-6a-5e80b415d2e7 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id C0.F7.07950.514B08E5; Sun, 29 Mar 2020 15:43:33 +0100 (BST) Received: from idyukov.rnd.samsung.ru (unknown [106.109.129.29]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200329144333eusmtip1ef117e8b2db6a3c0e2bd7418969aa684~AzX6-D6j10185501855eusmtip1Q; Sun, 29 Mar 2020 14:43:33 +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: Sun, 29 Mar 2020 17:42:47 +0300 Message-Id: <20200329144308.5103-2-i.dyukov@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200329144308.5103-1-i.dyukov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrFIsWRmVeSWpSXmKPExsWy7djP87qiWxriDLpfWFi07njAYvHu03Ym i1mXmtgtjnXuYbHY2vCfyeLPG1OLzRcnMTmwe/xasJTVY/Gel0we7/ddZfPo27KKMYAlissm JTUnsyy1SN8ugSvjzYHfjAXLBSta1/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jAckaJ/sutbCAJYQEbia8HZrKC2CwCqhILvzwAW8Ar YCHx4uFFqKnyEqs3HACzOQUsJSa8v8sIcUS6xMFdJ5gmMPIuYGRYxSiSWlqcm55bbKRXnJhb XJqXrpecn7uJERiQ24793LKDsetd8CFGAQ5GJR5eg8r6OCHWxLLiytxDjBIczEoivGz+DXFC vCmJlVWpRfnxRaU5qcWHGE2BjprILCWanA+MlrySeENTQ3MLS0NzY3NjMwslcd4OgYMxQGck lqRmp6YWpBbB9DFxcEo1MBZEpoXJPL/93MaW6cz8G6/Pci9dNF/VP2J1C5tob8w6g286DrFV k8ruFvao5U2Mn3rkXPq39Mpk+ZflxtwLt28XzU33u+dqu3b/Ov9AxqWpF/ecP3HoZ0L1+3dF XGUhD0p7eSycuX4LXp/vu+7WcVsvSxm/tTZfcsWPrT1vYnxHNumNi9NLPyWW4oxEQy3mouJE AF70tcxeAgAA X-CMS-MailID: 20200329144333eucas1p2aa754e8de8f2ba01da656821c76eae9f X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200329144333eucas1p2aa754e8de8f2ba01da656821c76eae9f X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200329144333eucas1p2aa754e8de8f2ba01da656821c76eae9f References: <20191212085012.9170-1-i.dyukov@samsung.com> <20200329144308.5103-1-i.dyukov@samsung.com> Subject: [dpdk-dev] [PATCH v7 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