From: Srikanth Yalavarthi <syalavar...@marvell.com>

Added functions for ML device debug APIs. The APIs
are used to dump ML device debug information and to run selftest.
Signed-off-by: Srikanth Yalavarthi <syalavar...@marvell.com>
Signed-off-by: Jerin Jacob <jer...@marvell.com>
---
 lib/mldev/rte_mldev.c      | 39 ++++++++++++++++++++++++++++++++++++++
 lib/mldev/rte_mldev_core.h | 37 ++++++++++++++++++++++++++++++++++++
 lib/mldev/version.map      |  2 ++
 3 files changed, 78 insertions(+)

diff --git a/lib/mldev/rte_mldev.c b/lib/mldev/rte_mldev.c
index 9258f44466..eeddb8e874 100644
--- a/lib/mldev/rte_mldev.c
+++ b/lib/mldev/rte_mldev.c
@@ -527,6 +527,45 @@ rte_ml_dev_xstats_reset(int16_t dev_id, const uint16_t 
*stat_ids, uint16_t nb_id
        return (*dev->dev_ops->dev_xstats_reset)(dev, stat_ids, nb_ids);
 }
 
+int
+rte_ml_dev_dump(int16_t dev_id, FILE *fd)
+{
+       struct rte_ml_dev *dev;
+
+       if (!rte_ml_dev_is_valid_dev(dev_id)) {
+               RTE_MLDEV_LOG(ERR, "Invalid dev_id = %d\n", dev_id);
+               return -EINVAL;
+       }
+
+       dev = rte_ml_dev_pmd_get_dev(dev_id);
+       if (*dev->dev_ops->dev_dump == NULL)
+               return -ENOTSUP;
+
+       if (fd == NULL) {
+               RTE_MLDEV_LOG(ERR, "Dev %d, file descriptor cannot be NULL\n", 
dev_id);
+               return -EINVAL;
+       }
+
+       return (*dev->dev_ops->dev_dump)(dev, fd);
+}
+
+int
+rte_ml_dev_selftest(int16_t dev_id)
+{
+       struct rte_ml_dev *dev;
+
+       if (!rte_ml_dev_is_valid_dev(dev_id)) {
+               RTE_MLDEV_LOG(ERR, "Invalid dev_id = %d\n", dev_id);
+               return -EINVAL;
+       }
+
+       dev = rte_ml_dev_pmd_get_dev(dev_id);
+       if (*dev->dev_ops->dev_selftest == NULL)
+               return -ENOTSUP;
+
+       return (*dev->dev_ops->dev_selftest)(dev);
+}
+
 int
 rte_ml_model_load(int16_t dev_id, struct rte_ml_model_params *params, uint16_t 
*model_id)
 {
diff --git a/lib/mldev/rte_mldev_core.h b/lib/mldev/rte_mldev_core.h
index 14c33175d2..98851e0fd5 100644
--- a/lib/mldev/rte_mldev_core.h
+++ b/lib/mldev/rte_mldev_core.h
@@ -317,6 +317,37 @@ typedef int (*mldev_xstats_get_t)(struct rte_ml_dev *dev, 
const uint16_t *stat_i
 typedef int (*mldev_xstats_reset_t)(struct rte_ml_dev *dev, const uint16_t 
*stat_ids,
                                    uint16_t nb_ids);
 
+/**
+ * @internal
+ *
+ * Function used to dump ML device debug info.
+ *
+ * @param dev
+ *     ML device pointer.
+ * @param fd
+ *     File descriptor to dump the debug info.
+ *
+ * @return
+ *     - 0 on success.
+ *     - < 0, error code on failure.
+ */
+
+typedef int (*mldev_dump_t)(struct rte_ml_dev *dev, FILE *fd);
+
+/**
+ * @internal
+ *
+ * Function used for selftest of ML device.
+ *
+ * @param dev
+ *     ML device pointer.
+ *
+ * @return
+ *     - 0 on success.
+ *     - < 0, error on failure.
+ */
+typedef int (*mldev_selftest_t)(struct rte_ml_dev *dev);
+
 /**
  * @internal
  *
@@ -560,6 +591,12 @@ struct rte_ml_dev_ops {
        /** Reset extended stats of the device. */
        mldev_xstats_reset_t dev_xstats_reset;
 
+       /** Dump ML device debug info. */
+       mldev_dump_t dev_dump;
+
+       /** Dump ML device debug info. */
+       mldev_selftest_t dev_selftest;
+
        /** Load an ML model. */
        mldev_model_load_t model_load;
 
diff --git a/lib/mldev/version.map b/lib/mldev/version.map
index ea91912f5f..d2b30a991a 100644
--- a/lib/mldev/version.map
+++ b/lib/mldev/version.map
@@ -5,11 +5,13 @@ EXPERIMENTAL {
        rte_ml_dev_close;
        rte_ml_dev_configure;
        rte_ml_dev_count;
+       rte_ml_dev_dump;
        rte_ml_dev_info_get;
        rte_ml_dev_init;
        rte_ml_dev_is_valid_dev;
        rte_ml_dev_logtype;
        rte_ml_dev_queue_pair_setup;
+       rte_ml_dev_selftest;
        rte_ml_dev_socket_id;
        rte_ml_dev_start;
        rte_ml_dev_stats_get;
-- 
2.39.1

Reply via email to