avf: avoid ring wrap in the tx path
[vpp.git] / src / plugins / avf / device.c
index c58b512..e0c3c99 100644 (file)
@@ -336,6 +336,9 @@ avf_txq_init (vlib_main_t * vm, avf_device_t * ad, u16 qid, u16 txq_size)
   /* initialize ring of pending RS slots */
   clib_ring_new_aligned (txq->rs_slots, 32, CLIB_CACHE_LINE_BYTES);
 
+  vec_validate_aligned (txq->tmp_descs, txq->size, CLIB_CACHE_LINE_BYTES);
+  vec_validate_aligned (txq->tmp_bufs, txq->size, CLIB_CACHE_LINE_BYTES);
+
   ad->n_tx_queues = clib_min (ad->num_queue_pairs, qid + 1);
   return 0;
 }
@@ -1469,6 +1472,7 @@ avf_delete_if (vlib_main_t * vm, avf_device_t * ad, int with_barrier)
   vnet_main_t *vnm = vnet_get_main ();
   avf_main_t *am = &avf_main;
   int i;
+  u32 dev_instance;
 
   ad->flags &= ~AVF_DEVICE_F_ADMIN_UP;
 
@@ -1517,14 +1521,17 @@ avf_delete_if (vlib_main_t * vm, avf_device_t * ad, int with_barrier)
       vlib_buffer_free_one(vm, txq->ctx_desc_placeholder_bi);
       vec_free (txq->bufs);
       clib_ring_free (txq->rs_slots);
+      vec_free (txq->tmp_bufs);
+      vec_free (txq->tmp_descs);
     }
   /* *INDENT-ON* */
   vec_free (ad->txqs);
   vec_free (ad->name);
 
   clib_error_free (ad->error);
+  dev_instance = ad->dev_instance;
   clib_memset (ad, 0, sizeof (*ad));
-  pool_put_index (am->devices, ad->dev_instance);
+  pool_put_index (am->devices, dev_instance);
   clib_mem_free (ad);
 }