DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ferruh Yigit <ferruh.yigit@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH] vfio: add no-iommu support
Date: Mon, 21 Dec 2015 12:18:25 +0000	[thread overview]
Message-ID: <1450700305-26453-1-git-send-email-ferruh.yigit@intel.com> (raw)
In-Reply-To: <20151221114643.GA30129@sivlogin002.ir.intel.com>

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 <ferruh.yigit@intel.com>
---
 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

  reply	other threads:[~2015-12-21 12:18 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-11 16:28 [dpdk-dev] VFIO no-iommu Thomas Monjalon
2015-12-11 22:12 ` Vincent JARDIN
2015-12-11 23:02   ` Alex Williamson
2015-12-15 13:43     ` O'Driscoll, Tim
2015-12-15 16:53       ` Alex Williamson
2015-12-16  4:04         ` Ferruh Yigit
2015-12-16  4:38           ` Alex Williamson
2015-12-16  8:35             ` Burakov, Anatoly
2015-12-16 16:23               ` Burakov, Anatoly
2015-12-16 23:17                 ` Thomas Monjalon
2015-12-17  9:52                   ` Burakov, Anatoly
2015-12-17 10:09                     ` Thomas Monjalon
2015-12-17 19:38                       ` Jan Viktorin
2015-12-17 21:16                         ` Vincent JARDIN
2015-12-17 23:29                         ` Stephen Hemminger
2015-12-16 17:11               ` Alex Williamson
2015-12-16 17:22                 ` Burakov, Anatoly
2015-12-17 16:43                   ` Alex Williamson
2015-12-18 10:43                     ` Yigit, Ferruh
2015-12-18 14:38                       ` Alex Williamson
2015-12-18 21:50                         ` Alex Williamson
2015-12-21 11:46                           ` Yigit, Ferruh
2015-12-21 12:18                             ` Ferruh Yigit [this message]
2015-12-21 15:15                               ` [dpdk-dev] [PATCH] vfio: add no-iommu support Burakov, Anatoly
2015-12-21 15:26                                 ` Yigit, Ferruh
2015-12-21 15:28                                   ` Burakov, Anatoly
2015-12-21 19:22                             ` [dpdk-dev] VFIO no-iommu Alex Williamson
2015-12-22 20:20                               ` Alex Williamson
2015-12-23 11:19                                 ` Burakov, Anatoly
2015-12-31 14:30                                   ` Santosh Shukla
2016-01-14  6:03             ` Jike Song
2016-01-14  6:52               ` Alex Williamson
2016-01-14  8:12                 ` Jike Song
2015-12-11 23:20 ` Jan Viktorin
2015-12-15 11:20   ` Alejandro Lucero

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1450700305-26453-1-git-send-email-ferruh.yigit@intel.com \
    --to=ferruh.yigit@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).