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 <cunming.liang at intel.com> --- 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 88d4ae1..cd8817d 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 @@ -82,8 +82,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 8e76a7a..96226d6 100644 --- a/lib/librte_eal/linuxapp/eal/eal_interrupts.c +++ b/lib/librte_eal/linuxapp/eal/eal_interrupts.c @@ -45,6 +45,7 @@ #include <sys/signalfd.h> #include <sys/ioctl.h> #include <sys/eventfd.h> +#include <assert.h> #include <rte_common.h> #include <rte_interrupts.h> @@ -1132,6 +1133,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); @@ -1188,5 +1191,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 b8fd318..6a2f495 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