From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <bernard.iremonger@intel.com>
Received: from mga14.intel.com (mga14.intel.com [192.55.52.115])
 by dpdk.org (Postfix) with ESMTP id 4122E5F2E
 for <dev@dpdk.org>; Fri, 31 Aug 2018 18:33:39 +0200 (CEST)
X-Amp-Result: SKIPPED(no attachment in message)
X-Amp-File-Uploaded: False
Received: from orsmga004.jf.intel.com ([10.7.209.38])
 by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;
 31 Aug 2018 09:33:38 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.53,312,1531810800"; d="scan'208";a="229245816"
Received: from irsmsx104.ger.corp.intel.com ([163.33.3.159])
 by orsmga004.jf.intel.com with ESMTP; 31 Aug 2018 09:33:37 -0700
Received: from irsmsx107.ger.corp.intel.com ([169.254.10.116]) by
 IRSMSX104.ger.corp.intel.com ([169.254.5.213]) with mapi id 14.03.0319.002;
 Fri, 31 Aug 2018 17:33:36 +0100
From: "Iremonger, Bernard" <bernard.iremonger@intel.com>
To: "Finn, Emma" <emma.finn@intel.com>, "dev@dpdk.org" <dev@dpdk.org>
CC: "Mcnamara, John" <john.mcnamara@intel.com>, "Yigit, Ferruh"
 <ferruh.yigit@intel.com>, "stephen@networkplumber.org"
 <stephen@networkplumber.org>
Thread-Topic: [PATCH v5] app/testpmd: add new command for show port info
Thread-Index: AQHUQGO1xABYACffwUmd8CRfK47yFaTaDQdQ
Date: Fri, 31 Aug 2018 16:33:36 +0000
Message-ID: <8CEF83825BEC744B83065625E567D7C260CEAB67@IRSMSX107.ger.corp.intel.com>
References: <1535626992-124946-1-git-send-email-emma.finn@intel.com>
 <1535634741-125515-1-git-send-email-emma.finn@intel.com>
In-Reply-To: <1535634741-125515-1-git-send-email-emma.finn@intel.com>
Accept-Language: en-GB, en-US
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiOWIxMDZkMGMtZDZkNC00MDZlLWE4ZTYtYzViNzBhZjJhYzdiIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoidDJFVStEcTE2N2NvSFwvRm1mdVFlUFFCa0dHeEVPdmJsdDZGV3lPbThZOGVEYlVQdUs3UUhuQlhwQWhJdVJ0TWMifQ==
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 v5] app/testpmd: add new command for show
	port info
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Fri, 31 Aug 2018 16:33:41 -0000

Hi Emma,

> -----Original Message-----
> From: Finn, Emma
> Sent: Thursday, August 30, 2018 2:12 PM
> To: dev@dpdk.org
> Cc: Mcnamara, John <john.mcnamara@intel.com>; Yigit, Ferruh
> <ferruh.yigit@intel.com>; Iremonger, Bernard
> <bernard.iremonger@intel.com>; stephen@networkplumber.org; Finn,
> Emma <emma.finn@intel.com>
> Subject: [PATCH v5] app/testpmd: add new command for show port info
>=20
> existing testpmd command "show port info" is too verbose.
> Added a new summary command to print brief information on ports.
>=20
> console output:
> 	testpmd> show port summary all
> 	Number of available ports: 2
> 	Port MAC Address       Name          Driver   Status Link
> 	0    11:22:33:44:55:66 0000:07:00.0  net_i40e  up    40000Mbps
> 	1    66:55:44:33:22:11 0000:07:00.1  net_i40e  up    40000Mbps
>=20
> Signed-off-by: Emma Finn <emma.finn@intel.com>
> Reviewed-by: Stephen Hemminger <stephen@networkplumber.org>
> Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
>=20
> ---
>=20
> v2: droped off redundant information added
>     a single header line. (Stephen Hemminger)
>=20
> v3: removed deprecated function and refactored code.
>=20
> v4: fixed unsigned checkpatch warning and removed commas.
>=20
> v5: fixed commit message console output.
> ---
>  app/test-pmd/cmdline.c                      | 19 +++++++++++----
>  app/test-pmd/config.c                       | 37 +++++++++++++++++++++++=
++++++
>  app/test-pmd/testpmd.h                      |  2 ++
>  doc/guides/testpmd_app_ug/testpmd_funcs.rst |  4 +++-
>  4 files changed, 56 insertions(+), 6 deletions(-)
>=20
> diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index
> 589121d..e54e2e5 100644
> --- a/app/test-pmd/cmdline.c
> +++ b/app/test-pmd/cmdline.c
> @@ -167,7 +167,7 @@ static void cmd_help_long_parsed(void
> *parsed_result,
>  			"Display:\n"
>  			"--------\n\n"
>=20
> -			"show port
> (info|stats|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
> +			"show port
> (info|stats|summary|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
>  			"    Display information for port_id, or all.\n\n"
>=20
>  			"show port X rss reta (size) (mask0,mask1,...)\n"
> @@ -7073,6 +7073,11 @@ static void cmd_showportall_parsed(void
> *parsed_result,
>  	} else if (!strcmp(res->what, "info"))
>  		RTE_ETH_FOREACH_DEV(i)
>  			port_infos_display(i);
> +	else if (!strcmp(res->what, "summary")) {
> +		port_summary_header_display();
> +		RTE_ETH_FOREACH_DEV(i)
> +			port_summary_display(i);
> +	}
>  	else if (!strcmp(res->what, "stats"))
>  		RTE_ETH_FOREACH_DEV(i)
>  			nic_stats_display(i);
> @@ -7100,14 +7105,14 @@ cmdline_parse_token_string_t
> cmd_showportall_port =3D
>  	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port,
> "port");  cmdline_parse_token_string_t cmd_showportall_what =3D
>  	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
> -
> "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
> +
> "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
>  cmdline_parse_token_string_t cmd_showportall_all =3D
>  	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all,
> "all");  cmdline_parse_inst_t cmd_showportall =3D {
>  	.f =3D cmd_showportall_parsed,
>  	.data =3D NULL,
>  	.help_str =3D "show|clear port "
> -		"info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
> +		"info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap
> all",
>  	.tokens =3D {
>  		(void *)&cmd_showportall_show,
>  		(void *)&cmd_showportall_port,
> @@ -7137,6 +7142,10 @@ static void cmd_showport_parsed(void
> *parsed_result,
>  			nic_xstats_clear(res->portnum);
>  	} else if (!strcmp(res->what, "info"))
>  		port_infos_display(res->portnum);
> +	else if (!strcmp(res->what, "summary")) {
> +		port_summary_header_display();
> +		port_summary_display(res->portnum);
> +	}
>  	else if (!strcmp(res->what, "stats"))
>  		nic_stats_display(res->portnum);
>  	else if (!strcmp(res->what, "xstats")) @@ -7158,7 +7167,7 @@
> cmdline_parse_token_string_t cmd_showport_port =3D
>  	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port,
> "port");  cmdline_parse_token_string_t cmd_showport_what =3D
>  	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
> -
> "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
> +
> "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
>  cmdline_parse_token_num_t cmd_showport_portnum =3D
>  	TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum,
> UINT16);
>=20
> @@ -7166,7 +7175,7 @@ cmdline_parse_inst_t cmd_showport =3D {
>  	.f =3D cmd_showport_parsed,
>  	.data =3D NULL,
>  	.help_str =3D "show|clear port "
> -		"info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
> +		"info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
>  		"<port_id>",
>  	.tokens =3D {
>  		(void *)&cmd_showport_show,
> diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index
> 14ccd68..208aa7e 100644
> --- a/app/test-pmd/config.c
> +++ b/app/test-pmd/config.c
> @@ -518,6 +518,43 @@ port_infos_display(portid_t port_id)  }
>=20
>  void
> +port_summary_header_display(void)
> +{
> +	uint16_t port_number;
> +
> +	port_number =3D rte_eth_dev_count_avail();
> +	printf("Number of available ports: %i\n", port_number);
> +	printf("%s %s %10s %14s %8s %s\n", "Port", "MAC Address",
> "Name",
> +			"Driver", "Status", "Link");
> +}

The field width of the "Driver" heading is fine for "net_i40e" but a charac=
ter short for "net_ixgbe".
The field should be probably be a bit wider to allow for longer driver name=
s.

> +
> +void
> +port_summary_display(portid_t port_id)
> +{
> +	struct ether_addr mac_addr;
> +	struct rte_eth_link link;
> +	struct rte_eth_dev_info dev_info;
> +	char name[RTE_ETH_NAME_MAX_LEN];
> +
> +	if (port_id_is_invalid(port_id, ENABLED_WARN)) {
> +		print_valid_ports();
> +		return;
> +	}
> +
> +	rte_eth_link_get_nowait(port_id, &link);
> +	rte_eth_dev_info_get(port_id, &dev_info);
> +	rte_eth_dev_get_name_by_port(port_id, name);
> +	rte_eth_macaddr_get(port_id, &mac_addr);
> +
> +	printf("%-4d %02X:%02X:%02X:%02X:%02X:%02X %s %s %-6s
> %uMbps\n",
> +		port_id, mac_addr.addr_bytes[0], mac_addr.addr_bytes[1],
> +		mac_addr.addr_bytes[2], mac_addr.addr_bytes[3],
> +		mac_addr.addr_bytes[4], mac_addr.addr_bytes[5], name,
> +		dev_info.driver_name, (link.link_status) ? ("up") : ("down"),
> +		(unsigned int) link.link_speed);
> +}
> +
> +void
>  port_offload_cap_display(portid_t port_id)  {
>  	struct rte_eth_dev_info dev_info;
> diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index
> a1f6614..f0bc716 100644
> --- a/app/test-pmd/testpmd.h
> +++ b/app/test-pmd/testpmd.h
> @@ -594,6 +594,8 @@ void nic_xstats_display(portid_t port_id);  void
> nic_xstats_clear(portid_t port_id);  void nic_stats_mapping_display(porti=
d_t
> port_id);  void port_infos_display(portid_t port_id);
> +void port_summary_display(portid_t port_id); void
> +port_summary_header_display(void);
>  void port_offload_cap_display(portid_t port_id);  void
> rx_queue_infos_display(portid_t port_idi, uint16_t queue_id);  void
> tx_queue_infos_display(portid_t port_idi, uint16_t queue_id); diff --git
> a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> index dde205a..23c4feb 100644
> --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> @@ -159,12 +159,14 @@ show port
>=20
>  Display information for a given port or all ports::
>=20
> -   testpmd> show port (info|stats|xstats|fdir|stat_qmap|dcb_tc|cap)
> (port_id|all)
> +   testpmd> show port
> + (info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)
>=20
>  The available information categories are:
>=20
>  * ``info``: General port information such as MAC address.
>=20
> +* ``summary``: Brief port summary such as Device Name, Driver Name etc.
> +
>  * ``stats``: RX/TX statistics.
>=20
>  * ``xstats``: RX/TX extended NIC statistics.
> --
> 2.7.4

Regards,

Bernard.