gve_tx_burst_ra() has three bugs on multi-segment bursts and ring wrap:
1. For non-TSO packets, hlen was set to tx_pkt->pkt_len instead of
tx_pkt->data_len and passed as the first descriptor's seg_len,
causing the device to overrun the head mbuf buffer on multi-segment
frames while also transmitting the trailing segment descriptors.
2. When txq->nb_free dropped below nb_used mid-burst, gve_tx_burst_ra()
aborted immediately without calling gve_tx_clean(txq) to reclaim
completed descriptors.
3. Unsent packets left for the caller on ring-full backpressure were
added to txq->stats.errors.
Use tx_pkt->data_len for the head segment of non-TSO frames, attempt
gve_tx_clean() before stopping when descriptors run low mid-burst, and
stop counting normal backpressure as Tx errors.
Fixes: a46583cf43c8 ("net/gve: support Rx/Tx")
Cc: [email protected]
Signed-off-by: Ryan Wolfe <[email protected]>
---
drivers/net/gve/gve_tx.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/net/gve/gve_tx.c b/drivers/net/gve/gve_tx.c
index d344648d0f..14495e3851 100644
--- a/drivers/net/gve/gve_tx.c
+++ b/drivers/net/gve/gve_tx.c
@@ -412,8 +412,11 @@ gve_tx_burst_ra(void *tx_queue, struct rte_mbuf **tx_pkts,
uint16_t nb_pkts)
if (ol_flags & RTE_MBUF_F_TX_TCP_SEG)
nb_used++;
- if (txq->nb_free < nb_used)
- goto end_of_tx;
+ if (txq->nb_free < nb_used) {
+ gve_tx_clean(txq);
+ if (txq->nb_free < nb_used)
+ goto end_of_tx;
+ }
tx_offload.l2_len = tx_pkt->l2_len;
tx_offload.l3_len = tx_pkt->l3_len;
@@ -425,7 +428,7 @@ gve_tx_burst_ra(void *tx_queue, struct rte_mbuf **tx_pkts,
uint16_t nb_pkts)
hlen = ol_flags & RTE_MBUF_F_TX_TCP_SEG ?
(uint32_t)(tx_offload.l2_len + tx_offload.l3_len +
tx_offload.l4_len) :
- tx_pkt->pkt_len;
+ tx_pkt->data_len;
/*
* if tso, the driver needs to fill 2 descs for 1 mbuf
* so only put this mbuf into the 1st tx entry in sw ring
@@ -466,7 +469,6 @@ gve_tx_burst_ra(void *tx_queue, struct rte_mbuf **tx_pkts,
uint16_t nb_pkts)
txq->stats.packets += nb_tx;
txq->stats.bytes += bytes;
- txq->stats.errors += nb_pkts - nb_tx;
}
return nb_tx;