virtio: add atomic call for kicking

Type: fix

Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
Change-Id: I41faa2ca249ff75e564a732af896e6b5d76bf665
diff --git a/src/vnet/devices/virtio/device.c b/src/vnet/devices/virtio/device.c
index 5796b1d..3482336 100644
--- a/src/vnet/devices/virtio/device.c
+++ b/src/vnet/devices/virtio/device.c
@@ -926,11 +926,11 @@
 
   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 @@
 
   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 788cc61..4a2e305 100644
--- a/src/vnet/devices/virtio/node.c
+++ b/src/vnet/devices/virtio/node.c
@@ -135,12 +135,11 @@
       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 @@
 
   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 @@
     }
   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,