git: ac24108dabca - main - iflib: Make the deferral test in iflib_txd_db_check() an early return

From: R. Christian McDonald <rcm_at_FreeBSD.org>
Date: Mon, 05 Oct 2026 18:53:11 UTC
The branch main has been updated by rcm:

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

commit ac24108dabcac04c7db351d33eb76f3ddee6073b
Author:     R. Christian McDonald <rcm@FreeBSD.org>
AuthorDate: 2026-10-05 18:52:10 +0000
Commit:     R. Christian McDonald <rcm@FreeBSD.org>
CommitDate: 2026-10-05 18:52:10 +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
---
 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 834cc37cb6ab..358e2f03aded 100644
--- a/sys/net/iflib.c
+++ b/sys/net/iflib.c
@@ -3466,26 +3466,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