[v1,12/12] mldev: support to get debug info and test device

Message ID 20221114120238.2143832-13-jerinj@marvell.com (mailing list archive)
State Changes Requested, archived
Delegated to: Thomas Monjalon
Headers
Series mldev: introduce machine learning device library |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/intel-Testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/github-robot: build success github build: passed
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS

Commit Message

Jerin Jacob Kollanukkaran Nov. 14, 2022, 12:02 p.m. UTC
  From: Srikanth Yalavarthi <syalavarthi@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@marvell.com>
Signed-off-by: Jerin Jacob <jerinj@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(+)
  

Patch

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;