Since the older kernel version do not implement the device request
interface for vfio, so when build on the kernel < v4.0.0, which is
the version begin to add the device request interface, it will
throw the error to show “VFIO_PCI_REQ_IRQ_INDEX” is undeclared.
This patch aim to fix this compile issue by add the macro
“HAVE_VFIO_DEV_REQ_INTERFACE” after checking the kernel version.
Fixes:
0eb8a1c4c786 ("vfio: add request notifier interrupt")
Fixes:
c115fd000c32 ("vfio: handle hotplug request notifier")
Signed-off-by: Jeff Guo <jia.guo@intel.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
+#ifdef HAVE_VFIO_DEV_REQ_INTERFACE
static void
pci_vfio_req_handler(void *param)
{
static void
pci_vfio_req_handler(void *param)
{
static int
pci_vfio_is_ioport_bar(int vfio_dev_fd, int bar_index)
static int
pci_vfio_is_ioport_bar(int vfio_dev_fd, int bar_index)
struct pci_map *maps;
dev->intr_handle.fd = -1;
struct pci_map *maps;
dev->intr_handle.fd = -1;
+#ifdef HAVE_VFIO_DEV_REQ_INTERFACE
dev->vfio_req_intr_handle.fd = -1;
dev->vfio_req_intr_handle.fd = -1;
/* store PCI address string */
snprintf(pci_addr, sizeof(pci_addr), PCI_PRI_FMT,
/* store PCI address string */
snprintf(pci_addr, sizeof(pci_addr), PCI_PRI_FMT,
+#ifdef HAVE_VFIO_DEV_REQ_INTERFACE
if (pci_vfio_enable_notifier(dev, vfio_dev_fd) != 0) {
RTE_LOG(ERR, EAL, "Error setting up notifier!\n");
goto err_vfio_res;
}
if (pci_vfio_enable_notifier(dev, vfio_dev_fd) != 0) {
RTE_LOG(ERR, EAL, "Error setting up notifier!\n");
goto err_vfio_res;
}
TAILQ_INSERT_TAIL(vfio_res_list, vfio_res, next);
return 0;
TAILQ_INSERT_TAIL(vfio_res_list, vfio_res, next);
return 0;
struct pci_map *maps;
dev->intr_handle.fd = -1;
struct pci_map *maps;
dev->intr_handle.fd = -1;
+#ifdef HAVE_VFIO_DEV_REQ_INTERFACE
dev->vfio_req_intr_handle.fd = -1;
dev->vfio_req_intr_handle.fd = -1;
/* store PCI address string */
snprintf(pci_addr, sizeof(pci_addr), PCI_PRI_FMT,
/* store PCI address string */
snprintf(pci_addr, sizeof(pci_addr), PCI_PRI_FMT,
/* we need save vfio_dev_fd, so it can be used during release */
dev->intr_handle.vfio_dev_fd = vfio_dev_fd;
/* we need save vfio_dev_fd, so it can be used during release */
dev->intr_handle.vfio_dev_fd = vfio_dev_fd;
+#ifdef HAVE_VFIO_DEV_REQ_INTERFACE
dev->vfio_req_intr_handle.vfio_dev_fd = vfio_dev_fd;
dev->vfio_req_intr_handle.vfio_dev_fd = vfio_dev_fd;
return 0;
err_vfio_dev_fd:
return 0;
err_vfio_dev_fd:
snprintf(pci_addr, sizeof(pci_addr), PCI_PRI_FMT,
loc->domain, loc->bus, loc->devid, loc->function);
snprintf(pci_addr, sizeof(pci_addr), PCI_PRI_FMT,
loc->domain, loc->bus, loc->devid, loc->function);
+#ifdef HAVE_VFIO_DEV_REQ_INTERFACE
ret = pci_vfio_disable_notifier(dev);
if (ret) {
RTE_LOG(ERR, EAL, "fail to disable req notifier.\n");
return -1;
}
ret = pci_vfio_disable_notifier(dev);
if (ret) {
RTE_LOG(ERR, EAL, "fail to disable req notifier.\n");
return -1;
}
if (close(dev->intr_handle.fd) < 0) {
RTE_LOG(INFO, EAL, "Error when closing eventfd file descriptor for %s\n",
pci_addr);
if (close(dev->intr_handle.fd) < 0) {
RTE_LOG(INFO, EAL, "Error when closing eventfd file descriptor for %s\n",
pci_addr);
return -1;
switch (pdev->kdrv) {
return -1;
switch (pdev->kdrv) {
+#ifdef HAVE_VFIO_DEV_REQ_INTERFACE
case RTE_KDRV_VFIO:
/*
* vfio kernel module guaranty the pci device would not be
case RTE_KDRV_VFIO:
/*
* vfio kernel module guaranty the pci device would not be
rte_dev_event_callback_process(dev->name,
RTE_DEV_EVENT_REMOVE);
break;
rte_dev_event_callback_process(dev->name,
RTE_DEV_EVENT_REMOVE);
break;
case RTE_KDRV_IGB_UIO:
case RTE_KDRV_UIO_GENERIC:
case RTE_KDRV_NIC_UIO:
case RTE_KDRV_IGB_UIO:
case RTE_KDRV_UIO_GENERIC:
case RTE_KDRV_NIC_UIO:
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)
#define VFIO_PRESENT
#endif /* kernel version >= 3.6.0 */
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)
#define VFIO_PRESENT
#endif /* kernel version >= 3.6.0 */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0)
+#define HAVE_VFIO_DEV_REQ_INTERFACE
+#endif /* kernel version >= 4.0.0 */
#endif /* RTE_EAL_VFIO */
#ifdef VFIO_PRESENT
#endif /* RTE_EAL_VFIO */
#ifdef VFIO_PRESENT
+#ifdef HAVE_VFIO_DEV_REQ_INTERFACE
/* enable req notifier */
static int
vfio_enable_req(const struct rte_intr_handle *intr_handle)
/* enable req notifier */
static int
vfio_enable_req(const struct rte_intr_handle *intr_handle)
static int
uio_intx_intr_disable(const struct rte_intr_handle *intr_handle)
static int
uio_intx_intr_disable(const struct rte_intr_handle *intr_handle)
if (vfio_enable_intx(intr_handle))
return -1;
break;
if (vfio_enable_intx(intr_handle))
return -1;
break;
+#ifdef HAVE_VFIO_DEV_REQ_INTERFACE
case RTE_INTR_HANDLE_VFIO_REQ:
if (vfio_enable_req(intr_handle))
return -1;
break;
case RTE_INTR_HANDLE_VFIO_REQ:
if (vfio_enable_req(intr_handle))
return -1;
break;
#endif
/* not used at this moment */
case RTE_INTR_HANDLE_DEV_EVENT:
#endif
/* not used at this moment */
case RTE_INTR_HANDLE_DEV_EVENT:
if (vfio_disable_intx(intr_handle))
return -1;
break;
if (vfio_disable_intx(intr_handle))
return -1;
break;
+#ifdef HAVE_VFIO_DEV_REQ_INTERFACE
case RTE_INTR_HANDLE_VFIO_REQ:
if (vfio_disable_req(intr_handle))
return -1;
break;
case RTE_INTR_HANDLE_VFIO_REQ:
if (vfio_disable_req(intr_handle))
return -1;
break;
#endif
/* not used at this moment */
case RTE_INTR_HANDLE_DEV_EVENT:
#endif
/* not used at this moment */
case RTE_INTR_HANDLE_DEV_EVENT:
case RTE_INTR_HANDLE_VFIO_LEGACY:
bytes_read = sizeof(buf.vfio_intr_count);
break;
case RTE_INTR_HANDLE_VFIO_LEGACY:
bytes_read = sizeof(buf.vfio_intr_count);
break;
+#ifdef HAVE_VFIO_DEV_REQ_INTERFACE
+ case RTE_INTR_HANDLE_VFIO_REQ:
+ bytes_read = 0;
+ call = true;
+ break;
+#endif
#endif
case RTE_INTR_HANDLE_VDEV:
case RTE_INTR_HANDLE_EXT:
#endif
case RTE_INTR_HANDLE_VDEV:
case RTE_INTR_HANDLE_EXT:
bytes_read = 0;
call = true;
break;
bytes_read = 0;
call = true;
break;
- case RTE_INTR_HANDLE_VFIO_REQ:
- bytes_read = 0;
- call = true;
- break;
default:
bytes_read = 1;
break;
default:
bytes_read = 1;
break;