From owner-svn-src-head@FreeBSD.ORG Mon Jan 10 23:28:46 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5F107106564A; Mon, 10 Jan 2011 23:28:46 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4E0C08FC12; Mon, 10 Jan 2011 23:28:46 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p0ANSkEp098936; Mon, 10 Jan 2011 23:28:46 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0ANSkaR098933; Mon, 10 Jan 2011 23:28:46 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201101102328.p0ANSkaR098933@svn.freebsd.org> From: Pyun YongHyeon Date: Mon, 10 Jan 2011 23:28:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217246 - in head/sys: dev/re pci X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Jan 2011 23:28:46 -0000 Author: yongari Date: Mon Jan 10 23:28:46 2011 New Revision: 217246 URL: http://svn.freebsd.org/changeset/base/217246 Log: 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. MFC after: 2 weeks Modified: head/sys/dev/re/if_re.c head/sys/pci/if_rlreg.h Modified: head/sys/dev/re/if_re.c ============================================================================== --- head/sys/dev/re/if_re.c Mon Jan 10 22:27:52 2011 (r217245) +++ head/sys/dev/re/if_re.c Mon Jan 10 23:28:46 2011 (r217246) @@ -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,12 +1485,14 @@ 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 + * Don't enable TSO by default for old controllers. Under + * certain circumtances the controller generated corrupted * packets in TSO size. */ - ifp->if_hwassist &= ~CSUM_TSO; - ifp->if_capenable &= ~(IFCAP_TSO4 | IFCAP_VLAN_HWTSO); + if ((sc->rl_flags & RL_FLAG_DESCV2) == 0) { + ifp->if_hwassist &= ~CSUM_TSO; + ifp->if_capenable &= ~(IFCAP_TSO4 | IFCAP_VLAN_HWTSO); + } #ifdef DEVICE_POLLING ifp->if_capabilities |= IFCAP_POLLING; #endif @@ -2413,11 +2405,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: head/sys/pci/if_rlreg.h ============================================================================== --- head/sys/pci/if_rlreg.h Mon Jan 10 22:27:52 2011 (r217245) +++ head/sys/pci/if_rlreg.h Mon Jan 10 23:28:46 2011 (r217246) @@ -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