crypto/scheduler: fix multicore rings re-use
authorKirill Rybalchenko <kirill.rybalchenko@intel.com>
Wed, 16 May 2018 14:24:31 +0000 (15:24 +0100)
committerPablo de Lara <pablo.de.lara.guarch@intel.com>
Tue, 22 May 2018 14:36:11 +0000 (16:36 +0200)
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 <kirill.rybalchenko@intel.com>
Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Acked-by: Fan Zhang <roy.fan.zhang@intel.com>
Tested-by: Reshma Pattan <reshma.pattan@intel.com>
drivers/crypto/scheduler/scheduler_multicore.c

index 644426e..555c405 100644 (file)
@@ -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;
+                       }
                }
        }