net/hns3: dump device basic info
authorMin Hu (Connor) <humin29@huawei.com>
Fri, 11 Feb 2022 04:49:23 +0000 (12:49 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 11 Feb 2022 17:49:03 +0000 (18:49 +0100)
This patch dumps device basic info such as device name, adapter state
for debug.

Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
drivers/net/hns3/hns3_ethdev.c
drivers/net/hns3/hns3_ethdev.h
drivers/net/hns3/hns3_ethdev_dump.c [new file with mode: 0644]
drivers/net/hns3/hns3_ethdev_vf.c
drivers/net/hns3/meson.build

index 2641b6f..bb1ea95 100644 (file)
@@ -6568,6 +6568,7 @@ static const struct eth_dev_ops hns3_eth_dev_ops = {
        .timesync_adjust_time       = hns3_timesync_adjust_time,
        .timesync_read_time         = hns3_timesync_read_time,
        .timesync_write_time        = hns3_timesync_write_time,
+       .eth_dev_priv_dump          = hns3_eth_dev_priv_dump,
 };
 
 static const struct hns3_reset_ops hns3_reset_ops = {
index ef028a7..551392c 100644 (file)
@@ -1055,6 +1055,7 @@ int hns3_timesync_read_time(struct rte_eth_dev *dev, struct timespec *ts);
 int hns3_timesync_write_time(struct rte_eth_dev *dev,
                        const struct timespec *ts);
 int hns3_timesync_adjust_time(struct rte_eth_dev *dev, int64_t delta);
+int hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file);
 
 static inline bool
 is_reset_pending(struct hns3_adapter *hns)
diff --git a/drivers/net/hns3/hns3_ethdev_dump.c b/drivers/net/hns3/hns3_ethdev_dump.c
new file mode 100644 (file)
index 0000000..b4e3017
--- /dev/null
@@ -0,0 +1,99 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2022 HiSilicon Limited
+ */
+
+#include <rte_kvargs.h>
+#include <rte_bus_pci.h>
+#include <ethdev_pci.h>
+#include <rte_pci.h>
+
+#include "hns3_common.h"
+#include "hns3_logs.h"
+#include "hns3_regs.h"
+#include "hns3_rxtx.h"
+
+static const char *
+get_adapter_state_name(uint32_t state)
+{
+       static const char * const state_name[] = {
+               "UNINITIALIZED",
+               "INITIALIZED",
+               "CONFIGURING",
+               "CONFIGURED",
+               "STARTING",
+               "STARTED",
+               "STOPPING",
+               "CLOSING",
+               "CLOSED",
+               "REMOVED",
+               "NSTATES"
+       };
+
+       if (state < RTE_DIM(state_name))
+               return state_name[state];
+       else
+               return "unknown";
+}
+
+static const char *
+get_io_func_hint_name(uint32_t hint)
+{
+       switch (hint) {
+       case HNS3_IO_FUNC_HINT_NONE:
+               return "none";
+       case HNS3_IO_FUNC_HINT_VEC:
+               return "vec";
+       case HNS3_IO_FUNC_HINT_SVE:
+               return "sve";
+       case HNS3_IO_FUNC_HINT_SIMPLE:
+               return "simple";
+       case HNS3_IO_FUNC_HINT_COMMON:
+               return "common";
+       default:
+               return "unknown";
+       }
+}
+
+static void
+get_device_basic_info(FILE *file, struct rte_eth_dev *dev)
+{
+       struct hns3_adapter *hns = dev->data->dev_private;
+       struct hns3_hw *hw = &hns->hw;
+
+       fprintf(file,
+               "  - Device Base Info:\n"
+               "\t  -- name: %s\n"
+               "\t  -- adapter_state=%s\n"
+               "\t  -- nb_rx_queues=%u nb_tx_queues=%u\n"
+               "\t  -- total_tqps_num=%u tqps_num=%u intr_tqps_num=%u\n"
+               "\t  -- rss_size_max=%u alloc_rss_size=%u tx_qnum_per_tc=%u\n"
+               "\t  -- min_tx_pkt_len=%u intr_mapping_mode=%u vlan_mode=%u\n"
+               "\t  -- tso_mode=%u max_non_tso_bd_num=%u\n"
+               "\t  -- max_tm_rate=%u Mbps\n"
+               "\t  -- set link down: %s\n"
+               "\t  -- rx_func_hint=%s tx_func_hint=%s\n"
+               "\t  -- dev_flags: lsc=%d\n"
+               "\t  -- intr_conf: lsc=%u rxq=%u\n",
+               dev->data->name,
+               get_adapter_state_name(hw->adapter_state),
+               dev->data->nb_rx_queues, dev->data->nb_tx_queues,
+               hw->total_tqps_num, hw->tqps_num, hw->intr_tqps_num,
+               hw->rss_size_max, hw->alloc_rss_size, hw->tx_qnum_per_tc,
+               hw->min_tx_pkt_len, hw->intr.mapping_mode, hw->vlan_mode,
+               hw->tso_mode, hw->max_non_tso_bd_num,
+               hw->max_tm_rate,
+               hw->set_link_down ? "Yes" : "No",
+               get_io_func_hint_name(hns->rx_func_hint),
+               get_io_func_hint_name(hns->tx_func_hint),
+               !!(dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC),
+               dev->data->dev_conf.intr_conf.lsc,
+               dev->data->dev_conf.intr_conf.rxq);
+}
+
+int
+hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file)
+{
+       get_device_basic_info(file, dev);
+
+       return 0;
+}
index dab1130..06ddf64 100644 (file)
@@ -2290,6 +2290,7 @@ static const struct eth_dev_ops hns3vf_eth_dev_ops = {
        .get_reg            = hns3_get_regs,
        .dev_supported_ptypes_get = hns3_dev_supported_ptypes_get,
        .tx_done_cleanup    = hns3_tx_done_cleanup,
+       .eth_dev_priv_dump  = hns3_eth_dev_priv_dump,
 };
 
 static const struct hns3_reset_ops hns3vf_reset_ops = {
index 8a4c7cc..f2aede9 100644 (file)
@@ -30,6 +30,7 @@ sources = files(
         'hns3_tm.c',
         'hns3_ptp.c',
         'hns3_common.c',
+        'hns3_ethdev_dump.c',
 )
 
 deps += ['hash']