[v5,1/2] eal: add API to check if its interrupt context
Checks
Commit Message
From: Harman Kalra <hkalra@marvell.com>
Added an API to check if current execution is in interrupt
context. This will be helpful to handle nested interrupt cases.
Signed-off-by: Harman Kalra <hkalra@marvell.com>
Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
---
v5:
- Fix shared library compilation error
v4:
- No changes.
v3:
- API Comment is updated as per man page.
- Scope updated within the library/driver only.
- Remove experimental tag
v2:
- Rebased patch on 19.11-rc4
lib/librte_eal/common/include/rte_eal_interrupts.h | 11 +++++++++++
lib/librte_eal/freebsd/eal/eal_interrupts.c | 5 +++++
lib/librte_eal/linux/eal/eal_interrupts.c | 5 +++++
lib/librte_eal/rte_eal_version.map | 1 +
4 files changed, 22 insertions(+)
@@ -220,4 +220,15 @@ rte_intr_allow_others(struct rte_intr_handle *intr_handle);
int
rte_intr_cap_multiple(struct rte_intr_handle *intr_handle);
+/**
+ * @internal
+ * Check if currently executing in interrupt context
+ *
+ * @return
+ * - non zero in case of interrupt context
+ * - zero in case of process context
+ */
+int
+rte_thread_is_intr(void);
+
#endif /* _RTE_EAL_INTERRUPTS_H_ */
@@ -671,3 +671,8 @@ rte_intr_free_epoll_fd(struct rte_intr_handle *intr_handle)
{
RTE_SET_USED(intr_handle);
}
+
+int rte_thread_is_intr(void)
+{
+ return pthread_equal(intr_thread, pthread_self());
+}
@@ -1488,3 +1488,8 @@ rte_intr_cap_multiple(struct rte_intr_handle *intr_handle)
return 0;
}
+
+int rte_thread_is_intr(void)
+{
+ return pthread_equal(intr_thread, pthread_self());
+}
@@ -91,6 +91,7 @@ DPDK_20.0 {
rte_intr_free_epoll_fd;
rte_intr_rx_ctl;
rte_intr_tls_epfd;
+ rte_thread_is_intr;
rte_keepalive_create;
rte_keepalive_dispatch_pings;
rte_keepalive_mark_alive;