bus/pci: support IOVA as VA on PowerNV systems

All recent POWER systems, Power 8 and 9 specifically, support an IOMMU
(it can't be disabled). The functionality of the IOMMU is different
depending on whether it's running on a bare metal PowerNV system or in
a virtual environment (PowerVM LPAR or KVM/QEMU).  DPDK currently
supports the IOMMU found on PowerNV platforms, sPAPRv2, so IOVA=VA
mode can be enabled when the correct platform is detected.

The POWER IOMMU type can't be detected through mechanisms such as
parsing files in the /sys hierarchy like x86_64 systems so the
/proc/cpuinfo file is parsed to determine whether Linux is running
on bare metal (i.e. PowerNV) or in a virtual environment (KVM/QEMU).

Signed-off-by: David Christensen <drc@linux.vnet.ibm.com>
This commit is contained in:
David Christensen 2020-03-16 13:38:28 -07:00 committed by David Marchand
parent 2c32cfdee1
commit 9052157318

View File

@ -554,7 +554,40 @@ 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)
{
return false;
/*
* 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 = NULL;
size_t len = 0;
char filename[PATH_MAX] = "/proc/cpuinfo";
FILE *fp = fopen(filename, "r");
bool ret = false;
if (fp == NULL) {
RTE_LOG(ERR, EAL, "%s(): can't open %s: %s\n",
__func__, filename, strerror(errno));
return ret;
}
/* Check for a PowerNV platform */
while (getline(&line, &len, fp) != -1) {
if (strstr(line, "platform") != NULL)
continue;
if (strstr(line, "PowerNV") != NULL) {
RTE_LOG(DEBUG, EAL, "Running on a PowerNV system\n");
ret = true;
break;
}
}
free(line);
fclose(fp);
return ret;
}
#else
bool