ethdev: introduce dump API
authorMin Hu (Connor) <humin29@huawei.com>
Fri, 11 Feb 2022 04:49:22 +0000 (12:49 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 11 Feb 2022 10:31:13 +0000 (11:31 +0100)
Added the ethdev dump API which provides querying private info from device.
There exists many private properties in different PMD drivers, such as
adapter state, Rx/Tx func algorithm in hns3 PMD. The information of these
properties is important for debug. As the information is private, the new
API is introduced.

Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
Acked-by: Ray Kinsella <mdr@ashroe.eu>
Acked-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
doc/guides/rel_notes/release_22_03.rst
lib/ethdev/ethdev_driver.h
lib/ethdev/rte_ethdev.c
lib/ethdev/rte_ethdev.h
lib/ethdev/version.map

index 9947ddd..db516c0 100644 (file)
@@ -87,6 +87,13 @@ New Features
   New APIs, ``rte_eth_dev_priority_flow_ctrl_queue_info_get()`` and
   ``rte_eth_dev_priority_flow_ctrl_queue_configure()``, was added.
 
+* **Added a private dump API, to dump private info from device.**
+
+  Added the private dump API which provides querying private info from device.
+  There exists many private properties in different PMD drivers.
+  The information of these properties is important for debug.
+  As the information is private, a dump function is introduced.
+
 * **Updated AF_XDP PMD**
 
   * Added support for libxdp >=v1.2.2.
index f426785..41a7dea 100644 (file)
@@ -1045,6 +1045,25 @@ typedef int (*eth_ip_reassembly_conf_get_t)(struct rte_eth_dev *dev,
 typedef int (*eth_ip_reassembly_conf_set_t)(struct rte_eth_dev *dev,
                const struct rte_eth_ip_reassembly_params *conf);
 
+/**
+ * @internal
+ * Dump private info from device to a file.
+ *
+ * @param dev
+ *   Port (ethdev) handle.
+ * @param file
+ *   A pointer to a file for output.
+ *
+ * @return
+ *   Negative value on error, 0 on success.
+ *
+ * @retval 0
+ *   Success
+ * @retval -EINVAL
+ *   Invalid file
+ */
+typedef int (*eth_dev_priv_dump_t)(struct rte_eth_dev *dev, FILE *file);
+
 /**
  * @internal A structure containing the functions exported by an Ethernet driver.
  */
@@ -1252,6 +1271,9 @@ struct eth_dev_ops {
        eth_ip_reassembly_conf_get_t ip_reassembly_conf_get;
        /** Set IP reassembly configuration */
        eth_ip_reassembly_conf_set_t ip_reassembly_conf_set;
+
+       /** Dump private info from device */
+       eth_dev_priv_dump_t eth_dev_priv_dump;
 };
 
 /**
index 155978c..6bd2d94 100644 (file)
@@ -6749,6 +6749,23 @@ rte_eth_ip_reassembly_dynfield_register(int *field_offset, int *flag_offset)
        return 0;
 }
 
+int
+rte_eth_dev_priv_dump(uint16_t port_id, FILE *file)
+{
+       struct rte_eth_dev *dev;
+
+       RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+       dev = &rte_eth_devices[port_id];
+
+       if (file == NULL) {
+               RTE_ETHDEV_LOG(ERR, "Invalid file (NULL)\n");
+               return -EINVAL;
+       }
+
+       RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->eth_dev_priv_dump, -ENOTSUP);
+       return eth_err(port_id, (*dev->dev_ops->eth_dev_priv_dump)(dev, file));
+}
+
 RTE_LOG_REGISTER_DEFAULT(rte_eth_dev_logtype, INFO);
 
 RTE_INIT(ethdev_init_telemetry)
index bee7986..c2d1f9a 100644 (file)
@@ -5431,6 +5431,26 @@ typedef struct {
        uint16_t nb_frags;
 } rte_eth_ip_reassembly_dynfield_t;
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Dump private info from device to a file. Provided data and the order depends
+ * on the PMD.
+ *
+ * @param port_id
+ *   The port identifier of the Ethernet device.
+ * @param file
+ *   A pointer to a file for output.
+ * @return
+ *   - (0) on success.
+ *   - (-ENODEV) if *port_id* is invalid.
+ *   - (-EINVAL) if null file.
+ *   - (-ENOTSUP) if the device does not support this function.
+ *   - (-EIO) if device is removed.
+ */
+__rte_experimental
+int rte_eth_dev_priv_dump(uint16_t port_id, FILE *file);
 
 #include <rte_ethdev_core.h>
 
index 1ca7ec3..1a43282 100644 (file)
@@ -260,6 +260,7 @@ EXPERIMENTAL {
        # added in 22.03
        rte_eth_dev_priority_flow_ctrl_queue_configure;
        rte_eth_dev_priority_flow_ctrl_queue_info_get;
+       rte_eth_dev_priv_dump;
        rte_eth_ip_reassembly_capability_get;
        rte_eth_ip_reassembly_conf_get;
        rte_eth_ip_reassembly_conf_set;