Fri Jun 1 08:56:01 2018 UTC ()
Rename

	M_CSUM_DATA_IPv6_HL -> M_CSUM_DATA_IPv6_IPHL
	M_CSUM_DATA_IPv6_HL_SET -> M_CSUM_DATA_IPv6_SET

Reduces the diff against IPv4. Also, clarify the definitions.


(maxv)
diff -r1.32 -r1.33 src/sys/arch/powerpc/booke/dev/pq3etsec.c
diff -r1.24 -r1.25 src/sys/arch/x86/pci/if_vmx.c
diff -r1.17 -r1.18 src/sys/dev/marvell/if_mvxpe.c
diff -r1.32 -r1.33 src/sys/dev/pci/if_jme.c
diff -r1.580 -r1.581 src/sys/dev/pci/if_wm.c
diff -r1.7 -r1.8 src/sys/netinet6/in6_offload.c
diff -r1.210 -r1.211 src/sys/netinet6/ip6_output.c
diff -r1.206 -r1.207 src/sys/sys/mbuf.h

cvs diff -r1.32 -r1.33 src/sys/arch/powerpc/booke/dev/pq3etsec.c (expand / switch to unified diff)

--- src/sys/arch/powerpc/booke/dev/pq3etsec.c 2017/10/23 09:23:48 1.32
+++ src/sys/arch/powerpc/booke/dev/pq3etsec.c 2018/06/01 08:56:00 1.33
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: pq3etsec.c,v 1.32 2017/10/23 09:23:48 msaitoh Exp $ */ 1/* $NetBSD: pq3etsec.c,v 1.33 2018/06/01 08:56:00 maxv Exp $ */
2/*- 2/*-
3 * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc. 3 * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * This code is derived from software contributed to The NetBSD Foundation 6 * This code is derived from software contributed to The NetBSD Foundation
7 * by Raytheon BBN Technologies Corp and Defense Advanced Research Projects 7 * by Raytheon BBN Technologies Corp and Defense Advanced Research Projects
8 * Agency and which was developed by Matt Thomas of 3am Software Foundry. 8 * Agency and which was developed by Matt Thomas of 3am Software Foundry.
9 * 9 *
10 * This material is based upon work supported by the Defense Advanced Research 10 * This material is based upon work supported by the Defense Advanced Research
11 * Projects Agency and Space and Naval Warfare Systems Center, Pacific, under 11 * Projects Agency and Space and Naval Warfare Systems Center, Pacific, under
12 * Contract No. N66001-09-C-2073. 12 * Contract No. N66001-09-C-2073.
13 * Approved for Public Release, Distribution Unlimited 13 * Approved for Public Release, Distribution Unlimited
14 * 14 *
@@ -31,27 +31,27 @@ @@ -31,27 +31,27 @@
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE. 34 * POSSIBILITY OF SUCH DAMAGE.
35 */ 35 */
36 36
37#include "opt_inet.h" 37#include "opt_inet.h"
38#include "opt_mpc85xx.h" 38#include "opt_mpc85xx.h"
39#include "opt_multiprocessor.h" 39#include "opt_multiprocessor.h"
40#include "opt_net_mpsafe.h" 40#include "opt_net_mpsafe.h"
41 41
42#include <sys/cdefs.h> 42#include <sys/cdefs.h>
43 43
44__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.32 2017/10/23 09:23:48 msaitoh Exp $"); 44__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.33 2018/06/01 08:56:00 maxv Exp $");
45 45
46#include <sys/param.h> 46#include <sys/param.h>
47#include <sys/cpu.h> 47#include <sys/cpu.h>
48#include <sys/device.h> 48#include <sys/device.h>
49#include <sys/mbuf.h> 49#include <sys/mbuf.h>
50#include <sys/ioctl.h> 50#include <sys/ioctl.h>
51#include <sys/intr.h> 51#include <sys/intr.h>
52#include <sys/bus.h> 52#include <sys/bus.h>
53#include <sys/kernel.h> 53#include <sys/kernel.h>
54#include <sys/kmem.h> 54#include <sys/kmem.h>
55#include <sys/proc.h> 55#include <sys/proc.h>
56#include <sys/atomic.h> 56#include <sys/atomic.h>
57#include <sys/callout.h> 57#include <sys/callout.h>
@@ -2053,27 +2053,27 @@ pq3etsec_tx_offload( @@ -2053,27 +2053,27 @@ pq3etsec_tx_offload(
2053 if (have_vtag) { 2053 if (have_vtag) {
2054 flags |= TXFCB_VLN; 2054 flags |= TXFCB_VLN;
2055 } 2055 }
2056 if (flags == 0) { 2056 if (flags == 0) {
2057 m->m_flags &= ~M_HASFCB; 2057 m->m_flags &= ~M_HASFCB;
2058 return; 2058 return;
2059 } 2059 }
2060 2060
2061 struct txfcb fcb; 2061 struct txfcb fcb;
2062 fcb.txfcb_flags = flags; 2062 fcb.txfcb_flags = flags;
2063 if (csum_flags & M_CSUM_IPv4) 2063 if (csum_flags & M_CSUM_IPv4)
2064 fcb.txfcb_l4os = M_CSUM_DATA_IPv4_IPHL(m->m_pkthdr.csum_data); 2064 fcb.txfcb_l4os = M_CSUM_DATA_IPv4_IPHL(m->m_pkthdr.csum_data);
2065 else 2065 else
2066 fcb.txfcb_l4os = M_CSUM_DATA_IPv6_HL(m->m_pkthdr.csum_data); 2066 fcb.txfcb_l4os = M_CSUM_DATA_IPv6_IPHL(m->m_pkthdr.csum_data);
2067 fcb.txfcb_l3os = ETHER_HDR_LEN; 2067 fcb.txfcb_l3os = ETHER_HDR_LEN;
2068 fcb.txfcb_phcs = 0; 2068 fcb.txfcb_phcs = 0;
2069 fcb.txfcb_vlctl = vtag; 2069 fcb.txfcb_vlctl = vtag;
2070 2070
2071#if 0 2071#if 0
2072 printf("%s: csum_flags=%#x: txfcb flags=%#x lsos=%u l4os=%u phcs=%u vlctl=%#x\n", 2072 printf("%s: csum_flags=%#x: txfcb flags=%#x lsos=%u l4os=%u phcs=%u vlctl=%#x\n",
2073 __func__, csum_flags, fcb.txfcb_flags, fcb.txfcb_l3os, fcb.txfcb_l4os, 2073 __func__, csum_flags, fcb.txfcb_flags, fcb.txfcb_l3os, fcb.txfcb_l4os,
2074 fcb.txfcb_phcs, fcb.txfcb_vlctl); 2074 fcb.txfcb_phcs, fcb.txfcb_vlctl);
2075#endif 2075#endif
2076 2076
2077 if (M_LEADINGSPACE(m) >= sizeof(fcb)) { 2077 if (M_LEADINGSPACE(m) >= sizeof(fcb)) {
2078 m->m_data -= sizeof(fcb); 2078 m->m_data -= sizeof(fcb);
2079 m->m_len += sizeof(fcb); 2079 m->m_len += sizeof(fcb);

cvs diff -r1.24 -r1.25 src/sys/arch/x86/pci/Attic/if_vmx.c (expand / switch to unified diff)

--- src/sys/arch/x86/pci/Attic/if_vmx.c 2018/04/16 09:12:52 1.24
+++ src/sys/arch/x86/pci/Attic/if_vmx.c 2018/06/01 08:56:00 1.25
@@ -1,35 +1,35 @@ @@ -1,35 +1,35 @@
1/* $NetBSD: if_vmx.c,v 1.24 2018/04/16 09:12:52 nonaka Exp $ */ 1/* $NetBSD: if_vmx.c,v 1.25 2018/06/01 08:56:00 maxv Exp $ */
2/* $OpenBSD: if_vmx.c,v 1.16 2014/01/22 06:04:17 brad Exp $ */ 2/* $OpenBSD: if_vmx.c,v 1.16 2014/01/22 06:04:17 brad Exp $ */
3 3
4/* 4/*
5 * Copyright (c) 2013 Tsubai Masanari 5 * Copyright (c) 2013 Tsubai Masanari
6 * Copyright (c) 2013 Bryan Venteicher <bryanv@FreeBSD.org> 6 * Copyright (c) 2013 Bryan Venteicher <bryanv@FreeBSD.org>
7 * 7 *
8 * Permission to use, copy, modify, and distribute this software for any 8 * Permission to use, copy, modify, and distribute this software for any
9 * purpose with or without fee is hereby granted, provided that the above 9 * purpose with or without fee is hereby granted, provided that the above
10 * copyright notice and this permission notice appear in all copies. 10 * copyright notice and this permission notice appear in all copies.
11 * 11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 15 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 */ 19 */
20 20
21#include <sys/cdefs.h> 21#include <sys/cdefs.h>
22__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.24 2018/04/16 09:12:52 nonaka Exp $"); 22__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.25 2018/06/01 08:56:00 maxv Exp $");
23 23
24#include <sys/param.h> 24#include <sys/param.h>
25#include <sys/cpu.h> 25#include <sys/cpu.h>
26#include <sys/kernel.h> 26#include <sys/kernel.h>
27#include <sys/kmem.h> 27#include <sys/kmem.h>
28#include <sys/bus.h> 28#include <sys/bus.h>
29#include <sys/device.h> 29#include <sys/device.h>
30#include <sys/mbuf.h> 30#include <sys/mbuf.h>
31#include <sys/sockio.h> 31#include <sys/sockio.h>
32 32
33#include <net/bpf.h> 33#include <net/bpf.h>
34#include <net/if.h> 34#include <net/if.h>
35#include <net/if_ether.h> 35#include <net/if_ether.h>
@@ -2526,27 +2526,27 @@ vmxnet3_txq_offload_ctx(struct vmxnet3_t @@ -2526,27 +2526,27 @@ vmxnet3_txq_offload_ctx(struct vmxnet3_t
2526 case ETHERTYPE_VLAN: 2526 case ETHERTYPE_VLAN:
2527 offset = ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN; 2527 offset = ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN;
2528 break; 2528 break;
2529 default: 2529 default:
2530 m_freem(m); 2530 m_freem(m);
2531 return (EINVAL); 2531 return (EINVAL);
2532 } 2532 }
2533 2533
2534 if ((m->m_pkthdr.csum_flags & 2534 if ((m->m_pkthdr.csum_flags &
2535 (M_CSUM_TSOv4|M_CSUM_UDPv4|M_CSUM_TCPv4)) != 0) { 2535 (M_CSUM_TSOv4|M_CSUM_UDPv4|M_CSUM_TCPv4)) != 0) {
2536 iphl = M_CSUM_DATA_IPv4_IPHL(m->m_pkthdr.csum_data); 2536 iphl = M_CSUM_DATA_IPv4_IPHL(m->m_pkthdr.csum_data);
2537 v4 = true; 2537 v4 = true;
2538 } else { 2538 } else {
2539 iphl = M_CSUM_DATA_IPv6_HL(m->m_pkthdr.csum_data); 2539 iphl = M_CSUM_DATA_IPv6_IPHL(m->m_pkthdr.csum_data);
2540 v4 = false; 2540 v4 = false;
2541 } 2541 }
2542 *start = offset + iphl; 2542 *start = offset + iphl;
2543 2543
2544 if (m->m_pkthdr.csum_flags & 2544 if (m->m_pkthdr.csum_flags &
2545 (M_CSUM_TCPv4 | M_CSUM_TCPv6 | M_CSUM_TSOv4 | M_CSUM_TSOv6)) { 2545 (M_CSUM_TCPv4 | M_CSUM_TCPv6 | M_CSUM_TSOv4 | M_CSUM_TSOv6)) {
2546 csum_off = offsetof(struct tcphdr, th_sum); 2546 csum_off = offsetof(struct tcphdr, th_sum);
2547 } else { 2547 } else {
2548 csum_off = offsetof(struct udphdr, uh_sum); 2548 csum_off = offsetof(struct udphdr, uh_sum);
2549 } 2549 }
2550 2550
2551 *csum_start = *start + csum_off; 2551 *csum_start = *start + csum_off;
2552 mp = m_pulldown(m, 0, *csum_start + 2, &offp); 2552 mp = m_pulldown(m, 0, *csum_start + 2, &offp);

cvs diff -r1.17 -r1.18 src/sys/dev/marvell/if_mvxpe.c (expand / switch to unified diff)

--- src/sys/dev/marvell/if_mvxpe.c 2016/12/15 09:28:05 1.17
+++ src/sys/dev/marvell/if_mvxpe.c 2018/06/01 08:56:00 1.18
@@ -1,41 +1,41 @@ @@ -1,41 +1,41 @@
1/* $NetBSD: if_mvxpe.c,v 1.17 2016/12/15 09:28:05 ozaki-r Exp $ */ 1/* $NetBSD: if_mvxpe.c,v 1.18 2018/06/01 08:56:00 maxv Exp $ */
2/* 2/*
3 * Copyright (c) 2015 Internet Initiative Japan Inc. 3 * Copyright (c) 2015 Internet Initiative Japan Inc.
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 18 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
19 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
23 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 23 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
24 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE. 25 * POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27#include <sys/cdefs.h> 27#include <sys/cdefs.h>
28__KERNEL_RCSID(0, "$NetBSD: if_mvxpe.c,v 1.17 2016/12/15 09:28:05 ozaki-r Exp $"); 28__KERNEL_RCSID(0, "$NetBSD: if_mvxpe.c,v 1.18 2018/06/01 08:56:00 maxv Exp $");
29 29
30#include "opt_multiprocessor.h" 30#include "opt_multiprocessor.h"
31 31
32#include <sys/param.h> 32#include <sys/param.h>
33#include <sys/bus.h> 33#include <sys/bus.h>
34#include <sys/callout.h> 34#include <sys/callout.h>
35#include <sys/device.h> 35#include <sys/device.h>
36#include <sys/endian.h> 36#include <sys/endian.h>
37#include <sys/errno.h> 37#include <sys/errno.h>
38#include <sys/evcnt.h> 38#include <sys/evcnt.h>
39#include <sys/kernel.h> 39#include <sys/kernel.h>
40#include <sys/kmem.h> 40#include <sys/kmem.h>
41#include <sys/mutex.h> 41#include <sys/mutex.h>
@@ -2229,27 +2229,27 @@ mvxpe_tx_set_csumflag(struct ifnet *ifp, @@ -2229,27 +2229,27 @@ mvxpe_tx_set_csumflag(struct ifnet *ifp,
2229 case ETHERTYPE_IPV6: 2229 case ETHERTYPE_IPV6:
2230 ipoff = ETHER_HDR_LEN; 2230 ipoff = ETHER_HDR_LEN;
2231 break; 2231 break;
2232 case ETHERTYPE_VLAN: 2232 case ETHERTYPE_VLAN:
2233 ipoff = ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN; 2233 ipoff = ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN;
2234 break; 2234 break;
2235 } 2235 }
2236 2236
2237 if (csum_flags & (M_CSUM_IPv4|M_CSUM_TCPv4|M_CSUM_UDPv4)) { 2237 if (csum_flags & (M_CSUM_IPv4|M_CSUM_TCPv4|M_CSUM_UDPv4)) {
2238 iphl = M_CSUM_DATA_IPv4_IPHL(m->m_pkthdr.csum_data); 2238 iphl = M_CSUM_DATA_IPv4_IPHL(m->m_pkthdr.csum_data);
2239 t->command |= MVXPE_TX_CMD_L3_IP4; 2239 t->command |= MVXPE_TX_CMD_L3_IP4;
2240 } 2240 }
2241 else if (csum_flags & (M_CSUM_TCPv6|M_CSUM_UDPv6)) { 2241 else if (csum_flags & (M_CSUM_TCPv6|M_CSUM_UDPv6)) {
2242 iphl = M_CSUM_DATA_IPv6_HL(m->m_pkthdr.csum_data); 2242 iphl = M_CSUM_DATA_IPv6_IPHL(m->m_pkthdr.csum_data);
2243 t->command |= MVXPE_TX_CMD_L3_IP6; 2243 t->command |= MVXPE_TX_CMD_L3_IP6;
2244 } 2244 }
2245 else { 2245 else {
2246 t->command |= MVXPE_TX_CMD_L4_CHECKSUM_NONE; 2246 t->command |= MVXPE_TX_CMD_L4_CHECKSUM_NONE;
2247 return; 2247 return;
2248 } 2248 }
2249 2249
2250 2250
2251 /* L3 */ 2251 /* L3 */
2252 if (csum_flags & M_CSUM_IPv4) { 2252 if (csum_flags & M_CSUM_IPv4) {
2253 t->command |= MVXPE_TX_CMD_IP4_CHECKSUM; 2253 t->command |= MVXPE_TX_CMD_IP4_CHECKSUM;
2254 } 2254 }
2255 2255

cvs diff -r1.32 -r1.33 src/sys/dev/pci/if_jme.c (expand / switch to unified diff)

--- src/sys/dev/pci/if_jme.c 2017/09/26 07:42:06 1.32
+++ src/sys/dev/pci/if_jme.c 2018/06/01 08:56:00 1.33
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_jme.c,v 1.32 2017/09/26 07:42:06 knakahara Exp $ */ 1/* $NetBSD: if_jme.c,v 1.33 2018/06/01 08:56:00 maxv Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2008 Manuel Bouyer. All rights reserved. 4 * Copyright (c) 2008 Manuel Bouyer. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 14 *
@@ -48,27 +48,27 @@ @@ -48,27 +48,27 @@
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE. 51 * SUCH DAMAGE.
52 */ 52 */
53 53
54 54
55/* 55/*
56 * Driver for JMicron Technologies JMC250 (Giganbit) and JMC260 (Fast) 56 * Driver for JMicron Technologies JMC250 (Giganbit) and JMC260 (Fast)
57 * Ethernet Controllers. 57 * Ethernet Controllers.
58 */ 58 */
59 59
60#include <sys/cdefs.h> 60#include <sys/cdefs.h>
61__KERNEL_RCSID(0, "$NetBSD: if_jme.c,v 1.32 2017/09/26 07:42:06 knakahara Exp $"); 61__KERNEL_RCSID(0, "$NetBSD: if_jme.c,v 1.33 2018/06/01 08:56:00 maxv Exp $");
62 62
63 63
64#include <sys/param.h> 64#include <sys/param.h>
65#include <sys/systm.h> 65#include <sys/systm.h>
66#include <sys/mbuf.h> 66#include <sys/mbuf.h>
67#include <sys/protosw.h> 67#include <sys/protosw.h>
68#include <sys/socket.h> 68#include <sys/socket.h>
69#include <sys/ioctl.h> 69#include <sys/ioctl.h>
70#include <sys/errno.h> 70#include <sys/errno.h>
71#include <sys/malloc.h> 71#include <sys/malloc.h>
72#include <sys/kernel.h> 72#include <sys/kernel.h>
73#include <sys/proc.h> /* only for declaration of wakeup() used by vm.h */ 73#include <sys/proc.h> /* only for declaration of wakeup() used by vm.h */
74#include <sys/device.h> 74#include <sys/device.h>
@@ -1351,27 +1351,27 @@ jme_encap(struct jme_softc *sc, struct m @@ -1351,27 +1351,27 @@ jme_encap(struct jme_softc *sc, struct m
1351 1351
1352 if (((*m_head)->m_pkthdr.csum_flags & (M_CSUM_TSOv4|M_CSUM_TSOv6)) != 0){ 1352 if (((*m_head)->m_pkthdr.csum_flags & (M_CSUM_TSOv4|M_CSUM_TSOv6)) != 0){
1353 /* 1353 /*
1354 * Due to the adherence to NDIS specification JMC250 1354 * Due to the adherence to NDIS specification JMC250
1355 * assumes upper stack computed TCP pseudo checksum 1355 * assumes upper stack computed TCP pseudo checksum
1356 * without including payload length. This breaks 1356 * without including payload length. This breaks
1357 * checksum offload for TSO case so recompute TCP 1357 * checksum offload for TSO case so recompute TCP
1358 * pseudo checksum for JMC250. Hopefully this wouldn't 1358 * pseudo checksum for JMC250. Hopefully this wouldn't
1359 * be much burden on modern CPUs. 1359 * be much burden on modern CPUs.
1360 */ 1360 */
1361 bool v4 = ((*m_head)->m_pkthdr.csum_flags & M_CSUM_TSOv4) != 0; 1361 bool v4 = ((*m_head)->m_pkthdr.csum_flags & M_CSUM_TSOv4) != 0;
1362 int iphl = v4 ? 1362 int iphl = v4 ?
1363 M_CSUM_DATA_IPv4_IPHL((*m_head)->m_pkthdr.csum_data) : 1363 M_CSUM_DATA_IPv4_IPHL((*m_head)->m_pkthdr.csum_data) :
1364 M_CSUM_DATA_IPv6_HL((*m_head)->m_pkthdr.csum_data); 1364 M_CSUM_DATA_IPv6_IPHL((*m_head)->m_pkthdr.csum_data);
1365 /* 1365 /*
1366 * note: we support vlan offloading, so we should never have 1366 * note: we support vlan offloading, so we should never have
1367 * a ETHERTYPE_VLAN packet here - so ETHER_HDR_LEN is always 1367 * a ETHERTYPE_VLAN packet here - so ETHER_HDR_LEN is always
1368 * right. 1368 * right.
1369 */ 1369 */
1370 int hlen = ETHER_HDR_LEN + iphl; 1370 int hlen = ETHER_HDR_LEN + iphl;
1371 1371
1372 if (__predict_false((*m_head)->m_len < 1372 if (__predict_false((*m_head)->m_len <
1373 (hlen + sizeof(struct tcphdr)))) { 1373 (hlen + sizeof(struct tcphdr)))) {
1374 /* 1374 /*
1375 * TCP/IP headers are not in the first mbuf; we need 1375 * TCP/IP headers are not in the first mbuf; we need
1376 * to do this the slow and painful way. Let's just 1376 * to do this the slow and painful way. Let's just
1377 * hope this doesn't happen very often. 1377 * hope this doesn't happen very often.

cvs diff -r1.580 -r1.581 src/sys/dev/pci/if_wm.c (expand / switch to unified diff)

--- src/sys/dev/pci/if_wm.c 2018/05/25 04:40:26 1.580
+++ src/sys/dev/pci/if_wm.c 2018/06/01 08:56:00 1.581
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_wm.c,v 1.580 2018/05/25 04:40:26 ozaki-r Exp $ */ 1/* $NetBSD: if_wm.c,v 1.581 2018/06/01 08:56:00 maxv Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc. 4 * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Written by Jason R. Thorpe for Wasabi Systems, Inc. 7 * Written by Jason R. Thorpe for Wasabi Systems, Inc.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -73,27 +73,27 @@ @@ -73,27 +73,27 @@
73 * TODO (in order of importance): 73 * TODO (in order of importance):
74 * 74 *
75 * - Check XXX'ed comments 75 * - Check XXX'ed comments
76 * - TX Multi queue improvement (refine queue selection logic) 76 * - TX Multi queue improvement (refine queue selection logic)
77 * - Split header buffer for newer descriptors 77 * - Split header buffer for newer descriptors
78 * - EEE (Energy Efficiency Ethernet) 78 * - EEE (Energy Efficiency Ethernet)
79 * - Virtual Function 79 * - Virtual Function
80 * - Set LED correctly (based on contents in EEPROM) 80 * - Set LED correctly (based on contents in EEPROM)
81 * - Rework how parameters are loaded from the EEPROM. 81 * - Rework how parameters are loaded from the EEPROM.
82 * - Image Unique ID 82 * - Image Unique ID
83 */ 83 */
84 84
85#include <sys/cdefs.h> 85#include <sys/cdefs.h>
86__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.580 2018/05/25 04:40:26 ozaki-r Exp $"); 86__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.581 2018/06/01 08:56:00 maxv Exp $");
87 87
88#ifdef _KERNEL_OPT 88#ifdef _KERNEL_OPT
89#include "opt_net_mpsafe.h" 89#include "opt_net_mpsafe.h"
90#include "opt_if_wm.h" 90#include "opt_if_wm.h"
91#endif 91#endif
92 92
93#include <sys/param.h> 93#include <sys/param.h>
94#include <sys/systm.h> 94#include <sys/systm.h>
95#include <sys/callout.h> 95#include <sys/callout.h>
96#include <sys/mbuf.h> 96#include <sys/mbuf.h>
97#include <sys/malloc.h> 97#include <sys/malloc.h>
98#include <sys/kmem.h> 98#include <sys/kmem.h>
99#include <sys/kernel.h> 99#include <sys/kernel.h>
@@ -6907,27 +6907,27 @@ wm_tx_offload(struct wm_softc *sc, struc @@ -6907,27 +6907,27 @@ wm_tx_offload(struct wm_softc *sc, struc
6907 default: 6907 default:
6908 /* 6908 /*
6909 * Don't support this protocol or encapsulation. 6909 * Don't support this protocol or encapsulation.
6910 */ 6910 */
6911 *fieldsp = 0; 6911 *fieldsp = 0;
6912 *cmdp = 0; 6912 *cmdp = 0;
6913 return 0; 6913 return 0;
6914 } 6914 }
6915 6915
6916 if ((m0->m_pkthdr.csum_flags & 6916 if ((m0->m_pkthdr.csum_flags &
6917 (M_CSUM_TSOv4 | M_CSUM_UDPv4 | M_CSUM_TCPv4 | M_CSUM_IPv4)) != 0) { 6917 (M_CSUM_TSOv4 | M_CSUM_UDPv4 | M_CSUM_TCPv4 | M_CSUM_IPv4)) != 0) {
6918 iphl = M_CSUM_DATA_IPv4_IPHL(m0->m_pkthdr.csum_data); 6918 iphl = M_CSUM_DATA_IPv4_IPHL(m0->m_pkthdr.csum_data);
6919 } else { 6919 } else {
6920 iphl = M_CSUM_DATA_IPv6_HL(m0->m_pkthdr.csum_data); 6920 iphl = M_CSUM_DATA_IPv6_IPHL(m0->m_pkthdr.csum_data);
6921 } 6921 }
6922 ipcse = offset + iphl - 1; 6922 ipcse = offset + iphl - 1;
6923 6923
6924 cmd = WTX_CMD_DEXT | WTX_DTYP_D; 6924 cmd = WTX_CMD_DEXT | WTX_DTYP_D;
6925 cmdlen = WTX_CMD_DEXT | WTX_DTYP_C | WTX_CMD_IDE; 6925 cmdlen = WTX_CMD_DEXT | WTX_DTYP_C | WTX_CMD_IDE;
6926 seg = 0; 6926 seg = 0;
6927 fields = 0; 6927 fields = 0;
6928 6928
6929 if ((m0->m_pkthdr.csum_flags & (M_CSUM_TSOv4 | M_CSUM_TSOv6)) != 0) { 6929 if ((m0->m_pkthdr.csum_flags & (M_CSUM_TSOv4 | M_CSUM_TSOv6)) != 0) {
6930 int hlen = offset + iphl; 6930 int hlen = offset + iphl;
6931 bool v4 = (m0->m_pkthdr.csum_flags & M_CSUM_TSOv4) != 0; 6931 bool v4 = (m0->m_pkthdr.csum_flags & M_CSUM_TSOv4) != 0;
6932 6932
6933 if (__predict_false(m0->m_len < 6933 if (__predict_false(m0->m_len <
@@ -7514,27 +7514,27 @@ wm_nq_tx_offload(struct wm_softc *sc, st @@ -7514,27 +7514,27 @@ wm_nq_tx_offload(struct wm_softc *sc, st
7514 return 0; 7514 return 0;
7515 } 7515 }
7516 *do_csum = true; 7516 *do_csum = true;
7517 *cmdlenp = NQTX_DTYP_D | NQTX_CMD_DEXT | NQTX_CMD_IFCS; 7517 *cmdlenp = NQTX_DTYP_D | NQTX_CMD_DEXT | NQTX_CMD_IFCS;
7518 cmdc = NQTX_DTYP_C | NQTX_CMD_DEXT; 7518 cmdc = NQTX_DTYP_C | NQTX_CMD_DEXT;
7519 7519
7520 vl_len = (offset << NQTXC_VLLEN_MACLEN_SHIFT); 7520 vl_len = (offset << NQTXC_VLLEN_MACLEN_SHIFT);
7521 KASSERT((offset & ~NQTXC_VLLEN_MACLEN_MASK) == 0); 7521 KASSERT((offset & ~NQTXC_VLLEN_MACLEN_MASK) == 0);
7522 7522
7523 if ((m0->m_pkthdr.csum_flags & 7523 if ((m0->m_pkthdr.csum_flags &
7524 (M_CSUM_TSOv4 | M_CSUM_UDPv4 | M_CSUM_TCPv4 | M_CSUM_IPv4)) != 0) { 7524 (M_CSUM_TSOv4 | M_CSUM_UDPv4 | M_CSUM_TCPv4 | M_CSUM_IPv4)) != 0) {
7525 iphl = M_CSUM_DATA_IPv4_IPHL(m0->m_pkthdr.csum_data); 7525 iphl = M_CSUM_DATA_IPv4_IPHL(m0->m_pkthdr.csum_data);
7526 } else { 7526 } else {
7527 iphl = M_CSUM_DATA_IPv6_HL(m0->m_pkthdr.csum_data); 7527 iphl = M_CSUM_DATA_IPv6_IPHL(m0->m_pkthdr.csum_data);
7528 } 7528 }
7529 vl_len |= (iphl << NQTXC_VLLEN_IPLEN_SHIFT); 7529 vl_len |= (iphl << NQTXC_VLLEN_IPLEN_SHIFT);
7530 KASSERT((iphl & ~NQTXC_VLLEN_IPLEN_MASK) == 0); 7530 KASSERT((iphl & ~NQTXC_VLLEN_IPLEN_MASK) == 0);
7531 7531
7532 if (vlan_has_tag(m0)) { 7532 if (vlan_has_tag(m0)) {
7533 vl_len |= ((vlan_get_tag(m0) & NQTXC_VLLEN_VLAN_MASK) 7533 vl_len |= ((vlan_get_tag(m0) & NQTXC_VLLEN_VLAN_MASK)
7534 << NQTXC_VLLEN_VLAN_SHIFT); 7534 << NQTXC_VLLEN_VLAN_SHIFT);
7535 *cmdlenp |= NQTX_CMD_VLE; 7535 *cmdlenp |= NQTX_CMD_VLE;
7536 } 7536 }
7537 7537
7538 mssidx = 0; 7538 mssidx = 0;
7539 7539
7540 if ((m0->m_pkthdr.csum_flags & (M_CSUM_TSOv4 | M_CSUM_TSOv6)) != 0) { 7540 if ((m0->m_pkthdr.csum_flags & (M_CSUM_TSOv4 | M_CSUM_TSOv6)) != 0) {

cvs diff -r1.7 -r1.8 src/sys/netinet6/in6_offload.c (expand / switch to unified diff)

--- src/sys/netinet6/in6_offload.c 2017/02/14 03:05:06 1.7
+++ src/sys/netinet6/in6_offload.c 2018/06/01 08:56:00 1.8
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: in6_offload.c,v 1.7 2017/02/14 03:05:06 ozaki-r Exp $ */ 1/* $NetBSD: in6_offload.c,v 1.8 2018/06/01 08:56:00 maxv Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c)2006 YAMAMOTO Takashi, 4 * Copyright (c)2006 YAMAMOTO Takashi,
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -17,27 +17,27 @@ @@ -17,27 +17,27 @@
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE. 26 * SUCH DAMAGE.
27 */ 27 */
28 28
29#include <sys/cdefs.h> 29#include <sys/cdefs.h>
30__KERNEL_RCSID(0, "$NetBSD: in6_offload.c,v 1.7 2017/02/14 03:05:06 ozaki-r Exp $"); 30__KERNEL_RCSID(0, "$NetBSD: in6_offload.c,v 1.8 2018/06/01 08:56:00 maxv Exp $");
31 31
32#include <sys/param.h> 32#include <sys/param.h>
33#include <sys/mbuf.h> 33#include <sys/mbuf.h>
34 34
35#include <net/if.h> 35#include <net/if.h>
36 36
37#include <netinet/in.h> 37#include <netinet/in.h>
38#include <netinet/in_systm.h> 38#include <netinet/in_systm.h>
39#include <netinet/ip6.h> 39#include <netinet/ip6.h>
40#include <netinet/tcp.h> 40#include <netinet/tcp.h>
41#include <netinet6/in6_var.h> 41#include <netinet6/in6_var.h>
42#include <netinet6/ip6_var.h> 42#include <netinet6/ip6_var.h>
43#include <netinet6/nd6.h> 43#include <netinet6/nd6.h>
@@ -204,27 +204,27 @@ ip6_undefer_csum(struct mbuf *m, size_t  @@ -204,27 +204,27 @@ ip6_undefer_csum(struct mbuf *m, size_t
204 uint16_t csum; 204 uint16_t csum;
205 205
206 KASSERT(m->m_flags & M_PKTHDR); 206 KASSERT(m->m_flags & M_PKTHDR);
207 KASSERT((m->m_pkthdr.csum_flags & csum_flags) == csum_flags); 207 KASSERT((m->m_pkthdr.csum_flags & csum_flags) == csum_flags);
208 KASSERT(csum_flags == M_CSUM_UDPv6 || csum_flags == M_CSUM_TCPv6); 208 KASSERT(csum_flags == M_CSUM_UDPv6 || csum_flags == M_CSUM_TCPv6);
209 209
210 if (__predict_true(hdrlen + sizeof(struct ip6_hdr) <= m->m_len)) { 210 if (__predict_true(hdrlen + sizeof(struct ip6_hdr) <= m->m_len)) {
211 plen = *(uint16_t *)(mtod(m, char *) + ip6_plen_offset); 211 plen = *(uint16_t *)(mtod(m, char *) + ip6_plen_offset);
212 } else { 212 } else {
213 m_copydata(m, ip6_plen_offset, sizeof(plen), &plen); 213 m_copydata(m, ip6_plen_offset, sizeof(plen), &plen);
214 } 214 }
215 plen = ntohs(plen); 215 plen = ntohs(plen);
216 216
217 l4hdroff = M_CSUM_DATA_IPv6_HL(m->m_pkthdr.csum_data); 217 l4hdroff = M_CSUM_DATA_IPv6_IPHL(m->m_pkthdr.csum_data);
218 l4offset = hdrlen + l4hdroff; 218 l4offset = hdrlen + l4hdroff;
219 csum = in6_cksum(m, 0, l4offset, plen - l4hdroff); 219 csum = in6_cksum(m, 0, l4offset, plen - l4hdroff);
220 220
221 if (csum == 0 && (csum_flags & M_CSUM_UDPv6) != 0) 221 if (csum == 0 && (csum_flags & M_CSUM_UDPv6) != 0)
222 csum = 0xffff; 222 csum = 0xffff;
223 223
224 l4offset += M_CSUM_DATA_IPv6_OFFSET(m->m_pkthdr.csum_data); 224 l4offset += M_CSUM_DATA_IPv6_OFFSET(m->m_pkthdr.csum_data);
225 225
226 if (__predict_true((l4offset + sizeof(uint16_t)) <= m->m_len)) { 226 if (__predict_true((l4offset + sizeof(uint16_t)) <= m->m_len)) {
227 *(uint16_t *)(mtod(m, char *) + l4offset) = csum; 227 *(uint16_t *)(mtod(m, char *) + l4offset) = csum;
228 } else { 228 } else {
229 m_copyback(m, l4offset, sizeof(csum), (void *) &csum); 229 m_copyback(m, l4offset, sizeof(csum), (void *) &csum);
230 } 230 }

cvs diff -r1.210 -r1.211 src/sys/netinet6/ip6_output.c (expand / switch to unified diff)

--- src/sys/netinet6/ip6_output.c 2018/05/29 16:21:30 1.210
+++ src/sys/netinet6/ip6_output.c 2018/06/01 08:56:00 1.211
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ip6_output.c,v 1.210 2018/05/29 16:21:30 maxv Exp $ */ 1/* $NetBSD: ip6_output.c,v 1.211 2018/06/01 08:56:00 maxv Exp $ */
2/* $KAME: ip6_output.c,v 1.172 2001/03/25 09:55:56 itojun Exp $ */ 2/* $KAME: ip6_output.c,v 1.172 2001/03/25 09:55:56 itojun Exp $ */
3 3
4/* 4/*
5 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 5 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
11 * 1. Redistributions of source code must retain the above copyright 11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer. 12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
@@ -52,27 +52,27 @@ @@ -52,27 +52,27 @@
52 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 52 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
53 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 53 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
54 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 54 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
55 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 55 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
56 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 56 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
57 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 57 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
58 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 58 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
59 * SUCH DAMAGE. 59 * SUCH DAMAGE.
60 * 60 *
61 * @(#)ip_output.c 8.3 (Berkeley) 1/21/94 61 * @(#)ip_output.c 8.3 (Berkeley) 1/21/94
62 */ 62 */
63 63
64#include <sys/cdefs.h> 64#include <sys/cdefs.h>
65__KERNEL_RCSID(0, "$NetBSD: ip6_output.c,v 1.210 2018/05/29 16:21:30 maxv Exp $"); 65__KERNEL_RCSID(0, "$NetBSD: ip6_output.c,v 1.211 2018/06/01 08:56:00 maxv Exp $");
66 66
67#ifdef _KERNEL_OPT 67#ifdef _KERNEL_OPT
68#include "opt_inet.h" 68#include "opt_inet.h"
69#include "opt_inet6.h" 69#include "opt_inet6.h"
70#include "opt_ipsec.h" 70#include "opt_ipsec.h"
71#endif 71#endif
72 72
73#include <sys/param.h> 73#include <sys/param.h>
74#include <sys/malloc.h> 74#include <sys/malloc.h>
75#include <sys/mbuf.h> 75#include <sys/mbuf.h>
76#include <sys/errno.h> 76#include <sys/errno.h>
77#include <sys/socket.h> 77#include <sys/socket.h>
78#include <sys/socketvar.h> 78#include <sys/socketvar.h>
@@ -231,27 +231,27 @@ ip6_output( @@ -231,27 +231,27 @@ ip6_output(
231 panic("ip6_output: no HDR"); 231 panic("ip6_output: no HDR");
232 if ((m->m_pkthdr.csum_flags & 232 if ((m->m_pkthdr.csum_flags &
233 (M_CSUM_TCPv4|M_CSUM_UDPv4|M_CSUM_TSOv4)) != 0) { 233 (M_CSUM_TCPv4|M_CSUM_UDPv4|M_CSUM_TSOv4)) != 0) {
234 panic("ip6_output: IPv4 checksum offload flags: %d", 234 panic("ip6_output: IPv4 checksum offload flags: %d",
235 m->m_pkthdr.csum_flags); 235 m->m_pkthdr.csum_flags);
236 } 236 }
237 if ((m->m_pkthdr.csum_flags & (M_CSUM_TCPv6|M_CSUM_UDPv6)) == 237 if ((m->m_pkthdr.csum_flags & (M_CSUM_TCPv6|M_CSUM_UDPv6)) ==
238 (M_CSUM_TCPv6|M_CSUM_UDPv6)) { 238 (M_CSUM_TCPv6|M_CSUM_UDPv6)) {
239 panic("ip6_output: conflicting checksum offload flags: %d", 239 panic("ip6_output: conflicting checksum offload flags: %d",
240 m->m_pkthdr.csum_flags); 240 m->m_pkthdr.csum_flags);
241 } 241 }
242#endif 242#endif
243 243
244 M_CSUM_DATA_IPv6_HL_SET(m->m_pkthdr.csum_data, sizeof(struct ip6_hdr)); 244 M_CSUM_DATA_IPv6_SET(m->m_pkthdr.csum_data, sizeof(struct ip6_hdr));
245 245
246#define MAKE_EXTHDR(hp, mp) \ 246#define MAKE_EXTHDR(hp, mp) \
247 do { \ 247 do { \
248 if (hp) { \ 248 if (hp) { \
249 struct ip6_ext *eh = (struct ip6_ext *)(hp); \ 249 struct ip6_ext *eh = (struct ip6_ext *)(hp); \
250 error = ip6_copyexthdr((mp), (void *)(hp), \ 250 error = ip6_copyexthdr((mp), (void *)(hp), \
251 ((eh)->ip6e_len + 1) << 3); \ 251 ((eh)->ip6e_len + 1) << 3); \
252 if (error) \ 252 if (error) \
253 goto freehdrs; \ 253 goto freehdrs; \
254 } \ 254 } \
255 } while (/*CONSTCOND*/ 0) 255 } while (/*CONSTCOND*/ 0)
256 256
257 memset(&exthdrs, 0, sizeof(exthdrs)); 257 memset(&exthdrs, 0, sizeof(exthdrs));
@@ -390,27 +390,27 @@ ip6_output( @@ -390,27 +390,27 @@ ip6_output(
390 }\ 390 }\
391 } while (/*CONSTCOND*/ 0) 391 } while (/*CONSTCOND*/ 0)
392 /* 392 /*
393 * result: IPv6 hbh dest1 rthdr dest2 payload 393 * result: IPv6 hbh dest1 rthdr dest2 payload
394 * m will point to IPv6 header. mprev will point to the 394 * m will point to IPv6 header. mprev will point to the
395 * extension header prior to dest2 (rthdr in the above case). 395 * extension header prior to dest2 (rthdr in the above case).
396 */ 396 */
397 MAKE_CHAIN(exthdrs.ip6e_hbh, mprev, nexthdrp, IPPROTO_HOPOPTS); 397 MAKE_CHAIN(exthdrs.ip6e_hbh, mprev, nexthdrp, IPPROTO_HOPOPTS);
398 MAKE_CHAIN(exthdrs.ip6e_dest1, mprev, nexthdrp, 398 MAKE_CHAIN(exthdrs.ip6e_dest1, mprev, nexthdrp,
399 IPPROTO_DSTOPTS); 399 IPPROTO_DSTOPTS);
400 MAKE_CHAIN(exthdrs.ip6e_rthdr, mprev, nexthdrp, 400 MAKE_CHAIN(exthdrs.ip6e_rthdr, mprev, nexthdrp,
401 IPPROTO_ROUTING); 401 IPPROTO_ROUTING);
402 402
403 M_CSUM_DATA_IPv6_HL_SET(m->m_pkthdr.csum_data, 403 M_CSUM_DATA_IPv6_SET(m->m_pkthdr.csum_data,
404 sizeof(struct ip6_hdr) + optlen); 404 sizeof(struct ip6_hdr) + optlen);
405 } 405 }
406 406
407 /* Need to save for pmtu */ 407 /* Need to save for pmtu */
408 finaldst = ip6->ip6_dst; 408 finaldst = ip6->ip6_dst;
409 409
410 /* 410 /*
411 * If there is a routing header, replace destination address field 411 * If there is a routing header, replace destination address field
412 * with the first hop of the routing header. 412 * with the first hop of the routing header.
413 */ 413 */
414 if (exthdrs.ip6e_rthdr) { 414 if (exthdrs.ip6e_rthdr) {
415 struct ip6_rthdr *rh; 415 struct ip6_rthdr *rh;
416 416
@@ -1074,27 +1074,27 @@ ip6_copyexthdr(struct mbuf **mp, void *h @@ -1074,27 +1074,27 @@ ip6_copyexthdr(struct mbuf **mp, void *h
1074/* 1074/*
1075 * Process a delayed payload checksum calculation. 1075 * Process a delayed payload checksum calculation.
1076 */ 1076 */
1077void 1077void
1078in6_delayed_cksum(struct mbuf *m) 1078in6_delayed_cksum(struct mbuf *m)
1079{ 1079{
1080 uint16_t csum, offset; 1080 uint16_t csum, offset;
1081 1081
1082 KASSERT((m->m_pkthdr.csum_flags & (M_CSUM_UDPv6|M_CSUM_TCPv6)) != 0); 1082 KASSERT((m->m_pkthdr.csum_flags & (M_CSUM_UDPv6|M_CSUM_TCPv6)) != 0);
1083 KASSERT((~m->m_pkthdr.csum_flags & (M_CSUM_UDPv6|M_CSUM_TCPv6)) != 0); 1083 KASSERT((~m->m_pkthdr.csum_flags & (M_CSUM_UDPv6|M_CSUM_TCPv6)) != 0);
1084 KASSERT((m->m_pkthdr.csum_flags 1084 KASSERT((m->m_pkthdr.csum_flags
1085 & (M_CSUM_UDPv4|M_CSUM_TCPv4|M_CSUM_TSOv4)) == 0); 1085 & (M_CSUM_UDPv4|M_CSUM_TCPv4|M_CSUM_TSOv4)) == 0);
1086 1086
1087 offset = M_CSUM_DATA_IPv6_HL(m->m_pkthdr.csum_data); 1087 offset = M_CSUM_DATA_IPv6_IPHL(m->m_pkthdr.csum_data);
1088 csum = in6_cksum(m, 0, offset, m->m_pkthdr.len - offset); 1088 csum = in6_cksum(m, 0, offset, m->m_pkthdr.len - offset);
1089 if (csum == 0 && (m->m_pkthdr.csum_flags & M_CSUM_UDPv6) != 0) { 1089 if (csum == 0 && (m->m_pkthdr.csum_flags & M_CSUM_UDPv6) != 0) {
1090 csum = 0xffff; 1090 csum = 0xffff;
1091 } 1091 }
1092 1092
1093 offset += M_CSUM_DATA_IPv6_OFFSET(m->m_pkthdr.csum_data); 1093 offset += M_CSUM_DATA_IPv6_OFFSET(m->m_pkthdr.csum_data);
1094 if ((offset + sizeof(csum)) > m->m_len) { 1094 if ((offset + sizeof(csum)) > m->m_len) {
1095 m_copyback(m, offset, sizeof(csum), &csum); 1095 m_copyback(m, offset, sizeof(csum), &csum);
1096 } else { 1096 } else {
1097 *(uint16_t *)(mtod(m, char *) + offset) = csum; 1097 *(uint16_t *)(mtod(m, char *) + offset) = csum;
1098 } 1098 }
1099} 1099}
1100 1100

cvs diff -r1.206 -r1.207 src/sys/sys/mbuf.h (expand / switch to unified diff)

--- src/sys/sys/mbuf.h 2018/05/18 18:52:17 1.206
+++ src/sys/sys/mbuf.h 2018/06/01 08:56:00 1.207
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: mbuf.h,v 1.206 2018/05/18 18:52:17 maxv Exp $ */ 1/* $NetBSD: mbuf.h,v 1.207 2018/06/01 08:56:00 maxv Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1996, 1997, 1999, 2001, 2007 The NetBSD Foundation, Inc. 4 * Copyright (c) 1996, 1997, 1999, 2001, 2007 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, 8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9 * NASA Ames Research Center and Matt Thomas of 3am Software Foundry. 9 * NASA Ames Research Center and Matt Thomas of 3am Software Foundry.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions
13 * are met: 13 * are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
@@ -156,27 +156,27 @@ struct m_hdr { @@ -156,27 +156,27 @@ struct m_hdr {
156 int mh_flags; /* flags; see below */ 156 int mh_flags; /* flags; see below */
157 paddr_t mh_paddr; /* physical address of mbuf */ 157 paddr_t mh_paddr; /* physical address of mbuf */
158 short mh_type; /* type of data in this mbuf */ 158 short mh_type; /* type of data in this mbuf */
159}; 159};
160 160
161/* 161/*
162 * record/packet header in first mbuf of chain; valid if M_PKTHDR set 162 * record/packet header in first mbuf of chain; valid if M_PKTHDR set
163 * 163 *
164 * A note about csum_data: 164 * A note about csum_data:
165 * 165 *
166 * o For the out-bound direction, the low 16 bits indicates the offset after 166 * o For the out-bound direction, the low 16 bits indicates the offset after
167 * the L4 header where the final L4 checksum value is to be stored and the 167 * the L4 header where the final L4 checksum value is to be stored and the
168 * high 16 bits is the length of the L3 header (the start of the data to 168 * high 16 bits is the length of the L3 header (the start of the data to
169 * be checksummed): 169 * be checksummed).
170 * 170 *
171 * o For the in-bound direction, it is only valid if the M_CSUM_DATA flag is 171 * o For the in-bound direction, it is only valid if the M_CSUM_DATA flag is
172 * set. In this case, an L4 checksum has been calculated by hardware and 172 * set. In this case, an L4 checksum has been calculated by hardware and
173 * is stored in csum_data, but it is up to software to perform final 173 * is stored in csum_data, but it is up to software to perform final
174 * verification. 174 * verification.
175 * 175 *
176 * Note for in-bound TCP/UDP checksums: we expect the csum_data to NOT 176 * Note for in-bound TCP/UDP checksums: we expect the csum_data to NOT
177 * be bit-wise inverted (the final step in the calculation of an IP 177 * be bit-wise inverted (the final step in the calculation of an IP
178 * checksum) -- this is so we can accumulate the checksum for fragmented 178 * checksum) -- this is so we can accumulate the checksum for fragmented
179 * packets during reassembly. 179 * packets during reassembly.
180 * 180 *
181 * Size ILP32: 40 181 * Size ILP32: 40
182 * LP64: 56 182 * LP64: 56
@@ -217,44 +217,38 @@ struct pkthdr { @@ -217,44 +217,38 @@ struct pkthdr {
217#define M_CSUM_TSOv6 0x00000200 /* TCPv6 segmentation offload */ 217#define M_CSUM_TSOv6 0x00000200 /* TCPv6 segmentation offload */
218 218
219/* Checksum-assist quirks: keep separate from jump-table bits. */ 219/* Checksum-assist quirks: keep separate from jump-table bits. */
220#define M_CSUM_NO_PSEUDOHDR 0x80000000 /* Rx csum_data does not include 220#define M_CSUM_NO_PSEUDOHDR 0x80000000 /* Rx csum_data does not include
221 * the UDP/TCP pseudo-hdr, and 221 * the UDP/TCP pseudo-hdr, and
222 * is not yet 1s-complemented. 222 * is not yet 1s-complemented.
223 */ 223 */
224 224
225#define M_CSUM_BITS \ 225#define M_CSUM_BITS \
226 "\20\1TCPv4\2UDPv4\3TCP_UDP_BAD\4DATA\5TCPv6\6UDPv6\7IPv4\10IPv4_BAD" \ 226 "\20\1TCPv4\2UDPv4\3TCP_UDP_BAD\4DATA\5TCPv6\6UDPv6\7IPv4\10IPv4_BAD" \
227 "\11TSOv4\12TSOv6\40NO_PSEUDOHDR" 227 "\11TSOv4\12TSOv6\40NO_PSEUDOHDR"
228 228
229/* 229/*
230 * Macros for manipulating csum_data on outgoing packets. These are 230 * Macros for manipulating csum_data on outgoing packets. These are
231 * used to pass information down from the L4/L3 to the L2. 231 * used to pass information down from the L4/L3 to the L2.
 232 *
 233 * _IPHL: Length of the IPv{4/6} header, plus the options; in other
 234 * words the offset of the UDP/TCP header in the packet.
 235 * _OFFSET: Offset of the checksum field in the UDP/TCP header.
232 */ 236 */
233#define M_CSUM_DATA_IPv4_IPHL(x) ((x) >> 16) 237#define M_CSUM_DATA_IPv4_IPHL(x) ((x) >> 16)
234#define M_CSUM_DATA_IPv4_OFFSET(x) ((x) & 0xffff) 238#define M_CSUM_DATA_IPv4_OFFSET(x) ((x) & 0xffff)
235 239#define M_CSUM_DATA_IPv6_IPHL(x) ((x) >> 16)
236/* 
237 * Macros for M_CSUM_TCPv6 and M_CSUM_UDPv6 
238 * 
239 * M_CSUM_DATA_IPv6_HL: length of ip6_hdr + ext header. 
240 * ie. offset of UDP/TCP header in the packet. 
241 * 
242 * M_CSUM_DATA_IPv6_OFFSET: offset of the checksum field in UDP/TCP header. 
243 */ 
244 
245#define M_CSUM_DATA_IPv6_HL(x) ((x) >> 16) 
246#define M_CSUM_DATA_IPv6_HL_SET(x, v) (x) = ((x) & 0xffff) | ((v) << 16) 
247#define M_CSUM_DATA_IPv6_OFFSET(x) ((x) & 0xffff) 240#define M_CSUM_DATA_IPv6_OFFSET(x) ((x) & 0xffff)
 241#define M_CSUM_DATA_IPv6_SET(x, v) (x) = ((x) & 0xffff) | ((v) << 16)
248 242
249/* 243/*
250 * Max # of pages we can attach to m_ext. This is carefully chosen 244 * Max # of pages we can attach to m_ext. This is carefully chosen
251 * to be able to handle SOSEND_LOAN_CHUNK with our minimum sized page. 245 * to be able to handle SOSEND_LOAN_CHUNK with our minimum sized page.
252 */ 246 */
253#ifdef MIN_PAGE_SIZE 247#ifdef MIN_PAGE_SIZE
254#define M_EXT_MAXPAGES ((65536 / MIN_PAGE_SIZE) + 1) 248#define M_EXT_MAXPAGES ((65536 / MIN_PAGE_SIZE) + 1)
255#endif 249#endif
256 250
257/* 251/*
258 * Description of external storage mapped into mbuf, valid if M_EXT set. 252 * Description of external storage mapped into mbuf, valid if M_EXT set.
259 */ 253 */
260struct _m_ext_storage { 254struct _m_ext_storage {