From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 6A66A1B562 for ; Fri, 29 Jun 2018 12:27:18 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Jun 2018 03:27:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,285,1526367600"; d="scan'208";a="241324473" Received: from jeffguo-z170x-ud5.sh.intel.com (HELO localhost.localdomain) ([10.67.104.10]) by fmsmga005.fm.intel.com with ESMTP; 29 Jun 2018 03:27:15 -0700 From: Jeff Guo To: stephen@networkplumber.org, bruce.richardson@intel.com, ferruh.yigit@intel.com, konstantin.ananyev@intel.com, gaetan.rivet@6wind.com, jingjing.wu@intel.com, thomas@monjalon.net, motih@mellanox.com, matan@mellanox.com, harry.van.haaren@intel.com, qi.z.zhang@intel.com, shaopeng.he@intel.com, bernard.iremonger@intel.com Cc: jblunck@infradead.org, shreyansh.jain@nxp.com, dev@dpdk.org, jia.guo@intel.com, helin.zhang@intel.com Date: Fri, 29 Jun 2018 18:24:31 +0800 Message-Id: <1530267871-7161-10-git-send-email-jia.guo@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1530267871-7161-1-git-send-email-jia.guo@intel.com> References: <1530267871-7161-1-git-send-email-jia.guo@intel.com> Subject: [dpdk-dev] [PATCH V4 9/9] app/testpmd: enable device hotplug monitoring X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jun 2018 10:27:19 -0000 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 --- 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(-) diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c index 7580762..601e13e 100644 --- a/app/test-pmd/parameters.c +++ b/app/test-pmd/parameters.c @@ -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")) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 42ed196..9269400 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -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; diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index f51cd9d..e29ee2a 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -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 diff --git a/doc/guides/testpmd_app_ug/run_app.rst b/doc/guides/testpmd_app_ug/run_app.rst index f301c2b..09e2716 100644 --- a/doc/guides/testpmd_app_ug/run_app.rst +++ b/doc/guides/testpmd_app_ug/run_app.rst @@ -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`` -- 2.7.4