[04/10] eventdev: add support in DSW for linking/unlinking ports

Message ID 20180830142719.28569-5-mattias.ronnblom@ericsson.com
State Superseded, archived
Delegated to: Jerin Jacob
Headers show
Series
  • Add the Distributed Software Event Device
Related show

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

Mattias Rönnblom Aug. 30, 2018, 2:27 p.m.
Added support for linking and unlinking ports to queues in a DSW event
device.

Signed-off-by: Mattias Rönnblom <mattias.ronnblom@ericsson.com>
---
 drivers/event/dsw/dsw_evdev.c | 67 +++++++++++++++++++++++++++++++++++
 drivers/event/dsw/dsw_evdev.h |  1 +
 2 files changed, 68 insertions(+)

Patch

diff --git a/drivers/event/dsw/dsw_evdev.c b/drivers/event/dsw/dsw_evdev.c
index 91b1a2449..5dccc232a 100644
--- a/drivers/event/dsw/dsw_evdev.c
+++ b/drivers/event/dsw/dsw_evdev.c
@@ -2,6 +2,8 @@ 
  * Copyright(c) 2018 Ericsson AB
  */
 
+#include <stdbool.h>
+
 #include <rte_eventdev_pmd.h>
 #include <rte_eventdev_pmd_vdev.h>
 
@@ -112,6 +114,69 @@  dsw_queue_release(struct rte_eventdev *dev __rte_unused,
 {
 }
 
+static void
+queue_add_port(struct dsw_queue *queue, uint16_t port_id)
+{
+	queue->serving_ports[queue->num_serving_ports] = port_id;
+	queue->num_serving_ports++;
+}
+
+static bool
+queue_remove_port(struct dsw_queue *queue, uint16_t port_id)
+{
+	uint16_t i;
+
+	for (i = 0; i < queue->num_serving_ports; i++)
+		if (queue->serving_ports[i] == port_id) {
+			uint16_t last_idx = queue->num_serving_ports - 1;
+			if (i != last_idx)
+				queue->serving_ports[i] =
+					queue->serving_ports[last_idx];
+			queue->num_serving_ports--;
+			return true;
+		}
+	return false;
+}
+
+static int
+dsw_port_link_unlink(struct rte_eventdev *dev, void *port,
+		     const uint8_t queues[], uint16_t num, bool link)
+{
+	struct dsw_evdev *dsw = dsw_pmd_priv(dev);
+	struct dsw_port *p = port;
+	uint16_t i;
+	uint16_t count = 0;
+
+	for (i = 0; i < num; i++) {
+		uint8_t qid = queues[i];
+		struct dsw_queue *q = &dsw->queues[qid];
+		if (link) {
+			queue_add_port(q, p->id);
+			count++;
+		} else {
+			bool removed = queue_remove_port(q, p->id);
+			if (removed)
+				count++;
+		}
+	}
+
+	return count;
+}
+
+static int
+dsw_port_link(struct rte_eventdev *dev, void *port, const uint8_t queues[],
+	      const uint8_t priorities[] __rte_unused, uint16_t num)
+{
+	return dsw_port_link_unlink(dev, port, queues, num, true);
+}
+
+static int
+dsw_port_unlink(struct rte_eventdev *dev, void *port, uint8_t queues[],
+		uint16_t num)
+{
+	return dsw_port_link_unlink(dev, port, queues, num, false);
+}
+
 static void
 dsw_info_get(struct rte_eventdev *dev __rte_unused,
 	     struct rte_event_dev_info *info)
@@ -150,6 +215,8 @@  static struct rte_eventdev_ops dsw_evdev_ops = {
 	.queue_setup = dsw_queue_setup,
 	.queue_def_conf = dsw_queue_def_conf,
 	.queue_release = dsw_queue_release,
+	.port_link = dsw_port_link,
+	.port_unlink = dsw_port_unlink,
 	.dev_infos_get = dsw_info_get,
 	.dev_configure = dsw_configure,
 };
diff --git a/drivers/event/dsw/dsw_evdev.h b/drivers/event/dsw/dsw_evdev.h
index 2a4f10421..ad0f857cc 100644
--- a/drivers/event/dsw/dsw_evdev.h
+++ b/drivers/event/dsw/dsw_evdev.h
@@ -51,6 +51,7 @@  struct dsw_port {
 
 struct dsw_queue {
 	uint8_t schedule_type;
+	uint8_t serving_ports[DSW_MAX_PORTS];
 	uint16_t num_serving_ports;
 };