From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 5510ADE3 for ; Mon, 21 Dec 2015 13:18:35 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP; 21 Dec 2015 04:18:34 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,459,1444719600"; d="scan'208";a="875928150" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga002.jf.intel.com with ESMTP; 21 Dec 2015 04:18:33 -0800 Received: from sivswdev02.ir.intel.com (sivswdev02.ir.intel.com [10.237.217.46]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id tBLCIWMR013805; Mon, 21 Dec 2015 12:18:32 GMT Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id tBLCIW6Y026495; Mon, 21 Dec 2015 12:18:32 GMT Received: (from fyigit@localhost) by sivswdev02.ir.intel.com with id tBLCIW6J026491; Mon, 21 Dec 2015 12:18:32 GMT From: Ferruh Yigit To: dev@dpdk.org Date: Mon, 21 Dec 2015 12:18:25 +0000 Message-Id: <1450700305-26453-1-git-send-email-ferruh.yigit@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <20151221114643.GA30129@sivlogin002.ir.intel.com> References: <20151221114643.GA30129@sivlogin002.ir.intel.com> Subject: [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 12:18:35 -0000 This is based on patch from Alex Williamson: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=033291eccbdb plus http://dpdk.org/dev/patchwork/patch/9598/ This patch is intended to test above patches on DPDK rather than official patch to DPDK. Test result is DPDK successfully run on no-iommu environment. Signed-off-by: Ferruh Yigit --- lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) 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 @@ #ifdef VFIO_PRESENT +/*#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)) @@ -71,7 +83,11 @@ EAL_REGISTER_TAILQ(rte_vfio_tailq) #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) /* 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 = rte_eal_get_physmem_layout(); - int i, ret; + int i; +#endif + int ret; ret = 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; } +#ifndef VFIO_NOIOMMU /* map all DPDK segments for DMA. use 1:1 PA to IOVA mapping */ for (i = 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 return 0; } @@ -373,7 +394,8 @@ pci_vfio_get_container_fd(void) } /* check if we support IOMMU type 1 */ - ret = ioctl(vfio_container_fd, VFIO_CHECK_EXTENSION, VFIO_TYPE1_IOMMU); + ret = ioctl(vfio_container_fd, VFIO_CHECK_EXTENSION, + VFIO_IOMMU_TYPE); if (ret != 1) { if (ret < 0) RTE_LOG(ERR, EAL, " could not get IOMMU type, " -- 2.5.0