aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMohsin Kazmi <sykazmi@cisco.com>2020-12-10 09:49:21 +0000
committerBeno�t Ganne <bganne@cisco.com>2021-02-08 16:45:34 +0000
commitd8b7decc1d6e7b0e16b4e7558ea37683c4e8db8f (patch)
treea77ebf3d191f15a131b917d571d554ef525b3e31 /src
parent0ebbbfc3c50361dbe8556f14f152613689448812 (diff)
virtio: add atomic call for kicking
Type: fix Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com> Change-Id: I41faa2ca249ff75e564a732af896e6b5d76bf665
Diffstat (limited to 'src')
-rw-r--r--src/vnet/devices/virtio/device.c12
-rw-r--r--src/vnet/devices/virtio/node.c14
-rw-r--r--src/vppinfra/atomics.h3
3 files changed, 9 insertions, 20 deletions
diff --git a/src/vnet/devices/virtio/device.c b/src/vnet/devices/virtio/device.c
index 5796b1d2150..3482336b2ad 100644
--- a/src/vnet/devices/virtio/device.c
+++ b/src/vnet/devices/virtio/device.c
@@ -926,11 +926,11 @@ virtio_interface_tx_split_gso_inline (vlib_main_t * vm,
if (n_left != n_vectors || n_buffers != n_buffers_left)
{
- CLIB_MEMORY_STORE_BARRIER ();
- vring->avail->idx = avail;
+ clib_atomic_store_seq_cst (&vring->avail->idx, avail);
vring->desc_next = next;
vring->desc_in_use = used;
- if ((vring->used->flags & VRING_USED_F_NO_NOTIFY) == 0)
+ if ((clib_atomic_load_seq_cst (&vring->used->flags) &
+ VRING_USED_F_NO_NOTIFY) == 0)
virtio_kick (vm, vring, vif);
}
@@ -997,12 +997,6 @@ VNET_DEVICE_CLASS_TX_FN (virtio_device_class) (vlib_main_t * vm,
clib_spinlock_lock_if_init (&vring->lockp);
- if (packed && (vring->device_event->flags != VRING_EVENT_F_DISABLE))
- virtio_kick (vm, vring, vif);
- else if ((vring->used->flags & VRING_USED_F_NO_NOTIFY) == 0 &&
- (vring->last_kick_avail_idx != vring->avail->idx))
- virtio_kick (vm, vring, vif);
-
if (vif->packet_coalesce)
{
n_vectors = n_left =
diff --git a/src/vnet/devices/virtio/node.c b/src/vnet/devices/virtio/node.c
index 788cc617f61..4a2e305a22e 100644
--- a/src/vnet/devices/virtio/node.c
+++ b/src/vnet/devices/virtio/node.c
@@ -135,12 +135,11 @@ more:
n_slots--;
used++;
}
- CLIB_MEMORY_STORE_BARRIER ();
- vring->avail->idx = avail;
+ clib_atomic_store_seq_cst (&vring->avail->idx, avail);
vring->desc_next = next;
vring->desc_in_use = used;
-
- if ((vring->used->flags & VRING_USED_F_NO_NOTIFY) == 0)
+ if ((clib_atomic_load_seq_cst (&vring->used->flags) &
+ VRING_USED_F_NO_NOTIFY) == 0)
{
virtio_kick (vm, vring, vif);
}
@@ -588,9 +587,6 @@ virtio_device_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
if (vif->is_packed)
{
- if (vring->device_event->flags != VRING_EVENT_F_DISABLE)
- virtio_kick (vm, vring, vif);
-
if (vif->gso_enabled)
rv =
virtio_device_input_gso_inline (vm, node, frame, vif, vring, type,
@@ -609,10 +605,6 @@ virtio_device_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
}
else
{
- if ((vring->used->flags & VRING_USED_F_NO_NOTIFY) == 0 &&
- vring->last_kick_avail_idx != vring->avail->idx)
- virtio_kick (vm, vring, vif);
-
if (vif->gso_enabled)
rv =
virtio_device_input_gso_inline (vm, node, frame, vif, vring, type,
diff --git a/src/vppinfra/atomics.h b/src/vppinfra/atomics.h
index 170b54a8477..5d3c5f8d601 100644
--- a/src/vppinfra/atomics.h
+++ b/src/vppinfra/atomics.h
@@ -50,6 +50,9 @@
#define clib_atomic_load_relax_n(a) __atomic_load_n((a), __ATOMIC_RELAXED)
#define clib_atomic_load_acq_n(a) __atomic_load_n((a), __ATOMIC_ACQUIRE)
#define clib_atomic_store_rel_n(a, b) __atomic_store_n ((a), (b), __ATOMIC_RELEASE)
+#define clib_atomic_store_seq_cst(a, b) \
+ __atomic_store_n ((a), (b), __ATOMIC_SEQ_CST)
+#define clib_atomic_load_seq_cst(a) __atomic_load_n ((a), __ATOMIC_SEQ_CST)
#define clib_atomic_swap_acq_n(a, b) __atomic_exchange_n ((a), (b), __ATOMIC_ACQUIRE)
#define clib_atomic_swap_rel_n(a, b) __atomic_exchange_n ((a), (b), __ATOMIC_RELEASE)