From owner-svn-src-user@FreeBSD.ORG Sun Nov 18 12:17:08 2012 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 13EA97C1; Sun, 18 Nov 2012 12:17:08 +0000 (UTC) (envelope-from andre@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id EE1B58FC13; Sun, 18 Nov 2012 12:17:07 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qAICH7os021498; Sun, 18 Nov 2012 12:17:07 GMT (envelope-from andre@svn.freebsd.org) Received: (from andre@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qAICH7aH021497; Sun, 18 Nov 2012 12:17:07 GMT (envelope-from andre@svn.freebsd.org) Message-Id: <201211181217.qAICH7aH021497@svn.freebsd.org> From: Andre Oppermann Date: Sun, 18 Nov 2012 12:17:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r243215 - user/andre/tcp_workqueue/sys/sys X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Nov 2012 12:17:08 -0000 Author: andre Date: Sun Nov 18 12:17:07 2012 New Revision: 243215 URL: http://svnweb.freebsd.org/changeset/base/243215 Log: Add mtodo(m, o, t) macro taking an additional offset into the mbuf data section before the casting to type 't'. Modified: user/andre/tcp_workqueue/sys/sys/mbuf.h Modified: user/andre/tcp_workqueue/sys/sys/mbuf.h ============================================================================== --- user/andre/tcp_workqueue/sys/sys/mbuf.h Sun Nov 18 12:16:50 2012 (r243214) +++ user/andre/tcp_workqueue/sys/sys/mbuf.h Sun Nov 18 12:17:07 2012 (r243215) @@ -64,8 +64,10 @@ * type: * * mtod(m, t) -- Convert mbuf pointer to data pointer of correct type. + * mtodo(m, o, t) - Same as above but with offset 'o' into data. */ #define mtod(m, t) ((t)((m)->m_data)) +#define mtodo(m, o, t) ((t)(((m)->m_data) + (o))) /* * Argument structure passed to UMA routines during mbuf and packet From owner-svn-src-user@FreeBSD.ORG Sun Nov 18 12:40:24 2012 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 7FB08641; Sun, 18 Nov 2012 12:40:24 +0000 (UTC) (envelope-from andre@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 64F738FC13; Sun, 18 Nov 2012 12:40:24 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qAICeOmh025541; Sun, 18 Nov 2012 12:40:24 GMT (envelope-from andre@svn.freebsd.org) Received: (from andre@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qAICeOfW025539; Sun, 18 Nov 2012 12:40:24 GMT (envelope-from andre@svn.freebsd.org) Message-Id: <201211181240.qAICeOfW025539@svn.freebsd.org> From: Andre Oppermann Date: Sun, 18 Nov 2012 12:40:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r243221 - in user/andre/tcp_workqueue/sys: netinet sys X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Nov 2012 12:40:24 -0000 Author: andre Date: Sun Nov 18 12:40:23 2012 New Revision: 243221 URL: http://svnweb.freebsd.org/changeset/base/243221 Log: Move SCTP protocol specific mbuf flag overlay definitions from global mbuf.h to protocol private sctp_os_bsd.h. Modified: user/andre/tcp_workqueue/sys/netinet/sctp_os_bsd.h user/andre/tcp_workqueue/sys/sys/mbuf.h Modified: user/andre/tcp_workqueue/sys/netinet/sctp_os_bsd.h ============================================================================== --- user/andre/tcp_workqueue/sys/netinet/sctp_os_bsd.h Sun Nov 18 12:30:04 2012 (r243220) +++ user/andre/tcp_workqueue/sys/netinet/sctp_os_bsd.h Sun Nov 18 12:40:23 2012 (r243221) @@ -139,6 +139,11 @@ MALLOC_DECLARE(SCTP_M_MCORE); #endif /* + * Protocol family specific mbuf flag overlays. + */ +#define M_NOTIFICATION M_PROTO5 /* SCTP notification */ + +/* * Macros to expand out globals defined by various modules * to either a real global or a virtualized instance of one, * depending on whether VIMAGE is defined. Modified: user/andre/tcp_workqueue/sys/sys/mbuf.h ============================================================================== --- user/andre/tcp_workqueue/sys/sys/mbuf.h Sun Nov 18 12:30:04 2012 (r243220) +++ user/andre/tcp_workqueue/sys/sys/mbuf.h Sun Nov 18 12:40:23 2012 (r243221) @@ -210,8 +210,6 @@ struct mbuf { */ #define M_FIB 0xF0000000 /* steal some bits to store fib number. */ -#define M_NOTIFICATION M_PROTO5 /* SCTP notification */ - /* * Flags to purge when crossing layers. */ From owner-svn-src-user@FreeBSD.ORG Sun Nov 18 12:41:35 2012 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 8DAB175C; Sun, 18 Nov 2012 12:41:35 +0000 (UTC) (envelope-from andre@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 734478FC14; Sun, 18 Nov 2012 12:41:35 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qAICfZRl025776; Sun, 18 Nov 2012 12:41:35 GMT (envelope-from andre@svn.freebsd.org) Received: (from andre@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qAICfZYY025775; Sun, 18 Nov 2012 12:41:35 GMT (envelope-from andre@svn.freebsd.org) Message-Id: <201211181241.qAICfZYY025775@svn.freebsd.org> From: Andre Oppermann Date: Sun, 18 Nov 2012 12:41:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r243222 - user/andre/tcp_workqueue/sys/netinet X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Nov 2012 12:41:35 -0000 Author: andre Date: Sun Nov 18 12:41:35 2012 New Revision: 243222 URL: http://svnweb.freebsd.org/changeset/base/243222 Log: Better description of protocol family specific mbuf flag overlay section. Modified: user/andre/tcp_workqueue/sys/netinet/ip_var.h Modified: user/andre/tcp_workqueue/sys/netinet/ip_var.h ============================================================================== --- user/andre/tcp_workqueue/sys/netinet/ip_var.h Sun Nov 18 12:40:23 2012 (r243221) +++ user/andre/tcp_workqueue/sys/netinet/ip_var.h Sun Nov 18 12:41:35 2012 (r243222) @@ -160,7 +160,7 @@ void kmod_ipstat_dec(int statnum); #define IP_ALLOWBROADCAST SO_BROADCAST /* 0x20 can send broadcast packets */ /* - * mbuf flag used by ip_fastfwd + * Protocol family specific mbuf flag overlays. */ #define M_FASTFWD_OURS M_PROTO1 /* changed dst to local */ #define M_IP_NEXTHOP M_PROTO2 /* explicit ip nexthop */ From owner-svn-src-user@FreeBSD.ORG Sun Nov 18 12:45:54 2012 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6669B893; Sun, 18 Nov 2012 12:45:54 +0000 (UTC) (envelope-from andre@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 4804D8FC12; Sun, 18 Nov 2012 12:45:54 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qAICjscs026472; Sun, 18 Nov 2012 12:45:54 GMT (envelope-from andre@svn.freebsd.org) Received: (from andre@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qAICjsSg026471; Sun, 18 Nov 2012 12:45:54 GMT (envelope-from andre@svn.freebsd.org) Message-Id: <201211181245.qAICjsSg026471@svn.freebsd.org> From: Andre Oppermann Date: Sun, 18 Nov 2012 12:45:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r243223 - user/andre/tcp_workqueue/sys/sys X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Nov 2012 12:45:54 -0000 Author: andre Date: Sun Nov 18 12:45:53 2012 New Revision: 243223 URL: http://svnweb.freebsd.org/changeset/base/243223 Log: Update comment to prefer M_NOWAIT over M_DONTWAIT and M_WAITOK over M_WAIT. Modified: user/andre/tcp_workqueue/sys/sys/mbuf.h Modified: user/andre/tcp_workqueue/sys/sys/mbuf.h ============================================================================== --- user/andre/tcp_workqueue/sys/sys/mbuf.h Sun Nov 18 12:41:35 2012 (r243222) +++ user/andre/tcp_workqueue/sys/sys/mbuf.h Sun Nov 18 12:45:53 2012 (r243223) @@ -350,8 +350,8 @@ struct mbstat { * Flags specifying how an allocation should be made. * * The flag to use is as follows: - * - M_DONTWAIT or M_NOWAIT from an interrupt handler to not block allocation. - * - M_WAIT or M_WAITOK from wherever it is safe to block. + * - M_NOWAIT (M_DONTWAIT) from an interrupt handler to not block allocation. + * - M_WAITOK (M_WAIT) from wherever it is safe to block. * * M_DONTWAIT/M_NOWAIT means that we will not block the thread explicitly and * if we cannot allocate immediately we may return NULL, whereas From owner-svn-src-user@FreeBSD.ORG Sun Nov 18 12:57:59 2012 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 4DC96D9E; Sun, 18 Nov 2012 12:57:59 +0000 (UTC) (envelope-from andre@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 19FC38FC13; Sun, 18 Nov 2012 12:57:59 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qAICvwtW028398; Sun, 18 Nov 2012 12:57:58 GMT (envelope-from andre@svn.freebsd.org) Received: (from andre@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qAICvwTD028397; Sun, 18 Nov 2012 12:57:58 GMT (envelope-from andre@svn.freebsd.org) Message-Id: <201211181257.qAICvwTD028397@svn.freebsd.org> From: Andre Oppermann Date: Sun, 18 Nov 2012 12:57:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r243225 - user/andre/tcp_workqueue/sys/sys X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Nov 2012 12:57:59 -0000 Author: andre Date: Sun Nov 18 12:57:58 2012 New Revision: 243225 URL: http://svnweb.freebsd.org/changeset/base/243225 Log: Extend the checksum offload fields in the mbuf packet header with layer 2-4 header length indicators for the current packet. It is only valid on the down/outbound path with the corresponding csum flags specified. The header length indicators are 8-bit wide and can specify a length of at most 256 bytes per header which is deemed sufficient. The header length indicators are unionized with the csum_data field. This simplifies setup of the offload DMA desriptors in the drivers considerably as they don't have to parse the packet anymore. Adjustments to Ethernet/IP/IPv6/UDP/TCP/SCTP to correctly set and update the header length indicators to follow. Modified: user/andre/tcp_workqueue/sys/sys/mbuf.h Modified: user/andre/tcp_workqueue/sys/sys/mbuf.h ============================================================================== --- user/andre/tcp_workqueue/sys/sys/mbuf.h Sun Nov 18 12:57:32 2012 (r243224) +++ user/andre/tcp_workqueue/sys/sys/mbuf.h Sun Nov 18 12:57:58 2012 (r243225) @@ -120,9 +120,17 @@ struct pkthdr { uint32_t flowid; /* packet's 4-tuple system * flow identifier */ - /* variables for hardware checksum */ - int csum_flags; /* flags regarding checksum */ - int csum_data; /* data field used by csum routines */ + /* Variables for various hardware offload features. */ + int csum_flags; /* flags regarding checksum */ + union { + int cd_data; /* data field for csum routines */ + struct { + uint8_t l2hlen; /* layer 2 header length */ + uint8_t l3hlen; /* layer 3 header length */ + uint8_t l4hlen; /* layer 4 header length */ + uint8_t unused; /* unused */ + } PHCD_hdr; + } PH_cd; u_int16_t tso_segsz; /* TSO segment size */ union { u_int16_t vt_vtag; /* Ethernet 802.1p+q vlan tag */ @@ -130,6 +138,10 @@ struct pkthdr { } PH_vt; SLIST_HEAD(packet_tags, m_tag) tags; /* list of packet tags */ }; +#define csum_data PH_cd.cd_data +#define csum_l2hlen PH_cd.PHCD_hdr.l2hlen +#define csum_l3hlen PH_cd.PHCD_hdr.l3hlen +#define csum_l4hlen PH_cd.PHCD_hdr.l4hlen #define ether_vtag PH_vt.vt_vtag /* From owner-svn-src-user@FreeBSD.ORG Sun Nov 18 14:00:04 2012 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 2DA09E05; Sun, 18 Nov 2012 14:00:04 +0000 (UTC) (envelope-from andre@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 13B3F8FC08; Sun, 18 Nov 2012 14:00:04 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qAIE032w038107; Sun, 18 Nov 2012 14:00:03 GMT (envelope-from andre@svn.freebsd.org) Received: (from andre@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qAIE03A1038101; Sun, 18 Nov 2012 14:00:03 GMT (envelope-from andre@svn.freebsd.org) Message-Id: <201211181400.qAIE03A1038101@svn.freebsd.org> From: Andre Oppermann Date: Sun, 18 Nov 2012 14:00:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r243226 - in user/andre/tcp_workqueue/sys: net netinet netinet6 X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Nov 2012 14:00:04 -0000 Author: andre Date: Sun Nov 18 14:00:03 2012 New Revision: 243226 URL: http://svnweb.freebsd.org/changeset/base/243226 Log: Adjustments to the various Ethernet/IP/IPv6/UDP/TCP/SCTP output functions to correctly set and update the csum_l[2-4]hlen header length indicators. Modified: user/andre/tcp_workqueue/sys/net/if_ethersubr.c user/andre/tcp_workqueue/sys/netinet/ip_output.c user/andre/tcp_workqueue/sys/netinet/sctp_output.c user/andre/tcp_workqueue/sys/netinet/tcp_output.c user/andre/tcp_workqueue/sys/netinet/udp_usrreq.c user/andre/tcp_workqueue/sys/netinet6/ip6_output.c Modified: user/andre/tcp_workqueue/sys/net/if_ethersubr.c ============================================================================== --- user/andre/tcp_workqueue/sys/net/if_ethersubr.c Sun Nov 18 12:57:58 2012 (r243225) +++ user/andre/tcp_workqueue/sys/net/if_ethersubr.c Sun Nov 18 14:00:03 2012 (r243226) @@ -328,6 +328,21 @@ ether_output(struct ifnet *ifp, struct m sizeof(eh->ether_shost)); /* + * Fill in ethernet header length for checksum offload features. + * NB: The vlan header length must not be specified with hardware + * vlan insertion. + */ + if (m->m_pkthdr.csum_flags) { + uint8_t ehlen; + + if (eh->ether_type == ntohs(ETHERTYPE_VLAN)) + ehlen = sizeof(struct ether_vlan_header); + else + ehlen = sizeof(struct ether_header); + m->m_pkthdr.csum_l2hlen += ehlen; + } + + /* * If a simplex interface, and the packet is being sent to our * Ethernet address or a broadcast address, loopback a copy. * XXX To make a simplex device behave exactly like a duplex Modified: user/andre/tcp_workqueue/sys/netinet/ip_output.c ============================================================================== --- user/andre/tcp_workqueue/sys/netinet/ip_output.c Sun Nov 18 12:57:58 2012 (r243225) +++ user/andre/tcp_workqueue/sys/netinet/ip_output.c Sun Nov 18 14:00:03 2012 (r243226) @@ -582,6 +582,7 @@ passout: } m->m_pkthdr.csum_flags |= CSUM_IP; + m->m_pkthdr.csum_l3hlen += ip_len; if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA & ~ifp->if_hwassist) { in_delayed_cksum(m); m->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA; Modified: user/andre/tcp_workqueue/sys/netinet/sctp_output.c ============================================================================== --- user/andre/tcp_workqueue/sys/netinet/sctp_output.c Sun Nov 18 12:57:58 2012 (r243225) +++ user/andre/tcp_workqueue/sys/netinet/sctp_output.c Sun Nov 18 14:00:03 2012 (r243226) @@ -4130,7 +4130,7 @@ sctp_lowlevel_chunk_output(struct sctp_i SCTP_STAT_INCR(sctps_sendnocrc); #else m->m_pkthdr.csum_flags = CSUM_SCTP; - m->m_pkthdr.csum_data = 0; + m->m_pkthdr.csum_l4hlen = sizeof(struct sctphdr); SCTP_STAT_INCR(sctps_sendhwcrc); #endif } @@ -4479,7 +4479,7 @@ sctp_lowlevel_chunk_output(struct sctp_i SCTP_STAT_INCR(sctps_sendnocrc); #else m->m_pkthdr.csum_flags = CSUM_SCTP_IPV6; - m->m_pkthdr.csum_data = 0; + m->m_pkthdr.csum_l4hlen = sizeof(struct sctphdr); SCTP_STAT_INCR(sctps_sendhwcrc); #endif } @@ -11006,7 +11006,7 @@ sctp_send_resp_msg(struct sockaddr *src, SCTP_STAT_INCR(sctps_sendnocrc); #else mout->m_pkthdr.csum_flags = CSUM_SCTP; - mout->m_pkthdr.csum_data = 0; + mout->m_pkthdr.csum_l4hlen = sizeof(struct sctphdr); SCTP_STAT_INCR(sctps_sendhwcrc); #endif } @@ -11036,7 +11036,7 @@ sctp_send_resp_msg(struct sockaddr *src, SCTP_STAT_INCR(sctps_sendnocrc); #else mout->m_pkthdr.csum_flags = CSUM_SCTP_IPV6; - mout->m_pkthdr.csum_data = 0; + mout->m_pkthdr.csum_l4hlen = sizeof(struct sctphdr); SCTP_STAT_INCR(sctps_sendhwcrc); #endif } Modified: user/andre/tcp_workqueue/sys/netinet/tcp_output.c ============================================================================== --- user/andre/tcp_workqueue/sys/netinet/tcp_output.c Sun Nov 18 12:57:58 2012 (r243225) +++ user/andre/tcp_workqueue/sys/netinet/tcp_output.c Sun Nov 18 14:00:03 2012 (r243226) @@ -1078,7 +1078,7 @@ send: * checksum extended header and data. */ m->m_pkthdr.len = hdrlen + len; /* in6_cksum() need this */ - m->m_pkthdr.csum_data = offsetof(struct tcphdr, th_sum); + m->m_pkthdr.csum_l4hlen = sizeof(struct tcphdr) + optlen; #ifdef INET6 if (isipv6) { /* Modified: user/andre/tcp_workqueue/sys/netinet/udp_usrreq.c ============================================================================== --- user/andre/tcp_workqueue/sys/netinet/udp_usrreq.c Sun Nov 18 12:57:58 2012 (r243225) +++ user/andre/tcp_workqueue/sys/netinet/udp_usrreq.c Sun Nov 18 14:00:03 2012 (r243226) @@ -1227,7 +1227,7 @@ udp_output(struct inpcb *inp, struct mbu ui->ui_sum = in_pseudo(ui->ui_src.s_addr, faddr.s_addr, htons((u_short)len + sizeof(struct udphdr) + IPPROTO_UDP)); m->m_pkthdr.csum_flags = CSUM_UDP; - m->m_pkthdr.csum_data = offsetof(struct udphdr, uh_sum); + m->m_pkthdr.csum_l4hlen = sizeof(struct udphdr); } else ui->ui_sum = 0; ((struct ip *)ui)->ip_len = htons(sizeof(struct udpiphdr) + len); Modified: user/andre/tcp_workqueue/sys/netinet6/ip6_output.c ============================================================================== --- user/andre/tcp_workqueue/sys/netinet6/ip6_output.c Sun Nov 18 12:57:58 2012 (r243225) +++ user/andre/tcp_workqueue/sys/netinet6/ip6_output.c Sun Nov 18 14:00:03 2012 (r243226) @@ -1030,6 +1030,9 @@ passout: ia6->ia_ifa.if_obytes += m->m_pkthdr.len; ifa_free(&ia6->ia_ifa); } + if (m->m_pkthdr.csum_flags & + (CSUM_UDP_IPV6|CSUM_TCP_IPV6|CSUM_SCTP_IPV6|CSUM_TSO)) + m->m_pkthdr.csum_l3hlen += sizeof(struct ip6_hdr); error = nd6_output(ifp, origifp, m, dst, ro->ro_rt); goto done; } From owner-svn-src-user@FreeBSD.ORG Sun Nov 18 14:23:35 2012 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9CA057B; Sun, 18 Nov 2012 14:23:35 +0000 (UTC) (envelope-from andre@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 8217E8FC08; Sun, 18 Nov 2012 14:23:35 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qAIENZ2h042428; Sun, 18 Nov 2012 14:23:35 GMT (envelope-from andre@svn.freebsd.org) Received: (from andre@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qAIENZUo042424; Sun, 18 Nov 2012 14:23:35 GMT (envelope-from andre@svn.freebsd.org) Message-Id: <201211181423.qAIENZUo042424@svn.freebsd.org> From: Andre Oppermann Date: Sun, 18 Nov 2012 14:23:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r243229 - in user/andre/tcp_workqueue/sys: dev/e1000 dev/ixgbe sys X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Nov 2012 14:23:35 -0000 Author: andre Date: Sun Nov 18 14:23:35 2012 New Revision: 243229 URL: http://svnweb.freebsd.org/changeset/base/243229 Log: After careful studying of our historic checksum offload capabilities, a number datasheets for modern high performance NICs and the NDIS 6.x documentation re-arrange and re-structure our checksum offload framework to better support available capabilities and to prepare for future ones. The input checksumming path, where the NIC has verified certain L3+L4 checksums, is simplified and no longer overlaying the output offload bits. This greatly reduces confusion. The output offloading capabilities path is clearly structured into the participating layers and improves naming of the options to reduce confusion here too. Also document the assumptions and guarantees made by the stack and at the driver boundary. Clean up a few CSUM definitions in drivers I already messed with. Modified: user/andre/tcp_workqueue/sys/dev/e1000/if_igb.c user/andre/tcp_workqueue/sys/dev/ixgbe/ixgbe.c user/andre/tcp_workqueue/sys/dev/ixgbe/ixv.c user/andre/tcp_workqueue/sys/sys/mbuf.h Modified: user/andre/tcp_workqueue/sys/dev/e1000/if_igb.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/e1000/if_igb.c Sun Nov 18 14:21:05 2012 (r243228) +++ user/andre/tcp_workqueue/sys/dev/e1000/if_igb.c Sun Nov 18 14:23:35 2012 (r243229) @@ -4945,7 +4945,7 @@ igb_rx_checksum(u32 staterr, struct mbuf } if (status & (E1000_RXD_STAT_TCPCS | E1000_RXD_STAT_UDPCS)) { - u16 type = (CSUM_DATA_VALID | CSUM_PSEUDO_HDR); + u32 type = (CSUM_DATA_VALID | CSUM_PSEUDO_HDR); #if __FreeBSD_version >= 800000 if (sctp) /* reassign */ type = CSUM_SCTP_VALID; Modified: user/andre/tcp_workqueue/sys/dev/ixgbe/ixgbe.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/ixgbe/ixgbe.c Sun Nov 18 14:21:05 2012 (r243228) +++ user/andre/tcp_workqueue/sys/dev/ixgbe/ixgbe.c Sun Nov 18 14:23:35 2012 (r243229) @@ -1823,7 +1823,7 @@ ixgbe_xmit(struct tx_ring *txr, struct m if ((m_head->m_flags & M_VLANTAG) || (m_head->m_pkthdr.csum_flags & (CSUM_IP|CSUM_TCP|CSUM_TCP_IPV6|CSUM_TSO|CSUM_UDP|CSUM_UDP_IPV6| - CSUM_UFO|CSUM_SCTP|CSUM_SCTP_IPV6))) { + CSUM_SCTP|CSUM_SCTP_IPV6))) { if (ixgbe_offload_setup(txr, m_head, &cmd_type_len, &olinfo_status)) ++adapter->tso_tx; @@ -3328,7 +3328,7 @@ ixgbe_offload_setup(struct tx_ring *txr, l4_hlen = sizeof(struct udphdr); if (m->m_pkthdr.csum_flags & (CSUM_UDP | CSUM_UDP_IPV6)) *olinfo_status |= IXGBE_TXD_POPTS_TXSM << 8; - if (m->m_pkthdr.csum_flags & (CSUM_UFO | 0)) { + if (m->m_pkthdr.csum_flags & (CSUM_IP_UFO | 0)) { *cmd_type_len |= IXGBE_ADVTXD_DCMD_TSE; paylen -= ehdrlen + ip_hlen + l4_hlen; } @@ -4722,7 +4722,7 @@ ixgbe_rx_checksum(u32 staterr, struct mb mp->m_pkthdr.csum_flags = 0; } if (status & IXGBE_RXD_STAT_L4CS) { - u16 type = (CSUM_DATA_VALID | CSUM_PSEUDO_HDR); + u32 type = (CSUM_DATA_VALID | CSUM_PSEUDO_HDR); #if __FreeBSD_version >= 800000 if (sctp) type = CSUM_SCTP_VALID; Modified: user/andre/tcp_workqueue/sys/dev/ixgbe/ixv.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/ixgbe/ixv.c Sun Nov 18 14:21:05 2012 (r243228) +++ user/andre/tcp_workqueue/sys/dev/ixgbe/ixv.c Sun Nov 18 14:23:35 2012 (r243229) @@ -3554,7 +3554,7 @@ ixv_rx_checksum(u32 staterr, struct mbuf mp->m_pkthdr.csum_flags = 0; } if (status & IXGBE_RXD_STAT_L4CS) { - u16 type = (CSUM_DATA_VALID | CSUM_PSEUDO_HDR); + u32 type = (CSUM_DATA_VALID | CSUM_PSEUDO_HDR); #if __FreeBSD_version >= 800000 if (sctp) type = CSUM_SCTP_VALID; Modified: user/andre/tcp_workqueue/sys/sys/mbuf.h ============================================================================== --- user/andre/tcp_workqueue/sys/sys/mbuf.h Sun Nov 18 14:21:05 2012 (r243228) +++ user/andre/tcp_workqueue/sys/sys/mbuf.h Sun Nov 18 14:23:35 2012 (r243229) @@ -287,32 +287,117 @@ struct mbuf { /* * Flags indicating hw checksum support and sw checksum requirements. This * field can be directly tested against if_data.ifi_hwassist. - */ -#define CSUM_IP 0x0001 /* will csum IP */ -#define CSUM_TCP 0x0002 /* will csum TCP */ -#define CSUM_UDP 0x0004 /* will csum UDP */ -#define CSUM_IPFRAG 0x0008 /* IP fragmentation offload */ -#define CSUM_UFO 0x0010 /* UDP fragmentation offload */ -#define CSUM_TSO 0x0020 /* TCP segmentation offload */ -#define CSUM_SCTP 0x0040 /* will csum SCTP */ -#define CSUM_SCTP_IPV6 0x0080 /* will csum IPv6/SCTP */ - -#define CSUM_IP_CHECKED 0x0100 /* did csum IP */ -#define CSUM_IP_VALID 0x0200 /* ... the csum is valid */ -#define CSUM_DATA_VALID 0x0400 /* csum_data field is valid */ -#define CSUM_PSEUDO_HDR 0x0800 /* csum_data has pseudo hdr */ -#define CSUM_SCTP_VALID 0x1000 /* SCTP checksum is valid */ -#define CSUM_UDP_IPV6 0x2000 /* will csum IPv6/UDP */ -#define CSUM_TCP_IPV6 0x4000 /* will csum IPv6/TCP */ -/* CSUM_TSO_IPV6 0x8000 will do IPv6/TSO */ - -/* CSUM_FRAGMENT_IPV6 0x10000 will do IPv6 fragementation */ + * + * The offloading flags are used on the inbound and outbound packet path. + * These two path behave differently. + * Please note that the IPv6 header doesn't have a checksum. + * + * Inbound: + * The NIC can support calculation of the checksum of the IP header, UDP, + * TCP and SCTP checksums. When the hardware calculated the checksum of + * the L3 or L4 header it sets the CALCULATED bit. If the calculated + * checksum also matches the original checksum in the packet it sets th + * VALID bit. The VALID bit MUST NOT be set without the corresponding + * CALCULATED bit. All L3+ packets, even with mismatched checksums are + * delivered up the network stack. The protocol specific input routines + * then can drop the packet. When doing L3 forwarding only the L3 checksum + * must be checked, a packet is to be forwarded even if the L4 checksum has + * a mismatch. + * The protocol type (eg. IPv4 or IPv6; UDP, TCP or SCTP) doesn't have to + * be stored in the bits because it follows from the packet content. + * XXXAO: See how encapsulated checksum verification can be handled. + * + * NB: A driver MUST NOT do checksumming in software just to set the checksum + * offload bits. + * NB: A driver MUST NOT set any of the CALCULATED or VALID bits if it didn't + * actually perform the nescessary checksum calculations. + * + * Outbound: + * The NIC can support calculation and insertion of the IP header, UDP, + * TCP and SCTP checksums. Additionally it can support segmentation of + * large TCP sends and IP level fragmentation of large UDP packets. + * The TCP and UDP layers generally calculate only the pseudo checksum + * WITHOUT a length value and put it into the L4 header checksum field. + * The same checksum value is also put into the csum_pseudo field. SCTP + * (thankfully) doesn't include a pseudo header in its checksum. The + * NIC may ignore the pseudo header checksum and do its own calculations + * entirely based on the packet content. + * + * More advanced features are TCP segmentation offload and UDP fragmentation + * offload. Whenever these flags are set, the upper layers will set the + * csum_l(2-4)hlen fields. The aggregated sum of the header length will + * be present contiguously in the first mbuf. The csum_pseudo is as before. + * Packets for segmentation/fragmentation do not exceed IP_MAXLEN (64K) + * including L3 headers. However the additional L2 headers come on top + * and put the entire frame above 64K. This has to be accounted for in + * the driver and its DMA setup. Segmentation and fragmentation features + * are protocol dependent and each protocol has to be defined. + * L4 seg/fragmentation offload always implies L4 and L3 checksum offloading + * as well. However they are always explicitly specified as well. + * + * NB: A driver can blindly verify the above to be true and simply test + * the first mbuf's length againt the aggregated csum_l(2-4)hlen. If is + * too short it can just drop the packet and return EINVAL. Additionally + * it should verify the mbuf chain's intergrity with m_sanity() in a KASSERT. + */ + +/* Inbound flags. */ +#define MCSUM_INFLAGS(m) ((m)->csum_flags & \ + 0xF0000000) + +#define CSUM_L3_CALC 0x10000000 /* IP hdr csum calculated */ +#define CSUM_L3_VALID 0x20000000 /* IP hdr csum equal calculated */ +#define CSUM_L4_CALC 0x40000000 /* UDP/TCP/SCTP csum calculated */ +#define CSUM_L4_VALID 0x80000000 /* UDP/TCP/SCTP csum eq. calc. */ + +/* Outboud flags, tested against ifi_hwassist. */ +#define MCSUM_OUTFLAGS(m) ((m)->csum_flags & \ + 0x0FFFFFF0) + +/* IPv4 csum offload 0x0000---0 */ +#define CSUM_IP 0x00000010 /* will csum IP header */ +#define CSUM_IP_UDP 0x00000030 /* will csum UDP */ +#define CSUM_IP_TCP 0x00000050 /* will csum TCP */ +#define CSUM_IP_SCTP 0x00000090 /* will csum SCTP */ + +#define CSUM_IP_FRAGO 0x00000110 /* IP fragmentation offload */ +#define CSUM_IP_UFO 0x00000230 /* UDP fragmentation offload */ +#define CSUM_IP_TSO 0x00000450 /* TCP segmentation offload */ +#define CSUM_IP_SCO 0x00000890 /* SCTP chunking offload */ + +/* IPv6 csum offload 0x0---0000 */ + /* IPv6 hdr has no csum */ +#define CSUM_IP6_UDP 0x00020000 /* will csum IPv6/UDP */ +#define CSUM_IP6_TCP 0x00040000 /* will csum IPv6/TCP */ +#define CSUM_IP6_SCTP 0x00080000 /* will csum IPv6/SCTP */ + +#define CSUM_IP6_FRAGO 0x00200000 /* IPv6 frag */ +#define CSUM_IP6_UFO 0x00220000 /* IPv6/UFO */ +#define CSUM_IP6_TSO 0x00440000 /* IPv6/TSO */ +#define CSUM_IP6_SCO 0x00880000 * SCTP chunk offload */ + +#define CSUM_RSS_HT_XX 0x00000001-F + +/* Definition compatiblity with < 20121118, goes away after tree pruning */ +#define CSUM_UDP CSUM_IP_UDP +#define CSUM_TCP CSUM_IP_TCP +#define CSUM_SCTP CSUM_IP_SCTP +#define CSUM_TSO CSUM_IP_TSO +#define CSUM_IPFRAG CSUM_IP_FRAGO +#define CSUM_UDP_IPV6 CSUM_IP6_UDP /* will csum IPv6/UDP */ +#define CSUM_TCP_IPV6 CSUM_IP6_TCP /* will csum IPv6/TCP */ +#define CSUM_SCTP_IPV6 CSUM_IP6_SCTP /* will csum IPv6/SCTP */ + +#define CSUM_IP_CHECKED CSUM_L3_CALC /* did csum IP */ +#define CSUM_IP_VALID CSUM_L3_VALID /* ... the csum is valid */ +#define CSUM_DATA_VALID CSUM_L4_VALID /* csum_data field is valid */ +#define CSUM_SCTP_VALID CSUM_L4_VALID /* SCTP checksum is valid */ +#define CSUM_PSEUDO_HDR 0x00000001 /* XXX csum_data has pseudo hdr */ #define CSUM_DELAY_DATA_IPV6 (CSUM_TCP_IPV6 | CSUM_UDP_IPV6) #define CSUM_DATA_VALID_IPV6 CSUM_DATA_VALID - #define CSUM_DELAY_DATA (CSUM_TCP | CSUM_UDP) -#define CSUM_DELAY_IP (CSUM_IP) /* Only v4, no v6 IP hdr csum */ +#define CSUM_DELAY_IP (CSUM_IP) /* * mbuf types. From owner-svn-src-user@FreeBSD.ORG Sun Nov 18 14:58:50 2012 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id B1AAC9CE; Sun, 18 Nov 2012 14:58:50 +0000 (UTC) (envelope-from andre@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 7EC2F8FC15; Sun, 18 Nov 2012 14:58:50 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qAIEwoAM048331; Sun, 18 Nov 2012 14:58:50 GMT (envelope-from andre@svn.freebsd.org) Received: (from andre@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qAIEwokF048330; Sun, 18 Nov 2012 14:58:50 GMT (envelope-from andre@svn.freebsd.org) Message-Id: <201211181458.qAIEwokF048330@svn.freebsd.org> From: Andre Oppermann Date: Sun, 18 Nov 2012 14:58:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r243230 - user/andre/tcp_workqueue/sys/sys X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Nov 2012 14:58:50 -0000 Author: andre Date: Sun Nov 18 14:58:50 2012 New Revision: 243230 URL: http://svnweb.freebsd.org/changeset/base/243230 Log: Fix small style nits with previous commit in r243229. Modified: user/andre/tcp_workqueue/sys/sys/mbuf.h Modified: user/andre/tcp_workqueue/sys/sys/mbuf.h ============================================================================== --- user/andre/tcp_workqueue/sys/sys/mbuf.h Sun Nov 18 14:23:35 2012 (r243229) +++ user/andre/tcp_workqueue/sys/sys/mbuf.h Sun Nov 18 14:58:50 2012 (r243230) @@ -363,7 +363,7 @@ struct mbuf { #define CSUM_IP_FRAGO 0x00000110 /* IP fragmentation offload */ #define CSUM_IP_UFO 0x00000230 /* UDP fragmentation offload */ #define CSUM_IP_TSO 0x00000450 /* TCP segmentation offload */ -#define CSUM_IP_SCO 0x00000890 /* SCTP chunking offload */ +#define CSUM_IP_SCO 0x00000890 /* SCTP chunking offload */ /* IPv6 csum offload 0x0---0000 */ /* IPv6 hdr has no csum */ @@ -374,9 +374,7 @@ struct mbuf { #define CSUM_IP6_FRAGO 0x00200000 /* IPv6 frag */ #define CSUM_IP6_UFO 0x00220000 /* IPv6/UFO */ #define CSUM_IP6_TSO 0x00440000 /* IPv6/TSO */ -#define CSUM_IP6_SCO 0x00880000 * SCTP chunk offload */ - -#define CSUM_RSS_HT_XX 0x00000001-F +#define CSUM_IP6_SCO 0x00880000 * SCTP chunk offload */ /* Definition compatiblity with < 20121118, goes away after tree pruning */ #define CSUM_UDP CSUM_IP_UDP @@ -393,7 +391,7 @@ struct mbuf { #define CSUM_DATA_VALID CSUM_L4_VALID /* csum_data field is valid */ #define CSUM_SCTP_VALID CSUM_L4_VALID /* SCTP checksum is valid */ -#define CSUM_PSEUDO_HDR 0x00000001 /* XXX csum_data has pseudo hdr */ +#define CSUM_PSEUDO_HDR 0x00000001 /* XXX csum_data has pseudo hdr */ #define CSUM_DELAY_DATA_IPV6 (CSUM_TCP_IPV6 | CSUM_UDP_IPV6) #define CSUM_DATA_VALID_IPV6 CSUM_DATA_VALID #define CSUM_DELAY_DATA (CSUM_TCP | CSUM_UDP) From owner-svn-src-user@FreeBSD.ORG Mon Nov 19 11:45:12 2012 Return-Path: Delivered-To: svn-src-user@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id A710B9E3; Mon, 19 Nov 2012 11:45:12 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from cell.glebius.int.ru (glebius.int.ru [81.19.64.117]) by mx1.freebsd.org (Postfix) with ESMTP id 1E0848FC17; Mon, 19 Nov 2012 11:45:11 +0000 (UTC) Received: from cell.glebius.int.ru (localhost [127.0.0.1]) by cell.glebius.int.ru (8.14.5/8.14.5) with ESMTP id qAJBjAOp062131; Mon, 19 Nov 2012 15:45:10 +0400 (MSK) (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by cell.glebius.int.ru (8.14.5/8.14.5/Submit) id qAJBjASU062130; Mon, 19 Nov 2012 15:45:10 +0400 (MSK) (envelope-from glebius@FreeBSD.org) X-Authentication-Warning: cell.glebius.int.ru: glebius set sender to glebius@FreeBSD.org using -f Date: Mon, 19 Nov 2012 15:45:10 +0400 From: Gleb Smirnoff To: Andre Oppermann Subject: Re: svn commit: r243215 - user/andre/tcp_workqueue/sys/sys Message-ID: <20121119114510.GQ38060@FreeBSD.org> References: <201211181217.qAICH7aH021497@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline In-Reply-To: <201211181217.qAICH7aH021497@svn.freebsd.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: src-committers@FreeBSD.org, svn-src-user@FreeBSD.org X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Nov 2012 11:45:12 -0000 On Sun, Nov 18, 2012 at 12:17:07PM +0000, Andre Oppermann wrote: A> Author: andre A> Date: Sun Nov 18 12:17:07 2012 A> New Revision: 243215 A> URL: http://svnweb.freebsd.org/changeset/base/243215 A> A> Log: A> Add mtodo(m, o, t) macro taking an additional offset into A> the mbuf data section before the casting to type 't'. IMHO, argument order of (m, t, o) is more intuitive, since matches order of mtod(). A> A> Modified: A> user/andre/tcp_workqueue/sys/sys/mbuf.h A> A> Modified: user/andre/tcp_workqueue/sys/sys/mbuf.h A> ============================================================================== A> --- user/andre/tcp_workqueue/sys/sys/mbuf.h Sun Nov 18 12:16:50 2012 (r243214) A> +++ user/andre/tcp_workqueue/sys/sys/mbuf.h Sun Nov 18 12:17:07 2012 (r243215) A> @@ -64,8 +64,10 @@ A> * type: A> * A> * mtod(m, t) -- Convert mbuf pointer to data pointer of correct type. A> + * mtodo(m, o, t) - Same as above but with offset 'o' into data. A> */ A> #define mtod(m, t) ((t)((m)->m_data)) A> +#define mtodo(m, o, t) ((t)(((m)->m_data) + (o))) A> A> /* A> * Argument structure passed to UMA routines during mbuf and packet -- Totus tuus, Glebius. From owner-svn-src-user@FreeBSD.ORG Mon Nov 19 13:33:38 2012 Return-Path: Delivered-To: svn-src-user@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 87B97A89 for ; Mon, 19 Nov 2012 13:33:38 +0000 (UTC) (envelope-from andre@freebsd.org) Received: from c00l3r.networx.ch (c00l3r.networx.ch [62.48.2.2]) by mx1.freebsd.org (Postfix) with ESMTP id E8FB98FC12 for ; Mon, 19 Nov 2012 13:33:37 +0000 (UTC) Received: (qmail 79555 invoked from network); 19 Nov 2012 15:06:37 -0000 Received: from c00l3r.networx.ch (HELO [127.0.0.1]) ([62.48.2.2]) (envelope-sender ) by c00l3r.networx.ch (qmail-ldap-1.03) with SMTP for ; 19 Nov 2012 15:06:37 -0000 Message-ID: <50AA3529.2030300@freebsd.org> Date: Mon, 19 Nov 2012 14:33:29 +0100 From: Andre Oppermann User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:16.0) Gecko/20121026 Thunderbird/16.0.2 MIME-Version: 1.0 To: Gleb Smirnoff Subject: Re: svn commit: r243215 - user/andre/tcp_workqueue/sys/sys References: <201211181217.qAICH7aH021497@svn.freebsd.org> <20121119114510.GQ38060@FreeBSD.org> In-Reply-To: <20121119114510.GQ38060@FreeBSD.org> Content-Type: text/plain; charset=KOI8-R; format=flowed Content-Transfer-Encoding: 7bit Cc: src-committers@FreeBSD.org, svn-src-user@FreeBSD.org X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Nov 2012 13:33:38 -0000 On 19.11.2012 12:45, Gleb Smirnoff wrote: > On Sun, Nov 18, 2012 at 12:17:07PM +0000, Andre Oppermann wrote: > A> Author: andre > A> Date: Sun Nov 18 12:17:07 2012 > A> New Revision: 243215 > A> URL: http://svnweb.freebsd.org/changeset/base/243215 > A> > A> Log: > A> Add mtodo(m, o, t) macro taking an additional offset into > A> the mbuf data section before the casting to type 't'. > > IMHO, argument order of (m, t, o) is more intuitive, since > matches order of mtod(). Yes, but that looks rather horrible and counter-intuitive: th = mtodo(m, struct tcphdr *, 20); vs. th = mtodo(m, 20, struct tcphdr *); Reads m->m_data at offset 20 is struct tcphdr. Naming it mtood() wasn't convincing either. ;-) -- Andre > A> > A> Modified: > A> user/andre/tcp_workqueue/sys/sys/mbuf.h > A> > A> Modified: user/andre/tcp_workqueue/sys/sys/mbuf.h > A> ============================================================================== > A> --- user/andre/tcp_workqueue/sys/sys/mbuf.h Sun Nov 18 12:16:50 2012 (r243214) > A> +++ user/andre/tcp_workqueue/sys/sys/mbuf.h Sun Nov 18 12:17:07 2012 (r243215) > A> @@ -64,8 +64,10 @@ > A> * type: > A> * > A> * mtod(m, t) -- Convert mbuf pointer to data pointer of correct type. > A> + * mtodo(m, o, t) - Same as above but with offset 'o' into data. > A> */ > A> #define mtod(m, t) ((t)((m)->m_data)) > A> +#define mtodo(m, o, t) ((t)(((m)->m_data) + (o))) > A> > A> /* > A> * Argument structure passed to UMA routines during mbuf and packet > From owner-svn-src-user@FreeBSD.ORG Mon Nov 19 17:01:50 2012 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 74918558; Mon, 19 Nov 2012 17:01:50 +0000 (UTC) (envelope-from mdf356@gmail.com) Received: from mail-pb0-f54.google.com (mail-pb0-f54.google.com [209.85.160.54]) by mx1.freebsd.org (Postfix) with ESMTP id 2C1038FC08; Mon, 19 Nov 2012 17:01:49 +0000 (UTC) Received: by mail-pb0-f54.google.com with SMTP id wz12so3764477pbc.13 for ; Mon, 19 Nov 2012 09:01:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=GTVr6WysR0+7993CUSlvEslUnJqh35SVPdN+QgfbXrQ=; b=Xyv+5vb0SAroMs+XORYjspC62enN+SQNTE42fOZftFpGKM8Kf4RdHN2GowyaMRTTNg WtN1BgRROuT1Z7U+wYkrZhvpXm2/zLeyooGPSfkHiD0gamYa194+xDXb/VNRn948QItq 9BDgPryqwY2NB/feUiyfsbqAUgZCIZXKbCJ0unX7YBhztic9eWhoexiYcLWZTiQ7rZ0X B9Y+oT52r7cW0MZ8jfCJrldPAeAoz9maU3zf5P+3iKuk2jS5KFx9+RBlae1dIxo6KAev rFipeR36r3eCs2NVDxCXJvBKRBZUz5WInZnHYkITINpuWsXHeC1X7hm1nfzWsp6D7jdd mrcA== MIME-Version: 1.0 Received: by 10.68.192.97 with SMTP id hf1mr34418054pbc.106.1353344509763; Mon, 19 Nov 2012 09:01:49 -0800 (PST) Sender: mdf356@gmail.com Received: by 10.68.132.136 with HTTP; Mon, 19 Nov 2012 09:01:49 -0800 (PST) In-Reply-To: <50AA3529.2030300@freebsd.org> References: <201211181217.qAICH7aH021497@svn.freebsd.org> <20121119114510.GQ38060@FreeBSD.org> <50AA3529.2030300@freebsd.org> Date: Mon, 19 Nov 2012 09:01:49 -0800 X-Google-Sender-Auth: ecTSZeVxnAIsZX3ZcN94S8frxPI Message-ID: Subject: Re: svn commit: r243215 - user/andre/tcp_workqueue/sys/sys From: mdf@FreeBSD.org To: Andre Oppermann Content-Type: text/plain; charset=ISO-8859-1 Cc: Gleb Smirnoff , src-committers@freebsd.org, svn-src-user@freebsd.org X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Nov 2012 17:01:50 -0000 On Mon, Nov 19, 2012 at 5:33 AM, Andre Oppermann wrote: > On 19.11.2012 12:45, Gleb Smirnoff wrote: >> >> On Sun, Nov 18, 2012 at 12:17:07PM +0000, Andre Oppermann wrote: >> A> Author: andre >> A> Date: Sun Nov 18 12:17:07 2012 >> A> New Revision: 243215 >> A> URL: http://svnweb.freebsd.org/changeset/base/243215 >> A> >> A> Log: >> A> Add mtodo(m, o, t) macro taking an additional offset into >> A> the mbuf data section before the casting to type 't'. >> >> IMHO, argument order of (m, t, o) is more intuitive, since >> matches order of mtod(). > > > Yes, but that looks rather horrible and counter-intuitive: > > th = mtodo(m, struct tcphdr *, 20); > > vs. > > th = mtodo(m, 20, struct tcphdr *); > > Reads m->m_data at offset 20 is struct tcphdr. > > Naming it mtood() wasn't convincing either. ;-) Why a cast at all? Perpetuating the mistake of mtod()'s casting isn't necessary. mtod() can't be fixed for source reasons, but the new one doesn't need to cast. Since C automatically casts from void * to any other pointer, the code gets shorter (usually) too: th = mtodo(m, 20); Not that I care much, it's just if we're having a bikeshed I have my favorite colors. :-) Cheers, matthew >> A> >> A> Modified: >> A> user/andre/tcp_workqueue/sys/sys/mbuf.h >> A> >> A> Modified: user/andre/tcp_workqueue/sys/sys/mbuf.h >> A> >> ============================================================================== >> A> --- user/andre/tcp_workqueue/sys/sys/mbuf.h Sun Nov 18 12:16:50 2012 >> (r243214) >> A> +++ user/andre/tcp_workqueue/sys/sys/mbuf.h Sun Nov 18 12:17:07 2012 >> (r243215) >> A> @@ -64,8 +64,10 @@ >> A> * type: >> A> * >> A> * mtod(m, t) -- Convert mbuf pointer to data pointer of correct >> type. >> A> + * mtodo(m, o, t) - Same as above but with offset 'o' into data. >> A> */ >> A> #define mtod(m, t) ((t)((m)->m_data)) >> A> +#define mtodo(m, o, t) ((t)(((m)->m_data) + (o))) >> A> >> A> /* >> A> * Argument structure passed to UMA routines during mbuf and packet >> > From owner-svn-src-user@FreeBSD.ORG Mon Nov 19 18:04:19 2012 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0F9503ED; Mon, 19 Nov 2012 18:04:19 +0000 (UTC) (envelope-from andre@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id E5B528FC08; Mon, 19 Nov 2012 18:04:18 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qAJI4Irb014630; Mon, 19 Nov 2012 18:04:18 GMT (envelope-from andre@svn.freebsd.org) Received: (from andre@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qAJI4IXX014601; Mon, 19 Nov 2012 18:04:18 GMT (envelope-from andre@svn.freebsd.org) Message-Id: <201211191804.qAJI4IXX014601@svn.freebsd.org> From: Andre Oppermann Date: Mon, 19 Nov 2012 18:04:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r243291 - in user/andre/tcp_workqueue/sys: net netinet netinet6 netipsec netpfil/ipfw netpfil/pf X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Nov 2012 18:04:19 -0000 Author: andre Date: Mon Nov 19 18:04:17 2012 New Revision: 243291 URL: http://svnweb.freebsd.org/changeset/base/243291 Log: Convert IP, IPv6, UDP, TCP and SCTP to the new checksum offloading semantics on the inbound and outbound path. In short for inbound there are two levels the offloading NIC can set: CSUM_L3_CALC for an IP layer 3 checksum calculated by the NIC; CSUM_L3_VALID set when the calculated checksum matches the one in the packet; CSUM_L4_CALC for an UDP/TCP/SCTP layer 4 checksum calculated by the NIC; CSUM_L4_VALID set when the calculated checksum matche the one in the packet. From this follows that a packet failed checksum verification when only *_CALC is set but not *_VALID. The NIC is expected to deliver a failed packet up the stack anyways for capture by BPF and to record protocol specific checksum mismatch statistics. The old approach with CSUM_DATA_VALID and CSUM_PSEUDO_HDR could not signal a failed packet. A failed packet was delivered into the stack and the protocol had to recalculate the checksum for verification every time to detect that as the absence of CSUM_DATA_VALID didn't signal that the packet was broken. It was only saying that the checksum wasn't calculated by the NIC, which actually wasn't the case. Drag the other stack infrastructure, including packet filters, along as well. Modified: user/andre/tcp_workqueue/sys/net/if_bridge.c user/andre/tcp_workqueue/sys/net/if_ethersubr.c user/andre/tcp_workqueue/sys/net/if_loop.c user/andre/tcp_workqueue/sys/netinet/ip_divert.c user/andre/tcp_workqueue/sys/netinet/ip_fastfwd.c user/andre/tcp_workqueue/sys/netinet/ip_input.c user/andre/tcp_workqueue/sys/netinet/ip_ipsec.c user/andre/tcp_workqueue/sys/netinet/ip_mroute.c user/andre/tcp_workqueue/sys/netinet/ip_output.c user/andre/tcp_workqueue/sys/netinet/sctp_input.c user/andre/tcp_workqueue/sys/netinet/sctp_os_bsd.h user/andre/tcp_workqueue/sys/netinet/sctp_output.c user/andre/tcp_workqueue/sys/netinet/siftr.c user/andre/tcp_workqueue/sys/netinet/tcp_input.c user/andre/tcp_workqueue/sys/netinet/tcp_lro.c user/andre/tcp_workqueue/sys/netinet/tcp_output.c user/andre/tcp_workqueue/sys/netinet/tcp_subr.c user/andre/tcp_workqueue/sys/netinet/tcp_syncache.c user/andre/tcp_workqueue/sys/netinet/tcp_timewait.c user/andre/tcp_workqueue/sys/netinet/udp_usrreq.c user/andre/tcp_workqueue/sys/netinet6/ip6_forward.c user/andre/tcp_workqueue/sys/netinet6/ip6_ipsec.c user/andre/tcp_workqueue/sys/netinet6/ip6_output.c user/andre/tcp_workqueue/sys/netinet6/sctp6_usrreq.c user/andre/tcp_workqueue/sys/netinet6/udp6_usrreq.c user/andre/tcp_workqueue/sys/netipsec/ipsec_pfil.c user/andre/tcp_workqueue/sys/netpfil/ipfw/ip_fw_nat.c user/andre/tcp_workqueue/sys/netpfil/pf/pf.c user/andre/tcp_workqueue/sys/netpfil/pf/pf_ioctl.c Modified: user/andre/tcp_workqueue/sys/net/if_bridge.c ============================================================================== --- user/andre/tcp_workqueue/sys/net/if_bridge.c Mon Nov 19 17:33:45 2012 (r243290) +++ user/andre/tcp_workqueue/sys/net/if_bridge.c Mon Nov 19 18:04:17 2012 (r243291) @@ -3263,8 +3263,8 @@ bridge_ip_checkbasic(struct mbuf **mp) if (ip == NULL) goto bad; } - if (m->m_pkthdr.csum_flags & CSUM_IP_CHECKED) { - sum = !(m->m_pkthdr.csum_flags & CSUM_IP_VALID); + if (m->m_pkthdr.csum_flags & CSUM_L3_CALC) { + sum = !(m->m_pkthdr.csum_flags & CSUM_L3_VALID); } else { if (hlen == sizeof(struct ip)) { sum = in_cksum_hdr(ip); Modified: user/andre/tcp_workqueue/sys/net/if_ethersubr.c ============================================================================== --- user/andre/tcp_workqueue/sys/net/if_ethersubr.c Mon Nov 19 17:33:45 2012 (r243290) +++ user/andre/tcp_workqueue/sys/net/if_ethersubr.c Mon Nov 19 18:04:17 2012 (r243291) @@ -299,12 +299,10 @@ ether_output(struct ifnet *ifp, struct m if (lle != NULL && (lle->la_flags & LLE_IFADDR)) { int csum_flags = 0; if (m->m_pkthdr.csum_flags & CSUM_IP) - 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; + csum_flags |= (CSUM_L3_CALC|CSUM_L3_VALID); + if (m->m_pkthdr.csum_flags & (CSUM_UDP|CSUM_TCP|CSUM_SCTP)) + csum_flags |= (CSUM_L4_CALC|CSUM_L4_VALID); + m->m_pkthdr.csum_flags = csum_flags; m->m_pkthdr.csum_data = 0xffff; return (if_simloop(ifp, m, dst->sa_family, 0)); } @@ -356,11 +354,9 @@ ether_output(struct ifnet *ifp, struct m int csum_flags = 0; if (m->m_pkthdr.csum_flags & CSUM_IP) - 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; + csum_flags |= (CSUM_L3_CALC|CSUM_L3_VALID); + if (m->m_pkthdr.csum_flags & (CSUM_UDP|CSUM_TCP|CSUM_SCTP)) + csum_flags |= (CSUM_L4_CALC|CSUM_L4_VALID); if (m->m_flags & M_BCAST) { struct mbuf *n; @@ -379,16 +375,12 @@ ether_output(struct ifnet *ifp, struct m */ if ((n = m_dup(m, M_DONTWAIT)) != NULL) { n->m_pkthdr.csum_flags |= csum_flags; - if (csum_flags & CSUM_DATA_VALID) - n->m_pkthdr.csum_data = 0xffff; (void)if_simloop(ifp, n, dst->sa_family, hlen); } else ifp->if_iqdrops++; } else if (bcmp(eh->ether_dhost, eh->ether_shost, ETHER_ADDR_LEN) == 0) { m->m_pkthdr.csum_flags |= csum_flags; - if (csum_flags & CSUM_DATA_VALID) - m->m_pkthdr.csum_data = 0xffff; (void) if_simloop(ifp, m, dst->sa_family, hlen); return (0); /* XXX */ } Modified: user/andre/tcp_workqueue/sys/net/if_loop.c ============================================================================== --- user/andre/tcp_workqueue/sys/net/if_loop.c Mon Nov 19 17:33:45 2012 (r243290) +++ user/andre/tcp_workqueue/sys/net/if_loop.c Mon Nov 19 18:04:17 2012 (r243291) @@ -91,12 +91,10 @@ #define LOMTU 16384 #endif -#define LO_CSUM_FEATURES (CSUM_IP | CSUM_TCP | CSUM_UDP | CSUM_SCTP) -#define LO_CSUM_FEATURES6 (CSUM_TCP_IPV6 | CSUM_UDP_IPV6 | CSUM_SCTP_IPV6) -#define LO_CSUM_SET (CSUM_DATA_VALID | CSUM_DATA_VALID_IPV6 | \ - CSUM_PSEUDO_HDR | \ - CSUM_IP_CHECKED | CSUM_IP_VALID | \ - CSUM_SCTP_VALID) +#define LO_CSUM_FEATURES (CSUM_IP|CSUM_IP_UDP|CSUM_IP_TCP|CSUM_IP_SCTP) +#define LO_CSUM_FEATURES6 (CSUM_IP6_UDP|CSUM_IP6_TCP|CSUM_IP6_SCTP) +#define LO_CSUM_SET (CSUM_L4_CALC | CSUM_L4_VALID | \ + CSUM_L3_CALC | CSUM_L3_VALID) int loioctl(struct ifnet *, u_long, caddr_t); static void lortrequest(int, struct rtentry *, struct rt_addrinfo *); Modified: user/andre/tcp_workqueue/sys/netinet/ip_divert.c ============================================================================== --- user/andre/tcp_workqueue/sys/netinet/ip_divert.c Mon Nov 19 17:33:45 2012 (r243290) +++ user/andre/tcp_workqueue/sys/netinet/ip_divert.c Mon Nov 19 18:04:17 2012 (r243291) @@ -207,14 +207,14 @@ divert_packet(struct mbuf *m, int incomi ip = mtod(m, struct ip *); /* Delayed checksums are currently not compatible with divert. */ - if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA) { + if (m->m_pkthdr.csum_flags & (CSUM_IP_UDP|CSUM_IP_TCP)) { in_delayed_cksum(m); - m->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA; + m->m_pkthdr.csum_flags &= ~(CSUM_IP_UDP|CSUM_IP_TCP); } #ifdef SCTP - if (m->m_pkthdr.csum_flags & CSUM_SCTP) { + if (m->m_pkthdr.csum_flags & CSUM_IP_SCTP) { sctp_delayed_cksum(m, (uint32_t)(ip->ip_hl << 2)); - m->m_pkthdr.csum_flags &= ~CSUM_SCTP; + m->m_pkthdr.csum_flags &= ~CSUM_IP_SCTP; } #endif bzero(&divsrc, sizeof(divsrc)); Modified: user/andre/tcp_workqueue/sys/netinet/ip_fastfwd.c ============================================================================== --- user/andre/tcp_workqueue/sys/netinet/ip_fastfwd.c Mon Nov 19 17:33:45 2012 (r243290) +++ user/andre/tcp_workqueue/sys/netinet/ip_fastfwd.c Mon Nov 19 18:04:17 2012 (r243291) @@ -230,23 +230,25 @@ ip_fastforward(struct mbuf *m) /* * Checksum correct? */ - if (m->m_pkthdr.csum_flags & CSUM_IP_CHECKED) - sum = !(m->m_pkthdr.csum_flags & CSUM_IP_VALID); - else { + if ((m->m_pkthdr.csum_flags & (CSUM_L3_CALC | CSUM_L3_VALID)) == + CSUM_L3_CALC) { + IPSTAT_INC(ips_badsum); + goto drop; + } else if (!(m->m_pkthdr.csum_flags & CSUM_L3_VALID)) { if (hlen == sizeof(struct ip)) sum = in_cksum_hdr(ip); else sum = in_cksum(m, hlen); + if (sum) { + IPSTAT_INC(ips_badsum); + goto drop; + } + /* + * Remember that we have checked the IP header and found + * it valid. + */ + m->m_pkthdr.csum_flags |= (CSUM_L3_CALC | CSUM_L3_VALID); } - if (sum) { - IPSTAT_INC(ips_badsum); - goto drop; - } - - /* - * Remember that we have checked the IP header and found it valid. - */ - m->m_pkthdr.csum_flags |= (CSUM_IP_CHECKED | CSUM_IP_VALID); ip_len = ntohs(ip->ip_len); @@ -523,7 +525,7 @@ passout: mtu = ifp->if_mtu; if (ip_len <= mtu || - (ifp->if_hwassist & CSUM_IPFRAG && (ip_off & IP_DF) == 0)) { + ((ifp->if_hwassist & CSUM_IP_FRAGO) && (ip_off & IP_DF) == 0)) { /* * Send off the packet via outgoing interface */ Modified: user/andre/tcp_workqueue/sys/netinet/ip_input.c ============================================================================== --- user/andre/tcp_workqueue/sys/netinet/ip_input.c Mon Nov 19 17:33:45 2012 (r243290) +++ user/andre/tcp_workqueue/sys/netinet/ip_input.c Mon Nov 19 18:04:17 2012 (r243291) @@ -435,19 +435,20 @@ ip_input(struct mbuf *m) } } - if (m->m_pkthdr.csum_flags & CSUM_IP_CHECKED) { - sum = !(m->m_pkthdr.csum_flags & CSUM_IP_VALID); - } else { - if (hlen == sizeof(struct ip)) { + if ((m->m_pkthdr.csum_flags & (CSUM_L3_CALC|CSUM_L3_VALID)) == + CSUM_L3_CALC) { + IPSTAT_INC(ips_badsum); + goto bad; + } else if (!(m->m_pkthdr.csum_flags & CSUM_L3_VALID)) { + if (hlen == sizeof(struct ip)) sum = in_cksum_hdr(ip); - } else { + else sum = in_cksum(m, hlen); + if (sum) { + IPSTAT_INC(ips_badsum); + goto bad; } } - if (sum) { - IPSTAT_INC(ips_badsum); - goto bad; - } #ifdef ALTQ if (altq_input != NULL && (*altq_input)(m, AF_INET) == 0) Modified: user/andre/tcp_workqueue/sys/netinet/ip_ipsec.c ============================================================================== --- user/andre/tcp_workqueue/sys/netinet/ip_ipsec.c Mon Nov 19 17:33:45 2012 (r243290) +++ user/andre/tcp_workqueue/sys/netinet/ip_ipsec.c Mon Nov 19 18:04:17 2012 (r243291) @@ -327,16 +327,16 @@ ip_ipsec_output(struct mbuf **m, struct * Do delayed checksums now because we send before * this is done in the normal processing path. */ - if ((*m)->m_pkthdr.csum_flags & CSUM_DELAY_DATA) { + if ((*m)->m_pkthdr.csum_flags & (CSUM_IP_UDP|CSUM_IP_TCP)) { in_delayed_cksum(*m); - (*m)->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA; + (*m)->m_pkthdr.csum_flags &= ~(CSUM_IP_UDP|CSUM_IP_TCP); } #ifdef SCTP - if ((*m)->m_pkthdr.csum_flags & CSUM_SCTP) { + if ((*m)->m_pkthdr.csum_flags & CSUM_IP_SCTP) { struct ip *ip = mtod(*m, struct ip *); sctp_delayed_cksum(*m, (uint32_t)(ip->ip_hl << 2)); - (*m)->m_pkthdr.csum_flags &= ~CSUM_SCTP; + (*m)->m_pkthdr.csum_flags &= ~CSUM_IP_SCTP; } #endif Modified: user/andre/tcp_workqueue/sys/netinet/ip_mroute.c ============================================================================== --- user/andre/tcp_workqueue/sys/netinet/ip_mroute.c Mon Nov 19 17:33:45 2012 (r243290) +++ user/andre/tcp_workqueue/sys/netinet/ip_mroute.c Mon Nov 19 18:04:17 2012 (r243291) @@ -2375,9 +2375,9 @@ pim_register_prepare(struct ip *ip, stru int mtu; /* Take care of delayed checksums */ - if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA) { + if (m->m_pkthdr.csum_flags & (CSUM_IP_UDP|CSUM_IP_TCP)) { in_delayed_cksum(m); - m->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA; + m->m_pkthdr.csum_flags &= ~(CSUM_IP_UDP|CSUM_IP_TCP); } /* Modified: user/andre/tcp_workqueue/sys/netinet/ip_output.c ============================================================================== --- user/andre/tcp_workqueue/sys/netinet/ip_output.c Mon Nov 19 17:33:45 2012 (r243290) +++ user/andre/tcp_workqueue/sys/netinet/ip_output.c Mon Nov 19 18:04:17 2012 (r243291) @@ -518,41 +518,31 @@ sendit: m->m_flags |= M_FASTFWD_OURS; if (m->m_pkthdr.rcvif == NULL) m->m_pkthdr.rcvif = V_loif; - if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA) { + /* Pretend that the checksum was verified by hw. */ + if (m->m_pkthdr.csum_flags & CSUM_IP) m->m_pkthdr.csum_flags |= - CSUM_DATA_VALID | CSUM_PSEUDO_HDR; - m->m_pkthdr.csum_data = 0xffff; - } - 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 + CSUM_L3_CALC | CSUM_L3_VALID; + if (m->m_pkthdr.csum_flags & + (CSUM_UDP|CSUM_TCP|CSUM_SCTP)) + m->m_pkthdr.csum_flags |= + CSUM_L4_CALC | CSUM_L4_VALID; error = netisr_queue(NETISR_IP, m); goto done; - } else { - if (ia != NULL) - ifa_free(&ia->ia_ifa); - goto again; /* Redo the routing table lookup. */ } + if (ia != NULL) + ifa_free(&ia->ia_ifa); + goto again; /* Redo the routing table lookup. */ } /* See if local, if yes, send it to netisr with IP_FASTFWD_OURS. */ if (m->m_flags & M_FASTFWD_OURS) { if (m->m_pkthdr.rcvif == NULL) m->m_pkthdr.rcvif = V_loif; - if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA) { - m->m_pkthdr.csum_flags |= - 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; + /* Pretend that the checksum was verified by hw. */ + if (m->m_pkthdr.csum_flags & CSUM_IP) + m->m_pkthdr.csum_flags |= CSUM_L3_CALC | CSUM_L3_VALID; + if (m->m_pkthdr.csum_flags & (CSUM_UDP|CSUM_TCP|CSUM_SCTP)) + m->m_pkthdr.csum_flags |= CSUM_L4_CALC | CSUM_L4_VALID; error = netisr_queue(NETISR_IP, m); goto done; @@ -583,14 +573,15 @@ passout: m->m_pkthdr.csum_flags |= CSUM_IP; m->m_pkthdr.csum_l3hlen += ip_len; - if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA & ~ifp->if_hwassist) { + if (m->m_pkthdr.csum_flags & (CSUM_IP_UDP|CSUM_IP_TCP) & + ~ifp->if_hwassist) { in_delayed_cksum(m); - m->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA; + m->m_pkthdr.csum_flags &= ~(CSUM_IP_UDP|CSUM_IP_TCP); } #ifdef SCTP - if (m->m_pkthdr.csum_flags & CSUM_SCTP & ~ifp->if_hwassist) { + else if (m->m_pkthdr.csum_flags & CSUM_IP_SCTP & ~ifp->if_hwassist) { sctp_delayed_cksum(m, (uint32_t)(ip->ip_hl << 2)); - m->m_pkthdr.csum_flags &= ~CSUM_SCTP; + m->m_pkthdr.csum_flags &= ~CSUM_IP_SCTP; } #endif @@ -599,8 +590,8 @@ passout: * care of the fragmentation for us, we can just send directly. */ if (ip_len <= mtu || - (m->m_pkthdr.csum_flags & ifp->if_hwassist & CSUM_TSO) != 0 || - ((ip_off & IP_DF) == 0 && (ifp->if_hwassist & CSUM_IPFRAG))) { + (m->m_pkthdr.csum_flags & ifp->if_hwassist & CSUM_IP_TSO) != 0 || + ((ip_off & IP_DF) == 0 && (ifp->if_hwassist & CSUM_IP_FRAGO))) { ip->ip_sum = 0; if (m->m_pkthdr.csum_flags & CSUM_IP & ~ifp->if_hwassist) { ip->ip_sum = in_cksum(m, hlen); @@ -609,12 +600,12 @@ passout: /* * Record statistics for this interface address. - * With CSUM_TSO the byte/packet count will be slightly + * With CSUM_IP_TSO the byte/packet count will be slightly * incorrect because we count the IP+TCP headers only * once instead of for every generated packet. */ if (!(flags & IP_FORWARDING) && ia) { - if (m->m_pkthdr.csum_flags & CSUM_TSO) + if (m->m_pkthdr.csum_flags & CSUM_IP_TSO) ia->ia_ifa.if_opackets += m->m_pkthdr.len / m->m_pkthdr.tso_segsz; else @@ -636,7 +627,7 @@ passout: } /* Balk when DF bit is set or the interface didn't support TSO. */ - if ((ip_off & IP_DF) || (m->m_pkthdr.csum_flags & CSUM_TSO)) { + if ((ip_off & IP_DF) || (m->m_pkthdr.csum_flags & CSUM_IP_TSO)) { error = EMSGSIZE; IPSTAT_INC(ips_cantfrag); goto bad; @@ -724,14 +715,14 @@ ip_fragment(struct ip *ip, struct mbuf * * If the interface will not calculate checksums on * fragmented packets, then do it here. */ - if (m0->m_pkthdr.csum_flags & CSUM_DELAY_DATA) { + if (m0->m_pkthdr.csum_flags & (CSUM_IP_UDP|CSUM_IP_TCP)) { in_delayed_cksum(m0); - m0->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA; + m0->m_pkthdr.csum_flags &= ~(CSUM_IP_UDP|CSUM_IP_TCP); } #ifdef SCTP - if (m0->m_pkthdr.csum_flags & CSUM_SCTP) { + if (m0->m_pkthdr.csum_flags & CSUM_IP_SCTP) { sctp_delayed_cksum(m0, hlen); - m0->m_pkthdr.csum_flags &= ~CSUM_SCTP; + m0->m_pkthdr.csum_flags &= ~CSUM_IP_SCTP; } #endif if (len > PAGE_SIZE) { @@ -872,7 +863,7 @@ in_delayed_cksum(struct mbuf *m) offset = ip->ip_hl << 2 ; ip_len = ntohs(ip->ip_len); csum = in_cksum_skip(m, ip_len, offset); - if (m->m_pkthdr.csum_flags & CSUM_UDP && csum == 0) + if (m->m_pkthdr.csum_flags & CSUM_IP_UDP && csum == 0) csum = 0xffff; offset += m->m_pkthdr.csum_data; /* checksum offset */ @@ -1296,11 +1287,11 @@ ip_mloopback(struct ifnet *ifp, struct m copym = m_pullup(copym, hlen); if (copym != NULL) { /* If needed, compute the checksum and mark it as valid. */ - if (copym->m_pkthdr.csum_flags & CSUM_DELAY_DATA) { + if (copym->m_pkthdr.csum_flags & (CSUM_IP_UDP|CSUM_IP_TCP)) { in_delayed_cksum(copym); - copym->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA; + copym->m_pkthdr.csum_flags &= ~(CSUM_IP_UDP|CSUM_IP_TCP); copym->m_pkthdr.csum_flags |= - CSUM_DATA_VALID | CSUM_PSEUDO_HDR; + CSUM_L4_CALC | CSUM_L4_VALID; copym->m_pkthdr.csum_data = 0xffff; } /* Modified: user/andre/tcp_workqueue/sys/netinet/sctp_input.c ============================================================================== --- user/andre/tcp_workqueue/sys/netinet/sctp_input.c Mon Nov 19 17:33:45 2012 (r243290) +++ user/andre/tcp_workqueue/sys/netinet/sctp_input.c Mon Nov 19 18:04:17 2012 (r243291) @@ -6064,9 +6064,15 @@ sctp_input_with_port(struct mbuf *i_pak, #if defined(SCTP_WITH_NO_CSUM) SCTP_STAT_INCR(sctps_recvnocrc); #else - if (m->m_pkthdr.csum_flags & CSUM_SCTP_VALID) { + if ((m->m_pkthdr.csum_flags & (CSUM_L4_CALC|CSUM_L4_VALID)) == + (CSUM_L4_CALC | CSUM_L4_VALID)) { SCTP_STAT_INCR(sctps_recvhwcrc); compute_crc = 0; + } else if ((m->m_pkthdr.csum_flags & (CSUM_L4_CALC|CSUM_L4_VALID)) == + CSUM_L4_CALC) { + SCTP_STAT_INCR(sctps_badsum); + SCTP_STAT_INCR_COUNTER32(sctps_checksumerrors); + goto out; } else { SCTP_STAT_INCR(sctps_recvswcrc); compute_crc = 1; Modified: user/andre/tcp_workqueue/sys/netinet/sctp_os_bsd.h ============================================================================== --- user/andre/tcp_workqueue/sys/netinet/sctp_os_bsd.h Mon Nov 19 17:33:45 2012 (r243290) +++ user/andre/tcp_workqueue/sys/netinet/sctp_os_bsd.h Mon Nov 19 18:04:17 2012 (r243291) @@ -366,8 +366,8 @@ typedef struct callout sctp_os_timer_t; #define SCTP_RELEASE_HEADER(m) #define SCTP_RELEASE_PKT(m) sctp_m_freem(m) #define SCTP_ENABLE_UDP_CSUM(m) do { \ - m->m_pkthdr.csum_flags = CSUM_UDP; \ - m->m_pkthdr.csum_data = offsetof(struct udphdr, uh_sum); \ + m->m_pkthdr.csum_flags = CSUM_IP_UDP; \ + m->m_pkthdr.csum_l4hlen = sizeof(struct udphdr); \ } while (0) #define SCTP_GET_PKT_VRFID(m, vrf_id) ((vrf_id = SCTP_DEFAULT_VRFID) != SCTP_DEFAULT_VRFID) Modified: user/andre/tcp_workqueue/sys/netinet/sctp_output.c ============================================================================== --- user/andre/tcp_workqueue/sys/netinet/sctp_output.c Mon Nov 19 17:33:45 2012 (r243290) +++ user/andre/tcp_workqueue/sys/netinet/sctp_output.c Mon Nov 19 18:04:17 2012 (r243291) @@ -4129,7 +4129,7 @@ sctp_lowlevel_chunk_output(struct sctp_i #if defined(SCTP_WITH_NO_CSUM) SCTP_STAT_INCR(sctps_sendnocrc); #else - m->m_pkthdr.csum_flags = CSUM_SCTP; + m->m_pkthdr.csum_flags = CSUM_IP_SCTP; m->m_pkthdr.csum_l4hlen = sizeof(struct sctphdr); SCTP_STAT_INCR(sctps_sendhwcrc); #endif @@ -4478,7 +4478,7 @@ sctp_lowlevel_chunk_output(struct sctp_i #if defined(SCTP_WITH_NO_CSUM) SCTP_STAT_INCR(sctps_sendnocrc); #else - m->m_pkthdr.csum_flags = CSUM_SCTP_IPV6; + m->m_pkthdr.csum_flags = CSUM_IP6_SCTP; m->m_pkthdr.csum_l4hlen = sizeof(struct sctphdr); SCTP_STAT_INCR(sctps_sendhwcrc); #endif @@ -11005,7 +11005,7 @@ sctp_send_resp_msg(struct sockaddr *src, #if defined(SCTP_WITH_NO_CSUM) SCTP_STAT_INCR(sctps_sendnocrc); #else - mout->m_pkthdr.csum_flags = CSUM_SCTP; + mout->m_pkthdr.csum_flags = CSUM_IP_SCTP; mout->m_pkthdr.csum_l4hlen = sizeof(struct sctphdr); SCTP_STAT_INCR(sctps_sendhwcrc); #endif @@ -11035,7 +11035,7 @@ sctp_send_resp_msg(struct sockaddr *src, #if defined(SCTP_WITH_NO_CSUM) SCTP_STAT_INCR(sctps_sendnocrc); #else - mout->m_pkthdr.csum_flags = CSUM_SCTP_IPV6; + mout->m_pkthdr.csum_flags = CSUM_IP6_SCTP; mout->m_pkthdr.csum_l4hlen = sizeof(struct sctphdr); SCTP_STAT_INCR(sctps_sendhwcrc); #endif Modified: user/andre/tcp_workqueue/sys/netinet/siftr.c ============================================================================== --- user/andre/tcp_workqueue/sys/netinet/siftr.c Mon Nov 19 17:33:45 2012 (r243290) +++ user/andre/tcp_workqueue/sys/netinet/siftr.c Mon Nov 19 18:04:17 2012 (r243291) @@ -904,7 +904,7 @@ siftr_chkpkt(void *arg, struct mbuf **m, siftr_siftdata(pn, inp, tp, INP_IPV4, dir, inp_locally_locked); if (siftr_generate_hashes) { - if ((*m)->m_pkthdr.csum_flags & CSUM_TCP) { + if ((*m)->m_pkthdr.csum_flags & CSUM_IP_TCP) { /* * For outbound packets, the TCP checksum isn't * calculated yet. This is a problem for our packet @@ -915,7 +915,7 @@ siftr_chkpkt(void *arg, struct mbuf **m, * software. We unset the CSUM_TCP flag so the lower * layers don't recalc it. */ - (*m)->m_pkthdr.csum_flags &= ~CSUM_TCP; + (*m)->m_pkthdr.csum_flags &= ~CSUM_IP_TCP; /* * Calculate the TCP checksum in software and assign Modified: user/andre/tcp_workqueue/sys/netinet/tcp_input.c ============================================================================== --- user/andre/tcp_workqueue/sys/netinet/tcp_input.c Mon Nov 19 17:33:45 2012 (r243290) +++ user/andre/tcp_workqueue/sys/netinet/tcp_input.c Mon Nov 19 18:04:17 2012 (r243291) @@ -614,16 +614,13 @@ tcp_input(struct mbuf *m, int off0) ip6 = mtod(m, struct ip6_hdr *); th = (struct tcphdr *)((caddr_t)ip6 + off0); tlen = sizeof(*ip6) + ntohs(ip6->ip6_plen) - off0; - if (m->m_pkthdr.csum_flags & CSUM_DATA_VALID_IPV6) { - if (m->m_pkthdr.csum_flags & CSUM_PSEUDO_HDR) - th->th_sum = m->m_pkthdr.csum_data; - else - th->th_sum = in6_cksum_pseudo(ip6, tlen, - IPPROTO_TCP, m->m_pkthdr.csum_data); - th->th_sum ^= 0xffff; - } else - th->th_sum = in6_cksum(m, IPPROTO_TCP, off0, tlen); - if (th->th_sum) { + + if ((m->m_pkthdr.csum_flags & (CSUM_L4_CALC|CSUM_L4_VALID)) == + CSUM_L4_CALC) { + TCPSTAT_INC(tcps_rcvbadsum); + goto drop; + } else if (!(m->m_pkthdr.csum_flags & CSUM_L4_VALID) && + in6_cksum(m, IPPROTO_TCP, off0, tlen)) { TCPSTAT_INC(tcps_rcvbadsum); goto drop; } @@ -666,16 +663,11 @@ tcp_input(struct mbuf *m, int off0) th = (struct tcphdr *)((caddr_t)ip + off0); tlen = ntohs(ip->ip_len) - off0; - if (m->m_pkthdr.csum_flags & CSUM_DATA_VALID) { - if (m->m_pkthdr.csum_flags & CSUM_PSEUDO_HDR) - th->th_sum = m->m_pkthdr.csum_data; - else - th->th_sum = in_pseudo(ip->ip_src.s_addr, - ip->ip_dst.s_addr, - htonl(m->m_pkthdr.csum_data + tlen + - IPPROTO_TCP)); - th->th_sum ^= 0xffff; - } else { + if ((m->m_pkthdr.csum_flags & (CSUM_L4_CALC|CSUM_L4_VALID)) == + CSUM_L4_CALC) { + TCPSTAT_INC(tcps_rcvbadsum); + goto drop; + } else if (!(m->m_pkthdr.csum_flags & CSUM_L4_VALID)) { struct ipovly *ipov = (struct ipovly *)ip; /* @@ -685,10 +677,11 @@ tcp_input(struct mbuf *m, int off0) bzero(ipov->ih_x1, sizeof(ipov->ih_x1)); ipov->ih_len = htons(tlen); th->th_sum = in_cksum(m, len); - } - if (th->th_sum) { - TCPSTAT_INC(tcps_rcvbadsum); - goto drop; + + if (th->th_sum) { + TCPSTAT_INC(tcps_rcvbadsum); + goto drop; + } } /* Re-initialization for later version check */ ip->ip_v = IPVERSION; @@ -3610,7 +3603,7 @@ tcp_mss(struct tcpcb *tp, int offer) SOCKBUF_UNLOCK(&so->so_rcv); /* Check the interface for TSO capabilities. */ - if (mtuflags & CSUM_TSO) + if (mtuflags & CSUM_IP_TSO) tp->t_flags |= TF_TSO; } Modified: user/andre/tcp_workqueue/sys/netinet/tcp_lro.c ============================================================================== --- user/andre/tcp_workqueue/sys/netinet/tcp_lro.c Mon Nov 19 17:33:45 2012 (r243290) +++ user/andre/tcp_workqueue/sys/netinet/tcp_lro.c Mon Nov 19 18:04:17 2012 (r243291) @@ -211,8 +211,8 @@ tcp_lro_flush(struct lro_ctrl *lc, struc ip6 = le->le_ip6; ip6->ip6_plen = p_len; th = (struct tcphdr *)(ip6 + 1); - le->m_head->m_pkthdr.csum_flags = CSUM_DATA_VALID | - CSUM_PSEUDO_HDR; + le->m_head->m_pkthdr.csum_flags = CSUM_L4_CALC | + CSUM_L4_VALID; le->p_len += ETHER_HDR_LEN + sizeof(*ip6); break; } @@ -242,8 +242,8 @@ tcp_lro_flush(struct lro_ctrl *lc, struc #endif ip4->ip_len = p_len; th = (struct tcphdr *)(ip4 + 1); - le->m_head->m_pkthdr.csum_flags = CSUM_DATA_VALID | - CSUM_PSEUDO_HDR | CSUM_IP_CHECKED | CSUM_IP_VALID; + le->m_head->m_pkthdr.csum_flags = CSUM_L4_CALC | + CSUM_L4_VALID | CSUM_L3_CALC | CSUM_L3_VALID; le->p_len += ETHER_HDR_LEN; break; } @@ -310,7 +310,6 @@ static int tcp_lro_rx_ipv4(struct lro_ctrl *lc, struct mbuf *m, struct ip *ip4, struct tcphdr **th) { - int csum_flags; uint16_t csum; if (ip4->ip_p != IPPROTO_TCP) @@ -325,18 +324,17 @@ tcp_lro_rx_ipv4(struct lro_ctrl *lc, str return (TCP_LRO_CANNOT); /* Legacy IP has a header checksum that needs to be correct. */ - csum_flags = m->m_pkthdr.csum_flags; - if (csum_flags & CSUM_IP_CHECKED) { - if (__predict_false((csum_flags & CSUM_IP_VALID) == 0)) { - lc->lro_bad_csum++; - return (TCP_LRO_CANNOT); - } - } else { + if ((m->m_pkthdr.csum_flags & (CSUM_L3_CALC | CSUM_L3_VALID)) == + CSUM_L3_CALC) { + lc->lro_bad_csum++; + return (TCP_LRO_CANNOT); + } else if (!(m->m_pkthdr.csum_flags & CSUM_L3_VALID)) { csum = in_cksum_hdr(ip4); if (__predict_false((csum ^ 0xffff) != 0)) { lc->lro_bad_csum++; return (TCP_LRO_CANNOT); } + m->m_pkthdr.csum_flags |= (CSUM_L3_CALC | CSUM_L3_VALID); } /* Find the TCP header (we assured there are no IP options). */ Modified: user/andre/tcp_workqueue/sys/netinet/tcp_output.c ============================================================================== --- user/andre/tcp_workqueue/sys/netinet/tcp_output.c Mon Nov 19 17:33:45 2012 (r243290) +++ user/andre/tcp_workqueue/sys/netinet/tcp_output.c Mon Nov 19 18:04:17 2012 (r243291) @@ -1085,7 +1085,7 @@ send: * ip6_plen is not need to be filled now, and will be filled * in ip6_output. */ - m->m_pkthdr.csum_flags = CSUM_TCP_IPV6; + m->m_pkthdr.csum_flags = CSUM_IP6_TCP; th->th_sum = in6_cksum_pseudo(ip6, sizeof(struct tcphdr) + optlen + len, IPPROTO_TCP, 0); } @@ -1095,7 +1095,7 @@ send: #endif #ifdef INET { - m->m_pkthdr.csum_flags = CSUM_TCP; + m->m_pkthdr.csum_flags = CSUM_IP_TCP; th->th_sum = in_pseudo(ip->ip_src.s_addr, ip->ip_dst.s_addr, htons(sizeof(struct tcphdr) + IPPROTO_TCP + len + optlen)); @@ -1113,7 +1113,10 @@ send: if (tso) { KASSERT(len > tp->t_maxopd - optlen, ("%s: len <= tso_segsz", __func__)); - m->m_pkthdr.csum_flags |= CSUM_TSO; + if (isipv6) + m->m_pkthdr.csum_flags |= CSUM_IP6_TSO; + else + m->m_pkthdr.csum_flags |= CSUM_IP_TSO; m->m_pkthdr.tso_segsz = tp->t_maxopd - optlen; } Modified: user/andre/tcp_workqueue/sys/netinet/tcp_subr.c ============================================================================== --- user/andre/tcp_workqueue/sys/netinet/tcp_subr.c Mon Nov 19 17:33:45 2012 (r243290) +++ user/andre/tcp_workqueue/sys/netinet/tcp_subr.c Mon Nov 19 18:04:17 2012 (r243291) @@ -623,12 +623,10 @@ tcp_respond(struct tcpcb *tp, void *ipge nth->th_win = htons((u_short)win); nth->th_urp = 0; - m->m_pkthdr.csum_data = offsetof(struct tcphdr, th_sum); + m->m_pkthdr.csum_l4hlen = sizeof(struct tcphdr); #ifdef INET6 if (isipv6) { - m->m_pkthdr.csum_flags = CSUM_TCP_IPV6; - nth->th_sum = in6_cksum_pseudo(ip6, - tlen - sizeof(struct ip6_hdr), IPPROTO_TCP, 0); + m->m_pkthdr.csum_flags = CSUM_IP6_TCP; ip6->ip6_hlim = in6_selecthlim(tp != NULL ? tp->t_inpcb : NULL, NULL); } @@ -638,9 +636,7 @@ tcp_respond(struct tcpcb *tp, void *ipge #endif #ifdef INET { - m->m_pkthdr.csum_flags = CSUM_TCP; - nth->th_sum = in_pseudo(ip->ip_src.s_addr, ip->ip_dst.s_addr, - htons((u_short)(tlen - sizeof(struct ip) + ip->ip_p))); + m->m_pkthdr.csum_flags = CSUM_IP_TCP; } #endif /* INET */ #ifdef TCPDEBUG @@ -1744,8 +1740,8 @@ tcp_maxmtu(struct in_conninfo *inc, int /* Report additional interface capabilities. */ if (flags != NULL) { if (ifp->if_capenable & IFCAP_TSO4 && - ifp->if_hwassist & CSUM_TSO) - *flags |= CSUM_TSO; + ifp->if_hwassist & CSUM_IP_TSO) + *flags |= CSUM_IP_TSO; } RTFREE(sro.ro_rt); } @@ -1781,8 +1777,8 @@ tcp_maxmtu6(struct in_conninfo *inc, int /* Report additional interface capabilities. */ if (flags != NULL) { if (ifp->if_capenable & IFCAP_TSO6 && - ifp->if_hwassist & CSUM_TSO) - *flags |= CSUM_TSO; + ifp->if_hwassist & CSUM_IP6_TSO) + *flags |= CSUM_IP6_TSO; } RTFREE(sro6.ro_rt); } Modified: user/andre/tcp_workqueue/sys/netinet/tcp_syncache.c ============================================================================== --- user/andre/tcp_workqueue/sys/netinet/tcp_syncache.c Mon Nov 19 17:33:45 2012 (r243290) +++ user/andre/tcp_workqueue/sys/netinet/tcp_syncache.c Mon Nov 19 18:04:17 2012 (r243291) @@ -1509,12 +1509,10 @@ syncache_respond(struct syncache *sc) optlen = 0; M_SETFIB(m, sc->sc_inc.inc_fibnum); - m->m_pkthdr.csum_data = offsetof(struct tcphdr, th_sum); + m->m_pkthdr.csum_l4hlen = sizeof(struct tcphdr) + optlen; #ifdef INET6 if (sc->sc_inc.inc_flags & INC_ISIPV6) { - m->m_pkthdr.csum_flags = CSUM_TCP_IPV6; - th->th_sum = in6_cksum_pseudo(ip6, tlen + optlen - hlen, - IPPROTO_TCP, 0); + m->m_pkthdr.csum_flags = CSUM_IP6_TCP; ip6->ip6_hlim = in6_selecthlim(NULL, NULL); error = ip6_output(m, NULL, NULL, 0, NULL, NULL, NULL); } @@ -1524,9 +1522,7 @@ syncache_respond(struct syncache *sc) #endif #ifdef INET { - m->m_pkthdr.csum_flags = CSUM_TCP; - th->th_sum = in_pseudo(ip->ip_src.s_addr, ip->ip_dst.s_addr, - htons(tlen + optlen - hlen + IPPROTO_TCP)); + m->m_pkthdr.csum_flags = CSUM_IP_TCP; #ifdef TCP_OFFLOAD if (ADDED_BY_TOE(sc)) { struct toedev *tod = sc->sc_tod; Modified: user/andre/tcp_workqueue/sys/netinet/tcp_timewait.c ============================================================================== --- user/andre/tcp_workqueue/sys/netinet/tcp_timewait.c Mon Nov 19 17:33:45 2012 (r243290) +++ user/andre/tcp_workqueue/sys/netinet/tcp_timewait.c Mon Nov 19 18:04:17 2012 (r243291) @@ -575,12 +575,10 @@ tcp_twrespond(struct tcptw *tw, int flag th->th_flags = flags; th->th_win = htons(tw->last_win); - m->m_pkthdr.csum_data = offsetof(struct tcphdr, th_sum); + m->m_pkthdr.csum_l4hlen = sizeof(struct tcphdr) + optlen; #ifdef INET6 if (isipv6) { - m->m_pkthdr.csum_flags = CSUM_TCP_IPV6; - th->th_sum = in6_cksum_pseudo(ip6, - sizeof(struct tcphdr) + optlen, IPPROTO_TCP, 0); + m->m_pkthdr.csum_flags = CSUM_IP6_TCP; ip6->ip6_hlim = in6_selecthlim(inp, NULL); error = ip6_output(m, inp->in6p_outputopts, NULL, (tw->tw_so_options & SO_DONTROUTE), NULL, NULL, inp); @@ -591,9 +589,7 @@ tcp_twrespond(struct tcptw *tw, int flag #endif #ifdef INET { - m->m_pkthdr.csum_flags = CSUM_TCP; - th->th_sum = in_pseudo(ip->ip_src.s_addr, ip->ip_dst.s_addr, - htons(sizeof(struct tcphdr) + optlen + IPPROTO_TCP)); + m->m_pkthdr.csum_flags = CSUM_IP_TCP; ip->ip_len = htons(m->m_pkthdr.len); if (V_path_mtu_discovery) ip->ip_off |= htons(IP_DF); Modified: user/andre/tcp_workqueue/sys/netinet/udp_usrreq.c ============================================================================== --- user/andre/tcp_workqueue/sys/netinet/udp_usrreq.c Mon Nov 19 17:33:45 2012 (r243290) +++ user/andre/tcp_workqueue/sys/netinet/udp_usrreq.c Mon Nov 19 18:04:17 2012 (r243291) @@ -410,19 +410,15 @@ udp_input(struct mbuf *m, int off) /* * Checksum extended UDP header and data. + * NB: UDP doesn't require the checksum to be present. */ if (uh->uh_sum) { - u_short uh_sum; + u_short uh_sum = 0; - if (m->m_pkthdr.csum_flags & CSUM_DATA_VALID) { - if (m->m_pkthdr.csum_flags & CSUM_PSEUDO_HDR) - uh_sum = m->m_pkthdr.csum_data; - else - uh_sum = in_pseudo(ip->ip_src.s_addr, - ip->ip_dst.s_addr, htonl((u_short)len + - m->m_pkthdr.csum_data + IPPROTO_UDP)); - uh_sum ^= 0xffff; - } else { + if ((m->m_pkthdr.csum_flags & (CSUM_L4_CALC|CSUM_L4_VALID)) == + CSUM_L4_CALC) { + uh_sum = 0x1; /* Failed checksum check. */ + } else if (!(m->m_pkthdr.csum_flags & CSUM_L4_VALID)) { char b[9]; bcopy(((struct ipovly *)ip)->ih_x1, b, 9); @@ -1226,7 +1222,7 @@ udp_output(struct inpcb *inp, struct mbu faddr.s_addr = INADDR_BROADCAST; ui->ui_sum = in_pseudo(ui->ui_src.s_addr, faddr.s_addr, htons((u_short)len + sizeof(struct udphdr) + IPPROTO_UDP)); - m->m_pkthdr.csum_flags = CSUM_UDP; + m->m_pkthdr.csum_flags = CSUM_IP_UDP; m->m_pkthdr.csum_l4hlen = sizeof(struct udphdr); } else ui->ui_sum = 0; @@ -1387,8 +1383,8 @@ udp4_espdecap(struct inpcb *inp, struct * We cannot yet update the cksums so clear any * h/w cksum flags as they are no longer valid. */ - if (m->m_pkthdr.csum_flags & CSUM_DATA_VALID) - m->m_pkthdr.csum_flags &= ~(CSUM_DATA_VALID|CSUM_PSEUDO_HDR); + if (m->m_pkthdr.csum_flags & CSUM_L4_CALC) + m->m_pkthdr.csum_flags &= ~(CSUM_L4_CALC|CSUM_L4_VALID); (void) ipsec4_common_input(m, iphlen, ip->ip_p); return (NULL); /* NB: consumed, bypass processing. */ Modified: user/andre/tcp_workqueue/sys/netinet6/ip6_forward.c ============================================================================== --- user/andre/tcp_workqueue/sys/netinet6/ip6_forward.c Mon Nov 19 17:33:45 2012 (r243290) +++ user/andre/tcp_workqueue/sys/netinet6/ip6_forward.c Mon Nov 19 18:04:17 2012 (r243291) @@ -577,14 +577,16 @@ skip_routing: m->m_flags |= M_FASTFWD_OURS; if (m->m_pkthdr.rcvif == NULL) m->m_pkthdr.rcvif = V_loif; - if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA_IPV6) { + if (m->m_pkthdr.csum_flags & + (CSUM_IP6_UDP|CSUM_IP6_TCP)) { m->m_pkthdr.csum_flags |= - CSUM_DATA_VALID_IPV6 | CSUM_PSEUDO_HDR; + CSUM_L4_CALC | CSUM_L4_VALID; m->m_pkthdr.csum_data = 0xffff; } #ifdef SCTP - if (m->m_pkthdr.csum_flags & CSUM_SCTP_IPV6) - m->m_pkthdr.csum_flags |= CSUM_SCTP_VALID; + if (m->m_pkthdr.csum_flags & CSUM_IP6_SCTP) + m->m_pkthdr.csum_flags |= + CSUM_L4_CALC | CSUM_L4_VALID; #endif error = netisr_queue(NETISR_IPV6, m); goto out; @@ -596,14 +598,13 @@ skip_routing: if (m->m_flags & M_FASTFWD_OURS) { if (m->m_pkthdr.rcvif == NULL) m->m_pkthdr.rcvif = V_loif; - if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA_IPV6) { - m->m_pkthdr.csum_flags |= - CSUM_DATA_VALID_IPV6 | CSUM_PSEUDO_HDR; + if (m->m_pkthdr.csum_flags & (CSUM_IP6_UDP|CSUM_IP6_TCP)) { + m->m_pkthdr.csum_flags |= CSUM_L4_CALC | CSUM_L4_VALID; m->m_pkthdr.csum_data = 0xffff; } #ifdef SCTP - if (m->m_pkthdr.csum_flags & CSUM_SCTP_IPV6) - m->m_pkthdr.csum_flags |= CSUM_SCTP_VALID; + if (m->m_pkthdr.csum_flags & CSUM_IP6_SCTP) + m->m_pkthdr.csum_flags |= CSUM_L4_CALC | CSUM_L4_VALID; #endif error = netisr_queue(NETISR_IPV6, m); goto out; Modified: user/andre/tcp_workqueue/sys/netinet6/ip6_ipsec.c ============================================================================== --- user/andre/tcp_workqueue/sys/netinet6/ip6_ipsec.c Mon Nov 19 17:33:45 2012 (r243290) +++ user/andre/tcp_workqueue/sys/netinet6/ip6_ipsec.c Mon Nov 19 18:04:17 2012 (r243291) @@ -288,11 +288,11 @@ ip6_ipsec_output(struct mbuf **m, struct * For IPv6 we do delayed checksums in ip6_output.c. */ #ifdef INET - if ((*m)->m_pkthdr.csum_flags & CSUM_DELAY_DATA) { + if ((*m)->m_pkthdr.csum_flags & (CSUM_IP_UDP|CSUM_IP_TCP)) { ipseclog((LOG_DEBUG, "%s: we do not support IPv4 over IPv6", __func__)); in_delayed_cksum(*m); - (*m)->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA; + (*m)->m_pkthdr.csum_flags &= ~(CSUM_IP_UDP|CSUM_IP_TCP); } #endif Modified: user/andre/tcp_workqueue/sys/netinet6/ip6_output.c ============================================================================== --- user/andre/tcp_workqueue/sys/netinet6/ip6_output.c Mon Nov 19 17:33:45 2012 (r243290) +++ user/andre/tcp_workqueue/sys/netinet6/ip6_output.c Mon Nov 19 18:04:17 2012 (r243291) @@ -307,15 +307,15 @@ ip6_output(struct mbuf *m0, struct ip6_p /* * Do delayed checksums now, as we may send before returning. */ - if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA_IPV6) { + if (m->m_pkthdr.csum_flags & (CSUM_IP6_UDP|CSUM_IP6_TCP)) { plen = m->m_pkthdr.len - sizeof(*ip6); in6_delayed_cksum(m, plen, sizeof(struct ip6_hdr)); - m->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA_IPV6; + m->m_pkthdr.csum_flags &= ~(CSUM_IP6_UDP|CSUM_IP6_TCP); } #ifdef SCTP - if (m->m_pkthdr.csum_flags & CSUM_SCTP_IPV6) { + if (m->m_pkthdr.csum_flags & CSUM_IP6_SCTP) { sctp_delayed_cksum(m, sizeof(struct ip6_hdr)); - m->m_pkthdr.csum_flags &= ~CSUM_SCTP_IPV6; + m->m_pkthdr.csum_flags &= ~CSUM_IP6_SCTP; } #endif case 0: /* No IPSec */ @@ -898,14 +898,16 @@ again: m->m_flags |= M_FASTFWD_OURS; if (m->m_pkthdr.rcvif == NULL) m->m_pkthdr.rcvif = V_loif; - if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA_IPV6) { + if (m->m_pkthdr.csum_flags & + (CSUM_IP6_UDP|CSUM_IP6_TCP)) { m->m_pkthdr.csum_flags |= - CSUM_DATA_VALID_IPV6 | CSUM_PSEUDO_HDR; + CSUM_L4_CALC | CSUM_L4_VALID; m->m_pkthdr.csum_data = 0xffff; } #ifdef SCTP if (m->m_pkthdr.csum_flags & CSUM_SCTP_IPV6) - m->m_pkthdr.csum_flags |= CSUM_SCTP_VALID; + m->m_pkthdr.csum_flags |= + CSUM_L4_CALC | CSUM_L4_VALID; #endif error = netisr_queue(NETISR_IPV6, m); goto done; @@ -917,14 +919,14 @@ again: if (m->m_flags & M_FASTFWD_OURS) { if (m->m_pkthdr.rcvif == NULL) m->m_pkthdr.rcvif = V_loif; - if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA_IPV6) { + if (m->m_pkthdr.csum_flags & (CSUM_IP6_UDP|CSUM_IP6_TCP)) { m->m_pkthdr.csum_flags |= - CSUM_DATA_VALID_IPV6 | CSUM_PSEUDO_HDR; + CSUM_L4_CALC | CSUM_L4_VALID; m->m_pkthdr.csum_data = 0xffff; } #ifdef SCTP if (m->m_pkthdr.csum_flags & CSUM_SCTP_IPV6) - m->m_pkthdr.csum_flags |= CSUM_SCTP_VALID; + m->m_pkthdr.csum_flags |= CSUM_L4_CALC | CSUM_L4_VALID; #endif error = netisr_queue(NETISR_IPV6, m); goto done; @@ -972,13 +974,13 @@ passout: * XXX-BZ Need a framework to know when the NIC can handle it, even * with ext. hdrs. */ - if (sw_csum & CSUM_DELAY_DATA_IPV6) { - sw_csum &= ~CSUM_DELAY_DATA_IPV6; + if (sw_csum & (CSUM_IP6_UDP|CSUM_IP6_TCP)) { + sw_csum &= ~(CSUM_IP6_UDP|CSUM_IP6_TCP); in6_delayed_cksum(m, plen, sizeof(struct ip6_hdr)); } #ifdef SCTP - if (sw_csum & CSUM_SCTP_IPV6) { - sw_csum &= ~CSUM_SCTP_IPV6; + if (sw_csum & CSUM_IP6_SCTP) { + sw_csum &= ~CSUM_IP6_SCTP; sctp_delayed_cksum(m, sizeof(struct ip6_hdr)); } #endif @@ -1091,14 +1093,14 @@ passout: * fragmented packets, then do it here. * XXX-BZ handle the hw offloading case. Need flags. */ - if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA_IPV6) { + if (m->m_pkthdr.csum_flags & (CSUM_IP6_UDP|CSUM_IP6_TCP)) { in6_delayed_cksum(m, plen, hlen); - m->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA_IPV6; + m->m_pkthdr.csum_flags &= ~(CSUM_IP6_UDP|CSUM_IP6_TCP); } #ifdef SCTP - if (m->m_pkthdr.csum_flags & CSUM_SCTP_IPV6) { + if (m->m_pkthdr.csum_flags & CSUM_IP6_SCTP) { sctp_delayed_cksum(m, hlen); - m->m_pkthdr.csum_flags &= ~CSUM_SCTP_IPV6; + m->m_pkthdr.csum_flags &= ~CSUM_IP6_SCTP; } #endif mnext = &m->m_nextpkt; Modified: user/andre/tcp_workqueue/sys/netinet6/sctp6_usrreq.c ============================================================================== --- user/andre/tcp_workqueue/sys/netinet6/sctp6_usrreq.c Mon Nov 19 17:33:45 2012 (r243290) +++ user/andre/tcp_workqueue/sys/netinet6/sctp6_usrreq.c Mon Nov 19 18:04:17 2012 (r243291) @@ -169,9 +169,15 @@ sctp6_input(struct mbuf **i_pak, int *of #if defined(SCTP_WITH_NO_CSUM) SCTP_STAT_INCR(sctps_recvnocrc); #else - if (m->m_pkthdr.csum_flags & CSUM_SCTP_VALID) { + if ((m->m_pkthdr.csum_flags & (CSUM_L4_CALC|CSUM_L4_VALID)) == + (CSUM_L4_CALC | CSUM_L4_VALID)) { SCTP_STAT_INCR(sctps_recvhwcrc); compute_crc = 0; + } else if ((m->m_pkthdr.csum_flags & (CSUM_L4_CALC|CSUM_L4_VALID)) == + CSUM_L4_CALC) { + SCTP_STAT_INCR(sctps_badsum); + SCTP_STAT_INCR_COUNTER32(sctps_checksumerrors); + goto out; } else { SCTP_STAT_INCR(sctps_recvswcrc); compute_crc = 1; Modified: user/andre/tcp_workqueue/sys/netinet6/udp6_usrreq.c ============================================================================== --- user/andre/tcp_workqueue/sys/netinet6/udp6_usrreq.c Mon Nov 19 17:33:45 2012 (r243290) +++ user/andre/tcp_workqueue/sys/netinet6/udp6_usrreq.c Mon Nov 19 18:04:17 2012 (r243291) @@ -183,7 +183,7 @@ udp6_input(struct mbuf **mp, int *offp, int plen, ulen; struct sockaddr_in6 fromsa; struct m_tag *fwd_tag; - uint16_t uh_sum; + uint16_t uh_sum = 0; ifp = m->m_pkthdr.rcvif; ip6 = mtod(m, struct ip6_hdr *); @@ -228,14 +228,10 @@ udp6_input(struct mbuf **mp, int *offp, goto badunlocked; } - if (m->m_pkthdr.csum_flags & CSUM_DATA_VALID_IPV6) { - if (m->m_pkthdr.csum_flags & CSUM_PSEUDO_HDR) - uh_sum = m->m_pkthdr.csum_data; - else - uh_sum = in6_cksum_pseudo(ip6, ulen, - IPPROTO_UDP, m->m_pkthdr.csum_data); - uh_sum ^= 0xffff; - } else + if ((m->m_pkthdr.csum_flags & (CSUM_L4_CALC|CSUM_L4_VALID)) == + CSUM_L4_CALC) { + uh_sum = 1; + } else if (!(m->m_pkthdr.csum_flags & CSUM_L4_VALID)) uh_sum = in6_cksum(m, IPPROTO_UDP, off, ulen); if (uh_sum != 0) { @@ -780,8 +776,8 @@ udp6_output(struct inpcb *inp, struct mb ip6->ip6_dst = *faddr; udp6->uh_sum = in6_cksum_pseudo(ip6, plen, IPPROTO_UDP, 0); - m->m_pkthdr.csum_flags = CSUM_UDP_IPV6; - m->m_pkthdr.csum_data = offsetof(struct udphdr, uh_sum); + m->m_pkthdr.csum_flags = CSUM_IP6_UDP; + m->m_pkthdr.csum_l4hlen = sizeof(struct udphdr); flags = 0; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Mon Nov 19 18:09:02 2012 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 3942F57C; Mon, 19 Nov 2012 18:09:02 +0000 (UTC) (envelope-from andre@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 16B0F8FC12; Mon, 19 Nov 2012 18:09:02 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qAJI92kW015654; Mon, 19 Nov 2012 18:09:02 GMT (envelope-from andre@svn.freebsd.org) Received: (from andre@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qAJI90Vb015606; Mon, 19 Nov 2012 18:09:00 GMT (envelope-from andre@svn.freebsd.org) Message-Id: <201211191809.qAJI90Vb015606@svn.freebsd.org> From: Andre Oppermann Date: Mon, 19 Nov 2012 18:09:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r243292 - in user/andre/tcp_workqueue/sys/dev: age ale bce bge bxe cas cxgb cxgbe cxgbe/tom e1000 fxp gem hme if_ndis ixgb ixgbe jme lge mge msk mxge nfe nge nxge oce qlxgb re rt sf sfx... X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Nov 2012 18:09:02 -0000 Author: andre Date: Mon Nov 19 18:09:00 2012 New Revision: 243292 URL: http://svnweb.freebsd.org/changeset/base/243292 Log: Convert the NIC drivers to the new checksum offloading semantics on the inbound path in a first step. This is a mostly mechanical conversion and the new semantics are not introduced. In short for inbound there are two levels the offloading NIC can set: CSUM_L3_CALC for an IP layer 3 checksum calculated by the NIC; CSUM_L3_VALID set when the calculated checksum matches the one in the packet; CSUM_L4_CALC for an UDP/TCP/SCTP layer 4 checksum calculated by the NIC; CSUM_L4_VALID set when the calculated checksum matche the one in the packet. From this follows that a packet failed checksum verification when only *_CALC is set but not *_VALID. The NIC is expected to deliver a failed packet up the stack anyways for capture by BPF and to record protocol specific checksum mismatch statistics. Please note that many NIC's do not or only partially follow these semantics. Some drop all packets with a failed checksum and most do not report a L4 failure but pass it on without any checksum flags set. They will have to be cleaned up later. Modified: user/andre/tcp_workqueue/sys/dev/age/if_age.c user/andre/tcp_workqueue/sys/dev/ale/if_ale.c user/andre/tcp_workqueue/sys/dev/bce/if_bce.c user/andre/tcp_workqueue/sys/dev/bge/if_bge.c user/andre/tcp_workqueue/sys/dev/bxe/if_bxe.c user/andre/tcp_workqueue/sys/dev/cas/if_cas.c user/andre/tcp_workqueue/sys/dev/cxgb/cxgb_sge.c user/andre/tcp_workqueue/sys/dev/cxgbe/t4_sge.c user/andre/tcp_workqueue/sys/dev/cxgbe/tom/t4_listen.c user/andre/tcp_workqueue/sys/dev/e1000/if_em.c user/andre/tcp_workqueue/sys/dev/e1000/if_igb.c user/andre/tcp_workqueue/sys/dev/e1000/if_lem.c user/andre/tcp_workqueue/sys/dev/fxp/if_fxp.c user/andre/tcp_workqueue/sys/dev/gem/if_gem.c user/andre/tcp_workqueue/sys/dev/hme/if_hme.c user/andre/tcp_workqueue/sys/dev/if_ndis/if_ndis.c user/andre/tcp_workqueue/sys/dev/ixgb/if_ixgb.c user/andre/tcp_workqueue/sys/dev/ixgbe/ixgbe.c user/andre/tcp_workqueue/sys/dev/ixgbe/ixv.c user/andre/tcp_workqueue/sys/dev/jme/if_jme.c user/andre/tcp_workqueue/sys/dev/lge/if_lge.c user/andre/tcp_workqueue/sys/dev/mge/if_mge.c user/andre/tcp_workqueue/sys/dev/msk/if_msk.c user/andre/tcp_workqueue/sys/dev/mxge/if_mxge.c user/andre/tcp_workqueue/sys/dev/mxge/mxge_lro.c user/andre/tcp_workqueue/sys/dev/nfe/if_nfe.c user/andre/tcp_workqueue/sys/dev/nge/if_nge.c user/andre/tcp_workqueue/sys/dev/nxge/if_nxge.c user/andre/tcp_workqueue/sys/dev/oce/oce_if.c user/andre/tcp_workqueue/sys/dev/qlxgb/qla_isr.c user/andre/tcp_workqueue/sys/dev/re/if_re.c user/andre/tcp_workqueue/sys/dev/rt/if_rt.c user/andre/tcp_workqueue/sys/dev/sf/if_sf.c user/andre/tcp_workqueue/sys/dev/sfxge/sfxge_rx.c user/andre/tcp_workqueue/sys/dev/sfxge/sfxge_tx.c user/andre/tcp_workqueue/sys/dev/sge/if_sge.c user/andre/tcp_workqueue/sys/dev/sk/if_sk.c user/andre/tcp_workqueue/sys/dev/stge/if_stge.c user/andre/tcp_workqueue/sys/dev/ti/if_ti.c user/andre/tcp_workqueue/sys/dev/tsec/if_tsec.c user/andre/tcp_workqueue/sys/dev/txp/if_txp.c user/andre/tcp_workqueue/sys/dev/usb/net/if_axe.c user/andre/tcp_workqueue/sys/dev/vge/if_vge.c user/andre/tcp_workqueue/sys/dev/virtio/network/if_vtnet.c user/andre/tcp_workqueue/sys/dev/vr/if_vr.c user/andre/tcp_workqueue/sys/dev/vxge/vxge.c user/andre/tcp_workqueue/sys/dev/xen/netback/netback.c user/andre/tcp_workqueue/sys/dev/xen/netback/netback_unit_tests.c user/andre/tcp_workqueue/sys/dev/xen/netfront/netfront.c user/andre/tcp_workqueue/sys/dev/xl/if_xl.c Modified: user/andre/tcp_workqueue/sys/dev/age/if_age.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/age/if_age.c Mon Nov 19 18:04:17 2012 (r243291) +++ user/andre/tcp_workqueue/sys/dev/age/if_age.c Mon Nov 19 18:09:00 2012 (r243292) @@ -2383,13 +2383,13 @@ age_rxeof(struct age_softc *sc, struct r */ if ((ifp->if_capenable & IFCAP_RXCSUM) != 0 && (status & AGE_RRD_IPV4) != 0) { - m->m_pkthdr.csum_flags |= CSUM_IP_CHECKED; + m->m_pkthdr.csum_flags |= CSUM_L3_CALC; if ((status & AGE_RRD_IPCSUM_NOK) == 0) - m->m_pkthdr.csum_flags |= CSUM_IP_VALID; + m->m_pkthdr.csum_flags |= CSUM_L3_VALID; if ((status & (AGE_RRD_TCP | AGE_RRD_UDP)) && (status & AGE_RRD_TCP_UDPCSUM_NOK) == 0) { m->m_pkthdr.csum_flags |= - CSUM_DATA_VALID | CSUM_PSEUDO_HDR; + CSUM_L4_CALC | CSUM_L4_VALID; m->m_pkthdr.csum_data = 0xffff; } /* Modified: user/andre/tcp_workqueue/sys/dev/ale/if_ale.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/ale/if_ale.c Mon Nov 19 18:04:17 2012 (r243291) +++ user/andre/tcp_workqueue/sys/dev/ale/if_ale.c Mon Nov 19 18:09:00 2012 (r243292) @@ -2429,16 +2429,16 @@ ale_rxcsum(struct ale_softc *sc, struct char *p; ifp = sc->ale_ifp; - m->m_pkthdr.csum_flags |= CSUM_IP_CHECKED; + m->m_pkthdr.csum_flags |= CSUM_L3_CALC; if ((status & ALE_RD_IPCSUM_NOK) == 0) - m->m_pkthdr.csum_flags |= CSUM_IP_VALID; + m->m_pkthdr.csum_flags |= CSUM_L3_VALID; if ((sc->ale_flags & ALE_FLAG_RXCSUM_BUG) == 0) { if (((status & ALE_RD_IPV4_FRAG) == 0) && ((status & (ALE_RD_TCP | ALE_RD_UDP)) != 0) && ((status & ALE_RD_TCP_UDPCSUM_NOK) == 0)) { m->m_pkthdr.csum_flags |= - CSUM_DATA_VALID | CSUM_PSEUDO_HDR; + CSUM_L4_CALC | CSUM_L4_VALID; m->m_pkthdr.csum_data = 0xffff; } } else { @@ -2454,8 +2454,8 @@ ale_rxcsum(struct ale_softc *sc, struct ip = (struct ip *)p; if (ip->ip_off != 0 && (status & ALE_RD_IPV4_DF) == 0) return; - m->m_pkthdr.csum_flags |= CSUM_DATA_VALID | - CSUM_PSEUDO_HDR; + m->m_pkthdr.csum_flags |= CSUM_L4_CALC | + CSUM_L4_VALID; m->m_pkthdr.csum_data = 0xffff; } } Modified: user/andre/tcp_workqueue/sys/dev/bce/if_bce.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/bce/if_bce.c Mon Nov 19 18:04:17 2012 (r243291) +++ user/andre/tcp_workqueue/sys/dev/bce/if_bce.c Mon Nov 19 18:09:00 2012 (r243292) @@ -6825,12 +6825,12 @@ bce_rx_intr(struct bce_softc *sc) /* Check for an IP datagram. */ if (!(status & L2_FHDR_STATUS_SPLIT) && (status & L2_FHDR_STATUS_IP_DATAGRAM)) { - m0->m_pkthdr.csum_flags |= CSUM_IP_CHECKED; + m0->m_pkthdr.csum_flags |= CSUM_L3_CALC; DBRUN(sc->csum_offload_ip++); /* Check if the IP checksum is valid. */ if ((l2fhdr->l2_fhdr_ip_xsum ^ 0xffff) == 0) m0->m_pkthdr.csum_flags |= - CSUM_IP_VALID; + CSUM_L3_VALID; } /* Check for a valid TCP/UDP frame. */ @@ -6844,8 +6844,7 @@ bce_rx_intr(struct bce_softc *sc) m0->m_pkthdr.csum_data = l2fhdr->l2_fhdr_tcp_udp_xsum; m0->m_pkthdr.csum_flags |= - (CSUM_DATA_VALID - | CSUM_PSEUDO_HDR); + (CSUM_L4_CALC | CSUM_L4_VALID); } } } Modified: user/andre/tcp_workqueue/sys/dev/bge/if_bge.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/bge/if_bge.c Mon Nov 19 18:04:17 2012 (r243291) +++ user/andre/tcp_workqueue/sys/dev/bge/if_bge.c Mon Nov 19 18:09:00 2012 (r243292) @@ -120,7 +120,7 @@ __FBSDID("$FreeBSD$"); #include -#define BGE_CSUM_FEATURES (CSUM_IP | CSUM_TCP) +#define BGE_CSUM_FEATURES (CSUM_IP | CSUM_IP_TCP) #define ETHER_MIN_NOPAD (ETHER_MIN_LEN - ETHER_CRC_LEN) /* i.e., 60 */ MODULE_DEPEND(bge, pci, 1, 1, 1); @@ -3647,7 +3647,7 @@ bge_attach(device_t dev) /* Initialize checksum features to use. */ sc->bge_csum_features = BGE_CSUM_FEATURES; if (sc->bge_forced_udpcsum != 0) - sc->bge_csum_features |= CSUM_UDP; + sc->bge_csum_features |= CSUM_IP_UDP; /* Set up ifnet structure */ ifp = sc->bge_ifp = if_alloc(IFT_ETHER); @@ -3669,7 +3669,7 @@ bge_attach(device_t dev) ifp->if_capabilities = IFCAP_HWCSUM | IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_MTU; if ((sc->bge_flags & (BGE_FLAG_TSO | BGE_FLAG_TSO3)) != 0) { - ifp->if_hwassist |= CSUM_TSO; + ifp->if_hwassist |= CSUM_IP_TSO; ifp->if_capabilities |= IFCAP_TSO4 | IFCAP_VLAN_HWTSO; } #ifdef IFCAP_VLAN_HWCSUM @@ -4222,30 +4222,30 @@ bge_rx_packet(struct bge_softc *sc, stru BGE_IS_5717_PLUS(sc)) { if ((rx->bge_flags & BGE_RXBDFLAG_IPV6) == 0) { if (rx->bge_flags & BGE_RXBDFLAG_IP_CSUM) { - m->m_pkthdr.csum_flags |= CSUM_IP_CHECKED; + m->m_pkthdr.csum_flags |= CSUM_L3_CALC; if ((rx->bge_error_flag & BGE_RXERRFLAG_IP_CSUM_NOK) == 0) - m->m_pkthdr.csum_flags |= CSUM_IP_VALID; + m->m_pkthdr.csum_flags |= CSUM_L3_VALID; } if (rx->bge_flags & BGE_RXBDFLAG_TCP_UDP_CSUM) { m->m_pkthdr.csum_data = rx->bge_tcp_udp_csum; - m->m_pkthdr.csum_flags |= CSUM_DATA_VALID | - CSUM_PSEUDO_HDR; + m->m_pkthdr.csum_flags |= CSUM_L4_CALC | + CSUM_L4_VALID; } } } else if (ifp->if_capenable & IFCAP_RXCSUM) { if (rx->bge_flags & BGE_RXBDFLAG_IP_CSUM) { - m->m_pkthdr.csum_flags |= CSUM_IP_CHECKED; + m->m_pkthdr.csum_flags |= CSUM_L3_CALC; if ((rx->bge_ip_csum ^ 0xFFFF) == 0) - m->m_pkthdr.csum_flags |= CSUM_IP_VALID; + m->m_pkthdr.csum_flags |= CSUM_L3_VALID; } if (rx->bge_flags & BGE_RXBDFLAG_TCP_UDP_CSUM && m->m_pkthdr.len >= ETHER_MIN_NOPAD) { m->m_pkthdr.csum_data = rx->bge_tcp_udp_csum; - m->m_pkthdr.csum_flags |= CSUM_DATA_VALID | - CSUM_PSEUDO_HDR; + m->m_pkthdr.csum_flags |= CSUM_L4_CALC | + CSUM_L4_VALID; } } Modified: user/andre/tcp_workqueue/sys/dev/bxe/if_bxe.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/bxe/if_bxe.c Mon Nov 19 18:04:17 2012 (r243291) +++ user/andre/tcp_workqueue/sys/dev/bxe/if_bxe.c Mon Nov 19 18:09:00 2012 (r243292) @@ -14753,8 +14753,9 @@ bxe_tpa_stop(struct bxe_softc *sc, struc m->m_pkthdr.len = m->m_len = len; /* Mark the checksums valid (taken care of by firmware). */ - m->m_pkthdr.csum_flags |= CSUM_IP_CHECKED | CSUM_IP_VALID | - CSUM_DATA_VALID | CSUM_PSEUDO_HDR; + /* XXXAO: Is this really unconditionally true? */ + m->m_pkthdr.csum_flags |= CSUM_L3_CALC | CSUM_L3_VALID | + CSUM_L4_CALC | CSUM_L4_VALID; m->m_pkthdr.csum_data = 0xffff; /* Aggregate all of the SGEs into a single mbuf. */ @@ -15002,7 +15003,7 @@ bxe_rxeof(struct bxe_fastpath *fp) !(cqe->fast_path_cqe.status_flags & ETH_FAST_PATH_RX_CQE_IP_XSUM_NO_VALIDATION_FLG)) { m->m_pkthdr.csum_flags |= - CSUM_IP_CHECKED; + CSUM_L3_CALC; if (__predict_false(cqe_fp_flags & ETH_FAST_PATH_RX_CQE_IP_BAD_XSUM_FLG)) { DBPRINT(sc, BXE_WARN_SEND, @@ -15010,7 +15011,7 @@ bxe_rxeof(struct bxe_fastpath *fp) __FUNCTION__); } else m->m_pkthdr.csum_flags |= - CSUM_IP_VALID; + CSUM_L3_VALID; } /* Check for a valid TCP/UDP frame. */ @@ -15026,8 +15027,8 @@ bxe_rxeof(struct bxe_fastpath *fp) } else { m->m_pkthdr.csum_data = 0xFFFF; m->m_pkthdr.csum_flags |= - (CSUM_DATA_VALID | - CSUM_PSEUDO_HDR); + (CSUM_L4_CALC | + CSUM_L4_VALID); } } } Modified: user/andre/tcp_workqueue/sys/dev/cas/if_cas.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/cas/if_cas.c Mon Nov 19 18:04:17 2012 (r243291) +++ user/andre/tcp_workqueue/sys/dev/cas/if_cas.c Mon Nov 19 18:09:00 2012 (r243292) @@ -592,7 +592,7 @@ cas_rxcksum(struct mbuf *m, uint16_t cks cksum = temp32 & 65535; } } - m->m_pkthdr.csum_flags |= CSUM_DATA_VALID; + m->m_pkthdr.csum_flags |= CSUM_L4_CALC | CSUM_L4_VALID; m->m_pkthdr.csum_data = cksum; } Modified: user/andre/tcp_workqueue/sys/dev/cxgb/cxgb_sge.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/cxgb/cxgb_sge.c Mon Nov 19 18:04:17 2012 (r243291) +++ user/andre/tcp_workqueue/sys/dev/cxgb/cxgb_sge.c Mon Nov 19 18:09:00 2012 (r243292) @@ -2655,13 +2655,13 @@ t3_rx_eth(struct adapter *adap, struct m if (ifp->if_capenable & IFCAP_RXCSUM && eh_type == htons(ETHERTYPE_IP)) { - m->m_pkthdr.csum_flags = (CSUM_IP_CHECKED | - CSUM_IP_VALID | CSUM_DATA_VALID | CSUM_PSEUDO_HDR); + /* XXXAO: Is this really unconditionally true? */ + m->m_pkthdr.csum_flags = (CSUM_L3_CALC | CSUM_L3_VALID | + CSUM_L4_CALC | CSUM_L4_VALID); m->m_pkthdr.csum_data = 0xffff; } else if (ifp->if_capenable & IFCAP_RXCSUM_IPV6 && eh_type == htons(ETHERTYPE_IPV6)) { - m->m_pkthdr.csum_flags = (CSUM_DATA_VALID_IPV6 | - CSUM_PSEUDO_HDR); + m->m_pkthdr.csum_flags = (CSUM_L4_CALC | CSUM_L4_VALID); m->m_pkthdr.csum_data = 0xffff; } } Modified: user/andre/tcp_workqueue/sys/dev/cxgbe/t4_sge.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/cxgbe/t4_sge.c Mon Nov 19 18:04:17 2012 (r243291) +++ user/andre/tcp_workqueue/sys/dev/cxgbe/t4_sge.c Mon Nov 19 18:09:00 2012 (r243292) @@ -1128,13 +1128,13 @@ t4_eth_rx(struct sge_iq *iq, const struc if (cpl->csum_calc && !cpl->err_vec) { if (ifp->if_capenable & IFCAP_RXCSUM && cpl->l2info & htobe32(F_RXF_IP)) { - m0->m_pkthdr.csum_flags = (CSUM_IP_CHECKED | - CSUM_IP_VALID | CSUM_DATA_VALID | CSUM_PSEUDO_HDR); + /* XXXAO: Is the really unconditionally true? */ + m0->m_pkthdr.csum_flags = (CSUM_L3_CALC | + CSUM_L3_VALID | CSUM_L4_CALC | CSUM_L4_VALID); rxq->rxcsum++; } else if (ifp->if_capenable & IFCAP_RXCSUM_IPV6 && cpl->l2info & htobe32(F_RXF_IP6)) { - m0->m_pkthdr.csum_flags = (CSUM_DATA_VALID_IPV6 | - CSUM_PSEUDO_HDR); + m0->m_pkthdr.csum_flags = (CSUM_L4_CALC|CSUM_L4_VALID); rxq->rxcsum++; } Modified: user/andre/tcp_workqueue/sys/dev/cxgbe/tom/t4_listen.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/cxgbe/tom/t4_listen.c Mon Nov 19 18:04:17 2012 (r243291) +++ user/andre/tcp_workqueue/sys/dev/cxgbe/tom/t4_listen.c Mon Nov 19 18:09:00 2012 (r243292) @@ -1221,8 +1221,8 @@ reject: if (__predict_true(m != NULL)) { m_adj(m, sizeof(*cpl)); - m->m_pkthdr.csum_flags |= (CSUM_IP_CHECKED | CSUM_IP_VALID | - CSUM_DATA_VALID | CSUM_PSEUDO_HDR); + m->m_pkthdr.csum_flags |= (CSUM_L3_CALC | CSUM_L3_VALID | + CSUM_L4_CALC | CSUM_L4_VALID); m->m_pkthdr.csum_data = 0xffff; ifp->if_input(ifp, m); } Modified: user/andre/tcp_workqueue/sys/dev/e1000/if_em.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/e1000/if_em.c Mon Nov 19 18:04:17 2012 (r243291) +++ user/andre/tcp_workqueue/sys/dev/e1000/if_em.c Mon Nov 19 18:09:00 2012 (r243292) @@ -4520,8 +4520,8 @@ em_receive_checksum(struct e1000_rx_desc /* Did it pass? */ if (!(rx_desc->errors & E1000_RXD_ERR_IPE)) { /* IP Checksum Good */ - mp->m_pkthdr.csum_flags = CSUM_IP_CHECKED; - mp->m_pkthdr.csum_flags |= CSUM_IP_VALID; + mp->m_pkthdr.csum_flags |= CSUM_L3_CALC; + mp->m_pkthdr.csum_flags |= CSUM_L3_VALID; } else { mp->m_pkthdr.csum_flags = 0; @@ -4531,8 +4531,8 @@ em_receive_checksum(struct e1000_rx_desc if (rx_desc->status & E1000_RXD_STAT_TCPCS) { /* Did it pass? */ if (!(rx_desc->errors & E1000_RXD_ERR_TCPE)) { - mp->m_pkthdr.csum_flags |= - (CSUM_DATA_VALID | CSUM_PSEUDO_HDR); + mp->m_pkthdr.csum_flags |= CSUM_L4_CALC; + mp->m_pkthdr.csum_flags |= CSUM_L4_VALID; mp->m_pkthdr.csum_data = htons(0xffff); } } Modified: user/andre/tcp_workqueue/sys/dev/e1000/if_igb.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/e1000/if_igb.c Mon Nov 19 18:04:17 2012 (r243291) +++ user/andre/tcp_workqueue/sys/dev/e1000/if_igb.c Mon Nov 19 18:09:00 2012 (r243292) @@ -4672,8 +4672,8 @@ igb_rx_input(struct rx_ring *rxr, struct (ptype & E1000_RXDADV_PKTTYPE_ETQF) == 0 && (ptype & (E1000_RXDADV_PKTTYPE_IPV4 | E1000_RXDADV_PKTTYPE_TCP)) == (E1000_RXDADV_PKTTYPE_IPV4 | E1000_RXDADV_PKTTYPE_TCP) && - (m->m_pkthdr.csum_flags & (CSUM_DATA_VALID | CSUM_PSEUDO_HDR)) == - (CSUM_DATA_VALID | CSUM_PSEUDO_HDR)) { + (m->m_pkthdr.csum_flags & (CSUM_L4_CALC | CSUM_L4_VALID)) == + (CSUM_L4_CALC | CSUM_L4_VALID)) { /* * Send to the stack if: ** - LRO not enabled, or @@ -4938,23 +4938,18 @@ igb_rx_checksum(u32 staterr, struct mbuf /* Did it pass? */ if (!(errors & E1000_RXD_ERR_IPE)) { /* IP Checksum Good */ - mp->m_pkthdr.csum_flags = CSUM_IP_CHECKED; - mp->m_pkthdr.csum_flags |= CSUM_IP_VALID; + mp->m_pkthdr.csum_flags |= CSUM_L3_CALC; + mp->m_pkthdr.csum_flags |= CSUM_L3_VALID; } else mp->m_pkthdr.csum_flags = 0; } if (status & (E1000_RXD_STAT_TCPCS | E1000_RXD_STAT_UDPCS)) { - u32 type = (CSUM_DATA_VALID | CSUM_PSEUDO_HDR); -#if __FreeBSD_version >= 800000 - if (sctp) /* reassign */ - type = CSUM_SCTP_VALID; -#endif /* Did it pass? */ if (!(errors & E1000_RXD_ERR_TCPE)) { - mp->m_pkthdr.csum_flags |= type; - if (sctp == 0) - mp->m_pkthdr.csum_data = htons(0xffff); + mp->m_pkthdr.csum_flags |= CSUM_L4_CALC; + mp->m_pkthdr.csum_flags |= CSUM_L4_VALID; + mp->m_pkthdr.csum_data = htons(0xffff); } } return; Modified: user/andre/tcp_workqueue/sys/dev/e1000/if_lem.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/e1000/if_lem.c Mon Nov 19 18:04:17 2012 (r243291) +++ user/andre/tcp_workqueue/sys/dev/e1000/if_lem.c Mon Nov 19 18:09:00 2012 (r243292) @@ -3677,8 +3677,8 @@ lem_receive_checksum(struct adapter *ada /* Did it pass? */ if (!(rx_desc->errors & E1000_RXD_ERR_IPE)) { /* IP Checksum Good */ - mp->m_pkthdr.csum_flags = CSUM_IP_CHECKED; - mp->m_pkthdr.csum_flags |= CSUM_IP_VALID; + mp->m_pkthdr.csum_flags |= CSUM_L3_CALC; + mp->m_pkthdr.csum_flags |= CSUM_L3_VALID; } else { mp->m_pkthdr.csum_flags = 0; @@ -3688,8 +3688,8 @@ lem_receive_checksum(struct adapter *ada if (rx_desc->status & E1000_RXD_STAT_TCPCS) { /* Did it pass? */ if (!(rx_desc->errors & E1000_RXD_ERR_TCPE)) { - mp->m_pkthdr.csum_flags |= - (CSUM_DATA_VALID | CSUM_PSEUDO_HDR); + mp->m_pkthdr.csum_flags |= CSUM_L4_CALC; + mp->m_pkthdr.csum_flags |= CSUM_L4_VALID; mp->m_pkthdr.csum_data = htons(0xffff); } } Modified: user/andre/tcp_workqueue/sys/dev/fxp/if_fxp.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/fxp/if_fxp.c Mon Nov 19 18:04:17 2012 (r243291) +++ user/andre/tcp_workqueue/sys/dev/fxp/if_fxp.c Mon Nov 19 18:09:00 2012 (r243292) @@ -1690,13 +1690,13 @@ fxp_rxcsum(struct fxp_softc *sc, struct if (!(sc->flags & FXP_FLAG_82559_RXCSUM)) { if (status & FXP_RFA_STATUS_PARSE) { if (status & FXP_RFDX_CS_IP_CSUM_BIT_VALID) - m->m_pkthdr.csum_flags |= CSUM_IP_CHECKED; + m->m_pkthdr.csum_flags |= CSUM_L3_CALC; if (status & FXP_RFDX_CS_IP_CSUM_VALID) - m->m_pkthdr.csum_flags |= CSUM_IP_VALID; + m->m_pkthdr.csum_flags |= CSUM_L3_VALID; if ((status & FXP_RFDX_CS_TCPUDP_CSUM_BIT_VALID) && (status & FXP_RFDX_CS_TCPUDP_CSUM_VALID)) { - m->m_pkthdr.csum_flags |= CSUM_DATA_VALID | - CSUM_PSEUDO_HDR; + m->m_pkthdr.csum_flags |= CSUM_L4_CALC; + m->m_pkthdr.csum_flags |= CSUM_L4_VALID; m->m_pkthdr.csum_data = 0xffff; } } Modified: user/andre/tcp_workqueue/sys/dev/gem/if_gem.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/gem/if_gem.c Mon Nov 19 18:04:17 2012 (r243291) +++ user/andre/tcp_workqueue/sys/dev/gem/if_gem.c Mon Nov 19 18:09:00 2012 (r243292) @@ -539,7 +539,7 @@ gem_rxcksum(struct mbuf *m, uint64_t fla cksum = temp32 & 65535; } } - m->m_pkthdr.csum_flags |= CSUM_DATA_VALID; + m->m_pkthdr.csum_flags |= CSUM_L4_CALC | CSUM_L4_VALID; m->m_pkthdr.csum_data = cksum; } Modified: user/andre/tcp_workqueue/sys/dev/hme/if_hme.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/hme/if_hme.c Mon Nov 19 18:04:17 2012 (r243291) +++ user/andre/tcp_workqueue/sys/dev/hme/if_hme.c Mon Nov 19 18:09:00 2012 (r243292) @@ -1264,7 +1264,7 @@ hme_rxcksum(struct mbuf *m, u_int32_t fl cksum = temp32 & 65535; } } - m->m_pkthdr.csum_flags |= CSUM_DATA_VALID; + m->m_pkthdr.csum_flags |= CSUM_L4_CALC | CSUM_L4_VALID; m->m_pkthdr.csum_data = cksum; } Modified: user/andre/tcp_workqueue/sys/dev/if_ndis/if_ndis.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/if_ndis/if_ndis.c Mon Nov 19 18:04:17 2012 (r243291) +++ user/andre/tcp_workqueue/sys/dev/if_ndis/if_ndis.c Mon Nov 19 18:09:00 2012 (r243292) @@ -1459,12 +1459,12 @@ ndis_rxeof(adapter, packets, pktcnt) if (csum->u.ntc_rxflags & NDIS_RXCSUM_IP_PASSED) m0->m_pkthdr.csum_flags |= - CSUM_IP_CHECKED|CSUM_IP_VALID; + CSUM_L3_CALC|CSUM_L3_VALID; if (csum->u.ntc_rxflags & (NDIS_RXCSUM_TCP_PASSED | NDIS_RXCSUM_UDP_PASSED)) { m0->m_pkthdr.csum_flags |= - CSUM_DATA_VALID|CSUM_PSEUDO_HDR; + CSUM_L4_CALC|CSUM_L4_VALID; m0->m_pkthdr.csum_data = 0xFFFF; } } Modified: user/andre/tcp_workqueue/sys/dev/ixgb/if_ixgb.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/ixgb/if_ixgb.c Mon Nov 19 18:04:17 2012 (r243291) +++ user/andre/tcp_workqueue/sys/dev/ixgb/if_ixgb.c Mon Nov 19 18:09:00 2012 (r243292) @@ -2268,8 +2268,8 @@ ixgb_receive_checksum(struct adapter * a /* Did it pass? */ if (!(rx_desc->errors & IXGB_RX_DESC_ERRORS_IPE)) { /* IP Checksum Good */ - mp->m_pkthdr.csum_flags = CSUM_IP_CHECKED; - mp->m_pkthdr.csum_flags |= CSUM_IP_VALID; + mp->m_pkthdr.csum_flags |= CSUM_L3_CALC; + mp->m_pkthdr.csum_flags |= CSUM_L3_VALID; } else { mp->m_pkthdr.csum_flags = 0; @@ -2278,8 +2278,8 @@ ixgb_receive_checksum(struct adapter * a if (rx_desc->status & IXGB_RX_DESC_STATUS_TCPCS) { /* Did it pass? */ if (!(rx_desc->errors & IXGB_RX_DESC_ERRORS_TCPE)) { - mp->m_pkthdr.csum_flags |= - (CSUM_DATA_VALID | CSUM_PSEUDO_HDR); + mp->m_pkthdr.csum_flags |= CSUM_L4_CALC; + mp->m_pkthdr.csum_flags |= CSUM_L4_VALID; mp->m_pkthdr.csum_data = htons(0xffff); } } Modified: user/andre/tcp_workqueue/sys/dev/ixgbe/ixgbe.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/ixgbe/ixgbe.c Mon Nov 19 18:04:17 2012 (r243291) +++ user/andre/tcp_workqueue/sys/dev/ixgbe/ixgbe.c Mon Nov 19 18:09:00 2012 (r243292) @@ -4331,8 +4331,8 @@ ixgbe_rx_input(struct rx_ring *rxr, stru (IXGBE_RXDADV_PKTTYPE_IPV4 | IXGBE_RXDADV_PKTTYPE_TCP) || (ptype & (IXGBE_RXDADV_PKTTYPE_IPV6 | IXGBE_RXDADV_PKTTYPE_TCP)) == (IXGBE_RXDADV_PKTTYPE_IPV6 | IXGBE_RXDADV_PKTTYPE_TCP)) && - (m->m_pkthdr.csum_flags & (CSUM_DATA_VALID | CSUM_PSEUDO_HDR)) == - (CSUM_DATA_VALID | CSUM_PSEUDO_HDR)) { + (m->m_pkthdr.csum_flags & (CSUM_L4_CALC | CSUM_L4_VALID)) == + (CSUM_L4_CALC | CSUM_L4_VALID)) { /* * Send to the stack if: ** - LRO not enabled, or @@ -4715,22 +4715,17 @@ ixgbe_rx_checksum(u32 staterr, struct mb if (status & IXGBE_RXD_STAT_IPCS) { if (!(errors & IXGBE_RXD_ERR_IPE)) { /* IP Checksum Good */ - mp->m_pkthdr.csum_flags = CSUM_IP_CHECKED; - mp->m_pkthdr.csum_flags |= CSUM_IP_VALID; + mp->m_pkthdr.csum_flags |= CSUM_L3_CALC; + mp->m_pkthdr.csum_flags |= CSUM_L3_VALID; } else mp->m_pkthdr.csum_flags = 0; } if (status & IXGBE_RXD_STAT_L4CS) { - u32 type = (CSUM_DATA_VALID | CSUM_PSEUDO_HDR); -#if __FreeBSD_version >= 800000 - if (sctp) - type = CSUM_SCTP_VALID; -#endif if (!(errors & IXGBE_RXD_ERR_TCPE)) { - mp->m_pkthdr.csum_flags |= type; - if (!sctp) - mp->m_pkthdr.csum_data = htons(0xffff); + mp->m_pkthdr.csum_flags |= CSUM_L4_CALC; + mp->m_pkthdr.csum_flags |= CSUM_L4_VALID; + mp->m_pkthdr.csum_data = htons(0xffff); } } return; Modified: user/andre/tcp_workqueue/sys/dev/ixgbe/ixv.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/ixgbe/ixv.c Mon Nov 19 18:04:17 2012 (r243291) +++ user/andre/tcp_workqueue/sys/dev/ixgbe/ixv.c Mon Nov 19 18:09:00 2012 (r243292) @@ -3238,8 +3238,8 @@ ixv_rx_input(struct rx_ring *rxr, struct (ptype & IXGBE_RXDADV_PKTTYPE_ETQF) == 0 && (ptype & (IXGBE_RXDADV_PKTTYPE_IPV4 | IXGBE_RXDADV_PKTTYPE_TCP)) == (IXGBE_RXDADV_PKTTYPE_IPV4 | IXGBE_RXDADV_PKTTYPE_TCP) && - (m->m_pkthdr.csum_flags & (CSUM_DATA_VALID | CSUM_PSEUDO_HDR)) == - (CSUM_DATA_VALID | CSUM_PSEUDO_HDR)) { + (m->m_pkthdr.csum_flags & (CSUM_L4_CALC | CSUM_L4_VALID)) == + (CSUM_L4_CALC | CSUM_L4_VALID)) { /* * Send to the stack if: ** - LRO not enabled, or @@ -3547,22 +3547,17 @@ ixv_rx_checksum(u32 staterr, struct mbuf if (status & IXGBE_RXD_STAT_IPCS) { if (!(errors & IXGBE_RXD_ERR_IPE)) { /* IP Checksum Good */ - mp->m_pkthdr.csum_flags = CSUM_IP_CHECKED; - mp->m_pkthdr.csum_flags |= CSUM_IP_VALID; + mp->m_pkthdr.csum_flags |= CSUM_L3_CALC; + mp->m_pkthdr.csum_flags |= CSUM_L3_VALID; } else mp->m_pkthdr.csum_flags = 0; } if (status & IXGBE_RXD_STAT_L4CS) { - u32 type = (CSUM_DATA_VALID | CSUM_PSEUDO_HDR); -#if __FreeBSD_version >= 800000 - if (sctp) - type = CSUM_SCTP_VALID; -#endif if (!(errors & IXGBE_RXD_ERR_TCPE)) { - mp->m_pkthdr.csum_flags |= type; - if (!sctp) - mp->m_pkthdr.csum_data = htons(0xffff); + mp->m_pkthdr.csum_flags |= CSUM_L4_CALC; + mp->m_pkthdr.csum_flags |= CSUM_L4_VALID; + mp->m_pkthdr.csum_data = htons(0xffff); } } return; Modified: user/andre/tcp_workqueue/sys/dev/jme/if_jme.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/jme/if_jme.c Mon Nov 19 18:04:17 2012 (r243291) +++ user/andre/tcp_workqueue/sys/dev/jme/if_jme.c Mon Nov 19 18:09:00 2012 (r243292) @@ -2605,16 +2605,16 @@ jme_rxeof(struct jme_softc *sc) /* Set checksum information. */ if ((ifp->if_capenable & IFCAP_RXCSUM) != 0 && (flags & JME_RD_IPV4) != 0) { - m->m_pkthdr.csum_flags |= CSUM_IP_CHECKED; + m->m_pkthdr.csum_flags |= CSUM_L3_CALC; if ((flags & JME_RD_IPCSUM) != 0) - m->m_pkthdr.csum_flags |= CSUM_IP_VALID; + m->m_pkthdr.csum_flags |= CSUM_L3_VALID; if (((flags & JME_RD_MORE_FRAG) == 0) && ((flags & (JME_RD_TCP | JME_RD_TCPCSUM)) == (JME_RD_TCP | JME_RD_TCPCSUM) || (flags & (JME_RD_UDP | JME_RD_UDPCSUM)) == (JME_RD_UDP | JME_RD_UDPCSUM))) { m->m_pkthdr.csum_flags |= - CSUM_DATA_VALID | CSUM_PSEUDO_HDR; + CSUM_L4_CALC | CSUM_L4_VALID; m->m_pkthdr.csum_data = 0xffff; } } Modified: user/andre/tcp_workqueue/sys/dev/lge/if_lge.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/lge/if_lge.c Mon Nov 19 18:04:17 2012 (r243291) +++ user/andre/tcp_workqueue/sys/dev/lge/if_lge.c Mon Nov 19 18:09:00 2012 (r243292) @@ -944,15 +944,15 @@ lge_rxeof(sc, cnt) /* Do IP checksum checking. */ if (rxsts & LGE_RXSTS_ISIP) - m->m_pkthdr.csum_flags |= CSUM_IP_CHECKED; + m->m_pkthdr.csum_flags |= CSUM_L3_CALC; if (!(rxsts & LGE_RXSTS_IPCSUMERR)) - m->m_pkthdr.csum_flags |= CSUM_IP_VALID; + m->m_pkthdr.csum_flags |= CSUM_L3_VALID; if ((rxsts & LGE_RXSTS_ISTCP && !(rxsts & LGE_RXSTS_TCPCSUMERR)) || (rxsts & LGE_RXSTS_ISUDP && !(rxsts & LGE_RXSTS_UDPCSUMERR))) { m->m_pkthdr.csum_flags |= - CSUM_DATA_VALID|CSUM_PSEUDO_HDR; + CSUM_L4_CALC|CSUM_L4_VALID; m->m_pkthdr.csum_data = 0xffff; } Modified: user/andre/tcp_workqueue/sys/dev/mge/if_mge.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/mge/if_mge.c Mon Nov 19 18:04:17 2012 (r243291) +++ user/andre/tcp_workqueue/sys/dev/mge/if_mge.c Mon Nov 19 18:09:00 2012 (r243292) @@ -1661,12 +1661,12 @@ mge_offload_process_frame(struct ifnet * if (ifp->if_capenable & IFCAP_RXCSUM) { if ((status & MGE_RX_L3_IS_IP) && (status & MGE_RX_IP_OK)) - csum_flags |= CSUM_IP_CHECKED | CSUM_IP_VALID; + csum_flags |= CSUM_L3_CALC | CSUM_L3_VALID; if ((bufsize & MGE_RX_IP_FRAGMENT) == 0 && (MGE_RX_L4_IS_TCP(status) || MGE_RX_L4_IS_UDP(status)) && (status & MGE_RX_L4_CSUM_OK)) { - csum_flags |= CSUM_DATA_VALID | CSUM_PSEUDO_HDR; + csum_flags |= CSUM_L4_CALC | CSUM_L4_VALID; frame->m_pkthdr.csum_data = 0xFFFF; } Modified: user/andre/tcp_workqueue/sys/dev/msk/if_msk.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/msk/if_msk.c Mon Nov 19 18:04:17 2012 (r243291) +++ user/andre/tcp_workqueue/sys/dev/msk/if_msk.c Mon Nov 19 18:09:00 2012 (r243292) @@ -3098,13 +3098,13 @@ msk_rxcsum(struct msk_if_softc *sc_if, u if ((sc_if->msk_flags & MSK_FLAG_DESCV2) != 0) { if ((control & (CSS_IPV4 | CSS_IPFRAG)) == CSS_IPV4) { - m->m_pkthdr.csum_flags |= CSUM_IP_CHECKED; + m->m_pkthdr.csum_flags |= CSUM_L3_CALC; if ((control & CSS_IPV4_CSUM_OK) != 0) - m->m_pkthdr.csum_flags |= CSUM_IP_VALID; + m->m_pkthdr.csum_flags |= CSUM_L3_VALID; if ((control & (CSS_TCP | CSS_UDP)) != 0 && (control & (CSS_TCPUDP_CSUM_OK)) != 0) { - m->m_pkthdr.csum_flags |= CSUM_DATA_VALID | - CSUM_PSEUDO_HDR; + m->m_pkthdr.csum_flags |= CSUM_L4_CALC | + CSUM_L4_VALID; m->m_pkthdr.csum_data = 0xffff; } } @@ -3173,7 +3173,7 @@ msk_rxcsum(struct msk_if_softc *sc_if, u csum = temp32 & 65535; } } - m->m_pkthdr.csum_flags |= CSUM_DATA_VALID; + m->m_pkthdr.csum_flags |= CSUM_L4_CALC | CSUM_L4_VALID; m->m_pkthdr.csum_data = csum; } Modified: user/andre/tcp_workqueue/sys/dev/mxge/if_mxge.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/mxge/if_mxge.c Mon Nov 19 18:04:17 2012 (r243291) +++ user/andre/tcp_workqueue/sys/dev/mxge/if_mxge.c Mon Nov 19 18:09:00 2012 (r243292) @@ -2045,13 +2045,12 @@ mxge_encap(struct mxge_slice_state *ss, ifp = sc->ifp; tx = &ss->tx; - ip_off = sizeof (struct ether_header); + ip_off = m->m_pkthdr.csum_l2hlen; #ifdef MXGE_NEW_VLAN_API if (m->m_flags & M_VLANTAG) { m = mxge_vlan_tag_insert(m); if (__predict_false(m == NULL)) goto drop; - ip_off += ETHER_VLAN_ENCAP_LEN; } #endif /* (try to) map the frame for DMA */ @@ -2096,18 +2095,12 @@ mxge_encap(struct mxge_slice_state *ss, flags = MXGEFW_FLAGS_NO_TSO; /* checksum offloading? */ - if (m->m_pkthdr.csum_flags & (CSUM_DELAY_DATA)) { + if (m->m_pkthdr.csum_flags & (CSUM_IP_UDP|CSUM_IP_TCP)) { /* ensure ip header is in first mbuf, copy it to a scratch buffer if not */ - if (__predict_false(m->m_len < ip_off + sizeof (*ip))) { - m_copydata(m, 0, ip_off + sizeof (*ip), - ss->scratch); - ip = (struct ip *)(ss->scratch + ip_off); - } else { - ip = (struct ip *)(mtod(m, char *) + ip_off); - } + ip = mtodo(m, ip_off, struct ip *); cksum_offset = ip_off + (ip->ip_hl << 2); - pseudo_hdr_offset = cksum_offset + m->m_pkthdr.csum_data; + pseudo_hdr_offset = cksum_offset + m->m_pkthdr.csum_l3hlen; pseudo_hdr_offset = htobe16(pseudo_hdr_offset); req->cksum_offset = cksum_offset; flags |= MXGEFW_FLAGS_CKSUM; @@ -2595,7 +2588,7 @@ mxge_rx_done_big(struct mxge_slice_state we could not do LRO on. Tell the stack that the checksum is good */ m->m_pkthdr.csum_data = 0xffff; - m->m_pkthdr.csum_flags = CSUM_PSEUDO_HDR | CSUM_DATA_VALID; + m->m_pkthdr.csum_flags = CSUM_L4_CALC | CSUM_L4_VALID; } /* flowid only valid if RSS hashing is enabled */ if (sc->num_slices > 1) { @@ -2660,7 +2653,7 @@ mxge_rx_done_small(struct mxge_slice_sta we could not do LRO on. Tell the stack that the checksum is good */ m->m_pkthdr.csum_data = 0xffff; - m->m_pkthdr.csum_flags = CSUM_PSEUDO_HDR | CSUM_DATA_VALID; + m->m_pkthdr.csum_flags = CSUM_L4_CALC | CSUM_L4_VALID; } /* flowid only valid if RSS hashing is enabled */ if (sc->num_slices > 1) { Modified: user/andre/tcp_workqueue/sys/dev/mxge/mxge_lro.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/mxge/mxge_lro.c Mon Nov 19 18:04:17 2012 (r243291) +++ user/andre/tcp_workqueue/sys/dev/mxge/mxge_lro.c Mon Nov 19 18:09:00 2012 (r243292) @@ -97,8 +97,8 @@ mxge_lro_flush(struct mxge_slice_state * mxge_csum_generic((uint16_t*)ip, sizeof (*ip)); - lro->m_head->m_pkthdr.csum_flags = CSUM_IP_CHECKED | - CSUM_IP_VALID | CSUM_DATA_VALID | CSUM_PSEUDO_HDR; + lro->m_head->m_pkthdr.csum_flags = CSUM_L3_CALC | + CSUM_L3_VALID | CSUM_L4_CALC | CSUM_L4_VALID; lro->m_head->m_pkthdr.csum_data = 0xffff; lro->m_head->m_pkthdr.len = lro->len; Modified: user/andre/tcp_workqueue/sys/dev/nfe/if_nfe.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/nfe/if_nfe.c Mon Nov 19 18:04:17 2012 (r243291) +++ user/andre/tcp_workqueue/sys/dev/nfe/if_nfe.c Mon Nov 19 18:09:00 2012 (r243292) @@ -2165,12 +2165,12 @@ nfe_rxeof(struct nfe_softc *sc, int coun if ((ifp->if_capenable & IFCAP_RXCSUM) != 0) { if ((flags & NFE_RX_IP_CSUMOK) != 0) { - m->m_pkthdr.csum_flags |= CSUM_IP_CHECKED; - m->m_pkthdr.csum_flags |= CSUM_IP_VALID; + m->m_pkthdr.csum_flags |= CSUM_L3_CALC; + m->m_pkthdr.csum_flags |= CSUM_L3_VALID; if ((flags & NFE_RX_TCP_CSUMOK) != 0 || (flags & NFE_RX_UDP_CSUMOK) != 0) { m->m_pkthdr.csum_flags |= - CSUM_DATA_VALID | CSUM_PSEUDO_HDR; + CSUM_L4_CALC | CSUM_L4_VALID; m->m_pkthdr.csum_data = 0xffff; } } @@ -2281,12 +2281,12 @@ nfe_jrxeof(struct nfe_softc *sc, int cou if ((ifp->if_capenable & IFCAP_RXCSUM) != 0) { if ((flags & NFE_RX_IP_CSUMOK) != 0) { - m->m_pkthdr.csum_flags |= CSUM_IP_CHECKED; - m->m_pkthdr.csum_flags |= CSUM_IP_VALID; + m->m_pkthdr.csum_flags |= CSUM_L3_CALC; + m->m_pkthdr.csum_flags |= CSUM_L3_VALID; if ((flags & NFE_RX_TCP_CSUMOK) != 0 || (flags & NFE_RX_UDP_CSUMOK) != 0) { m->m_pkthdr.csum_flags |= - CSUM_DATA_VALID | CSUM_PSEUDO_HDR; + CSUM_L4_CALC | CSUM_L4_VALID; m->m_pkthdr.csum_data = 0xffff; } } Modified: user/andre/tcp_workqueue/sys/dev/nge/if_nge.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/nge/if_nge.c Mon Nov 19 18:04:17 2012 (r243291) +++ user/andre/tcp_workqueue/sys/dev/nge/if_nge.c Mon Nov 19 18:09:00 2012 (r243292) @@ -1569,15 +1569,15 @@ nge_rxeof(struct nge_softc *sc) if ((ifp->if_capenable & IFCAP_RXCSUM) != 0) { /* Do IP checksum checking. */ if ((extsts & NGE_RXEXTSTS_IPPKT) != 0) - m->m_pkthdr.csum_flags |= CSUM_IP_CHECKED; + m->m_pkthdr.csum_flags |= CSUM_L3_CALC; if ((extsts & NGE_RXEXTSTS_IPCSUMERR) == 0) - m->m_pkthdr.csum_flags |= CSUM_IP_VALID; + m->m_pkthdr.csum_flags |= CSUM_L3_VALID; if ((extsts & NGE_RXEXTSTS_TCPPKT && !(extsts & NGE_RXEXTSTS_TCPCSUMERR)) || (extsts & NGE_RXEXTSTS_UDPPKT && !(extsts & NGE_RXEXTSTS_UDPCSUMERR))) { m->m_pkthdr.csum_flags |= - CSUM_DATA_VALID | CSUM_PSEUDO_HDR; + CSUM_L4_CALC | CSUM_L4_VALID; m->m_pkthdr.csum_data = 0xffff; } } Modified: user/andre/tcp_workqueue/sys/dev/nxge/if_nxge.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/nxge/if_nxge.c Mon Nov 19 18:04:17 2012 (r243291) +++ user/andre/tcp_workqueue/sys/dev/nxge/if_nxge.c Mon Nov 19 18:09:00 2012 (r243292) @@ -2434,9 +2434,10 @@ _exit: void xge_set_mbuf_cflags(mbuf_t pkt) { - pkt->m_pkthdr.csum_flags = CSUM_IP_CHECKED; - pkt->m_pkthdr.csum_flags |= CSUM_IP_VALID; - pkt->m_pkthdr.csum_flags |= (CSUM_DATA_VALID | CSUM_PSEUDO_HDR); + /* XXXAO: Is this really unconditionally true? */ + pkt->m_pkthdr.csum_flags = CSUM_L3_CALC; + pkt->m_pkthdr.csum_flags |= CSUM_L3_VALID; + pkt->m_pkthdr.csum_flags |= (CSUM_L4_CALC | CSUM_L4_VALID); pkt->m_pkthdr.csum_data = htons(0xffff); } Modified: user/andre/tcp_workqueue/sys/dev/oce/oce_if.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/oce/oce_if.c Mon Nov 19 18:04:17 2012 (r243291) +++ user/andre/tcp_workqueue/sys/dev/oce/oce_if.c Mon Nov 19 18:09:00 2012 (r243292) @@ -1255,13 +1255,13 @@ oce_rx(struct oce_rq *rq, uint32_t rqe_i if (IF_CSUM_ENABLED(sc)) { if (cqe->u0.s.l4_cksum_pass) { pd->mbuf->m_pkthdr.csum_flags |= - (CSUM_DATA_VALID | CSUM_PSEUDO_HDR); + (CSUM_L4_CALC | CSUM_L4_VALID); pd->mbuf->m_pkthdr.csum_data = 0xffff; } if (cqe->u0.s.ip_cksum_pass) { if (!cqe->u0.s.ip_ver) { /* IPV4 */ pd->mbuf->m_pkthdr.csum_flags |= - (CSUM_IP_CHECKED|CSUM_IP_VALID); + (CSUM_L3_CALC|CSUM_L3_VALID); } } } Modified: user/andre/tcp_workqueue/sys/dev/qlxgb/qla_isr.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/qlxgb/qla_isr.c Mon Nov 19 18:04:17 2012 (r243291) +++ user/andre/tcp_workqueue/sys/dev/qlxgb/qla_isr.c Mon Nov 19 18:09:00 2012 (r243292) @@ -132,7 +132,7 @@ qla_rx_intr(qla_host_t *ha, uint64_t dat } if (status == Q8_STAT_DESC_STATUS_CHKSUM_OK) { - mp->m_pkthdr.csum_flags = (CSUM_IP_CHECKED | CSUM_IP_VALID); + mp->m_pkthdr.csum_flags = (CSUM_L3_CALC | CSUM_L3_VALID); } else { mp->m_pkthdr.csum_flags = 0; } Modified: user/andre/tcp_workqueue/sys/dev/re/if_re.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/re/if_re.c Mon Nov 19 18:04:17 2012 (r243291) +++ user/andre/tcp_workqueue/sys/dev/re/if_re.c Mon Nov 19 18:09:00 2012 (r243292) @@ -2281,10 +2281,10 @@ re_rxeof(struct rl_softc *sc, int *rx_np /* Check IP header checksum */ if (rxstat & RL_RDESC_STAT_PROTOID) m->m_pkthdr.csum_flags |= - CSUM_IP_CHECKED; + CSUM_L3_CALC; if (!(rxstat & RL_RDESC_STAT_IPSUMBAD)) m->m_pkthdr.csum_flags |= - CSUM_IP_VALID; + CSUM_L3_VALID; /* Check TCP/UDP checksum */ if ((RL_TCPPKT(rxstat) && @@ -2292,7 +2292,7 @@ re_rxeof(struct rl_softc *sc, int *rx_np (RL_UDPPKT(rxstat) && !(rxstat & RL_RDESC_STAT_UDPSUMBAD))) { m->m_pkthdr.csum_flags |= - CSUM_DATA_VALID|CSUM_PSEUDO_HDR; + CSUM_L4_CALC|CSUM_L4_VALID; m->m_pkthdr.csum_data = 0xffff; } } else { @@ -2302,17 +2302,17 @@ re_rxeof(struct rl_softc *sc, int *rx_np if ((rxstat & RL_RDESC_STAT_PROTOID) && (rxvlan & RL_RDESC_IPV4)) m->m_pkthdr.csum_flags |= - CSUM_IP_CHECKED; + CSUM_L3_CALC; if (!(rxstat & RL_RDESC_STAT_IPSUMBAD) && (rxvlan & RL_RDESC_IPV4)) m->m_pkthdr.csum_flags |= - CSUM_IP_VALID; + CSUM_L3_VALID; 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 |= - CSUM_DATA_VALID|CSUM_PSEUDO_HDR; + CSUM_L4_CALC|CSUM_L4_CALC; m->m_pkthdr.csum_data = 0xffff; } } Modified: user/andre/tcp_workqueue/sys/dev/rt/if_rt.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/rt/if_rt.c Mon Nov 19 18:04:17 2012 (r243291) +++ user/andre/tcp_workqueue/sys/dev/rt/if_rt.c Mon Nov 19 18:09:00 2012 (r243292) @@ -1712,8 +1712,8 @@ rt_rx_eof(struct rt_softc *sc, int limit } } if ((desc_flags & RXDSXR_SRC_IP_CSUM_FAIL) != 0) { - m->m_pkthdr.csum_flags |= CSUM_IP_CHECKED; - m->m_pkthdr.csum_flags |= CSUM_IP_VALID; + m->m_pkthdr.csum_flags |= CSUM_L3_CALC; + m->m_pkthdr.csum_flags |= CSUM_L3_VALID; m->m_pkthdr.csum_data = 0xffff; } m->m_flags &= ~M_HASFCS; Modified: user/andre/tcp_workqueue/sys/dev/sf/if_sf.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/sf/if_sf.c Mon Nov 19 18:04:17 2012 (r243291) +++ user/andre/tcp_workqueue/sys/dev/sf/if_sf.c Mon Nov 19 18:09:00 2012 (r243292) @@ -1619,8 +1619,8 @@ sf_rxeof(struct sf_softc *sc) SF_RXSTAT2_UDP)) != 0) { if ((status2 & SF_RXSTAT2_CSUM_OK)) { m->m_pkthdr.csum_flags = - CSUM_DATA_VALID | - CSUM_PSEUDO_HDR; + CSUM_L4_CALC | + CSUM_L4_VALID; m->m_pkthdr.csum_data = 0xffff; } } @@ -1631,7 +1631,7 @@ sf_rxeof(struct sf_softc *sc) SF_RXSTAT2_UDP)) != 0) { if ((status2 & SF_RXSTAT2_PCSUM_OK)) { m->m_pkthdr.csum_flags = - CSUM_DATA_VALID; + CSUM_L4_CALC; /*XXXAO*/ m->m_pkthdr.csum_data = (status & SF_RX_CMPDESC_CSUM2); Modified: user/andre/tcp_workqueue/sys/dev/sfxge/sfxge_rx.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/sfxge/sfxge_rx.c Mon Nov 19 18:04:17 2012 (r243291) +++ user/andre/tcp_workqueue/sys/dev/sfxge/sfxge_rx.c Mon Nov 19 18:09:00 2012 (r243292) @@ -295,9 +295,9 @@ sfxge_rx_deliver(struct sfxge_softc *sc, /* Convert checksum flags */ csum_flags = (rx_desc->flags & EFX_CKSUM_IPV4) ? - (CSUM_IP_CHECKED | CSUM_IP_VALID) : 0; + (CSUM_L3_CALC | CSUM_L3_VALID) : 0; if (rx_desc->flags & EFX_CKSUM_TCPUDP) - csum_flags |= CSUM_DATA_VALID | CSUM_PSEUDO_HDR; + csum_flags |= CSUM_L4_CALC | CSUM_L4_VALID; #ifdef SFXGE_HAVE_MQ /* The hash covers a 4-tuple for TCP only */ @@ -336,13 +336,13 @@ sfxge_lro_deliver(struct sfxge_lro_state iph->ip_sum = 0; iph->ip_sum = in_cksum_hdr(iph); c_th = (struct tcphdr *)(iph + 1); - csum_flags = (CSUM_DATA_VALID | CSUM_PSEUDO_HDR | - CSUM_IP_CHECKED | CSUM_IP_VALID); + csum_flags = (CSUM_L4_CALC | CSUM_L4_VALID | + CSUM_L3_CALC | CSUM_L4_VALID); } else { struct ip6_hdr *iph = c->nh; iph->ip6_plen = htons(iph->ip6_plen); c_th = (struct tcphdr *)(iph + 1); - csum_flags = CSUM_DATA_VALID | CSUM_PSEUDO_HDR; + csum_flags = CSUM_L4_CALC | CSUM_L4_VALID; } c_th->th_win = c->th_last->th_win; Modified: user/andre/tcp_workqueue/sys/dev/sfxge/sfxge_tx.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/sfxge/sfxge_tx.c Mon Nov 19 18:04:17 2012 (r243291) +++ user/andre/tcp_workqueue/sys/dev/sfxge/sfxge_tx.c Mon Nov 19 18:09:00 2012 (r243292) @@ -592,7 +592,7 @@ sfxge_if_transmit(struct ifnet *ifp, str } /* Pick the desired transmit queue. */ - if (m->m_pkthdr.csum_flags & (CSUM_DELAY_DATA | CSUM_TSO)) { + if (m->m_pkthdr.csum_flags & (CSUM_IP_UDP|CSUM_IP_TCP|CSUM_TSO)) { int index = 0; if (m->m_flags & M_FLOWID) { @@ -601,7 +601,7 @@ sfxge_if_transmit(struct ifnet *ifp, str index = sc->rx_indir_table[hash % SFXGE_RX_SCALE_MAX]; } txq = sc->txq[SFXGE_TXQ_IP_TCP_UDP_CKSUM + index]; - } else if (m->m_pkthdr.csum_flags & CSUM_DELAY_IP) { + } else if (m->m_pkthdr.csum_flags & CSUM_IP) { txq = sc->txq[SFXGE_TXQ_IP_CKSUM]; } else { txq = sc->txq[SFXGE_TXQ_NON_CKSUM]; Modified: user/andre/tcp_workqueue/sys/dev/sge/if_sge.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/sge/if_sge.c Mon Nov 19 18:04:17 2012 (r243291) +++ user/andre/tcp_workqueue/sys/dev/sge/if_sge.c Mon Nov 19 18:09:00 2012 (r243292) @@ -1183,13 +1183,13 @@ sge_rxeof(struct sge_softc *sc) if ((rxinfo & RDC_IP_CSUM) != 0 && (rxinfo & RDC_IP_CSUM_OK) != 0) m->m_pkthdr.csum_flags |= - CSUM_IP_CHECKED | CSUM_IP_VALID; + CSUM_L3_CALC | CSUM_L3_VALID; if (((rxinfo & RDC_TCP_CSUM) != 0 && (rxinfo & RDC_TCP_CSUM_OK) != 0) || ((rxinfo & RDC_UDP_CSUM) != 0 && (rxinfo & RDC_UDP_CSUM_OK) != 0)) { m->m_pkthdr.csum_flags |= - CSUM_DATA_VALID | CSUM_PSEUDO_HDR; + CSUM_L4_CALC | CSUM_L4_VALID; m->m_pkthdr.csum_data = 0xffff; } } Modified: user/andre/tcp_workqueue/sys/dev/sk/if_sk.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/sk/if_sk.c Mon Nov 19 18:04:17 2012 (r243291) +++ user/andre/tcp_workqueue/sys/dev/sk/if_sk.c Mon Nov 19 18:09:00 2012 (r243292) @@ -2705,9 +2705,9 @@ sk_rxcksum(ifp, m, csum) */ return; } - m->m_pkthdr.csum_flags = CSUM_IP_CHECKED; + m->m_pkthdr.csum_flags = CSUM_L3_CALC; if (ipcsum == 0xffff) - m->m_pkthdr.csum_flags |= CSUM_IP_VALID; + m->m_pkthdr.csum_flags |= CSUM_L3_VALID; } static __inline int Modified: user/andre/tcp_workqueue/sys/dev/stge/if_stge.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/stge/if_stge.c Mon Nov 19 18:04:17 2012 (r243291) +++ user/andre/tcp_workqueue/sys/dev/stge/if_stge.c Mon Nov 19 18:09:00 2012 (r243292) @@ -1726,17 +1726,17 @@ stge_rxeof(struct stge_softc *sc) if ((ifp->if_capenable & IFCAP_RXCSUM) != 0) { if ((status & RFD_IPDetected) != 0) { m->m_pkthdr.csum_flags |= - CSUM_IP_CHECKED; + CSUM_L3_CALC; if ((status & RFD_IPError) == 0) m->m_pkthdr.csum_flags |= - CSUM_IP_VALID; + CSUM_L3_VALID; } if (((status & RFD_TCPDetected) != 0 && (status & RFD_TCPError) == 0) || ((status & RFD_UDPDetected) != 0 && (status & RFD_UDPError) == 0)) { m->m_pkthdr.csum_flags |= - (CSUM_DATA_VALID | CSUM_PSEUDO_HDR); + (CSUM_L4_CALC | CSUM_L4_VALID); m->m_pkthdr.csum_data = 0xffff; } } Modified: user/andre/tcp_workqueue/sys/dev/ti/if_ti.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/ti/if_ti.c Mon Nov 19 18:04:17 2012 (r243291) +++ user/andre/tcp_workqueue/sys/dev/ti/if_ti.c Mon Nov 19 18:09:00 2012 (r243292) @@ -2866,14 +2866,16 @@ ti_rxeof(struct ti_softc *sc) if (ifp->if_capenable & IFCAP_RXCSUM) { if (cur_rx->ti_flags & TI_BDFLAG_IP_CKSUM) { - m->m_pkthdr.csum_flags |= CSUM_IP_CHECKED; + m->m_pkthdr.csum_flags |= CSUM_L3_CALC; if ((cur_rx->ti_ip_cksum ^ 0xffff) == 0) - m->m_pkthdr.csum_flags |= CSUM_IP_VALID; + m->m_pkthdr.csum_flags |= CSUM_L3_VALID; } if (cur_rx->ti_flags & TI_BDFLAG_TCP_UDP_CKSUM) { m->m_pkthdr.csum_data = cur_rx->ti_tcp_udp_cksum; - m->m_pkthdr.csum_flags |= CSUM_DATA_VALID; + m->m_pkthdr.csum_flags |= CSUM_L4_CALC; + /* XXXAO: look at specs. */ + m->m_pkthdr.csum_flags |= CSUM_L4_VALID; } } @@ -3167,7 +3169,7 @@ ti_start_locked(struct ifnet *ifp) * (paranoia -- may not actually be needed) */ if (m_head->m_flags & M_FIRSTFRAG && - m_head->m_pkthdr.csum_flags & (CSUM_DELAY_DATA)) { + m_head->m_pkthdr.csum_flags & (CSUM_IP_UDP|CSUM_IP_TCP)) { if ((TI_TX_RING_CNT - sc->ti_txcnt) < m_head->m_pkthdr.csum_data + 16) { IFQ_DRV_PREPEND(&ifp->if_snd, m_head); Modified: user/andre/tcp_workqueue/sys/dev/tsec/if_tsec.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/tsec/if_tsec.c Mon Nov 19 18:04:17 2012 (r243291) +++ user/andre/tcp_workqueue/sys/dev/tsec/if_tsec.c Mon Nov 19 18:09:00 2012 (r243292) @@ -1847,17 +1847,17 @@ tsec_offload_process_frame(struct tsec_s protocol = rx_fcb.protocol; if (TSEC_RX_FCB_IP_CSUM_CHECKED(flags)) { - csum_flags |= CSUM_IP_CHECKED; + csum_flags |= CSUM_L3_CALC; if ((flags & TSEC_RX_FCB_IP_CSUM_ERROR) == 0) - csum_flags |= CSUM_IP_VALID; + csum_flags |= CSUM_L3_VALID; } if ((protocol == IPPROTO_TCP || protocol == IPPROTO_UDP) && *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Mon Nov 19 18:13:37 2012 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 23A4576F for ; Mon, 19 Nov 2012 18:13:37 +0000 (UTC) (envelope-from andre@freebsd.org) Received: from c00l3r.networx.ch (c00l3r.networx.ch [62.48.2.2]) by mx1.freebsd.org (Postfix) with ESMTP id 7548A8FC16 for ; Mon, 19 Nov 2012 18:13:36 +0000 (UTC) Received: (qmail 80585 invoked from network); 19 Nov 2012 19:46:39 -0000 Received: from c00l3r.networx.ch (HELO [127.0.0.1]) ([62.48.2.2]) (envelope-sender ) by c00l3r.networx.ch (qmail-ldap-1.03) with SMTP for ; 19 Nov 2012 19:46:39 -0000 Message-ID: <50AA76CD.3070904@freebsd.org> Date: Mon, 19 Nov 2012 19:13:33 +0100 From: Andre Oppermann User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:16.0) Gecko/20121026 Thunderbird/16.0.2 MIME-Version: 1.0 To: mdf@FreeBSD.org Subject: Re: svn commit: r243215 - user/andre/tcp_workqueue/sys/sys References: <201211181217.qAICH7aH021497@svn.freebsd.org> <20121119114510.GQ38060@FreeBSD.org> <50AA3529.2030300@freebsd.org> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Gleb Smirnoff , src-committers@freebsd.org, svn-src-user@freebsd.org X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Nov 2012 18:13:37 -0000 On 19.11.2012 18:01, mdf@FreeBSD.org wrote: > On Mon, Nov 19, 2012 at 5:33 AM, Andre Oppermann wrote: >> On 19.11.2012 12:45, Gleb Smirnoff wrote: >>> >>> On Sun, Nov 18, 2012 at 12:17:07PM +0000, Andre Oppermann wrote: >>> A> Author: andre >>> A> Date: Sun Nov 18 12:17:07 2012 >>> A> New Revision: 243215 >>> A> URL: http://svnweb.freebsd.org/changeset/base/243215 >>> A> >>> A> Log: >>> A> Add mtodo(m, o, t) macro taking an additional offset into >>> A> the mbuf data section before the casting to type 't'. >>> >>> IMHO, argument order of (m, t, o) is more intuitive, since >>> matches order of mtod(). >> >> >> Yes, but that looks rather horrible and counter-intuitive: >> >> th = mtodo(m, struct tcphdr *, 20); >> >> vs. >> >> th = mtodo(m, 20, struct tcphdr *); >> >> Reads m->m_data at offset 20 is struct tcphdr. >> >> Naming it mtood() wasn't convincing either. ;-) > > Why a cast at all? Perpetuating the mistake of mtod()'s casting isn't > necessary. mtod() can't be fixed for source reasons, but the new one > doesn't need to cast. Since C automatically casts from void * to any > other pointer, the code gets shorter (usually) too: > > th = mtodo(m, 20); m->m_data is caddr_t which is "char *" > Not that I care much, it's just if we're having a bikeshed I have my > favorite colors. :-) -- Andre From owner-svn-src-user@FreeBSD.ORG Mon Nov 19 18:16:25 2012 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 29439A51; Mon, 19 Nov 2012 18:16:25 +0000 (UTC) (envelope-from nparhar@gmail.com) Received: from mail-pb0-f54.google.com (mail-pb0-f54.google.com [209.85.160.54]) by mx1.freebsd.org (Postfix) with ESMTP id CBAF18FC13; Mon, 19 Nov 2012 18:16:24 +0000 (UTC) Received: by mail-pb0-f54.google.com with SMTP id wz12so3815559pbc.13 for ; Mon, 19 Nov 2012 10:16:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=X4irGxOUzO3CVVY2i3AivEAG1iXiL+sRGTOo577FpLQ=; b=NfinrCWaotc0y3s8ock+V1WPVpwc7TyN7QwR+ZAWVO0qInzk7QSIb5I8OlHC0HAYaW Y7EttCPduPEuAIVClMnyJHfDsspRm335ufDQlZ37YfBY9SYW5Mfp+dJv2kzf9xuPtlIq RfM896v9EUhc+P76VpS3NnI0fGA03pKCJfsh9On/yKURKJYUu6Bt6HOgRgmgiMedPRGg 2XV1b37kKS3dP5GO67+RX+ZwAXWES8mvfNxy2UM3XpRCVmhfIyUpgM6PUC5n/5Fr/LCb MNw99PRBaENq0NzabeT9ucN6TfmkWEnod6ouonhy8+OKwTLvAwoa8pzW1ZTz0m9IDKAJ eBeQ== Received: by 10.66.77.39 with SMTP id p7mr550084paw.8.1353348983736; Mon, 19 Nov 2012 10:16:23 -0800 (PST) Received: from [10.192.166.0] (stargate.chelsio.com. [67.207.112.58]) by mx.google.com with ESMTPS id t1sm6541880paw.11.2012.11.19.10.16.21 (version=SSLv3 cipher=OTHER); Mon, 19 Nov 2012 10:16:22 -0800 (PST) Sender: Navdeep Parhar Message-ID: <50AA7773.1050401@FreeBSD.org> Date: Mon, 19 Nov 2012 10:16:19 -0800 From: Navdeep Parhar User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:16.0) Gecko/20121114 Thunderbird/16.0.2 MIME-Version: 1.0 To: Andre Oppermann Subject: Re: svn commit: r243215 - user/andre/tcp_workqueue/sys/sys References: <201211181217.qAICH7aH021497@svn.freebsd.org> <20121119114510.GQ38060@FreeBSD.org> <50AA3529.2030300@freebsd.org> <50AA76CD.3070904@freebsd.org> In-Reply-To: <50AA76CD.3070904@freebsd.org> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: mdf@FreeBSD.org, Gleb Smirnoff , src-committers@freebsd.org, svn-src-user@freebsd.org X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Nov 2012 18:16:25 -0000 On 11/19/12 10:13, Andre Oppermann wrote: > On 19.11.2012 18:01, mdf@FreeBSD.org wrote: >> On Mon, Nov 19, 2012 at 5:33 AM, Andre Oppermann >> wrote: >>> On 19.11.2012 12:45, Gleb Smirnoff wrote: >>>> >>>> On Sun, Nov 18, 2012 at 12:17:07PM +0000, Andre Oppermann wrote: >>>> A> Author: andre >>>> A> Date: Sun Nov 18 12:17:07 2012 >>>> A> New Revision: 243215 >>>> A> URL: http://svnweb.freebsd.org/changeset/base/243215 >>>> A> >>>> A> Log: >>>> A> Add mtodo(m, o, t) macro taking an additional offset into >>>> A> the mbuf data section before the casting to type 't'. >>>> >>>> IMHO, argument order of (m, t, o) is more intuitive, since >>>> matches order of mtod(). >>> >>> >>> Yes, but that looks rather horrible and counter-intuitive: >>> >>> th = mtodo(m, struct tcphdr *, 20); >>> >>> vs. >>> >>> th = mtodo(m, 20, struct tcphdr *); >>> >>> Reads m->m_data at offset 20 is struct tcphdr. >>> >>> Naming it mtood() wasn't convincing either. ;-) >> >> Why a cast at all? Perpetuating the mistake of mtod()'s casting isn't >> necessary. mtod() can't be fixed for source reasons, but the new one >> doesn't need to cast. Since C automatically casts from void * to any >> other pointer, the code gets shorter (usually) too: >> >> th = mtodo(m, 20); > > m->m_data is caddr_t which is "char *" No matter what it is you can always cast it to void * before returning, instead of having the caller supply the type. Navdeep > >> Not that I care much, it's just if we're having a bikeshed I have my >> favorite colors. :-) > From owner-svn-src-user@FreeBSD.ORG Mon Nov 19 18:44:01 2012 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id CCF8EC2E; Mon, 19 Nov 2012 18:44:01 +0000 (UTC) (envelope-from mdf356@gmail.com) Received: from mail-pb0-f54.google.com (mail-pb0-f54.google.com [209.85.160.54]) by mx1.freebsd.org (Postfix) with ESMTP id 76B478FC0C; Mon, 19 Nov 2012 18:44:01 +0000 (UTC) Received: by mail-pb0-f54.google.com with SMTP id wz12so3833294pbc.13 for ; Mon, 19 Nov 2012 10:44:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=xf28z9IqA8THanzLnQHhaWEeyMu7wCMHacGAh1vIES4=; b=UUQrDRvKbdXTq+k9+NCr32bS6VWwzYuCzo3M0bz/Nop/VHoO4nENEgSHBjjIO5bb8m +uEed1QvfXn+Irt3TynpzmISrMc2dmWuKFkRUDlWiNa04NYNjkv4tqGJ3ZP0p12J21Se mRUOAjNl0emAxdzP363lqMoM2YYC6mjWhAytmE3+Y85ClfqFCrBKzYU7lIQ4H3UAJkCi AX0KPvUCbPQ6hrKqB4m2O/uEUQ2AbslRK68zx17FDAb3UY1IwdRmPFVYE23r5lBLCpYK W7U7k+OupjgNjiRhFTLfEqpR4sSOkCEHzugt2Siwv2Y6nc5Rk3Vtym/tH07zA7KDpXEH qLsg== MIME-Version: 1.0 Received: by 10.68.189.138 with SMTP id gi10mr40866651pbc.165.1353350640973; Mon, 19 Nov 2012 10:44:00 -0800 (PST) Sender: mdf356@gmail.com Received: by 10.68.132.136 with HTTP; Mon, 19 Nov 2012 10:44:00 -0800 (PST) In-Reply-To: <50AA7773.1050401@FreeBSD.org> References: <201211181217.qAICH7aH021497@svn.freebsd.org> <20121119114510.GQ38060@FreeBSD.org> <50AA3529.2030300@freebsd.org> <50AA76CD.3070904@freebsd.org> <50AA7773.1050401@FreeBSD.org> Date: Mon, 19 Nov 2012 10:44:00 -0800 X-Google-Sender-Auth: vBuvL96xxyXO-6_DA4lgreQ9Tzc Message-ID: Subject: Re: svn commit: r243215 - user/andre/tcp_workqueue/sys/sys From: mdf@FreeBSD.org To: Navdeep Parhar Content-Type: text/plain; charset=ISO-8859-1 Cc: Gleb Smirnoff , Andre Oppermann , src-committers@freebsd.org, svn-src-user@freebsd.org X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Nov 2012 18:44:01 -0000 On Mon, Nov 19, 2012 at 10:16 AM, Navdeep Parhar wrote: > On 11/19/12 10:13, Andre Oppermann wrote: >> On 19.11.2012 18:01, mdf@FreeBSD.org wrote: >>> On Mon, Nov 19, 2012 at 5:33 AM, Andre Oppermann >>> wrote: >>>> On 19.11.2012 12:45, Gleb Smirnoff wrote: >>>>> >>>>> On Sun, Nov 18, 2012 at 12:17:07PM +0000, Andre Oppermann wrote: >>>>> A> Author: andre >>>>> A> Date: Sun Nov 18 12:17:07 2012 >>>>> A> New Revision: 243215 >>>>> A> URL: http://svnweb.freebsd.org/changeset/base/243215 >>>>> A> >>>>> A> Log: >>>>> A> Add mtodo(m, o, t) macro taking an additional offset into >>>>> A> the mbuf data section before the casting to type 't'. >>>>> >>>>> IMHO, argument order of (m, t, o) is more intuitive, since >>>>> matches order of mtod(). >>>> >>>> >>>> Yes, but that looks rather horrible and counter-intuitive: >>>> >>>> th = mtodo(m, struct tcphdr *, 20); >>>> >>>> vs. >>>> >>>> th = mtodo(m, 20, struct tcphdr *); >>>> >>>> Reads m->m_data at offset 20 is struct tcphdr. >>>> >>>> Naming it mtood() wasn't convincing either. ;-) >>> >>> Why a cast at all? Perpetuating the mistake of mtod()'s casting isn't >>> necessary. mtod() can't be fixed for source reasons, but the new one >>> doesn't need to cast. Since C automatically casts from void * to any >>> other pointer, the code gets shorter (usually) too: >>> >>> th = mtodo(m, 20); >> >> m->m_data is caddr_t which is "char *" > > No matter what it is you can always cast it to void * before returning, > instead of having the caller supply the type. Right, this is what I meant. Instead of a parameter to cast to, just return void *. Let the caller cast, or not, as needed. It's a simpler macro that way. Cheers, matthew From owner-svn-src-user@FreeBSD.ORG Mon Nov 19 18:57:36 2012 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9EBB32E7; Mon, 19 Nov 2012 18:57:36 +0000 (UTC) (envelope-from tuexen@fh-muenster.de) Received: from mail-n.franken.de (drew.ipv6.franken.de [IPv6:2001:638:a02:a001:20e:cff:fe4a:feaa]) by mx1.freebsd.org (Postfix) with ESMTP id 4332C8FC0C; Mon, 19 Nov 2012 18:57:35 +0000 (UTC) Received: from [192.168.1.101] (p4FF52545.dip.t-dialin.net [79.245.37.69]) (Authenticated sender: macmic) by mail-n.franken.de (Postfix) with ESMTP id F2FD31C0C069A; Mon, 19 Nov 2012 19:57:31 +0100 (CET) Subject: Re: svn commit: r243291 - in user/andre/tcp_workqueue/sys: net netinet netinet6 netipsec netpfil/ipfw netpfil/pf Mime-Version: 1.0 (Apple Message framework v1283) Content-Type: text/plain; charset=us-ascii From: Michael Tuexen In-Reply-To: <201211191804.qAJI4IXX014601@svn.freebsd.org> Date: Mon, 19 Nov 2012 19:57:34 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: References: <201211191804.qAJI4IXX014601@svn.freebsd.org> To: Andre Oppermann X-Mailer: Apple Mail (2.1283) Cc: src-committers@freebsd.org, svn-src-user@freebsd.org X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Nov 2012 18:57:36 -0000 On Nov 19, 2012, at 7:04 PM, Andre Oppermann wrote: > Author: andre > Date: Mon Nov 19 18:04:17 2012 > New Revision: 243291 > URL: http://svnweb.freebsd.org/changeset/base/243291 >=20 > Log: > Convert IP, IPv6, UDP, TCP and SCTP to the new checksum offloading > semantics on the inbound and outbound path. >=20 > In short for inbound there are two levels the offloading NIC can > set: >=20 > CSUM_L3_CALC for an IP layer 3 checksum calculated by the = NIC; > CSUM_L3_VALID set when the calculated checksum matches the one > in the packet; > CSUM_L4_CALC for an UDP/TCP/SCTP layer 4 checksum calculated = by > the NIC; > CSUM_L4_VALID set when the calculated checksum matche the one > in the packet. >=20 > =46rom this follows that a packet failed checksum verification when > only *_CALC is set but not *_VALID. The NIC is expected to deliver > a failed packet up the stack anyways for capture by BPF and to > record protocol specific checksum mismatch statistics. >=20 > The old approach with CSUM_DATA_VALID and CSUM_PSEUDO_HDR could not > signal a failed packet. A failed packet was delivered into the stack > and the protocol had to recalculate the checksum for verification > every time to detect that as the absence of CSUM_DATA_VALID didn't > signal that the packet was broken. It was only saying that the > checksum wasn't calculated by the NIC, which actually wasn't the = case. >=20 > Drag the other stack infrastructure, including packet filters, along > as well. I looked at the code for SCTP. If the NIC reports that it computed the checksum and the checksum is not reported as valid, you are dropping the packet. The problem with this code is, that at least some NICs report for small SCTP packets that the checksum is wrong. To deal with this, I did the checksum verification is software in case the hardware = reported a bad checksum. Are you planning to deal with this in the specific = drivers? Best regards Michael >=20 > Modified: > user/andre/tcp_workqueue/sys/net/if_bridge.c > user/andre/tcp_workqueue/sys/net/if_ethersubr.c > user/andre/tcp_workqueue/sys/net/if_loop.c > user/andre/tcp_workqueue/sys/netinet/ip_divert.c > user/andre/tcp_workqueue/sys/netinet/ip_fastfwd.c > user/andre/tcp_workqueue/sys/netinet/ip_input.c > user/andre/tcp_workqueue/sys/netinet/ip_ipsec.c > user/andre/tcp_workqueue/sys/netinet/ip_mroute.c > user/andre/tcp_workqueue/sys/netinet/ip_output.c > user/andre/tcp_workqueue/sys/netinet/sctp_input.c > user/andre/tcp_workqueue/sys/netinet/sctp_os_bsd.h > user/andre/tcp_workqueue/sys/netinet/sctp_output.c > user/andre/tcp_workqueue/sys/netinet/siftr.c > user/andre/tcp_workqueue/sys/netinet/tcp_input.c > user/andre/tcp_workqueue/sys/netinet/tcp_lro.c > user/andre/tcp_workqueue/sys/netinet/tcp_output.c > user/andre/tcp_workqueue/sys/netinet/tcp_subr.c > user/andre/tcp_workqueue/sys/netinet/tcp_syncache.c > user/andre/tcp_workqueue/sys/netinet/tcp_timewait.c > user/andre/tcp_workqueue/sys/netinet/udp_usrreq.c > user/andre/tcp_workqueue/sys/netinet6/ip6_forward.c > user/andre/tcp_workqueue/sys/netinet6/ip6_ipsec.c > user/andre/tcp_workqueue/sys/netinet6/ip6_output.c > user/andre/tcp_workqueue/sys/netinet6/sctp6_usrreq.c > user/andre/tcp_workqueue/sys/netinet6/udp6_usrreq.c > user/andre/tcp_workqueue/sys/netipsec/ipsec_pfil.c > user/andre/tcp_workqueue/sys/netpfil/ipfw/ip_fw_nat.c > user/andre/tcp_workqueue/sys/netpfil/pf/pf.c > user/andre/tcp_workqueue/sys/netpfil/pf/pf_ioctl.c >=20 > Modified: user/andre/tcp_workqueue/sys/net/if_bridge.c > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- user/andre/tcp_workqueue/sys/net/if_bridge.c Mon Nov 19 = 17:33:45 2012 (r243290) > +++ user/andre/tcp_workqueue/sys/net/if_bridge.c Mon Nov 19 = 18:04:17 2012 (r243291) > @@ -3263,8 +3263,8 @@ bridge_ip_checkbasic(struct mbuf **mp) > if (ip =3D=3D NULL) goto bad; > } >=20 > - if (m->m_pkthdr.csum_flags & CSUM_IP_CHECKED) { > - sum =3D !(m->m_pkthdr.csum_flags & CSUM_IP_VALID); > + if (m->m_pkthdr.csum_flags & CSUM_L3_CALC) { > + sum =3D !(m->m_pkthdr.csum_flags & CSUM_L3_VALID); > } else { > if (hlen =3D=3D sizeof(struct ip)) { > sum =3D in_cksum_hdr(ip); >=20 > Modified: user/andre/tcp_workqueue/sys/net/if_ethersubr.c > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- user/andre/tcp_workqueue/sys/net/if_ethersubr.c Mon Nov 19 = 17:33:45 2012 (r243290) > +++ user/andre/tcp_workqueue/sys/net/if_ethersubr.c Mon Nov 19 = 18:04:17 2012 (r243291) > @@ -299,12 +299,10 @@ ether_output(struct ifnet *ifp, struct m > if (lle !=3D NULL && (lle->la_flags & LLE_IFADDR)) { > int csum_flags =3D 0; > if (m->m_pkthdr.csum_flags & CSUM_IP) > - csum_flags |=3D (CSUM_IP_CHECKED|CSUM_IP_VALID); > - if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA) > - csum_flags |=3D = (CSUM_DATA_VALID|CSUM_PSEUDO_HDR); > - if (m->m_pkthdr.csum_flags & CSUM_SCTP) > - csum_flags |=3D CSUM_SCTP_VALID; > - m->m_pkthdr.csum_flags |=3D csum_flags; > + csum_flags |=3D (CSUM_L3_CALC|CSUM_L3_VALID); > + if (m->m_pkthdr.csum_flags & = (CSUM_UDP|CSUM_TCP|CSUM_SCTP)) > + csum_flags |=3D (CSUM_L4_CALC|CSUM_L4_VALID); > + m->m_pkthdr.csum_flags =3D csum_flags; > m->m_pkthdr.csum_data =3D 0xffff; > return (if_simloop(ifp, m, dst->sa_family, 0)); > } > @@ -356,11 +354,9 @@ ether_output(struct ifnet *ifp, struct m > int csum_flags =3D 0; >=20 > if (m->m_pkthdr.csum_flags & CSUM_IP) > - csum_flags |=3D (CSUM_IP_CHECKED|CSUM_IP_VALID); > - if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA) > - csum_flags |=3D = (CSUM_DATA_VALID|CSUM_PSEUDO_HDR); > - if (m->m_pkthdr.csum_flags & CSUM_SCTP) > - csum_flags |=3D CSUM_SCTP_VALID; > + csum_flags |=3D (CSUM_L3_CALC|CSUM_L3_VALID); > + if (m->m_pkthdr.csum_flags & = (CSUM_UDP|CSUM_TCP|CSUM_SCTP)) > + csum_flags |=3D (CSUM_L4_CALC|CSUM_L4_VALID); >=20 > if (m->m_flags & M_BCAST) { > struct mbuf *n; > @@ -379,16 +375,12 @@ ether_output(struct ifnet *ifp, struct m > */ > if ((n =3D m_dup(m, M_DONTWAIT)) !=3D NULL) { > n->m_pkthdr.csum_flags |=3D csum_flags; > - if (csum_flags & CSUM_DATA_VALID) > - n->m_pkthdr.csum_data =3D = 0xffff; > (void)if_simloop(ifp, n, dst->sa_family, = hlen); > } else > ifp->if_iqdrops++; > } else if (bcmp(eh->ether_dhost, eh->ether_shost, > ETHER_ADDR_LEN) =3D=3D 0) { > m->m_pkthdr.csum_flags |=3D csum_flags; > - if (csum_flags & CSUM_DATA_VALID) > - m->m_pkthdr.csum_data =3D 0xffff; > (void) if_simloop(ifp, m, dst->sa_family, hlen); > return (0); /* XXX */ > } >=20 > Modified: user/andre/tcp_workqueue/sys/net/if_loop.c > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- user/andre/tcp_workqueue/sys/net/if_loop.c Mon Nov 19 = 17:33:45 2012 (r243290) > +++ user/andre/tcp_workqueue/sys/net/if_loop.c Mon Nov 19 = 18:04:17 2012 (r243291) > @@ -91,12 +91,10 @@ > #define LOMTU 16384 > #endif >=20 > -#define LO_CSUM_FEATURES (CSUM_IP | CSUM_TCP | CSUM_UDP | = CSUM_SCTP) > -#define LO_CSUM_FEATURES6 (CSUM_TCP_IPV6 | CSUM_UDP_IPV6 | = CSUM_SCTP_IPV6) > -#define LO_CSUM_SET (CSUM_DATA_VALID | = CSUM_DATA_VALID_IPV6 | \ > - CSUM_PSEUDO_HDR | \ > - CSUM_IP_CHECKED | CSUM_IP_VALID | \ > - CSUM_SCTP_VALID) > +#define LO_CSUM_FEATURES = (CSUM_IP|CSUM_IP_UDP|CSUM_IP_TCP|CSUM_IP_SCTP) > +#define LO_CSUM_FEATURES6 = (CSUM_IP6_UDP|CSUM_IP6_TCP|CSUM_IP6_SCTP) > +#define LO_CSUM_SET (CSUM_L4_CALC | CSUM_L4_VALID | = \ > + CSUM_L3_CALC | CSUM_L3_VALID) >=20 > int loioctl(struct ifnet *, u_long, caddr_t); > static void lortrequest(int, struct rtentry *, struct rt_addrinfo = *); >=20 > Modified: user/andre/tcp_workqueue/sys/netinet/ip_divert.c > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- user/andre/tcp_workqueue/sys/netinet/ip_divert.c Mon Nov 19 = 17:33:45 2012 (r243290) > +++ user/andre/tcp_workqueue/sys/netinet/ip_divert.c Mon Nov 19 = 18:04:17 2012 (r243291) > @@ -207,14 +207,14 @@ divert_packet(struct mbuf *m, int incomi > ip =3D mtod(m, struct ip *); >=20 > /* Delayed checksums are currently not compatible with divert. = */ > - if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA) { > + if (m->m_pkthdr.csum_flags & (CSUM_IP_UDP|CSUM_IP_TCP)) { > in_delayed_cksum(m); > - m->m_pkthdr.csum_flags &=3D ~CSUM_DELAY_DATA; > + m->m_pkthdr.csum_flags &=3D ~(CSUM_IP_UDP|CSUM_IP_TCP); > } > #ifdef SCTP > - if (m->m_pkthdr.csum_flags & CSUM_SCTP) { > + if (m->m_pkthdr.csum_flags & CSUM_IP_SCTP) { > sctp_delayed_cksum(m, (uint32_t)(ip->ip_hl << 2)); > - m->m_pkthdr.csum_flags &=3D ~CSUM_SCTP; > + m->m_pkthdr.csum_flags &=3D ~CSUM_IP_SCTP; > } > #endif > bzero(&divsrc, sizeof(divsrc)); >=20 > Modified: user/andre/tcp_workqueue/sys/netinet/ip_fastfwd.c > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- user/andre/tcp_workqueue/sys/netinet/ip_fastfwd.c Mon Nov 19 = 17:33:45 2012 (r243290) > +++ user/andre/tcp_workqueue/sys/netinet/ip_fastfwd.c Mon Nov 19 = 18:04:17 2012 (r243291) > @@ -230,23 +230,25 @@ ip_fastforward(struct mbuf *m) > /* > * Checksum correct? > */ > - if (m->m_pkthdr.csum_flags & CSUM_IP_CHECKED) > - sum =3D !(m->m_pkthdr.csum_flags & CSUM_IP_VALID); > - else { > + if ((m->m_pkthdr.csum_flags & (CSUM_L3_CALC | CSUM_L3_VALID)) =3D=3D= > + CSUM_L3_CALC) { > + IPSTAT_INC(ips_badsum); > + goto drop; > + } else if (!(m->m_pkthdr.csum_flags & CSUM_L3_VALID)) { > if (hlen =3D=3D sizeof(struct ip)) > sum =3D in_cksum_hdr(ip); > else > sum =3D in_cksum(m, hlen); > + if (sum) { > + IPSTAT_INC(ips_badsum); > + goto drop; > + } > + /* > + * Remember that we have checked the IP header and found > + * it valid. > + */ > + m->m_pkthdr.csum_flags |=3D (CSUM_L3_CALC | = CSUM_L3_VALID); > } > - if (sum) { > - IPSTAT_INC(ips_badsum); > - goto drop; > - } > - > - /* > - * Remember that we have checked the IP header and found it = valid. > - */ > - m->m_pkthdr.csum_flags |=3D (CSUM_IP_CHECKED | CSUM_IP_VALID); >=20 > ip_len =3D ntohs(ip->ip_len); >=20 > @@ -523,7 +525,7 @@ passout: > mtu =3D ifp->if_mtu; >=20 > if (ip_len <=3D mtu || > - (ifp->if_hwassist & CSUM_IPFRAG && (ip_off & IP_DF) =3D=3D = 0)) { > + ((ifp->if_hwassist & CSUM_IP_FRAGO) && (ip_off & IP_DF) =3D=3D= 0)) { > /* > * Send off the packet via outgoing interface > */ >=20 > Modified: user/andre/tcp_workqueue/sys/netinet/ip_input.c > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- user/andre/tcp_workqueue/sys/netinet/ip_input.c Mon Nov 19 = 17:33:45 2012 (r243290) > +++ user/andre/tcp_workqueue/sys/netinet/ip_input.c Mon Nov 19 = 18:04:17 2012 (r243291) > @@ -435,19 +435,20 @@ ip_input(struct mbuf *m) > } > } >=20 > - if (m->m_pkthdr.csum_flags & CSUM_IP_CHECKED) { > - sum =3D !(m->m_pkthdr.csum_flags & CSUM_IP_VALID); > - } else { > - if (hlen =3D=3D sizeof(struct ip)) { > + if ((m->m_pkthdr.csum_flags & (CSUM_L3_CALC|CSUM_L3_VALID)) =3D=3D= > + CSUM_L3_CALC) { > + IPSTAT_INC(ips_badsum); > + goto bad; > + } else if (!(m->m_pkthdr.csum_flags & CSUM_L3_VALID)) { > + if (hlen =3D=3D sizeof(struct ip)) > sum =3D in_cksum_hdr(ip); > - } else { > + else > sum =3D in_cksum(m, hlen); > + if (sum) { > + IPSTAT_INC(ips_badsum); > + goto bad; > } > } > - if (sum) { > - IPSTAT_INC(ips_badsum); > - goto bad; > - } >=20 > #ifdef ALTQ > if (altq_input !=3D NULL && (*altq_input)(m, AF_INET) =3D=3D 0) >=20 > Modified: user/andre/tcp_workqueue/sys/netinet/ip_ipsec.c > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- user/andre/tcp_workqueue/sys/netinet/ip_ipsec.c Mon Nov 19 = 17:33:45 2012 (r243290) > +++ user/andre/tcp_workqueue/sys/netinet/ip_ipsec.c Mon Nov 19 = 18:04:17 2012 (r243291) > @@ -327,16 +327,16 @@ ip_ipsec_output(struct mbuf **m, struct=20 > * Do delayed checksums now because we send before > * this is done in the normal processing path. > */ > - if ((*m)->m_pkthdr.csum_flags & CSUM_DELAY_DATA) { > + if ((*m)->m_pkthdr.csum_flags & = (CSUM_IP_UDP|CSUM_IP_TCP)) { > in_delayed_cksum(*m); > - (*m)->m_pkthdr.csum_flags &=3D ~CSUM_DELAY_DATA; > + (*m)->m_pkthdr.csum_flags &=3D = ~(CSUM_IP_UDP|CSUM_IP_TCP); > } > #ifdef SCTP > - if ((*m)->m_pkthdr.csum_flags & CSUM_SCTP) { > + if ((*m)->m_pkthdr.csum_flags & CSUM_IP_SCTP) { > struct ip *ip =3D mtod(*m, struct ip *); >=20 > sctp_delayed_cksum(*m, (uint32_t)(ip->ip_hl << = 2)); > - (*m)->m_pkthdr.csum_flags &=3D ~CSUM_SCTP; > + (*m)->m_pkthdr.csum_flags &=3D ~CSUM_IP_SCTP; > } > #endif >=20 >=20 > Modified: user/andre/tcp_workqueue/sys/netinet/ip_mroute.c > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- user/andre/tcp_workqueue/sys/netinet/ip_mroute.c Mon Nov 19 = 17:33:45 2012 (r243290) > +++ user/andre/tcp_workqueue/sys/netinet/ip_mroute.c Mon Nov 19 = 18:04:17 2012 (r243291) > @@ -2375,9 +2375,9 @@ pim_register_prepare(struct ip *ip, stru > int mtu; >=20 > /* Take care of delayed checksums */ > - if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA) { > + if (m->m_pkthdr.csum_flags & (CSUM_IP_UDP|CSUM_IP_TCP)) { > in_delayed_cksum(m); > - m->m_pkthdr.csum_flags &=3D ~CSUM_DELAY_DATA; > + m->m_pkthdr.csum_flags &=3D ~(CSUM_IP_UDP|CSUM_IP_TCP); > } >=20 > /* >=20 > Modified: user/andre/tcp_workqueue/sys/netinet/ip_output.c > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- user/andre/tcp_workqueue/sys/netinet/ip_output.c Mon Nov 19 = 17:33:45 2012 (r243290) > +++ user/andre/tcp_workqueue/sys/netinet/ip_output.c Mon Nov 19 = 18:04:17 2012 (r243291) > @@ -518,41 +518,31 @@ sendit: > m->m_flags |=3D M_FASTFWD_OURS; > if (m->m_pkthdr.rcvif =3D=3D NULL) > m->m_pkthdr.rcvif =3D V_loif; > - if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA) { > + /* Pretend that the checksum was verified by hw. = */ > + if (m->m_pkthdr.csum_flags & CSUM_IP) > m->m_pkthdr.csum_flags |=3D > - CSUM_DATA_VALID | CSUM_PSEUDO_HDR; > - m->m_pkthdr.csum_data =3D 0xffff; > - } > - m->m_pkthdr.csum_flags |=3D > - CSUM_IP_CHECKED | CSUM_IP_VALID; > -#ifdef SCTP > - if (m->m_pkthdr.csum_flags & CSUM_SCTP) > - m->m_pkthdr.csum_flags |=3D = CSUM_SCTP_VALID; > -#endif > + CSUM_L3_CALC | CSUM_L3_VALID; > + if (m->m_pkthdr.csum_flags & > + (CSUM_UDP|CSUM_TCP|CSUM_SCTP)) > + m->m_pkthdr.csum_flags |=3D > + CSUM_L4_CALC | CSUM_L4_VALID; > error =3D netisr_queue(NETISR_IP, m); > goto done; > - } else { > - if (ia !=3D NULL) > - ifa_free(&ia->ia_ifa); > - goto again; /* Redo the routing table = lookup. */ > } > + if (ia !=3D NULL) > + ifa_free(&ia->ia_ifa); > + goto again; /* Redo the routing table lookup. */ > } >=20 > /* See if local, if yes, send it to netisr with IP_FASTFWD_OURS. = */ > if (m->m_flags & M_FASTFWD_OURS) { > if (m->m_pkthdr.rcvif =3D=3D NULL) > m->m_pkthdr.rcvif =3D V_loif; > - if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA) { > - m->m_pkthdr.csum_flags |=3D > - CSUM_DATA_VALID | CSUM_PSEUDO_HDR; > - m->m_pkthdr.csum_data =3D 0xffff; > - } > -#ifdef SCTP > - if (m->m_pkthdr.csum_flags & CSUM_SCTP) > - m->m_pkthdr.csum_flags |=3D CSUM_SCTP_VALID; > -#endif > - m->m_pkthdr.csum_flags |=3D > - CSUM_IP_CHECKED | CSUM_IP_VALID; > + /* Pretend that the checksum was verified by hw. */ > + if (m->m_pkthdr.csum_flags & CSUM_IP) > + m->m_pkthdr.csum_flags |=3D CSUM_L3_CALC | = CSUM_L3_VALID; > + if (m->m_pkthdr.csum_flags & = (CSUM_UDP|CSUM_TCP|CSUM_SCTP)) > + m->m_pkthdr.csum_flags |=3D CSUM_L4_CALC | = CSUM_L4_VALID; >=20 > error =3D netisr_queue(NETISR_IP, m); > goto done; > @@ -583,14 +573,15 @@ passout: >=20 > m->m_pkthdr.csum_flags |=3D CSUM_IP; > m->m_pkthdr.csum_l3hlen +=3D ip_len; > - if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA & = ~ifp->if_hwassist) { > + if (m->m_pkthdr.csum_flags & (CSUM_IP_UDP|CSUM_IP_TCP) & > + ~ifp->if_hwassist) { > in_delayed_cksum(m); > - m->m_pkthdr.csum_flags &=3D ~CSUM_DELAY_DATA; > + m->m_pkthdr.csum_flags &=3D ~(CSUM_IP_UDP|CSUM_IP_TCP); > } > #ifdef SCTP > - if (m->m_pkthdr.csum_flags & CSUM_SCTP & ~ifp->if_hwassist) { > + else if (m->m_pkthdr.csum_flags & CSUM_IP_SCTP & = ~ifp->if_hwassist) { > sctp_delayed_cksum(m, (uint32_t)(ip->ip_hl << 2)); > - m->m_pkthdr.csum_flags &=3D ~CSUM_SCTP; > + m->m_pkthdr.csum_flags &=3D ~CSUM_IP_SCTP; > } > #endif >=20 > @@ -599,8 +590,8 @@ passout: > * care of the fragmentation for us, we can just send directly. > */ > if (ip_len <=3D mtu || > - (m->m_pkthdr.csum_flags & ifp->if_hwassist & CSUM_TSO) !=3D = 0 || > - ((ip_off & IP_DF) =3D=3D 0 && (ifp->if_hwassist & = CSUM_IPFRAG))) { > + (m->m_pkthdr.csum_flags & ifp->if_hwassist & CSUM_IP_TSO) !=3D= 0 || > + ((ip_off & IP_DF) =3D=3D 0 && (ifp->if_hwassist & = CSUM_IP_FRAGO))) { > ip->ip_sum =3D 0; > if (m->m_pkthdr.csum_flags & CSUM_IP & = ~ifp->if_hwassist) { > ip->ip_sum =3D in_cksum(m, hlen); > @@ -609,12 +600,12 @@ passout: >=20 > /* > * Record statistics for this interface address. > - * With CSUM_TSO the byte/packet count will be slightly > + * With CSUM_IP_TSO the byte/packet count will be = slightly > * incorrect because we count the IP+TCP headers only > * once instead of for every generated packet. > */ > if (!(flags & IP_FORWARDING) && ia) { > - if (m->m_pkthdr.csum_flags & CSUM_TSO) > + if (m->m_pkthdr.csum_flags & CSUM_IP_TSO) > ia->ia_ifa.if_opackets +=3D > m->m_pkthdr.len / = m->m_pkthdr.tso_segsz; > else > @@ -636,7 +627,7 @@ passout: > } >=20 > /* Balk when DF bit is set or the interface didn't support TSO. = */ > - if ((ip_off & IP_DF) || (m->m_pkthdr.csum_flags & CSUM_TSO)) { > + if ((ip_off & IP_DF) || (m->m_pkthdr.csum_flags & CSUM_IP_TSO)) = { > error =3D EMSGSIZE; > IPSTAT_INC(ips_cantfrag); > goto bad; > @@ -724,14 +715,14 @@ ip_fragment(struct ip *ip, struct mbuf * > * If the interface will not calculate checksums on > * fragmented packets, then do it here. > */ > - if (m0->m_pkthdr.csum_flags & CSUM_DELAY_DATA) { > + if (m0->m_pkthdr.csum_flags & (CSUM_IP_UDP|CSUM_IP_TCP)) { > in_delayed_cksum(m0); > - m0->m_pkthdr.csum_flags &=3D ~CSUM_DELAY_DATA; > + m0->m_pkthdr.csum_flags &=3D ~(CSUM_IP_UDP|CSUM_IP_TCP); > } > #ifdef SCTP > - if (m0->m_pkthdr.csum_flags & CSUM_SCTP) { > + if (m0->m_pkthdr.csum_flags & CSUM_IP_SCTP) { > sctp_delayed_cksum(m0, hlen); > - m0->m_pkthdr.csum_flags &=3D ~CSUM_SCTP; > + m0->m_pkthdr.csum_flags &=3D ~CSUM_IP_SCTP; > } > #endif > if (len > PAGE_SIZE) { > @@ -872,7 +863,7 @@ in_delayed_cksum(struct mbuf *m) > offset =3D ip->ip_hl << 2 ; > ip_len =3D ntohs(ip->ip_len); > csum =3D in_cksum_skip(m, ip_len, offset); > - if (m->m_pkthdr.csum_flags & CSUM_UDP && csum =3D=3D 0) > + if (m->m_pkthdr.csum_flags & CSUM_IP_UDP && csum =3D=3D 0) > csum =3D 0xffff; > offset +=3D m->m_pkthdr.csum_data; /* checksum offset */ >=20 > @@ -1296,11 +1287,11 @@ ip_mloopback(struct ifnet *ifp, struct m > copym =3D m_pullup(copym, hlen); > if (copym !=3D NULL) { > /* If needed, compute the checksum and mark it as valid. = */ > - if (copym->m_pkthdr.csum_flags & CSUM_DELAY_DATA) { > + if (copym->m_pkthdr.csum_flags & = (CSUM_IP_UDP|CSUM_IP_TCP)) { > in_delayed_cksum(copym); > - copym->m_pkthdr.csum_flags &=3D = ~CSUM_DELAY_DATA; > + copym->m_pkthdr.csum_flags &=3D = ~(CSUM_IP_UDP|CSUM_IP_TCP); > copym->m_pkthdr.csum_flags |=3D > - CSUM_DATA_VALID | CSUM_PSEUDO_HDR; > + CSUM_L4_CALC | CSUM_L4_VALID; > copym->m_pkthdr.csum_data =3D 0xffff; > } > /* >=20 > Modified: user/andre/tcp_workqueue/sys/netinet/sctp_input.c > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- user/andre/tcp_workqueue/sys/netinet/sctp_input.c Mon Nov 19 = 17:33:45 2012 (r243290) > +++ user/andre/tcp_workqueue/sys/netinet/sctp_input.c Mon Nov 19 = 18:04:17 2012 (r243291) > @@ -6064,9 +6064,15 @@ sctp_input_with_port(struct mbuf *i_pak, > #if defined(SCTP_WITH_NO_CSUM) > SCTP_STAT_INCR(sctps_recvnocrc); > #else > - if (m->m_pkthdr.csum_flags & CSUM_SCTP_VALID) { > + if ((m->m_pkthdr.csum_flags & (CSUM_L4_CALC|CSUM_L4_VALID)) =3D=3D= > + (CSUM_L4_CALC | CSUM_L4_VALID)) { > SCTP_STAT_INCR(sctps_recvhwcrc); > compute_crc =3D 0; > + } else if ((m->m_pkthdr.csum_flags & = (CSUM_L4_CALC|CSUM_L4_VALID)) =3D=3D > + CSUM_L4_CALC) { > + SCTP_STAT_INCR(sctps_badsum); > + SCTP_STAT_INCR_COUNTER32(sctps_checksumerrors); > + goto out; > } else { > SCTP_STAT_INCR(sctps_recvswcrc); > compute_crc =3D 1; >=20 > Modified: user/andre/tcp_workqueue/sys/netinet/sctp_os_bsd.h > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- user/andre/tcp_workqueue/sys/netinet/sctp_os_bsd.h Mon Nov = 19 17:33:45 2012 (r243290) > +++ user/andre/tcp_workqueue/sys/netinet/sctp_os_bsd.h Mon Nov = 19 18:04:17 2012 (r243291) > @@ -366,8 +366,8 @@ typedef struct callout sctp_os_timer_t; > #define SCTP_RELEASE_HEADER(m) > #define SCTP_RELEASE_PKT(m) sctp_m_freem(m) > #define SCTP_ENABLE_UDP_CSUM(m) do { \ > - m->m_pkthdr.csum_flags =3D = CSUM_UDP; \ > - m->m_pkthdr.csum_data =3D = offsetof(struct udphdr, uh_sum); \ > + m->m_pkthdr.csum_flags =3D = CSUM_IP_UDP; \ > + m->m_pkthdr.csum_l4hlen =3D = sizeof(struct udphdr); \ > } while (0) >=20 > #define SCTP_GET_PKT_VRFID(m, vrf_id) ((vrf_id =3D = SCTP_DEFAULT_VRFID) !=3D SCTP_DEFAULT_VRFID) >=20 > Modified: user/andre/tcp_workqueue/sys/netinet/sctp_output.c > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- user/andre/tcp_workqueue/sys/netinet/sctp_output.c Mon Nov = 19 17:33:45 2012 (r243290) > +++ user/andre/tcp_workqueue/sys/netinet/sctp_output.c Mon Nov = 19 18:04:17 2012 (r243291) > @@ -4129,7 +4129,7 @@ sctp_lowlevel_chunk_output(struct sctp_i > #if defined(SCTP_WITH_NO_CSUM) > SCTP_STAT_INCR(sctps_sendnocrc); > #else > - m->m_pkthdr.csum_flags =3D CSUM_SCTP; > + m->m_pkthdr.csum_flags =3D CSUM_IP_SCTP; > m->m_pkthdr.csum_l4hlen =3D = sizeof(struct sctphdr); > SCTP_STAT_INCR(sctps_sendhwcrc); > #endif > @@ -4478,7 +4478,7 @@ sctp_lowlevel_chunk_output(struct sctp_i > #if defined(SCTP_WITH_NO_CSUM) > SCTP_STAT_INCR(sctps_sendnocrc); > #else > - m->m_pkthdr.csum_flags =3D = CSUM_SCTP_IPV6; > + m->m_pkthdr.csum_flags =3D = CSUM_IP6_SCTP; > m->m_pkthdr.csum_l4hlen =3D = sizeof(struct sctphdr); > SCTP_STAT_INCR(sctps_sendhwcrc); > #endif > @@ -11005,7 +11005,7 @@ sctp_send_resp_msg(struct sockaddr *src, > #if defined(SCTP_WITH_NO_CSUM) > SCTP_STAT_INCR(sctps_sendnocrc); > #else > - mout->m_pkthdr.csum_flags =3D CSUM_SCTP; > + mout->m_pkthdr.csum_flags =3D CSUM_IP_SCTP; > mout->m_pkthdr.csum_l4hlen =3D sizeof(struct = sctphdr); > SCTP_STAT_INCR(sctps_sendhwcrc); > #endif > @@ -11035,7 +11035,7 @@ sctp_send_resp_msg(struct sockaddr *src, > #if defined(SCTP_WITH_NO_CSUM) > SCTP_STAT_INCR(sctps_sendnocrc); > #else > - mout->m_pkthdr.csum_flags =3D CSUM_SCTP_IPV6; > + mout->m_pkthdr.csum_flags =3D CSUM_IP6_SCTP; > mout->m_pkthdr.csum_l4hlen =3D sizeof(struct = sctphdr); > SCTP_STAT_INCR(sctps_sendhwcrc); > #endif >=20 > Modified: user/andre/tcp_workqueue/sys/netinet/siftr.c > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- user/andre/tcp_workqueue/sys/netinet/siftr.c Mon Nov 19 = 17:33:45 2012 (r243290) > +++ user/andre/tcp_workqueue/sys/netinet/siftr.c Mon Nov 19 = 18:04:17 2012 (r243291) > @@ -904,7 +904,7 @@ siftr_chkpkt(void *arg, struct mbuf **m, > siftr_siftdata(pn, inp, tp, INP_IPV4, dir, inp_locally_locked); >=20 > if (siftr_generate_hashes) { > - if ((*m)->m_pkthdr.csum_flags & CSUM_TCP) { > + if ((*m)->m_pkthdr.csum_flags & CSUM_IP_TCP) { > /* > * For outbound packets, the TCP checksum isn't > * calculated yet. This is a problem for our = packet > @@ -915,7 +915,7 @@ siftr_chkpkt(void *arg, struct mbuf **m, > * software. We unset the CSUM_TCP flag so the = lower > * layers don't recalc it. > */ > - (*m)->m_pkthdr.csum_flags &=3D ~CSUM_TCP; > + (*m)->m_pkthdr.csum_flags &=3D ~CSUM_IP_TCP; >=20 > /* > * Calculate the TCP checksum in software and = assign >=20 > Modified: user/andre/tcp_workqueue/sys/netinet/tcp_input.c > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- user/andre/tcp_workqueue/sys/netinet/tcp_input.c Mon Nov 19 = 17:33:45 2012 (r243290) > +++ user/andre/tcp_workqueue/sys/netinet/tcp_input.c Mon Nov 19 = 18:04:17 2012 (r243291) > @@ -614,16 +614,13 @@ tcp_input(struct mbuf *m, int off0) > ip6 =3D mtod(m, struct ip6_hdr *); > th =3D (struct tcphdr *)((caddr_t)ip6 + off0); > tlen =3D sizeof(*ip6) + ntohs(ip6->ip6_plen) - off0; > - if (m->m_pkthdr.csum_flags & CSUM_DATA_VALID_IPV6) { > - if (m->m_pkthdr.csum_flags & CSUM_PSEUDO_HDR) > - th->th_sum =3D m->m_pkthdr.csum_data; > - else > - th->th_sum =3D in6_cksum_pseudo(ip6, = tlen, > - IPPROTO_TCP, m->m_pkthdr.csum_data); > - th->th_sum ^=3D 0xffff; > - } else > - th->th_sum =3D in6_cksum(m, IPPROTO_TCP, off0, = tlen); > - if (th->th_sum) { > + > + if ((m->m_pkthdr.csum_flags & = (CSUM_L4_CALC|CSUM_L4_VALID)) =3D=3D > + CSUM_L4_CALC) { > + TCPSTAT_INC(tcps_rcvbadsum); > + goto drop; > + } else if (!(m->m_pkthdr.csum_flags & CSUM_L4_VALID) && > + in6_cksum(m, IPPROTO_TCP, off0, tlen)) { > TCPSTAT_INC(tcps_rcvbadsum); > goto drop; > } > @@ -666,16 +663,11 @@ tcp_input(struct mbuf *m, int off0) > th =3D (struct tcphdr *)((caddr_t)ip + off0); > tlen =3D ntohs(ip->ip_len) - off0; >=20 > - if (m->m_pkthdr.csum_flags & CSUM_DATA_VALID) { > - if (m->m_pkthdr.csum_flags & CSUM_PSEUDO_HDR) > - th->th_sum =3D m->m_pkthdr.csum_data; > - else > - th->th_sum =3D = in_pseudo(ip->ip_src.s_addr, > - ip->ip_dst.s_addr, > - htonl(m->m_pkthdr.csum_data + tlen + > - IPPROTO_TCP)); > - th->th_sum ^=3D 0xffff; > - } else { > + if ((m->m_pkthdr.csum_flags & = (CSUM_L4_CALC|CSUM_L4_VALID)) =3D=3D > + CSUM_L4_CALC) { > + TCPSTAT_INC(tcps_rcvbadsum); > + goto drop; > + } else if (!(m->m_pkthdr.csum_flags & CSUM_L4_VALID)) { > struct ipovly *ipov =3D (struct ipovly *)ip; >=20 > /* > @@ -685,10 +677,11 @@ tcp_input(struct mbuf *m, int off0) > bzero(ipov->ih_x1, sizeof(ipov->ih_x1)); > ipov->ih_len =3D htons(tlen); > th->th_sum =3D in_cksum(m, len); > - } > - if (th->th_sum) { > - TCPSTAT_INC(tcps_rcvbadsum); > - goto drop; > + > + if (th->th_sum) { > + TCPSTAT_INC(tcps_rcvbadsum); > + goto drop; > + } > } > /* Re-initialization for later version check */ > ip->ip_v =3D IPVERSION; > @@ -3610,7 +3603,7 @@ tcp_mss(struct tcpcb *tp, int offer) > SOCKBUF_UNLOCK(&so->so_rcv); >=20 > /* Check the interface for TSO capabilities. */ > - if (mtuflags & CSUM_TSO) > + if (mtuflags & CSUM_IP_TSO) > tp->t_flags |=3D TF_TSO; > } >=20 >=20 > Modified: user/andre/tcp_workqueue/sys/netinet/tcp_lro.c > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- user/andre/tcp_workqueue/sys/netinet/tcp_lro.c Mon Nov 19 = 17:33:45 2012 (r243290) > +++ user/andre/tcp_workqueue/sys/netinet/tcp_lro.c Mon Nov 19 = 18:04:17 2012 (r243291) > @@ -211,8 +211,8 @@ tcp_lro_flush(struct lro_ctrl *lc, struc > ip6 =3D le->le_ip6; > ip6->ip6_plen =3D p_len; > th =3D (struct tcphdr *)(ip6 + 1); > - le->m_head->m_pkthdr.csum_flags =3D = CSUM_DATA_VALID | > - CSUM_PSEUDO_HDR; > + le->m_head->m_pkthdr.csum_flags =3D CSUM_L4_CALC = | > + CSUM_L4_VALID; > le->p_len +=3D ETHER_HDR_LEN + sizeof(*ip6); > break; > } > @@ -242,8 +242,8 @@ tcp_lro_flush(struct lro_ctrl *lc, struc > #endif > ip4->ip_len =3D p_len; > th =3D (struct tcphdr *)(ip4 + 1); > - le->m_head->m_pkthdr.csum_flags =3D = CSUM_DATA_VALID | > - CSUM_PSEUDO_HDR | CSUM_IP_CHECKED | = CSUM_IP_VALID; > + le->m_head->m_pkthdr.csum_flags =3D CSUM_L4_CALC = | > + CSUM_L4_VALID | CSUM_L3_CALC | = CSUM_L3_VALID; > le->p_len +=3D ETHER_HDR_LEN; > break; > } > @@ -310,7 +310,6 @@ static int > tcp_lro_rx_ipv4(struct lro_ctrl *lc, struct mbuf *m, struct ip *ip4, > struct tcphdr **th) > { > - int csum_flags; > uint16_t csum; >=20 > if (ip4->ip_p !=3D IPPROTO_TCP) > @@ -325,18 +324,17 @@ tcp_lro_rx_ipv4(struct lro_ctrl *lc, str > return (TCP_LRO_CANNOT); >=20 > /* Legacy IP has a header checksum that needs to be correct. */ > - csum_flags =3D m->m_pkthdr.csum_flags; > - if (csum_flags & CSUM_IP_CHECKED) { > - if (__predict_false((csum_flags & CSUM_IP_VALID) =3D=3D = 0)) { > - lc->lro_bad_csum++; > - return (TCP_LRO_CANNOT); > - } > - } else { > + if ((m->m_pkthdr.csum_flags & (CSUM_L3_CALC | CSUM_L3_VALID)) =3D=3D= > + CSUM_L3_CALC) { > + lc->lro_bad_csum++; > + return (TCP_LRO_CANNOT); > + } else if (!(m->m_pkthdr.csum_flags & CSUM_L3_VALID)) { > csum =3D in_cksum_hdr(ip4); > if (__predict_false((csum ^ 0xffff) !=3D 0)) { > lc->lro_bad_csum++; > return (TCP_LRO_CANNOT); > } > + m->m_pkthdr.csum_flags |=3D (CSUM_L3_CALC | = CSUM_L3_VALID); > } >=20 > /* Find the TCP header (we assured there are no IP options). */ >=20 > Modified: user/andre/tcp_workqueue/sys/netinet/tcp_output.c > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- user/andre/tcp_workqueue/sys/netinet/tcp_output.c Mon Nov 19 = 17:33:45 2012 (r243290) > +++ user/andre/tcp_workqueue/sys/netinet/tcp_output.c Mon Nov 19 = 18:04:17 2012 (r243291) > @@ -1085,7 +1085,7 @@ send: > * ip6_plen is not need to be filled now, and will be = filled > * in ip6_output. > */ > - m->m_pkthdr.csum_flags =3D CSUM_TCP_IPV6; > + m->m_pkthdr.csum_flags =3D CSUM_IP6_TCP; > th->th_sum =3D in6_cksum_pseudo(ip6, sizeof(struct = tcphdr) + > optlen + len, IPPROTO_TCP, 0); > } > @@ -1095,7 +1095,7 @@ send: > #endif > #ifdef INET > { > - m->m_pkthdr.csum_flags =3D CSUM_TCP; > + m->m_pkthdr.csum_flags =3D CSUM_IP_TCP; > th->th_sum =3D in_pseudo(ip->ip_src.s_addr, = ip->ip_dst.s_addr, > htons(sizeof(struct tcphdr) + IPPROTO_TCP + len + = optlen)); >=20 > @@ -1113,7 +1113,10 @@ send: > if (tso) { > KASSERT(len > tp->t_maxopd - optlen, > ("%s: len <=3D tso_segsz", __func__)); > - m->m_pkthdr.csum_flags |=3D CSUM_TSO; > + if (isipv6) > + m->m_pkthdr.csum_flags |=3D CSUM_IP6_TSO; > + else > + m->m_pkthdr.csum_flags |=3D CSUM_IP_TSO; > m->m_pkthdr.tso_segsz =3D tp->t_maxopd - optlen; > } >=20 >=20 > Modified: user/andre/tcp_workqueue/sys/netinet/tcp_subr.c > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- user/andre/tcp_workqueue/sys/netinet/tcp_subr.c Mon Nov 19 = 17:33:45 2012 (r243290) > +++ user/andre/tcp_workqueue/sys/netinet/tcp_subr.c Mon Nov 19 = 18:04:17 2012 (r243291) > @@ -623,12 +623,10 @@ tcp_respond(struct tcpcb *tp, void *ipge > nth->th_win =3D htons((u_short)win); > nth->th_urp =3D 0; >=20 > - m->m_pkthdr.csum_data =3D offsetof(struct tcphdr, th_sum); > + m->m_pkthdr.csum_l4hlen =3D sizeof(struct tcphdr); > #ifdef INET6 > if (isipv6) { > - m->m_pkthdr.csum_flags =3D CSUM_TCP_IPV6; > - nth->th_sum =3D in6_cksum_pseudo(ip6, > - tlen - sizeof(struct ip6_hdr), IPPROTO_TCP, 0); > + m->m_pkthdr.csum_flags =3D CSUM_IP6_TCP; > ip6->ip6_hlim =3D in6_selecthlim(tp !=3D NULL ? = tp->t_inpcb : > NULL, NULL); > } > @@ -638,9 +636,7 @@ tcp_respond(struct tcpcb *tp, void *ipge > #endif > #ifdef INET > { > - m->m_pkthdr.csum_flags =3D CSUM_TCP; > - nth->th_sum =3D in_pseudo(ip->ip_src.s_addr, = ip->ip_dst.s_addr, > - htons((u_short)(tlen - sizeof(struct ip) + = ip->ip_p))); > + m->m_pkthdr.csum_flags =3D CSUM_IP_TCP; > } > #endif /* INET */ > #ifdef TCPDEBUG > @@ -1744,8 +1740,8 @@ tcp_maxmtu(struct in_conninfo *inc, int=20 > /* Report additional interface capabilities. */ > if (flags !=3D NULL) { > if (ifp->if_capenable & IFCAP_TSO4 && > - ifp->if_hwassist & CSUM_TSO) > - *flags |=3D CSUM_TSO; > + ifp->if_hwassist & CSUM_IP_TSO) > + *flags |=3D CSUM_IP_TSO; > } > RTFREE(sro.ro_rt); > } > @@ -1781,8 +1777,8 @@ tcp_maxmtu6(struct in_conninfo *inc, int > /* Report additional interface capabilities. */ > if (flags !=3D NULL) { > if (ifp->if_capenable & IFCAP_TSO6 && > - ifp->if_hwassist & CSUM_TSO) > - *flags |=3D CSUM_TSO; > + ifp->if_hwassist & CSUM_IP6_TSO) > + *flags |=3D CSUM_IP6_TSO; > } > RTFREE(sro6.ro_rt); > } >=20 > Modified: user/andre/tcp_workqueue/sys/netinet/tcp_syncache.c > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- user/andre/tcp_workqueue/sys/netinet/tcp_syncache.c Mon Nov = 19 17:33:45 2012 (r243290) > +++ user/andre/tcp_workqueue/sys/netinet/tcp_syncache.c Mon Nov = 19 18:04:17 2012 (r243291) > @@ -1509,12 +1509,10 @@ syncache_respond(struct syncache *sc) > optlen =3D 0; >=20 > M_SETFIB(m, sc->sc_inc.inc_fibnum); > - m->m_pkthdr.csum_data =3D offsetof(struct tcphdr, th_sum); > + m->m_pkthdr.csum_l4hlen =3D sizeof(struct tcphdr) + optlen; > #ifdef INET6 > if (sc->sc_inc.inc_flags & INC_ISIPV6) { > - m->m_pkthdr.csum_flags =3D CSUM_TCP_IPV6; > - th->th_sum =3D in6_cksum_pseudo(ip6, tlen + optlen - = hlen, > - IPPROTO_TCP, 0); > + m->m_pkthdr.csum_flags =3D CSUM_IP6_TCP; > ip6->ip6_hlim =3D in6_selecthlim(NULL, NULL); > error =3D ip6_output(m, NULL, NULL, 0, NULL, NULL, = NULL); > } > @@ -1524,9 +1522,7 @@ syncache_respond(struct syncache *sc) > #endif > #ifdef INET > { > - m->m_pkthdr.csum_flags =3D CSUM_TCP; > - th->th_sum =3D in_pseudo(ip->ip_src.s_addr, = ip->ip_dst.s_addr, > - htons(tlen + optlen - hlen + IPPROTO_TCP)); > + m->m_pkthdr.csum_flags =3D CSUM_IP_TCP; > #ifdef TCP_OFFLOAD > if (ADDED_BY_TOE(sc)) { > struct toedev *tod =3D sc->sc_tod; >=20 > Modified: user/andre/tcp_workqueue/sys/netinet/tcp_timewait.c > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- user/andre/tcp_workqueue/sys/netinet/tcp_timewait.c Mon Nov = 19 17:33:45 2012 (r243290) > +++ user/andre/tcp_workqueue/sys/netinet/tcp_timewait.c Mon Nov = 19 18:04:17 2012 (r243291) > @@ -575,12 +575,10 @@ tcp_twrespond(struct tcptw *tw, int flag > th->th_flags =3D flags; > th->th_win =3D htons(tw->last_win); >=20 > - m->m_pkthdr.csum_data =3D offsetof(struct tcphdr, th_sum); > + m->m_pkthdr.csum_l4hlen =3D sizeof(struct tcphdr) + optlen; > #ifdef INET6 > if (isipv6) { > - m->m_pkthdr.csum_flags =3D CSUM_TCP_IPV6; > - th->th_sum =3D in6_cksum_pseudo(ip6, > - sizeof(struct tcphdr) + optlen, IPPROTO_TCP, 0); > + m->m_pkthdr.csum_flags =3D CSUM_IP6_TCP; > ip6->ip6_hlim =3D in6_selecthlim(inp, NULL); > error =3D ip6_output(m, inp->in6p_outputopts, NULL, > (tw->tw_so_options & SO_DONTROUTE), NULL, NULL, = inp); > @@ -591,9 +589,7 @@ tcp_twrespond(struct tcptw *tw, int flag > #endif > #ifdef INET > { > - m->m_pkthdr.csum_flags =3D CSUM_TCP; > - th->th_sum =3D in_pseudo(ip->ip_src.s_addr, = ip->ip_dst.s_addr, > - htons(sizeof(struct tcphdr) + optlen + = IPPROTO_TCP)); > + m->m_pkthdr.csum_flags =3D CSUM_IP_TCP; > ip->ip_len =3D htons(m->m_pkthdr.len); > if (V_path_mtu_discovery) > ip->ip_off |=3D htons(IP_DF); >=20 > Modified: user/andre/tcp_workqueue/sys/netinet/udp_usrreq.c > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- user/andre/tcp_workqueue/sys/netinet/udp_usrreq.c Mon Nov 19 = 17:33:45 2012 (r243290) > +++ user/andre/tcp_workqueue/sys/netinet/udp_usrreq.c Mon Nov 19 = 18:04:17 2012 (r243291) > @@ -410,19 +410,15 @@ udp_input(struct mbuf *m, int off) >=20 > /* > * Checksum extended UDP header and data. > + * NB: UDP doesn't require the checksum to be present. > */ > if (uh->uh_sum) { > - u_short uh_sum; > + u_short uh_sum =3D 0; >=20 > - if (m->m_pkthdr.csum_flags & CSUM_DATA_VALID) { > - if (m->m_pkthdr.csum_flags & CSUM_PSEUDO_HDR) > - uh_sum =3D m->m_pkthdr.csum_data; > - else > - uh_sum =3D in_pseudo(ip->ip_src.s_addr, > - ip->ip_dst.s_addr, = htonl((u_short)len + > - m->m_pkthdr.csum_data + = IPPROTO_UDP)); > - uh_sum ^=3D 0xffff; > - } else { > + if ((m->m_pkthdr.csum_flags & = (CSUM_L4_CALC|CSUM_L4_VALID)) =3D=3D > + CSUM_L4_CALC) { > + uh_sum =3D 0x1; /* Failed checksum check. */ > + } else if (!(m->m_pkthdr.csum_flags & CSUM_L4_VALID)) { > char b[9]; >=20 > bcopy(((struct ipovly *)ip)->ih_x1, b, 9); > @@ -1226,7 +1222,7 @@ udp_output(struct inpcb *inp, struct mbu > faddr.s_addr =3D INADDR_BROADCAST; > ui->ui_sum =3D in_pseudo(ui->ui_src.s_addr, = faddr.s_addr, > htons((u_short)len + sizeof(struct udphdr) + = IPPROTO_UDP)); > - m->m_pkthdr.csum_flags =3D CSUM_UDP; > + m->m_pkthdr.csum_flags =3D CSUM_IP_UDP; > m->m_pkthdr.csum_l4hlen =3D sizeof(struct udphdr); > } else > ui->ui_sum =3D 0; > @@ -1387,8 +1383,8 @@ udp4_espdecap(struct inpcb *inp, struct=20 > * We cannot yet update the cksums so clear any > * h/w cksum flags as they are no longer valid. > */ > - if (m->m_pkthdr.csum_flags & CSUM_DATA_VALID) > - m->m_pkthdr.csum_flags &=3D = ~(CSUM_DATA_VALID|CSUM_PSEUDO_HDR); > + if (m->m_pkthdr.csum_flags & CSUM_L4_CALC) > + m->m_pkthdr.csum_flags &=3D = ~(CSUM_L4_CALC|CSUM_L4_VALID); >=20 > (void) ipsec4_common_input(m, iphlen, ip->ip_p); > return (NULL); /* NB: consumed, bypass = processing. */ >=20 > Modified: user/andre/tcp_workqueue/sys/netinet6/ip6_forward.c > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- user/andre/tcp_workqueue/sys/netinet6/ip6_forward.c Mon Nov = 19 17:33:45 2012 (r243290) > +++ user/andre/tcp_workqueue/sys/netinet6/ip6_forward.c Mon Nov = 19 18:04:17 2012 (r243291) > @@ -577,14 +577,16 @@ skip_routing: > m->m_flags |=3D M_FASTFWD_OURS; > if (m->m_pkthdr.rcvif =3D=3D NULL) > m->m_pkthdr.rcvif =3D V_loif; > - if (m->m_pkthdr.csum_flags & = CSUM_DELAY_DATA_IPV6) { > + if (m->m_pkthdr.csum_flags & > + (CSUM_IP6_UDP|CSUM_IP6_TCP)) { > m->m_pkthdr.csum_flags |=3D > - CSUM_DATA_VALID_IPV6 | = CSUM_PSEUDO_HDR; > + CSUM_L4_CALC | CSUM_L4_VALID; > m->m_pkthdr.csum_data =3D 0xffff; > } > #ifdef SCTP > - if (m->m_pkthdr.csum_flags & CSUM_SCTP_IPV6) > - m->m_pkthdr.csum_flags |=3D = CSUM_SCTP_VALID; > + if (m->m_pkthdr.csum_flags & CSUM_IP6_SCTP) > + m->m_pkthdr.csum_flags |=3D > + CSUM_L4_CALC | CSUM_L4_VALID; > #endif > error =3D netisr_queue(NETISR_IPV6, m); > goto out; > @@ -596,14 +598,13 @@ skip_routing: > if (m->m_flags & M_FASTFWD_OURS) { > if (m->m_pkthdr.rcvif =3D=3D NULL) > m->m_pkthdr.rcvif =3D V_loif; > - if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA_IPV6) { > - m->m_pkthdr.csum_flags |=3D > - CSUM_DATA_VALID_IPV6 | CSUM_PSEUDO_HDR; > + if (m->m_pkthdr.csum_flags & = (CSUM_IP6_UDP|CSUM_IP6_TCP)) { > + m->m_pkthdr.csum_flags |=3D CSUM_L4_CALC | = CSUM_L4_VALID; > m->m_pkthdr.csum_data =3D 0xffff; > } > #ifdef SCTP > - if (m->m_pkthdr.csum_flags & CSUM_SCTP_IPV6) > - m->m_pkthdr.csum_flags |=3D CSUM_SCTP_VALID; > + if (m->m_pkthdr.csum_flags & CSUM_IP6_SCTP) > + m->m_pkthdr.csum_flags |=3D CSUM_L4_CALC | = CSUM_L4_VALID; > #endif > error =3D netisr_queue(NETISR_IPV6, m); > goto out; >=20 > Modified: user/andre/tcp_workqueue/sys/netinet6/ip6_ipsec.c > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- user/andre/tcp_workqueue/sys/netinet6/ip6_ipsec.c Mon Nov 19 = 17:33:45 2012 (r243290) > +++ user/andre/tcp_workqueue/sys/netinet6/ip6_ipsec.c Mon Nov 19 = 18:04:17 2012 (r243291) > @@ -288,11 +288,11 @@ ip6_ipsec_output(struct mbuf **m, struct > * For IPv6 we do delayed checksums in ip6_output.c. > */ > #ifdef INET > - if ((*m)->m_pkthdr.csum_flags & CSUM_DELAY_DATA) { > + if ((*m)->m_pkthdr.csum_flags & = (CSUM_IP_UDP|CSUM_IP_TCP)) { > ipseclog((LOG_DEBUG, > "%s: we do not support IPv4 over IPv6", = __func__)); > in_delayed_cksum(*m); > - (*m)->m_pkthdr.csum_flags &=3D ~CSUM_DELAY_DATA; > + (*m)->m_pkthdr.csum_flags &=3D = ~(CSUM_IP_UDP|CSUM_IP_TCP); > } > #endif >=20 >=20 > Modified: user/andre/tcp_workqueue/sys/netinet6/ip6_output.c > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- user/andre/tcp_workqueue/sys/netinet6/ip6_output.c Mon Nov = 19 17:33:45 2012 (r243290) > +++ user/andre/tcp_workqueue/sys/netinet6/ip6_output.c Mon Nov = 19 18:04:17 2012 (r243291) > @@ -307,15 +307,15 @@ ip6_output(struct mbuf *m0, struct ip6_p > /* > * Do delayed checksums now, as we may send before = returning. > */ > - if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA_IPV6) { > + if (m->m_pkthdr.csum_flags & = (CSUM_IP6_UDP|CSUM_IP6_TCP)) { > plen =3D m->m_pkthdr.len - sizeof(*ip6); > in6_delayed_cksum(m, plen, sizeof(struct = ip6_hdr)); > - m->m_pkthdr.csum_flags &=3D = ~CSUM_DELAY_DATA_IPV6; > + m->m_pkthdr.csum_flags &=3D = ~(CSUM_IP6_UDP|CSUM_IP6_TCP); > } > #ifdef SCTP > - if (m->m_pkthdr.csum_flags & CSUM_SCTP_IPV6) { > + if (m->m_pkthdr.csum_flags & CSUM_IP6_SCTP) { > sctp_delayed_cksum(m, sizeof(struct ip6_hdr)); > - m->m_pkthdr.csum_flags &=3D ~CSUM_SCTP_IPV6; > + m->m_pkthdr.csum_flags &=3D ~CSUM_IP6_SCTP; > } > #endif > case 0: /* No IPSec */ > @@ -898,14 +898,16 @@ again: > m->m_flags |=3D M_FASTFWD_OURS; > if (m->m_pkthdr.rcvif =3D=3D NULL) > m->m_pkthdr.rcvif =3D V_loif; > - if (m->m_pkthdr.csum_flags & = CSUM_DELAY_DATA_IPV6) { > + if (m->m_pkthdr.csum_flags & > + (CSUM_IP6_UDP|CSUM_IP6_TCP)) { > m->m_pkthdr.csum_flags |=3D > - CSUM_DATA_VALID_IPV6 | = CSUM_PSEUDO_HDR; > + CSUM_L4_CALC | CSUM_L4_VALID; > m->m_pkthdr.csum_data =3D 0xffff; > } > #ifdef SCTP > if (m->m_pkthdr.csum_flags & CSUM_SCTP_IPV6) > - m->m_pkthdr.csum_flags |=3D = CSUM_SCTP_VALID; > + m->m_pkthdr.csum_flags |=3D > + CSUM_L4_CALC | CSUM_L4_VALID; > #endif > error =3D netisr_queue(NETISR_IPV6, m); > goto done; > @@ -917,14 +919,14 @@ again: > if (m->m_flags & M_FASTFWD_OURS) { > if (m->m_pkthdr.rcvif =3D=3D NULL) > m->m_pkthdr.rcvif =3D V_loif; > - if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA_IPV6) { > + if (m->m_pkthdr.csum_flags & = (CSUM_IP6_UDP|CSUM_IP6_TCP)) { > m->m_pkthdr.csum_flags |=3D > - CSUM_DATA_VALID_IPV6 | CSUM_PSEUDO_HDR; > + CSUM_L4_CALC | CSUM_L4_VALID; > m->m_pkthdr.csum_data =3D 0xffff; > } > #ifdef SCTP > if (m->m_pkthdr.csum_flags & CSUM_SCTP_IPV6) > - m->m_pkthdr.csum_flags |=3D CSUM_SCTP_VALID; > + m->m_pkthdr.csum_flags |=3D CSUM_L4_CALC | = CSUM_L4_VALID; > #endif > error =3D netisr_queue(NETISR_IPV6, m); > goto done; > @@ -972,13 +974,13 @@ passout: > * XXX-BZ Need a framework to know when the NIC can handle it, = even > * with ext. hdrs. > */ > - if (sw_csum & CSUM_DELAY_DATA_IPV6) { > - sw_csum &=3D ~CSUM_DELAY_DATA_IPV6; > + if (sw_csum & (CSUM_IP6_UDP|CSUM_IP6_TCP)) { > + sw_csum &=3D ~(CSUM_IP6_UDP|CSUM_IP6_TCP); > in6_delayed_cksum(m, plen, sizeof(struct ip6_hdr)); > } > #ifdef SCTP > - if (sw_csum & CSUM_SCTP_IPV6) { > - sw_csum &=3D ~CSUM_SCTP_IPV6; > + if (sw_csum & CSUM_IP6_SCTP) { > + sw_csum &=3D ~CSUM_IP6_SCTP; > sctp_delayed_cksum(m, sizeof(struct ip6_hdr)); > } > #endif > @@ -1091,14 +1093,14 @@ passout: > * fragmented packets, then do it here. > * XXX-BZ handle the hw offloading case. Need flags. > */ > - if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA_IPV6) { > + if (m->m_pkthdr.csum_flags & = (CSUM_IP6_UDP|CSUM_IP6_TCP)) { > in6_delayed_cksum(m, plen, hlen); > - m->m_pkthdr.csum_flags &=3D = ~CSUM_DELAY_DATA_IPV6; > + m->m_pkthdr.csum_flags &=3D = ~(CSUM_IP6_UDP|CSUM_IP6_TCP); > } > #ifdef SCTP > - if (m->m_pkthdr.csum_flags & CSUM_SCTP_IPV6) { > + if (m->m_pkthdr.csum_flags & CSUM_IP6_SCTP) { > sctp_delayed_cksum(m, hlen); > - m->m_pkthdr.csum_flags &=3D ~CSUM_SCTP_IPV6; > + m->m_pkthdr.csum_flags &=3D ~CSUM_IP6_SCTP; > } > #endif > mnext =3D &m->m_nextpkt; >=20 > Modified: user/andre/tcp_workqueue/sys/netinet6/sctp6_usrreq.c > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- user/andre/tcp_workqueue/sys/netinet6/sctp6_usrreq.c Mon Nov = 19 17:33:45 2012 (r243290) > +++ user/andre/tcp_workqueue/sys/netinet6/sctp6_usrreq.c Mon Nov = 19 18:04:17 2012 (r243291) > @@ -169,9 +169,15 @@ sctp6_input(struct mbuf **i_pak, int *of > #if defined(SCTP_WITH_NO_CSUM) > SCTP_STAT_INCR(sctps_recvnocrc); > #else > - if (m->m_pkthdr.csum_flags & CSUM_SCTP_VALID) { > + if ((m->m_pkthdr.csum_flags & (CSUM_L4_CALC|CSUM_L4_VALID)) =3D=3D= > + (CSUM_L4_CALC | CSUM_L4_VALID)) { > SCTP_STAT_INCR(sctps_recvhwcrc); > compute_crc =3D 0; > + } else if ((m->m_pkthdr.csum_flags & = (CSUM_L4_CALC|CSUM_L4_VALID)) =3D=3D > + CSUM_L4_CALC) { > + SCTP_STAT_INCR(sctps_badsum); > + SCTP_STAT_INCR_COUNTER32(sctps_checksumerrors); > + goto out; > } else { > SCTP_STAT_INCR(sctps_recvswcrc); > compute_crc =3D 1; >=20 > Modified: user/andre/tcp_workqueue/sys/netinet6/udp6_usrreq.c > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- user/andre/tcp_workqueue/sys/netinet6/udp6_usrreq.c Mon Nov = 19 17:33:45 2012 (r243290) > +++ user/andre/tcp_workqueue/sys/netinet6/udp6_usrreq.c Mon Nov = 19 18:04:17 2012 (r243291) > @@ -183,7 +183,7 @@ udp6_input(struct mbuf **mp, int *offp,=20 > int plen, ulen; > struct sockaddr_in6 fromsa; > struct m_tag *fwd_tag; > - uint16_t uh_sum; > + uint16_t uh_sum =3D 0; >=20 > ifp =3D m->m_pkthdr.rcvif; > ip6 =3D mtod(m, struct ip6_hdr *); > @@ -228,14 +228,10 @@ udp6_input(struct mbuf **mp, int *offp,=20 > goto badunlocked; > } >=20 > - if (m->m_pkthdr.csum_flags & CSUM_DATA_VALID_IPV6) { > - if (m->m_pkthdr.csum_flags & CSUM_PSEUDO_HDR) > - uh_sum =3D m->m_pkthdr.csum_data; > - else > - uh_sum =3D in6_cksum_pseudo(ip6, ulen, > - IPPROTO_UDP, m->m_pkthdr.csum_data); > - uh_sum ^=3D 0xffff; > - } else > + if ((m->m_pkthdr.csum_flags & (CSUM_L4_CALC|CSUM_L4_VALID)) =3D=3D= > + CSUM_L4_CALC) { > + uh_sum =3D 1; > + } else if (!(m->m_pkthdr.csum_flags & CSUM_L4_VALID)) > uh_sum =3D in6_cksum(m, IPPROTO_UDP, off, ulen); >=20 > if (uh_sum !=3D 0) { > @@ -780,8 +776,8 @@ udp6_output(struct inpcb *inp, struct mb > ip6->ip6_dst =3D *faddr; >=20 > udp6->uh_sum =3D in6_cksum_pseudo(ip6, plen, = IPPROTO_UDP, 0); > - m->m_pkthdr.csum_flags =3D CSUM_UDP_IPV6; > - m->m_pkthdr.csum_data =3D offsetof(struct udphdr, = uh_sum); > + m->m_pkthdr.csum_flags =3D CSUM_IP6_UDP; > + m->m_pkthdr.csum_l4hlen =3D sizeof(struct udphdr); >=20 > flags =3D 0; >=20 >=20 > *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** >=20 >=20 From owner-svn-src-user@FreeBSD.ORG Mon Nov 19 19:06:06 2012 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 05CE55C7 for ; Mon, 19 Nov 2012 19:06:06 +0000 (UTC) (envelope-from andre@freebsd.org) Received: from c00l3r.networx.ch (c00l3r.networx.ch [62.48.2.2]) by mx1.freebsd.org (Postfix) with ESMTP id 626048FC14 for ; Mon, 19 Nov 2012 19:06:04 +0000 (UTC) Received: (qmail 80820 invoked from network); 19 Nov 2012 20:39:08 -0000 Received: from c00l3r.networx.ch (HELO [127.0.0.1]) ([62.48.2.2]) (envelope-sender ) by c00l3r.networx.ch (qmail-ldap-1.03) with SMTP for ; 19 Nov 2012 20:39:08 -0000 Message-ID: <50AA831A.5000808@freebsd.org> Date: Mon, 19 Nov 2012 20:06:02 +0100 From: Andre Oppermann User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:16.0) Gecko/20121026 Thunderbird/16.0.2 MIME-Version: 1.0 To: Michael Tuexen Subject: Re: svn commit: r243291 - in user/andre/tcp_workqueue/sys: net netinet netinet6 netipsec netpfil/ipfw netpfil/pf References: <201211191804.qAJI4IXX014601@svn.freebsd.org> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: src-committers@freebsd.org, svn-src-user@freebsd.org X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Nov 2012 19:06:06 -0000 On 19.11.2012 19:57, Michael Tuexen wrote: > On Nov 19, 2012, at 7:04 PM, Andre Oppermann wrote: > >> Author: andre >> Date: Mon Nov 19 18:04:17 2012 >> New Revision: 243291 >> URL: http://svnweb.freebsd.org/changeset/base/243291 >> >> Log: >> Convert IP, IPv6, UDP, TCP and SCTP to the new checksum offloading >> semantics on the inbound and outbound path. >> >> In short for inbound there are two levels the offloading NIC can >> set: >> >> CSUM_L3_CALC for an IP layer 3 checksum calculated by the NIC; >> CSUM_L3_VALID set when the calculated checksum matches the one >> in the packet; >> CSUM_L4_CALC for an UDP/TCP/SCTP layer 4 checksum calculated by >> the NIC; >> CSUM_L4_VALID set when the calculated checksum matche the one >> in the packet. >> >> From this follows that a packet failed checksum verification when >> only *_CALC is set but not *_VALID. The NIC is expected to deliver >> a failed packet up the stack anyways for capture by BPF and to >> record protocol specific checksum mismatch statistics. >> >> The old approach with CSUM_DATA_VALID and CSUM_PSEUDO_HDR could not >> signal a failed packet. A failed packet was delivered into the stack >> and the protocol had to recalculate the checksum for verification >> every time to detect that as the absence of CSUM_DATA_VALID didn't >> signal that the packet was broken. It was only saying that the >> checksum wasn't calculated by the NIC, which actually wasn't the case. >> >> Drag the other stack infrastructure, including packet filters, along >> as well. > I looked at the code for SCTP. If the NIC reports that it computed the > checksum and the checksum is not reported as valid, you are dropping the > packet. The problem with this code is, that at least some NICs report > for small SCTP packets that the checksum is wrong. To deal with this, > I did the checksum verification is software in case the hardware reported > a bad checksum. Are you planning to deal with this in the specific drivers? Yes, in that case the definition is that the driver must not set CSUM_L4_CALC and CSUM_L4_VALID so the protocol can calculated the checksum itself. If it is known that, for example, packets shorter than 128 bytes are not correctly calculated by hardware the driver must check for that when it sets the checksum flags. Do you have a list of NICs that are broken with SCTP/CRC32c in particular cases? It may be helpful to add an INVARIANTS case where the checksum is always recomputed by the protocol as well and compared with the outcome of the hardware calculation. That way we cancatch misbehaving NICs early on. -- Andre From owner-svn-src-user@FreeBSD.ORG Mon Nov 19 20:23:56 2012 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 47074EAB; Mon, 19 Nov 2012 20:23:56 +0000 (UTC) (envelope-from tuexen@fh-muenster.de) Received: from mail-n.franken.de (drew.ipv6.franken.de [IPv6:2001:638:a02:a001:20e:cff:fe4a:feaa]) by mx1.freebsd.org (Postfix) with ESMTP id A44D18FC0C; Mon, 19 Nov 2012 20:23:55 +0000 (UTC) Received: from [192.168.1.101] (p4FF52545.dip.t-dialin.net [79.245.37.69]) (Authenticated sender: macmic) by mail-n.franken.de (Postfix) with ESMTP id 6F62C1C0C069A; Mon, 19 Nov 2012 21:23:54 +0100 (CET) Subject: Re: svn commit: r243291 - in user/andre/tcp_workqueue/sys: net netinet netinet6 netipsec netpfil/ipfw netpfil/pf Mime-Version: 1.0 (Apple Message framework v1283) Content-Type: text/plain; charset=iso-8859-1 From: Michael Tuexen In-Reply-To: <50AA831A.5000808@freebsd.org> Date: Mon, 19 Nov 2012 21:23:53 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: <4973333F-FDA4-412E-91F2-64639BDB04A6@fh-muenster.de> References: <201211191804.qAJI4IXX014601@svn.freebsd.org> <50AA831A.5000808@freebsd.org> To: Andre Oppermann X-Mailer: Apple Mail (2.1283) Cc: src-committers@freebsd.org, svn-src-user@freebsd.org X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Nov 2012 20:23:56 -0000 On Nov 19, 2012, at 8:06 PM, Andre Oppermann wrote: > On 19.11.2012 19:57, Michael Tuexen wrote: >> On Nov 19, 2012, at 7:04 PM, Andre Oppermann wrote: >>=20 >>> Author: andre >>> Date: Mon Nov 19 18:04:17 2012 >>> New Revision: 243291 >>> URL: http://svnweb.freebsd.org/changeset/base/243291 >>>=20 >>> Log: >>> Convert IP, IPv6, UDP, TCP and SCTP to the new checksum offloading >>> semantics on the inbound and outbound path. >>>=20 >>> In short for inbound there are two levels the offloading NIC can >>> set: >>>=20 >>> CSUM_L3_CALC for an IP layer 3 checksum calculated by the = NIC; >>> CSUM_L3_VALID set when the calculated checksum matches the one >>> in the packet; >>> CSUM_L4_CALC for an UDP/TCP/SCTP layer 4 checksum calculated = by >>> the NIC; >>> CSUM_L4_VALID set when the calculated checksum matche the one >>> in the packet. >>>=20 >>> =46rom this follows that a packet failed checksum verification when >>> only *_CALC is set but not *_VALID. The NIC is expected to deliver >>> a failed packet up the stack anyways for capture by BPF and to >>> record protocol specific checksum mismatch statistics. >>>=20 >>> The old approach with CSUM_DATA_VALID and CSUM_PSEUDO_HDR could not >>> signal a failed packet. A failed packet was delivered into the = stack >>> and the protocol had to recalculate the checksum for verification >>> every time to detect that as the absence of CSUM_DATA_VALID didn't >>> signal that the packet was broken. It was only saying that the >>> checksum wasn't calculated by the NIC, which actually wasn't the = case. >>>=20 >>> Drag the other stack infrastructure, including packet filters, = along >>> as well. >> I looked at the code for SCTP. If the NIC reports that it computed = the >> checksum and the checksum is not reported as valid, you are dropping = the >> packet. The problem with this code is, that at least some NICs report >> for small SCTP packets that the checksum is wrong. To deal with this, >> I did the checksum verification is software in case the hardware = reported >> a bad checksum. Are you planning to deal with this in the specific = drivers? >=20 > Yes, in that case the definition is that the driver must not set > CSUM_L4_CALC and CSUM_L4_VALID so the protocol can calculated the > checksum itself. If it is known that, for example, packets shorter > than 128 bytes are not correctly calculated by hardware the driver > must check for that when it sets the checksum flags. >=20 > Do you have a list of NICs that are broken with SCTP/CRC32c in > particular cases? If I remember correctly, igb with packets up to 64 bytes (such there is final ethernet padding). >=20 > It may be helpful to add an INVARIANTS case where the checksum is > always recomputed by the protocol as well and compared with the > outcome of the hardware calculation. That way we cancatch misbehaving > NICs early on. Not sure we need this. In case the driver reports the checksum as bad and the transport layer will drop the packet, the connection will = eventually break. We also have counters... So it should show up during testing. Best regards Michael >=20 > --=20 > Andre >=20 >=20 From owner-svn-src-user@FreeBSD.ORG Tue Nov 20 15:19:56 2012 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id F016C7CF; Tue, 20 Nov 2012 15:19:55 +0000 (UTC) (envelope-from andre@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id D195E8FC13; Tue, 20 Nov 2012 15:19:55 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qAKFJt8H044504; Tue, 20 Nov 2012 15:19:55 GMT (envelope-from andre@svn.freebsd.org) Received: (from andre@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qAKFJt0J044503; Tue, 20 Nov 2012 15:19:55 GMT (envelope-from andre@svn.freebsd.org) Message-Id: <201211201519.qAKFJt0J044503@svn.freebsd.org> From: Andre Oppermann Date: Tue, 20 Nov 2012 15:19:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r243338 - user/andre/tcp_workqueue/sys/contrib/ipfilter/netinet X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Nov 2012 15:19:56 -0000 Author: andre Date: Tue Nov 20 15:19:55 2012 New Revision: 243338 URL: http://svnweb.freebsd.org/changeset/base/243338 Log: Adjust IPFILTER to the updated checksum definitions. Modified: user/andre/tcp_workqueue/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c Modified: user/andre/tcp_workqueue/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c ============================================================================== --- user/andre/tcp_workqueue/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c Tue Nov 20 14:11:27 2012 (r243337) +++ user/andre/tcp_workqueue/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c Tue Nov 20 15:19:55 2012 (r243338) @@ -1332,7 +1332,7 @@ fr_info_t *fin; INLINE void fr_checkv4sum(fin) fr_info_t *fin; { -#ifdef CSUM_DATA_VALID +#ifdef CSUM_L4_VALID int manual = 0; u_short sum; ip_t *ip; @@ -1351,9 +1351,9 @@ fr_info_t *fin; } ip = fin->fin_ip; - if (m->m_pkthdr.csum_flags & CSUM_DATA_VALID) { - if (m->m_pkthdr.csum_flags & CSUM_PSEUDO_HDR) - sum = m->m_pkthdr.csum_data; + if (m->m_pkthdr.csum_flags & CSUM_L4_CALC) { + if (m->m_pkthdr.csum_flags & CSUM_L4_VALID) + sum = 0xffff; else sum = in_pseudo(ip->ip_src.s_addr, ip->ip_dst.s_addr, htonl(m->m_pkthdr.csum_data + From owner-svn-src-user@FreeBSD.ORG Tue Nov 20 17:02:34 2012 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 8F8D1750; Tue, 20 Nov 2012 17:02:34 +0000 (UTC) (envelope-from andre@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 5B4858FC0C; Tue, 20 Nov 2012 17:02:34 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qAKH2YSL059272; Tue, 20 Nov 2012 17:02:34 GMT (envelope-from andre@svn.freebsd.org) Received: (from andre@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qAKH2YEm059270; Tue, 20 Nov 2012 17:02:34 GMT (envelope-from andre@svn.freebsd.org) Message-Id: <201211201702.qAKH2YEm059270@svn.freebsd.org> From: Andre Oppermann Date: Tue, 20 Nov 2012 17:02:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r243343 - user/andre/tcp_workqueue/sys/sys X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Nov 2012 17:02:34 -0000 Author: andre Date: Tue Nov 20 17:02:33 2012 New Revision: 243343 URL: http://svnweb.freebsd.org/changeset/base/243343 Log: Fix a couple of CSUM_* definitions and comment out unused compatility definitions. Modified: user/andre/tcp_workqueue/sys/sys/mbuf.h Modified: user/andre/tcp_workqueue/sys/sys/mbuf.h ============================================================================== --- user/andre/tcp_workqueue/sys/sys/mbuf.h Tue Nov 20 15:45:48 2012 (r243342) +++ user/andre/tcp_workqueue/sys/sys/mbuf.h Tue Nov 20 17:02:33 2012 (r243343) @@ -342,7 +342,7 @@ struct mbuf { */ /* Inbound flags. */ -#define MCSUM_INFLAGS(m) ((m)->csum_flags & \ +#define MCSUM_INFLAGS(m) ((m)->m_pkthdr.csum_flags & \ 0xF0000000) #define CSUM_L3_CALC 0x10000000 /* IP hdr csum calculated */ @@ -351,7 +351,7 @@ struct mbuf { #define CSUM_L4_VALID 0x80000000 /* UDP/TCP/SCTP csum eq. calc. */ /* Outboud flags, tested against ifi_hwassist. */ -#define MCSUM_OUTFLAGS(m) ((m)->csum_flags & \ +#define MCSUM_OUTFLAGS(m) ((m)->m_pkthdr.csum_flags & \ 0x0FFFFFF0) /* IPv4 csum offload 0x0000---0 */ @@ -366,15 +366,15 @@ struct mbuf { #define CSUM_IP_SCO 0x00000890 /* SCTP chunking offload */ /* IPv6 csum offload 0x0---0000 */ - /* IPv6 hdr has no csum */ -#define CSUM_IP6_UDP 0x00020000 /* will csum IPv6/UDP */ -#define CSUM_IP6_TCP 0x00040000 /* will csum IPv6/TCP */ -#define CSUM_IP6_SCTP 0x00080000 /* will csum IPv6/SCTP */ +#define CSUM_IP6 0x00010000 /* NB: IPv6 hdr has no csum */ +#define CSUM_IP6_UDP 0x00030000 /* will csum IPv6/UDP */ +#define CSUM_IP6_TCP 0x00050000 /* will csum IPv6/TCP */ +#define CSUM_IP6_SCTP 0x00090000 /* will csum IPv6/SCTP */ #define CSUM_IP6_FRAGO 0x00200000 /* IPv6 frag */ #define CSUM_IP6_UFO 0x00220000 /* IPv6/UFO */ #define CSUM_IP6_TSO 0x00440000 /* IPv6/TSO */ -#define CSUM_IP6_SCO 0x00880000 * SCTP chunk offload */ +#define CSUM_IP6_SCO 0x00880000 /* SCTP chunk offload */ /* Definition compatiblity with < 20121118, goes away after tree pruning */ #define CSUM_UDP CSUM_IP_UDP @@ -386,6 +386,7 @@ struct mbuf { #define CSUM_TCP_IPV6 CSUM_IP6_TCP /* will csum IPv6/TCP */ #define CSUM_SCTP_IPV6 CSUM_IP6_SCTP /* will csum IPv6/SCTP */ +#if 0 #define CSUM_IP_CHECKED CSUM_L3_CALC /* did csum IP */ #define CSUM_IP_VALID CSUM_L3_VALID /* ... the csum is valid */ #define CSUM_DATA_VALID CSUM_L4_VALID /* csum_data field is valid */ @@ -396,6 +397,7 @@ struct mbuf { #define CSUM_DATA_VALID_IPV6 CSUM_DATA_VALID #define CSUM_DELAY_DATA (CSUM_TCP | CSUM_UDP) #define CSUM_DELAY_IP (CSUM_IP) +#endif /* * mbuf types. From owner-svn-src-user@FreeBSD.ORG Tue Nov 20 17:04:53 2012 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 8B53E8A6; Tue, 20 Nov 2012 17:04:53 +0000 (UTC) (envelope-from andre@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 666F78FC0C; Tue, 20 Nov 2012 17:04:53 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qAKH4rPA059672; Tue, 20 Nov 2012 17:04:53 GMT (envelope-from andre@svn.freebsd.org) Received: (from andre@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qAKH4r8c059671; Tue, 20 Nov 2012 17:04:53 GMT (envelope-from andre@svn.freebsd.org) Message-Id: <201211201704.qAKH4r8c059671@svn.freebsd.org> From: Andre Oppermann Date: Tue, 20 Nov 2012 17:04:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r243344 - user/andre/tcp_workqueue/sys/kern X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Nov 2012 17:04:53 -0000 Author: andre Date: Tue Nov 20 17:04:52 2012 New Revision: 243344 URL: http://svnweb.freebsd.org/changeset/base/243344 Log: Add CSUM flags checking to m_sanity() to test for flags and parameter integrity. Advanced protocol specific tests for header length validation are not yet complete and commented out. Modified: user/andre/tcp_workqueue/sys/kern/uipc_mbuf.c Modified: user/andre/tcp_workqueue/sys/kern/uipc_mbuf.c ============================================================================== --- user/andre/tcp_workqueue/sys/kern/uipc_mbuf.c Tue Nov 20 17:02:33 2012 (r243343) +++ user/andre/tcp_workqueue/sys/kern/uipc_mbuf.c Tue Nov 20 17:04:52 2012 (r243344) @@ -420,6 +420,220 @@ m_sanity(struct mbuf *m0, int sanitize) else M_SANITY_ACTION("m_pkthdr.len != mbuf chain length"); } + + /* + * Verify the integrity of the checksum and offload parameters. + */ + if (m->m_pkthdr.csum_flags) { + int cflags = m->m_pkthdr.csum_flags; + + /* Mixing of in and outboud flags is not permitted. */ + if (MCSUM_INFLAGS(m) && MCSUM_OUTFLAGS(m)) + M_SANITY_ACTION("in and outbound csum flags present"); + + /* The inbound checksum flags must be consistent. */ + if ((cflags & (CSUM_L3_CALC|CSUM_L3_VALID)) == CSUM_L3_VALID) + M_SANITY_ACTION("CSUM_L3_VALID but not CSUM_L3_CALC"); + if ((cflags & (CSUM_L4_CALC|CSUM_L4_VALID)) == CSUM_L4_VALID) + M_SANITY_ACTION("CSUM_L4_VALID but not CSUM_L4_CALC"); + + /* + * Validate the l[2-4]hlen fields against first mbuf length. + * The headers must be present and contiguous in the first + * mbuf when offload capabilities are used. + */ + if (MCSUM_OUTFLAGS(m)) { + /* + * When seg/fragmentation offload is specified the + * segment size of the resulting packets is required. + */ + if (cflags & (CSUM_IP_UFO|CSUM_IP_TSO|CSUM_IP_SCO| + CSUM_IP6_UFO|CSUM_IP6_TSO|CSUM_IP6_SCO)) { + if (m->m_pkthdr.tso_segsz == 0) + M_SANITY_ACTION("unspecified tso_segsz"); + if (m->m_pkthdr.tso_segsz >= m->m_pkthdr.len) + M_SANITY_ACTION("tso_segsz >= pkthdr.len"); + } + /* The headers must be in the first mbuf. */ + if (m->m_len < m->m_pkthdr.csum_l2hlen) + M_SANITY_ACTION("csum_l2hlen > m_len"); + if (m->m_len < m->m_pkthdr.csum_l2hlen + + m->m_pkthdr.csum_l3hlen) + M_SANITY_ACTION("csum_l{2+3}hlen > m_len"); + if (m->m_len < m->m_pkthdr.csum_l2hlen + + m->m_pkthdr.csum_l3hlen + m->m_pkthdr.csum_l3hlen) + M_SANITY_ACTION("csum_l{2+3+4}hlen > m_len"); + } + + /* Layer 4 capabilities depend on lower layers. */ + if (cflags & (CSUM_IP_UFO|CSUM_IP_TSO|CSUM_IP_SCO)) { + if (!(cflags & CSUM_IP)) + M_SANITY_ACTION("IP offload w/o IP hdr csum"); + if ((cflags & (CSUM_IP_UFO|CSUM_IP_UDP)) != + (CSUM_IP_UFO|CSUM_IP_UDP)) + M_SANITY_ACTION("UDP frag offload w/o UDP csum"); + if ((cflags & (CSUM_IP_TSO|CSUM_IP_TCP)) != + (CSUM_IP_TSO|CSUM_IP_TCP)) + M_SANITY_ACTION("TCP seg offload w/o TCP csum"); + if ((cflags & (CSUM_IP_SCO|CSUM_IP_SCTP)) != + (CSUM_IP_SCO|CSUM_IP_SCTP)) + M_SANITY_ACTION("SCTP chunk offl w/o SCTP csum"); + } + if (cflags & (CSUM_IP6_UFO|CSUM_IP6_TSO|CSUM_IP6_SCO)) { + if ((cflags & (CSUM_IP6_UFO|CSUM_IP6_UDP)) != + (CSUM_IP6_UFO|CSUM_IP6_UDP)) + M_SANITY_ACTION("UDP frag offload w/o UDP csum"); + if ((cflags & (CSUM_IP6_TSO|CSUM_IP6_TCP)) != + (CSUM_IP6_TSO|CSUM_IP6_TCP)) + M_SANITY_ACTION("TCP seg offload w/o TCP csum"); + if ((cflags & (CSUM_IP6_SCO|CSUM_IP6_SCTP)) != + (CSUM_IP_SCO|CSUM_IP6_SCTP)) + M_SANITY_ACTION("SCTP chunk offl w/o SCTP csum"); + } + /* IP and IP6 flags may not be combined. */ + if ((cflags & (CSUM_IP|CSUM_IP_UDP|CSUM_IP_TCP|CSUM_IP_SCTP)) && + (cflags & (CSUM_IP6|CSUM_IP6_UDP|CSUM_IP6_TCP|CSUM_IP6_SCTP))) + M_SANITY_ACTION("IPv4 and IPv6 csum flags present"); + +#ifdef notyet + /* + * For now offload capabilities are only supported + * on ethernet NICs so we can assume an ethernet header. + */ + if (m->m_pkthdr.csum_l2hlen > 0) { + struct ether_vlan_header *evh; + int l2hlen = 0; + + evh = mtodo(m, l2hlen); + l3proto = ntonh(evh->evl_encap_proto); + + switch (l3proto) { + case ETHERTYPE_IP: + case ETHERTYPE_IPV6: + l2hlen += sizeof(struct ether_header); + break; + case ETHERTYPE_VLAN: + /* XXXAO: VLAN header stacking. */ + l2hlen += sizeof(struct ether_vlan_header); + l3proto = ntohs(evh->evl_proto); + break; + default: + break; + } + if (l2hlen != m->m_pkthdr.csum_l2hlen) + M_SANITY_ACTION("l2hlen != csum_l2hlen"); + if (l3proto != ETHERTYPE_IP && + l3proto != ETHERTYPE_IPV6) + M_SANITY_ACTION("unsupported l3 protocol"); + } + + /* + * Check layer 3 headers and length. + */ + if (m->m_pkthdr.csum_l3hlen > 0) { + int l3hlen = 0; + + switch (cflags & (CSUM_IP|CSUM_IP6)) { + case CSUM_IP: { + struct ip *ip; + + ip = mtodo(m, l2hlen); + if (ip->ip_v != IPVERSION) + M_SANITY_ACTION(""); + if (ip->ip_hl << 2 != sizeof(struct ip)) + M_SANITY_ACTION(""); + l3hlen += (ip->ip_hl << 2); + + if (m->m_pkthdr.len != ntohs(ip->ip_len) + + m->m_pkthdr.csum_l2hlen) + M_SANITY_ACTION(""); + l4proto = ip->ip_p; + } + break; + case CSUM_IP6: { + struct ip6_hdr *ip6; + + if ((ip6->ip6_vfc & IPV6_VERSION_MASK) != + IPV6_VERSION) + M_SANITY_ACTION(""); + do { + ip6 = mtodo(m, l2hlen); + l4proto = ip6->ip6_nxt; + } while (extension headers); + + if (m->m_pkthdr.len != ntohs() + + m->m_pkthdr.csum_l2hlen) + M_SANITY_ACTION(""); + } + break; + default: + break; + } + if (l3hlen != m->m_pkthdr.csum_l3hlen) + M_SANITY_ACTION(""); + if (l4proto != IPPROTO_UDP && + l4proto != IPPROTO_TCP && + l4proto != IPPROTO_SCTP) + M_SANITY_ACTION(""); + } + + /* + * Check layer 4 headers and length. + */ + if (m->m_pkthdr.csum_l4hlen > 0) { + + switch (cflags & (CSUM_IP_UFO|CSUM_IP6_UFO| + CSUM_IP_TSO|CSUM_IP6_TSO| + CSUM_IP_SCTP|CSUM_IP6_SCTP)) { + case CSUM_IP_UFO: + case CSUM_IP6_UFO: { + struct udphdr *udp; + + udp = mtodo(m, l2hlen + l3hlen); + /* Check pseudo csum. */ + sum = ip_pseudo(); + if (sum != th->th_sum) + M_SANITY_ACTION(); + + l4hlen = sizeof(struct udphdr); + } + break; + case CSUM_IP_TSO: + case CSUM_IP6_TSO: { + struct tcphdr *th; + + th = mtodo(m, l2hlen + l3hlen); + /* Check pseudo csum. */ + sum = ip_pseudo(); + if (sum != th->th_sum) + M_SANITY_ACTION(); + + l4hlen = th->th_off << 2; + } + break; + case CSUM_IP_SCTP: + case CSUM_IP6_SCTP: { + struct sctphdr *sctp; + struct sctp_chunkhdr *sctp_ch; + + sctp = mtodo(m, l2hlen + l3hlen); + /* Thankfully SCTP doesn't have a pseudo hdr. */ + l4hlen = sizeof(struct sctphdr); + } + break; + default: + M_SANITY_ACTION(); + break; + } + if (l4hlen != m->m_pkthdr.csum_l4hlen) + M_SANITY_ACTION(""); + + } else if (cflags & (CSUM_IP_UFO|CSUM_IP6_UFO| + CSUM_IP_TSO|CSUM_IP6_TSO| + CSUM_IP_SCTP|CSUM_IP6_SCTP)) + M_SANITY_ACTION("l4 offload w/o l4hlen"); +#endif + } return 1; #undef M_SANITY_ACTION From owner-svn-src-user@FreeBSD.ORG Tue Nov 20 17:08:38 2012 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0F57BA2B; Tue, 20 Nov 2012 17:08:38 +0000 (UTC) (envelope-from andre@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id E249B8FC13; Tue, 20 Nov 2012 17:08:37 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qAKH8bYZ060347; Tue, 20 Nov 2012 17:08:37 GMT (envelope-from andre@svn.freebsd.org) Received: (from andre@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qAKH8bW2060333; Tue, 20 Nov 2012 17:08:37 GMT (envelope-from andre@svn.freebsd.org) Message-Id: <201211201708.qAKH8bW2060333@svn.freebsd.org> From: Andre Oppermann Date: Tue, 20 Nov 2012 17:08:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r243345 - in user/andre/tcp_workqueue/sys: amd64/amd64 arm/arm arm/conf arm/xscale/i80321 boot/forth boot/i386/common boot/powerpc/boot1.chrp boot/sparc64/boot1 boot/userboot boot/userb... X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Nov 2012 17:08:38 -0000 Author: andre Date: Tue Nov 20 17:08:37 2012 New Revision: 243345 URL: http://svnweb.freebsd.org/changeset/base/243345 Log: Integrate from HEAD @243344. Added: user/andre/tcp_workqueue/sys/mips/cavium/octeon_pci_console.c - copied unchanged from r243344, head/sys/mips/cavium/octeon_pci_console.c user/andre/tcp_workqueue/sys/ufs/ffs/ffs_suspend.c - copied unchanged from r243344, head/sys/ufs/ffs/ffs_suspend.c Modified: user/andre/tcp_workqueue/sys/amd64/amd64/minidump_machdep.c user/andre/tcp_workqueue/sys/amd64/amd64/uma_machdep.c user/andre/tcp_workqueue/sys/arm/arm/busdma_machdep-v6.c user/andre/tcp_workqueue/sys/arm/arm/cpufunc.c user/andre/tcp_workqueue/sys/arm/arm/cpufunc_asm_armv7.S user/andre/tcp_workqueue/sys/arm/arm/pmap-v6.c user/andre/tcp_workqueue/sys/arm/arm/pmap.c user/andre/tcp_workqueue/sys/arm/arm/vm_machdep.c user/andre/tcp_workqueue/sys/arm/conf/CAMBRIA user/andre/tcp_workqueue/sys/arm/xscale/i80321/ep80219_machdep.c user/andre/tcp_workqueue/sys/arm/xscale/i80321/iq31244_machdep.c user/andre/tcp_workqueue/sys/boot/forth/menu-commands.4th user/andre/tcp_workqueue/sys/boot/forth/menu.4th user/andre/tcp_workqueue/sys/boot/i386/common/edd.h user/andre/tcp_workqueue/sys/boot/powerpc/boot1.chrp/boot1.c user/andre/tcp_workqueue/sys/boot/sparc64/boot1/boot1.c user/andre/tcp_workqueue/sys/boot/userboot/test/test.c user/andre/tcp_workqueue/sys/boot/userboot/userboot.h user/andre/tcp_workqueue/sys/boot/userboot/userboot/main.c user/andre/tcp_workqueue/sys/bsm/audit_kevents.h user/andre/tcp_workqueue/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c user/andre/tcp_workqueue/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c user/andre/tcp_workqueue/sys/cddl/contrib/opensolaris/uts/common/sys/procset.h user/andre/tcp_workqueue/sys/compat/freebsd32/freebsd32.h user/andre/tcp_workqueue/sys/compat/freebsd32/freebsd32_misc.c user/andre/tcp_workqueue/sys/compat/freebsd32/freebsd32_proto.h user/andre/tcp_workqueue/sys/compat/freebsd32/freebsd32_syscall.h user/andre/tcp_workqueue/sys/compat/freebsd32/freebsd32_syscalls.c user/andre/tcp_workqueue/sys/compat/freebsd32/freebsd32_sysent.c user/andre/tcp_workqueue/sys/compat/freebsd32/freebsd32_systrace_args.c user/andre/tcp_workqueue/sys/compat/freebsd32/syscalls.master user/andre/tcp_workqueue/sys/conf/files user/andre/tcp_workqueue/sys/conf/files.mips user/andre/tcp_workqueue/sys/conf/kern.pre.mk user/andre/tcp_workqueue/sys/contrib/octeon-sdk/cvmx-helper-board.c user/andre/tcp_workqueue/sys/contrib/octeon-sdk/cvmx-helper-spi.c user/andre/tcp_workqueue/sys/contrib/octeon-sdk/cvmx-spi.c user/andre/tcp_workqueue/sys/contrib/octeon-sdk/octeon-pci-console.c user/andre/tcp_workqueue/sys/dev/acpica/acpivar.h user/andre/tcp_workqueue/sys/dev/adb/adb_mouse.c user/andre/tcp_workqueue/sys/dev/agp/agp.c user/andre/tcp_workqueue/sys/dev/agp/agp_ali.c user/andre/tcp_workqueue/sys/dev/agp/agp_amd.c user/andre/tcp_workqueue/sys/dev/agp/agp_amd64.c user/andre/tcp_workqueue/sys/dev/agp/agp_apple.c user/andre/tcp_workqueue/sys/dev/agp/agp_ati.c user/andre/tcp_workqueue/sys/dev/agp/agp_i810.c user/andre/tcp_workqueue/sys/dev/agp/agp_intel.c user/andre/tcp_workqueue/sys/dev/agp/agp_nvidia.c user/andre/tcp_workqueue/sys/dev/agp/agp_sis.c user/andre/tcp_workqueue/sys/dev/agp/agp_via.c user/andre/tcp_workqueue/sys/dev/aic7xxx/aicasm/aicasm_gram.y user/andre/tcp_workqueue/sys/dev/ath/ath_hal/ar5210/ar5210.h user/andre/tcp_workqueue/sys/dev/ath/ath_hal/ar5210/ar5210_misc.c user/andre/tcp_workqueue/sys/dev/ath/ath_hal/ar5210/ar5210_recv.c user/andre/tcp_workqueue/sys/dev/ath/ath_hal/ar5210/ar5210_reset.c user/andre/tcp_workqueue/sys/dev/ath/ath_hal/ar5210/ar5210_xmit.c user/andre/tcp_workqueue/sys/dev/ath/ath_hal/ar5210/ar5210desc.h user/andre/tcp_workqueue/sys/dev/ath/ath_hal/ar5210/ar5210reg.h user/andre/tcp_workqueue/sys/dev/ath/ath_hal/ar5211/ar5211desc.h user/andre/tcp_workqueue/sys/dev/ath/ath_hal/ar5212/ar5212_recv.c user/andre/tcp_workqueue/sys/dev/ath/ath_hal/ar5212/ar5212_xmit.c user/andre/tcp_workqueue/sys/dev/ath/ath_hal/ar5212/ar5212desc.h user/andre/tcp_workqueue/sys/dev/ath/ath_hal/ar5416/ar5416desc.h user/andre/tcp_workqueue/sys/dev/ath/if_ath.c user/andre/tcp_workqueue/sys/dev/ath/if_ath_alq.c user/andre/tcp_workqueue/sys/dev/ath/if_ath_alq.h user/andre/tcp_workqueue/sys/dev/ath/if_ath_keycache.c user/andre/tcp_workqueue/sys/dev/ath/if_ath_rx.c user/andre/tcp_workqueue/sys/dev/ath/if_ath_sysctl.c user/andre/tcp_workqueue/sys/dev/ath/if_ath_tx.c user/andre/tcp_workqueue/sys/dev/ath/if_ath_tx.h user/andre/tcp_workqueue/sys/dev/ath/if_ath_tx_edma.c user/andre/tcp_workqueue/sys/dev/cxgbe/tom/t4_listen.c user/andre/tcp_workqueue/sys/dev/fdc/fdc.c user/andre/tcp_workqueue/sys/dev/iicbus/iic.c user/andre/tcp_workqueue/sys/dev/mfi/mfi_syspd.c user/andre/tcp_workqueue/sys/dev/sio/sio_isa.c user/andre/tcp_workqueue/sys/dev/sound/pci/hda/hdaa.c user/andre/tcp_workqueue/sys/dev/sound/pcm/channel.c user/andre/tcp_workqueue/sys/dev/sound/pcm/feeder_matrix.c user/andre/tcp_workqueue/sys/dev/sound/pcm/matrix.h user/andre/tcp_workqueue/sys/dev/sound/pcm/matrix_map.h user/andre/tcp_workqueue/sys/dev/uart/uart_bus_isa.c user/andre/tcp_workqueue/sys/dev/xen/netback/netback_unit_tests.c user/andre/tcp_workqueue/sys/fs/devfs/devfs_devs.c user/andre/tcp_workqueue/sys/fs/ext2fs/ext2_vfsops.c user/andre/tcp_workqueue/sys/fs/msdosfs/msdosfs_denode.c user/andre/tcp_workqueue/sys/fs/nfsclient/nfs_clnode.c user/andre/tcp_workqueue/sys/fs/nfsclient/nfs_clport.c user/andre/tcp_workqueue/sys/fs/nullfs/null_subr.c user/andre/tcp_workqueue/sys/fs/smbfs/smbfs_node.c user/andre/tcp_workqueue/sys/fs/smbfs/smbfs_vnops.c user/andre/tcp_workqueue/sys/fs/unionfs/union_subr.c user/andre/tcp_workqueue/sys/geom/bde/g_bde.c user/andre/tcp_workqueue/sys/geom/cache/g_cache.c user/andre/tcp_workqueue/sys/geom/geom.h user/andre/tcp_workqueue/sys/geom/geom_aes.c user/andre/tcp_workqueue/sys/geom/geom_dev.c user/andre/tcp_workqueue/sys/geom/geom_mbr.c user/andre/tcp_workqueue/sys/geom/geom_slice.c user/andre/tcp_workqueue/sys/geom/geom_slice.h user/andre/tcp_workqueue/sys/geom/label/g_label.c user/andre/tcp_workqueue/sys/geom/mountver/g_mountver.c user/andre/tcp_workqueue/sys/geom/multipath/g_multipath.c user/andre/tcp_workqueue/sys/geom/nop/g_nop.c user/andre/tcp_workqueue/sys/geom/sched/g_sched.c user/andre/tcp_workqueue/sys/gnu/fs/reiserfs/reiserfs_inode.c user/andre/tcp_workqueue/sys/i386/xen/clock.c user/andre/tcp_workqueue/sys/ia64/ia64/uma_machdep.c user/andre/tcp_workqueue/sys/kern/init_sysent.c user/andre/tcp_workqueue/sys/kern/kern_exit.c user/andre/tcp_workqueue/sys/kern/kern_ktr.c user/andre/tcp_workqueue/sys/kern/kern_proc.c user/andre/tcp_workqueue/sys/kern/kern_prot.c user/andre/tcp_workqueue/sys/kern/kern_racct.c user/andre/tcp_workqueue/sys/kern/sched_ule.c user/andre/tcp_workqueue/sys/kern/subr_lock.c user/andre/tcp_workqueue/sys/kern/subr_smp.c user/andre/tcp_workqueue/sys/kern/subr_taskqueue.c user/andre/tcp_workqueue/sys/kern/sys_procdesc.c user/andre/tcp_workqueue/sys/kern/syscalls.c user/andre/tcp_workqueue/sys/kern/syscalls.master user/andre/tcp_workqueue/sys/kern/systrace_args.c user/andre/tcp_workqueue/sys/kern/tty_pts.c user/andre/tcp_workqueue/sys/kern/uipc_usrreq.c user/andre/tcp_workqueue/sys/kern/vfs_subr.c user/andre/tcp_workqueue/sys/kern/vnode_if.src user/andre/tcp_workqueue/sys/mips/atheros/files.ar71xx user/andre/tcp_workqueue/sys/mips/cavium/files.octeon1 user/andre/tcp_workqueue/sys/mips/cavium/octe/ethernet-tx.c user/andre/tcp_workqueue/sys/mips/cavium/octe/ethernet.c user/andre/tcp_workqueue/sys/mips/cavium/octeon_machdep.c user/andre/tcp_workqueue/sys/mips/conf/AR71XX_BASE user/andre/tcp_workqueue/sys/mips/conf/AR724X_BASE user/andre/tcp_workqueue/sys/mips/conf/AR91XX_BASE user/andre/tcp_workqueue/sys/mips/conf/OCTEON1 user/andre/tcp_workqueue/sys/mips/conf/PB92 user/andre/tcp_workqueue/sys/mips/include/pmap.h user/andre/tcp_workqueue/sys/mips/mips/pmap.c user/andre/tcp_workqueue/sys/mips/mips/support.S user/andre/tcp_workqueue/sys/mips/mips/uma_machdep.c user/andre/tcp_workqueue/sys/modules/Makefile user/andre/tcp_workqueue/sys/modules/agp/Makefile user/andre/tcp_workqueue/sys/modules/mthca/Makefile user/andre/tcp_workqueue/sys/modules/ufs/Makefile user/andre/tcp_workqueue/sys/net/rtsock.c user/andre/tcp_workqueue/sys/netinet/sctp_constants.h user/andre/tcp_workqueue/sys/netinet/sctp_indata.c user/andre/tcp_workqueue/sys/netinet/sctp_input.c user/andre/tcp_workqueue/sys/netinet/sctp_output.c user/andre/tcp_workqueue/sys/netinet/sctp_pcb.c user/andre/tcp_workqueue/sys/netinet/sctp_pcb.h user/andre/tcp_workqueue/sys/netinet/sctp_sysctl.c user/andre/tcp_workqueue/sys/netinet/sctp_timer.c user/andre/tcp_workqueue/sys/netinet/sctputil.c user/andre/tcp_workqueue/sys/netinet/sctputil.h user/andre/tcp_workqueue/sys/netinet6/icmp6.c user/andre/tcp_workqueue/sys/netinet6/in6_src.c user/andre/tcp_workqueue/sys/netinet6/ip6_input.c user/andre/tcp_workqueue/sys/netinet6/ip6_mroute.c user/andre/tcp_workqueue/sys/netinet6/nd6.c user/andre/tcp_workqueue/sys/netinet6/nd6_rtr.c user/andre/tcp_workqueue/sys/netinet6/scope6.c user/andre/tcp_workqueue/sys/netinet6/sctp6_usrreq.c user/andre/tcp_workqueue/sys/netinet6/sctp6_var.h user/andre/tcp_workqueue/sys/nfsclient/nfs_node.c user/andre/tcp_workqueue/sys/ofed/drivers/infiniband/core/cma.c user/andre/tcp_workqueue/sys/ofed/drivers/infiniband/core/ud_header.c user/andre/tcp_workqueue/sys/ofed/drivers/infiniband/ulp/sdp/sdp_rx.c user/andre/tcp_workqueue/sys/ofed/include/linux/pci.h user/andre/tcp_workqueue/sys/powerpc/aim/mmu_oea64.c user/andre/tcp_workqueue/sys/powerpc/aim/slb.c user/andre/tcp_workqueue/sys/powerpc/aim/uma_machdep.c user/andre/tcp_workqueue/sys/sparc64/include/ktr.h user/andre/tcp_workqueue/sys/sparc64/sparc64/pmap.c user/andre/tcp_workqueue/sys/sparc64/sparc64/vm_machdep.c user/andre/tcp_workqueue/sys/sys/ktr.h user/andre/tcp_workqueue/sys/sys/lock.h user/andre/tcp_workqueue/sys/sys/param.h user/andre/tcp_workqueue/sys/sys/proc.h user/andre/tcp_workqueue/sys/sys/resource.h user/andre/tcp_workqueue/sys/sys/smp.h user/andre/tcp_workqueue/sys/sys/syscall.h user/andre/tcp_workqueue/sys/sys/syscall.mk user/andre/tcp_workqueue/sys/sys/syscallsubr.h user/andre/tcp_workqueue/sys/sys/sysproto.h user/andre/tcp_workqueue/sys/sys/vmmeter.h user/andre/tcp_workqueue/sys/sys/wait.h user/andre/tcp_workqueue/sys/ufs/ffs/ffs_extern.h user/andre/tcp_workqueue/sys/ufs/ffs/ffs_softdep.c user/andre/tcp_workqueue/sys/ufs/ffs/ffs_vfsops.c user/andre/tcp_workqueue/sys/ufs/ffs/fs.h user/andre/tcp_workqueue/sys/ufs/ufs/ufsmount.h user/andre/tcp_workqueue/sys/vm/device_pager.c user/andre/tcp_workqueue/sys/vm/sg_pager.c user/andre/tcp_workqueue/sys/vm/swap_pager.c user/andre/tcp_workqueue/sys/vm/vm_fault.c user/andre/tcp_workqueue/sys/vm/vm_kern.c user/andre/tcp_workqueue/sys/vm/vm_page.c user/andre/tcp_workqueue/sys/vm/vm_page.h user/andre/tcp_workqueue/sys/vm/vm_pageout.c user/andre/tcp_workqueue/sys/vm/vm_phys.h Directory Properties: user/andre/tcp_workqueue/sys/ (props changed) user/andre/tcp_workqueue/sys/boot/ (props changed) user/andre/tcp_workqueue/sys/boot/powerpc/boot1.chrp/ (props changed) user/andre/tcp_workqueue/sys/cddl/contrib/opensolaris/ (props changed) user/andre/tcp_workqueue/sys/conf/ (props changed) user/andre/tcp_workqueue/sys/contrib/octeon-sdk/ (props changed) Modified: user/andre/tcp_workqueue/sys/amd64/amd64/minidump_machdep.c ============================================================================== --- user/andre/tcp_workqueue/sys/amd64/amd64/minidump_machdep.c Tue Nov 20 17:04:52 2012 (r243344) +++ user/andre/tcp_workqueue/sys/amd64/amd64/minidump_machdep.c Tue Nov 20 17:08:37 2012 (r243345) @@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include Modified: user/andre/tcp_workqueue/sys/amd64/amd64/uma_machdep.c ============================================================================== --- user/andre/tcp_workqueue/sys/amd64/amd64/uma_machdep.c Tue Nov 20 17:04:52 2012 (r243344) +++ user/andre/tcp_workqueue/sys/amd64/amd64/uma_machdep.c Tue Nov 20 17:08:37 2012 (r243345) @@ -29,6 +29,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -48,12 +49,7 @@ uma_small_alloc(uma_zone_t zone, int byt int pflags; *flags = UMA_SLAB_PRIV; - if ((wait & (M_NOWAIT|M_USE_RESERVE)) == M_NOWAIT) - pflags = VM_ALLOC_INTERRUPT | VM_ALLOC_NOOBJ | VM_ALLOC_WIRED; - else - pflags = VM_ALLOC_SYSTEM | VM_ALLOC_NOOBJ | VM_ALLOC_WIRED; - if (wait & M_ZERO) - pflags |= VM_ALLOC_ZERO; + pflags = malloc2vm_flags(wait) | VM_ALLOC_NOOBJ | VM_ALLOC_WIRED; for (;;) { m = vm_page_alloc(NULL, 0, pflags); if (m == NULL) { Modified: user/andre/tcp_workqueue/sys/arm/arm/busdma_machdep-v6.c ============================================================================== --- user/andre/tcp_workqueue/sys/arm/arm/busdma_machdep-v6.c Tue Nov 20 17:04:52 2012 (r243344) +++ user/andre/tcp_workqueue/sys/arm/arm/busdma_machdep-v6.c Tue Nov 20 17:08:37 2012 (r243345) @@ -1463,7 +1463,6 @@ add_bounce_page(bus_dma_tag_t dmat, bus_ struct bounce_zone *bz; struct bounce_page *bpage; - printf("add bounce page\n"); KASSERT(dmat->bounce_zone != NULL, ("no bounce zone in dma tag")); KASSERT(map != NULL, ("add_bounce_page: bad map %p", map)); Modified: user/andre/tcp_workqueue/sys/arm/arm/cpufunc.c ============================================================================== --- user/andre/tcp_workqueue/sys/arm/arm/cpufunc.c Tue Nov 20 17:04:52 2012 (r243344) +++ user/andre/tcp_workqueue/sys/arm/arm/cpufunc.c Tue Nov 20 17:08:37 2012 (r243345) @@ -1047,7 +1047,7 @@ struct cpu_functions cortexa_cpufuncs = /* TLB functions */ - arm11_tlb_flushID, /* tlb_flushID */ + armv7_tlb_flushID, /* tlb_flushID */ armv7_tlb_flushID_SE, /* tlb_flushID_SE */ arm11_tlb_flushI, /* tlb_flushI */ arm11_tlb_flushI_SE, /* tlb_flushI_SE */ @@ -1067,7 +1067,8 @@ struct cpu_functions cortexa_cpufuncs = armv7_idcache_wbinv_all, /* idcache_wbinv_all */ armv7_idcache_wbinv_range, /* idcache_wbinv_range */ - /* Note: From OMAP4 the L2 ops are filled in when the + /* + * Note: For CPUs using the PL310 the L2 ops are filled in when the * L2 cache controller is actually enabled. */ cpufunc_nullop, /* l2cache_wbinv_all */ Modified: user/andre/tcp_workqueue/sys/arm/arm/cpufunc_asm_armv7.S ============================================================================== --- user/andre/tcp_workqueue/sys/arm/arm/cpufunc_asm_armv7.S Tue Nov 20 17:04:52 2012 (r243344) +++ user/andre/tcp_workqueue/sys/arm/arm/cpufunc_asm_armv7.S Tue Nov 20 17:08:37 2012 (r243345) @@ -70,7 +70,11 @@ ENTRY(armv7_setttb) orr r0, r0, #PT_ATTR mcr p15, 0, r0, c2, c0, 0 /* Translation Table Base Register 0 (TTBR0) */ +#ifdef SMP + mcr p15, 0, r0, c8, c3, 0 /* invalidate I+D TLBs Inner Shareable*/ +#else mcr p15, 0, r0, c8, c7, 0 /* invalidate I+D TLBs */ +#endif dsb isb RET @@ -78,11 +82,12 @@ ENTRY(armv7_setttb) ENTRY(armv7_tlb_flushID) dsb #ifdef SMP - mcr p15, 0, r0, c8, c3, 0 + mcr p15, 0, r0, c8, c3, 0 /* flush I+D tlb */ + mcr p15, 0, r0, c7, c1, 6 /* flush BTB */ #else mcr p15, 0, r0, c8, c7, 0 /* flush I+D tlb */ -#endif mcr p15, 0, r0, c7, c5, 6 /* flush BTB */ +#endif dsb isb mov pc, lr @@ -91,11 +96,12 @@ ENTRY(armv7_tlb_flushID_SE) ldr r1, .Lpage_mask bic r0, r0, r1 #ifdef SMP - mcr p15, 0, r0, c8, c3, 1 /* flush D tlb single entry */ + mcr p15, 0, r0, c8, c3, 1 /* flush D tlb single entry Inner Shareable*/ + mcr p15, 0, r0, c7, c1, 6 /* flush BTB Inner Shareable */ #else mcr p15, 0, r0, c8, c7, 1 /* flush D tlb single entry */ -#endif mcr p15, 0, r0, c7, c5, 6 /* flush BTB */ +#endif dsb isb mov pc, lr @@ -155,7 +161,11 @@ Finished: ENTRY(armv7_idcache_wbinv_all) stmdb sp!, {lr} bl armv7_dcache_wbinv_all +#ifdef SMP + mcr p15, 0, r0, c7, c1, 0 /* Invalidate all I caches to PoU (ICIALLUIS) */ +#else mcr p15, 0, r0, c7, c5, 0 /* Invalidate all I caches to PoU (ICIALLU) */ +#endif dsb isb ldmia sp!, {lr} @@ -251,7 +261,11 @@ ENTRY(armv7_context_switch) orr r0, r0, #PT_ATTR mcr p15, 0, r0, c2, c0, 0 /* set the new TTB */ +#ifdef SMP + mcr p15, 0, r0, c8, c3, 0 /* and flush the I+D tlbs Inner Sharable */ +#else mcr p15, 0, r0, c8, c7, 0 /* and flush the I+D tlbs */ +#endif dsb isb RET Modified: user/andre/tcp_workqueue/sys/arm/arm/pmap-v6.c ============================================================================== --- user/andre/tcp_workqueue/sys/arm/arm/pmap-v6.c Tue Nov 20 17:04:52 2012 (r243344) +++ user/andre/tcp_workqueue/sys/arm/arm/pmap-v6.c Tue Nov 20 17:08:37 2012 (r243345) @@ -2361,8 +2361,10 @@ pmap_change_attr(vm_offset_t sva, vm_siz * Only supported on kernel virtual addresses, including the direct * map but excluding the recursive map. */ - if (base < DMAP_MIN_ADDRESS) + if (base < DMAP_MIN_ADDRESS) { + PMAP_UNLOCK(kernel_pmap); return (EINVAL); + } #endif for (tmpva = base; tmpva < base + size; ) { next_bucket = L2_NEXT_BUCKET(tmpva); @@ -2377,8 +2379,10 @@ pmap_change_attr(vm_offset_t sva, vm_siz ptep = &l2b->l2b_kva[l2pte_index(tmpva)]; - if (*ptep == 0) + if (*ptep == 0) { + PMAP_UNLOCK(kernel_pmap); return(EINVAL); + } pte = *ptep &~ L2_S_CACHE_MASK; cpu_idcache_wbinv_range(tmpva, PAGE_SIZE); Modified: user/andre/tcp_workqueue/sys/arm/arm/pmap.c ============================================================================== --- user/andre/tcp_workqueue/sys/arm/arm/pmap.c Tue Nov 20 17:04:52 2012 (r243344) +++ user/andre/tcp_workqueue/sys/arm/arm/pmap.c Tue Nov 20 17:08:37 2012 (r243345) @@ -165,6 +165,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include Modified: user/andre/tcp_workqueue/sys/arm/arm/vm_machdep.c ============================================================================== --- user/andre/tcp_workqueue/sys/arm/arm/vm_machdep.c Tue Nov 20 17:04:52 2012 (r243344) +++ user/andre/tcp_workqueue/sys/arm/arm/vm_machdep.c Tue Nov 20 17:08:37 2012 (r243345) @@ -651,12 +651,7 @@ uma_small_alloc(uma_zone_t zone, int byt ret = ((void *)kmem_malloc(kmem_map, bytes, M_NOWAIT)); return (ret); } - if ((wait & (M_NOWAIT|M_USE_RESERVE)) == M_NOWAIT) - pflags = VM_ALLOC_INTERRUPT | VM_ALLOC_WIRED; - else - pflags = VM_ALLOC_SYSTEM | VM_ALLOC_WIRED; - if (wait & M_ZERO) - pflags |= VM_ALLOC_ZERO; + pflags = malloc2vm_flags(wait) | VM_ALLOC_WIRED; for (;;) { m = vm_page_alloc(NULL, 0, pflags | VM_ALLOC_NOOBJ); if (m == NULL) { Modified: user/andre/tcp_workqueue/sys/arm/conf/CAMBRIA ============================================================================== --- user/andre/tcp_workqueue/sys/arm/conf/CAMBRIA Tue Nov 20 17:04:52 2012 (r243344) +++ user/andre/tcp_workqueue/sys/arm/conf/CAMBRIA Tue Nov 20 17:08:37 2012 (r243345) @@ -126,26 +126,15 @@ device ath # Atheros NICs device ath_pci # Atheros pci/cardbus glue options ATH_DEBUG options ATH_DIAGAPI +options ATH_ENABLE_DFS +options ATH_ENABLE_11N #options ATH_TX99_DIAG device ath_rate_sample # SampleRate tx rate control for ath -#options AH_DEBUG -#options AH_ASSERT +options AH_DEBUG options AH_PRIVATE_DIAG -#device ath_ar5210 -#device ath_ar5211 -# -device ath_ar5212 -#device ath_rf2413 -#device ath_rf2425 # NB:supports 2417 too -#device ath_rf5111 -device ath_rf5112 -device ath_rf5413 -# -#device ath_ar5416 options AH_SUPPORT_AR5416 # NB: for 11n descriptor format -#device ath_ar9160 -#device ath_ar9280 +device ath_hal # NB: 2 USB 2.0 ports standard device usb Modified: user/andre/tcp_workqueue/sys/arm/xscale/i80321/ep80219_machdep.c ============================================================================== --- user/andre/tcp_workqueue/sys/arm/xscale/i80321/ep80219_machdep.c Tue Nov 20 17:04:52 2012 (r243344) +++ user/andre/tcp_workqueue/sys/arm/xscale/i80321/ep80219_machdep.c Tue Nov 20 17:08:37 2012 (r243345) @@ -95,11 +95,11 @@ __FBSDID("$FreeBSD$"); #include #include -#define KERNEL_PT_SYS 0 /* Page table for mapping proc0 zero page */ -#define KERNEL_PT_IOPXS 1 -#define KERNEL_PT_BEFOREKERN 2 -#define KERNEL_PT_AFKERNEL 3 /* L2 table for mapping after kernel */ -#define KERNEL_PT_AFKERNEL_NUM 9 +#define KERNEL_PT_SYS 0 /* Page table for mapping proc0 zero page */ +#define KERNEL_PT_IOPXS 1 +#define KERNEL_PT_BEFOREKERN 2 +#define KERNEL_PT_AFKERNEL 3 /* L2 table for mapping after kernel */ +#define KERNEL_PT_AFKERNEL_NUM 9 /* this should be evenly divisable by PAGE_SIZE / L2_TABLE_SIZE_REAL (or 4) */ #define NUM_KERNEL_PTS (KERNEL_PT_AFKERNEL + KERNEL_PT_AFKERNEL_NUM) @@ -184,10 +184,13 @@ initarm(struct arm_boot_params *abp) pcpu_init(pcpup, 0, sizeof(struct pcpu)); PCPU_SET(curthread, &thread0); + /* Do basic tuning, hz etc */ + init_param1(); + freemempos = 0xa0200000; /* Define a macro to simplify memory allocation */ #define valloc_pages(var, np) \ - alloc_pages((var).pv_pa, (np)); \ + alloc_pages((var).pv_pa, (np)); \ (var).pv_va = (var).pv_pa + 0x20000000; #define alloc_pages(var, np) \ @@ -195,16 +198,13 @@ initarm(struct arm_boot_params *abp) (var) = freemempos; \ memset((char *)(var), 0, ((np) * PAGE_SIZE)); - /* Do basic tuning, hz etc */ - init_param1(); - while (((freemempos - L1_TABLE_SIZE) & (L1_TABLE_SIZE - 1)) != 0) freemempos -= PAGE_SIZE; valloc_pages(kernel_l1pt, L1_TABLE_SIZE / PAGE_SIZE); for (loop = 0; loop < NUM_KERNEL_PTS; ++loop) { if (!(loop % (PAGE_SIZE / L2_TABLE_SIZE_REAL))) { valloc_pages(kernel_pt_table[loop], - L2_TABLE_SIZE / PAGE_SIZE); + L2_TABLE_SIZE / PAGE_SIZE); } else { kernel_pt_table[loop].pv_pa = freemempos + (loop % (PAGE_SIZE / L2_TABLE_SIZE_REAL)) * @@ -237,15 +237,14 @@ initarm(struct arm_boot_params *abp) freemempos -= PAGE_SIZE; freemem_pt = trunc_page(freemem_pt); freemem_after = freemempos - ((freemem_pt - 0xa0100000) / - PAGE_SIZE) * sizeof(struct arm_small_page); - arm_add_smallalloc_pages((void *)(freemem_after + 0x20000000) - , (void *)0xc0100000, freemem_pt - 0xa0100000, 1); + PAGE_SIZE) * sizeof(struct arm_small_page); + arm_add_smallalloc_pages((void *)(freemem_after + 0x20000000), + (void *)0xc0100000, freemem_pt - 0xa0100000, 1); freemem_after -= ((freemem_after - 0xa0001000) / PAGE_SIZE) * sizeof(struct arm_small_page); arm_add_smallalloc_pages((void *)(freemem_after + 0x20000000), - (void *)0xc0001000, - trunc_page(freemem_after) - 0xa0001000, 0); - + (void *)0xc0001000, trunc_page(freemem_after) - 0xa0001000, 0); + freemempos = trunc_page(freemem_after); freemempos -= PAGE_SIZE; #endif @@ -265,27 +264,27 @@ initarm(struct arm_boot_params *abp) /* Map the L2 pages tables in the L1 page table */ pmap_link_l2pt(l1pagetable, ARM_VECTORS_HIGH & ~(0x00100000 - 1), - &kernel_pt_table[KERNEL_PT_SYS]); + &kernel_pt_table[KERNEL_PT_SYS]); pmap_link_l2pt(l1pagetable, IQ80321_IOPXS_VBASE, - &kernel_pt_table[KERNEL_PT_IOPXS]); + &kernel_pt_table[KERNEL_PT_IOPXS]); pmap_link_l2pt(l1pagetable, KERNBASE, - &kernel_pt_table[KERNEL_PT_BEFOREKERN]); + &kernel_pt_table[KERNEL_PT_BEFOREKERN]); pmap_map_chunk(l1pagetable, KERNBASE, IQ80321_SDRAM_START, 0x100000, - VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE); + VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE); pmap_map_chunk(l1pagetable, KERNBASE + 0x100000, IQ80321_SDRAM_START + 0x100000, - 0x100000, VM_PROT_READ|VM_PROT_WRITE, PTE_PAGETABLE); + 0x100000, VM_PROT_READ|VM_PROT_WRITE, PTE_PAGETABLE); pmap_map_chunk(l1pagetable, KERNBASE + 0x200000, IQ80321_SDRAM_START + 0x200000, - (((uint32_t)(lastaddr) - KERNBASE - 0x200000) + L1_S_SIZE) & ~(L1_S_SIZE - 1), - VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE); + (((uint32_t)(lastaddr) - KERNBASE - 0x200000) + L1_S_SIZE) & ~(L1_S_SIZE - 1), + VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE); freemem_after = ((int)lastaddr + PAGE_SIZE) & ~(PAGE_SIZE - 1); afterkern = round_page(((vm_offset_t)lastaddr + L1_S_SIZE) & ~(L1_S_SIZE - - 1)); + - 1)); for (i = 0; i < KERNEL_PT_AFKERNEL_NUM; i++) { pmap_link_l2pt(l1pagetable, afterkern + i * 0x00100000, - &kernel_pt_table[KERNEL_PT_AFKERNEL + i]); + &kernel_pt_table[KERNEL_PT_AFKERNEL + i]); } pmap_map_entry(l1pagetable, afterkern, minidataclean.pv_pa, - VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE); + VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE); #ifdef ARM_USE_SMALL_ALLOC @@ -299,11 +298,11 @@ initarm(struct arm_boot_params *abp) /* Map the Mini-Data cache clean area. */ xscale_setup_minidata(l1pagetable, afterkern, - minidataclean.pv_pa); + minidataclean.pv_pa); /* Map the vector page. */ pmap_map_entry(l1pagetable, ARM_VECTORS_HIGH, systempage.pv_pa, - VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE); + VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE); pmap_devmap_bootstrap(l1pagetable, ep80219_devmap); /* * Give the XScale global cache clean code an appropriately @@ -360,10 +359,15 @@ initarm(struct arm_boot_params *abp) arm_vector_init(ARM_VECTORS_HIGH, ARM_VEC_ALL); pmap_curmaxkvaddr = afterkern + PAGE_SIZE; + /* + * ARM_USE_SMALL_ALLOC uses dump_avail, so it must be filled before + * calling pmap_bootstrap. + */ dump_avail[0] = 0xa0000000; dump_avail[1] = 0xa0000000 + memsize; dump_avail[2] = 0; dump_avail[3] = 0; + pmap_bootstrap(pmap_curmaxkvaddr, 0xd0000000, &kernel_l1pt); msgbufp = (void*)msgbufpv.pv_va; Modified: user/andre/tcp_workqueue/sys/arm/xscale/i80321/iq31244_machdep.c ============================================================================== --- user/andre/tcp_workqueue/sys/arm/xscale/i80321/iq31244_machdep.c Tue Nov 20 17:04:52 2012 (r243344) +++ user/andre/tcp_workqueue/sys/arm/xscale/i80321/iq31244_machdep.c Tue Nov 20 17:08:37 2012 (r243345) @@ -95,10 +95,10 @@ __FBSDID("$FreeBSD$"); #include #include -#define KERNEL_PT_SYS 0 /* Page table for mapping proc0 zero page */ +#define KERNEL_PT_SYS 0 /* Page table for mapping proc0 zero page */ #define KERNEL_PT_IOPXS 1 -#define KERNEL_PT_BEFOREKERN 2 -#define KERNEL_PT_AFKERNEL 3 /* L2 table for mapping after kernel */ +#define KERNEL_PT_BEFOREKERN 2 +#define KERNEL_PT_AFKERNEL 3 /* L2 table for mapping after kernel */ #define KERNEL_PT_AFKERNEL_NUM 9 /* this should be evenly divisable by PAGE_SIZE / L2_TABLE_SIZE_REAL (or 4) */ @@ -187,7 +187,7 @@ initarm(struct arm_boot_params *abp) /* Do basic tuning, hz etc */ init_param1(); - + freemempos = 0xa0200000; /* Define a macro to simplify memory allocation */ #define valloc_pages(var, np) \ @@ -239,12 +239,13 @@ initarm(struct arm_boot_params *abp) freemem_pt = trunc_page(freemem_pt); freemem_after = freemempos - ((freemem_pt - 0xa0100000) / PAGE_SIZE) * sizeof(struct arm_small_page); - arm_add_smallalloc_pages((void *)(freemem_after + 0x20000000) - , (void *)0xc0100000, freemem_pt - 0xa0100000, 1); + arm_add_smallalloc_pages((void *)(freemem_after + 0x20000000), + (void *)0xc0100000, freemem_pt - 0xa0100000, 1); freemem_after -= ((freemem_after - 0xa0001000) / PAGE_SIZE) * sizeof(struct arm_small_page); - arm_add_smallalloc_pages((void *)(freemem_after + 0x20000000) - , (void *)0xc0001000, trunc_page(freemem_after) - 0xa0001000, 0); + arm_add_smallalloc_pages((void *)(freemem_after + 0x20000000), + (void *)0xc0001000, trunc_page(freemem_after) - 0xa0001000, 0); + freemempos = trunc_page(freemem_after); freemempos -= PAGE_SIZE; #endif @@ -266,7 +267,7 @@ initarm(struct arm_boot_params *abp) pmap_link_l2pt(l1pagetable, ARM_VECTORS_HIGH & ~(0x00100000 - 1), &kernel_pt_table[KERNEL_PT_SYS]); pmap_link_l2pt(l1pagetable, IQ80321_IOPXS_VBASE, - &kernel_pt_table[KERNEL_PT_IOPXS]); + &kernel_pt_table[KERNEL_PT_IOPXS]); pmap_link_l2pt(l1pagetable, KERNBASE, &kernel_pt_table[KERNEL_PT_BEFOREKERN]); pmap_map_chunk(l1pagetable, KERNBASE, SDRAM_START, 0x100000, @@ -274,7 +275,7 @@ initarm(struct arm_boot_params *abp) pmap_map_chunk(l1pagetable, KERNBASE + 0x100000, SDRAM_START + 0x100000, 0x100000, VM_PROT_READ|VM_PROT_WRITE, PTE_PAGETABLE); pmap_map_chunk(l1pagetable, KERNBASE + 0x200000, SDRAM_START + 0x200000, - (((uint32_t)(lastaddr) - KERNBASE - 0x200000) + L1_S_SIZE) & ~(L1_S_SIZE - 1), + (((uint32_t)(lastaddr) - KERNBASE - 0x200000) + L1_S_SIZE) & ~(L1_S_SIZE - 1), VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE); freemem_after = ((int)lastaddr + PAGE_SIZE) & ~(PAGE_SIZE - 1); afterkern = round_page(((vm_offset_t)lastaddr + L1_S_SIZE) & ~(L1_S_SIZE @@ -358,9 +359,6 @@ initarm(struct arm_boot_params *abp) /* Enable MMU, I-cache, D-cache, write buffer. */ arm_vector_init(ARM_VECTORS_HIGH, ARM_VEC_ALL); - - - pmap_curmaxkvaddr = afterkern + PAGE_SIZE; /* * ARM_USE_SMALL_ALLOC uses dump_avail, so it must be filled before @@ -396,7 +394,6 @@ initarm(struct arm_boot_params *abp) sizeof(struct pcb))); } - extern int machdep_pci_route_interrupt(device_t pcib, device_t dev, int pin) { Modified: user/andre/tcp_workqueue/sys/boot/forth/menu-commands.4th ============================================================================== --- user/andre/tcp_workqueue/sys/boot/forth/menu-commands.4th Tue Nov 20 17:04:52 2012 (r243344) +++ user/andre/tcp_workqueue/sys/boot/forth/menu-commands.4th Tue Nov 20 17:08:37 2012 (r243345) @@ -31,6 +31,10 @@ include /boot/menusets.4th variable kernel_state variable root_state +\ +\ ACPI +\ + : acpi_enable ( -- ) s" set acpi_load=YES" evaluate \ XXX deprecated but harmless s" set hint.acpi.0.disabled=0" evaluate @@ -58,9 +62,38 @@ variable root_state TRUE \ loop menu again ; +\ +\ Safe Mode +\ + +: safemode_enabled? ( -- flag ) + s" kern.smp.disabled" getenv -1 <> dup if + swap drop ( c-addr flag -- flag ) + then +; + +: safemode_enable ( -- ) + s" set kern.smp.disabled=1" evaluate + s" set hw.ata.ata_dma=0" evaluate + s" set hw.ata.atapi_dma=0" evaluate + s" set hw.ata.wc=0" evaluate + s" set hw.eisa_slots=0" evaluate + s" set kern.eventtimer.periodic=1" evaluate + s" set kern.geom.part.check_integrity=0" evaluate +; + +: safemode_disable ( -- ) + s" kern.smp.disabled" unsetenv + s" hw.ata.ata_dma" unsetenv + s" hw.ata.atapi_dma" unsetenv + s" hw.ata.wc" unsetenv + s" hw.eisa_slots" unsetenv + s" kern.eventtimer.periodic" unsetenv + s" kern.geom.part.check_integrity" unsetenv +; + : init_safemode ( N -- N ) - s" kern.smp.disabled" getenv -1 <> if - drop ( n c-addr -- n ) \ unused + safemode_enabled? if toggle_menuitem ( n -- n ) then ; @@ -70,25 +103,10 @@ variable root_state \ Now we're going to make the change effective - s" toggle_stateN @" \ base name of toggle state var - -rot 2dup 12 + c! rot \ replace 'N' with ASCII numeral - - evaluate 0= if - s" kern.smp.disabled" unsetenv - s" hw.ata.ata_dma" unsetenv - s" hw.ata.atapi_dma" unsetenv - s" hw.ata.wc" unsetenv - s" hw.eisa_slots" unsetenv - s" kern.eventtimer.periodic" unsetenv - s" kern.geom.part.check_integrity" unsetenv + dup toggle_stateN @ 0= if + safemode_disable else - s" set kern.smp.disabled=1" evaluate - s" set hw.ata.ata_dma=0" evaluate - s" set hw.ata.atapi_dma=0" evaluate - s" set hw.ata.wc=0" evaluate - s" set hw.eisa_slots=0" evaluate - s" set kern.eventtimer.periodic=1" evaluate - s" set kern.geom.part.check_integrity=0" evaluate + safemode_enable then menu-redraw @@ -96,9 +114,26 @@ variable root_state TRUE \ loop menu again ; +\ +\ Single User Mode +\ + +: singleuser_enabled? ( -- flag ) + s" boot_single" getenv -1 <> dup if + swap drop ( c-addr flag -- flag ) + then +; + +: singleuser_enable ( -- ) + s" set boot_single=YES" evaluate +; + +: singleuser_disable ( -- ) + s" boot_single" unsetenv +; + : init_singleuser ( N -- N ) - s" boot_single" getenv -1 <> if - drop ( n c-addr -- n ) \ unused + singleuser_enabled? if toggle_menuitem ( n -- n ) then ; @@ -109,21 +144,35 @@ variable root_state \ Now we're going to make the change effective - s" toggle_stateN @" \ base name of toggle state var - -rot 2dup 12 + c! rot \ replace 'N' with ASCII numeral - - evaluate 0= if - s" boot_single" unsetenv + dup toggle_stateN @ 0= if + singleuser_disable else - s" set boot_single=YES" evaluate + singleuser_enable then TRUE \ loop menu again ; +\ +\ Verbose Boot +\ + +: verbose_enabled? ( -- flag ) + s" boot_verbose" getenv -1 <> dup if + swap drop ( c-addr flag -- flag ) + then +; + +: verbose_enable ( -- ) + s" set boot_verbose=YES" evaluate +; + +: verbose_disable ( -- ) + s" boot_verbose" unsetenv +; + : init_verbose ( N -- N ) - s" boot_verbose" getenv -1 <> if - drop ( n c-addr -- n ) \ unused + verbose_enabled? if toggle_menuitem ( n -- n ) then ; @@ -134,18 +183,19 @@ variable root_state \ Now we're going to make the change effective - s" toggle_stateN @" \ base name of toggle state var - -rot 2dup 12 + c! rot \ replace 'N' with ASCII numeral - - evaluate 0= if - s" boot_verbose" unsetenv + dup toggle_stateN @ 0= if + verbose_disable else - s" set boot_verbose=YES" evaluate + verbose_enable then TRUE \ loop menu again ; +\ +\ Escape to Prompt +\ + : goto_prompt ( N -- N FALSE ) s" set autoboot_delay=NO" evaluate @@ -158,11 +208,12 @@ variable root_state FALSE \ exit the menu ; +\ +\ Cyclestate (used by kernel/root below) +\ + : init_cyclestate ( N K -- N ) - over ( n k -- n k n ) - s" cycle_stateN" ( n k n -- n k n c-addr u ) - -rot tuck 11 + c! swap ( n k n c-addr u -- n k c-addr u ) - evaluate ( n k c-addr u -- n k addr ) + over cycle_stateN ( n k -- n k addr ) begin tuck @ ( n k addr -- n addr k c ) over <> ( n addr k c -- n addr k 0|-1 ) @@ -174,6 +225,10 @@ variable root_state 2drop ( n k addr -- n ) ; +\ +\ Kernel +\ + : init_kernel ( N -- N ) kernel_state @ ( n -- n k ) init_cyclestate ( n k -- n ) @@ -185,21 +240,21 @@ variable root_state \ Now we're going to make the change effective - s" cycle_stateN" \ base name of array state var - -rot 2dup 11 + c! rot \ replace 'N' with ASCII numeral - evaluate \ translate name into address - @ \ dereference address into value + dup cycle_stateN @ dup kernel_state ! \ save a copy for re-initialization 48 + \ convert to ASCII numeral s" set kernel=${kernel_prefix}${kernel[N]}${kernel_suffix}" - \ command to assemble full kernel-path - -rot tuck 36 + c! swap \ replace 'N' with array index value - evaluate \ sets $kernel to full kernel-path + 36 +c! \ replace 'N' with ASCII numeral + evaluate \ sets $kernel to full kernel-path TRUE \ loop menu again ; +\ +\ Root +\ + : init_root ( N -- N ) root_state @ ( n -- n k ) init_cyclestate ( n k -- n ) @@ -211,21 +266,21 @@ variable root_state \ Now we're going to make the change effective - s" cycle_stateN" \ base name of array state var - -rot 2dup 11 + c! rot \ replace 'N' with ASCII numeral - evaluate \ translate name into address - @ \ dereference address into value + dup cycle_stateN @ dup root_state ! \ save a copy for re-initialization 48 + \ convert to ASCII numeral s" set root=${root_prefix}${root[N]}${root_suffix}" - \ command to assemble root image-path - -rot tuck 30 + c! swap \ replace 'N' with array index value - evaluate \ sets $kernel to full kernel-path + 30 +c! \ replace 'N' with ASCII numeral + evaluate \ sets $root to full root-path TRUE \ loop menu again ; +\ +\ Menusets +\ + : goto_menu ( N M -- N TRUE ) menu-unset menuset-loadsetnum ( n m -- n ) Modified: user/andre/tcp_workqueue/sys/boot/forth/menu.4th ============================================================================== --- user/andre/tcp_workqueue/sys/boot/forth/menu.4th Tue Nov 20 17:04:52 2012 (r243344) +++ user/andre/tcp_workqueue/sys/boot/forth/menu.4th Tue Nov 20 17:08:37 2012 (r243345) @@ -116,6 +116,48 @@ create init_text6 255 allot create init_text7 255 allot create init_text8 255 allot +: +c! ( N C-ADDR/U K -- C-ADDR/U ) + 3 pick 3 pick ( n c-addr/u k -- n c-addr/u k n c-addr ) + rot + c! ( n c-addr/u k n c-addr -- n c-addr/u ) + rot drop ( n c-addr/u -- c-addr/u ) +; + +: menukeyN ( N -- ADDR ) s" menukeyN" 7 +c! evaluate ; +: init_stateN ( N -- ADDR ) s" init_stateN" 10 +c! evaluate ; +: toggle_stateN ( N -- ADDR ) s" toggle_stateN" 12 +c! evaluate ; +: cycle_stateN ( N -- ADDR ) s" cycle_stateN" 11 +c! evaluate ; +: init_textN ( N -- C-ADDR ) s" init_textN" 9 +c! evaluate ; + +: str_loader_menu_title ( -- C-ADDR/U ) s" loader_menu_title" ; +: str_loader_menu_timeout_x ( -- C-ADDR/U ) s" loader_menu_timeout_x" ; +: str_loader_menu_timeout_y ( -- C-ADDR/U ) s" loader_menu_timeout_y" ; +: str_menu_init ( -- C-ADDR/U ) s" menu_init" ; +: str_menu_timeout_command ( -- C-ADDR/U ) s" menu_timeout_command" ; +: str_menu_reboot ( -- C-ADDR/U ) s" menu_reboot" ; +: str_menu_acpi ( -- C-ADDR/U ) s" menu_acpi" ; +: str_menu_options ( -- C-ADDR/U ) s" menu_options" ; +: str_menu_optionstext ( -- C-ADDR/U ) s" menu_optionstext" ; + +: str_menu_init[x] ( -- C-ADDR/U ) s" menu_init[x]" ; +: str_menu_command[x] ( -- C-ADDR/U ) s" menu_command[x]" ; +: str_menu_caption[x] ( -- C-ADDR/U ) s" menu_caption[x]" ; +: str_ansi_caption[x] ( -- C-ADDR/U ) s" ansi_caption[x]" ; +: str_menu_keycode[x] ( -- C-ADDR/U ) s" menu_keycode[x]" ; +: str_toggled_text[x] ( -- C-ADDR/U ) s" toggled_text[x]" ; +: str_toggled_ansi[x] ( -- C-ADDR/U ) s" toggled_ansi[x]" ; +: str_menu_caption[x][y] ( -- C-ADDR/U ) s" menu_caption[x][y]" ; +: str_ansi_caption[x][y] ( -- C-ADDR/U ) s" ansi_caption[x][y]" ; + +: menu_init[x] ( N -- C-ADDR/U ) str_menu_init[x] 10 +c! ; +: menu_command[x] ( N -- C-ADDR/U ) str_menu_command[x] 13 +c! ; +: menu_caption[x] ( N -- C-ADDR/U ) str_menu_caption[x] 13 +c! ; +: ansi_caption[x] ( N -- C-ADDR/U ) str_ansi_caption[x] 13 +c! ; +: menu_keycode[x] ( N -- C-ADDR/U ) str_menu_keycode[x] 13 +c! ; +: toggled_text[x] ( N -- C-ADDR/U ) str_toggled_text[x] 13 +c! ; +: toggled_ansi[x] ( N -- C-ADDR/U ) str_toggled_ansi[x] 13 +c! ; +: menu_caption[x][y] ( N M -- C-ADDR/U ) str_menu_caption[x][y] 16 +c! 13 +c! ; +: ansi_caption[x][y] ( N M -- C-ADDR/U ) str_ansi_caption[x][y] 16 +c! 13 +c! ; + : arch-i386? ( -- BOOL ) \ Returns TRUE (-1) on i386, FALSE (0) otherwise. s" arch-i386" environment? dup if drop @@ -172,10 +214,7 @@ create init_text8 255 allot \ ASCII numeral equal to user-selected menu item must be on the stack. \ We do not modify the stack, so the ASCII numeral is left on top. - s" init_textN" \ base name of buffer - -rot 2dup 9 + c! rot \ replace 'N' with ASCII num - - evaluate c@ 0= if + dup init_textN c@ 0= if \ NOTE: no need to check toggle_stateN since the first time we \ are called, we will populate init_textN. Further, we don't \ need to test whether menu_caption[x] (ansi_caption[x] when @@ -183,19 +222,16 @@ create init_text8 255 allot \ called if the caption was NULL. \ base name of environment variable + dup ( n -- n n ) \ key pressed loader_color? if - s" ansi_caption[x]" + ansi_caption[x] else - s" menu_caption[x]" + menu_caption[x] then - -rot 2dup 13 + c! rot \ replace 'x' with ASCII numeral - getenv dup -1 <> if - s" init_textN" \ base name of buffer - 4 pick \ copy ASCII num to top - rot tuck 9 + c! swap \ replace 'N' with ASCII num - evaluate + 2 pick ( n c-addr/u -- n c-addr/u n ) + init_textN ( n c-addr/u n -- n c-addr/u c-addr ) \ now we have the buffer c-addr on top \ ( followed by c-addr/u of current caption ) @@ -227,67 +263,49 @@ create init_text8 255 allot \ negate the toggled state so that we reverse the flow on subsequent \ calls. - s" toggle_stateN @" \ base name of toggle state var - -rot 2dup 12 + c! rot \ replace 'N' with ASCII numeral - - evaluate 0= if + dup toggle_stateN @ 0= if \ state is OFF, toggle to ON - \ base name of toggled text var + dup ( n -- n n ) \ key pressed loader_color? if - s" toggled_ansi[x]" + toggled_ansi[x] else - s" toggled_text[x]" + toggled_text[x] then - -rot 2dup 13 + c! rot \ replace 'x' with ASCII num - getenv dup -1 <> if \ Assign toggled text to menu caption - - \ base name of caption var + 2 pick ( n c-addr/u -- n c-addr/u n ) \ key pressed loader_color? if - s" ansi_caption[x]" + ansi_caption[x] else - s" menu_caption[x]" + menu_caption[x] then - 4 pick \ copy ASCII num to top - rot tuck 13 + c! swap \ replace 'x' with ASCII num - - setenv \ set new caption + setenv else \ No toggled text, keep the same caption - - drop + drop ( n -1 -- n ) \ getenv cruft then true \ new value of toggle state var (to be stored later) else \ state is ON, toggle to OFF - s" init_textN" \ base name of initial text buffer - -rot 2dup 9 + c! rot \ replace 'N' with ASCII numeral - evaluate \ convert string to c-addr - count \ convert c-addr to c-addr/u + dup init_textN count ( n -- n c-addr/u ) - \ base name of caption var + \ Assign init_textN text to menu caption + 2 pick ( n c-addr/u -- n c-addr/u n ) \ key pressed loader_color? if - s" ansi_caption[x]" + ansi_caption[x] else - s" menu_caption[x]" + menu_caption[x] then - 4 pick \ copy ASCII num to top - rot tuck 13 + c! swap \ replace 'x' with ASCII numeral + setenv - setenv \ set new caption - false \ new value of toggle state var (to be stored below) + false \ new value of toggle state var (to be stored below) then \ now we'll store the new toggle state (on top of stack) - s" toggle_stateN" \ base name of toggle state var - 3 pick \ copy ASCII numeral to top - rot tuck 12 + c! swap \ replace 'N' with ASCII numeral - evaluate \ convert string to addr - ! \ store new value + over toggle_stateN ! ; : cycle_menuitem ( N -- N ) \ cycles through array of choices for a menuitem @@ -295,28 +313,23 @@ create init_text8 255 allot \ ASCII numeral equal to user-selected menu item must be on the stack. \ We do not modify the stack, so the ASCII numeral is left on top. - s" cycle_stateN" \ base name of array state var - -rot 2dup 11 + c! rot \ replace 'N' with ASCII numeral - - evaluate \ we now have a pointer to the proper variable - dup @ \ resolve the pointer (but leave it on the stack) - 1+ \ increment the value + dup cycle_stateN dup @ 1+ \ get value and increment \ Before assigning the (incremented) value back to the pointer, \ let's test for the existence of this particular array element. \ If the element exists, we'll store index value and move on. \ Otherwise, we'll loop around to zero and store that. - dup 48 + \ duplicate Array index and convert to ASCII numeral + dup 48 + ( n addr k -- n addr k k' ) + \ duplicate array index and convert to ASCII numeral - \ base name of array caption text + 3 pick swap ( n addr k k' -- n addr k n k' ) \ (n,k') as (x,y) loader_color? if - s" ansi_caption[x][y]" + ansi_caption[x][y] else - s" menu_caption[x][y]" + menu_caption[x][y] then - -rot tuck 16 + c! swap \ replace 'y' with Array index - 4 pick rot tuck 13 + c! swap \ replace 'x' with menu choice + ( n addr k n k' -- n addr k c-addr/u ) \ Now test for the existence of our incremented array index in the \ form of $menu_caption[x][y] ($ansi_caption[x][y] with loader_color @@ -325,48 +338,47 @@ create init_text8 255 allot getenv dup -1 = if \ No caption set for this array index. Loop back to zero. - drop ( getenv cruft ) - drop ( incremented array index ) - 0 ( new array index that will be stored later ) + drop ( n addr k -1 -- n addr k ) \ getenv cruft + drop 0 ( n addr k -- n addr 0 ) \ new value to store later - \ base name of caption var + 2 pick [char] 0 ( n addr 0 -- n addr 0 n 48 ) \ (n,48) as (x,y) loader_color? if - s" ansi_caption[x][0]" + ansi_caption[x][y] else - s" menu_caption[x][0]" + menu_caption[x][y] then - 4 pick rot tuck 13 + c! swap \ replace 'x' with menu choice - + ( n addr 0 n 48 -- n addr 0 c-addr/u ) getenv dup -1 = if \ This is highly unlikely to occur, but to make \ sure that things move along smoothly, allocate \ a temporary NULL string - s" " + drop ( n addr 0 -1 -- n addr 0 ) \ getenv cruft + s" " ( n addr 0 -- n addr 0 c-addr/u ) then then \ At this point, we should have the following on the stack (in order, \ from bottom to top): \ - \ N - Ascii numeral representing the menu choice (inherited) - \ Addr - address of our internal cycle_stateN variable - \ N - zero-based number we intend to store to the above - \ C-Addr - string value we intend to store to menu_caption[x] - \ (or ansi_caption[x] with loader_color enabled) + \ n - Ascii numeral representing the menu choice (inherited) + \ addr - address of our internal cycle_stateN variable + \ k - zero-based number we intend to store to the above + \ c-addr/u - string value we intend to store to menu_caption[x] + \ (or ansi_caption[x] with loader_color enabled) \ \ Let's perform what we need to with the above. - \ base name of menuitem caption var + \ Assign array value text to menu caption + 4 pick ( n addr k c-addr/u -- n addr k c-addr/u n ) loader_color? if - s" ansi_caption[x]" + ansi_caption[x] else - s" menu_caption[x]" + menu_caption[x] then - 6 pick rot tuck 13 + c! swap \ replace 'x' with menu choice - setenv \ set the new caption + setenv - swap ! \ update array state variable + swap ! ( n addr k -- n ) \ update array state variable ; : acpipresent? ( -- flag ) \ Returns TRUE if ACPI is present, FALSE otherwise @@ -400,15 +412,15 @@ create init_text8 255 allot acpipresent? if acpienabled? if loader_color? if - s" toggled_ansi[x]" + str_toggled_ansi[x] else - s" toggled_text[x]" + str_toggled_text[x] then else loader_color? if - s" ansi_caption[x]" + str_ansi_caption[x] else - s" menu_caption[x]" + str_menu_caption[x] *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Wed Nov 21 19:57:58 2012 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 48158560; Wed, 21 Nov 2012 19:57:58 +0000 (UTC) (envelope-from andre@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 2DB218FC12; Wed, 21 Nov 2012 19:57:58 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qALJvwIh020596; Wed, 21 Nov 2012 19:57:58 GMT (envelope-from andre@svn.freebsd.org) Received: (from andre@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qALJvw10020593; Wed, 21 Nov 2012 19:57:58 GMT (envelope-from andre@svn.freebsd.org) Message-Id: <201211211957.qALJvw10020593@svn.freebsd.org> From: Andre Oppermann Date: Wed, 21 Nov 2012 19:57:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r243377 - in user/andre/tcp_workqueue/sys: kern sys X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Nov 2012 19:57:58 -0000 Author: andre Date: Wed Nov 21 19:57:57 2012 New Revision: 243377 URL: http://svnweb.freebsd.org/changeset/base/243377 Log: Extend m_print() to inform about all aspects of an mbuf, its header, external storage, packet header, m_tags and offloading features. A function callback is provided for protocols to also print parsed mbuf data contents. Add bit definition for various mbuf related flags for %b printing. Modified: user/andre/tcp_workqueue/sys/kern/uipc_mbuf.c user/andre/tcp_workqueue/sys/sys/mbuf.h Modified: user/andre/tcp_workqueue/sys/kern/uipc_mbuf.c ============================================================================== --- user/andre/tcp_workqueue/sys/kern/uipc_mbuf.c Wed Nov 21 18:38:56 2012 (r243376) +++ user/andre/tcp_workqueue/sys/kern/uipc_mbuf.c Wed Nov 21 19:57:57 2012 (r243377) @@ -1623,15 +1623,19 @@ m_getptr(struct mbuf *m, int loc, int *o return (NULL); } +/* + * Print all information on an mbuf. + */ void -m_print(const struct mbuf *m, int maxlen) +m_print(const struct mbuf *m, int maxlen, void (*func)(const struct mbuf *)) { int len; int pdata; const struct mbuf *m2; + struct m_tag *mt; if (m == NULL) { - printf("mbuf: %p\n", m); + printf("mbuf = %p\n", m); return; } @@ -1639,23 +1643,86 @@ m_print(const struct mbuf *m, int maxlen len = m->m_pkthdr.len; else len = -1; - m2 = m; - while (m2 != NULL && (len == -1 || len)) { + + for (m2 = m; m2 != NULL && (len == -1 || len); m2 = m2->m_next) { pdata = m2->m_len; if (maxlen != -1 && pdata > maxlen) pdata = maxlen; - printf("mbuf: %p len: %d, next: %p, %b%s", m2, m2->m_len, - m2->m_next, m2->m_flags, "\20\20freelist\17skipfw" - "\11proto5\10proto4\7proto3\6proto2\5proto1\4rdonly" - "\3eor\2pkthdr\1ext", pdata ? "" : "\n"); + + printf("mbuf = 0x%p\n" + "\t m_next = 0x%p\n" + "\t m_data = 0x%p\n" + "\t m_len = %u\n" + "\tm_flags = 0x%8X\n" + "\tm_flags = %b\n" + "\t m_type = %u\n", + m2, m2->m_next, m2->m_data, m2->m_len, m2->m_flags, + (m2->m_flags & 0xFFFFFF), M_FLAG_BITS, m2->m_type); + + if (m2->m_flags & M_EXT) { + printf(" m_ext:\n" + "\t ext_buf = 0x%p\n" + "\text_free = 0x%p\n" + "\text_arg1 = 0x%p\n" + "\text_arg2 = 0x%p\n" + "\text_size = %u\n" + "\t ref_cnt = %u (0x%p)\n" + "\text_type = %X %b\n", + m2->m_ext.ext_buf, m2->m_ext.ext_free, + m2->m_ext.ext_arg1, m2->m_ext.ext_arg2, + m2->m_ext.ext_size, (*m2->m_ext.ref_cnt), + m2->m_ext.ref_cnt, (m2->m_type & 0xFF), + (m2->m_type & 0xF00), M_EXT_TYPE_BITS); + } + + if (m2->m_flags & M_PKTHDR) { + printf(" m_pkthdr:\n" + "\t rcvif = 0x%p" + "\t header = 0x%p\n" + "\t len = %u\n" + "\t flowid = 0x%X\n" + "\t csum_flags = 0x%8X\n" + "\t csum_flags = %b\n" + "\tcsum_l2hlen = %u\n" + "\tcsum_l3hlen = %u\n" + "\tcsum_l4hlen = %u\n" + "\t tso_segsz = %u\n" + "\t ether_vtag = 0x%X\n" + "\t hash_type = 0x%X\n", + m2->m_pkthdr.rcvif, m2->m_pkthdr.header, + m2->m_pkthdr.len, m2->m_pkthdr.flowid, + m2->m_pkthdr.csum_flags, + m2->m_pkthdr.csum_flags, M_CSUM_FLAG_BITS, + m2->m_pkthdr.csum_l2hlen, m2->m_pkthdr.csum_l3hlen, + m2->m_pkthdr.csum_l4hlen, m2->m_pkthdr.tso_segsz, + m2->m_pkthdr.ether_vtag, M_HASHTYPE_GET(m2)); + + for (mt = SLIST_FIRST(&m2->m_pkthdr.tags); mt != NULL; + mt = SLIST_NEXT(mt, m_tag_link)) { + printf(" m_tag:\n" + "\t m_tag_id = %u %b\n" + "\t m_tag_len = %u\n" + "\tm_tag_cookie = 0x%X\n" + "\t m_tag_free = 0x%p\n", + (mt->m_tag_id & 0xFF), + (mt->m_tag_id & 0xF00), MTAG_FLAG_BITS, + mt->m_tag_len, mt->m_tag_cookie, + mt->m_tag_free); + printf("\tm_tag data:\n"); + printf("\t %*D\n", + mt->m_tag_len, (u_char *)(mt + 1), " "); + } + } + if (pdata) - printf(", %*D\n", pdata, (u_char *)m2->m_data, "-"); + printf(", %*D\n", pdata, (u_char *)m2->m_data, " "); if (len != -1) len -= m2->m_len; - m2 = m2->m_next; } if (len > 0) printf("%d bytes unaccounted for.\n", len); + if (func != NULL) + (*func)(m); return; } Modified: user/andre/tcp_workqueue/sys/sys/mbuf.h ============================================================================== --- user/andre/tcp_workqueue/sys/sys/mbuf.h Wed Nov 21 18:38:56 2012 (r243376) +++ user/andre/tcp_workqueue/sys/sys/mbuf.h Wed Nov 21 19:57:57 2012 (r243377) @@ -216,6 +216,12 @@ struct mbuf { #define M_FLOWID 0x00400000 /* deprecated: flowid is valid */ #define M_HASHTYPEBITS 0x0F000000 /* mask of bits holding flowid hash type */ +#define M_FLAG_BITS \ + "\20\27FLOWID\26PROTO8\25PROTO7\24PROTO6\23NOFREE\22PROMISC" \ + "\21VLANTAG\20FREELIST\17SKIP_FIREWALL\16LASTFRAG\15FIRSTFRAG" \ + "\14FRAG\13MCAST\12BCAST\11PROTO5\10PROTO4\7PROTO3\6PROTO2" \ + "\5PROTO1\4RDONLY\3EOR\2PKTHDR\1EXT" /* for use with m_print */ + /* * For RELENG_{6,7} steal these flags for limited multiple routing table * support. In RELENG_8 and beyond, use just one flag and a tag. @@ -284,6 +290,9 @@ struct mbuf { #define EXT_DISPOSABLE 300 /* can throw this buffer away w/page flipping */ #define EXT_EXTREF 400 /* has externally maintained ref_cnt ptr */ +#define M_EXT_TYPE_BITS \ + "\20\16ext_EXTREF\15ext_DISPOSABLE\14ext_MOD_TYPE\13ext_NET_DRV" + /* * Flags indicating hw checksum support and sw checksum requirements. This * field can be directly tested against if_data.ifi_hwassist. @@ -376,6 +385,13 @@ struct mbuf { #define CSUM_IP6_TSO 0x00440000 /* IPv6/TSO */ #define CSUM_IP6_SCO 0x00880000 /* SCTP chunk offload */ +#define M_CSUM_FLAG_BITS \ + "\20\40csum_L4_VALID\37csum_L4_CALC\36csum_L3_VALID\35csum_L3_CALC" \ + "\30csum_IP6_SCO\27csum_IP6_TSO\26csum_IP6_UFO\25csum_IP6_FRAG0" \ + "\24csum_IP6_SCTP\23csum_IP6_TCP\22csum_IP6_UDP\21csum_IP6" \ + "\14csum_IP_SCO\13csum_IP_TSO\12csum_IP_UFO\11csum_IP_FRAG0" \ + "\10csum_IP_SCTP\7csum_IP_TCP\6csum_IP_UDP\5csum_IP" + /* Definition compatiblity with < 20121118, goes away after tree pruning */ #define CSUM_UDP CSUM_IP_UDP #define CSUM_TCP CSUM_IP_TCP @@ -1006,7 +1022,8 @@ u_int m_length(struct mbuf *, struct m int m_mbuftouio(struct uio *, struct mbuf *, int); void m_move_pkthdr(struct mbuf *, struct mbuf *); struct mbuf *m_prepend(struct mbuf *, int, int); -void m_print(const struct mbuf *, int); +void m_print(const struct mbuf *, int, + void (*)(const struct mbuf *)); struct mbuf *m_pulldown(struct mbuf *, int, int, int *); struct mbuf *m_pullup(struct mbuf *, int); int m_sanity(struct mbuf *, int); @@ -1065,6 +1082,9 @@ struct mbuf *m_unshare(struct mbuf *, in */ #define MTAG_PERSISTENT 0x800 +#define MTAG_FLAG_BITS \ + "\20\14mtag_PERSISTENT" + #define PACKET_TAG_NONE 0 /* Nadda */ /* Packet tags for use with PACKET_ABI_COMPAT. */ From owner-svn-src-user@FreeBSD.ORG Wed Nov 21 21:03:15 2012 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 55D66738; Wed, 21 Nov 2012 21:03:15 +0000 (UTC) (envelope-from andre@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 385BF8FC15; Wed, 21 Nov 2012 21:03:15 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qALL3FMk029547; Wed, 21 Nov 2012 21:03:15 GMT (envelope-from andre@svn.freebsd.org) Received: (from andre@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qALL3EFF029525; Wed, 21 Nov 2012 21:03:14 GMT (envelope-from andre@svn.freebsd.org) Message-Id: <201211212103.qALL3EFF029525@svn.freebsd.org> From: Andre Oppermann Date: Wed, 21 Nov 2012 21:03:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r243379 - in user/andre/tcp_workqueue/sys: dev/bxe dev/cxgb dev/cxgbe dev/e1000 dev/ixgbe dev/mxge dev/oce dev/sfxge dev/vxge kern net netinet netinet6 sys X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Nov 2012 21:03:15 -0000 Author: andre Date: Wed Nov 21 21:03:14 2012 New Revision: 243379 URL: http://svnweb.freebsd.org/changeset/base/243379 Log: Move the RSS hash type definition from m_flags to m_pkthdr.csum_flags and change the names accordingly. The csum and offload section is a much more appropriate place for the RSS hash information. Modified: user/andre/tcp_workqueue/sys/dev/bxe/if_bxe.c user/andre/tcp_workqueue/sys/dev/cxgb/cxgb_sge.c user/andre/tcp_workqueue/sys/dev/cxgbe/t4_main.c user/andre/tcp_workqueue/sys/dev/cxgbe/t4_sge.c user/andre/tcp_workqueue/sys/dev/e1000/if_igb.c user/andre/tcp_workqueue/sys/dev/ixgbe/ixgbe.c user/andre/tcp_workqueue/sys/dev/ixgbe/ixv.c user/andre/tcp_workqueue/sys/dev/mxge/if_mxge.c user/andre/tcp_workqueue/sys/dev/oce/oce_if.c user/andre/tcp_workqueue/sys/dev/sfxge/sfxge_rx.c user/andre/tcp_workqueue/sys/dev/sfxge/sfxge_tx.c user/andre/tcp_workqueue/sys/dev/vxge/vxge.c user/andre/tcp_workqueue/sys/kern/uipc_mbuf.c user/andre/tcp_workqueue/sys/net/ieee8023ad_lacp.c user/andre/tcp_workqueue/sys/net/if_lagg.c user/andre/tcp_workqueue/sys/net/netisr.c user/andre/tcp_workqueue/sys/netinet/ip_output.c user/andre/tcp_workqueue/sys/netinet/sctp_input.c user/andre/tcp_workqueue/sys/netinet/sctp_output.c user/andre/tcp_workqueue/sys/netinet/tcp_input.c user/andre/tcp_workqueue/sys/netinet6/sctp6_usrreq.c user/andre/tcp_workqueue/sys/sys/mbuf.h Modified: user/andre/tcp_workqueue/sys/dev/bxe/if_bxe.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/bxe/if_bxe.c Wed Nov 21 20:29:27 2012 (r243378) +++ user/andre/tcp_workqueue/sys/dev/bxe/if_bxe.c Wed Nov 21 21:03:14 2012 (r243379) @@ -9455,7 +9455,7 @@ bxe_tx_mq_start(struct ifnet *ifp, struc fp_index = 0; /* If using flow ID, assign the TX queue based on the flow ID. */ - if ((m->m_flags & M_FLOWID) != 0) + if (CSUM_HASH_GET(m) != 0) fp_index = m->m_pkthdr.flowid % sc->num_queues; /* Select the fastpath TX queue for the frame. */ @@ -15047,7 +15047,7 @@ bxe_rxeof(struct bxe_fastpath *fp) #if __FreeBSD_version >= 800000 /* Tell OS what RSS queue was used for this flow. */ m->m_pkthdr.flowid = fp->index; - m->m_flags |= M_FLOWID; + CSUM_HASH_SET(m, CSUM_HASH_OPAQUE); #endif /* Last chance to check for problems. */ Modified: user/andre/tcp_workqueue/sys/dev/cxgb/cxgb_sge.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/cxgb/cxgb_sge.c Wed Nov 21 20:29:27 2012 (r243378) +++ user/andre/tcp_workqueue/sys/dev/cxgb/cxgb_sge.c Wed Nov 21 21:03:14 2012 (r243379) @@ -1739,7 +1739,7 @@ cxgb_transmit(struct ifnet *ifp, struct return (0); } - if (m->m_flags & M_FLOWID) + if (CSUM_HASH_GET(m)) qidx = (m->m_pkthdr.flowid % pi->nqsets) + pi->first_qset; qs = &pi->adapter->sge.qs[qidx]; @@ -2906,7 +2906,7 @@ process_responses(adapter_t *adap, struc eop = get_packet(adap, drop_thresh, qs, mh, r); if (eop) { if (r->rss_hdr.hash_type && !adap->timestamp) - mh->mh_head->m_flags |= M_FLOWID; + CSUM_HASH_SET(mh->mh_head, CSUM_HASH_OPAQUE); mh->mh_head->m_pkthdr.flowid = rss_hash; } Modified: user/andre/tcp_workqueue/sys/dev/cxgbe/t4_main.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/cxgbe/t4_main.c Wed Nov 21 20:29:27 2012 (r243378) +++ user/andre/tcp_workqueue/sys/dev/cxgbe/t4_main.c Wed Nov 21 21:03:14 2012 (r243379) @@ -1171,7 +1171,7 @@ cxgbe_transmit(struct ifnet *ifp, struct return (ENETDOWN); } - if (m->m_flags & M_FLOWID) + if (CSUM_HASH_GET(m)) txq += (m->m_pkthdr.flowid % pi->ntxq); br = txq->br; Modified: user/andre/tcp_workqueue/sys/dev/cxgbe/t4_sge.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/cxgbe/t4_sge.c Wed Nov 21 20:29:27 2012 (r243378) +++ user/andre/tcp_workqueue/sys/dev/cxgbe/t4_sge.c Wed Nov 21 21:03:14 2012 (r243379) @@ -1122,7 +1122,7 @@ t4_eth_rx(struct sge_iq *iq, const struc m0->m_data += fl_pktshift; m0->m_pkthdr.rcvif = ifp; - m0->m_flags |= M_FLOWID; + CSUM_HASH_SET(m0, CSUM_HASH_OPAQUE); m0->m_pkthdr.flowid = rss->hash_val; if (cpl->csum_calc && !cpl->err_vec) { Modified: user/andre/tcp_workqueue/sys/dev/e1000/if_igb.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/e1000/if_igb.c Wed Nov 21 20:29:27 2012 (r243378) +++ user/andre/tcp_workqueue/sys/dev/e1000/if_igb.c Wed Nov 21 21:03:14 2012 (r243379) @@ -952,7 +952,7 @@ igb_mq_start(struct ifnet *ifp, struct m int i, err = 0; /* Which queue to use */ - if ((m->m_flags & M_FLOWID) != 0) + if (CSUM_HASH_GET(m) != 0) i = m->m_pkthdr.flowid % adapter->num_queues; else i = curcpu % adapter->num_queues; @@ -4855,7 +4855,7 @@ igb_rxeof(struct igb_queue *que, int cou } #if __FreeBSD_version >= 800000 rxr->fmp->m_pkthdr.flowid = que->msix; - rxr->fmp->m_flags |= M_FLOWID; + CSUM_HASH_SET(rxr->fmp, CSUM_HASH_OPAQUE); #endif sendmp = rxr->fmp; /* Make sure to set M_PKTHDR. */ Modified: user/andre/tcp_workqueue/sys/dev/ixgbe/ixgbe.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/ixgbe/ixgbe.c Wed Nov 21 20:29:27 2012 (r243378) +++ user/andre/tcp_workqueue/sys/dev/ixgbe/ixgbe.c Wed Nov 21 21:03:14 2012 (r243379) @@ -812,7 +812,7 @@ ixgbe_mq_start(struct ifnet *ifp, struct int i = 0, err = 0; /* Which queue to use */ - if ((m->m_flags & M_FLOWID) != 0) + if (CSUM_HASH_GET(m) != 0) i = m->m_pkthdr.flowid % adapter->num_queues; else i = curcpu % adapter->num_queues; @@ -4640,7 +4640,7 @@ ixgbe_rxeof(struct ix_queue *que, int co ixgbe_rx_checksum(staterr, sendmp, ptype); #if __FreeBSD_version >= 800000 sendmp->m_pkthdr.flowid = que->msix; - sendmp->m_flags |= M_FLOWID; + CSUM_HASH_SET(sendmp, CSUM_HASH_OPAQUE); #endif } next_desc: Modified: user/andre/tcp_workqueue/sys/dev/ixgbe/ixv.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/ixgbe/ixv.c Wed Nov 21 20:29:27 2012 (r243378) +++ user/andre/tcp_workqueue/sys/dev/ixgbe/ixv.c Wed Nov 21 21:03:14 2012 (r243379) @@ -583,7 +583,7 @@ ixv_mq_start(struct ifnet *ifp, struct m int i = 0, err = 0; /* Which queue to use */ - if ((m->m_flags & M_FLOWID) != 0) + if (CSUM_HASH_GET(m) != 0) i = m->m_pkthdr.flowid % adapter->num_queues; txr = &adapter->tx_rings[i]; @@ -3475,7 +3475,7 @@ ixv_rxeof(struct ix_queue *que, int coun ixv_rx_checksum(staterr, sendmp, ptype); #if __FreeBSD_version >= 800000 sendmp->m_pkthdr.flowid = que->msix; - sendmp->m_flags |= M_FLOWID; + CSUM_HASH_SET(sendmp, CSUM_HASH_OPAQUE); #endif } next_desc: Modified: user/andre/tcp_workqueue/sys/dev/mxge/if_mxge.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/mxge/if_mxge.c Wed Nov 21 20:29:27 2012 (r243378) +++ user/andre/tcp_workqueue/sys/dev/mxge/if_mxge.c Wed Nov 21 21:03:14 2012 (r243379) @@ -2593,7 +2593,7 @@ mxge_rx_done_big(struct mxge_slice_state /* flowid only valid if RSS hashing is enabled */ if (sc->num_slices > 1) { m->m_pkthdr.flowid = (ss - sc->ss); - m->m_flags |= M_FLOWID; + CSUM_HASH_SET(m, CSUM_HASH_OPAQUE); } /* pass the frame up the stack */ (*ifp->if_input)(ifp, m); @@ -2658,7 +2658,7 @@ mxge_rx_done_small(struct mxge_slice_sta /* flowid only valid if RSS hashing is enabled */ if (sc->num_slices > 1) { m->m_pkthdr.flowid = (ss - sc->ss); - m->m_flags |= M_FLOWID; + CSUM_HASH_SET(m, CSUM_HASH_OPAQUE); } /* pass the frame up the stack */ (*ifp->if_input)(ifp, m); Modified: user/andre/tcp_workqueue/sys/dev/oce/oce_if.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/oce/oce_if.c Wed Nov 21 20:29:27 2012 (r243378) +++ user/andre/tcp_workqueue/sys/dev/oce/oce_if.c Wed Nov 21 21:03:14 2012 (r243379) @@ -485,7 +485,7 @@ oce_multiq_start(struct ifnet *ifp, stru int queue_index = 0; int status = 0; - if ((m->m_flags & M_FLOWID) != 0) + if (CSUM_HASH_GET(m) != 0) queue_index = m->m_pkthdr.flowid % sc->nwqs; wq = sc->wq[queue_index]; @@ -1280,7 +1280,7 @@ oce_rx(struct oce_rq *rq, uint32_t rqe_i m->m_pkthdr.rcvif = sc->ifp; #if __FreeBSD_version >= 800000 m->m_pkthdr.flowid = rq->queue_index; - m->m_flags |= M_FLOWID; + CSUM_HASH_SET(m, CSUM_HASH_OPAQUE); #endif /* This deternies if vlan tag is Valid */ if (oce_cqe_vtp_valid(sc, cqe)) { Modified: user/andre/tcp_workqueue/sys/dev/sfxge/sfxge_rx.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/sfxge/sfxge_rx.c Wed Nov 21 20:29:27 2012 (r243378) +++ user/andre/tcp_workqueue/sys/dev/sfxge/sfxge_rx.c Wed Nov 21 21:03:14 2012 (r243379) @@ -304,7 +304,7 @@ sfxge_rx_deliver(struct sfxge_softc *sc, if (rx_desc->flags & EFX_PKT_TCP) { m->m_pkthdr.flowid = EFX_RX_HASH_VALUE(EFX_RX_HASHALG_TOEPLITZ, mtod(m, uint8_t *)); - m->m_flags |= M_FLOWID; + CSUM_HASH_SET(m, CSUM_HASH_OPAQUE); } #endif m->m_data += sc->rx_prefix_size; @@ -355,7 +355,7 @@ sfxge_lro_deliver(struct sfxge_lro_state #ifdef SFXGE_HAVE_MQ m->m_pkthdr.flowid = c->conn_hash; - m->m_flags |= M_FLOWID; + CSUM_HASH_SET(m, CSUM_HASH_OPAQUE); #endif m->m_pkthdr.csum_flags = csum_flags; __sfxge_rx_deliver(sc, m); Modified: user/andre/tcp_workqueue/sys/dev/sfxge/sfxge_tx.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/sfxge/sfxge_tx.c Wed Nov 21 20:29:27 2012 (r243378) +++ user/andre/tcp_workqueue/sys/dev/sfxge/sfxge_tx.c Wed Nov 21 21:03:14 2012 (r243379) @@ -595,7 +595,7 @@ sfxge_if_transmit(struct ifnet *ifp, str if (m->m_pkthdr.csum_flags & (CSUM_IP_UDP|CSUM_IP_TCP|CSUM_TSO)) { int index = 0; - if (m->m_flags & M_FLOWID) { + if (CSUM_HASH_GET(m)) { uint32_t hash = m->m_pkthdr.flowid; index = sc->rx_indir_table[hash % SFXGE_RX_SCALE_MAX]; Modified: user/andre/tcp_workqueue/sys/dev/vxge/vxge.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/vxge/vxge.c Wed Nov 21 20:29:27 2012 (r243378) +++ user/andre/tcp_workqueue/sys/dev/vxge/vxge.c Wed Nov 21 21:03:14 2012 (r243379) @@ -660,7 +660,7 @@ vxge_mq_send(ifnet_t ifp, mbuf_t m_head) if (vdev->config.tx_steering) { i = vxge_vpath_get(vdev, m_head); - } else if ((m_head->m_flags & M_FLOWID) != 0) { + } else if (CSUM_HASH_GET(m_head) != 0) { i = m_head->m_pkthdr.flowid % vdev->no_of_vpath; } @@ -1070,7 +1070,7 @@ vxge_rx_compl(vxge_hal_vpath_h vpath_han vxge_rx_checksum(ext_info, mbuf_up); #if __FreeBSD_version >= 800000 - mbuf_up->m_flags |= M_FLOWID; + CSUM_HASH_SET(mbuf_up, CSUM_HASH_OPAQUE); mbuf_up->m_pkthdr.flowid = vpath->vp_index; #endif /* Post-Read sync for buffers */ Modified: user/andre/tcp_workqueue/sys/kern/uipc_mbuf.c ============================================================================== --- user/andre/tcp_workqueue/sys/kern/uipc_mbuf.c Wed Nov 21 20:29:27 2012 (r243378) +++ user/andre/tcp_workqueue/sys/kern/uipc_mbuf.c Wed Nov 21 21:03:14 2012 (r243379) @@ -1695,7 +1695,7 @@ m_print(const struct mbuf *m, int maxlen m2->m_pkthdr.csum_flags, M_CSUM_FLAG_BITS, m2->m_pkthdr.csum_l2hlen, m2->m_pkthdr.csum_l3hlen, m2->m_pkthdr.csum_l4hlen, m2->m_pkthdr.tso_segsz, - m2->m_pkthdr.ether_vtag, M_HASHTYPE_GET(m2)); + m2->m_pkthdr.ether_vtag, CSUM_HASH_GET(m2)); for (mt = SLIST_FIRST(&m2->m_pkthdr.tags); mt != NULL; mt = SLIST_NEXT(mt, m_tag_link)) { Modified: user/andre/tcp_workqueue/sys/net/ieee8023ad_lacp.c ============================================================================== --- user/andre/tcp_workqueue/sys/net/ieee8023ad_lacp.c Wed Nov 21 20:29:27 2012 (r243378) +++ user/andre/tcp_workqueue/sys/net/ieee8023ad_lacp.c Wed Nov 21 21:03:14 2012 (r243379) @@ -815,7 +815,7 @@ lacp_select_tx_port(struct lagg_softc *s return (NULL); } - if (sc->use_flowid && (m->m_flags & M_FLOWID)) + if (sc->use_flowid && CSUM_HASH_GET(m)) hash = m->m_pkthdr.flowid; else hash = lagg_hashmbuf(sc, m, lsc->lsc_hashkey); Modified: user/andre/tcp_workqueue/sys/net/if_lagg.c ============================================================================== --- user/andre/tcp_workqueue/sys/net/if_lagg.c Wed Nov 21 20:29:27 2012 (r243378) +++ user/andre/tcp_workqueue/sys/net/if_lagg.c Wed Nov 21 21:03:14 2012 (r243379) @@ -174,7 +174,7 @@ static int lagg_failover_rx_all = 0; /* SYSCTL_INT(_net_link_lagg, OID_AUTO, failover_rx_all, CTLFLAG_RW, &lagg_failover_rx_all, 0, "Accept input from any interface in a failover lagg"); -static int def_use_flowid = 1; /* Default value for using M_FLOWID */ +static int def_use_flowid = 1; /* Default value for using flowid */ TUNABLE_INT("net.link.lagg.default_use_flowid", &def_use_flowid); SYSCTL_INT(_net_link_lagg, OID_AUTO, default_use_flowid, CTLFLAG_RW, &def_use_flowid, 0, @@ -1760,7 +1760,7 @@ lagg_lb_start(struct lagg_softc *sc, str struct lagg_port *lp = NULL; uint32_t p = 0; - if (sc->use_flowid && (m->m_flags & M_FLOWID)) + if (sc->use_flowid && CSUM_HASH_GET(m)) p = m->m_pkthdr.flowid; else p = lagg_hashmbuf(sc, m, lb->lb_key); Modified: user/andre/tcp_workqueue/sys/net/netisr.c ============================================================================== --- user/andre/tcp_workqueue/sys/net/netisr.c Wed Nov 21 20:29:27 2012 (r243378) +++ user/andre/tcp_workqueue/sys/net/netisr.c Wed Nov 21 21:03:14 2012 (r243379) @@ -727,12 +727,12 @@ netisr_select_cpuid(struct netisr_proto } if (policy == NETISR_POLICY_FLOW) { - if (!(m->m_flags & M_FLOWID) && npp->np_m2flow != NULL) { + if (!CSUM_HASH_GET(m) && npp->np_m2flow != NULL) { m = npp->np_m2flow(m, source); if (m == NULL) return (NULL); } - if (m->m_flags & M_FLOWID) { + if (CSUM_HASH_GET(m)) { *cpuidp = netisr_default_flow2cpu(m->m_pkthdr.flowid); return (m); Modified: user/andre/tcp_workqueue/sys/netinet/ip_output.c ============================================================================== --- user/andre/tcp_workqueue/sys/netinet/ip_output.c Wed Nov 21 20:29:27 2012 (r243378) +++ user/andre/tcp_workqueue/sys/netinet/ip_output.c Wed Nov 21 21:03:14 2012 (r243379) @@ -140,7 +140,7 @@ ip_output(struct mbuf *m, struct mbuf *o M_SETFIB(m, inp->inp_inc.inc_fibnum); if (inp->inp_flags & (INP_HW_FLOWID|INP_SW_FLOWID)) { m->m_pkthdr.flowid = inp->inp_flowid; - m->m_flags |= M_FLOWID; + CSUM_HASH_SET(m, CSUM_HASH_OPAQUE); } } Modified: user/andre/tcp_workqueue/sys/netinet/sctp_input.c ============================================================================== --- user/andre/tcp_workqueue/sys/netinet/sctp_input.c Wed Nov 21 20:29:27 2012 (r243378) +++ user/andre/tcp_workqueue/sys/netinet/sctp_input.c Wed Nov 21 21:03:14 2012 (r243379) @@ -6015,7 +6015,7 @@ sctp_input_with_port(struct mbuf *i_pak, m->m_pkthdr.len, if_name(m->m_pkthdr.rcvif), m->m_pkthdr.csum_flags); - if (m->m_flags & M_FLOWID) { + if (CSUM_HASH_GET(m)) { mflowid = m->m_pkthdr.flowid; use_mflowid = 1; } else { @@ -6112,7 +6112,7 @@ sctp_input(struct mbuf *m, int off) uint32_t flowid, tag; if (mp_ncpus > 1) { - if (m->m_flags & M_FLOWID) { + if (CSUM_HASH_GET(m)) { flowid = m->m_pkthdr.flowid; } else { /* @@ -6131,7 +6131,7 @@ sctp_input(struct mbuf *m, int off) tag = htonl(sh->v_tag); flowid = tag ^ ntohs(sh->dest_port) ^ ntohs(sh->src_port); m->m_pkthdr.flowid = flowid; - m->m_flags |= M_FLOWID; + CSUM_HASH_SET(m, CSUM_HASH_OPAQUE); } cpu_to_use = sctp_cpuarry[flowid % mp_ncpus]; sctp_queue_to_mcore(m, off, cpu_to_use); Modified: user/andre/tcp_workqueue/sys/netinet/sctp_output.c ============================================================================== --- user/andre/tcp_workqueue/sys/netinet/sctp_output.c Wed Nov 21 20:29:27 2012 (r243378) +++ user/andre/tcp_workqueue/sys/netinet/sctp_output.c Wed Nov 21 21:03:14 2012 (r243379) @@ -3957,11 +3957,11 @@ sctp_lowlevel_chunk_output(struct sctp_i } #endif m->m_pkthdr.flowid = net->flowid; - m->m_flags |= M_FLOWID; + CSUM_HASH_SET(m, CSUM_HASH_OPAQUE); } else { if (use_mflowid != 0) { m->m_pkthdr.flowid = mflowid; - m->m_flags |= M_FLOWID; + CSUM_HASH_SET(m, CSUM_HASH_OPAQUE); } } packet_length = sctp_calculate_len(m); @@ -4246,11 +4246,11 @@ sctp_lowlevel_chunk_output(struct sctp_i } #endif m->m_pkthdr.flowid = net->flowid; - m->m_flags |= M_FLOWID; + CSUM_HASH_SET(m, CSUM_HASH_OPAQUE); } else { if (use_mflowid != 0) { m->m_pkthdr.flowid = mflowid; - m->m_flags |= M_FLOWID; + CSUM_HASH_SET(m, CSUM_HASH_OPAQUE); } } packet_length = sctp_calculate_len(m); @@ -10881,7 +10881,7 @@ sctp_send_resp_msg(struct sockaddr *src, SCTP_BUF_NEXT(mout) = cause; if (use_mflowid != 0) { mout->m_pkthdr.flowid = mflowid; - mout->m_flags |= M_FLOWID; + CSUM_HASH_SET(mout, CSUM_HASH_OPAQUE); } #ifdef INET ip = NULL; Modified: user/andre/tcp_workqueue/sys/netinet/tcp_input.c ============================================================================== --- user/andre/tcp_workqueue/sys/netinet/tcp_input.c Wed Nov 21 20:29:27 2012 (r243378) +++ user/andre/tcp_workqueue/sys/netinet/tcp_input.c Wed Nov 21 21:03:14 2012 (r243379) @@ -876,7 +876,7 @@ findpcb: } INP_WLOCK_ASSERT(inp); if (!(inp->inp_flags & INP_HW_FLOWID) - && (m->m_flags & M_FLOWID) + && (CSUM_HASH_GET(m)) && ((inp->inp_socket == NULL) || !(inp->inp_socket->so_options & SO_ACCEPTCONN))) { inp->inp_flags |= INP_HW_FLOWID; Modified: user/andre/tcp_workqueue/sys/netinet6/sctp6_usrreq.c ============================================================================== --- user/andre/tcp_workqueue/sys/netinet6/sctp6_usrreq.c Wed Nov 21 20:29:27 2012 (r243378) +++ user/andre/tcp_workqueue/sys/netinet6/sctp6_usrreq.c Wed Nov 21 21:03:14 2012 (r243379) @@ -113,7 +113,7 @@ sctp6_input_with_port(struct mbuf **i_pa m->m_pkthdr.len, if_name(m->m_pkthdr.rcvif), m->m_pkthdr.csum_flags); - if (m->m_flags & M_FLOWID) { + if (CSUM_HASH_GET(m)) { mflowid = m->m_pkthdr.flowid; use_mflowid = 1; } else { Modified: user/andre/tcp_workqueue/sys/sys/mbuf.h ============================================================================== --- user/andre/tcp_workqueue/sys/sys/mbuf.h Wed Nov 21 20:29:27 2012 (r243378) +++ user/andre/tcp_workqueue/sys/sys/mbuf.h Wed Nov 21 21:03:14 2012 (r243379) @@ -213,8 +213,6 @@ struct mbuf { #define M_PROTO6 0x00080000 /* protocol-specific */ #define M_PROTO7 0x00100000 /* protocol-specific */ #define M_PROTO8 0x00200000 /* protocol-specific */ -#define M_FLOWID 0x00400000 /* deprecated: flowid is valid */ -#define M_HASHTYPEBITS 0x0F000000 /* mask of bits holding flowid hash type */ #define M_FLAG_BITS \ "\20\27FLOWID\26PROTO8\25PROTO7\24PROTO6\23NOFREE\22PROMISC" \ @@ -240,40 +238,39 @@ struct mbuf { * can then be used to maintain ordering while delivering packets to the OS * via parallel input queues, as well as to provide a stateless affinity * model. NIC drivers can pass up the hash via m->m_pkthdr.flowid, and set - * m_flag fields to indicate how the hash should be interpreted by the + * csum_flags fields to indicate how the hash should be interpreted by the * network stack. * * Most NICs support RSS, which provides ordering and explicit affinity, and * use the hash m_flag bits to indicate what header fields were covered by - * the hash. M_HASHTYPE_OPAQUE can be set by non-RSS cards or configurations + * the hash. CSUM_HASH_OPAQUE can be set by non-RSS cards or configurations * that provide an opaque flow identifier, allowing for ordering and * distribution without explicit affinity. */ -#define M_HASHTYPE_SHIFT 24 -#define M_HASHTYPE_NONE 0x0 -#define M_HASHTYPE_RSS_IPV4 0x1 /* IPv4 2-tuple */ -#define M_HASHTYPE_RSS_TCP_IPV4 0x2 /* TCPv4 4-tuple */ -#define M_HASHTYPE_RSS_IPV6 0x3 /* IPv6 2-tuple */ -#define M_HASHTYPE_RSS_TCP_IPV6 0x4 /* TCPv6 4-tuple */ -#define M_HASHTYPE_RSS_IPV6_EX 0x5 /* IPv6 2-tuple + ext hdrs */ -#define M_HASHTYPE_RSS_TCP_IPV6_EX 0x6 /* TCPv6 4-tiple + ext hdrs */ -#define M_HASHTYPE_OPAQUE 0xf /* ordering, not affinity */ - -#define M_HASHTYPE_CLEAR(m) (m)->m_flags &= ~(M_HASHTYPEBITS) -#define M_HASHTYPE_GET(m) (((m)->m_flags & M_HASHTYPEBITS) >> \ - M_HASHTYPE_SHIFT) -#define M_HASHTYPE_SET(m, v) do { \ - (m)->m_flags &= ~M_HASHTYPEBITS; \ - (m)->m_flags |= ((v) << M_HASHTYPE_SHIFT); \ +#define CSUM_HASH_NONE 0x0 /* no RSS hash computed */ +#define CSUM_HASH_IPV4 0x1 /* IPv4 2-tuple */ +#define CSUM_HASH_TCP_IPV4 0x2 /* TCPv4 4-tuple */ +#define CSUM_HASH_IPV6 0x3 /* IPv6 2-tuple */ +#define CSUM_HASH_TCP_IPV6 0x4 /* TCPv6 4-tuple */ +#define CSUM_HASH_IPV6_EX 0x5 /* IPv6 2-tuple + ext hdrs */ +#define CSUM_HASH_TCP_IPV6_EX 0x6 /* TCPv6 4-tiple + ext hdrs */ +#define CSUM_HASH_OPAQUE 0xf /* ordering, not affinity */ + +#define CSUM_HASH_MASK 0x0000000F +#define CSUM_HASH_CLEAR(m) ((m)->m_pkthdr.csum_flags &= ~CSUM_HASH_MASK) +#define CSUM_HASH_GET(m) ((m)->m_pkthdr.csum_flags & CSUM_HASH_MASK) +#define CSUM_HASH_SET(m, v) do { \ + (m)->m_pkthdr.csum_flags &= ~CSUM_HASH_MASK; \ + (m)->m_pkthdr.csum_flags |= (v); \ } while (0) -#define M_HASHTYPE_TEST(m, v) (M_HASHTYPE_GET(m) == (v)) +#define CSUM_HASH_TEST(m, v) (CSUM_HASH_GET(m) == (v)) /* * Flags preserved when copying m_pkthdr. */ #define M_COPYFLAGS \ (M_PKTHDR|M_EOR|M_RDONLY|M_PROTOFLAGS|M_SKIP_FIREWALL|M_BCAST|M_MCAST|\ - M_FRAG|M_FIRSTFRAG|M_LASTFRAG|M_VLANTAG|M_PROMISC|M_FIB|M_HASHTYPEBITS) + M_FRAG|M_FIRSTFRAG|M_LASTFRAG|M_VLANTAG|M_PROMISC|M_FIB) /* * External buffer types: identify ext_buf type. From owner-svn-src-user@FreeBSD.ORG Thu Nov 22 15:38:09 2012 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id E1185A44; Thu, 22 Nov 2012 15:38:09 +0000 (UTC) (envelope-from andre@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id C72048FC15; Thu, 22 Nov 2012 15:38:09 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qAMFc96v010773; Thu, 22 Nov 2012 15:38:09 GMT (envelope-from andre@svn.freebsd.org) Received: (from andre@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qAMFc9sC010772; Thu, 22 Nov 2012 15:38:09 GMT (envelope-from andre@svn.freebsd.org) Message-Id: <201211221538.qAMFc9sC010772@svn.freebsd.org> From: Andre Oppermann Date: Thu, 22 Nov 2012 15:38:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r243406 - user/andre/tcp_workqueue/sys/sys X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Nov 2012 15:38:09 -0000 Author: andre Date: Thu Nov 22 15:38:09 2012 New Revision: 243406 URL: http://svnweb.freebsd.org/changeset/base/243406 Log: Move m_nextpkt pointer from m_hdr to m_pkthdr where it belongs. m_nextpkt is never valid unless M_PKTHDR is set. Modified: user/andre/tcp_workqueue/sys/sys/mbuf.h Modified: user/andre/tcp_workqueue/sys/sys/mbuf.h ============================================================================== --- user/andre/tcp_workqueue/sys/sys/mbuf.h Thu Nov 22 15:19:53 2012 (r243405) +++ user/andre/tcp_workqueue/sys/sys/mbuf.h Thu Nov 22 15:38:09 2012 (r243406) @@ -90,7 +90,6 @@ struct mb_args { */ struct m_hdr { struct mbuf *mh_next; /* next buffer in chain */ - struct mbuf *mh_nextpkt; /* next chain in queue/record */ caddr_t mh_data; /* location of data */ int mh_len; /* amount of data in this mbuf */ int mh_flags; /* flags; see below */ @@ -114,6 +113,7 @@ struct m_tag { */ struct pkthdr { struct ifnet *rcvif; /* rcv interface */ + struct mbuf *ph_nextpkt; /* next chain in queue/record */ /* variables for ip and tcp reassembly */ void *header; /* pointer to packet header */ int len; /* total packet length */ @@ -181,9 +181,9 @@ struct mbuf { #define m_data m_hdr.mh_data #define m_type m_hdr.mh_type #define m_flags m_hdr.mh_flags -#define m_nextpkt m_hdr.mh_nextpkt #define m_act m_nextpkt #define m_pkthdr M_dat.MH.MH_pkthdr +#define m_nextpkt M_dat.MH.MH_pkthdr.ph_nextpkt #define m_ext M_dat.MH.MH_dat.MH_ext #define m_pktdat M_dat.MH.MH_dat.MH_databuf #define m_dat M_dat.M_databuf From owner-svn-src-user@FreeBSD.ORG Thu Nov 22 16:14:42 2012 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9CC555DB; Thu, 22 Nov 2012 16:14:42 +0000 (UTC) (envelope-from andre@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 69F4B8FC13; Thu, 22 Nov 2012 16:14:42 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qAMGEgKN017864; Thu, 22 Nov 2012 16:14:42 GMT (envelope-from andre@svn.freebsd.org) Received: (from andre@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qAMGEgaw017861; Thu, 22 Nov 2012 16:14:42 GMT (envelope-from andre@svn.freebsd.org) Message-Id: <201211221614.qAMGEgaw017861@svn.freebsd.org> From: Andre Oppermann Date: Thu, 22 Nov 2012 16:14:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r243407 - in user/andre/tcp_workqueue/sys: dev/mxge sys X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Nov 2012 16:14:42 -0000 Author: andre Date: Thu Nov 22 16:14:41 2012 New Revision: 243407 URL: http://svnweb.freebsd.org/changeset/base/243407 Log: Omit the type casting parameter from mtodo() and cast through void * which then can be assigned to any other pointer type without warning from the compiler. Suggested by: mdf Modified: user/andre/tcp_workqueue/sys/dev/mxge/if_mxge.c user/andre/tcp_workqueue/sys/sys/mbuf.h Modified: user/andre/tcp_workqueue/sys/dev/mxge/if_mxge.c ============================================================================== --- user/andre/tcp_workqueue/sys/dev/mxge/if_mxge.c Thu Nov 22 15:38:09 2012 (r243406) +++ user/andre/tcp_workqueue/sys/dev/mxge/if_mxge.c Thu Nov 22 16:14:41 2012 (r243407) @@ -2098,7 +2098,7 @@ mxge_encap(struct mxge_slice_state *ss, if (m->m_pkthdr.csum_flags & (CSUM_IP_UDP|CSUM_IP_TCP)) { /* ensure ip header is in first mbuf, copy it to a scratch buffer if not */ - ip = mtodo(m, ip_off, struct ip *); + ip = mtodo(m, ip_off); cksum_offset = ip_off + (ip->ip_hl << 2); pseudo_hdr_offset = cksum_offset + m->m_pkthdr.csum_l3hlen; pseudo_hdr_offset = htobe16(pseudo_hdr_offset); Modified: user/andre/tcp_workqueue/sys/sys/mbuf.h ============================================================================== --- user/andre/tcp_workqueue/sys/sys/mbuf.h Thu Nov 22 15:38:09 2012 (r243406) +++ user/andre/tcp_workqueue/sys/sys/mbuf.h Thu Nov 22 16:14:41 2012 (r243407) @@ -64,10 +64,10 @@ * type: * * mtod(m, t) -- Convert mbuf pointer to data pointer of correct type. - * mtodo(m, o, t) - Same as above but with offset 'o' into data. + * mtodo(m, o) -- Same as above but with offset 'o' into data. */ #define mtod(m, t) ((t)((m)->m_data)) -#define mtodo(m, o, t) ((t)(((m)->m_data) + (o))) +#define mtodo(m, o) ((void *)(((m)->m_data) + (o))) /* * Argument structure passed to UMA routines during mbuf and packet From owner-svn-src-user@FreeBSD.ORG Thu Nov 22 16:48:58 2012 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id DADB720B; Thu, 22 Nov 2012 16:48:58 +0000 (UTC) (envelope-from andre@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id A8C598FC13; Thu, 22 Nov 2012 16:48:58 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qAMGmwMb024181; Thu, 22 Nov 2012 16:48:58 GMT (envelope-from andre@svn.freebsd.org) Received: (from andre@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qAMGmwAE024180; Thu, 22 Nov 2012 16:48:58 GMT (envelope-from andre@svn.freebsd.org) Message-Id: <201211221648.qAMGmwAE024180@svn.freebsd.org> From: Andre Oppermann Date: Thu, 22 Nov 2012 16:48:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r243409 - user/andre/tcp_workqueue/sys/sys X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Nov 2012 16:48:58 -0000 Author: andre Date: Thu Nov 22 16:48:58 2012 New Revision: 243409 URL: http://svnweb.freebsd.org/changeset/base/243409 Log: lign and pad the mbuf header structures using the __aligned() attribute instead of manual padding. The alignment and padding is set to sizeof(void *) to align to the native pointer width on all architectures. Modified: user/andre/tcp_workqueue/sys/sys/mbuf.h Modified: user/andre/tcp_workqueue/sys/sys/mbuf.h ============================================================================== --- user/andre/tcp_workqueue/sys/sys/mbuf.h Thu Nov 22 16:20:08 2012 (r243408) +++ user/andre/tcp_workqueue/sys/sys/mbuf.h Thu Nov 22 16:48:58 2012 (r243409) @@ -79,12 +79,6 @@ struct mb_args { }; #endif /* _KERNEL */ -#if defined(__LP64__) -#define M_HDR_PAD 6 -#else -#define M_HDR_PAD 2 -#endif - /* * Header present at the beginning of every mbuf. */ @@ -94,8 +88,7 @@ struct m_hdr { int mh_len; /* amount of data in this mbuf */ int mh_flags; /* flags; see below */ short mh_type; /* type of data in this mbuf */ - uint8_t pad[M_HDR_PAD];/* word align */ -}; +} __aligned(sizeof(void *)); /* * Packet tag structure (see below for details). @@ -137,7 +130,7 @@ struct pkthdr { u_int16_t vt_nrecs; /* # of IGMPv3 records in this chain */ } PH_vt; SLIST_HEAD(packet_tags, m_tag) tags; /* list of packet tags */ -}; +} __aligned(sizeof(void *)); #define csum_data PH_cd.cd_data #define csum_l2hlen PH_cd.PHCD_hdr.l2hlen #define csum_l3hlen PH_cd.PHCD_hdr.l3hlen @@ -157,7 +150,7 @@ struct m_ext { u_int ext_size; /* size of buffer, for ext_free */ volatile u_int *ref_cnt; /* pointer to ref count info */ int ext_type; /* type of external storage */ -}; +} __aligned(sizeof(void *)); /* * The core of the mbuf object along with some shortcut defines for practical From owner-svn-src-user@FreeBSD.ORG Thu Nov 22 17:00:35 2012 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 037C2522; Thu, 22 Nov 2012 17:00:35 +0000 (UTC) (envelope-from andre@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id DC1388FC08; Thu, 22 Nov 2012 17:00:34 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qAMH0YYT026799; Thu, 22 Nov 2012 17:00:34 GMT (envelope-from andre@svn.freebsd.org) Received: (from andre@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qAMH0YGT026798; Thu, 22 Nov 2012 17:00:34 GMT (envelope-from andre@svn.freebsd.org) Message-Id: <201211221700.qAMH0YGT026798@svn.freebsd.org> From: Andre Oppermann Date: Thu, 22 Nov 2012 17:00:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r243410 - user/andre/tcp_workqueue/sys/sys X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Nov 2012 17:00:35 -0000 Author: andre Date: Thu Nov 22 17:00:34 2012 New Revision: 243410 URL: http://svnweb.freebsd.org/changeset/base/243410 Log: Rearrange the fields in struct m_ext to get better packing on 64bit architectures. Modified: user/andre/tcp_workqueue/sys/sys/mbuf.h Modified: user/andre/tcp_workqueue/sys/sys/mbuf.h ============================================================================== --- user/andre/tcp_workqueue/sys/sys/mbuf.h Thu Nov 22 16:48:58 2012 (r243409) +++ user/andre/tcp_workqueue/sys/sys/mbuf.h Thu Nov 22 17:00:34 2012 (r243410) @@ -143,13 +143,13 @@ struct pkthdr { */ struct m_ext { caddr_t ext_buf; /* start of buffer */ + volatile u_int *ref_cnt; /* pointer to ref count info */ + u_int ext_size; /* size of buffer, for ext_free */ + int ext_type; /* type of external storage */ void (*ext_free) /* free routine if not the usual */ (void *, void *); void *ext_arg1; /* optional argument pointer */ void *ext_arg2; /* optional argument pointer */ - u_int ext_size; /* size of buffer, for ext_free */ - volatile u_int *ref_cnt; /* pointer to ref count info */ - int ext_type; /* type of external storage */ } __aligned(sizeof(void *)); /* From owner-svn-src-user@FreeBSD.ORG Thu Nov 22 17:26:28 2012 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id C3250914; Thu, 22 Nov 2012 17:26:28 +0000 (UTC) (envelope-from andre@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 9DBCB8FC0C; Thu, 22 Nov 2012 17:26:28 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qAMHQSLL031355; Thu, 22 Nov 2012 17:26:28 GMT (envelope-from andre@svn.freebsd.org) Received: (from andre@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qAMHQSpu031352; Thu, 22 Nov 2012 17:26:28 GMT (envelope-from andre@svn.freebsd.org) Message-Id: <201211221726.qAMHQSpu031352@svn.freebsd.org> From: Andre Oppermann Date: Thu, 22 Nov 2012 17:26:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r243411 - user/andre/tcp_workqueue/sys/net X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Nov 2012 17:26:28 -0000 Author: andre Date: Thu Nov 22 17:26:28 2012 New Revision: 243411 URL: http://svnweb.freebsd.org/changeset/base/243411 Log: Introduce typedef for pfil hook callback function and replace all spelled out occurrences with it. Do some style cleanup of the pfil lock function prototypes. Modified: user/andre/tcp_workqueue/sys/net/pfil.c user/andre/tcp_workqueue/sys/net/pfil.h Modified: user/andre/tcp_workqueue/sys/net/pfil.c ============================================================================== --- user/andre/tcp_workqueue/sys/net/pfil.c Thu Nov 22 17:00:34 2012 (r243410) +++ user/andre/tcp_workqueue/sys/net/pfil.c Thu Nov 22 17:26:28 2012 (r243411) @@ -236,8 +236,7 @@ pfil_head_get(int type, u_long val) * The cookie is simply is a random value that should be unique. */ int -pfil_add_hook(int (*func)(void *, struct mbuf **, struct ifnet *, int, - struct inpcb *), void *arg, int flags, struct pfil_head *ph) +pfil_add_hook(pfil_func_t func, void *arg, int flags, struct pfil_head *ph) { return (pfil_add_hook_order(func, arg, "unknown", flags, @@ -245,9 +244,8 @@ pfil_add_hook(int (*func)(void *, struct } int -pfil_add_hook_order(int (*func)(void *, struct mbuf **, struct ifnet *, int, - struct inpcb *), void *arg, char *name, int flags, uint8_t order, - struct pfil_head *ph) +pfil_add_hook_order(pfil_func_t func, void *arg, char *name, int flags, + uint8_t order, struct pfil_head *ph) { struct packet_filter_hook *pfh1 = NULL; struct packet_filter_hook *pfh2 = NULL; @@ -312,8 +310,7 @@ error: * list. */ int -pfil_remove_hook(int (*func)(void *, struct mbuf **, struct ifnet *, int, - struct inpcb *), void *arg, int flags, struct pfil_head *ph) +pfil_remove_hook(pfil_func_t func, void *arg, int flags, struct pfil_head *ph) { int err = 0; @@ -333,8 +330,7 @@ pfil_remove_hook(int (*func)(void *, str } int -pfil_get_cookie(int (*func)(void *, struct mbuf **, struct ifnet *, int, - struct inpcb *), void *arg, int flags, struct pfil_head *ph) +pfil_get_cookie(pfil_func_t func, void *arg, int flags, struct pfil_head *ph) { pfil_list_t *list; struct packet_filter_hook *pfh; @@ -402,9 +398,7 @@ pfil_list_add(pfil_list_t *list, struct * specified list. */ static int -pfil_list_remove(pfil_list_t *list, - int (*func)(void *, struct mbuf **, struct ifnet *, int, struct inpcb *), - void *arg) +pfil_list_remove(pfil_list_t *list, pfil_func_t func, void *arg) { struct packet_filter_hook *pfh; Modified: user/andre/tcp_workqueue/sys/net/pfil.h ============================================================================== --- user/andre/tcp_workqueue/sys/net/pfil.h Thu Nov 22 17:00:34 2012 (r243410) +++ user/andre/tcp_workqueue/sys/net/pfil.h Thu Nov 22 17:26:28 2012 (r243411) @@ -43,14 +43,16 @@ struct mbuf; struct ifnet; struct inpcb; +typedef int (*pfil_func_t)(void *, struct mbuf **, struct ifnet *, int, + struct inpcb *); + /* * The packet filter hooks are designed for anything to call them to * possibly intercept the packet. */ struct packet_filter_hook { TAILQ_ENTRY(packet_filter_hook) pfil_link; - int (*pfil_func)(void *, struct mbuf **, struct ifnet *, int, - struct inpcb *); + pfil_func_t pfil_func; void *pfil_arg; int pfil_cookie; uint8_t pfil_order; @@ -94,32 +96,29 @@ struct pfil_head { LIST_ENTRY(pfil_head) ph_list; }; -int pfil_add_hook(int (*func)(void *, struct mbuf **, struct ifnet *, - int, struct inpcb *), void *, int, struct pfil_head *); -int pfil_add_hook_order(int (*func)(void *, struct mbuf **, struct ifnet *, - int, struct inpcb *), void *, char *, int, uint8_t, +int pfil_add_hook(pfil_func_t, void *, int, struct pfil_head *); +int pfil_add_hook_order(pfil_func_t, void *, char *, int, uint8_t, struct pfil_head *); -int pfil_get_cookie(int (*func)(void *, struct mbuf **, struct ifnet *, - int, struct inpcb *), void *, int, struct pfil_head *); -int pfil_remove_hook(int (*func)(void *, struct mbuf **, struct ifnet *, - int, struct inpcb *), void *, int, struct pfil_head *); +int pfil_get_cookie(pfil_func_t, void *, int, struct pfil_head *); +int pfil_remove_hook(pfil_func_t, void *, int, struct pfil_head *); + int pfil_run_hooks(struct pfil_head *, struct mbuf **, struct ifnet *, int, struct inpcb *inp); int pfil_run_inject(struct pfil_head *, struct mbuf **, struct ifnet *, int, struct inpcb *inp, int cookie); struct rm_priotracker; /* Do not require including rmlock header */ -int pfil_try_rlock(struct pfil_head *, struct rm_priotracker *); -void pfil_rlock(struct pfil_head *, struct rm_priotracker *); -void pfil_runlock(struct pfil_head *, struct rm_priotracker *); -void pfil_wlock(struct pfil_head *); -void pfil_wunlock(struct pfil_head *); -int pfil_wowned(struct pfil_head *ph); +int pfil_try_rlock(struct pfil_head *, struct rm_priotracker *); +void pfil_rlock(struct pfil_head *, struct rm_priotracker *); +void pfil_runlock(struct pfil_head *, struct rm_priotracker *); +void pfil_wlock(struct pfil_head *); +void pfil_wunlock(struct pfil_head *); +int pfil_wowned(struct pfil_head *ph); int pfil_head_register(struct pfil_head *); int pfil_head_unregister(struct pfil_head *); -struct pfil_head *pfil_head_get(int, u_long); +struct pfil_head *pfil_head_get(int, u_long); #define PFIL_HOOKED(p) ((p)->ph_nhooks > 0) #define PFIL_LOCK_INIT_REAL(l, t) \ From owner-svn-src-user@FreeBSD.ORG Thu Nov 22 17:32:11 2012 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6ADD9A8E; Thu, 22 Nov 2012 17:32:11 +0000 (UTC) (envelope-from andre@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 519298FC13; Thu, 22 Nov 2012 17:32:11 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qAMHWBmD032119; Thu, 22 Nov 2012 17:32:11 GMT (envelope-from andre@svn.freebsd.org) Received: (from andre@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qAMHWBmS032118; Thu, 22 Nov 2012 17:32:11 GMT (envelope-from andre@svn.freebsd.org) Message-Id: <201211221732.qAMHWBmS032118@svn.freebsd.org> From: Andre Oppermann Date: Thu, 22 Nov 2012 17:32:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r243412 - user/andre/tcp_workqueue/sys/net X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Nov 2012 17:32:11 -0000 Author: andre Date: Thu Nov 22 17:32:10 2012 New Revision: 243412 URL: http://svnweb.freebsd.org/changeset/base/243412 Log: Remove bitrot linux and win32 ifdef from struct pfil_head. Modified: user/andre/tcp_workqueue/sys/net/pfil.h Modified: user/andre/tcp_workqueue/sys/net/pfil.h ============================================================================== --- user/andre/tcp_workqueue/sys/net/pfil.h Thu Nov 22 17:26:28 2012 (r243411) +++ user/andre/tcp_workqueue/sys/net/pfil.h Thu Nov 22 17:32:10 2012 (r243412) @@ -80,13 +80,9 @@ struct pfil_head { pfil_list_t ph_out; int ph_type; int ph_nhooks; -#if defined( __linux__ ) || defined( _WIN32 ) - rwlock_t ph_mtx; -#else struct rmlock *ph_plock; /* Pointer to the used lock */ struct rmlock ph_lock; /* Private lock storage */ int flags; -#endif union { u_long phu_val; void *phu_ptr; From owner-svn-src-user@FreeBSD.ORG Thu Nov 22 20:23:47 2012 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 30105CEC; Thu, 22 Nov 2012 20:23:47 +0000 (UTC) (envelope-from andre@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 166758FC08; Thu, 22 Nov 2012 20:23:47 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qAMKNk4Y057354; Thu, 22 Nov 2012 20:23:46 GMT (envelope-from andre@svn.freebsd.org) Received: (from andre@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qAMKNkrA057353; Thu, 22 Nov 2012 20:23:46 GMT (envelope-from andre@svn.freebsd.org) Message-Id: <201211222023.qAMKNkrA057353@svn.freebsd.org> From: Andre Oppermann Date: Thu, 22 Nov 2012 20:23:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r243413 - user/andre/tcp_workqueue/sys/net X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Nov 2012 20:23:47 -0000 Author: andre Date: Thu Nov 22 20:23:46 2012 New Revision: 243413 URL: http://svnweb.freebsd.org/changeset/base/243413 Log: Convert another function prototype to use the pfil hook callback that got overlooked in r243411. The typedef name will be re-considered again later. Modified: user/andre/tcp_workqueue/sys/net/pfil.c Modified: user/andre/tcp_workqueue/sys/net/pfil.c ============================================================================== --- user/andre/tcp_workqueue/sys/net/pfil.c Thu Nov 22 17:32:10 2012 (r243412) +++ user/andre/tcp_workqueue/sys/net/pfil.c Thu Nov 22 20:23:46 2012 (r243413) @@ -52,10 +52,7 @@ MTX_SYSINIT(pfil_global_lock, &pfil_glob static int pfil_list_add(pfil_list_t *, struct packet_filter_hook *, int, uint8_t); - -static int pfil_list_remove(pfil_list_t *, - int (*)(void *, struct mbuf **, struct ifnet *, int, struct inpcb *), - void *); +static int pfil_list_remove(pfil_list_t *, pfil_func_t, void *); LIST_HEAD(pfilheadhead, pfil_head); VNET_DEFINE(struct pfilheadhead, pfil_head_list); From owner-svn-src-user@FreeBSD.ORG Thu Nov 22 20:43:09 2012 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id EE121457; Thu, 22 Nov 2012 20:43:09 +0000 (UTC) (envelope-from andre@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id BB2A68FC13; Thu, 22 Nov 2012 20:43:09 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qAMKh9n2060181; Thu, 22 Nov 2012 20:43:09 GMT (envelope-from andre@svn.freebsd.org) Received: (from andre@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qAMKh9Zs060179; Thu, 22 Nov 2012 20:43:09 GMT (envelope-from andre@svn.freebsd.org) Message-Id: <201211222043.qAMKh9Zs060179@svn.freebsd.org> From: Andre Oppermann Date: Thu, 22 Nov 2012 20:43:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r243414 - user/andre/tcp_workqueue/sys/net X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Nov 2012 20:43:10 -0000 Author: andre Date: Thu Nov 22 20:43:09 2012 New Revision: 243414 URL: http://svnweb.freebsd.org/changeset/base/243414 Log: Internalize pfil_hook_get(). There are no outside consumers of this API, it is only safe for internal use and even the pfil(9) man page says so in the BUGS section. Remember to adjust the pfil(9) man page. Modified: user/andre/tcp_workqueue/sys/net/pfil.c user/andre/tcp_workqueue/sys/net/pfil.h Modified: user/andre/tcp_workqueue/sys/net/pfil.c ============================================================================== --- user/andre/tcp_workqueue/sys/net/pfil.c Thu Nov 22 20:23:46 2012 (r243413) +++ user/andre/tcp_workqueue/sys/net/pfil.c Thu Nov 22 20:43:09 2012 (r243414) @@ -74,6 +74,18 @@ pfil_run_hooks(struct pfil_head *ph, str return (pfil_run_inject(ph, mp, ifp, dir, inp, 0)); } +static struct packet_filter_hook * +pfil_hook_get(int dir, struct pfil_head *ph) +{ + + if (dir == PFIL_IN) + return (TAILQ_FIRST(&ph->ph_in)); + else if (dir == PFIL_OUT) + return (TAILQ_FIRST(&ph->ph_out)); + else + return (NULL); +} + int pfil_run_inject(struct pfil_head *ph, struct mbuf **mp, struct ifnet *ifp, int dir, struct inpcb *inp, int cookie) Modified: user/andre/tcp_workqueue/sys/net/pfil.h ============================================================================== --- user/andre/tcp_workqueue/sys/net/pfil.h Thu Nov 22 20:23:46 2012 (r243413) +++ user/andre/tcp_workqueue/sys/net/pfil.h Thu Nov 22 20:43:09 2012 (r243414) @@ -141,16 +141,4 @@ struct pfil_head *pfil_head_get(int, u_l #define PFIL_LIST_LOCK() mtx_lock(&pfil_global_lock) #define PFIL_LIST_UNLOCK() mtx_unlock(&pfil_global_lock) -static __inline struct packet_filter_hook * -pfil_hook_get(int dir, struct pfil_head *ph) -{ - - if (dir == PFIL_IN) - return (TAILQ_FIRST(&ph->ph_in)); - else if (dir == PFIL_OUT) - return (TAILQ_FIRST(&ph->ph_out)); - else - return (NULL); -} - #endif /* _NET_PFIL_H_ */ From owner-svn-src-user@FreeBSD.ORG Thu Nov 22 20:48:11 2012 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 1F9566C9; Thu, 22 Nov 2012 20:48:11 +0000 (UTC) (envelope-from ermal.luci@gmail.com) Received: from mail-qc0-f182.google.com (mail-qc0-f182.google.com [209.85.216.182]) by mx1.freebsd.org (Postfix) with ESMTP id 90DF78FC0C; Thu, 22 Nov 2012 20:48:10 +0000 (UTC) Received: by mail-qc0-f182.google.com with SMTP id k19so7628600qcs.13 for ; Thu, 22 Nov 2012 12:48:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=/5G546lDgIM+SD23BBnJ7C+toXI5RHW4Ev8eK0sSZUk=; b=p92Ev6MEb+TVckFcU6h3tqEoksnGeMAJuW79F8aMwqRBWkn4kDQ4fgPLvAO8KRWRIa F4FtwIZUcscXCec24N9ZADZqpaMT6dNdcogu+0W1NGiNVRa4flSMgP2Ju/Ln1lOW69lT NSydu6LlHQNFtQtFYh9hiqXr9hllK8Dm9mpcL3BeIyLRl8xNnPVO1pQIUIjMKJuqYuXJ TCOJWkEPQbpHXZTAljFPemcL/af6Vkb0cav6Mj1QN+1yRiflTa9uCNWtYqPobQb+qSsp pN+8TKTK+aTo18cBMyWvXgv5E+b8cYG2fKgCCcf2Tx8RFzt6zdhyDDy8bIJOA4WQYqDs PP/A== MIME-Version: 1.0 Received: by 10.229.196.96 with SMTP id ef32mr378232qcb.101.1353617289717; Thu, 22 Nov 2012 12:48:09 -0800 (PST) Sender: ermal.luci@gmail.com Received: by 10.49.121.163 with HTTP; Thu, 22 Nov 2012 12:48:09 -0800 (PST) In-Reply-To: <201211222043.qAMKh9Zs060179@svn.freebsd.org> References: <201211222043.qAMKh9Zs060179@svn.freebsd.org> Date: Thu, 22 Nov 2012 21:48:09 +0100 X-Google-Sender-Auth: Qg7EZdepfjdMx2bSYgroW6DpGZU Message-ID: Subject: Re: svn commit: r243414 - user/andre/tcp_workqueue/sys/net From: =?ISO-8859-1?Q?Ermal_Lu=E7i?= To: Andre Oppermann Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.14 Cc: src-committers@freebsd.org, svn-src-user@freebsd.org X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Nov 2012 20:48:11 -0000 Hello Andre, you plan to introduce pfil(9) at layer2 as well? On Thu, Nov 22, 2012 at 9:43 PM, Andre Oppermann wrote: > Author: andre > Date: Thu Nov 22 20:43:09 2012 > New Revision: 243414 > URL: http://svnweb.freebsd.org/changeset/base/243414 > > Log: > Internalize pfil_hook_get(). There are no outside consumers > of this API, it is only safe for internal use and even the > pfil(9) man page says so in the BUGS section. > > Remember to adjust the pfil(9) man page. > > Modified: > user/andre/tcp_workqueue/sys/net/pfil.c > user/andre/tcp_workqueue/sys/net/pfil.h > > Modified: user/andre/tcp_workqueue/sys/net/pfil.c > > ============================================================================== > --- user/andre/tcp_workqueue/sys/net/pfil.c Thu Nov 22 20:23:46 2012 > (r243413) > +++ user/andre/tcp_workqueue/sys/net/pfil.c Thu Nov 22 20:43:09 2012 > (r243414) > @@ -74,6 +74,18 @@ pfil_run_hooks(struct pfil_head *ph, str > return (pfil_run_inject(ph, mp, ifp, dir, inp, 0)); > } > > +static struct packet_filter_hook * > +pfil_hook_get(int dir, struct pfil_head *ph) > +{ > + > + if (dir == PFIL_IN) > + return (TAILQ_FIRST(&ph->ph_in)); > + else if (dir == PFIL_OUT) > + return (TAILQ_FIRST(&ph->ph_out)); > + else > + return (NULL); > +} > + > int > pfil_run_inject(struct pfil_head *ph, struct mbuf **mp, struct ifnet *ifp, > int dir, struct inpcb *inp, int cookie) > > Modified: user/andre/tcp_workqueue/sys/net/pfil.h > > ============================================================================== > --- user/andre/tcp_workqueue/sys/net/pfil.h Thu Nov 22 20:23:46 2012 > (r243413) > +++ user/andre/tcp_workqueue/sys/net/pfil.h Thu Nov 22 20:43:09 2012 > (r243414) > @@ -141,16 +141,4 @@ struct pfil_head *pfil_head_get(int, u_l > #define PFIL_LIST_LOCK() mtx_lock(&pfil_global_lock) > #define PFIL_LIST_UNLOCK() mtx_unlock(&pfil_global_lock) > > -static __inline struct packet_filter_hook * > -pfil_hook_get(int dir, struct pfil_head *ph) > -{ > - > - if (dir == PFIL_IN) > - return (TAILQ_FIRST(&ph->ph_in)); > - else if (dir == PFIL_OUT) > - return (TAILQ_FIRST(&ph->ph_out)); > - else > - return (NULL); > -} > - > #endif /* _NET_PFIL_H_ */ > -- Ermal From owner-svn-src-user@FreeBSD.ORG Thu Nov 22 21:47:22 2012 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 73D2F29B; Thu, 22 Nov 2012 21:47:22 +0000 (UTC) (envelope-from andre@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 5937F8FC08; Thu, 22 Nov 2012 21:47:22 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qAMLlMIv070114; Thu, 22 Nov 2012 21:47:22 GMT (envelope-from andre@svn.freebsd.org) Received: (from andre@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qAMLlMKB070112; Thu, 22 Nov 2012 21:47:22 GMT (envelope-from andre@svn.freebsd.org) Message-Id: <201211222147.qAMLlMKB070112@svn.freebsd.org> From: Andre Oppermann Date: Thu, 22 Nov 2012 21:47:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r243415 - user/andre/tcp_workqueue/sys/net X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Nov 2012 21:47:22 -0000 Author: andre Date: Thu Nov 22 21:47:21 2012 New Revision: 243415 URL: http://svnweb.freebsd.org/changeset/base/243415 Log: Resolve the confusion between the head_list and the hook list. The linked list of pfil hooks is changed to "chain" and this term applied consistently. The head_list remains with "list" term. Add KASSERT to vnet_pfil_uninit(). Update and extend comments. Modified: user/andre/tcp_workqueue/sys/net/pfil.c user/andre/tcp_workqueue/sys/net/pfil.h Modified: user/andre/tcp_workqueue/sys/net/pfil.c ============================================================================== --- user/andre/tcp_workqueue/sys/net/pfil.c Thu Nov 22 20:43:09 2012 (r243414) +++ user/andre/tcp_workqueue/sys/net/pfil.c Thu Nov 22 21:47:21 2012 (r243415) @@ -50,9 +50,9 @@ static struct mtx pfil_global_lock; MTX_SYSINIT(pfil_global_lock, &pfil_global_lock, "pfil_head_list lock", MTX_DEF); -static int pfil_list_add(pfil_list_t *, struct packet_filter_hook *, int, - uint8_t); -static int pfil_list_remove(pfil_list_t *, pfil_func_t, void *); +static int pfil_chain_add(pfil_chain_t *, struct packet_filter_hook *, + int, uint8_t); +static int pfil_chain_remove(pfil_chain_t *, pfil_func_t, void *); LIST_HEAD(pfilheadhead, pfil_head); VNET_DEFINE(struct pfilheadhead, pfil_head_list); @@ -63,8 +63,9 @@ VNET_DEFINE(struct rmlock, pfil_lock); /* * pfil_run_hooks() runs the specified packet filter hooks. * - * The cookie, if set, skips all hooks before the hook with - * the same cookie and continues with the next hook after it. + * The cookie, if set, skips all hooks before and including + * the hook with the same cookie and continues with the next + * hook after it. */ int pfil_run_hooks(struct pfil_head *ph, struct mbuf **mp, struct ifnet *ifp, @@ -75,7 +76,7 @@ pfil_run_hooks(struct pfil_head *ph, str } static struct packet_filter_hook * -pfil_hook_get(int dir, struct pfil_head *ph) +pfil_chain_get(int dir, struct pfil_head *ph) { if (dir == PFIL_IN) @@ -97,8 +98,8 @@ pfil_run_inject(struct pfil_head *ph, st PFIL_RLOCK(ph, &rmpt); KASSERT(ph->ph_nhooks >= 0, ("Pfil hook count dropped < 0")); - for (pfh = pfil_hook_get(dir, ph); pfh != NULL; - pfh = TAILQ_NEXT(pfh, pfil_link)) { + for (pfh = pfil_chain_get(dir, ph); pfh != NULL; + pfh = TAILQ_NEXT(pfh, pfil_chain)) { if (cookie != 0) { /* Continue on the next hook. */ if (pfh->pfil_cookie == cookie) @@ -171,6 +172,7 @@ pfil_wowned(struct pfil_head *ph) { return PFIL_WOWNED(ph); } + /* * pfil_head_register() registers a pfil_head with the packet filter hook * mechanism. @@ -210,9 +212,9 @@ pfil_head_unregister(struct pfil_head *p PFIL_LIST_LOCK(); LIST_REMOVE(ph, ph_list); PFIL_LIST_UNLOCK(); - TAILQ_FOREACH_SAFE(pfh, &ph->ph_in, pfil_link, pfnext) + TAILQ_FOREACH_SAFE(pfh, &ph->ph_in, pfil_chain, pfnext) free(pfh, M_IFADDR); - TAILQ_FOREACH_SAFE(pfh, &ph->ph_out, pfil_link, pfnext) + TAILQ_FOREACH_SAFE(pfh, &ph->ph_out, pfil_chain, pfnext) free(pfh, M_IFADDR); PFIL_LOCK_DESTROY(ph); return (0); @@ -288,16 +290,16 @@ pfil_add_hook_order(pfil_func_t func, vo } PFIL_WLOCK(ph); if (flags & PFIL_IN) { - err = pfil_list_add(&ph->ph_in, pfh1, flags & ~PFIL_OUT, order); + err = pfil_chain_add(&ph->ph_in, pfh1, flags & ~PFIL_OUT, order); if (err) goto locked_error; ph->ph_nhooks++; } if (flags & PFIL_OUT) { - err = pfil_list_add(&ph->ph_out, pfh2, flags & ~PFIL_IN, order); + err = pfil_chain_add(&ph->ph_out, pfh2, flags & ~PFIL_IN, order); if (err) { if (flags & PFIL_IN) - pfil_list_remove(&ph->ph_in, func, arg); + pfil_chain_remove(&ph->ph_in, func, arg); goto locked_error; } ph->ph_nhooks++; @@ -325,12 +327,12 @@ pfil_remove_hook(pfil_func_t func, void PFIL_WLOCK(ph); if (flags & PFIL_IN) { - err = pfil_list_remove(&ph->ph_in, func, arg); + err = pfil_chain_remove(&ph->ph_in, func, arg); if (err == 0) ph->ph_nhooks--; } if ((err == 0) && (flags & PFIL_OUT)) { - err = pfil_list_remove(&ph->ph_out, func, arg); + err = pfil_chain_remove(&ph->ph_out, func, arg); if (err == 0) ph->ph_nhooks--; } @@ -341,20 +343,20 @@ pfil_remove_hook(pfil_func_t func, void int pfil_get_cookie(pfil_func_t func, void *arg, int flags, struct pfil_head *ph) { - pfil_list_t *list; + pfil_chain_t *chain; struct packet_filter_hook *pfh; struct rm_priotracker tracker; int cookie = 0; PFIL_RLOCK(ph, &tracker); if (flags & PFIL_IN) - list = &ph->ph_in; + chain = &ph->ph_in; else if (flags & PFIL_OUT) - list = &ph->ph_out; + chain = &ph->ph_out; else goto out; - TAILQ_FOREACH(pfh, list, pfil_link) + TAILQ_FOREACH(pfh, chain, pfil_chain) if (pfh->pfil_func == func && pfh->pfil_arg == arg) cookie = pfh->pfil_cookie; @@ -363,8 +365,11 @@ out: return (cookie); } +/* + * Internal: Add a new pfil hook into a hook chain. + */ static int -pfil_list_add(pfil_list_t *list, struct packet_filter_hook *pfh1, int flags, +pfil_chain_add(pfil_chain_t *chain, struct packet_filter_hook *pfh1, int flags, uint8_t order) { struct packet_filter_hook *pfh; @@ -372,7 +377,7 @@ pfil_list_add(pfil_list_t *list, struct /* * First make sure the hook is not already there. */ - TAILQ_FOREACH(pfh, list, pfil_link) + TAILQ_FOREACH(pfh, chain, pfil_chain) if (pfh->pfil_func == pfh1->pfil_func && pfh->pfil_arg == pfh1->pfil_arg) return (EEXIST); @@ -382,38 +387,37 @@ pfil_list_add(pfil_list_t *list, struct * the same path is followed in or out of the kernel. */ if (flags & PFIL_IN) { - TAILQ_FOREACH(pfh, list, pfil_link) { + TAILQ_FOREACH(pfh, chain, pfil_chain) { if (pfh->pfil_order <= order) break; } if (pfh == NULL) - TAILQ_INSERT_HEAD(list, pfh1, pfil_link); + TAILQ_INSERT_HEAD(chain, pfh1, pfil_chain); else - TAILQ_INSERT_BEFORE(pfh, pfh1, pfil_link); + TAILQ_INSERT_BEFORE(pfh, pfh1, pfil_chain); } else { - TAILQ_FOREACH_REVERSE(pfh, list, pfil_list, pfil_link) + TAILQ_FOREACH_REVERSE(pfh, chain, pfil_chain, pfil_chain) if (pfh->pfil_order >= order) break; if (pfh == NULL) - TAILQ_INSERT_TAIL(list, pfh1, pfil_link); + TAILQ_INSERT_TAIL(chain, pfh1, pfil_chain); else - TAILQ_INSERT_AFTER(list, pfh, pfh1, pfil_link); + TAILQ_INSERT_AFTER(chain, pfh, pfh1, pfil_chain); } return (0); } /* - * pfil_list_remove is an internal function that takes a function off the - * specified list. + * Internal: Remove a pfil hook from a hook chain. */ static int -pfil_list_remove(pfil_list_t *list, pfil_func_t func, void *arg) +pfil_chain_remove(pfil_chain_t *chain, pfil_func_t func, void *arg) { struct packet_filter_hook *pfh; - TAILQ_FOREACH(pfh, list, pfil_link) + TAILQ_FOREACH(pfh, chain, pfil_chain) if (pfh->pfil_func == func && pfh->pfil_arg == arg) { - TAILQ_REMOVE(list, pfh, pfil_link); + TAILQ_REMOVE(chain, pfh, pfil_chain); free(pfh, M_IFADDR); return (0); } @@ -440,7 +444,8 @@ static int vnet_pfil_uninit(const void *unused) { - /* XXX should panic if list is not empty */ + KASSERT(LIST_EMPTY(&V_pfil_head_list), + ("%s: pfil_head_list %p not empty", __func__, &V_pfil_head_list)); PFIL_LOCK_DESTROY_REAL(&V_pfil_lock); return (0); } Modified: user/andre/tcp_workqueue/sys/net/pfil.h ============================================================================== --- user/andre/tcp_workqueue/sys/net/pfil.h Thu Nov 22 20:43:09 2012 (r243414) +++ user/andre/tcp_workqueue/sys/net/pfil.h Thu Nov 22 21:47:21 2012 (r243415) @@ -48,10 +48,11 @@ typedef int (*pfil_func_t)(void *, struc /* * The packet filter hooks are designed for anything to call them to - * possibly intercept the packet. + * possibly intercept the packet. Multiple filter hooks are chained + * together and after each other in the specified order. */ struct packet_filter_hook { - TAILQ_ENTRY(packet_filter_hook) pfil_link; + TAILQ_ENTRY(packet_filter_hook) pfil_chain; pfil_func_t pfil_func; void *pfil_arg; int pfil_cookie; @@ -68,16 +69,20 @@ struct packet_filter_hook { #define PFIL_WAITOK 0x00000004 #define PFIL_ALL (PFIL_IN|PFIL_OUT) -typedef TAILQ_HEAD(pfil_list, packet_filter_hook) pfil_list_t; +typedef TAILQ_HEAD(pfil_chain, packet_filter_hook) pfil_chain_t; #define PFIL_TYPE_AF 1 /* key is AF_* type */ #define PFIL_TYPE_IFNET 2 /* key is ifnet pointer */ #define PFIL_FLAG_PRIVATE_LOCK 0x01 /* Personal lock instead of global */ +/* + * A pfil head is created by each protocol or packet intercept point. + * For packet is then run through the hook chain for inspection. + */ struct pfil_head { - pfil_list_t ph_in; - pfil_list_t ph_out; + pfil_chain_t ph_in; + pfil_chain_t ph_out; int ph_type; int ph_nhooks; struct rmlock *ph_plock; /* Pointer to the used lock */ @@ -92,12 +97,14 @@ struct pfil_head { LIST_ENTRY(pfil_head) ph_list; }; +/* Public functions for pfil head management by protocols. */ int pfil_add_hook(pfil_func_t, void *, int, struct pfil_head *); int pfil_add_hook_order(pfil_func_t, void *, char *, int, uint8_t, struct pfil_head *); int pfil_get_cookie(pfil_func_t, void *, int, struct pfil_head *); int pfil_remove_hook(pfil_func_t, void *, int, struct pfil_head *); +/* Public functions to run the packet inspection by protocols. */ int pfil_run_hooks(struct pfil_head *, struct mbuf **, struct ifnet *, int, struct inpcb *inp); int pfil_run_inject(struct pfil_head *, struct mbuf **, struct ifnet *, From owner-svn-src-user@FreeBSD.ORG Thu Nov 22 22:10:10 2012 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id A842B6CC; Thu, 22 Nov 2012 22:10:10 +0000 (UTC) (envelope-from andre@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 8DD6B8FC0C; Thu, 22 Nov 2012 22:10:10 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qAMMAAov074312; Thu, 22 Nov 2012 22:10:10 GMT (envelope-from andre@svn.freebsd.org) Received: (from andre@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qAMMAAq3074310; Thu, 22 Nov 2012 22:10:10 GMT (envelope-from andre@svn.freebsd.org) Message-Id: <201211222210.qAMMAAq3074310@svn.freebsd.org> From: Andre Oppermann Date: Thu, 22 Nov 2012 22:10:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r243416 - user/andre/tcp_workqueue/sys/net X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Nov 2012 22:10:10 -0000 Author: andre Date: Thu Nov 22 22:10:10 2012 New Revision: 243416 URL: http://svnweb.freebsd.org/changeset/base/243416 Log: Rename PFIL_LIST_[UN]LOCK() to PFIL_HEADLIST_[UN]LOCK() to avoid confusion with the pfil_head locking macros. Shuffle around and group definitions and function prototypes by purpose to improve readability and restyle in various places. Modified: user/andre/tcp_workqueue/sys/net/pfil.c user/andre/tcp_workqueue/sys/net/pfil.h Modified: user/andre/tcp_workqueue/sys/net/pfil.c ============================================================================== --- user/andre/tcp_workqueue/sys/net/pfil.c Thu Nov 22 21:47:21 2012 (r243415) +++ user/andre/tcp_workqueue/sys/net/pfil.c Thu Nov 22 22:10:10 2012 (r243416) @@ -182,11 +182,11 @@ pfil_head_register(struct pfil_head *ph) { struct pfil_head *lph; - PFIL_LIST_LOCK(); + PFIL_HEADLIST_LOCK(); LIST_FOREACH(lph, &V_pfil_head_list, ph_list) { if (ph->ph_type == lph->ph_type && ph->ph_un.phu_val == lph->ph_un.phu_val) { - PFIL_LIST_UNLOCK(); + PFIL_HEADLIST_UNLOCK(); return (EEXIST); } } @@ -195,7 +195,7 @@ pfil_head_register(struct pfil_head *ph) TAILQ_INIT(&ph->ph_in); TAILQ_INIT(&ph->ph_out); LIST_INSERT_HEAD(&V_pfil_head_list, ph, ph_list); - PFIL_LIST_UNLOCK(); + PFIL_HEADLIST_UNLOCK(); return (0); } @@ -209,9 +209,9 @@ pfil_head_unregister(struct pfil_head *p { struct packet_filter_hook *pfh, *pfnext; - PFIL_LIST_LOCK(); + PFIL_HEADLIST_LOCK(); LIST_REMOVE(ph, ph_list); - PFIL_LIST_UNLOCK(); + PFIL_HEADLIST_UNLOCK(); TAILQ_FOREACH_SAFE(pfh, &ph->ph_in, pfil_chain, pfnext) free(pfh, M_IFADDR); TAILQ_FOREACH_SAFE(pfh, &ph->ph_out, pfil_chain, pfnext) @@ -228,11 +228,11 @@ pfil_head_get(int type, u_long val) { struct pfil_head *ph; - PFIL_LIST_LOCK(); + PFIL_HEADLIST_LOCK(); LIST_FOREACH(ph, &V_pfil_head_list, ph_list) if (ph->ph_type == type && ph->ph_un.phu_val == val) break; - PFIL_LIST_UNLOCK(); + PFIL_HEADLIST_UNLOCK(); return (ph); } Modified: user/andre/tcp_workqueue/sys/net/pfil.h ============================================================================== --- user/andre/tcp_workqueue/sys/net/pfil.h Thu Nov 22 21:47:21 2012 (r243415) +++ user/andre/tcp_workqueue/sys/net/pfil.h Thu Nov 22 22:10:10 2012 (r243416) @@ -53,11 +53,11 @@ typedef int (*pfil_func_t)(void *, struc */ struct packet_filter_hook { TAILQ_ENTRY(packet_filter_hook) pfil_chain; - pfil_func_t pfil_func; - void *pfil_arg; - int pfil_cookie; - uint8_t pfil_order; - char *pfil_name; + pfil_func_t pfil_func; + void *pfil_arg; + int pfil_cookie; + uint8_t pfil_order; + char *pfil_name; }; #define PFIL_ORDER_FIRST 0 @@ -81,15 +81,15 @@ typedef TAILQ_HEAD(pfil_chain, packet_fi * For packet is then run through the hook chain for inspection. */ struct pfil_head { - pfil_chain_t ph_in; - pfil_chain_t ph_out; - int ph_type; - int ph_nhooks; + pfil_chain_t ph_in; + pfil_chain_t ph_out; + int ph_type; + int ph_nhooks; + int flags; struct rmlock *ph_plock; /* Pointer to the used lock */ - struct rmlock ph_lock; /* Private lock storage */ - int flags; + struct rmlock ph_lock; /* Private lock storage */ union { - u_long phu_val; + u_long phu_val; void *phu_ptr; } ph_un; #define ph_af ph_un.phu_val @@ -98,11 +98,17 @@ struct pfil_head { }; /* Public functions for pfil head management by protocols. */ +struct pfil_head *pfil_head_get(int, u_long); +int pfil_head_register(struct pfil_head *); +int pfil_head_unregister(struct pfil_head *); + +/* Public functions for pfil hook management by protocols. */ int pfil_add_hook(pfil_func_t, void *, int, struct pfil_head *); int pfil_add_hook_order(pfil_func_t, void *, char *, int, uint8_t, struct pfil_head *); int pfil_get_cookie(pfil_func_t, void *, int, struct pfil_head *); int pfil_remove_hook(pfil_func_t, void *, int, struct pfil_head *); +#define PFIL_HOOKED(p) ((p)->ph_nhooks > 0) /* Public functions to run the packet inspection by protocols. */ int pfil_run_hooks(struct pfil_head *, struct mbuf **, struct ifnet *, @@ -110,7 +116,8 @@ int pfil_run_hooks(struct pfil_head *, s int pfil_run_inject(struct pfil_head *, struct mbuf **, struct ifnet *, int, struct inpcb *inp, int cookie); -struct rm_priotracker; /* Do not require including rmlock header */ +/* Locking functions for pfil_head to run the hook chain. */ +struct rm_priotracker; /* Do not require including rmlock header */ int pfil_try_rlock(struct pfil_head *, struct rm_priotracker *); void pfil_rlock(struct pfil_head *, struct rm_priotracker *); void pfil_runlock(struct pfil_head *, struct rm_priotracker *); @@ -118,15 +125,16 @@ void pfil_wlock(struct pfil_head *); void pfil_wunlock(struct pfil_head *); int pfil_wowned(struct pfil_head *ph); -int pfil_head_register(struct pfil_head *); -int pfil_head_unregister(struct pfil_head *); - -struct pfil_head *pfil_head_get(int, u_long); +#define PFIL_TRY_RLOCK(p, t) rm_try_rlock((p)->ph_plock, (t)) +#define PFIL_RLOCK(p, t) rm_rlock((p)->ph_plock, (t)) +#define PFIL_WLOCK(p) rm_wlock((p)->ph_plock) +#define PFIL_RUNLOCK(p, t) rm_runlock((p)->ph_plock, (t)) +#define PFIL_WUNLOCK(p) rm_wunlock((p)->ph_plock) +#define PFIL_WOWNED(p) rm_wowned((p)->ph_plock) -#define PFIL_HOOKED(p) ((p)->ph_nhooks > 0) -#define PFIL_LOCK_INIT_REAL(l, t) \ +#define PFIL_LOCK_INIT_REAL(l, t) \ rm_init_flags(l, "PFil " t " rmlock", RM_RECURSE) -#define PFIL_LOCK_DESTROY_REAL(l) \ +#define PFIL_LOCK_DESTROY_REAL(l) \ rm_destroy(l) #define PFIL_LOCK_INIT(p) do { \ if ((p)->flags & PFIL_FLAG_PRIVATE_LOCK) { \ @@ -139,13 +147,9 @@ struct pfil_head *pfil_head_get(int, u_l if ((p)->flags & PFIL_FLAG_PRIVATE_LOCK) \ PFIL_LOCK_DESTROY_REAL((p)->ph_plock); \ } while (0) -#define PFIL_TRY_RLOCK(p, t) rm_try_rlock((p)->ph_plock, (t)) -#define PFIL_RLOCK(p, t) rm_rlock((p)->ph_plock, (t)) -#define PFIL_WLOCK(p) rm_wlock((p)->ph_plock) -#define PFIL_RUNLOCK(p, t) rm_runlock((p)->ph_plock, (t)) -#define PFIL_WUNLOCK(p) rm_wunlock((p)->ph_plock) -#define PFIL_WOWNED(p) rm_wowned((p)->ph_plock) -#define PFIL_LIST_LOCK() mtx_lock(&pfil_global_lock) -#define PFIL_LIST_UNLOCK() mtx_unlock(&pfil_global_lock) + +/* Internal locking macros for global/vnet pfil_head_list. */ +#define PFIL_HEADLIST_LOCK() mtx_lock(&pfil_global_lock) +#define PFIL_HEADLIST_UNLOCK() mtx_unlock(&pfil_global_lock) #endif /* _NET_PFIL_H_ */ From owner-svn-src-user@FreeBSD.ORG Thu Nov 22 22:14:04 2012 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 26E12830 for ; Thu, 22 Nov 2012 22:14:04 +0000 (UTC) (envelope-from andre@freebsd.org) Received: from c00l3r.networx.ch (c00l3r.networx.ch [62.48.2.2]) by mx1.freebsd.org (Postfix) with ESMTP id A2E898FC1B for ; Thu, 22 Nov 2012 22:14:03 +0000 (UTC) Received: (qmail 11571 invoked from network); 22 Nov 2012 23:46:25 -0000 Received: from c00l3r.networx.ch (HELO [127.0.0.1]) ([62.48.2.2]) (envelope-sender ) by c00l3r.networx.ch (qmail-ldap-1.03) with SMTP for ; 22 Nov 2012 23:46:25 -0000 Message-ID: <50AEA39D.4080704@freebsd.org> Date: Thu, 22 Nov 2012 23:13:49 +0100 From: Andre Oppermann User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:16.0) Gecko/20121026 Thunderbird/16.0.2 MIME-Version: 1.0 To: =?ISO-8859-1?Q?Ermal_Lu=E7i?= Subject: Re: svn commit: r243414 - user/andre/tcp_workqueue/sys/net References: <201211222043.qAMKh9Zs060179@svn.freebsd.org> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Cc: src-committers@freebsd.org, svn-src-user@freebsd.org X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Nov 2012 22:14:04 -0000 On 22.11.2012 21:48, Ermal Luçi wrote: > Hello Andre, > > you plan to introduce pfil(9) at layer2 as well? We already have that in net/if_ethersubr.c for ethernet at least. -- Andre From owner-svn-src-user@FreeBSD.ORG Thu Nov 22 22:53:40 2012 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id B30E458C; Thu, 22 Nov 2012 22:53:40 +0000 (UTC) (envelope-from ermal.luci@gmail.com) Received: from mail-qa0-f54.google.com (mail-qa0-f54.google.com [209.85.216.54]) by mx1.freebsd.org (Postfix) with ESMTP id 379558FC17; Thu, 22 Nov 2012 22:53:39 +0000 (UTC) Received: by mail-qa0-f54.google.com with SMTP id g24so1350560qab.13 for ; Thu, 22 Nov 2012 14:53:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=aRnov/3TkgqlJU+K7Ye0XTn5Neo8WE/nux9S6ySTGuY=; b=iRgjUF+Cur6U4+/HdGmKiiimxV9T5JDW0qdm+RtKVDgNntrers/2gPfMClaIG3DkxV EsC5v6DGUOVgZOgFT2I8gHnNoVSppvWp5F2088I6gm6ziOTLJrjVIkKlafVViov0/ov7 lB5yBKlmZwNLPUbUcvNA+zLt6owNBRedLbO0yP18KQP0zakgiwcV0sPvLiBYYP5WmezH ra8VgYy+tRnN0ZHo5r48rmDxn3lcB1TrB4EoDhynrGm+anToT9L9SVGF3LbDRP2vHJEx WkgmvELQvFYVhOQeS/coyPJRUpY8b99BnQAqF+4fM77VNrq5PkGIOXovJWp+1g+AEEKL 1vmw== MIME-Version: 1.0 Received: by 10.224.53.5 with SMTP id k5mr2579808qag.20.1353624819384; Thu, 22 Nov 2012 14:53:39 -0800 (PST) Sender: ermal.luci@gmail.com Received: by 10.49.121.163 with HTTP; Thu, 22 Nov 2012 14:53:39 -0800 (PST) In-Reply-To: <50AEA39D.4080704@freebsd.org> References: <201211222043.qAMKh9Zs060179@svn.freebsd.org> <50AEA39D.4080704@freebsd.org> Date: Thu, 22 Nov 2012 23:53:39 +0100 X-Google-Sender-Auth: eX6EA05pkDAp7-6-OYgAfiH8gl0 Message-ID: Subject: Re: svn commit: r243414 - user/andre/tcp_workqueue/sys/net From: =?ISO-8859-1?Q?Ermal_Lu=E7i?= To: Andre Oppermann Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.14 Cc: src-committers@freebsd.org, svn-src-user@freebsd.org X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Nov 2012 22:53:40 -0000 On Thu, Nov 22, 2012 at 11:13 PM, Andre Oppermann wrote= : > On 22.11.2012 21:48, Ermal Lu=E7i wrote: > >> Hello Andre, >> >> you plan to introduce pfil(9) at layer2 as well? >> > > We already have that in net/if_ethersubr.c for ethernet at least. > > Hmm have missed the addition of that one. I would have liked that with that hook all the special cases(bridge/netgraph/carp/... to go away. Anyway, thank you for the reply. --=20 > Andre > > --=20 Ermal From owner-svn-src-user@FreeBSD.ORG Thu Nov 22 23:18:48 2012 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 31FE9A0C for ; Thu, 22 Nov 2012 23:18:48 +0000 (UTC) (envelope-from andre@freebsd.org) Received: from c00l3r.networx.ch (c00l3r.networx.ch [62.48.2.2]) by mx1.freebsd.org (Postfix) with ESMTP id 80DDA8FC17 for ; Thu, 22 Nov 2012 23:18:47 +0000 (UTC) Received: (qmail 11825 invoked from network); 23 Nov 2012 00:51:15 -0000 Received: from c00l3r.networx.ch (HELO [127.0.0.1]) ([62.48.2.2]) (envelope-sender ) by c00l3r.networx.ch (qmail-ldap-1.03) with SMTP for ; 23 Nov 2012 00:51:15 -0000 Message-ID: <50AEB2CF.3040904@freebsd.org> Date: Fri, 23 Nov 2012 00:18:39 +0100 From: Andre Oppermann User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:16.0) Gecko/20121026 Thunderbird/16.0.2 MIME-Version: 1.0 To: =?ISO-8859-1?Q?Ermal_Lu=E7i?= Subject: Re: svn commit: r243414 - user/andre/tcp_workqueue/sys/net References: <201211222043.qAMKh9Zs060179@svn.freebsd.org> <50AEA39D.4080704@freebsd.org> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Cc: src-committers@freebsd.org, svn-src-user@freebsd.org X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Nov 2012 23:18:48 -0000 On 22.11.2012 23:53, Ermal Luçi wrote: > > > > On Thu, Nov 22, 2012 at 11:13 PM, Andre Oppermann > wrote: > > On 22.11.2012 21:48, Ermal Luçi wrote: > > Hello Andre, > > you plan to introduce pfil(9) at layer2 as well? > > > We already have that in net/if_ethersubr.c for ethernet at least. > > > Hmm have missed the addition of that one. > I would have liked that with that hook all the special cases(bridge/netgraph/carp/... to go away. Indeed. Lets make it happen. :-) -- Andre From owner-svn-src-user@FreeBSD.ORG Fri Nov 23 06:44:15 2012 Return-Path: Delivered-To: svn-src-user@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9EA0645D; Fri, 23 Nov 2012 06:44:15 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from cell.glebius.int.ru (glebius.int.ru [81.19.64.117]) by mx1.freebsd.org (Postfix) with ESMTP id 12DBD8FC0C; Fri, 23 Nov 2012 06:44:14 +0000 (UTC) Received: from cell.glebius.int.ru (localhost [127.0.0.1]) by cell.glebius.int.ru (8.14.5/8.14.5) with ESMTP id qAN6iD51088776; Fri, 23 Nov 2012 10:44:13 +0400 (MSK) (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by cell.glebius.int.ru (8.14.5/8.14.5/Submit) id qAN6iDv1088775; Fri, 23 Nov 2012 10:44:13 +0400 (MSK) (envelope-from glebius@FreeBSD.org) X-Authentication-Warning: cell.glebius.int.ru: glebius set sender to glebius@FreeBSD.org using -f Date: Fri, 23 Nov 2012 10:44:13 +0400 From: Gleb Smirnoff To: Andre Oppermann Subject: Re: svn commit: r243414 - user/andre/tcp_workqueue/sys/net Message-ID: <20121123064413.GG84121@FreeBSD.org> References: <201211222043.qAMKh9Zs060179@svn.freebsd.org> <50AEA39D.4080704@freebsd.org> <50AEB2CF.3040904@freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline In-Reply-To: <50AEB2CF.3040904@freebsd.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: Ermal Lu?i , src-committers@FreeBSD.org, svn-src-user@FreeBSD.org X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Nov 2012 06:44:15 -0000 On Fri, Nov 23, 2012 at 12:18:39AM +0100, Andre Oppermann wrote: A> > On Thu, Nov 22, 2012 at 11:13 PM, Andre Oppermann > wrote: A> > A> > Hello Andre, A> > you plan to introduce pfil(9) at layer2 as well? A> > A> > We already have that in net/if_ethersubr.c for ethernet at least. A> > A> > Hmm have missed the addition of that one. A> > I would have liked that with that hook all the special cases(bridge/netgraph/carp/... to go away. A> A> Indeed. Lets make it happen. :-) It is impossible to convert netgraph to be a pfil, since netgraph isn't just a function call. It doesn't return processed packet immediately. The carp(4) isn't a layer 2 protocol, but is IP protocol, so I don't understand how can it be converted to a pfil hook. -- Totus tuus, Glebius. From owner-svn-src-user@FreeBSD.ORG Fri Nov 23 07:51:52 2012 Return-Path: Delivered-To: svn-src-user@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 015B4AC for ; Fri, 23 Nov 2012 07:51:52 +0000 (UTC) (envelope-from andre@freebsd.org) Received: from c00l3r.networx.ch (c00l3r.networx.ch [62.48.2.2]) by mx1.freebsd.org (Postfix) with ESMTP id 5B2038FC12 for ; Fri, 23 Nov 2012 07:51:51 +0000 (UTC) Received: (qmail 13524 invoked from network); 23 Nov 2012 09:24:15 -0000 Received: from c00l3r.networx.ch (HELO [127.0.0.1]) ([62.48.2.2]) (envelope-sender ) by c00l3r.networx.ch (qmail-ldap-1.03) with SMTP for ; 23 Nov 2012 09:24:15 -0000 Message-ID: <50AF2B0F.7000002@freebsd.org> Date: Fri, 23 Nov 2012 08:51:43 +0100 From: Andre Oppermann User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:16.0) Gecko/20121026 Thunderbird/16.0.2 MIME-Version: 1.0 To: Gleb Smirnoff Subject: Re: svn commit: r243414 - user/andre/tcp_workqueue/sys/net References: <201211222043.qAMKh9Zs060179@svn.freebsd.org> <50AEA39D.4080704@freebsd.org> <50AEB2CF.3040904@freebsd.org> <20121123064413.GG84121@FreeBSD.org> In-Reply-To: <20121123064413.GG84121@FreeBSD.org> Content-Type: text/plain; charset=KOI8-R; format=flowed Content-Transfer-Encoding: 7bit Cc: Ermal Lu?i , src-committers@FreeBSD.org, svn-src-user@FreeBSD.org X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Nov 2012 07:51:52 -0000 On 23.11.2012 07:44, Gleb Smirnoff wrote: > On Fri, Nov 23, 2012 at 12:18:39AM +0100, Andre Oppermann wrote: > A> > On Thu, Nov 22, 2012 at 11:13 PM, Andre Oppermann > wrote: > A> > > A> > Hello Andre, > A> > you plan to introduce pfil(9) at layer2 as well? > A> > > A> > We already have that in net/if_ethersubr.c for ethernet at least. > A> > > A> > Hmm have missed the addition of that one. > A> > I would have liked that with that hook all the special cases(bridge/netgraph/carp/... to go away. > A> > A> Indeed. Lets make it happen. :-) > > It is impossible to convert netgraph to be a pfil, since netgraph isn't > just a function call. It doesn't return processed packet immediately. That's why I added the pfil cookies. You can re-inject a packet after a particular hook after deferred processing. > The carp(4) isn't a layer 2 protocol, but is IP protocol, so I > don't understand how can it be converted to a pfil hook. Obviously not everything can be a layer 2 pfil hook. Where it can, we should at least investigate it to limit the number of special cases in the path. A potential issue is the cpu pinning of the pfil rmlock. We'll have to see whether this is an immediate problem, and if yes, what we can do about it. -- Andre From owner-svn-src-user@FreeBSD.ORG Fri Nov 23 11:40:35 2012 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 4DF65400; Fri, 23 Nov 2012 11:40:35 +0000 (UTC) (envelope-from ermal.luci@gmail.com) Received: from mail-qc0-f182.google.com (mail-qc0-f182.google.com [209.85.216.182]) by mx1.freebsd.org (Postfix) with ESMTP id B30B08FC08; Fri, 23 Nov 2012 11:40:34 +0000 (UTC) Received: by mail-qc0-f182.google.com with SMTP id k19so8022859qcs.13 for ; Fri, 23 Nov 2012 03:40:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=7/y5aWn9gxuOUGrf+Wa/wFqgTTPeMM83DoOuevaAePE=; b=rl+8bNkrdvHrDuj1Hp9lmo5ciplwKbxcQhpuGVnhYlfWsSf0Z98nC5VIiae4Qst+yB W59hjdulg5dREWO9T8Bd7JqVXtBKhBcVIG6mdMcmR4ioNXMwi2IJTuVQmTpq14JO9nM9 0b+x/+jZW7lyNCemVxwZq8JhfBH+BOXI0DCIjVHKKnaS/9gu2Ff8twYkrD/KS89dRR2j Qs58vJvZJH0Pr1h98V9h3R+zIMPDeMADkVxKgBI3mj/ANltjsB3YcSVBdsMeZp3G3iUV y5Hf8GxA5+LyTYjs5I+3MNjbwQhee5ASGKNsNeRn6kEU5lCuwMM0y7V3bqMSKuic0wK4 JIKQ== MIME-Version: 1.0 Received: by 10.224.53.5 with SMTP id k5mr4021061qag.20.1353670834012; Fri, 23 Nov 2012 03:40:34 -0800 (PST) Sender: ermal.luci@gmail.com Received: by 10.49.121.163 with HTTP; Fri, 23 Nov 2012 03:40:33 -0800 (PST) In-Reply-To: <50AF2B0F.7000002@freebsd.org> References: <201211222043.qAMKh9Zs060179@svn.freebsd.org> <50AEA39D.4080704@freebsd.org> <50AEB2CF.3040904@freebsd.org> <20121123064413.GG84121@FreeBSD.org> <50AF2B0F.7000002@freebsd.org> Date: Fri, 23 Nov 2012 12:40:33 +0100 X-Google-Sender-Auth: aBoBO2ut9ZZVzzC2Mz_yF37UpJQ Message-ID: Subject: Re: svn commit: r243414 - user/andre/tcp_workqueue/sys/net From: =?ISO-8859-1?Q?Ermal_Lu=E7i?= To: Andre Oppermann Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.14 Cc: Gleb Smirnoff , src-committers@freebsd.org, svn-src-user@freebsd.org X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Nov 2012 11:40:35 -0000 On Fri, Nov 23, 2012 at 8:51 AM, Andre Oppermann wrote: > On 23.11.2012 07:44, Gleb Smirnoff wrote: > >> On Fri, Nov 23, 2012 at 12:18:39AM +0100, Andre Oppermann wrote: >> A> > On Thu, Nov 22, 2012 at 11:13 PM, Andre Oppermann > andre@freebsd.org>> wrote: >> A> > >> A> > Hello Andre, >> A> > you plan to introduce pfil(9) at layer2 as well? >> A> > >> A> > We already have that in net/if_ethersubr.c for ethernet at least. >> A> > >> A> > Hmm have missed the addition of that one. >> A> > I would have liked that with that hook all the special >> cases(bridge/netgraph/carp/... to go away. >> A> >> A> Indeed. Lets make it happen. :-) >> >> It is impossible to convert netgraph to be a pfil, since netgraph isn't >> just a function call. It doesn't return processed packet immediately. >> > > That's why I added the pfil cookies. You can re-inject a packet after a > particular hook after deferred processing. > > Oh this is on your branch. I see the usability of it. What would have been more interesting is to split all function where pfil hook is called in two. I.e taking into consideration ip_output. Split the function into two parts at the pfil hook call and pass to the pfil_hook call the next step as a callback. 1) ip_output_start() 2) Call pfil hook(callback ip_output_do()) 3) pfil consumer does its own processing/looping/or choose a different output path 4) Default method after pfil return call callback This even resolves the issues of implementation of pf(4) route-to/reply-to or whatever other implementation. This is similar to how crypto currently does this. That way you avoid locking and deferring issues and simplify functionality. > > The carp(4) isn't a layer 2 protocol, but is IP protocol, so I >> don't understand how can it be converted to a pfil hook. >> > > Obviously not everything can be a layer 2 pfil hook. Where it can, we > should at least investigate it to limit the number of special cases in > the path. > > Surely carp(4) is a hybrid approach. Though it hooks into at least the ethernet layer to do some rewriting of packet information. If it can be integrated into the pfil hook why not go that route. While the better solution would be support for stacked interfaces, incremental is better in general for this part of system. > A potential issue is the cpu pinning of the pfil rmlock. We'll have to > see whether this is an immediate problem, and if yes, what we can do about > it. > > Also it would be nice to have some locality information on the pfil per interface to avoid 'overhead' of going into the pfil chain call. This is an optimization which would remove the special fields in the ifnet structure and allow to have the pfil hook per interface. Also it avoids sending every packet to a hook consumer that is interested on packets from only a specific source. So the subsystems can implement their own optimizations and be self contained. > -- > Andre > > -- Ermal From owner-svn-src-user@FreeBSD.ORG Fri Nov 23 14:16:24 2012 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id C45CF955; Fri, 23 Nov 2012 14:16:24 +0000 (UTC) (envelope-from andre@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id A829C8FC0C; Fri, 23 Nov 2012 14:16:24 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qANEGOuA029765; Fri, 23 Nov 2012 14:16:24 GMT (envelope-from andre@svn.freebsd.org) Received: (from andre@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qANEGOgE029763; Fri, 23 Nov 2012 14:16:24 GMT (envelope-from andre@svn.freebsd.org) Message-Id: <201211231416.qANEGOgE029763@svn.freebsd.org> From: Andre Oppermann Date: Fri, 23 Nov 2012 14:16:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r243454 - in user/andre/tcp_workqueue/sys: net netinet X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Nov 2012 14:16:25 -0000 Author: andre Date: Fri Nov 23 14:16:24 2012 New Revision: 243454 URL: http://svnweb.freebsd.org/changeset/base/243454 Log: Move declaration of _net_link_ether sysctl node to net/ethernet.h. Modified: user/andre/tcp_workqueue/sys/net/ethernet.h user/andre/tcp_workqueue/sys/netinet/if_ether.c Modified: user/andre/tcp_workqueue/sys/net/ethernet.h ============================================================================== --- user/andre/tcp_workqueue/sys/net/ethernet.h Fri Nov 23 14:00:26 2012 (r243453) +++ user/andre/tcp_workqueue/sys/net/ethernet.h Fri Nov 23 14:16:24 2012 (r243454) @@ -363,6 +363,10 @@ struct ether_addr { #ifdef _KERNEL +#ifdef SYSCTL_DECL +SYSCTL_DECL(_net_link_ether); +#endif + struct ifnet; struct mbuf; struct route; Modified: user/andre/tcp_workqueue/sys/netinet/if_ether.c ============================================================================== --- user/andre/tcp_workqueue/sys/netinet/if_ether.c Fri Nov 23 14:00:26 2012 (r243453) +++ user/andre/tcp_workqueue/sys/netinet/if_ether.c Fri Nov 23 14:16:24 2012 (r243454) @@ -76,7 +76,6 @@ __FBSDID("$FreeBSD$"); #define SIN(s) ((struct sockaddr_in *)s) #define SDL(s) ((struct sockaddr_dl *)s) -SYSCTL_DECL(_net_link_ether); static SYSCTL_NODE(_net_link_ether, PF_INET, inet, CTLFLAG_RW, 0, ""); static SYSCTL_NODE(_net_link_ether, PF_ARP, arp, CTLFLAG_RW, 0, ""); From owner-svn-src-user@FreeBSD.ORG Fri Nov 23 14:18:24 2012 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 7C642BF6; Fri, 23 Nov 2012 14:18:24 +0000 (UTC) (envelope-from andre@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 619D08FC08; Fri, 23 Nov 2012 14:18:24 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qANEIOGv030115; Fri, 23 Nov 2012 14:18:24 GMT (envelope-from andre@svn.freebsd.org) Received: (from andre@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qANEIOjv030113; Fri, 23 Nov 2012 14:18:24 GMT (envelope-from andre@svn.freebsd.org) Message-Id: <201211231418.qANEIOjv030113@svn.freebsd.org> From: Andre Oppermann Date: Fri, 23 Nov 2012 14:18:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r243456 - user/andre/tcp_workqueue/sys/netinet6 X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Nov 2012 14:18:24 -0000 Author: andre Date: Fri Nov 23 14:18:23 2012 New Revision: 243456 URL: http://svnweb.freebsd.org/changeset/base/243456 Log: Move declaration of _net_inet6 sysctl node to netinet6/in6_var.h. Modified: user/andre/tcp_workqueue/sys/netinet6/in6_var.h user/andre/tcp_workqueue/sys/netinet6/ip6_input.c Modified: user/andre/tcp_workqueue/sys/netinet6/in6_var.h ============================================================================== --- user/andre/tcp_workqueue/sys/netinet6/in6_var.h Fri Nov 23 14:16:55 2012 (r243455) +++ user/andre/tcp_workqueue/sys/netinet6/in6_var.h Fri Nov 23 14:18:23 2012 (r243456) @@ -498,6 +498,9 @@ struct in6_rrenumreq { #endif #ifdef _KERNEL +#ifdef SYSCTL_DECL +SYSCTL_DECL(_net_inet6); +#endif VNET_DECLARE(struct in6_ifaddrhead, in6_ifaddrhead); #define V_in6_ifaddrhead VNET(in6_ifaddrhead) Modified: user/andre/tcp_workqueue/sys/netinet6/ip6_input.c ============================================================================== --- user/andre/tcp_workqueue/sys/netinet6/ip6_input.c Fri Nov 23 14:16:55 2012 (r243455) +++ user/andre/tcp_workqueue/sys/netinet6/ip6_input.c Fri Nov 23 14:18:23 2012 (r243456) @@ -174,7 +174,8 @@ ip6_init(void) /* Initialize packet filter hooks. */ V_inet6_pfil_hook.ph_type = PFIL_TYPE_AF; V_inet6_pfil_hook.ph_af = AF_INET6; - if ((i = pfil_head_register(&V_inet6_pfil_hook)) != 0) + if ((i = pfil_head_register(&V_inet6_pfil_hook, + SYSCTL_STATIC_CHILDREN(_net_inet6))) != 0) printf("%s: WARNING: unable to register pfil hook, " "error %d\n", __func__, i); From owner-svn-src-user@FreeBSD.ORG Fri Nov 23 14:20:28 2012 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 338A9E4F; Fri, 23 Nov 2012 14:20:28 +0000 (UTC) (envelope-from andre@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 19EDD8FC14; Fri, 23 Nov 2012 14:20:28 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qANEKRch030437; Fri, 23 Nov 2012 14:20:27 GMT (envelope-from andre@svn.freebsd.org) Received: (from andre@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qANEKRfF030435; Fri, 23 Nov 2012 14:20:27 GMT (envelope-from andre@svn.freebsd.org) Message-Id: <201211231420.qANEKRfF030435@svn.freebsd.org> From: Andre Oppermann Date: Fri, 23 Nov 2012 14:20:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r243457 - user/andre/tcp_workqueue/sys/netinet6 X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Nov 2012 14:20:28 -0000 Author: andre Date: Fri Nov 23 14:20:27 2012 New Revision: 243457 URL: http://svnweb.freebsd.org/changeset/base/243457 Log: Move declaration of _net_inet6 sysctl node to netinet6/in6_var.h. Fix to r243456. Modified: user/andre/tcp_workqueue/sys/netinet6/ip6_mroute.c Modified: user/andre/tcp_workqueue/sys/netinet6/ip6_mroute.c ============================================================================== --- user/andre/tcp_workqueue/sys/netinet6/ip6_mroute.c Fri Nov 23 14:18:23 2012 (r243456) +++ user/andre/tcp_workqueue/sys/netinet6/ip6_mroute.c Fri Nov 23 14:20:27 2012 (r243457) @@ -153,7 +153,6 @@ static int pim6_encapcheck(const struct static VNET_DEFINE(int, ip6_mrouter_ver) = 0; #define V_ip6_mrouter_ver VNET(ip6_mrouter_ver) -SYSCTL_DECL(_net_inet6); SYSCTL_DECL(_net_inet6_ip6); static SYSCTL_NODE(_net_inet6, IPPROTO_PIM, pim, CTLFLAG_RW, 0, "PIM"); From owner-svn-src-user@FreeBSD.ORG Fri Nov 23 14:53:29 2012 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 097F4AAE; Fri, 23 Nov 2012 14:53:29 +0000 (UTC) (envelope-from andre@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id D81568FC08; Fri, 23 Nov 2012 14:53:28 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qANErS4l034911; Fri, 23 Nov 2012 14:53:28 GMT (envelope-from andre@svn.freebsd.org) Received: (from andre@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qANErSKF034907; Fri, 23 Nov 2012 14:53:28 GMT (envelope-from andre@svn.freebsd.org) Message-Id: <201211231453.qANErSKF034907@svn.freebsd.org> From: Andre Oppermann Date: Fri, 23 Nov 2012 14:53:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r243458 - in user/andre/tcp_workqueue/sys: net netinet X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Nov 2012 14:53:29 -0000 Author: andre Date: Fri Nov 23 14:53:28 2012 New Revision: 243458 URL: http://svnweb.freebsd.org/changeset/base/243458 Log: Add sysctl support for pfil hook reporting and ordering. pfil_head_register() takes an additional pointer to the parent sysctl node pointer of the protocol family that is being registered here. Two new branches are then attached named "pfil_in" and "pfil_out". In each branch a list of the attached pfil hooks in the order of their processing is provided in the "hooks" string sysctl. In addition each attached pfil hook has its own node with a numeric representation of is ordering rank (0-255). Writing a new ordering rank changes the processing order. If two hooks have the same rank the last installed or changed comes first. Example output: net.inet.pfil_in.hooks="pf,ipfw,ipfilter" net.inet.pfil_in.pf=200 net.inet.pfil_in.ipfw=201 net.inet.pfil_in.ipfilter=202 net.inet.pfil_out.hooks="ipfilter,ipfw,pf" net.inet.pfil_out.ipfilter=53 net.inet.pfil_out.ipfw=54 net.inet.pfil_out.pf=55 This may be further tweaked and refined. Modified: user/andre/tcp_workqueue/sys/net/if_ethersubr.c user/andre/tcp_workqueue/sys/net/pfil.c user/andre/tcp_workqueue/sys/net/pfil.h user/andre/tcp_workqueue/sys/netinet/ip_input.c Modified: user/andre/tcp_workqueue/sys/net/if_ethersubr.c ============================================================================== --- user/andre/tcp_workqueue/sys/net/if_ethersubr.c Fri Nov 23 14:20:27 2012 (r243457) +++ user/andre/tcp_workqueue/sys/net/if_ethersubr.c Fri Nov 23 14:53:28 2012 (r243458) @@ -48,6 +48,7 @@ #include #include #include +#include #include #include @@ -686,7 +687,8 @@ vnet_ether_init(__unused void *arg) /* Initialize packet filter hooks. */ V_link_pfil_hook.ph_type = PFIL_TYPE_AF; V_link_pfil_hook.ph_af = AF_LINK; - if ((i = pfil_head_register(&V_link_pfil_hook)) != 0) + if ((i = pfil_head_register(&V_link_pfil_hook, + SYSCTL_STATIC_CHILDREN(_net_link_ether))) != 0) printf("%s: WARNING: unable to register pfil link hook, " "error %d\n", __func__, i); } Modified: user/andre/tcp_workqueue/sys/net/pfil.c ============================================================================== --- user/andre/tcp_workqueue/sys/net/pfil.c Fri Nov 23 14:20:27 2012 (r243457) +++ user/andre/tcp_workqueue/sys/net/pfil.c Fri Nov 23 14:53:28 2012 (r243458) @@ -37,12 +37,15 @@ #include #include #include +#include #include +#include #include #include #include #include #include +#include #include #include @@ -50,9 +53,10 @@ static struct mtx pfil_global_lock; MTX_SYSINIT(pfil_global_lock, &pfil_global_lock, "pfil_head_list lock", MTX_DEF); -static int pfil_chain_add(pfil_chain_t *, struct packet_filter_hook *, - int, uint8_t); +static int pfil_chain_add(pfil_chain_t *, struct packet_filter_hook *, int); static int pfil_chain_remove(pfil_chain_t *, pfil_func_t, void *); +static int pfil_chain_sysctl(SYSCTL_HANDLER_ARGS); +static int pfil_hook_sysctl(SYSCTL_HANDLER_ARGS); LIST_HEAD(pfilheadhead, pfil_head); VNET_DEFINE(struct pfilheadhead, pfil_head_list); @@ -178,7 +182,7 @@ pfil_wowned(struct pfil_head *ph) * mechanism. */ int -pfil_head_register(struct pfil_head *ph) +pfil_head_register(struct pfil_head *ph, struct sysctl_oid_list *parent) { struct pfil_head *lph; @@ -195,6 +199,18 @@ pfil_head_register(struct pfil_head *ph) TAILQ_INIT(&ph->ph_in); TAILQ_INIT(&ph->ph_out); LIST_INSERT_HEAD(&V_pfil_head_list, ph, ph_list); + sysctl_ctx_init(ph->ph_sysctl_ctx); + ph->ph_sysctl_oid_in = SYSCTL_ADD_NODE(ph->ph_sysctl_ctx, parent, + OID_AUTO, "pfil_in", CTLFLAG_RD, NULL, "input packet filter hooks"); + SYSCTL_ADD_PROC(ph->ph_sysctl_ctx, SYSCTL_CHILDREN(ph->ph_sysctl_oid_in), + OID_AUTO, "hooks", (CTLTYPE_STRING|CTLFLAG_RD), ph, (intptr_t)&ph->ph_in, + pfil_chain_sysctl, "S", "input chain list"); + ph->ph_sysctl_oid_out = SYSCTL_ADD_NODE(ph->ph_sysctl_ctx, parent, + OID_AUTO, "pfil_out", CTLFLAG_RD, NULL, "output packet filter hooks"); + SYSCTL_ADD_PROC(ph->ph_sysctl_ctx, SYSCTL_CHILDREN(ph->ph_sysctl_oid_out), + OID_AUTO, "hooks", (CTLTYPE_STRING|CTLFLAG_RD), ph, (intptr_t)&ph->ph_out, + pfil_chain_sysctl, "S", "output chain list"); + PFIL_HEADLIST_UNLOCK(); return (0); } @@ -212,6 +228,7 @@ pfil_head_unregister(struct pfil_head *p PFIL_HEADLIST_LOCK(); LIST_REMOVE(ph, ph_list); PFIL_HEADLIST_UNLOCK(); + sysctl_ctx_free(ph->ph_sysctl_ctx); /* Removes all children. */ TAILQ_FOREACH_SAFE(pfh, &ph->ph_in, pfil_chain, pfnext) free(pfh, M_IFADDR); TAILQ_FOREACH_SAFE(pfh, &ph->ph_out, pfil_chain, pfnext) @@ -262,6 +279,11 @@ pfil_add_hook_order(pfil_func_t func, vo struct packet_filter_hook *pfh2 = NULL; int err; + KASSERT(func != NULL || arg != NULL || ph != NULL, + ("%s: func, arg or ph is NULL", __func__)); + KASSERT(name != NULL || *name != '\0', + ("%s: name is NULL or empty", __func__)); + if (flags & PFIL_IN) { pfh1 = (struct packet_filter_hook *)malloc(sizeof(*pfh1), M_IFADDR, (flags & PFIL_WAITOK) ? M_WAITOK : M_NOWAIT); @@ -274,6 +296,7 @@ pfil_add_hook_order(pfil_func_t func, vo pfh1->pfil_cookie = (int)random(); pfh1->pfil_order = order; pfh1->pfil_name = name; + pfh1->pfil_head = ph; } if (flags & PFIL_OUT) { pfh2 = (struct packet_filter_hook *)malloc(sizeof(*pfh1), @@ -287,16 +310,17 @@ pfil_add_hook_order(pfil_func_t func, vo pfh2->pfil_cookie = (int)random(); pfh2->pfil_order = order; pfh2->pfil_name = name; + pfh2->pfil_head = ph; } PFIL_WLOCK(ph); if (flags & PFIL_IN) { - err = pfil_chain_add(&ph->ph_in, pfh1, flags & ~PFIL_OUT, order); + err = pfil_chain_add(&ph->ph_in, pfh1, flags & ~PFIL_OUT); if (err) goto locked_error; ph->ph_nhooks++; } if (flags & PFIL_OUT) { - err = pfil_chain_add(&ph->ph_out, pfh2, flags & ~PFIL_IN, order); + err = pfil_chain_add(&ph->ph_out, pfh2, flags & ~PFIL_IN); if (err) { if (flags & PFIL_IN) pfil_chain_remove(&ph->ph_in, func, arg); @@ -304,6 +328,22 @@ pfil_add_hook_order(pfil_func_t func, vo } ph->ph_nhooks++; } + + if (flags & PFIL_IN) { + pfh1->pfil_sysctl_oid = SYSCTL_ADD_PROC(ph->ph_sysctl_ctx, + SYSCTL_CHILDREN(ph->ph_sysctl_oid_in), OID_AUTO, name, + (CTLTYPE_INT|CTLFLAG_RW), pfh1,(intptr_t)&ph->ph_in, + pfil_hook_sysctl, "I", + "place in input chain of this packet filter hook"); + } + if (flags & PFIL_OUT) { + pfh2->pfil_sysctl_oid = SYSCTL_ADD_PROC(ph->ph_sysctl_ctx, + SYSCTL_CHILDREN(ph->ph_sysctl_oid_out), OID_AUTO, name, + (CTLTYPE_INT|CTLFLAG_RW), pfh2, (intptr_t)&ph->ph_out, + pfil_hook_sysctl, "I", + "place in output chain of this packet filter hook"); + } + PFIL_WUNLOCK(ph); return (0); locked_error: @@ -369,8 +409,7 @@ out: * Internal: Add a new pfil hook into a hook chain. */ static int -pfil_chain_add(pfil_chain_t *chain, struct packet_filter_hook *pfh1, int flags, - uint8_t order) +pfil_chain_add(pfil_chain_t *chain, struct packet_filter_hook *pfh1, int flags) { struct packet_filter_hook *pfh; @@ -388,7 +427,7 @@ pfil_chain_add(pfil_chain_t *chain, stru */ if (flags & PFIL_IN) { TAILQ_FOREACH(pfh, chain, pfil_chain) { - if (pfh->pfil_order <= order) + if (pfh->pfil_order <= pfh1->pfil_order) break; } if (pfh == NULL) @@ -397,7 +436,7 @@ pfil_chain_add(pfil_chain_t *chain, stru TAILQ_INSERT_BEFORE(pfh, pfh1, pfil_chain); } else { TAILQ_FOREACH_REVERSE(pfh, chain, pfil_chain, pfil_chain) - if (pfh->pfil_order >= order) + if (pfh->pfil_order >= pfh1->pfil_order) break; if (pfh == NULL) TAILQ_INSERT_TAIL(chain, pfh1, pfil_chain); @@ -409,6 +448,7 @@ pfil_chain_add(pfil_chain_t *chain, stru /* * Internal: Remove a pfil hook from a hook chain. + * NB: Frees the packet_filter_hook struct. */ static int pfil_chain_remove(pfil_chain_t *chain, pfil_func_t func, void *arg) @@ -418,6 +458,7 @@ pfil_chain_remove(pfil_chain_t *chain, p TAILQ_FOREACH(pfh, chain, pfil_chain) if (pfh->pfil_func == func && pfh->pfil_arg == arg) { TAILQ_REMOVE(chain, pfh, pfil_chain); + sysctl_remove_oid(pfh->pfil_sysctl_oid, 1, 0); free(pfh, M_IFADDR); return (0); } @@ -425,6 +466,94 @@ pfil_chain_remove(pfil_chain_t *chain, p } /* + * Report an ordered list of pfil hook names. + */ +static int +pfil_chain_sysctl(SYSCTL_HANDLER_ARGS) +{ + struct rm_priotracker rmpt; + struct pfil_head *ph; + struct pfil_chain *chain; + struct packet_filter_hook *pfh; + struct sbuf *sb; + int error; + + ph = arg1; + chain = (struct pfil_chain *)arg2; + + sb = sbuf_new_auto(); + PFIL_RLOCK(ph, &rmpt); + if (chain == &ph->ph_in) { + TAILQ_FOREACH(pfh, chain, pfil_chain) { + sbuf_cat(sb, pfh->pfil_name); + if (TAILQ_NEXT(pfh, pfil_chain) != NULL) + sbuf_cat(sb, ","); + } + } else { + TAILQ_FOREACH_REVERSE(pfh, chain, pfil_chain, pfil_chain) { + sbuf_cat(sb, pfh->pfil_name); + if (TAILQ_PREV(pfh, pfil_chain, pfil_chain) != NULL) + sbuf_cat(sb, ","); + } + } + PFIL_RUNLOCK(ph, &rmpt); + if ((error = sbuf_finish(sb)) != 0) + goto out; + + error = sysctl_handle_string(oidp, sbuf_data(sb), sbuf_len(sb), req); +out: + sbuf_delete(sb); + return (error); +} + +/* + * Report the order rank of a pfil hook. + * Change the rank if a new value is provided. + */ +static int +pfil_hook_sysctl(SYSCTL_HANDLER_ARGS) +{ + struct rm_priotracker rmpt; + struct pfil_head *ph; + struct pfil_chain *chain; + struct packet_filter_hook *pfh; + int error, flags, order; + + pfh = arg1; + chain = (pfil_chain_t *)arg2; + + ph = pfh->pfil_head; + PFIL_RLOCK(ph, &rmpt); + order = pfh->pfil_order; + if (chain == &ph->ph_in) + order = pfh->pfil_order; + else + order = ~pfh->pfil_order; + PFIL_RUNLOCK(ph, &rmpt); + + error = sysctl_handle_int(oidp, &order, 0, req); + if (error != 0 || req->newptr == NULL) + goto out; + + if (order < 255 && order >= 0) { + PFIL_WLOCK(ph); + pfh->pfil_order = order; + if (chain == &ph->ph_in) + flags = PFIL_IN; + else { + flags = PFIL_OUT; + pfh->pfil_order = ~pfh->pfil_order; + } + TAILQ_REMOVE(chain, pfh, pfil_chain); + pfil_chain_add(chain, pfh, flags); + PFIL_WUNLOCK(ph); + } else + error = EINVAL; +out: + return (error); +} + +/* * Stuff that must be initialized for every instance (including the first of * course). */ Modified: user/andre/tcp_workqueue/sys/net/pfil.h ============================================================================== --- user/andre/tcp_workqueue/sys/net/pfil.h Fri Nov 23 14:20:27 2012 (r243457) +++ user/andre/tcp_workqueue/sys/net/pfil.h Fri Nov 23 14:53:28 2012 (r243458) @@ -38,6 +38,7 @@ #include #include #include +#include struct mbuf; struct ifnet; @@ -58,6 +59,8 @@ struct packet_filter_hook { int pfil_cookie; uint8_t pfil_order; char *pfil_name; + struct sysctl_oid *pfil_sysctl_oid; + struct pfil_head *pfil_head; }; #define PFIL_ORDER_FIRST 0 @@ -94,12 +97,15 @@ struct pfil_head { } ph_un; #define ph_af ph_un.phu_val #define ph_ifnet ph_un.phu_ptr + struct sysctl_ctx_list *ph_sysctl_ctx; + struct sysctl_oid *ph_sysctl_oid_in; + struct sysctl_oid *ph_sysctl_oid_out; LIST_ENTRY(pfil_head) ph_list; }; /* Public functions for pfil head management by protocols. */ struct pfil_head *pfil_head_get(int, u_long); -int pfil_head_register(struct pfil_head *); +int pfil_head_register(struct pfil_head *, struct sysctl_oid_list *); int pfil_head_unregister(struct pfil_head *); /* Public functions for pfil hook management by protocols. */ Modified: user/andre/tcp_workqueue/sys/netinet/ip_input.c ============================================================================== --- user/andre/tcp_workqueue/sys/netinet/ip_input.c Fri Nov 23 14:20:27 2012 (r243457) +++ user/andre/tcp_workqueue/sys/netinet/ip_input.c Fri Nov 23 14:53:28 2012 (r243458) @@ -298,7 +298,8 @@ ip_init(void) /* Initialize packet filter hooks. */ V_inet_pfil_hook.ph_type = PFIL_TYPE_AF; V_inet_pfil_hook.ph_af = AF_INET; - if ((i = pfil_head_register(&V_inet_pfil_hook)) != 0) + if ((i = pfil_head_register(&V_inet_pfil_hook, + SYSCTL_STATIC_CHILDREN(_net_inet))) != 0) printf("%s: WARNING: unable to register pfil hook, " "error %d\n", __func__, i); From owner-svn-src-user@FreeBSD.ORG Fri Nov 23 14:59:19 2012 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 8C797EC9 for ; Fri, 23 Nov 2012 14:59:19 +0000 (UTC) (envelope-from andre@freebsd.org) Received: from c00l3r.networx.ch (c00l3r.networx.ch [62.48.2.2]) by mx1.freebsd.org (Postfix) with ESMTP id DA5468FC16 for ; Fri, 23 Nov 2012 14:59:18 +0000 (UTC) Received: (qmail 16875 invoked from network); 23 Nov 2012 16:31:38 -0000 Received: from c00l3r.networx.ch (HELO [127.0.0.1]) ([62.48.2.2]) (envelope-sender ) by c00l3r.networx.ch (qmail-ldap-1.03) with SMTP for ; 23 Nov 2012 16:31:38 -0000 Message-ID: <50AF8F3E.9050902@freebsd.org> Date: Fri, 23 Nov 2012 15:59:10 +0100 From: Andre Oppermann User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:16.0) Gecko/20121026 Thunderbird/16.0.2 MIME-Version: 1.0 To: =?ISO-8859-1?Q?Ermal_Lu=E7i?= Subject: Re: svn commit: r243414 - user/andre/tcp_workqueue/sys/net References: <201211222043.qAMKh9Zs060179@svn.freebsd.org> <50AEA39D.4080704@freebsd.org> <50AEB2CF.3040904@freebsd.org> <20121123064413.GG84121@FreeBSD.org> <50AF2B0F.7000002@freebsd.org> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Cc: Gleb Smirnoff , src-committers@freebsd.org, svn-src-user@freebsd.org X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Nov 2012 14:59:19 -0000 On 23.11.2012 12:40, Ermal Luçi wrote: > On Fri, Nov 23, 2012 at 8:51 AM, Andre Oppermann > wrote: > On 23.11.2012 07:44, Gleb Smirnoff wrote: > On Fri, Nov 23, 2012 at 12:18:39AM +0100, Andre Oppermann wrote: > A> > On Thu, Nov 22, 2012 at 11:13 PM, Andre Oppermann >> wrote: > A> > > A> > Hello Andre, > A> > you plan to introduce pfil(9) at layer2 as well? > A> > > A> > We already have that in net/if_ethersubr.c for ethernet at least. > A> > > A> > Hmm have missed the addition of that one. > A> > I would have liked that with that hook all the special cases(bridge/netgraph/carp/... > to go away. > A> > A> Indeed. Lets make it happen. :-) > > It is impossible to convert netgraph to be a pfil, since netgraph isn't > just a function call. It doesn't return processed packet immediately. > > > That's why I added the pfil cookies. You can re-inject a packet after a > particular hook after deferred processing. > > Oh this is on your branch. > I see the usability of it. > What would have been more interesting is to split all function where pfil hook is called in two. > I.e taking into consideration ip_output. > Split the function into two parts at the pfil hook call and pass to the pfil_hook call the next step > as a callback. > 1) ip_output_start() > 2) Call pfil hook(callback ip_output_do()) > 3) pfil consumer does its own processing/looping/or choose a different output path > 4) Default method after pfil return call callback That would be very bad and totally break hook chaining. > This even resolves the issues of implementation of pf(4) route-to/reply-to or whatever other > implementation. That isn't a problem. It's just poorly implemented as is. It should do the same thing as ipfw does and return a correctly tagged mbuf with the new nexthop. ip_output() then handles the rest. > This is similar to how crypto currently does this. > That way you avoid locking and deferring issues and simplify functionality. > > > The carp(4) isn't a layer 2 protocol, but is IP protocol, so I > don't understand how can it be converted to a pfil hook. > > > Obviously not everything can be a layer 2 pfil hook. Where it can, we > should at least investigate it to limit the number of special cases in > the path. > > Surely carp(4) is a hybrid approach. Though it hooks into at least the ethernet layer to do some > rewriting of packet information. > If it can be integrated into the pfil hook why not go that route. Yes, it can be tried. > While the better solution would be support for stacked interfaces, incremental is better in general > for this part of system. > > A potential issue is the cpu pinning of the pfil rmlock. We'll have to > see whether this is an immediate problem, and if yes, what we can do about > it. > > Also it would be nice to have some locality information on the pfil per interface to avoid > 'overhead' of going into the pfil chain call. > This is an optimization which would remove the special fields in the ifnet structure and allow to > have the pfil hook per interface. > Also it avoids sending every packet to a hook consumer that is interested on packets from only a > specific source. > > So the subsystems can implement their own optimizations and be self contained. They can already do that. -- Andre From owner-svn-src-user@FreeBSD.ORG Fri Nov 23 15:27:45 2012 Return-Path: Delivered-To: svn-src-user@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 97E756D6; Fri, 23 Nov 2012 15:27:45 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from cell.glebius.int.ru (glebius.int.ru [81.19.64.117]) by mx1.freebsd.org (Postfix) with ESMTP id 15DA38FC08; Fri, 23 Nov 2012 15:27:44 +0000 (UTC) Received: from cell.glebius.int.ru (localhost [127.0.0.1]) by cell.glebius.int.ru (8.14.5/8.14.5) with ESMTP id qANFRfWt090975; Fri, 23 Nov 2012 19:27:41 +0400 (MSK) (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by cell.glebius.int.ru (8.14.5/8.14.5/Submit) id qANFRf6H090974; Fri, 23 Nov 2012 19:27:41 +0400 (MSK) (envelope-from glebius@FreeBSD.org) X-Authentication-Warning: cell.glebius.int.ru: glebius set sender to glebius@FreeBSD.org using -f Date: Fri, 23 Nov 2012 19:27:41 +0400 From: Gleb Smirnoff To: Andre Oppermann Subject: Re: svn commit: r243458 - in user/andre/tcp_workqueue/sys: net netinet Message-ID: <20121123152741.GZ84121@FreeBSD.org> References: <201211231453.qANErSKF034907@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline In-Reply-To: <201211231453.qANErSKF034907@svn.freebsd.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: src-committers@FreeBSD.org, svn-src-user@FreeBSD.org X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Nov 2012 15:27:45 -0000 Andre, On Fri, Nov 23, 2012 at 02:53:28PM +0000, Andre Oppermann wrote: A> Log: A> Add sysctl support for pfil hook reporting and ordering. A> A> pfil_head_register() takes an additional pointer to the parent sysctl A> node pointer of the protocol family that is being registered here. A> A> Two new branches are then attached named "pfil_in" and "pfil_out". A> In each branch a list of the attached pfil hooks in the order of A> their processing is provided in the "hooks" string sysctl. A> A> In addition each attached pfil hook has its own node with a numeric A> representation of is ordering rank (0-255). Writing a new ordering A> rank changes the processing order. If two hooks have the same rank A> the last installed or changed comes first. A> A> Example output: A> net.inet.pfil_in.hooks="pf,ipfw,ipfilter" A> net.inet.pfil_in.pf=200 A> net.inet.pfil_in.ipfw=201 A> net.inet.pfil_in.ipfilter=202 A> net.inet.pfil_out.hooks="ipfilter,ipfw,pf" A> net.inet.pfil_out.ipfilter=53 A> net.inet.pfil_out.ipfw=54 A> net.inet.pfil_out.pf=55 A> A> This may be further tweaked and refined. Frankly speaking, the fact that the list can't be set directly in one sysctl oid: sysctl net.inet.pfil_in.hooks="pf,ipfw,ipfilter" , but can only be set via suppling pointless numeric values to N oids looks very poor from perspective of an average user. He might think something like "oh, FreeBSD developers were too lazy to parse a string", or "they designed an interface not for people but for nerds". Interface must be easier! If you don't like parsing strings in kernel, then /sbin/pfilctl can be introduced. The utility eventually may grow more functionality. -- Totus tuus, Glebius. From owner-svn-src-user@FreeBSD.ORG Fri Nov 23 16:11:13 2012 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 30B6CB48; Fri, 23 Nov 2012 16:11:13 +0000 (UTC) (envelope-from ermal.luci@gmail.com) Received: from mail-qa0-f54.google.com (mail-qa0-f54.google.com [209.85.216.54]) by mx1.freebsd.org (Postfix) with ESMTP id 899AD8FC0C; Fri, 23 Nov 2012 16:11:12 +0000 (UTC) Received: by mail-qa0-f54.google.com with SMTP id g24so1803733qab.13 for ; Fri, 23 Nov 2012 08:11:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=S05Oer6PPrPlTxmIap8OigPVSbAjvAP1bQr2T7Rh/UM=; b=IKjQX5qIXbMyhDhG0aIV8IbQhZtRcsXYP0xMWcNEcnwpPmTXQac2Vw3/XTfa1L9SAt /+LHJCQWoFBTC4WepoUYyeVVqMsxk35oFFh71RMM3M8HXqTuk9oSktpqElogPkan75hL O8rq0RpuWWzeVPOKeRbKVrCQ3Ztgj4gCreyBliUQAw7Q/NYpWq4EEVK+OV/Szii9Ixor R9Z3uZRt2ds/ll8BibsUjEJ4fonsFoFCID+hG3igKEH6ScgW3/gUIaaiSeEQjRvtdvTs Y52U6ecHPO7vbcpLkWKaqiqXLuwcKxxkmESnMpO8d1SOmmsESIEkThwblU+gMLdNE5Lf MbKA== MIME-Version: 1.0 Received: by 10.49.48.111 with SMTP id k15mr4767747qen.28.1353687071874; Fri, 23 Nov 2012 08:11:11 -0800 (PST) Sender: ermal.luci@gmail.com Received: by 10.49.121.163 with HTTP; Fri, 23 Nov 2012 08:11:11 -0800 (PST) In-Reply-To: <20121123152741.GZ84121@FreeBSD.org> References: <201211231453.qANErSKF034907@svn.freebsd.org> <20121123152741.GZ84121@FreeBSD.org> Date: Fri, 23 Nov 2012 17:11:11 +0100 X-Google-Sender-Auth: PLllzn9visGLzxQQ7JGhJrbh2dY Message-ID: Subject: Re: svn commit: r243458 - in user/andre/tcp_workqueue/sys: net netinet From: =?ISO-8859-1?Q?Ermal_Lu=E7i?= To: Gleb Smirnoff Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.14 Cc: src-committers@freebsd.org, Andre Oppermann , svn-src-user@freebsd.org X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Nov 2012 16:11:13 -0000 On Fri, Nov 23, 2012 at 4:27 PM, Gleb Smirnoff wrote: > Frankly speaking, the fact that the list can't be set directly > in one sysctl oid: > > sysctl net.inet.pfil_in.hooks="pf,ipfw,ipfilter" > > , but can only be set via suppling pointless numeric values to N > oids looks very poor from perspective of an average user. He might > think something like "oh, FreeBSD developers were too lazy to parse > a string", or "they designed an interface not for people but for nerds". > > Interface must be easier! If you don't like parsing strings in kernel, > then /sbin/pfilctl can be introduced. The utility eventually may grow > more functionality. > I already gave a link to already existing patch for this. Not sure why andre@ decided the other way around. -- Ermal