git: cdf77394a8de - stable/15 - iflib: Make the deferral test in iflib_txd_db_check() an early return

From: Kevin Bowling <kbowling_at_FreeBSD.org>
Date: Thu, 29 Oct 2026 06:03:26 UTC
The branch stable/15 has been updated by kbowling:

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

commit cdf77394a8de2e00dc4c2ce4859552e77bb3aa91
Author:     R. Christian McDonald <rcm@FreeBSD.org>
AuthorDate: 2026-10-05 18:52:10 +0000
Commit:     Kevin Bowling <kbowling@FreeBSD.org>
CommitDate: 2026-10-29 05:42:08 +0000

    iflib: Make the deferral test in iflib_txd_db_check() an early return
    
    Invert the test so the doorbell write is no longer nested inside the
    conditional, and wrap its comments to 80 columns.  Fix a typo in one of
    them.
    
    No functional change intended.
    
    Reviewed by:            kbowling
    Sponsored by:           Rubicon Communications, LLC ("Netgate")
    Differential Revision:  https://reviews.freebsd.org/D60371
    
    (cherry picked from commit ac24108dabcac04c7db351d33eb76f3ddee6073b)
---
 sys/net/iflib.c | 37 +++++++++++++++++++------------------
 1 file changed, 19 insertions(+), 18 deletions(-)

diff --git a/sys/net/iflib.c b/sys/net/iflib.c
index a954011660e1..59b76974a3fc 100644
--- a/sys/net/iflib.c
+++ b/sys/net/iflib.c
@@ -3469,26 +3469,27 @@ iflib_txd_db_check(iflib_txq_t txq, int ring)
 
 	max = TXQ_MAX_DB_DEFERRED(txq, txq->ift_in_use);
 
-	/* force || threshold exceeded || at the edge of the ring */
-	if (ring || (txq->ift_db_pending >= max) || (TXQ_AVAIL(txq) <= MAX_TX_DESC(ctx))) {
+	/* Defer unless forced, at the threshold or at the edge of the ring. */
+	if (!ring && txq->ift_db_pending < max &&
+	    TXQ_AVAIL(txq) > MAX_TX_DESC(ctx))
+		return (false);
 
-		/*
-		 * 'npending' is used if the card's doorbell is in terms of the number of descriptors
-		 * pending flush (BRCM). 'pidx' is used in cases where the card's doorbeel uses the
-		 * producer index explicitly (INTC).
-		 */
-		dbval = txq->ift_npending ? txq->ift_npending : txq->ift_pidx;
-		bus_dmamap_sync(txq->ift_ifdi->idi_tag, txq->ift_ifdi->idi_map,
-		    BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
-		ctx->isc_txd_flush(ctx->ifc_softc, txq->ift_id, dbval);
+	/*
+	 * 'npending' is used if the card's doorbell is in terms of the number
+	 * of descriptors pending flush (BRCM). 'pidx' is used in cases where
+	 * the card's doorbell uses the producer index explicitly (INTC).
+	 */
+	dbval = txq->ift_npending ? txq->ift_npending : txq->ift_pidx;
+	bus_dmamap_sync(txq->ift_ifdi->idi_tag, txq->ift_ifdi->idi_map,
+	    BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
+	ctx->isc_txd_flush(ctx->ifc_softc, txq->ift_id, dbval);
 
-		/*
-		 * Absent bugs there are zero packets pending so reset pending counts to zero.
-		 */
-		txq->ift_db_pending = txq->ift_npending = 0;
-		return (true);
-	}
-	return (false);
+	/*
+	 * Absent bugs there are zero packets pending so reset pending counts
+	 * to zero.
+	 */
+	txq->ift_db_pending = txq->ift_npending = 0;
+	return (true);
 }
 
 #ifdef PKT_DEBUG