From cc32201a8d834a690d76cd281acf553182894d9f Mon Sep 17 00:00:00 2001 From: Kirill Rybalchenko Date: Wed, 16 May 2018 15:24:31 +0100 Subject: [PATCH] crypto/scheduler: fix multicore rings re-use When scheduler mode changed from multicore to roundrobin and back to multicore, scheduler tries to create memory rings with the same name and fails. The fix allows to lookup and re-use previously allocated memory rings. Fixes: 4c07e0552f0a ("crypto/scheduler: add multicore scheduling mode") Cc: stable@dpdk.org Signed-off-by: Kirill Rybalchenko Acked-by: Pablo de Lara Acked-by: Fan Zhang Tested-by: Reshma Pattan --- .../crypto/scheduler/scheduler_multicore.c | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/drivers/crypto/scheduler/scheduler_multicore.c b/drivers/crypto/scheduler/scheduler_multicore.c index 644426e93b..555c405c10 100644 --- a/drivers/crypto/scheduler/scheduler_multicore.c +++ b/drivers/crypto/scheduler/scheduler_multicore.c @@ -348,18 +348,30 @@ scheduler_create_private_ctx(struct rte_cryptodev *dev) char r_name[16]; snprintf(r_name, sizeof(r_name), MC_SCHED_ENQ_RING_NAME_PREFIX "%u", i); - mc_ctx->sched_enq_ring[i] = rte_ring_create(r_name, PER_SLAVE_BUFF_SIZE, - rte_socket_id(), RING_F_SC_DEQ | RING_F_SP_ENQ); + mc_ctx->sched_enq_ring[i] = rte_ring_lookup(r_name); if (!mc_ctx->sched_enq_ring[i]) { - CS_LOG_ERR("Cannot create ring for worker %u", i); - goto exit; + mc_ctx->sched_enq_ring[i] = rte_ring_create(r_name, + PER_SLAVE_BUFF_SIZE, + rte_socket_id(), + RING_F_SC_DEQ | RING_F_SP_ENQ); + if (!mc_ctx->sched_enq_ring[i]) { + CS_LOG_ERR("Cannot create ring for worker %u", + i); + goto exit; + } } snprintf(r_name, sizeof(r_name), MC_SCHED_DEQ_RING_NAME_PREFIX "%u", i); - mc_ctx->sched_deq_ring[i] = rte_ring_create(r_name, PER_SLAVE_BUFF_SIZE, - rte_socket_id(), RING_F_SC_DEQ | RING_F_SP_ENQ); + mc_ctx->sched_deq_ring[i] = rte_ring_lookup(r_name); if (!mc_ctx->sched_deq_ring[i]) { - CS_LOG_ERR("Cannot create ring for worker %u", i); - goto exit; + mc_ctx->sched_deq_ring[i] = rte_ring_create(r_name, + PER_SLAVE_BUFF_SIZE, + rte_socket_id(), + RING_F_SC_DEQ | RING_F_SP_ENQ); + if (!mc_ctx->sched_deq_ring[i]) { + CS_LOG_ERR("Cannot create ring for worker %u", + i); + goto exit; + } } } -- 2.20.1