From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by dpdk.org (Postfix) with ESMTP id 4EFC48DA5 for ; Sun, 20 May 2018 15:08:51 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id F240820B4F; Sun, 20 May 2018 09:08:50 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Sun, 20 May 2018 09:08:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fridaylinux.org; h=cc:date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=nsecOFqJSVRrZxvEA 7H77wBJtOHSVeTMGu+IHJCxBo0=; b=DpoJSHRdUOJ2Iphlpt/XHV6qiosCtyTSa KwFFcOTaWRGEdGYsWerrZ2IfVddzkb89TJY5NZMWEHz1zCF7TE1t91NXscNLvJr4 Cv4zDJDT611aE5RedvZROLXkE5cH7ZmBRM5C1MxwsJAdDWgkEaBHxYHnS81CKBH+ 2pMzsel+uZuyR8WWSULZT/laI2rqCOlyYsgtSgf5nxhV494hTe8YEI5Ge0C4Y2Jv KP1U21k3NDoVxQn1BwlmZdc15pSFQrEhW7oGAcNZ1jFtQFGG35W0v/X3iKXI/8Dt lxmJAwDQh8iF+5PiNLm1ZuQMOC4wwH5enyoecwLMkCVi5nW82EB6Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=nsecOFqJSVRrZxvEA7H77wBJtOHSVeTMGu+IHJCxBo0=; b=J+vtFXUp dw3nyroygYJ8cmXhwdA+/7+XRgrhZFvaD5VYjtmfd/zUXLlI3XEgpG88Q7kZTK25 NevJSW+7zDO7DvSCCWXxQTZbwEQYdTHNZ72hwfL+AS7iRgueKwzB4RRfI0zSo0Rm f/P3BBd/QM1+E+lyF6k9+Y3wikMUxNpfJumE1WEXXf1tE+XGnz6eBwZdkJwzsgDB fQxr2HJ5Qezhk+MXG06ABOsssXQTol42hh/eeU+NpowfKXw+Mxfac7CPfasP3siR EAxlnEfH0lN40wt9aJa+HJw7VdBX+W2b3EUX6Mp80+RSjteG7kNl8gnOXpfhnyZ4 DFyuvNIqF4hByA== X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Sender: Received: from yuanhanliu-NB0.tencent.com (unknown [223.74.148.80]) by mail.messagingengine.com (Postfix) with ESMTPA id 795801025C; Sun, 20 May 2018 09:08:49 -0400 (EDT) From: Yuanhan Liu To: Matan Azrad Cc: dpdk stable Date: Sun, 20 May 2018 21:02:26 +0800 Message-Id: <20180520130246.16287-10-yliu@fridaylinux.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180520130246.16287-1-yliu@fridaylinux.org> References: <20180520130246.16287-1-yliu@fridaylinux.org> Subject: [dpdk-stable] patch 'app/testpmd: fix valid ports prints' has been queued to LTS release 17.11.3 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 May 2018 13:08:51 -0000 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 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 --- 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