net/hns3: dump device basic info
[dpdk.git] / drivers / net / hns3 / hns3_ethdev_dump.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(C) 2022 HiSilicon Limited
3  */
4
5 #include <rte_kvargs.h>
6 #include <rte_bus_pci.h>
7 #include <ethdev_pci.h>
8 #include <rte_pci.h>
9
10 #include "hns3_common.h"
11 #include "hns3_logs.h"
12 #include "hns3_regs.h"
13 #include "hns3_rxtx.h"
14
15 static const char *
16 get_adapter_state_name(uint32_t state)
17 {
18         static const char * const state_name[] = {
19                 "UNINITIALIZED",
20                 "INITIALIZED",
21                 "CONFIGURING",
22                 "CONFIGURED",
23                 "STARTING",
24                 "STARTED",
25                 "STOPPING",
26                 "CLOSING",
27                 "CLOSED",
28                 "REMOVED",
29                 "NSTATES"
30         };
31
32         if (state < RTE_DIM(state_name))
33                 return state_name[state];
34         else
35                 return "unknown";
36 }
37
38 static const char *
39 get_io_func_hint_name(uint32_t hint)
40 {
41         switch (hint) {
42         case HNS3_IO_FUNC_HINT_NONE:
43                 return "none";
44         case HNS3_IO_FUNC_HINT_VEC:
45                 return "vec";
46         case HNS3_IO_FUNC_HINT_SVE:
47                 return "sve";
48         case HNS3_IO_FUNC_HINT_SIMPLE:
49                 return "simple";
50         case HNS3_IO_FUNC_HINT_COMMON:
51                 return "common";
52         default:
53                 return "unknown";
54         }
55 }
56
57 static void
58 get_device_basic_info(FILE *file, struct rte_eth_dev *dev)
59 {
60         struct hns3_adapter *hns = dev->data->dev_private;
61         struct hns3_hw *hw = &hns->hw;
62
63         fprintf(file,
64                 "  - Device Base Info:\n"
65                 "\t  -- name: %s\n"
66                 "\t  -- adapter_state=%s\n"
67                 "\t  -- nb_rx_queues=%u nb_tx_queues=%u\n"
68                 "\t  -- total_tqps_num=%u tqps_num=%u intr_tqps_num=%u\n"
69                 "\t  -- rss_size_max=%u alloc_rss_size=%u tx_qnum_per_tc=%u\n"
70                 "\t  -- min_tx_pkt_len=%u intr_mapping_mode=%u vlan_mode=%u\n"
71                 "\t  -- tso_mode=%u max_non_tso_bd_num=%u\n"
72                 "\t  -- max_tm_rate=%u Mbps\n"
73                 "\t  -- set link down: %s\n"
74                 "\t  -- rx_func_hint=%s tx_func_hint=%s\n"
75                 "\t  -- dev_flags: lsc=%d\n"
76                 "\t  -- intr_conf: lsc=%u rxq=%u\n",
77                 dev->data->name,
78                 get_adapter_state_name(hw->adapter_state),
79                 dev->data->nb_rx_queues, dev->data->nb_tx_queues,
80                 hw->total_tqps_num, hw->tqps_num, hw->intr_tqps_num,
81                 hw->rss_size_max, hw->alloc_rss_size, hw->tx_qnum_per_tc,
82                 hw->min_tx_pkt_len, hw->intr.mapping_mode, hw->vlan_mode,
83                 hw->tso_mode, hw->max_non_tso_bd_num,
84                 hw->max_tm_rate,
85                 hw->set_link_down ? "Yes" : "No",
86                 get_io_func_hint_name(hns->rx_func_hint),
87                 get_io_func_hint_name(hns->tx_func_hint),
88                 !!(dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC),
89                 dev->data->dev_conf.intr_conf.lsc,
90                 dev->data->dev_conf.intr_conf.rxq);
91 }
92
93 int
94 hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file)
95 {
96         get_device_basic_info(file, dev);
97
98         return 0;
99 }