As we know, there 2 different hotplug mechanisms in dpdk, the one is
ethdev event + kernel driver hotplug solution, while the other one is
eal device event + pci uio driver hotplug solution, each of them have
different configure and callback process in testpmd. In oder to avoid
the race between them, this patch aim to use a new parameter
"--hotplug-mode" to replace the previous "--hot-plug" command parameter,
to identify these different mode.
There are 3 modes on hotplug mode: disable, eal, or ethdev(default).
If user want to use eal device event monitor mode, could use below
command when start testpmd. If not set this parameter, ethdev hotplug
mode is default to be used.
E.g. ./build/app/testpmd -c 0x3 --n 4 -- -i --hotplug-mode=eal
Signed-off-by: Jeff Guo <jia.guo@intel.com>
---
v4->v3:
change to use new parameter "--hotplug-mode" in testpmd
to identify the eal hotplug and ethdev hotplug
---
app/test-pmd/parameters.c | 20 ++++++++++++++++----
app/test-pmd/testpmd.c | 18 +++++++++++-------
app/test-pmd/testpmd.h | 8 +++++++-
doc/guides/testpmd_app_ug/run_app.rst | 10 ++++++++--
4 files changed, 42 insertions(+), 14 deletions(-)
@@ -186,7 +186,8 @@ usage(char* progname)
printf(" --flow-isolate-all: "
"requests flow API isolated mode on all ports at initialization time.\n");
printf(" --tx-offloads=0xXXXXXXXX: hexadecimal bitmask of TX queue offloads\n");
- printf(" --hot-plug: enable hot plug for device.\n");
+ printf(" --hotplug-mode=N: set hotplug mode for device "
+ "(N: disable (default) or eal or ethdev.\n");
printf(" --vxlan-gpe-port=N: UPD port of tunnel VXLAN-GPE\n");
printf(" --mlockall: lock all memory\n");
printf(" --no-mlockall: do not lock all memory\n");
@@ -621,7 +622,7 @@ launch_args_parse(int argc, char** argv)
{ "print-event", 1, 0, 0 },
{ "mask-event", 1, 0, 0 },
{ "tx-offloads", 1, 0, 0 },
- { "hot-plug", 0, 0, 0 },
+ { "hotplug-mode", 1, 0, 0 },
{ "vxlan-gpe-port", 1, 0, 0 },
{ "mlockall", 0, 0, 0 },
{ "no-mlockall", 0, 0, 0 },
@@ -1139,8 +1140,19 @@ launch_args_parse(int argc, char** argv)
rte_exit(EXIT_FAILURE,
"invalid mask-event argument\n");
}
- if (!strcmp(lgopts[opt_idx].name, "hot-plug"))
- hot_plug = 1;
+ if (!strcmp(lgopts[opt_idx].name, "hotplug-mode")) {
+ if (!strcmp(optarg, "disable"))
+ hotplug_mode = HOTPLUG_MODE_DISABLE;
+ else if (!strcmp(optarg, "eal"))
+ hotplug_mode = HOTPLUG_MODE_EAL;
+ else if (!strcmp(optarg, "ethdev"))
+ hotplug_mode = HOTPLUG_MODE_ETHDEV;
+ else
+ rte_exit(EXIT_FAILURE,
+ "hotplug-mode %s invalid - must be: "
+ "disable, eal, ethdev.\n",
+ optarg);
+ }
if (!strcmp(lgopts[opt_idx].name, "mlockall"))
do_mlockall = 1;
if (!strcmp(lgopts[opt_idx].name, "no-mlockall"))
@@ -286,7 +286,7 @@ uint8_t lsc_interrupt = 1; /* enabled by default */
*/
uint8_t rmv_interrupt = 1; /* enabled by default */
-uint8_t hot_plug = 0; /**< hotplug disabled by default. */
+uint8_t hotplug_mode = HOTPLUG_MODE_ETHDEV; /**< hotplug disabled by default. */
/*
* Display or mask ether events
@@ -2043,7 +2043,7 @@ pmd_test_exit(void)
}
}
- if (hot_plug) {
+ if (hotplug_mode == HOTPLUG_MODE_EAL) {
ret = rte_dev_event_monitor_stop();
if (ret)
RTE_LOG(ERR, EAL,
@@ -2181,9 +2181,13 @@ eth_event_callback(portid_t port_id, enum rte_eth_event_type type, void *param,
switch (type) {
case RTE_ETH_EVENT_INTR_RMV:
- if (rte_eal_alarm_set(100000,
- rmv_event_callback, (void *)(intptr_t)port_id))
- fprintf(stderr, "Could not set up deferred device removal\n");
+ if (hotplug_mode == HOTPLUG_MODE_ETHDEV) {
+ if (rte_eal_alarm_set(100000,
+ rmv_event_callback,
+ (void *)(intptr_t)port_id))
+ fprintf(stderr, "Could not set up deferred "
+ "device removal\n");
+ }
break;
default:
break;
@@ -2734,8 +2738,8 @@ main(int argc, char** argv)
init_config();
- if (hot_plug) {
- /* enable hot plug monitoring */
+ if (hotplug_mode == HOTPLUG_MODE_EAL) {
+ /* enable hotplug event monitoring */
ret = rte_dev_event_monitor_start();
if (ret) {
rte_errno = EINVAL;
@@ -69,6 +69,12 @@ enum {
PORT_TOPOLOGY_LOOP,
};
+enum {
+ HOTPLUG_MODE_DISABLE,
+ HOTPLUG_MODE_EAL,
+ HOTPLUG_MODE_ETHDEV,
+};
+
#ifdef RTE_TEST_PMD_RECORD_BURST_STATS
/**
* The data structure associated with RX and TX packet burst statistics
@@ -335,7 +341,7 @@ extern uint8_t lsc_interrupt; /**< disabled by "--no-lsc-interrupt" parameter */
extern uint8_t rmv_interrupt; /**< disabled by "--no-rmv-interrupt" parameter */
extern uint32_t event_print_mask;
/**< set by "--print-event xxxx" and "--mask-event xxxx parameters */
-extern uint8_t hot_plug; /**< enable by "--hot-plug" parameter */
+extern uint8_t hotplug_mode; /**< set by "--hotplug-mode" parameter */
extern int do_mlockall; /**< set by "--mlockall" or "--no-mlockall" parameter */
#ifdef RTE_LIBRTE_IXGBE_BYPASS
@@ -482,9 +482,15 @@ The commandline options are:
Set the hexadecimal bitmask of TX queue offloads.
The default value is 0.
-* ``--hot-plug``
+* ``--hotplug-mode``
- Enable device event monitor machenism for hotplug.
+ Set the hotplug handle mode, that is ``disable`` or ``eal`` or ``ethdev`` (the default).
+
+ In ``disable`` mode, it will not handle the hotplug for device.
+
+ In ``eal`` mode, it will start device event monitor and register eth_dev_event_callback for hotplug process.
+
+ In ``ethdev`` mode, it will process RTE_ETH_EVENT_INTR_RMV event which is detected from ethdev.
* ``--vxlan-gpe-port=N``