misc: move to new pool_foreach macros
[vpp.git] / src / plugins / avf / device.c
index bb2dcf7..ffd372d 100644 (file)
@@ -298,6 +298,8 @@ avf_txq_init (vlib_main_t * vm, avf_device_t * ad, u16 qid, u16 txq_size)
 {
   clib_error_t *err;
   avf_txq_t *txq;
+  u8 bpi = vlib_buffer_pool_get_default_for_numa (vm,
+                                                 ad->numa_node);
 
   if (qid >= ad->num_queue_pairs)
     {
@@ -313,6 +315,14 @@ avf_txq_init (vlib_main_t * vm, avf_device_t * ad, u16 qid, u16 txq_size)
   txq = vec_elt_at_index (ad->txqs, qid);
   txq->size = txq_size;
   txq->next = 0;
+
+  /* Prepare a placeholder buffer to maintain a 1-1
+     relationship between bufs and descs when a context
+     descriptor is added in descs */
+  if (!vlib_buffer_alloc_from_pool
+      (vm, &txq->ctx_desc_placeholder_bi, 1, bpi))
+    return clib_error_return (0, "buffer allocation error");
+
   txq->descs = vlib_physmem_alloc_aligned_on_numa (vm, txq->size *
                                                   sizeof (avf_tx_desc_t),
                                                   2 * CLIB_CACHE_LINE_BYTES,
@@ -1297,10 +1307,10 @@ avf_process (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_frame_t * f)
        * during suspend */
       vec_reset_length (dev_pointers);
       /* *INDENT-OFF* */
-      pool_foreach_index (i, am->devices,
+      pool_foreach_index (i, am->devices)
         {
          vec_add1 (dev_pointers, avf_get_device (i));
-       });
+       }
 
       vec_foreach_index (i, dev_pointers)
         {
@@ -1442,6 +1452,8 @@ avf_delete_if (vlib_main_t * vm, avf_device_t * ad, int with_barrier)
          vlib_buffer_free_from_ring (vm, txq->bufs, first, txq->size,
                                      txq->n_enqueued);
        }
+      /* Free the placeholder buffer */
+      vlib_buffer_free_one(vm, txq->ctx_desc_placeholder_bi);
       vec_free (txq->bufs);
       clib_ring_free (txq->rs_slots);
     }
@@ -1507,7 +1519,7 @@ avf_create_if (vlib_main_t * vm, avf_create_if_args_t * args)
     return;
 
   /* *INDENT-OFF* */
-  pool_foreach (adp, am->devices, ({
+  pool_foreach (adp, am->devices)  {
        if ((*adp)->pci_addr.as_u32 == args->addr.as_u32)
       {
        args->rv = VNET_API_ERROR_ADDRESS_IN_USE;
@@ -1516,7 +1528,7 @@ avf_create_if (vlib_main_t * vm, avf_create_if_args_t * args)
                             &args->addr, "pci address in use");
        return;
       }
-  }));
+  }
   /* *INDENT-ON* */
 
   pool_get (am->devices, adp);
@@ -1638,7 +1650,8 @@ avf_create_if (vlib_main_t * vm, avf_create_if_args_t * args)
   vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, ad->hw_if_index);
   hi->flags |=
     VNET_HW_INTERFACE_FLAG_SUPPORTS_MAC_FILTER |
-    VNET_HW_INTERFACE_FLAG_SUPPORTS_TX_L4_CKSUM_OFFLOAD;
+    VNET_HW_INTERFACE_FLAG_SUPPORTS_TX_L4_CKSUM_OFFLOAD |
+    VNET_HW_INTERFACE_FLAG_SUPPORTS_GSO;
   ethernet_set_flags (vnm, ad->hw_if_index,
                      ETHERNET_INTERFACE_FLAG_DEFAULT_L3);