src/dpdk/drivers/bus/pci/linux/pci_vfio.c
static int
pci_vfio_enable_notifier(struct rte_pci_device *dev, int vfio_dev_fd)
{
	int ret;
	int fd = -1;

	/* set up an eventfd for req notifier */
	fd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
	if (fd < 0) {
		RTE_LOG(ERR, EAL, "Cannot set up eventfd, error %i (%s)\n",
			errno, strerror(errno));
		return -1;
	}

	dev->vfio_req_intr_handle.fd = fd;
	dev->vfio_req_intr_handle.type = RTE_INTR_HANDLE_VFIO_REQ;
	dev->vfio_req_intr_handle.vfio_dev_fd = vfio_dev_fd;

	ret = rte_intr_callback_register(&dev->vfio_req_intr_handle,
					 pci_vfio_req_handler,
					 (void *)&dev->device);
	if (ret) {
		RTE_LOG(ERR, EAL, "Fail to register req notifier handler.\n");
		goto error;
	}

	ret = rte_intr_enable(&dev->vfio_req_intr_handle);
	if (ret) {
		RTE_LOG(ERR, EAL, "Fail to enable req notifier.\n");
		ret = rte_intr_callback_unregister(&dev->vfio_req_intr_handle,
						 pci_vfio_req_handler,
						 (void *)&dev->device);
		if (ret < 0)
			RTE_LOG(ERR, EAL,
				"Fail to unregister req notifier handler.\n");
		goto error;
	}

	return 0;
error:
	close(fd);

	dev->vfio_req_intr_handle.fd = -1;
	dev->vfio_req_intr_handle.type = RTE_INTR_HANDLE_UNKNOWN;
	dev->vfio_req_intr_handle.vfio_dev_fd = -1;

	return -1;
}
/* enable notifier (only enable req now) */
enable notifier (only enable req now)
enable notifier ( only enable req now )
static int
pci_vfio_enable_notifier(struct rte_pci_device *dev, int vfio_dev_fd)
{
	int ret;
	int fd = -1;
	fd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
	if (fd < 0) {
		RTE_LOG(ERR, EAL, "Cannot set up eventfd, error %i (%s)\n",
			errno, strerror(errno));
		return -1;
	}
	dev->vfio_req_intr_handle.fd = fd;
	dev->vfio_req_intr_handle.type = RTE_INTR_HANDLE_VFIO_REQ;
	dev->vfio_req_intr_handle.vfio_dev_fd = vfio_dev_fd;
	ret = rte_intr_callback_register(&dev->vfio_req_intr_handle,
					 pci_vfio_req_handler,
					 (void *)&dev->device);
	if (ret) {
		RTE_LOG(ERR, EAL, "Fail to register req notifier handler.\n");
		goto error;
	}
	ret = rte_intr_enable(&dev->vfio_req_intr_handle);
	if (ret) {
		RTE_LOG(ERR, EAL, "Fail to enable req notifier.\n");
		ret = rte_intr_callback_unregister(&dev->vfio_req_intr_handle,
						 pci_vfio_req_handler,
						 (void *)&dev->device);
		if (ret < 0)
			RTE_LOG(ERR, EAL,
				"Fail to unregister req notifier handler.\n");
		goto error;
	}
	return 0;
error:
	close(fd);
	dev->vfio_req_intr_handle.fd = -1;
	dev->vfio_req_intr_handle.type = RTE_INTR_HANDLE_UNKNOWN;
	dev->vfio_req_intr_handle.vfio_dev_fd = -1;
	return -1;
}
static int pci_vfio_enable_notifier ( struct rte_pci_device * dev , int vfio_dev_fd ) { int ret ; int fd = -1 ; fd = eventfd ( 0 , EFD_NONBLOCK | EFD_CLOEXEC ) ; if ( fd < 0 ) { RTE_LOG ( ERR , EAL , " \n " , errno , strerror ( errno ) ) ; return -1 ; } dev -> vfio_req_intr_handle . fd = fd ; dev -> vfio_req_intr_handle . type = RTE_INTR_HANDLE_VFIO_REQ ; dev -> vfio_req_intr_handle . vfio_dev_fd = vfio_dev_fd ; ret = rte_intr_callback_register ( & dev -> vfio_req_intr_handle , pci_vfio_req_handler , ( void * ) & dev -> device ) ; if ( ret ) { RTE_LOG ( ERR , EAL , " \n " ) ; goto error ; } ret = rte_intr_enable ( & dev -> vfio_req_intr_handle ) ; if ( ret ) { RTE_LOG ( ERR , EAL , " \n " ) ; ret = rte_intr_callback_unregister ( & dev -> vfio_req_intr_handle , pci_vfio_req_handler , ( void * ) & dev -> device ) ; if ( ret < 0 ) RTE_LOG ( ERR , EAL , " \n " ) ; goto error ; } return 0 ; error : close ( fd ) ; dev -> vfio_req_intr_handle . fd = -1 ; dev -> vfio_req_intr_handle . type = RTE_INTR_HANDLE_UNKNOWN ; dev -> vfio_req_intr_handle . vfio_dev_fd = -1 ; return -1 ; }
enable notifier (only enable req now)
enable notifier ( only enable req now )
/* set up an eventfd for req notifier */