When a single mbuf segment has more data than can be handled by a single
Tx data descriptor in the TSO case, adjust how the storing of mbufs is
being done. Rather than putting the mbuf pointer in the first slot for
that segment, store it in the last slot instead. This guarantees for us
that the descriptor for which we have desc-done (DD) writeback always
has a valid mbuf associated with it.

Signed-off-by: Bruce Richardson <[email protected]>
---
 drivers/net/intel/common/tx_scalar.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/intel/common/tx_scalar.h 
b/drivers/net/intel/common/tx_scalar.h
index 9fcd2e4733..7809bd53e8 100644
--- a/drivers/net/intel/common/tx_scalar.h
+++ b/drivers/net/intel/common/tx_scalar.h
@@ -509,7 +509,6 @@ ci_xmit_pkts(struct ci_tx_queue *txq,
 
                        if (txe->mbuf)
                                rte_pktmbuf_free_seg(txe->mbuf);
-                       txe->mbuf = m_seg;
 
                        /* Setup TX Descriptor */
                        /* Calculate segment length, using IPsec callback if 
provided */
@@ -528,6 +527,7 @@ ci_xmit_pkts(struct ci_tx_queue *txq,
                                        ((uint64_t)CI_MAX_DATA_PER_TXD << 
CI_TXD_QW1_TX_BUF_SZ_S) |
                                        ((uint64_t)td_tag << 
CI_TXD_QW1_L2TAG1_S);
                                write_txd(txd, buf_dma_addr, 
cmd_type_offset_bsz);
+                               txe->mbuf = NULL;
 
                                buf_dma_addr += CI_MAX_DATA_PER_TXD;
                                slen -= CI_MAX_DATA_PER_TXD;
@@ -548,6 +548,7 @@ ci_xmit_pkts(struct ci_tx_queue *txq,
                                ((uint64_t)slen << CI_TXD_QW1_TX_BUF_SZ_S) |
                                ((uint64_t)td_tag << CI_TXD_QW1_L2TAG1_S);
                        write_txd(txd, buf_dma_addr, cmd_type_offset_bsz);
+                       txe->mbuf = m_seg;
 
                        tx_id = txe->next_id;
                        txe = txn;
-- 
2.53.0

Reply via email to