From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id C2F635F51 for ; Wed, 24 Oct 2018 18:13:25 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Oct 2018 09:13:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,421,1534834800"; d="scan'208";a="100330435" Received: from irsmsx153.ger.corp.intel.com ([163.33.192.75]) by fmsmga004.fm.intel.com with ESMTP; 24 Oct 2018 09:13:23 -0700 Received: from irsmsx156.ger.corp.intel.com (10.108.20.68) by IRSMSX153.ger.corp.intel.com (163.33.192.75) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 24 Oct 2018 17:13:22 +0100 Received: from irsmsx107.ger.corp.intel.com ([169.254.10.56]) by IRSMSX156.ger.corp.intel.com ([169.254.3.178]) with mapi id 14.03.0319.002; Wed, 24 Oct 2018 17:13:22 +0100 From: "Iremonger, Bernard" To: Thomas Monjalon , "Wu, Jingjing" , "Lu, Wenzhuo" CC: "dev@dpdk.org" , "ophirmu@mellanox.com" , "wisamm@mellanox.com" , "Yigit, Ferruh" , "arybchenko@solarflare.com" Thread-Topic: [PATCH 5/5] app/testpmd: setup attached ports on probe event Thread-Index: AQHUa59IVW7PytvdmkexSgler8eagKUujQZA Date: Wed, 24 Oct 2018 16:13:21 +0000 Message-ID: <8CEF83825BEC744B83065625E567D7C260D17043@IRSMSX107.ger.corp.intel.com> References: <20181024134111.26771-1-thomas@monjalon.net> <20181024134111.26771-6-thomas@monjalon.net> In-Reply-To: <20181024134111.26771-6-thomas@monjalon.net> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNTlmZjM3YTUtOGUzNi00ZTljLWJiZTUtNWQ1YzJhNmNjNTBiIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiSGNtYjh0MWJ5SndzZTlUQjdkOGJnOVcrQWtia1UrOXNJVVBGTnBET29HUHNwdkVvTHpYVWpWWVdkSkw1ZU9KRSJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [163.33.239.181] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH 5/5] app/testpmd: setup attached ports on probe event 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, 24 Oct 2018 16:13:26 -0000 Hi Thomas, > -----Original Message----- > From: Thomas Monjalon [mailto:thomas@monjalon.net] > Sent: Wednesday, October 24, 2018 2:41 PM > To: Iremonger, Bernard ; Wu, Jingjing > ; Lu, Wenzhuo > Cc: dev@dpdk.org; ophirmu@mellanox.com; wisamm@mellanox.com; Yigit, > Ferruh ; arybchenko@solarflare.com > Subject: [PATCH 5/5] app/testpmd: setup attached ports on probe event >=20 > After probing is done, each new port must be setup. > The new ports are currently guessed by iterating on ports matching the de= vargs > string used for probing. >=20 > When probing a port, it is possible that one more port probing get trigge= red (e.g. > PF is automatically probed when probing a VF representor). Such automatic > probing will be caught only on event. >=20 > The iterator loop may be replaced by a call from the event callback. > In order to be able to test both modes, a command is added to choose betw= een > iterator and event modes. >=20 > Signed-off-by: Thomas Monjalon > --- > app/test-pmd/cmdline.c | 57 +++++++++++++++++++++ > app/test-pmd/testpmd.c | 27 ++++++++-- > app/test-pmd/testpmd.h | 4 ++ > doc/guides/testpmd_app_ug/testpmd_funcs.rst | 9 ++++ > 4 files changed, 93 insertions(+), 4 deletions(-) >=20 > diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index > f041a01aa..148bd6366 100644 > --- a/app/test-pmd/cmdline.c > +++ b/app/test-pmd/cmdline.c > @@ -280,6 +280,9 @@ static void cmd_help_long_parsed(void *parsed_result, > "set portlist (x[,y]*)\n" > " Set the list of forwarding ports.\n\n" >=20 > + "set port setup on (iterator|event)\n" > + " Select how attached port is retrieved for setup.\n\n" > + > "set tx loopback (port_id) (on|off)\n" > " Enable or disable tx loopback.\n\n" >=20 > @@ -1249,6 +1252,59 @@ cmdline_parse_inst_t cmd_operate_specific_port =3D > { > }, > }; >=20 > +/* *** enable port setup (after attach) via iterator or event *** */ > +struct cmd_set_port_setup_on_result { > + cmdline_fixed_string_t set; > + cmdline_fixed_string_t port; > + cmdline_fixed_string_t setup; > + cmdline_fixed_string_t on; > + cmdline_fixed_string_t mode; > +}; > + > +static void cmd_set_port_setup_on_parsed(void *parsed_result, > + __attribute__((unused)) struct cmdline *cl, > + __attribute__((unused)) void *data) { > + struct cmd_set_port_setup_on_result *res =3D parsed_result; > + > + if (strcmp(res->mode, "event") =3D=3D 0) > + setup_on_probe_event =3D true; > + else if (strcmp(res->mode, "iterator") =3D=3D 0) > + setup_on_probe_event =3D false; > + else > + printf("Unknown mode\n"); > +} > + > +cmdline_parse_token_string_t cmd_set_port_setup_on_set =3D > + TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, > + set, "set"); > +cmdline_parse_token_string_t cmd_set_port_setup_on_port =3D > + TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, > + port, "port"); > +cmdline_parse_token_string_t cmd_set_port_setup_on_setup =3D > + TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, > + setup, "setup"); > +cmdline_parse_token_string_t cmd_set_port_setup_on_on =3D > + TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, > + on, "on"); > +cmdline_parse_token_string_t cmd_set_port_setup_on_mode =3D > + TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, > + mode, "iterator#event"); > + > +cmdline_parse_inst_t cmd_set_port_setup_on =3D { > + .f =3D cmd_set_port_setup_on_parsed, > + .data =3D NULL, > + .help_str =3D "set port setup on iterator|event", > + .tokens =3D { > + (void *)&cmd_set_port_setup_on_set, > + (void *)&cmd_set_port_setup_on_port, > + (void *)&cmd_set_port_setup_on_setup, > + (void *)&cmd_set_port_setup_on_on, > + (void *)&cmd_set_port_setup_on_mode, > + NULL, > + }, > +}; > + > /* *** attach a specified port *** */ > struct cmd_operate_attach_port_result { > cmdline_fixed_string_t port; > @@ -17796,6 +17852,7 @@ cmdline_parse_ctx_t main_ctx[] =3D { > (cmdline_parse_inst_t *)&cmd_operate_specific_port, > (cmdline_parse_inst_t *)&cmd_operate_attach_port, > (cmdline_parse_inst_t *)&cmd_operate_detach_port, > + (cmdline_parse_inst_t *)&cmd_set_port_setup_on, > (cmdline_parse_inst_t *)&cmd_config_speed_all, > (cmdline_parse_inst_t *)&cmd_config_speed_specific, > (cmdline_parse_inst_t *)&cmd_config_loopback_all, diff --git > a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index > 6eb416e7a..abecb58bf 100644 > --- a/app/test-pmd/testpmd.c > +++ b/app/test-pmd/testpmd.c > @@ -345,6 +345,9 @@ uint8_t rmv_interrupt =3D 1; /* enabled by default */ >=20 > uint8_t hot_plug =3D 0; /**< hotplug disabled by default. */ >=20 > +/* After attach, port setup is called on event or by iterator */ bool > +setup_on_probe_event =3D true; > + > /* Pretty printing of ethdev events */ > static const char * const eth_event_desc[] =3D { > [RTE_ETH_EVENT_UNKNOWN] =3D "unknown", > @@ -2280,7 +2283,7 @@ reset_port(portid_t pid) void attach_port(char > *identifier) { > - portid_t pi =3D 0; > + portid_t pi; > struct rte_dev_iterator iterator; >=20 > printf("Attaching a new port...\n"); > @@ -2295,7 +2298,19 @@ attach_port(char *identifier) > return; > } >=20 > + /* first attach mode: event */ > + if (setup_on_probe_event) { > + /* new ports are detected on RTE_ETH_EVENT_NEW event */ > + for (pi =3D 0; pi < RTE_MAX_ETHPORTS; pi++) > + if (ports[pi].port_status =3D=3D RTE_PORT_HANDLING && > + ports[pi].need_setup !=3D 0) > + setup_attached_port(pi); > + return; > + } > + > + /* second attach mode: iterator */ > RTE_ETH_FOREACH_MATCHING_DEV(pi, identifier, &iterator) { > + /* setup ports matching the devargs used for probing */ > if (port_is_forwarding(pi)) > continue; /* port was already attached before */ > setup_attached_port(pi); > @@ -2317,6 +2332,7 @@ setup_attached_port(portid_t pi) > ports_ids[nb_ports++] =3D pi; > fwd_ports_ids[nb_fwd_ports++] =3D pi; > nb_cfg_ports =3D nb_fwd_ports; > + ports[pi].need_setup =3D 0; > ports[pi].port_status =3D RTE_PORT_STOPPED; >=20 > printf("Port %d is attached. Now total ports is %d\n", pi, nb_ports); @= @ > -2535,11 +2551,14 @@ eth_event_callback(portid_t port_id, enum > rte_eth_event_type type, void *param, > fflush(stdout); > } >=20 > - if (port_id_is_invalid(port_id, DISABLED_WARN)) > - return 0; > - > switch (type) { > + case RTE_ETH_EVENT_NEW: > + ports[port_id].need_setup =3D 1; > + ports[port_id].port_status =3D RTE_PORT_HANDLING; > + break; > case RTE_ETH_EVENT_INTR_RMV: > + if (port_id_is_invalid(port_id, DISABLED_WARN)) > + break; > if (rte_eal_alarm_set(100000, > rmv_event_callback, (void *)(intptr_t)port_id)) > fprintf(stderr, "Could not set up deferred device > removal\n"); diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h > index 646e44940..28f13f630 100644 > --- a/app/test-pmd/testpmd.h > +++ b/app/test-pmd/testpmd.h > @@ -5,6 +5,8 @@ > #ifndef _TESTPMD_H_ > #define _TESTPMD_H_ >=20 > +#include > + > #include > #include > #include > @@ -179,6 +181,7 @@ struct rte_port { > uint8_t tx_queue_stats_mapping_enabled; > uint8_t rx_queue_stats_mapping_enabled; > volatile uint16_t port_status; /**< port started or not */ > + uint8_t need_setup; /**< port just attached */ > uint8_t need_reconfig; /**< need reconfiguring port or= not */ > uint8_t need_reconfig_queues; /**< need reconfiguring q= ueues > or not */ > uint8_t rss_flag; /**< enable rss or not */ > @@ -326,6 +329,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 bool setup_on_probe_event; /**< disabled by port setup-on > +iterator */ > extern uint8_t hot_plug; /**< enable by "--hot-plug" parameter */ exter= n int > do_mlockall; /**< set by "--mlockall" or "--no-mlockall" parameter */ >=20 > diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst > b/doc/guides/testpmd_app_ug/testpmd_funcs.rst > index d712bb657..8447f6c89 100644 > --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst > +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst > @@ -603,6 +603,15 @@ For example, to change the port forwarding: > RX P=3D1/Q=3D0 (socket 0) -> TX P=3D3/Q=3D0 (socket 0) peer=3D02:00:0= 0:00:00:03 > RX P=3D3/Q=3D0 (socket 0) -> TX P=3D1/Q=3D0 (socket 0) peer=3D02:00:0= 0:00:00:02 >=20 > +set port setup on > +~~~~~~~~~~~~~~~~~ > + > +Select how to retrieve new ports created after "port attach" command. > + > +For each new port, a setup is done. > +It will find the probed ports via RTE_ETH_FOREACH_MATCHING_DEV loop in > +iterator mode, or via RTE_ETH_EVENT_NEW in event mode. > + It would be useful to add an example command here (similar to other command= s). > set tx loopback > ~~~~~~~~~~~~~~~ >=20 > -- > 2.19.0 Regards, Bernard.