DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Burakov, Anatoly" <anatoly.burakov@intel.com>
To: "Yigit, Ferruh" <ferruh.yigit@intel.com>, "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH] vfio: add no-iommu support
Date: Mon, 21 Dec 2015 15:15:46 +0000	[thread overview]
Message-ID: <C6ECDF3AB251BE4894318F4E45123697820B36E9@IRSMSX109.ger.corp.intel.com> (raw)
In-Reply-To: <1450700305-26453-1-git-send-email-ferruh.yigit@intel.com>

Hi Ferruh,

> This is based on patch from Alex Williamson:
> https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=03
> 3291eccbdb
> 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

This is one approach :) I was thinking of another, building some kind of more generic support for multiple VFIO drivers. It's a bit more code and probably 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 having their own DMA mapping function), should we choose to do so. I'm still working on the patch, but if everyone is OK with this approach instead of a more general one, that's fine with me.

Thanks,
Anatoly

  reply	other threads:[~2015-12-21 15:15 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                             ` [dpdk-dev] [PATCH] vfio: add no-iommu support Ferruh Yigit
2015-12-21 15:15                               ` Burakov, Anatoly [this message]
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=C6ECDF3AB251BE4894318F4E45123697820B36E9@IRSMSX109.ger.corp.intel.com \
    --to=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    /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).