gso: remove the interface count
[vpp.git] / src / vnet / devices / virtio / pci.c
index b02b79d..925c6f5 100644 (file)
@@ -247,7 +247,6 @@ virtio_pci_flag_change (vnet_main_t * vnm, vnet_hw_interface_t * hw,
 static clib_error_t *
 virtio_pci_get_max_virtqueue_pairs (vlib_main_t * vm, virtio_if_t * vif)
 {
-  virtio_main_t *vim = &virtio_main;
   virtio_net_config_t config;
   clib_error_t *error = 0;
   u16 max_queue_pairs = 1;
@@ -261,7 +260,7 @@ virtio_pci_get_max_virtqueue_pairs (vlib_main_t * vm, virtio_if_t * vif)
       max_queue_pairs = config.max_virtqueue_pairs;
     }
 
-  virtio_log_debug (vim, vif, "max queue pair is %x", max_queue_pairs);
+  virtio_log_debug (vif, "max queue pair is %x", max_queue_pairs);
   if (max_queue_pairs < 1 || max_queue_pairs > 0x8000)
     return clib_error_return (error, "max queue pair is %x", max_queue_pairs);
 
@@ -452,31 +451,25 @@ debug_device_config_space (vlib_main_t * vm, virtio_if_t * vif)
     }
 }
 
-struct virtio_ctrl_mq_status_hdr
+struct virtio_ctrl_msg
 {
   struct virtio_net_ctrl_hdr ctrl;
-  struct virtio_net_ctrl_mq num_mqs;
   virtio_net_ctrl_ack status;
+  u8 data[1024];
 };
 
 static int
-virtio_pci_enable_multiqueue (vlib_main_t * vm, virtio_if_t * vif,
-                             u16 num_queues)
+virtio_pci_send_ctrl_msg (vlib_main_t * vm, virtio_if_t * vif,
+                         struct virtio_ctrl_msg *data, u32 len)
 {
-  virtio_main_t *vim = &virtio_main;
   virtio_vring_t *vring = vif->cxq_vring;
+  virtio_net_ctrl_ack status = VIRTIO_NET_ERR;
+  struct virtio_ctrl_msg result;
   u32 buffer_index;
   vlib_buffer_t *b;
   u16 used, next, avail;
   u16 sz = vring->size;
   u16 mask = sz - 1;
-  struct virtio_ctrl_mq_status_hdr mq_hdr, result;
-  virtio_net_ctrl_ack status = VIRTIO_NET_ERR;
-
-  mq_hdr.ctrl.class = VIRTIO_NET_CTRL_MQ;
-  mq_hdr.ctrl.cmd = VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET;
-  mq_hdr.status = VIRTIO_NET_ERR;
-  mq_hdr.num_mqs.virtqueue_pairs = num_queues;
 
   used = vring->desc_in_use;
   next = vring->desc_next;
@@ -492,8 +485,8 @@ virtio_pci_enable_multiqueue (vlib_main_t * vm, virtio_if_t * vif,
    * previous offset.
    */
   b->current_data = 0;
-  clib_memcpy (vlib_buffer_get_current (b), &mq_hdr,
-              sizeof (struct virtio_ctrl_mq_status_hdr));
+  clib_memcpy (vlib_buffer_get_current (b), data,
+              sizeof (struct virtio_ctrl_msg));
   d->flags = VRING_DESC_F_NEXT;
   d->addr = vlib_buffer_get_current_pa (vm, b);
   d->len = sizeof (struct virtio_net_ctrl_hdr);
@@ -506,8 +499,8 @@ virtio_pci_enable_multiqueue (vlib_main_t * vm, virtio_if_t * vif,
   d = &vring->desc[next];
   d->flags = VRING_DESC_F_NEXT;
   d->addr = vlib_buffer_get_current_pa (vm, b) +
-    STRUCT_OFFSET_OF (struct virtio_ctrl_mq_status_hdr, num_mqs);
-  d->len = sizeof (struct virtio_net_ctrl_mq);
+    STRUCT_OFFSET_OF (struct virtio_ctrl_msg, data);
+  d->len = len;
   next = (next + 1) & mask;
   d->next = next;
   used++;
@@ -515,8 +508,8 @@ virtio_pci_enable_multiqueue (vlib_main_t * vm, virtio_if_t * vif,
   d = &vring->desc[next];
   d->flags = VRING_DESC_F_WRITE;
   d->addr = vlib_buffer_get_current_pa (vm, b) +
-    STRUCT_OFFSET_OF (struct virtio_ctrl_mq_status_hdr, status);
-  d->len = sizeof (mq_hdr.status);
+    STRUCT_OFFSET_OF (struct virtio_ctrl_msg, status);
+  d->len = sizeof (data->status);
   next = (next + 1) & mask;
   used++;
 
@@ -530,7 +523,6 @@ virtio_pci_enable_multiqueue (vlib_main_t * vm, virtio_if_t * vif,
       virtio_kick (vm, vring, vif);
     }
 
-  clib_memset (&result, 0, sizeof (result));
   u16 last = vring->last_used_idx, n_left = 0;
   n_left = vring->used->idx - last;
 
@@ -555,15 +547,50 @@ virtio_pci_enable_multiqueue (vlib_main_t * vm, virtio_if_t * vif,
 
   CLIB_MEMORY_BARRIER ();
   clib_memcpy (&result, vlib_buffer_get_current (b),
-              sizeof (struct virtio_ctrl_mq_status_hdr));
-
-  virtio_log_debug (vim, vif, "multi-queue enable status on Ctrl queue : %u",
-                   result.status);
+              sizeof (struct virtio_ctrl_msg));
+  virtio_log_debug (vif, "ctrl-queue: status %u", result.status);
   status = result.status;
   vlib_buffer_free (vm, &buffer_index, 1);
   return status;
 }
 
+static int
+virtio_pci_enable_gso (vlib_main_t * vm, virtio_if_t * vif)
+{
+  struct virtio_ctrl_msg gso_hdr;
+  virtio_net_ctrl_ack status = VIRTIO_NET_ERR;
+
+  gso_hdr.ctrl.class = VIRTIO_NET_CTRL_GUEST_OFFLOADS;
+  gso_hdr.ctrl.cmd = VIRTIO_NET_CTRL_GUEST_OFFLOADS_SET;
+  gso_hdr.status = VIRTIO_NET_ERR;
+  u64 offloads = VIRTIO_FEATURE (VIRTIO_NET_F_GUEST_CSUM)
+    | VIRTIO_FEATURE (VIRTIO_NET_F_GUEST_TSO4)
+    | VIRTIO_FEATURE (VIRTIO_NET_F_GUEST_TSO6)
+    | VIRTIO_FEATURE (VIRTIO_NET_F_GUEST_UFO);
+  clib_memcpy (gso_hdr.data, &offloads, sizeof (offloads));
+
+  status = virtio_pci_send_ctrl_msg (vm, vif, &gso_hdr, sizeof (offloads));
+  virtio_log_debug (vif, "enable gso");
+  return status;
+}
+
+static int
+virtio_pci_enable_multiqueue (vlib_main_t * vm, virtio_if_t * vif,
+                             u16 num_queues)
+{
+  struct virtio_ctrl_msg mq_hdr;
+  virtio_net_ctrl_ack status = VIRTIO_NET_ERR;
+
+  mq_hdr.ctrl.class = VIRTIO_NET_CTRL_MQ;
+  mq_hdr.ctrl.cmd = VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET;
+  mq_hdr.status = VIRTIO_NET_ERR;
+  clib_memcpy (mq_hdr.data, &num_queues, sizeof (num_queues));
+
+  status = virtio_pci_send_ctrl_msg (vm, vif, &mq_hdr, sizeof (num_queues));
+  virtio_log_debug (vif, "multi-queue enable %u queues", num_queues);
+  return status;
+}
+
 static u8
 virtio_pci_queue_size_valid (u16 qsz)
 {
@@ -579,7 +606,6 @@ virtio_pci_control_vring_init (vlib_main_t * vm, virtio_if_t * vif,
                               u16 queue_num)
 {
   clib_error_t *error = 0;
-  virtio_main_t *vim = &virtio_main;
   u16 queue_size = 0;
   virtio_vring_t *vring;
   struct vring vr;
@@ -619,7 +645,7 @@ virtio_pci_control_vring_init (vlib_main_t * vm, virtio_if_t * vif,
   ASSERT (vring->buffers == 0);
 
   vring->size = queue_size;
-  virtio_log_debug (vim, vif, "control-queue: number %u, size %u", queue_num,
+  virtio_log_debug (vif, "control-queue: number %u, size %u", queue_num,
                    queue_size);
   virtio_pci_legacy_setup_queue (vm, vif, queue_num, ptr);
   vring->kick_fd = -1;
@@ -631,7 +657,6 @@ clib_error_t *
 virtio_pci_vring_init (vlib_main_t * vm, virtio_if_t * vif, u16 queue_num)
 {
   clib_error_t *error = 0;
-  virtio_main_t *vim = &virtio_main;
   vlib_thread_main_t *vtm = vlib_get_thread_main ();
   u16 queue_size = 0;
   virtio_vring_t *vring;
@@ -684,26 +709,14 @@ virtio_pci_vring_init (vlib_main_t * vm, virtio_if_t * vif, u16 queue_num)
 
   ASSERT (vring->buffers == 0);
   vec_validate_aligned (vring->buffers, queue_size, CLIB_CACHE_LINE_BYTES);
-  ASSERT (vring->indirect_buffers == 0);
-  vec_validate_aligned (vring->indirect_buffers, queue_size,
-                       CLIB_CACHE_LINE_BYTES);
   if (queue_num % 2)
     {
-      u32 n_alloc = 0;
-      do
-       {
-         if (n_alloc < queue_size)
-           n_alloc =
-             vlib_buffer_alloc (vm, vring->indirect_buffers + n_alloc,
-                                queue_size - n_alloc);
-       }
-      while (n_alloc != queue_size);
-      virtio_log_debug (vim, vif, "tx-queue: number %u, size %u", queue_num,
+      virtio_log_debug (vif, "tx-queue: number %u, size %u", queue_num,
                        queue_size);
     }
   else
     {
-      virtio_log_debug (vim, vif, "rx-queue: number %u, size %u", queue_num,
+      virtio_log_debug (vif, "rx-queue: number %u, size %u", queue_num,
                        queue_size);
     }
   vring->size = queue_size;
@@ -722,8 +735,18 @@ virtio_negotiate_features (vlib_main_t * vm, virtio_if_t * vif,
    * if features are not requested
    * default: all supported features
    */
-  u64 supported_features = VIRTIO_FEATURE (VIRTIO_NET_F_MTU)
+  u64 supported_features = VIRTIO_FEATURE (VIRTIO_NET_F_CSUM)
+    | VIRTIO_FEATURE (VIRTIO_NET_F_GUEST_CSUM)
+    | VIRTIO_FEATURE (VIRTIO_NET_F_CTRL_GUEST_OFFLOADS)
+    | VIRTIO_FEATURE (VIRTIO_NET_F_MTU)
     | VIRTIO_FEATURE (VIRTIO_NET_F_MAC)
+    | VIRTIO_FEATURE (VIRTIO_NET_F_GSO)
+    | VIRTIO_FEATURE (VIRTIO_NET_F_GUEST_TSO4)
+    | VIRTIO_FEATURE (VIRTIO_NET_F_GUEST_TSO6)
+    | VIRTIO_FEATURE (VIRTIO_NET_F_GUEST_UFO)
+    | VIRTIO_FEATURE (VIRTIO_NET_F_HOST_TSO4)
+    | VIRTIO_FEATURE (VIRTIO_NET_F_HOST_TSO6)
+    | VIRTIO_FEATURE (VIRTIO_NET_F_HOST_UFO)
     | VIRTIO_FEATURE (VIRTIO_NET_F_MRG_RXBUF)
     | VIRTIO_FEATURE (VIRTIO_NET_F_STATUS)
     | VIRTIO_FEATURE (VIRTIO_NET_F_CTRL_VQ)
@@ -796,14 +819,13 @@ clib_error_t *
 virtio_pci_read_caps (vlib_main_t * vm, virtio_if_t * vif)
 {
   clib_error_t *error = 0;
-  virtio_main_t *vim = &virtio_main;
   struct virtio_pci_cap cap;
   u8 pos, common_cfg = 0, notify_base = 0, dev_cfg = 0, isr = 0, pci_cfg = 0;
   vlib_pci_dev_handle_t h = vif->pci_dev_handle;
 
   if ((error = vlib_pci_read_config_u8 (vm, h, PCI_CAPABILITY_LIST, &pos)))
     {
-      virtio_log_error (vim, vif, "error in reading capabilty list position");
+      virtio_log_error (vif, "error in reading capabilty list position");
       clib_error_return (error, "error in reading capabilty list position");
     }
   while (pos)
@@ -812,7 +834,7 @@ virtio_pci_read_caps (vlib_main_t * vm, virtio_if_t * vif)
           vlib_pci_read_write_config (vm, h, VLIB_READ, pos, &cap,
                                       sizeof (cap))))
        {
-         virtio_log_error (vim, vif, "%s [%2x]",
+         virtio_log_error (vif, "%s [%2x]",
                            "error in reading the capability at", pos);
          clib_error_return (error,
                             "error in reading the capability at [%2x]", pos);
@@ -830,29 +852,29 @@ virtio_pci_read_caps (vlib_main_t * vm, virtio_if_t * vif)
                               pos + 2);
 
          table_size = flags & table_size_mask;
-         virtio_log_debug (vim, vif, "flags:0x%x %s 0x%x", flags,
+         virtio_log_debug (vif, "flags:0x%x %s 0x%x", flags,
                            "msix interrupt vector table-size", table_size);
 
          if (flags & PCI_MSIX_ENABLE)
            {
-             virtio_log_debug (vim, vif, "msix interrupt enabled");
+             virtio_log_debug (vif, "msix interrupt enabled");
              vif->msix_enabled = VIRTIO_MSIX_ENABLED;
            }
          else
            {
-             virtio_log_debug (vim, vif, "msix interrupt disabled");
+             virtio_log_debug (vif, "msix interrupt disabled");
              vif->msix_enabled = VIRTIO_MSIX_DISABLED;
            }
        }
 
       if (cap.cap_vndr != PCI_CAP_ID_VNDR)
        {
-         virtio_log_debug (vim, vif, "[%2x] %s %2x ", pos,
+         virtio_log_debug (vif, "[%2x] %s %2x ", pos,
                            "skipping non VNDR cap id:", cap.cap_vndr);
          goto next;
        }
 
-      virtio_log_debug (vim, vif,
+      virtio_log_debug (vif,
                        "[%4x] cfg type: %u, bar: %u, offset: %04x, len: %u",
                        pos, cap.cfg_type, cap.bar, cap.offset, cap.length);
       switch (cap.cfg_type)
@@ -880,14 +902,14 @@ virtio_pci_read_caps (vlib_main_t * vm, virtio_if_t * vif)
 
   if (common_cfg == 0 || notify_base == 0 || dev_cfg == 0 || isr == 0)
     {
-      virtio_log_debug (vim, vif, "legacy virtio pci device found");
+      virtio_log_debug (vif, "legacy virtio pci device found");
       return error;
     }
 
   if (!pci_cfg)
     clib_error_return (error, "modern virtio pci device found");
 
-  virtio_log_debug (vim, vif, "transitional virtio pci device found");
+  virtio_log_debug (vif, "transitional virtio pci device found");
   return error;
 }
 
@@ -896,7 +918,6 @@ virtio_pci_device_init (vlib_main_t * vm, virtio_if_t * vif,
                        virtio_pci_create_if_args_t * args)
 {
   clib_error_t *error = 0;
-  virtio_main_t *vim = &virtio_main;
   u8 status = 0;
 
   if ((error = virtio_pci_read_caps (vm, vif)))
@@ -904,7 +925,7 @@ virtio_pci_device_init (vlib_main_t * vm, virtio_if_t * vif,
 
   if (virtio_pci_reset_device (vm, vif) < 0)
     {
-      virtio_log_error (vim, vif, "Failed to reset the device");
+      virtio_log_error (vif, "Failed to reset the device");
       clib_error_return (error, "Failed to reset the device");
     }
   /*
@@ -920,7 +941,7 @@ virtio_pci_device_init (vlib_main_t * vm, virtio_if_t * vif,
   status = virtio_pci_legacy_get_status (vm, vif);
   if (!(status & VIRTIO_CONFIG_STATUS_FEATURES_OK))
     {
-      virtio_log_error (vim, vif,
+      virtio_log_error (vif,
                        "error encountered: Device doesn't support requested features");
       clib_error_return (error, "Device doesn't support requested features");
     }
@@ -954,7 +975,7 @@ virtio_pci_device_init (vlib_main_t * vm, virtio_if_t * vif,
     {
       if ((error = virtio_pci_vring_init (vm, vif, RX_QUEUE (i))))
        {
-         virtio_log_warning (vim, vif, "%s (%u) %s", "error in rxq-queue",
+         virtio_log_warning (vif, "%s (%u) %s", "error in rxq-queue",
                              RX_QUEUE (i), "initialization");
        }
       else
@@ -964,7 +985,7 @@ virtio_pci_device_init (vlib_main_t * vm, virtio_if_t * vif,
 
       if ((error = virtio_pci_vring_init (vm, vif, TX_QUEUE (i))))
        {
-         virtio_log_warning (vim, vif, "%s (%u) %s", "error in txq-queue",
+         virtio_log_warning (vif, "%s (%u) %s", "error in txq-queue",
                              TX_QUEUE (i), "initialization");
        }
       else
@@ -978,8 +999,7 @@ virtio_pci_device_init (vlib_main_t * vm, virtio_if_t * vif,
       if ((error =
           virtio_pci_control_vring_init (vm, vif, vif->max_queue_pairs * 2)))
        {
-         virtio_log_warning (vim, vif, "%s (%u) %s",
-                             "error in control-queue",
+         virtio_log_warning (vif, "%s (%u) %s", "error in control-queue",
                              vif->max_queue_pairs * 2, "initialization");
          if (vif->features & VIRTIO_FEATURE (VIRTIO_NET_F_MQ))
            vif->features &= ~VIRTIO_FEATURE (VIRTIO_NET_F_MQ);
@@ -987,7 +1007,7 @@ virtio_pci_device_init (vlib_main_t * vm, virtio_if_t * vif,
     }
   else
     {
-      virtio_log_debug (vim, vif, "control queue is not available");
+      virtio_log_debug (vif, "control queue is not available");
       vif->cxq_vring = NULL;
     }
 
@@ -998,10 +1018,10 @@ virtio_pci_device_init (vlib_main_t * vm, virtio_if_t * vif,
     {
       if (virtio_pci_legacy_set_config_irq (vm, vif, 1) ==
          VIRTIO_MSI_NO_VECTOR)
-       virtio_log_warning (vim, vif, "config vector 1 is not set");
+       virtio_log_warning (vif, "config vector 1 is not set");
       if (virtio_pci_legacy_set_queue_irq (vm, vif, 0, 0) ==
          VIRTIO_MSI_NO_VECTOR)
-       virtio_log_warning (vim, vif, "queue vector 0 is not set");
+       virtio_log_warning (vif, "queue vector 0 is not set");
     }
 
   /*
@@ -1046,7 +1066,6 @@ virtio_pci_create_if (vlib_main_t * vm, virtio_pci_create_if_args_t * args)
        vlib_pci_device_open (vm, (vlib_pci_addr_t *) & vif->pci_addr,
                             virtio_pci_device_ids, &h)))
     {
-      pool_put (vim->interfaces, vif);
       args->rv = VNET_API_ERROR_INVALID_INTERFACE;
       args->error =
        clib_error_return (error, "pci-addr %U", format_vlib_pci_addr,
@@ -1054,22 +1073,23 @@ virtio_pci_create_if (vlib_main_t * vm, virtio_pci_create_if_args_t * args)
       vlib_log (VLIB_LOG_LEVEL_ERR, vim->log_default, "%U: %s",
                format_vlib_pci_addr, &vif->pci_addr,
                "error encountered on pci device open");
+      pool_put (vim->interfaces, vif);
       return;
     }
   vif->pci_dev_handle = h;
   vlib_pci_set_private_data (vm, h, vif->dev_instance);
   vif->numa_node = vlib_pci_get_numa_node (vm, h);
+  vif->type = VIRTIO_IF_TYPE_PCI;
 
   if ((error = vlib_pci_bus_master_enable (vm, h)))
     {
-      virtio_log_error (vim, vif,
-                       "error encountered on pci bus master enable");
+      virtio_log_error (vif, "error encountered on pci bus master enable");
       goto error;
     }
 
   if ((error = vlib_pci_io_region (vm, h, 0)))
     {
-      virtio_log_error (vim, vif, "error encountered on pci io region");
+      virtio_log_error (vif, "error encountered on pci io region");
       goto error;
     }
 
@@ -1078,26 +1098,25 @@ virtio_pci_create_if (vlib_main_t * vm, virtio_pci_create_if_args_t * args)
       if ((error = vlib_pci_register_msix_handler (vm, h, 0, 1,
                                                   &virtio_pci_irq_0_handler)))
        {
-         virtio_log_error (vim, vif,
+         virtio_log_error (vif,
                            "error encountered on pci register msix handler 0");
          goto error;
        }
       if ((error = vlib_pci_register_msix_handler (vm, h, 1, 1,
                                                   &virtio_pci_irq_1_handler)))
        {
-         virtio_log_error (vim, vif,
+         virtio_log_error (vif,
                            "error encountered on pci register msix handler 1");
          goto error;
        }
 
       if ((error = vlib_pci_enable_msix_irq (vm, h, 0, 2)))
        {
-         virtio_log_error (vim, vif,
-                           "error encountered on pci enable msix irq");
+         virtio_log_error (vif, "error encountered on pci enable msix irq");
          goto error;
        }
       vif->support_int_mode = 1;
-      virtio_log_debug (vim, vif, "device supports msix interrupts");
+      virtio_log_debug (vif, "device supports msix interrupts");
     }
   else if (vlib_pci_get_num_msix_interrupts (vm, h) == 1)
     {
@@ -1107,12 +1126,12 @@ virtio_pci_create_if (vlib_main_t * vm, virtio_pci_create_if_args_t * args)
       if ((error =
           vlib_pci_register_intx_handler (vm, h, &virtio_pci_irq_handler)))
        {
-         virtio_log_error (vim, vif,
+         virtio_log_error (vif,
                            "error encountered on pci register interrupt handler");
          goto error;
        }
       vif->support_int_mode = 1;
-      virtio_log_debug (vim, vif, "pci register interrupt handler");
+      virtio_log_debug (vif, "pci register interrupt handler");
     }
   else
     {
@@ -1121,23 +1140,21 @@ virtio_pci_create_if (vlib_main_t * vm, virtio_pci_create_if_args_t * args)
        * Please don't use interrupt mode with UIO driver.
        */
       vif->support_int_mode = 0;
-      virtio_log_debug (vim, vif, "driver is configured in poll mode only");
+      virtio_log_debug (vif, "driver is configured in poll mode only");
     }
 
   if ((error = vlib_pci_intr_enable (vm, h)))
     {
-      virtio_log_error (vim, vif,
-                       "error encountered on pci interrupt enable");
+      virtio_log_error (vif, "error encountered on pci interrupt enable");
       goto error;
     }
 
   if ((error = virtio_pci_device_init (vm, vif, args)))
     {
-      virtio_log_error (vim, vif, "error encountered on device init");
+      virtio_log_error (vif, "error encountered on device init");
       goto error;
     }
 
-  vif->type = VIRTIO_IF_TYPE_PCI;
   /* create interface */
   error = ethernet_register_interface (vnm, virtio_device_class.index,
                                       vif->dev_instance, vif->mac_addr,
@@ -1146,7 +1163,7 @@ virtio_pci_create_if (vlib_main_t * vm, virtio_pci_create_if_args_t * args)
 
   if (error)
     {
-      virtio_log_error (vim, vif,
+      virtio_log_error (vif,
                        "error encountered on ethernet register interface");
       goto error;
     }
@@ -1177,14 +1194,30 @@ virtio_pci_create_if (vlib_main_t * vm, virtio_pci_create_if_args_t * args)
   else
     vnet_hw_interface_set_flags (vnm, vif->hw_if_index, 0);
 
-  if ((vif->features & VIRTIO_FEATURE (VIRTIO_NET_F_CTRL_VQ)) &&
-      (vif->features & VIRTIO_FEATURE (VIRTIO_NET_F_MQ)))
+  if (vif->features & VIRTIO_FEATURE (VIRTIO_NET_F_CTRL_VQ))
     {
-      if (virtio_pci_enable_multiqueue (vm, vif, vif->max_queue_pairs))
-       virtio_log_warning (vim, vif, "multiqueue is not set");
+      if (vif->features & VIRTIO_FEATURE (VIRTIO_NET_F_CTRL_GUEST_OFFLOADS) &&
+         args->gso_enabled)
+       {
+         if (virtio_pci_enable_gso (vm, vif))
+           {
+             virtio_log_warning (vif, "gso is not enabled");
+           }
+         else
+           {
+             vif->gso_enabled = 1;
+             hw->flags |= VNET_HW_INTERFACE_FLAG_SUPPORTS_GSO;
+           }
+       }
+      if (vif->features & VIRTIO_FEATURE (VIRTIO_NET_F_MQ))
+       {
+         if (virtio_pci_enable_multiqueue (vm, vif, vif->max_queue_pairs))
+           virtio_log_warning (vif, "multiqueue is not set");
+       }
     }
   return;
 
+
 error:
   virtio_pci_delete_if (vm, vif);
   args->rv = VNET_API_ERROR_INVALID_INTERFACE;
@@ -1236,7 +1269,6 @@ virtio_pci_delete_if (vlib_main_t * vm, virtio_if_t * vif)
        virtio_free_rx_buffers (vm, vring);
       }
     vec_free (vring->buffers);
-    vec_free (vring->indirect_buffers);
     vlib_physmem_free (vm, vring->desc);
   }
 
@@ -1249,12 +1281,8 @@ virtio_pci_delete_if (vlib_main_t * vm, virtio_if_t * vif)
       {
        virtio_free_used_desc (vm, vring);
       }
-    if (vring->queue_id % 2)
-      {
-       vlib_buffer_free_no_next (vm, vring->indirect_buffers, vring->size);
-      }
     vec_free (vring->buffers);
-    vec_free (vring->indirect_buffers);
+    clib_spinlock_free (&vring->lockp);
     vlib_physmem_free (vm, vring->desc);
   }
 
@@ -1276,10 +1304,6 @@ virtio_pci_delete_if (vlib_main_t * vm, virtio_if_t * vif)
   vec_free (vif->txq_vrings);
   vec_free (vif->cxq_vring);
 
-  if (vif->fd != -1)
-    vif->fd = -1;
-  if (vif->tap_fd != -1)
-    vif->tap_fd = -1;
   clib_error_free (vif->error);
   memset (vif, 0, sizeof (*vif));
   pool_put (vim->interfaces, vif);