From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 9693A8E58 for ; Thu, 24 Sep 2015 07:34:04 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP; 23 Sep 2015 22:34:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,579,1437462000"; d="scan'208";a="775850113" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga001.jf.intel.com with ESMTP; 23 Sep 2015 22:34:04 -0700 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id t8O5Y1aS027384; Thu, 24 Sep 2015 13:34:01 +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 t8O5XvMG019122; Thu, 24 Sep 2015 13:33:59 +0800 Received: (from cliang18@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id t8O5Xv8T019118; Thu, 24 Sep 2015 13:33:57 +0800 From: Cunming Liang To: dev@dpdk.org Date: Thu, 24 Sep 2015 13:33:41 +0800 Message-Id: <1443072831-19065-2-git-send-email-cunming.liang@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1443072831-19065-1-git-send-email-cunming.liang@intel.com> References: <1443072831-19065-1-git-send-email-cunming.liang@intel.com> Subject: [dpdk-dev] [PATCH v1 01/11] eal/linux: 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: Thu, 24 Sep 2015 05:34:05 -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. Signed-off-by: Cunming Liang --- lib/librte_eal/linuxapp/eal/eal_interrupts.c | 18 ++++++++++++------ .../linuxapp/eal/include/exec-env/rte_interrupts.h | 3 +++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/lib/librte_eal/linuxapp/eal/eal_interrupts.c b/lib/librte_eal/linuxapp/eal/eal_interrupts.c index 078318c..8e76a7a 100644 --- a/lib/librte_eal/linuxapp/eal/eal_interrupts.c +++ b/lib/librte_eal/linuxapp/eal/eal_interrupts.c @@ -300,8 +300,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; + fd_ptr[MISC_VEC_ID] = intr_handle->fd; + /* follow up with misc(0) interrupt */ + memcpy(&fd_ptr[RX_VEC_START], intr_handle->efds, + sizeof(*intr_handle->efds) * intr_handle->nb_efd); ret = ioctl(intr_handle->vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set); @@ -1068,10 +1070,13 @@ 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 >= RX_VEC_START) ? (vec - RX_VEC_START) : 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; } @@ -1079,7 +1084,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; @@ -1091,7 +1096,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" @@ -1101,7 +1107,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 45071b7..b8fd318 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 @@ -77,6 +77,9 @@ struct rte_epoll_event { struct rte_epoll_data epdata; }; +#define MISC_VEC_ID (0) +#define RX_VEC_START (MISC_VEC_ID + 1) + /** Handle for interrupts. */ struct rte_intr_handle { union { -- 2.4.3