vfio: honor IOVA mode before mapping
authorSantosh Shukla <santosh.shukla@caviumnetworks.com>
Fri, 6 Oct 2017 11:03:44 +0000 (16:33 +0530)
committerThomas Monjalon <thomas@monjalon.net>
Fri, 6 Oct 2017 18:39:07 +0000 (20:39 +0200)
Check iova mode and accordingly map iova to pa or va.

Signed-off-by: Santosh Shukla <santosh.shukla@caviumnetworks.com>
Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
Tested-by: Hemant Agrawal <hemant.agrawal@nxp.com>
lib/librte_eal/linuxapp/eal/eal_vfio.c

index c8a97b7..b32cd09 100644 (file)
@@ -706,7 +706,10 @@ vfio_type1_dma_map(int vfio_container_fd)
                dma_map.argsz = sizeof(struct vfio_iommu_type1_dma_map);
                dma_map.vaddr = ms[i].addr_64;
                dma_map.size = ms[i].len;
-               dma_map.iova = ms[i].phys_addr;
+               if (rte_eal_iova_mode() == RTE_IOVA_VA)
+                       dma_map.iova = dma_map.vaddr;
+               else
+                       dma_map.iova = ms[i].phys_addr;
                dma_map.flags = VFIO_DMA_MAP_FLAG_READ | VFIO_DMA_MAP_FLAG_WRITE;
 
                ret = ioctl(vfio_container_fd, VFIO_IOMMU_MAP_DMA, &dma_map);
@@ -792,7 +795,10 @@ vfio_spapr_dma_map(int vfio_container_fd)
                dma_map.argsz = sizeof(struct vfio_iommu_type1_dma_map);
                dma_map.vaddr = ms[i].addr_64;
                dma_map.size = ms[i].len;
-               dma_map.iova = ms[i].phys_addr;
+               if (rte_eal_iova_mode() == RTE_IOVA_VA)
+                       dma_map.iova = dma_map.vaddr;
+               else
+                       dma_map.iova = ms[i].phys_addr;
                dma_map.flags = VFIO_DMA_MAP_FLAG_READ |
                                 VFIO_DMA_MAP_FLAG_WRITE;