event/cnxk: add device stop and close
authorShijith Thotton <sthotton@marvell.com>
Tue, 4 May 2021 00:27:09 +0000 (05:57 +0530)
committerJerin Jacob <jerinj@marvell.com>
Tue, 4 May 2021 04:52:50 +0000 (06:52 +0200)
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
drivers/event/cnxk/cn9k_eventdev.c
drivers/event/cnxk/cnxk_eventdev.c
drivers/event/cnxk/cnxk_eventdev.h

index 8d6b1e4..5b7cd67 100644 (file)
@@ -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
index 20919e3..f13f50f 100644 (file)
@@ -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
index 5feae52..a390031 100644 (file)
@@ -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)
 {
index f175c23..3011af1 100644 (file)
@@ -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__ */