From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on0067.outbound.protection.outlook.com [104.47.0.67]) by dpdk.org (Postfix) with ESMTP id 472291C7DD for ; Wed, 4 Apr 2018 18:31:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=c/gp5npfjdJmr6eqkr/6Ff6lVk4pol6DhcD9GNvWPaw=; b=sBKOqyT6VYI+LsFerKTEcOHO9Ryl9Im24S/zzBJk0G/n43WGeqmcLv0i4XTs6AnvjQ2zOKaQLK1/rR43KwyQUk+ilboGHFTBHqffxKmWHnf4excB1o/LcUAvjIZU8rwZeo69vkzU6axX/kE0zQdkvxmyrXmevEjeHI7pW2zj1YQ= Received: from AM4PR0501MB2657.eurprd05.prod.outlook.com (10.172.215.19) by AM4PR0501MB2753.eurprd05.prod.outlook.com (10.172.216.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.653.12; Wed, 4 Apr 2018 16:31:35 +0000 Received: from AM4PR0501MB2657.eurprd05.prod.outlook.com ([fe80::6885:c169:afcb:37e6]) by AM4PR0501MB2657.eurprd05.prod.outlook.com ([fe80::6885:c169:afcb:37e6%7]) with mapi id 15.20.0653.012; Wed, 4 Apr 2018 16:31:35 +0000 From: Matan Azrad To: "Tan, Jianfeng" , "Guo, Jia" , "stephen@networkplumber.org" , "Richardson, Bruce" , "Yigit, Ferruh" , "Ananyev, Konstantin" , "gaetan.rivet@6wind.com" , "Wu, Jingjing" , "Thomas Monjalon" , Mordechay Haimovsky , "Van Haaren, Harry" CC: "jblunck@infradead.org" , "shreyansh.jain@nxp.com" , "dev@dpdk.org" , "Zhang, Helin" Thread-Topic: [dpdk-dev] [PATCH V18 4/4] app/testpmd: enable device hotplug monitoring Thread-Index: AQHTyzeHWnfSmuxmjUqO6LYtZVRH66Pv8gYAgADbGoA= Date: Wed, 4 Apr 2018 16:31:35 +0000 Message-ID: References: <1522339205-27698-5-git-send-email-jia.guo@intel.com> <1522751639-2315-1-git-send-email-jia.guo@intel.com> <1522751639-2315-5-git-send-email-jia.guo@intel.com> In-Reply-To: Accept-Language: en-US, he-IL Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=matan@mellanox.com; x-originating-ip: [85.64.136.190] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM4PR0501MB2753; 7:NaB/WRypDMMDY7xRvdI+RhxeZr/L9LsOwiNHLKSrLWhFTZ6Y4wV9xY4GEzjuLialQwvgKDBxJ8ciZauq0ZedTM4sdhACwQLQKFZ+fE7A0aF6DeMOtOH1Qve58zONexTF/zRSMgLm4e/3Aksugf5scKCLqD0btaCsaUcmsWtUeSaAxHU8HoQniJOw7hsLMF3OxDJMyQ67ylMAGHzCsHqCje0oJfuEq4/FjGs031dGRMrzkehqMIjnNuO6Nw6x3L0L x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: e12022ac-a8b0-4688-0bb8-08d59a4988a9 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4604075)(3008032)(48565401081)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:AM4PR0501MB2753; x-ms-traffictypediagnostic: AM4PR0501MB2753: x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(72170088055959)(185117386973197)(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231221)(944501327)(52105095)(10201501046)(93006095)(93001095)(3002001)(6055026)(6041310)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:AM4PR0501MB2753; BCL:0; PCL:0; RULEID:; SRVR:AM4PR0501MB2753; x-forefront-prvs: 0632519F33 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(366004)(39860400002)(376002)(346002)(39380400002)(13464003)(199004)(189003)(53754006)(59450400001)(11346002)(33656002)(575784001)(305945005)(7696005)(86362001)(99286004)(76176011)(8656006)(7736002)(81166006)(476003)(74316002)(186003)(2906002)(26005)(6506007)(81156014)(446003)(3660700001)(4326008)(3280700002)(6246003)(25786009)(102836004)(7416002)(8936002)(229853002)(55016002)(6436002)(9686003)(53936002)(106356001)(53546011)(97736004)(105586002)(2900100001)(68736007)(6116002)(66066001)(3846002)(478600001)(5890100001)(5250100002)(2501003)(110136005)(93886005)(316002)(5660300001)(486006)(54906003)(14454004)(921003)(1121003); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR0501MB2753; H:AM4PR0501MB2657.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: AK3N+BH7CeHSvcG6LjgEs6aFxKPLSgvz+ExjCGBK+SAnVKTBqpXpI9YnKwVe3SBlF7Exe0aQ6LQY3AFCYEiZeqm/C4OQDwbVBmPzws8FHX5NtoYEC3g1Xeh0okhzNueV839DNj3y7CVdldE85ue9hSeQuhG8mHc/04zxkgUixfEGRdyy0pSVm0gEK4ip/GQymtqh3V/oGpU+kkteU7S6uffrgimD4tT8QhfU553wkPuGkZxQuJus/j55VeGMYUMM3r8/p1x6Mg3GL6/SH38petOA0JHSUizNc893eHJtpWn1r9Oe0q3sqXPd2cpDXT0K0k8X9E/Mp4Qlx+E5Xhlsm8CkNudjpxB6Dts5KH6ja/nJkcgfOM+r2n8B6s+BffNCEhVe1zlnJYPIMw0vEliV18k4I3vQGAdwrCNNTUP7i34= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: e12022ac-a8b0-4688-0bb8-08d59a4988a9 X-MS-Exchange-CrossTenant-originalarrivaltime: 04 Apr 2018 16:31:35.7769 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR0501MB2753 Subject: Re: [dpdk-dev] [PATCH V18 4/4] 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: Wed, 04 Apr 2018 16:31:38 -0000 Hi all What do you think about adding the "--hotplug" parameter as a new EAL comma= nd line parameter? From: Tan, Jianfeng, Wednesday, April 4, 2018 6:23 AM > > -----Original Message----- > > From: Guo, Jia > > Sent: Tuesday, April 3, 2018 6:34 PM > > To: stephen@networkplumber.org; Richardson, Bruce; Yigit, Ferruh; > > Ananyev, Konstantin; gaetan.rivet@6wind.com; Wu, Jingjing; > > thomas@monjalon.net; motih@mellanox.com; Van Haaren, Harry; Tan, > > Jianfeng > > Cc: jblunck@infradead.org; shreyansh.jain@nxp.com; dev@dpdk.org; Guo, > > Jia; Zhang, Helin > > Subject: [PATCH V18 4/4] app/testpmd: enable device hotplug monitoring > > > > Use testpmd for example, to show how an application use device event >=20 > s/use/uses >=20 > > APIs to monitor the hotplug events, including both hot removal event > > and hot insertion event. > > > > The process is that, testpmd first enable hotplug by below commands, > > > > E.g. ./build/app/testpmd -c 0x3 --n 4 -- -i --hot-plug > > > > then testpmd start the device event monitor by call the new API >=20 > s/start/starts > s/call/calling >=20 > > (rte_dev_event_monitor_start) and register the user's callback by call > > the API (rte_dev_event_callback_register), when device being hotplug > > insertion or hotplug removal, the device event monitor detects the > > event and call user's callbacks, user could process the event in the > > callback accordingly. > > > > This patch only shows the event monitoring, device attach/detach would > > not be involved here, will add from other hotplug patch set. > > > > Signed-off-by: Jeff Guo >=20 > Some typos and a trivial suggestion. Feel free to carry my >=20 > Reviewed-by: Jianfeng Tan >=20 > in the next version. >=20 > > --- > > v18->v17: > > remove hotplug policy and detach/attach process from testpmd, let it > > focus on the device event monitoring which the patch set introduced. > > --- > > app/test-pmd/parameters.c | 5 +- > > app/test-pmd/testpmd.c | 112 > > +++++++++++++++++++++++++++++++++- > > app/test-pmd/testpmd.h | 2 + > > doc/guides/testpmd_app_ug/run_app.rst | 4 ++ > > 4 files changed, 121 insertions(+), 2 deletions(-) > > > > diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c > > index 97d22b8..558cd40 100644 > > --- a/app/test-pmd/parameters.c > > +++ b/app/test-pmd/parameters.c > > @@ -186,6 +186,7 @@ usage(char* progname) > > printf(" --flow-isolate-all: " > > "requests flow API isolated mode on all ports at > > initialization time.\n"); > > printf(" --tx-offloads=3D0xXXXXXXXX: hexadecimal bitmask of TX > queue > > offloads\n"); > > + printf(" --hot-plug: enable hot plug for device.\n"); > > } > > > > #ifdef RTE_LIBRTE_CMDLINE > > @@ -621,6 +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 }, > > { 0, 0, 0, 0 }, > > }; > > > > @@ -1102,7 +1104,8 @@ 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 =3D 1; > > break; > > case 'h': > > usage(argv[0]); > > diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index > > 4c0e258..2faeb90 100644 > > --- a/app/test-pmd/testpmd.c > > +++ b/app/test-pmd/testpmd.c > > @@ -12,6 +12,7 @@ > > #include > > #include > > #include > > +#include > > > > #include > > #include > > @@ -284,6 +285,8 @@ uint8_t lsc_interrupt =3D 1; /* enabled by default = */ > > */ > > uint8_t rmv_interrupt =3D 1; /* enabled by default */ > > > > +uint8_t hot_plug =3D 0; /**< hotplug disabled by default. */ > > + > > /* > > * Display or mask ether events > > * Default to all events except VF_MBOX @@ -391,6 +394,12 @@ static > > void check_all_ports_link_status(uint32_t > > port_mask); > > static int eth_event_callback(portid_t port_id, > > enum rte_eth_event_type type, > > void *param, void *ret_param); > > +static int eth_dev_event_callback(char *device_name, > > + enum rte_dev_event_type type, > > + void *param); > > +static int eth_dev_event_callback_register(void); > > +static int eth_dev_event_callback_unregister(void); > > + > > > > /* > > * Check if all the ports are started. > > @@ -1853,6 +1862,39 @@ reset_port(portid_t pid) > > printf("Done\n"); > > } > > > > +static int > > +eth_dev_event_callback_register(void) > > +{ > > + int diag; > > + > > + /* register the device event callback */ > > + diag =3D rte_dev_event_callback_register(NULL, > > + eth_dev_event_callback, NULL); > > + if (diag) { > > + printf("Failed to setup dev_event callback\n"); > > + return -1; > > + } > > + > > + return 0; > > +} > > + > > + > > +static int > > +eth_dev_event_callback_unregister(void) > > +{ > > + int diag; > > + > > + /* unregister the device event callback */ > > + diag =3D rte_dev_event_callback_unregister(NULL, > > + eth_dev_event_callback, NULL); > > + if (diag) { > > + printf("Failed to setup dev_event callback\n"); > > + return -1; > > + } > > + > > + return 0; > > +} > > + > > void > > attach_port(char *identifier) > > { > > @@ -1916,6 +1958,7 @@ void > > pmd_test_exit(void) > > { > > portid_t pt_id; > > + int ret; > > > > if (test_done =3D=3D 0) > > stop_packet_forwarding(); > > @@ -1929,6 +1972,18 @@ pmd_test_exit(void) > > close_port(pt_id); > > } > > } > > + > > + if (hot_plug) { > > + ret =3D rte_dev_event_monitor_stop(); > > + if (ret) > > + RTE_LOG(ERR, EAL, > > + "fail to stop device event monitor."); > > + > > + ret =3D eth_dev_event_callback_unregister(); > > + if (ret) > > + RTE_LOG(ERR, EAL, > > + "fail to unregister all event callbacks."); > > + } > > printf("\nBye...\n"); > > } > > > > @@ -2059,6 +2114,48 @@ eth_event_callback(portid_t port_id, enum > > rte_eth_event_type type, void *param, > > return 0; > > } > > > > +/* This function is used by the interrupt thread */ static int > > +eth_dev_event_callback(char *device_name, enum rte_dev_event_type > > type, > > + __rte_unused void *arg) > > +{ > > + int ret =3D 0; >=20 > From here >=20 > > + static const char * const event_desc[] =3D { > > + [RTE_DEV_EVENT_ADD] =3D "add", > > + [RTE_DEV_EVENT_REMOVE] =3D "remove", > > + }; > > + > > + if (type >=3D RTE_DEV_EVENT_MAX) { > > + fprintf(stderr, "%s called upon invalid event %d\n", > > + __func__, type); > > + fflush(stderr); > > + } else if (event_print_mask & (UINT32_C(1) << type)) { > > + printf("%s event\n", > > + event_desc[type]); > > + fflush(stdout); > > + } >=20 > to here, these check are not necessary. >=20 > > + > > + switch (type) { > > + case RTE_DEV_EVENT_REMOVE: > > + RTE_LOG(ERR, EAL, "The device: %s has been removed!\n", > > + device_name); > > + /* TODO: After finish failure handle, begin to stop > > + * packet forward, stop port, close port, detach port. > > + */ > > + break; > > + case RTE_DEV_EVENT_ADD: > > + RTE_LOG(ERR, EAL, "The device: %s has been added!\n", > > + device_name); > > + /* TODO: After finish kernel driver binding, > > + * begin to attach port. > > + */ > > + break; > > + default: > > + break; > > + } > > + return ret; > > +} > > + > > static int > > set_tx_queue_stats_mapping_registers(portid_t port_id, struct > > rte_port > > *port) > > { > > @@ -2474,8 +2571,9 @@ signal_handler(int signum) int main(int argc, > > char** argv) { > > - int diag; > > + int diag; > > portid_t port_id; > > + int ret; > > > > signal(SIGINT, signal_handler); > > signal(SIGTERM, signal_handler); > > @@ -2543,6 +2641,18 @@ main(int argc, char** argv) > > nb_rxq, nb_txq); > > > > init_config(); > > + > > + if (hot_plug) { > > + /* enable hot plug monitoring */ > > + ret =3D rte_dev_event_monitor_start(); > > + if (ret) { > > + rte_errno =3D EINVAL; > > + return -1; > > + } > > + eth_dev_event_callback_register(); > > + > > + } > > + > > if (start_port(RTE_PORT_ALL) !=3D 0) > > rte_exit(EXIT_FAILURE, "Start ports failed\n"); > > > > diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index > > 153abea..8fde68d 100644 > > --- a/app/test-pmd/testpmd.h > > +++ b/app/test-pmd/testpmd.h > > @@ -319,6 +319,8 @@ extern volatile int test_done; /* stop packet > > forwarding when set to 1. */ 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; > > +extern uint8_t hot_plug; /**< enable by "--hot-plug" parameter */ > > + > > /**< set by "--print-event xxxx" and "--mask-event xxxx parameters */ > > > > #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 1fd5395..d0ced36 100644 > > --- a/doc/guides/testpmd_app_ug/run_app.rst > > +++ b/doc/guides/testpmd_app_ug/run_app.rst > > @@ -479,3 +479,7 @@ The commandline options are: > > > > Set the hexadecimal bitmask of TX queue offloads. > > The default value is 0. > > + > > +* ``--hot-plug`` > > + > > + Enable device event monitor machenism for hotplug. >=20 > s/machenism/mechanism >=20 > > -- > > 2.7.4