From: Cunming Liang Date: Wed, 4 Nov 2015 08:45:31 +0000 (+0800) Subject: eal/linux: forbid enabling zero interrupt vector X-Git-Tag: spdx-start~8129 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=7eeed914480a4c845d6a621d4ebed4eb0c6751c3;p=dpdk.git eal/linux: forbid enabling zero interrupt vector 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 Acked-by: David Marchand --- 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 05bb4843b3..3d138bf5fc 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 8758239d0f..89380675ef 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 8da81e7e05..b44e69cc83 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.