src/dpdk/drivers/bus/fslmc/fslmc_vfio.c
int
rte_dpaa2_vfio_setup_intr(struct rte_intr_handle *intr_handle,
			  int vfio_dev_fd,
			  int num_irqs)
{
	int i, ret;

	/* start from MSI-X interrupt type */
	for (i = 0; i < num_irqs; i++) {
		struct vfio_irq_info irq_info = { .argsz = sizeof(irq_info) };
		int fd = -1;

		irq_info.index = i;

		ret = ioctl(vfio_dev_fd, VFIO_DEVICE_GET_IRQ_INFO, &irq_info);
		if (ret < 0) {
			DPAA2_BUS_ERR("Cannot get IRQ(%d) info, error %i (%s)",
				      i, errno, strerror(errno));
			return -1;
		}

		/* if this vector cannot be used with eventfd,
		 * fail if we explicitly
		 * specified interrupt type, otherwise continue
		 */
		if ((irq_info.flags & VFIO_IRQ_INFO_EVENTFD) == 0)
			continue;

		/* set up an eventfd for interrupts */
		fd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
		if (fd < 0) {
			DPAA2_BUS_ERR("Cannot set up eventfd, error %i (%s)",
				      errno, strerror(errno));
			return -1;
		}

		intr_handle->fd = fd;
		intr_handle->type = RTE_INTR_HANDLE_VFIO_MSI;
		intr_handle->vfio_dev_fd = vfio_dev_fd;

		return 0;
	}

	/* if we're here, we haven't found a suitable interrupt vector */
	return -1;
}
/* set up interrupt support (but not enable interrupts) */
set up interrupt support (but not enable interrupts)
set up interrupt support ( but not enable interrupts )
int
rte_dpaa2_vfio_setup_intr(struct rte_intr_handle *intr_handle,
			  int vfio_dev_fd,
			  int num_irqs)
{
	int i, ret;
	for (i = 0; i < num_irqs; i++) {
		struct vfio_irq_info irq_info = { .argsz = sizeof(irq_info) };
		int fd = -1;
		irq_info.index = i;
		ret = ioctl(vfio_dev_fd, VFIO_DEVICE_GET_IRQ_INFO, &irq_info);
		if (ret < 0) {
			DPAA2_BUS_ERR("Cannot get IRQ(%d) info, error %i (%s)",
				      i, errno, strerror(errno));
			return -1;
		}
		if ((irq_info.flags & VFIO_IRQ_INFO_EVENTFD) == 0)
			continue;
		fd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
		if (fd < 0) {
			DPAA2_BUS_ERR("Cannot set up eventfd, error %i (%s)",
				      errno, strerror(errno));
			return -1;
		}
		intr_handle->fd = fd;
		intr_handle->type = RTE_INTR_HANDLE_VFIO_MSI;
		intr_handle->vfio_dev_fd = vfio_dev_fd;
		return 0;
	}
	return -1;
}
int rte_dpaa2_vfio_setup_intr ( struct rte_intr_handle * intr_handle , int vfio_dev_fd , int num_irqs ) { int i , ret ; for ( i = 0 ; i < num_irqs ; i ++ ) { struct vfio_irq_info irq_info = { . argsz = sizeof ( irq_info ) } ; int fd = -1 ; irq_info . index = i ; ret = ioctl ( vfio_dev_fd , VFIO_DEVICE_GET_IRQ_INFO , & irq_info ) ; if ( ret < 0 ) { DPAA2_BUS_ERR ( " " , i , errno , strerror ( errno ) ) ; return -1 ; } if ( ( irq_info . flags & VFIO_IRQ_INFO_EVENTFD ) == 0 ) continue ; fd = eventfd ( 0 , EFD_NONBLOCK | EFD_CLOEXEC ) ; if ( fd < 0 ) { DPAA2_BUS_ERR ( " " , errno , strerror ( errno ) ) ; return -1 ; } intr_handle -> fd = fd ; intr_handle -> type = RTE_INTR_HANDLE_VFIO_MSI ; intr_handle -> vfio_dev_fd = vfio_dev_fd ; return 0 ; } return -1 ; }
set up interrupt support (but not enable interrupts)
set up interrupt support ( but not enable interrupts )
/* start from MSI-X interrupt type */ /* if this vector cannot be used with eventfd,
		 * fail if we explicitly
		 * specified interrupt type, otherwise continue
		 */ /* set up an eventfd for interrupts */ /* if we're here, we haven't found a suitable interrupt vector */