From nobody Fri Sep 27 08:33:31 2024 X-Original-To: dev-commits-src-main@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 4XFNyz4vVlz5XjWq; Fri, 27 Sep 2024 08:33:31 +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 4XFNyz3q6Vz4MdC; Fri, 27 Sep 2024 08:33:31 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1727426011; 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=cF5SqEsOM+jDQii+JzCTxm+gP1WLOlvJdDDhPX7mQWA=; b=bADVbdyXar4oh7q4m+DRzoXuNORh15FcEnfrEbVeykqM0i3AK/fKvWZtASf2bQJtEYutFM ed7Okw3fznf5eGMxs6ForusnxpSZfat1XGhWO7KyJzqHmFi48da/wgPFwr0lhrJk8s2fAg wV7zt5tQ39ySUXIk93+B9QTnF072vB3M9h88APwNwf/Zn0+ZXmfoEYY4460ZMmKXkl2MG5 HJT+c2+9qYKtfjs+Dg/pAA2iujXC+ffa0FNDDhH3ZUArcEO/h8Yd7DDrSw8tiicukZdzGU azuOmRkmtmn7MIzY7irmjbWHCjCHGR4LjVte3cW5WqcukYq4hXYzuzWZdVyEXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1727426011; 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=cF5SqEsOM+jDQii+JzCTxm+gP1WLOlvJdDDhPX7mQWA=; b=FnXI402qdWF9KGF7VxsUPtC/p7SlqNQLv4IFckdrbwjTfTHTfzThZHPwd8HvoQUtRjPj+k 9vldopy6fkkcIGZAU7XrvPwG6toTG1GVOPHsyQ3KhmlI5LkOBjCQIRB9g1jzUZgYZaWKhc cnSvQJ624+skh/wQhWvQopVQNbP4twmwLYgjo3weYV6fMrKzMsVuHbo++ZiyfLGoeLglH7 VM9y6GZNuB05Z75sriojEzRpCT2foCnCQhvCSbd2edwt/D4XhkbAMGXqkbqsfnv6iwIQcI T/NvcbF2Q9r9X58QkS98n31bq2QpFrQSNSU9MwIvbzCHjJ5aIql6QEDaZHbqYQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1727426011; a=rsa-sha256; cv=none; b=Tbwhyq+Ut0woZ2BSwF04Eka4vjOPNnYxhSArQSAfsTliv0XSu4eeznh6wxn0n/UWogfqjh HpOu87q2/fKZTlEnHRBrRm9fKqzbHs+6h92oHkMO1leYNDKXJ5SEHtbu+scMtYNVTpUWvX Gb68kHuRaihgdITF38iDa2wx2WFsUO/aE6WL+253VtOGyKo/93NjWlhQZOFmLyjYxH8TWq 0eY/3v070/66LCYVWen4E9uW0Fhve82ig95fMRgnd6j3fxRrMBsPW1u6ibfJYyw8/kxXf8 XW3IcgF5uyqrRbD4RPLlk89tsGW8bTn60Roxh9Mk72HYRsDV7jAdm9K6zEAOTA== 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 4XFNyz3MdQzZ6Z; Fri, 27 Sep 2024 08:33:31 +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 48R8XV5e047281; Fri, 27 Sep 2024 08:33:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 48R8XVT1047279; Fri, 27 Sep 2024 08:33:31 GMT (envelope-from git) Date: Fri, 27 Sep 2024 08:33:31 GMT Message-Id: <202409270833.48R8XVT1047279@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kevin Bowling Subject: git: 9bf9164fc8aa - main - e1000: Clean up ITR/EITR in preparation for AIM List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 9bf9164fc8aad1ca828c725413e06462aef1e4dd Auto-Submitted: auto-generated The branch main has been updated by kbowling: URL: https://cgit.FreeBSD.org/src/commit/?id=9bf9164fc8aad1ca828c725413e06462aef1e4dd commit 9bf9164fc8aad1ca828c725413e06462aef1e4dd Author: Kevin Bowling AuthorDate: 2024-09-27 08:03:31 +0000 Commit: Kevin Bowling CommitDate: 2024-09-27 08:30:05 +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. MFC after: 1 week Sponsored by: BBOX.io --- 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 cdadec17e355..b9c6131e6741 100644 --- a/sys/dev/e1000/if_em.c +++ b/sys/dev/e1000/if_em.c @@ -499,9 +499,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 @@ -551,7 +548,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"); @@ -1050,7 +1047,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; @@ -2287,7 +2285,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; @@ -3386,11 +3384,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 @@ -3418,7 +3414,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