From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id D4E02A00C4;
	Mon, 14 Nov 2022 13:09:07 +0100 (CET)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id C4A9340150;
	Mon, 14 Nov 2022 13:09:07 +0100 (CET)
Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com
 [67.231.156.173])
 by mails.dpdk.org (Postfix) with ESMTP id 5C1604014F
 for <dev@dpdk.org>; Mon, 14 Nov 2022 13:09:06 +0100 (CET)
Received: from pps.filterd (m0045851.ppops.net [127.0.0.1])
 by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id
 2AE6h1B5008496; Mon, 14 Nov 2022 04:06:45 -0800
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com;
 h=from : to : cc :
 subject : date : message-id : in-reply-to : references : mime-version :
 content-transfer-encoding : content-type; s=pfpt0220;
 bh=mTuuWXmirBa9P5VE17mJlqq2CXWTe8vlIvwA3yPo5D0=;
 b=MrcVTqNJvgkzkxPw+vCYvQTEjww1/Wl8mZEtq1nwwueU2kYy5N14383k6RGcXFx7tXVN
 m2lHJ0jyYMrqQF+dD+grst+wcYKJWLtS172/fBowF/Jx8DfHwf8i8VPhedPQtBRyWB3I
 vKJZdUwsN2rp9SbMyQhARIgV5lKUVwmYHMrO78f6K0gD76VDXAyMxUQfSnqg82U0Z8uo
 AqtUKp0h/OYAShiz1QKmAU3vxwA5M/bQdUsEehzLVIDGRKuoUb5d+X8gaN6Y7wdBL2iQ
 UXsjm7CJWjJBmUdftyYA362p0akTBYg6B7G1ErPLf0kMHNfvNqnXMhp6H/mneYHFwKt3 SA== 
Received: from dc5-exch01.marvell.com ([199.233.59.181])
 by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3kugnb0wwu-1
 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT);
 Mon, 14 Nov 2022 04:06:44 -0800
Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com
 (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2;
 Mon, 14 Nov 2022 04:06:42 -0800
Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com
 (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend
 Transport; Mon, 14 Nov 2022 04:06:42 -0800
Received: from jerin-lab.marvell.com (jerin-lab.marvell.com [10.28.34.14])
 by maili.marvell.com (Postfix) with ESMTP id 407D15C6928;
 Mon, 14 Nov 2022 04:06:17 -0800 (PST)
From: <jerinj@marvell.com>
To: <dev@dpdk.org>, Srikanth Yalavarthi <syalavarthi@marvell.com>
CC: <thomas@monjalon.net>, <ferruh.yigit@xilinx.com>,
 <ajit.khaparde@broadcom.com>, <aboyer@pensando.io>,
 <andrew.rybchenko@oktetlabs.ru>, <beilei.xing@intel.com>,
 <bruce.richardson@intel.com>, <chas3@att.com>, <chenbo.xia@intel.com>,
 <ciara.loftus@intel.com>, <dsinghrawat@marvell.com>,
 <ed.czeck@atomicrules.com>, <evgenys@amazon.com>, <grive@u256.net>,
 <g.singh@nxp.com>, <zhouguoyang@huawei.com>, <haiyue.wang@intel.com>,
 <hkalra@marvell.com>, <heinrich.kuhn@corigine.com>,
 <hemant.agrawal@nxp.com>, <hyonkim@cisco.com>, <igorch@amazon.com>,
 <irusskikh@marvell.com>, <jgrajcia@cisco.com>,
 <jasvinder.singh@intel.com>, <jianwang@trustnetic.com>,
 <jiawenwu@trustnetic.com>, <jingjing.wu@intel.com>,
 <johndale@cisco.com>, <john.miller@atomicrules.com>,
 <linville@tuxdriver.com>, <keith.wiles@intel.com>,
 <kirankumark@marvell.com>, <oulijun@huawei.com>, <lironh@marvell.com>,
 <longli@microsoft.com>, <mw@semihalf.com>, <spinler@cesnet.cz>,
 <matan@nvidia.com>, <matt.peters@windriver.com>,
 <maxime.coquelin@redhat.com>, <mk@semihalf.com>, <humin29@huawei.com>,
 <pnalla@marvell.com>, <ndabilpuram@marvell.com>,
 <qiming.yang@intel.com>, <qi.z.zhang@intel.com>, <radhac@marvell.com>,
 <rahul.lakkireddy@chelsio.com>, <rmody@marvell.com>,
 <rosen.xu@intel.com>, <sachin.saxena@oss.nxp.com>,
 <skoteshwar@marvell.com>, <shshaikh@marvell.com>,
 <shaibran@amazon.com>, <shepard.siegel@atomicrules.com>,
 <asomalap@amd.com>, <somnath.kotur@broadcom.com>,
 <sthemmin@microsoft.com>, <steven.webster@windriver.com>,
 <skori@marvell.com>, <mtetsuyah@gmail.com>, <vburru@marvell.com>,
 <viacheslavo@nvidia.com>, <xiao.w.wang@intel.com>,
 <cloud.wangxiaoyun@huawei.com>, <yisen.zhuang@huawei.com>,
 <yongwang@vmware.com>, <xuanziyang2@huawei.com>, <pkapoor@marvell.com>,
 <nadavh@marvell.com>, <sburla@marvell.com>, <pathreya@marvell.com>,
 <gakhil@marvell.com>, <mdr@ashroe.eu>, <dmitry.kozliuk@gmail.com>,
 <anatoly.burakov@intel.com>, <cristian.dumitrescu@intel.com>,
 <honnappa.nagarahalli@arm.com>, <mattias.ronnblom@ericsson.com>,
 <ruifeng.wang@arm.com>, <drc@linux.vnet.ibm.com>,
 <konstantin.ananyev@intel.com>, <olivier.matz@6wind.com>,
 <jay.jayatheerthan@intel.com>, <asekhar@marvell.com>,
 <pbhagavatula@marvell.com>, <eagostini@nvidia.com>,
 <dchickles@marvell.com>, <sshankarnara@marvell.com>,
 Jerin Jacob <jerinj@marvell.com>
Subject: [dpdk-dev] [PATCH v1 08/12] mldev: support inference enqueue and
 dequeue
Date: Mon, 14 Nov 2022 17:32:34 +0530
Message-ID: <20221114120238.2143832-9-jerinj@marvell.com>
X-Mailer: git-send-email 2.38.1
In-Reply-To: <20221114120238.2143832-1-jerinj@marvell.com>
References: <20220803132839.2747858-2-jerinj@marvell.com>
 <20221114120238.2143832-1-jerinj@marvell.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Proofpoint-ORIG-GUID: W_CMHeuSw4YrqIPQ3MHCz1U4s-9bdz5A
X-Proofpoint-GUID: W_CMHeuSw4YrqIPQ3MHCz1U4s-9bdz5A
X-Proofpoint-Virus-Version: vendor=baseguard
 engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1
 definitions=2022-11-14_10,2022-11-11_01,2022-06-22_01
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org

From: Srikanth Yalavarthi <syalavarthi@marvell.com>

Added implementations of fast-path functions to enqueue
and dequeue ML requests from an ML device queue-pair.

Signed-off-by: Srikanth Yalavarthi <syalavarthi@marvell.com>
Signed-off-by: Jerin Jacob <jerinj@marvell.com>
---
 lib/mldev/rte_mldev.c      | 76 ++++++++++++++++++++++++++++++++++++++
 lib/mldev/rte_mldev_core.h | 46 +++++++++++++++++++++++
 lib/mldev/rte_mldev_pmd.h  |  2 +
 lib/mldev/version.map      |  2 +
 4 files changed, 126 insertions(+)

diff --git a/lib/mldev/rte_mldev.c b/lib/mldev/rte_mldev.c
index cc87837d85..adf8ab8cbc 100644
--- a/lib/mldev/rte_mldev.c
+++ b/lib/mldev/rte_mldev.c
@@ -2,6 +2,7 @@
  * Copyright (c) 2022 Marvell.
  */
 
+#include <rte_errno.h>
 #include <rte_mldev.h>
 #include <rte_mldev_pmd.h>
 
@@ -105,6 +106,9 @@ rte_ml_dev_pmd_allocate(const char *name, uint8_t socket_id)
 		ml_dev_globals.nb_devs++;
 	}
 
+	dev->enqueue_burst = NULL;
+	dev->dequeue_burst = NULL;
+
 	return dev;
 }
 
@@ -625,3 +629,75 @@ rte_ml_op_pool_free(struct rte_mempool *mempool)
 	if (mempool != NULL)
 		rte_mempool_free(mempool);
 }
+
+uint16_t
+rte_ml_enqueue_burst(int16_t dev_id, uint16_t qp_id, struct rte_ml_op **ops, uint16_t nb_ops)
+{
+	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);
+		rte_errno = -EINVAL;
+		return 0;
+	}
+
+	dev = rte_ml_dev_pmd_get_dev(dev_id);
+	if (*dev->enqueue_burst == NULL) {
+		rte_errno = -ENOTSUP;
+		return 0;
+	}
+
+	if (ops == NULL) {
+		ML_DEV_LOG(ERR, "Dev %d, ops cannot be NULL\n", dev_id);
+		rte_errno = -EINVAL;
+		return 0;
+	}
+
+	if (qp_id >= dev->data->nb_queue_pairs) {
+		ML_DEV_LOG(ERR, "Invalid qp_id %u\n", qp_id);
+		rte_errno = -EINVAL;
+		return 0;
+	}
+#else
+	dev = rte_ml_dev_pmd_get_dev(dev_id);
+#endif
+
+	return (*dev->enqueue_burst)(dev, qp_id, ops, nb_ops);
+}
+
+uint16_t
+rte_ml_dequeue_burst(int16_t dev_id, uint16_t qp_id, struct rte_ml_op **ops, uint16_t nb_ops)
+{
+	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);
+		rte_errno = -EINVAL;
+		return 0;
+	}
+
+	dev = rte_ml_dev_pmd_get_dev(dev_id);
+	if (*dev->dequeue_burst == NULL) {
+		rte_errno = -ENOTSUP;
+		return 0;
+	}
+
+	if (ops == NULL) {
+		ML_DEV_LOG(ERR, "Dev %d, ops cannot be NULL\n", dev_id);
+		rte_errno = -EINVAL;
+		return 0;
+	}
+
+	if (qp_id >= dev->data->nb_queue_pairs) {
+		ML_DEV_LOG(ERR, "Invalid qp_id %u\n", qp_id);
+		rte_errno = -EINVAL;
+		return 0;
+	}
+#else
+	dev = rte_ml_dev_pmd_get_dev(dev_id);
+#endif
+
+	return (*dev->dequeue_burst)(dev, qp_id, ops, nb_ops);
+}
diff --git a/lib/mldev/rte_mldev_core.h b/lib/mldev/rte_mldev_core.h
index b388553a96..9c19d7badf 100644
--- a/lib/mldev/rte_mldev_core.h
+++ b/lib/mldev/rte_mldev_core.h
@@ -37,6 +37,46 @@ extern "C" {
 
 struct rte_ml_dev;
 
+/**
+ * @internal
+ *
+ * Enqueue a burst of inference requests to a queue on ML device.
+ *
+ * @param dev
+ *	ML device pointer.
+ * @param qp_id
+ *	Queue-pair ID.
+ * @param ops
+ *	Array of ML ops to be enqueued.
+ * @param nb_ops
+ *	Number of ops to enqueue.
+ *
+ * @return
+ *	- Number of ops enqueued.
+ */
+typedef uint16_t (*mldev_enqueue_t)(struct rte_ml_dev *dev, uint16_t qp_id, struct rte_ml_op **ops,
+				    uint16_t nb_ops);
+
+/**
+ * @internal
+ *
+ * Dequeue a burst of inference requests from a queue on ML device.
+ *
+ * @param dev
+ *	ML device pointer.
+ * @param qp_id
+ *	Queue-pair ID.
+ * @param ops
+ *	Array of ML ops to dequeued.
+ * @param nb_ops
+ *	Number of ops to dequeue.
+ *
+ * @return
+ *	- Number of ops dequeued.
+ */
+typedef uint16_t (*mldev_dequeue_t)(struct rte_ml_dev *dev, uint16_t qp_id, struct rte_ml_op **ops,
+				    uint16_t nb_ops);
+
 /**
  * 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.
@@ -455,6 +495,12 @@ struct rte_ml_dev_data {
  * The data structure associated with each ML device.
  */
 struct rte_ml_dev {
+	/** Pointer to PMD enqueue function. */
+	mldev_enqueue_t enqueue_burst;
+
+	/** Pointer to PMD dequeue function. */
+	mldev_dequeue_t dequeue_burst;
+
 	/** Pointer to device data. */
 	struct rte_ml_dev_data *data;
 
diff --git a/lib/mldev/rte_mldev_pmd.h b/lib/mldev/rte_mldev_pmd.h
index 33544f1b80..afe617e4bf 100644
--- a/lib/mldev/rte_mldev_pmd.h
+++ b/lib/mldev/rte_mldev_pmd.h
@@ -40,6 +40,8 @@ struct rte_ml_dev_pmd_init_params {
 	uint64_t private_data_size;
 };
 
+struct rte_ml_dev;
+
 /**
  * @internal
  *
diff --git a/lib/mldev/version.map b/lib/mldev/version.map
index 396ca0b96a..5d44d210d7 100644
--- a/lib/mldev/version.map
+++ b/lib/mldev/version.map
@@ -1,6 +1,7 @@
 EXPERIMENTAL {
 	global:
 
+	rte_ml_dequeue_burst;
 	rte_ml_dev_close;
 	rte_ml_dev_configure;
 	rte_ml_dev_count;
@@ -10,6 +11,7 @@ EXPERIMENTAL {
 	rte_ml_dev_socket_id;
 	rte_ml_dev_start;
 	rte_ml_dev_stop;
+	rte_ml_enqueue_burst;
 	rte_ml_io_dequantize;
 	rte_ml_io_input_size_get;
 	rte_ml_io_output_size_get;
-- 
2.38.1