DPDK patches and discussions
 help / color / mirror / Atom feed
* Re: [dpdk-dev] [PATCH v1] testpmd: add new command for show port info
@ 2018-08-29  5:36 Rami Rosen
  0 siblings, 0 replies; 3+ messages in thread
From: Rami Rosen @ 2018-08-29  5:36 UTC (permalink / raw)
  To: dev; +Cc: emma.finn

Hi,
Thanks for this patch, this patch is something needed.

It seems to me that adding get_valid_ports() is not necessary, as you have
rte_eth_dev_count_avail(), which is implemented the same; please look
in rte_ethdev.[c,h; and actually, testpmd uses
rte_eth_dev_count_avail(), for example, in attach_port() in testpmd.c.
Besides, it should return uint16_t and not int, as DPDK ports are 16
bits, and count is defined as uint16_t.

+int get_valid_ports(void)
+{
+ portid_t pid;
+ uint16_t count = 0;
+
+ RTE_ETH_FOREACH_DEV(pid) {
+ count ++;
+ }
+ return count;
+}

and in rte_ethdev.c you have:
uint16_t
rte_eth_dev_count_avail(void)
{
    uint16_t p;
    uint16_t count;

    count = 0;

    RTE_ETH_FOREACH_DEV(p)
        count++;

    return count;
}


Regards,
Rami Rosen

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH v1] testpmd: add new command for show port info
  2018-08-28 14:11 Emma Finn
@ 2018-08-28 16:55 ` Stephen Hemminger
  0 siblings, 0 replies; 3+ messages in thread
From: Stephen Hemminger @ 2018-08-28 16:55 UTC (permalink / raw)
  To: Emma Finn; +Cc: dev, john.mcnamara, ferruh.yigit, bernard.iremonger

On Tue, 28 Aug 2018 15:11:34 +0100
Emma Finn <emma.finn@intel.com> wrote:

> existing testpmd command "show port info" is too verbose.
> Added a new summary command to print brief information on ports.
> 
> Signed-off-by: Emma Finn <emma.finn@intel.com>

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
...

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [dpdk-dev] [PATCH v1] testpmd: add new command for show port info
@ 2018-08-28 14:11 Emma Finn
  2018-08-28 16:55 ` Stephen Hemminger
  0 siblings, 1 reply; 3+ messages in thread
From: Emma Finn @ 2018-08-28 14:11 UTC (permalink / raw)
  To: dev; +Cc: john.mcnamara, ferruh.yigit, bernard.iremonger, Emma Finn

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

Signed-off-by: Emma Finn <emma.finn@intel.com>
---
 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

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
old mode 100644
new mode 100755
index 589121d..21e0b7a
--- 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"
 
-			"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,
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
old mode 100644
new mode 100755
index 14ccd68..3e049ca
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -518,6 +518,35 @@ port_infos_display(portid_t port_id)
 }
 
 void
+port_summary_display(portid_t port_id, int all)
+{
+	struct ether_addr mac_addr;
+	struct rte_eth_link link;
+	struct rte_eth_dev_info dev_info;
+	int port_number;
+	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);
+	memset(&dev_info, 0, sizeof(dev_info));
+	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);
+	port_number = get_valid_ports();
+	if(all==1 && port_id ==0)
+		printf("Number of ports: %i \n", port_number);
+	printf("Port %-2d: %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;
@@ -768,6 +797,18 @@ void print_valid_ports(void)
 	printf(" ]\n");
 }
 
+int get_valid_ports(void)
+{
+	portid_t pid;
+	uint16_t count = 0;
+
+	RTE_ETH_FOREACH_DEV(pid) {
+		count ++;
+	}
+	return count;
+}
+
+
 static int
 vlan_id_is_invalid(uint16_t vlan_id)
 {
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
old mode 100644
new mode 100755
index a1f6614..28250e4
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -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);
-- 
2.7.4

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-08-29  5:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-29  5:36 [dpdk-dev] [PATCH v1] testpmd: add new command for show port info Rami Rosen
  -- strict thread matches above, loose matches on Subject: below --
2018-08-28 14:11 Emma Finn
2018-08-28 16:55 ` Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).