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 33835A0542; Fri, 7 Feb 2020 12:25:40 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7CD111C068; Fri, 7 Feb 2020 12:25:39 +0100 (CET) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by dpdk.org (Postfix) with ESMTP id 7B7351BFF7 for ; Fri, 7 Feb 2020 12:25:37 +0100 (CET) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20200207112536euoutp026e50950a4a2d7a94ef76ad94908042fe~xGxiSyRhC0449304493euoutp027 for ; Fri, 7 Feb 2020 11:25:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20200207112536euoutp026e50950a4a2d7a94ef76ad94908042fe~xGxiSyRhC0449304493euoutp027 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1581074736; bh=0XjvQCEiVj60+UBTAarvishZLNeMmePERL7qVRhbsj8=; h=From:To:Cc:Subject:Date:References:From; b=Z3fJC9MdzGsPkhR5CVl5IwCfChEnwQZPSjwB1X93yxPZJww6160EDgu6C0XO1yXoW eUTxVb9zKBNAtGRJ5smd1BH04OmdpV3TAyYY5iBCTIsA7UpZ9IBVZZ6RaoH9Xnc8Yt /CxDbPTntMoabQyjA/GtI+IbnzexY6PdiNLesSZM= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20200207112536eucas1p1c2d76773efbe641839d01051e990c686~xGxh_GKbD3030530305eucas1p1f; Fri, 7 Feb 2020 11:25:36 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id B0.7C.61286.0394D3E5; Fri, 7 Feb 2020 11:25:36 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20200207112535eucas1p2e333a3f5788b70f6de679332eff266e0~xGxhkw4oN1904519045eucas1p2L; Fri, 7 Feb 2020 11:25:35 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200207112535eusmtrp214641d10aa1a4d0f09d0d8b83fb6e3e5~xGxhkKoAG0873908739eusmtrp2h; Fri, 7 Feb 2020 11:25:35 +0000 (GMT) X-AuditID: cbfec7f2-f0bff7000001ef66-8d-5e3d493066bd Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 74.E0.08375.F294D3E5; Fri, 7 Feb 2020 11:25:35 +0000 (GMT) Received: from idyukov.rnd.samsung.ru (unknown [106.109.129.29]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200207112535eusmtip160df7730c6afc00a3db7512a8df83a81~xGxhBydiL2615826158eusmtip1d; Fri, 7 Feb 2020 11:25:35 +0000 (GMT) From: Ivan Dyukov To: dev@dpdk.org, maxime.coquelin@redhat.com, tiwei.bie@intel.com, amorenoz@redhat.com Cc: Ivan Dyukov Date: Fri, 7 Feb 2020 14:25:25 +0300 Message-Id: <20200207112526.11455-1-i.dyukov@samsung.com> X-Mailer: git-send-email 2.17.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrPIsWRmVeSWpSXmKPExsWy7djP87oGnrZxBremcli07njAYvHu03Ym i1mXmtgtjnXuYbHY2vCfyYHV49eCpawei/e8ZPJ4v+8qm0ffllWMASxRXDYpqTmZZalF+nYJ XBn35u5nLVgjWLF57wfmBsZGvi5GTg4JAROJT12/2bsYuTiEBFYwSqxs3cMG4XxhlNh47hor hPOZUeLAmhtsMC1Prm6CalnOKLH7ygUo5yujxM+L15hB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rJ+bmbGIFBtu3Yz807GC9t DD7EKMDBqMTDm+BoEyfEmlhWXJl7iFGCg1lJhLdP1TZOiDclsbIqtSg/vqg0J7X4EKMp0O6J zFKiyfnACMgriTc0NTS3sDQ0NzY3NrNQEuftEDgYIySQnliSmp2aWpBaBNPHxMEp1cDYXrqz alOX8JlpEW7fg0xKlywOaGJ/FnBz6s8onkMc1k9X75otLu8icLzdyGTb5Ykvrqn/M5A43MR2 x/96+LLkxYIv37L/O+Npd09VQ+KMFxvvEqk5Z1S457XoMlye4OlR8kvVr2t3Uo/j+oOrNnpX yfQ5zAwP3sK9YOuyUN1pFvKFPlkTpH2VWIozEg21mIuKEwHta7LbSAIAAA== X-CMS-MailID: 20200207112535eucas1p2e333a3f5788b70f6de679332eff266e0 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200207112535eucas1p2e333a3f5788b70f6de679332eff266e0 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200207112535eucas1p2e333a3f5788b70f6de679332eff266e0 References: Subject: [dpdk-dev] [PATCH v3 1/2] 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 | 35 +++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index 044eb10a7..22323d9a5 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,17 @@ 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_DRV_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