From nobody Mon Oct 05 20:23:25 2026 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 4hz9nV0Qb2z6vMb2 for ; Mon, 05 Oct 2026 20:23:26 +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 "YR2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hz9nT4yCMz51LT for ; Mon, 05 Oct 2026 20:23:25 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1791231805; 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=j6/W10Gqn0byZtbyqvE2Uqr0GfgR4Cyt/ofLlYLrfNA=; b=pJlzRcfzGiX6PwnGEB2J7S4tFEMqOjFwoSd8Etcn35H6pJi6G2Jfeh9l0CDAFJNJAt2h6P FO8bt90kjIEVu/Mw/cbJu9cLw+Qo7z2xgE6HkkZUoGMHVkLmv4DDzK+VZYo9KsxdF4/aIb n925Ri/ACceW0kg7S221fYDcSRklYP4u3XggfBtQKudUiaTsMrv4owwz/x+RLMEhpdA1AY MxY2YMfSuAnNnodSrz1oZjqo0HGK9azxsqa0STyopSI0SQ8fjeIPV+k5i12nvZqEXXT2Sg JWbfFyBNvxeIpXh7uvRDYSACGSsfIHeuE77uN+t6CUXGaNccfZfjaGz0i+u+jg== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1791231805; b=AT8tyA4i1uv0rV0QhCdt4F31QYeSwqlB24lleXrKuCKUy9Cu9fzwY72ENhExW1qln/aKP0 biT2eG4+1IqMTbn+dkhQnSMMz7LFNJk9OuvXnwSfnC2wi+aiRcos31wEQRR8Z1T5prVUYg 9BXot9pcsQmu/7mM6ihxRcFcef4mjlT3uki4DuG6alVFcx4ye0+MLKvlyHokC3DF5J4lQM BEYD1KDDw/LYjguKKKZGm+ZHgjnxDaCvNfEvr32dgkToid96O7MQ+PuYl/fXeVqPuzite4 QmGbPnlJFbQIBpO6TJPCgs4Uiqs2TMFvpMq629JRnqFRBiZvL+aDduWZYZLkvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1791231805; 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=j6/W10Gqn0byZtbyqvE2Uqr0GfgR4Cyt/ofLlYLrfNA=; b=nQHUZ94kEoV+DqoRUECvHhSLuuRpkrP9TKSsNV28c1UMJan3KgCXin77uPqxzWjqVz+e48 I7VvTyEWWfEcgHRgoVKfBlnjNBaCs1kULv/G1UeEDbqH+HVlr1j/RCI9zqVnMSh8YuK63d uBH7YCea0/5RvteVVSksHmfEWnQN0dc4mPYtqI5wljm34Oc5TMF7zmN4X1ti0um/Bu389F qzF60NtWZ0UJPua7gqGDvw1kxaZkSur+RCjypsCdq5acjet1h3s+4EdG6z7TiXozxGaVVA LhQPaDSC5kQyvyooQQqR+rCYyXtqt7sn4lViDlp/omqg4tEzeLUpeYODBU8VHg== 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 4hz9nT3qsYzcjV for ; Mon, 05 Oct 2026 20:23:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 4407e by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 05 Oct 2026 20:23:25 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: R. Christian McDonald Subject: git: 481447ad9be2 - main - e1000: Fix the flow control sysctl 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 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: rcm X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 481447ad9be2e60e0bb3744ab199ce121baadf84 Auto-Submitted: auto-generated Date: Mon, 05 Oct 2026 20:23:25 +0000 Message-Id: <6ac4073d.4407e.4473e1ff@gitrepo.freebsd.org> The branch main has been updated by rcm: URL: https://cgit.FreeBSD.org/src/commit/?id=481447ad9be2e60e0bb3744ab199ce121baadf84 commit 481447ad9be2e60e0bb3744ab199ce121baadf84 Author: R. Christian McDonald AuthorDate: 2026-10-05 20:21:47 +0000 Commit: R. Christian McDonald CommitDate: 2026-10-05 20:22:44 +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 --- 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 eac1798c9d25..5a44956f2a88 100644 --- a/sys/dev/e1000/if_em.c +++ b/sys/dev/e1000/if_em.c @@ -544,6 +544,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); @@ -1223,6 +1224,7 @@ em_add_device_sysctls(struct e1000_softc *sc) CTLTYPE_STRING | CTLFLAG_RD, sc, 0, em_sysctl_print_fw_version, "A", "Prints FW/NVM Versions"); + 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"); @@ -5095,10 +5097,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; @@ -5111,7 +5110,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; @@ -8533,34 +8535,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