From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f177.google.com (mail-pf0-f177.google.com [209.85.192.177]) by dpdk.org (Postfix) with ESMTP id 9B6156CC0 for ; Mon, 29 Feb 2016 14:15:27 +0100 (CET) Received: by mail-pf0-f177.google.com with SMTP id w128so47328094pfb.2 for ; Mon, 29 Feb 2016 05:15:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mvista-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc; bh=QXn9ebj4AI5p/lsT7NTjzzt/wsw76QbLqj0Jt2dhQDY=; b=QtZuIgdcKsROi+TD3lT5b0aHb9D53auumi9nM7WgBY0qNJ35tbQiY0e2EUwGJPjh08 FgqtymsqJB2ku8Rk58ZzUlAFTOW31Y0S9U5bAVZAv/nXlZjX1/HNnXrl/vW2l/YFsI56 u3Zz+HmJCn6votdI/Co5QxMzU7edNRTew2XAddSwRoe0VU0qRD/A9UJ2vXzxqN2H8r/F 3VMoeIwIaDEcILPd/RQltivOIOdnsm/9FARzHMNIX7jHlyWD1xgjwnEt6g47Mt3dybK9 V5zufqTxdqBftqlCMZNvVa6gRTfEWh/BJUdjEutkF8xDVLDQmeVkEOu0hWz09zb+DxdB WHOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc; bh=QXn9ebj4AI5p/lsT7NTjzzt/wsw76QbLqj0Jt2dhQDY=; b=Zqmc+qQbVVdO9BWBpAevvcwmuiQZxV7WIKS6Ov1Ti6GmYDUmYYUKgcOXH2f81toe/Q /CcMSg0DYcCCtLDiMbAKL2IsNt3ykCbyxoyJ4tqyeeJxlxDf10sGTWXu66tT9z6AxXdr ngHDrBruiozeR8q2ELQTt65xfnwmM93lBm4SdktVy3a1PNM3cLghIQtbaI7PFzEgNvTA PHg3WmEQciOLnjJzdiiZ3lsm2Mulw3+nkO6qHPm0CchddmvK+Lnik0N1ydt2QEXYZQU7 bG+aL8xE5a9ccZifCDdBMnqlb3qVpB2JUIyaqdYbAzQyrpayQXow9Fxp6VGI1a6RuRri eAYA== X-Gm-Message-State: AD7BkJKP1LnscGJjazbtsuYwn1VuH9Qpb4gVAwxoKTPW4suke76hw99yUmG6MK2vm/5KLWS23TyIOnUzqKrPcghI MIME-Version: 1.0 X-Received: by 10.98.0.11 with SMTP id 11mr22254523pfa.5.1456751726904; Mon, 29 Feb 2016 05:15:26 -0800 (PST) Received: by 10.66.176.200 with HTTP; Mon, 29 Feb 2016 05:15:26 -0800 (PST) In-Reply-To: <1456451636-118476-5-git-send-email-huawei.xie@intel.com> References: <20151222035041.GA7532@pxdev.xzpeter.org> <1456451636-118476-1-git-send-email-huawei.xie@intel.com> <1456451636-118476-5-git-send-email-huawei.xie@intel.com> Date: Mon, 29 Feb 2016 18:45:26 +0530 Message-ID: From: Santosh Shukla To: Huawei Xie Content-Type: text/plain; charset=UTF-8 Cc: dpdk , nikita.troitsky@intel.com Subject: Re: [dpdk-dev] [PATCH v4 4/4] 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: Mon, 29 Feb 2016 13:15:28 -0000 On Fri, Feb 26, 2016 at 7:23 AM, Huawei Xie wrote: > v4 changes: > Rebase as io port map is moved to eal. > Only fall back to PORT IO when there isn't any kernel driver (including Pl. mention that fallback behaviour applicable to x86 arch only.. However this patch fixes one problem in non-x86 arch issue, Example: VM has 8 virtio interface and 2 i/f attached out of 8, so in default case - after 2nd interface, ioport try to program 3..8 ports, result to failure, lead to exit dpdk application. Patch fixes this problem for non-x86 arch, test on arm64 platform. > VFIO/UIO) managing the device. Before v4, we fall back to PORT IO even if > VFIO/UIO fails. > Reword the commit message. > > v3 changes: > Change log message to tell user that the virtio device is skipped > due to it is managed by kernel driver, instead of asking user to > unbind it from kernel driver. > > v2 changes: > Remove unnecessary assignment of NULL to dev->data->mac_addrs. > Ajust one comment's position. > > virtio PMD could use IO port to configure the virtio device without > using UIO/VFIO driver in legacy mode. > > There are two issues with the 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 > --- > drivers/net/virtio/virtio_ethdev.c | 9 +++++++-- > drivers/net/virtio/virtio_pci.c | 15 ++++++++++++++- > 2 files changed, 21 insertions(+), 3 deletions(-) > > diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c > index caa970c..8601080 100644 > --- a/drivers/net/virtio/virtio_ethdev.c > +++ b/drivers/net/virtio/virtio_ethdev.c > @@ -1,4 +1,5 @@ > /*- > + > * BSD LICENSE > * > * Copyright(c) 2010-2015 Intel Corporation. All rights reserved. > @@ -1015,6 +1016,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 +1039,11 @@ 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) { > + rte_free(eth_dev->data->mac_addrs); > + 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..f159b2a 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,14 @@ 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) { > + 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); Tested-by: Santosh Shukla Acked-by: Santosh Shukla > -- > 1.8.1.4 >