From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 21CB3A2EEB for ; Thu, 12 Sep 2019 12:53:57 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 07D7E1E933; Thu, 12 Sep 2019 12:53:56 +0200 (CEST) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id C12721E90B for ; Thu, 12 Sep 2019 12:53:53 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Sep 2019 03:53:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,495,1559545200"; d="scan'208";a="186097778" Received: from irsmsx151.ger.corp.intel.com ([163.33.192.59]) by fmsmga007.fm.intel.com with ESMTP; 12 Sep 2019 03:53:51 -0700 Received: from irsmsx108.ger.corp.intel.com ([169.254.11.26]) by IRSMSX151.ger.corp.intel.com ([169.254.4.234]) with mapi id 14.03.0439.000; Thu, 12 Sep 2019 11:53:50 +0100 From: "Iremonger, Bernard" To: "vattunuru@marvell.com" , "dev@dpdk.org" CC: "Lu, Wenzhuo" , "Wu, Jingjing" , "thomas@monjalon.net" Thread-Topic: [dpdk-dev] [PATCH v1 1/1] app/testpmd: add function to display port supported ptypes Thread-Index: AQHVYHrzlBBjIkNdQEmsBWkwesSYcKcn7tog Date: Thu, 12 Sep 2019 10:53:49 +0000 Message-ID: <8CEF83825BEC744B83065625E567D7C260DF7131@IRSMSX108.ger.corp.intel.com> References: <20190901040731.13820-1-vattunuru@marvell.com> In-Reply-To: <20190901040731.13820-1-vattunuru@marvell.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYzZhZjdkZjYtMDg2MS00ZjBjLWFiNzgtOTdmZGIzMTJlNmYzIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiVkZnNWtneUgxR0pZY2xvWjJycDBcLzNMMHZsOGZQYTRpUHBVTXhKOTJyMEtraFJzYUFmRlcyZkRsS1pwNmdQbkYifQ== x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-originating-ip: [163.33.239.182] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v1 1/1] app/testpmd: add function to display port supported ptypes 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi Vamsi, > -----Original Message----- > From: vattunuru@marvell.com [mailto:vattunuru@marvell.com] > Sent: Sunday, September 1, 2019 5:08 AM > To: dev@dpdk.org > Cc: Lu, Wenzhuo ; Wu, Jingjing > ; Iremonger, Bernard = ; > thomas@monjalon.net; Vamsi Attunuru > Subject: [dpdk-dev] [PATCH v1 1/1] app/testpmd: add function to display p= ort > supported ptypes >=20 > From: Vamsi Attunuru >=20 > Patch adds a runtime function to display ptypes supported by the given po= rt in > different layers. >=20 > Signed-off-by: Vamsi Attunuru > --- > app/test-pmd/cmdline.c | 111 ++++++++++++++++++++++= ++++++ > doc/guides/testpmd_app_ug/testpmd_funcs.rst | 7 ++ > 2 files changed, 118 insertions(+) >=20 > diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index > 56783aa..839c1b0 100644 > --- a/app/test-pmd/cmdline.c > +++ b/app/test-pmd/cmdline.c > @@ -238,6 +238,10 @@ static void cmd_help_long_parsed(void *parsed_result= , > " Show Tx metadata value set" > " for a specific port\n\n" >=20 > + "show port (port_id) ptypes\n" > + " Show port supported ptypes" > + " for a specific port\n\n" > + > "show device info (|all)" > " Show general information about devices > probed.\n\n" > ); > @@ -18820,6 +18824,112 @@ cmdline_parse_inst_t cmd_show_tx_metadata =3D > { > }, > }; >=20 > +/* show port supported ptypes */ > + > +/* Common result structure for show port ptypes */ struct > +cmd_show_port_supported_ptypes_result { > + cmdline_fixed_string_t show; > + cmdline_fixed_string_t port; > + portid_t port_id; > + cmdline_fixed_string_t ptypes; > +}; > + > +/* Common CLI fields for show port ptypes */ > +cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =3D > + TOKEN_STRING_INITIALIZER > + (struct cmd_show_port_supported_ptypes_result, > + show, "show"); > +cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =3D > + TOKEN_STRING_INITIALIZER > + (struct cmd_show_port_supported_ptypes_result, > + port, "port"); > +cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =3D > + TOKEN_NUM_INITIALIZER > + (struct cmd_show_port_supported_ptypes_result, > + port_id, UINT16); > +cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =3D > + TOKEN_STRING_INITIALIZER > + (struct cmd_show_port_supported_ptypes_result, > + ptypes, "ptypes"); > + > +static void > +cmd_show_port_supported_ptypes_parsed( > + void *parsed_result, > + __attribute__((unused)) struct cmdline *cl, > + __attribute__((unused)) void *data) > +{ > + struct cmd_show_port_supported_ptypes_result *res =3D parsed_result; > + uint32_t ptype_mask =3D RTE_PTYPE_L2_MASK; > + uint32_t resv_mask =3D 0xf0000000; It would be better to replace 0xf0000000 with a macro. > + uint16_t port_id =3D res->port_id; > + int max_layer_ptypes =3D 16; > + uint32_t ptypes[max_layer_ptypes]; > + char buf[256], ltype[32]; It would be better to replace the numbers 16, 256 and 32 with macros. > + int ret, i; > + > + ret =3D rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, > 0); > + if (ret < 0) > + return; > + > + while (ptype_mask !=3D resv_mask) { > + > + switch (ptype_mask) { > + case RTE_PTYPE_L2_MASK: > + strlcpy(ltype, "L2", sizeof(ltype)); > + break; > + case RTE_PTYPE_L3_MASK: > + strlcpy(ltype, "L3", sizeof(ltype)); > + break; > + case RTE_PTYPE_L4_MASK: > + strlcpy(ltype, "L4", sizeof(ltype)); > + break; > + case RTE_PTYPE_TUNNEL_MASK: > + strlcpy(ltype, "Tunnel", sizeof(ltype)); > + break; > + case RTE_PTYPE_INNER_L2_MASK: > + strlcpy(ltype, "Inner L2", sizeof(ltype)); > + break; > + case RTE_PTYPE_INNER_L3_MASK: > + strlcpy(ltype, "Inner L3", sizeof(ltype)); > + break; > + case RTE_PTYPE_INNER_L4_MASK: > + strlcpy(ltype, "Inner L4", sizeof(ltype)); > + break; > + default: > + return; > + } > + > + ret =3D rte_eth_dev_get_supported_ptypes(res->port_id, > + ptype_mask, ptypes, > + max_layer_ptypes); > + > + if (ret > 0) > + printf("Supported %s ptypes:\n", ltype); > + else > + printf("%s ptypes unsupported\n", ltype); > + > + for (i =3D 0; i < ret; ++i) { > + rte_get_ptype_name(ptypes[i], buf, sizeof(buf)); > + printf("%s\n", buf); > + } > + > + ptype_mask <<=3D 4; > + } > +} > + > +cmdline_parse_inst_t cmd_show_port_supported_ptypes =3D { > + .f =3D cmd_show_port_supported_ptypes_parsed, > + .data =3D NULL, > + .help_str =3D "show port ptypes", > + .tokens =3D { > + (void *)&cmd_show_port_supported_ptypes_show, > + (void *)&cmd_show_port_supported_ptypes_port, > + (void *)&cmd_show_port_supported_ptypes_port_id, > + (void *)&cmd_show_port_supported_ptypes_ptypes, > + NULL, > + }, > +}; > + > /* > ***************************************************************** > *************** */ >=20 > /* list of instructions */ > @@ -19058,6 +19168,7 @@ cmdline_parse_ctx_t main_ctx[] =3D { > (cmdline_parse_inst_t *)&cmd_clear_input_set, > (cmdline_parse_inst_t *)&cmd_show_vf_stats, > (cmdline_parse_inst_t *)&cmd_clear_vf_stats, > + (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes, > (cmdline_parse_inst_t *)&cmd_ptype_mapping_get, > (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace, > (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset, diff --git > a/doc/guides/testpmd_app_ug/testpmd_funcs.rst > b/doc/guides/testpmd_app_ug/testpmd_funcs.rst > index 313e070..1acd958 100644 > --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst > +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst > @@ -467,6 +467,13 @@ Show Tx metadata value set for a specific port:: >=20 > testpmd> show port (port_id) tx_metadata >=20 > +show port supported ptypes > +~~~~~~~~~~~~~~~~~~~~~~~~~~ > + > +Show ptypes supported for a specific port:: > + > + testpmd> show port (port_id) ptypes > + > show device info > ~~~~~~~~~~~~~~~~ >=20 > -- > 2.8.4 The 19.11 release notes should also be updated to announce the new command. Regards, Bernard.