app/testpmd: fix transmission from speed to str

Message ID 1602215119-64740-1-git-send-email-humin29@huawei.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series app/testpmd: fix transmission from speed to str |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK

Commit Message

humin (Q) Oct. 9, 2020, 3:45 a.m. UTC
  This patch uses a new 'rte_eth_link_speed_to_str()' API in the
ethdev which enables removing above global 'eth_speed_name' array [1].

Fixes: 466c55e4d85b ("app/testpmd: add FEC command")

Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
 app/test-pmd/config.c | 47 ++++++-----------------------------------------
 1 file changed, 6 insertions(+), 41 deletions(-)
  

Comments

Ferruh Yigit Oct. 9, 2020, 11:05 a.m. UTC | #1
On 10/9/2020 4:45 AM, Min Hu (Connor) wrote:
> This patch uses a new 'rte_eth_link_speed_to_str()' API in the
> ethdev which enables removing above global 'eth_speed_name' array [1].
> 
> Fixes: 466c55e4d85b ("app/testpmd: add FEC command")
> 
> Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
>

Squashed into relevant commit in next-net, thanks.
  

Patch

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 7873426..8ccd989 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -161,36 +161,6 @@  static const struct {
 	},
 };
 
-static const struct {
-	uint32_t speed;
-	const char *name;
-} eth_speed_name[] = {
-	{
-		.speed = ETH_SPEED_NUM_10G,
-		.name = "Speed 10G",
-	},
-	{
-		.speed = ETH_SPEED_NUM_25G,
-		.name = "Speed 25G",
-	},
-	{
-		.speed = ETH_SPEED_NUM_40G,
-		.name = "Speed 40G",
-	},
-	{
-		.speed = ETH_SPEED_NUM_50G,
-		.name = "Speed 50G",
-	},
-	{
-		.speed = ETH_SPEED_NUM_100G,
-		.name = "Speed 100G",
-	},
-	{
-		.speed = ETH_SPEED_NUM_200G,
-		.name = "Speed 200G",
-	},
-};
-
 static void
 print_ethaddr(const char *name, struct rte_ether_addr *eth_addr)
 {
@@ -3260,23 +3230,18 @@  parse_fec_mode(const char *name, uint32_t *mode)
 void
 show_fec_capability(unsigned int num, struct rte_eth_fec_capa *speed_fec_capa)
 {
-	unsigned int i, j, k;
+	unsigned int i, j;
 
 	printf("FEC capabilities:\n");
 
 	for (i = 0; i < num; i++) {
-		for (j = 0; j < RTE_DIM(eth_speed_name); j++) {
-			if (eth_speed_name[j].speed ==
-						speed_fec_capa[i].speed) {
-				printf("%s : ", eth_speed_name[j].name);
-				break;
-			}
-		}
+		printf("%s : ",
+			rte_eth_link_speed_to_str(speed_fec_capa[i].speed));
 
-		for (k = RTE_ETH_FEC_AUTO; k < RTE_DIM(fec_mode_name); k++) {
-			if (RTE_ETH_FEC_MODE_TO_CAPA(k) &
+		for (j = RTE_ETH_FEC_AUTO; j < RTE_DIM(fec_mode_name); j++) {
+			if (RTE_ETH_FEC_MODE_TO_CAPA(j) &
 						speed_fec_capa[i].capa)
-				printf("%s ", fec_mode_name[k].name);
+				printf("%s ", fec_mode_name[j].name);
 		}
 		printf("\n");
 	}