From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>
Subject: [dpdk-dev] [RFC 1/3] eal/hotplug: allow monitor to be setup by multiple places
Date: Thu, 7 May 2020 20:59:04 -0700 [thread overview]
Message-ID: <20200508035906.18359-2-stephen@networkplumber.org> (raw)
In-Reply-To: <20200508035906.18359-1-stephen@networkplumber.org>
In some cases, a device or infrastructure may want to enable hotplug
but application may also try and start hotplug as well. Therefore
change the monitor_started from a boolean into a reference count.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
lib/librte_eal/linux/eal_dev.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/lib/librte_eal/linux/eal_dev.c b/lib/librte_eal/linux/eal_dev.c
index 83c9cd660754..4d1c08f4c258 100644
--- a/lib/librte_eal/linux/eal_dev.c
+++ b/lib/librte_eal/linux/eal_dev.c
@@ -23,8 +23,11 @@
#include "eal_private.h"
-static struct rte_intr_handle intr_handle = {.fd = -1 };
-static bool monitor_started;
+static struct rte_intr_handle intr_handle = {
+ .type = RTE_INTR_HANDLE_DEV_EVENT,
+ .fd = -1,
+};
+static uint32_t monitor_refcount;
static bool hotplug_handle;
#define EAL_UEV_MSG_LEN 4096
@@ -290,7 +293,7 @@ rte_dev_event_monitor_start(void)
{
int ret;
- if (monitor_started)
+ if (__atomic_fetch_add(&monitor_refcount, 1, __ATOMIC_RELAXED))
return 0;
ret = dev_uev_socket_fd_create();
@@ -299,7 +302,6 @@ rte_dev_event_monitor_start(void)
return -1;
}
- intr_handle.type = RTE_INTR_HANDLE_DEV_EVENT;
ret = rte_intr_callback_register(&intr_handle, dev_uev_handler, NULL);
if (ret) {
@@ -307,8 +309,6 @@ rte_dev_event_monitor_start(void)
return -1;
}
- monitor_started = true;
-
return 0;
}
@@ -317,7 +317,7 @@ rte_dev_event_monitor_stop(void)
{
int ret;
- if (!monitor_started)
+ if (__atomic_sub_fetch(&monitor_refcount, 1, __ATOMIC_RELAXED))
return 0;
ret = rte_intr_callback_unregister(&intr_handle, dev_uev_handler,
@@ -329,7 +329,6 @@ rte_dev_event_monitor_stop(void)
close(intr_handle.fd);
intr_handle.fd = -1;
- monitor_started = false;
return 0;
}
--
2.20.1
next prev parent reply other threads:[~2020-05-08 3:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-08 3:59 [dpdk-dev] [RFC 0/3] Auto enable hotplug with netvsc devices Stephen Hemminger
2020-05-08 3:59 ` Stephen Hemminger [this message]
2020-05-08 3:59 ` [dpdk-dev] [RFC 2/3] net/vdev_netvsc: automatically enable hotplug support Stephen Hemminger
2020-05-08 3:59 ` [dpdk-dev] [RFC 3/3] net/netvsc: " Stephen Hemminger
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=20200508035906.18359-2-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=dev@dpdk.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).