*** D:\WORK\project\platform\two\dpdk-18.08\eal_vfio.c 2018-11-27 07:36:00.000000000 +0800 --- D:\WORK\project\platform\two\dpdk-18.08\dpdk-18.11\lib\librte_eal\linuxapp\eal\eal_vfio.c 2018-12-28 13:27:56.000000000 +0800 *************** *** 569,580 **** --- 569,610 ---- vfio_cfg->vfio_groups[i].devices = 0; vfio_cfg->vfio_active_groups--; return 0; } + + static const struct vfio_iommu_type * + vfio_get_supported_extensions(int vfio_container_fd) + { + int ret; + unsigned idx = 0; + for (idx = 0; idx < RTE_DIM(iommu_types); idx++) { + const struct vfio_iommu_type *t = &iommu_types[idx]; + + ret = ioctl(vfio_container_fd, VFIO_CHECK_EXTENSION, + t->type_id); + if (ret < 0) { + RTE_LOG(ERR, EAL, " could not get IOMMU type, " + "error %i (%s)\n", errno, + strerror(errno)); + return NULL; + } else if (ret == 1) { + /* we found a supported extension */ + return t; + } + RTE_LOG(DEBUG, EAL, " IOMMU type %d (%s) is %s\n", + t->type_id, t->name, + ret ? "supported" : "not supported"); + } + + /* if we didn't find any supported IOMMU types, fail */ + return NULL; + } + + int rte_vfio_setup_device(const char *sysfs_base, const char *dev_addr, int *vfio_dev_fd, struct vfio_device_info *device_info) { struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config; rte_rwlock_t *mem_lock = &mcfg->memory_hotplug_lock; *************** *** 742,753 **** --- 772,785 ---- } if (ret) RTE_LOG(DEBUG, EAL, "Memory event callbacks not supported\n"); else RTE_LOG(DEBUG, EAL, "Installed memory event callback for VFIO\n"); } + } else { + vfio_cfg->vfio_iommu_type = vfio_get_supported_extensions(vfio_container_fd); } /* get a file descriptor for the device */ *vfio_dev_fd = ioctl(vfio_group_fd, VFIO_GROUP_GET_DEVICE_FD, dev_addr); if (*vfio_dev_fd < 0) { /* if we cannot get a device fd, this implies a problem with