From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id E7A7E7EEF for ; Wed, 4 Nov 2015 07:07:55 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 03 Nov 2015 22:07:54 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,241,1444719600"; d="scan'208";a="811314998" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga001.jf.intel.com with ESMTP; 03 Nov 2015 22:07:54 -0800 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id tA467qGq008741; Wed, 4 Nov 2015 14:07:52 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id tA467mSX007506; Wed, 4 Nov 2015 14:07:50 +0800 Received: (from cliang18@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id tA467mrv007502; Wed, 4 Nov 2015 14:07:48 +0800 From: Cunming Liang To: dev@dpdk.org Date: Wed, 4 Nov 2015 14:07:31 +0800 Message-Id: <1446617263-7448-2-git-send-email-cunming.liang@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1446617263-7448-1-git-send-email-cunming.liang@intel.com> References: <1446182873-28814-2-git-send-email-cunming.liang@intel.com> <1446617263-7448-1-git-send-email-cunming.liang@intel.com> Subject: [dpdk-dev] [PATCH v3 01/13] eal: vfio map misc intr to vector zero X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Nov 2015 06:07:56 -0000 During VFIO_DEVICE_SET_IRQS, the previous order is {Q0_fd, ... Qn_fd, misc_fd}. The vector number of misc is indeterminable which is ugly to some NIC(e.g. i40e, fm10k). The patch adjusts the order in {misc_fd, Q0_fd, ... Qn_fd}, always reserve the first vector to misc interrupt. v3 changes: - rename MISC_VEC_ID to RTE_INTR_VEC_ZERO_OFFSET - rename RX_VEC_START to RTE_INTR_VEC_RXTX_OFFSET - add macro definition in bsd header file Signed-off-by: Cunming Liang --- .../bsdapp/eal/include/exec-env/rte_interrupts.h | 3 +++ lib/librte_eal/linuxapp/eal/eal_interrupts.c | 19 +++++++++++++------ .../linuxapp/eal/include/exec-env/rte_interrupts.h | 2 ++ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/lib/librte_eal/bsdapp/eal/include/exec-env/rte_interrupts.h b/lib/librte_eal/bsdapp/eal/include/exec-env/rte_interrupts.h index 88d4ae1..05bb484 100644 --- a/lib/librte_eal/bsdapp/eal/include/exec-env/rte_interrupts.h +++ b/lib/librte_eal/bsdapp/eal/include/exec-env/rte_interrupts.h @@ -38,6 +38,9 @@ #ifndef _RTE_BSDAPP_INTERRUPTS_H_ #define _RTE_BSDAPP_INTERRUPTS_H_ +#define RTE_INTR_VEC_ZERO_OFFSET 0 +#define RTE_INTR_VEC_RXTX_OFFSET 1 + enum rte_intr_handle_type { RTE_INTR_HANDLE_UNKNOWN = 0, RTE_INTR_HANDLE_UIO, /**< uio device handle */ diff --git a/lib/librte_eal/linuxapp/eal/eal_interrupts.c b/lib/librte_eal/linuxapp/eal/eal_interrupts.c index a4b9506..8758239 100644 --- a/lib/librte_eal/linuxapp/eal/eal_interrupts.c +++ b/lib/librte_eal/linuxapp/eal/eal_interrupts.c @@ -301,8 +301,10 @@ vfio_enable_msix(struct rte_intr_handle *intr_handle) { irq_set->index = VFIO_PCI_MSIX_IRQ_INDEX; irq_set->start = 0; fd_ptr = (int *) &irq_set->data; - memcpy(fd_ptr, intr_handle->efds, sizeof(intr_handle->efds)); - fd_ptr[intr_handle->max_intr - 1] = intr_handle->fd; + /* INTR vector offset 0 reserve for non-efds mapping */ + fd_ptr[RTE_INTR_VEC_ZERO_OFFSET] = intr_handle->fd; + memcpy(&fd_ptr[RTE_INTR_VEC_RXTX_OFFSET], intr_handle->efds, + sizeof(*intr_handle->efds) * intr_handle->nb_efd); ret = ioctl(intr_handle->vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set); @@ -1083,10 +1085,14 @@ rte_intr_rx_ctl(struct rte_intr_handle *intr_handle, int epfd, struct rte_epoll_event *rev; struct rte_epoll_data *epdata; int epfd_op; + unsigned int efd_idx; int rc = 0; + efd_idx = (vec >= RTE_INTR_VEC_RXTX_OFFSET) ? + (vec - RTE_INTR_VEC_RXTX_OFFSET) : vec; + if (!intr_handle || intr_handle->nb_efd == 0 || - vec >= intr_handle->nb_efd) { + efd_idx >= intr_handle->nb_efd) { RTE_LOG(ERR, EAL, "Wrong intr vector number.\n"); return -EPERM; } @@ -1094,7 +1100,7 @@ rte_intr_rx_ctl(struct rte_intr_handle *intr_handle, int epfd, switch (op) { case RTE_INTR_EVENT_ADD: epfd_op = EPOLL_CTL_ADD; - rev = &intr_handle->elist[vec]; + rev = &intr_handle->elist[efd_idx]; if (rev->status != RTE_EPOLL_INVALID) { RTE_LOG(INFO, EAL, "Event already been added.\n"); return -EEXIST; @@ -1106,7 +1112,8 @@ rte_intr_rx_ctl(struct rte_intr_handle *intr_handle, int epfd, epdata->data = data; epdata->cb_fun = (rte_intr_event_cb_t)eal_intr_proc_rxtx_intr; epdata->cb_arg = (void *)intr_handle; - rc = rte_epoll_ctl(epfd, epfd_op, intr_handle->efds[vec], rev); + rc = rte_epoll_ctl(epfd, epfd_op, + intr_handle->efds[efd_idx], rev); if (!rc) RTE_LOG(DEBUG, EAL, "efd %d associated with vec %d added on epfd %d" @@ -1116,7 +1123,7 @@ rte_intr_rx_ctl(struct rte_intr_handle *intr_handle, int epfd, break; case RTE_INTR_EVENT_DEL: epfd_op = EPOLL_CTL_DEL; - rev = &intr_handle->elist[vec]; + rev = &intr_handle->elist[efd_idx]; if (rev->status == RTE_EPOLL_INVALID) { RTE_LOG(INFO, EAL, "Event does not exist.\n"); return -EPERM; diff --git a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_interrupts.h b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_interrupts.h index b095b86..8da81e7 100644 --- a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_interrupts.h +++ b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_interrupts.h @@ -39,6 +39,8 @@ #define _RTE_LINUXAPP_INTERRUPTS_H_ #define RTE_MAX_RXTX_INTR_VEC_ID 32 +#define RTE_INTR_VEC_ZERO_OFFSET 0 +#define RTE_INTR_VEC_RXTX_OFFSET 1 enum rte_intr_handle_type { RTE_INTR_HANDLE_UNKNOWN = 0, -- 2.4.3