From 0cb8b0a03e86db2b29f8072c04ca2fe9f273eb6f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mattias=20R=C3=B6nnblom?= Date: Tue, 18 Sep 2018 14:45:08 +0200 Subject: [PATCH] event/dsw: support linking/unlinking ports MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Added support for linking and unlinking ports to queues in a DSW event device. Signed-off-by: Mattias Rönnblom Acked-by: Jerin Jacob --- drivers/event/dsw/dsw_evdev.c | 67 +++++++++++++++++++++++++++++++++++ drivers/event/dsw/dsw_evdev.h | 1 + 2 files changed, 68 insertions(+) diff --git a/drivers/event/dsw/dsw_evdev.c b/drivers/event/dsw/dsw_evdev.c index 91b1a24494..5dccc232a4 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 + #include #include @@ -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 2a4f104215..ad0f857cc9 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; }; -- 2.20.1