Skip to contentSkip to conversation

dump device info

PATCH In review Min Hu (Connor) 2 participants 12 messages Feb 11, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover dump device info

This patch set contains introduce dump API and a set of patches for hns3 dump implementation.

Min Hu (Connor) (9):
ethdev: introduce dump API
net/hns3: dump device basic info
net/hns3: dump device feature capability
net/hns3: dump device MAC info
net/hns3: dump queue info
net/hns3: dump VLAN configuration info
net/hns3: dump flow director basic info
net/hns3: dump TM configuration info
net/hns3: dump flow control info

 doc/guides/rel_notes/release_22_03.rst |   7 +
 drivers/net/hns3/hns3_ethdev.c         |   3 +-
 drivers/net/hns3/hns3_ethdev.h         |   3 +
 drivers/net/hns3/hns3_ethdev_dump.c    | 917 +++++++++++++++++++++++++
 drivers/net/hns3/hns3_ethdev_vf.c      |   1 +
 drivers/net/hns3/meson.build           |   1 +
 lib/ethdev/ethdev_driver.h             |  22 +
 lib/ethdev/rte_ethdev.c                |  17 +
 lib/ethdev/rte_ethdev.h                |  20 +
 lib/ethdev/version.map                 |   1 +
 10 files changed, 991 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/hns3/hns3_ethdev_dump.c
Signature · 1 line
2.33.0
#1 lore raw

PATCH v4 1/9 ethdev: introduce dump API

Added the ethdev dump API which provides querying private info from device. There exists many private properties in different PMD drivers, such as adapter state, Rx/Tx func algorithm in hns3 PMD. The information of these properties is important for debug. As the information is private, the new API is introduced.

---
v4:
* fix comments for API.
v3:
* change 'ethdev' to 'device'
v2:
* fixed comments from Ferruh.

---
 doc/guides/rel_notes/release_22_03.rst |  7 +++++++
 lib/ethdev/ethdev_driver.h             | 22 ++++++++++++++++++++++
 lib/ethdev/rte_ethdev.c                | 17 +++++++++++++++++
 lib/ethdev/rte_ethdev.h                | 20 ++++++++++++++++++++
 lib/ethdev/version.map                 |  1 +
 5 files changed, 67 insertions(+)
doc/guides/rel_notes/release_22_03.rst +7 -0
index 0f1d3adaf2..10ac807e1c 100644
@@ -80,6 +80,13 @@ New Features
   New APIs, ``rte_eth_dev_priority_flow_ctrl_queue_info_get()`` and
   ``rte_eth_dev_priority_flow_ctrl_queue_configure()``, was added.
 
+* **Added the private dump API, for query private info from device.**
+
+  Added the private dump API which provides querying private info from device.
+  There exists many private properties in different PMD drivers. The
+  information of these properties is important for debug. As the information
+  is private, the new API is introduced.
+
 * **Updated AF_XDP PMD**
 
   * Added support for libxdp >=v1.2.2.
lib/ethdev/ethdev_driver.h +22 -0
index 76a3975c1b..617b450d57 100644
@@ -1045,6 +1045,25 @@ typedef int (*eth_ip_reassembly_conf_get_t)(struct rte_eth_dev *dev,
 typedef int (*eth_ip_reassembly_conf_set_t)(struct rte_eth_dev *dev,
 		const struct rte_eth_ip_reassembly_params *conf);
 
+/**
+ * @internal
+ * Dump private info from device to a file.
+ *
+ * @param dev
+ *   Port (ethdev) handle.
+ * @param file
+ *   A pointer to a file for output.
+ *
+ * @return
+ *   Negative value on error, 0 on success.
+ *
+ * @retval 0
+ *   Success
+ * @retval -EINVAL
+ *   Invalid file
+ */
+typedef int (*eth_dev_priv_dump_t)(struct rte_eth_dev *dev, FILE *file);
+
 /**
  * @internal A structure containing the functions exported by an Ethernet driver.
  */
@@ -1252,6 +1271,9 @@ struct eth_dev_ops {
 	eth_ip_reassembly_conf_get_t ip_reassembly_conf_get;
 	/** Set IP reassembly configuration */
 	eth_ip_reassembly_conf_set_t ip_reassembly_conf_set;
+
+	/** Dump private info from device */
+	eth_dev_priv_dump_t eth_dev_priv_dump;
 };
 
 /**
lib/ethdev/rte_ethdev.c +17 -0
index c95b3cd3db..2a479bea21 100644
@@ -6750,6 +6750,23 @@ rte_eth_ip_reassembly_dynfield_register(int *field_offset, int *flag_offset)
 	return 0;
 }
 
+int
+rte_eth_dev_priv_dump(uint16_t port_id, FILE *file)
+{
+	struct rte_eth_dev *dev;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	dev = &rte_eth_devices[port_id];
+
+	if (file == NULL) {
+		RTE_ETHDEV_LOG(ERR, "Invalid file (NULL)\n");
+		return -EINVAL;
+	}
+
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->eth_dev_priv_dump, -ENOTSUP);
+	return eth_err(port_id, (*dev->dev_ops->eth_dev_priv_dump)(dev, file));
+}
+
 RTE_LOG_REGISTER_DEFAULT(rte_eth_dev_logtype, INFO);
 
 RTE_INIT(ethdev_init_telemetry)
lib/ethdev/rte_ethdev.h +20 -0
index f554e716bc..3439b04119 100644
@@ -5432,6 +5432,26 @@ typedef struct {
 	uint16_t nb_frags;
 } rte_eth_ip_reassembly_dynfield_t;
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Dump private info from device to a file. Provided data and the order depends
+ * on the PMD.
+ *
+ * @param port_id
+ *   The port identifier of the Ethernet device.
+ * @param file
+ *   A pointer to a file for output.
+ * @return
+ *   - (0) on success.
+ *   - (-ENODEV) if *port_id* is invalid.
+ *   - (-EINVAL) if null file.
+ *   - (-ENOTSUP) if the device does not support this function.
+ *   - (-EIO) if device is removed.
+ */
+__rte_experimental
+int rte_eth_dev_priv_dump(uint16_t port_id, FILE *file);
 
 #include <rte_ethdev_core.h>
 
lib/ethdev/version.map +1 -0
index 1ca7ec33ee..fb82c8bf53 100644
@@ -263,6 +263,7 @@ EXPERIMENTAL {
 	rte_eth_ip_reassembly_capability_get;
 	rte_eth_ip_reassembly_conf_get;
 	rte_eth_ip_reassembly_conf_set;
+	rte_eth_dev_priv_dump;
 };
 
 INTERNAL {
Signature · 1 line
2.33.0
Applied
#2 lore raw

Re: [PATCH v4 1/9] ethdev: introduce dump API

Quoted 11 lines · Min Hu (Connor)

Added the ethdev dump API which provides querying private info from device. There exists many private properties in different PMD drivers, such as adapter state, Rx/Tx func algorithm in hns3 PMD. The information of these properties is important for debug. As the information is private, the new API is introduced.

Applied to dpdk-next-net/main, thanks.

#3 lore raw

PATCH 2/9 net/hns3: dump device basic info

In reply to Min Hu (Connor)

This patch dumps device basic info such as device name, adapter state for debug.

---
 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
drivers/net/hns3/hns3_ethdev.c +1 -0
index 2641b6f79b..bb1ea95ed4 100644
@@ -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 = {
drivers/net/hns3/hns3_ethdev.h +1 -0
index ef028a7b2c..551392ca6d 100644
@@ -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)
drivers/net/hns3/hns3_ethdev_dump.c new file +99 -0

99 lines not on this page · raw message

drivers/net/hns3/hns3_ethdev_vf.c +1 -0
index dab1130dad..06ddf64184 100644
@@ -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 = {
drivers/net/hns3/meson.build +1 -0
index 8a4c7cc100..665b2afedf 100644
@@ -30,6 +30,7 @@ sources = files(
         'hns3_tm.c',
         'hns3_ptp.c',
         'hns3_common.c',
+	'hns3_ethdev_dump.c',
 )
 
 deps += ['hash']
Signature · 1 line
2.33.0
#4 lore raw

PATCH 3/9 net/hns3: dump device feature capability

In reply to Min Hu (Connor)

Kunpeng 920 and Kunpeng 930 support different feature capability. This patch dumps feature capability Current device supports.

---
 drivers/net/hns3/hns3_ethdev_dump.c | 30 +++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
drivers/net/hns3/hns3_ethdev_dump.c +30 -0
index 094648cf47..80e7e0f996 100644
@@ -54,6 +54,32 @@ get_io_func_hint_name(uint32_t hint)
 	}
 }
 
+static void
+get_dev_feature_capability(FILE *file, struct hns3_hw *hw)
+{
+	const char * const caps_name[] = {
+		"DCB",
+		"COPPER",
+		"FD QUEUE REGION",
+		"PTP",
+		"TX PUSH",
+		"INDEP TXRX",
+		"STASH",
+		"SIMPLE BD",
+		"RXD Advanced Layout",
+		"OUTER UDP CKSUM",
+		"RAS IMP",
+		"TM",
+		"VF VLAN FILTER MOD",
+	};
+	uint32_t i;
+
+	fprintf(file, "  - Dev Capability:\n");
+	for (i = 0; i < RTE_DIM(caps_name); i++)
+		fprintf(file, "\t  -- support %s: %s\n", caps_name[i],
+			hw->capability & BIT(i) ? "yes" : "no");
+}
+
 static void
 get_device_basic_info(FILE *file, struct rte_eth_dev *dev)
 {
@@ -93,7 +119,11 @@ get_device_basic_info(FILE *file, struct rte_eth_dev *dev)
 int
 hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file)
 {
+	struct hns3_adapter *hns = dev->data->dev_private;
+	struct hns3_hw *hw = &hns->hw;
+
 	get_device_basic_info(file, dev);
+	get_dev_feature_capability(file, hw);
 
 	return 0;
 }
Signature · 1 line
2.33.0
#5 lore raw

PATCH 4/9 net/hns3: dump device MAC info

In reply to Min Hu (Connor)

This patch dumps device MAC info which hns3 PMD private info offers.

---
 drivers/net/hns3/hns3_ethdev_dump.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
drivers/net/hns3/hns3_ethdev_dump.c +28 -0
index 80e7e0f996..6ceeb5a349 100644
@@ -54,6 +54,28 @@ get_io_func_hint_name(uint32_t hint)
 	}
 }
 
+static void
+get_dev_mac_info(FILE *file, struct hns3_adapter *hns)
+{
+	struct hns3_hw *hw = &hns->hw;
+	struct hns3_pf *pf = &hns->pf;
+
+	fprintf(file, "  - MAC Info:\n");
+	fprintf(file,
+		"\t  -- query_type=%u\n"
+		"\t  -- supported_speed=0x%x\n"
+		"\t  -- advertising=0x%x\n"
+		"\t  -- lp_advertising=0x%x\n"
+		"\t  -- support_autoneg=%s\n"
+		"\t  -- support_fc_autoneg=%s\n",
+		hw->mac.query_type,
+		hw->mac.supported_speed,
+		hw->mac.advertising,
+		hw->mac.lp_advertising,
+		hw->mac.support_autoneg != 0 ? "Yes" : "No",
+		pf->support_fc_autoneg ? "Yes" : "No");
+}
+
 static void
 get_dev_feature_capability(FILE *file, struct hns3_hw *hw)
 {
@@ -125,5 +147,11 @@ hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file)
 	get_device_basic_info(file, dev);
 	get_dev_feature_capability(file, hw);
 
+	/* VF only supports dumping basic info and feaure capability */
+	if (hns->is_vf)
+		return 0;
+
+	get_dev_mac_info(file, hns);
+
 	return 0;
 }
Signature · 1 line
2.33.0
#6 lore raw

PATCH 5/9 net/hns3: dump queue info

In reply to Min Hu (Connor)

This patch dumps Rx/Tx queue info, such as queue numbers, queue enable state for debug.

---
 drivers/net/hns3/hns3_ethdev_dump.c | 224 ++++++++++++++++++++++++++++
 1 file changed, 224 insertions(+)
drivers/net/hns3/hns3_ethdev_dump.c +224 -0
index 6ceeb5a349..f9647e6007 100644
@@ -138,6 +138,229 @@ get_device_basic_info(FILE *file, struct rte_eth_dev *dev)
 		dev->data->dev_conf.intr_conf.rxq);
 }
 
+/*
+ * Note: caller must make sure queue_id < nb_queues
+ *       nb_queues = RTE_MAX(eth_dev->data->nb_rx_queues,
+ *                           eth_dev->data->nb_tx_queues)
+ */
+static struct hns3_rx_queue *
+get_rx_queue(struct rte_eth_dev *dev, unsigned int queue_id)
+{
+	struct hns3_adapter *hns = dev->data->dev_private;
+	struct hns3_hw *hw = &hns->hw;
+	unsigned int offset;
+	void **rx_queues;
+
+	if (queue_id < dev->data->nb_rx_queues) {
+		rx_queues = dev->data->rx_queues;
+		offset = queue_id;
+	} else {
+		/*
+		 * For kunpeng930, fake queue is not exist. But since the queues
+		 * are usually accessd in pairs, this branch may still exist.
+		 */
+		if (hns3_dev_get_support(hw, INDEP_TXRX))
+			return NULL;
+
+		rx_queues = hw->fkq_data.rx_queues;
+		offset = queue_id - dev->data->nb_rx_queues;
+	}
+
+	if (rx_queues != NULL && rx_queues[offset] != NULL)
+		return rx_queues[offset];
+
+	hns3_err(hw, "Detect rx_queues is NULL!\n");
+	return NULL;
+}
+
+/*
+ * Note: caller must make sure queue_id < nb_queues
+ *       nb_queues = RTE_MAX(eth_dev->data->nb_rx_queues,
+ *                           eth_dev->data->nb_tx_queues)
+ */
+static struct hns3_tx_queue *
+get_tx_queue(struct rte_eth_dev *dev, unsigned int queue_id)
+{
+	struct hns3_adapter *hns = dev->data->dev_private;
+	struct hns3_hw *hw = &hns->hw;
+	unsigned int offset;
+	void **tx_queues;
+
+	if (queue_id < dev->data->nb_tx_queues) {
+		tx_queues = dev->data->tx_queues;
+		offset = queue_id;
+	} else {
+		/*
+		 * For kunpeng930, fake queue is not exist. But since the queues
+		 * are usually accessd in pairs, this branch may still exist.
+		 */
+		if (hns3_dev_get_support(hw, INDEP_TXRX))
+			return NULL;
+		tx_queues = hw->fkq_data.tx_queues;
+		offset = queue_id - dev->data->nb_tx_queues;
+	}
+
+	if (tx_queues != NULL && tx_queues[offset] != NULL)
+		return tx_queues[offset];
+
+	hns3_err(hw, "Detect tx_queues is NULL!\n");
+	return NULL;
+}
+
+static void
+get_rxtx_fake_queue_info(FILE *file, struct rte_eth_dev *dev)
+{
+	struct hns3_adapter *hns = dev->data->dev_private;
+	struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(hns);
+	struct hns3_rx_queue *rxq;
+	struct hns3_tx_queue *txq;
+	unsigned int queue_id;
+
+	if (dev->data->nb_rx_queues != dev->data->nb_tx_queues &&
+	    !hns3_dev_get_support(hw, INDEP_TXRX)) {
+		queue_id = RTE_MIN(dev->data->nb_rx_queues,
+				   dev->data->nb_tx_queues);
+		rxq = get_rx_queue(dev, queue_id);
+		if (rxq == NULL)
+			return;
+		txq = get_tx_queue(dev, queue_id);
+		if (txq == NULL)
+			return;
+		fprintf(file,
+			"\t  -- first fake_queue rxtx info:\n"
+			"\t       rx: port=%u nb_desc=%u free_thresh=%u\n"
+			"\t       tx: port=%u nb_desc=%u\n",
+			rxq->port_id, rxq->nb_rx_desc, rxq->rx_free_thresh,
+			txq->port_id, txq->nb_tx_desc);
+	}
+}
+
+static void
+get_queue_enable_state(struct hns3_hw *hw, uint32_t *queue_state,
+			uint32_t nb_queues, bool is_rxq)
+{
+#define STATE_SIZE (sizeof(*queue_state) * CHAR_BIT)
+	uint32_t queue_en_reg;
+	uint32_t reg_offset;
+	uint32_t state;
+	uint32_t i;
+
+	queue_en_reg = is_rxq ? HNS3_RING_RX_EN_REG : HNS3_RING_TX_EN_REG;
+	for (i = 0; i < nb_queues; i++) {
+		reg_offset = hns3_get_tqp_reg_offset(i);
+		state = hns3_read_dev(hw, reg_offset + HNS3_RING_EN_REG);
+		if (hns3_dev_get_support(hw, INDEP_TXRX))
+			state = state && hns3_read_dev(hw, reg_offset +
+						       queue_en_reg);
+		hns3_set_bit(queue_state[i / STATE_SIZE],
+				i % STATE_SIZE, state);
+	}
+}
+
+static void
+print_queue_state_perline(FILE *file, const uint32_t *queue_state,
+			  uint32_t nb_queues, uint32_t line_num)
+{
+#define NUM_QUEUE_PER_LINE (sizeof(*queue_state) * CHAR_BIT)
+	uint32_t qid = line_num * NUM_QUEUE_PER_LINE;
+	uint32_t j;
+
+	for (j = 0; j < NUM_QUEUE_PER_LINE; j++) {
+		fprintf(file, "%1lx", hns3_get_bit(queue_state[line_num], j));
+
+		if (qid % CHAR_BIT == CHAR_BIT - 1) {
+			fprintf(file, "%s",
+				j == NUM_QUEUE_PER_LINE - 1 ? "\n" : ":");
+		}
+		qid++;
+		if (qid >= nb_queues) {
+			fprintf(file, "\n");
+			break;
+		}
+	}
+}
+
+static void
+display_queue_enable_state(FILE *file, const uint32_t *queue_state,
+			   uint32_t nb_queues, bool is_rxq)
+{
+#define NUM_QUEUE_PER_LINE (sizeof(*queue_state) * CHAR_BIT)
+	uint32_t i;
+
+	if (nb_queues == 0) {
+		fprintf(file, "\t       %s queue number is 0\n",
+				is_rxq ? "Rx" : "Tx");
+		return;
+	}
+
+	fprintf(file, "\t       %s queue id | enable state bitMap\n",
+			is_rxq ? "rx" : "tx");
+
+	for (i = 0; i < (nb_queues - 1) / NUM_QUEUE_PER_LINE + 1; i++) {
+		uint32_t line_end = (i + 1) * NUM_QUEUE_PER_LINE - 1;
+		uint32_t line_start = i * NUM_QUEUE_PER_LINE;
+		fprintf(file, "\t       %04u - %04u | ", line_start,
+			nb_queues - 1 > line_end ? line_end : nb_queues - 1);
+
+
+		print_queue_state_perline(file, queue_state, nb_queues, i);
+	}
+}
+
+static void
+get_rxtx_queue_enable_state(FILE *file, struct rte_eth_dev *dev)
+{
+#define MAX_TQP_NUM 1280
+#define QUEUE_BITMAP_SIZE (MAX_TQP_NUM / 32)
+	struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	uint32_t rx_queue_state[QUEUE_BITMAP_SIZE] = {0};
+	uint32_t tx_queue_state[QUEUE_BITMAP_SIZE] = {0};
+	uint32_t nb_rx_queues;
+	uint32_t nb_tx_queues;
+
+	nb_rx_queues = dev->data->nb_rx_queues;
+	nb_tx_queues = dev->data->nb_tx_queues;
+
+	fprintf(file, "\t  -- enable state:\n");
+	get_queue_enable_state(hw, rx_queue_state, nb_rx_queues, true);
+	display_queue_enable_state(file, rx_queue_state, nb_rx_queues,
+					 true);
+
+	get_queue_enable_state(hw, tx_queue_state, nb_tx_queues, false);
+	display_queue_enable_state(file, tx_queue_state, nb_tx_queues,
+					 false);
+}
+
+static void
+get_rxtx_queue_info(FILE *file, struct rte_eth_dev *dev)
+{
+	struct hns3_rx_queue *rxq;
+	struct hns3_tx_queue *txq;
+	unsigned int queue_id = 0;
+
+	rxq = get_rx_queue(dev, queue_id);
+	if (rxq == NULL)
+		return;
+	txq = get_tx_queue(dev, queue_id);
+	if (txq == NULL)
+		return;
+	fprintf(file, "  - Rx/Tx Queue Info:\n");
+	fprintf(file,
+		"\t  -- nb_rx_queues=%u nb_tx_queues=%u, "
+		"first queue rxtx info:\n"
+		"\t       rx: port=%u nb_desc=%u free_thresh=%u\n"
+		"\t       tx: port=%u nb_desc=%u\n"
+		"\t  -- tx push: %s\n",
+		dev->data->nb_rx_queues,
+		dev->data->nb_tx_queues,
+		rxq->port_id, rxq->nb_rx_desc, rxq->rx_free_thresh,
+		txq->port_id, txq->nb_tx_desc,
+		txq->tx_push_enable ? "enabled" : "disabled");
+
+	get_rxtx_fake_queue_info(file, dev);
+	get_rxtx_queue_enable_state(file, dev);
+}
+
 int
 hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file)
 {
@@ -152,6 +375,7 @@ hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file)
 		return 0;
 
 	get_dev_mac_info(file, hns);
+	get_rxtx_queue_info(file, dev);
 
 	return 0;
 }
Signature · 1 line
2.33.0
#7 lore raw

PATCH 6/9 net/hns3: dump VLAN configuration info

In reply to Min Hu (Connor)

This patch dump VLAN filter, strip related info and Pvid info for debug.

---
 drivers/net/hns3/hns3_ethdev_dump.c | 196 ++++++++++++++++++++++++++++
 1 file changed, 196 insertions(+)
drivers/net/hns3/hns3_ethdev_dump.c +196 -0
index f9647e6007..a08f8418a2 100644
@@ -361,6 +361,201 @@ get_rxtx_queue_info(FILE *file, struct rte_eth_dev *dev)
 	get_rxtx_queue_enable_state(file, dev);
 }
 
+static int
+get_vlan_filter_cfg(FILE *file, struct hns3_hw *hw)
+{
+#define HNS3_FILTER_TYPE_VF		0
+#define HNS3_FILTER_TYPE_PORT		1
+#define HNS3_FILTER_FE_NIC_INGRESS_B	BIT(0)
+#define HNS3_FILTER_FE_NIC_EGRESS_B	BIT(1)
+	struct hns3_vlan_filter_ctrl_cmd *req;
+	struct hns3_cmd_desc desc;
+	uint8_t i;
+	int ret;
+
+	static const uint32_t vlan_filter_type[] = {
+		HNS3_FILTER_TYPE_PORT,
+		HNS3_FILTER_TYPE_VF
+	};
+
+	for (i = 0; i < RTE_DIM(vlan_filter_type); i++) {
+		hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_VLAN_FILTER_CTRL,
+						true);
+		req = (struct hns3_vlan_filter_ctrl_cmd *)desc.data;
+		req->vlan_type = vlan_filter_type[i];
+		req->vf_id = HNS3_PF_FUNC_ID;
+		ret = hns3_cmd_send(hw, &desc, 1);
+		if (ret != 0) {
+			hns3_err(hw,
+				"NIC IMP exec ret=%d desc_num=%d optcode=0x%x!",
+				ret, 1, rte_le_to_cpu_16(desc.opcode));
+			return ret;
+		}
+		fprintf(file,
+			"\t  -- %s VLAN filter configuration\n"
+			"\t       nic_ingress           :%s\n"
+			"\t       nic_egress            :%s\n",
+			req->vlan_type == HNS3_FILTER_TYPE_PORT ?
+			"Port" : "VF",
+			req->vlan_fe & HNS3_FILTER_FE_NIC_INGRESS_B ?
+			"Enable" : "Disable",
+			req->vlan_fe & HNS3_FILTER_FE_NIC_EGRESS_B ?
+			"Enable" : "Disable");
+	}
+
+	return 0;
+}
+
+static int
+get_vlan_rx_offload_cfg(FILE *file, struct hns3_hw *hw)
+{
+	struct hns3_vport_vtag_rx_cfg_cmd *req;
+	struct hns3_cmd_desc desc;
+	uint16_t vport_id;
+	uint8_t bitmap;
+	int ret;
+
+	hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_VLAN_PORT_RX_CFG, true);
+	req = (struct hns3_vport_vtag_rx_cfg_cmd *)desc.data;
+	vport_id = HNS3_PF_FUNC_ID;
+	req->vf_offset = vport_id / HNS3_VF_NUM_PER_CMD;
+	bitmap = 1 << (vport_id % HNS3_VF_NUM_PER_BYTE);
+	req->vf_bitmap[req->vf_offset] = bitmap;
+
+	/*
+	 * current version VF is not supported when PF is driven by DPDK driver,
+	 * just need to configure rx parameters for PF vport.
+	 */
+	ret = hns3_cmd_send(hw, &desc, 1);
+	if (ret != 0) {
+		hns3_err(hw,
+			"NIC IMP exec ret=%d desc_num=%d optcode=0x%x!",
+			ret, 1, rte_le_to_cpu_16(desc.opcode));
+		return ret;
+	}
+
+	fprintf(file,
+		"\t  -- RX VLAN configuration\n"
+		"\t       vlan1_strip_en        :%s\n"
+		"\t       vlan2_strip_en        :%s\n"
+		"\t       vlan1_vlan_prionly    :%s\n"
+		"\t       vlan2_vlan_prionly    :%s\n"
+		"\t       vlan1_strip_discard   :%s\n"
+		"\t       vlan2_strip_discard   :%s\n",
+		hns3_get_bit(req->vport_vlan_cfg,
+			HNS3_REM_TAG1_EN_B) ? "Enable" : "Disable",
+		hns3_get_bit(req->vport_vlan_cfg,
+			HNS3_REM_TAG2_EN_B) ? "Enable" : "Disable",
+		hns3_get_bit(req->vport_vlan_cfg,
+			HNS3_SHOW_TAG1_EN_B) ? "Enable" : "Disable",
+		hns3_get_bit(req->vport_vlan_cfg,
+			HNS3_SHOW_TAG2_EN_B) ? "Enable" : "Disable",
+		hns3_get_bit(req->vport_vlan_cfg,
+			HNS3_DISCARD_TAG1_EN_B) ? "Enable" : "Disable",
+		hns3_get_bit(req->vport_vlan_cfg,
+			HNS3_DISCARD_TAG2_EN_B) ? "Enable" : "Disable");
+
+	return 0;
+}
+
+static void
+parse_tx_vlan_cfg(FILE *file, struct hns3_vport_vtag_tx_cfg_cmd *req)
+{
+#define VLAN_VID_MASK 0x0fff
+#define VLAN_PRIO_SHIFT 13
+
+	fprintf(file,
+		"\t  -- TX VLAN configuration\n"
+		"\t       accept_tag1           :%s\n"
+		"\t       accept_untag1         :%s\n"
+		"\t       insert_tag1_en        :%s\n"
+		"\t       default_vlan_tag1 = %d, qos = %d\n"
+		"\t       accept_tag2           :%s\n"
+		"\t       accept_untag2         :%s\n"
+		"\t       insert_tag2_en        :%s\n"
+		"\t       default_vlan_tag2 = %d, qos = %d\n"
+		"\t       vlan_shift_mode       :%s\n",
+		hns3_get_bit(req->vport_vlan_cfg,
+			HNS3_ACCEPT_TAG1_B) ? "Enable" : "Disable",
+		hns3_get_bit(req->vport_vlan_cfg,
+			HNS3_ACCEPT_UNTAG1_B) ? "Enable" : "Disable",
+		hns3_get_bit(req->vport_vlan_cfg,
+			HNS3_PORT_INS_TAG1_EN_B) ? "Enable" : "Disable",
+		req->def_vlan_tag1 & VLAN_VID_MASK,
+		req->def_vlan_tag1 >> VLAN_PRIO_SHIFT,
+		hns3_get_bit(req->vport_vlan_cfg,
+			HNS3_ACCEPT_TAG2_B) ? "Enable" : "Disable",
+		hns3_get_bit(req->vport_vlan_cfg,
+			HNS3_ACCEPT_UNTAG2_B) ? "Enable" : "Disable",
+		hns3_get_bit(req->vport_vlan_cfg,
+			HNS3_PORT_INS_TAG2_EN_B) ? "Enable" : "Disable",
+		req->def_vlan_tag2 & VLAN_VID_MASK,
+		req->def_vlan_tag2 >> VLAN_PRIO_SHIFT,
+		hns3_get_bit(req->vport_vlan_cfg,
+			HNS3_TAG_SHIFT_MODE_EN_B) ? "Enable" :
+			"Disable");
+}
+
+static int
+get_vlan_tx_offload_cfg(FILE *file, struct hns3_hw *hw)
+{
+	struct hns3_vport_vtag_tx_cfg_cmd *req;
+	struct hns3_cmd_desc desc;
+	uint16_t vport_id;
+	uint8_t bitmap;
+	int ret;
+
+	hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_VLAN_PORT_TX_CFG, true);
+	req = (struct hns3_vport_vtag_tx_cfg_cmd *)desc.data;
+	vport_id = HNS3_PF_FUNC_ID;
+	req->vf_offset = vport_id / HNS3_VF_NUM_PER_CMD;
+	bitmap = 1 << (vport_id % HNS3_VF_NUM_PER_BYTE);
+	req->vf_bitmap[req->vf_offset] = bitmap;
+	/*
+	 * current version VF is not supported when PF is driven by DPDK driver,
+	 * just need to configure tx parameters for PF vport.
+	 */
+	ret = hns3_cmd_send(hw, &desc, 1);
+	if (ret != 0) {
+		hns3_err(hw,
+			"NIC IMP exec ret=%d desc_num=%d optcode=0x%x!",
+			ret, 1, rte_le_to_cpu_16(desc.opcode));
+		return ret;
+	}
+
+	parse_tx_vlan_cfg(file, req);
+
+	return 0;
+}
+
+static void
+get_port_pvid_info(FILE *file, struct hns3_hw *hw)
+{
+	fprintf(file, "\t  -- pvid status: %s\n",
+		hw->port_base_vlan_cfg.state ? "on" : "off");
+}
+
+static void
+get_vlan_config_info(FILE *file, struct hns3_hw *hw)
+{
+	int ret;
+
+	fprintf(file, "  - VLAN Config Info:\n");
+	ret = get_vlan_filter_cfg(file, hw);
+	if (ret < 0)
+		return;
+
+	ret = get_vlan_rx_offload_cfg(file, hw);
+	if (ret < 0)
+		return;
+
+	ret = get_vlan_tx_offload_cfg(file, hw);
+	if (ret < 0)
+		return;
+
+	get_port_pvid_info(file, hw);
+}
+
 int
 hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file)
 {
@@ -376,6 +571,7 @@ hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file)
 
 	get_dev_mac_info(file, hns);
 	get_rxtx_queue_info(file, dev);
+	get_vlan_config_info(file, hw);
 
 	return 0;
 }
Signature · 1 line
2.33.0
#8 lore raw

PATCH 7/9 net/hns3: dump flow director basic info

In reply to Min Hu (Connor)

This patch dumps flow director basic info such rule numbers, hit counts for debug.

---
 drivers/net/hns3/hns3_ethdev_dump.c | 84 +++++++++++++++++++++++++++++
 1 file changed, 84 insertions(+)
drivers/net/hns3/hns3_ethdev_dump.c +84 -0
index a08f8418a2..3fb4959885 100644
@@ -102,6 +102,89 @@ get_dev_feature_capability(FILE *file, struct hns3_hw *hw)
 			hw->capability & BIT(i) ? "yes" : "no");
 }
 
+static const char *
+get_fdir_tuple_name(uint32_t index)
+{
+	static const char * const tuple_name[] = {
+		"outer_dst_mac",
+		"outer_src_mac",
+		"outer_vlan_1st_tag",
+		"outer_vlan_2nd_tag",
+		"outer_eth_type",
+		"outer_l2_rsv",
+		"outer_ip_tos",
+		"outer_ip_proto",
+		"outer_src_ip",
+		"outer_dst_ip",
+		"outer_l3_rsv",
+		"outer_src_port",
+		"outer_dst_port",
+		"outer_l4_rsv",
+		"outer_tun_vni",
+		"outer_tun_flow_id",
+		"inner_dst_mac",
+		"inner_src_mac",
+		"inner_vlan_tag1",
+		"inner_vlan_tag2",
+		"inner_eth_type",
+		"inner_l2_rsv",
+		"inner_ip_tos",
+		"inner_ip_proto",
+		"inner_src_ip",
+		"inner_dst_ip",
+		"inner_l3_rsv",
+		"inner_src_port",
+		"inner_dst_port",
+		"inner_sctp_tag",
+	};
+	if (index < RTE_DIM(tuple_name))
+		return tuple_name[index];
+	else
+		return "unknown";
+}
+
+static void
+get_fdir_basic_info(FILE *file, struct hns3_pf *pf)
+{
+#define TMPBUF_SIZE		2048
+#define PERLINE_TUPLE_NAMES	4
+	struct hns3_fd_cfg *fdcfg = &pf->fdir.fd_cfg;
+	char tmpbuf[TMPBUF_SIZE] = {0};
+	uint32_t i, count = 0;
+
+	fprintf(file, "  - Fdir Info:\n");
+	fprintf(file,
+		"\t  -- mode=%u max_key_len=%u rule_num:%u cnt_num:%u\n"
+		"\t  -- key_sel=%u tuple_active=0x%x meta_data_active=0x%x\n"
+		"\t  -- ipv6_word_en: in_s=%u in_d=%u out_s=%u out_d=%u\n"
+		"\t  -- active_tuples:\n",
+		fdcfg->fd_mode, fdcfg->max_key_length,
+		fdcfg->rule_num[HNS3_FD_STAGE_1],
+		fdcfg->cnt_num[HNS3_FD_STAGE_1],
+		fdcfg->key_cfg[HNS3_FD_STAGE_1].key_sel,
+		fdcfg->key_cfg[HNS3_FD_STAGE_1].tuple_active,
+		fdcfg->key_cfg[HNS3_FD_STAGE_1].meta_data_active,
+		fdcfg->key_cfg[HNS3_FD_STAGE_1].inner_sipv6_word_en,
+		fdcfg->key_cfg[HNS3_FD_STAGE_1].inner_dipv6_word_en,
+		fdcfg->key_cfg[HNS3_FD_STAGE_1].outer_sipv6_word_en,
+		fdcfg->key_cfg[HNS3_FD_STAGE_1].outer_dipv6_word_en);
+
+	for (i = 0; i < MAX_TUPLE; i++) {
+		if (!(fdcfg->key_cfg[HNS3_FD_STAGE_1].tuple_active & BIT(i)))
+			continue;
+		if (count % PERLINE_TUPLE_NAMES == 0)
+			fprintf(file, "\t      ");
+		fprintf(file, " %s", get_fdir_tuple_name(i));
+		count++;
+		if (count % PERLINE_TUPLE_NAMES == 0)
+			fprintf(file, "\n");
+	}
+	if (count % PERLINE_TUPLE_NAMES)
+		fprintf(file, "\n");
+
+	fprintf(file, "%s", tmpbuf);
+}
+
 static void
 get_device_basic_info(FILE *file, struct rte_eth_dev *dev)
 {
@@ -572,6 +655,7 @@ hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file)
 	get_dev_mac_info(file, hns);
 	get_rxtx_queue_info(file, dev);
 	get_vlan_config_info(file, hw);
+	get_fdir_basic_info(file, &hns->pf);
 
 	return 0;
 }
Signature · 1 line
2.33.0
#9 lore raw

PATCH 8/9 net/hns3: dump TM configuration info

In reply to Min Hu (Connor)

This patch dumps TM configuration info about shaper, port node, TC node, queue node related info.

---
 drivers/net/hns3/hns3_ethdev_dump.c | 153 ++++++++++++++++++++++++++++
 1 file changed, 153 insertions(+)
drivers/net/hns3/hns3_ethdev_dump.c +153 -0
index 3fb4959885..675c7efed4 100644
@@ -639,6 +639,158 @@ get_vlan_config_info(FILE *file, struct hns3_hw *hw)
 	get_port_pvid_info(file, hw);
 }
 
+static void
+get_tm_conf_shaper_info(FILE *file, struct hns3_tm_conf *conf)
+{
+	struct hns3_shaper_profile_list *shaper_profile_list =
+		&conf->shaper_profile_list;
+	struct hns3_tm_shaper_profile *shaper_profile;
+
+	if (!conf->nb_shaper_profile)
+		return;
+
+	fprintf(file, "  shaper_profile:\n");
+	TAILQ_FOREACH(shaper_profile, shaper_profile_list, node) {
+		fprintf(file,
+			"    id=%u reference_count=%u peak_rate=%" PRIu64 "Bps\n",
+			shaper_profile->shaper_profile_id,
+			shaper_profile->reference_count,
+			shaper_profile->profile.peak.rate);
+	}
+}
+
+static void
+get_tm_conf_port_node_info(FILE *file, struct hns3_tm_conf *conf)
+{
+	if (!conf->root)
+		return;
+
+	fprintf(file,
+		"  port_node: \n"
+		"    node_id=%u reference_count=%u shaper_profile_id=%d\n",
+		conf->root->id, conf->root->reference_count,
+		conf->root->shaper_profile ?
+		(int)conf->root->shaper_profile->shaper_profile_id : -1);
+}
+
+static void
+get_tm_conf_tc_node_info(FILE *file, struct hns3_tm_conf *conf)
+{
+	struct hns3_tm_node_list *tc_list = &conf->tc_list;
+	struct hns3_tm_node *tc_node[HNS3_MAX_TC_NUM];
+	struct hns3_tm_node *tm_node;
+	uint32_t tidx;
+
+	if (!conf->nb_tc_node)
+		return;
+
+	fprintf(file, "  tc_node: \n");
+	memset(tc_node, 0, sizeof(tc_node));
+	TAILQ_FOREACH(tm_node, tc_list, node) {
+		tidx = hns3_tm_calc_node_tc_no(conf, tm_node->id);
+		if (tidx < HNS3_MAX_TC_NUM)
+			tc_node[tidx] = tm_node;
+	}
+
+	for (tidx = 0; tidx < HNS3_MAX_TC_NUM; tidx++) {
+		tm_node = tc_node[tidx];
+		if (tm_node == NULL)
+			continue;
+		fprintf(file,
+			"    id=%u TC%u reference_count=%u parent_id=%d "
+			"shaper_profile_id=%d\n",
+			tm_node->id, hns3_tm_calc_node_tc_no(conf, tm_node->id),
+			tm_node->reference_count,
+			tm_node->parent ? (int)tm_node->parent->id : -1,
+			tm_node->shaper_profile ?
+			(int)tm_node->shaper_profile->shaper_profile_id : -1);
+	}
+}
+
+static void
+get_tm_conf_queue_format_info(FILE *file, struct hns3_tm_node **queue_node,
+			      uint32_t *queue_node_tc,  uint32_t nb_tx_queues)
+{
+#define PERLINE_QUEUES	32
+#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++) {
+		start_queue = i * PERLINE_QUEUES;
+		end_queue = (i + 1) * PERLINE_QUEUES - 1;
+		if (end_queue > nb_tx_queues - 1)
+			end_queue = nb_tx_queues - 1;
+		fprintf(file, "    %04u - %04u | ", start_queue, end_queue);
+		for (j = start_queue; j < nb_tx_queues; j++) {
+			if (j >= end_queue + 1)
+				break;
+			if (j > start_queue && j % PERLINE_STRIDE == 0)
+				fprintf(file, ":");
+			fprintf(file, "%u",
+				queue_node[j] ? queue_node_tc[j] :
+				HNS3_MAX_TC_NUM);
+		}
+		fprintf(file, "%s\n", tmpbuf);
+	}
+}
+
+static void
+get_tm_conf_queue_node_info(FILE *file, struct hns3_tm_conf *conf,
+			    uint32_t nb_tx_queues)
+{
+	struct hns3_tm_node_list *queue_list = &conf->queue_list;
+	uint32_t nb_queue_node = conf->nb_leaf_nodes_max + 1;
+	struct hns3_tm_node *queue_node[nb_queue_node];
+	uint32_t queue_node_tc[nb_queue_node];
+	struct hns3_tm_node *tm_node;
+
+	if (!conf->nb_queue_node)
+		return;
+
+	fprintf(file,
+		"  queue_node: \n"
+		"    tx queue id | mapped tc (8 mean node not exist)\n");
+
+	memset(queue_node, 0, sizeof(queue_node));
+	memset(queue_node_tc, 0, sizeof(queue_node_tc));
+	nb_tx_queues = RTE_MIN(nb_tx_queues, nb_queue_node);
+	TAILQ_FOREACH(tm_node, queue_list, node) {
+		if (tm_node->id >= nb_queue_node)
+			continue;
+		queue_node[tm_node->id] = tm_node;
+		queue_node_tc[tm_node->id] = tm_node->parent ?
+			hns3_tm_calc_node_tc_no(conf, tm_node->parent->id) : 0;
+		nb_tx_queues = RTE_MAX(nb_tx_queues, tm_node->id + 1);
+	}
+
+	get_tm_conf_queue_format_info(file, queue_node, queue_node_tc,
+				      nb_tx_queues);
+}
+
+static void
+get_tm_conf_info(FILE *file, struct rte_eth_dev *dev)
+{
+	struct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(dev->data->dev_private);
+	struct hns3_tm_conf *conf = &pf->tm_conf;
+
+	fprintf(file, "  - TM config info:\n");
+	fprintf(file,
+		"\t  -- nb_leaf_nodes_max=%u nb_nodes_max=%u\n"
+		"\t  -- nb_shaper_profile=%u nb_tc_node=%u nb_queue_node=%u\n"
+		"\t  -- committed=%u\n",
+		conf->nb_leaf_nodes_max, conf->nb_nodes_max,
+		conf->nb_shaper_profile, conf->nb_tc_node, conf->nb_queue_node,
+		conf->committed);
+
+	get_tm_conf_shaper_info(file, conf);
+	get_tm_conf_port_node_info(file, conf);
+	get_tm_conf_tc_node_info(file, conf);
+	get_tm_conf_queue_node_info(file, conf, dev->data->nb_tx_queues);
+}
+
 int
 hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file)
 {
@@ -656,6 +808,7 @@ hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file)
 	get_rxtx_queue_info(file, dev);
 	get_vlan_config_info(file, hw);
 	get_fdir_basic_info(file, &hns->pf);
+	get_tm_conf_info(file, dev);
 
 	return 0;
 }
Signature · 1 line
2.33.0
#10 lore raw

PATCH 9/9 net/hns3: dump flow control info

In reply to Min Hu (Connor)

This patch dumps flow control info such as flow control mode for debug.

---
 drivers/net/hns3/hns3_ethdev.c      |   2 +-
 drivers/net/hns3/hns3_ethdev.h      |   2 +
 drivers/net/hns3/hns3_ethdev_dump.c | 103 ++++++++++++++++++++++++++++
 3 files changed, 106 insertions(+), 1 deletion(-)
drivers/net/hns3/hns3_ethdev.c +1 -1
index bb1ea95ed4..4e089e682f 100644
@@ -5350,7 +5350,7 @@ hns3_get_current_fc_mode(struct rte_eth_dev *dev)
 	return hns3_get_autoneg_fc_mode(hw);
 }
 
-static int
+int
 hns3_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
 {
 	struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
drivers/net/hns3/hns3_ethdev.h +2 -0
index 551392ca6d..9a0fa09b57 100644
@@ -1030,6 +1030,8 @@ hns3_test_and_clear_bit(unsigned int nr, volatile uint64_t *addr)
 	return __atomic_fetch_and(addr, ~mask, __ATOMIC_RELAXED) & mask;
 }
 
+int
+hns3_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf);
 uint32_t hns3_get_speed_capa(struct hns3_hw *hw);
 
 int hns3_buffer_alloc(struct hns3_hw *hw);
drivers/net/hns3/hns3_ethdev_dump.c +103 -0

115 lines not on this page · raw message

Signature · 1 line
2.33.0
#11 lore raw
In reply to Min Hu (Connor)
Quoted 14 lines · Min Hu (Connor)

This patch set contains introduce dump API and a set of patches for hns3 dump implementation.

Min Hu (Connor) (9):
ethdev: introduce dump API
net/hns3: dump device basic info
net/hns3: dump device feature capability
net/hns3: dump device MAC info
net/hns3: dump queue info
net/hns3: dump VLAN configuration info
net/hns3: dump flow director basic info
net/hns3: dump TM configuration info
net/hns3: dump flow control info

Series applied to dpdk-next-net/main, thanks.