New upstream version 16.11.8
[deb_dpdk.git] / drivers / net / thunderx / nicvf_rxtx.c
index fc43b74..4b9b293 100644 (file)
@@ -190,12 +190,14 @@ nicvf_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
                free_desc -= TX_DESC_PER_PKT;
        }
 
-       sq->tail = tail;
-       sq->xmit_bufs += i;
-       rte_wmb();
+       if (likely(i)) {
+               sq->tail = tail;
+               sq->xmit_bufs += i;
+               rte_wmb();
 
-       /* Inform HW to xmit the packets */
-       nicvf_addr_write(sq->sq_door, i * TX_DESC_PER_PKT);
+               /* Inform HW to xmit the packets */
+               nicvf_addr_write(sq->sq_door, i * TX_DESC_PER_PKT);
+       }
        return i;
 }
 
@@ -246,13 +248,15 @@ nicvf_xmit_pkts_multiseg(void *tx_queue, struct rte_mbuf **tx_pkts,
                }
        }
 
-       sq->tail = tail;
-       sq->xmit_bufs += used_bufs;
-       rte_wmb();
+       if (likely(used_desc)) {
+               sq->tail = tail;
+               sq->xmit_bufs += used_bufs;
+               rte_wmb();
 
-       /* Inform HW to xmit the packets */
-       nicvf_addr_write(sq->sq_door, used_desc);
-       return nb_pkts;
+               /* Inform HW to xmit the packets */
+               nicvf_addr_write(sq->sq_door, used_desc);
+       }
+       return i;
 }
 
 static const uint32_t ptype_table[16][16] __rte_cache_aligned = {
@@ -469,11 +473,10 @@ nicvf_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
                rxq->head = cqe_head;
                nicvf_addr_write(rxq->cq_door, to_process);
                rxq->recv_buffers += to_process;
-               if (rxq->recv_buffers > rxq->rx_free_thresh) {
-                       rxq->recv_buffers -= nicvf_fill_rbdr(rxq,
-                                               rxq->rx_free_thresh);
-                       NICVF_RX_ASSERT(rxq->recv_buffers >= 0);
-               }
+       }
+       if (rxq->recv_buffers > rxq->rx_free_thresh) {
+               rxq->recv_buffers -= nicvf_fill_rbdr(rxq, rxq->rx_free_thresh);
+               NICVF_RX_ASSERT(rxq->recv_buffers >= 0);
        }
 
        return to_process;
@@ -563,11 +566,10 @@ nicvf_recv_pkts_multiseg(void *rx_queue, struct rte_mbuf **rx_pkts,
                rxq->head = cqe_head;
                nicvf_addr_write(rxq->cq_door, to_process);
                rxq->recv_buffers += buffers_consumed;
-               if (rxq->recv_buffers > rxq->rx_free_thresh) {
-                       rxq->recv_buffers -=
-                               nicvf_fill_rbdr(rxq, rxq->rx_free_thresh);
-                       NICVF_RX_ASSERT(rxq->recv_buffers >= 0);
-               }
+       }
+       if (rxq->recv_buffers > rxq->rx_free_thresh) {
+               rxq->recv_buffers -= nicvf_fill_rbdr(rxq, rxq->rx_free_thresh);
+               NICVF_RX_ASSERT(rxq->recv_buffers >= 0);
        }
 
        return to_process;