From nobody Fri Oct 04 06:42:43 2024 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 4XKf9v27jLz5Y258; Fri, 04 Oct 2024 06:42:43 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XKf9v1X8Mz3y0y; Fri, 4 Oct 2024 06:42:43 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728024163; 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=xlz13UzUnx9VCQA3Q8xhbKAIunXYgxSc3f9mler0pgk=; b=IEyZeuJUnC3Skd7BDYW7/FRpNE/19uvH0xBzavTPXrehUDZxFlahqwhbc6HbJFbGp1Vvjn DZ70j2KiMRTJHUrJmUGEp/61QI0pTic0NXL/3R0EpVpHbv8w7e+KQOfLpPlyT0ZB0GECVt P+StmvegWNwTxz1Fi9IpqMLGWMr23ywKvEEKhlo6IVHQZ1Ci26p4OaDIV9pDFmKuV+C6r9 pOmvSWGP/+3QFglr5I5rqm9G6TF3UNbImMNVsaZMhV7gKAUWrIdGY83yXmz5xANYAtbws6 GexHmf6IpZ/aoCOC+76NtYG+w00JX++Se8zdBjjOqb+A9IqvP4UN6eJykstPIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728024163; 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=xlz13UzUnx9VCQA3Q8xhbKAIunXYgxSc3f9mler0pgk=; b=I3w7JV71/SngOr42zoRdlvg7NaCXcVJfhbPTZYW0LjVaX/Qhs0xlkWFGIAAwLsRtJ3tS68 MRfS3dJmMf2//+1GrS/d1w+KiuGX+15QjVxCROOtU1Pl5/UiNW67Oe2o15vkBt0OBDGDTA BDgI+vrR4hirTDBUSYJyhayfRP41QbcGAecbelZgipsTYUNC7F8Xbujjlrtmmon/X4+ES4 aW2NDNzrMC4e2B2vI8s1yOHevx7L3kaYk8Rfdjnw1RxnRS28U3sA2XYh8hk2vvqi6frql2 qTl7vHTWrv6gxLZ5U1ur2zswnvMFmoG3XnXKN+ob8z3LY+Ffu0uXRnBt0K2EUQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1728024163; a=rsa-sha256; cv=none; b=l62p2XX7rTpfNbJPEUbF9o/peSETbf5FtQ8umWtdXN1k25Fw6mQu3EdFi7lgohxAAh4Pt9 /DRXS5EfMH1jStpFclwWl14sq81wqroPUKTgwtG4v3odfP0trc93B0mCCwcVx9zaO85HKb 95buiz5usd1Iof+nZu4YRHGKChKCCIp/6mlSlZ+tT2CX/Yrd5R+xcolc/tLh10dvRqyTW3 dC4+bcsOdLkVFx9B8Gik2pdpGuE7AKUhyJoar/ByhLPyi5UZGMSm4mquHPYICYqZ0JwWdv IufDWkI9i1jE2Dm4VACJgYn4DligZXtR5sDEK+9rKpRsRRE8VYfuZ3kZwilr0w== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4XKf9v17H8zPJc; Fri, 4 Oct 2024 06:42:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4946ghME016685; Fri, 4 Oct 2024 06:42:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4946ghEB016682; Fri, 4 Oct 2024 06:42:43 GMT (envelope-from git) Date: Fri, 4 Oct 2024 06:42:43 GMT Message-Id: <202410040642.4946ghEB016682@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kevin Bowling Subject: git: 94227aef87bd - stable/13 - e1000: Clean up ITR/EITR in preparation for 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 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/13 X-Git-Reftype: branch X-Git-Commit: 94227aef87bd5233b0996d9ff23d1f839229b20f Auto-Submitted: auto-generated The branch stable/13 has been updated by kbowling: URL: https://cgit.FreeBSD.org/src/commit/?id=94227aef87bd5233b0996d9ff23d1f839229b20f commit 94227aef87bd5233b0996d9ff23d1f839229b20f Author: Kevin Bowling AuthorDate: 2024-09-27 08:03:31 +0000 Commit: Kevin Bowling CommitDate: 2024-10-04 06:42:31 +0000 e1000: Clean up ITR/EITR in preparation for AIM Provide macros to derive the various needed values and make it a bit more clear the differences between em and igb. The igb default EITR was not landing at the right offset. Respect the 'max_interrupt_rate' tunable. Sponsored by: BBOX.io (cherry picked from commit 9bf9164fc8aad1ca828c725413e06462aef1e4dd) --- sys/dev/e1000/if_em.c | 20 ++++++++------------ sys/dev/e1000/if_em.h | 11 +++++++++-- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/sys/dev/e1000/if_em.c b/sys/dev/e1000/if_em.c index 8a3178d737b2..41d3ba093bab 100644 --- a/sys/dev/e1000/if_em.c +++ b/sys/dev/e1000/if_em.c @@ -501,9 +501,6 @@ static driver_t igb_if_driver = { #define EM_TICKS_TO_USECS(ticks) ((1024 * (ticks) + 500) / 1000) #define EM_USECS_TO_TICKS(usecs) ((1000 * (usecs) + 512) / 1024) -#define MAX_INTS_PER_SEC 8000 -#define DEFAULT_ITR (1000000000/(MAX_INTS_PER_SEC * 256)) - /* Allow common code without TSO */ #ifndef CSUM_TSO #define CSUM_TSO 0 @@ -553,7 +550,7 @@ SYSCTL_INT(_hw_em, OID_AUTO, eee_setting, CTLFLAG_RDTUN, &eee_setting, 0, /* ** Tuneable Interrupt rate */ -static int em_max_interrupt_rate = 8000; +static int em_max_interrupt_rate = EM_INTS_PER_SEC; SYSCTL_INT(_hw_em, OID_AUTO, max_interrupt_rate, CTLFLAG_RDTUN, &em_max_interrupt_rate, 0, "Maximum interrupts per second"); @@ -1052,7 +1049,8 @@ em_if_attach_pre(if_ctx_t ctx) E1000_REGISTER(hw, E1000_TADV), em_tx_abs_int_delay_dflt); em_add_int_delay_sysctl(sc, "itr", "interrupt delay limit in usecs/4", &sc->tx_itr, - E1000_REGISTER(hw, E1000_ITR), DEFAULT_ITR); + E1000_REGISTER(hw, E1000_ITR), + EM_INTS_TO_ITR(em_max_interrupt_rate)); } hw->mac.autoneg = DO_AUTO_NEG; @@ -2289,7 +2287,7 @@ igb_configure_queues(struct e1000_softc *sc) /* Set the igb starting interrupt rate */ if (em_max_interrupt_rate > 0) { - newitr = (4000000 / em_max_interrupt_rate) & 0x7FFC; + newitr = IGB_INTS_TO_EITR(em_max_interrupt_rate); if (hw->mac.type == e1000_82575) newitr |= newitr << 16; @@ -3388,11 +3386,9 @@ em_initialize_receive_unit(if_ctx_t ctx) if (hw->mac.type >= e1000_82540) { E1000_WRITE_REG(hw, E1000_RADV, sc->rx_abs_int_delay.value); - /* - * Set the interrupt throttling rate. Value is calculated - * as DEFAULT_ITR = 1/(MAX_INTS_PER_SEC * 256ns) - */ - E1000_WRITE_REG(hw, E1000_ITR, DEFAULT_ITR); + /* Set the default interrupt throttling rate */ + E1000_WRITE_REG(hw, E1000_ITR, + EM_INTS_TO_ITR(em_max_interrupt_rate)); } /* XXX TEMPORARY WORKAROUND: on some systems with 82573 @@ -3420,7 +3416,7 @@ em_initialize_receive_unit(if_ctx_t ctx) if (hw->mac.type == e1000_82574) { for (int i = 0; i < 4; i++) E1000_WRITE_REG(hw, E1000_EITR_82574(i), - DEFAULT_ITR); + EM_INTS_TO_ITR(em_max_interrupt_rate)); /* Disable accelerated acknowledge */ rfctl |= E1000_RFCTL_ACK_DIS; } diff --git a/sys/dev/e1000/if_em.h b/sys/dev/e1000/if_em.h index 244762e8ed0d..7219dc57c333 100644 --- a/sys/dev/e1000/if_em.h +++ b/sys/dev/e1000/if_em.h @@ -244,8 +244,15 @@ #define IGB_MEDIA_RESET (1 << 0) /* Define the starting Interrupt rate per Queue */ -#define IGB_INTS_PER_SEC 8000 -#define IGB_DEFAULT_ITR ((1000000/IGB_INTS_PER_SEC) << 2) +#define EM_INTS_PER_SEC 8000 +#define EM_INTS_MULTIPLIER 256 +#define EM_ITR_DIVIDEND 1000000000 +#define EM_INTS_TO_ITR(i) (EM_ITR_DIVIDEND/(i * EM_INTS_MULTIPLIER)) +#define IGB_ITR_DIVIDEND 1000000 +#define IGB_ITR_SHIFT 2 +#define IGB_QVECTOR_MASK 0x7FFC +#define IGB_INTS_TO_EITR(i) (((IGB_ITR_DIVIDEND/i) & IGB_QVECTOR_MASK) << \ + IGB_ITR_SHIFT) #define IGB_LINK_ITR 2000 #define I210_LINK_DELAY 1000