Skip to contentSkip to conversation

support HW Rx/Tx descriptor dump

PATCH Superseded Min Hu (Connor) 7 participants 52 messages May 27, 2022 – Oct 8, 2022

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

cover support HW Rx/Tx descriptor dump

This patch set support HW Rx/Tx descriptor dump by using procinfo tool.

Min Hu (Connor) (4):
ethdev: introduce ethdev HW desc dump PI
net/hns3: rename hns3 dump files
net/hns3: support Rx/Tx bd dump
app/procinfo: support descriptor dump

 app/proc-info/main.c                          | 81 +++++++++++++++++++
 doc/guides/rel_notes/release_22_07.rst        |  6 ++
 .../hns3/{hns3_ethdev_dump.c => hns3_dump.c}  | 66 ++++++++++++++-
 drivers/net/hns3/hns3_dump.h                  | 17 ++++
 drivers/net/hns3/hns3_ethdev.c                |  3 +
 drivers/net/hns3/hns3_ethdev.h                |  1 -
 drivers/net/hns3/hns3_ethdev_vf.c             |  3 +
 drivers/net/hns3/meson.build                  |  2 +-
 lib/ethdev/ethdev_driver.h                    | 42 ++++++++++
 lib/ethdev/rte_ethdev.c                       | 44 ++++++++++
 lib/ethdev/rte_ethdev.h                       | 44 ++++++++++
 lib/ethdev/version.map                        |  2 +
 12 files changed, 308 insertions(+), 3 deletions(-)
 rename drivers/net/hns3/{hns3_ethdev_dump.c => hns3_dump.c} (93%)
 create mode 100644 drivers/net/hns3/hns3_dump.h
Signature · 1 line
2.33.0
#1 lore raw

PATCH 1/4 ethdev: introduce ethdev HW desc dump PI

Added the ethdev HW Rx desc dump API which provides functions for query HW descriptor from device. HW descriptor info differs in different NICs. The information demonstrates I/O process which is important for debug. As the information is different between NICs, the new API is introduced.

---
 doc/guides/rel_notes/release_22_07.rst |  6 ++++
 lib/ethdev/ethdev_driver.h             | 42 ++++++++++++++++++++++++
 lib/ethdev/rte_ethdev.c                | 44 ++++++++++++++++++++++++++
 lib/ethdev/rte_ethdev.h                | 44 ++++++++++++++++++++++++++
 lib/ethdev/version.map                 |  2 ++
 5 files changed, 138 insertions(+)
doc/guides/rel_notes/release_22_07.rst +6 -0
index 0ed4f92820..cfb9117dd3 100644
@@ -95,6 +95,12 @@ New Features
   * Added AH mode support in lookaside protocol (IPsec) for CN9K & CN10K.
   * Added AES-GMAC support in lookaside protocol (IPsec) for CN9K & CN10K.
 
+* **Added ethdev HW desc dump API, to dump Rx/Tx HW desc info from device.**
+
+  Added the ethdev HW Rx desc dump API which provides functions for query
+  HW descriptor from device. HW descriptor info differs in different NICs.
+  The information demonstrates I/O process which is important for debug.
+  As the information is different between NICs, the new API is introduced.
 
 Removed Items
 -------------
lib/ethdev/ethdev_driver.h +42 -0

54 lines not on this page · raw message

lib/ethdev/rte_ethdev.c +44 -0

50 lines not on this page · raw message

lib/ethdev/rte_ethdev.h +44 -0

50 lines not on this page · raw message

lib/ethdev/version.map +2 -0
index daca7851f2..109f4ea818 100644
@@ -285,6 +285,8 @@ EXPERIMENTAL {
 	rte_mtr_color_in_protocol_priority_get;
 	rte_mtr_color_in_protocol_set;
 	rte_mtr_meter_vlan_table_update;
+	rte_eth_rx_hw_desc_dump;
+	rte_eth_tx_hw_desc_dump;
 };
 
 INTERNAL {
Signature · 1 line
2.33.0
#2 lore raw

Re: [PATCH 1/4] ethdev: introduce ethdev HW desc dump PI

Quoted 64 lines · On Fri, 27 May 2022 10:33:48 +0800 "Min Hu (Connor)" <[email protected]> wrote:

Added the ethdev HW Rx desc dump API which provides functions for query HW descriptor from device. HW descriptor info differs in different NICs. The information demonstrates I/O process which is important for debug. As the information is different between NICs, the new API is introduced.

---
 doc/guides/rel_notes/release_22_07.rst |  6 ++++
 lib/ethdev/ethdev_driver.h             | 42 ++++++++++++++++++++++++
 lib/ethdev/rte_ethdev.c                | 44 ++++++++++++++++++++++++++
 lib/ethdev/rte_ethdev.h                | 44 ++++++++++++++++++++++++++
 lib/ethdev/version.map                 |  2 ++
 5 files changed, 138 insertions(+)
doc/guides/rel_notes/release_22_07.rst +6 -0
index 0ed4f92820..cfb9117dd3 100644
@@ -95,6 +95,12 @@ New Features
   * Added AH mode support in lookaside protocol (IPsec) for CN9K & CN10K.
   * Added AES-GMAC support in lookaside protocol (IPsec) for CN9K & CN10K.
 
+* **Added ethdev HW desc dump API, to dump Rx/Tx HW desc info from device.**
+
+  Added the ethdev HW Rx desc dump API which provides functions for query
+  HW descriptor from device. HW descriptor info differs in different NICs.
+  The information demonstrates I/O process which is important for debug.
+  As the information is different between NICs, the new API is introduced.
 
 Removed Items
 -------------
lib/ethdev/ethdev_driver.h +25 -0
index 69d9dc21d8..89512ab360 100644
@@ -1073,6 +1073,42 @@ typedef int (*eth_ip_reassembly_conf_set_t)(struct rte_eth_dev *dev,
  */
 typedef int (*eth_dev_priv_dump_t)(struct rte_eth_dev *dev, FILE *file);
 
+/**
+ * @internal
+ * Dump ethdev Rx descriptor info to a file.
+ *
+ * @param file
+ *   A pointer to a file for output.
+ * @param dev
+ *   Port (ethdev) handle.
+ * @param queue_id
+ *   The selected queue.
+ * @param desc_id
+ *   The selected descriptor.
+ * @return
+ *   Negative errno value on error, zero on success.
+ */
+typedef int (*eth_rx_hw_desc_dump_t)(FILE *file, struct rte_eth_dev *dev,
+				       uint16_t queue_id, uint16_t desc_id);
+
+/**
+ * @internal
+ * Dump ethdev Tx descriptor info to a file.
+ *
+ * @param file
+ *   A pointer to a file for output.
+ * @param dev

lib/ethdev/ethdev_driver.h typedef int (*eth_ip_reassembly_conf_set_t)(struct rte_eth_dev *dev, · line 1110

Quoted 10 lines
lib/ethdev/ethdev_driver.h +10 -0
+ *   Port (ethdev) handle.
+ * @param queue_id
+ *   The selected queue.
+ * @param desc_id
+ *   The selected descriptor.
+ * @return
+ *   Negative errno value on error, zero on success.
+ */
+typedef int (*eth_tx_hw_desc_dump_t)(FILE *file, struct rte_eth_dev *dev,
+				       uint16_t queue_id, uint16_t desc_id);

Should be 'const struct rte_eth_dev *dev' to remind developers that dump should not modify device?

#3 lore raw

Re: [PATCH 1/4] ethdev: introduce ethdev HW desc dump PI

Thanks Stephen, v2 has been sent.

Quoted 82 lines · Stephen Hemminger
Quoted 64 lines · On Fri, 27 May 2022 10:33:48 +0800 "Min Hu (Connor)" <[email protected]> wrote:

Added the ethdev HW Rx desc dump API which provides functions for query HW descriptor from device. HW descriptor info differs in different NICs. The information demonstrates I/O process which is important for debug. As the information is different between NICs, the new API is introduced.

---
  doc/guides/rel_notes/release_22_07.rst |  6 ++++
  lib/ethdev/ethdev_driver.h             | 42 ++++++++++++++++++++++++
  lib/ethdev/rte_ethdev.c                | 44 ++++++++++++++++++++++++++
  lib/ethdev/rte_ethdev.h                | 44 ++++++++++++++++++++++++++
  lib/ethdev/version.map                 |  2 ++
  5 files changed, 138 insertions(+)
doc/guides/rel_notes/release_22_07.rst +6 -0
index 0ed4f92820..cfb9117dd3 100644
@@ -95,6 +95,12 @@ New Features
    * Added AH mode support in lookaside protocol (IPsec) for CN9K & CN10K.
    * Added AES-GMAC support in lookaside protocol (IPsec) for CN9K & CN10K.
 
+* **Added ethdev HW desc dump API, to dump Rx/Tx HW desc info from device.**
+
+  Added the ethdev HW Rx desc dump API which provides functions for query
+  HW descriptor from device. HW descriptor info differs in different NICs.
+  The information demonstrates I/O process which is important for debug.
+  As the information is different between NICs, the new API is introduced.
 
  Removed Items
  -------------
lib/ethdev/ethdev_driver.h +25 -0
index 69d9dc21d8..89512ab360 100644
@@ -1073,6 +1073,42 @@ typedef int (*eth_ip_reassembly_conf_set_t)(struct rte_eth_dev *dev,
   */
  typedef int (*eth_dev_priv_dump_t)(struct rte_eth_dev *dev, FILE *file);
 
+/**
+ * @internal
+ * Dump ethdev Rx descriptor info to a file.
+ *
+ * @param file
+ *   A pointer to a file for output.
+ * @param dev
+ *   Port (ethdev) handle.
+ * @param queue_id
+ *   The selected queue.
+ * @param desc_id
+ *   The selected descriptor.
+ * @return
+ *   Negative errno value on error, zero on success.
+ */
+typedef int (*eth_rx_hw_desc_dump_t)(FILE *file, struct rte_eth_dev *dev,
+				       uint16_t queue_id, uint16_t desc_id);
+
+/**
+ * @internal
+ * Dump ethdev Tx descriptor info to a file.
+ *
+ * @param file
+ *   A pointer to a file for output.
+ * @param dev

lib/ethdev/ethdev_driver.h typedef int (*eth_ip_reassembly_conf_set_t)(struct rte_eth_dev *dev, · line 1110

Quoted 10 lines
lib/ethdev/ethdev_driver.h +10 -0
+ *   Port (ethdev) handle.
+ * @param queue_id
+ *   The selected queue.
+ * @param desc_id
+ *   The selected descriptor.
+ * @return
+ *   Negative errno value on error, zero on success.
+ */
+typedef int (*eth_tx_hw_desc_dump_t)(FILE *file, struct rte_eth_dev *dev,
+				       uint16_t queue_id, uint16_t desc_id);

Should be 'const struct rte_eth_dev *dev' to remind developers that dump should not modify device?
.

#4 lore raw

Re: [PATCH 1/4] ethdev: introduce ethdev HW desc dump PI

In reply to Min Hu (Connor)
Quoted 206 lines · Min Hu (Connor)

Added the ethdev HW Rx desc dump API which provides functions for query HW descriptor from device. HW descriptor info differs in different NICs. The information demonstrates I/O process which is important for debug. As the information is different between NICs, the new API is introduced.

---
 doc/guides/rel_notes/release_22_07.rst |  6 ++++
 lib/ethdev/ethdev_driver.h             | 42 ++++++++++++++++++++++++
 lib/ethdev/rte_ethdev.c                | 44 ++++++++++++++++++++++++++
 lib/ethdev/rte_ethdev.h                | 44 ++++++++++++++++++++++++++
 lib/ethdev/version.map                 |  2 ++
 5 files changed, 138 insertions(+)
doc/guides/rel_notes/release_22_07.rst +6 -0
index 0ed4f92820..cfb9117dd3 100644
@@ -95,6 +95,12 @@ New Features
   * Added AH mode support in lookaside protocol (IPsec) for CN9K & CN10K.
   * Added AES-GMAC support in lookaside protocol (IPsec) for CN9K & CN10K.
 
+* **Added ethdev HW desc dump API, to dump Rx/Tx HW desc info from device.**
+
+  Added the ethdev HW Rx desc dump API which provides functions for query
+  HW descriptor from device. HW descriptor info differs in different NICs.
+  The information demonstrates I/O process which is important for debug.
+  As the information is different between NICs, the new API is introduced.
 
 Removed Items
 -------------
lib/ethdev/ethdev_driver.h +42 -0
index 69d9dc21d8..89512ab360 100644
@@ -1073,6 +1073,42 @@ typedef int (*eth_ip_reassembly_conf_set_t)(struct rte_eth_dev *dev,
  */
 typedef int (*eth_dev_priv_dump_t)(struct rte_eth_dev *dev, FILE *file);
 
+/**
+ * @internal
+ * Dump ethdev Rx descriptor info to a file.
+ *
+ * @param file
+ *   A pointer to a file for output.
+ * @param dev
+ *   Port (ethdev) handle.
+ * @param queue_id
+ *   The selected queue.
+ * @param desc_id
+ *   The selected descriptor.
+ * @return
+ *   Negative errno value on error, zero on success.
+ */
+typedef int (*eth_rx_hw_desc_dump_t)(FILE *file, struct rte_eth_dev *dev,
+				       uint16_t queue_id, uint16_t desc_id);
+
+/**
+ * @internal
+ * Dump ethdev Tx descriptor info to a file.
+ *
+ * @param file
+ *   A pointer to a file for output.
+ * @param dev
+ *   Port (ethdev) handle.
+ * @param queue_id
+ *   The selected queue.
+ * @param desc_id
+ *   The selected descriptor.
+ * @return
+ *   Negative errno value on error, zero on success.
+ */
+typedef int (*eth_tx_hw_desc_dump_t)(FILE *file, struct rte_eth_dev *dev,
+				       uint16_t queue_id, uint16_t desc_id);
+
 /**
  * @internal A structure containing the functions exported by an Ethernet driver.
  */
@@ -1283,6 +1319,12 @@ struct eth_dev_ops {
 
 	/** Dump private info from device */
 	eth_dev_priv_dump_t eth_dev_priv_dump;
+
+	/** Dump ethdev Rx descriptor info */
+	eth_rx_hw_desc_dump_t eth_rx_hw_desc_dump;
+
+	/** Dump ethdev Tx descriptor info */
+	eth_tx_hw_desc_dump_t eth_tx_hw_desc_dump;
 };
 
 /**
lib/ethdev/rte_ethdev.c +44 -0
index a175867651..09abee6345 100644
@@ -5874,6 +5874,50 @@ rte_eth_dev_priv_dump(uint16_t port_id, FILE *file)
 	return eth_err(port_id, (*dev->dev_ops->eth_dev_priv_dump)(dev, file));
 }
 
+int
+rte_eth_rx_hw_desc_dump(FILE *file, uint16_t port_id, uint16_t queue_id,
+			uint16_t desc_id)
+{
+	struct rte_eth_dev *dev;
+	int ret;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	dev = &rte_eth_devices[port_id];
+
+	if (queue_id >= dev->data->nb_rx_queues) {
+		RTE_ETHDEV_LOG(ERR, "Invalid Rx queue_id=%u\n", queue_id);
+		return -EINVAL;
+	}
+
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->eth_rx_hw_desc_dump, -ENOTSUP);
+	ret = (*dev->dev_ops->eth_rx_hw_desc_dump)(file, dev, queue_id,
+						   desc_id);
+
+	return ret;
+}
+
+int
+rte_eth_tx_hw_desc_dump(FILE *file, uint16_t port_id, uint16_t queue_id,
+			uint16_t desc_id)
+{
+	struct rte_eth_dev *dev;
+	int ret;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	dev = &rte_eth_devices[port_id];
+
+	if (queue_id >= dev->data->nb_tx_queues) {
+		RTE_ETHDEV_LOG(ERR, "Invalid Tx queue_id=%u\n", queue_id);
+		return -EINVAL;
+	}
+
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->eth_tx_hw_desc_dump, -ENOTSUP);
+	ret = (*dev->dev_ops->eth_tx_hw_desc_dump)(file, dev, queue_id,
+						   desc_id);
+
+	return ret;
+}
+
 RTE_LOG_REGISTER_DEFAULT(rte_eth_dev_logtype, INFO);
 
 RTE_INIT(ethdev_init_telemetry)
lib/ethdev/rte_ethdev.h +44 -0
index 02df65d923..56ae630209 100644
@@ -5456,6 +5456,50 @@ typedef struct {
 __rte_experimental
 int rte_eth_dev_priv_dump(uint16_t port_id, FILE *file);
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Dump ethdev Rx descriptor info to a file.
+ *
+ * @param file
+ *   A pointer to a file for output.
+ * @param dev
+ *   Port (ethdev) handle.
+ * @param queue_id
+ *   The selected queue.
+ * @param desc_id
+ *   The selected descriptor.
+ * @return
+ *   - On success, zero.
+ *   - On failure, a negative value.
+ */
+__rte_experimental
+int rte_eth_rx_hw_desc_dump(FILE *file, uint16_t port_id, uint16_t queue_id,
+			    uint16_t desc_id);
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Dump ethdev Tx descriptor info to a file.
+ *
+ * @param file
+ *   A pointer to a file for output.
+ * @param dev
+ *   Port (ethdev) handle.
+ * @param queue_id
+ *   The selected queue.
+ * @param desc_id
+ *   The selected descriptor.
+ * @return
+ *   - On success, zero.
+ *   - On failure, a negative value.
+ */
+__rte_experimental
+int rte_eth_tx_hw_desc_dump(FILE *file, uint16_t port_id, uint16_t queue_id,
+			    uint16_t desc_id);
+
 #include <rte_ethdev_core.h>
 
 /**
lib/ethdev/version.map +0 -0
index daca7851f2..109f4ea818 100644

lib/ethdev/version.map EXPERIMENTAL { · line 287

Quoted 3 lines
lib/ethdev/version.map +0 -0
@@ -285,6 +285,8 @@ EXPERIMENTAL {
 	rte_mtr_color_in_protocol_priority_get;
 	rte_mtr_color_in_protocol_set;
 	rte_mtr_meter_vlan_table_update;

Please annotate with a comment indicating in which release the symbols have been added.

Quoted 5 lines
lib/ethdev/version.map +2 -0
+	rte_eth_rx_hw_desc_dump;
+	rte_eth_tx_hw_desc_dump;
 };
 
 INTERNAL {
Signature · 1 line
Regards, Ray K
#5 lore raw

Re: [PATCH 1/4] ethdev: introduce ethdev HW desc dump PI

Hi, Ray,

Quoted 203 lines · Ray Kinsella
Quoted 200 lines · Min Hu (Connor)

Added the ethdev HW Rx desc dump API which provides functions for query HW descriptor from device. HW descriptor info differs in different NICs. The information demonstrates I/O process which is important for debug. As the information is different between NICs, the new API is introduced.

---
  doc/guides/rel_notes/release_22_07.rst |  6 ++++
  lib/ethdev/ethdev_driver.h             | 42 ++++++++++++++++++++++++
  lib/ethdev/rte_ethdev.c                | 44 ++++++++++++++++++++++++++
  lib/ethdev/rte_ethdev.h                | 44 ++++++++++++++++++++++++++
  lib/ethdev/version.map                 |  2 ++
  5 files changed, 138 insertions(+)
doc/guides/rel_notes/release_22_07.rst +6 -0
index 0ed4f92820..cfb9117dd3 100644
@@ -95,6 +95,12 @@ New Features
    * Added AH mode support in lookaside protocol (IPsec) for CN9K & CN10K.
    * Added AES-GMAC support in lookaside protocol (IPsec) for CN9K & CN10K.
 
+* **Added ethdev HW desc dump API, to dump Rx/Tx HW desc info from device.**
+
+  Added the ethdev HW Rx desc dump API which provides functions for query
+  HW descriptor from device. HW descriptor info differs in different NICs.
+  The information demonstrates I/O process which is important for debug.
+  As the information is different between NICs, the new API is introduced.
 
  Removed Items
  -------------
lib/ethdev/ethdev_driver.h +42 -0
index 69d9dc21d8..89512ab360 100644
@@ -1073,6 +1073,42 @@ typedef int (*eth_ip_reassembly_conf_set_t)(struct rte_eth_dev *dev,
   */
  typedef int (*eth_dev_priv_dump_t)(struct rte_eth_dev *dev, FILE *file);
 
+/**
+ * @internal
+ * Dump ethdev Rx descriptor info to a file.
+ *
+ * @param file
+ *   A pointer to a file for output.
+ * @param dev
+ *   Port (ethdev) handle.
+ * @param queue_id
+ *   The selected queue.
+ * @param desc_id
+ *   The selected descriptor.
+ * @return
+ *   Negative errno value on error, zero on success.
+ */
+typedef int (*eth_rx_hw_desc_dump_t)(FILE *file, struct rte_eth_dev *dev,
+				       uint16_t queue_id, uint16_t desc_id);
+
+/**
+ * @internal
+ * Dump ethdev Tx descriptor info to a file.
+ *
+ * @param file
+ *   A pointer to a file for output.
+ * @param dev
+ *   Port (ethdev) handle.
+ * @param queue_id
+ *   The selected queue.
+ * @param desc_id
+ *   The selected descriptor.
+ * @return
+ *   Negative errno value on error, zero on success.
+ */
+typedef int (*eth_tx_hw_desc_dump_t)(FILE *file, struct rte_eth_dev *dev,
+				       uint16_t queue_id, uint16_t desc_id);
+
  /**
   * @internal A structure containing the functions exported by an Ethernet driver.
   */
@@ -1283,6 +1319,12 @@ struct eth_dev_ops {
 
  	/** Dump private info from device */
  	eth_dev_priv_dump_t eth_dev_priv_dump;
+
+	/** Dump ethdev Rx descriptor info */
+	eth_rx_hw_desc_dump_t eth_rx_hw_desc_dump;
+
+	/** Dump ethdev Tx descriptor info */
+	eth_tx_hw_desc_dump_t eth_tx_hw_desc_dump;
  };
 
  /**
lib/ethdev/rte_ethdev.c +44 -0
index a175867651..09abee6345 100644
@@ -5874,6 +5874,50 @@ rte_eth_dev_priv_dump(uint16_t port_id, FILE *file)
  	return eth_err(port_id, (*dev->dev_ops->eth_dev_priv_dump)(dev, file));
  }
 
+int
+rte_eth_rx_hw_desc_dump(FILE *file, uint16_t port_id, uint16_t queue_id,
+			uint16_t desc_id)
+{
+	struct rte_eth_dev *dev;
+	int ret;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	dev = &rte_eth_devices[port_id];
+
+	if (queue_id >= dev->data->nb_rx_queues) {
+		RTE_ETHDEV_LOG(ERR, "Invalid Rx queue_id=%u\n", queue_id);
+		return -EINVAL;
+	}
+
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->eth_rx_hw_desc_dump, -ENOTSUP);
+	ret = (*dev->dev_ops->eth_rx_hw_desc_dump)(file, dev, queue_id,
+						   desc_id);
+
+	return ret;
+}
+
+int
+rte_eth_tx_hw_desc_dump(FILE *file, uint16_t port_id, uint16_t queue_id,
+			uint16_t desc_id)
+{
+	struct rte_eth_dev *dev;
+	int ret;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	dev = &rte_eth_devices[port_id];
+
+	if (queue_id >= dev->data->nb_tx_queues) {
+		RTE_ETHDEV_LOG(ERR, "Invalid Tx queue_id=%u\n", queue_id);
+		return -EINVAL;
+	}
+
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->eth_tx_hw_desc_dump, -ENOTSUP);
+	ret = (*dev->dev_ops->eth_tx_hw_desc_dump)(file, dev, queue_id,
+						   desc_id);
+
+	return ret;
+}
+
  RTE_LOG_REGISTER_DEFAULT(rte_eth_dev_logtype, INFO);
 
  RTE_INIT(ethdev_init_telemetry)
lib/ethdev/rte_ethdev.h +44 -0
index 02df65d923..56ae630209 100644
@@ -5456,6 +5456,50 @@ typedef struct {
  __rte_experimental
  int rte_eth_dev_priv_dump(uint16_t port_id, FILE *file);
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Dump ethdev Rx descriptor info to a file.
+ *
+ * @param file
+ *   A pointer to a file for output.
+ * @param dev
+ *   Port (ethdev) handle.
+ * @param queue_id
+ *   The selected queue.
+ * @param desc_id
+ *   The selected descriptor.
+ * @return
+ *   - On success, zero.
+ *   - On failure, a negative value.
+ */
+__rte_experimental
+int rte_eth_rx_hw_desc_dump(FILE *file, uint16_t port_id, uint16_t queue_id,
+			    uint16_t desc_id);
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Dump ethdev Tx descriptor info to a file.
+ *
+ * @param file
+ *   A pointer to a file for output.
+ * @param dev
+ *   Port (ethdev) handle.
+ * @param queue_id
+ *   The selected queue.
+ * @param desc_id
+ *   The selected descriptor.
+ * @return
+ *   - On success, zero.
+ *   - On failure, a negative value.
+ */
+__rte_experimental
+int rte_eth_tx_hw_desc_dump(FILE *file, uint16_t port_id, uint16_t queue_id,
+			    uint16_t desc_id);
+
  #include <rte_ethdev_core.h>
 
Quoted 12 lines

lib/ethdev/version.map EXPERIMENTAL { · line 287

Quoted 9 lines
lib/ethdev/rte_ethdev.h +0 -0
  /**
lib/ethdev/version.map +0 -0
index daca7851f2..109f4ea818 100644
@@ -285,6 +285,8 @@ EXPERIMENTAL {
  	rte_mtr_color_in_protocol_priority_get;
  	rte_mtr_color_in_protocol_set;
  	rte_mtr_meter_vlan_table_update;

Please annotate with a comment indicating in which release the symbols have been added.

The patch doesn't show the whole picture.
Actually, The code is:

        # added in 22.07
        rte_mtr_color_in_protocol_get;
        rte_mtr_color_in_protocol_priority_get;
        rte_mtr_color_in_protocol_set;
        rte_mtr_meter_vlan_table_update;
        rte_eth_rx_hw_desc_dump;
        rte_eth_tx_hw_desc_dump;

Thanks.

Quoted 8 lines
Quoted 6 lines
lib/ethdev/version.map +2 -0
+	rte_eth_rx_hw_desc_dump;
+	rte_eth_tx_hw_desc_dump;
  };
 
  INTERNAL {
Acked-by
#6 lore raw

Re: [PATCH 1/4] ethdev: introduce ethdev HW desc dump PI

Quoted 19 lines · Min Hu (Connor)

Hi, Ray,

Quoted 16 lines · Ray Kinsella
Quoted 14 lines · Min Hu (Connor)

Added the ethdev HW Rx desc dump API which provides functions for query HW descriptor from device. HW descriptor info differs in different NICs. The information demonstrates I/O process which is important for debug. As the information is different between NICs, the new API is introduced.

---
  doc/guides/rel_notes/release_22_07.rst |  6 ++++
  lib/ethdev/ethdev_driver.h             | 42 ++++++++++++++++++++++++
  lib/ethdev/rte_ethdev.c                | 44 ++++++++++++++++++++++++++
  lib/ethdev/rte_ethdev.h                | 44 ++++++++++++++++++++++++++
  lib/ethdev/version.map                 |  2 ++
  5 files changed, 138 insertions(+)
#7 lore raw

PATCH 2/4 net/hns3: rename hns3 dump files

In reply to Min Hu (Connor)

This patch rename hns3 dump files and abstract a head file for dump.

---
 .../net/hns3/{hns3_ethdev_dump.c => hns3_dump.c}    |  2 +-
 drivers/net/hns3/hns3_dump.h                        | 13 +++++++++++++
 drivers/net/hns3/hns3_ethdev.c                      |  1 +
 drivers/net/hns3/hns3_ethdev.h                      |  1 -
 drivers/net/hns3/hns3_ethdev_vf.c                   |  1 +
 drivers/net/hns3/meson.build                        |  2 +-
 6 files changed, 17 insertions(+), 3 deletions(-)
 rename drivers/net/hns3/{hns3_ethdev_dump.c => hns3_dump.c} (99%)
 create mode 100644 drivers/net/hns3/hns3_dump.h
drivers/net/hns3/hns3_dump.c renamed from drivers/net/hns3/hns3_ethdev_dump.c +1 -1
similarity index 99%
rename from drivers/net/hns3/hns3_ethdev_dump.c
rename to drivers/net/hns3/hns3_dump.c
index 1bb2ab7556..2cfab429af 100644
@@ -6,7 +6,7 @@
 #include "hns3_logs.h"
 #include "hns3_regs.h"
 #include "hns3_rxtx.h"
-#include "hns3_ethdev.h"
+#include "hns3_dump.h"
 
 static const char *
 get_adapter_state_name(enum hns3_adapter_state state)
drivers/net/hns3/hns3_dump.h new file +13 -0
new file mode 100644
index 0000000000..b0fe37ee21
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2022 HiSilicon Limited
+ */
+
+#ifndef _HNS3_DUMP_H_
+#define _HNS3_DUMP_H_
+
+#include <stdio.h>
+
+#include <ethdev_driver.h>
+
+int hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file);
+#endif /* _HNS3_DUMP_H_ */
drivers/net/hns3/hns3_ethdev.c +1 -0
index 0b565a5614..6fa07c4c94 100644
@@ -8,6 +8,7 @@
 
 #include "hns3_ethdev.h"
 #include "hns3_common.h"
+#include "hns3_dump.h"
 #include "hns3_logs.h"
 #include "hns3_rxtx.h"
 #include "hns3_intr.h"
drivers/net/hns3/hns3_ethdev.h +0 -1
index 5e8a746514..8de5a712f4 100644
@@ -1062,7 +1062,6 @@ 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_vf.c +1 -0
index 589de0ab3a..5fc6515de9 100644
@@ -10,6 +10,7 @@
 
 #include "hns3_ethdev.h"
 #include "hns3_common.h"
+#include "hns3_dump.h"
 #include "hns3_logs.h"
 #include "hns3_rxtx.h"
 #include "hns3_regs.h"
drivers/net/hns3/meson.build +1 -1
index f2aede94ed..dc99cb0209 100644
@@ -30,7 +30,7 @@ sources = files(
         'hns3_tm.c',
         'hns3_ptp.c',
         'hns3_common.c',
-        'hns3_ethdev_dump.c',
+        'hns3_dump.c',
 )
 
 deps += ['hash']
Signature · 1 line
2.33.0
#8 lore raw

PATCH 3/4 net/hns3: support Rx/Tx bd dump

In reply to Min Hu (Connor)

This patch support query HW descriptor from hns3 device. HW descriptor is also called BD(buffer description) which is shared memory between software and hardware.

---
 drivers/net/hns3/hns3_dump.c      | 64 +++++++++++++++++++++++++++++++
 drivers/net/hns3/hns3_dump.h      |  4 ++
 drivers/net/hns3/hns3_ethdev.c    |  2 +
 drivers/net/hns3/hns3_ethdev_vf.c |  2 +
 4 files changed, 72 insertions(+)
drivers/net/hns3/hns3_dump.c +64 -0
index 2cfab429af..f5de5be4eb 100644
@@ -8,6 +8,9 @@
 #include "hns3_rxtx.h"
 #include "hns3_dump.h"
 
+#define HNS3_BD_DW_NUM 8
+#define HNS3_BD_ADDRESS_LAST_DW 2
+
 static const char *
 get_adapter_state_name(enum hns3_adapter_state state)
 {
@@ -911,3 +914,64 @@ hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file)
 
 	return 0;
 }
+
+int hns3_rx_hw_desc_dump(FILE *file, struct rte_eth_dev *dev, uint16_t queue_id,
+			 uint16_t desc_id)
+{
+	struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct hns3_rx_queue *rxq = dev->data->rx_queues[queue_id];
+	uint32_t *bd_data;
+	int i;
+
+	if (desc_id >= rxq->nb_rx_desc) {
+		hns3_err(hw, "Invalid Rx BD id=%u\n", desc_id);
+		return -EINVAL;
+	}
+
+	bd_data = (uint32_t *)rxq->rx_ring;
+	fprintf(file, "Rx queue id:%u BD id:%u\n", queue_id, desc_id);
+	for (i = 0; i < HNS3_BD_DW_NUM; i++) {
+		/*
+		 * For the sake of security, first 8 bytes of BD which stands
+		 * for physical address of packet should not be shown.
+		 */
+		if (i < HNS3_BD_ADDRESS_LAST_DW) {
+			fprintf(file, "RX BD WORD[%d]:0x%08x\n", i, 0);
+			continue;
+		}
+		fprintf(file, "RX BD WORD[%d]:0x%08x\n", i, *(bd_data + i));
+	}
+
+	return 0;
+}
+
+int hns3_tx_hw_desc_dump(FILE *file, struct rte_eth_dev *dev, uint16_t queue_id,
+			 uint16_t desc_id)
+{
+	struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct hns3_tx_queue *txq = dev->data->tx_queues[queue_id];
+	uint32_t *bd_data;
+	int i;
+
+	if (desc_id >= txq->nb_tx_desc) {
+		hns3_err(hw, "Invalid Tx BD id=%u\n", desc_id);
+		return -EINVAL;
+	}
+
+	bd_data = (uint32_t *)txq->tx_ring;
+	fprintf(file, "Tx queue id:%u BD id:%u\n", queue_id, desc_id);
+	for (i = 0; i < HNS3_BD_DW_NUM; i++) {
+		/*
+		 * For the sake of security, first 8 bytes of BD which stands
+		 * for physical address of packet should not be shown.
+		 */
+		if (i < HNS3_BD_ADDRESS_LAST_DW) {
+			fprintf(file, "TX BD WORD[%d]:0x%08x\n", i, 0);
+			continue;
+		}
+
+		fprintf(file, "Tx BD WORD[%d]:0x%08x\n", i, *(bd_data + i));
+	}
+
+	return 0;
+}
drivers/net/hns3/hns3_dump.h +4 -0
index b0fe37ee21..7cc0b36834 100644
@@ -10,4 +10,8 @@
 #include <ethdev_driver.h>
 
 int hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file);
+int hns3_rx_hw_desc_dump(FILE *file, struct rte_eth_dev *dev, uint16_t queue_id,
+			 uint16_t desc_id);
+int hns3_tx_hw_desc_dump(FILE *file, struct rte_eth_dev *dev, uint16_t queue_id,
+			 uint16_t desc_id);
 #endif /* _HNS3_DUMP_H_ */
drivers/net/hns3/hns3_ethdev.c +2 -0
index 6fa07c4c94..ad5018f8a1 100644
@@ -6562,6 +6562,8 @@ static const struct eth_dev_ops hns3_eth_dev_ops = {
 	.timesync_read_time         = hns3_timesync_read_time,
 	.timesync_write_time        = hns3_timesync_write_time,
 	.eth_dev_priv_dump          = hns3_eth_dev_priv_dump,
+	.eth_rx_hw_desc_dump        = hns3_rx_hw_desc_dump,
+	.eth_tx_hw_desc_dump        = hns3_tx_hw_desc_dump,
 };
 
 static const struct hns3_reset_ops hns3_reset_ops = {
drivers/net/hns3/hns3_ethdev_vf.c +2 -0
index 5fc6515de9..26173442b2 100644
@@ -2288,6 +2288,8 @@ static const struct eth_dev_ops hns3vf_eth_dev_ops = {
 	.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,
+	.eth_rx_hw_desc_dump = hns3_rx_hw_desc_dump,
+	.eth_tx_hw_desc_dump = hns3_tx_hw_desc_dump,
 };
 
 static const struct hns3_reset_ops hns3vf_reset_ops = {
Signature · 1 line
2.33.0
#9 lore raw

Re: [PATCH 3/4] net/hns3: support Rx/Tx bd dump

drivers/net/hns3/hns3_dump.c hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file) · line 973

Quoted 11 lines · On Fri, 27 May 2022 10:33:50 +0800 "Min Hu (Connor)" <[email protected]> wrote:
drivers/net/hns3/hns3_dump.c +11 -0
+	for (i = 0; i < HNS3_BD_DW_NUM; i++) {
+		/*
+		 * For the sake of security, first 8 bytes of BD which stands
+		 * for physical address of packet should not be shown.
+		 */
+		if (i < HNS3_BD_ADDRESS_LAST_DW) {
+			fprintf(file, "TX BD WORD[%d]:0x%08x\n", i, 0);
+			continue;
+		}
+
+		fprintf(file, "Tx BD WORD[%d]:0x%08x\n", i, *(bd_data + i));

Use hex dump that exists?
Also this is not the kernel so leaking physical address values is not a real security concern.

#10 lore raw

Re: [PATCH 3/4] net/hns3: support Rx/Tx bd dump

Hi, Stephen,

Quoted 16 lines · Stephen Hemminger

drivers/net/hns3/hns3_dump.c hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file) · line 973

Quoted 11 lines · On Fri, 27 May 2022 10:33:50 +0800 "Min Hu (Connor)" <[email protected]> wrote:
drivers/net/hns3/hns3_dump.c +11 -0
+	for (i = 0; i < HNS3_BD_DW_NUM; i++) {
+		/*
+		 * For the sake of security, first 8 bytes of BD which stands
+		 * for physical address of packet should not be shown.
+		 */
+		if (i < HNS3_BD_ADDRESS_LAST_DW) {
+			fprintf(file, "TX BD WORD[%d]:0x%08x\n", i, 0);
+			continue;
+		}
+
+		fprintf(file, "Tx BD WORD[%d]:0x%08x\n", i, *(bd_data + i));

Use hex dump that exists?

I redefine the dump style because it'd better be consistent with the layout of decription for HW buffer. Like this :
### NIC descriptor for port 0 ###
Rx queue id:0 BD id:1
RX BD WORD[0]:0x00000000
RX BD WORD[1]:0x00000000
RX BD WORD[2]:0x00000000
RX BD WORD[3]:0x00000000
RX BD WORD[4]:0x00000000
RX BD WORD[5]:0x00000000
RX BD WORD[6]:0x00000000
RX BD WORD[7]:0x00000000

The style is more readable.

Quoted 2 lines

Also this is not the kernel so leaking physical address values is not a real security concern.

This address is physical address of packet. It will be used illegal like tamper with packets. This is unsafe to do so.

Quoted 2 lines

.

#11 lore raw

PATCH 4/4 app/procinfo: support descriptor dump

In reply to Min Hu (Connor)

This patch support HW Rx/Tx descriptor dump

The command is like:
dpdk-proc-info -a xxxx:xx:xx.x --file-prefix=xxx -- -- --show-rx-descriptor queue_id:descriptor_id

dpdk-proc-info -a xxxx:xx:xx.x --file-prefix=xxx -- -- --show-tx-descriptor queue_id:descriptor_id

---
 app/proc-info/main.c | 81 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 81 insertions(+)
app/proc-info/main.c +81 -0
index b7e70b4bf5..dd481e26b8 100644
@@ -49,6 +49,9 @@
 #define STATS_BDR_STR(w, s) printf("%.*s%s%.*s\n", w, \
 	STATS_BDR_FMT, s, w, STATS_BDR_FMT)
 
+typedef int (*desc_dump_t)(FILE *file, uint16_t port_id, uint16_t queue_id,
+			    uint16_t desc_id);
+
 /**< mask of enabled ports */
 static unsigned long enabled_port_mask;
 /**< Enable stats. */
@@ -107,6 +110,12 @@ static uint32_t enable_shw_version;
 static uint32_t enable_shw_rss_reta;
 /**< Enable show module info. */
 static uint32_t enable_shw_module_info;
+/**< Enable dump buffer descriptor. */
+#define MAX_NB_ITEM 2
+static uint16_t rx_nb_item;
+static uint16_t tx_nb_item;
+static uint16_t rx_item_opt[MAX_NB_ITEM];
+static uint16_t tx_item_opt[MAX_NB_ITEM];
 
 /**< display usage */
 static void
@@ -137,6 +146,8 @@ proc_info_usage(const char *prgname)
 		"  --show-version: to display DPDK version and firmware version\n"
 		"  --show-rss-reta: to display ports redirection table\n"
 		"  --show-module-info: to display ports module info\n"
+		"  --show-rx-descriptor queue_id:descriptor_id: to display ports Rx buffer description by queue id and descriptor id\n"
+		"  --show-tx-descriptor queue_id:descriptor_id: to display ports Tx buffer description by queue id and descriptor id\n"
 		"  --iter-mempool=name: iterate mempool elements to display content\n"
 		"  --dump-regs=file-prefix: dump registers to file with the file-prefix\n",
 		prgname);
@@ -189,6 +200,34 @@ parse_xstats_ids(char *list, uint64_t *ids, int limit) {
 	return length;
 }
 
+/*
+ * Parse ids value list into array
+ */
+static int
+parse_descriptor_param(char *list, uint16_t *item_opt, int limit)
+{
+	int length;
+	char *token;
+	char *ctx = NULL;
+	char *endptr;
+
+	length = 0;
+	token = strtok_r(list, ":", &ctx);
+	while (token != NULL) {
+		item_opt[length] = strtoul(token, &endptr, 10);
+		if (*endptr != '\0')
+			return -EINVAL;
+
+		length++;
+		if (length > limit)
+			return -E2BIG;
+
+		token = strtok_r(NULL, ":", &ctx);
+	}
+
+	return length;
+}
+
 static int
 proc_info_preparse_args(int argc, char **argv)
 {
@@ -251,6 +290,8 @@ proc_info_parse_args(int argc, char **argv)
 		{"show-version", 0, NULL, 0},
 		{"show-rss-reta", 0, NULL, 0},
 		{"show-module-info", 0, NULL, 0},
+		{"show-rx-descriptor", required_argument, NULL, 1},
+		{"show-tx-descriptor", required_argument, NULL, 1},
 		{NULL, 0, 0, 0}
 	};
 
@@ -348,6 +389,26 @@ proc_info_parse_args(int argc, char **argv)
 					return -1;
 				}
 				nb_xstats_ids = ret;
+			} else if (!strncmp(long_option[option_index].name,
+				"show-rx-descriptor", MAX_LONG_OPT_SZ)) {
+				int ret = parse_descriptor_param(optarg,
+								 rx_item_opt,
+								 MAX_NB_ITEM);
+				if (ret < MAX_NB_ITEM) {
+					printf("Rx descriptor param parse error.\n");
+					return -1;
+				}
+				rx_nb_item = ret;
+			} else if (!strncmp(long_option[option_index].name,
+				"show-tx-descriptor", MAX_LONG_OPT_SZ)) {
+				int ret = parse_descriptor_param(optarg,
+								 tx_item_opt,
+								 MAX_NB_ITEM);
+				if (ret < MAX_NB_ITEM) {
+					printf("Tx descriptor param parse error.\n");
+					return -1;
+				}
+				tx_nb_item = ret;
 			}
 			break;
 		default:
@@ -1597,6 +1658,20 @@ static void show_module_eeprom_info(void)
 	}
 }
 
+static void
+nic_descriptor_display(uint16_t port_id, uint16_t *item_opt,
+		       desc_dump_t desc_dump)
+{
+	static const char *nic_desc_border = "###";
+	uint16_t queue_id = item_opt[0];
+	uint16_t desc_id = item_opt[1];
+
+	printf("%s NIC descriptor for port %u %s\n",
+		   nic_desc_border, port_id, nic_desc_border);
+
+	desc_dump(stdout, port_id, queue_id, desc_id);
+}
+
 int
 main(int argc, char **argv)
 {
@@ -1680,6 +1755,12 @@ main(int argc, char **argv)
 		else if (nb_xstats_ids > 0)
 			nic_xstats_by_ids_display(i, xstats_ids,
 						  nb_xstats_ids);
+		else if (rx_nb_item > 0)
+			nic_descriptor_display(i, rx_item_opt,
+					       rte_eth_rx_hw_desc_dump);
+		else if (tx_nb_item > 0)
+			nic_descriptor_display(i, tx_item_opt,
+					       rte_eth_tx_hw_desc_dump);
 #ifdef RTE_LIB_METRICS
 		else if (enable_metrics)
 			metrics_display(i);
Signature · 1 line
2.33.0
#12 lore raw

v2 cover support HW Rx/Tx descriptor dump

In reply to Min Hu (Connor)

This patch set support HW Rx/Tx descriptor dump by using procinfo tool.

Min Hu (Connor) (4):
ethdev: introduce ethdev HW desc dump PI
net/hns3: rename hns3 dump files
net/hns3: support Rx/Tx bd dump
app/procinfo: support descriptor dump

 app/proc-info/main.c                          | 81 +++++++++++++++++++
 doc/guides/rel_notes/release_22_07.rst        |  6 ++
 .../hns3/{hns3_ethdev_dump.c => hns3_dump.c}  | 66 ++++++++++++++-
 drivers/net/hns3/hns3_dump.h                  | 17 ++++
 drivers/net/hns3/hns3_ethdev.c                |  3 +
 drivers/net/hns3/hns3_ethdev.h                |  1 -
 drivers/net/hns3/hns3_ethdev_vf.c             |  3 +
 drivers/net/hns3/meson.build                  |  2 +-
 lib/ethdev/ethdev_driver.h                    | 42 ++++++++++
 lib/ethdev/rte_ethdev.c                       | 44 ++++++++++
 lib/ethdev/rte_ethdev.h                       | 44 ++++++++++
 lib/ethdev/version.map                        |  2 +
 12 files changed, 308 insertions(+), 3 deletions(-)
 rename drivers/net/hns3/{hns3_ethdev_dump.c => hns3_dump.c} (93%)
 create mode 100644 drivers/net/hns3/hns3_dump.h

---
v2:
* add 'const' for ethdev.

Signature · 1 line
2.33.0
#13 lore raw

PATCH v2 1/4 ethdev: introduce ethdev HW desc dump PI

Added the ethdev HW Rx desc dump API which provides functions for query HW descriptor from device. HW descriptor info differs in different NICs. The information demonstrates I/O process which is important for debug. As the information is different between NICs, the new API is introduced.

---
 doc/guides/rel_notes/release_22_07.rst |  6 ++++
 lib/ethdev/ethdev_driver.h             | 42 ++++++++++++++++++++++++
 lib/ethdev/rte_ethdev.c                | 44 ++++++++++++++++++++++++++
 lib/ethdev/rte_ethdev.h                | 44 ++++++++++++++++++++++++++
 lib/ethdev/version.map                 |  2 ++
 5 files changed, 138 insertions(+)
doc/guides/rel_notes/release_22_07.rst +6 -0
index 0ed4f92820..cfb9117dd3 100644
@@ -95,6 +95,12 @@ New Features
   * Added AH mode support in lookaside protocol (IPsec) for CN9K & CN10K.
   * Added AES-GMAC support in lookaside protocol (IPsec) for CN9K & CN10K.
 
+* **Added ethdev HW desc dump API, to dump Rx/Tx HW desc info from device.**
+
+  Added the ethdev HW Rx desc dump API which provides functions for query
+  HW descriptor from device. HW descriptor info differs in different NICs.
+  The information demonstrates I/O process which is important for debug.
+  As the information is different between NICs, the new API is introduced.
 
 Removed Items
 -------------
lib/ethdev/ethdev_driver.h +42 -0

54 lines not on this page · raw message

lib/ethdev/rte_ethdev.c +44 -0

50 lines not on this page · raw message

lib/ethdev/rte_ethdev.h +44 -0

50 lines not on this page · raw message

lib/ethdev/version.map +2 -0
index daca7851f2..109f4ea818 100644
@@ -285,6 +285,8 @@ EXPERIMENTAL {
 	rte_mtr_color_in_protocol_priority_get;
 	rte_mtr_color_in_protocol_set;
 	rte_mtr_meter_vlan_table_update;
+	rte_eth_rx_hw_desc_dump;
+	rte_eth_tx_hw_desc_dump;
 };
 
 INTERNAL {
Signature · 1 line
2.33.0
#14 lore raw

PATCH v2 2/4 net/hns3: rename hns3 dump files

In reply to Min Hu (Connor)

This patch rename hns3 dump files and abstract a head file for dump.

---
 .../net/hns3/{hns3_ethdev_dump.c => hns3_dump.c}    |  2 +-
 drivers/net/hns3/hns3_dump.h                        | 13 +++++++++++++
 drivers/net/hns3/hns3_ethdev.c                      |  1 +
 drivers/net/hns3/hns3_ethdev.h                      |  1 -
 drivers/net/hns3/hns3_ethdev_vf.c                   |  1 +
 drivers/net/hns3/meson.build                        |  2 +-
 6 files changed, 17 insertions(+), 3 deletions(-)
 rename drivers/net/hns3/{hns3_ethdev_dump.c => hns3_dump.c} (99%)
 create mode 100644 drivers/net/hns3/hns3_dump.h
drivers/net/hns3/hns3_dump.c renamed from drivers/net/hns3/hns3_ethdev_dump.c +1 -1
similarity index 99%
rename from drivers/net/hns3/hns3_ethdev_dump.c
rename to drivers/net/hns3/hns3_dump.c
index 1bb2ab7556..2cfab429af 100644
@@ -6,7 +6,7 @@
 #include "hns3_logs.h"
 #include "hns3_regs.h"
 #include "hns3_rxtx.h"
-#include "hns3_ethdev.h"
+#include "hns3_dump.h"
 
 static const char *
 get_adapter_state_name(enum hns3_adapter_state state)
drivers/net/hns3/hns3_dump.h new file +13 -0
new file mode 100644
index 0000000000..b0fe37ee21
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2022 HiSilicon Limited
+ */
+
+#ifndef _HNS3_DUMP_H_
+#define _HNS3_DUMP_H_
+
+#include <stdio.h>
+
+#include <ethdev_driver.h>
+
+int hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file);
+#endif /* _HNS3_DUMP_H_ */
drivers/net/hns3/hns3_ethdev.c +1 -0
index 0b565a5614..6fa07c4c94 100644
@@ -8,6 +8,7 @@
 
 #include "hns3_ethdev.h"
 #include "hns3_common.h"
+#include "hns3_dump.h"
 #include "hns3_logs.h"
 #include "hns3_rxtx.h"
 #include "hns3_intr.h"
drivers/net/hns3/hns3_ethdev.h +0 -1
index 5e8a746514..8de5a712f4 100644
@@ -1062,7 +1062,6 @@ 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_vf.c +1 -0
index 589de0ab3a..5fc6515de9 100644
@@ -10,6 +10,7 @@
 
 #include "hns3_ethdev.h"
 #include "hns3_common.h"
+#include "hns3_dump.h"
 #include "hns3_logs.h"
 #include "hns3_rxtx.h"
 #include "hns3_regs.h"
drivers/net/hns3/meson.build +1 -1
index f2aede94ed..dc99cb0209 100644
@@ -30,7 +30,7 @@ sources = files(
         'hns3_tm.c',
         'hns3_ptp.c',
         'hns3_common.c',
-        'hns3_ethdev_dump.c',
+        'hns3_dump.c',
 )
 
 deps += ['hash']
Signature · 1 line
2.33.0
#15 lore raw

PATCH v2 3/4 net/hns3: support Rx/Tx bd dump

In reply to Min Hu (Connor)

This patch support query HW descriptor from hns3 device. HW descriptor is also called BD(buffer description) which is shared memory between software and hardware.

---
 drivers/net/hns3/hns3_dump.c      | 64 +++++++++++++++++++++++++++++++
 drivers/net/hns3/hns3_dump.h      |  4 ++
 drivers/net/hns3/hns3_ethdev.c    |  2 +
 drivers/net/hns3/hns3_ethdev_vf.c |  2 +
 4 files changed, 72 insertions(+)
drivers/net/hns3/hns3_dump.c +64 -0
index 2cfab429af..8db2f26144 100644
@@ -8,6 +8,9 @@
 #include "hns3_rxtx.h"
 #include "hns3_dump.h"
 
+#define HNS3_BD_DW_NUM 8
+#define HNS3_BD_ADDRESS_LAST_DW 2
+
 static const char *
 get_adapter_state_name(enum hns3_adapter_state state)
 {
@@ -911,3 +914,64 @@ hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file)
 
 	return 0;
 }
+
+int hns3_rx_hw_desc_dump(FILE *file, const struct rte_eth_dev *dev,
+			 uint16_t queue_id, uint16_t desc_id)
+{
+	struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct hns3_rx_queue *rxq = dev->data->rx_queues[queue_id];
+	uint32_t *bd_data;
+	int i;
+
+	if (desc_id >= rxq->nb_rx_desc) {
+		hns3_err(hw, "Invalid Rx BD id=%u\n", desc_id);
+		return -EINVAL;
+	}
+
+	bd_data = (uint32_t *)rxq->rx_ring;
+	fprintf(file, "Rx queue id:%u BD id:%u\n", queue_id, desc_id);
+	for (i = 0; i < HNS3_BD_DW_NUM; i++) {
+		/*
+		 * For the sake of security, first 8 bytes of BD which stands
+		 * for physical address of packet should not be shown.
+		 */
+		if (i < HNS3_BD_ADDRESS_LAST_DW) {
+			fprintf(file, "RX BD WORD[%d]:0x%08x\n", i, 0);
+			continue;
+		}
+		fprintf(file, "RX BD WORD[%d]:0x%08x\n", i, *(bd_data + i));
+	}
+
+	return 0;
+}
+
+int hns3_tx_hw_desc_dump(FILE *file, const struct rte_eth_dev *dev,
+			 uint16_t queue_id, uint16_t desc_id)
+{
+	struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct hns3_tx_queue *txq = dev->data->tx_queues[queue_id];
+	uint32_t *bd_data;
+	int i;
+
+	if (desc_id >= txq->nb_tx_desc) {
+		hns3_err(hw, "Invalid Tx BD id=%u\n", desc_id);
+		return -EINVAL;
+	}
+
+	bd_data = (uint32_t *)txq->tx_ring;
+	fprintf(file, "Tx queue id:%u BD id:%u\n", queue_id, desc_id);
+	for (i = 0; i < HNS3_BD_DW_NUM; i++) {
+		/*
+		 * For the sake of security, first 8 bytes of BD which stands
+		 * for physical address of packet should not be shown.
+		 */
+		if (i < HNS3_BD_ADDRESS_LAST_DW) {
+			fprintf(file, "TX BD WORD[%d]:0x%08x\n", i, 0);
+			continue;
+		}
+
+		fprintf(file, "Tx BD WORD[%d]:0x%08x\n", i, *(bd_data + i));
+	}
+
+	return 0;
+}
drivers/net/hns3/hns3_dump.h +4 -0
index b0fe37ee21..3dcd9a0466 100644
@@ -10,4 +10,8 @@
 #include <ethdev_driver.h>
 
 int hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file);
+int hns3_rx_hw_desc_dump(FILE *file, const struct rte_eth_dev *dev,
+			 uint16_t queue_id, uint16_t desc_id);
+int hns3_tx_hw_desc_dump(FILE *file, const struct rte_eth_dev *dev,
+			 uint16_t queue_id, uint16_t desc_id);
 #endif /* _HNS3_DUMP_H_ */
drivers/net/hns3/hns3_ethdev.c +2 -0
index 6fa07c4c94..ad5018f8a1 100644
@@ -6562,6 +6562,8 @@ static const struct eth_dev_ops hns3_eth_dev_ops = {
 	.timesync_read_time         = hns3_timesync_read_time,
 	.timesync_write_time        = hns3_timesync_write_time,
 	.eth_dev_priv_dump          = hns3_eth_dev_priv_dump,
+	.eth_rx_hw_desc_dump        = hns3_rx_hw_desc_dump,
+	.eth_tx_hw_desc_dump        = hns3_tx_hw_desc_dump,
 };
 
 static const struct hns3_reset_ops hns3_reset_ops = {
drivers/net/hns3/hns3_ethdev_vf.c +2 -0
index 5fc6515de9..26173442b2 100644
@@ -2288,6 +2288,8 @@ static const struct eth_dev_ops hns3vf_eth_dev_ops = {
 	.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,
+	.eth_rx_hw_desc_dump = hns3_rx_hw_desc_dump,
+	.eth_tx_hw_desc_dump = hns3_tx_hw_desc_dump,
 };
 
 static const struct hns3_reset_ops hns3vf_reset_ops = {
Signature · 1 line
2.33.0
#16 lore raw

PATCH v2 4/4 app/procinfo: support descriptor dump

In reply to Min Hu (Connor)

This patch support HW Rx/Tx descriptor dump

The command is like:
dpdk-proc-info -a xxxx:xx:xx.x --file-prefix=xxx -- -- --show-rx-descriptor queue_id:descriptor_id

dpdk-proc-info -a xxxx:xx:xx.x --file-prefix=xxx -- -- --show-tx-descriptor queue_id:descriptor_id

---
 app/proc-info/main.c | 81 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 81 insertions(+)
app/proc-info/main.c +81 -0
index 56070a3317..eab1b546d1 100644
@@ -48,6 +48,9 @@
 #define STATS_BDR_STR(w, s) printf("%.*s%s%.*s\n", w, \
 	STATS_BDR_FMT, s, w, STATS_BDR_FMT)
 
+typedef int (*desc_dump_t)(FILE *file, uint16_t port_id, uint16_t queue_id,
+			    uint16_t desc_id);
+
 /**< mask of enabled ports */
 static unsigned long enabled_port_mask;
 /**< Enable stats. */
@@ -100,6 +103,12 @@ static char *mempool_iter_name;
 /**< Enable dump regs. */
 static uint32_t enable_dump_regs;
 static char *dump_regs_file_prefix;
+/**< Enable dump buffer descriptor. */
+#define MAX_NB_ITEM 2
+static uint16_t rx_nb_item;
+static uint16_t tx_nb_item;
+static uint16_t rx_item_opt[MAX_NB_ITEM];
+static uint16_t tx_item_opt[MAX_NB_ITEM];
 
 /**< display usage */
 static void
@@ -127,6 +136,8 @@ proc_info_usage(const char *prgname)
 		"  --show-crypto: to display crypto information\n"
 		"  --show-ring[=name]: to display ring information\n"
 		"  --show-mempool[=name]: to display mempool information\n"
+		"  --show-rx-descriptor queue_id:descriptor_id: to display ports Rx buffer description by queue id and descriptor id\n"
+		"  --show-tx-descriptor queue_id:descriptor_id: to display ports Tx buffer description by queue id and descriptor id\n"
 		"  --iter-mempool=name: iterate mempool elements to display content\n"
 		"  --dump-regs=file-prefix: dump registers to file with the file-prefix\n",
 		prgname);
@@ -179,6 +190,34 @@ parse_xstats_ids(char *list, uint64_t *ids, int limit) {
 	return length;
 }
 
+/*
+ * Parse ids value list into array
+ */
+static int
+parse_descriptor_param(char *list, uint16_t *item_opt, int limit)
+{
+	int length;
+	char *token;
+	char *ctx = NULL;
+	char *endptr;
+
+	length = 0;
+	token = strtok_r(list, ":", &ctx);
+	while (token != NULL) {
+		item_opt[length] = strtoul(token, &endptr, 10);
+		if (*endptr != '\0')
+			return -EINVAL;
+
+		length++;
+		if (length > limit)
+			return -E2BIG;
+
+		token = strtok_r(NULL, ":", &ctx);
+	}
+
+	return length;
+}
+
 static int
 proc_info_preparse_args(int argc, char **argv)
 {
@@ -238,6 +277,8 @@ proc_info_parse_args(int argc, char **argv)
 		{"show-mempool", optional_argument, NULL, 0},
 		{"iter-mempool", required_argument, NULL, 0},
 		{"dump-regs", required_argument, NULL, 0},
+		{"show-rx-descriptor", required_argument, NULL, 1},
+		{"show-tx-descriptor", required_argument, NULL, 1},
 		{NULL, 0, 0, 0}
 	};
 
@@ -327,6 +368,26 @@ proc_info_parse_args(int argc, char **argv)
 					return -1;
 				}
 				nb_xstats_ids = ret;
+			} else if (!strncmp(long_option[option_index].name,
+				"show-rx-descriptor", MAX_LONG_OPT_SZ)) {
+				int ret = parse_descriptor_param(optarg,
+								 rx_item_opt,
+								 MAX_NB_ITEM);
+				if (ret < MAX_NB_ITEM) {
+					printf("Rx descriptor param parse error.\n");
+					return -1;
+				}
+				rx_nb_item = ret;
+			} else if (!strncmp(long_option[option_index].name,
+				"show-tx-descriptor", MAX_LONG_OPT_SZ)) {
+				int ret = parse_descriptor_param(optarg,
+								 tx_item_opt,
+								 MAX_NB_ITEM);
+				if (ret < MAX_NB_ITEM) {
+					printf("Tx descriptor param parse error.\n");
+					return -1;
+				}
+				tx_nb_item = ret;
 			}
 			break;
 		default:
@@ -1450,6 +1511,20 @@ dump_regs(char *file_prefix)
 	}
 }
 
+static void
+nic_descriptor_display(uint16_t port_id, uint16_t *item_opt,
+		       desc_dump_t desc_dump)
+{
+	static const char *nic_desc_border = "###";
+	uint16_t queue_id = item_opt[0];
+	uint16_t desc_id = item_opt[1];
+
+	printf("%s NIC descriptor for port %u %s\n",
+		   nic_desc_border, port_id, nic_desc_border);
+
+	desc_dump(stdout, port_id, queue_id, desc_id);
+}
+
 int
 main(int argc, char **argv)
 {
@@ -1533,6 +1608,12 @@ main(int argc, char **argv)
 		else if (nb_xstats_ids > 0)
 			nic_xstats_by_ids_display(i, xstats_ids,
 						  nb_xstats_ids);
+		else if (rx_nb_item > 0)
+			nic_descriptor_display(i, rx_item_opt,
+					       rte_eth_rx_hw_desc_dump);
+		else if (tx_nb_item > 0)
+			nic_descriptor_display(i, tx_item_opt,
+					       rte_eth_tx_hw_desc_dump);
 #ifdef RTE_LIB_METRICS
 		else if (enable_metrics)
 			metrics_display(i);
Signature · 1 line
2.33.0
#17 lore raw

v3 cover support HW Rx/Tx descriptor dump

In reply to Min Hu (Connor)

This patch set support HW Rx/Tx descriptor dump by using procinfo tool.

Min Hu (Connor) (4):
ethdev: introduce ethdev HW desc dump PI
net/hns3: rename hns3 dump files
net/hns3: support Rx/Tx bd dump
app/procinfo: support descriptor dump

 app/proc-info/main.c                          | 81 +++++++++++++++++++
 doc/guides/rel_notes/release_22_07.rst        |  7 ++
 .../hns3/{hns3_ethdev_dump.c => hns3_dump.c}  | 66 ++++++++++++++-
 drivers/net/hns3/hns3_dump.h                  | 17 ++++
 drivers/net/hns3/hns3_ethdev.c                |  3 +
 drivers/net/hns3/hns3_ethdev.h                |  1 -
 drivers/net/hns3/hns3_ethdev_vf.c             |  3 +
 drivers/net/hns3/meson.build                  |  2 +-
 lib/ethdev/ethdev_driver.h                    | 42 ++++++++++
 lib/ethdev/rte_ethdev.c                       | 44 ++++++++++
 lib/ethdev/rte_ethdev.h                       | 44 ++++++++++
 lib/ethdev/version.map                        |  2 +
 12 files changed, 309 insertions(+), 3 deletions(-)
 rename drivers/net/hns3/{hns3_ethdev_dump.c => hns3_dump.c} (93%)
 create mode 100644 drivers/net/hns3/hns3_dump.h

---
v3:
* fix desc id handling.

v2:
* add 'const' for ethdev.

Signature · 1 line
2.33.0
#18 lore raw

PATCH v3 1/4 ethdev: introduce ethdev HW desc dump PI

Added the ethdev HW Rx desc dump API which provides functions for query HW descriptor from device. HW descriptor info differs in different NICs. The information demonstrates I/O process which is important for debug. As the information is different between NICs, the new API is introduced.

---
 doc/guides/rel_notes/release_22_07.rst |  7 ++++
 lib/ethdev/ethdev_driver.h             | 42 ++++++++++++++++++++++++
 lib/ethdev/rte_ethdev.c                | 44 ++++++++++++++++++++++++++
 lib/ethdev/rte_ethdev.h                | 44 ++++++++++++++++++++++++++
 lib/ethdev/version.map                 |  2 ++
 5 files changed, 139 insertions(+)
doc/guides/rel_notes/release_22_07.rst +7 -0
index 8932a1d478..56c675121a 100644
@@ -137,6 +137,13 @@ New Features
   * ``RTE_EVENT_QUEUE_ATTR_WEIGHT``
   * ``RTE_EVENT_QUEUE_ATTR_AFFINITY``
 
+* **Added ethdev HW desc dump API, to dump Rx/Tx HW desc info from device.**
+
+  Added the ethdev HW Rx desc dump API which provides functions for query
+  HW descriptor from device. HW descriptor info differs in different NICs.
+  The information demonstrates I/O process which is important for debug.
+  As the information is different between NICs, the new API is introduced.
+
 
 Removed Items
 -------------
lib/ethdev/ethdev_driver.h +42 -0

54 lines not on this page · raw message

lib/ethdev/rte_ethdev.c +44 -0

50 lines not on this page · raw message

lib/ethdev/rte_ethdev.h +44 -0

50 lines not on this page · raw message

lib/ethdev/version.map +2 -0
index daca7851f2..109f4ea818 100644
@@ -285,6 +285,8 @@ EXPERIMENTAL {
 	rte_mtr_color_in_protocol_priority_get;
 	rte_mtr_color_in_protocol_set;
 	rte_mtr_meter_vlan_table_update;
+	rte_eth_rx_hw_desc_dump;
+	rte_eth_tx_hw_desc_dump;
 };
 
 INTERNAL {
Signature · 1 line
2.33.0
#19 lore raw

Re: [PATCH v3 1/4] ethdev: introduce ethdev HW desc dump PI

Quoted 37 lines · Min Hu (Connor)

Added the ethdev HW Rx desc dump API which provides functions for query HW descriptor from device. HW descriptor info differs in different NICs. The information demonstrates I/O process which is important for debug. As the information is different between NICs, the new API is introduced.

---
  doc/guides/rel_notes/release_22_07.rst |  7 ++++
  lib/ethdev/ethdev_driver.h             | 42 ++++++++++++++++++++++++
  lib/ethdev/rte_ethdev.c                | 44 ++++++++++++++++++++++++++
  lib/ethdev/rte_ethdev.h                | 44 ++++++++++++++++++++++++++
  lib/ethdev/version.map                 |  2 ++
  5 files changed, 139 insertions(+)
doc/guides/rel_notes/release_22_07.rst +7 -0
index 8932a1d478..56c675121a 100644
@@ -137,6 +137,13 @@ New Features
    * ``RTE_EVENT_QUEUE_ATTR_WEIGHT``
    * ``RTE_EVENT_QUEUE_ATTR_AFFINITY``
 
+* **Added ethdev HW desc dump API, to dump Rx/Tx HW desc info from device.**
+
+  Added the ethdev HW Rx desc dump API which provides functions for query
+  HW descriptor from device. HW descriptor info differs in different NICs.
+  The information demonstrates I/O process which is important for debug.
+  As the information is different between NICs, the new API is introduced.
+
 
  Removed Items
  -------------
lib/ethdev/ethdev_driver.h +0 -0
index 69d9dc21d8..9c1726eb2d 100644

lib/ethdev/ethdev_driver.h typedef int (*eth_ip_reassembly_conf_set_t)(struct rte_eth_dev *dev, · line 1078

Quoted 6 lines
lib/ethdev/ethdev_driver.h +3 -0
@@ -1073,6 +1073,42 @@ typedef int (*eth_ip_reassembly_conf_set_t)(struct rte_eth_dev *dev,
   */
  typedef int (*eth_dev_priv_dump_t)(struct rte_eth_dev *dev, FILE *file);
 
+/**
+ * @internal
+ * Dump ethdev Rx descriptor info to a file.

ethdev is not required in the description above. It is an ethdev operation type.

Is there any limitations on caller context? Should be it the same CPU core (since typically it is the case for per-queue API) which polls the queue? The answer must be in the API function description.

lib/ethdev/ethdev_driver.h typedef int (*eth_ip_reassembly_conf_set_t)(struct rte_eth_dev *dev, · line 1087

Quoted 9 lines
lib/ethdev/ethdev_driver.h +9 -0
+ *
+ * @param file
+ *   A pointer to a file for output.
+ * @param dev
+ *   Port (ethdev) handle.
+ * @param queue_id
+ *   The selected queue.
+ * @param desc_id
+ *   The selected descriptor.

Is it an ID in the ring regardless of the current position or is it offset relative to current position in the ring? It should be clarified in any case.
I'd say that it should be an offset to be consistent with descriptor status API.

It would be useful to be able to dump many descriptor at once.

Quoted 28 lines
lib/ethdev/ethdev_driver.h +24 -0
+ * @return
+ *   Negative errno value on error, zero on success.
+ */
+typedef int (*eth_rx_hw_desc_dump_t)(FILE *file, const struct rte_eth_dev *dev,
+				     uint16_t queue_id, uint16_t desc_id);
+
+/**
+ * @internal
+ * Dump ethdev Tx descriptor info to a file.
+ *
+ * @param file
+ *   A pointer to a file for output.
+ * @param dev
+ *   Port (ethdev) handle.
+ * @param queue_id
+ *   The selected queue.
+ * @param desc_id
+ *   The selected descriptor.
+ * @return
+ *   Negative errno value on error, zero on success.
+ */
+typedef int (*eth_tx_hw_desc_dump_t)(FILE *file, const struct rte_eth_dev *dev,
+				     uint16_t queue_id, uint16_t desc_id);
+
  /**
   * @internal A structure containing the functions exported by an Ethernet driver.
   */

lib/ethdev/ethdev_driver.h struct eth_dev_ops { · line 1323

Quoted 5 lines
lib/ethdev/ethdev_driver.h +2 -0
@@ -1283,6 +1319,12 @@ struct eth_dev_ops {
 
  	/** Dump private info from device */
  	eth_dev_priv_dump_t eth_dev_priv_dump;
+
+	/** Dump ethdev Rx descriptor info */\\

It is an ethdev operations. So, 'ethdev' is not necessary in the description.

Quoted 14 lines
lib/ethdev/ethdev_driver.h +4 -0
+	eth_rx_hw_desc_dump_t eth_rx_hw_desc_dump;
+
+	/** Dump ethdev Tx descriptor info */
+	eth_tx_hw_desc_dump_t eth_tx_hw_desc_dump;
  };
 
  /**
lib/ethdev/rte_ethdev.c +0 -0
index 46c088dc88..bbd8439fa0 100644
@@ -5876,6 +5876,50 @@ rte_eth_dev_priv_dump(uint16_t port_id, FILE *file)
  	return eth_err(port_id, (*dev->dev_ops->eth_dev_priv_dump)(dev, file));
  }

lib/ethdev/rte_ethdev.c rte_eth_dev_priv_dump(uint16_t port_id, FILE *file) · line 5887

Quoted 10 lines
lib/ethdev/rte_ethdev.c +9 -0
 
+int
+rte_eth_rx_hw_desc_dump(FILE *file, uint16_t port_id, uint16_t queue_id,
+			uint16_t desc_id)
+{
+	struct rte_eth_dev *dev;
+	int ret;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	dev = &rte_eth_devices[port_id];

Shouldn't we check file vs null?

lib/ethdev/rte_ethdev.c rte_eth_dev_priv_dump(uint16_t port_id, FILE *file) · line 5892

Quoted 5 lines
lib/ethdev/rte_ethdev.c +5 -0
+
+	if (queue_id >= dev->data->nb_rx_queues) {
+		RTE_ETHDEV_LOG(ERR, "Invalid Rx queue_id=%u\n", queue_id);
+		return -EINVAL;
+	}

Don't we need a check vs queue size?

Quoted 7 lines
lib/ethdev/rte_ethdev.c +7 -0
+
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->eth_rx_hw_desc_dump, -ENOTSUP);
+	ret = (*dev->dev_ops->eth_rx_hw_desc_dump)(file, dev, queue_id,
+						   desc_id);
+
+	return ret;
+}
#20 lore raw

Re: [PATCH v3 1/4] ethdev: introduce ethdev HW desc dump PI

Hi Andrew

Many thanks for your review.

Quoted 43 lines · Andrew Rybchenko
Quoted 42 lines · Min Hu (Connor)

Added the ethdev HW Rx desc dump API which provides functions for query HW descriptor from device. HW descriptor info differs in different NICs. The information demonstrates I/O process which is important for debug. As the information is different between NICs, the new API is introduced.

---
  doc/guides/rel_notes/release_22_07.rst |  7 ++++
  lib/ethdev/ethdev_driver.h             | 42 ++++++++++++++++++++++++
  lib/ethdev/rte_ethdev.c                | 44 ++++++++++++++++++++++++++
  lib/ethdev/rte_ethdev.h                | 44 ++++++++++++++++++++++++++
  lib/ethdev/version.map                 |  2 ++
  5 files changed, 139 insertions(+)
doc/guides/rel_notes/release_22_07.rst +0 -0
index 8932a1d478..56c675121a 100644
@@ -137,6 +137,13 @@ New Features
    * ``RTE_EVENT_QUEUE_ATTR_WEIGHT``
    * ``RTE_EVENT_QUEUE_ATTR_AFFINITY``
  +* **Added ethdev HW desc dump API, to dump Rx/Tx HW desc info from

device.**

doc/guides/rel_notes/release_22_07.rst +2 -0
+
+  Added the ethdev HW Rx desc dump API which provides functions for

query
+ HW descriptor from device. HW descriptor info differs in different NICs.

doc/guides/rel_notes/release_22_07.rst +2 -0
+  The information demonstrates I/O process which is important for debug.
+  As the information is different between NICs, the new API is

introduced.

doc/guides/rel_notes/release_22_07.rst +1 -0
+
    Removed Items
  -------------
lib/ethdev/ethdev_driver.h +0 -0
index 69d9dc21d8..9c1726eb2d 100644
@@ -1073,6 +1073,42 @@ typedef int
 (*eth_ip_reassembly_conf_set_t)(struct rte_eth_dev *dev,
   */
Quoted 8 lines

lib/ethdev/ethdev_driver.h typedef int · line 1079

Quoted 5 lines
lib/ethdev/ethdev_driver.h +2 -0
  typedef int (*eth_dev_priv_dump_t)(struct rte_eth_dev *dev, FILE
 *file);
  +/**
+ * @internal
+ * Dump ethdev Rx descriptor info to a file.

ethdev is not required in the description above. It is an ethdev operation type.

Will remove it.

Quoted 4 lines

Is there any limitations on caller context? Should be it the same CPU core (since typically it is the case for per-queue API) which polls the queue? The answer must be in the API function description.

"[PATCH v3 4/4] app/procinfo: support descriptor dump" shows how to use the API. It is used for debug, not a dataplane API, no special limitations on caller context.

Quoted 11 lines

lib/ethdev/ethdev_driver.h typedef int (*eth_ip_reassembly_conf_set_t)(struct rte_eth_dev *dev, · line 1087

Quoted 10 lines
lib/ethdev/ethdev_driver.h +9 -0
+ *
+ * @param file
+ *   A pointer to a file for output.
+ * @param dev
+ *   Port (ethdev) handle.
+ * @param queue_id
+ *   The selected queue.
+ * @param desc_id
+ *   The selected descriptor.
Quoted 5 lines

Is it an ID in the ring regardless of the current position or is it offset relative to current position in the ring? It should be clarified in any case.
I'd say that it should be an offset to be consistent with descriptor status API.

It is an ID in the ring regardless of the current position.

Quoted 2 lines

It would be useful to be able to dump many descriptor at once.

This can be done by the appliacation.

Quoted 31 lines
Quoted 31 lines
lib/ethdev/ethdev_driver.h +22 -0
+ * @return
+ *   Negative errno value on error, zero on success.
+ */
+typedef int (*eth_rx_hw_desc_dump_t)(FILE *file, const struct
 rte_eth_dev *dev,
+                     uint16_t queue_id, uint16_t desc_id);
+
+/**
+ * @internal
+ * Dump ethdev Tx descriptor info to a file.
+ *
+ * @param file
+ *   A pointer to a file for output.
+ * @param dev
+ *   Port (ethdev) handle.
+ * @param queue_id
+ *   The selected queue.
+ * @param desc_id
+ *   The selected descriptor.
+ * @return
+ *   Negative errno value on error, zero on success.
+ */
+typedef int (*eth_tx_hw_desc_dump_t)(FILE *file, const struct

rte_eth_dev *dev,

lib/ethdev/ethdev_driver.h +2 -0
+                     uint16_t queue_id, uint16_t desc_id);
+
  /**
   * @internal A structure containing the functions exported by an

Ethernet driver.
*/

Quoted 8 lines

lib/ethdev/ethdev_driver.h struct eth_dev_ops { · line 1322

Quoted 5 lines
lib/ethdev/ethdev_driver.h +2 -0
@@ -1283,6 +1319,12 @@ struct eth_dev_ops {
        /** Dump private info from device */
      eth_dev_priv_dump_t eth_dev_priv_dump;
+
+    /** Dump ethdev Rx descriptor info */\\

It is an ethdev operations. So, 'ethdev' is not necessary in the description.

Will fix.

Quoted 19 lines
Quoted 19 lines
lib/ethdev/ethdev_driver.h +4 -0
+    eth_rx_hw_desc_dump_t eth_rx_hw_desc_dump;
+
+    /** Dump ethdev Tx descriptor info */
+    eth_tx_hw_desc_dump_t eth_tx_hw_desc_dump;
  };
    /**
lib/ethdev/rte_ethdev.c +2 -0
index 46c088dc88..bbd8439fa0 100644
@@ -5876,6 +5876,50 @@ rte_eth_dev_priv_dump(uint16_t port_id, FILE
 *file)
      return eth_err(port_id, (*dev->dev_ops->eth_dev_priv_dump)(dev,
 file));
  }
  +int
+rte_eth_rx_hw_desc_dump(FILE *file, uint16_t port_id, uint16_t queue_id,
+            uint16_t desc_id)
Quoted 8 lines

lib/ethdev/rte_ethdev.c rte_eth_dev_priv_dump(uint16_t port_id, FILE *file) · line 5887

Quoted 6 lines
lib/ethdev/rte_ethdev.c +6 -0
+{
+    struct rte_eth_dev *dev;
+    int ret;
+
+    RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+    dev = &rte_eth_devices[port_id];

Shouldn't we check file vs null?

Yes, will do.

Quoted 8 lines

lib/ethdev/rte_ethdev.c rte_eth_dev_priv_dump(uint16_t port_id, FILE *file) · line 5892

Quoted 6 lines
lib/ethdev/rte_ethdev.c +5 -0
+
+    if (queue_id >= dev->data->nb_rx_queues) {
+        RTE_ETHDEV_LOG(ERR, "Invalid Rx queue_id=%u\n", queue_id);
+        return -EINVAL;
+    }

Don't we need a check vs queue size?

This need to be done in pmd as "[PATCH v3 3/4] net/hns3: support Rx/Tx bd dump" shows.

Thanks,
Dongdong

Quoted 12 lines

lib/ethdev/rte_ethdev.c rte_eth_dev_priv_dump(uint16_t port_id, FILE *file) · line 5899

Quoted 9 lines
lib/ethdev/rte_ethdev.c +7 -1
+
+    RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->eth_rx_hw_desc_dump,
-ENOTSUP);
+    ret = (*dev->dev_ops->eth_rx_hw_desc_dump)(file, dev, queue_id,
+                           desc_id);
+
+    return ret;
+}

.

#21 lore raw

Re: [PATCH v3 1/4] ethdev: introduce ethdev HW desc dump PI

Cc various driver maintainers looking for opinion about API discussion below

Quoted 60 lines · Dongdong Liu

Hi Andrew

Many thanks for your review.

Quoted 44 lines · Andrew Rybchenko
Quoted 43 lines · Min Hu (Connor)

Added the ethdev HW Rx desc dump API which provides functions for query HW descriptor from device. HW descriptor info differs in different NICs. The information demonstrates I/O process which is important for debug. As the information is different between NICs, the new API is introduced.

---
  doc/guides/rel_notes/release_22_07.rst |  7 ++++ lib/ethdev/ethdev_driver.h             | 42 ++++++++++++++++++++++++ lib/ethdev/rte_ethdev.c                | 44 ++++++++++++++++++++++++++ lib/ethdev/rte_ethdev.h                | 44 ++++++++++++++++++++++++++ lib/ethdev/version.map                 |  2 ++

  5 files changed, 139 insertions(+)
doc/guides/rel_notes/release_22_07.rst +0 -0
index 8932a1d478..56c675121a 100644
@@ -137,6 +137,13 @@ New Features
     * ``RTE_EVENT_QUEUE_ATTR_WEIGHT``
     * ``RTE_EVENT_QUEUE_ATTR_AFFINITY``

  +* **Added ethdev HW desc dump API, to dump Rx/Tx HW desc info from device.**
+
+  Added the ethdev HW Rx desc dump API which provides functions for query
+  HW descriptor from device. HW descriptor info differs in different NICs.
+  The information demonstrates I/O process which is important for debug.
+  As the information is different between NICs, the new API is introduced.
+
    Removed Items
  -------------

lib/ethdev/ethdev_driver.h +0 -0
index 69d9dc21d8..9c1726eb2d 100644
@@ -1073,6 +1073,42 @@ typedef int
 (*eth_ip_reassembly_conf_set_t)(struct rte_eth_dev *dev,
    */
Quoted 8 lines
Quoted 5 lines

  typedef int (*eth_dev_priv_dump_t)(struct rte_eth_dev *dev, FILE *file);
  +/**
+ * @internal
+ * Dump ethdev Rx descriptor info to a file.

ethdev is not required in the description above. It is an ethdev operation type.

Will remove it.

Quoted 1 line
Quoted 7 lines
Quoted 3 lines

Is there any limitations on caller context? Should be it the same CPU core (since typically it is the case for per-queue API) which polls the queue? The answer must be in the API function description.

"[PATCH v3 4/4] app/procinfo: support descriptor dump" shows how to use the API. It is used for debug, not a dataplane API,  no special limitations on caller context.

Please, be explicit in the ethdev API documentation.

Quoted 11 lines
Quoted 11 lines
Quoted 10 lines

+ *
+ * @param file
+ *   A pointer to a file for output.
+ * @param dev
+ *   Port (ethdev) handle.
+ * @param queue_id
+ *   The selected queue.
+ * @param desc_id
+ *   The selected descriptor.

Quoted 7 lines
Quoted 5 lines

Is it an ID in the ring regardless of the current position or is it offset relative to current position in the ring? It should be clarified in any case.
I'd say that it should be an offset to be consistent with descriptor status API.

It is an ID in the ring regardless of the current position.

IMHO, it is inconvenient since typically it is interesting what happens nearby current position.

Quoted 3 lines
Quoted 2 lines

It would be useful to be able to dump many descriptor at once.

This can be done by the appliacation.

Yes, that's true, but easy to do in the driver as well. It would be especially important if ID semantics changes.

Quoted 76 lines
Quoted 31 lines
Quoted 31 lines

+ * @return
+ *   Negative errno value on error, zero on success.
+ */
+typedef int (*eth_rx_hw_desc_dump_t)(FILE *file, const struct rte_eth_dev *dev,
+                     uint16_t queue_id, uint16_t desc_id);

lib/ethdev/ethdev_driver.h +17 -0
+
+/**
+ * @internal
+ * Dump ethdev Tx descriptor info to a file.
+ *
+ * @param file
+ *   A pointer to a file for output.
+ * @param dev
+ *   Port (ethdev) handle.
+ * @param queue_id
+ *   The selected queue.
+ * @param desc_id
+ *   The selected descriptor.
+ * @return
+ *   Negative errno value on error, zero on success.
+ */
+typedef int (*eth_tx_hw_desc_dump_t)(FILE *file, const struct

rte_eth_dev *dev,
+                     uint16_t queue_id, uint16_t desc_id); +
  /**
   * @internal A structure containing the functions exported by an Ethernet driver.
   */

Quoted 8 lines

lib/ethdev/ethdev_driver.h struct eth_dev_ops { · line 1322

Quoted 5 lines
lib/ethdev/ethdev_driver.h +2 -0
@@ -1283,6 +1319,12 @@ struct eth_dev_ops {
         /** Dump private info from device */
       eth_dev_priv_dump_t eth_dev_priv_dump;
+
+    /** Dump ethdev Rx descriptor info */\\

It is an ethdev operations. So, 'ethdev' is not necessary in the description.

Will fix.

Quoted 20 lines
Quoted 20 lines
lib/ethdev/ethdev_driver.h +4 -0
+    eth_rx_hw_desc_dump_t eth_rx_hw_desc_dump;
+
+    /** Dump ethdev Tx descriptor info */
+    eth_tx_hw_desc_dump_t eth_tx_hw_desc_dump;
   };
     /**
lib/ethdev/rte_ethdev.c +0 -0
index 46c088dc88..bbd8439fa0 100644
@@ -5876,6 +5876,50 @@ rte_eth_dev_priv_dump(uint16_t port_id, FILE
 *file)
       return eth_err(port_id, (*dev->dev_ops->eth_dev_priv_dump)(dev,
 file));
   }

  +int
+rte_eth_rx_hw_desc_dump(FILE *file, uint16_t port_id, uint16_t queue_id,
+            uint16_t desc_id)

Quoted 8 lines

lib/ethdev/rte_ethdev.c rte_eth_dev_priv_dump(uint16_t port_id, FILE *file) · line 5887

Quoted 6 lines
lib/ethdev/rte_ethdev.c +6 -0
+{
+    struct rte_eth_dev *dev;
+    int ret;
+
+    RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+    dev = &rte_eth_devices[port_id];

Shouldn't we check file vs null?

Yes, will do.

Quoted 7 lines
Quoted 6 lines

+
+    if (queue_id >= dev->data->nb_rx_queues) {
+        RTE_ETHDEV_LOG(ERR, "Invalid Rx queue_id=%u\n", queue_id); +        return -EINVAL;
+    }

Quoted 3 lines
Quoted 1 line

Don't we need a check vs queue size?

This need to be done in pmd as "[PATCH v3 3/4] net/hns3: support Rx/Tx bd dump" shows.

All applicable generic checks must be done on ethdev level to avoid code duplication and missing checks in PMDs.

Andrew.

#22 lore raw

Re: [PATCH v3 1/4] ethdev: introduce ethdev HW desc dump PI

Hi Andrew

Many thanks for your review.

Quoted 72 lines · Andrew Rybchenko

Cc various driver maintainers looking for opinion about API discussion below

Quoted 68 lines · Dongdong Liu

Hi Andrew

Many thanks for your review.

Quoted 48 lines · Andrew Rybchenko
Quoted 47 lines · Min Hu (Connor)

Added the ethdev HW Rx desc dump API which provides functions for query HW descriptor from device. HW descriptor info differs in different NICs.
The information demonstrates I/O process which is important for debug. As the information is different between NICs, the new API is introduced.

---
  doc/guides/rel_notes/release_22_07.rst |  7 ++++
  lib/ethdev/ethdev_driver.h             | 42 ++++++++++++++++++++++++
  lib/ethdev/rte_ethdev.c                | 44
++++++++++++++++++++++++++
  lib/ethdev/rte_ethdev.h                | 44
++++++++++++++++++++++++++
  lib/ethdev/version.map                 |  2 ++
  5 files changed, 139 insertions(+)
doc/guides/rel_notes/release_22_07.rst +0 -0
index 8932a1d478..56c675121a 100644
@@ -137,6 +137,13 @@ New Features
    * ``RTE_EVENT_QUEUE_ATTR_WEIGHT``
    * ``RTE_EVENT_QUEUE_ATTR_AFFINITY``
  +* **Added ethdev HW desc dump API, to dump Rx/Tx HW desc info from

device.**

doc/guides/rel_notes/release_22_07.rst +2 -0
+
+  Added the ethdev HW Rx desc dump API which provides functions for

query
+ HW descriptor from device. HW descriptor info differs in different NICs.
+ The information demonstrates I/O process which is important for debug.
+ As the information is different between NICs, the new API is introduced.

doc/guides/rel_notes/release_22_07.rst +1 -0
+
    Removed Items
  -------------
lib/ethdev/ethdev_driver.h +0 -0
index 69d9dc21d8..9c1726eb2d 100644
@@ -1073,6 +1073,42 @@ typedef int
 (*eth_ip_reassembly_conf_set_t)(struct rte_eth_dev *dev,
   */
Quoted 8 lines

lib/ethdev/ethdev_driver.h typedef int · line 1079

Quoted 5 lines
lib/ethdev/ethdev_driver.h +2 -0
  typedef int (*eth_dev_priv_dump_t)(struct rte_eth_dev *dev, FILE
 *file);
  +/**
+ * @internal
+ * Dump ethdev Rx descriptor info to a file.

ethdev is not required in the description above. It is an ethdev operation type.

Will remove it.

Quoted 4 lines

Is there any limitations on caller context? Should be it the same CPU core (since typically it is the case for per-queue API) which polls the queue? The answer must be in the API function description.

Quoted 5 lines
Quoted 3 lines

"[PATCH v3 4/4] app/procinfo: support descriptor dump" shows how to use the API. It is used for debug, not a dataplane API, no special limitations on caller context.

Please, be explicit in the ethdev API documentation.

OK, will do

Quoted 18 lines
Quoted 18 lines
Quoted 17 lines

lib/ethdev/ethdev_driver.h typedef int (*eth_ip_reassembly_conf_set_t)(struct rte_eth_dev *dev, · line 1087

Quoted 11 lines
lib/ethdev/ethdev_driver.h +9 -0
+ *
+ * @param file
+ *   A pointer to a file for output.
+ * @param dev
+ *   Port (ethdev) handle.
+ * @param queue_id
+ *   The selected queue.
+ * @param desc_id
+ *   The selected descriptor.

Is it an ID in the ring regardless of the current position or is it offset relative to current position in the ring? It should be clarified in any case.
I'd say that it should be an offset to be consistent with descriptor status API.

Quoted 5 lines
Quoted 1 line

It is an ID in the ring regardless of the current position.

IMHO, it is inconvenient since typically it is interesting what happens nearby current position.

OK, will fix.

Quoted 6 lines
Quoted 3 lines
Quoted 2 lines

It would be useful to be able to dump many descriptor at once.

This can be done by the appliacation.

Yes, that's true, but easy to do in the driver as well. It would be especially important if ID semantics changes.

How about changing parameter 'desc_id' to 'num' to dump [current position, current position + num - 1] descriptors.

/**
* @internal
* Dump Rx descriptor info to a file.
*
* @param file
* A pointer to a file for output.
* @param dev
* Port (ethdev) handle.
* @param queue_id
* The selected queue.
* @param num
* The number of the descriptors to dump.
* @return
* Negative errno value on error, zero on success.

*/
typedef int (*eth_rx_hw_desc_dump_t)(FILE *file, const struct rte_eth_dev *dev,

									 uint16_t queue_id, uint16_t num);
Quoted 77 lines
Quoted 77 lines
Quoted 32 lines
Quoted 32 lines
lib/ethdev/ethdev_driver.h +22 -0
+ * @return
+ *   Negative errno value on error, zero on success.
+ */
+typedef int (*eth_rx_hw_desc_dump_t)(FILE *file, const struct
 rte_eth_dev *dev,
+                     uint16_t queue_id, uint16_t desc_id);
+
+/**
+ * @internal
+ * Dump ethdev Tx descriptor info to a file.
+ *
+ * @param file
+ *   A pointer to a file for output.
+ * @param dev
+ *   Port (ethdev) handle.
+ * @param queue_id
+ *   The selected queue.
+ * @param desc_id
+ *   The selected descriptor.
+ * @return
+ *   Negative errno value on error, zero on success.
+ */
+typedef int (*eth_tx_hw_desc_dump_t)(FILE *file, const struct

rte_eth_dev *dev,

lib/ethdev/ethdev_driver.h +2 -0
+                     uint16_t queue_id, uint16_t desc_id);
+
  /**
   * @internal A structure containing the functions exported by an

Ethernet driver.
*/

Quoted 8 lines

lib/ethdev/ethdev_driver.h struct eth_dev_ops { · line 1322

Quoted 5 lines
lib/ethdev/ethdev_driver.h +2 -0
@@ -1283,6 +1319,12 @@ struct eth_dev_ops {
        /** Dump private info from device */
      eth_dev_priv_dump_t eth_dev_priv_dump;
+
+    /** Dump ethdev Rx descriptor info */\\

It is an ethdev operations. So, 'ethdev' is not necessary in the description.

Will fix.

Quoted 20 lines
Quoted 20 lines
lib/ethdev/ethdev_driver.h +4 -0
+    eth_rx_hw_desc_dump_t eth_rx_hw_desc_dump;
+
+    /** Dump ethdev Tx descriptor info */
+    eth_tx_hw_desc_dump_t eth_tx_hw_desc_dump;
  };
    /**
lib/ethdev/rte_ethdev.c +2 -0
index 46c088dc88..bbd8439fa0 100644
@@ -5876,6 +5876,50 @@ rte_eth_dev_priv_dump(uint16_t port_id, FILE
 *file)
      return eth_err(port_id, (*dev->dev_ops->eth_dev_priv_dump)(dev,
 file));
  }
  +int
+rte_eth_rx_hw_desc_dump(FILE *file, uint16_t port_id, uint16_t
 queue_id,
+            uint16_t desc_id)
Quoted 8 lines

lib/ethdev/rte_ethdev.c rte_eth_dev_priv_dump(uint16_t port_id, FILE *file) · line 5887

Quoted 6 lines
lib/ethdev/rte_ethdev.c +6 -0
+{
+    struct rte_eth_dev *dev;
+    int ret;
+
+    RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+    dev = &rte_eth_devices[port_id];

Shouldn't we check file vs null?

Yes, will do.

Quoted 7 lines
Quoted 6 lines
lib/ethdev/rte_ethdev.c +5 -0
+
+    if (queue_id >= dev->data->nb_rx_queues) {
+        RTE_ETHDEV_LOG(ERR, "Invalid Rx queue_id=%u\n", queue_id);
+        return -EINVAL;
+    }
Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Don't we need a check vs queue size?

This need to be done in pmd as "[PATCH v3 3/4] net/hns3: support Rx/Tx bd dump" shows.

All applicable generic checks must be done on ethdev level to avoid code duplication and missing checks in PMDs.

The ethdev level does not know the queue size. This is similar to rte_eth_rx_descriptor_status(), queue size check is also done in PMDs.

Thanks,
Dongdong.

Quoted 4 lines

Andrew.
.

#23 lore raw

PATCH v3 2/4 net/hns3: rename hns3 dump files

In reply to Min Hu (Connor)

This patch rename hns3 dump files and abstract a head file for dump.

---
 .../net/hns3/{hns3_ethdev_dump.c => hns3_dump.c}    |  2 +-
 drivers/net/hns3/hns3_dump.h                        | 13 +++++++++++++
 drivers/net/hns3/hns3_ethdev.c                      |  1 +
 drivers/net/hns3/hns3_ethdev.h                      |  1 -
 drivers/net/hns3/hns3_ethdev_vf.c                   |  1 +
 drivers/net/hns3/meson.build                        |  2 +-
 6 files changed, 17 insertions(+), 3 deletions(-)
 rename drivers/net/hns3/{hns3_ethdev_dump.c => hns3_dump.c} (99%)
 create mode 100644 drivers/net/hns3/hns3_dump.h
drivers/net/hns3/hns3_dump.c renamed from drivers/net/hns3/hns3_ethdev_dump.c +1 -1
similarity index 99%
rename from drivers/net/hns3/hns3_ethdev_dump.c
rename to drivers/net/hns3/hns3_dump.c
index 1bb2ab7556..2cfab429af 100644
@@ -6,7 +6,7 @@
 #include "hns3_logs.h"
 #include "hns3_regs.h"
 #include "hns3_rxtx.h"
-#include "hns3_ethdev.h"
+#include "hns3_dump.h"
 
 static const char *
 get_adapter_state_name(enum hns3_adapter_state state)
drivers/net/hns3/hns3_dump.h new file +13 -0
new file mode 100644
index 0000000000..b0fe37ee21
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2022 HiSilicon Limited
+ */
+
+#ifndef _HNS3_DUMP_H_
+#define _HNS3_DUMP_H_
+
+#include <stdio.h>
+
+#include <ethdev_driver.h>
+
+int hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file);
+#endif /* _HNS3_DUMP_H_ */
drivers/net/hns3/hns3_ethdev.c +1 -0
index 0b565a5614..6fa07c4c94 100644
@@ -8,6 +8,7 @@
 
 #include "hns3_ethdev.h"
 #include "hns3_common.h"
+#include "hns3_dump.h"
 #include "hns3_logs.h"
 #include "hns3_rxtx.h"
 #include "hns3_intr.h"
drivers/net/hns3/hns3_ethdev.h +0 -1
index 5e8a746514..8de5a712f4 100644
@@ -1062,7 +1062,6 @@ 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_vf.c +1 -0
index 589de0ab3a..5fc6515de9 100644
@@ -10,6 +10,7 @@
 
 #include "hns3_ethdev.h"
 #include "hns3_common.h"
+#include "hns3_dump.h"
 #include "hns3_logs.h"
 #include "hns3_rxtx.h"
 #include "hns3_regs.h"
drivers/net/hns3/meson.build +1 -1
index f2aede94ed..dc99cb0209 100644
@@ -30,7 +30,7 @@ sources = files(
         'hns3_tm.c',
         'hns3_ptp.c',
         'hns3_common.c',
-        'hns3_ethdev_dump.c',
+        'hns3_dump.c',
 )
 
 deps += ['hash']
Signature · 1 line
2.33.0
#24 lore raw

PATCH v3 3/4 net/hns3: support Rx/Tx bd dump

In reply to Min Hu (Connor)

This patch support query HW descriptor from hns3 device. HW descriptor is also called BD(buffer description) which is shared memory between software and hardware.

---
 drivers/net/hns3/hns3_dump.c      | 64 +++++++++++++++++++++++++++++++
 drivers/net/hns3/hns3_dump.h      |  4 ++
 drivers/net/hns3/hns3_ethdev.c    |  2 +
 drivers/net/hns3/hns3_ethdev_vf.c |  2 +
 4 files changed, 72 insertions(+)
drivers/net/hns3/hns3_dump.c +64 -0
index 2cfab429af..74f687f0d7 100644
@@ -8,6 +8,9 @@
 #include "hns3_rxtx.h"
 #include "hns3_dump.h"
 
+#define HNS3_BD_DW_NUM 8
+#define HNS3_BD_ADDRESS_LAST_DW 2
+
 static const char *
 get_adapter_state_name(enum hns3_adapter_state state)
 {
@@ -911,3 +914,64 @@ hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file)
 
 	return 0;
 }
+
+int hns3_rx_hw_desc_dump(FILE *file, const struct rte_eth_dev *dev,
+			 uint16_t queue_id, uint16_t desc_id)
+{
+	struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct hns3_rx_queue *rxq = dev->data->rx_queues[queue_id];
+	uint32_t *bd_data;
+	int i;
+
+	if (desc_id >= rxq->nb_rx_desc) {
+		hns3_err(hw, "Invalid Rx BD id=%u\n", desc_id);
+		return -EINVAL;
+	}
+
+	bd_data = (uint32_t *)(&rxq->rx_ring[desc_id]);
+	fprintf(file, "Rx queue id:%u BD id:%u\n", queue_id, desc_id);
+	for (i = 0; i < HNS3_BD_DW_NUM; i++) {
+		/*
+		 * For the sake of security, first 8 bytes of BD which stands
+		 * for physical address of packet should not be shown.
+		 */
+		if (i < HNS3_BD_ADDRESS_LAST_DW) {
+			fprintf(file, "RX BD WORD[%d]:0x%08x\n", i, 0);
+			continue;
+		}
+		fprintf(file, "RX BD WORD[%d]:0x%08x\n", i, *(bd_data + i));
+	}
+
+	return 0;
+}
+
+int hns3_tx_hw_desc_dump(FILE *file, const struct rte_eth_dev *dev,
+			 uint16_t queue_id, uint16_t desc_id)
+{
+	struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct hns3_tx_queue *txq = dev->data->tx_queues[queue_id];
+	uint32_t *bd_data;
+	int i;
+
+	if (desc_id >= txq->nb_tx_desc) {
+		hns3_err(hw, "Invalid Tx BD id=%u\n", desc_id);
+		return -EINVAL;
+	}
+
+	bd_data = (uint32_t *)(&txq->tx_ring[desc_id]);
+	fprintf(file, "Tx queue id:%u BD id:%u\n", queue_id, desc_id);
+	for (i = 0; i < HNS3_BD_DW_NUM; i++) {
+		/*
+		 * For the sake of security, first 8 bytes of BD which stands
+		 * for physical address of packet should not be shown.
+		 */
+		if (i < HNS3_BD_ADDRESS_LAST_DW) {
+			fprintf(file, "TX BD WORD[%d]:0x%08x\n", i, 0);
+			continue;
+		}
+
+		fprintf(file, "Tx BD WORD[%d]:0x%08x\n", i, *(bd_data + i));
+	}
+
+	return 0;
+}
drivers/net/hns3/hns3_dump.h +4 -0
index b0fe37ee21..3dcd9a0466 100644
@@ -10,4 +10,8 @@
 #include <ethdev_driver.h>
 
 int hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file);
+int hns3_rx_hw_desc_dump(FILE *file, const struct rte_eth_dev *dev,
+			 uint16_t queue_id, uint16_t desc_id);
+int hns3_tx_hw_desc_dump(FILE *file, const struct rte_eth_dev *dev,
+			 uint16_t queue_id, uint16_t desc_id);
 #endif /* _HNS3_DUMP_H_ */
drivers/net/hns3/hns3_ethdev.c +2 -0
index 6fa07c4c94..ad5018f8a1 100644
@@ -6562,6 +6562,8 @@ static const struct eth_dev_ops hns3_eth_dev_ops = {
 	.timesync_read_time         = hns3_timesync_read_time,
 	.timesync_write_time        = hns3_timesync_write_time,
 	.eth_dev_priv_dump          = hns3_eth_dev_priv_dump,
+	.eth_rx_hw_desc_dump        = hns3_rx_hw_desc_dump,
+	.eth_tx_hw_desc_dump        = hns3_tx_hw_desc_dump,
 };
 
 static const struct hns3_reset_ops hns3_reset_ops = {
drivers/net/hns3/hns3_ethdev_vf.c +2 -0
index 5fc6515de9..26173442b2 100644
@@ -2288,6 +2288,8 @@ static const struct eth_dev_ops hns3vf_eth_dev_ops = {
 	.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,
+	.eth_rx_hw_desc_dump = hns3_rx_hw_desc_dump,
+	.eth_tx_hw_desc_dump = hns3_tx_hw_desc_dump,
 };
 
 static const struct hns3_reset_ops hns3vf_reset_ops = {
Signature · 1 line
2.33.0
#25 lore raw

PATCH v3 4/4 app/procinfo: support descriptor dump

In reply to Min Hu (Connor)

This patch support HW Rx/Tx descriptor dump

The command is like:
dpdk-proc-info -a xxxx:xx:xx.x --file-prefix=xxx -- -- --show-rx-descriptor queue_id:descriptor_id

dpdk-proc-info -a xxxx:xx:xx.x --file-prefix=xxx -- -- --show-tx-descriptor queue_id:descriptor_id

---
 app/proc-info/main.c | 81 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 81 insertions(+)
app/proc-info/main.c +81 -0
index 56070a3317..eab1b546d1 100644
@@ -48,6 +48,9 @@
 #define STATS_BDR_STR(w, s) printf("%.*s%s%.*s\n", w, \
 	STATS_BDR_FMT, s, w, STATS_BDR_FMT)
 
+typedef int (*desc_dump_t)(FILE *file, uint16_t port_id, uint16_t queue_id,
+			    uint16_t desc_id);
+
 /**< mask of enabled ports */
 static unsigned long enabled_port_mask;
 /**< Enable stats. */
@@ -100,6 +103,12 @@ static char *mempool_iter_name;
 /**< Enable dump regs. */
 static uint32_t enable_dump_regs;
 static char *dump_regs_file_prefix;
+/**< Enable dump buffer descriptor. */
+#define MAX_NB_ITEM 2
+static uint16_t rx_nb_item;
+static uint16_t tx_nb_item;
+static uint16_t rx_item_opt[MAX_NB_ITEM];
+static uint16_t tx_item_opt[MAX_NB_ITEM];
 
 /**< display usage */
 static void
@@ -127,6 +136,8 @@ proc_info_usage(const char *prgname)
 		"  --show-crypto: to display crypto information\n"
 		"  --show-ring[=name]: to display ring information\n"
 		"  --show-mempool[=name]: to display mempool information\n"
+		"  --show-rx-descriptor queue_id:descriptor_id: to display ports Rx buffer description by queue id and descriptor id\n"
+		"  --show-tx-descriptor queue_id:descriptor_id: to display ports Tx buffer description by queue id and descriptor id\n"
 		"  --iter-mempool=name: iterate mempool elements to display content\n"
 		"  --dump-regs=file-prefix: dump registers to file with the file-prefix\n",
 		prgname);
@@ -179,6 +190,34 @@ parse_xstats_ids(char *list, uint64_t *ids, int limit) {
 	return length;
 }
 
+/*
+ * Parse ids value list into array
+ */
+static int
+parse_descriptor_param(char *list, uint16_t *item_opt, int limit)
+{
+	int length;
+	char *token;
+	char *ctx = NULL;
+	char *endptr;
+
+	length = 0;
+	token = strtok_r(list, ":", &ctx);
+	while (token != NULL) {
+		item_opt[length] = strtoul(token, &endptr, 10);
+		if (*endptr != '\0')
+			return -EINVAL;
+
+		length++;
+		if (length > limit)
+			return -E2BIG;
+
+		token = strtok_r(NULL, ":", &ctx);
+	}
+
+	return length;
+}
+
 static int
 proc_info_preparse_args(int argc, char **argv)
 {
@@ -238,6 +277,8 @@ proc_info_parse_args(int argc, char **argv)
 		{"show-mempool", optional_argument, NULL, 0},
 		{"iter-mempool", required_argument, NULL, 0},
 		{"dump-regs", required_argument, NULL, 0},
+		{"show-rx-descriptor", required_argument, NULL, 1},
+		{"show-tx-descriptor", required_argument, NULL, 1},
 		{NULL, 0, 0, 0}
 	};
 
@@ -327,6 +368,26 @@ proc_info_parse_args(int argc, char **argv)
 					return -1;
 				}
 				nb_xstats_ids = ret;
+			} else if (!strncmp(long_option[option_index].name,
+				"show-rx-descriptor", MAX_LONG_OPT_SZ)) {
+				int ret = parse_descriptor_param(optarg,
+								 rx_item_opt,
+								 MAX_NB_ITEM);
+				if (ret < MAX_NB_ITEM) {
+					printf("Rx descriptor param parse error.\n");
+					return -1;
+				}
+				rx_nb_item = ret;
+			} else if (!strncmp(long_option[option_index].name,
+				"show-tx-descriptor", MAX_LONG_OPT_SZ)) {
+				int ret = parse_descriptor_param(optarg,
+								 tx_item_opt,
+								 MAX_NB_ITEM);
+				if (ret < MAX_NB_ITEM) {
+					printf("Tx descriptor param parse error.\n");
+					return -1;
+				}
+				tx_nb_item = ret;
 			}
 			break;
 		default:
@@ -1450,6 +1511,20 @@ dump_regs(char *file_prefix)
 	}
 }
 
+static void
+nic_descriptor_display(uint16_t port_id, uint16_t *item_opt,
+		       desc_dump_t desc_dump)
+{
+	static const char *nic_desc_border = "###";
+	uint16_t queue_id = item_opt[0];
+	uint16_t desc_id = item_opt[1];
+
+	printf("%s NIC descriptor for port %u %s\n",
+		   nic_desc_border, port_id, nic_desc_border);
+
+	desc_dump(stdout, port_id, queue_id, desc_id);
+}
+
 int
 main(int argc, char **argv)
 {
@@ -1533,6 +1608,12 @@ main(int argc, char **argv)
 		else if (nb_xstats_ids > 0)
 			nic_xstats_by_ids_display(i, xstats_ids,
 						  nb_xstats_ids);
+		else if (rx_nb_item > 0)
+			nic_descriptor_display(i, rx_item_opt,
+					       rte_eth_rx_hw_desc_dump);
+		else if (tx_nb_item > 0)
+			nic_descriptor_display(i, tx_item_opt,
+					       rte_eth_tx_hw_desc_dump);
 #ifdef RTE_LIB_METRICS
 		else if (enable_metrics)
 			metrics_display(i);
Signature · 1 line
2.33.0
#26 lore raw
In reply to Min Hu (Connor)

Again, please, add maintainers using --cc-cmd or --to-cmd to patches. Also, don't forget to keep in Cc participants of the discussion.

Quoted 29 lines · Min Hu (Connor)

This patch set support HW Rx/Tx descriptor dump by using procinfo tool.

Min Hu (Connor) (4):
ethdev: introduce ethdev HW desc dump PI
net/hns3: rename hns3 dump files
net/hns3: support Rx/Tx bd dump
app/procinfo: support descriptor dump

  app/proc-info/main.c                          | 81 +++++++++++++++++++
  doc/guides/rel_notes/release_22_07.rst        |  7 ++
  .../hns3/{hns3_ethdev_dump.c => hns3_dump.c}  | 66 ++++++++++++++-
  drivers/net/hns3/hns3_dump.h                  | 17 ++++
  drivers/net/hns3/hns3_ethdev.c                |  3 +
  drivers/net/hns3/hns3_ethdev.h                |  1 -
  drivers/net/hns3/hns3_ethdev_vf.c             |  3 +
  drivers/net/hns3/meson.build                  |  2 +-
  lib/ethdev/ethdev_driver.h                    | 42 ++++++++++
  lib/ethdev/rte_ethdev.c                       | 44 ++++++++++
  lib/ethdev/rte_ethdev.h                       | 44 ++++++++++
  lib/ethdev/version.map                        |  2 +
  12 files changed, 309 insertions(+), 3 deletions(-)

rename drivers/net/hns3/{hns3_ethdev_dump.c => hns3_dump.c} (93%) create mode 100644 drivers/net/hns3/hns3_dump.h
---
v3:
* fix desc id handling.

v2:
* add 'const' for ethdev.

#27 lore raw
Quoted 2 lines · Andrew Rybchenko

Again, please, add maintainers using --cc-cmd or --to-cmd to patches. Also, don't forget to keep in Cc participants of the discussion.

And you can add my Acked-by to 1/4.

Quoted 27 lines · Min Hu (Connor)
Quoted 26 lines

This patch set support HW Rx/Tx descriptor dump by using procinfo tool. Min Hu (Connor) (4):
ethdev: introduce ethdev HW desc dump PI
net/hns3: rename hns3 dump files
net/hns3: support Rx/Tx bd dump
app/procinfo: support descriptor dump

  app/proc-info/main.c                          | 81 +++++++++++++++++++
  doc/guides/rel_notes/release_22_07.rst        |  7 ++
  .../hns3/{hns3_ethdev_dump.c => hns3_dump.c}  | 66 ++++++++++++++-
  drivers/net/hns3/hns3_dump.h                  | 17 ++++
  drivers/net/hns3/hns3_ethdev.c                |  3 +
  drivers/net/hns3/hns3_ethdev.h                |  1 -
  drivers/net/hns3/hns3_ethdev_vf.c             |  3 +
  drivers/net/hns3/meson.build                  |  2 +-
  lib/ethdev/ethdev_driver.h                    | 42 ++++++++++
  lib/ethdev/rte_ethdev.c                       | 44 ++++++++++
  lib/ethdev/rte_ethdev.h                       | 44 ++++++++++
  lib/ethdev/version.map                        |  2 +
  12 files changed, 309 insertions(+), 3 deletions(-)

rename drivers/net/hns3/{hns3_ethdev_dump.c => hns3_dump.c} (93%) create mode 100644 drivers/net/hns3/hns3_dump.h
---
v3:
* fix desc id handling.
v2:
* add 'const' for ethdev.

Signature · 1 line
Regards, Ray K
#28 lore raw
Quoted 7 lines · Ray Kinsella
Quoted 2 lines · Andrew Rybchenko

Again, please, add maintainers using --cc-cmd or --to-cmd to patches. Also, don't forget to keep in Cc participants of the discussion.

And you can add my Acked-by to 1/4.

will do,

Thanks,
Dongdong

Quoted 30 lines
Quoted 28 lines · Min Hu (Connor)
Quoted 26 lines

This patch set support HW Rx/Tx descriptor dump by using procinfo tool. Min Hu (Connor) (4):
ethdev: introduce ethdev HW desc dump PI
net/hns3: rename hns3 dump files
net/hns3: support Rx/Tx bd dump
app/procinfo: support descriptor dump

  app/proc-info/main.c                          | 81 +++++++++++++++++++
  doc/guides/rel_notes/release_22_07.rst        |  7 ++
  .../hns3/{hns3_ethdev_dump.c => hns3_dump.c}  | 66 ++++++++++++++-
  drivers/net/hns3/hns3_dump.h                  | 17 ++++
  drivers/net/hns3/hns3_ethdev.c                |  3 +
  drivers/net/hns3/hns3_ethdev.h                |  1 -
  drivers/net/hns3/hns3_ethdev_vf.c             |  3 +
  drivers/net/hns3/meson.build                  |  2 +-
  lib/ethdev/ethdev_driver.h                    | 42 ++++++++++
  lib/ethdev/rte_ethdev.c                       | 44 ++++++++++
  lib/ethdev/rte_ethdev.h                       | 44 ++++++++++
  lib/ethdev/version.map                        |  2 +
  12 files changed, 309 insertions(+), 3 deletions(-)

rename drivers/net/hns3/{hns3_ethdev_dump.c => hns3_dump.c} (93%) create mode 100644 drivers/net/hns3/hns3_dump.h
---
v3:
* fix desc id handling.
v2:
* add 'const' for ethdev.

#29 lore raw
In reply to Andrew Rybchenko
Quoted 5 lines · Andrew Rybchenko

Again, please, add maintainers using --cc-cmd or --to-cmd to patches. Also, don't forget to keep in Cc participants of the discussion.

Quoted 1 line · Min Hu (Connor)

This patch set support HW Rx/Tx descriptor dump by using procinfo tool.

One more thing. I'd remove HW from the description. Format is undefined and driver can log any kind of information related to particular descriptor.
Just highlight that the dupmp format is vendor-specific.

Quoted 29 lines
Quoted 28 lines

Min Hu (Connor) (4):
   ethdev: introduce ethdev HW desc dump PI
   net/hns3: rename hns3 dump files
   net/hns3: support Rx/Tx bd dump
   app/procinfo: support descriptor dump

  app/proc-info/main.c                          | 81 +++++++++++++++++++ doc/guides/rel_notes/release_22_07.rst        |  7 ++ .../hns3/{hns3_ethdev_dump.c => hns3_dump.c}  | 66 ++++++++++++++- drivers/net/hns3/hns3_dump.h                  | 17 ++++ drivers/net/hns3/hns3_ethdev.c                |  3 + drivers/net/hns3/hns3_ethdev.h                |  1 - drivers/net/hns3/hns3_ethdev_vf.c             |  3 + drivers/net/hns3/meson.build                  |  2 +- lib/ethdev/ethdev_driver.h                    | 42 ++++++++++ lib/ethdev/rte_ethdev.c                       | 44 ++++++++++ lib/ethdev/rte_ethdev.h                       | 44 ++++++++++ lib/ethdev/version.map                        |  2 +

  12 files changed, 309 insertions(+), 3 deletions(-)

  rename drivers/net/hns3/{hns3_ethdev_dump.c => hns3_dump.c} (93%) create mode 100644 drivers/net/hns3/hns3_dump.h
---
v3:
* fix desc id handling.

v2:
* add 'const' for ethdev.

#30 lore raw
In reply to Andrew Rybchenko

Hi Andrew

Quoted 2 lines · Andrew Rybchenko

Again, please, add maintainers using --cc-cmd or --to-cmd to patches. Also, don't forget to keep in Cc participants of the discussion.

Thanks for remind this, will do.

Thanks,
Dongdong

Quoted 34 lines · Min Hu (Connor)
Quoted 21 lines

This patch set support HW Rx/Tx descriptor dump by using procinfo tool.

Min Hu (Connor) (4):
ethdev: introduce ethdev HW desc dump PI
net/hns3: rename hns3 dump files
net/hns3: support Rx/Tx bd dump
app/procinfo: support descriptor dump

  app/proc-info/main.c                          | 81 +++++++++++++++++++
  doc/guides/rel_notes/release_22_07.rst        |  7 ++
  .../hns3/{hns3_ethdev_dump.c => hns3_dump.c}  | 66 ++++++++++++++-
  drivers/net/hns3/hns3_dump.h                  | 17 ++++
  drivers/net/hns3/hns3_ethdev.c                |  3 +
  drivers/net/hns3/hns3_ethdev.h                |  1 -
  drivers/net/hns3/hns3_ethdev_vf.c             |  3 +
  drivers/net/hns3/meson.build                  |  2 +-
  lib/ethdev/ethdev_driver.h                    | 42 ++++++++++
  lib/ethdev/rte_ethdev.c                       | 44 ++++++++++
  lib/ethdev/rte_ethdev.h                       | 44 ++++++++++
  lib/ethdev/version.map                        |  2 +
  12 files changed, 309 insertions(+), 3 deletions(-)
Quoted 8 lines

rename drivers/net/hns3/{hns3_ethdev_dump.c => hns3_dump.c} (93%) create mode 100644 drivers/net/hns3/hns3_dump.h
---
v3:
* fix desc id handling.

v2:
* add 'const' for ethdev.

.

#31 lore raw

v4 cover support ethdev Rx/Tx descriptor dump

In reply to Min Hu (Connor)

Support ethdev Rx/Tx descriptor dump by using procinfo tool.

Note:
'[PATCH v4 1/3] net/hns3: support Rx/Tx bd dump' depend on [1] applied first. Hope patchset [1] can be applied soon.

[1]: [PATCH RESEND 00/13] some bugfixes and clean code for hns3
https://patches.dpdk.org/project/dpdk/list/?series=24533

v3->v4:
1. Modify the desc dump API to dump specified number of descriptors.
2. Modify the hn3 pmd implementation and procinfo part.

Min Hu (Connor) (3):
ethdev: introduce ethdev desc dump API
net/hns3: support Rx/Tx bd dump
app/procinfo: support descriptor dump

 app/proc-info/main.c                   | 80 ++++++++++++++++++++++++++
 doc/guides/rel_notes/release_22_11.rst |  7 +++
 drivers/net/hns3/hns3_dump.c           | 80 ++++++++++++++++++++++++++
 drivers/net/hns3/hns3_dump.h           |  5 ++
 drivers/net/hns3/hns3_ethdev.c         |  2 +
 drivers/net/hns3/hns3_ethdev_vf.c      |  2 +
 lib/ethdev/ethdev_driver.h             | 46 +++++++++++++++
 lib/ethdev/rte_ethdev.c                | 52 +++++++++++++++++
 lib/ethdev/rte_ethdev.h                | 49 ++++++++++++++++
 lib/ethdev/version.map                 |  2 +
 10 files changed, 325 insertions(+)

--
2.22.0

#32 lore raw

PATCH v4 1/3 ethdev: introduce ethdev desc dump API

From: "Min Hu (Connor)" <[email protected]>

Added the ethdev Rx/Tx desc dump API which provides functions for query descriptor from device. HW descriptor info differs in different NICs. The information demonstrates I/O process which is important for debug. As the information is different between NICs, the new API is introduced.

---
 doc/guides/rel_notes/release_22_11.rst |  7 ++++
 lib/ethdev/ethdev_driver.h             | 46 +++++++++++++++++++++++
 lib/ethdev/rte_ethdev.c                | 52 ++++++++++++++++++++++++++
 lib/ethdev/rte_ethdev.h                | 49 ++++++++++++++++++++++++
 lib/ethdev/version.map                 |  2 +
 5 files changed, 156 insertions(+)
doc/guides/rel_notes/release_22_11.rst +7 -0
index f60161765b..d3f3f2e50c 100644
@@ -55,6 +55,13 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Added ethdev desc dump API, to dump Rx/Tx desc info from device.**
+
+Added the ethdev Rx/Tx desc dump API which provides functions for query
+descriptor from device. The descriptor info differs in different NICs.
+The information demonstrates I/O process which is important for debug.
+As the information is different between NICs, the new API is introduced.
+The dump format is vendor-specific.
 
 Removed Items
 -------------
lib/ethdev/ethdev_driver.h +46 -0

58 lines not on this page · raw message

lib/ethdev/rte_ethdev.c +52 -0

58 lines not on this page · raw message

lib/ethdev/rte_ethdev.h +49 -0

55 lines not on this page · raw message

lib/ethdev/version.map +2 -0
index 03f52fee91..3c7c75b582 100644
@@ -285,6 +285,8 @@ EXPERIMENTAL {
 	rte_mtr_color_in_protocol_priority_get;
 	rte_mtr_color_in_protocol_set;
 	rte_mtr_meter_vlan_table_update;
+	rte_eth_rx_hw_desc_dump;
+	rte_eth_tx_hw_desc_dump;
 };
 
 INTERNAL {
Signature · 1 line
2.22.0
#33 lore raw

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

Quoted 7 lines · Dongdong Liu

From: "Min Hu (Connor)" <[email protected]>

Added the ethdev Rx/Tx desc dump API which provides functions for query descriptor from device. HW descriptor info differs in different NICs. The information demonstrates I/O process which is important for debug. As the information is different

Overall OK to have these new APIs, please find comments below.

Do you think does it worth to list this as one of the PMD future in future list, in 'doc/guides/nics/features.rst' ?

between NICs, the new API is introduced.

Quoted 4 lines

<...>

Quoted 15 lines
  int rte_eth_dev_priv_dump(uint16_t port_id, FILE *file);
lib/ethdev/rte_ethdev.h +13 -0
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Dump ethdev Rx descriptor info to a file.
+ *
+ * This API is used for debugging, not a dataplane API.
+ *
+ * @param file
+ *   A pointer to a file for output.
+ * @param dev
+ *   Port (ethdev) handle.
+ * @param queue_id

lib/ethdev/rte_ethdev.h typedef struct { · line 5246

Quoted 10 lines
lib/ethdev/rte_ethdev.h +10 -0
+ *   The selected queue.
+ * @param num
+ *   The number of the descriptors to dump.
+ * @return
+ *   - On success, zero.
+ *   - On failure, a negative value.
+ */
+__rte_experimental
+int rte_eth_rx_hw_desc_dump(FILE *file, uint16_t port_id, uint16_t queue_id,
+                           uint16_t num);

There are other HW desc related APIs, like 'rte_eth_rx_descriptor_status()'. Should this APIs follow same naming convention:
'rte_eth_rx_descriptor_dump()'
'rte_eth_tx_descriptor_dump()'

Quoted 14 lines
lib/ethdev/rte_ethdev.h +14 -0
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Dump ethdev Tx descriptor info to a file.
+ *
+ * This API is used for debugging, not a dataplane API.
+ *
+ * @param file
+ *   A pointer to a file for output.
+ * @param dev
+ *   Port (ethdev) handle.
+ * @param queue_id

lib/ethdev/rte_ethdev.h typedef struct { · line 5270

Quoted 10 lines
lib/ethdev/rte_ethdev.h +10 -0
+ *   The selected queue.
+ * @param num
+ *   The number of the descriptors to dump.
+ * @return
+ *   - On success, zero.
+ *   - On failure, a negative value.
+ */
+__rte_experimental
+int rte_eth_tx_hw_desc_dump(FILE *file, uint16_t port_id, uint16_t queue_id,
+                           uint16_t num);

'num' is provided, does it assume it starts from offset 0, what do you think to provide 'offset' as parameter? It may be a use case to start from where tail/head pointer is.

Quoted 10 lines
lib/ethdev/rte_ethdev.h +2 -0
+
+
  #include <rte_ethdev_core.h>
 
  /**
lib/ethdev/version.map +0 -0
index 03f52fee91..3c7c75b582 100644

lib/ethdev/version.map EXPERIMENTAL { · line 289

Quoted 5 lines
lib/ethdev/version.map +2 -0
@@ -285,6 +285,8 @@ EXPERIMENTAL {
         rte_mtr_color_in_protocol_priority_get;
         rte_mtr_color_in_protocol_set;
         rte_mtr_meter_vlan_table_update;
+       rte_eth_rx_hw_desc_dump;
+       rte_eth_tx_hw_desc_dump;

These new APIs should go after "# added in 22.11" comment, if you rebase on top of latest HEAD, comment is already there.

#34 lore raw

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

Quoted 5 lines · Ferruh Yigit
Quoted 3 lines · Dongdong Liu

From: "Min Hu (Connor)" <[email protected]>

Quoted 8 lines
Quoted 4 lines

Added the ethdev Rx/Tx desc dump API which provides functions for query descriptor from device. HW descriptor info differs in different NICs. The information demonstrates I/O process which is important for debug. As the information is different

Overall OK to have these new APIs, please find comments below.

Do you think does it worth to list this as one of the PMD future in future list, in 'doc/guides/nics/features.rst' ?

IMHO it does not deserve entry in features.
It is a deep debugging using vendor-specific information.

Quoted 33 lines

 between NICs, the new API is introduced.

Quoted 4 lines

<...>

Quoted 24 lines

  int rte_eth_dev_priv_dump(uint16_t port_id, FILE *file);

+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Dump ethdev Rx descriptor info to a file.
+ *
+ * This API is used for debugging, not a dataplane API.
+ *
+ * @param file
+ *   A pointer to a file for output.
+ * @param dev
+ *   Port (ethdev) handle.
+ * @param queue_id
+ *   The selected queue.
+ * @param num
+ *   The number of the descriptors to dump.
+ * @return
+ *   - On success, zero.
+ *   - On failure, a negative value.
+ */
+__rte_experimental

Quoted 8 lines
Quoted 3 lines

+int rte_eth_rx_hw_desc_dump(FILE *file, uint16_t port_id, uint16_t queue_id,
+                           uint16_t num);

There are other HW desc related APIs, like 'rte_eth_rx_descriptor_status()'. Should this APIs follow same naming convention:
'rte_eth_rx_descriptor_dump()'
'rte_eth_tx_descriptor_dump()'

+1 on naming, it should not be bound to HW. SW parts could be interesting as well.

Quoted 49 lines
Quoted 25 lines
lib/ethdev/rte_ethdev.h +4 -0
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior 

notice
+ *
+ * Dump ethdev Tx descriptor info to a file.
+ *
+ * This API is used for debugging, not a dataplane API.
+ *
+ * @param file
+ *   A pointer to a file for output.
+ * @param dev
+ *   Port (ethdev) handle.
+ * @param queue_id
+ *   The selected queue.
+ * @param num
+ *   The number of the descriptors to dump.
+ * @return
+ *   - On success, zero.
+ *   - On failure, a negative value.
+ */

(quoted diff) +2 -0
+__rte_experimental
+int rte_eth_tx_hw_desc_dump(FILE *file, uint16_t port_id, uint16_t 
Quoted 2 lines

queue_id,
+                           uint16_t num);

'num' is provided, does it assume it starts from offset 0, what do you think to provide 'offset' as parameter? It may be a use case to start from where tail/head pointer is.

Quoted 10 lines
(quoted diff) +2 -0
+
+

  #include <rte_ethdev_core.h>

  /**

lib/ethdev/version.map +0 -0
index 03f52fee91..3c7c75b582 100644

lib/ethdev/version.map EXPERIMENTAL { · line 289

Quoted 5 lines
lib/ethdev/version.map +2 -0
@@ -285,6 +285,8 @@ EXPERIMENTAL {
          rte_mtr_color_in_protocol_priority_get;
          rte_mtr_color_in_protocol_set;
          rte_mtr_meter_vlan_table_update;
+       rte_eth_rx_hw_desc_dump;
+       rte_eth_tx_hw_desc_dump;

These new APIs should go after "# added in 22.11" comment, if you rebase on top of latest HEAD, comment is already there.

#35 lore raw

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

In reply to Ferruh Yigit

Hi Ferruh

Many thanks for your review.

Quoted 10 lines · Ferruh Yigit
Quoted 7 lines · Dongdong Liu

From: "Min Hu (Connor)" <[email protected]>

Added the ethdev Rx/Tx desc dump API which provides functions for query descriptor from device. HW descriptor info differs in different NICs. The information demonstrates I/O process which is important for debug. As the information is different

Quoted 4 lines

Overall OK to have these new APIs, please find comments below.

Do you think does it worth to list this as one of the PMD future in future list, in 'doc/guides/nics/features.rst' ?

As Andrew said
It does not deserve entry in features.
It is a deep debugging using vendor-specific information.

I agree with him.

Quoted 34 lines

between NICs, the new API is introduced.

Quoted 4 lines

<...>

Quoted 25 lines
  int rte_eth_dev_priv_dump(uint16_t port_id, FILE *file);

+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Dump ethdev Rx descriptor info to a file.
+ *
+ * This API is used for debugging, not a dataplane API.
+ *
+ * @param file
+ * A pointer to a file for output.
+ * @param dev
+ * Port (ethdev) handle.
+ * @param queue_id
+ * The selected queue.
+ * @param num
+ * The number of the descriptors to dump.
+ * @return
+ * - On success, zero.
+ * - On failure, a negative value.
+ */

(quoted diff) +2 -0
+__rte_experimental
+int rte_eth_rx_hw_desc_dump(FILE *file, uint16_t port_id, uint16_t
Quoted 8 lines
Quoted 2 lines

queue_id,
+ uint16_t num);

There are other HW desc related APIs, like
'rte_eth_rx_descriptor_status()'.
Should this APIs follow same naming convention:
'rte_eth_rx_descriptor_dump()'
'rte_eth_tx_descriptor_dump()'

Looks good, will do.

Quoted 23 lines
Quoted 23 lines
lib/ethdev/rte_ethdev.h +4 -0
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior

notice
+ *
+ * Dump ethdev Tx descriptor info to a file.
+ *
+ * This API is used for debugging, not a dataplane API.
+ *
+ * @param file
+ * A pointer to a file for output.
+ * @param dev
+ * Port (ethdev) handle.
+ * @param queue_id
+ * The selected queue.
+ * @param num
+ * The number of the descriptors to dump.
+ * @return
+ * - On success, zero.
+ * - On failure, a negative value.
+ */

Quoted 8 lines
Quoted 4 lines
(quoted diff) +2 -0
+__rte_experimental
+int rte_eth_tx_hw_desc_dump(FILE *file, uint16_t port_id, uint16_t

queue_id,
+ uint16_t num);

'num' is provided, does it assume it starts from offset 0, what do you think to provide 'offset' as parameter?
It may be a use case to start from where tail/head pointer is.

It will be ok to provide 'offset' as parameter. will change as below.

/**
* @warning
* @b EXPERIMENTAL: this API may change, or be removed, without prior
notice
*
* Dump ethdev Rx descriptor info to a file.

*
* This API is used for debugging, not a dataplane API. *
* @param port_id
* The port identifier of the Ethernet device.
* @param queue_id
* A Rx queue identifier on this port.
* @param offset
* The offset of the descriptor starting from tail. (0 is the next
* packet to be received by the driver).
* @param num
* The number of the descriptors to dump.
* @param file
* A pointer to a file for output.
* @return
* - On success, zero.
* - On failure, a negative value.
*/
__rte_experimental
int rte_eth_rx_descriptor_dump(uint16_t port_id, uint16_t queue_id,

                               uint16_t offset, uint16_t num, FILE *file);
Quoted 5 lines
Quoted 5 lines
lib/ethdev/rte_ethdev.h +2 -0
+
+
  #include <rte_ethdev_core.h>
Quoted 14 lines

lib/ethdev/version.map EXPERIMENTAL { · line 289

Quoted 11 lines

/**

lib/ethdev/version.map +2 -0
index 03f52fee91..3c7c75b582 100644
@@ -285,6 +285,8 @@ EXPERIMENTAL {
         rte_mtr_color_in_protocol_priority_get;
         rte_mtr_color_in_protocol_set;
         rte_mtr_meter_vlan_table_update;
+       rte_eth_rx_hw_desc_dump;
+       rte_eth_tx_hw_desc_dump;

These new APIs should go after "# added in 22.11" comment, if you rebase on top of latest HEAD, comment is already there.

Will rebase on top of latest HEAD.

Thanks,
Dongdong

Quoted 3 lines

.

#36 lore raw

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

Quoted 7 lines · On Thu, 6 Oct 2022 16:26:24 +0800 Dongdong Liu <[email protected]> wrote:
Quoted 2 lines

Do you think does it worth to list this as one of the PMD future in future list, in 'doc/guides/nics/features.rst' ?

As Andrew said
It does not deserve entry in features.
It is a deep debugging using vendor-specific information.

I agree with him.

This should never be a stable API either. Format may change.

#37 lore raw

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

Quoted 5 lines · Stephen Hemminger
Quoted 2 lines · On Thu, 6 Oct 2022 16:26:24 +0800 Dongdong Liu <[email protected]> wrote:
Quoted 2 lines

Do you think does it worth to list this as one of the PMD future in future list, in 'doc/guides/nics/features.rst' ?

Quoted 7 lines
Quoted 5 lines

As Andrew said
It does not deserve entry in features.
It is a deep debugging using vendor-specific information.

I agree with him.

This should never be a stable API either. Format may change.

Format is not defined in the API, it is vendor specific. But the API itself can be stable I think, after we have more PMDs implement it.

#38 lore raw

PATCH v4 2/3 net/hns3: support Rx/Tx bd dump

In reply to Dongdong Liu

From: "Min Hu (Connor)" <[email protected]>

This patch support query HW descriptor from hns3 device. HW descriptor is also called BD(buffer description) which is shared memory between software and hardware.

---
 drivers/net/hns3/hns3_dump.c      | 80 +++++++++++++++++++++++++++++++
 drivers/net/hns3/hns3_dump.h      |  5 ++
 drivers/net/hns3/hns3_ethdev.c    |  2 +
 drivers/net/hns3/hns3_ethdev_vf.c |  2 +
 4 files changed, 89 insertions(+)
drivers/net/hns3/hns3_dump.c +80 -0
index 95b64f8896..ce26e5b65f 100644
@@ -10,6 +10,9 @@
 #include "hns3_rxtx.h"
 #include "hns3_dump.h"
 
+#define HNS3_BD_DW_NUM 8
+#define HNS3_BD_ADDRESS_LAST_DW 2
+
 static const char *
 hns3_get_adapter_state_name(enum hns3_adapter_state state)
 {
@@ -931,3 +934,80 @@ hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file)
 
 	return 0;
 }
+
+int hns3_rx_hw_desc_dump(FILE *file, const struct rte_eth_dev *dev,
+			 uint16_t queue_id, uint16_t num)
+{
+	struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct hns3_rx_queue *rxq = dev->data->rx_queues[queue_id];
+	uint32_t *bd_data;
+	uint16_t count = 0;
+	uint16_t desc_id;
+	int i;
+
+	if (num > rxq->nb_rx_desc) {
+		hns3_err(hw, "Invalid BD num=%u\n", num);
+		return -EINVAL;
+	}
+
+	while (count < num) {
+		desc_id = (rxq->next_to_use + count) % rxq->nb_rx_desc;
+		bd_data = (uint32_t *)(&rxq->rx_ring[desc_id]);
+		fprintf(file, "Rx queue id:%u BD id:%u\n", queue_id, desc_id);
+		for (i = 0; i < HNS3_BD_DW_NUM; i++) {
+			/*
+			 * For the sake of security, first 8 bytes of BD which
+			 * stands for physical address of packet should not be
+			 * shown.
+			 */
+			if (i < HNS3_BD_ADDRESS_LAST_DW) {
+				fprintf(file, "RX BD WORD[%d]:0x%08x\n", i, 0);
+				continue;
+			}
+			fprintf(file, "RX BD WORD[%d]:0x%08x\n", i,
+				*(bd_data + i));
+		}
+		count++;
+	}
+
+	return 0;
+}
+
+int hns3_tx_hw_desc_dump(FILE *file, const struct rte_eth_dev *dev,
+			 uint16_t queue_id, uint16_t num)
+{
+	struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct hns3_tx_queue *txq = dev->data->tx_queues[queue_id];
+	uint32_t *bd_data;
+	uint16_t count = 0;
+	uint16_t desc_id;
+	int i;
+
+	if (num > txq->nb_tx_desc) {
+		hns3_err(hw, "Invalid BD num=%u\n", num);
+		return -EINVAL;
+	}
+
+	while (count < num) {
+		desc_id = (txq->next_to_use + count) % txq->nb_tx_desc;
+		bd_data = (uint32_t *)(&txq->tx_ring[desc_id]);
+		fprintf(file, "Tx queue id:%u BD id:%u\n", queue_id, desc_id);
+		for (i = 0; i < HNS3_BD_DW_NUM; i++) {
+			/*
+			 * For the sake of security, first 8 bytes of BD which
+			 * stands for physical address of packet should not be
+			 * shown.
+			 */
+			if (i < HNS3_BD_ADDRESS_LAST_DW) {
+				fprintf(file, "TX BD WORD[%d]:0x%08x\n", i, 0);
+				continue;
+			}
+
+			fprintf(file, "Tx BD WORD[%d]:0x%08x\n", i,
+				*(bd_data + i));
+		}
+		count++;
+	}
+
+	return 0;
+}
drivers/net/hns3/hns3_dump.h +5 -0
index b0fe37ee21..f92d8af880 100644
@@ -10,4 +10,9 @@
 #include <ethdev_driver.h>
 
 int hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file);
+
+int hns3_rx_hw_desc_dump(FILE *file, const struct rte_eth_dev *dev,
+			 uint16_t queue_id, uint16_t num);
+int hns3_tx_hw_desc_dump(FILE *file, const struct rte_eth_dev *dev,
+			 uint16_t queue_id, uint16_t num);
 #endif /* _HNS3_DUMP_H_ */
drivers/net/hns3/hns3_ethdev.c +2 -0
index 7cd1ff53e8..43a604c0fd 100644
@@ -6567,6 +6567,8 @@ static const struct eth_dev_ops hns3_eth_dev_ops = {
 	.timesync_read_time         = hns3_timesync_read_time,
 	.timesync_write_time        = hns3_timesync_write_time,
 	.eth_dev_priv_dump          = hns3_eth_dev_priv_dump,
+	.eth_rx_hw_desc_dump        = hns3_rx_hw_desc_dump,
+	.eth_tx_hw_desc_dump        = hns3_tx_hw_desc_dump,
 };
 
 static const struct hns3_reset_ops hns3_reset_ops = {
drivers/net/hns3/hns3_ethdev_vf.c +2 -0
index a72535eb7d..b1997c42f4 100644
@@ -2308,6 +2308,8 @@ static const struct eth_dev_ops hns3vf_eth_dev_ops = {
 	.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,
+	.eth_rx_hw_desc_dump = hns3_rx_hw_desc_dump,
+	.eth_tx_hw_desc_dump = hns3_tx_hw_desc_dump,
 };
 
 static const struct hns3_reset_ops hns3vf_reset_ops = {
Signature · 1 line
2.22.0
#39 lore raw

PATCH v4 3/3 app/procinfo: support descriptor dump

In reply to Dongdong Liu

From: "Min Hu (Connor)" <[email protected]>

This patch support HW Rx/Tx descriptor dump

The command is like:
dpdk-proc-info -a xxxx:xx:xx.x --file-prefix=xxx -- -- --show-rx-descriptor queue_id:num

dpdk-proc-info -a xxxx:xx:xx.x --file-prefix=xxx -- -- --show-tx-descriptor queue_id:num

---
 app/proc-info/main.c | 80 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 80 insertions(+)
app/proc-info/main.c +80 -0
index 1bfba5f60d..3907af3213 100644
@@ -48,6 +48,9 @@
 #define STATS_BDR_STR(w, s) printf("%.*s%s%.*s\n", w, \
 	STATS_BDR_FMT, s, w, STATS_BDR_FMT)
 
+typedef int (*desc_dump_t)(FILE *file, uint16_t port_id, uint16_t queue_id,
+			   uint16_t num);
+
 /**< mask of enabled ports */
 static unsigned long enabled_port_mask;
 /**< Enable stats. */
@@ -102,6 +105,12 @@ static char *mempool_iter_name;
 /**< Enable dump regs. */
 static uint32_t enable_dump_regs;
 static char *dump_regs_file_prefix;
+/* Enable dump buffer descriptor. */
+#define MAX_NB_ITEM 2
+static uint16_t rx_nb_item;
+static uint16_t tx_nb_item;
+static uint16_t rx_item_opt[MAX_NB_ITEM];
+static uint16_t tx_item_opt[MAX_NB_ITEM];
 
 /**< display usage */
 static void
@@ -130,6 +139,8 @@ proc_info_usage(const char *prgname)
 		"  --show-crypto: to display crypto information\n"
 		"  --show-ring[=name]: to display ring information\n"
 		"  --show-mempool[=name]: to display mempool information\n"
+		"  --show-rx-descriptor queue_id:num: to display ports Rx buffer description by queue id and num\n"
+		"  --show-tx-descriptor queue_id:num: to display ports Tx buffer description by queue id and num\n"
 		"  --iter-mempool=name: iterate mempool elements to display content\n"
 		"  --dump-regs=file-prefix: dump registers to file with the file-prefix\n",
 		prgname);
@@ -182,6 +193,34 @@ parse_xstats_ids(char *list, uint64_t *ids, int limit) {
 	return length;
 }
 
+/*
+ * Parse ids value list into array
+ */
+static int
+parse_descriptor_param(char *list, uint16_t *item_opt, int limit)
+{
+	int length;
+	char *token;
+	char *ctx = NULL;
+	char *endptr;
+
+	length = 0;
+	token = strtok_r(list, ":", &ctx);
+	while (token != NULL) {
+		item_opt[length] = strtoul(token, &endptr, 10);
+		if (*endptr != '\0')
+			return -EINVAL;
+
+		length++;
+		if (length > limit)
+			return -E2BIG;
+
+		token = strtok_r(NULL, ":", &ctx);
+	}
+
+	return length;
+}
+
 static int
 proc_info_preparse_args(int argc, char **argv)
 {
@@ -242,6 +281,8 @@ proc_info_parse_args(int argc, char **argv)
 		{"show-mempool", optional_argument, NULL, 0},
 		{"iter-mempool", required_argument, NULL, 0},
 		{"dump-regs", required_argument, NULL, 0},
+		{"show-rx-descriptor", required_argument, NULL, 1},
+		{"show-tx-descriptor", required_argument, NULL, 1},
 		{NULL, 0, 0, 0}
 	};
 
@@ -334,6 +375,26 @@ proc_info_parse_args(int argc, char **argv)
 					return -1;
 				}
 				nb_xstats_ids = ret;
+			} else if (!strncmp(long_option[option_index].name,
+				"show-rx-descriptor", MAX_LONG_OPT_SZ)) {
+				int ret = parse_descriptor_param(optarg,
+								 rx_item_opt,
+								 MAX_NB_ITEM);
+				if (ret < MAX_NB_ITEM) {
+					printf("Rx descriptor param parse error.\n");
+					return -1;
+				}
+				rx_nb_item = ret;
+			} else if (!strncmp(long_option[option_index].name,
+				"show-tx-descriptor", MAX_LONG_OPT_SZ)) {
+				int ret = parse_descriptor_param(optarg,
+								 tx_item_opt,
+								 MAX_NB_ITEM);
+				if (ret < MAX_NB_ITEM) {
+					printf("Tx descriptor param parse error.\n");
+					return -1;
+				}
+				tx_nb_item = ret;
 			}
 			break;
 		default:
@@ -1476,6 +1537,19 @@ dump_regs(char *file_prefix)
 	}
 }
 
+static void
+nic_descriptor_display(uint16_t port_id, uint16_t *item_opt,
+		       desc_dump_t desc_dump)
+{
+	static const char *nic_desc_border = "###";
+	uint16_t queue_id = item_opt[0];
+	uint16_t num = item_opt[1];
+
+	printf("%s NIC descriptor for port %u %s\n",
+		   nic_desc_border, port_id, nic_desc_border);
+
+	desc_dump(stdout, port_id, queue_id, num);
+}
 int
 main(int argc, char **argv)
 {
@@ -1559,6 +1633,12 @@ main(int argc, char **argv)
 		else if (nb_xstats_ids > 0)
 			nic_xstats_by_ids_display(i, xstats_ids,
 						  nb_xstats_ids);
+		else if (rx_nb_item > 0)
+			nic_descriptor_display(i, rx_item_opt,
+					       rte_eth_rx_hw_desc_dump);
+		else if (tx_nb_item > 0)
+			nic_descriptor_display(i, tx_item_opt,
+					       rte_eth_tx_hw_desc_dump);
 #ifdef RTE_LIB_METRICS
 		else if (enable_metrics)
 			metrics_display(i);
Signature · 1 line
2.22.0
#40 lore raw

RE: [PATCH v4 3/3] app/procinfo: support descriptor dump

Quoted 6 lines

-----Original Message-----
From: Dongdong Liu <[email protected]>
Subject: [PATCH v4 3/3] app/procinfo: support descriptor dump

Quoted 7 lines

From: "Min Hu (Connor)" <[email protected]>

This patch support HW Rx/Tx descriptor dump

The command is like:
dpdk-proc-info -a xxxx:xx:xx.x --file-prefix=xxx -- -- --show-rx-descriptor queue_id:num

What is num here? You need to describe about this in commit message. Is num means number of descriptors? Better use the descriptor word here in num

Quoted 3 lines

dpdk-proc-info -a xxxx:xx:xx.x --file-prefix=xxx -- -- --show-tx-descriptor queue_id:num

Same here.

app/proc-info/main.c static char *mempool_iter_name;

Quoted 5 lines
app/proc-info/main.c +5 -0
+/* Enable dump buffer descriptor. */
+#define MAX_NB_ITEM 2
+static uint16_t rx_nb_item;
+static uint16_t tx_nb_item;
+static uint16_t rx_item_opt[MAX_NB_ITEM]; static uint16_t

Instead of using array to keep queid and number of descriptors info , better have structure with 2 parameters one for queue and one for the number of descriptors. And You can use the same structure to declare tx_item.

Quoted 7 lines
(quoted diff) +2 -0
+tx_item_opt[MAX_NB_ITEM];
 
 
+		"  --show-rx-descriptor queue_id:num: to display ports Rx

buffer description by queue id and num\n"

(quoted diff) +1 -0
+		"  --show-tx-descriptor queue_id:num: to display ports Tx

buffer description by queue id and num\n"

Here also use enough description what is num means or use the another name.

Review

Quoted 1 line
(quoted diff) +1 -0
+				if (ret < MAX_NB_ITEM) {

You can check ret < 0 no need to use MAX_NB_ITEM again.

app/proc-info/main.c proc_info_parse_args(int argc, char **argv) · line 386

Quoted 3 lines
app/proc-info/main.c +3 -0
+					printf("Rx descriptor param parse error.\n");
+					return -1;
+				}

Instead of saying parse error. You might need to give clear reason of failure. That is invalid queueid:num passed by user or user passed more than one pair.

app/proc-info/main.c proc_info_parse_args(int argc, char **argv) · line 382

Quoted 3 lines
app/proc-info/main.c +3 -0
+				int ret = parse_descriptor_param(optarg,
+								 rx_item_opt,
+								 MAX_NB_ITEM);

Do we need to really pass the MAX_NB_ITEM> I don't think we need you can directly use the macro in the called function.

Review

Quoted 1 line
(quoted diff) +1 -0
+				if (ret < MAX_NB_ITEM) {

You can check ret < 0 no need to use MAX_NB_ITEM again.

app/proc-info/main.c proc_info_parse_args(int argc, char **argv) · line 396

Quoted 3 lines
app/proc-info/main.c +3 -0
+					printf("Tx descriptor param parse error.\n");
+					return -1;
+				}

Same here.

Thanks,
Reshma

#41 lore raw

Re: [PATCH v4 3/3] app/procinfo: support descriptor dump

Hi Reshma

Many thanks for your view.

Quoted 10 lines · Reshma
Quoted 10 lines

-----Original Message-----
From: Dongdong Liu <[email protected]>
Subject: [PATCH v4 3/3] app/procinfo: support descriptor dump

From: "Min Hu (Connor)" <[email protected]>

This patch support HW Rx/Tx descriptor dump

Quoted 7 lines
Quoted 3 lines

The command is like:
dpdk-proc-info -a xxxx:xx:xx.x --file-prefix=xxx -- -- --show-rx-descriptor queue_id:num

What is num here? You need to describe about this in commit message. Is num means number of descriptors? Better use the descriptor word here in num

Yes, It means number of descriptors. How about rename it to desc_num.

Quoted 6 lines
Quoted 4 lines

dpdk-proc-info -a xxxx:xx:xx.x --file-prefix=xxx -- -- --show-tx-descriptor queue_id:num

Same here.

Will fix.

Quoted 10 lines

app/proc-info/main.c static char *mempool_iter_name;

Quoted 6 lines
app/proc-info/main.c +5 -0
+/* Enable dump buffer descriptor. */
+#define MAX_NB_ITEM 2
+static uint16_t rx_nb_item;
+static uint16_t tx_nb_item;
+static uint16_t rx_item_opt[MAX_NB_ITEM]; static uint16_t

Instead of using array to keep queid and number of descriptors info , better have structure with 2 parameters one for queue and one for the number of descriptors. And You can use the same structure to declare tx_item.

Good point, will do.

Quoted 10 lines
Quoted 8 lines
(quoted diff) +2 -0
+tx_item_opt[MAX_NB_ITEM];
 
 
+		"  --show-rx-descriptor queue_id:num: to display ports Rx

buffer description by queue id and num\n"

(quoted diff) +1 -0
+		"  --show-tx-descriptor queue_id:num: to display ports Tx

buffer description by queue id and num\n"

Here also use enough description what is num means or use the another name.

Will do.

Quoted 10 lines

Review

Quoted 2 lines
(quoted diff) +1 -0
+				if (ret < MAX_NB_ITEM) {

You can check ret < 0 no need to use MAX_NB_ITEM again.

app/proc-info/main.c proc_info_parse_args(int argc, char **argv) · line 386

Quoted 3 lines
app/proc-info/main.c +3 -0
+					printf("Rx descriptor param parse error.\n");
+					return -1;
+				}

Instead of saying parse error. You might need to give clear reason of failure. That is invalid queueid:num passed by user or user passed more than one pair.

Will do.

Quoted 11 lines

app/proc-info/main.c proc_info_parse_args(int argc, char **argv) · line 382

Quoted 4 lines
app/proc-info/main.c +3 -0
+				int ret = parse_descriptor_param(optarg,
+								 rx_item_opt,
+								 MAX_NB_ITEM);

Do we need to really pass the MAX_NB_ITEM> I don't think we need you can directly use the macro in the called function.

Review

Quoted 1 line
(quoted diff) +1 -0
+				if (ret < MAX_NB_ITEM) {

You can check ret < 0 no need to use MAX_NB_ITEM again.

Will fix.

Quoted 6 lines

app/proc-info/main.c proc_info_parse_args(int argc, char **argv) · line 396

Quoted 4 lines
app/proc-info/main.c +3 -0
+					printf("Tx descriptor param parse error.\n");
+					return -1;
+				}

Same here.

Will do.

Thanks,
Dongdong

Quoted 7 lines

Thanks,
Reshma

.

#42 lore raw

v5 cover support ethdev Rx/Tx descriptor dump

In reply to Min Hu (Connor)

Support ethdev Rx/Tx descriptor dump by using procinfo tool.

Thanks to Ferruh, Andrew and Reshma help to review the patchset.

NOTE:
October 1st to October 7th is China's National Day holiday. I don't have a test environment available at the moment. I will test this patchset on October 8th. Current compile is ok.

v4->v5:
- Rename the Rx/Tx descriptor dump API and provide 'offset' parameter.
- Refactor procinfo dump descriptor code as Reshma suggested.

v3->v4:
- Modify the desc dump API to dump specified number of descriptors.
- Modify the hn3 pmd implementation and procinfo part

Dongdong Liu (3):
ethdev: introduce ethdev desc dump API
net/hns3: support Rx/Tx bd dump
app/procinfo: support descriptor dump

 app/proc-info/main.c                   | 80 +++++++++++++++++++++++
 doc/guides/rel_notes/release_22_11.rst |  6 ++
 drivers/net/hns3/hns3_dump.c           | 88 ++++++++++++++++++++++++++
 drivers/net/hns3/hns3_dump.h           |  5 ++
 drivers/net/hns3/hns3_ethdev.c         |  2 +
 drivers/net/hns3/hns3_ethdev_vf.c      |  2 +
 lib/ethdev/ethdev_driver.h             | 53 ++++++++++++++++
 lib/ethdev/rte_ethdev.c                | 52 +++++++++++++++
 lib/ethdev/rte_ethdev.h                | 55 ++++++++++++++++
 lib/ethdev/version.map                 |  2 +
 10 files changed, 345 insertions(+)

--
2.22.0

#43 lore raw

PATCH v5 1/3 ethdev: introduce ethdev desc dump API

Added the ethdev Rx/Tx desc dump API which provides functions for query descriptor from device. HW descriptor info differs in different NICs. The information demonstrates I/O process which is important for debug. As the information is different between NICs, the new API is introduced.

---
 doc/guides/rel_notes/release_22_11.rst |  6 +++
 lib/ethdev/ethdev_driver.h             | 53 +++++++++++++++++++++++++
 lib/ethdev/rte_ethdev.c                | 52 ++++++++++++++++++++++++
 lib/ethdev/rte_ethdev.h                | 55 ++++++++++++++++++++++++++
 lib/ethdev/version.map                 |  2 +
 5 files changed, 168 insertions(+)
doc/guides/rel_notes/release_22_11.rst +6 -0
index f1cc129933..453562fe69 100644
@@ -144,6 +144,12 @@ New Features
   into single event containing ``rte_event_vector``
   whose event type is ``RTE_EVENT_TYPE_CRYPTODEV_VECTOR``.
 
+* **Added ethdev desc dump API, to dump Rx/Tx desc info from device.**
+  Added the ethdev Rx/Tx desc dump API which provides functions for query
+  descriptor from device. The descriptor info differs in different NICs.
+  The information demonstrates I/O process which is important for debug.
+  As the information is different between NICs, the new API is introduced.
+  The dump format is vendor-specific.
 
 Removed Items
 -------------
lib/ethdev/ethdev_driver.h +53 -0

65 lines not on this page · raw message

lib/ethdev/rte_ethdev.c +52 -0

58 lines not on this page · raw message

lib/ethdev/rte_ethdev.h +55 -0

61 lines not on this page · raw message

lib/ethdev/version.map +2 -0
index 3651ceb234..375e30adeb 100644
@@ -290,6 +290,8 @@ EXPERIMENTAL {
 	rte_flow_async_action_handle_query;
 	rte_mtr_meter_policy_get;
 	rte_mtr_meter_profile_get;
+	rte_eth_rx_descriptor_dump;
+	rte_eth_tx_descriptor_dump;
 };
 
 INTERNAL {
Signature · 1 line
2.22.0
Reviewed-by on v5 1/3
#44 lore raw

Re: [PATCH v5 1/3] ethdev: introduce ethdev desc dump API

Quoted 7 lines · Dongdong Liu

Added the ethdev Rx/Tx desc dump API which provides functions for query descriptor from device. HW descriptor info differs in different NICs. The information demonstrates I/O process which is important for debug. As the information is different between NICs, the new API is introduced.

#45 lore raw

PATCH v5 2/3 net/hns3: support Rx/Tx bd dump

In reply to Dongdong Liu

This patch support query HW descriptor from hns3 device. HW descriptor is also called BD(buffer description) which is shared memory between software and hardware.

---
 drivers/net/hns3/hns3_dump.c      | 88 +++++++++++++++++++++++++++++++
 drivers/net/hns3/hns3_dump.h      |  5 ++
 drivers/net/hns3/hns3_ethdev.c    |  2 +
 drivers/net/hns3/hns3_ethdev_vf.c |  2 +
 4 files changed, 97 insertions(+)
drivers/net/hns3/hns3_dump.c +88 -0
index 95b64f8896..ae62bb56c8 100644
@@ -10,6 +10,9 @@
 #include "hns3_rxtx.h"
 #include "hns3_dump.h"
 
+#define HNS3_BD_DW_NUM 8
+#define HNS3_BD_ADDRESS_LAST_DW 2
+
 static const char *
 hns3_get_adapter_state_name(enum hns3_adapter_state state)
 {
@@ -931,3 +934,88 @@ hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file)
 
 	return 0;
 }
+
+int
+hns3_rx_descriptor_dump(const struct rte_eth_dev *dev, uint16_t queue_id,
+			uint16_t offset, uint16_t num, FILE *file)
+{
+	struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct hns3_rx_queue *rxq = dev->data->rx_queues[queue_id];
+	uint32_t *bd_data;
+	uint16_t count = 0;
+	uint16_t desc_id;
+	int i;
+
+	if (offset >= rxq->nb_rx_desc)
+		return -EINVAL;
+
+	if (num > rxq->nb_rx_desc) {
+		hns3_err(hw, "Invalid BD num=%u\n", num);
+		return -EINVAL;
+	}
+
+	while (count < num) {
+		desc_id = (rxq->next_to_use + offset + count) % rxq->nb_rx_desc;
+		bd_data = (uint32_t *)(&rxq->rx_ring[desc_id]);
+		fprintf(file, "Rx queue id:%u BD id:%u\n", queue_id, desc_id);
+		for (i = 0; i < HNS3_BD_DW_NUM; i++) {
+			/*
+			 * For the sake of security, first 8 bytes of BD which
+			 * stands for physical address of packet should not be
+			 * shown.
+			 */
+			if (i < HNS3_BD_ADDRESS_LAST_DW) {
+				fprintf(file, "RX BD WORD[%d]:0x%08x\n", i, 0);
+				continue;
+			}
+			fprintf(file, "RX BD WORD[%d]:0x%08x\n", i,
+				*(bd_data + i));
+		}
+		count++;
+	}
+
+	return 0;
+}
+
+int
+hns3_tx_descriptor_dump(const struct rte_eth_dev *dev, uint16_t queue_id,
+			uint16_t offset, uint16_t num, FILE *file)
+{
+	struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct hns3_tx_queue *txq = dev->data->tx_queues[queue_id];
+	uint32_t *bd_data;
+	uint16_t count = 0;
+	uint16_t desc_id;
+	int i;
+
+	if (offset >= txq->nb_tx_desc)
+		return -EINVAL;
+
+	if (num > txq->nb_tx_desc) {
+		hns3_err(hw, "Invalid BD num=%u\n", num);
+		return -EINVAL;
+	}
+
+	while (count < num) {
+		desc_id = (txq->next_to_use + offset + count) % txq->nb_tx_desc;
+		bd_data = (uint32_t *)(&txq->tx_ring[desc_id]);
+		fprintf(file, "Tx queue id:%u BD id:%u\n", queue_id, desc_id);
+		for (i = 0; i < HNS3_BD_DW_NUM; i++) {
+			/*
+			 * For the sake of security, first 8 bytes of BD which
+			 * stands for physical address of packet should not be
+			 * shown.
+			 */
+			if (i < HNS3_BD_ADDRESS_LAST_DW) {
+				fprintf(file, "TX BD WORD[%d]:0x%08x\n", i, 0);
+				continue;
+			}
+
+			fprintf(file, "Tx BD WORD[%d]:0x%08x\n", i,
+				*(bd_data + i));
+		}
+		count++;
+	}
+
+	return 0;
+}
drivers/net/hns3/hns3_dump.h +5 -0
index 43e983a42f..54f6c67e63 100644
@@ -10,4 +10,9 @@
 #include <ethdev_driver.h>
 
 int hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file);
+
+int hns3_rx_descriptor_dump(const struct rte_eth_dev *dev, uint16_t queue_id,
+			    uint16_t offset, uint16_t num, FILE *file);
+int hns3_tx_descriptor_dump(const struct rte_eth_dev *dev, uint16_t queue_id,
+			    uint16_t offset, uint16_t num, FILE *file);
 #endif /* HNS3_DUMP_H */
drivers/net/hns3/hns3_ethdev.c +2 -0
index 813fcedc6a..b4365b78be 100644
@@ -6558,6 +6558,8 @@ static const struct eth_dev_ops hns3_eth_dev_ops = {
 	.timesync_read_time         = hns3_timesync_read_time,
 	.timesync_write_time        = hns3_timesync_write_time,
 	.eth_dev_priv_dump          = hns3_eth_dev_priv_dump,
+	.eth_rx_descriptor_dump     = hns3_rx_descriptor_dump,
+	.eth_tx_descriptor_dump     = hns3_tx_descriptor_dump,
 };
 
 static const struct hns3_reset_ops hns3_reset_ops = {
drivers/net/hns3/hns3_ethdev_vf.c +2 -0
index c1bbcf42b1..d220522c43 100644
@@ -2302,6 +2302,8 @@ static const struct eth_dev_ops hns3vf_eth_dev_ops = {
 	.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,
+	.eth_rx_descriptor_dump = hns3_rx_descriptor_dump,
+	.eth_tx_descriptor_dump = hns3_tx_descriptor_dump,
 };
 
 static const struct hns3_reset_ops hns3vf_reset_ops = {
Signature · 1 line
2.22.0
#47 lore raw

PATCH v5 3/3 app/procinfo: support descriptor dump

In reply to Dongdong Liu

This patch support Rx/Tx descriptor dump

The command is like:
dpdk-proc-info -a xxxx:xx:xx.x --file-prefix=xxx -- --show-rx-descriptor queue_id:offset:num

dpdk-proc-info -a xxxx:xx:xx.x --file-prefix=xxx -- --show-tx-descriptor queue_id:offset:num

queue_id: A queue identifier on this port.
offset: The offset of the descriptor starting from tail.
num: The number of the descriptors to dump.

---
 app/proc-info/main.c | 80 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 80 insertions(+)
app/proc-info/main.c +80 -0
index d52ac8a038..d8a9639ad2 100644
@@ -48,6 +48,9 @@
 #define STATS_BDR_STR(w, s) printf("%.*s%s%.*s\n", w, \
 	STATS_BDR_FMT, s, w, STATS_BDR_FMT)
 
+typedef int (*desc_dump_t)(uint16_t port_id, uint16_t queue_id,
+			   uint16_t offset, uint16_t num, FILE *file);
+
 /**< mask of enabled ports */
 static unsigned long enabled_port_mask;
 /**< Enable stats. */
@@ -103,6 +106,19 @@ static char *mempool_iter_name;
 static uint32_t enable_dump_regs;
 static char *dump_regs_file_prefix;
 
+/* Enable dump Rx/Tx descriptor. */
+#define DESC_PARAM_NUM 3
+
+struct desc_param {
+	uint16_t queue_id;  /* A queue identifier on this port. */
+	uint16_t offset;    /* The offset of the descriptor starting from tail. */
+	uint16_t num;       /* The number of the descriptors to dump. */
+	bool valid;
+};
+
+static struct desc_param rx_desc_param;
+static struct desc_param tx_desc_param;
+
 /**< display usage */
 static void
 proc_info_usage(const char *prgname)
@@ -130,6 +146,14 @@ proc_info_usage(const char *prgname)
 		"  --show-crypto: to display crypto information\n"
 		"  --show-ring[=name]: to display ring information\n"
 		"  --show-mempool[=name]: to display mempool information\n"
+		"  --show-rx-descriptor queue_id:offset:num to display ports Rx descriptor information. "
+			"queue_id: A Rx queue identifier on this port. "
+			"offset: The offset of the descriptor starting from tail. "
+			"num: The number of the descriptors to dump.\n"
+		"  --show-tx-descriptor queue_id:offset:num to display ports Tx descriptor information. "
+			"queue_id: A Tx queue identifier on this port. "
+			"offset: The offset of the descriptor starting from tail. "
+			"num: The number of the descriptors to dump.\n"
 		"  --iter-mempool=name: iterate mempool elements to display content\n"
 		"  --dump-regs=file-prefix: dump registers to file with the file-prefix\n",
 		prgname);
@@ -182,6 +206,23 @@ parse_xstats_ids(char *list, uint64_t *ids, int limit) {
 	return length;
 }
 
+static int
+parse_descriptor_param(char *list, struct desc_param *desc)
+{
+	int ret;
+
+	ret = sscanf(list, "%hu:%hu:%hu", &desc->queue_id, &desc->offset,
+		     &desc->num);
+	if (ret != DESC_PARAM_NUM) {
+		desc->valid = false;
+		return -EINVAL;
+	}
+
+	desc->valid = true;
+
+	return 0;
+}
+
 static int
 proc_info_preparse_args(int argc, char **argv)
 {
@@ -242,6 +283,8 @@ proc_info_parse_args(int argc, char **argv)
 		{"show-mempool", optional_argument, NULL, 0},
 		{"iter-mempool", required_argument, NULL, 0},
 		{"dump-regs", required_argument, NULL, 0},
+		{"show-rx-descriptor", required_argument, NULL, 1},
+		{"show-tx-descriptor", required_argument, NULL, 1},
 		{NULL, 0, 0, 0}
 	};
 
@@ -334,6 +377,22 @@ proc_info_parse_args(int argc, char **argv)
 					return -1;
 				}
 				nb_xstats_ids = ret;
+			} else if (!strncmp(long_option[option_index].name,
+				"show-rx-descriptor", MAX_LONG_OPT_SZ)) {
+				int ret = parse_descriptor_param(optarg,
+							&rx_desc_param);
+				if (ret < 0) {
+					printf("Rx descriptor param parse error.\n");
+					return -1;
+				}
+			} else if (!strncmp(long_option[option_index].name,
+				"show-tx-descriptor", MAX_LONG_OPT_SZ)) {
+				int ret = parse_descriptor_param(optarg,
+							&tx_desc_param);
+				if (ret < 0) {
+					printf("Tx descriptor param parse error.\n");
+					return -1;
+				}
 			}
 			break;
 		default:
@@ -1476,6 +1535,21 @@ dump_regs(char *file_prefix)
 	}
 }
 
+static void
+nic_descriptor_display(uint16_t port_id, struct desc_param *desc,
+		       desc_dump_t desc_dump)
+{
+	static const char *nic_desc_border = "###";
+	uint16_t queue_id = desc->queue_id;
+	uint16_t offset = desc->offset;
+	uint16_t num = desc->num;
+
+	printf("%s NIC descriptor for port %u %s\n",
+		   nic_desc_border, port_id, nic_desc_border);
+
+	desc_dump(port_id, queue_id, offset, num, stdout);
+}
+
 int
 main(int argc, char **argv)
 {
@@ -1564,6 +1638,12 @@ main(int argc, char **argv)
 			metrics_display(i);
 #endif
 
+		if (rx_desc_param.valid)
+			nic_descriptor_display(i, &rx_desc_param,
+					       rte_eth_rx_descriptor_dump);
+		if (tx_desc_param.valid)
+			nic_descriptor_display(i, &tx_desc_param,
+					       rte_eth_tx_descriptor_dump);
 	}
 
 #ifdef RTE_LIB_METRICS
Signature · 1 line
2.22.0
#48 lore raw

RE: [PATCH v5 3/3] app/procinfo: support descriptor dump

app/proc-info/main.c static char *mempool_iter_name; · line 116

Quoted 11 lines

-----Original Message-----

app/proc-info/main.c +8 -0
+/* Enable dump Rx/Tx descriptor. */
+#define DESC_PARAM_NUM 3
+
+struct desc_param {
+	uint16_t queue_id;  /* A queue identifier on this port. */
+	uint16_t offset;    /* The offset of the descriptor starting from tail. */
+	uint16_t num;       /* The number of the descriptors to dump. */
+	bool valid;

You don't need to keep if the descriptor parameters are valid or not, as you are exiting the application when you see invalid parameters are entered by user.

app/proc-info/main.c parse_xstats_ids(char *list, uint64_t *ids, int limit) { · line 218

Quoted 10 lines
app/proc-info/main.c +9 -0
+static int
+parse_descriptor_param(char *list, struct desc_param *desc) {
+	int ret;
+
+	ret = sscanf(list, "%hu:%hu:%hu", &desc->queue_id, &desc->offset,
+		     &desc->num);
+	if (ret != DESC_PARAM_NUM) {
+		desc->valid = false;
+		return -EINVAL;

On error return application is exiting , so no need to maintain desc->valid

app/proc-info/main.c main(int argc, char **argv) · line 1641

Quoted 7 lines

main(int argc, char **argv)
{

app/proc-info/main.c +1 -0
@@ -1564,6 +1638,12 @@ main(int argc, char **argv)
 			metrics_display(i);
 #endif
 
+		if (rx_desc_param.valid)

So if rx_desc dump is requested in command line you can set some global variable like "enable-show-rx-desc-dump" and display below info only if that variable is set. So we no need to use valid here.

app/proc-info/main.c main(int argc, char **argv) · line 1644

Quoted 3 lines
app/proc-info/main.c +3 -0
+			nic_descriptor_display(i, &rx_desc_param,
+					       rte_eth_rx_descriptor_dump);
+		if (tx_desc_param.valid)

Same here as above comment.

#49 lore raw

Re: [PATCH v5 3/3] app/procinfo: support descriptor dump

Hi Reshma

Many thanks for your review.
I have sent out the below patchset. this patchset have fixed the comments.

[v8,7/8] app/procinfo: support descriptor dump
https://patches.dpdk.org/project/dpdk/list/?series=25047

Thanks,
Dongdong.

Quoted 48 lines · Reshma

app/proc-info/main.c static char *mempool_iter_name; · line 116

Quoted 11 lines

-----Original Message-----

app/proc-info/main.c +8 -0
+/* Enable dump Rx/Tx descriptor. */
+#define DESC_PARAM_NUM 3
+
+struct desc_param {
+	uint16_t queue_id;  /* A queue identifier on this port. */
+	uint16_t offset;    /* The offset of the descriptor starting from tail. */
+	uint16_t num;       /* The number of the descriptors to dump. */
+	bool valid;

You don't need to keep if the descriptor parameters are valid or not, as you are exiting the application when you see invalid parameters are entered by user.

app/proc-info/main.c parse_xstats_ids(char *list, uint64_t *ids, int limit) { · line 218

Quoted 10 lines
app/proc-info/main.c +9 -0
+static int
+parse_descriptor_param(char *list, struct desc_param *desc) {
+	int ret;
+
+	ret = sscanf(list, "%hu:%hu:%hu", &desc->queue_id, &desc->offset,
+		     &desc->num);
+	if (ret != DESC_PARAM_NUM) {
+		desc->valid = false;
+		return -EINVAL;

On error return application is exiting , so no need to maintain desc->valid

app/proc-info/main.c main(int argc, char **argv) · line 1641

Quoted 7 lines

main(int argc, char **argv)
{

app/proc-info/main.c +1 -0
@@ -1564,6 +1638,12 @@ main(int argc, char **argv)
 			metrics_display(i);
 #endif
 
+		if (rx_desc_param.valid)

So if rx_desc dump is requested in command line you can set some global variable like "enable-show-rx-desc-dump" and display below info only if that variable is set. So we no need to use valid here.

app/proc-info/main.c main(int argc, char **argv) · line 1644

Quoted 3 lines
app/proc-info/main.c +3 -0
+			nic_descriptor_display(i, &rx_desc_param,
+					       rte_eth_rx_descriptor_dump);
+		if (tx_desc_param.valid)

Same here as above comment.

.

#50 lore raw

Re: [PATCH v5 0/3] support ethdev Rx/Tx descriptor dump

In reply to Dongdong Liu
Quoted 13 lines · Dongdong Liu

Support ethdev Rx/Tx descriptor dump by using procinfo tool.

Thanks to Ferruh, Andrew and Reshma help to review the patchset.

NOTE:
October 1st to October 7th is China's National Day holiday. I don't have a test environment available at the moment. I will test this patchset on October 8th. Current compile is ok.

v4->v5:
- Rename the Rx/Tx descriptor dump API and provide 'offset' parameter.
- Refactor procinfo dump descriptor code as Reshma suggested.

Quoted 9 lines

v3->v4:
- Modify the desc dump API to dump specified number of descriptors.
- Modify the hn3 pmd implementation and procinfo part

Dongdong Liu (3):
ethdev: introduce ethdev desc dump API
net/hns3: support Rx/Tx bd dump
app/procinfo: support descriptor dump

I will wait review from Reshma for procinfo, but will merge rest to make them available for -rc1, procinfo can get after -rc1,

Except from procinfo patch, 3/3,
Series applied to dpdk-next-net/main, thanks.

Release notes and .map file order updated while merging.

#51 lore raw

Re: [PATCH v5 0/3] support ethdev Rx/Tx descriptor dump

Quoted 9 lines · Ferruh Yigit
Quoted 8 lines · Dongdong Liu

Support ethdev Rx/Tx descriptor dump by using procinfo tool.

Thanks to Ferruh, Andrew and Reshma help to review the patchset.

NOTE:
October 1st to October 7th is China's National Day holiday. I don't have a test environment available at the moment. I will test this patchset on October 8th. Current compile is ok.

I have tested the patchset and it works ok.

Quoted 15 lines
Quoted 5 lines

v4->v5:
- Rename the Rx/Tx descriptor dump API and provide 'offset' parameter.
- Refactor procinfo dump descriptor code as Reshma suggested.

Quoted 9 lines

v3->v4:
- Modify the desc dump API to dump specified number of descriptors.
- Modify the hn3 pmd implementation and procinfo part

Dongdong Liu (3):
ethdev: introduce ethdev desc dump API
net/hns3: support Rx/Tx bd dump
app/procinfo: support descriptor dump

Quoted 8 lines

I will wait review from Reshma for procinfo, but will merge rest to make them available for -rc1, procinfo can get after -rc1,

Except from procinfo patch, 3/3,
Series applied to dpdk-next-net/main, thanks.

Release notes and .map file order updated while merging.

Thanks for the work.

I have sent out the below patchset for the procinfo.

[PATCH v9 0/8] app/procinfo: add some extended features
https://patches.dpdk.org/project/dpdk/list/?series=25048

[v9,7/8] app/procinfo: support descriptor dump
https://patches.dpdk.org/project/dpdk/patch/[email protected]/

Thanks,
Dongdong.

Quoted 3 lines

.