/* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright (c) 2015-2016 Freescale Semiconductor, Inc. All rights reserved.
- * Copyright 2016-2018 NXP
+ * Copyright 2016-2019 NXP
*
*/
static struct fslmc_vfio_group vfio_group;
static struct fslmc_vfio_container vfio_container;
static int container_device_fd;
-static char *g_container;
+static char *fslmc_container;
+static int fslmc_iommu_type;
static uint32_t *msi_intr_vaddr;
void *(*rte_mcp_ptr_list);
int ret;
char *container;
- if (!g_container) {
+ if (!fslmc_container) {
container = getenv("DPRC");
if (container == NULL) {
DPAA2_BUS_DEBUG("DPAA2: DPRC not available");
return -1;
}
- g_container = strdup(container);
- if (!g_container) {
+ fslmc_container = strdup(container);
+ if (!fslmc_container) {
DPAA2_BUS_ERR("Mem alloc failure; Container name");
return -ENOMEM;
}
}
+ fslmc_iommu_type = (rte_vfio_noiommu_is_enabled() == 1) ?
+ RTE_VFIO_NOIOMMU : VFIO_TYPE1_IOMMU;
+
/* get group number */
ret = rte_vfio_get_group_num(SYSFS_FSL_MC_DEVICES,
- g_container, groupid);
+ fslmc_container, groupid);
if (ret <= 0) {
- DPAA2_BUS_ERR("Unable to find %s IOMMU group", g_container);
+ DPAA2_BUS_ERR("Unable to find %s IOMMU group", fslmc_container);
return -1;
}
DPAA2_BUS_DEBUG("Container: %s has VFIO iommu group id = %d",
- g_container, *groupid);
+ fslmc_container, *groupid);
return 0;
}
}
/* Check whether support for SMMU type IOMMU present or not */
- if (ioctl(fd, VFIO_CHECK_EXTENSION, VFIO_TYPE1_IOMMU)) {
+ if (ioctl(fd, VFIO_CHECK_EXTENSION, fslmc_iommu_type)) {
/* Connect group to container */
ret = ioctl(vfio_group.fd, VFIO_GROUP_SET_CONTAINER, &fd);
if (ret) {
return -errno;
}
- ret = ioctl(fd, VFIO_SET_IOMMU, VFIO_TYPE1_IOMMU);
+ ret = ioctl(fd, VFIO_SET_IOMMU, fslmc_iommu_type);
if (ret) {
DPAA2_BUS_ERR("Failed to setup VFIO iommu");
close(fd);
};
int ret;
+ if (fslmc_iommu_type == RTE_VFIO_NOIOMMU) {
+ DPAA2_BUS_DEBUG("Running in NOIOMMU mode");
+ return 0;
+ }
+
dma_map.size = len;
dma_map.vaddr = vaddr;
};
int ret;
+ if (fslmc_iommu_type == RTE_VFIO_NOIOMMU) {
+ DPAA2_BUS_DEBUG("Running in NOIOMMU mode");
+ return 0;
+ }
+
dma_unmap.size = len;
dma_unmap.iova = vaddr;
}
/* Get Device information */
- ret = ioctl(vfio_group.fd, VFIO_GROUP_GET_DEVICE_FD, g_container);
+ ret = ioctl(vfio_group.fd, VFIO_GROUP_GET_DEVICE_FD, fslmc_container);
if (ret < 0) {
DPAA2_BUS_ERR("Error getting device %s fd from group %d",
- g_container, vfio_group.groupid);
+ fslmc_container, vfio_group.groupid);
close(vfio_group.fd);
rte_vfio_clear_group(vfio_group.fd);
return ret;