DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Min Hu (Connor)" <humin29@huawei.com>
To: <dev@dpdk.org>
Cc: "Min Hu (Connor)" <humin29@huawei.com>,
	Yisen Zhuang <yisen.zhuang@huawei.com>,
	Lijun Ou <oulijun@huawei.com>
Subject: [PATCH 2/9] net/hns3: dump device basic info
Date: Fri, 11 Feb 2022 12:49:23 +0800	[thread overview]
Message-ID: <20220211044930.2449-3-humin29@huawei.com> (raw)
In-Reply-To: <20220211044930.2449-1-humin29@huawei.com>

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      |  1 +
 drivers/net/hns3/hns3_ethdev.h      |  1 +
 drivers/net/hns3/hns3_ethdev_dump.c | 99 +++++++++++++++++++++++++++++
 drivers/net/hns3/hns3_ethdev_vf.c   |  1 +
 drivers/net/hns3/meson.build        |  1 +
 5 files changed, 103 insertions(+)
 create mode 100644 drivers/net/hns3/hns3_ethdev_dump.c

diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index 2641b6f79b..bb1ea95ed4 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -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 = {
diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h
index ef028a7b2c..551392ca6d 100644
--- a/drivers/net/hns3/hns3_ethdev.h
+++ b/drivers/net/hns3/hns3_ethdev.h
@@ -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
index 0000000000..094648cf47
--- /dev/null
+++ b/drivers/net/hns3/hns3_ethdev_dump.c
@@ -0,0 +1,99 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 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;
+}
diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c
index dab1130dad..06ddf64184 100644
--- a/drivers/net/hns3/hns3_ethdev_vf.c
+++ b/drivers/net/hns3/hns3_ethdev_vf.c
@@ -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 = {
diff --git a/drivers/net/hns3/meson.build b/drivers/net/hns3/meson.build
index 8a4c7cc100..665b2afedf 100644
--- a/drivers/net/hns3/meson.build
+++ b/drivers/net/hns3/meson.build
@@ -30,6 +30,7 @@ sources = files(
         'hns3_tm.c',
         'hns3_ptp.c',
         'hns3_common.c',
+	'hns3_ethdev_dump.c',
 )
 
 deps += ['hash']
-- 
2.33.0


  parent reply	other threads:[~2022-02-11  4:49 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-11  4:49 [PATCH 0/9] dump device info Min Hu (Connor)
2022-02-11  4:49 ` [PATCH v4 1/9] ethdev: introduce dump API Min Hu (Connor)
2022-02-11 10:41   ` Ferruh Yigit
2022-02-11  4:49 ` Min Hu (Connor) [this message]
2022-02-11  4:49 ` [PATCH 3/9] net/hns3: dump device feature capability Min Hu (Connor)
2022-02-11  4:49 ` [PATCH 4/9] net/hns3: dump device MAC info Min Hu (Connor)
2022-02-11  4:49 ` [PATCH 5/9] net/hns3: dump queue info Min Hu (Connor)
2022-02-11  4:49 ` [PATCH 6/9] net/hns3: dump VLAN configuration info Min Hu (Connor)
2022-02-11  4:49 ` [PATCH 7/9] net/hns3: dump flow director basic info Min Hu (Connor)
2022-02-11  4:49 ` [PATCH 8/9] net/hns3: dump TM configuration info Min Hu (Connor)
2022-02-11  4:49 ` [PATCH 9/9] net/hns3: dump flow control info Min Hu (Connor)
2022-02-11 18:04 ` [PATCH 0/9] dump device info Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220211044930.2449-3-humin29@huawei.com \
    --to=humin29@huawei.com \
    --cc=dev@dpdk.org \
    --cc=oulijun@huawei.com \
    --cc=yisen.zhuang@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).