virtio: fix the interrupt

Type: fix

virtio/tap interfaces set the empty buffers in the input node
for receiving data. Backend uses those buffers, fills them with
data and notifies the virtio/tap driver. But virtio/tap driver
gets into stall state if interface is created and configured
through exec script on VPP startup.conf and put the interface in
interrupt mode while VPP is only configured with main thread.

This patch fixes the problem by prefilling buffers during the
interface creation.

Change-Id: Ibc4d0e70e127ccc4b7cf8b2b18406ae4b02c73b4
Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
diff --git a/src/vnet/devices/virtio/virtio.c b/src/vnet/devices/virtio/virtio.c
index 4f812b1..b8054d1 100644
--- a/src/vnet/devices/virtio/virtio.c
+++ b/src/vnet/devices/virtio/virtio.c
@@ -30,6 +30,7 @@
 #include <vnet/ip/ip4_packet.h>
 #include <vnet/ip/ip6_packet.h>
 #include <vnet/devices/virtio/virtio.h>
+#include <vnet/devices/virtio/virtio_inline.h>
 #include <vnet/devices/virtio/pci.h>
 #include <vnet/interface/rx_queue_funcs.h>
 
@@ -220,6 +221,19 @@
   return error;
 }
 
+static void
+virtio_vring_fill (vlib_main_t *vm, virtio_if_t *vif, virtio_vring_t *vring)
+{
+  if (vif->is_packed)
+    virtio_refill_vring_packed (vm, vif, vif->type, vring,
+				vif->virtio_net_hdr_sz,
+				virtio_input_node.index);
+  else
+    virtio_refill_vring_split (vm, vif, vif->type, vring,
+			       vif->virtio_net_hdr_sz,
+			       virtio_input_node.index);
+}
+
 void
 virtio_vring_set_rx_queues (vlib_main_t *vm, virtio_if_t *vif)
 {
@@ -262,6 +276,10 @@
 					      file_index);
 	  i++;
 	}
+      vnet_hw_if_set_rx_queue_mode (vnm, vring->queue_index,
+				    VNET_HW_IF_RX_MODE_POLLING);
+      vring->mode = VNET_HW_IF_RX_MODE_POLLING;
+      virtio_vring_fill (vm, vif, vring);
     }
   vnet_hw_if_update_runtime_data (vnm, vif->hw_if_index);
 }