From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 6CC208F9D for ; Wed, 4 Nov 2015 07:08:02 +0100 (CET) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP; 03 Nov 2015 22:08:01 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,241,1444719600"; d="scan'208";a="593683360" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by FMSMGA003.fm.intel.com with ESMTP; 03 Nov 2015 22:08:00 -0800 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id tA467xu8009706; Wed, 4 Nov 2015 14:07:59 +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 tA467tFI007527; Wed, 4 Nov 2015 14:07:57 +0800 Received: (from cliang18@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id tA467tlE007523; Wed, 4 Nov 2015 14:07:55 +0800 From: Cunming Liang To: dev@dpdk.org Date: Wed, 4 Nov 2015 14:07:34 +0800 Message-Id: <1446617263-7448-5-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 04/13] eal/linux: not allow to enable zero intr efd 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:08:02 -0000 The patch adds condition check to avoid enable nothing. In disable state, both max_intr and nb_efd are zero. Signed-off-by: Cunming Liang --- lib/librte_eal/bsdapp/eal/include/exec-env/rte_interrupts.h | 3 ++- lib/librte_eal/linuxapp/eal/eal_interrupts.c | 8 +++++++- lib/librte_eal/linuxapp/eal/include/exec-env/rte_interrupts.h | 3 ++- 3 files changed, 11 insertions(+), 3 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 05bb484..3d138bf 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 @@ -85,8 +85,9 @@ rte_intr_rx_ctl(struct rte_intr_handle *intr_handle, * * @param intr_handle * Pointer to the interrupt handle. - * @param nb_vec + * @param nb_efd * Number of interrupt vector trying to enable. + * The value 0 is not allowed. * @return * - On success, zero. * - On failure, a negative value. diff --git a/lib/librte_eal/linuxapp/eal/eal_interrupts.c b/lib/librte_eal/linuxapp/eal/eal_interrupts.c index 8758239..8938067 100644 --- a/lib/librte_eal/linuxapp/eal/eal_interrupts.c +++ b/lib/librte_eal/linuxapp/eal/eal_interrupts.c @@ -45,6 +45,7 @@ #include #include #include +#include #include #include @@ -1148,6 +1149,8 @@ rte_intr_efd_enable(struct rte_intr_handle *intr_handle, uint32_t nb_efd) int fd; uint32_t n = RTE_MIN(nb_efd, (uint32_t)RTE_MAX_RXTX_INTR_VEC_ID); + assert(nb_efd != 0); + if (intr_handle->type == RTE_INTR_HANDLE_VFIO_MSIX) { for (i = 0; i < n; i++) { fd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC); @@ -1204,5 +1207,8 @@ rte_intr_dp_is_en(struct rte_intr_handle *intr_handle) int rte_intr_allow_others(struct rte_intr_handle *intr_handle) { - return !!(intr_handle->max_intr - intr_handle->nb_efd); + if (!rte_intr_dp_is_en(intr_handle)) + return 1; + else + return !!(intr_handle->max_intr - intr_handle->nb_efd); } 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 8da81e7..b44e69c 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 @@ -176,8 +176,9 @@ rte_intr_rx_ctl(struct rte_intr_handle *intr_handle, * * @param intr_handle * Pointer to the interrupt handle. - * @param nb_vec + * @param nb_efd * Number of interrupt vector trying to enable. + * The value 0 is not allowed. * @return * - On success, zero. * - On failure, a negative value. -- 2.4.3