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 84D53DE3 for ; Mon, 21 Dec 2015 16:15:49 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP; 21 Dec 2015 07:15:49 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,460,1444719600"; d="scan'208";a="845822744" Received: from irsmsx153.ger.corp.intel.com ([163.33.192.75]) by orsmga001.jf.intel.com with ESMTP; 21 Dec 2015 07:15:48 -0800 Received: from irsmsx109.ger.corp.intel.com ([169.254.13.96]) by IRSMSX153.ger.corp.intel.com ([169.254.9.208]) with mapi id 14.03.0248.002; Mon, 21 Dec 2015 15:15:46 +0000 From: "Burakov, Anatoly" To: "Yigit, Ferruh" , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH] vfio: add no-iommu support Thread-Index: AQHRO+nQTVgHXiCJE0CDmD7MVOP0BJ7VjDeQ Date: Mon, 21 Dec 2015 15:15:46 +0000 Message-ID: References: <20151221114643.GA30129@sivlogin002.ir.intel.com> <1450700305-26453-1-git-send-email-ferruh.yigit@intel.com> In-Reply-To: <1450700305-26453-1-git-send-email-ferruh.yigit@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.180] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] vfio: add no-iommu support 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, 21 Dec 2015 15:15:50 -0000 Hi Ferruh, > This is based on patch from Alex Williamson: > https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?i= d=3D03 > 3291eccbdb > plus > http://dpdk.org/dev/patchwork/patch/9598/ >=20 > This patch is intended to test above patches on DPDK rather than official > patch to DPDK. >=20 > Test result is DPDK successfully run on no-iommu environment. >=20 > Signed-off-by: Ferruh Yigit > --- > lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 28 > +++++++++++++++++++++++++--- > 1 file changed, 25 insertions(+), 3 deletions(-) >=20 > diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c > b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c > index 74f91ba..90bba4a 100644 > --- a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c > +++ b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c > @@ -61,6 +61,18 @@ >=20 > #ifdef VFIO_PRESENT >=20 > +/*#define VFIO_NOIOMMU*/ > + > +#ifndef VFIO_NOIOMMU_IOMMU > +#define VFIO_NOIOMMU_IOMMU 8 > +#endif > + > +#ifdef VFIO_NOIOMMU > +#define VFIO_IOMMU_TYPE VFIO_NOIOMMU_IOMMU #else #define > +VFIO_IOMMU_TYPE VFIO_TYPE1_IOMMU #endif > + > #define PAGE_SIZE (sysconf(_SC_PAGESIZE)) > #define PAGE_MASK (~(PAGE_SIZE - 1)) >=20 > @@ -71,7 +83,11 @@ EAL_REGISTER_TAILQ(rte_vfio_tailq) >=20 > #define VFIO_DIR "/dev/vfio" > #define VFIO_CONTAINER_PATH "/dev/vfio/vfio" > +#ifdef VFIO_NOIOMMU > +#define VFIO_GROUP_FMT "/dev/vfio/noiommu-%u" > +#else > #define VFIO_GROUP_FMT "/dev/vfio/%u" > +#endif > #define VFIO_GET_REGION_ADDR(x) ((uint64_t) x << 40ULL) >=20 > /* per-process VFIO config */ > @@ -212,17 +228,21 @@ pci_vfio_set_bus_master(int dev_fd) static int > pci_vfio_setup_dma_maps(int vfio_container_fd) { > +#ifndef VFIO_NOIOMMU > const struct rte_memseg *ms =3D rte_eal_get_physmem_layout(); > - int i, ret; > + int i; > +#endif > + int ret; >=20 > ret =3D ioctl(vfio_container_fd, VFIO_SET_IOMMU, > - VFIO_TYPE1_IOMMU); > + VFIO_IOMMU_TYPE); > if (ret) { > RTE_LOG(ERR, EAL, " cannot set IOMMU type, " > "error %i (%s)\n", errno, strerror(errno)); > return -1; > } >=20 > +#ifndef VFIO_NOIOMMU > /* map all DPDK segments for DMA. use 1:1 PA to IOVA mapping */ > for (i =3D 0; i < RTE_MAX_MEMSEG; i++) { > struct vfio_iommu_type1_dma_map dma_map; @@ -245,6 > +265,7 @@ pci_vfio_setup_dma_maps(int vfio_container_fd) > return -1; > } > } > +#endif >=20 > return 0; > } > @@ -373,7 +394,8 @@ pci_vfio_get_container_fd(void) > } >=20 > /* check if we support IOMMU type 1 */ > - ret =3D ioctl(vfio_container_fd, VFIO_CHECK_EXTENSION, > VFIO_TYPE1_IOMMU); > + ret =3D ioctl(vfio_container_fd, VFIO_CHECK_EXTENSION, > + VFIO_IOMMU_TYPE); > if (ret !=3D 1) { > if (ret < 0) > RTE_LOG(ERR, EAL, " could not get IOMMU > type, " > -- > 2.5.0 This is one approach :) I was thinking of another, building some kind of mo= re generic support for multiple VFIO drivers. It's a bit more code and prob= ably overkill as a solution to this particular problem, but hopefully it'll= make it easier to add new VFIO drivers down the line (with each driver hav= ing their own DMA mapping function), should we choose to do so. I'm still w= orking on the patch, but if everyone is OK with this approach instead of a = more general one, that's fine with me. Thanks, Anatoly