aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/devices/virtio/virtio.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet/devices/virtio/virtio.c')
-rw-r--r--src/vnet/devices/virtio/virtio.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/vnet/devices/virtio/virtio.c b/src/vnet/devices/virtio/virtio.c
index 90acb75fa6d..a3fd05dbb55 100644
--- a/src/vnet/devices/virtio/virtio.c
+++ b/src/vnet/devices/virtio/virtio.c
@@ -83,9 +83,12 @@ virtio_vring_init (vlib_main_t * vm, virtio_if_t * vif, u16 idx, u16 sz)
if (idx % 2)
{
+ vlib_thread_main_t *thm = vlib_get_thread_main ();
vec_validate_aligned (vif->txq_vrings, TX_QUEUE_ACCESS (idx),
CLIB_CACHE_LINE_BYTES);
vring = vec_elt_at_index (vif->txq_vrings, TX_QUEUE_ACCESS (idx));
+ if (thm->n_vlib_mains > 1)
+ clib_spinlock_init (&vring->lockp);
}
else
{
@@ -230,6 +233,7 @@ virtio_vring_free_tx (vlib_main_t * vm, virtio_if_t * vif, u32 idx)
if (vring->avail)
clib_mem_free (vring->avail);
vec_free (vring->buffers);
+ clib_spinlock_free (&vring->lockp);
return 0;
}