From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 7757B5B12 for ; Tue, 16 Oct 2018 13:39:32 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Oct 2018 04:39:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,388,1534834800"; d="scan'208";a="81609265" Received: from jeffguo-s2600wt2.sh.intel.com (HELO localhost.localdomain) ([10.67.110.10]) by orsmga007.jf.intel.com with ESMTP; 16 Oct 2018 04:39:30 -0700 From: Jeff Guo To: anatoly.burakov@intel.com, ferruh.yigit@intel.com, thomas@monjalon.net Cc: dev@dpdk.org, jia.guo@intel.com Date: Tue, 16 Oct 2018 19:42:33 +0800 Message-Id: <1539690153-133112-1-git-send-email-jia.guo@intel.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 2/2] vfio: fix build issue X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Oct 2018 11:39:33 -0000 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. Signed-off-by: Jeff Guo --- drivers/bus/pci/linux/pci_vfio.c | 12 ++++++++++++ drivers/bus/pci/pci_common.c | 2 ++ lib/librte_eal/common/include/rte_vfio.h | 3 +++ lib/librte_eal/linuxapp/eal/eal_interrupts.c | 17 ++++++++++++----- 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/drivers/bus/pci/linux/pci_vfio.c b/drivers/bus/pci/linux/pci_vfio.c index 72d77bf..cc2387e 100644 --- a/drivers/bus/pci/linux/pci_vfio.c +++ b/drivers/bus/pci/linux/pci_vfio.c @@ -279,6 +279,7 @@ pci_vfio_setup_interrupts(struct rte_pci_device *dev, int vfio_dev_fd) return -1; } +#ifdef HAVE_VFIO_DEV_REQ_INTERFACE static void pci_vfio_req_handler(void *param) { @@ -384,6 +385,7 @@ pci_vfio_disable_notifier(struct rte_pci_device *dev) return 0; } +#endif static int pci_vfio_is_ioport_bar(int vfio_dev_fd, int bar_index) @@ -625,7 +627,9 @@ pci_vfio_map_resource_primary(struct rte_pci_device *dev) struct pci_map *maps; dev->intr_handle.fd = -1; +#ifdef HAVE_VFIO_DEV_REQ_INTERFACE dev->vfio_req_intr_handle.fd = -1; +#endif /* store PCI address string */ snprintf(pci_addr, sizeof(pci_addr), PCI_PRI_FMT, @@ -736,11 +740,13 @@ pci_vfio_map_resource_primary(struct rte_pci_device *dev) goto err_vfio_res; } +#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; } +#endif TAILQ_INSERT_TAIL(vfio_res_list, vfio_res, next); return 0; @@ -766,7 +772,9 @@ pci_vfio_map_resource_secondary(struct rte_pci_device *dev) struct pci_map *maps; dev->intr_handle.fd = -1; +#ifdef HAVE_VFIO_DEV_REQ_INTERFACE dev->vfio_req_intr_handle.fd = -1; +#endif /* store PCI address string */ snprintf(pci_addr, sizeof(pci_addr), PCI_PRI_FMT, @@ -807,7 +815,9 @@ pci_vfio_map_resource_secondary(struct rte_pci_device *dev) /* 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; +#endif return 0; err_vfio_dev_fd: @@ -880,12 +890,14 @@ pci_vfio_unmap_resource_primary(struct rte_pci_device *dev) 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; } +#endif if (close(dev->intr_handle.fd) < 0) { RTE_LOG(INFO, EAL, "Error when closing eventfd file descriptor for %s\n", pci_addr); diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c index 5085c34..4b3749a 100644 --- a/drivers/bus/pci/pci_common.c +++ b/drivers/bus/pci/pci_common.c @@ -444,6 +444,7 @@ pci_hot_unplug_handler(struct rte_device *dev) 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 @@ -454,6 +455,7 @@ pci_hot_unplug_handler(struct rte_device *dev) rte_dev_event_callback_process(dev->name, RTE_DEV_EVENT_REMOVE); break; +#endif case RTE_KDRV_IGB_UIO: case RTE_KDRV_UIO_GENERIC: case RTE_KDRV_NIC_UIO: diff --git a/lib/librte_eal/common/include/rte_vfio.h b/lib/librte_eal/common/include/rte_vfio.h index f6617e0..7d66438 100644 --- a/lib/librte_eal/common/include/rte_vfio.h +++ b/lib/librte_eal/common/include/rte_vfio.h @@ -24,6 +24,9 @@ extern "C" { #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 diff --git a/lib/librte_eal/linuxapp/eal/eal_interrupts.c b/lib/librte_eal/linuxapp/eal/eal_interrupts.c index 7f611b3..767b508 100644 --- a/lib/librte_eal/linuxapp/eal/eal_interrupts.c +++ b/lib/librte_eal/linuxapp/eal/eal_interrupts.c @@ -309,6 +309,7 @@ vfio_disable_msix(const struct rte_intr_handle *intr_handle) { return ret; } +#ifdef HAVE_VFIO_DEV_REQ_INTERFACE /* enable req notifier */ static int vfio_enable_req(const struct rte_intr_handle *intr_handle) @@ -367,6 +368,7 @@ vfio_disable_req(const struct rte_intr_handle *intr_handle) return ret; } #endif +#endif static int uio_intx_intr_disable(const struct rte_intr_handle *intr_handle) @@ -614,11 +616,13 @@ rte_intr_enable(const struct rte_intr_handle *intr_handle) 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; #endif +#endif /* not used at this moment */ case RTE_INTR_HANDLE_DEV_EVENT: return -1; @@ -668,11 +672,12 @@ rte_intr_disable(const struct rte_intr_handle *intr_handle) 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; - +#endif #endif /* not used at this moment */ case RTE_INTR_HANDLE_DEV_EVENT: @@ -739,6 +744,12 @@ eal_intr_process_interrupts(struct epoll_event *events, int nfds) 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: @@ -749,10 +760,6 @@ eal_intr_process_interrupts(struct epoll_event *events, int nfds) bytes_read = 0; call = true; break; - case RTE_INTR_HANDLE_VFIO_REQ: - bytes_read = 0; - call = true; - break; default: bytes_read = 1; break; -- 2.7.4