[v7,1/2] eal: add API to check if its interrupt context
diff mbox series

Message ID 20200114090453.4548-1-skori@marvell.com
State Accepted, archived
Delegated to: David Marchand
Headers show
Series
  • [v7,1/2] eal: add API to check if its interrupt context
Related show

Checks

Context Check Description
ci/iol-nxp-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/checkpatch warning coding style issues

Commit Message

Sunil Kumar Kori Jan. 14, 2020, 9:04 a.m. UTC
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>
Reviewed-by: Jerin Jacob <jerinj@marvell.com>
---
v7:
 - No changes.
v6:
 - No changes.
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(+)

Comments

David Marchand Feb. 6, 2020, 3:35 p.m. UTC | #1
On Tue, Jan 14, 2020 at 10:05 AM Sunil Kumar Kori <skori@marvell.com> wrote:
>
> 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>
> Reviewed-by: Jerin Jacob <jerinj@marvell.com>
> ---
> v7:
>  - No changes.
> v6:
>  - No changes.
> 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(+)
>
> diff --git a/lib/librte_eal/common/include/rte_eal_interrupts.h b/lib/librte_eal/common/include/rte_eal_interrupts.h
> index b370c0d26..19d1d45ab 100644
> --- a/lib/librte_eal/common/include/rte_eal_interrupts.h
> +++ b/lib/librte_eal/common/include/rte_eal_interrupts.h
> @@ -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_ */
> diff --git a/lib/librte_eal/freebsd/eal/eal_interrupts.c b/lib/librte_eal/freebsd/eal/eal_interrupts.c
> index f6831b790..ce2a27b4a 100644
> --- a/lib/librte_eal/freebsd/eal/eal_interrupts.c
> +++ b/lib/librte_eal/freebsd/eal/eal_interrupts.c
> @@ -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());
> +}
> diff --git a/lib/librte_eal/linux/eal/eal_interrupts.c b/lib/librte_eal/linux/eal/eal_interrupts.c
> index 14ebb108c..cb8e10709 100644
> --- a/lib/librte_eal/linux/eal/eal_interrupts.c
> +++ b/lib/librte_eal/linux/eal/eal_interrupts.c
> @@ -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());
> +}
> diff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map
> index e38d02530..06ed2e9dc 100644
> --- a/lib/librte_eal/rte_eal_version.map
> +++ b/lib/librte_eal/rte_eal_version.map
> @@ -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;
> --
> 2.17.1


We can't put this symbol in the stable ABI and just flag it as
internal in the function description.
Users won't notice this warning.

I moved this as an experimental API and enabled the use of
experimental api in octeontx2 common driver.
We can revisit once we have the rte_internal tag Neil had proposed.


Series applied, thanks.



--
David Marchand

Patch
diff mbox series

diff --git a/lib/librte_eal/common/include/rte_eal_interrupts.h b/lib/librte_eal/common/include/rte_eal_interrupts.h
index b370c0d26..19d1d45ab 100644
--- a/lib/librte_eal/common/include/rte_eal_interrupts.h
+++ b/lib/librte_eal/common/include/rte_eal_interrupts.h
@@ -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_ */
diff --git a/lib/librte_eal/freebsd/eal/eal_interrupts.c b/lib/librte_eal/freebsd/eal/eal_interrupts.c
index f6831b790..ce2a27b4a 100644
--- a/lib/librte_eal/freebsd/eal/eal_interrupts.c
+++ b/lib/librte_eal/freebsd/eal/eal_interrupts.c
@@ -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());
+}
diff --git a/lib/librte_eal/linux/eal/eal_interrupts.c b/lib/librte_eal/linux/eal/eal_interrupts.c
index 14ebb108c..cb8e10709 100644
--- a/lib/librte_eal/linux/eal/eal_interrupts.c
+++ b/lib/librte_eal/linux/eal/eal_interrupts.c
@@ -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());
+}
diff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map
index e38d02530..06ed2e9dc 100644
--- a/lib/librte_eal/rte_eal_version.map
+++ b/lib/librte_eal/rte_eal_version.map
@@ -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;