Module Name: src Committed By: snj Date: Tue Oct 24 08:39:00 UTC 2017
Modified Files: src/sys/arch/powerpc/booke/dev [netbsd-8]: pq3etsec.c src/sys/arch/x86/pci [netbsd-8]: if_vmx.c src/sys/dev/ic [netbsd-8]: i82557.c rtl8169.c src/sys/dev/pci [netbsd-8]: if_age.c if_alc.c if_ale.c if_bge.c if_bnx.c if_jme.c if_nfe.c if_sip.c if_stge.c if_ti.c if_txp.c if_vge.c if_wm.c src/sys/dev/pci/cxgb [netbsd-8]: cxgb_sge.c src/sys/dev/pci/ixgbe [netbsd-8]: ix_txrx.c src/sys/net [netbsd-8]: if_ether.h if_ethersubr.c if_vlan.c src/sys/net/agr [netbsd-8]: if_agrether_hash.c src/sys/net80211 [netbsd-8]: ieee80211_input.c ieee80211_output.c src/sys/sys [netbsd-8]: mbuf.h Log Message: Pull up following revision(s) (requested by knakahara in ticket #302): sys/arch/powerpc/booke/dev/pq3etsec.c: 1.30-1.31 sys/arch/x86/pci/if_vmx.c: 1.20 sys/dev/ic/i82557.c: 1.148 sys/dev/ic/rtl8169.c: 1.152 sys/dev/pci/cxgb/cxgb_sge.c: 1.5 sys/dev/pci/if_age.c: 1.51 sys/dev/pci/if_alc.c: 1.25 sys/dev/pci/if_ale.c: 1.23 sys/dev/pci/if_bge.c: 1.311 sys/dev/pci/if_bge.c: 1.312 sys/dev/pci/if_bnx.c: 1.62 sys/dev/pci/if_jme.c: 1.32 sys/dev/pci/if_nfe.c: 1.64 sys/dev/pci/if_sip.c: 1.167 sys/dev/pci/if_stge.c: 1.63-1.64 sys/dev/pci/if_ti.c: 1.102 sys/dev/pci/if_txp.c: 1.48 sys/dev/pci/if_vge.c: 1.61 sys/dev/pci/if_wm.c: 1.538 sys/dev/pci/ixgbe/ix_txrx.c: 1.29 via patch sys/net/agr/if_agrether_hash.c: 1.4 sys/net/if_ether.h: 1.67-1.68 sys/net/if_ethersubr.c: 1.244 sys/net/if_vlan.c: 1.100 sys/net80211/ieee80211_input.c: 1.89 sys/net80211/ieee80211_output.c: 1.59 sys/sys/mbuf.h: 1.171 VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ. I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks. See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html -- only get vtag when we have vtag like the other drivers. -- - only get the vtag if we have it like the other drivers - mask the hardware vlan tag -- - add a constant for the vlan mask. - enforce that we have a tag before we get it. only get vtag when we have vtag like the other drivers. like if_bge.c:1.312 and if_stge.c:1.64. fixed by s-yamaguchi@IIJ, thanks. To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.29.8.1 src/sys/arch/powerpc/booke/dev/pq3etsec.c cvs rdiff -u -r1.19 -r1.19.6.1 src/sys/arch/x86/pci/if_vmx.c cvs rdiff -u -r1.147 -r1.147.6.1 src/sys/dev/ic/i82557.c cvs rdiff -u -r1.151 -r1.151.2.1 src/sys/dev/ic/rtl8169.c cvs rdiff -u -r1.50 -r1.50.8.1 src/sys/dev/pci/if_age.c cvs rdiff -u -r1.24 -r1.24.8.1 src/sys/dev/pci/if_alc.c cvs rdiff -u -r1.22 -r1.22.2.1 src/sys/dev/pci/if_ale.c cvs rdiff -u -r1.310 -r1.310.2.1 src/sys/dev/pci/if_bge.c cvs rdiff -u -r1.61 -r1.61.8.1 src/sys/dev/pci/if_bnx.c cvs rdiff -u -r1.31 -r1.31.8.1 src/sys/dev/pci/if_jme.c cvs rdiff -u -r1.63 -r1.63.8.1 src/sys/dev/pci/if_nfe.c cvs rdiff -u -r1.166 -r1.166.2.1 src/sys/dev/pci/if_sip.c cvs rdiff -u -r1.62 -r1.62.8.1 src/sys/dev/pci/if_stge.c cvs rdiff -u -r1.101 -r1.101.8.1 src/sys/dev/pci/if_ti.c cvs rdiff -u -r1.47 -r1.47.8.1 src/sys/dev/pci/if_txp.c cvs rdiff -u -r1.60 -r1.60.8.1 src/sys/dev/pci/if_vge.c cvs rdiff -u -r1.508.4.3 -r1.508.4.4 src/sys/dev/pci/if_wm.c cvs rdiff -u -r1.4 -r1.4.10.1 src/sys/dev/pci/cxgb/cxgb_sge.c cvs rdiff -u -r1.24.2.1 -r1.24.2.2 src/sys/dev/pci/ixgbe/ix_txrx.c cvs rdiff -u -r1.66 -r1.66.8.1 src/sys/net/if_ether.h cvs rdiff -u -r1.242 -r1.242.6.1 src/sys/net/if_ethersubr.c cvs rdiff -u -r1.97.2.2 -r1.97.2.3 src/sys/net/if_vlan.c cvs rdiff -u -r1.3 -r1.3.114.1 src/sys/net/agr/if_agrether_hash.c cvs rdiff -u -r1.88 -r1.88.6.1 src/sys/net80211/ieee80211_input.c cvs rdiff -u -r1.58 -r1.58.8.1 src/sys/net80211/ieee80211_output.c cvs rdiff -u -r1.170 -r1.170.2.1 src/sys/sys/mbuf.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/powerpc/booke/dev/pq3etsec.c diff -u src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.29 src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.29.8.1 --- src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.29 Thu Dec 15 09:28:04 2016 +++ src/sys/arch/powerpc/booke/dev/pq3etsec.c Tue Oct 24 08:38:58 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: pq3etsec.c,v 1.29 2016/12/15 09:28:04 ozaki-r Exp $ */ +/* $NetBSD: pq3etsec.c,v 1.29.8.1 2017/10/24 08:38:58 snj Exp $ */ /*- * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc. * All rights reserved. @@ -41,7 +41,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.29 2016/12/15 09:28:04 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.29.8.1 2017/10/24 08:38:58 snj Exp $"); #include <sys/param.h> #include <sys/cpu.h> @@ -1512,8 +1512,7 @@ pq3etsec_rx_offload( const struct rxfcb *fcb) { if (fcb->rxfcb_flags & RXFCB_VLN) { - VLAN_INPUT_TAG(&sc->sc_if, m, fcb->rxfcb_vlctl, - m_freem(m); return false); + vlan_set_tag(m, fcb->rxfcb_vlctl); } if ((fcb->rxfcb_flags & RXFCB_IP) == 0 || (fcb->rxfcb_flags & (RXFCB_CIP|RXFCB_CTU)) == 0) @@ -1991,14 +1990,18 @@ pq3etsec_tx_offload( { struct mbuf *m = *mp; u_int csum_flags = m->m_pkthdr.csum_flags; - struct m_tag *vtag = VLAN_OUTPUT_TAG(&sc->sc_ec, m); + bool have_vtag; + uint16_t vtag; KASSERT(m->m_flags & M_PKTHDR); + have_vtag = vlan_has_tag(m); + vtag = (have_vtag) ? vlan_get_tag(m) : 0; + /* * Let see if we are doing any offload first. */ - if (csum_flags == 0 && vtag == 0) { + if (csum_flags == 0 && !have_vtag) { m->m_flags &= ~M_HASFCB; return; } @@ -2012,7 +2015,7 @@ pq3etsec_tx_offload( | ((csum_flags & M_CSUM_CIP) ? TXFCB_CIP : 0) | ((csum_flags & M_CSUM_CTU) ? TXFCB_CTU : 0); } - if (vtag) { + if (have_vtag) { flags |= TXFCB_VLN; } if (flags == 0) { @@ -2028,7 +2031,7 @@ pq3etsec_tx_offload( fcb.txfcb_l4os = M_CSUM_DATA_IPv6_HL(m->m_pkthdr.csum_data); fcb.txfcb_l3os = ETHER_HDR_LEN; fcb.txfcb_phcs = 0; - fcb.txfcb_vlctl = vtag ? VLAN_TAG_VALUE(vtag) & 0xffff : 0; + fcb.txfcb_vlctl = vtag; #if 0 printf("%s: csum_flags=%#x: txfcb flags=%#x lsos=%u l4os=%u phcs=%u vlctl=%#x\n", @@ -2063,7 +2066,6 @@ pq3etsec_tx_offload( panic("%s: impossible M_CSUM flags %#x", device_xname(sc->sc_dev), csum_flags); #endif - } else if (vtag) { } m->m_flags &= ~M_HASFCB; Index: src/sys/arch/x86/pci/if_vmx.c diff -u src/sys/arch/x86/pci/if_vmx.c:1.19 src/sys/arch/x86/pci/if_vmx.c:1.19.6.1 --- src/sys/arch/x86/pci/if_vmx.c:1.19 Mon Feb 20 09:02:01 2017 +++ src/sys/arch/x86/pci/if_vmx.c Tue Oct 24 08:38:59 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_vmx.c,v 1.19 2017/02/20 09:02:01 knakahara Exp $ */ +/* $NetBSD: if_vmx.c,v 1.19.6.1 2017/10/24 08:38:59 snj Exp $ */ /* $OpenBSD: if_vmx.c,v 1.16 2014/01/22 06:04:17 brad Exp $ */ /* @@ -19,7 +19,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.19 2017/02/20 09:02:01 knakahara Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.19.6.1 2017/10/24 08:38:59 snj Exp $"); #include <sys/param.h> #include <sys/cpu.h> @@ -1979,12 +1979,8 @@ vmxnet3_rxq_input(struct vmxnet3_rxqueue if (!rxcd->no_csum) vmxnet3_rx_csum(rxcd, m); - if (rxcd->vlan) { - VLAN_INPUT_TAG(ifp, m, rxcd->vtag, - rxq->vxrxq_stats.vmrxs_ierrors++; - m_freem(m); - return); - } + if (rxcd->vlan) + vlan_set_tag(m, rxcd->vtag); rxq->vxrxq_stats.vmrxs_ipackets++; rxq->vxrxq_stats.vmrxs_ibytes += m->m_pkthdr.len; @@ -2638,7 +2634,6 @@ vmxnet3_txq_encap(struct vmxnet3_txqueue struct mbuf *m; bus_dmamap_t dmap; bus_dma_segment_t *segs; - struct m_tag *mtag; int i, gen, start, csum_start, nsegs, error; sc = txq->vxtxq_sc; @@ -2701,9 +2696,9 @@ vmxnet3_txq_encap(struct vmxnet3_txqueue txd->eop = 1; txd->compreq = 1; - if ((mtag = VLAN_OUTPUT_TAG(&sc->vmx_ethercom, m)) != NULL) { + if (vlan_has_tag(m)) { sop->vtag_mode = 1; - sop->vtag = VLAN_TAG_VALUE(mtag); + sop->vtag = vlan_get_tag(m); } if (m->m_pkthdr.csum_flags & (M_CSUM_TSOv4 | M_CSUM_TSOv6)) { Index: src/sys/dev/ic/i82557.c diff -u src/sys/dev/ic/i82557.c:1.147 src/sys/dev/ic/i82557.c:1.147.6.1 --- src/sys/dev/ic/i82557.c:1.147 Mon Feb 20 07:43:29 2017 +++ src/sys/dev/ic/i82557.c Tue Oct 24 08:38:59 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: i82557.c,v 1.147 2017/02/20 07:43:29 ozaki-r Exp $ */ +/* $NetBSD: i82557.c,v 1.147.6.1 2017/10/24 08:38:59 snj Exp $ */ /*- * Copyright (c) 1997, 1998, 1999, 2001, 2002 The NetBSD Foundation, Inc. @@ -66,7 +66,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: i82557.c,v 1.147 2017/02/20 07:43:29 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: i82557.c,v 1.147.6.1 2017/10/24 08:38:59 snj Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -944,7 +944,6 @@ fxp_start(struct ifnet *ifp) KASSERT((csum_flags & (M_CSUM_TCPv6 | M_CSUM_UDPv6)) == 0); if (sc->sc_flags & FXPF_EXT_RFA) { - struct m_tag *vtag; struct fxp_ipcb *ipcb; /* * Deal with TCP/IP checksum offload. Note that @@ -979,10 +978,8 @@ fxp_start(struct ifnet *ifp) /* * request VLAN tag insertion if needed. */ - vtag = VLAN_OUTPUT_TAG(&sc->sc_ethercom, m0); - if (vtag) { - ipcb->ipcb_vlan_id = - htobe16(*(u_int *)(vtag + 1)); + if (vlan_has_tag(m0)) { + ipcb->ipcb_vlan_id = htobe16(vlan_get_tag(m0)); ipcb->ipcb_ip_activation_high |= FXP_IPCB_INSERTVLAN_ENABLE; } @@ -1403,16 +1400,8 @@ fxp_rxintr(struct fxp_softc *sc) * check VLAN tag stripping. */ if ((sc->sc_flags & FXPF_EXT_RFA) != 0 && - (rfa->rfa_status & htole16(FXP_RFA_STATUS_VLAN)) != 0) { - struct m_tag *vtag; - - vtag = m_tag_get(PACKET_TAG_VLAN, sizeof(u_int), - M_NOWAIT); - if (vtag == NULL) - goto dropit; - *(u_int *)(vtag + 1) = be16toh(rfa->vlan_id); - m_tag_prepend(m, vtag); - } + (rfa->rfa_status & htole16(FXP_RFA_STATUS_VLAN)) != 0) + vlan_set_tag(m, be16toh(rfa->vlan_id)); /* Do checksum checking. */ if ((ifp->if_csum_flags_rx & (M_CSUM_TCPv4|M_CSUM_UDPv4)) != 0) Index: src/sys/dev/ic/rtl8169.c diff -u src/sys/dev/ic/rtl8169.c:1.151 src/sys/dev/ic/rtl8169.c:1.151.2.1 --- src/sys/dev/ic/rtl8169.c:1.151 Tue May 16 06:16:35 2017 +++ src/sys/dev/ic/rtl8169.c Tue Oct 24 08:38:59 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: rtl8169.c,v 1.151 2017/05/16 06:16:35 snj Exp $ */ +/* $NetBSD: rtl8169.c,v 1.151.2.1 2017/10/24 08:38:59 snj Exp $ */ /* * Copyright (c) 1997, 1998-2003 @@ -33,7 +33,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rtl8169.c,v 1.151 2017/05/16 06:16:35 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rtl8169.c,v 1.151.2.1 2017/10/24 08:38:59 snj Exp $"); /* $FreeBSD: /repoman/r/ncvs/src/sys/dev/re/if_re.c,v 1.20 2004/04/11 20:34:08 ru Exp $ */ /* @@ -1345,9 +1345,8 @@ re_rxeof(struct rtk_softc *sc) } if (rxvlan & RE_RDESC_VLANCTL_TAG) { - VLAN_INPUT_TAG(ifp, m, - bswap16(rxvlan & RE_RDESC_VLANCTL_DATA), - continue); + vlan_set_tag(m, + bswap16(rxvlan & RE_RDESC_VLANCTL_DATA)); } if_percpuq_enqueue(ifp->if_percpuq, m); } @@ -1515,7 +1514,6 @@ re_start(struct ifnet *ifp) bus_dmamap_t map; struct re_txq *txq; struct re_desc *d; - struct m_tag *mtag; uint32_t cmdstat, re_flags, vlanctl; int ofree, idx, error, nsegs, seg; int startdesc, curdesc, lastdesc; @@ -1640,8 +1638,8 @@ re_start(struct ifnet *ifp) * appear in all descriptors of a multi-descriptor * transmission attempt. */ - if ((mtag = VLAN_OUTPUT_TAG(&sc->ethercom, m)) != NULL) - vlanctl |= bswap16(VLAN_TAG_VALUE(mtag)) | + if (vlan_has_tag(m)) + vlanctl |= bswap16(vlan_get_tag(m)) | RE_TDESC_VLANCTL_TAG; /* Index: src/sys/dev/pci/if_age.c diff -u src/sys/dev/pci/if_age.c:1.50 src/sys/dev/pci/if_age.c:1.50.8.1 --- src/sys/dev/pci/if_age.c:1.50 Thu Dec 15 09:28:05 2016 +++ src/sys/dev/pci/if_age.c Tue Oct 24 08:38:59 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_age.c,v 1.50 2016/12/15 09:28:05 ozaki-r Exp $ */ +/* $NetBSD: if_age.c,v 1.50.8.1 2017/10/24 08:38:59 snj Exp $ */ /* $OpenBSD: if_age.c,v 1.1 2009/01/16 05:00:34 kevlo Exp $ */ /*- @@ -31,7 +31,7 @@ /* Driver for Attansic Technology Corp. L1 Gigabit Ethernet. */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_age.c,v 1.50 2016/12/15 09:28:05 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_age.c,v 1.50.8.1 2017/10/24 08:38:59 snj Exp $"); #include "vlan.h" @@ -1190,9 +1190,6 @@ age_encap(struct age_softc *sc, struct m bus_dmamap_t map; uint32_t cflags, poff, vtag; int error, i, nsegs, prod; -#if NVLAN > 0 - struct m_tag *mtag; -#endif m = *m_head; cflags = vtag = 0; @@ -1260,8 +1257,8 @@ age_encap(struct age_softc *sc, struct m #if NVLAN > 0 /* Configure VLAN hardware tag insertion. */ - if ((mtag = VLAN_OUTPUT_TAG(&sc->sc_ec, m))) { - vtag = AGE_TX_VLAN_TAG(htons(VLAN_TAG_VALUE(mtag))); + if (vlan_has_tag(m)) { + vtag = AGE_TX_VLAN_TAG(htons(vlan_get_tag(m))); vtag = ((vtag << AGE_TD_VLAN_SHIFT) & AGE_TD_VLAN_MASK); cflags |= AGE_TD_INSERT_VLAN_TAG; } @@ -1499,8 +1496,7 @@ age_rxeof(struct age_softc *sc, struct r /* Check for VLAN tagged frames. */ if (status & AGE_RRD_VLAN) { uint32_t vtag = AGE_RX_VLAN(le32toh(rxrd->vtags)); - VLAN_INPUT_TAG(ifp, m, AGE_RX_VLAN_TAG(vtag), - continue); + vlan_set_tag(m, AGE_RX_VLAN_TAG(vtag)); } #endif Index: src/sys/dev/pci/if_alc.c diff -u src/sys/dev/pci/if_alc.c:1.24 src/sys/dev/pci/if_alc.c:1.24.8.1 --- src/sys/dev/pci/if_alc.c:1.24 Wed Dec 21 11:56:55 2016 +++ src/sys/dev/pci/if_alc.c Tue Oct 24 08:38:59 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_alc.c,v 1.24 2016/12/21 11:56:55 maya Exp $ */ +/* $NetBSD: if_alc.c,v 1.24.8.1 2017/10/24 08:38:59 snj Exp $ */ /* $OpenBSD: if_alc.c,v 1.1 2009/08/08 09:31:13 kevlo Exp $ */ /*- * Copyright (c) 2009, Pyun YongHyeon <yong...@freebsd.org> @@ -1853,9 +1853,6 @@ alc_encap(struct alc_softc *sc, struct m bus_dmamap_t map; uint32_t cflags, poff, vtag; int error, idx, nsegs, prod; -#if NVLAN > 0 - struct m_tag *mtag; -#endif m = *m_head; cflags = vtag = 0; @@ -1914,8 +1911,8 @@ alc_encap(struct alc_softc *sc, struct m idx = 0; #if NVLAN > 0 /* Configure VLAN hardware tag insertion. */ - if ((mtag = VLAN_OUTPUT_TAG(&sc->sc_ec, m))) { - vtag = htons(VLAN_TAG_VALUE(mtag)); + if (vlan_has_tag(m)) { + vtag = htons(vlan_get_tag(m)); vtag = (vtag << TD_VLAN_SHIFT) & TD_VLAN_MASK; cflags |= TD_INS_VLAN_TAG; } @@ -2582,7 +2579,7 @@ alc_rxeof(struct alc_softc *sc, struct r */ if (status & RRD_VLAN_TAG) { u_int32_t vtag = RRD_VLAN(le32toh(rrd->vtag)); - VLAN_INPUT_TAG(ifp, m, ntohs(vtag), ); + vlan_set_tag(m, ntohs(vtag)); } #endif Index: src/sys/dev/pci/if_ale.c diff -u src/sys/dev/pci/if_ale.c:1.22 src/sys/dev/pci/if_ale.c:1.22.2.1 --- src/sys/dev/pci/if_ale.c:1.22 Tue May 23 02:19:14 2017 +++ src/sys/dev/pci/if_ale.c Tue Oct 24 08:38:59 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_ale.c,v 1.22 2017/05/23 02:19:14 ozaki-r Exp $ */ +/* $NetBSD: if_ale.c,v 1.22.2.1 2017/10/24 08:38:59 snj Exp $ */ /*- * Copyright (c) 2008, Pyun YongHyeon <yong...@freebsd.org> @@ -32,7 +32,7 @@ /* Driver for Atheros AR8121/AR8113/AR8114 PCIe Ethernet. */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_ale.c,v 1.22 2017/05/23 02:19:14 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ale.c,v 1.22.2.1 2017/10/24 08:38:59 snj Exp $"); #include "vlan.h" @@ -910,9 +910,6 @@ ale_encap(struct ale_softc *sc, struct m bus_dmamap_t map; uint32_t cflags, poff, vtag; int error, i, nsegs, prod; -#if NVLAN > 0 - struct m_tag *mtag; -#endif m = *m_head; cflags = vtag = 0; @@ -997,8 +994,8 @@ ale_encap(struct ale_softc *sc, struct m #if NVLAN > 0 /* Configure VLAN hardware tag insertion. */ - if ((mtag = VLAN_OUTPUT_TAG(&sc->sc_ec, m))) { - vtag = ALE_TX_VLAN_TAG(htons(VLAN_TAG_VALUE(mtag))); + if (vlan_has_tag(m)) { + vtag = ALE_TX_VLAN_TAG(htons(vlan_get_tag(m))); vtag = ((vtag << ALE_TD_VLAN_SHIFT) & ALE_TD_VLAN_MASK); cflags |= ALE_TD_INSERT_VLAN_TAG; } @@ -1540,7 +1537,7 @@ ale_rxeof(struct ale_softc *sc) #if NVLAN > 0 if (status & ALE_RD_VLAN) { uint32_t vtags = ALE_RX_VLAN(le32toh(rs->vtags)); - VLAN_INPUT_TAG(ifp, m, ALE_RX_VLAN_TAG(vtags), ); + vlan_set_tag(m, ALE_RX_VLAN_TAG(vtags)); } #endif Index: src/sys/dev/pci/if_bge.c diff -u src/sys/dev/pci/if_bge.c:1.310 src/sys/dev/pci/if_bge.c:1.310.2.1 --- src/sys/dev/pci/if_bge.c:1.310 Thu Apr 27 10:01:54 2017 +++ src/sys/dev/pci/if_bge.c Tue Oct 24 08:38:59 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_bge.c,v 1.310 2017/04/27 10:01:54 msaitoh Exp $ */ +/* $NetBSD: if_bge.c,v 1.310.2.1 2017/10/24 08:38:59 snj Exp $ */ /* * Copyright (c) 2001 Wind River Systems @@ -79,7 +79,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.310 2017/04/27 10:01:54 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.310.2.1 2017/10/24 08:38:59 snj Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -4607,7 +4607,7 @@ bge_rxeof(struct bge_softc *sc) * to vlan_input() instead of ether_input(). */ if (cur_rx->bge_flags & BGE_RXBDFLAG_VLAN_TAG) { - VLAN_INPUT_TAG(ifp, m, cur_rx->bge_vlan_tag, continue); + vlan_set_tag(m, cur_rx->bge_vlan_tag & ETHER_VLAN_MASK); } if_percpuq_enqueue(ifp->if_percpuq, m); @@ -5127,8 +5127,9 @@ bge_encap(struct bge_softc *sc, struct m struct txdmamap_pool_entry *dma; bus_dmamap_t dmamap; int i = 0; - struct m_tag *mtag; int use_tso, maxsegsize, error; + bool have_vtag; + uint16_t vtag; cur = frag = *txidx; @@ -5330,9 +5331,9 @@ doit: goto fail_unload; } - mtag = sc->ethercom.ec_nvlans ? - m_tag_find(m_head, PACKET_TAG_VLAN, NULL) : NULL; - + have_vtag = vlan_has_tag(m_head); + if (have_vtag) + vtag = vlan_get_tag(m_head); /* Iterate over dmap-map fragments. */ for (i = 0; i < dmamap->dm_nsegs; i++) { @@ -5363,9 +5364,9 @@ doit: f->bge_flags = csum_flags; } - if (mtag != NULL) { + if (have_vtag) { f->bge_flags |= BGE_TXBDFLAG_VLAN_TAG; - f->bge_vlan_tag = VLAN_TAG_VALUE(mtag); + f->bge_vlan_tag = vtag; } else { f->bge_vlan_tag = 0; } Index: src/sys/dev/pci/if_bnx.c diff -u src/sys/dev/pci/if_bnx.c:1.61 src/sys/dev/pci/if_bnx.c:1.61.8.1 --- src/sys/dev/pci/if_bnx.c:1.61 Thu Dec 15 09:28:05 2016 +++ src/sys/dev/pci/if_bnx.c Tue Oct 24 08:38:59 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_bnx.c,v 1.61 2016/12/15 09:28:05 ozaki-r Exp $ */ +/* $NetBSD: if_bnx.c,v 1.61.8.1 2017/10/24 08:38:59 snj Exp $ */ /* $OpenBSD: if_bnx.c,v 1.85 2009/11/09 14:32:41 dlg Exp $ */ /*- @@ -35,7 +35,7 @@ #if 0 __FBSDID("$FreeBSD: src/sys/dev/bce/if_bce.c,v 1.3 2006/04/13 14:12:26 ru Exp $"); #endif -__KERNEL_RCSID(0, "$NetBSD: if_bnx.c,v 1.61 2016/12/15 09:28:05 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_bnx.c,v 1.61.8.1 2017/10/24 08:38:59 snj Exp $"); /* * The following controllers are supported by this driver: @@ -4633,9 +4633,7 @@ bnx_rx_intr(struct bnx_softc *sc) */ if ((status & L2_FHDR_STATUS_L2_VLAN_TAG) && !(sc->rx_mode & BNX_EMAC_RX_MODE_KEEP_VLAN_TAG)) { - VLAN_INPUT_TAG(ifp, m, - l2fhdr->l2_fhdr_vlan_tag, - continue); + vlan_set_tag(m, l2fhdr->l2_fhdr_vlan_tag); } /* Pass the mbuf off to the upper layers. */ @@ -4947,7 +4945,6 @@ bnx_tx_encap(struct bnx_softc *sc, struc #endif uint32_t addr, prod_bseq; int i, error; - struct m_tag *mtag; static struct work bnx_wk; /* Dummy work. Statically allocated. */ mutex_enter(&sc->tx_pkt_mtx); @@ -4980,10 +4977,9 @@ bnx_tx_encap(struct bnx_softc *sc, struc } /* Transfer any VLAN tags to the bd. */ - mtag = VLAN_OUTPUT_TAG(&sc->bnx_ec, m); - if (mtag != NULL) { + if (vlan_has_tag(m)) { flags |= TX_BD_FLAGS_VLAN_TAG; - vlan_tag = VLAN_TAG_VALUE(mtag); + vlan_tag = vlan_get_tag(m); } /* Map the mbuf into DMAable memory. */ Index: src/sys/dev/pci/if_jme.c diff -u src/sys/dev/pci/if_jme.c:1.31 src/sys/dev/pci/if_jme.c:1.31.8.1 --- src/sys/dev/pci/if_jme.c:1.31 Thu Dec 15 09:28:05 2016 +++ src/sys/dev/pci/if_jme.c Tue Oct 24 08:38:59 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_jme.c,v 1.31 2016/12/15 09:28:05 ozaki-r Exp $ */ +/* $NetBSD: if_jme.c,v 1.31.8.1 2017/10/24 08:38:59 snj Exp $ */ /* * Copyright (c) 2008 Manuel Bouyer. All rights reserved. @@ -58,7 +58,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_jme.c,v 1.31 2016/12/15 09:28:05 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_jme.c,v 1.31.8.1 2017/10/24 08:38:59 snj Exp $"); #include <sys/param.h> @@ -1208,8 +1208,7 @@ jme_intr_rx(jme_softc_t *sc) { } if (flags & JME_RD_VLAN_TAG) { /* pass to vlan_input() */ - VLAN_INPUT_TAG(ifp, mhead, - (flags & JME_RD_VLAN_MASK), continue); + vlan_set_tag(mhead, (flags & JME_RD_VLAN_MASK)); } if_percpuq_enqueue(ifp->if_percpuq, mhead); } @@ -1347,7 +1346,6 @@ jme_encap(struct jme_softc *sc, struct m { struct jme_desc *desc; struct mbuf *m; - struct m_tag *mtag; int error, i, prod, headdsc, nsegs; uint32_t cflags, tso_segsz; @@ -1490,8 +1488,8 @@ jme_encap(struct jme_softc *sc, struct m cflags |= JME_TD_UDPCSUM; } /* Configure VLAN. */ - if ((mtag = VLAN_OUTPUT_TAG(&sc->jme_ec, m)) != NULL) { - cflags |= (VLAN_TAG_VALUE(mtag) & JME_TD_VLAN_MASK); + if (vlan_has_tag(m)) { + cflags |= (vlan_get_tag(m) & JME_TD_VLAN_MASK); cflags |= JME_TD_VLAN_TAG; } Index: src/sys/dev/pci/if_nfe.c diff -u src/sys/dev/pci/if_nfe.c:1.63 src/sys/dev/pci/if_nfe.c:1.63.8.1 --- src/sys/dev/pci/if_nfe.c:1.63 Thu Dec 15 09:28:05 2016 +++ src/sys/dev/pci/if_nfe.c Tue Oct 24 08:38:59 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_nfe.c,v 1.63 2016/12/15 09:28:05 ozaki-r Exp $ */ +/* $NetBSD: if_nfe.c,v 1.63.8.1 2017/10/24 08:38:59 snj Exp $ */ /* $OpenBSD: if_nfe.c,v 1.77 2008/02/05 16:52:50 brad Exp $ */ /*- @@ -21,7 +21,7 @@ /* Driver for NVIDIA nForce MCP Fast Ethernet and Gigabit Ethernet */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_nfe.c,v 1.63 2016/12/15 09:28:05 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_nfe.c,v 1.63.8.1 2017/10/24 08:38:59 snj Exp $"); #include "opt_inet.h" #include "vlan.h" @@ -1072,7 +1072,6 @@ nfe_encap(struct nfe_softc *sc, struct m bus_dmamap_t map; uint16_t flags, csumflags; #if NVLAN > 0 - struct m_tag *mtag; uint32_t vtag = 0; #endif int error, i, first; @@ -1101,8 +1100,8 @@ nfe_encap(struct nfe_softc *sc, struct m #if NVLAN > 0 /* setup h/w VLAN tagging */ - if ((mtag = VLAN_OUTPUT_TAG(&sc->sc_ethercom, m0)) != NULL) - vtag = NFE_TX_VTAG | VLAN_TAG_VALUE(mtag); + if (vlan_has_tag(m0)) + vtag = NFE_TX_VTAG | vlan_get_tag(m0); #endif if ((sc->sc_flags & NFE_HW_CSUM) != 0) { if (m0->m_pkthdr.csum_flags & M_CSUM_IPv4) Index: src/sys/dev/pci/if_sip.c diff -u src/sys/dev/pci/if_sip.c:1.166 src/sys/dev/pci/if_sip.c:1.166.2.1 --- src/sys/dev/pci/if_sip.c:1.166 Wed May 10 02:46:33 2017 +++ src/sys/dev/pci/if_sip.c Tue Oct 24 08:38:59 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_sip.c,v 1.166 2017/05/10 02:46:33 msaitoh Exp $ */ +/* $NetBSD: if_sip.c,v 1.166.2.1 2017/10/24 08:38:59 snj Exp $ */ /*- * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc. @@ -73,7 +73,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_sip.c,v 1.166 2017/05/10 02:46:33 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_sip.c,v 1.166.2.1 2017/10/24 08:38:59 snj Exp $"); @@ -1376,7 +1376,6 @@ static inline void sipcom_set_extsts(struct sip_softc *sc, int lasttx, struct mbuf *m0, uint64_t capenable) { - struct m_tag *mtag; u_int32_t extsts; #ifdef DEBUG struct ifnet *ifp = &sc->sc_ethercom.ec_if; @@ -1397,10 +1396,10 @@ sipcom_set_extsts(struct sip_softc *sc, * htole32(). That's why there must be an * unconditional swap instead of htons() inside. */ - if ((mtag = VLAN_OUTPUT_TAG(&sc->sc_ethercom, m0)) != NULL) { + if (vlan_has_tag(m0)) { sc->sc_txdescs[lasttx].sipd_extsts |= htole32(EXTSTS_VPKT | - (bswap16(VLAN_TAG_VALUE(mtag)) & + (bswap16(vlan_get_tag(m0)) & EXTSTS_VTCI)); } @@ -2206,8 +2205,7 @@ gsip_rxintr(struct sip_softc *sc) * of htons() is used. */ if ((extsts & EXTSTS_VPKT) != 0) { - VLAN_INPUT_TAG(ifp, m, bswap16(extsts & EXTSTS_VTCI), - continue); + vlan_set_tag(m, bswap16(extsts & EXTSTS_VTCI)); } /* Index: src/sys/dev/pci/if_stge.c diff -u src/sys/dev/pci/if_stge.c:1.62 src/sys/dev/pci/if_stge.c:1.62.8.1 --- src/sys/dev/pci/if_stge.c:1.62 Thu Dec 15 09:28:05 2016 +++ src/sys/dev/pci/if_stge.c Tue Oct 24 08:38:59 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_stge.c,v 1.62 2016/12/15 09:28:05 ozaki-r Exp $ */ +/* $NetBSD: if_stge.c,v 1.62.8.1 2017/10/24 08:38:59 snj Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_stge.c,v 1.62 2016/12/15 09:28:05 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_stge.c,v 1.62.8.1 2017/10/24 08:38:59 snj Exp $"); #include <sys/param.h> @@ -805,8 +805,9 @@ stge_start(struct ifnet *ifp) * descriptors. */ for (;;) { - struct m_tag *mtag; uint64_t tfc; + bool have_vtag; + uint16_t vtag; /* * Grab a packet off the queue. @@ -827,7 +828,9 @@ stge_start(struct ifnet *ifp) /* * See if we have any VLAN stuff. */ - mtag = VLAN_OUTPUT_TAG(&sc->sc_ethercom, m0); + have_vtag = vlan_has_tag(m0); + if (have_vtag) + vtag = vlan_get_tag(m0); /* * Get the last and next available transmit descriptor. @@ -931,7 +934,7 @@ stge_start(struct ifnet *ifp) TFD_FragCount(seg) | csum_flags | (((nexttx & STGE_TXINTR_SPACING_MASK) == 0) ? TFD_TxDMAIndicate : 0); - if (mtag) { + if (have_vtag) { #if 0 struct ether_header *eh = mtod(m0, struct ether_header *); @@ -943,7 +946,7 @@ stge_start(struct ifnet *ifp) #ifdef STGE_VLAN_CFI TFD_CFI | #endif - TFD_VID(VLAN_TAG_VALUE(mtag)); + TFD_VID(vtag); } tfd->tfd_control = htole64(tfc); @@ -1358,7 +1361,7 @@ stge_rxintr(struct stge_softc *sc) * Check for VLAN tagged packets */ if (status & RFD_VLANDetected) - VLAN_INPUT_TAG(ifp, m, RFD_TCI(status), continue); + vlan_set_tag(m, RFD_TCI(status)); #endif #if 0 Index: src/sys/dev/pci/if_ti.c diff -u src/sys/dev/pci/if_ti.c:1.101 src/sys/dev/pci/if_ti.c:1.101.8.1 --- src/sys/dev/pci/if_ti.c:1.101 Thu Dec 15 09:28:05 2016 +++ src/sys/dev/pci/if_ti.c Tue Oct 24 08:38:59 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_ti.c,v 1.101 2016/12/15 09:28:05 ozaki-r Exp $ */ +/* $NetBSD: if_ti.c,v 1.101.8.1 2017/10/24 08:38:59 snj Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -81,7 +81,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_ti.c,v 1.101 2016/12/15 09:28:05 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ti.c,v 1.101.8.1 2017/10/24 08:38:59 snj Exp $"); #include "opt_inet.h" @@ -2018,10 +2018,8 @@ ti_rxeof(struct ti_softc *sc) } if (cur_rx->ti_flags & TI_BDFLAG_VLAN_TAG) { - VLAN_INPUT_TAG(ifp, m, - /* ti_vlan_tag also has the priority, trim it */ - cur_rx->ti_vlan_tag & 4095, - continue); + /* ti_vlan_tag also has the priority, trim it */ + vlan_set_tag(m, cur_rx->ti_vlan_tag & 0x0fff); } if_percpuq_enqueue(ifp->if_percpuq, m); @@ -2209,7 +2207,6 @@ ti_encap_tigon1(struct ti_softc *sc, str struct txdmamap_pool_entry *dma; bus_dmamap_t dmamap; int error, i; - struct m_tag *mtag; u_int16_t csum_flags = 0; dma = SIMPLEQ_FIRST(&sc->txdma_list); @@ -2265,9 +2262,9 @@ ti_encap_tigon1(struct ti_softc *sc, str TI_HOSTADDR(f->ti_addr) = dmamap->dm_segs[i].ds_addr; f->ti_len = dmamap->dm_segs[i].ds_len; f->ti_flags = csum_flags; - if ((mtag = VLAN_OUTPUT_TAG(&sc->ethercom, m_head))) { + if (vlan_has_tag(m_head)) { f->ti_flags |= TI_BDFLAG_VLAN_TAG; - f->ti_vlan_tag = VLAN_TAG_VALUE(mtag); + f->ti_vlan_tag = vlan_get_tag(m_head); } else { f->ti_vlan_tag = 0; } @@ -2313,7 +2310,6 @@ ti_encap_tigon2(struct ti_softc *sc, str struct txdmamap_pool_entry *dma; bus_dmamap_t dmamap; int error, i; - struct m_tag *mtag; u_int16_t csum_flags = 0; dma = SIMPLEQ_FIRST(&sc->txdma_list); @@ -2357,9 +2353,9 @@ ti_encap_tigon2(struct ti_softc *sc, str TI_HOSTADDR(f->ti_addr) = dmamap->dm_segs[i].ds_addr; f->ti_len = dmamap->dm_segs[i].ds_len; f->ti_flags = csum_flags; - if ((mtag = VLAN_OUTPUT_TAG(&sc->ethercom, m_head))) { + if (vlan_has_tag(m_head)) { f->ti_flags |= TI_BDFLAG_VLAN_TAG; - f->ti_vlan_tag = VLAN_TAG_VALUE(mtag); + f->ti_vlan_tag = vlan_get_tag(m_head); } else { f->ti_vlan_tag = 0; } Index: src/sys/dev/pci/if_txp.c diff -u src/sys/dev/pci/if_txp.c:1.47 src/sys/dev/pci/if_txp.c:1.47.8.1 --- src/sys/dev/pci/if_txp.c:1.47 Thu Dec 15 09:28:05 2016 +++ src/sys/dev/pci/if_txp.c Tue Oct 24 08:38:59 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_txp.c,v 1.47 2016/12/15 09:28:05 ozaki-r Exp $ */ +/* $NetBSD: if_txp.c,v 1.47.8.1 2017/10/24 08:38:59 snj Exp $ */ /* * Copyright (c) 2001 @@ -32,7 +32,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_txp.c,v 1.47 2016/12/15 09:28:05 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_txp.c,v 1.47.8.1 2017/10/24 08:38:59 snj Exp $"); #include "opt_inet.h" @@ -749,8 +749,7 @@ txp_rx_reclaim(struct txp_softc *sc, str m->m_pkthdr.csum_flags = sumflags; if (rxd->rx_stat & htole32(RX_STAT_VLAN)) { - VLAN_INPUT_TAG(ifp, m, htons(rxd->rx_vlan >> 16), - continue); + vlan_set_tag(m, htons(rxd->rx_vlan >> 16)); } if_percpuq_enqueue(ifp->if_percpuq, m); @@ -1397,7 +1396,6 @@ txp_start(struct ifnet *ifp) struct mbuf *m, *mnew; struct txp_swdesc *sd; u_int32_t firstprod, firstcnt, prod, cnt, i; - struct m_tag *mtag; if ((ifp->if_flags & (IFF_RUNNING | IFF_OACTIVE)) != IFF_RUNNING) return; @@ -1458,9 +1456,9 @@ txp_start(struct ifnet *ifp) if (++cnt >= (TX_ENTRIES - 4)) goto oactive; - if ((mtag = VLAN_OUTPUT_TAG(&sc->sc_arpcom, m))) + if (vlan_has_tag(m)) txd->tx_pflags = TX_PFLAGS_VLAN | - (htons(VLAN_TAG_VALUE(mtag)) << TX_PFLAGS_VLANTAG_S); + (htons(vlan_get_tag(m)) << TX_PFLAGS_VLANTAG_S); if (m->m_pkthdr.csum_flags & M_CSUM_IPv4) txd->tx_pflags |= TX_PFLAGS_IPCKSUM; Index: src/sys/dev/pci/if_vge.c diff -u src/sys/dev/pci/if_vge.c:1.60 src/sys/dev/pci/if_vge.c:1.60.8.1 --- src/sys/dev/pci/if_vge.c:1.60 Thu Dec 15 09:28:05 2016 +++ src/sys/dev/pci/if_vge.c Tue Oct 24 08:38:59 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_vge.c,v 1.60 2016/12/15 09:28:05 ozaki-r Exp $ */ +/* $NetBSD: if_vge.c,v 1.60.8.1 2017/10/24 08:38:59 snj Exp $ */ /*- * Copyright (c) 2004 @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_vge.c,v 1.60 2016/12/15 09:28:05 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_vge.c,v 1.60.8.1 2017/10/24 08:38:59 snj Exp $"); /* * VIA Networking Technologies VT612x PCI gigabit ethernet NIC driver. @@ -1364,8 +1364,7 @@ vge_rxeof(struct vge_softc *sc) * On BE machines, tag is stored in BE as stream data * but it was already swapped by le32toh() above. */ - VLAN_INPUT_TAG(ifp, m, - bswap16(rxctl & VGE_RDCTL_VLANID), continue); + vlan_set_tag(m, bswap16(rxctl & VGE_RDCTL_VLANID)); } if_percpuq_enqueue(ifp->if_percpuq, m); @@ -1539,7 +1538,6 @@ vge_encap(struct vge_softc *sc, struct m struct mbuf *m_new; bus_dmamap_t map; int m_csumflags, seg, error, flags; - struct m_tag *mtag; size_t sz; uint32_t td_sts, td_ctl; @@ -1630,14 +1628,13 @@ vge_encap(struct vge_softc *sc, struct m /* * Set up hardware VLAN tagging. */ - mtag = VLAN_OUTPUT_TAG(&sc->sc_ethercom, m_head); - if (mtag != NULL) { + if (vlan_has_tag(m_head)) { /* * No need htons() here since vge(4) chip assumes * that tags are written in little endian and * we already use htole32() here. */ - td_ctl |= VLAN_TAG_VALUE(mtag) | VGE_TDCTL_VTAG; + td_ctl |= vlan_get_tag(m_head) | VGE_TDCTL_VTAG; } txd->td_ctl = htole32(td_ctl); txd->td_sts = htole32(td_sts); Index: src/sys/dev/pci/if_wm.c diff -u src/sys/dev/pci/if_wm.c:1.508.4.3 src/sys/dev/pci/if_wm.c:1.508.4.4 --- src/sys/dev/pci/if_wm.c:1.508.4.3 Sun Oct 15 20:18:17 2017 +++ src/sys/dev/pci/if_wm.c Tue Oct 24 08:38:59 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wm.c,v 1.508.4.3 2017/10/15 20:18:17 snj Exp $ */ +/* $NetBSD: if_wm.c,v 1.508.4.4 2017/10/24 08:38:59 snj Exp $ */ /* * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc. @@ -83,7 +83,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.508.4.3 2017/10/15 20:18:17 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.508.4.4 2017/10/24 08:38:59 snj Exp $"); #ifdef _KERNEL_OPT #include "opt_net_mpsafe.h" @@ -7043,7 +7043,6 @@ wm_send_common_locked(struct ifnet *ifp, { struct wm_softc *sc = ifp->if_softc; struct mbuf *m0; - struct m_tag *mtag; struct wm_txsoft *txs; bus_dmamap_t dmamap; int error, nexttx, lasttx = -1, ofree, seg, segs_needed, use_tso; @@ -7292,11 +7291,11 @@ wm_send_common_locked(struct ifnet *ifp, * * This is only valid on the last descriptor of the packet. */ - if ((mtag = VLAN_OUTPUT_TAG(&sc->sc_ethercom, m0)) != NULL) { + if (vlan_has_tag(m0)) { txq->txq_descs[lasttx].wtx_cmdlen |= htole32(WTX_CMD_VLE); txq->txq_descs[lasttx].wtx_fields.wtxu_vlan - = htole16(VLAN_TAG_VALUE(mtag) & 0xffff); + = htole16(vlan_get_tag(m0)); } txs->txs_lastdesc = lasttx; @@ -7365,7 +7364,6 @@ wm_nq_tx_offload(struct wm_softc *sc, st struct wm_txsoft *txs, uint32_t *cmdlenp, uint32_t *fieldsp, bool *do_csum) { struct mbuf *m0 = txs->txs_mbuf; - struct m_tag *mtag; uint32_t vl_len, mssidx, cmdc; struct ether_header *eh; int offset, iphl; @@ -7409,8 +7407,8 @@ wm_nq_tx_offload(struct wm_softc *sc, st vl_len |= (iphl << NQTXC_VLLEN_IPLEN_SHIFT); KASSERT((iphl & ~NQTXC_VLLEN_IPLEN_MASK) == 0); - if ((mtag = VLAN_OUTPUT_TAG(&sc->sc_ethercom, m0)) != NULL) { - vl_len |= ((VLAN_TAG_VALUE(mtag) & NQTXC_VLLEN_VLAN_MASK) + if (vlan_has_tag(m0)) { + vl_len |= ((vlan_get_tag(m0) & NQTXC_VLLEN_VLAN_MASK) << NQTXC_VLLEN_VLAN_SHIFT); *cmdlenp |= NQTX_CMD_VLE; } @@ -7648,7 +7646,6 @@ wm_nq_send_common_locked(struct ifnet *i { struct wm_softc *sc = ifp->if_softc; struct mbuf *m0; - struct m_tag *mtag; struct wm_txsoft *txs; bus_dmamap_t dmamap; int error, nexttx, lasttx = -1, seg, segs_needed; @@ -7809,12 +7806,11 @@ wm_nq_send_common_locked(struct ifnet *i htole32(WTX_CMD_IFCS | dmamap->dm_segs[0].ds_len); txq->txq_descs[nexttx].wtx_fields.wtxu_status = 0; txq->txq_descs[nexttx].wtx_fields.wtxu_options = 0; - if ((mtag = VLAN_OUTPUT_TAG(&sc->sc_ethercom, m0)) != - NULL) { + if (vlan_has_tag(m0)) { txq->txq_descs[nexttx].wtx_cmdlen |= htole32(WTX_CMD_VLE); txq->txq_descs[nexttx].wtx_fields.wtxu_vlan = - htole16(VLAN_TAG_VALUE(mtag) & 0xffff); + htole16(vlan_get_tag(m0)); } else { txq->txq_descs[nexttx].wtx_fields.wtxu_vlan =0; } @@ -8228,11 +8224,10 @@ static inline bool wm_rxdesc_input_vlantag(struct wm_rxqueue *rxq, uint32_t status, uint16_t vlantag, struct mbuf *m) { - struct ifnet *ifp = &rxq->rxq_sc->sc_ethercom.ec_if; if (wm_rxdesc_is_set_status(rxq->rxq_sc, status, WRX_ST_VP, EXTRXC_STATUS_VP, NQRXC_STATUS_VP)) { - VLAN_INPUT_TAG(ifp, m, le16toh(vlantag), return false); + vlan_set_tag(m, le16toh(vlantag)); } return true; Index: src/sys/dev/pci/cxgb/cxgb_sge.c diff -u src/sys/dev/pci/cxgb/cxgb_sge.c:1.4 src/sys/dev/pci/cxgb/cxgb_sge.c:1.4.10.1 --- src/sys/dev/pci/cxgb/cxgb_sge.c:1.4 Fri Jun 10 13:27:14 2016 +++ src/sys/dev/pci/cxgb/cxgb_sge.c Tue Oct 24 08:38:59 2017 @@ -28,7 +28,7 @@ POSSIBILITY OF SUCH DAMAGE. ***************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: cxgb_sge.c,v 1.4 2016/06/10 13:27:14 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cxgb_sge.c,v 1.4.10.1 2017/10/24 08:38:59 snj Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -1198,8 +1198,8 @@ t3_encap(struct port_info *p, struct mbu * XXX need to add VLAN support for 6.x */ #ifdef VLAN_SUPPORTED - if (m0->m_flags & M_VLANTAG) - cntrl |= F_TXPKT_VLAN_VLD | V_TXPKT_VLAN(m0->m_pkthdr.ether_vtag); + if (vlan_has_tag(m0)) + cntrl |= F_TXPKT_VLAN_VLD | V_TXPKT_VLAN(vlan_get_tag(m0)); if (m0->m_pkthdr.csum_flags & (CSUM_TSO)) tso_info = V_LSO_MSS(m0->m_pkthdr.tso_segsz); #endif @@ -1222,7 +1222,7 @@ t3_encap(struct port_info *p, struct mbu } #ifdef VLAN_SUPPORTED - if (__predict_false(m0->m_flags & M_VLANTAG)) { + if (vlan_has_tag(m0)) { eth_type = CPL_ETH_II_VLAN; ip = (struct ip *)(pkthdr + ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN); @@ -2163,9 +2163,8 @@ t3_rx_eth(struct adapter *adap, struct s * XXX need to add VLAN support for 6.x */ #ifdef VLAN_SUPPORTED - if (__predict_false(cpl->vlan_valid)) { - m->m_pkthdr.ether_vtag = ntohs(cpl->vlan); - m->m_flags |= M_VLANTAG; + if (cpl->vlan_valid) { + vlan_set_tag(ntohs(cpl->vlan)); } #endif Index: src/sys/dev/pci/ixgbe/ix_txrx.c diff -u src/sys/dev/pci/ixgbe/ix_txrx.c:1.24.2.1 src/sys/dev/pci/ixgbe/ix_txrx.c:1.24.2.2 --- src/sys/dev/pci/ixgbe/ix_txrx.c:1.24.2.1 Sat Aug 5 03:49:35 2017 +++ src/sys/dev/pci/ixgbe/ix_txrx.c Tue Oct 24 08:38:59 2017 @@ -59,7 +59,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ /*$FreeBSD: head/sys/dev/ixgbe/ix_txrx.c 301538 2016-06-07 04:51:50Z sephe $*/ -/*$NetBSD: ix_txrx.c,v 1.24.2.1 2017/08/05 03:49:35 snj Exp $*/ +/*$NetBSD: ix_txrx.c,v 1.24.2.2 2017/10/24 08:38:59 snj Exp $*/ #include "opt_inet.h" #include "opt_inet6.h" @@ -331,10 +331,8 @@ ixgbe_deferred_mq_start(void *arg) static int ixgbe_xmit(struct tx_ring *txr, struct mbuf *m_head) { - struct m_tag *mtag; struct adapter *adapter = txr->adapter; struct ifnet *ifp = adapter->ifp; - struct ethercom *ec = &adapter->osdep.ec; u32 olinfo_status = 0, cmd_type_len; int i, j, error; int first; @@ -347,7 +345,7 @@ ixgbe_xmit(struct tx_ring *txr, struct m cmd_type_len = (IXGBE_ADVTXD_DTYP_DATA | IXGBE_ADVTXD_DCMD_IFCS | IXGBE_ADVTXD_DCMD_DEXT); - if ((mtag = VLAN_OUTPUT_TAG(ec, m_head)) != NULL) + if (vlan_has_tag(m_head)) cmd_type_len |= IXGBE_ADVTXD_DCMD_VLE; /* @@ -734,8 +732,6 @@ ixgbe_tx_ctx_setup(struct tx_ring *txr, u32 *cmd_type_len, u32 *olinfo_status) { struct adapter *adapter = txr->adapter; - struct ethercom *ec = &adapter->osdep.ec; - struct m_tag *mtag; struct ixgbe_adv_tx_context_desc *TXD; struct ether_vlan_header *eh; #ifdef INET @@ -777,8 +773,8 @@ ixgbe_tx_ctx_setup(struct tx_ring *txr, ** be placed into the context descriptor. Hence ** we need to make one even if not doing offloads. */ - if ((mtag = VLAN_OUTPUT_TAG(ec, mp)) != NULL) { - vtag = htole16(VLAN_TAG_VALUE(mtag) & 0xffff); + if (vlan_has_tag(mp)) { + vtag = htole16(vlan_get_tag(mp)); vlan_macip_lens |= (vtag << IXGBE_ADVTXD_VLAN_SHIFT); } else if (!IXGBE_IS_X550VF(adapter) && (offload == FALSE)) return (0); @@ -895,9 +891,6 @@ static int ixgbe_tso_setup(struct tx_ring *txr, struct mbuf *mp, u32 *cmd_type_len, u32 *olinfo_status) { - struct m_tag *mtag; - struct adapter *adapter = txr->adapter; - struct ethercom *ec = &adapter->osdep.ec; struct ixgbe_adv_tx_context_desc *TXD; u32 vlan_macip_lens = 0, type_tucmd_mlhl = 0; u32 mss_l4len_idx = 0, paylen; @@ -970,8 +963,8 @@ ixgbe_tso_setup(struct tx_ring *txr, str paylen = mp->m_pkthdr.len - ehdrlen - ip_hlen - tcp_hlen; /* VLAN MACLEN IPLEN */ - if ((mtag = VLAN_OUTPUT_TAG(ec, mp)) != NULL) { - vtag = htole16(VLAN_TAG_VALUE(mtag) & 0xffff); + if (vlan_has_tag(mp)) { + vtag = htole16(vlan_get_tag(mp)); vlan_macip_lens |= (vtag << IXGBE_ADVTXD_VLAN_SHIFT); } @@ -1954,9 +1947,7 @@ ixgbe_rxeof(struct ix_queue *que) (staterr & IXGBE_RXD_STAT_VP)) vtag = le16toh(cur->wb.upper.vlan); if (vtag) { - VLAN_INPUT_TAG(ifp, sendmp, vtag, - printf("%s: could not apply VLAN " - "tag", __func__)); + vlan_set_tag(sendmp, vtag); } if ((ifp->if_capenable & IFCAP_RXCSUM) != 0) { ixgbe_rx_checksum(staterr, sendmp, ptype, Index: src/sys/net/if_ether.h diff -u src/sys/net/if_ether.h:1.66 src/sys/net/if_ether.h:1.66.8.1 --- src/sys/net/if_ether.h:1.66 Wed Dec 28 07:32:16 2016 +++ src/sys/net/if_ether.h Tue Oct 24 08:38:59 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_ether.h,v 1.66 2016/12/28 07:32:16 ozaki-r Exp $ */ +/* $NetBSD: if_ether.h,v 1.66.8.1 2017/10/24 08:38:59 snj Exp $ */ /* * Copyright (c) 1982, 1986, 1993 @@ -60,6 +60,7 @@ * Some Ethernet extensions. */ #define ETHER_VLAN_ENCAP_LEN 4 /* length of 802.1Q VLAN encapsulation */ +#define ETHER_VLAN_MASK 0xFFF /* bits in a vlan tag */ #define ETHER_PPPOE_ENCAP_LEN 8 /* length of PPPoE encapsulation */ /* @@ -295,35 +296,30 @@ struct ether_multistep { */ /* add VLAN tag to input/received packet */ -static inline int vlan_input_tag(struct ifnet *, struct mbuf *, u_int); -static inline int -vlan_input_tag(struct ifnet *ifp, struct mbuf *m, u_int vlanid) +static inline void +vlan_set_tag(struct mbuf *m, u_int16_t vlanid) { - struct m_tag *mtag; - mtag = m_tag_get(PACKET_TAG_VLAN, sizeof(u_int), M_NOWAIT); - if (mtag == NULL) { - ifp->if_ierrors++; - printf("%s: unable to allocate VLAN tag\n", ifp->if_xname); - m_freem(m); - return 1; - } - *(u_int *)(mtag + 1) = vlanid; - m_tag_prepend(m, mtag); - return 0; + + KASSERT((vlanid & ~ETHER_VLAN_MASK) == 0); + + m->m_pkthdr.ether_vtag = vlanid; + m->m_flags |= M_VLANTAG; + return; } -#define VLAN_INPUT_TAG(ifp, m, vlanid, _errcase) \ - if (vlan_input_tag(ifp, m, vlanid) != 0) { \ - _errcase; \ - } - -/* extract VLAN tag from output/trasmit packet */ -#define VLAN_OUTPUT_TAG(ec, m0) \ - (VLAN_ATTACHED(ec) ? m_tag_find((m0), PACKET_TAG_VLAN, NULL) : NULL) +static inline bool +vlan_has_tag(struct mbuf *m) +{ + return (m->m_flags & M_VLANTAG) != 0; +} /* extract VLAN ID value from a VLAN tag */ -#define VLAN_TAG_VALUE(mtag) \ - ((*(u_int *)(mtag + 1)) & 4095) +static inline uint16_t +vlan_get_tag(struct mbuf *m) +{ + KASSERT(m->m_flags & M_VLANTAG); + return m->m_pkthdr.ether_vtag; +} /* test if any VLAN is configured for this interface */ #define VLAN_ATTACHED(ec) ((ec)->ec_nvlans > 0) Index: src/sys/net/if_ethersubr.c diff -u src/sys/net/if_ethersubr.c:1.242 src/sys/net/if_ethersubr.c:1.242.6.1 --- src/sys/net/if_ethersubr.c:1.242 Thu Apr 6 03:54:59 2017 +++ src/sys/net/if_ethersubr.c Tue Oct 24 08:38:59 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_ethersubr.c,v 1.242 2017/04/06 03:54:59 ozaki-r Exp $ */ +/* $NetBSD: if_ethersubr.c,v 1.242.6.1 2017/10/24 08:38:59 snj Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -61,7 +61,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.242 2017/04/06 03:54:59 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.242.6.1 2017/10/24 08:38:59 snj Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -679,7 +679,7 @@ ether_input(struct ifnet *ifp, struct mb * see if the device performed the decapsulation and * provided us with the tag. */ - if (ec->ec_nvlans && m_tag_find(m, PACKET_TAG_VLAN, NULL) != NULL) { + if (ec->ec_nvlans && vlan_has_tag(m)) { #if NVLAN > 0 /* * vlan_input() will either recursively call ether_input() Index: src/sys/net/if_vlan.c diff -u src/sys/net/if_vlan.c:1.97.2.2 src/sys/net/if_vlan.c:1.97.2.3 --- src/sys/net/if_vlan.c:1.97.2.2 Mon Aug 14 23:39:24 2017 +++ src/sys/net/if_vlan.c Tue Oct 24 08:38:59 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_vlan.c,v 1.97.2.2 2017/08/14 23:39:24 snj Exp $ */ +/* $NetBSD: if_vlan.c,v 1.97.2.3 2017/10/24 08:38:59 snj Exp $ */ /*- * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc. @@ -78,7 +78,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.97.2.2 2017/08/14 23:39:24 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.97.2.3 2017/10/24 08:38:59 snj Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -1231,17 +1231,7 @@ vlan_start(struct ifnet *ifp) * the tag in the mbuf header. */ if (ec->ec_capabilities & ETHERCAP_VLAN_HWTAGGING) { - struct m_tag *mtag; - - mtag = m_tag_get(PACKET_TAG_VLAN, sizeof(u_int), - M_NOWAIT); - if (mtag == NULL) { - ifp->if_oerrors++; - m_freem(m); - continue; - } - *(u_int *)(mtag + 1) = mib->ifvm_tag; - m_tag_prepend(m, mtag); + vlan_set_tag(m, mib->ifvm_tag); } else { /* * insert the tag ourselves @@ -1360,18 +1350,7 @@ vlan_transmit(struct ifnet *ifp, struct * the tag in the mbuf header. */ if (ec->ec_capabilities & ETHERCAP_VLAN_HWTAGGING) { - struct m_tag *mtag; - - mtag = m_tag_get(PACKET_TAG_VLAN, sizeof(u_int), - M_NOWAIT); - if (mtag == NULL) { - ifp->if_oerrors++; - m_freem(m); - error = ENOBUFS; - goto out; - } - *(u_int *)(mtag + 1) = mib->ifvm_tag; - m_tag_prepend(m, mtag); + vlan_set_tag(m, mib->ifvm_tag); } else { /* * insert the tag ourselves @@ -1479,15 +1458,14 @@ vlan_input(struct ifnet *ifp, struct mbu { struct ifvlan *ifv; u_int tag; - struct m_tag *mtag; struct ifvlan_linkmib *mib; struct psref psref; + bool have_vtag; - mtag = m_tag_find(m, PACKET_TAG_VLAN, NULL); - if (mtag != NULL) { - /* m contains a normal ethernet frame, the tag is in mtag */ - tag = EVL_VLANOFTAG(*(u_int *)(mtag + 1)); - m_tag_delete(m, mtag); + have_vtag = vlan_has_tag(m); + if (have_vtag) { + tag = EVL_VLANOFTAG(vlan_get_tag(m)); + m->m_flags &= ~M_VLANTAG; } else { switch (ifp->if_type) { case IFT_ETHER: @@ -1542,7 +1520,7 @@ vlan_input(struct ifnet *ifp, struct mbu * Now, remove the encapsulation header. The original * header has already been fixed up above. */ - if (mtag == NULL) { + if (!have_vtag) { memmove(mtod(m, char *) + mib->ifvm_encaplen, mtod(m, void *), sizeof(struct ether_header)); m_adj(m, mib->ifvm_encaplen); Index: src/sys/net/agr/if_agrether_hash.c diff -u src/sys/net/agr/if_agrether_hash.c:1.3 src/sys/net/agr/if_agrether_hash.c:1.3.114.1 --- src/sys/net/agr/if_agrether_hash.c:1.3 Sat May 5 18:23:23 2007 +++ src/sys/net/agr/if_agrether_hash.c Tue Oct 24 08:38:59 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_agrether_hash.c,v 1.3 2007/05/05 18:23:23 yamt Exp $ */ +/* $NetBSD: if_agrether_hash.c,v 1.3.114.1 2017/10/24 08:38:59 snj Exp $ */ /*- * Copyright (c)2005 YAMAMOTO Takashi, @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_agrether_hash.c,v 1.3 2007/05/05 18:23:23 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_agrether_hash.c,v 1.3.114.1 2017/10/24 08:38:59 snj Exp $"); #include <sys/param.h> #include <sys/mbuf.h> @@ -77,7 +77,6 @@ agrether_hashmbuf(struct agr_softc *sc, int off = 0; uint16_t tci; uint16_t etype; - struct m_tag *mtag; eh = agr_m_extract(m, off, sizeof(*eh), &eh_store); if (eh == NULL) { @@ -101,8 +100,8 @@ agrether_hashmbuf(struct agr_softc *sc, tci = vlanhdr->evl_tag; etype = vlanhdr->evl_proto; off += sizeof(*vlanhdr) - sizeof(*eh); - } else if ((mtag = m_tag_find(m, PACKET_TAG_VLAN, NULL)) != NULL) { - tci = htole16((*(u_int *)(mtag + 1)) & 0xffff); + } else if (vlan_has_tag(m)) { + tci = htole16(vlan_get_tag(m)); } else { tci = 0; } Index: src/sys/net80211/ieee80211_input.c diff -u src/sys/net80211/ieee80211_input.c:1.88 src/sys/net80211/ieee80211_input.c:1.88.6.1 --- src/sys/net80211/ieee80211_input.c:1.88 Mon Mar 6 08:36:20 2017 +++ src/sys/net80211/ieee80211_input.c Tue Oct 24 08:39:00 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ieee80211_input.c,v 1.88 2017/03/06 08:36:20 ozaki-r Exp $ */ +/* $NetBSD: ieee80211_input.c,v 1.88.6.1 2017/10/24 08:39:00 snj Exp $ */ /*- * Copyright (c) 2001 Atsushi Onoe * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting @@ -36,7 +36,7 @@ __FBSDID("$FreeBSD: src/sys/net80211/ieee80211_input.c,v 1.81 2005/08/10 16:22:29 sam Exp $"); #endif #ifdef __NetBSD__ -__KERNEL_RCSID(0, "$NetBSD: ieee80211_input.c,v 1.88 2017/03/06 08:36:20 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ieee80211_input.c,v 1.88.6.1 2017/10/24 08:39:00 snj Exp $"); #endif #ifdef _KERNEL_OPT @@ -788,11 +788,8 @@ ieee80211_deliver_data(struct ieee80211c } if (m != NULL) { - if (ni->ni_vlan != 0) { - /* attach vlan tag */ - /* XXX goto err? */ - VLAN_INPUT_TAG(ifp, m, ni->ni_vlan, goto out); - } + if (ni->ni_vlan != 0) + vlan_set_tag(m, ni->ni_vlan); /* * XXX once ieee80211_input (or rxintr itself) runs in softint @@ -802,11 +799,6 @@ ieee80211_deliver_data(struct ieee80211c if_percpuq_enqueue(ifp->if_percpuq, m); } return; - out: - if (m != NULL) { - bpf_mtap3(ic->ic_rawbpf, m); - m_freem(m); - } } static struct mbuf * Index: src/sys/net80211/ieee80211_output.c diff -u src/sys/net80211/ieee80211_output.c:1.58 src/sys/net80211/ieee80211_output.c:1.58.8.1 --- src/sys/net80211/ieee80211_output.c:1.58 Wed Jan 4 03:05:24 2017 +++ src/sys/net80211/ieee80211_output.c Tue Oct 24 08:39:00 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ieee80211_output.c,v 1.58 2017/01/04 03:05:24 nonaka Exp $ */ +/* $NetBSD: ieee80211_output.c,v 1.58.8.1 2017/10/24 08:39:00 snj Exp $ */ /*- * Copyright (c) 2001 Atsushi Onoe * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting @@ -36,7 +36,7 @@ __FBSDID("$FreeBSD: src/sys/net80211/ieee80211_output.c,v 1.34 2005/08/10 16:22:29 sam Exp $"); #endif #ifdef __NetBSD__ -__KERNEL_RCSID(0, "$NetBSD: ieee80211_output.c,v 1.58 2017/01/04 03:05:24 nonaka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ieee80211_output.c,v 1.58.8.1 2017/10/24 08:39:00 snj Exp $"); #endif #ifdef _KERNEL_OPT @@ -296,12 +296,11 @@ ieee80211_classify(struct ieee80211com * v_wme_ac = 0; if (ni->ni_vlan != 0) { /* XXX used to check ec_nvlans. */ - struct m_tag *mtag = m_tag_find(m, PACKET_TAG_VLAN, NULL); - if (mtag == NULL) { + if (!vlan_has_tag(m)) { IEEE80211_NODE_STAT(ni, tx_novlantag); return 1; } - if (EVL_VLANOFTAG(VLAN_TAG_VALUE(mtag)) != + if (EVL_VLANOFTAG(vlan_get_tag(m)) != EVL_VLANOFTAG(ni->ni_vlan)) { IEEE80211_NODE_STAT(ni, tx_vlanmismatch); return 1; Index: src/sys/sys/mbuf.h diff -u src/sys/sys/mbuf.h:1.170 src/sys/sys/mbuf.h:1.170.2.1 --- src/sys/sys/mbuf.h:1.170 Sat May 27 21:02:56 2017 +++ src/sys/sys/mbuf.h Tue Oct 24 08:39:00 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: mbuf.h,v 1.170 2017/05/27 21:02:56 bouyer Exp $ */ +/* $NetBSD: mbuf.h,v 1.170.2.1 2017/10/24 08:39:00 snj Exp $ */ /*- * Copyright (c) 1996, 1997, 1999, 2001, 2007 The NetBSD Foundation, Inc. @@ -174,7 +174,7 @@ struct m_hdr { * checksum) -- this is so we can accumulate the checksum for fragmented * packets during reassembly. * - * Size ILP32: 36 + * Size ILP32: 40 * LP64: 56 */ struct pkthdr { @@ -188,14 +188,16 @@ struct pkthdr { int csum_flags; /* checksum flags */ uint32_t csum_data; /* checksum data */ u_int segsz; /* segment size */ + uint16_t ether_vtag; /* ethernet 802.1p+q vlan tag */ + uint16_t pad0; /* padding */ /* * Following three fields are open-coded struct altq_pktattr * to rearrange struct pkthdr fields flexibly. */ + int pattr_af; /* ALTQ: address family */ void *pattr_class; /* ALTQ: sched class set by classifier */ void *pattr_hdr; /* ALTQ: saved header position in mbuf */ - int pattr_af; /* ALTQ: address family */ }; /* @@ -370,6 +372,8 @@ MBUF_DEFINE(mbuf, MHLEN, MLEN); #define M_LINK6 0x00040000 /* link layer specific flag */ #define M_LINK7 0x00080000 /* link layer specific flag */ +#define M_VLANTAG 0x00100000 /* ether_vtag is valid */ + /* additional flags for M_EXT mbufs */ #define M_EXT_FLAGS 0xff000000 #define M_EXT_CLUSTER 0x01000000 /* ext is a cluster */ @@ -385,10 +389,13 @@ MBUF_DEFINE(mbuf, MHLEN, MLEN); "\20\1EXT\2PKTHDR\3EOR\4PROTO1\5AUTHIPHDR\6DECRYPTED\7LOOP\10AUTHIPDGM" \ "\11BCAST\12MCAST\13CANFASTFWD\14ANYCAST6\15LINK0\16LINK1\17LINK2\20LINK3" \ "\21LINK4\22LINK5\23LINK6\24LINK7" \ + "\25VLANTAG" \ "\31EXT_CLUSTER\32EXT_PAGES\33EXT_ROMAP\34EXT_RW" /* flags copied when copying m_pkthdr */ -#define M_COPYFLAGS (M_PKTHDR|M_EOR|M_BCAST|M_MCAST|M_CANFASTFWD|M_ANYCAST6|M_LINK0|M_LINK1|M_LINK2|M_AUTHIPHDR|M_DECRYPTED|M_LOOP|M_AUTHIPDGM) +#define M_COPYFLAGS (M_PKTHDR|M_EOR|M_BCAST|M_MCAST|M_CANFASTFWD| \ + M_ANYCAST6|M_LINK0|M_LINK1|M_LINK2|M_AUTHIPHDR|M_DECRYPTED|M_LOOP| \ + M_AUTHIPDGM|M_VLANTAG) /* flag copied when shallow-copying external storage */ #define M_EXTCOPYFLAGS (M_EXT|M_EXT_FLAGS) @@ -894,7 +901,7 @@ struct m_tag *m_tag_next(struct mbuf *, /* Packet tag types */ #define PACKET_TAG_NONE 0 /* Nothing */ -#define PACKET_TAG_VLAN 1 /* VLAN ID */ + /* 1: Used to be VLAN ID */ #define PACKET_TAG_ENCAP 2 /* encapsulation data */ #define PACKET_TAG_ESP 3 /* ESP information */ #define PACKET_TAG_SO 4 /* sending socket pointer */