aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Bowling <kbowling@FreeBSD.org>2023-08-03 05:47:15 +0000
committerKevin Bowling <kbowling@FreeBSD.org>2023-08-10 00:27:12 +0000
commitc68db90db19230cdc579c88003d69bf515f4dd92 (patch)
treead74debd5e7256479b662a34a3d30f49316bd5f9
parent5abba9619cbb6f1cdd598d6eaa80ebd1947fa7f5 (diff)
downloadsrc-c68db90db19230cdc579c88003d69bf515f4dd92.tar.gz
src-c68db90db19230cdc579c88003d69bf515f4dd92.zip
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. Differential Revision: https://reviews.freebsd.org/D41170 (cherry picked from commit 2ddf24f8f52559b08da700ab044c33d0a9ed5601)
-rw-r--r--sys/dev/e1000/if_em.c50
-rw-r--r--sys/dev/e1000/if_em.h1
2 files changed, 49 insertions, 2 deletions
diff --git a/sys/dev/e1000/if_em.c b/sys/dev/e1000/if_em.c
index 88738e5f0a08..bf5fec7e9e3a 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);
@@ -535,6 +536,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,
@@ -939,6 +944,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
@@ -1081,6 +1088,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"
@@ -1819,6 +1829,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 */
@@ -1896,8 +1907,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;
@@ -3878,6 +3895,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;