strerror(errno));
return -1;
}
- return 0;
+ return -ENOENT;
}
/* noiommu group found */
}
vfio_group_fd = mp_rep->fds[0];
} else if (p->result == SOCKET_NO_FD) {
RTE_LOG(ERR, EAL, " bad VFIO group fd\n");
- vfio_group_fd = 0;
+ vfio_group_fd = -ENOENT;
}
}
free(mp_reply.msgs);
- if (vfio_group_fd < 0)
+ if (vfio_group_fd < 0 && vfio_group_fd != -ENOENT)
RTE_LOG(ERR, EAL, " cannot request group fd\n");
return vfio_group_fd;
}
}
vfio_group_fd = vfio_open_group_fd(iommu_group_num);
- if (vfio_group_fd <= 0) {
+ if (vfio_group_fd < 0) {
RTE_LOG(ERR, EAL, "Failed to open group %d\n", iommu_group_num);
- return -1;
+ return vfio_group_fd;
}
cur_grp->group_num = 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 the actual group fd */
vfio_group_fd = rte_vfio_get_group_fd(iommu_group_num);
- if (vfio_group_fd < 0)
+ if (vfio_group_fd < 0 && vfio_group_fd != -ENOENT)
return -1;
- /* if group_fd == 0, that means the device isn't managed by VFIO */
- if (vfio_group_fd == 0) {
+ /*
+ * if vfio_group_fd == -ENOENT, that means the device
+ * isn't managed by VFIO
+ */
+ if (vfio_group_fd == -ENOENT) {
RTE_LOG(WARNING, EAL, " %s not managed by VFIO driver, skipping\n",
dev_addr);
return 1;
/* 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, "
/* get the actual group fd */
vfio_group_fd = rte_vfio_get_group_fd(iommu_group_num);
- if (vfio_group_fd <= 0) {
+ if (vfio_group_fd < 0) {
RTE_LOG(INFO, EAL, "rte_vfio_get_group_fd failed for %s\n",
dev_addr);
- ret = -1;
+ ret = vfio_group_fd;
goto out;
}
/* 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");
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;
}