[PATCH v5 2/3] eal/interrupt: add interrupt event info

Kevin Traynor
2026-03-03T18:58:48Z

Add RTE_INTR_EVENT_* defines and a new internal API
rte_intr_active_events_flags() in order to retrieve them.

As the events are in the context of the current interrupt,
rte_intr_active_events_flags() must be called from the context of
an interrupt callback.

Cc: stable@dpdk.org

Signed-off-by: Kevin Traynor <ktraynor@redhat.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
---
lib/eal/freebsd/eal_interrupts.c | 7 +++++++
lib/eal/include/rte_interrupts.h | 21 +++++++++++++++++++++
lib/eal/linux/eal_interrupts.c | 31 ++++++++++++++++++++++++++++++-
lib/eal/windows/eal_interrupts.c | 7 +++++++
4 files changed, 65 insertions(+), 1 deletion(-)

diff --git a/lib/eal/freebsd/eal_interrupts.c b/lib/eal/freebsd/eal_interrupts.c
index 5c3ab6699e..bb2bc529f2 100644
--- a/lib/eal/freebsd/eal_interrupts.c
+++ b/lib/eal/freebsd/eal_interrupts.c
@@ -769,2 +769,9 @@ int rte_thread_is_intr(void)
return rte_thread_equal(intr_thread, rte_thread_self());
}
+
+RTE_EXPORT_INTERNAL_SYMBOL(rte_intr_active_events_flags)
+uint32_t
+rte_intr_active_events_flags(void)
+{
+ return 0;
+}
diff --git a/lib/eal/include/rte_interrupts.h b/lib/eal/include/rte_interrupts.h
index 1b9a0b2a78..0ae16bbe19 100644
--- a/lib/eal/include/rte_interrupts.h
+++ b/lib/eal/include/rte_interrupts.h
@@ -40,4 +40,10 @@ struct rte_intr_handle;
#define RTE_INTR_VEC_RXTX_OFFSET 1

+/** Interrupt event flags returned by rte_intr_active_events_flags() */
+#define RTE_INTR_EVENT_IN RTE_BIT32(0) /**< Data available to read */
+#define RTE_INTR_EVENT_ERR RTE_BIT32(1) /**< Error condition on fd */
+#define RTE_INTR_EVENT_HUP RTE_BIT32(2) /**< Hang up / disconnect */
+#define RTE_INTR_EVENT_RDHUP RTE_BIT32(3) /**< Read hang up / disconnect */
+
/**
* The interrupt source type, e.g. UIO, VFIO, ALARM etc.
@@ -197,4 +203,19 @@ int rte_intr_ack(const struct rte_intr_handle *intr_handle);
int rte_thread_is_intr(void);

+/**
+ * @internal
+ * Return the event flags for the interrupt currently being processed.
+ *
+ * Must be called from an interrupt callback running on the EAL
+ * interrupt thread. The returned value is a bitmask of
+ * RTE_INTR_EVENT_* flags.
+ *
+ * @return
+ * Active event flags, or 0 if not in interrupt context or
+ * on platforms that do not support this feature.
+ */
+__rte_internal
+uint32_t rte_intr_active_events_flags(void);
+
/**
* It allocates memory for interrupt instance. API takes flag as an argument
diff --git a/lib/eal/linux/eal_interrupts.c b/lib/eal/linux/eal_interrupts.c
index f3f6bdd01d..5d0607effe 100644
--- a/lib/eal/linux/eal_interrupts.c
+++ b/lib/eal/linux/eal_interrupts.c
@@ -41,4 +41,6 @@
static RTE_DEFINE_PER_LCORE(int, _epfd) = -1; /**< epoll fd per thread */

+static uint32_t active_events; /**< events for active interrupt */
+
/**
* union for pipe fds.
@@ -887,4 +889,20 @@ rte_intr_disable(const struct rte_intr_handle *intr_handle)
}

+static uint32_t
+epoll_to_intr_events(uint32_t epoll_events)
+{
+ uint32_t ev = 0;
+
+ if (epoll_events & EPOLLIN)
+ ev |= RTE_INTR_EVENT_IN;
+ if (epoll_events & EPOLLERR)
+ ev |= RTE_INTR_EVENT_ERR;
+ if (epoll_events & EPOLLHUP)
+ ev |= RTE_INTR_EVENT_HUP;
+ if (epoll_events & EPOLLRDHUP)
+ ev |= RTE_INTR_EVENT_RDHUP;
+ return ev;
+}
+
static void
eal_intr_source_remove_and_free(struct rte_intr_source *src)
@@ -1014,5 +1032,5 @@ eal_intr_process_interrupts(struct epoll_event *events, int nfds)

if (call) {
-
+ active_events = epoll_to_intr_events(events[n].events);
/* Finally, call all callbacks. */
TAILQ_FOREACH(cb, &src->callbacks, next) {
@@ -1028,4 +1046,5 @@ eal_intr_process_interrupts(struct epoll_event *events, int nfds)
rte_spinlock_lock(&intr_lock);
}
+ active_events = 0;
}
/* we done with that interrupt source, release it. */
@@ -1642,2 +1661,12 @@ int rte_thread_is_intr(void)
return rte_thread_equal(intr_thread, rte_thread_self());
}
+
+RTE_EXPORT_INTERNAL_SYMBOL(rte_intr_active_events_flags)
+uint32_t
+rte_intr_active_events_flags(void)
+{
+ if (rte_thread_is_intr())
+ return active_events;
+
+ return 0;
+}
diff --git a/lib/eal/windows/eal_interrupts.c b/lib/eal/windows/eal_interrupts.c
index 5ff30c7631..5650b84d1f 100644
--- a/lib/eal/windows/eal_interrupts.c
+++ b/lib/eal/windows/eal_interrupts.c
@@ -117,4 +117,11 @@ rte_thread_is_intr(void)
}

+RTE_EXPORT_INTERNAL_SYMBOL(rte_intr_active_events_flags)
+uint32_t
+rte_intr_active_events_flags(void)
+{
+ return 0;
+}
+
RTE_EXPORT_INTERNAL_SYMBOL(rte_intr_rx_ctl)
int
--
2.53.0