summaryrefslogtreecommitdiffstats
path: root/src/plugins/memif
diff options
context:
space:
mode:
authorNathan Skrzypczak <nathan.skrzypczak@gmail.com>2022-01-07 16:02:02 +0100
committerDamjan Marion <dmarion@me.com>2022-03-18 10:10:22 +0000
commit6798e9ec34a49df008ecb7f84559e531f6c0d651 (patch)
tree66144d952a4b102317d9d23b260ac6d21d88abef /src/plugins/memif
parent0b77e312827f68251f10ac1f674e3e564059fc52 (diff)
memif: fix rx/txqueue RC on connected
Type: fix Calling vnet_hw_if_register_tx_queue should be done with the worker barrier held, as virtio-pre-input might be grabbing a queue while a memif connect event is triggered. Change-Id: Ie1272cdfd2477faf7a4e10f30778279872f04916 Signed-off-by: Nathan Skrzypczak <nathan.skrzypczak@gmail.com>
Diffstat (limited to 'src/plugins/memif')
-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;
}