From patchwork Mon Nov 14 12:02:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerin Jacob X-Patchwork-Id: 119826 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7985BA00C4; Mon, 14 Nov 2022 13:07:27 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6873242C29; Mon, 14 Nov 2022 13:07:27 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id A08D542C29 for ; Mon, 14 Nov 2022 13:07:25 +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 2AE6h5OC008532; Mon, 14 Nov 2022 04:05: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=Vp26mkqtBcpq1xhaIvt9jFoMF0fXCPchxamtym9jhMo=; b=g/R5uoYukDcQT+8af1H5gt4X+w852ib4PLOH3rlwNdD1IaK0Qa3KUrr730hfKNxUdJsm qcjpthlONEONDkMCAcfV+nK1oVFSmnzfgKgd3Ixgs50vs3vGkbrAkjm4V9+eMPavV528 o+6hYHBfIa6sQFOaCI58tIAQa0iL46QPF9tdrAi5OEqChCtrNOrc/dgdZbVnD8wy2LjN +XV5mzluTGQmjlA3cNsu6FKqaS8TWatn/kHhH0lKMHqjfdPFIxkc5E8Fp6DZBOBJnqcT pYNU9Z+td14p5Fi/Bu/M/8lct8MpUMkj/HjTslD6j61LHnASmXre+BKY1/BzainTHkLW Ng== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3kugnb0wsn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 14 Nov 2022 04:05:02 -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:05:00 -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:05:00 -0800 Received: from jerin-lab.marvell.com (jerin-lab.marvell.com [10.28.34.14]) by maili.marvell.com (Postfix) with ESMTP id 8767C5C68E5; Mon, 14 Nov 2022 04:04:35 -0800 (PST) From: To: , Srikanth Yalavarthi CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Jerin Jacob Subject: [dpdk-dev] [PATCH v1 04/12] mldev: support device queue-pair setup Date: Mon, 14 Nov 2022 17:32:30 +0530 Message-ID: <20221114120238.2143832-5-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 X-Proofpoint-ORIG-GUID: lngkZEJddPk4tlgAqT8Alj28HZ5JdUbh X-Proofpoint-GUID: lngkZEJddPk4tlgAqT8Alj28HZ5JdUbh 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Srikanth Yalavarthi Added APIs to create a queue-pair attached to ML device. Queue pairs are created with a user specified ID. Added function prototypes to be used by ML drivers for queue pair create and destroy. Signed-off-by: Srikanth Yalavarthi Signed-off-by: Jerin Jacob --- lib/mldev/rte_mldev.c | 33 ++++++++++++++++++++++++++++ lib/mldev/rte_mldev_core.h | 44 ++++++++++++++++++++++++++++++++++++++ lib/mldev/version.map | 1 + 3 files changed, 78 insertions(+) diff --git a/lib/mldev/rte_mldev.c b/lib/mldev/rte_mldev.c index 651f8b2f7c..c8672cff8e 100644 --- a/lib/mldev/rte_mldev.c +++ b/lib/mldev/rte_mldev.c @@ -306,3 +306,36 @@ rte_ml_dev_stop(int16_t dev_id) return ret; } + +int +rte_ml_dev_queue_pair_setup(int16_t dev_id, uint16_t queue_pair_id, + const struct rte_ml_dev_qp_conf *qp_conf, int socket_id) +{ + struct rte_ml_dev *dev; + + 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->dev_ops->dev_queue_pair_setup == NULL) + return -ENOTSUP; + + if (queue_pair_id >= dev->data->nb_queue_pairs) { + ML_DEV_LOG(ERR, "Invalid queue_pair_id = %d", queue_pair_id); + return -EINVAL; + } + + if (qp_conf == NULL) { + ML_DEV_LOG(ERR, "Dev %d, qp_conf cannot be NULL\n", dev_id); + return -EINVAL; + } + + if (dev->data->dev_started) { + ML_DEV_LOG(ERR, "Device %d must be stopped to allow configuration", dev_id); + return -EBUSY; + } + + return (*dev->dev_ops->dev_queue_pair_setup)(dev, queue_pair_id, qp_conf, socket_id); +} diff --git a/lib/mldev/rte_mldev_core.h b/lib/mldev/rte_mldev_core.h index 1405cce7f7..e2a16034d6 100644 --- a/lib/mldev/rte_mldev_core.h +++ b/lib/mldev/rte_mldev_core.h @@ -117,6 +117,44 @@ typedef int (*mldev_start_t)(struct rte_ml_dev *dev); */ typedef int (*mldev_stop_t)(struct rte_ml_dev *dev); +/** + * @internal + * + * Setup a queue pair for a device. + * + * @param dev + * ML device pointer. + * @param queue_pair_id + * Queue pair index. + * @param queue_pair_conf + * Queue pair configuration structure. + * @param socket_id + * Socket index. + * + * @return + * - 0 on success. + * - < 0, error on failure. + */ +typedef int (*mldev_queue_pair_setup_t)(struct rte_ml_dev *dev, uint16_t queue_pair_id, + const struct rte_ml_dev_qp_conf *queue_pair_conf, + int socket_id); + +/** + * @internal + * + * Release memory resources allocated by given queue pair. + * + * @param dev + * ML device pointer. + * @param queue_pair_id + * Queue pair index. + * + * @return + * - 0 on success. + * - -EAGAIN, if can't close as device is busy. + */ +typedef int (*mldev_queue_pair_release_t)(struct rte_ml_dev *dev, uint16_t queue_pair_id); + /** * @internal * @@ -137,6 +175,12 @@ struct rte_ml_dev_ops { /** Stop device. */ mldev_stop_t dev_stop; + + /** Set up a device queue pair. */ + mldev_queue_pair_setup_t dev_queue_pair_setup; + + /** Release a device queue pair. */ + mldev_queue_pair_release_t dev_queue_pair_release; }; /** diff --git a/lib/mldev/version.map b/lib/mldev/version.map index 1be508ab5f..cd44c05f3a 100644 --- a/lib/mldev/version.map +++ b/lib/mldev/version.map @@ -6,6 +6,7 @@ EXPERIMENTAL { rte_ml_dev_count; rte_ml_dev_info_get; rte_ml_dev_is_valid_dev; + rte_ml_dev_queue_pair_setup; rte_ml_dev_socket_id; rte_ml_dev_start; rte_ml_dev_stop;