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 C0C6443857; Sun, 7 Jan 2024 16:36:05 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0F13740A81; Sun, 7 Jan 2024 16:35:28 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 94F054069D for ; Sun, 7 Jan 2024 16:35:24 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 407DlRPv022570 for ; Sun, 7 Jan 2024 07:35:24 -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=8RbFeghdMuxTooKD8XM+VT5OGWAe2K0clJ3WYfscLyM=; b=UHr ywZt0P2/SWaEKexJYNJaGLHWI/o5VQFtQkmXCddl5TBq7w2KuZUfOl1wZtXiNIRI 9VS+sR3xMWe3uSn3rM57q8mleTBfS0GYUD1jd5j2K3Rme8xeWuRnJHbQRhmfsSoh q6mzJZ4uRAO56nGNmETgqaLLydKx6QKKm/ux04lvDPbLtOH5LNnrf3DFBcIwOc/P 4KgPnpZG0cwDMWGgdH8zn5t0Bfyr7AEs5BomdtBgKpmYR5gTYH+YRXnHZg9xRMDq dGIgKoEmHa8ctypshwN92KATurs50w4/YsVjkot4zVPPnLH1wwQJo5t0LWPZMRn+ O0qb5NE70nma14WvdcQ== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3vf78n2a1r-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Sun, 07 Jan 2024 07:35:23 -0800 (PST) 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.48; Sun, 7 Jan 2024 07:35:22 -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.48 via Frontend Transport; Sun, 7 Jan 2024 07:35:22 -0800 Received: from ml-host-33.caveonetworks.com (unknown [10.110.143.233]) by maili.marvell.com (Postfix) with ESMTP id ED60C3F7093; Sun, 7 Jan 2024 07:35:21 -0800 (PST) From: Srikanth Yalavarthi To: Jerin Jacob , Srikanth Yalavarthi CC: , , , Subject: [PATCH 07/11] event/ml: add adapter start and stop Date: Sun, 7 Jan 2024 07:34:46 -0800 Message-ID: <20240107153454.3909-8-syalavarthi@marvell.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240107153454.3909-1-syalavarthi@marvell.com> References: <20240107153454.3909-1-syalavarthi@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: Bo20HX__XF6x_DgPA7zB6XBtPqBjElUi X-Proofpoint-GUID: Bo20HX__XF6x_DgPA7zB6XBtPqBjElUi X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-09_02,2023-12-07_01,2023-05-22_02 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 Added ML adapter start and stop functions. Signed-off-by: Srikanth Yalavarthi --- lib/eventdev/eventdev_pmd.h | 42 ++++++++++++++++ lib/eventdev/rte_event_ml_adapter.c | 75 +++++++++++++++++++++++++++++ 2 files changed, 117 insertions(+) diff --git a/lib/eventdev/eventdev_pmd.h b/lib/eventdev/eventdev_pmd.h index 48e970a5097..44f26473075 100644 --- a/lib/eventdev/eventdev_pmd.h +++ b/lib/eventdev/eventdev_pmd.h @@ -1599,6 +1599,44 @@ typedef int (*eventdev_ml_adapter_queue_pair_del_t)(const struct rte_eventdev *d const struct rte_ml_dev *cdev, int32_t queue_pair_id); +/** + * Start ML adapter. This callback is invoked if + * the caps returned from rte_event_ml_adapter_caps_get(.., mldev_id) + * has RTE_EVENT_ML_ADAPTER_CAP_INTERNAL_PORT_* set and queue pairs + * from mldev_id have been added to the event device. + * + * @param dev + * Event device pointer + * + * @param mldev + * ML device pointer + * + * @return + * - 0: Success, ML adapter started successfully. + * - <0: Error code returned by the driver function. + */ +typedef int (*eventdev_ml_adapter_start_t)(const struct rte_eventdev *dev, + const struct rte_ml_dev *mldev); + +/** + * Stop ML adapter. This callback is invoked if + * the caps returned from rte_event_ml_adapter_caps_get(.., mldev_id) + * has RTE_EVENT_ML_ADAPTER_CAP_INTERNAL_PORT_* set and queue pairs + * from mldev_id have been added to the event device. + * + * @param dev + * Event device pointer + * + * @param mldev + * ML device pointer + * + * @return + * - 0: Success, ML adapter stopped successfully. + * - <0: Error code returned by the driver function. + */ +typedef int (*eventdev_ml_adapter_stop_t)(const struct rte_eventdev *dev, + const struct rte_ml_dev *mldev); + /** Event device operations function pointer table */ struct eventdev_ops { eventdev_info_get_t dev_infos_get; /**< Get device info. */ @@ -1744,6 +1782,10 @@ struct eventdev_ops { /**< Add queue pair to ML adapter */ eventdev_ml_adapter_queue_pair_del_t ml_adapter_queue_pair_del; /**< Delete queue pair from ML adapter */ + eventdev_ml_adapter_start_t ml_adapter_start; + /**< Start ML adapter */ + eventdev_ml_adapter_stop_t ml_adapter_stop; + /**< Stop ML adapter */ eventdev_selftest dev_selftest; /**< Start eventdev Selftest */ diff --git a/lib/eventdev/rte_event_ml_adapter.c b/lib/eventdev/rte_event_ml_adapter.c index 95f566b1025..60c10caef68 100644 --- a/lib/eventdev/rte_event_ml_adapter.c +++ b/lib/eventdev/rte_event_ml_adapter.c @@ -61,6 +61,14 @@ struct ml_device_info { /* Next queue pair to be processed */ uint16_t next_queue_pair_id; + + /* Set to indicate processing has been started */ + uint8_t dev_started; + + /* Set to indicate mldev->eventdev packet + * transfer uses a hardware mechanism + */ + uint8_t internal_event_port; } __rte_cache_aligned; struct event_ml_adapter { @@ -1071,3 +1079,70 @@ rte_event_ml_adapter_queue_pair_del(uint8_t id, int16_t mldev_id, int32_t queue_ return ret; } + +static int +emla_adapter_ctrl(uint8_t id, int start) +{ + struct event_ml_adapter *adapter; + struct ml_device_info *dev_info; + struct rte_eventdev *dev; + int stop = !start; + int use_service; + uint32_t i; + + if (!emla_valid_id(id)) { + RTE_EDEV_LOG_ERR("Invalid ML adapter id = %d", id); + return -EINVAL; + } + + adapter = emla_id_to_adapter(id); + if (adapter == NULL) + return -EINVAL; + + dev = &rte_eventdevs[adapter->eventdev_id]; + + use_service = 0; + for (i = 0; i < rte_ml_dev_count(); i++) { + dev_info = &adapter->mldevs[i]; + /* if start check for num queue pairs */ + if (start && !dev_info->num_qpairs) + continue; + /* if stop check if dev has been started */ + if (stop && !dev_info->dev_started) + continue; + use_service |= !dev_info->internal_event_port; + dev_info->dev_started = start; + if (dev_info->internal_event_port == 0) + continue; + start ? (*dev->dev_ops->ml_adapter_start)(dev, &dev_info->dev[i]) : + (*dev->dev_ops->ml_adapter_stop)(dev, &dev_info->dev[i]); + } + + if (use_service) + rte_service_runstate_set(adapter->service_id, start); + + return 0; +} + +int +rte_event_ml_adapter_start(uint8_t id) +{ + struct event_ml_adapter *adapter; + + if (!emla_valid_id(id)) { + RTE_EDEV_LOG_ERR("Invalid ML adapter id = %d", id); + return -EINVAL; + } + + adapter = emla_id_to_adapter(id); + if (adapter == NULL) + return -EINVAL; + + return emla_adapter_ctrl(id, 1); +} + +int +rte_event_ml_adapter_stop(uint8_t id) +{ + return emla_adapter_ctrl(id, 0); +} -- 2.42.0