Skip to contentSkip to conversation

testpmd: add new command for show port info

PATCH Superseded Emma Finn 5 participants 13 messages Aug 28, 2018 – Oct 11, 2018

lore
Share & tools
lore

Emma Finn

author
#0 lore raw

PATCH 1/1 testpmd: add new command for show port info

existing testpmd command "show port info" is too verbose. Added a new summary command to print brief information on ports.

---
 app/test-pmd/cmdline.c | 15 ++++++++++-----
 app/test-pmd/config.c  | 41 +++++++++++++++++++++++++++++++++++++++++
 app/test-pmd/testpmd.h |  2 ++
 3 files changed, 53 insertions(+), 5 deletions(-)
 mode change 100644 => 100755 app/test-pmd/cmdline.c
 mode change 100644 => 100755 app/test-pmd/config.c
 mode change 100644 => 100755 app/test-pmd/testpmd.h
app/test-pmd/cmdline.c +10 -5
old mode 100644
new mode 100755
index 589121d..21e0b7a
@@ -167,7 +167,7 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"Display:\n"
 			"--------\n\n"
 
-			"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"
 
 			"show port X rss reta (size) (mask0,mask1,...)\n"
@@ -7073,6 +7073,9 @@ 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"))
+		RTE_ETH_FOREACH_DEV(i)
+			port_summary_display(i,1);
 	else if (!strcmp(res->what, "stats"))
 		RTE_ETH_FOREACH_DEV(i)
 			nic_stats_display(i);
@@ -7100,14 +7103,14 @@ cmdline_parse_token_string_t cmd_showportall_port =
 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
 cmdline_parse_token_string_t cmd_showportall_what =
 	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 =
 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
 cmdline_parse_inst_t cmd_showportall = {
 	.f = cmd_showportall_parsed,
 	.data = NULL,
 	.help_str = "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 = {
 		(void *)&cmd_showportall_show,
 		(void *)&cmd_showportall_port,
@@ -7137,6 +7140,8 @@ 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_display(res->portnum,0);
 	else if (!strcmp(res->what, "stats"))
 		nic_stats_display(res->portnum);
 	else if (!strcmp(res->what, "xstats"))
@@ -7158,7 +7163,7 @@ cmdline_parse_token_string_t cmd_showport_port =
 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
 cmdline_parse_token_string_t cmd_showport_what =
 	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 =
 	TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
 
@@ -7166,7 +7171,7 @@ cmdline_parse_inst_t cmd_showport = {
 	.f = cmd_showport_parsed,
 	.data = NULL,
 	.help_str = "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 = {
 		(void *)&cmd_showport_show,
app/test-pmd/config.c +41 -0

53 lines not on this page · raw message

app/test-pmd/testpmd.h +2 -0
old mode 100644
new mode 100755
index a1f6614..28250e4
@@ -594,6 +594,7 @@ void nic_xstats_display(portid_t port_id);
 void nic_xstats_clear(portid_t port_id);
 void nic_stats_mapping_display(portid_t port_id);
 void port_infos_display(portid_t port_id);
+void port_summary_display(portid_t port_id, int all);
 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);
@@ -736,6 +737,7 @@ enum print_warning {
 };
 int port_id_is_invalid(portid_t port_id, enum print_warning warning);
 void print_valid_ports(void);
+int get_valid_ports(void);
 int new_socket_id(unsigned int socket_id);
 
 queueid_t get_allowed_max_nb_rxq(portid_t *pid);
Signature · 1 line
2.7.4
#1 lore raw
Quoted 4 lines · On Tue, 28 Aug 2018 15:11:34 +0100 Emma Finn <[email protected]> wrote:

existing testpmd command "show port info" is too verbose. Added a new summary command to print brief information on ports.

Looks good.
Maybe it would be better to drop off redundant information or only add a single header line like:

testpmd> show port summary all
Port Mac Name Driver Link Status
0 11:22:33:44:55 0001:00 ixgbe 10Gbit Up
...

author
#2 lore raw

PATCH v2 1/1 app/testpmd: add new command for show port info

In reply to Emma Finn

existing testpmd command "show port info" is too verbose. Added a new summary command to print brief information on ports.

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, 40000 Mbps
1 66:55:44:33:22:11 0000:07:00.1, net_i40e, up, 40000 Mbps

---

v2: droped off redundant information added
a single header line. (Stephen Hemminger)

---
 app/test-pmd/cmdline.c                      | 19 +++++++++++----
 app/test-pmd/config.c                       | 38 +++++++++++++++++++++++++++++
 app/test-pmd/testpmd.h                      |  2 ++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  4 ++-
 4 files changed, 57 insertions(+), 6 deletions(-)
app/test-pmd/cmdline.c +14 -5
index 589121d..bb15338 100644
@@ -167,7 +167,7 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"Display:\n"
 			"--------\n\n"
 
-			"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"
 
 			"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_number_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 =
 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
 cmdline_parse_token_string_t cmd_showportall_what =
 	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 =
 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
 cmdline_parse_inst_t cmd_showportall = {
 	.f = cmd_showportall_parsed,
 	.data = NULL,
 	.help_str = "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 = {
 		(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_number_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 =
 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
 cmdline_parse_token_string_t cmd_showport_what =
 	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 =
 	TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
 
@@ -7166,7 +7175,7 @@ cmdline_parse_inst_t cmd_showport = {
 	.f = cmd_showport_parsed,
 	.data = NULL,
 	.help_str = "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 = {
 		(void *)&cmd_showport_show,
app/test-pmd/config.c +38 -0
index 14ccd68..cf436ba 100644
@@ -518,6 +518,44 @@ port_infos_display(portid_t port_id)
 }
 
 void
+port_number_display(void)
+{
+	uint16_t port_number;
+	port_number = rte_eth_dev_count();
+	printf("Number of available ports: %i\n", port_number);
+	printf("%s %s %10s %15s %8s %s\n", "Port", "MAC Address", "Name",
+	"Driver", "Status", "Link");
+}
+
+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, %s, %u Mbps\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) link.link_speed);
+}
+
+
+void
 port_offload_cap_display(portid_t port_id)
 {
 	struct rte_eth_dev_info dev_info;
app/test-pmd/testpmd.h +2 -0
index a1f6614..842d4e0 100644
@@ -594,6 +594,7 @@ void nic_xstats_display(portid_t port_id);
 void nic_xstats_clear(portid_t port_id);
 void nic_stats_mapping_display(portid_t port_id);
 void port_infos_display(portid_t port_id);
+void port_summary_display(portid_t port_id);
 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);
@@ -736,6 +737,7 @@ enum print_warning {
 };
 int port_id_is_invalid(portid_t port_id, enum print_warning warning);
 void print_valid_ports(void);
+void port_number_display(void);
 int new_socket_id(unsigned int socket_id);
 
 queueid_t get_allowed_max_nb_rxq(portid_t *pid);
doc/guides/testpmd_app_ug/testpmd_funcs.rst +3 -1
index dde205a..23c4feb 100644
@@ -159,12 +159,14 @@ show port
 
 Display information for a given port or all ports::
 
-   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)
 
 The available information categories are:
 
 * ``info``: General port information such as MAC address.
 
+* ``summary``: Brief port summary such as Device Name, Driver Name etc.
+
 * ``stats``: RX/TX statistics.
 
 * ``xstats``: RX/TX extended NIC statistics.
Signature · 1 line
2.7.4
author
#3 lore raw

PATCH v3 1/1 app/testpmd: add new command for show port info

existing testpmd command "show port info" is too verbose. Added a new summary command to print brief information on ports.

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, 40000 Mbps
1 66:55:44:33:22:11 0000:07:00.1, net_i40e, up, 40000 Mbps

---

v2: droped off redundant information added
a single header line. (Stephen Hemminger)

v3: removed deprecated function and refactored code.

---
 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(-)
app/test-pmd/cmdline.c +14 -5
index 589121d..e54e2e5 100644
@@ -167,7 +167,7 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"Display:\n"
 			"--------\n\n"
 
-			"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"
 
 			"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 =
 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
 cmdline_parse_token_string_t cmd_showportall_what =
 	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 =
 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
 cmdline_parse_inst_t cmd_showportall = {
 	.f = cmd_showportall_parsed,
 	.data = NULL,
 	.help_str = "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 = {
 		(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 =
 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
 cmdline_parse_token_string_t cmd_showport_what =
 	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 =
 	TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
 
@@ -7166,7 +7175,7 @@ cmdline_parse_inst_t cmd_showport = {
 	.f = cmd_showport_parsed,
 	.data = NULL,
 	.help_str = "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 = {
 		(void *)&cmd_showport_show,
app/test-pmd/config.c +37 -0
index 14ccd68..237efc3 100644
@@ -518,6 +518,43 @@ port_infos_display(portid_t port_id)
 }
 
 void
+port_summary_header_display(void)
+{
+	uint16_t port_number;
+
+	port_number = rte_eth_dev_count_avail();
+	printf("Number of available ports: %i\n", port_number);
+	printf("%s %s %10s %15s %8s %s\n", "Port", "MAC Address", "Name",
+			"Driver", "Status", "Link");
+}
+
+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, %s, %u Mbps\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) link.link_speed);
+}
+
+void
 port_offload_cap_display(portid_t port_id)
 {
 	struct rte_eth_dev_info dev_info;
app/test-pmd/testpmd.h +2 -0
index a1f6614..f0bc716 100644
@@ -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(portid_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);
doc/guides/testpmd_app_ug/testpmd_funcs.rst +3 -1
index dde205a..23c4feb 100644
@@ -159,12 +159,14 @@ show port
 
 Display information for a given port or all ports::
 
-   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)
 
 The available information categories are:
 
 * ``info``: General port information such as MAC address.
 
+* ``summary``: Brief port summary such as Device Name, Driver Name etc.
+
 * ``stats``: RX/TX statistics.
 
 * ``xstats``: RX/TX extended NIC statistics.
Signature · 1 line
2.7.4
Reviewed-by on v3 1/1
#4 lore raw

Re: [PATCH v3] app/testpmd: add new command for show port info

Quoted 12 lines · On Wed, 29 Aug 2018 11:47:29 +0100 Emma Finn <[email protected]> wrote:

existing testpmd command "show port info" is too verbose. Added a new summary command to print brief information on ports.

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, 40000 Mbps
1 66:55:44:33:22:11 0000:07:00.1, net_i40e, up, 40000 Mbps

Looks good, thanks for doing this.
Is there a good way to handle ports that are "owned" as in bonding/failsafe etc?

Reviewed-by on v3 1/1
#5 lore raw

Re: [PATCH v3] app/testpmd: add new command for show port info

In reply to Emma Finn
Quoted 11 lines · Emma Finn

existing testpmd command "show port info" is too verbose. Added a new summary command to print brief information on ports.

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, 40000 Mbps
1 66:55:44:33:22:11 0000:07:00.1, net_i40e, up, 40000 Mbps

When header is used, I think no need "," between fields. Except from this,

#6 lore raw

Re: [PATCH v3] app/testpmd: add new command for show port info

In reply to Emma Finn

Hi Emma,

Quoted 148 lines

-----Original Message-----
From: Finn, Emma
Sent: Wednesday, August 29, 2018 11:47 AM
To: [email protected]
Cc: Mcnamara, John <[email protected]>; Yigit, Ferruh <[email protected]>; Iremonger, Bernard <[email protected]>; [email protected]; Finn, Emma <[email protected]>
Subject: [PATCH v3] app/testpmd: add new command for show port info

existing testpmd command "show port info" is too verbose. Added a new summary command to print brief information on ports.

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, 40000 Mbps
1 66:55:44:33:22:11 0000:07:00.1, net_i40e, up, 40000 Mbps

---

v2: droped off redundant information added
a single header line. (Stephen Hemminger)

v3: removed deprecated function and refactored code.

---
 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(-)
app/test-pmd/cmdline.c index renamed from app/test-pmd/cmdline.c +0 -0

589121d..e54e2e5 100644

app/test-pmd/cmdline.c +0 -1
@@ -167,7 +167,7 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"Display:\n"
 			"--------\n\n"
 
-			"show port

(info|stats|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"

app/test-pmd/cmdline.c +1 -0
+			"show port

(info|stats|summary|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"

app/test-pmd/cmdline.c +5 -0
 			"    Display information for port_id, or all.\n\n"
 
 			"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)
app/test-pmd/cmdline.c +0 -0
 			nic_stats_display(i);
@@ -7100,14 +7105,14 @@ cmdline_parse_token_string_t

cmd_showportall_port =
TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port,
"port"); cmdline_parse_token_string_t cmd_showportall_what =

app/test-pmd/cmdline.c +0 -1
 	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 =
TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
cmdline_parse_inst_t cmd_showportall = {

app/test-pmd/cmdline.c +5 -1
 	.f = cmd_showportall_parsed,
 	.data = NULL,
 	.help_str = "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 = {
 		(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 =
TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
cmdline_parse_token_string_t cmd_showport_what =

app/test-pmd/cmdline.c +0 -1
 	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 =
TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum,
UINT16);

app/test-pmd/cmdline.c +1 -1
@@ -7166,7 +7175,7 @@ cmdline_parse_inst_t cmd_showport = {
 	.f = cmd_showport_parsed,
 	.data = NULL,
 	.help_str = "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 = {
 		(void *)&cmd_showport_show,
app/test-pmd/config.c index renamed from app/test-pmd/config.c +0 -0

14ccd68..237efc3 100644

app/test-pmd/config.c +26 -0
@@ -518,6 +518,43 @@ port_infos_display(portid_t port_id)  }
 
 void
+port_summary_header_display(void)
+{
+	uint16_t port_number;
+
+	port_number = rte_eth_dev_count_avail();
+	printf("Number of available ports: %i\n", port_number);
+	printf("%s %s %10s %15s %8s %s\n", "Port", "MAC Address", "Name",
+			"Driver", "Status", "Link");
+}
+
+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);

app/test-pmd/config.c port_infos_display(portid_t port_id) } · line 555

Quoted 10 lines
app/test-pmd/config.c +9 -0
+	rte_eth_macaddr_get(port_id, &mac_addr);
+
+	printf("%-4d %02X:%02X:%02X:%02X:%02X:%02X %s, %s, %s, %u
 Mbps\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) link.link_speed);
+}

The checkpatch warning in the line above should probably be fixed.

WARNING: Prefer 'unsigned int' to bare use of 'unsigned' #157: FILE: app/test-pmd/config.c:554:
+ (unsigned) link.link_speed);

Quoted 40 lines
app/test-pmd/config.c +2 -0
+
+void
 port_offload_cap_display(portid_t port_id)  {
 	struct rte_eth_dev_info dev_info;
app/test-pmd/testpmd.h index renamed from app/test-pmd/testpmd.h +0 -0

a1f6614..f0bc716 100644

app/test-pmd/testpmd.h +0 -0
@@ -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(portid_t port_id); void port_infos_display(portid_t port_id);

app/test-pmd/testpmd.h +2 -0
+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

doc/guides/testpmd_app_ug/testpmd_funcs.rst +4 -2
@@ -159,12 +159,14 @@ show port
 
 Display information for a given port or all ports::
 
-   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)
 
 The available information categories are:
 
 * ``info``: General port information such as MAC address.
 
+* ``summary``: Brief port summary such as Device Name, Driver Name etc.
+
 * ``stats``: RX/TX statistics.
 
 * ``xstats``: RX/TX extended NIC statistics.
--
Quoted 1 line

2.7.4

Regards,

Bernard.

author
#7 lore raw

PATCH v4 1/1 app/testpmd: add new command for show port info

In reply to Emma Finn

existing testpmd command "show port info" is too verbose. Added a new summary command to print brief information on ports.

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, 40000 Mbps
1 66:55:44:33:22:11 0000:07:00.1, net_i40e, up, 40000 Mbps

---

v2: droped off redundant information added
a single header line. (Stephen Hemminger)

v3: removed deprecated function and refactored code.

v4: fixed unsigned checkpatch warning and removed commas.

---
 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(-)
app/test-pmd/cmdline.c +14 -5
index 589121d..e54e2e5 100644
@@ -167,7 +167,7 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"Display:\n"
 			"--------\n\n"
 
-			"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"
 
 			"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 =
 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
 cmdline_parse_token_string_t cmd_showportall_what =
 	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 =
 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
 cmdline_parse_inst_t cmd_showportall = {
 	.f = cmd_showportall_parsed,
 	.data = NULL,
 	.help_str = "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 = {
 		(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 =
 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
 cmdline_parse_token_string_t cmd_showport_what =
 	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 =
 	TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
 
@@ -7166,7 +7175,7 @@ cmdline_parse_inst_t cmd_showport = {
 	.f = cmd_showport_parsed,
 	.data = NULL,
 	.help_str = "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 = {
 		(void *)&cmd_showport_show,
app/test-pmd/config.c +37 -0
index 14ccd68..208aa7e 100644
@@ -518,6 +518,43 @@ port_infos_display(portid_t port_id)
 }
 
 void
+port_summary_header_display(void)
+{
+	uint16_t port_number;
+
+	port_number = 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");
+}
+
+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;
app/test-pmd/testpmd.h +2 -0
index a1f6614..f0bc716 100644
@@ -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(portid_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);
doc/guides/testpmd_app_ug/testpmd_funcs.rst +3 -1
index dde205a..23c4feb 100644
@@ -159,12 +159,14 @@ show port
 
 Display information for a given port or all ports::
 
-   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)
 
 The available information categories are:
 
 * ``info``: General port information such as MAC address.
 
+* ``summary``: Brief port summary such as Device Name, Driver Name etc.
+
 * ``stats``: RX/TX statistics.
 
 * ``xstats``: RX/TX extended NIC statistics.
Signature · 1 line
2.7.4
author
#8 lore raw

PATCH v5 1/1 app/testpmd: add new command for show port info

existing testpmd command "show port info" is too verbose. Added a new summary command to print brief information on ports.

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

---

v2: droped off redundant information added
a single header line. (Stephen Hemminger)

v3: removed deprecated function and refactored code.

v4: fixed unsigned checkpatch warning and removed commas.

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(-)
app/test-pmd/cmdline.c +14 -5
index 589121d..e54e2e5 100644
@@ -167,7 +167,7 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"Display:\n"
 			"--------\n\n"
 
-			"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"
 
 			"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 =
 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
 cmdline_parse_token_string_t cmd_showportall_what =
 	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 =
 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
 cmdline_parse_inst_t cmd_showportall = {
 	.f = cmd_showportall_parsed,
 	.data = NULL,
 	.help_str = "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 = {
 		(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 =
 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
 cmdline_parse_token_string_t cmd_showport_what =
 	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 =
 	TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
 
@@ -7166,7 +7175,7 @@ cmdline_parse_inst_t cmd_showport = {
 	.f = cmd_showport_parsed,
 	.data = NULL,
 	.help_str = "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 = {
 		(void *)&cmd_showport_show,
app/test-pmd/config.c +37 -0
index 14ccd68..208aa7e 100644
@@ -518,6 +518,43 @@ port_infos_display(portid_t port_id)
 }
 
 void
+port_summary_header_display(void)
+{
+	uint16_t port_number;
+
+	port_number = 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");
+}
+
+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;
app/test-pmd/testpmd.h +2 -0
index a1f6614..f0bc716 100644
@@ -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(portid_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);
doc/guides/testpmd_app_ug/testpmd_funcs.rst +3 -1
index dde205a..23c4feb 100644
@@ -159,12 +159,14 @@ show port
 
 Display information for a given port or all ports::
 
-   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)
 
 The available information categories are:
 
 * ``info``: General port information such as MAC address.
 
+* ``summary``: Brief port summary such as Device Name, Driver Name etc.
+
 * ``stats``: RX/TX statistics.
 
 * ``xstats``: RX/TX extended NIC statistics.
Signature · 1 line
2.7.4
#9 lore raw

Re: [PATCH v5] app/testpmd: add new command for show port info

Hi Emma,

Quoted 131 lines

-----Original Message-----
From: Finn, Emma
Sent: Thursday, August 30, 2018 2:12 PM
To: [email protected]
Cc: Mcnamara, John <[email protected]>; Yigit, Ferruh <[email protected]>; Iremonger, Bernard <[email protected]>; [email protected]; Finn, Emma <[email protected]>
Subject: [PATCH v5] app/testpmd: add new command for show port info

existing testpmd command "show port info" is too verbose. Added a new summary command to print brief information on ports.

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

---

v2: droped off redundant information added
a single header line. (Stephen Hemminger)

v3: removed deprecated function and refactored code.

v4: fixed unsigned checkpatch warning and removed commas.

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(-)
app/test-pmd/cmdline.c index renamed from app/test-pmd/cmdline.c +0 -0

589121d..e54e2e5 100644

app/test-pmd/cmdline.c +0 -1
@@ -167,7 +167,7 @@ static void cmd_help_long_parsed(void
 *parsed_result,
 			"Display:\n"
 			"--------\n\n"
 
-			"show port

(info|stats|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"

app/test-pmd/cmdline.c +1 -0
+			"show port

(info|stats|summary|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"

app/test-pmd/cmdline.c +5 -0
 			"    Display information for port_id, or all.\n\n"
 
 			"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)
app/test-pmd/cmdline.c +0 -0
 			nic_stats_display(i);
@@ -7100,14 +7105,14 @@ cmdline_parse_token_string_t

cmd_showportall_port =
TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port,
"port"); cmdline_parse_token_string_t cmd_showportall_what =

app/test-pmd/cmdline.c +0 -1
 	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 =
TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all,
"all"); cmdline_parse_inst_t cmd_showportall = {

app/test-pmd/cmdline.c +1 -1
 	.f = cmd_showportall_parsed,
 	.data = NULL,
 	.help_str = "show|clear port "
-		"info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
+		"info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap

all",

app/test-pmd/cmdline.c +4 -0
 	.tokens = {
 		(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 =
TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port,
"port"); cmdline_parse_token_string_t cmd_showport_what =

app/test-pmd/cmdline.c +0 -1
 	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 =
TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum,
UINT16);

app/test-pmd/cmdline.c +1 -1
@@ -7166,7 +7175,7 @@ cmdline_parse_inst_t cmd_showport = {
 	.f = cmd_showport_parsed,
 	.data = NULL,
 	.help_str = "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 = {
 		(void *)&cmd_showport_show,
app/test-pmd/config.c index renamed from app/test-pmd/config.c +0 -0

14ccd68..208aa7e 100644

app/test-pmd/config.c +0 -0
@@ -518,6 +518,43 @@ port_infos_display(portid_t port_id)  }
 
 void

app/test-pmd/config.c port_infos_display(portid_t port_id) } · line 529

Quoted 10 lines
app/test-pmd/config.c +9 -0
+port_summary_header_display(void)
+{
+	uint16_t port_number;
+
+	port_number = 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 character short for "net_ixgbe". The field should be probably be a bit wider to allow for longer driver names.

Quoted 67 lines
app/test-pmd/config.c +28 -0
+
+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;
app/test-pmd/testpmd.h index renamed from app/test-pmd/testpmd.h +0 -0

a1f6614..f0bc716 100644

app/test-pmd/testpmd.h +0 -0
@@ -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(portid_t port_id); void port_infos_display(portid_t port_id);

app/test-pmd/testpmd.h +2 -0
+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

doc/guides/testpmd_app_ug/testpmd_funcs.rst +4 -2
@@ -159,12 +159,14 @@ show port
 
 Display information for a given port or all ports::
 
-   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)
 
 The available information categories are:
 
 * ``info``: General port information such as MAC address.
 
+* ``summary``: Brief port summary such as Device Name, Driver Name etc.
+
 * ``stats``: RX/TX statistics.
 
 * ``xstats``: RX/TX extended NIC statistics.
--
Quoted 1 line

2.7.4

Regards,

Bernard.

#10 lore raw

PATCH v6 1/1 app/testpmd: add new command for show port info

In reply to Emma Finn

From: Emma Finn <[email protected]>

existing testpmd command "show port info" is too verbose. Added a new summary command to print brief information on ports.

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

---

v2: droped off redundant information added
a single header line. (Stephen Hemminger)

v3: removed deprecated function and refactored code.

v4: fixed unsigned checkpatch warning and removed commas.

v5: fixed commit message console output.

V6: changed the fields to me a bit wider to allow for longer
driver names

---
 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(-)
app/test-pmd/cmdline.c +14 -5
index 0cbd340..cb0d9ef 100644
@@ -167,7 +167,7 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"Display:\n"
 			"--------\n\n"
 
-			"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"
 
 			"show port X rss reta (size) (mask0,mask1,...)\n"
@@ -7071,6 +7071,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);
@@ -7098,14 +7103,14 @@ cmdline_parse_token_string_t cmd_showportall_port =
 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
 cmdline_parse_token_string_t cmd_showportall_what =
 	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 =
 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
 cmdline_parse_inst_t cmd_showportall = {
 	.f = cmd_showportall_parsed,
 	.data = NULL,
 	.help_str = "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 = {
 		(void *)&cmd_showportall_show,
 		(void *)&cmd_showportall_port,
@@ -7135,6 +7140,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"))
@@ -7156,7 +7165,7 @@ cmdline_parse_token_string_t cmd_showport_port =
 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
 cmdline_parse_token_string_t cmd_showport_what =
 	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 =
 	TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
 
@@ -7164,7 +7173,7 @@ cmdline_parse_inst_t cmd_showport = {
 	.f = cmd_showport_parsed,
 	.data = NULL,
 	.help_str = "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 = {
 		(void *)&cmd_showport_show,
app/test-pmd/config.c +37 -0
index a0f9349..d53723c 100644
@@ -518,6 +518,43 @@ port_infos_display(portid_t port_id)
 }
 
 void
+port_summary_header_display(void)
+{
+	uint16_t port_number;
+
+	port_number = rte_eth_dev_count_avail();
+	printf("Number of available ports: %i\n", port_number);
+	printf("%-4s %-17s %-12s %-14s %-8s %s\n", "Port", "MAC Address", "Name",
+			"Driver", "Status", "Link");
+}
+
+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 %-12s %-14s %-8s %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;
app/test-pmd/testpmd.h +2 -0
index a1f6614..f0bc716 100644
@@ -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(portid_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);
doc/guides/testpmd_app_ug/testpmd_funcs.rst +3 -1
index dde205a..23c4feb 100644
@@ -159,12 +159,14 @@ show port
 
 Display information for a given port or all ports::
 
-   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)
 
 The available information categories are:
 
 * ``info``: General port information such as MAC address.
 
+* ``summary``: Brief port summary such as Device Name, Driver Name etc.
+
 * ``stats``: RX/TX statistics.
 
 * ``xstats``: RX/TX extended NIC statistics.
Signature · 1 line
2.9.5
Acked-by on v6 1/1
#11 lore raw

Re: [PATCH v6] app/testpmd: add new command for show port info

Quoted 20 lines

-----Original Message-----
From: Kovacevic, Marko
Sent: Tuesday, September 25, 2018 11:33 AM
To: [email protected]
Cc: Yigit, Ferruh <[email protected]>; Iremonger, Bernard <[email protected]>; Finn, Emma <[email protected]>
Subject: [PATCH v6] app/testpmd: add new command for show port info

From: Emma Finn <[email protected]>

existing testpmd command "show port info" is too verbose. Added a new summary command to print brief information on ports.

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

Quoted 3 lines
Applied
#12 lore raw

Re: [PATCH v6] app/testpmd: add new command for show port info

Quoted 20 lines · Bernard
Quoted 20 lines

-----Original Message-----
From: Kovacevic, Marko
Sent: Tuesday, September 25, 2018 11:33 AM
To: [email protected]
Cc: Yigit, Ferruh <[email protected]>; Iremonger, Bernard <[email protected]>; Finn, Emma <[email protected]>
Subject: [PATCH v6] app/testpmd: add new command for show port info

From: Emma Finn <[email protected]>

existing testpmd command "show port info" is too verbose. Added a new summary command to print brief information on ports.

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

Quoted 5 lines
Quoted 3 lines

Applied to dpdk-next-net/master, thanks.