eal: check if running in interrupt context
authorHarman Kalra <hkalra@marvell.com>
Tue, 14 Jan 2020 09:04:52 +0000 (14:34 +0530)
committerDavid Marchand <david.marchand@redhat.com>
Thu, 6 Feb 2020 15:35:40 +0000 (16:35 +0100)
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>
Reviewed-by: Jerin Jacob <jerinj@marvell.com>
lib/librte_eal/common/include/rte_eal_interrupts.h
lib/librte_eal/freebsd/eal/eal_interrupts.c
lib/librte_eal/linux/eal/eal_interrupts.c
lib/librte_eal/rte_eal_version.map

index b370c0d..773a34a 100644 (file)
@@ -220,4 +220,19 @@ rte_intr_allow_others(struct rte_intr_handle *intr_handle);
 int
 rte_intr_cap_multiple(struct rte_intr_handle *intr_handle);
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * @internal
+ * Check if currently executing in interrupt context
+ *
+ * @return
+ *  - non zero in case of interrupt context
+ *  - zero in case of process context
+ */
+__rte_experimental
+int
+rte_thread_is_intr(void);
+
 #endif /* _RTE_EAL_INTERRUPTS_H_ */
index f6831b7..ce2a27b 100644 (file)
@@ -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());
+}
index 14ebb10..cb8e107 100644 (file)
@@ -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());
+}
index e38d025..6cf5070 100644 (file)
@@ -332,4 +332,7 @@ EXPERIMENTAL {
        # added in 19.11
        rte_log_get_stream;
        rte_mcfg_get_single_file_segments;
+
+       # added in 20.02
+       rte_thread_is_intr;
 };