[v1,11/12] mldev: support to retrieve error information

Message ID 20221114120238.2143832-12-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

Commit Message

Jerin Jacob Kollanukkaran Nov. 14, 2022, 12:02 p.m. UTC
  From: Srikanth Yalavarthi <syalavarthi@marvell.com>

Added functions to get error information for an ML op.
This information can include both drive specific error
message and error code.

Signed-off-by: Srikanth Yalavarthi <syalavarthi@marvell.com>
Signed-off-by: Jerin Jacob <jerinj@marvell.com>
---
 lib/mldev/rte_mldev.c      | 31 +++++++++++++++++++++++++++++++
 lib/mldev/rte_mldev_core.h | 22 ++++++++++++++++++++++
 lib/mldev/version.map      |  1 +
 3 files changed, 54 insertions(+)
  

Patch

diff --git a/lib/mldev/rte_mldev.c b/lib/mldev/rte_mldev.c
index cdd68e933c..7497a1316d 100644
--- a/lib/mldev/rte_mldev.c
+++ b/lib/mldev/rte_mldev.c
@@ -829,3 +829,34 @@  rte_ml_dequeue_burst(int16_t dev_id, uint16_t qp_id, struct rte_ml_op **ops, uin
 
 	return (*dev->dequeue_burst)(dev, qp_id, ops, nb_ops);
 }
+
+int
+rte_ml_op_error_get(int16_t dev_id, struct rte_ml_op *op, struct rte_ml_op_error *error)
+{
+	struct rte_ml_dev *dev;
+
+#ifdef RTE_LIBRTE_ML_DEV_DEBUG
+	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->op_error_get == NULL)
+		return -ENOTSUP;
+
+	if (op == NULL) {
+		ML_DEV_LOG(ERR, "Dev %d, op cannot be NULL\n", dev_id);
+		return -EINVAL;
+	}
+
+	if (error == NULL) {
+		ML_DEV_LOG(ERR, "Dev %d, error cannot be NULL\n", dev_id);
+		return -EINVAL;
+	}
+#else
+	dev = rte_ml_dev_pmd_get_dev(dev_id);
+#endif
+
+	return (*dev->op_error_get)(dev, op, error);
+}
diff --git a/lib/mldev/rte_mldev_core.h b/lib/mldev/rte_mldev_core.h
index 82e8ed0422..9e3873dd3a 100644
--- a/lib/mldev/rte_mldev_core.h
+++ b/lib/mldev/rte_mldev_core.h
@@ -77,6 +77,25 @@  typedef uint16_t (*mldev_enqueue_t)(struct rte_ml_dev *dev, uint16_t qp_id, stru
 typedef uint16_t (*mldev_dequeue_t)(struct rte_ml_dev *dev, uint16_t qp_id, struct rte_ml_op **ops,
 				    uint16_t nb_ops);
 
+/**
+ * @internal
+ *
+ * Get error information for an Op.
+ *
+ * @param dev
+ *	ML device pointer.
+ * @param op
+ *	ML Op handle.
+ * @param error
+ *	Pointer to error structure.
+ *
+ * @return
+ *	- 0 on success.
+ *	- <0, error on failure.
+ */
+typedef int (*mldev_op_error_get_t)(struct rte_ml_dev *dev, struct rte_ml_op *op,
+				    struct rte_ml_op_error *error);
+
 /**
  * Definitions of all functions exported by a driver through the generic structure of type
  * *ml_dev_ops* supplied in the *rte_ml_dev* structure associated with a device.
@@ -626,6 +645,9 @@  struct rte_ml_dev {
 	/** Pointer to PMD dequeue function. */
 	mldev_dequeue_t dequeue_burst;
 
+	/** Pointer to PMD Op error get function. */
+	mldev_op_error_get_t op_error_get;
+
 	/** Pointer to device data. */
 	struct rte_ml_dev_data *data;
 
diff --git a/lib/mldev/version.map b/lib/mldev/version.map
index 02d2eab100..86ab2129ce 100644
--- a/lib/mldev/version.map
+++ b/lib/mldev/version.map
@@ -28,6 +28,7 @@  EXPERIMENTAL {
 	rte_ml_model_start;
 	rte_ml_model_stop;
 	rte_ml_model_unload;
+	rte_ml_op_error_get;
 	rte_ml_op_pool_create;
 	rte_ml_op_pool_free;