diff mbox series

[v2,17/33] event/cnxk: add device stop and close functions

Message ID 20210426174441.2302-18-pbhagavatula@marvell.com (mailing list archive)
State Changes Requested, archived
Delegated to: Jerin Jacob
Headers show
Series Marvell CNXK Event device Driver | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Pavan Nikhilesh Bhagavatula April 26, 2021, 5:44 p.m. UTC
From: Shijith Thotton <sthotton@marvell.com>

Add event device stop and close callback functions.

Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
Signed-off-by: Shijith Thotton <sthotton@marvell.com>
---
 drivers/event/cnxk/cn10k_eventdev.c | 15 +++++++++
 drivers/event/cnxk/cn9k_eventdev.c  | 14 +++++++++
 drivers/event/cnxk/cnxk_eventdev.c  | 48 +++++++++++++++++++++++++++++
 drivers/event/cnxk/cnxk_eventdev.h  |  6 ++++
 4 files changed, 83 insertions(+)
diff mbox series

Patch

diff --git a/drivers/event/cnxk/cn10k_eventdev.c b/drivers/event/cnxk/cn10k_eventdev.c
index 0de44ed43..6a0b9bcd9 100644
--- a/drivers/event/cnxk/cn10k_eventdev.c
+++ b/drivers/event/cnxk/cn10k_eventdev.c
@@ -388,6 +388,19 @@  cn10k_sso_start(struct rte_eventdev *event_dev)
 	return rc;
 }
 
+static void
+cn10k_sso_stop(struct rte_eventdev *event_dev)
+{
+	cnxk_sso_stop(event_dev, cn10k_sso_hws_reset,
+		      cn10k_sso_hws_flush_events);
+}
+
+static int
+cn10k_sso_close(struct rte_eventdev *event_dev)
+{
+	return cnxk_sso_close(event_dev, cn10k_sso_hws_unlink);
+}
+
 static struct rte_eventdev_ops cn10k_sso_dev_ops = {
 	.dev_infos_get = cn10k_sso_info_get,
 	.dev_configure = cn10k_sso_dev_configure,
@@ -402,6 +415,8 @@  static struct rte_eventdev_ops cn10k_sso_dev_ops = {
 	.timeout_ticks = cnxk_sso_timeout_ticks,
 
 	.dev_start = cn10k_sso_start,
+	.dev_stop = cn10k_sso_stop,
+	.dev_close = cn10k_sso_close,
 };
 
 static int
diff --git a/drivers/event/cnxk/cn9k_eventdev.c b/drivers/event/cnxk/cn9k_eventdev.c
index 39f29b687..195ed49d8 100644
--- a/drivers/event/cnxk/cn9k_eventdev.c
+++ b/drivers/event/cnxk/cn9k_eventdev.c
@@ -463,6 +463,18 @@  cn9k_sso_start(struct rte_eventdev *event_dev)
 	return rc;
 }
 
+static void
+cn9k_sso_stop(struct rte_eventdev *event_dev)
+{
+	cnxk_sso_stop(event_dev, cn9k_sso_hws_reset, cn9k_sso_hws_flush_events);
+}
+
+static int
+cn9k_sso_close(struct rte_eventdev *event_dev)
+{
+	return cnxk_sso_close(event_dev, cn9k_sso_hws_unlink);
+}
+
 static struct rte_eventdev_ops cn9k_sso_dev_ops = {
 	.dev_infos_get = cn9k_sso_info_get,
 	.dev_configure = cn9k_sso_dev_configure,
@@ -477,6 +489,8 @@  static struct rte_eventdev_ops cn9k_sso_dev_ops = {
 	.timeout_ticks = cnxk_sso_timeout_ticks,
 
 	.dev_start = cn9k_sso_start,
+	.dev_stop = cn9k_sso_stop,
+	.dev_close = cn9k_sso_close,
 };
 
 static int
diff --git a/drivers/event/cnxk/cnxk_eventdev.c b/drivers/event/cnxk/cnxk_eventdev.c
index 0059b0eca..01685633d 100644
--- a/drivers/event/cnxk/cnxk_eventdev.c
+++ b/drivers/event/cnxk/cnxk_eventdev.c
@@ -390,6 +390,54 @@  cnxk_sso_start(struct rte_eventdev *event_dev, cnxk_sso_hws_reset_t reset_fn,
 	return 0;
 }
 
+void
+cnxk_sso_stop(struct rte_eventdev *event_dev, cnxk_sso_hws_reset_t reset_fn,
+	      cnxk_sso_hws_flush_t flush_fn)
+{
+	plt_sso_dbg();
+	cnxk_sso_cleanup(event_dev, reset_fn, flush_fn, false);
+	rte_mb();
+}
+
+int
+cnxk_sso_close(struct rte_eventdev *event_dev, cnxk_sso_unlink_t unlink_fn)
+{
+	struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
+	uint16_t all_queues[CNXK_SSO_MAX_HWGRP];
+	uint16_t i;
+	void *ws;
+
+	if (!dev->configured)
+		return 0;
+
+	for (i = 0; i < dev->nb_event_queues; i++)
+		all_queues[i] = i;
+
+	for (i = 0; i < dev->nb_event_ports; i++) {
+		ws = event_dev->data->ports[i];
+		unlink_fn(dev, ws, all_queues, dev->nb_event_queues);
+		rte_free(cnxk_sso_hws_get_cookie(ws));
+		event_dev->data->ports[i] = NULL;
+	}
+
+	roc_sso_rsrc_fini(&dev->sso);
+	rte_mempool_free(dev->xaq_pool);
+	rte_memzone_free(rte_memzone_lookup(CNXK_SSO_FC_NAME));
+
+	dev->fc_iova = 0;
+	dev->fc_mem = NULL;
+	dev->xaq_pool = NULL;
+	dev->configured = false;
+	dev->is_timeout_deq = 0;
+	dev->nb_event_ports = 0;
+	dev->max_num_events = -1;
+	dev->nb_event_queues = 0;
+	dev->min_dequeue_timeout_ns = USEC2NSEC(1);
+	dev->max_dequeue_timeout_ns = USEC2NSEC(0x3FF);
+
+	return 0;
+}
+
 static void
 parse_queue_param(char *value, void *opaque)
 {
diff --git a/drivers/event/cnxk/cnxk_eventdev.h b/drivers/event/cnxk/cnxk_eventdev.h
index 6ead171c0..1030d5840 100644
--- a/drivers/event/cnxk/cnxk_eventdev.h
+++ b/drivers/event/cnxk/cnxk_eventdev.h
@@ -48,6 +48,8 @@  typedef void (*cnxk_sso_hws_setup_t)(void *dev, void *ws, uintptr_t *grp_base);
 typedef void (*cnxk_sso_hws_release_t)(void *dev, void *ws);
 typedef int (*cnxk_sso_link_t)(void *dev, void *ws, uint16_t *map,
 			       uint16_t nb_link);
+typedef int (*cnxk_sso_unlink_t)(void *dev, void *ws, uint16_t *map,
+				 uint16_t nb_link);
 typedef void (*cnxk_handle_event_t)(void *arg, struct rte_event ev);
 typedef void (*cnxk_sso_hws_reset_t)(void *arg, void *ws);
 typedef void (*cnxk_sso_hws_flush_t)(void *ws, uint8_t queue_id, uintptr_t base,
@@ -205,5 +207,9 @@  int cnxk_sso_timeout_ticks(struct rte_eventdev *event_dev, uint64_t ns,
 int cnxk_sso_start(struct rte_eventdev *event_dev,
 		   cnxk_sso_hws_reset_t reset_fn,
 		   cnxk_sso_hws_flush_t flush_fn);
+void cnxk_sso_stop(struct rte_eventdev *event_dev,
+		   cnxk_sso_hws_reset_t reset_fn,
+		   cnxk_sso_hws_flush_t flush_fn);
+int cnxk_sso_close(struct rte_eventdev *event_dev, cnxk_sso_unlink_t unlink_fn);
 
 #endif /* __CNXK_EVENTDEV_H__ */