From owner-svn-src-head@FreeBSD.ORG Tue Feb 3 11:00:43 2009 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 B90A7106564A; Tue, 3 Feb 2009 11:00:43 +0000 (UTC) (envelope-from rrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9D2908FC12; Tue, 3 Feb 2009 11:00:43 +0000 (UTC) (envelope-from rrs@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n13B0hAD028522; Tue, 3 Feb 2009 11:00:43 GMT (envelope-from rrs@svn.freebsd.org) Received: (from rrs@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n13B0hvp028517; Tue, 3 Feb 2009 11:00:43 GMT (envelope-from rrs@svn.freebsd.org) Message-Id: <200902031100.n13B0hvp028517@svn.freebsd.org> From: Randall Stewart Date: Tue, 3 Feb 2009 11:00:43 +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: r188066 - in head/sys: dev/xen/netback net netinet 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: Tue, 03 Feb 2009 11:00:44 -0000 Author: rrs Date: Tue Feb 3 11:00:43 2009 New Revision: 188066 URL: http://svn.freebsd.org/changeset/base/188066 Log: Adds support for SCTP checksum offload. This means we, like TCP and UDP, move the checksum calculation into the IP routines when there is no hardware support we call into the normal SCTP checksum routine. The next round of SCTP updates will use this functionality. Of course the IGB driver needs a few updates to support the new intel controller set that actually does SCTP csum offload too. Reviewed by: gnn, rwatson, kmacy Modified: head/sys/dev/xen/netback/netback.c head/sys/net/if_ethersubr.c head/sys/netinet/ip_divert.c head/sys/netinet/ip_ipsec.c head/sys/netinet/ip_output.c Modified: head/sys/dev/xen/netback/netback.c ============================================================================== --- head/sys/dev/xen/netback/netback.c Tue Feb 3 09:01:45 2009 (r188065) +++ head/sys/dev/xen/netback/netback.c Tue Feb 3 11:00:43 2009 (r188066) @@ -30,6 +30,7 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_sctp.h" #include #include @@ -57,6 +58,10 @@ __FBSDID("$FreeBSD$"); #include #include #include +#ifdef SCTP +#include +#include +#endif #include #include @@ -295,6 +300,11 @@ fixup_checksum(struct mbuf *m) htons(IPPROTO_TCP + (iplen - iphlen))); th->th_sum = in_cksum_skip(m, iplen + sizeof(*eh), sizeof(*eh) + iphlen); m->m_pkthdr.csum_flags &= ~CSUM_TCP; +#ifdef SCTP + } else if (sw_csum & CSUM_SCTP) { + sctp_delayed_cksum(m); + sw_csum &= ~CSUM_SCTP; +#endif } else { u_short csum; struct udphdr *uh = (struct udphdr *)((caddr_t)ip + iphlen); @@ -908,7 +918,8 @@ netif_rx(netif_t *netif) #ifdef XEN_NETBACK_FIXUP_CSUM /* Check if we need to compute a checksum. This happens */ /* when bridging from one domain to another. */ - if ((m->m_pkthdr.csum_flags & CSUM_DELAY_DATA)) + if ((m->m_pkthdr.csum_flags & CSUM_DELAY_DATA) || + (m->m_pkthdr.csum_flags & CSUM_SCTP)) fixup_checksum(m); #endif Modified: head/sys/net/if_ethersubr.c ============================================================================== --- head/sys/net/if_ethersubr.c Tue Feb 3 09:01:45 2009 (r188065) +++ head/sys/net/if_ethersubr.c Tue Feb 3 11:00:43 2009 (r188066) @@ -299,6 +299,8 @@ ether_output(struct ifnet *ifp, struct m csum_flags |= (CSUM_IP_CHECKED|CSUM_IP_VALID); if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA) csum_flags |= (CSUM_DATA_VALID|CSUM_PSEUDO_HDR); + if (m->m_pkthdr.csum_flags & CSUM_SCTP) + csum_flags |= CSUM_SCTP_VALID; m->m_pkthdr.csum_flags |= csum_flags; m->m_pkthdr.csum_data = 0xffff; return (if_simloop(ifp, m, dst->sa_family, 0)); @@ -339,6 +341,8 @@ ether_output(struct ifnet *ifp, struct m csum_flags |= (CSUM_IP_CHECKED|CSUM_IP_VALID); if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA) csum_flags |= (CSUM_DATA_VALID|CSUM_PSEUDO_HDR); + if (m->m_pkthdr.csum_flags & CSUM_SCTP) + csum_flags |= CSUM_SCTP_VALID; if (m->m_flags & M_BCAST) { struct mbuf *n; Modified: head/sys/netinet/ip_divert.c ============================================================================== --- head/sys/netinet/ip_divert.c Tue Feb 3 09:01:45 2009 (r188065) +++ head/sys/netinet/ip_divert.c Tue Feb 3 11:00:43 2009 (r188066) @@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$"); #include "opt_inet.h" #include "opt_ipfw.h" #include "opt_mac.h" +#include "opt_sctp.h" #ifndef INET #error "IPDIVERT requires INET." #endif @@ -76,6 +77,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#ifdef SCTP +#include +#endif #include @@ -222,7 +226,14 @@ divert_packet(struct mbuf *m, int incomi m->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA; ip->ip_len = htons(ip->ip_len); } - +#ifdef SCTP + if (m->m_pkthdr.csum_flags & CSUM_SCTP) { + ip->ip_len = ntohs(ip->ip_len); + sctp_delayed_cksum(m); + m->m_pkthdr.csum_flags &= ~CSUM_SCTP; + ip->ip_len = htons(ip->ip_len); + } +#endif /* * Record receive interface address, if any. * But only for incoming packets. Modified: head/sys/netinet/ip_ipsec.c ============================================================================== --- head/sys/netinet/ip_ipsec.c Tue Feb 3 09:01:45 2009 (r188065) +++ head/sys/netinet/ip_ipsec.c Tue Feb 3 11:00:43 2009 (r188066) @@ -31,6 +31,7 @@ __FBSDID("$FreeBSD$"); #include "opt_ipsec.h" +#include "opt_sctp.h" #include #include @@ -56,6 +57,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#ifdef SCTP +#include +#endif #include @@ -328,7 +332,12 @@ ip_ipsec_output(struct mbuf **m, struct in_delayed_cksum(*m); (*m)->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA; } - +#ifdef SCTP + if ((*m)->m_pkthdr.csum_flags & CSUM_SCTP) { + sctp_delayed_cksum(*m); + (*m)->m_pkthdr.csum_flags &= ~CSUM_SCTP; + } +#endif ip->ip_len = htons(ip->ip_len); ip->ip_off = htons(ip->ip_off); Modified: head/sys/netinet/ip_output.c ============================================================================== --- head/sys/netinet/ip_output.c Tue Feb 3 09:01:45 2009 (r188065) +++ head/sys/netinet/ip_output.c Tue Feb 3 11:00:43 2009 (r188066) @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include "opt_mac.h" #include "opt_mbuf_stress_test.h" #include "opt_mpath.h" +#include "opt_sctp.h" #include #include @@ -70,6 +71,10 @@ __FBSDID("$FreeBSD$"); #include #include #include +#ifdef SCTP +#include +#include +#endif #ifdef IPSEC #include @@ -485,7 +490,10 @@ sendit: } m->m_pkthdr.csum_flags |= CSUM_IP_CHECKED | CSUM_IP_VALID; - +#ifdef SCTP + if (m->m_pkthdr.csum_flags & CSUM_SCTP) + m->m_pkthdr.csum_flags |= CSUM_SCTP_VALID; +#endif error = netisr_queue(NETISR_IP, m); goto done; } else @@ -502,6 +510,10 @@ sendit: CSUM_DATA_VALID | CSUM_PSEUDO_HDR; m->m_pkthdr.csum_data = 0xffff; } +#ifdef SCTP + if (m->m_pkthdr.csum_flags & CSUM_SCTP) + m->m_pkthdr.csum_flags |= CSUM_SCTP_VALID; +#endif m->m_pkthdr.csum_flags |= CSUM_IP_CHECKED | CSUM_IP_VALID; @@ -536,6 +548,12 @@ passout: in_delayed_cksum(m); sw_csum &= ~CSUM_DELAY_DATA; } +#ifdef SCTP + if (sw_csum & CSUM_SCTP) { + sctp_delayed_cksum(m); + sw_csum &= ~CSUM_SCTP; + } +#endif m->m_pkthdr.csum_flags &= ifp->if_hwassist; /* @@ -670,7 +688,13 @@ ip_fragment(struct ip *ip, struct mbuf * in_delayed_cksum(m0); m0->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA; } - +#ifdef SCTP + if (m0->m_pkthdr.csum_flags & CSUM_SCTP && + (if_hwassist_flags & CSUM_IP_FRAGS) == 0) { + sctp_delayed_cksum(m0); + m0->m_pkthdr.csum_flags &= ~CSUM_SCTP; + } +#endif if (len > PAGE_SIZE) { /* * Fragment large datagrams such that each segment