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 2CC3242672;
	Fri, 29 Sep 2023 13:52:39 +0200 (CEST)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 050F1410DD;
	Fri, 29 Sep 2023 13:52:37 +0200 (CEST)
Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com
 [67.231.148.174])
 by mails.dpdk.org (Postfix) with ESMTP id 5B947410E6
 for <dev@dpdk.org>; Fri, 29 Sep 2023 13:52:35 +0200 (CEST)
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
 38T2730E031713; Fri, 29 Sep 2023 04:52:34 -0700
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=W3ON137Hs89KrRQu8/tJDQGtVe2GL5lHsQ/NpsCf6qQ=;
 b=NPa5uTVxdKe6uErDVU032LF8vjPg0D7Qdmk48pUsj0syu2FsrujsZvF0Yr24PUhF2+a2
 X92fwV6wieIi3TgTUxxPI17qbZVOcNbodBlQqXcI159QEdyBfDnvjLQril17EExd84l2
 MiTXCKDv2JaUjL4hBs7TAdSNkNp4HDOhn8RtkHI5VsqB655+D8fLcRluhc+5+bmQGW9I
 4ztRa1GTtp9l5wXZhhbRIc/LLbYTQuLkc08I8oQ4PqhzDjJjBmbPHt3GvRoloWhDBJIU
 MJzhD25f8Na050W+ppbpk6dzMEoTVe4eKtUf9g8hn7FKpOiiwSO84UVbz44T/AZZm0Zw dA== 
Received: from dc5-exch02.marvell.com ([199.233.59.182])
 by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3td7y6wdw1-1
 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT);
 Fri, 29 Sep 2023 04:52:34 -0700
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.48;
 Fri, 29 Sep 2023 04:52:32 -0700
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.48 via Frontend
 Transport; Fri, 29 Sep 2023 04:52:32 -0700
Received: from localhost.localdomain (unknown [10.28.36.157])
 by maili.marvell.com (Postfix) with ESMTP id 4445D3F7048;
 Fri, 29 Sep 2023 04:52:27 -0700 (PDT)
From: Amit Prakash Shukla <amitprakashs@marvell.com>
To: Amit Prakash Shukla <amitprakashs@marvell.com>, Jerin Jacob
 <jerinj@marvell.com>
CC: <dev@dpdk.org>, <fengchengwen@huawei.com>, <kevin.laatz@intel.com>,
 <bruce.richardson@intel.com>, <conor.walsh@intel.com>,
 <vattunuru@marvell.com>, <g.singh@nxp.com>,
 <sachin.saxena@oss.nxp.com>, <hemant.agrawal@nxp.com>,
 <cheng1.jiang@intel.com>, <ndabilpuram@marvell.com>,
 <anoobj@marvell.com>, <mb@smartsharesystems.com>
Subject: [PATCH v8 06/12] eventdev/dma: support adapter start and stop
Date: Fri, 29 Sep 2023 17:20:45 +0530
Message-ID: <20230929115051.564063-7-amitprakashs@marvell.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20230929115051.564063-1-amitprakashs@marvell.com>
References: <20230929081309.464565-1-amitprakashs@marvell.com>
 <20230929115051.564063-1-amitprakashs@marvell.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Proofpoint-ORIG-GUID: D3I35vT2H39nx3R1eAqWWczXeRngrhki
X-Proofpoint-GUID: D3I35vT2H39nx3R1eAqWWczXeRngrhki
X-Proofpoint-Virus-Version: vendor=baseguard
 engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26
 definitions=2023-09-29_10,2023-09-28_03,2023-05-22_02
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

Added API support to start and stop DMA adapter.

Signed-off-by: Amit Prakash Shukla <amitprakashs@marvell.com>
---
 lib/eventdev/rte_event_dma_adapter.c | 69 ++++++++++++++++++++++++++++
 1 file changed, 69 insertions(+)

diff --git a/lib/eventdev/rte_event_dma_adapter.c b/lib/eventdev/rte_event_dma_adapter.c
index 1d8bae0422..be6c2623e9 100644
--- a/lib/eventdev/rte_event_dma_adapter.c
+++ b/lib/eventdev/rte_event_dma_adapter.c
@@ -74,6 +74,13 @@ struct dma_device_info {
 	/* Next queue pair to be processed */
 	uint16_t next_vchan_id;
 
+	/* Set to indicate processing has been started */
+	uint8_t dev_started;
+
+	/* Set to indicate dmadev->eventdev packet
+	 * transfer uses a hardware mechanism
+	 */
+	uint8_t internal_event_port;
 } __rte_cache_aligned;
 
 struct event_dma_adapter {
@@ -1129,3 +1136,65 @@ rte_event_dma_adapter_vchan_del(uint8_t id, int16_t dma_dev_id, uint16_t vchan)
 
 	return ret;
 }
+
+static int
+edma_adapter_ctrl(uint8_t id, int start)
+{
+	struct event_dma_adapter *adapter;
+	struct dma_device_info *dev_info;
+	struct rte_eventdev *dev;
+	uint16_t num_dma_dev;
+	int stop = !start;
+	int use_service;
+	uint32_t i;
+
+	use_service = 0;
+	EVENT_DMA_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
+	adapter = edma_id_to_adapter(id);
+	if (adapter == NULL)
+		return -EINVAL;
+
+	num_dma_dev = rte_dma_count_avail();
+	dev = &rte_eventdevs[adapter->eventdev_id];
+
+	for (i = 0; i < num_dma_dev; i++) {
+		dev_info = &adapter->dma_devs[i];
+		/* start check for num queue pairs */
+		if (start && !dev_info->num_vchanq)
+			continue;
+		/* 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->dma_adapter_start)(dev, i) :
+			(*dev->dev_ops->dma_adapter_stop)(dev, i);
+	}
+
+	if (use_service)
+		rte_service_runstate_set(adapter->service_id, start);
+
+	return 0;
+}
+
+int
+rte_event_dma_adapter_start(uint8_t id)
+{
+	struct event_dma_adapter *adapter;
+
+	EVENT_DMA_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
+
+	adapter = edma_id_to_adapter(id);
+	if (adapter == NULL)
+		return -EINVAL;
+
+	return edma_adapter_ctrl(id, 1);
+}
+
+int
+rte_event_dma_adapter_stop(uint8_t id)
+{
+	return edma_adapter_ctrl(id, 0);
+}
-- 
2.25.1