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 E4A78A056A; Tue, 3 Mar 2020 19:29:11 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6933B1C00E; Tue, 3 Mar 2020 19:29:07 +0100 (CET) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by dpdk.org (Postfix) with ESMTP id A68041C00D for ; Tue, 3 Mar 2020 19:29:05 +0100 (CET) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20200303182904euoutp02f776c83d777ef879d8ef18c8266798dd~43raZ-uIt0662906629euoutp02p for ; Tue, 3 Mar 2020 18:29:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20200303182904euoutp02f776c83d777ef879d8ef18c8266798dd~43raZ-uIt0662906629euoutp02p DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1583260144; bh=uoKcpBlnjKNHps9LwNaAF1miImcsZMlQR8uL91wEOoc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Rp+wS+b/qlr0S4564P0tagAQvNez1GWPQcCKFKvvPr26Dx1z6V4bvQnZaV36MOOG/ QR8r/SFFK/N7mB5xpZf2jbGL8Wfx0ir2InIr/fl6KSTkNoCcmQJIylo5mt3/UwfmjC VNoUG3Uob1nnqhxHBUE0f+o8hdCPhb5ZmutM+oqw= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20200303182904eucas1p1dd3937c5da1833ea06ce29eb98799a84~43raAONTj0553105531eucas1p1X; Tue, 3 Mar 2020 18:29:04 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 20.A0.60679.0F1AE5E5; Tue, 3 Mar 2020 18:29:04 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20200303182903eucas1p2f46d594c58b9add3aa09fa05a7aa037c~43rZfEtMm0075300753eucas1p2D; Tue, 3 Mar 2020 18:29:03 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200303182903eusmtrp215bf7fd880a1f3b4e8ad8878834293a8~43rZefy5y0347103471eusmtrp2h; Tue, 3 Mar 2020 18:29:03 +0000 (GMT) X-AuditID: cbfec7f4-0e5ff7000001ed07-29-5e5ea1f00936 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 3A.A4.07950.FE1AE5E5; Tue, 3 Mar 2020 18:29:03 +0000 (GMT) Received: from idyukov.rnd.samsung.ru (unknown [106.109.129.29]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200303182903eusmtip18ceb30e660ea699eca2505f6bb230fc9~43rY8yQwp0510805108eusmtip1e; Tue, 3 Mar 2020 18:29:03 +0000 (GMT) From: Ivan Dyukov To: dev@dpdk.org, maxime.coquelin@redhat.com, tiwei.bie@intel.com, amorenoz@redhat.com, zhihong.wang@intel.com, xiaolong.ye@intel.com Cc: Ivan Dyukov Date: Tue, 3 Mar 2020 21:27:02 +0300 Message-Id: <20200303182846.26109-2-i.dyukov@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200303182846.26109-1-i.dyukov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrCIsWRmVeSWpSXmKPExsWy7djPc7ofFsbFGXQ1iVm07njAYvHu03Ym i1mXmtgtjnXuYbHY2vCfyeLPG1OLzRcnMTmwe/xasJTVY/Gel0we7/ddZfPo27KKMYAlissm JTUnsyy1SN8ugSvj9a9nbAXLBSvOr3Ns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U2/voN1sEsoCbxoec9WJGwgI3E38dTGUFsFgFV iSfz3rCC2LwClhJnTnxihdggL7F6wwGwXk4BK4kTd9qgLmpglNiwazHLBEa+BYwMqxhFUkuL c9Nzi430ihNzi0vz0vWS83M3MQJDdduxn1t2MHa9Cz7EKMDBqMTDK+EZFyfEmlhWXJl7iFGC g1lJhNeXMzpOiDclsbIqtSg/vqg0J7X4EKMp0FUTmaVEk/OBcZRXEm9oamhuYWlobmxubGah JM7bIXAwRkggPbEkNTs1tSC1CKaPiYNTqoFR63Vi4CVOYblM22VrZUxEfrl43QqbvHyG6nI+ I//Ly72jvs/i1pvq6y3m3z2hPCi+klOr3lDv1/XHppE8Ew6XV+79INVcGLe4lVMwRTWorenw tYLYb+kcaxk/nrr5o/dZluz9/3+7I42SJkUFZS7ZeDwk101rv+bZ6wZ3trxdwBEqH38lKUeJ pTgj0VCLuag4EQDptKZlawIAAA== X-CMS-MailID: 20200303182903eucas1p2f46d594c58b9add3aa09fa05a7aa037c X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200303182903eucas1p2f46d594c58b9add3aa09fa05a7aa037c X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200303182903eucas1p2f46d594c58b9add3aa09fa05a7aa037c References: <20200303182846.26109-1-i.dyukov@samsung.com> Subject: [dpdk-dev] [PATCH v6 1/4] 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 044eb10a7..f814aa926 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,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