DPDK patches and discussions
 help / color / mirror / Atom feed
From: Srikanth Yalavarthi <syalavarthi@marvell.com>
To: Jerin Jacob <jerinj@marvell.com>,
	Srikanth Yalavarthi <syalavarthi@marvell.com>
Cc: <dev@dpdk.org>, <aprabhu@marvell.com>, <sshankarnara@marvell.com>,
	<ptakkar@marvell.com>
Subject: [PATCH 07/11] event/ml: add adapter start and stop
Date: Sun, 7 Jan 2024 07:34:46 -0800	[thread overview]
Message-ID: <20240107153454.3909-8-syalavarthi@marvell.com> (raw)
In-Reply-To: <20240107153454.3909-1-syalavarthi@marvell.com>

Added ML adapter start and stop functions.

Signed-off-by: Srikanth Yalavarthi <syalavarthi@marvell.com>
---
 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


  parent reply	other threads:[~2024-01-07 15:36 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-07 15:34 [PATCH 00/11] Introduce Event ML Adapter Srikanth Yalavarthi
2024-01-07 15:34 ` [PATCH 01/11] eventdev: introduce ML event adapter library Srikanth Yalavarthi
2024-02-02  8:51   ` Jerin Jacob
2024-02-07  9:17   ` Naga Harish K, S V
2024-01-07 15:34 ` [PATCH 02/11] event/ml: add ml adapter capabilities get Srikanth Yalavarthi
2024-01-07 15:34 ` [PATCH 03/11] event/ml: add adapter create and free Srikanth Yalavarthi
2024-01-07 15:34 ` [PATCH 04/11] event/ml: add adapter port get Srikanth Yalavarthi
2024-01-07 15:34 ` [PATCH 05/11] event/ml: add adapter queue pair add and delete Srikanth Yalavarthi
2024-01-07 15:34 ` [PATCH 06/11] event/ml: add support for service function Srikanth Yalavarthi
2024-01-07 15:34 ` Srikanth Yalavarthi [this message]
2024-01-07 15:34 ` [PATCH 08/11] event/ml: add support to get adapter service ID Srikanth Yalavarthi
2024-01-07 15:34 ` [PATCH 09/11] event/ml: add support for runtime params Srikanth Yalavarthi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240107153454.3909-8-syalavarthi@marvell.com \
    --to=syalavarthi@marvell.com \
    --cc=aprabhu@marvell.com \
    --cc=dev@dpdk.org \
    --cc=jerinj@marvell.com \
    --cc=ptakkar@marvell.com \
    --cc=sshankarnara@marvell.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).