From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id 5E4113250 for ; Tue, 11 Jul 2017 11:23:27 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4880430AF44; Tue, 11 Jul 2017 09:23:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4880430AF44 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=maxime.coquelin@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 4880430AF44 Received: from [10.36.112.40] (ovpn-112-40.ams2.redhat.com [10.36.112.40]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9E0B75DD71; Tue, 11 Jul 2017 09:23:21 +0000 (UTC) To: Santosh Shukla , thomas@monjalon.net, dev@dpdk.org Cc: bruce.richardson@intel.com, jerin.jacob@caviumnetworks.com, hemant.agrawal@nxp.com, shreyansh.jain@nxp.com, gaetan.rivet@6wind.com, sergio.gonzalez.monroy@intel.com, anatoly.burakov@intel.com, stephen@networkplumber.org, olivier.matz@6wind.com References: <20170710114235.18970-1-santosh.shukla@caviumnetworks.com> <20170711061631.5018-1-santosh.shukla@caviumnetworks.com> <20170711061631.5018-5-santosh.shukla@caviumnetworks.com> From: Maxime Coquelin Message-ID: <7e98c200-bea5-c04e-ecde-4d3072e18c6e@redhat.com> Date: Tue, 11 Jul 2017 11:23:19 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 MIME-Version: 1.0 In-Reply-To: <20170711061631.5018-5-santosh.shukla@caviumnetworks.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 11 Jul 2017 09:23:26 +0000 (UTC) Subject: Re: [dpdk-dev] [PATCH v3 04/11] linuxapp/eal_pci: get iommu class 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: , X-List-Received-Date: Tue, 11 Jul 2017 09:23:27 -0000 On 07/11/2017 08:16 AM, Santosh Shukla wrote: > Get iommu class of PCI device on the bus and returns preferred iova > mapping mode for that bus. > > Algorithm for iova scheme selection for PCI bus: > 0. Look for device attached to vfio kdrv and has .drv_flag set > to RTE_PCI_DRV_NEED_IOVA_VA. > 1. Look for any device attached to UIO class of driver. > 2. Check for vfio-noiommu mode enabled. > > If 1) & 2) is false and 0) is true then select > mapping scheme as iova=va. Otherwise use default > mapping scheme (iova_pa). > > Signed-off-by: Santosh Shukla > Signed-off-by: Jerin Jacob > --- > v1 --> v2: > - Removed Linux version check in vfio_noiommu func. Refer [1]. > - Extending autodetction logic for _iommu_class. > Refer [2]. > > [1] https://www.mail-archive.com/dev@dpdk.org/msg70108.html > [2] https://www.mail-archive.com/dev@dpdk.org/msg70279.html > > lib/librte_eal/linuxapp/eal/eal_pci.c | 66 +++++++++++++++++++++++++ > lib/librte_eal/linuxapp/eal/eal_vfio.c | 19 +++++++ > lib/librte_eal/linuxapp/eal/eal_vfio.h | 4 ++ > lib/librte_eal/linuxapp/eal/rte_eal_version.map | 1 + > 4 files changed, 90 insertions(+) > > diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linuxapp/eal/eal_pci.c > index 7d9e1a99b..573caa000 100644 > --- a/lib/librte_eal/linuxapp/eal/eal_pci.c > +++ b/lib/librte_eal/linuxapp/eal/eal_pci.c > @@ -45,6 +45,7 @@ > #include "eal_filesystem.h" > #include "eal_private.h" > #include "eal_pci_init.h" > +#include "eal_vfio.h" > > /** > * @file > @@ -488,6 +489,71 @@ rte_pci_scan(void) > return -1; > } > > +/* > + * Any one of the device bound to uio > + */ > +static inline int > +pci_device_bound_uio(void) > +{ > + struct rte_pci_device *dev = NULL; > + > + FOREACH_DEVICE_ON_PCIBUS(dev) { > + if (dev->kdrv == RTE_KDRV_IGB_UIO || > + dev->kdrv == RTE_KDRV_UIO_GENERIC) { > + return 1; > + } > + } > + return 0; > +} > + > +/* > + * Any one of the device has iova as va > + */ > +static inline int > +pci_device_has_iova_va(void) > +{ > + struct rte_pci_device *dev = NULL; > + struct rte_pci_driver *drv = NULL; > + > + FOREACH_DRIVER_ON_PCIBUS(drv) { > + if (drv && drv->drv_flags & RTE_PCI_DRV_NEED_IOVA_VA) { > + FOREACH_DEVICE_ON_PCIBUS(dev) { > + if (dev->kdrv == RTE_KDRV_VFIO && > + rte_pci_match(drv, dev)) > + return 1; > + } > + } > + } > + return 0; > +} > + > +/* > + * Get iommu class of PCI devices on the bus. > + */ > +enum rte_iova_mode > +rte_pci_get_iommu_class(void) > +{ > + bool is_vfio_noiommu_enabled; > + bool has_iova_va; > + bool is_bound_uio; > + > + has_iova_va = pci_device_has_iova_va(); > + is_bound_uio = pci_device_bound_uio(); > + is_vfio_noiommu_enabled = vfio_noiommu_is_enabled() == 1 ? 1 : 0; > + > + if (has_iova_va && !is_bound_uio && !is_vfio_noiommu_enabled) > + return RTE_IOVA_VA; > + > + if (has_iova_va) { > + if (is_vfio_noiommu_enabled) > + RTE_LOG(WARNING, EAL, "vfio-noiommu mode configured\n"); > + if (is_bound_uio) > + RTE_LOG(WARNING, EAL, "Some device attached to UIO\n"); Maybe worth having more verbose warning for user not familiar with the feature. Like stating that some devices want VA but PA will be used because of vfio-noiommu or UIO. Maxime