virtio: remove the extra return call
[vpp.git] / src / vnet / devices / virtio / device.c
index 275a3c7..69aca65 100644 (file)
@@ -24,6 +24,8 @@
 #include <vlib/vlib.h>
 #include <vlib/unix/unix.h>
 #include <vnet/ethernet/ethernet.h>
+#include <vnet/ip/ip4_packet.h>
+#include <vnet/ip/ip6_packet.h>
 #include <vnet/devices/virtio/virtio.h>
 
 #define foreach_virtio_tx_func_error          \
@@ -55,7 +57,7 @@ format_virtio_device_name (u8 * s, va_list * args)
 
   if (vif->type == VIRTIO_IF_TYPE_TAP)
     {
-      s = format (s, "tap-%s", vif->name);
+      s = format (s, "tap%u", vif->id);
     }
   else
     s = format (s, "virtio%lu", vif->dev_instance);
@@ -86,7 +88,7 @@ format_virtio_tx_trace (u8 * s, va_list * args)
   return s;
 }
 
-static_always_inline void
+inline void
 virtio_free_used_desc (vlib_main_t * vm, virtio_vring_t * vring)
 {
   u16 used = vring->desc_in_use;
@@ -128,6 +130,9 @@ add_buffer_to_slot (vlib_main_t * vm, virtio_vring_t * vring, u32 bi,
   struct vring_desc *d;
   d = &vring->desc[next];
   vlib_buffer_t *b = vlib_get_buffer (vm, bi);
+  struct virtio_net_hdr_v1 *hdr = vlib_buffer_get_current (b) - hdr_sz;
+
+  clib_memset (hdr, 0, hdr_sz);
 
   if (PREDICT_TRUE ((b->flags & VLIB_BUFFER_NEXT_PRESENT) == 0))
     {
@@ -177,6 +182,8 @@ virtio_interface_tx_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
   u16 mask = sz - 1;
   u32 *buffers = vlib_frame_args (frame);
 
+  clib_spinlock_lock_if_init (&vif->lockp);
+
   /* free consumed buffers */
   virtio_free_used_desc (vm, vring);
 
@@ -216,6 +223,8 @@ virtio_interface_tx_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
       vlib_buffer_free (vm, buffers, n_left);
     }
 
+  clib_spinlock_unlock_if_init (&vif->lockp);
+
   return frame->n_vectors - n_left;
 }
 
@@ -279,14 +288,12 @@ virtio_interface_admin_up_down (vnet_main_t * vnm, u32 hw_if_index, u32 flags)
   virtio_main_t *mm = &virtio_main;
   vnet_hw_interface_t *hw = vnet_get_hw_interface (vnm, hw_if_index);
   virtio_if_t *vif = pool_elt_at_index (mm->interfaces, hw->dev_instance);
-  static clib_error_t *error = 0;
 
   if (flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP)
     vif->flags |= VIRTIO_IF_FLAG_ADMIN_UP;
   else
     vif->flags &= ~VIRTIO_IF_FLAG_ADMIN_UP;
 
-  return error;
   return 0;
 }