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 D0FE141C25; Mon, 6 Feb 2023 21:26:04 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 64468427E9; Mon, 6 Feb 2023 21:25:46 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id B21AA427E9 for ; Mon, 6 Feb 2023 21:25:44 +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 316KLefg021478; Mon, 6 Feb 2023 12:25:44 -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=NaG16/Z6CCHVNl45uk1fN7QG/asFdx3GjxwX9yL64rA=; b=lATMdaBm8nma7tJJelN6yceLZQhw66MYm5nV8LaMRyOw5Bg/k7+bCZ7XTu2B4ecqAece iw9FuR+imOC7Roh6hv0xEyWZKAR2QC+3mj4A+SYVPCoyDcebBlCKQSipe492sy/idCJO vmim5ikgp+1wSjU86KT1iOrI7TwT4wSqCFSSJNBm8OQmUGdJNIc9FMOVujQbfox5bdJG e5aoaTKiBCUFmUKiDjXiT+ChGetrxO7ZrgZA491YFWWu/kdLUv5D+qi6wJaATy3LdgzJ Ux44qOudcpwRDGXfejXIJjSWa6WR80uuNW9TMlvWExsHx3GOnZDfzYoMCIDQr/hPryK5 VA== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3nhnkv5am1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 06 Feb 2023 12:25:43 -0800 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Mon, 6 Feb 2023 12:25: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.42 via Frontend Transport; Mon, 6 Feb 2023 12:25:41 -0800 Received: from jerin-lab.marvell.com (jerin-lab.marvell.com [10.28.34.14]) by maili.marvell.com (Postfix) with ESMTP id 3DF363F705B; Mon, 6 Feb 2023 12:25:39 -0800 (PST) From: To: , Srikanth Yalavarthi CC: , , , , , , Jerin Jacob Subject: [dpdk-dev] [PATCH v2 08/12] mldev: support inference enqueue and dequeue Date: Tue, 7 Feb 2023 01:54:49 +0530 Message-ID: <20230206202453.336280-9-jerinj@marvell.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230206202453.336280-1-jerinj@marvell.com> References: <20221114120238.2143832-1-jerinj@marvell.com> <20230206202453.336280-1-jerinj@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: fJLGZBDk0KdHAoVag1KgfG1jvMTykv5c X-Proofpoint-GUID: fJLGZBDk0KdHAoVag1KgfG1jvMTykv5c 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-06_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 | 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 b669d866bf..872e4e200a 100644 --- a/lib/mldev/rte_mldev.c +++ b/lib/mldev/rte_mldev.c @@ -2,6 +2,7 @@ * Copyright (c) 2022 Marvell. */ +#include #include #include #include @@ -107,6 +108,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; } @@ -628,4 +632,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 1bbc9fda0e..b0144aaf0c 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. @@ -451,6 +491,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 b5ee45108b..b585b09ec1 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; @@ -11,6 +12,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