If you have any of the newer PCIe re(4) chipsets in your system
(especially the 8168C since that is all we have seen so far)
please test the following diff which adds support for TX/RX
checksum offload.


Index: re.c
===================================================================
RCS file: /cvs/src/sys/dev/ic/re.c,v
retrieving revision 1.84
diff -u -p -r1.84 re.c
--- re.c	15 Jul 2008 13:21:17 -0000	1.84
+++ re.c	17 Jul 2008 13:36:04 -0000
@@ -1053,11 +1053,8 @@ re_attach(struct rl_softc *sc, const cha
 	IFQ_SET_MAXLEN(&ifp->if_snd, RL_TX_QLEN);
 	IFQ_SET_READY(&ifp->if_snd);
 
-	
-	ifp->if_capabilities = IFCAP_VLAN_MTU;
-	if ((sc->rl_flags & RL_FLAG_DESCV2) == 0)
-		ifp->if_capabilities |= IFCAP_CSUM_IPv4 |
-		    IFCAP_CSUM_TCPv4 | IFCAP_CSUM_UDPv4;
+	ifp->if_capabilities = IFCAP_VLAN_MTU | IFCAP_CSUM_IPv4 |
+			       IFCAP_CSUM_TCPv4 | IFCAP_CSUM_UDPv4;
 
 #if NVLAN > 0
 	ifp->if_capabilities |= IFCAP_VLAN_HWTAGGING;
@@ -1278,7 +1275,7 @@ re_rxeof(struct rl_softc *sc)
 	int		i, total_len;
 	struct rl_desc	*cur_rx;
 	struct rl_rxsoft *rxs;
-	u_int32_t	rxstat;
+	u_int32_t	rxstat, rxvlan;
 
 	ifp = &sc->sc_arpcom.ac_if;
 
@@ -1287,6 +1284,7 @@ re_rxeof(struct rl_softc *sc)
 		RL_RXDESCSYNC(sc, i,
 		    BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE);
 		rxstat = letoh32(cur_rx->rl_cmdstat);
+		rxvlan = letoh32(cur_rx->rl_vlanctl);
 		RL_RXDESCSYNC(sc, i, BUS_DMASYNC_PREREAD);
 		if ((rxstat & RL_RDESC_STAT_OWN) != 0)
 			break;
@@ -1399,7 +1397,19 @@ re_rxeof(struct rl_softc *sc)
 		/* Do RX checksumming */
 
 		if (sc->rl_flags & RL_FLAG_DESCV2) {
-			/* XXX V2 CSUM */
+			/* Check IP header checksum */
+			if ((rxstat & RL_RDESC_STAT_PROTOID) &&
+			    !(rxstat & RL_RDESC_STAT_IPSUMBAD) &&
+			    (rxvlan & RL_RDESC_IPV4))
+				m->m_pkthdr.csum_flags |= M_IPV4_CSUM_IN_OK;
+
+			/* Check TCP/UDP checksum */
+			if (((rxstat & RL_RDESC_STAT_TCP) &&
+			    !(rxstat & RL_RDESC_STAT_TCPSUMBAD)) ||
+			    ((rxstat & RL_RDESC_STAT_UDP) &&
+			    !(rxstat & RL_RDESC_STAT_UDPSUMBAD)))
+				m->m_pkthdr.csum_flags |= M_TCP_CSUM_IN_OK |
+				    M_UDP_CSUM_IN_OK;
 		} else {
 			/* Check IP header checksum */
 			if ((rxstat & RL_RDESC_STAT_PROTOID) &&
@@ -1614,11 +1624,19 @@ re_encap(struct rl_softc *sc, struct mbu
 
 	if ((m->m_pkthdr.csum_flags &
 	    (M_IPV4_CSUM_OUT|M_TCPV4_CSUM_OUT|M_UDPV4_CSUM_OUT)) != 0) {
-		rl_flags |= RL_TDESC_CMD_IPCSUM;
-		if (m->m_pkthdr.csum_flags & M_TCPV4_CSUM_OUT)
-			rl_flags |= RL_TDESC_CMD_TCPCSUM;
-		if (m->m_pkthdr.csum_flags & M_UDPV4_CSUM_OUT)
-			rl_flags |= RL_TDESC_CMD_UDPCSUM;
+		if (sc->rl_flags & RL_FLAG_DESCV2) {
+			rl_flags |= RL_TDESC_CMD_IPCSUMV2;
+			if (m->m_pkthdr.csum_flags & M_TCPV4_CSUM_OUT)
+				rl_flags |= RL_TDESC_CMD_TCPCSUMV2;
+			if (m->m_pkthdr.csum_flags & M_UDPV4_CSUM_OUT)
+				rl_flags |= RL_TDESC_CMD_UDPCSUMV2;
+		} else {
+			rl_flags |= RL_TDESC_CMD_IPCSUM;
+			if (m->m_pkthdr.csum_flags & M_TCPV4_CSUM_OUT)
+				rl_flags |= RL_TDESC_CMD_TCPCSUM;
+			if (m->m_pkthdr.csum_flags & M_UDPV4_CSUM_OUT)
+				rl_flags |= RL_TDESC_CMD_UDPCSUM;
+		}
 	}
 
 	txq = &sc->rl_ldata.rl_txq[*idx];
@@ -1634,7 +1652,8 @@ re_encap(struct rl_softc *sc, struct mbu
 
 	nsegs = map->dm_nsegs;
 	pad = 0;
-	if (m->m_pkthdr.len <= RL_IP4CSUMTX_PADLEN &&
+	if ((sc->rl_flags & RL_FLAG_DESCV2) == 0 &&
+	    m->m_pkthdr.len <= RL_IP4CSUMTX_PADLEN &&
 	    (rl_flags & RL_TDESC_CMD_IPCSUM) != 0) {
 		pad = 1;
 		nsegs++;
Index: rtl81x9reg.h
===================================================================
RCS file: /cvs/src/sys/dev/ic/rtl81x9reg.h,v
retrieving revision 1.49
diff -u -p -r1.49 rtl81x9reg.h
--- rtl81x9reg.h	15 Jul 2008 13:21:17 -0000	1.49
+++ rtl81x9reg.h	17 Jul 2008 13:16:52 -0000
@@ -528,6 +528,10 @@ struct rl_desc {
 
 #define RL_TDESC_VLANCTL_TAG	0x00020000	/* Insert VLAN tag */
 #define RL_TDESC_VLANCTL_DATA	0x0000FFFF	/* TAG data */
+/* RTL8168C/RTL8168CP/RTL8111C/RTL8111CP */
+#define	RL_TDESC_CMD_IPCSUMV2	0x20000000
+#define	RL_TDESC_CMD_TCPCSUMV2	0x40000000
+#define	RL_TDESC_CMD_UDPCSUMV2	0x80000000
 
 /*
  * Error bits are valid only on the last descriptor of a frame
@@ -565,6 +569,8 @@ struct rl_desc {
 #define RL_RDESC_STAT_RUNT	0x00080000	/* runt packet received */
 #define RL_RDESC_STAT_CRCERR	0x00040000	/* CRC error */
 #define RL_RDESC_STAT_PROTOID	0x00030000	/* Protocol type */
+#define	RL_RDESC_STAT_UDP	0x00020000	/* UDP, 8168C/CP, 8111C/CP */
+#define	RL_RDESC_STAT_TCP	0x00010000	/* TCP, 8168C/CP, 8111C/CP */
 #define RL_RDESC_STAT_IPSUMBAD	0x00008000	/* IP header checksum bad */
 #define RL_RDESC_STAT_UDPSUMBAD	0x00004000	/* UDP checksum bad */
 #define RL_RDESC_STAT_TCPSUMBAD	0x00002000	/* TCP checksum bad */
@@ -576,6 +582,9 @@ struct rl_desc {
 #define RL_RDESC_VLANCTL_TAG	0x00010000	/* VLAN tag available
 						   (rl_vlandata valid)*/
 #define RL_RDESC_VLANCTL_DATA	0x0000FFFF	/* TAG data */
+/* RTL8168C/RTL8168CP/RTL8111C/RTL8111CP */
+#define	RL_RDESC_IPV6		0x80000000
+#define	RL_RDESC_IPV4		0x40000000
 
 #define RL_PROTOID_NONIP	0x00000000
 #define RL_PROTOID_TCPIP	0x00010000

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

