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) <humi...@huawei.com>
---
 app/test-pmd/config.c | 47 ++++++-----------------------------------------
 1 file changed, 6 insertions(+), 41 deletions(-)

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");
        }
-- 
2.7.4

Reply via email to