Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 21 Feb 2011 00:47:39 +0000 (UTC)
From:      Pyun YongHyeon <yongari@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r218897 - in stable/8/sys: dev/re pci
Message-ID:  <201102210047.p1L0ldm4050089@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: yongari
Date: Mon Feb 21 00:47:39 2011
New Revision: 218897
URL: http://svn.freebsd.org/changeset/base/218897

Log:
  MFC r217246,217832:
  r217246:
    Implement TSO on RealTek RTL8168/8111 C or later controllers.
    RealTek changed TX descriptor format for later controllers so these
    controllers require MSS configuration in different location of TX
    descriptor. TSO is enabled by default for controllers that use new
    descriptor format.
    For old controllers, TSO is still disabled by default due to broken
    frames under certain conditions but users can enable it.
    Special thanks to Hayes Wang at RealTek.
  
  r217832:
    Disable TSO for all Realtek controllers. Experimentation showed
    RTL8111C generated corrupted frames where TCP option header was
    broken. All other sample controllers I have did not show such
    problem so it could be RTL8111C specific issue. Because there are
    too many variants it's hard to tell how many controllers have such
    issue. Just disable TSO by default but have user override it.

Modified:
  stable/8/sys/dev/re/if_re.c
  stable/8/sys/pci/if_rlreg.h
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)

Modified: stable/8/sys/dev/re/if_re.c
==============================================================================
--- stable/8/sys/dev/re/if_re.c	Sun Feb 20 22:32:21 2011	(r218896)
+++ stable/8/sys/dev/re/if_re.c	Mon Feb 21 00:47:39 2011	(r218897)
@@ -1460,8 +1460,8 @@ re_attach(device_t dev)
 	ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
 	ifp->if_ioctl = re_ioctl;
 	ifp->if_start = re_start;
-	ifp->if_hwassist = RE_CSUM_FEATURES;
-	ifp->if_capabilities = IFCAP_HWCSUM;
+	ifp->if_hwassist = RE_CSUM_FEATURES | CSUM_TSO;
+	ifp->if_capabilities = IFCAP_HWCSUM | IFCAP_TSO4;
 	ifp->if_capenable = ifp->if_capabilities;
 	ifp->if_init = re_init;
 	IFQ_SET_MAXLEN(&ifp->if_snd, RL_IFQ_MAXLEN);
@@ -1472,16 +1472,6 @@ re_attach(device_t dev)
 	TASK_INIT(&sc->rl_inttask, 0, re_int_task, sc);
 
 	/*
-	 * XXX
-	 * Still have no idea how to make TSO work on 8168C, 8168CP,
-	 * 8111C and 8111CP.
-	 */
-	if ((sc->rl_flags & RL_FLAG_DESCV2) == 0) {
-		ifp->if_hwassist |= CSUM_TSO;
-		ifp->if_capabilities |= IFCAP_TSO4 | IFCAP_VLAN_HWTSO;
-	}
-
-	/*
 	 * Call MI attach routine.
 	 */
 	ether_ifattach(ifp, eaddr);
@@ -1495,9 +1485,9 @@ re_attach(device_t dev)
 		ifp->if_capabilities |= IFCAP_WOL;
 	ifp->if_capenable = ifp->if_capabilities;
 	/*
-	 * Don't enable TSO by default. Under certain
-	 * circumtances the controller generated corrupted
-	 * packets in TSO size.
+	 * Don't enable TSO by default.  It is known to generate
+	 * corrupted TCP segments(bad TCP options) under certain
+	 * circumtances.
 	 */
 	ifp->if_hwassist &= ~CSUM_TSO;
 	ifp->if_capenable &= ~(IFCAP_TSO4 | IFCAP_VLAN_HWTSO);
@@ -2413,11 +2403,17 @@ re_encap(struct rl_softc *sc, struct mbu
 	 */
 	vlanctl = 0;
 	csum_flags = 0;
-	if (((*m_head)->m_pkthdr.csum_flags & CSUM_TSO) != 0)
-		csum_flags = RL_TDESC_CMD_LGSEND |
-		    ((uint32_t)(*m_head)->m_pkthdr.tso_segsz <<
-		    RL_TDESC_CMD_MSSVAL_SHIFT);
-	else {
+	if (((*m_head)->m_pkthdr.csum_flags & CSUM_TSO) != 0) {
+		if ((sc->rl_flags & RL_FLAG_DESCV2) != 0) {
+			csum_flags |= RL_TDESC_CMD_LGSEND;
+			vlanctl |= ((uint32_t)(*m_head)->m_pkthdr.tso_segsz <<
+			    RL_TDESC_CMD_MSSVALV2_SHIFT);
+		} else {
+			csum_flags |= RL_TDESC_CMD_LGSEND |
+			    ((uint32_t)(*m_head)->m_pkthdr.tso_segsz <<
+			    RL_TDESC_CMD_MSSVAL_SHIFT);
+		}
+	} else {
 		/*
 		 * Unconditionally enable IP checksum if TCP or UDP
 		 * checksum is required. Otherwise, TCP/UDP checksum

Modified: stable/8/sys/pci/if_rlreg.h
==============================================================================
--- stable/8/sys/pci/if_rlreg.h	Sun Feb 20 22:32:21 2011	(r218896)
+++ stable/8/sys/pci/if_rlreg.h	Mon Feb 21 00:47:39 2011	(r218897)
@@ -657,6 +657,8 @@ struct rl_desc {
 #define	RL_TDESC_CMD_UDPCSUMV2	0x80000000
 #define	RL_TDESC_CMD_TCPCSUMV2	0x40000000
 #define	RL_TDESC_CMD_IPCSUMV2	0x20000000
+#define	RL_TDESC_CMD_MSSVALV2	0x1FFC0000
+#define	RL_TDESC_CMD_MSSVALV2_SHIFT	18
 
 /*
  * Error bits are valid only on the last descriptor of a frame



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201102210047.p1L0ldm4050089>