net/hns3: fix TM info dump
authorMin Hu (Connor) <humin29@huawei.com>
Thu, 14 Apr 2022 13:00:55 +0000 (21:00 +0800)
committerFerruh Yigit <ferruh.yigit@xilinx.com>
Thu, 5 May 2022 12:57:10 +0000 (14:57 +0200)
Shouldn't dump TM info when TM is not supported by the NIC.
This patch fixed it.

Fixes: e4cfe6bb9114 ("net/hns3: dump TM configuration info")
Cc: stable@dpdk.org
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
drivers/net/hns3/hns3_ethdev_dump.c

index 9934e4e..1548d23 100644 (file)
@@ -709,7 +709,6 @@ get_tm_conf_queue_format_info(FILE *file, struct hns3_tm_node **queue_node,
 #define PERLINE_STRIDE 8
 #define LINE_BUF_SIZE  1024
        uint32_t i, j, line_num, start_queue, end_queue;
-       char tmpbuf[LINE_BUF_SIZE] = {0};
 
        line_num = (nb_tx_queues + PERLINE_QUEUES - 1) / PERLINE_QUEUES;
        for (i = 0; i < line_num; i++) {
@@ -727,7 +726,7 @@ get_tm_conf_queue_format_info(FILE *file, struct hns3_tm_node **queue_node,
                                queue_node[j] ? queue_node_tc[j] :
                                HNS3_MAX_TC_NUM);
                }
-               fprintf(file, "%s\n", tmpbuf);
+               fprintf(file, "\n");
        }
 }
 
@@ -767,9 +766,13 @@ get_tm_conf_queue_node_info(FILE *file, struct hns3_tm_conf *conf,
 static void
 get_tm_conf_info(FILE *file, struct rte_eth_dev *dev)
 {
+       struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
        struct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(dev->data->dev_private);
        struct hns3_tm_conf *conf = &pf->tm_conf;
 
+       if (!hns3_dev_get_support(hw, TM))
+               return;
+
        fprintf(file, "  - TM config info:\n");
        fprintf(file,
                "\t  -- nb_leaf_nodes_max=%u nb_nodes_max=%u\n"