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 DE857A055E; Wed, 26 Feb 2020 08:18:58 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2317F1BFAB; Wed, 26 Feb 2020 08:18:58 +0100 (CET) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id E62F51C01 for ; Wed, 26 Feb 2020 08:18:56 +0100 (CET) X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Feb 2020 23:18:55 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,487,1574150400"; d="scan'208";a="256225266" Received: from yexl-server.sh.intel.com (HELO localhost) ([10.67.117.17]) by orsmga002.jf.intel.com with ESMTP; 25 Feb 2020 23:18:53 -0800 Date: Wed, 26 Feb 2020 15:16:58 +0800 From: Ye Xiaolong To: Ivan Dyukov Cc: dev@dpdk.org, maxime.coquelin@redhat.com, tiwei.bie@intel.com, amorenoz@redhat.com, zhihong.wang@intel.com Message-ID: <20200226071658.GA105977@intel.com> References: <20200225072813.9385-1-i.dyukov@samsung.com> <20200225072813.9385-2-i.dyukov@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200225072813.9385-2-i.dyukov@samsung.com> User-Agent: Mutt/1.9.4 (2018-02-28) Subject: Re: [dpdk-dev] [PATCH v4 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" On 02/25, Ivan Dyukov wrote: >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) Double space between 'ret' and '<'. >+ 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"); I think PMD_INIG_LOG should be used, and there is no need to split into 2 lines as it won't exceed 80 chars. Thanks, Xiaolong >+ 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 >