Skip to contentSkip to conversation

Question regarding rte_eth_tx_burst()

DISCUSSION Jesus Velazquez 1 participant 1 message Jul 26, 2013

lore
Share & tools
lore
#0 lore raw

Hi all,

Any ideas would be helpful, I have an application that uses a rte_ring for queuing packets to be sent (a single consumer - multiple producer).

The problem I am facing is with rte_eth_tx_burst(), once I dequeue N packets from tx ring, there is no guaranty that all packets will be sent, if not all packets are sent, rte_ring does not allow pushing packets at front (it is a FIFO). So, if I re-queue them in the ring, packets will be network reordered.

There is no mechanism to know the number of TX free descriptors in a particular queue. I'm working with ixgbe and I found that nb_tx_free is an approximation of that, it is updated every time at ixgbe_xmit_cleanup() that is called during ixgbe_xmit_pkts().

I was wondering to add a function that returns nb_tx_free value in order to have an idea of how many packets can be safety sent.

Right now my code does this:

....
nbulk = RTE_MIN(rte_ring_count(queue->tx_ring), (uint16_t)TX_DRAIN_PKTS);

ret = rte_ring_sc_dequeue_bulk(queue->tx_ring, (void **)ptrs, nbulk); if(unlikely(ret < 0))
return 0; /* Not enough objects?, I asked a moment ago */

  ret = rte_eth_tx_burst(queue->port, queue->id, ptrs, nbulk);
  if(unlikely(ret > nbulk)) {
    TRACE(RTE, ">>>Imposible sent more than existing\n");
    return -1;
  }

  while(ret < nbulk) {
    /* bad case: packet reordering */
    ret2 = rte_ring_mp_enqueue(queue->tx_ring, (void *)&ptrs[ret]);
    if(ret2 < 0) {
      /* TODO: may be an emergency tx queue? */
      /* wrost case: dropping */
      rte_pktmbuf_free(ptrs[ret]);
    }
    ret++;
  }

I would appreciate any ideas of how to overcome this situation.

Thanks and regards,

Jesus