From patchwork Fri Oct 30 05:27:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cunming Liang X-Patchwork-Id: 8309 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id B48E28DAC; Fri, 30 Oct 2015 06:28:13 +0100 (CET) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 13DD88DA8 for ; Fri, 30 Oct 2015 06:28:11 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP; 29 Oct 2015 22:28:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,217,1444719600"; d="scan'208";a="838585685" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga002.jf.intel.com with ESMTP; 29 Oct 2015 22:28:04 -0700 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id t9U5S2ml023212; Fri, 30 Oct 2015 13:28:02 +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 t9U5RwFC028870; Fri, 30 Oct 2015 13:28:00 +0800 Received: (from cliang18@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id t9U5RwX0028866; Fri, 30 Oct 2015 13:27:58 +0800 From: Cunming Liang To: dev@dpdk.org Date: Fri, 30 Oct 2015 13:27:43 +0800 Message-Id: <1446182873-28814-2-git-send-email-cunming.liang@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1446182873-28814-1-git-send-email-cunming.liang@intel.com> References: <1443072831-19065-1-git-send-email-cunming.liang@intel.com> <1446182873-28814-1-git-send-email-cunming.liang@intel.com> Subject: [dpdk-dev] [PATCH v2 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 Acked-by: Helin Zhang --- 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 {