Date: Fri, 24 Apr 2026 22:30:35 +0000 From: Colin Percival <cperciva@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: f6d2c8591c10 - main - ena: Adjust ena_[rt]x_cleanup to return bool Message-ID: <69ebef0b.433f8.6fba5de8@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch main has been updated by cperciva: URL: https://cgit.FreeBSD.org/src/commit/?id=f6d2c8591c10d87050c358ef20428f13c19554ca commit f6d2c8591c10d87050c358ef20428f13c19554ca Author: Colin Percival <cperciva@FreeBSD.org> AuthorDate: 2026-04-17 17:13:44 +0000 Commit: Colin Percival <cperciva@FreeBSD.org> CommitDate: 2026-04-24 22:29:57 +0000 ena: Adjust ena_[rt]x_cleanup to return bool The ena_[rt]x_cleanup functions are limited internally to a maximum number of packets; this ensures that TX doesn't starve RX (or vice versa) and also attempts to ensure that we get a chance to refill the RX buffer ring before the device runs out of buffers and starts dropping packets. Historically these functions have returned the number of packets which they processed which ena_cleanup compares to their respective budgets to decide whether to reinvoke them. This is unnecessary complication; since the precise number of packets processed is never used, adjust the APIs of those functions to return a bool indicating if they want to be reinvoked (aka if they hit their limits). Since ena_tx_cleanup now only uses work_done if diagnostics are enabled (ena_log_io macros to nothing otherwise) eliminate that variable and pass its value (ENA_TX_BUDGET - budget) to ena_log_io directly. No functional change intended; this will simplify a future commit. Reviewed by: akiyano Sponsored by: Amazon MFC after: 6 days Differential Revision: https://reviews.freebsd.org/D56478 --- sys/dev/ena/ena_datapath.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/sys/dev/ena/ena_datapath.c b/sys/dev/ena/ena_datapath.c index ec64ae9324bf..57148d8ef81f 100644 --- a/sys/dev/ena/ena_datapath.c +++ b/sys/dev/ena/ena_datapath.c @@ -42,8 +42,8 @@ * Static functions prototypes *********************************************************************/ -static int ena_tx_cleanup(struct ena_ring *); -static int ena_rx_cleanup(struct ena_ring *); +static bool ena_tx_cleanup(struct ena_ring *); +static bool ena_rx_cleanup(struct ena_ring *); static inline int ena_get_tx_req_id(struct ena_ring *tx_ring, struct ena_com_io_cq *io_cq, uint16_t *req_id); static void ena_rx_hash_mbuf(struct ena_ring *, struct ena_com_rx_ctx *, @@ -73,7 +73,8 @@ ena_cleanup(void *arg, int pending) struct ena_com_io_cq *io_cq; struct ena_eth_io_intr_reg intr_reg; int qid, ena_qid; - int txc, rxc, i; + int i; + bool rx_again, tx_again; tx_ring = que->tx_ring; rx_ring = que->rx_ring; @@ -97,14 +98,14 @@ ena_cleanup(void *arg, int pending) atomic_store_8(&rx_ring->first_interrupt, 1); for (i = 0; i < ENA_CLEAN_BUDGET; ++i) { - rxc = ena_rx_cleanup(rx_ring); - txc = ena_tx_cleanup(tx_ring); + rx_again = ena_rx_cleanup(rx_ring); + tx_again = ena_tx_cleanup(tx_ring); if (unlikely(((if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0) || (ENA_FLAG_ISSET(ENA_FLAG_TRIGGER_RESET, adapter)))) return; - if ((txc != ENA_TX_BUDGET) && (rxc != ENA_RX_BUDGET)) + if (!rx_again && !tx_again) break; } @@ -236,7 +237,7 @@ ena_get_tx_req_id(struct ena_ring *tx_ring, struct ena_com_io_cq *io_cq, * TX_COMMIT. The first check of free descriptor is performed before the actual * loop, then repeated at the loop end. **/ -static int +static bool ena_tx_cleanup(struct ena_ring *tx_ring) { struct ena_adapter *adapter; @@ -248,7 +249,6 @@ ena_tx_cleanup(struct ena_ring *tx_ring) int rc; int commit = ENA_TX_COMMIT; int budget = ENA_TX_BUDGET; - int work_done; bool above_thresh; adapter = tx_ring->que->adapter; @@ -302,10 +302,8 @@ ena_tx_cleanup(struct ena_ring *tx_ring) } } while (likely(--budget)); - work_done = ENA_TX_BUDGET - budget; - ena_log_io(adapter->pdev, DBG, "tx: q %d done. total pkts: %d\n", - tx_ring->qid, work_done); + tx_ring->qid, ENA_TX_BUDGET - budget); /* If there is still something to commit update ring state */ if (likely(commit != ENA_TX_COMMIT)) { @@ -337,7 +335,7 @@ ena_tx_cleanup(struct ena_ring *tx_ring) tx_ring->tx_last_cleanup_ticks = ticks; - return (work_done); + return (budget == 0); } static void @@ -555,7 +553,7 @@ ena_rx_checksum(struct ena_ring *rx_ring, struct ena_com_rx_ctx *ena_rx_ctx, * ena_rx_cleanup - handle rx irq * @arg: ring for which irq is being handled **/ -static int +static bool ena_rx_cleanup(struct ena_ring *rx_ring) { struct ena_adapter *adapter; @@ -697,7 +695,7 @@ ena_rx_cleanup(struct ena_ring *rx_ring) tcp_lro_flush_all(&rx_ring->lro); - return (ENA_RX_BUDGET - budget); + return (budget == 0); } static voidhome | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69ebef0b.433f8.6fba5de8>
