svn commit: r323293 - stable/10/sys/dev/e1000

Marius Strobl marius at FreeBSD.org
Fri Sep 8 00:11:38 UTC 2017


Author: marius
Date: Fri Sep  8 00:11:35 2017
New Revision: 323293
URL: https://svnweb.freebsd.org/changeset/base/323293

Log:
  - Ever since the workaround for the silicon bug of TSO4 causing MAC hangs
    was committed in r295133 (MFCed to stable/10 in r295287), CSUM_TSO gets
    always disabled by em(4) on the first invocation of em_init_locked() as
    at that point no link is established, yet. In turn, this causes CSUM_TSO
    also to be off when em(4) is used as a parent device for vlan(4), i. e.
    besides IFCAP_TSO4, IFCAP_VLAN_HWTSO effectively doesn't work either.
  
    In head an attempt to fix this was made with r308345, but that revision
    had several problems on its own. One of which was that r308345 caused
    IFCAP_TSO4 to also be cleared from both the interface capability and
    capability enable bits. Thus, once a link switched from gigabit to a
    lower speed, TSO no longer could be enabled, even not via ifconfig(8).
    So this change moves the aforementioned WAR to em_update_link_status()
    like r308345 did, but only alters the hardware assist bits accordingly,
    leaving IFCAP_TSO4 flags alone.
  
    Still, this isn't the only problem r308345 had. Another one is that there
    just is no way to atomically flush TSO-using descriptors already queued
    at the point in time a link speed switch to below GbE occurs. Thus, such
    in-flight descriptors still may hang the MAC. Moreover, at least currently
    there also is no way of triggering a reconfiguration of vlan(4) when the
    state of IFCAP_VLAN_HWTSO support changes at runtime, causing vlan(4) to
    continue employing TSO. Last but not least, testing shows that - despite
    all the WARs for TSO-related silicon bugs in em(4) - at least 82579 still
    may hang at gigabit speed with IFCAP_TSO4 enabled. Therefore, this change
    further removes IFCAP_TSO4 and IFCAP_VLAN_HWTSO from interface capability
    enable bits as set by em(4). While at it, the use of CSUM_TCP is replaced
    with CSUM_IP_TSO as em(4) only implements support for IFCAP_TSO4 but not
    IFCAP_TSO6 (although in principle available with a subset of the supported
    MACs).
  
    At the bottom line, this change allows IFCAP_TSO4 and IFCAP_VLAN_HWTSO to
    be used again with em(4), but these hardware offloading capabilities now
    need to be explicitly enabled via ifconfig(8). Beware that it's only
    considered safe to do so (and also only may work) in environments where
    the link speed is not to be expected to change from GbE. Moreover, em(4)
    appears to still be missing some more TSO workarounds for at least some
    models, specifically the 82579 (I could not find an errata sheet and
    "specification update" respectively for these latter, though, and the
    generic ICH8 one doesn't list any TSO related bugs).
  
  - Let igb_tso_setup() handle EtherType protocols that are unsupported or
    for which support hasn't been compiled in gracefully instead of calling
    panic(9).
  
  - Make em_allocate_{legacy,msix}() and lem_allocate_irq() match their
    prototypes WRT static.
  
  This is a direct commit to stable/10 as corresponding code is no longer
  present in head.
  
  Approved by:	re (gjb, kib)

Modified:
  stable/10/sys/dev/e1000/if_em.c
  stable/10/sys/dev/e1000/if_igb.c
  stable/10/sys/dev/e1000/if_lem.c

Modified: stable/10/sys/dev/e1000/if_em.c
==============================================================================
--- stable/10/sys/dev/e1000/if_em.c	Fri Sep  8 00:11:10 2017	(r323292)
+++ stable/10/sys/dev/e1000/if_em.c	Fri Sep  8 00:11:35 2017	(r323293)
@@ -371,11 +371,6 @@ MODULE_DEPEND(em, ether, 1, 1, 1);
 #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
-#endif
-
 #define TSO_WORKAROUND	4
 
 static SYSCTL_NODE(_hw, OID_AUTO, em, CTLFLAG_RD, 0, "EM driver parameters");
@@ -1406,18 +1401,10 @@ em_init_locked(struct adapter *adapter)
 	E1000_WRITE_REG(&adapter->hw, E1000_VET, ETHERTYPE_VLAN);
 
 	/* Set hardware offload abilities */
-	ifp->if_hwassist = 0;
 	if (ifp->if_capenable & IFCAP_TXCSUM)
 		ifp->if_hwassist |= (CSUM_TCP | CSUM_UDP);
-	/* 
-	** There have proven to be problems with TSO when not
-	** at full gigabit speed, so disable the assist automatically
-	** when at lower speeds.  -jfv
-	*/
-	if (ifp->if_capenable & IFCAP_TSO4) {
-		if (adapter->link_speed == SPEED_1000)
-			ifp->if_hwassist |= CSUM_TSO;
-	}
+	else
+		ifp->if_hwassist &= ~(CSUM_TCP | CSUM_UDP);
 
 	/* Configure for OS presence */
 	em_init_manageability(adapter);
@@ -1933,7 +1920,7 @@ em_xmit(struct tx_ring *txr, struct mbuf **m_headp)
 	bool			do_tso, tso_desc, remap = TRUE;
 
 	m_head = *m_headp;
-	do_tso = (m_head->m_pkthdr.csum_flags & CSUM_TSO);
+	do_tso = m_head->m_pkthdr.csum_flags & CSUM_IP_TSO;
 	tso_desc = FALSE;
 	ip_off = poff = 0;
 
@@ -2120,7 +2107,7 @@ retry:
 	m_head = *m_headp;
 
 	/* Do hardware assists */
-	if (m_head->m_pkthdr.csum_flags & CSUM_TSO) {
+	if (m_head->m_pkthdr.csum_flags & CSUM_IP_TSO) {
 		em_tso_setup(txr, m_head, ip_off, ip, tp,
 		    &txd_upper, &txd_lower);
 		/* we need to make a final sentinel transmit desc */
@@ -2465,6 +2452,19 @@ em_update_link_status(struct adapter *adapter)
 	if (link_check && (adapter->link_active == 0)) {
 		e1000_get_speed_and_duplex(hw, &adapter->link_speed,
 		    &adapter->link_duplex);
+
+		/*
+		** There have proven to be problems with TSO when not at full
+		** gigabit speed, so disable the assist automatically when at
+		** lower speeds.  -jfv
+		*/
+		if (ifp->if_capenable & IFCAP_TSO4) {
+			if (adapter->link_speed == SPEED_1000)
+				ifp->if_hwassist |= CSUM_IP_TSO;
+			else
+				ifp->if_hwassist &= ~CSUM_IP_TSO;
+		}
+
 		/* Check if we must disable SPEED_MODE bit on PCI-E */
 		if ((adapter->link_speed != SPEED_1000) &&
 		    ((hw->mac.type == e1000_82571) ||
@@ -2601,7 +2601,7 @@ em_allocate_pci_resources(struct adapter *adapter)
  *  Setup the Legacy or MSI Interrupt handler
  *
  **********************************************************************/
-int
+static int
 em_allocate_legacy(struct adapter *adapter)
 {
 	device_t dev = adapter->dev;
@@ -2658,7 +2658,7 @@ em_allocate_legacy(struct adapter *adapter)
  *   for TX, RX, and Link.
  *
  **********************************************************************/
-int
+static int
 em_allocate_msix(struct adapter *adapter)
 {
 	device_t	dev = adapter->dev;
@@ -3270,11 +3270,9 @@ em_setup_interface(device_t dev, struct adapter *adapt
 
 	ether_ifattach(ifp, adapter->hw.mac.addr);
 
-	ifp->if_capabilities = ifp->if_capenable = 0;
+	ifp->if_capabilities = IFCAP_HWCSUM | IFCAP_VLAN_HWCSUM;
+	ifp->if_capenable = ifp->if_capabilities;
 
-
-	ifp->if_capabilities |= IFCAP_HWCSUM | IFCAP_VLAN_HWCSUM;
-	ifp->if_capabilities |= IFCAP_TSO4;
 	/*
 	 * Tell the upper layer(s) we
 	 * support full VLAN capability
@@ -3283,7 +3281,26 @@ em_setup_interface(device_t dev, struct adapter *adapt
 	ifp->if_capabilities |= IFCAP_VLAN_HWTAGGING
 			     |  IFCAP_VLAN_HWTSO
 			     |  IFCAP_VLAN_MTU;
-	ifp->if_capenable = ifp->if_capabilities;
+	ifp->if_capenable |= IFCAP_VLAN_HWTAGGING
+			  |  IFCAP_VLAN_MTU;
+
+	/*
+	 * We don't enable IFCAP_{TSO4,VLAN_HWTSO} by default because:
+	 * - Although the silicon bug of TSO only working at gigabit speed is
+	 *   worked around in em_update_link_status() by selectively setting
+	 *   CSUM_IP_TSO, we cannot atomically flush already queued TSO-using
+	 *   descriptors.  Thus, such descriptors may still cause the MAC to
+	 *   hang and, consequently, TSO is only safe to be used in setups
+	 *   where the link isn't expected to switch from gigabit to lower
+	 *   speeds.
+	 * - Similarly, there's currently no way to trigger a reconfiguration
+	 *   of vlan(4) when the state of IFCAP_VLAN_HWTSO support changes at
+	 *   runtime.  Therefore, IFCAP_VLAN_HWTSO also only is safe to use
+	 *   when link speed changes are not to be expected.
+	 * - Despite all the workarounds for TSO-related silicon bugs, at
+	 *   least 82579 still may hang at gigabit speed with IFCAP_TSO4.
+	 */
+	ifp->if_capabilities |= IFCAP_TSO4 | IFCAP_VLAN_HWTSO;
 
 	/*
 	** Don't turn this on by default, if vlans are

Modified: stable/10/sys/dev/e1000/if_igb.c
==============================================================================
--- stable/10/sys/dev/e1000/if_igb.c	Fri Sep  8 00:11:10 2017	(r323292)
+++ stable/10/sys/dev/e1000/if_igb.c	Fri Sep  8 00:11:35 2017	(r323293)
@@ -3737,9 +3737,10 @@ igb_tso_setup(struct tx_ring *txr, struct mbuf *mp,
 		break;
 #endif
 	default:
-		panic("%s: CSUM_TSO but no supported IP version (0x%04x)",
-		    __func__, ntohs(eh_type));
-		break;
+		device_printf(adapter->dev,
+		    "CSUM_TSO but no supported IP version (0x%04x)",
+		    ntohs(eh_type));
+		return (ENXIO);
 	}
 
 	ctxd = txr->next_avail_desc;

Modified: stable/10/sys/dev/e1000/if_lem.c
==============================================================================
--- stable/10/sys/dev/e1000/if_lem.c	Fri Sep  8 00:11:10 2017	(r323292)
+++ stable/10/sys/dev/e1000/if_lem.c	Fri Sep  8 00:11:35 2017	(r323293)
@@ -2336,7 +2336,7 @@ lem_allocate_pci_resources(struct adapter *adapter)
  *  Setup the Legacy or MSI Interrupt handler
  *
  **********************************************************************/
-int
+static int
 lem_allocate_irq(struct adapter *adapter)
 {
 	device_t dev = adapter->dev;


More information about the svn-src-all mailing list