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

Yuanhan Liu yliu at fridaylinux.org
Sun May 20 15:02:26 CEST 2018


Hi,

FYI, your patch has been queued to LTS release 17.11.3

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/27/18. So please
shout if anyone has objections.

Thanks.

	--yliu

---
>From 1e9c8c032819494252345b2965f66f56d7cf5fcf 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 a0f3c2468..61608d18f 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -149,15 +149,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");
-		RTE_ETH_FOREACH_DEV(pid)
-			printf(", %d", pid);
-		printf("]\n");
+		print_valid_ports();
 		return;
 	}
 	rte_eth_stats_get(port_id, &stats);
@@ -231,13 +227,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");
-		RTE_ETH_FOREACH_DEV(pid)
-			printf(", %d", pid);
-		printf("]\n");
+		print_valid_ports();
 		return;
 	}
 	rte_eth_stats_reset(port_id);
@@ -314,15 +305,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");
-		RTE_ETH_FOREACH_DEV(pid)
-			printf(", %d", pid);
-		printf("]\n");
+		print_valid_ports();
 		return;
 	}
 
@@ -434,14 +421,10 @@ port_infos_display(portid_t port_id)
 	int vlan_offload;
 	struct rte_mempool * mp;
 	static const char *info_border = "*********************";
-	portid_t pid;
 	uint16_t mtu;
 
 	if (port_id_is_invalid(port_id, ENABLED_WARN)) {
-		printf("Valid port range is [0");
-		RTE_ETH_FOREACH_DEV(pid)
-			printf(", %d", pid);
-		printf("]\n");
+		print_valid_ports();
 		return;
 	}
 	port = &ports[port_id];
@@ -739,6 +722,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 [");
+	RTE_ETH_FOREACH_DEV(pid) {
+		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 8fbb5150b..5d51808f5 100644
--- a/app/test-pmd/parameters.c
+++ b/app/test-pmd/parameters.c
@@ -403,7 +403,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) {
@@ -427,10 +426,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");
-			RTE_ETH_FOREACH_DEV(pid)
-				printf(", %d", pid);
-			printf("]\n");
+			print_valid_ports();
 			return -1;
 		}
 		socket_id = (uint8_t)int_fld[FLD_SOCKET];
@@ -461,7 +457,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
@@ -488,10 +483,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");
-			RTE_ETH_FOREACH_DEV(pid)
-				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 92e16073f..3d3f7972a 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -726,6 +726,7 @@ enum print_warning {
 	DISABLED_WARN
 };
 int port_id_is_invalid(portid_t port_id, enum print_warning warning);
+void print_valid_ports(void);
 int new_socket_id(unsigned int socket_id);
 
 queueid_t get_allowed_max_nb_rxq(portid_t *pid);
-- 
2.11.0



More information about the stable mailing list