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 58B48A0588; Thu, 16 Apr 2020 14:43:37 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 384B01DC68; Thu, 16 Apr 2020 14:43:18 +0200 (CEST) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by dpdk.org (Postfix) with ESMTP id 784631DC51 for ; Thu, 16 Apr 2020 14:43:15 +0200 (CEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20200416124315euoutp02c8773306f021b52949445c779009575a~GTWBqF78y0222002220euoutp02I for ; Thu, 16 Apr 2020 12:43:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20200416124315euoutp02c8773306f021b52949445c779009575a~GTWBqF78y0222002220euoutp02I DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1587040995; bh=pXfMAz6A0sy/vAmRSzTMWuO76j3j9BMZZjyvc1gPfa8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=MlEdX3lI9ODiZQYOqChBxZt299ikNSl6CYsqa1fIGAsnOH0IOKAvam4Xr4FGERtoQ l9E/yWf920v2Rw0eaIbvDED4VHfE8/4ebPgG5+APj48AMGjtT5fhdpVJ7C0/CYcvRC OqdOflwHwbjDt7rBqzYI25LX2HNiN1g+RN/xxJ2g= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20200416124314eucas1p25d4eb121c0b9254d4d7c02ba275d0474~GTWBZhskA1918619186eucas1p2B; Thu, 16 Apr 2020 12:43:14 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 84.4E.60698.2E2589E5; Thu, 16 Apr 2020 13:43:14 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20200416124314eucas1p21c88e52504d01e4fd6ebe9f790b0e5bd~GTWBH2agv1243412434eucas1p2S; Thu, 16 Apr 2020 12:43:14 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200416124314eusmtrp1023e7ce05998c523dfe6ecb4cfc24dfa~GTWBDQw9J0947209472eusmtrp1G; Thu, 16 Apr 2020 12:43:14 +0000 (GMT) X-AuditID: cbfec7f5-a0fff7000001ed1a-b5-5e9852e2c247 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id CF.C8.07950.2E2589E5; Thu, 16 Apr 2020 13:43:14 +0100 (BST) Received: from idyukov.rnd.samsung.ru (unknown [106.109.129.29]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200416124313eusmtip2ed29251cedab6e3d6aa77e7503238152~GTWAeoajZ0263102631eusmtip2Y; Thu, 16 Apr 2020 12:43: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: Thu, 16 Apr 2020 15:42:54 +0300 Message-Id: <20200416124258.15549-4-i.dyukov@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200416124258.15549-1-i.dyukov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrIIsWRmVeSWpSXmKPExsWy7djPc7qPgmbEGXy8aGzRuuMBi8W7T9uZ LGZdamK3ONa5h8Wi79dVRovTNzezW/x5Y2qx+eIkJgcOj18LlrJ6LN7zksnj/b6rbB59W1Yx epx61M0cwBrFZZOSmpNZllqkb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1m7GDmAEhIS r58wQ9QIS/y51gVV85lRYuOSG+wgCTYBDYnTHfOYQBIiAscZJXpn/WcCaRYWsJU4MisbpIZF QFXi0dUdYGFeAUuJ1xtLIGbKS6zecABsPqeAlcTd7lesILaQQIbEwkuPWSYw8i5gZFjFKJJa WpybnltspFecmFtcmpeul5yfu4kRGKLbjv3csoOx613wIUYBDkYlHt4E+xlxQqyJZcWVuYcY JTiYlUR4+UyBQrwpiZVVqUX58UWlOanFhxhNgW6ayCwlmpwPjJ+8knhDU0NzC0tDc2NzYzML JXHeDoGDMUIC6YklqdmpqQWpRTB9TBycUg2MmxWsb3KbOfBqpWtmWevMWqWrUNfw23lK2ar8 w32uHgEr1RMSXLbO6F/2yX7mnqcvpWc/yw50811p8ajHLmzRHqHFN95Lsmx/y8Zg2f6mp674 beEFkStHl9lwC0qqLGvj+n9t6ZrNPlPLeY6Y9m67YWE4Q73Yw/Zcj6PzEfUL9xq2Ma7KfnVI iaU4I9FQi7moOBEAxlsCUWcCAAA= X-CMS-MailID: 20200416124314eucas1p21c88e52504d01e4fd6ebe9f790b0e5bd X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200416124314eucas1p21c88e52504d01e4fd6ebe9f790b0e5bd X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200416124314eucas1p21c88e52504d01e4fd6ebe9f790b0e5bd References: <20191212085012.9170-1-i.dyukov@samsung.com> <20200416124258.15549-1-i.dyukov@samsung.com> Subject: [dpdk-dev] [PATCH v12 3/7] 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 f914329ed..ca323ee57 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