git: 4bf6ca0e71e2 - releng/13.4 - cxgbe: Flush transmitted packets more regularly in netmap mode

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Thu, 08 Aug 2024 17:28:20 UTC
The branch releng/13.4 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=4bf6ca0e71e2c726f6e662ea95b5c37d1fabf071

commit 4bf6ca0e71e2c726f6e662ea95b5c37d1fabf071
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2024-05-21 19:18:32 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-08-08 17:13:56 +0000

    cxgbe: Flush transmitted packets more regularly in netmap mode
    
    Previously, when transmitting short runs of packets via cxgbe_nm_tx(),
    we would wait until a large number of packets were buffered before
    scheduling a task to clean transmit buffers.
    
    Approved by:    re (cperciva)
    Obtained from:  np
    
    (cherry picked from commit 6af3d59962449c66688361598163dd174cc5fb2a)
    (cherry picked from commit 59a9c20d7736d41be22791ec9a797cc535734ace)
---
 sys/dev/cxgbe/t4_netmap.c | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/sys/dev/cxgbe/t4_netmap.c b/sys/dev/cxgbe/t4_netmap.c
index 581094735c36..b60c1a88168c 100644
--- a/sys/dev/cxgbe/t4_netmap.c
+++ b/sys/dev/cxgbe/t4_netmap.c
@@ -1025,29 +1025,28 @@ cxgbe_nm_tx(struct adapter *sc, struct sge_nm_txq *nm_txq,
 			nm_txq->pidx = 0;
 		}
 
-		if (npkt == 0 && npkt_remaining == 0) {
+		if (npkt + npkt_remaining == 0) {
 			/* All done. */
-			if (lazy_tx_credit_flush == 0) {
+			if (lazy_tx_credit_flush == 0 ||
+			    NMIDXDIFF(nm_txq, equiqidx) >= nm_txq->sidx / 2) {
 				wr->equiq_to_len16 |= htobe32(F_FW_WR_EQUEQ |
 				    F_FW_WR_EQUIQ);
 				nm_txq->equeqidx = nm_txq->pidx;
 				nm_txq->equiqidx = nm_txq->pidx;
+			} else if (NMIDXDIFF(nm_txq, equeqidx) >= 64) {
+				wr->equiq_to_len16 |= htobe32(F_FW_WR_EQUEQ);
+				nm_txq->equeqidx = nm_txq->pidx;
 			}
 			ring_nm_txq_db(sc, nm_txq);
 			return;
 		}
-
-		if (NMIDXDIFF(nm_txq, equiqidx) >= nm_txq->sidx / 2) {
-			wr->equiq_to_len16 |= htobe32(F_FW_WR_EQUEQ |
-			    F_FW_WR_EQUIQ);
-			nm_txq->equeqidx = nm_txq->pidx;
-			nm_txq->equiqidx = nm_txq->pidx;
-		} else if (NMIDXDIFF(nm_txq, equeqidx) >= 64) {
-			wr->equiq_to_len16 |= htobe32(F_FW_WR_EQUEQ);
-			nm_txq->equeqidx = nm_txq->pidx;
-		}
-		if (NMIDXDIFF(nm_txq, dbidx) >= 2 * SGE_MAX_WR_NDESC)
+		if (NMIDXDIFF(nm_txq, dbidx) >= 2 * SGE_MAX_WR_NDESC) {
+			if (NMIDXDIFF(nm_txq, equeqidx) >= 64) {
+				wr->equiq_to_len16 |= htobe32(F_FW_WR_EQUEQ);
+				nm_txq->equeqidx = nm_txq->pidx;
+			}
 			ring_nm_txq_db(sc, nm_txq);
+		}
 	}
 
 	/* Will get called again. */