net/ena: check for free buffers prior Tx
authorJakub Palider <jpa@semihalf.com>
Sat, 29 Oct 2016 01:06:15 +0000 (03:06 +0200)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Mon, 7 Nov 2016 16:56:14 +0000 (17:56 +0100)
Signed-off-by: Tal Avraham <talavr@annapurnalabs.com>
Signed-off-by: Jakub Palider <jpa@semihalf.com>
drivers/net/ena/ena_ethdev.c

index adf94f2..ab9a178 100644 (file)
@@ -1583,7 +1583,7 @@ static uint16_t eth_ena_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
        struct ena_tx_buffer *tx_info;
        struct ena_com_buf *ebuf;
        uint16_t rc, req_id, total_tx_descs = 0;
-       uint16_t sent_idx = 0;
+       uint16_t sent_idx = 0, empty_tx_reqs;
        int nb_hw_desc;
 
        /* Check adapter state */
@@ -1593,6 +1593,10 @@ static uint16_t eth_ena_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
                return 0;
        }
 
+       empty_tx_reqs = ring_size - (next_to_use - next_to_clean);
+       if (nb_pkts > empty_tx_reqs)
+               nb_pkts = empty_tx_reqs;
+
        for (sent_idx = 0; sent_idx < nb_pkts; sent_idx++) {
                mbuf = tx_pkts[sent_idx];