[dpdk-dev] [PATCH] event/sw: allow multiple calls to port setup

Harry van Haaren harry.van.haaren at intel.com
Mon Jul 3 15:00:47 CEST 2017


This commit allows port_setup() to be called multiple times,
as is required by the API to re-configure an already initialized port.

Signed-off-by: Harry van Haaren <harry.van.haaren at intel.com>

---

This patch can be squashed with 5/5 of Bruce's event rings patchset:
http://dpdk.org/dev/patchwork/patch/26110/

 drivers/event/sw/sw_evdev.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/event/sw/sw_evdev.c b/drivers/event/sw/sw_evdev.c
index 8588003..5b33bfd 100644
--- a/drivers/event/sw/sw_evdev.c
+++ b/drivers/event/sw/sw_evdev.c
@@ -161,8 +161,16 @@ sw_port_setup(struct rte_eventdev *dev, uint8_t port_id,
 	p->id = port_id;
 	p->sw = sw;
 
+	/* check to see if rings exists - port_setup() can be called multiple
+	 * times legally (assuming device is stopped). If ring exists, free it
+	 * to so it gets re-created with the correct size
+	 */
 	snprintf(buf, sizeof(buf), "sw%d_p%u_%s", dev->data->dev_id,
 			port_id, "rx_worker_ring");
+	struct rte_event_ring *existing_ring = rte_event_ring_lookup(buf);
+	if (existing_ring)
+		rte_event_ring_free(existing_ring);
+
 	p->rx_worker_ring = rte_event_ring_create(buf, MAX_SW_PROD_Q_DEPTH,
 			dev->data->socket_id,
 			RING_F_SP_ENQ | RING_F_SC_DEQ | RING_F_EXACT_SZ);
@@ -174,8 +182,13 @@ sw_port_setup(struct rte_eventdev *dev, uint8_t port_id,
 
 	p->inflight_max = conf->new_event_threshold;
 
+	/* check if ring exists, same as rx_worker above */
 	snprintf(buf, sizeof(buf), "sw%d_p%u, %s", dev->data->dev_id,
 			port_id, "cq_worker_ring");
+	existing_ring = rte_event_ring_lookup(buf);
+	if (existing_ring)
+		rte_event_ring_free(existing_ring);
+
 	p->cq_worker_ring = rte_event_ring_create(buf, conf->dequeue_depth,
 			dev->data->socket_id,
 			RING_F_SP_ENQ | RING_F_SC_DEQ | RING_F_EXACT_SZ);
-- 
2.7.4



More information about the dev mailing list