From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id BA4F741C30; Tue, 7 Feb 2023 16:14:34 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 30EDE4282D; Tue, 7 Feb 2023 16:14:05 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 636CF4282D for ; Tue, 7 Feb 2023 16:14:03 +0100 (CET) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 317EgVPP017206; Tue, 7 Feb 2023 07:14:02 -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=JDSgWVX+N/lS2DLqacWqnOWA5ZG8eWF4LAqA+8arp0M=; b=YV6rgEA9OuPVQrOUPcsqViaUyfyx4stnomUGBAo0rdO9cDFJ4HxuniCFcUivMoJ90qh6 J5Y4ZvpKOg1DIz48hsGm0G5+IgecYZrvU5LYhRqLF2Jftb33dbtzs5ORMIc3VEd+KvJt W369Rj2L/WltUb4EKIyIl8ngS3vtlmYtEnrjGLkhs8l/4XmwN8wfl2/5qVv4mT0XFl1t beio+NwWQStqUbjinMBYoaoSnRMGv89ZE52+8U2j2ZGfM1xsFDgjWIxi37vESPEAQZW6 g9nB2PnbLn37B0UPDrKSBPVECIhqm/UcNzZmqASpjeVNrEEf9Mc9CtkjVKbf3vTWIUCH uA== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3nkdyrsk3g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 07 Feb 2023 07:14:02 -0800 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Tue, 7 Feb 2023 07:14:00 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.42 via Frontend Transport; Tue, 7 Feb 2023 07:14:00 -0800 Received: from jerin-lab.marvell.com (jerin-lab.marvell.com [10.28.34.14]) by maili.marvell.com (Postfix) with ESMTP id 338D53F7082; Tue, 7 Feb 2023 07:13:57 -0800 (PST) From: To: , Srikanth Yalavarthi CC: , , , , , Jerin Jacob Subject: [dpdk-dev] [PATCH v3 08/12] mldev: support inference enqueue and dequeue Date: Tue, 7 Feb 2023 20:43:12 +0530 Message-ID: <20230207151316.835441-9-jerinj@marvell.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230207151316.835441-1-jerinj@marvell.com> References: <20230206202453.336280-1-jerinj@marvell.com> <20230207151316.835441-1-jerinj@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: GWXhEG916ZGxYfuEMmNtjbQX8glFDW5X X-Proofpoint-GUID: GWXhEG916ZGxYfuEMmNtjbQX8glFDW5X X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-02-07_07,2023-02-06_03,2022-06-22_01 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Srikanth Yalavarthi Added implementations of fast-path functions to enqueue and dequeue ML requests from an ML device queue-pair. Signed-off-by: Srikanth Yalavarthi Signed-off-by: Jerin Jacob --- lib/mldev/rte_mldev.c | 75 ++++++++++++++++++++++++++++++++++++++ lib/mldev/rte_mldev_core.h | 46 +++++++++++++++++++++++ lib/mldev/rte_mldev_pmd.h | 2 + lib/mldev/version.map | 2 + 4 files changed, 125 insertions(+) diff --git a/lib/mldev/rte_mldev.c b/lib/mldev/rte_mldev.c index da65819c08..184d87c70a 100644 --- a/lib/mldev/rte_mldev.c +++ b/lib/mldev/rte_mldev.c @@ -114,6 +114,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; } @@ -671,4 +674,76 @@ rte_ml_op_pool_free(struct rte_mempool *mempool) 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)) { + RTE_MLDEV_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) { + RTE_MLDEV_LOG(ERR, "Dev %d, ops cannot be NULL\n", dev_id); + rte_errno = -EINVAL; + return 0; + } + + if (qp_id >= dev->data->nb_queue_pairs) { + RTE_MLDEV_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)) { + RTE_MLDEV_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) { + RTE_MLDEV_LOG(ERR, "Dev %d, ops cannot be NULL\n", dev_id); + rte_errno = -EINVAL; + return 0; + } + + if (qp_id >= dev->data->nb_queue_pairs) { + RTE_MLDEV_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); +} + RTE_LOG_REGISTER_DEFAULT(rte_ml_dev_logtype, INFO); diff --git a/lib/mldev/rte_mldev_core.h b/lib/mldev/rte_mldev_core.h index 46e6e7a4e5..1c02813c87 100644 --- a/lib/mldev/rte_mldev_core.h +++ b/lib/mldev/rte_mldev_core.h @@ -33,6 +33,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. @@ -448,6 +488,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 7665226d0e..e6b1ac4a4d 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; @@ -12,6 +13,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.39.1