From nobody Sun Aug 2 04:27:34 2026 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4hCRc656dkz6n667 for ; Sun, 02 Aug 2026 04:27:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hCRc63wJxz4FTj for ; Sun, 02 Aug 2026 04:27:34 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1785644854; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=1NkNbUHmpD5KQYPSXojjZXv+enYhaakePUeSuRnWWD8=; b=FyLg5h7PQ08bF+DrCUVU9CSb0M5mzPL4c8A0UvHoDDFxwTNBDhTGJTn4opZP/1WpaV7IcE oQJDsqNDCjDseFYDaq3nI2r+dvfy0XNTIa7ddoq5hwHoyBU503602fv9X612HMqs4AEe8u wJxvJCrBSSA4KBazeVLRb9YCJmQi4fYRFwWcEZuO42NFiHoj1UuRWq0I+fkLBNzHY44TGc kqwQqKR7J2nbNdizxbrM7vFN2REg3qlpqyLJ/FdK9Nes0sZxn4S9OGXsp0mSaAj1I19Eh6 Bp24uOamw49h3/+YyEhdByWySGYNDr94An5KFsdhjaq484leNhG6t9bBbNaFXQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1785644854; a=rsa-sha256; cv=none; b=JoQwUMkxzj8BCWAvkEfNeEhGDhXSxxzlp2BLqqoD+bu/4KZfXy869iAjH1sJaHgyCu33Nb 3PnTbngSBhGxa+95QsQCBnLXDw8Qe+ep+UjPOxJFdlvFJ/TKe9K2TAtKPGmmhnhm0vNeuH o488t84W3pKBVl9GRtzTa83dt942acKVXQh8ks11GU2nigHFFRlDrlbSaZVxiBwU5SN9ji TVsLRAQuUtSe8sNYuIcGjs3wk2CibVi4vftJf7R+QGOX8xYgheMYuwktRU6QMZco7IJopq CiKE/3MCyHZcM3Y54+EFA2oHQt0HMZBgTvipO5b3edIjSAffyIRY7I9q10LXZA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1785644854; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=1NkNbUHmpD5KQYPSXojjZXv+enYhaakePUeSuRnWWD8=; b=QCDR64bg4YJCNfAPQs32jO3GkW7DMj04fVPNIPCw0h5S/wW4aEEbAe1Ck6uB5c+GeR27oG KfA3cpbpfNb5LRUMwaV5UKUJRAwLVgttWOCzfKfzxVZW82ECElwrFzA9aeAytrvALxuys6 eO1fdBKplKutQlvymufFTxza4KSDMFfs7T3QCsQW1XT0HEDlqGJIM960cTKKjUpDfwlxv5 f7pxllxn2E12xNa/cGvYlRinrtwWBaqvfPiKpwsD3X1HHlI0m/WPdKPCPI7jKGcNPa0Uav aO5EtXdtfAS8GJHFpAk/esh1MNCpEhDDCYuozs2uJCHH0Vx3NvhiEfS7H8rKow== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hCRc62mNHz1DWl for ; Sun, 02 Aug 2026 04:27:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3bb47 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sun, 02 Aug 2026 04:27:34 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kevin Bowling Subject: git: a1281bfc313e - stable/14 - e1000: restore packet-size AIM List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kbowling X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: a1281bfc313eafc275bfda39084e4ccd403e0632 Auto-Submitted: auto-generated Date: Sun, 02 Aug 2026 04:27:34 +0000 Message-Id: <6a6ec736.3bb47.36e263ae@gitrepo.freebsd.org> The branch stable/14 has been updated by kbowling: URL: https://cgit.FreeBSD.org/src/commit/?id=a1281bfc313eafc275bfda39084e4ccd403e0632 commit a1281bfc313eafc275bfda39084e4ccd403e0632 Author: Kevin Bowling AuthorDate: 2026-07-25 23:49:31 +0000 Commit: Kevin Bowling CommitDate: 2026-08-02 04:25:49 +0000 e1000: restore packet-size AIM Restore the packet-size calculation introduced in a69ed8dfb381 and used by igb(4) until the iflib conversion in f2d6ace4a684. It derives interrupt holdoff from average packet size, so RSS queue count does not change its behavior. The calculation follows the pre-iflib code. Retain the current normal and low-latency rate caps, and keep the current setting when an interval has no usable sample. Fixes: 3e501ef89667 ("e1000: Re-add AIM") (cherry picked from commit dc4a5087b160c1a94d135ab636642defe2c71c20) --- sys/dev/e1000/if_em.c | 170 +++++++++++++++++++------------------------------- sys/dev/e1000/if_em.h | 11 +++- 2 files changed, 73 insertions(+), 108 deletions(-) diff --git a/sys/dev/e1000/if_em.c b/sys/dev/e1000/if_em.c index 9a79cb6115d9..d19de710ae2c 100644 --- a/sys/dev/e1000/if_em.c +++ b/sys/dev/e1000/if_em.c @@ -1685,12 +1685,60 @@ em_aim_tx_delta(struct tx_ring *txr, u32 *bytes, u32 *packets) txr->tx_packets_last = now_packets; } -enum itr_latency_target { - itr_latency_disabled = 0, - itr_latency_lowest = 1, - itr_latency_low = 2, - itr_latency_bulk = 3 -}; +/********************************************************************* + * + * Do Adaptive Interrupt Moderation: + * - Calculate based on average size over the last interval + * + * Returns interrupts per second rather than a register value, so that the + * caller's EM_INTS_TO_ITR()/IGB_INTS_TO_EITR() conversion applies, or zero + * if the interval carried no packet to measure. + * + *********************************************************************/ +static u32 +em_ring_itr(struct e1000_softc *sc, u32 rxbytes, u32 rxpackets, u32 txbytes, + u32 txpackets) +{ + u32 newitr = 0; + + if (txbytes && txpackets) + newitr = txbytes / txpackets; + if (rxbytes && rxpackets) + newitr = max(newitr, rxbytes / rxpackets); + + /* + * No packet was observed, so there is no size to work from. Report no + * observation and let the caller keep the rate it already has. + */ + if (newitr == 0) + return (0); + + newitr += 24; /* account for hardware frame, crc */ + /* set an upper boundary */ + newitr = min(newitr, 3000); + /* Be nice to the mid range */ + if ((newitr > 300) && (newitr < 1200)) + newitr = (newitr / 3); + else + newitr = (newitr / 2); + + /* The value above was written straight to EITR; make it a rate */ + newitr = EM_AIM_DIVIDEND / newitr; + + /* + * Cap the rate: enable_aim=1 is the normal setting, enable_aim=2 opts + * into the low latency end. The original was unbounded and would ask + * for ~95k ints/s on minimum sized frames. There is deliberately no + * floor, so jumbo traffic settles near 2.7k ints/s. + */ + if (sc->enable_aim == 1) + newitr = min(newitr, EM_INTS_20K); + else + newitr = min(newitr, EM_INTS_70K); + + return (newitr); +} + /********************************************************************* * * Helper to calculate next (E)ITR value for AIM @@ -1702,10 +1750,8 @@ em_newitr(struct e1000_softc *sc, struct em_rx_queue *que, { struct e1000_hw *hw = &sc->hw; struct em_tx_queue *tx_que; - u32 bytes, bytes_per_packet, packets; u32 ringbytes, ringpackets, rxbytes, rxpackets, txbytes, txpackets; u32 newitr; - u8 nextlatency; int i; em_aim_rx_delta(rxr, &rxbytes, &rxpackets); @@ -1729,108 +1775,22 @@ em_newitr(struct e1000_softc *sc, struct em_rx_queue *que, if (txbytes == 0 && rxbytes == 0) return; - newitr = 0; - - if (sc->enable_aim) { - nextlatency = rxr->rx_nextlatency; - + if (sc->enable_aim == 0) { + newitr = em_max_interrupt_rate; + } else if (sc->link_speed < SPEED_1000) { /* Use half default (4K) ITR if sub-gig */ - if (sc->link_speed < SPEED_1000) { - newitr = EM_INTS_4K; - goto em_set_next_itr; - } - /* Want at least enough packet buffer for two frames to AIM */ - if (sc->shared->isc_max_frame_size * 2 > (sc->pba << 10)) { - newitr = em_max_interrupt_rate; - goto em_set_next_itr; - } - - bytes = bytes_per_packet = packets = 0; - /* Get largest values from the associated tx and rx ring */ - if (txpackets != 0) { - bytes = txbytes; - bytes_per_packet = txbytes / txpackets; - packets = txpackets; - } - if (rxpackets != 0) { - bytes = lmax(bytes, rxbytes); - bytes_per_packet = - lmax(bytes_per_packet, rxbytes / rxpackets); - packets = lmax(packets, rxpackets); - } - - /* Latency state machine */ - switch (nextlatency) { - case itr_latency_disabled: /* Bootstrapping */ - nextlatency = itr_latency_low; - break; - case itr_latency_lowest: /* 70k ints/s */ - /* TSO and jumbo frames */ - if (bytes_per_packet > 8000) - nextlatency = itr_latency_bulk; - else if ((packets < 5) && (bytes > 512)) - nextlatency = itr_latency_low; - break; - case itr_latency_low: /* 20k ints/s */ - if (bytes > 10000) { - /* Handle TSO */ - if (bytes_per_packet > 8000) - nextlatency = itr_latency_bulk; - else if ((packets < 10) || - (bytes_per_packet > 1200)) - nextlatency = itr_latency_bulk; - else if (packets > 35) - nextlatency = itr_latency_lowest; - } else if (bytes_per_packet > 2000) { - nextlatency = itr_latency_bulk; - } else if (packets < 3 && bytes < 512) { - nextlatency = itr_latency_lowest; - } - break; - case itr_latency_bulk: /* 4k ints/s */ - if (bytes > 25000) { - if (packets > 35) - nextlatency = itr_latency_low; - } else if (bytes < 1500) - nextlatency = itr_latency_low; - break; - default: - nextlatency = itr_latency_low; - device_printf(sc->dev, - "Unexpected newitr transition %d\n", nextlatency); - break; - } - - /* Trim itr_latency_lowest for default AIM setting */ - if (sc->enable_aim == 1 && nextlatency == itr_latency_lowest) - nextlatency = itr_latency_low; - - /* Request new latency */ - rxr->rx_nextlatency = nextlatency; - } else { - /* We may have toggled to AIM disabled */ - nextlatency = itr_latency_disabled; - rxr->rx_nextlatency = nextlatency; - } - - /* ITR state machine */ - switch(nextlatency) { - case itr_latency_lowest: - newitr = EM_INTS_70K; - break; - case itr_latency_low: - newitr = EM_INTS_20K; - break; - case itr_latency_bulk: newitr = EM_INTS_4K; - break; - case itr_latency_disabled: - default: + } else if (sc->shared->isc_max_frame_size * 2 > (sc->pba << 10)) { + /* Want at least enough packet buffer for two frames to AIM */ newitr = em_max_interrupt_rate; - break; + } else { + newitr = em_ring_itr(sc, rxbytes, rxpackets, txbytes, + txpackets); + /* No usable observation; leave the rate where it is */ + if (newitr == 0) + return; } -em_set_next_itr: if (hw->mac.type >= igb_mac_min) { newitr = IGB_INTS_TO_EITR(newitr); diff --git a/sys/dev/e1000/if_em.h b/sys/dev/e1000/if_em.h index 3f71a0ae6358..16da6684c30d 100644 --- a/sys/dev/e1000/if_em.h +++ b/sys/dev/e1000/if_em.h @@ -260,6 +260,14 @@ #define IGB_EITR_TO_INTS(i) ((IGB_EITR_DIVIDEND << IGB_EITR_SHIFT) / \ ((i) & IGB_QVECTOR_MASK)) +/* + * The average packet size calculation in em_ring_itr() yields an EITR + * interval field value. That field is quarter microsecond granular (see + * IGB_EITR_SHIFT), so an interval of V is 1000000 / (V / 4) interrupts per + * second. + */ +#define EM_AIM_DIVIDEND (IGB_EITR_DIVIDEND << IGB_EITR_SHIFT) + #define IGB_LINK_ITR 2000 #define I210_LINK_DELAY 1000 @@ -465,9 +473,6 @@ struct rx_ring { uint64_t rx_aim_snapshot __aligned(8); u32 rx_packets_last; u32 rx_bytes_last; - - /* Next requested ITR latency */ - u8 rx_nextlatency; }; static __inline void