summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/plugins/memif/memif.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/plugins/memif/memif.c b/src/plugins/memif/memif.c
index 2b25a82f5dd..b89665f9a29 100644
--- a/src/plugins/memif/memif.c
+++ b/src/plugins/memif/memif.c
@@ -248,6 +248,7 @@ memif_connect (memif_if_t * mif)
u32 n_txqs = 0, n_threads = vlib_get_n_threads ();
clib_error_t *err = NULL;
u8 max_log2_ring_sz = 0;
+ int with_barrier = 0;
memif_log_debug (mif, "connect %u", mif->dev_instance);
@@ -278,6 +279,13 @@ memif_connect (memif_if_t * mif)
template.read_function = memif_int_fd_read_ready;
template.write_function = memif_int_fd_write_ready;
+ with_barrier = 1;
+ if (vlib_worker_thread_barrier_held ())
+ with_barrier = 0;
+
+ if (with_barrier)
+ vlib_worker_thread_barrier_sync (vm);
+
/* *INDENT-OFF* */
vec_foreach_index (i, mif->tx_queues)
{
@@ -359,13 +367,6 @@ memif_connect (memif_if_t * mif)
if (1 << max_log2_ring_sz > vec_len (mm->per_thread_data[0].desc_data))
{
memif_per_thread_data_t *ptd;
- int with_barrier = 1;
-
- if (vlib_worker_thread_barrier_held ())
- with_barrier = 0;
-
- if (with_barrier)
- vlib_worker_thread_barrier_sync (vm);
vec_foreach (ptd, mm->per_thread_data)
{
@@ -376,9 +377,9 @@ memif_connect (memif_if_t * mif)
vec_validate_aligned (ptd->desc_status, pow2_mask (max_log2_ring_sz),
CLIB_CACHE_LINE_BYTES);
}
- if (with_barrier)
- vlib_worker_thread_barrier_release (vm);
}
+ if (with_barrier)
+ vlib_worker_thread_barrier_release (vm);
mif->flags &= ~MEMIF_IF_FLAG_CONNECTING;
mif->flags |= MEMIF_IF_FLAG_CONNECTED;
@@ -388,6 +389,8 @@ memif_connect (memif_if_t * mif)
return 0;
error:
+ if (with_barrier)
+ vlib_worker_thread_barrier_release (vm);
memif_log_err (mif, "%U", format_clib_error, err);
return err;
}