struct rte_mp_reply mp_reply = {0};
struct timespec ts = {.tv_sec = 5, .tv_nsec = 0};
struct vfio_mp_param *p = (struct vfio_mp_param *)mp_req.param;
+ const struct internal_config *internal_conf =
+ eal_get_internal_configuration();
/* if primary, try to open the group */
- if (internal_config.process_type == RTE_PROC_PRIMARY) {
+ if (internal_conf->process_type == RTE_PROC_PRIMARY) {
/* try regular group format */
snprintf(filename, sizeof(filename),
VFIO_GROUP_FMT, iommu_group_num);
int vfio_container_fd;
int vfio_group_fd;
int iommu_group_num;
+ rte_uuid_t vf_token;
int i, ret;
+ const struct internal_config *internal_conf =
+ eal_get_internal_configuration();
/* get group number */
ret = rte_vfio_get_group_num(sysfs_base, dev_addr, &iommu_group_num);
* Note this can happen several times with the hotplug
* functionality.
*/
- if (internal_config.process_type == RTE_PROC_PRIMARY &&
+ if (internal_conf->process_type == RTE_PROC_PRIMARY &&
vfio_cfg->vfio_active_groups == 1 &&
vfio_group_device_count(vfio_group_fd) == 0) {
const struct vfio_iommu_type *t;
/* we have successfully initialized VFIO, notify user */
const struct vfio_iommu_type *t =
default_vfio_cfg->vfio_iommu_type;
- RTE_LOG(NOTICE, EAL, " using IOMMU type %d (%s)\n",
+ RTE_LOG(INFO, EAL, " using IOMMU type %d (%s)\n",
t->type_id, t->name);
}
+ rte_eal_vfio_get_vf_token(vf_token);
+
+ /* get a file descriptor for the device with VF token firstly */
+ if (!rte_uuid_is_null(vf_token)) {
+ char vf_token_str[RTE_UUID_STRLEN];
+ char dev[PATH_MAX];
+
+ rte_uuid_unparse(vf_token, vf_token_str, sizeof(vf_token_str));
+ snprintf(dev, sizeof(dev),
+ "%s vf_token=%s", dev_addr, vf_token_str);
+
+ *vfio_dev_fd = ioctl(vfio_group_fd, VFIO_GROUP_GET_DEVICE_FD,
+ dev);
+ if (*vfio_dev_fd >= 0)
+ goto dev_get_info;
+ }
+
/* 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) {
}
/* test and setup the device */
+dev_get_info:
ret = ioctl(*vfio_dev_fd, VFIO_DEVICE_GET_INFO, device_info);
if (ret) {
RTE_LOG(ERR, EAL, " %s cannot get device info, "
rte_vfio_release_device(const char *sysfs_base, const char *dev_addr,
int vfio_dev_fd)
{
- struct vfio_group_status group_status = {
- .argsz = sizeof(group_status)
- };
struct vfio_config *vfio_cfg;
int vfio_group_fd;
int iommu_group_num;
/* initialize group list */
int i, j;
int vfio_available;
+ const struct internal_config *internal_conf =
+ eal_get_internal_configuration();
rte_spinlock_recursive_t lock = RTE_SPINLOCK_RECURSIVE_INITIALIZER;
return 0;
}
- if (internal_config.process_type == RTE_PROC_PRIMARY) {
+ if (internal_conf->process_type == RTE_PROC_PRIMARY) {
/* open a new container */
default_vfio_cfg->vfio_container_fd =
rte_vfio_get_container_fd();
/* check if we have VFIO driver enabled */
if (default_vfio_cfg->vfio_container_fd != -1) {
- RTE_LOG(NOTICE, EAL, "VFIO support initialized\n");
+ RTE_LOG(INFO, EAL, "VFIO support initialized\n");
default_vfio_cfg->vfio_enabled = 1;
} else {
RTE_LOG(NOTICE, EAL, "VFIO support could not be initialized\n");
struct timespec ts = {.tv_sec = 5, .tv_nsec = 0};
struct vfio_mp_param *p = (struct vfio_mp_param *)mp_req.param;
int container_fd;
+ const struct internal_config *internal_conf =
+ eal_get_internal_configuration();
if (default_vfio_cfg->vfio_enabled)
return default_vfio_cfg->vfio_container_fd;
- if (internal_config.process_type == RTE_PROC_PRIMARY) {
+ if (internal_conf->process_type == RTE_PROC_PRIMARY) {
/* if we were secondary process we would try requesting
* container fd from the primary, but we're the primary
* process so just exit here
int ret = ioctl(vfio_container_fd, VFIO_SET_IOMMU,
t->type_id);
if (!ret) {
- RTE_LOG(NOTICE, EAL, " using IOMMU type %d (%s)\n",
+ RTE_LOG(INFO, EAL, " using IOMMU type %d (%s)\n",
t->type_id, t->name);
return t;
}
struct rte_mp_reply mp_reply = {0};
struct timespec ts = {.tv_sec = 5, .tv_nsec = 0};
struct vfio_mp_param *p = (struct vfio_mp_param *)mp_req.param;
+ const struct internal_config *internal_conf =
+ eal_get_internal_configuration();
/* if we're in a primary process, try to open the container */
- if (internal_config.process_type == RTE_PROC_PRIMARY) {
+ if (internal_conf->process_type == RTE_PROC_PRIMARY) {
vfio_container_fd = open(VFIO_CONTAINER_PATH, O_RDWR);
if (vfio_container_fd < 0) {
RTE_LOG(ERR, EAL, " cannot open VFIO container, "