From nobody Wed Oct 28 20:36:02 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 4jFJzR22vYz6x6Kn for ; Wed, 28 Oct 2026 20:36:03 +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) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jFJzQ5xCzz4RTF for ; Wed, 28 Oct 2026 20:36:02 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793219762; 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=snlHc5o5RT+57v9qBhMKhWMBixV+Az9DuqJ28FiXwi8=; b=Etnies1k/XsvoH/przPRwa1LE7MZzhP9K4SpsGy/DqjQH5EpE4gyEA3AN/lsgeBTfMQlEo NJeI03r18EzW9zl4el8OHP2g6M1+P7kPn6JbM0aFzouCK5aRpiB7iEMlpdfwJ0XGTOdtlG HNDojBov9q0WRi4N43znSgudw61UfW1+1NYfVBK0M76kCkAxcSTiV3XknjDL1sxE4CF3Ux kmVOE66wS2Z9Acsmwe47EEmbtinX/crEdDUOHtSIsCIyjiHZ5DmuVi1R3YBSEKrtPZtSPL 6+/z1OnO2jMSuevg/OHSumMt4MirgPnS9fwEpwxsdLYMZpnIDABhIVqSb7S7tA== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1793219762; b=S3qnRipq/YmgECh0RuVNQbwI+gbTehxaagMPStEAspERGyarRsrRTKUB8Jf2AMq2PRj13T 64j0ETZzfatUCjBFFbmYzUQqM2vaDqgh82aYIlVy1viLygxxyCc/r/ekXHaYJATHPDgwFj zelx2oSDzHguL32m2R1eboMD+HIULIn5bM0hQLQw8vr93VbZSwa24Ro9uifFY+VzyjzB5m urG4jopu8cpcjCYEgJgHFUmA+nxLsdJNdFe8n8S32hjTml7u3/cP2wOqgC9RURdCL7yelR LJOQsF87LSnbsN3q5Y6O4dD2dCZAi/NPds3+UY8UoZWvISKofqSqEhaHFKT4Xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793219762; 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=snlHc5o5RT+57v9qBhMKhWMBixV+Az9DuqJ28FiXwi8=; b=aISUTgLGd3wyMDZMsVn0+c6gRZSFKbAZSHVTe9NUJswYV/fraSs3/GTDm/aNzy8ddMw3Jj 7lHY61yS6wDlWbVzw8L+PBz1CxcJru8+KEzwwdE3yvcZvDH54GxAIfaSPtLlshfyiiDqL7 q6jQiq0r8KfvbJOmbipiM0gdIGUa4bd9w0gvuxhDN5t9Kp06UWKmJYgMrvaUIUnKGDT2Hn /O0UIGXvCwOl4ajnIPAVNAPwTRhBv4KWDGv5BZ3Bw/B9U8HFXi7XHw/VddjWVABM1NXES6 I7c9Rud0OIHumkL8xE2EFps5+YkWNyi02C0S612wsSfd1c756PahTRuhcRX6ZA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jFJzQ5YBHz1MkD for ; Wed, 28 Oct 2026 20:36:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1d113 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 28 Oct 2026 20:36:02 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: R. Christian McDonald Subject: git: fe6bf86f76ea - stable/15 - e1000: Fix the flow control sysctl List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org List-Id: Commits to the stable branches of the FreeBSD src repository 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: rcm X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: fe6bf86f76ea4ec4d29dea2801df4845d7bd13cd Auto-Submitted: auto-generated Date: Wed, 28 Oct 2026 20:36:02 +0000 Message-Id: <6ae25cb2.1d113.19ec7a51@gitrepo.freebsd.org> The branch stable/15 has been updated by rcm: URL: https://cgit.FreeBSD.org/src/commit/?id=fe6bf86f76ea4ec4d29dea2801df4845d7bd13cd commit fe6bf86f76ea4ec4d29dea2801df4845d7bd13cd Author: R. Christian McDonald AuthorDate: 2026-10-05 20:21:47 +0000 Commit: R. Christian McDonald CommitDate: 2026-10-28 20:34:18 +0000 e1000: Fix the flow control sysctl dev.em.N.fc and dev.igb.N.fc read and wrote a function-static variable shared by every em(4) and igb(4) device, so a read returned the last value written to any of them (3 until the first write), not the state of the device. The softc value started as 0, which is also the value of "no flow control", while the hardware was set up for full flow control. As a result: - Writing 0 was taken for no change and did nothing, unless another value had been written to that device before. - em_reset() took a softc value of 0 for "not set", so a device set to 0 went back to full flow control on the next init. - On igb(4) with more than one receive queue the driver enabled per-queue drop (SRRCTL.DROP_EN), which is meant for a MAC that does not send pause frames, although the MAC was told to send them. - Values out of range were accepted and ignored. A write only forced the MAC's flow control bits. The pause bits advertised to the link partner, the pause thresholds and DROP_EN stayed as the last init had set them, and the next link event resolved flow control from the stale advertisement again. On 82577 and 82578 (pchlan) a write could also turn on transmit flow control, which em_reset() keeps off there as a workaround. Start the softc value as full, report it, use it as it is in em_reset(), reject invalid values, and apply a change by reinitializing the interface, as the dmac and eee_control sysctls do. This is the same fix as 68386f6b551e ("igc: Fix the flow control sysctl"); igc(4) inherited the handler from this driver. On pchlan, remove transmit pause from the requested mode instead of replacing the mode with receive pause, so that the workaround stays and 0 still turns flow control off. Reviewed by: kbowling MFC after: 2 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D60376 (cherry picked from commit 481447ad9be2e60e0bb3744ab199ce121baadf84) --- sys/dev/e1000/if_em.c | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/sys/dev/e1000/if_em.c b/sys/dev/e1000/if_em.c index b1ac04589c09..6cd7ebce5f0f 100644 --- a/sys/dev/e1000/if_em.c +++ b/sys/dev/e1000/if_em.c @@ -528,6 +528,7 @@ static void em_handle_link(void *); static void em_enable_vectors_82574(if_ctx_t); +static void em_sysctl_request_reinit(struct e1000_softc *); static int em_set_flowcntl(SYSCTL_HANDLER_ARGS); static int em_sysctl_eee(SYSCTL_HANDLER_ARGS); static int igb_sysctl_dmac(SYSCTL_HANDLER_ARGS); @@ -1055,6 +1056,7 @@ em_if_attach_pre(if_ctx_t ctx) CTLTYPE_INT | CTLFLAG_RW, sc, 0, em_sysctl_debug_info, "I", "Debug Information"); + sc->fc = e1000_fc_full; SYSCTL_ADD_PROC(ctx_list, child, OID_AUTO, "fc", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc, 0, em_set_flowcntl, "I", "Flow Control"); @@ -4560,10 +4562,7 @@ em_reset(if_ctx_t ctx) roundup2(hw->mac.max_frame_size, 1024); hw->fc.low_water = hw->fc.high_water - 1500; - if (sc->fc) /* locally set flow control value? */ - hw->fc.requested_mode = sc->fc; - else - hw->fc.requested_mode = e1000_fc_full; + hw->fc.requested_mode = sc->fc; if (hw->mac.type == e1000_80003es2lan) hw->fc.pause_time = 0xFFFF; @@ -4576,7 +4575,10 @@ em_reset(if_ctx_t ctx) switch (hw->mac.type) { case e1000_pchlan: /* Workaround: no TX flow ctrl for PCH */ - hw->fc.requested_mode = e1000_fc_rx_pause; + if (hw->fc.requested_mode == e1000_fc_full) + hw->fc.requested_mode = e1000_fc_rx_pause; + else if (hw->fc.requested_mode == e1000_fc_tx_pause) + hw->fc.requested_mode = e1000_fc_none; hw->fc.pause_time = 0xFFFF; /* override */ if (if_getmtu(ifp) > ETHERMTU) { hw->fc.high_water = 0x3500; @@ -7725,34 +7727,35 @@ em_add_int_delay_sysctl(struct e1000_softc *sc, const char *name, static int em_set_flowcntl(SYSCTL_HANDLER_ARGS) { - int error; - static int input = 3; /* default is full */ + int error, input; struct e1000_softc *sc = (struct e1000_softc *) arg1; + input = sc->fc; error = sysctl_handle_int(oidp, &input, 0, req); if ((error) || (req->newptr == NULL)) return (error); - if (input == sc->fc) /* no change? */ - return (error); - switch (input) { case e1000_fc_rx_pause: case e1000_fc_tx_pause: case e1000_fc_full: case e1000_fc_none: - sc->hw.fc.requested_mode = input; - sc->fc = input; break; default: - /* Do nothing */ - return (error); + return (EINVAL); } - sc->hw.fc.current_mode = sc->hw.fc.requested_mode; - e1000_force_mac_fc(&sc->hw); - return (error); + if (input == sc->fc) /* no change? */ + return (0); + + /* + * The mode is advertised to the link partner and also decides the + * pause thresholds and per-queue drop, so it takes a reinit to apply. + */ + sc->fc = input; + em_sysctl_request_reinit(sc); + return (0); } static void