[PATCH v4 28/39] ml/cnxk: add internal function for sync mode run
Srikanth Yalavarthi
syalavarthi at marvell.com
Wed Feb 1 10:22:59 CET 2023
Added internal function to execute ML inference requests
in synchronous mode. Sync mode inference execution is used
to launch inference requests without using a queue-pair.
Signed-off-by: Srikanth Yalavarthi <syalavarthi at marvell.com>
---
drivers/ml/cnxk/cn10k_ml_ops.c | 53 ++++++++++++++++++++++++++++++++++
drivers/ml/cnxk/cn10k_ml_ops.h | 1 +
2 files changed, 54 insertions(+)
diff --git a/drivers/ml/cnxk/cn10k_ml_ops.c b/drivers/ml/cnxk/cn10k_ml_ops.c
index ef3cbadca7..b6a35f9a4f 100644
--- a/drivers/ml/cnxk/cn10k_ml_ops.c
+++ b/drivers/ml/cnxk/cn10k_ml_ops.c
@@ -1533,6 +1533,59 @@ cn10k_ml_dequeue_burst(struct rte_ml_dev *dev, uint16_t qp_id, struct rte_ml_op
return count;
}
+__rte_hot int
+cn10k_ml_inference_sync(struct rte_ml_dev *dev, struct rte_ml_op *op)
+{
+ struct cn10k_ml_model *model;
+ struct cn10k_ml_dev *mldev;
+ struct cn10k_ml_req *req;
+ bool timeout;
+ int ret = 0;
+
+ mldev = dev->data->dev_private;
+ model = dev->data->models[op->model_id];
+ req = model->req;
+
+ cn10k_ml_prep_fp_job_descriptor(dev, req, op);
+
+ memset(&req->result, 0, sizeof(struct cn10k_ml_result));
+ req->result.user_ptr = op->user_ptr;
+
+ plt_write64(ML_CN10K_POLL_JOB_START, &req->status);
+ req->jcmd.w1.s.jobptr = PLT_U64_CAST(&req->jd);
+
+ timeout = true;
+ req->timeout = plt_tsc_cycles() + ML_CN10K_CMD_TIMEOUT * plt_tsc_hz();
+ do {
+ if (roc_ml_jcmdq_enqueue_lf(&mldev->roc, &req->jcmd)) {
+ req->op = op;
+ timeout = false;
+ break;
+ }
+ } while (plt_tsc_cycles() < req->timeout);
+
+ if (timeout) {
+ ret = -EBUSY;
+ goto error_enqueue;
+ }
+
+ timeout = true;
+ do {
+ if (plt_read64(&req->status) == ML_CN10K_POLL_JOB_FINISH) {
+ timeout = false;
+ break;
+ }
+ } while (plt_tsc_cycles() < req->timeout);
+
+ if (timeout)
+ ret = -ETIME;
+ else
+ cn10k_ml_result_update(dev, -1, &req->result, req->op);
+
+error_enqueue:
+ return ret;
+}
+
struct rte_ml_dev_ops cn10k_ml_ops = {
/* Device control ops */
.dev_info_get = cn10k_ml_dev_info_get,
diff --git a/drivers/ml/cnxk/cn10k_ml_ops.h b/drivers/ml/cnxk/cn10k_ml_ops.h
index 3178295bba..a17a2851b1 100644
--- a/drivers/ml/cnxk/cn10k_ml_ops.h
+++ b/drivers/ml/cnxk/cn10k_ml_ops.h
@@ -75,5 +75,6 @@ __rte_hot uint16_t cn10k_ml_enqueue_burst(struct rte_ml_dev *dev, uint16_t qp_id
struct rte_ml_op **ops, uint16_t nb_ops);
__rte_hot uint16_t cn10k_ml_dequeue_burst(struct rte_ml_dev *dev, uint16_t qp_id,
struct rte_ml_op **ops, uint16_t nb_ops);
+__rte_hot int cn10k_ml_inference_sync(struct rte_ml_dev *dev, struct rte_ml_op *op);
#endif /* _CN10K_ML_OPS_H_ */
--
2.17.1
More information about the dev
mailing list