[dpdk-dev] [PATCH v1 12/12] mldev: support to get debug info and test device

jerinj at marvell.com jerinj at marvell.com
Mon Nov 14 13:02:38 CET 2022


From: Srikanth Yalavarthi <syalavarthi at marvell.com>

Added library 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 <syalavarthi at marvell.com>
Signed-off-by: Jerin Jacob <jerinj at 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 7497a1316d..71aa98ee96 100644
--- a/lib/mldev/rte_mldev.c
+++ b/lib/mldev/rte_mldev.c
@@ -483,6 +483,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)) {
+		ML_DEV_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) {
+		ML_DEV_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)) {
+		ML_DEV_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, int16_t *model_id)
 {
diff --git a/lib/mldev/rte_mldev_core.h b/lib/mldev/rte_mldev_core.h
index 9e3873dd3a..b1426806a3 100644
--- a/lib/mldev/rte_mldev_core.h
+++ b/lib/mldev/rte_mldev_core.h
@@ -321,6 +321,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
  *
@@ -564,6 +595,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 86ab2129ce..61955ab701 100644
--- a/lib/mldev/version.map
+++ b/lib/mldev/version.map
@@ -5,9 +5,11 @@ 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_is_valid_dev;
 	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.38.1



More information about the dev mailing list