From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id CAE273989 for ; Wed, 9 Mar 2016 08:27:53 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP; 08 Mar 2016 23:27:53 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,310,1455004800"; d="scan'208";a="905752503" Received: from dpdk15.sh.intel.com ([10.239.129.25]) by orsmga001.jf.intel.com with ESMTP; 08 Mar 2016 23:27:52 -0800 From: Huawei Xie To: dev@dpdk.org Date: Tue, 8 Mar 2016 23:33:43 +0800 Message-Id: <1457451223-82306-7-git-send-email-huawei.xie@intel.com> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1457451223-82306-1-git-send-email-huawei.xie@intel.com> References: <20151222035041.GA7532@pxdev.xzpeter.org> <1457451223-82306-1-git-send-email-huawei.xie@intel.com> Cc: nikita.troitsky@intel.com Subject: [dpdk-dev] [PATCH v5 6/6] virtio: return 1 to tell the upper layer we don't take over this device X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Mar 2016 07:27:54 -0000 virtio PMD could use IO port to configure the virtio device without using UIO/VFIO driver in legacy mode. There are two issues with previous implementation: 1) virtio PMD will take over the virtio device(s) blindly even if not intended for DPDK. 2) driver conflict between virtio PMD and virtio-net kernel driver. This patch checks if there is kernel driver other than UIO/VFIO managing the virtio device before using port IO. If legacy_virtio_resource_init fails and kernel driver other than VFIO/UIO is managing the device ,return 1 to tell the upper layer we don't take over this device. For all other IO port mapping errors, return -1. Note than if VFIO/UIO fails, now we don't fall back to port IO. Fixes: da978dfdc43b ("virtio: use port IO to get PCI resource") Signed-off-by: Huawei Xie Acked-by: Yuanhan Liu Acked-by: David Marchand --- drivers/net/virtio/virtio_ethdev.c | 6 ++++-- drivers/net/virtio/virtio_pci.c | 16 +++++++++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index caa970c..06bddd7 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -1015,6 +1015,7 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev) struct virtio_net_config *config; struct virtio_net_config local_config; struct rte_pci_device *pci_dev; + int ret; RTE_BUILD_BUG_ON(RTE_PKTMBUF_HEADROOM < sizeof(struct virtio_net_hdr)); @@ -1037,8 +1038,9 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev) pci_dev = eth_dev->pci_dev; - if (vtpci_init(pci_dev, hw) < 0) - return -1; + ret = vtpci_init(pci_dev, hw); + if (ret) + return ret; /* Reset the device although not necessary at startup */ vtpci_reset(hw); diff --git a/drivers/net/virtio/virtio_pci.c b/drivers/net/virtio/virtio_pci.c index 85fbe88..98fc370 100644 --- a/drivers/net/virtio/virtio_pci.c +++ b/drivers/net/virtio/virtio_pci.c @@ -622,6 +622,13 @@ next: return 0; } +/* + * Return -1: + * if there is error mapping with VFIO/UIO. + * if port map error when driver type is KDRV_NONE. + * Return 1 if kernel driver is managing the device. + * Return 0 on success. + */ int vtpci_init(struct rte_pci_device *dev, struct virtio_hw *hw) { @@ -641,8 +648,15 @@ vtpci_init(struct rte_pci_device *dev, struct virtio_hw *hw) } PMD_INIT_LOG(INFO, "trying with legacy virtio pci."); - if (legacy_virtio_resource_init(dev, hw) < 0) + if (legacy_virtio_resource_init(dev, hw) < 0) { + if (dev->kdrv == RTE_KDRV_UNKNOWN && + dev->devargs->type != RTE_DEVTYPE_WHITELISTED_PCI) { + PMD_INIT_LOG(INFO, + "skip kernel managed virtio device."); + return 1; + } return -1; + } hw->vtpci_ops = &legacy_ops; hw->use_msix = legacy_virtio_has_msix(&dev->addr); -- 1.8.1.4