From mboxrd@z Thu Jan 1 00:00:00 1970 From: Xiao Wang Subject: [PATCH v3 2/4] net/virtio: skip device probe in vdpa mode Date: Sat, 31 Mar 2018 10:29:27 +0800 Message-ID: <20180331022929.42172-3-xiao.w.wang@intel.com> References: <20180321132108.52464-4-xiao.w.wang@intel.com> <20180331022929.42172-1-xiao.w.wang@intel.com> Cc: dev@dpdk.org, zhihong.wang@intel.com, yliu@fridaylinux.org, jianfeng.tan@intel.com, tiwei.bie@intel.com, cunming.liang@intel.com, dan.daly@intel.com, thomas@monjalon.net, gaetan.rivet@6wind.com, anatoly.burakov@intel.com, Xiao Wang To: ferruh.yigit@intel.com, maxime.coquelin@redhat.com Return-path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 64A62A48C for ; Fri, 30 Mar 2018 19:56:14 +0200 (CEST) In-Reply-To: <20180331022929.42172-1-xiao.w.wang@intel.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" If we want a virtio device to work in vDPA (vhost data path acceleration) mode, we could add a "vdpa=1" devarg for this device to specify the mode. This patch let virtio pmd skip device probe when detecting this parameter. Signed-off-by: Xiao Wang --- drivers/net/virtio/virtio_ethdev.c | 43 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index 884f74ad0..6551a367f 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -29,6 +29,7 @@ #include #include #include +#include #include "virtio_ethdev.h" #include "virtio_pci.h" @@ -1744,9 +1745,51 @@ eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev) return 0; } +static int vdpa_check_handler(__rte_unused const char *key, + const char *value, __rte_unused void *opaque) +{ + if (strcmp(value, "1")) + return -1; + + return 0; +} + +static int +vdpa_mode_selected(struct rte_devargs *devargs) +{ + struct rte_kvargs *kvlist; + const char *key = "vdpa"; + int ret = 0; + + if (devargs == NULL) + return 0; + + kvlist = rte_kvargs_parse(devargs->args, NULL); + if (kvlist == NULL) + return 0; + + 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; + } + ret = 1; + +exit: + rte_kvargs_free(kvlist); + return ret; +} + static int eth_virtio_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, struct rte_pci_device *pci_dev) { + /* virtio pmd skips probe if device needs to work in vdpa mode */ + if (vdpa_mode_selected(pci_dev->device.devargs)) + return 1; + return rte_eth_dev_pci_generic_probe(pci_dev, sizeof(struct virtio_hw), eth_virtio_dev_init); } -- 2.15.1