aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorR. Christian McDonald <rcm@FreeBSD.org>2026-10-05 18:52:10 +0000
committerR. Christian McDonald <rcm@FreeBSD.org>2026-10-05 18:52:10 +0000
commitac24108dabcac04c7db351d33eb76f3ddee6073b (patch)
treed429b7ba6101ee938d4987d09a14d725eca1e1f4
parente89c3ac5df58a9eae9d01f325ffc9b34258c4b29 (diff)
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
-rw-r--r--sys/net/iflib.c37
1 files 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