DPDK patches and discussions
 help / color / mirror / Atom feed
From: Harman Kalra <hkalra@marvell.com>
To: "stephen@networkplumber.org" <stephen@networkplumber.org>,
	"Bruce Richardson" <bruce.richardson@intel.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>, Harman Kalra <hkalra@marvell.com>
Subject: [dpdk-dev] [PATCH v2] eal: add API to check if its interrupt context
Date: Mon, 18 Nov 2019 07:43:24 +0000	[thread overview]
Message-ID: <1574062926-14099-1-git-send-email-hkalra@marvell.com> (raw)
In-Reply-To: <20191117120351.0f9b24d0@hermes.lan>

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>
---
V2:
* Removed unnecessary if statement.
* Reworded subject line
* Updated return values of API

 lib/librte_eal/common/include/rte_interrupts.h | 15 +++++++++++++++
 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, 26 insertions(+)

diff --git a/lib/librte_eal/common/include/rte_interrupts.h b/lib/librte_eal/common/include/rte_interrupts.h
index e3b406abc..0a82e28a8 100644
--- a/lib/librte_eal/common/include/rte_interrupts.h
+++ b/lib/librte_eal/common/include/rte_interrupts.h
@@ -138,6 +138,21 @@ int rte_intr_disable(const struct rte_intr_handle *intr_handle);
 __rte_experimental
 int rte_intr_ack(const struct rte_intr_handle *intr_handle);
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * Check if currently executing in interrupt context
+ *
+ * @return
+ *  - positive in case of interrupt context
+ *  - zero in case of process context
+ *  - negative if unsuccessful
+ */
+__rte_experimental
+int
+rte_thread_is_intr(void);
+
 #ifdef __cplusplus
 }
 #endif
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 1955324d3..c00f5a575 100644
--- a/lib/librte_eal/linux/eal/eal_interrupts.c
+++ b/lib/librte_eal/linux/eal/eal_interrupts.c
@@ -1487,3 +1487,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 f1982f2f7..ab5dd5b47 100644
--- a/lib/librte_eal/rte_eal_version.map
+++ b/lib/librte_eal/rte_eal_version.map
@@ -427,4 +427,5 @@ EXPERIMENTAL {
 
 	# added in 19.11
 	rte_log_get_stream;
+	rte_thread_is_intr;
 };
-- 
2.18.0


  reply	other threads:[~2019-11-18  7:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-17 19:36 [dpdk-dev] [PATCH] eal: check for " Harman Kalra
2019-11-17 20:03 ` Stephen Hemminger
2019-11-18  7:43   ` Harman Kalra [this message]
2019-11-17 20:04 ` Stephen Hemminger
2019-11-18 10:18 ` Burakov, Anatoly

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1574062926-14099-1-git-send-email-hkalra@marvell.com \
    --to=hkalra@marvell.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).