From nobody Thu Aug 03 05:53:04 2023 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 4RGdL92LSpz4n5b8; Thu, 3 Aug 2023 05:53:05 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4RGdL91TnDz4GYX; Thu, 3 Aug 2023 05:53:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1691041985; 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=WaxKydkxFpJ93P7mgJsYp34BV1GdY+l6YqoazrQjMd4=; b=dHy08n4qCRKERoLSA+a0z+frgv/5JSsHWMf18T7kdkef6HO/KEOdEij8UPcHyyKxpXFVLD i37POq/F+wg40QQT8psY2LbaqXTV6EBe446tAwZx/TmBc0WV2z14ZNwrVZ9llgnURU2hN1 asD1X3Vlt4hbmuele601i7Hk8HxUhwJtUcMdJnLjJhRImBX43hWXXYej1J2mQO4HvAtxhU 610I5M/ANL01KXIRAbUzEzBNywuvyJe6TilKZ3aUaPVVUr0vYrF1fCmTJGTjqLl/AKKw3U Cnbt+NXW7O44pCWP7yW3mqv8H2acA6pi50tA/fguVYkk84UPVkH3mstJsVc1nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1691041985; 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=WaxKydkxFpJ93P7mgJsYp34BV1GdY+l6YqoazrQjMd4=; b=xUN/x7SM8WmuGv2frgzIA+UYioosWzqgdE+WdzHLkkk9iZ70k9lGisSvwGlmPQsAFBLJ9Z KcoTuDnZ2A3GNgq6EF8EoYAVgzkMZCbTL6Pdu6kklZUiVy64vlINVPHsITg1F5iC4mKrMA ZbiDYHAIfeHe3wsVJjBGS+xIgr1iZ84qcs0ItGBaRPdZgksLs7ZW1gU9HVqeaVZaDk0CCs x1X07/q8NAgWcJ+a99vYi1BG1jVM90tXMb8vLNUpz1yqFxg4SH5ECyP4xQ/M+m+vLCL20b ZEcCwIPx5XhsFizWjWNthlh3WiTde+9lZ+7CcvlhckfC7J73Bg1yfZjLRKQSIw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1691041985; a=rsa-sha256; cv=none; b=hsHDLa+GmozjvRwGxbSyjkMk0in0HuwSDNW6YdaJORq8DE/MuyCrRAonyiIA1OhngGi9Rr QwfdCPZusTcDkxEycKYtHNTTJkiX28RyVRRl8nzy/EBYlSPke95Z/AdrG9tCSyg/m7m19r vTOGyrpNuZoIjEqzPycPuEPUrfx4F+2YIb9faIUTEZPwftmrFagSgf3VG44ZHMJCMTMRsp Om/r5VJmU16oy1MO7nEvIKqnbG5b2yTJBdRCBawf+y4p+LW+fum+BNMh/JrdD8NGCIeXeT ioqLHFQ43E1592iLEJsa9fymqK8JAs6bKfXnswSDYbxhQdYt/hmBskx08vcvoQ== 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 4RGdL90bfczJ3m; Thu, 3 Aug 2023 05:53:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3735r4FY077409; Thu, 3 Aug 2023 05:53:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3735r44L077408; Thu, 3 Aug 2023 05:53:04 GMT (envelope-from git) Date: Thu, 3 Aug 2023 05:53:04 GMT Message-Id: <202308030553.3735r44L077408@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: 2ddf24f8f525 - main - e1000: Automask TSO on lem(4)/em(4) 10/100 Ethernet 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: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: 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: 2ddf24f8f52559b08da700ab044c33d0a9ed5601 Auto-Submitted: auto-generated The branch main has been updated by kbowling: URL: https://cgit.FreeBSD.org/src/commit/?id=2ddf24f8f52559b08da700ab044c33d0a9ed5601 commit 2ddf24f8f52559b08da700ab044c33d0a9ed5601 Author: Kevin Bowling AuthorDate: 2023-08-03 05:47:15 +0000 Commit: Kevin Bowling CommitDate: 2023-08-03 05:52:55 +0000 e1000: Automask TSO on lem(4)/em(4) 10/100 Ethernet This feature masks TSO capability when a link comes up at 10 or 100mbit due to errata on the chips. This behavior matches previous versions of FreeBSD as well as NetBSD and Linux. A tunable, hw.em.unsupported_tso may be set if the admin desires to disabling automasking and configure TSO settings manually. MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D41170 --- sys/dev/e1000/if_em.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++-- sys/dev/e1000/if_em.h | 1 + 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/sys/dev/e1000/if_em.c b/sys/dev/e1000/if_em.c index 40579b0a5a55..1da0579cdce9 100644 --- a/sys/dev/e1000/if_em.c +++ b/sys/dev/e1000/if_em.c @@ -330,6 +330,7 @@ static int em_sysctl_debug_info(SYSCTL_HANDLER_ARGS); static int em_get_rs(SYSCTL_HANDLER_ARGS); static void em_print_debug_info(struct e1000_softc *); static int em_is_valid_ether_addr(u8 *); +static bool em_automask_tso(if_ctx_t); static int em_sysctl_int_delay(SYSCTL_HANDLER_ARGS); static void em_add_int_delay_sysctl(struct e1000_softc *, const char *, const char *, struct em_int_delay_info *, int, int); @@ -533,6 +534,10 @@ static int em_smart_pwr_down = false; SYSCTL_INT(_hw_em, OID_AUTO, smart_pwr_down, CTLFLAG_RDTUN, &em_smart_pwr_down, 0, "Set to true to leave smart power down enabled on newer adapters"); +static bool em_unsupported_tso = false; +SYSCTL_BOOL(_hw_em, OID_AUTO, unsupported_tso, CTLFLAG_RDTUN, + &em_unsupported_tso, 0, "Allow unsupported em(4) TSO configurations"); + /* Controls whether promiscuous also shows bad packets */ static int em_debug_sbp = false; SYSCTL_INT(_hw_em, OID_AUTO, sbp, CTLFLAG_RDTUN, &em_debug_sbp, 0, @@ -937,6 +942,8 @@ em_if_attach_pre(if_ctx_t ctx) scctx->isc_tx_tso_size_max = EM_TSO_SIZE; scctx->isc_tx_tso_segsize_max = EM_TSO_SEG_SIZE; scctx->isc_capabilities = scctx->isc_capenable = LEM_CAPS; + if (em_unsupported_tso) + scctx->isc_capabilities |= IFCAP_TSO6; /* * For LEM-class devices, don't enable IFCAP_{TSO4,VLAN_HWTSO} * by default as we don't have workarounds for all associated @@ -1079,6 +1086,9 @@ em_if_attach_pre(if_ctx_t ctx) goto err_late; } + /* Clear the IFCAP_TSO auto mask */ + sc->tso_automasked = 0; + /* Check SOL/IDER usage */ if (e1000_check_reset_block(hw)) device_printf(dev, "PHY reset is blocked" @@ -1817,6 +1827,7 @@ em_if_update_admin_status(if_ctx_t ctx) struct e1000_hw *hw = &sc->hw; device_t dev = iflib_get_dev(ctx); u32 link_check, thstat, ctrl; + bool automasked = false; link_check = thstat = ctrl = 0; /* Get the cached link value or read phy for real */ @@ -1894,8 +1905,14 @@ em_if_update_admin_status(if_ctx_t ctx) sc->flags |= IGB_MEDIA_RESET; em_reset(ctx); } - iflib_link_state_change(ctx, LINK_STATE_UP, - IF_Mbps(sc->link_speed)); + /* Only do TSO on gigabit Ethernet for older chips due to errata */ + if (hw->mac.type < igb_mac_min) + automasked = em_automask_tso(ctx); + + /* Automasking resets the interface, so don't mark it up yet */ + if (!automasked) + iflib_link_state_change(ctx, LINK_STATE_UP, + IF_Mbps(sc->link_speed)); } else if (!link_check && (sc->link_active == 1)) { sc->link_speed = 0; sc->link_duplex = 0; @@ -3876,6 +3893,35 @@ em_is_valid_ether_addr(u8 *addr) return (true); } +static bool +em_automask_tso(if_ctx_t ctx) +{ + struct e1000_softc *sc = iflib_get_softc(ctx); + if_softc_ctx_t scctx = iflib_get_softc_ctx(ctx); + if_t ifp = iflib_get_ifp(ctx); + + if (!em_unsupported_tso && sc->link_speed && + sc->link_speed != SPEED_1000 && scctx->isc_capenable & IFCAP_TSO) { + device_printf(sc->dev, "Disabling TSO for 10/100 Ethernet.\n"); + sc->tso_automasked = scctx->isc_capenable & IFCAP_TSO; + scctx->isc_capenable &= ~IFCAP_TSO; + if_setcapenablebit(ifp, 0, IFCAP_TSO); + /* iflib_init_locked handles ifnet hwassistbits */ + iflib_request_reset(ctx); + return true; + } else if (sc->link_speed == SPEED_1000 && sc->tso_automasked) { + device_printf(sc->dev, "Re-enabling TSO for GbE.\n"); + scctx->isc_capenable |= sc->tso_automasked; + if_setcapenablebit(ifp, sc->tso_automasked, 0); + sc->tso_automasked = 0; + /* iflib_init_locked handles ifnet hwassistbits */ + iflib_request_reset(ctx); + return true; + } + + return false; +} + /* ** Parse the interface capabilities with regard ** to both system management and wake-on-lan for diff --git a/sys/dev/e1000/if_em.h b/sys/dev/e1000/if_em.h index 8c5abf5b48cb..d3c3bc0da097 100644 --- a/sys/dev/e1000/if_em.h +++ b/sys/dev/e1000/if_em.h @@ -509,6 +509,7 @@ struct e1000_softc { u32 smartspeed; u32 dmac; int link_mask; + int tso_automasked; u64 que_mask;