From owner-svn-src-all@FreeBSD.ORG Mon Mar 16 10:56:51 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2D46F1065678; Mon, 16 Mar 2009 10:56:51 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 01D3A8FC2D; Mon, 16 Mar 2009 10:56:51 +0000 (UTC) (envelope-from rwatson@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 n2GAuoAn058533; Mon, 16 Mar 2009 10:56:50 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2GAuoQM058532; Mon, 16 Mar 2009 10:56:50 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <200903161056.n2GAuoQM058532@svn.freebsd.org> From: Robert Watson Date: Mon, 16 Mar 2009 10:56:50 +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: r189873 - head/sys/net X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Mar 2009 10:56:51 -0000 Author: rwatson Date: Mon Mar 16 10:56:50 2009 New Revision: 189873 URL: http://svn.freebsd.org/changeset/base/189873 Log: Define and use two macros for loopback checksum offload: LO_CSUM_FEATURES - a bitmask of supported transmit offload features, which will be stored in if_hwassist if IFCAP_TXCSUM is enabled, and be cleared from mbuf packet header csum flags on transmit. (1) LO_CSUM_SET - a bitmask of supported receive offload features, which will be set on the mbuf packet header csum flags on transmit if IFCAP_RXCSUM is enabled. While here, fix SCTP offload for loopback: offer generation on the transmit side, don't just skip validation on the receive side. Obtained from: DragonflyBSD (1) MFC after: 1 week Modified: head/sys/net/if_loop.c Modified: head/sys/net/if_loop.c ============================================================================== --- head/sys/net/if_loop.c Mon Mar 16 10:36:24 2009 (r189872) +++ head/sys/net/if_loop.c Mon Mar 16 10:56:50 2009 (r189873) @@ -94,6 +94,11 @@ #define LOMTU 16384 #endif +#define LO_CSUM_FEATURES (CSUM_IP | CSUM_TCP | CSUM_UDP | CSUM_SCTP) +#define LO_CSUM_SET (CSUM_DATA_VALID | CSUM_PSEUDO_HDR | \ + CSUM_IP_CHECKED | CSUM_IP_VALID | \ + CSUM_SCTP_VALID) + int loioctl(struct ifnet *, u_long, caddr_t); static void lortrequest(int, struct rtentry *, struct rt_addrinfo *); int looutput(struct ifnet *ifp, struct mbuf *m, @@ -139,7 +144,7 @@ lo_clone_create(struct if_clone *ifc, in ifp->if_output = looutput; ifp->if_snd.ifq_maxlen = ifqmaxlen; ifp->if_capabilities = ifp->if_capenable = IFCAP_HWCSUM; - ifp->if_hwassist = CSUM_IP | CSUM_TCP | CSUM_UDP; + ifp->if_hwassist = LO_CSUM_FEATURES; if_attach(ifp); bpfattach(ifp, DLT_NULL, sizeof(u_int32_t)); if (V_loif == NULL) @@ -216,11 +221,9 @@ looutput(struct ifnet *ifp, struct mbuf case AF_INET: if (ifp->if_capenable & IFCAP_RXCSUM) { m->m_pkthdr.csum_data = 0xffff; - m->m_pkthdr.csum_flags = CSUM_DATA_VALID | - CSUM_PSEUDO_HDR | CSUM_IP_CHECKED | - CSUM_IP_VALID | CSUM_SCTP_VALID; + m->m_pkthdr.csum_flags = LO_CSUM_SET; } - m->m_pkthdr.csum_flags &= ~(CSUM_IP | CSUM_TCP | CSUM_UDP); + m->m_pkthdr.csum_flags &= ~LO_CSUM_FEATURES; case AF_INET6: case AF_IPX: case AF_APPLETALK: @@ -407,7 +410,7 @@ loioctl(struct ifnet *ifp, u_long cmd, c if ((mask & IFCAP_TXCSUM) != 0) ifp->if_capenable ^= IFCAP_TXCSUM; if (ifp->if_capenable & IFCAP_TXCSUM) - ifp->if_hwassist = CSUM_IP | CSUM_TCP | CSUM_UDP; + ifp->if_hwassist = LO_CSUM_FEATURES; else ifp->if_hwassist = 0; break;