#include <vlib/vlib.h>
#include <vlib/unix/unix.h>
#include <vlib/pci/pci.h>
+#include <vppinfra/ring.h>
#include <vnet/ethernet/ethernet.h>
#include <vnet/devices/devices.h>
u32 n_packets, int use_va_dma)
{
u16 next = txq->next;
- u64 bits = (AVF_TXD_CMD_EOP | AVF_TXD_CMD_RS | AVF_TXD_CMD_RSV);
+ u64 bits = AVF_TXD_CMD_EOP | AVF_TXD_CMD_RSV;
u16 n_desc = 0;
- u16 n_desc_left, n_packets_left = n_packets;
+ u16 *slot, n_desc_left, n_packets_left = n_packets;
u16 mask = txq->size - 1;
vlib_buffer_t *b[4];
avf_tx_desc_t *d = txq->descs + next;
/* avoid ring wrap */
n_desc_left = txq->size - clib_max (txq->next, txq->n_enqueued + 8);
+ if (n_desc_left == 0)
+ return 0;
+
while (n_packets_left && n_desc_left)
{
u32 or_flags;
if (or_flags & VLIB_BUFFER_NEXT_PRESENT)
goto one_by_one;
- clib_memcpy_fast (txq->bufs + next, buffers, sizeof (u32) * 4);
+ vlib_buffer_copy_indices (txq->bufs + next, buffers, 4);
if (use_va_dma)
{
d += 1;
}
+ if ((slot = clib_ring_enq (txq->rs_slots)))
+ {
+ u16 rs_slot = slot[0] = (next - 1) & mask;
+ d = txq->descs + rs_slot;
+ d[0].qword[1] |= AVF_TXD_CMD_RS;
+ }
+
CLIB_MEMORY_BARRIER ();
*(txq->qtx_tail) = txq->next = next & mask;
txq->n_enqueued += n_desc;
avf_txq_t *txq = vec_elt_at_index (ad->txqs, qid % ad->num_queue_pairs);
u32 *buffers = vlib_frame_vector_args (frame);
u16 n_enq, n_left;
- u16 n_retry = 5;
+ u16 n_retry = 2;
clib_spinlock_lock_if_init (&txq->lock);
/* release consumed bufs */
if (txq->n_enqueued)
{
- avf_tx_desc_t *d0;
- u16 first, slot, n_free = 0, mask = txq->size - 1;
- first = slot = (txq->next - txq->n_enqueued) & mask;
- d0 = txq->descs + slot;
- while (n_free < txq->n_enqueued && avf_tx_desc_get_dtyp (d0) == 0x0F)
+ i32 complete_slot = -1;
+ while (1)
{
- n_free++;
- slot = (slot + 1) & mask;
- d0 = txq->descs + slot;
+ u16 *slot = clib_ring_get_first (txq->rs_slots);
+
+ if (slot == 0)
+ break;
+
+ if (avf_tx_desc_get_dtyp (txq->descs + slot[0]) != 0x0F)
+ break;
+
+ complete_slot = slot[0];
+
+ clib_ring_deq (txq->rs_slots);
}
- if (n_free)
+ if (complete_slot >= 0)
{
+ u16 first, mask, n_free;
+ mask = txq->size - 1;
+ first = (txq->next - txq->n_enqueued) & mask;
+ n_free = (complete_slot + 1 - first) & mask;
+
txq->n_enqueued -= n_free;
vlib_buffer_free_from_ring (vm, txq->bufs, first, txq->size,
n_free);