[dpdk-stable] patch 'app/testpmd: fix valid ports prints' has been queued to LTS release 16.11.7

luca.boccassi at gmail.com luca.boccassi at gmail.com
Tue May 15 19:19:16 CEST 2018


Hi,

FYI, your patch has been queued to LTS release 16.11.7

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 05/16/18. So please
shout if anyone has objections.

Thanks.

Luca Boccassi

---
>From 7b0aba99264016554e6583ba3d5df5800a7dd2b1 Mon Sep 17 00:00:00 2001
From: Matan Azrad <matan at mellanox.com>
Date: Thu, 3 May 2018 10:31:43 +0000
Subject: [PATCH] app/testpmd: fix valid ports prints

[ upstream commit 8f3c4176fc11ed10dac9384a33ca470f3ef52c6a ]

There are several cases of an invalid port data access that causes the
printing of all the valid ports, for example, when the user asks to
receive a port information of an invalid port.

Wrongly, the port with id 0 is printed in all the above described
cases, regardless of its validity.

Print port 0 only if it is valid as done for the rest of the ports.

Fixes: af75078fece3 ("first public release")
Fixes: b6ea6408fbc7 ("ethdev: store numa_node per device")
Fixes: edab33b1c01d ("app/testpmd: support port hotplug")

Signed-off-by: Matan Azrad <matan at mellanox.com>
---
 app/test-pmd/config.c     | 36 +++++++++++++++---------------------
 app/test-pmd/parameters.c | 12 ++----------
 app/test-pmd/testpmd.h    |  1 +
 3 files changed, 18 insertions(+), 31 deletions(-)

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 69fa04be4..130ff1480 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -163,15 +163,11 @@ nic_stats_display(portid_t port_id)
 	struct rte_eth_stats stats;
 	struct rte_port *port = &ports[port_id];
 	uint8_t i;
-	portid_t pid;
 
 	static const char *nic_stats_border = "########################";
 
 	if (port_id_is_invalid(port_id, ENABLED_WARN)) {
-		printf("Valid port range is [0");
-		FOREACH_PORT(pid, ports)
-			printf(", %d", pid);
-		printf("]\n");
+		print_valid_ports();
 		return;
 	}
 	rte_eth_stats_get(port_id, &stats);
@@ -245,13 +241,8 @@ nic_stats_display(portid_t port_id)
 void
 nic_stats_clear(portid_t port_id)
 {
-	portid_t pid;
-
 	if (port_id_is_invalid(port_id, ENABLED_WARN)) {
-		printf("Valid port range is [0");
-		FOREACH_PORT(pid, ports)
-			printf(", %d", pid);
-		printf("]\n");
+		print_valid_ports();
 		return;
 	}
 	rte_eth_stats_reset(port_id);
@@ -325,15 +316,11 @@ nic_stats_mapping_display(portid_t port_id)
 {
 	struct rte_port *port = &ports[port_id];
 	uint16_t i;
-	portid_t pid;
 
 	static const char *nic_stats_mapping_border = "########################";
 
 	if (port_id_is_invalid(port_id, ENABLED_WARN)) {
-		printf("Valid port range is [0");
-		FOREACH_PORT(pid, ports)
-			printf(", %d", pid);
-		printf("]\n");
+		print_valid_ports();
 		return;
 	}
 
@@ -445,13 +432,9 @@ port_infos_display(portid_t port_id)
 	int vlan_offload;
 	struct rte_mempool * mp;
 	static const char *info_border = "*********************";
-	portid_t pid;
 
 	if (port_id_is_invalid(port_id, ENABLED_WARN)) {
-		printf("Valid port range is [0");
-		FOREACH_PORT(pid, ports)
-			printf(", %d", pid);
-		printf("]\n");
+		print_valid_ports();
 		return;
 	}
 	port = &ports[port_id];
@@ -554,6 +537,17 @@ port_id_is_invalid(portid_t port_id, enum print_warning warning)
 	return 1;
 }
 
+void print_valid_ports(void)
+{
+	portid_t pid;
+
+	printf("The valid ports array is [");
+	FOREACH_PORT(pid, ports) {
+		printf(" %d", pid);
+	}
+	printf(" ]\n");
+}
+
 static int
 vlan_id_is_invalid(uint16_t vlan_id)
 {
diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c
index 092339174..4a74ada22 100644
--- a/app/test-pmd/parameters.c
+++ b/app/test-pmd/parameters.c
@@ -370,7 +370,6 @@ parse_portnuma_config(const char *q_arg)
 	};
 	unsigned long int_fld[_NUM_FLD];
 	char *str_fld[_NUM_FLD];
-	portid_t pid;
 
 	/* reset from value set at definition */
 	while ((p = strchr(p0,'(')) != NULL) {
@@ -394,10 +393,7 @@ parse_portnuma_config(const char *q_arg)
 		port_id = (portid_t)int_fld[FLD_PORT];
 		if (port_id_is_invalid(port_id, ENABLED_WARN) ||
 			port_id == (portid_t)RTE_PORT_ALL) {
-			printf("Valid port range is [0");
-			FOREACH_PORT(pid, ports)
-				printf(", %d", pid);
-			printf("]\n");
+			print_valid_ports();
 			return -1;
 		}
 		socket_id = (uint8_t)int_fld[FLD_SOCKET];
@@ -429,7 +425,6 @@ parse_ringnuma_config(const char *q_arg)
 	};
 	unsigned long int_fld[_NUM_FLD];
 	char *str_fld[_NUM_FLD];
-	portid_t pid;
 	#define RX_RING_ONLY 0x1
 	#define TX_RING_ONLY 0x2
 	#define RXTX_RING    0x3
@@ -456,10 +451,7 @@ parse_ringnuma_config(const char *q_arg)
 		port_id = (portid_t)int_fld[FLD_PORT];
 		if (port_id_is_invalid(port_id, ENABLED_WARN) ||
 			port_id == (portid_t)RTE_PORT_ALL) {
-			printf("Valid port range is [0");
-			FOREACH_PORT(pid, ports)
-				printf(", %d", pid);
-			printf("]\n");
+			print_valid_ports();
 			return -1;
 		}
 		socket_id = (uint8_t)int_fld[FLD_SOCKET];
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 9c1e7039c..81034d0ea 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -599,6 +599,7 @@ enum print_warning {
 	DISABLED_WARN
 };
 int port_id_is_invalid(portid_t port_id, enum print_warning warning);
+void print_valid_ports(void);
 
 /*
  * Work-around of a compilation error with ICC on invocations of the
-- 
2.14.2



More information about the stable mailing list