DPDK patches and discussions
 help / color / mirror / Atom feed
From: Jeff Guo <jia.guo@intel.com>
To: bernard.iremonger@intel.com, wenzhuo.lu@intel.com,
	shahafs@mellanox.com, thomas@monjalon.net, matan@mellanox.com
Cc: ferruh.yigit@intel.com, konstantin.ananyev@intel.com,
	dev@dpdk.org, jia.guo@intel.com, stephen@networkplumber.org,
	gaetan.rivet@6wind.com, qi.z.zhang@intel.com,
	arybchenko@solarflare.com, bruce.richardson@intel.com,
	shaopeng.he@intel.com, anatoly.burakov@intel.com
Subject: [dpdk-dev] [PATCH 1/3] eal: add --dev-hotplug option
Date: Fri, 14 Dec 2018 15:45:38 +0800	[thread overview]
Message-ID: <1544773540-89825-2-git-send-email-jia.guo@intel.com> (raw)
In-Reply-To: <1544773540-89825-1-git-send-email-jia.guo@intel.com>

This command-line option will enable hotplug event detecting and enable
hotplug handling for device hotplug.

Signed-off-by: Jeff Guo <jia.guo@intel.com>
---
 lib/librte_eal/bsdapp/eal/eal.c            | 16 ++++++++++++++++
 lib/librte_eal/common/eal_common_options.c |  5 +++++
 lib/librte_eal/common/eal_internal_cfg.h   |  1 +
 lib/librte_eal/common/eal_options.h        |  4 +++-
 lib/librte_eal/linuxapp/eal/eal.c          | 16 ++++++++++++++++
 5 files changed, 41 insertions(+), 1 deletion(-)

diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c
index b8152a7..b9c29e4 100644
--- a/lib/librte_eal/bsdapp/eal/eal.c
+++ b/lib/librte_eal/bsdapp/eal/eal.c
@@ -699,6 +699,22 @@ rte_eal_init(int argc, char **argv)
 #endif
 	}
 
+	if (internal_config.dev_hotplug) {
+		ret = rte_dev_hotplug_handle_enable();
+		if (ret) {
+			RTE_LOG(ERR, EAL,
+				"fail to enable hotplug handling.");
+			return -1;
+		}
+
+		ret = rte_dev_event_monitor_start();
+		if (ret) {
+			RTE_LOG(ERR, EAL,
+				"fail to start device event monitoring.");
+			return -1;
+		}
+	}
+
 	rte_srand(rte_rdtsc());
 
 	/* in secondary processes, memory init may allocate additional fbarrays
diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c
index e31eca5..70cb374 100644
--- a/lib/librte_eal/common/eal_common_options.c
+++ b/lib/librte_eal/common/eal_common_options.c
@@ -79,6 +79,7 @@ eal_long_options[] = {
 	{OPT_VMWARE_TSC_MAP,    0, NULL, OPT_VMWARE_TSC_MAP_NUM   },
 	{OPT_LEGACY_MEM,        0, NULL, OPT_LEGACY_MEM_NUM       },
 	{OPT_SINGLE_FILE_SEGMENTS, 0, NULL, OPT_SINGLE_FILE_SEGMENTS_NUM},
+	{OPT_DEV_HOTPLUG,       0, NULL, OPT_DEV_HOTPLUG_NUM      },
 	{0,                     0, NULL, 0                        }
 };
 
@@ -1309,6 +1310,9 @@ eal_parse_common_option(int opt, const char *optarg,
 			return -1;
 		}
 		break;
+	case OPT_DEV_HOTPLUG_NUM:
+		conf->dev_hotplug = 1;
+		break;
 
 	/* don't know what to do, leave this to caller */
 	default:
@@ -1476,6 +1480,7 @@ eal_common_usage(void)
 	       "  -h, --help          This help\n"
 	       "  --"OPT_IN_MEMORY"   Operate entirely in memory. This will\n"
 	       "                      disable secondary process support\n"
+	       "  --"OPT_DEV_HOTPLUG" Enable device hotplug\n"
 	       "\nEAL options for DEBUG use only:\n"
 	       "  --"OPT_HUGE_UNLINK"       Unlink hugepage files after init\n"
 	       "  --"OPT_NO_HUGE"           Use malloc instead of hugetlbfs\n"
diff --git a/lib/librte_eal/common/eal_internal_cfg.h b/lib/librte_eal/common/eal_internal_cfg.h
index 737f17e..d160ee3 100644
--- a/lib/librte_eal/common/eal_internal_cfg.h
+++ b/lib/librte_eal/common/eal_internal_cfg.h
@@ -73,6 +73,7 @@ struct internal_config {
 	enum rte_iova_mode iova_mode ;    /**< Set IOVA mode on this system  */
 	volatile unsigned int init_complete;
 	/**< indicates whether EAL has completed initialization */
+	volatile unsigned dev_hotplug;    /**< true to enable device hotplug */
 };
 extern struct internal_config internal_config; /**< Global EAL configuration. */
 
diff --git a/lib/librte_eal/common/eal_options.h b/lib/librte_eal/common/eal_options.h
index 5271f94..4d8a12e 100644
--- a/lib/librte_eal/common/eal_options.h
+++ b/lib/librte_eal/common/eal_options.h
@@ -65,7 +65,9 @@ enum {
 	OPT_SINGLE_FILE_SEGMENTS_NUM,
 #define OPT_IOVA_MODE          "iova-mode"
 	OPT_IOVA_MODE_NUM,
-	OPT_LONG_MAX_NUM
+	OPT_LONG_MAX_NUM,
+#define OPT_DEV_HOTPLUG	      "dev-hotplug"
+	OPT_DEV_HOTPLUG_NUM,
 };
 
 extern const char eal_short_options[];
diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
index 361744d..8de7401 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -960,6 +960,22 @@ rte_eal_init(int argc, char **argv)
 #endif
 	}
 
+	if (internal_config.dev_hotplug) {
+		ret = rte_dev_hotplug_handle_enable();
+		if (ret) {
+			RTE_LOG(ERR, EAL,
+				"fail to enable hotplug handling.");
+			return -1;
+		}
+
+		ret = rte_dev_event_monitor_start();
+		if (ret) {
+			RTE_LOG(ERR, EAL,
+				"fail to start device event monitoring.");
+			return -1;
+		}
+	}
+
 	rte_srand(rte_rdtsc());
 
 	if (rte_eal_log_init(logid, internal_config.syslog_facility) < 0) {
-- 
2.7.4

  reply	other threads:[~2018-12-14  7:41 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-14  7:45 [dpdk-dev] [PATCH 0/3] use a common eal device event for hot-unplug Jeff Guo
2018-12-14  7:45 ` Jeff Guo [this message]
2018-12-17 10:15   ` [dpdk-dev] [PATCH 1/3] eal: add --dev-hotplug option David Marchand
2018-12-29  4:06     ` Jeff Guo
2019-01-02 14:46       ` David Marchand
2018-12-14  7:45 ` [dpdk-dev] [PATCH 2/3] ethdev: remove ethdev rmv interrupt Jeff Guo
2018-12-14  7:45 ` [dpdk-dev] [PATCH 3/3] testpmd: remove device detach into eal Jeff Guo
2019-04-08 14:10 ` [dpdk-dev] [PATCH 0/3] use a common eal device event for hot-unplug Iremonger, Bernard
2019-04-08 14:10   ` Iremonger, Bernard
2023-06-09 17:18 ` 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=1544773540-89825-2-git-send-email-jia.guo@intel.com \
    --to=jia.guo@intel.com \
    --cc=anatoly.burakov@intel.com \
    --cc=arybchenko@solarflare.com \
    --cc=bernard.iremonger@intel.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=gaetan.rivet@6wind.com \
    --cc=konstantin.ananyev@intel.com \
    --cc=matan@mellanox.com \
    --cc=qi.z.zhang@intel.com \
    --cc=shahafs@mellanox.com \
    --cc=shaopeng.he@intel.com \
    --cc=stephen@networkplumber.org \
    --cc=thomas@monjalon.net \
    --cc=wenzhuo.lu@intel.com \
    /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).