Bare metal PowerNV systems include a DPDK supported IOMMU that allows
IOVA=VA support. Test for the platform type and report virtual address
support if running on a PowerNV system.

Signed-off-by: David Christensen <d...@linux.vnet.ibm.com>
---
 drivers/bus/pci/linux/pci.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/drivers/bus/pci/linux/pci.c b/drivers/bus/pci/linux/pci.c
index 740a2cdad..696dc177e 100644
--- a/drivers/bus/pci/linux/pci.c
+++ b/drivers/bus/pci/linux/pci.c
@@ -549,6 +549,35 @@ pci_device_iommu_support_va(const struct rte_pci_device 
*dev)
 bool
 pci_device_iommu_support_va(__rte_unused const struct rte_pci_device *dev)
 {
+       /*
+        * IOMMU is always present on a PowerNV host (IOMMUv2).
+        * IOMMU is also present in a KVM/QEMU VM (IOMMUv1) but is not
+        * currently supported by DPDK. Test for our current environment
+        * and report VA support as appropriate.
+        */
+
+       char *line = 0;
+       size_t len = 0;
+       char filename[PATH_MAX] = "/proc/cpuinfo";
+       FILE *fp = fopen(filename, "r");
+
+       if (fp == NULL) {
+               RTE_LOG(ERR, EAL, "%s(): can't open %s: %s\n",
+                       __func__, filename, strerror(errno));
+               return false;
+       }
+
+       /* Check for a PowerNV platform */
+       while (getline(&line, &len, fp) != -1) {
+               if (strstr(line, "platform") != NULL)
+                       if (strstr(line, "PowerNV") != NULL) {
+                               RTE_LOG(DEBUG, EAL, "Running on a PowerNV 
system\n");
+                               fclose(fp);
+                               return true;
+                       }
+       }
+       fclose(fp);
+
        return false;
 }
 #else
-- 
2.18.1

Reply via email to