This patch is meant to implement the second option suggested here: https://mail-index.NetBSD.org/tech-net/2022/09/28/msg008338.html The main purpose is to avoid code like: void some_vlan_function(struct ifnet *ifp) { struct ethercom *ec = (void*)ifp; /* access vlan parts of ethercom via *ec */ that is: assumptions that all interfaces used for vlan(4) are ethernet interfaces and their struct ifnet * points to a valid struct ethercom. The patch splits all vlan relevant parts of struct ethercom into a separate struct vlancom (and aggregates a vlancom as ec_vlan into struct ethercom). Instead of casting and going via ethercom, new code would do: void some_vlan_function(struct ifnet *ifp) { struct vlancom *vc = if_get_vlancom(ifp); /* access vlan data via *vc */ and if_get_vlancom is implemented via a special "kernel only" ioctl, so drivers (or as a concrete example: the IEEE 802.11 stack) can intercept the ioctl and return the proper struct vlancom pointer. The common ethernet implementation of the ioctl stays with the ethercom cast and returns &ec->ec_vlan. The patch is quite intrusive, as the above split requires also splitting up ethernet capabilities and vlan capabilities. This means lots of changes in many drivers, but this part is mostly mechanical. The first hunk below is a very typical example. Even drivers with hardware vlan support are easy to convert. Besides the ether/vlan split the other intrusive part is a change of the vlan callback function, which now gets a vlancom pointer and an explicit struct ifnet pointer. The vlancom structure has its own lock, but in case of the common ethernet implementation this is just the same pointer as ther ethercom lock. This avoids lock order issues and saves another lock instances for basically the same structure. The userland interface was left alone, that is: the ethernet capabilities ioctls remained untouched (from a userland perspective), which provides binary compatibility and also avoids ifconfig(8) user interface changes. Index: arch/arm/imx/if_enet.c =================================================================== RCS file: /cvsroot/src/sys/arch/arm/imx/if_enet.c,v retrieving revision 1.36 diff -u -p -r1.36 if_enet.c --- arch/arm/imx/if_enet.c 18 Sep 2022 13:53:06 -0000 1.36 +++ arch/arm/imx/if_enet.c 15 Oct 2022 15:25:24 -0000 @@ -224,7 +224,7 @@ enet_attach_common(device_t self) ifp->if_stop = enet_stop; ifp->if_watchdog = enet_watchdog; - sc->sc_ethercom.ec_capabilities |= ETHERCAP_VLAN_MTU; + sc->sc_ethercom.ec_vlan.vc_capabilities |= VLANCAP_VLAN_MTU; #ifdef ENET_SUPPORT_JUMBO sc->sc_ethercom.ec_capabilities |= ETHERCAP_JUMBO_MTU; #endif Index: arch/arm/sunxi/sunxi_emac.c =================================================================== RCS file: /cvsroot/src/sys/arch/arm/sunxi/sunxi_emac.c,v retrieving revision 1.37 diff -u -p -r1.37 sunxi_emac.c --- arch/arm/sunxi/sunxi_emac.c 18 Sep 2022 15:44:29 -0000 1.37 +++ arch/arm/sunxi/sunxi_emac.c 15 Oct 2022 15:25:25 -0000 @@ -1451,7 +1451,7 @@ sunxi_emac_attach(device_t parent, devic IFQ_SET_READY(&ifp->if_snd); /* 802.1Q VLAN-sized frames are supported */ - sc->ec.ec_capabilities |= ETHERCAP_VLAN_MTU; + sc->ec.ec_vlan.vc_capabilities |= VLANCAP_VLAN_MTU; /* Attach MII driver */ sc->ec.ec_mii = mii; Index: arch/xen/xen/if_xennet_xenbus.c =================================================================== RCS file: /cvsroot/src/sys/arch/xen/xen/if_xennet_xenbus.c,v retrieving revision 1.128 diff -u -p -r1.128 if_xennet_xenbus.c --- arch/xen/xen/if_xennet_xenbus.c 26 Aug 2020 15:54:10 -0000 1.128 +++ arch/xen/xen/if_xennet_xenbus.c 15 Oct 2022 15:25:26 -0000 @@ -371,7 +371,7 @@ xennet_xenbus_attach(device_t parent, de /* Initialize ifnet structure and attach interface */ strlcpy(ifp->if_xname, device_xname(self), IFNAMSIZ); - sc->sc_ethercom.ec_capabilities |= ETHERCAP_VLAN_MTU; + sc->sc_ethercom.ec_vlan.vc_capabilities |= VLANCAP_VLAN_MTU; if (sc->sc_features & FEATURE_SG) sc->sc_ethercom.ec_capabilities |= ETHERCAP_JUMBO_MTU; ifp->if_softc = sc; Index: dev/hyperv/if_hvn.c =================================================================== RCS file: /cvsroot/src/sys/dev/hyperv/if_hvn.c,v retrieving revision 1.24 diff -u -p -r1.24 if_hvn.c --- dev/hyperv/if_hvn.c 18 Sep 2022 16:59:35 -0000 1.24 +++ dev/hyperv/if_hvn.c 15 Oct 2022 15:25:26 -0000 @@ -700,8 +700,8 @@ hvn_attach(device_t parent, device_t sel /* XXX TSOv4, TSOv6 */ if (sc->sc_caps & HVN_CAPS_VLAN) { /* XXX not sure about VLAN_MTU. */ - sc->sc_ec.ec_capabilities |= ETHERCAP_VLAN_HWTAGGING; - sc->sc_ec.ec_capabilities |= ETHERCAP_VLAN_MTU; + sc->sc_ec.ec_vlan.vc_capabilities |= VLANCAP_HWTAGGING; + sc->sc_ec.ec_vlan.vc_capabilities |= VLANCAP_VLAN_MTU; } sc->sc_ec.ec_capabilities |= ETHERCAP_JUMBO_MTU; @@ -4825,7 +4825,7 @@ hvn_rxeof(struct hvn_rx_ring *rxr, uint8 t |= NDIS_VLAN_INFO_PRI(vlan) << EVL_PRIO_BITS; t |= NDIS_VLAN_INFO_CFI(vlan) << EVL_CFI_BITS; - if (ISSET(sc->sc_ec.ec_capenable, ETHERCAP_VLAN_HWTAGGING)) { + if (ISSET(sc->sc_ec.ec_vlan.vc_capenable, VLANCAP_HWTAGGING)) { vlan_set_tag(m, t); rxr->rxr_evvlanhwtagging.ev_count++; } else { Index: dev/ic/bcmgenet.c =================================================================== RCS file: /cvsroot/src/sys/dev/ic/bcmgenet.c,v retrieving revision 1.14 diff -u -p -r1.14 bcmgenet.c --- dev/ic/bcmgenet.c 18 Sep 2022 17:18:19 -0000 1.14 +++ dev/ic/bcmgenet.c 15 Oct 2022 15:25:26 -0000 @@ -1086,7 +1086,7 @@ genet_attach(struct genet_softc *sc) IFQ_SET_READY(&ifp->if_snd); /* 802.1Q VLAN-sized frames are supported */ - sc->sc_ec.ec_capabilities |= ETHERCAP_VLAN_MTU; + sc->sc_ec.ec_vlan.vc_capabilities |= VLANCAP_VLAN_MTU; /* Attach MII driver */ sc->sc_ec.ec_mii = mii; Index: dev/ic/dp8390.c =================================================================== RCS file: /cvsroot/src/sys/dev/ic/dp8390.c,v retrieving revision 1.100 diff -u -p -r1.100 dp8390.c --- dev/ic/dp8390.c 18 Sep 2022 18:03:51 -0000 1.100 +++ dev/ic/dp8390.c 15 Oct 2022 15:25:26 -0000 @@ -144,7 +144,7 @@ dp8390_config(struct dp8390_softc *sc) (*sc->sc_media_init)(sc); /* We can support 802.1Q VLAN-sized frames. */ - sc->sc_ec.ec_capabilities |= ETHERCAP_VLAN_MTU; + sc->sc_ec.ec_vlan.vc_capabilities |= VLANCAP_VLAN_MTU; /* Attach the interface. */ if_attach(ifp); Index: dev/ic/dwc_eqos.c =================================================================== RCS file: /cvsroot/src/sys/dev/ic/dwc_eqos.c,v retrieving revision 1.16 diff -u -p -r1.16 dwc_eqos.c --- dev/ic/dwc_eqos.c 18 Sep 2022 18:20:31 -0000 1.16 +++ dev/ic/dwc_eqos.c 15 Oct 2022 15:25:27 -0000 @@ -1466,7 +1466,7 @@ eqos_attach(struct eqos_softc *sc) IFQ_SET_READY(&ifp->if_snd); /* 802.1Q VLAN-sized frames, and jumbo frame are supported */ - sc->sc_ec.ec_capabilities |= ETHERCAP_VLAN_MTU; + sc->sc_ec.ec_vlan.vc_capabilities |= VLANCAP_VLAN_MTU; sc->sc_ec.ec_capabilities |= ETHERCAP_JUMBO_MTU; /* Attach MII driver */ Index: dev/ic/dwc_gmac.c =================================================================== RCS file: /cvsroot/src/sys/dev/ic/dwc_gmac.c,v retrieving revision 1.78 diff -u -p -r1.78 dwc_gmac.c --- dev/ic/dwc_gmac.c 18 Sep 2022 18:26:53 -0000 1.78 +++ dev/ic/dwc_gmac.c 15 Oct 2022 15:25:27 -0000 @@ -325,7 +325,7 @@ dwc_gmac_attach(struct dwc_gmac_softc *s /* * We can support 802.1Q VLAN-sized frames. */ - sc->sc_ec.ec_capabilities |= ETHERCAP_VLAN_MTU; + sc->sc_ec.ec_vlan.vc_capabilities |= VLANCAP_VLAN_MTU; /* * Ready, attach interface Index: dev/ic/elinkxl.c =================================================================== RCS file: /cvsroot/src/sys/dev/ic/elinkxl.c,v retrieving revision 1.139 diff -u -p -r1.139 elinkxl.c --- dev/ic/elinkxl.c 29 May 2022 10:43:46 -0000 1.139 +++ dev/ic/elinkxl.c 15 Oct 2022 15:25:27 -0000 @@ -413,7 +413,7 @@ ex_config(struct ex_softc *sc) /* * We can support 802.1Q VLAN-sized frames. */ - sc->sc_ethercom.ec_capabilities |= ETHERCAP_VLAN_MTU; + sc->sc_ethercom.ec_vlan.vc_capabilities |= VLANCAP_VLAN_MTU; /* * The 3c90xB has hardware IPv4/TCPv4/UDPv4 checksum support. @@ -1365,8 +1365,8 @@ ex_intr(void *arg) uint16_t total_len; if (pktstat & - ((sc->sc_ethercom.ec_capenable & - ETHERCAP_VLAN_MTU) ? + ((sc->sc_ethercom.ec_vlan.vc_capenable & + VLANCAP_VLAN_MTU) ? EX_UPD_ERR_VLAN : EX_UPD_ERR)) { if_statinc(ifp, if_ierrors); m_freem(m); Index: dev/ic/gem.c =================================================================== RCS file: /cvsroot/src/sys/dev/ic/gem.c,v retrieving revision 1.135 diff -u -p -r1.135 gem.c --- dev/ic/gem.c 25 Sep 2022 18:43:32 -0000 1.135 +++ dev/ic/gem.c 15 Oct 2022 15:25:27 -0000 @@ -574,7 +574,7 @@ gem_attach(struct gem_softc *sc, const u } /* claim 802.1q capability */ - sc->sc_ethercom.ec_capabilities |= ETHERCAP_VLAN_MTU; + sc->sc_ethercom.ec_vlan.vc_capabilities |= VLANCAP_VLAN_MTU; /* Attach the interface. */ if_attach(ifp); @@ -845,7 +845,7 @@ gem_rx_common(struct gem_softc *sc) /* Set receive h/w checksum offset */ #ifdef INET v |= (ETHER_HDR_LEN + sizeof(struct ip) + - ((sc->sc_ethercom.ec_capenable & ETHERCAP_VLAN_MTU) ? + ((sc->sc_ethercom.ec_vlan.vc_capenable & VLANCAP_VLAN_MTU) ? ETHER_VLAN_ENCAP_LEN : 0)) << GEM_RX_CONFIG_CXM_START_SHFT; #endif @@ -1165,7 +1165,7 @@ gem_init(struct ifnet *ifp) gem_init_regs(sc); max_frame_size = uimax(sc->sc_ethercom.ec_if.if_mtu, ETHERMTU); max_frame_size += ETHER_HDR_LEN + ETHER_CRC_LEN; - if (sc->sc_ethercom.ec_capenable & ETHERCAP_VLAN_MTU) + if (sc->sc_ethercom.ec_vlan.vc_capenable & VLANCAP_VLAN_MTU) max_frame_size += ETHER_VLAN_ENCAP_LEN; bus_space_write_4(t, h, GEM_MAC_MAC_MAX_FRAME, max_frame_size|/* burst size */(0x2000<<16)); @@ -1854,7 +1854,7 @@ gem_rint(struct gem_softc *sc) struct ip *ip; int32_t hlen, pktlen; - if (sc->sc_ethercom.ec_capenable & ETHERCAP_VLAN_MTU) { + if (sc->sc_ethercom.ec_vlan.vc_capenable & VLANCAP_VLAN_MTU) { pktlen = m->m_pkthdr.len - ETHER_HDR_LEN - ETHER_VLAN_ENCAP_LEN; eh = (struct ether_header *) (mtod(m, char *) + Index: dev/ic/hme.c =================================================================== RCS file: /cvsroot/src/sys/dev/ic/hme.c,v retrieving revision 1.109 diff -u -p -r1.109 hme.c --- dev/ic/hme.c 29 May 2022 10:43:46 -0000 1.109 +++ dev/ic/hme.c 15 Oct 2022 15:25:27 -0000 @@ -295,7 +295,7 @@ hme_config(struct hme_softc *sc) } /* claim 802.1q capability */ - sc->sc_ethercom.ec_capabilities |= ETHERCAP_VLAN_MTU; + sc->sc_ethercom.ec_vlan.vc_capabilities |= VLANCAP_VLAN_MTU; /* Attach the interface. */ if_attach(ifp); @@ -511,7 +511,7 @@ hme_init(struct ifnet *ifp) bus_space_write_4(t, mac, HME_MACI_EXCNT, 0); bus_space_write_4(t, mac, HME_MACI_LTCNT, 0); bus_space_write_4(t, mac, HME_MACI_TXSIZE, - (sc->sc_ethercom.ec_capenable & ETHERCAP_VLAN_MTU) ? + (sc->sc_ethercom.ec_vlan.vc_capenable & VLANCAP_VLAN_MTU) ? ETHER_VLAN_ENCAP_LEN + ETHER_MAX_LEN : ETHER_MAX_LEN); sc->sc_ec_capenable = sc->sc_ethercom.ec_capenable; @@ -541,7 +541,7 @@ hme_init(struct ifnet *ifp) bus_space_write_4(t, erx, HME_ERXI_RING, sc->sc_rb.rb_rxddma); bus_space_write_4(t, mac, HME_MACI_RXSIZE, - (sc->sc_ethercom.ec_capenable & ETHERCAP_VLAN_MTU) ? + (sc->sc_ethercom.ec_vlan.vc_capenable & VLANCAP_VLAN_MTU) ? ETHER_VLAN_ENCAP_LEN + ETHER_MAX_LEN : ETHER_MAX_LEN); /* step 8. Global Configuration & Interrupt Mask */ @@ -863,7 +863,7 @@ hme_read(struct hme_softc *sc, int ix, u len = HME_XD_DECODE_RSIZE(flags); if (len <= sizeof(struct ether_header) || - len > ((sc->sc_ethercom.ec_capenable & ETHERCAP_VLAN_MTU) ? + len > ((sc->sc_ethercom.ec_vlan.vc_capenable & VLANCAP_VLAN_MTU) ? ETHER_VLAN_ENCAP_LEN + ETHERMTU + sizeof(struct ether_header) : ETHERMTU + sizeof(struct ether_header))) { #ifdef HMEDEBUG Index: dev/ic/i82557.c =================================================================== RCS file: /cvsroot/src/sys/dev/ic/i82557.c,v retrieving revision 1.160 diff -u -p -r1.160 i82557.c --- dev/ic/i82557.c 25 Jun 2022 02:46:15 -0000 1.160 +++ dev/ic/i82557.c 15 Oct 2022 15:25:27 -0000 @@ -392,8 +392,8 @@ fxp_attach(struct fxp_softc *sc) IFCAP_CSUM_IPv4_Tx | IFCAP_CSUM_IPv4_Rx | IFCAP_CSUM_TCPv4_Tx | IFCAP_CSUM_TCPv4_Rx | IFCAP_CSUM_UDPv4_Tx | IFCAP_CSUM_UDPv4_Rx; - sc->sc_ethercom.ec_capabilities |= ETHERCAP_VLAN_HWTAGGING; - sc->sc_ethercom.ec_capenable |= ETHERCAP_VLAN_HWTAGGING; + sc->sc_ethercom.ec_vlan.vc_capabilities |= VLANCAP_HWTAGGING; + sc->sc_ethercom.ec_vlan.vc_capenable |= VLANCAP_HWTAGGING; } else if (sc->sc_flags & FXPF_82559_RXCSUM) { ifp->if_capabilities = IFCAP_CSUM_TCPv4_Rx | @@ -403,7 +403,7 @@ fxp_attach(struct fxp_softc *sc) /* * We can support 802.1Q VLAN-sized frames. */ - sc->sc_ethercom.ec_capabilities |= ETHERCAP_VLAN_MTU; + sc->sc_ethercom.ec_vlan.vc_capabilities |= VLANCAP_VLAN_MTU; /* * Attach the interface. @@ -1392,7 +1392,7 @@ fxp_rxintr(struct fxp_softc *sc) * checking (as we are saving bad frames, in * order to receive the larger ones). */ - if ((ec->ec_capenable & ETHERCAP_VLAN_MTU) != 0 && + if ((ec->ec_vlan.vc_capenable & VLANCAP_VLAN_MTU) != 0 && (rxstat & (FXP_RFA_STATUS_OVERRUN | FXP_RFA_STATUS_RNR | FXP_RFA_STATUS_ALIGN | @@ -1724,7 +1724,7 @@ fxp_init(struct ifnet *ifp) save_bf = 0; lrxen = 0; vlan_drop = 0; - if (sc->sc_ethercom.ec_capenable & ETHERCAP_VLAN_MTU) { + if (sc->sc_ethercom.ec_vlan.vc_capenable & VLANCAP_VLAN_MTU) { if (sc->sc_rev < FXP_REV_82558_A4) save_bf = 1; else Index: dev/ic/rtl8169.c =================================================================== RCS file: /cvsroot/src/sys/dev/ic/rtl8169.c,v retrieving revision 1.175 diff -u -p -r1.175 rtl8169.c --- dev/ic/rtl8169.c 25 Sep 2022 18:43:32 -0000 1.175 +++ dev/ic/rtl8169.c 15 Oct 2022 15:25:27 -0000 @@ -899,8 +899,8 @@ re_attach(struct rtk_softc *sc) ifp->if_mtu = ETHERMTU; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = re_ioctl; - sc->ethercom.ec_capabilities |= - ETHERCAP_VLAN_MTU | ETHERCAP_VLAN_HWTAGGING; + sc->ethercom.ec_vlan.vc_capabilities |= + VLANCAP_VLAN_MTU | VLANCAP_HWTAGGING; ifp->if_start = re_start; ifp->if_stop = re_stop; @@ -1884,7 +1884,7 @@ re_init(struct ifnet *ifp) if ((sc->sc_quirk & RTKQ_8169NONS) != 0) cfg |= (0x1 << 14); - if ((sc->ethercom.ec_capenable & ETHERCAP_VLAN_HWTAGGING) != 0) + if ((sc->ethercom.ec_vlan.vc_capenable & VLANCAP_HWTAGGING) != 0) cfg |= RE_CPLUSCMD_VLANSTRIP; if ((ifp->if_capenable & (IFCAP_CSUM_IPv4_Rx | IFCAP_CSUM_TCPv4_Rx | IFCAP_CSUM_UDPv4_Rx)) != 0) Index: dev/ic/smc83c170.c =================================================================== RCS file: /cvsroot/src/sys/dev/ic/smc83c170.c,v retrieving revision 1.96 diff -u -p -r1.96 smc83c170.c --- dev/ic/smc83c170.c 25 Sep 2022 18:43:32 -0000 1.96 +++ dev/ic/smc83c170.c 15 Oct 2022 15:25:27 -0000 @@ -286,7 +286,7 @@ epic_attach(struct epic_softc *sc) /* * We can support 802.1Q VLAN-sized frames. */ - sc->sc_ethercom.ec_capabilities |= ETHERCAP_VLAN_MTU; + sc->sc_ethercom.ec_vlan.vc_capabilities |= VLANCAP_VLAN_MTU; /* * Attach the interface. Index: dev/ic/tulip.c =================================================================== RCS file: /cvsroot/src/sys/dev/ic/tulip.c,v retrieving revision 1.208 diff -u -p -r1.208 tulip.c --- dev/ic/tulip.c 1 Aug 2022 10:30:28 -0000 1.208 +++ dev/ic/tulip.c 15 Oct 2022 15:25:27 -0000 @@ -518,7 +518,7 @@ tlp_attach(struct tulip_softc *sc, const /* * We can support 802.1Q VLAN-sized frames. */ - sc->sc_ethercom.ec_capabilities |= ETHERCAP_VLAN_MTU; + sc->sc_ethercom.ec_vlan.vc_capabilities |= VLANCAP_VLAN_MTU; /* * Attach the interface. @@ -1254,7 +1254,7 @@ tlp_rxintr(struct tulip_softc *sc) * If 802.1Q VLAN MTU is enabled, ignore the Frame Too Long * error. */ - if ((sc->sc_ethercom.ec_capenable & ETHERCAP_VLAN_MTU) != 0) + if ((sc->sc_ethercom.ec_vlan.vc_capenable & VLANCAP_VLAN_MTU) != 0) errors &= ~TDSTAT_Rx_TL; /* * If chip doesn't have MII, ignore the MII error bit. Index: dev/pci/if_age.c =================================================================== RCS file: /cvsroot/src/sys/dev/pci/if_age.c,v retrieving revision 1.73 diff -u -p -r1.73 if_age.c --- dev/pci/if_age.c 17 Sep 2022 13:51:09 -0000 1.73 +++ dev/pci/if_age.c 15 Oct 2022 15:25:28 -0000 @@ -253,7 +253,7 @@ age_attach(device_t parent, device_t sel IFQ_SET_READY(&ifp->if_snd); strlcpy(ifp->if_xname, device_xname(sc->sc_dev), IFNAMSIZ); - sc->sc_ec.ec_capabilities = ETHERCAP_VLAN_MTU; + sc->sc_ec.ec_vlan.vc_capabilities = VLANCAP_VLAN_MTU; ifp->if_capabilities |= IFCAP_CSUM_IPv4_Rx | IFCAP_CSUM_TCPv4_Rx | @@ -265,8 +265,8 @@ age_attach(device_t parent, device_t sel #endif #if NVLAN > 0 - sc->sc_ec.ec_capabilities |= ETHERCAP_VLAN_HWTAGGING; - sc->sc_ec.ec_capenable |= ETHERCAP_VLAN_HWTAGGING; + sc->sc_ec.ec_vlan.vc_capabilities |= VLANCAP_HWTAGGING; + sc->sc_ec.ec_vlan.vc_capenable |= VLANCAP_HWTAGGING; #endif /* Set up MII bus. */ @@ -2277,7 +2277,7 @@ age_rxvlan(struct age_softc *sc) reg = CSR_READ_4(sc, AGE_MAC_CFG); reg &= ~MAC_CFG_VLAN_TAG_STRIP; - if (sc->sc_ec.ec_capenable & ETHERCAP_VLAN_HWTAGGING) + if (sc->sc_ec.ec_vlan.vc_capenable & VLANCAP_HWTAGGING) reg |= MAC_CFG_VLAN_TAG_STRIP; CSR_WRITE_4(sc, AGE_MAC_CFG, reg); } Index: dev/pci/if_alc.c =================================================================== RCS file: /cvsroot/src/sys/dev/pci/if_alc.c,v retrieving revision 1.53 diff -u -p -r1.53 if_alc.c --- dev/pci/if_alc.c 17 Sep 2022 13:55:35 -0000 1.53 +++ dev/pci/if_alc.c 15 Oct 2022 15:25:28 -0000 @@ -1459,7 +1459,7 @@ alc_attach(device_t parent, device_t sel IFQ_SET_READY(&ifp->if_snd); strlcpy(ifp->if_xname, device_xname(sc->sc_dev), IFNAMSIZ); - sc->sc_ec.ec_capabilities = ETHERCAP_VLAN_MTU; + sc->sc_ec.ec_vlan.vc_capabilities = VLANCAP_VLAN_MTU; #ifdef ALC_CHECKSUM ifp->if_capabilities |= IFCAP_CSUM_IPv4_Tx | IFCAP_CSUM_IPv4_Rx | @@ -1468,8 +1468,8 @@ alc_attach(device_t parent, device_t sel #endif #if NVLAN > 0 - sc->sc_ec.ec_capabilities |= ETHERCAP_VLAN_HWTAGGING; - sc->sc_ec.ec_capenable |= ETHERCAP_VLAN_HWTAGGING; + sc->sc_ec.ec_vlan.vc_capabilities |= VLANCAP_HWTAGGING; + sc->sc_ec.ec_vlan.vc_capenable |= VLANCAP_HWTAGGING; #endif /* @@ -3442,7 +3442,7 @@ alc_rxvlan(struct alc_softc *sc) uint32_t reg; reg = CSR_READ_4(sc, ALC_MAC_CFG); - if (sc->sc_ec.ec_capenable & ETHERCAP_VLAN_HWTAGGING) + if (sc->sc_ec.ec_vlan.vc_capenable & VLANCAP_HWTAGGING) reg |= MAC_CFG_VLAN_TAG_STRIP; else reg &= ~MAC_CFG_VLAN_TAG_STRIP; Index: dev/pci/if_ale.c =================================================================== RCS file: /cvsroot/src/sys/dev/pci/if_ale.c,v retrieving revision 1.43 diff -u -p -r1.43 if_ale.c --- dev/pci/if_ale.c 22 Aug 2022 15:59:42 -0000 1.43 +++ dev/pci/if_ale.c 15 Oct 2022 15:25:28 -0000 @@ -543,7 +543,7 @@ ale_attach(device_t parent, device_t sel IFQ_SET_READY(&ifp->if_snd); strlcpy(ifp->if_xname, device_xname(sc->sc_dev), IFNAMSIZ); - sc->sc_ec.ec_capabilities = ETHERCAP_VLAN_MTU; + sc->sc_ec.ec_vlan.vc_capabilities = VLANCAP_VLAN_MTU; #ifdef ALE_CHECKSUM ifp->if_capabilities |= IFCAP_CSUM_IPv4_Tx | IFCAP_CSUM_IPv4_Rx | @@ -552,8 +552,8 @@ ale_attach(device_t parent, device_t sel #endif #if NVLAN > 0 - sc->sc_ec.ec_capabilities |= ETHERCAP_VLAN_HWTAGGING; - sc->sc_ec.ec_capenable |= ETHERCAP_VLAN_HWTAGGING; + sc->sc_ec.ec_vlan.vc_capabilities |= VLANCAP_HWTAGGING; + sc->sc_ec.ec_vlan.vc_capenable |= VLANCAP_HWTAGGING; #endif /* Set up MII bus. */ @@ -1972,7 +1972,7 @@ ale_rxvlan(struct ale_softc *sc) reg = CSR_READ_4(sc, ALE_MAC_CFG); reg &= ~MAC_CFG_VLAN_TAG_STRIP; - if (sc->sc_ec.ec_capenable & ETHERCAP_VLAN_HWTAGGING) + if (sc->sc_ec.ec_vlan.vc_capenable & VLANCAP_HWTAGGING) reg |= MAC_CFG_VLAN_TAG_STRIP; CSR_WRITE_4(sc, ALE_MAC_CFG, reg); } Index: dev/pci/if_aq.c =================================================================== RCS file: /cvsroot/src/sys/dev/pci/if_aq.c,v retrieving revision 1.35 diff -u -p -r1.35 if_aq.c --- dev/pci/if_aq.c 22 Sep 2022 06:04:26 -0000 1.35 +++ dev/pci/if_aq.c 15 Oct 2022 15:25:28 -0000 @@ -1021,7 +1021,7 @@ struct aq_softc { struct ethercom sc_ethercom; struct ether_addr sc_enaddr; struct ifmedia sc_media; - int sc_ec_capenable; /* last ec_capenable */ + int sc_vc_capenable; /* last ec_vlan.vc_capenable */ unsigned short sc_if_flags; /* last if_flags */ bool sc_tx_sending; @@ -1071,7 +1071,8 @@ static int aq_establish_msix_intr(struct static int aq_ifmedia_change(struct ifnet * const); static void aq_ifmedia_status(struct ifnet * const, struct ifmediareq *); -static int aq_vlan_cb(struct ethercom *ec, uint16_t vid, bool set); +static int aq_vlan_cb(struct ifnet *, struct vlancom *ec, + uint16_t vid, bool set); static int aq_ifflags_cb(struct ethercom *); static int aq_init(struct ifnet *); static int aq_init_locked(struct ifnet *); @@ -1470,14 +1471,14 @@ aq_attach(device_t parent, device_t self /* TODO */ sc->sc_ethercom.ec_capabilities |= ETHERCAP_EEE; #endif - sc->sc_ethercom.ec_capabilities |= - ETHERCAP_JUMBO_MTU | - ETHERCAP_VLAN_MTU | - ETHERCAP_VLAN_HWTAGGING | - ETHERCAP_VLAN_HWFILTER; - sc->sc_ethercom.ec_capenable |= - ETHERCAP_VLAN_HWTAGGING | - ETHERCAP_VLAN_HWFILTER; + sc->sc_ethercom.ec_capabilities |= ETHERCAP_JUMBO_MTU; + sc->sc_ethercom.ec_vlan.vc_capabilities |= + VLANCAP_VLAN_MTU | + VLANCAP_HWTAGGING | + VLANCAP_HWFILTER; + sc->sc_ethercom.ec_vlan.vc_capenable |= + VLANCAP_HWTAGGING | + VLANCAP_HWFILTER; ifp->if_capabilities = 0; ifp->if_capenable = 0; @@ -3295,10 +3296,10 @@ aq_set_vlan_filters(struct aq_softc *sc) /* count VID */ i = 0; - SIMPLEQ_FOREACH(vlanidp, &ec->ec_vids, vid_list) + SIMPLEQ_FOREACH(vlanidp, &ec->ec_vlan.vc_vids, vid_list) i++; - if (((sc->sc_ethercom.ec_capenable & ETHERCAP_VLAN_HWFILTER) == 0) || + if (((sc->sc_ethercom.ec_vlan.vc_capenable & VLANCAP_HWFILTER) == 0) || (ifp->if_flags & IFF_PROMISC) || (i > RPF_VLAN_MAX_FILTERS)) { /* @@ -3313,7 +3314,7 @@ aq_set_vlan_filters(struct aq_softc *sc) /* receive only selected VID */ AQ_WRITE_REG_BIT(sc, RPF_VLAN_MODE_REG, RPF_VLAN_MODE_PROMISC, 0); i = 0; - SIMPLEQ_FOREACH(vlanidp, &ec->ec_vids, vid_list) { + SIMPLEQ_FOREACH(vlanidp, &ec->ec_vlan.vc_vids, vid_list) { AQ_WRITE_REG_BIT(sc, RPF_VLAN_FILTER_REG(i), RPF_VLAN_FILTER_EN, 1); AQ_WRITE_REG_BIT(sc, RPF_VLAN_FILTER_REG(i), @@ -4159,7 +4160,7 @@ aq_rxring_reset(struct aq_softc *sc, str RX_DMA_DESC_HEADER_SPLIT, 0); AQ_WRITE_REG_BIT(sc, RX_DMA_DESC_REG(ringidx), RX_DMA_DESC_VLAN_STRIP, - (sc->sc_ethercom.ec_capenable & ETHERCAP_VLAN_HWTAGGING) ? + (sc->sc_ethercom.ec_vlan.vc_capenable & VLANCAP_HWTAGGING) ? 1 : 0); /* @@ -4478,8 +4479,8 @@ aq_rx_intr(void *arg) m->m_len = mlen; m0->m_pkthdr.len = rxd_pktlen; /* VLAN offloading */ - if ((sc->sc_ethercom.ec_capenable & - ETHERCAP_VLAN_HWTAGGING) && + if ((sc->sc_ethercom.ec_vlan.vc_capenable & + VLANCAP_HWTAGGING) && (__SHIFTOUT(rxd_type, RXDESC_TYPE_PKTTYPE_VLAN) || __SHIFTOUT(rxd_type, RXDESC_TYPE_PKTTYPE_VLAN_DOUBLE))) { @@ -4587,9 +4588,8 @@ aq_rx_intr(void *arg) } static int -aq_vlan_cb(struct ethercom *ec, uint16_t vid, bool set) +aq_vlan_cb(struct ifnet *ifp, struct vlancom *vc, uint16_t vid, bool set) { - struct ifnet *ifp = &ec->ec_if; struct aq_softc * const sc = ifp->if_softc; aq_set_vlan_filters(sc); @@ -4601,7 +4601,7 @@ aq_ifflags_cb(struct ethercom *ec) { struct ifnet * const ifp = &ec->ec_if; struct aq_softc * const sc = ifp->if_softc; - int i, ecchange, error = 0; + int i, vcchange, error = 0; unsigned short iffchange; AQ_LOCK(sc); @@ -4610,21 +4610,21 @@ aq_ifflags_cb(struct ethercom *ec) if ((iffchange & IFF_PROMISC) != 0) error = aq_set_filter(sc); - ecchange = ec->ec_capenable ^ sc->sc_ec_capenable; - if (ecchange & ETHERCAP_VLAN_HWTAGGING) { + vcchange = ec->ec_vlan.vc_capenable ^ sc->sc_vc_capenable; + if (vcchange & VLANCAP_HWTAGGING) { for (i = 0; i < AQ_RINGS_NUM; i++) { AQ_WRITE_REG_BIT(sc, RX_DMA_DESC_REG(i), RX_DMA_DESC_VLAN_STRIP, - (ec->ec_capenable & ETHERCAP_VLAN_HWTAGGING) ? + (ec->ec_vlan.vc_capenable & VLANCAP_HWTAGGING) ? 1 : 0); } } /* vlan configuration depends on also interface promiscuous mode */ - if ((ecchange & ETHERCAP_VLAN_HWFILTER) || (iffchange & IFF_PROMISC)) + if ((vcchange & VLANCAP_HWFILTER) || (iffchange & IFF_PROMISC)) aq_set_vlan_filters(sc); - sc->sc_ec_capenable = ec->ec_capenable; + sc->sc_vc_capenable = ec->ec_vlan.vc_capenable; sc->sc_if_flags = ifp->if_flags; AQ_UNLOCK(sc); Index: dev/pci/if_bce.c =================================================================== RCS file: /cvsroot/src/sys/dev/pci/if_bce.c,v retrieving revision 1.62 diff -u -p -r1.62 if_bce.c --- dev/pci/if_bce.c 25 Sep 2022 12:41:46 -0000 1.62 +++ dev/pci/if_bce.c 15 Oct 2022 15:25:28 -0000 @@ -418,7 +418,7 @@ bce_attach(device_t parent, device_t sel ifp->if_stop = bce_stop; IFQ_SET_READY(&ifp->if_snd); - sc->ethercom.ec_capabilities |= ETHERCAP_VLAN_MTU; + sc->ethercom.ec_vlan.vc_capabilities |= VLANCAP_VLAN_MTU; /* Initialize our media structures and probe the MII. */ Index: dev/pci/if_bge.c =================================================================== RCS file: /cvsroot/src/sys/dev/pci/if_bge.c,v retrieving revision 1.388 diff -u -p -r1.388 if_bge.c --- dev/pci/if_bge.c 11 Oct 2022 22:03:37 -0000 1.388 +++ dev/pci/if_bge.c 15 Oct 2022 15:25:28 -0000 @@ -3896,9 +3896,9 @@ bge_attach(device_t parent, device_t sel IFCAP_CSUM_TCPv4_Tx | IFCAP_CSUM_TCPv4_Rx | IFCAP_CSUM_UDPv4_Tx | IFCAP_CSUM_UDPv4_Rx; #endif - sc->ethercom.ec_capabilities |= - ETHERCAP_VLAN_HWTAGGING | ETHERCAP_VLAN_MTU; - sc->ethercom.ec_capenable |= ETHERCAP_VLAN_HWTAGGING; + sc->ethercom.ec_vlan.vc_capabilities |= + VLANCAP_HWTAGGING | VLANCAP_VLAN_MTU; + sc->ethercom.ec_vlan.vc_capenable |= VLANCAP_HWTAGGING; if (sc->bge_flags & BGEF_TSO) sc->ethercom.ec_if.if_capabilities |= IFCAP_TSOv4; Index: dev/pci/if_bnx.c =================================================================== RCS file: /cvsroot/src/sys/dev/pci/if_bnx.c,v retrieving revision 1.111 diff -u -p -r1.111 if_bnx.c --- dev/pci/if_bnx.c 4 Aug 2022 21:11:52 -0000 1.111 +++ dev/pci/if_bnx.c 15 Oct 2022 15:25:28 -0000 @@ -861,9 +861,10 @@ bnx_attach(device_t parent, device_t sel IFQ_SET_READY(&ifp->if_snd); memcpy(ifp->if_xname, device_xname(self), IFNAMSIZ); - sc->bnx_ec.ec_capabilities |= ETHERCAP_JUMBO_MTU | - ETHERCAP_VLAN_MTU | ETHERCAP_VLAN_HWTAGGING; - sc->bnx_ec.ec_capenable |= ETHERCAP_VLAN_HWTAGGING; + sc->bnx_ec.ec_capabilities |= ETHERCAP_JUMBO_MTU; + sc->bnx_ec.ec_vlan.vc_capabilities |= + VLANCAP_VLAN_MTU | VLANCAP_HWTAGGING; + sc->bnx_ec.ec_vlan.vc_capenable |= VLANCAP_HWTAGGING; ifp->if_capabilities |= IFCAP_CSUM_IPv4_Tx | IFCAP_CSUM_IPv4_Rx | Index: dev/pci/if_cas.c =================================================================== RCS file: /cvsroot/src/sys/dev/pci/if_cas.c,v retrieving revision 1.47 diff -u -p -r1.47 if_cas.c --- dev/pci/if_cas.c 24 Sep 2022 18:12:42 -0000 1.47 +++ dev/pci/if_cas.c 15 Oct 2022 15:25:28 -0000 @@ -708,7 +708,7 @@ cas_config(struct cas_softc *sc, const u } /* claim 802.1q capability */ - sc->sc_ethercom.ec_capabilities |= ETHERCAP_VLAN_MTU; + sc->sc_ethercom.ec_vlan.vc_capabilities |= VLANCAP_VLAN_MTU; /* Attach the interface. */ if_attach(ifp); Index: dev/pci/if_dge.c =================================================================== RCS file: /cvsroot/src/sys/dev/pci/if_dge.c,v retrieving revision 1.63 diff -u -p -r1.63 if_dge.c --- dev/pci/if_dge.c 31 Dec 2021 14:25:23 -0000 1.63 +++ dev/pci/if_dge.c 15 Oct 2022 15:25:29 -0000 @@ -925,8 +925,8 @@ dge_attach(device_t parent, device_t sel IFQ_SET_MAXLEN(&ifp->if_snd, uimax(DGE_IFQUEUELEN, IFQ_MAXLEN)); IFQ_SET_READY(&ifp->if_snd); - sc->sc_ethercom.ec_capabilities |= - ETHERCAP_JUMBO_MTU | ETHERCAP_VLAN_MTU; + sc->sc_ethercom.ec_capabilities |= ETHERCAP_JUMBO_MTU; + sc->sc_ethercom.ec_vlan.vc_capabilities |= VLANCAP_VLAN_MTU; /* * We can perform TCPv4 and UDPv4 checksums in-bound. Index: dev/pci/if_iavf.c =================================================================== RCS file: /cvsroot/src/sys/dev/pci/if_iavf.c,v retrieving revision 1.16 diff -u -p -r1.16 if_iavf.c --- dev/pci/if_iavf.c 17 Jun 2022 06:18:09 -0000 1.16 +++ dev/pci/if_iavf.c 15 Oct 2022 15:25:29 -0000 @@ -542,7 +542,7 @@ static void iavf_watchdog_timeout(void * static int iavf_media_change(struct ifnet *); static void iavf_media_status(struct ifnet *, struct ifmediareq *); static int iavf_ifflags_cb(struct ethercom *); -static int iavf_vlan_cb(struct ethercom *, uint16_t, bool); +static int iavf_vlan_cb(struct ifnet *, struct vlancom *, uint16_t, bool); static void iavf_deferred_transmit(void *); static void iavf_handle_queue(void *); static void iavf_handle_queue_wk(struct work *, void *); @@ -898,9 +898,9 @@ iavf_attach(device_t parent, device_t se ifp->if_capabilities |= IAVF_IFCAP_TXCSUM; ether_set_vlan_cb(&sc->sc_ec, iavf_vlan_cb); - sc->sc_ec.ec_capabilities |= ETHERCAP_VLAN_HWTAGGING; - sc->sc_ec.ec_capabilities |= ETHERCAP_VLAN_HWFILTER; - sc->sc_ec.ec_capenable = sc->sc_ec.ec_capabilities; + sc->sc_ec.ec_vlan.vc_capabilities |= VLANCAP_HWTAGGING; + sc->sc_ec.ec_vlan.vc_capabilities |= VLANCAP_HWFILTER; + sc->sc_ec.ec_vlan.vc_capenable = sc->sc_ec.ec_vlan.vc_capabilities; ether_set_ifflags_cb(&sc->sc_ec, iavf_ifflags_cb); @@ -1086,7 +1086,7 @@ iavf_init_locked(struct iavf_softc *sc) }; /* ETHERCAP_VLAN_HWFILTER can not be disabled */ - SET(sc->sc_ec.ec_capenable, ETHERCAP_VLAN_HWFILTER); + SET(sc->sc_ec.ec_vlan.vc_capenable, VLANCAP_HWFILTER); callout_schedule(&sc->sc_tick, IAVF_TICK_INTERVAL); return 0; @@ -1286,15 +1286,14 @@ iavf_ifflags_cb(struct ethercom *ec) struct iavf_softc *sc = ifp->if_softc; /* vlan hwfilter can not be disabled */ - SET(ec->ec_capenable, ETHERCAP_VLAN_HWFILTER); + SET(ec->ec_vlan.vc_capenable, VLANCAP_HWFILTER); return iavf_iff(sc); } static int -iavf_vlan_cb(struct ethercom *ec, uint16_t vid, bool set) +iavf_vlan_cb(struct ifnet *ifp, struct vlancom *vc, uint16_t vid, bool set) { - struct ifnet *ifp = &ec->ec_if; struct iavf_softc *sc = ifp->if_softc; int rv; @@ -1311,13 +1310,13 @@ iavf_vlan_cb(struct ethercom *ec, uint16 } /* ETHERCAP_VLAN_HWFILTER can not be disabled */ - SET(sc->sc_ec.ec_capenable, ETHERCAP_VLAN_HWFILTER); + SET(sc->sc_ec.ec_vlan.vc_capenable, VLANCAP_HWFILTER); if (set) { rv = iavf_config_vlan_id(sc, vid, IAVF_VC_OP_ADD_VLAN); - if (!ISSET(sc->sc_ec.ec_capenable, ETHERCAP_VLAN_HWTAGGING)) { + if (!ISSET(sc->sc_ec.ec_vlan.vc_capenable, VLANCAP_HWTAGGING)) { iavf_config_vlan_stripping(sc, - sc->sc_ec.ec_capenable); + sc->sc_ec.ec_vlan.vc_capenable); } } else { rv = iavf_config_vlan_id(sc, vid, IAVF_VC_OP_DEL_VLAN); @@ -1430,7 +1429,7 @@ iavf_iff_locked(struct iavf_softc *sc) iavf_config_promisc_mode(sc, unicast, multicast); - iavf_config_vlan_stripping(sc, sc->sc_ec.ec_capenable); + iavf_config_vlan_stripping(sc, sc->sc_ec.ec_vlan.vc_capenable); enaddr = CLLADDR(ifp->if_sadl); if (memcmp(enaddr, sc->sc_enaddr_added, ETHER_ADDR_LEN) != 0) { @@ -3566,7 +3565,7 @@ iavf_reset_finish(struct iavf_softc *sc) } } - SIMPLEQ_FOREACH(vlanidp, &ec->ec_vids, vid_list) { + SIMPLEQ_FOREACH(vlanidp, &ec->ec_vlan.vc_vids, vid_list) { ETHER_UNLOCK(ec); iavf_config_vlan_id(sc, vlanidp->vid, IAVF_VC_OP_ADD_VLAN); ETHER_LOCK(ec); @@ -5036,12 +5035,12 @@ iavf_config_promisc_mode(struct iavf_sof } static int -iavf_config_vlan_stripping(struct iavf_softc *sc, int eccap) +iavf_config_vlan_stripping(struct iavf_softc *sc, int vccap) { struct ixl_aq_desc iaq; uint32_t opcode; - opcode = ISSET(eccap, ETHERCAP_VLAN_HWTAGGING) ? + opcode = ISSET(vccap, VLANCAP_HWTAGGING) ? IAVF_VC_OP_ENABLE_VLAN_STRIP : IAVF_VC_OP_DISABLE_VLAN_STRIP; memset(&iaq, 0, sizeof(iaq)); Index: dev/pci/if_ixl.c =================================================================== RCS file: /cvsroot/src/sys/dev/pci/if_ixl.c,v retrieving revision 1.88 diff -u -p -r1.88 if_ixl.c --- dev/pci/if_ixl.c 16 Sep 2022 03:12:03 -0000 1.88 +++ dev/pci/if_ixl.c 15 Oct 2022 15:25:31 -0000 @@ -602,7 +602,7 @@ struct ixl_softc { u_int sc_tx_intr_process_limit; u_int sc_rx_intr_process_limit; - int sc_cur_ec_capenable; + int sc_cur_vc_capenable; struct pci_attach_args sc_pa; pci_intr_handle_t *sc_ihp; @@ -848,7 +848,7 @@ static const struct ixl_product * ixl_lookup(const struct pci_attach_args *pa); static void ixl_link_state_update(struct ixl_softc *, const struct ixl_aq_desc *); -static int ixl_vlan_cb(struct ethercom *, uint16_t, bool); +static int ixl_vlan_cb(struct ifnet *, struct vlancom *, uint16_t, bool); static int ixl_setup_vlan_hwfilter(struct ixl_softc *); static void ixl_teardown_vlan_hwfilter(struct ixl_softc *); static int ixl_update_macvlan(struct ixl_softc *); @@ -1310,14 +1310,14 @@ ixl_attach(device_t parent, device_t sel #endif ether_set_vlan_cb(&sc->sc_ec, ixl_vlan_cb); sc->sc_ec.ec_capabilities |= ETHERCAP_JUMBO_MTU; - sc->sc_ec.ec_capabilities |= ETHERCAP_VLAN_HWTAGGING; - sc->sc_ec.ec_capabilities |= ETHERCAP_VLAN_HWFILTER; + sc->sc_ec.ec_vlan.vc_capabilities |= VLANCAP_HWTAGGING; + sc->sc_ec.ec_vlan.vc_capabilities |= VLANCAP_HWFILTER; - sc->sc_ec.ec_capenable = sc->sc_ec.ec_capabilities; + sc->sc_ec.ec_vlan.vc_capenable = sc->sc_ec.ec_vlan.vc_capabilities; /* Disable VLAN_HWFILTER by default */ - CLR(sc->sc_ec.ec_capenable, ETHERCAP_VLAN_HWFILTER); + CLR(sc->sc_ec.ec_vlan.vc_capenable, VLANCAP_HWFILTER); - sc->sc_cur_ec_capenable = sc->sc_ec.ec_capenable; + sc->sc_cur_vc_capenable = sc->sc_ec.ec_vlan.vc_capenable; sc->sc_ec.ec_ifmedia = &sc->sc_media; ifmedia_init_with_lock(&sc->sc_media, IFM_IMASK, ixl_media_change, @@ -1369,8 +1369,8 @@ ixl_attach(device_t parent, device_t sel if (ixl_update_macvlan(sc) != 0) { aprint_debug_dev(self, "couldn't enable vlan hardware filter\n"); - CLR(sc->sc_ec.ec_capenable, ETHERCAP_VLAN_HWFILTER); - CLR(sc->sc_cur_ec_capenable, ETHERCAP_VLAN_HWFILTER); + CLR(sc->sc_ec.ec_vlan.vc_capenable, VLANCAP_HWFILTER); + CLR(sc->sc_cur_vc_capenable, VLANCAP_HWFILTER); } sc->sc_txrx_workqueue = true; @@ -1545,13 +1545,12 @@ ixl_workqs_teardown(device_t self) } static int -ixl_vlan_cb(struct ethercom *ec, uint16_t vid, bool set) +ixl_vlan_cb(struct ifnet *ifp, struct vlancom *vc, uint16_t vid, bool set) { - struct ifnet *ifp = &ec->ec_if; struct ixl_softc *sc = ifp->if_softc; int rv; - if (!ISSET(sc->sc_cur_ec_capenable, ETHERCAP_VLAN_HWFILTER)) { + if (!ISSET(sc->sc_cur_vc_capenable, VLANCAP_HWFILTER)) { return 0; } @@ -2020,7 +2019,7 @@ ixl_init_locked(struct ixl_softc *sc) { struct ifnet *ifp = &sc->sc_ec.ec_if; unsigned int i; - int error, eccap_change; + int error, vccap_change; KASSERT(mutex_owned(&sc->sc_cfg_lock)); @@ -2031,16 +2030,16 @@ ixl_init_locked(struct ixl_softc *sc) return ENXIO; } - eccap_change = sc->sc_ec.ec_capenable ^ sc->sc_cur_ec_capenable; - if (ISSET(eccap_change, ETHERCAP_VLAN_HWTAGGING)) - sc->sc_cur_ec_capenable ^= ETHERCAP_VLAN_HWTAGGING; + vccap_change = sc->sc_ec.ec_vlan.vc_capenable ^ sc->sc_cur_vc_capenable; + if (ISSET(vccap_change, VLANCAP_HWTAGGING)) + sc->sc_cur_vc_capenable ^= VLANCAP_HWTAGGING; - if (ISSET(eccap_change, ETHERCAP_VLAN_HWFILTER)) { + if (ISSET(vccap_change, VLANCAP_HWFILTER)) { if (ixl_update_macvlan(sc) == 0) { - sc->sc_cur_ec_capenable ^= ETHERCAP_VLAN_HWFILTER; + sc->sc_cur_vc_capenable ^= VLANCAP_HWFILTER; } else { - CLR(sc->sc_ec.ec_capenable, ETHERCAP_VLAN_HWFILTER); - CLR(sc->sc_cur_ec_capenable, ETHERCAP_VLAN_HWFILTER); + CLR(sc->sc_ec.ec_vlan.vc_capenable, VLANCAP_HWFILTER); + CLR(sc->sc_cur_vc_capenable, VLANCAP_HWFILTER); } } @@ -2113,7 +2112,7 @@ ixl_iff(struct ixl_softc *sc) param = (struct ixl_aq_vsi_promisc_param *)&iaq->iaq_param; param->flags = htole16(0); - if (!ISSET(sc->sc_cur_ec_capenable, ETHERCAP_VLAN_HWFILTER) + if (!ISSET(sc->sc_cur_vc_capenable, VLANCAP_HWFILTER) || ISSET(ifp->if_flags, IFF_PROMISC)) { param->flags |= htole16(IXL_AQ_VSI_PROMISC_FLAG_BCAST | IXL_AQ_VSI_PROMISC_FLAG_VLAN); @@ -2138,7 +2137,7 @@ ixl_iff(struct ixl_softc *sc) return EIO; if (memcmp(sc->sc_enaddr, CLLADDR(ifp->if_sadl), ETHER_ADDR_LEN) != 0) { - if (ISSET(sc->sc_cur_ec_capenable, ETHERCAP_VLAN_HWFILTER)) { + if (ISSET(sc->sc_cur_vc_capenable, VLANCAP_HWFILTER)) { flag_add = IXL_AQ_OP_ADD_MACVLAN_PERFECT_MATCH; flag_del = IXL_AQ_OP_REMOVE_MACVLAN_PERFECT_MATCH; } else { @@ -4533,7 +4532,7 @@ ixl_set_vsi(struct ixl_softc *sc) CLR(val, IXL_AQ_VSI_PVLAN_MODE_MASK | IXL_AQ_VSI_PVLAN_EMOD_MASK); SET(val, IXL_AQ_VSI_PVLAN_MODE_ALL); - if (ISSET(sc->sc_cur_ec_capenable, ETHERCAP_VLAN_HWTAGGING)) { + if (ISSET(sc->sc_cur_vc_capenable, VLANCAP_HWTAGGING)) { SET(val, IXL_AQ_VSI_PVLAN_EMOD_STR_BOTH); } else { SET(val, IXL_AQ_VSI_PVLAN_EMOD_NOTHING); @@ -5543,7 +5542,7 @@ ixl_setup_vlan_hwfilter(struct ixl_softc return rv; ETHER_LOCK(ec); - SIMPLEQ_FOREACH(vlanidp, &ec->ec_vids, vid_list) { + SIMPLEQ_FOREACH(vlanidp, &ec->ec_vlan.vc_vids, vid_list) { rv = ixl_add_macvlan(sc, sc->sc_enaddr, vlanidp->vid, IXL_AQ_OP_ADD_MACVLAN_PERFECT_MATCH); if (rv != 0) @@ -5570,7 +5569,7 @@ ixl_teardown_vlan_hwfilter(struct ixl_so IXL_AQ_OP_REMOVE_MACVLAN_PERFECT_MATCH); ETHER_LOCK(ec); - SIMPLEQ_FOREACH(vlanidp, &ec->ec_vids, vid_list) { + SIMPLEQ_FOREACH(vlanidp, &ec->ec_vlan.vc_vids, vid_list) { ixl_remove_macvlan(sc, sc->sc_enaddr, vlanidp->vid, IXL_AQ_OP_REMOVE_MACVLAN_PERFECT_MATCH); ixl_remove_macvlan(sc, etherbroadcastaddr, @@ -5588,9 +5587,9 @@ static int ixl_update_macvlan(struct ixl_softc *sc) { int rv = 0; - int next_ec_capenable = sc->sc_ec.ec_capenable; + int next_vc_capenable = sc->sc_ec.ec_vlan.vc_capenable; - if (ISSET(next_ec_capenable, ETHERCAP_VLAN_HWFILTER)) { + if (ISSET(next_vc_capenable, VLANCAP_HWFILTER)) { rv = ixl_setup_vlan_hwfilter(sc); if (rv != 0) ixl_teardown_vlan_hwfilter(sc); @@ -5610,21 +5609,21 @@ ixl_ifflags_cb(struct ethercom *ec) mutex_enter(&sc->sc_cfg_lock); - change = ec->ec_capenable ^ sc->sc_cur_ec_capenable; + change = ec->ec_vlan.vc_capenable ^ sc->sc_cur_vc_capenable; - if (ISSET(change, ETHERCAP_VLAN_HWTAGGING)) { - sc->sc_cur_ec_capenable ^= ETHERCAP_VLAN_HWTAGGING; + if (ISSET(change, VLANCAP_HWTAGGING)) { + sc->sc_cur_vc_capenable ^= VLANCAP_HWTAGGING; rv = ENETRESET; goto out; } - if (ISSET(change, ETHERCAP_VLAN_HWFILTER)) { + if (ISSET(change, VLANCAP_HWFILTER)) { rv = ixl_update_macvlan(sc); if (rv == 0) { - sc->sc_cur_ec_capenable ^= ETHERCAP_VLAN_HWFILTER; + sc->sc_cur_vc_capenable ^= VLANCAP_HWFILTER; } else { - CLR(ec->ec_capenable, ETHERCAP_VLAN_HWFILTER); - CLR(sc->sc_cur_ec_capenable, ETHERCAP_VLAN_HWFILTER); + CLR(ec->ec_vlan.vc_capenable, VLANCAP_HWFILTER); + CLR(sc->sc_cur_vc_capenable, VLANCAP_HWFILTER); } } Index: dev/pci/if_jme.c =================================================================== RCS file: /cvsroot/src/sys/dev/pci/if_jme.c,v retrieving revision 1.55 diff -u -p -r1.55 if_jme.c --- dev/pci/if_jme.c 2 Sep 2022 23:48:10 -0000 1.55 +++ dev/pci/if_jme.c 15 Oct 2022 15:25:31 -0000 @@ -454,9 +454,9 @@ jme_pci_attach(device_t parent, device_t /* * We can support 802.1Q VLAN-sized frames. */ - sc->jme_ec.ec_capabilities |= - ETHERCAP_VLAN_MTU | ETHERCAP_VLAN_HWTAGGING; - sc->jme_ec.ec_capenable |= ETHERCAP_VLAN_HWTAGGING; + sc->jme_ec.ec_vlan.vc_capabilities |= + VLANCAP_VLAN_MTU | VLANCAP_HWTAGGING; + sc->jme_ec.ec_vlan.vc_capenable |= VLANCAP_HWTAGGING; if (sc->jme_flags & JME_FLAG_GIGA) sc->jme_ec.ec_capabilities |= ETHERCAP_JUMBO_MTU; Index: dev/pci/if_kse.c =================================================================== RCS file: /cvsroot/src/sys/dev/pci/if_kse.c,v retrieving revision 1.59 diff -u -p -r1.59 if_kse.c --- dev/pci/if_kse.c 24 Sep 2022 18:12:42 -0000 1.59 +++ dev/pci/if_kse.c 15 Oct 2022 15:25:32 -0000 @@ -559,7 +559,7 @@ kse_attach(device_t parent, device_t sel * capable of 802.1Q VLAN-sized frames and hw assisted tagging. * can do IPv4, TCPv4, and UDPv4 checksums in hardware. */ - sc->sc_ethercom.ec_capabilities = ETHERCAP_VLAN_MTU; + sc->sc_ethercom.ec_vlan.vc_capabilities = VLANCAP_VLAN_MTU; ifp->if_capabilities = IFCAP_CSUM_IPv4_Tx | IFCAP_CSUM_IPv4_Rx | IFCAP_CSUM_TCPv4_Tx | IFCAP_CSUM_TCPv4_Rx | Index: dev/pci/if_lii.c =================================================================== RCS file: /cvsroot/src/sys/dev/pci/if_lii.c,v retrieving revision 1.29 diff -u -p -r1.29 if_lii.c --- dev/pci/if_lii.c 16 Sep 2022 20:43:17 -0000 1.29 +++ dev/pci/if_lii.c 15 Oct 2022 15:25:32 -0000 @@ -335,7 +335,7 @@ lii_attach(device_t parent, device_t sel * While the device does support HW VLAN tagging, there is no * real point using that feature. */ - sc->sc_ec.ec_capabilities = ETHERCAP_VLAN_MTU; + sc->sc_ec.ec_vlan.vc_capabilities = VLANCAP_VLAN_MTU; if_attach(ifp); if_deferred_start_init(ifp, NULL); Index: dev/pci/if_mcx.c =================================================================== RCS file: /cvsroot/src/sys/dev/pci/if_mcx.c,v retrieving revision 1.25 diff -u -p -r1.25 if_mcx.c --- dev/pci/if_mcx.c 28 Aug 2022 07:54:03 -0000 1.25 +++ dev/pci/if_mcx.c 15 Oct 2022 15:25:32 -0000 @@ -2983,9 +2983,10 @@ mcx_attach(device_t parent, device_t sel IFQ_SET_MAXLEN(&ifp->if_snd, 1024); IFQ_SET_READY(&ifp->if_snd); - sc->sc_ec.ec_capabilities = ETHERCAP_JUMBO_MTU | - ETHERCAP_VLAN_MTU | ETHERCAP_VLAN_HWTAGGING; - sc->sc_ec.ec_capenable |= ETHERCAP_VLAN_HWTAGGING; + sc->sc_ec.ec_capabilities = ETHERCAP_JUMBO_MTU; + sc->sc_ec.ec_vlan.vc_capabilities = + VLANCAP_VLAN_MTU | VLANCAP_HWTAGGING; + sc->sc_ec.ec_vlan.vc_capenable |= VLANCAP_HWTAGGING; sc->sc_ec.ec_ifmedia = &sc->sc_media; ifmedia_init_with_lock(&sc->sc_media, IFM_IMASK, mcx_media_change, Index: dev/pci/if_msk.c =================================================================== RCS file: /cvsroot/src/sys/dev/pci/if_msk.c,v retrieving revision 1.119 diff -u -p -r1.119 if_msk.c --- dev/pci/if_msk.c 24 Sep 2022 18:12:42 -0000 1.119 +++ dev/pci/if_msk.c 15 Oct 2022 15:25:32 -0000 @@ -1299,7 +1299,7 @@ msk_attach(device_t parent, device_t sel goto fail_3; } - sc_if->sk_ethercom.ec_capabilities = ETHERCAP_VLAN_MTU; + sc_if->sk_ethercom.ec_vlan.vc_capabilities = VLANCAP_VLAN_MTU; if (sc->sk_type != SK_YUKON_FE && sc->sk_type != SK_YUKON_FE_P) sc_if->sk_ethercom.ec_capabilities |= ETHERCAP_JUMBO_MTU; Index: dev/pci/if_nfe.c =================================================================== RCS file: /cvsroot/src/sys/dev/pci/if_nfe.c,v retrieving revision 1.80 diff -u -p -r1.80 if_nfe.c --- dev/pci/if_nfe.c 22 Jan 2022 19:07:25 -0000 1.80 +++ dev/pci/if_nfe.c 15 Oct 2022 15:25:33 -0000 @@ -386,9 +386,9 @@ nfe_attach(device_t parent, device_t sel #if NVLAN > 0 if (sc->sc_flags & NFE_HW_VLAN) { - sc->sc_ethercom.ec_capabilities |= - ETHERCAP_VLAN_HWTAGGING | ETHERCAP_VLAN_MTU; - sc->sc_ethercom.ec_capenable |= ETHERCAP_VLAN_HWTAGGING; + sc->sc_ethercom.ec_vlan.vc_capabilities |= + VLANCAP_HWTAGGING | VLANCAP_VLAN_MTU; + sc->sc_ethercom.ec_vlan.vc_capenable |= VLANCAP_HWTAGGING; } #endif if (sc->sc_flags & NFE_HW_CSUM) { Index: dev/pci/if_rge.c =================================================================== RCS file: /cvsroot/src/sys/dev/pci/if_rge.c,v retrieving revision 1.24 diff -u -p -r1.24 if_rge.c --- dev/pci/if_rge.c 24 Sep 2022 18:12:42 -0000 1.24 +++ dev/pci/if_rge.c 15 Oct 2022 15:25:33 -0000 @@ -330,8 +330,8 @@ rge_attach(device_t parent, device_t sel IFCAP_CSUM_UDPv4_Rx | IFCAP_CSUM_UDPv4_Tx; #endif - sc->sc_ec.ec_capabilities |= ETHERCAP_VLAN_MTU; - sc->sc_ec.ec_capabilities |= ETHERCAP_VLAN_HWTAGGING; + sc->sc_ec.ec_vlan.vc_capabilities |= VLANCAP_VLAN_MTU; + sc->sc_ec.ec_vlan.vc_capabilities |= VLANCAP_HWTAGGING; callout_init(&sc->sc_timeout, CALLOUT_FLAGS); callout_setfunc(&sc->sc_timeout, rge_tick, sc); @@ -788,7 +788,7 @@ rge_init(struct ifnet *ifp) rge_write_mac_ocp(sc, 0xe098, 0xc302); - if ((sc->sc_ec.ec_capenable & ETHERCAP_VLAN_HWTAGGING) != 0) + if ((sc->sc_ec.ec_vlan.vc_capenable & VLANCAP_HWTAGGING) != 0) RGE_SETBIT_4(sc, RGE_RXCFG, RGE_RXCFG_VLANSTRIP); else RGE_CLRBIT_4(sc, RGE_RXCFG, RGE_RXCFG_VLANSTRIP); Index: dev/pci/if_sip.c =================================================================== RCS file: /cvsroot/src/sys/dev/pci/if_sip.c,v retrieving revision 1.189 diff -u -p -r1.189 if_sip.c --- dev/pci/if_sip.c 24 Sep 2022 18:12:42 -0000 1.189 +++ dev/pci/if_sip.c 15 Oct 2022 15:25:33 -0000 @@ -1358,16 +1358,17 @@ sipcom_attach(device_t parent, device_t /* * We can support 802.1Q VLAN-sized frames. */ - sc->sc_ethercom.ec_capabilities |= ETHERCAP_VLAN_MTU; + sc->sc_ethercom.ec_vlan.vc_capabilities |= VLANCAP_VLAN_MTU; if (sc->sc_gigabit) { /* * And the DP83820 can do VLAN tagging in hardware, and * support the jumbo Ethernet MTU. */ - sc->sc_ethercom.ec_capabilities |= - ETHERCAP_VLAN_HWTAGGING | ETHERCAP_JUMBO_MTU; - sc->sc_ethercom.ec_capenable |= ETHERCAP_VLAN_HWTAGGING; + sc->sc_ethercom.ec_capabilities |= ETHERCAP_JUMBO_MTU; + sc->sc_ethercom.ec_vlan.vc_capabilities |= + VLANCAP_HWTAGGING; + sc->sc_ethercom.ec_vlan.vc_capenable |= VLANCAP_HWTAGGING; /* * The DP83820 can do IPv4, TCPv4, and UDPv4 checksums @@ -2743,7 +2744,7 @@ sipcom_init(struct ifnet *ifp) * 802.1q-tagged frames and jumbo frames properly. */ if ((sc->sc_gigabit && ifp->if_mtu > ETHERMTU) || - (sc->sc_ethercom.ec_capenable & ETHERCAP_VLAN_MTU)) + (sc->sc_ethercom.ec_vlan.vc_capenable & VLANCAP_VLAN_MTU)) sc->sc_rxcfg |= RXCFG_ALP; /* Index: dev/pci/if_sk.c =================================================================== RCS file: /cvsroot/src/sys/dev/pci/if_sk.c,v retrieving revision 1.111 diff -u -p -r1.111 if_sk.c --- dev/pci/if_sk.c 23 May 2022 13:53:37 -0000 1.111 +++ dev/pci/if_sk.c 15 Oct 2022 15:25:34 -0000 @@ -1376,8 +1376,8 @@ sk_attach(device_t parent, device_t self ifp->if_xname); goto fail; } - sc_if->sk_ethercom.ec_capabilities = ETHERCAP_VLAN_MTU - | ETHERCAP_JUMBO_MTU; + sc_if->sk_ethercom.ec_capabilities = ETHERCAP_JUMBO_MTU; + sc_if->sk_ethercom.ec_vlan.vc_capabilities = VLANCAP_VLAN_MTU; ifp->if_softc = sc_if; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; Index: dev/pci/if_ste.c =================================================================== RCS file: /cvsroot/src/sys/dev/pci/if_ste.c,v retrieving revision 1.64 diff -u -p -r1.64 if_ste.c --- dev/pci/if_ste.c 21 Sep 2022 20:24:42 -0000 1.64 +++ dev/pci/if_ste.c 15 Oct 2022 15:25:34 -0000 @@ -561,7 +561,7 @@ ste_attach(device_t parent, device_t sel /* * We can support 802.1Q VLAN-sized frames. */ - sc->sc_ethercom.ec_capabilities |= ETHERCAP_VLAN_MTU; + sc->sc_ethercom.ec_vlan.vc_capabilities |= VLANCAP_VLAN_MTU; /* * Attach the interface. @@ -1347,7 +1347,7 @@ ste_init(struct ifnet *ifp) bus_space_write_1(st, sh, STE_TxReleaseThresh, 512 >> 4); /* Set maximum packet size for VLAN. */ - if (sc->sc_ethercom.ec_capenable & ETHERCAP_VLAN_MTU) + if (sc->sc_ethercom.ec_vlan.vc_capenable & VLANCAP_VLAN_MTU) bus_space_write_2(st, sh, STE_MaxFrameSize, ETHER_MAX_LEN + 4); else bus_space_write_2(st, sh, STE_MaxFrameSize, ETHER_MAX_LEN); @@ -1371,7 +1371,7 @@ ste_init(struct ifnet *ifp) * as setting the media will actually program the register. */ sc->sc_MacCtrl0 = MC0_IFSSelect(0); - if (sc->sc_ethercom.ec_capenable & ETHERCAP_VLAN_MTU) + if (sc->sc_ethercom.ec_vlan.vc_capenable & VLANCAP_VLAN_MTU) sc->sc_MacCtrl0 |= MC0_RcvLargeFrames; /* Index: dev/pci/if_stge.c =================================================================== RCS file: /cvsroot/src/sys/dev/pci/if_stge.c,v retrieving revision 1.90 diff -u -p -r1.90 if_stge.c --- dev/pci/if_stge.c 24 Sep 2022 18:12:43 -0000 1.90 +++ dev/pci/if_stge.c 15 Oct 2022 15:25:35 -0000 @@ -679,10 +679,9 @@ stge_attach(device_t parent, device_t se * XXX Figure out how to do hw-assisted VLAN tagging in * XXX a reasonable way on this chip. */ - sc->sc_ethercom.ec_capabilities |= - ETHERCAP_VLAN_MTU | /* XXX ETHERCAP_JUMBO_MTU | */ - ETHERCAP_VLAN_HWTAGGING; - sc->sc_ethercom.ec_capenable |= ETHERCAP_VLAN_HWTAGGING; + sc->sc_ethercom.ec_vlan.vc_capabilities |= + VLANCAP_VLAN_MTU | VLANCAP_HWTAGGING; + sc->sc_ethercom.ec_vlan.vc_capenable |= VLANCAP_HWTAGGING; /* * We can do IPv4/TCPv4/UDPv4 checksums in hardware. @@ -1659,7 +1658,7 @@ stge_init(struct ifnet *ifp) */ CSR_WRITE_2(sc, STGE_MaxFrameSize, ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN + - ((sc->sc_ethercom.ec_capenable & ETHERCAP_VLAN_MTU) ? + ((sc->sc_ethercom.ec_vlan.vc_capenable & VLANCAP_VLAN_MTU) ? ETHER_VLAN_ENCAP_LEN : 0)); /* Index: dev/pci/if_ti.c =================================================================== RCS file: /cvsroot/src/sys/dev/pci/if_ti.c,v retrieving revision 1.123 diff -u -p -r1.123 if_ti.c --- dev/pci/if_ti.c 23 May 2022 13:53:37 -0000 1.123 +++ dev/pci/if_ti.c 15 Oct 2022 15:25:35 -0000 @@ -1554,7 +1554,7 @@ ti_gibinit(struct ti_softc *sc) /* Set up tuneables */ if (ifp->if_mtu > (ETHERMTU + ETHER_HDR_LEN + ETHER_CRC_LEN) || - (sc->ethercom.ec_capenable & ETHERCAP_VLAN_MTU)) + (sc->ethercom.ec_vlan.vc_capenable & VLANCAP_VLAN_MTU)) CSR_WRITE_4(sc, TI_GCR_RX_COAL_TICKS, (sc->ti_rx_coal_ticks / 10)); else @@ -1829,9 +1829,9 @@ ti_attach(device_t parent, device_t self /* * We can support 802.1Q VLAN-sized frames. */ - sc->ethercom.ec_capabilities |= - ETHERCAP_VLAN_MTU | ETHERCAP_VLAN_HWTAGGING; - sc->ethercom.ec_capenable |= ETHERCAP_VLAN_HWTAGGING; + sc->ethercom.ec_vlan.vc_capabilities |= + VLANCAP_VLAN_MTU | VLANCAP_HWTAGGING; + sc->ethercom.ec_vlan.vc_capenable |= VLANCAP_HWTAGGING; /* * We can do IPv4, TCPv4, and UDPv4 checksums in hardware. @@ -2483,7 +2483,7 @@ ti_init2(struct ti_softc *sc) CSR_WRITE_4(sc, TI_GCR_IFINDEX, device_unit(sc->sc_dev)); /* ??? */ tmp = ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN; - if (sc->ethercom.ec_capenable & ETHERCAP_VLAN_MTU) + if (sc->ethercom.ec_vlan.vc_capenable & VLANCAP_VLAN_MTU) tmp += ETHER_VLAN_ENCAP_LEN; CSR_WRITE_4(sc, TI_GCR_IFMTU, tmp); Index: dev/pci/if_tl.c =================================================================== RCS file: /cvsroot/src/sys/dev/pci/if_tl.c,v retrieving revision 1.125 diff -u -p -r1.125 if_tl.c --- dev/pci/if_tl.c 2 Sep 2022 23:48:10 -0000 1.125 +++ dev/pci/if_tl.c 15 Oct 2022 15:25:35 -0000 @@ -438,7 +438,7 @@ tl_pci_attach(device_t parent, device_t /* * We can support 802.1Q VLAN-sized frames. */ - sc->tl_ec.ec_capabilities |= ETHERCAP_VLAN_MTU; + sc->tl_ec.ec_vlan.vc_capabilities |= VLANCAP_VLAN_MTU; strlcpy(ifp->if_xname, device_xname(self), IFNAMSIZ); ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; Index: dev/pci/if_txp.c =================================================================== RCS file: /cvsroot/src/sys/dev/pci/if_txp.c,v retrieving revision 1.73 diff -u -p -r1.73 if_txp.c --- dev/pci/if_txp.c 10 Mar 2020 01:23:42 -0000 1.73 +++ dev/pci/if_txp.c 15 Oct 2022 15:25:35 -0000 @@ -2077,12 +2077,12 @@ txp_capabilities(struct txp_softc *sc) sc->sc_tx_capability = ext->ext_1 & OFFLOAD_MASK; sc->sc_rx_capability = ext->ext_2 & OFFLOAD_MASK; - sc->sc_arpcom.ec_capabilities |= ETHERCAP_VLAN_MTU; + sc->sc_arpcom.ec_vlan.vc_capabilities |= VLANCAP_VLAN_MTU; if (rsp->rsp_par2 & rsp->rsp_par3 & OFFLOAD_VLAN) { sc->sc_tx_capability |= OFFLOAD_VLAN; sc->sc_rx_capability |= OFFLOAD_VLAN; - sc->sc_arpcom.ec_capabilities |= ETHERCAP_VLAN_HWTAGGING; - sc->sc_arpcom.ec_capenable |= ETHERCAP_VLAN_HWTAGGING; + sc->sc_arpcom.ec_vlan.vc_capabilities |= VLANCAP_HWTAGGING; + sc->sc_arpcom.ec_vlan.vc_capenable |= VLANCAP_HWTAGGING; } #if 0 Index: dev/pci/if_vge.c =================================================================== RCS file: /cvsroot/src/sys/dev/pci/if_vge.c,v retrieving revision 1.86 diff -u -p -r1.86 if_vge.c --- dev/pci/if_vge.c 24 Sep 2022 18:12:43 -0000 1.86 +++ dev/pci/if_vge.c 15 Oct 2022 15:25:35 -0000 @@ -1004,10 +1004,10 @@ vge_attach(device_t parent, device_t sel * We can support 802.1Q VLAN-sized frames and jumbo * Ethernet frames. */ - sc->sc_ethercom.ec_capabilities |= - ETHERCAP_VLAN_MTU | ETHERCAP_JUMBO_MTU | - ETHERCAP_VLAN_HWTAGGING; - sc->sc_ethercom.ec_capenable |= ETHERCAP_VLAN_HWTAGGING; + sc->sc_ethercom.ec_capabilities |= ETHERCAP_JUMBO_MTU; + sc->sc_ethercom.ec_vlan.vc_capabilities |= + VLANCAP_VLAN_MTU | VLANCAP_HWTAGGING; + sc->sc_ethercom.ec_vlan.vc_capenable |= VLANCAP_HWTAGGING; /* * We can do IPv4/TCPv4/UDPv4 checksums in hardware. Index: dev/pci/if_vioif.c =================================================================== RCS file: /cvsroot/src/sys/dev/pci/if_vioif.c,v retrieving revision 1.82 diff -u -p -r1.82 if_vioif.c --- dev/pci/if_vioif.c 12 Sep 2022 07:26:04 -0000 1.82 +++ dev/pci/if_vioif.c 15 Oct 2022 15:25:35 -0000 @@ -1050,7 +1050,7 @@ vioif_attach(device_t parent, device_t s IFQ_SET_MAXLEN(&ifp->if_snd, MAX(txq->txq_vq->vq_num, IFQ_MAXLEN)); IFQ_SET_READY(&ifp->if_snd); - sc->sc_ethercom.ec_capabilities |= ETHERCAP_VLAN_MTU; + sc->sc_ethercom.ec_vlan.vc_capabilities |= VLANCAP_VLAN_MTU; if_attach(ifp); if_deferred_start_init(ifp, NULL); Index: dev/pci/if_vmx.c =================================================================== RCS file: /cvsroot/src/sys/dev/pci/if_vmx.c,v retrieving revision 1.11 diff -u -p -r1.11 if_vmx.c --- dev/pci/if_vmx.c 16 Sep 2022 07:55:34 -0000 1.11 +++ dev/pci/if_vmx.c 15 Oct 2022 15:25:36 -0000 @@ -1754,7 +1754,7 @@ vmxnet3_reinit_shared_data(struct vmxnet (IFCAP_CSUM_IPv4_Rx | IFCAP_CSUM_TCPv4_Rx | IFCAP_CSUM_UDPv4_Rx | IFCAP_CSUM_TCPv6_Rx | IFCAP_CSUM_UDPv6_Rx)) ds->upt_features |= UPT1_F_CSUM; - if (sc->vmx_ethercom.ec_capenable & ETHERCAP_VLAN_HWTAGGING) + if (sc->vmx_ethercom.ec_vlan.vc_capenable & VLANCAP_HWTAGGING) ds->upt_features |= UPT1_F_VLAN; if (sc->vmx_flags & VMXNET3_FLAG_RSS) { @@ -1828,9 +1828,10 @@ vmxnet3_setup_interface(struct vmxnet3_s sc->vmx_ethercom.ec_if.if_capabilities |= IFCAP_TSOv4 | IFCAP_TSOv6; - sc->vmx_ethercom.ec_capabilities |= - ETHERCAP_VLAN_MTU | ETHERCAP_VLAN_HWTAGGING | ETHERCAP_JUMBO_MTU; - sc->vmx_ethercom.ec_capenable |= ETHERCAP_VLAN_HWTAGGING; + sc->vmx_ethercom.ec_capabilities |= ETHERCAP_JUMBO_MTU; + sc->vmx_ethercom.ec_vlan.vc_capabilities |= + VLANCAP_VLAN_MTU | VLANCAP_HWTAGGING; + sc->vmx_ethercom.ec_vlan.vc_capenable |= VLANCAP_HWTAGGING; IFQ_SET_MAXLEN(&ifp->if_snd, sc->vmx_ntxdescs); IFQ_SET_READY(&ifp->if_snd); Index: dev/pci/if_vr.c =================================================================== RCS file: /cvsroot/src/sys/dev/pci/if_vr.c,v retrieving revision 1.137 diff -u -p -r1.137 if_vr.c --- dev/pci/if_vr.c 24 Sep 2022 18:12:43 -0000 1.137 +++ dev/pci/if_vr.c 15 Oct 2022 15:25:36 -0000 @@ -1719,7 +1719,7 @@ vr_attach(device_t parent, device_t self } else ifmedia_set(&mii->mii_media, IFM_ETHER | IFM_AUTO); - sc->vr_ec.ec_capabilities |= ETHERCAP_VLAN_MTU; + sc->vr_ec.ec_vlan.vc_capabilities |= VLANCAP_VLAN_MTU; /* * Call MI attach routines. Index: dev/pci/if_wm.c =================================================================== RCS file: /cvsroot/src/sys/dev/pci/if_wm.c,v retrieving revision 1.764 diff -u -p -r1.764 if_wm.c --- dev/pci/if_wm.c 8 Sep 2022 02:40:10 -0000 1.764 +++ dev/pci/if_wm.c 15 Oct 2022 15:25:37 -0000 @@ -3137,9 +3137,9 @@ alloc_retry: /* If we're a i82543 or greater, we can support VLANs. */ if (sc->sc_type >= WM_T_82543) { - sc->sc_ethercom.ec_capabilities |= - ETHERCAP_VLAN_MTU | ETHERCAP_VLAN_HWTAGGING; - sc->sc_ethercom.ec_capenable |= ETHERCAP_VLAN_HWTAGGING; + sc->sc_ethercom.ec_vlan.vc_capabilities |= + VLANCAP_VLAN_MTU | VLANCAP_HWTAGGING; + sc->sc_ethercom.ec_vlan.vc_capenable |= VLANCAP_HWTAGGING; } if ((sc->sc_flags & WM_F_EEE) != 0) Index: dev/pci/if_xge.c =================================================================== RCS file: /cvsroot/src/sys/dev/pci/if_xge.c,v retrieving revision 1.35 diff -u -p -r1.35 if_xge.c --- dev/pci/if_xge.c 24 Sep 2022 18:12:43 -0000 1.35 +++ dev/pci/if_xge.c 15 Oct 2022 15:25:37 -0000 @@ -544,8 +544,8 @@ xge_attach(device_t parent, device_t sel /* * Offloading capabilities. */ - sc->sc_ethercom.ec_capabilities |= - ETHERCAP_JUMBO_MTU | ETHERCAP_VLAN_MTU; + sc->sc_ethercom.ec_capabilities |= ETHERCAP_JUMBO_MTU; + sc->sc_ethercom.ec_vlan.vc_capabilities |= VLANCAP_VLAN_MTU; ifp->if_capabilities |= IFCAP_CSUM_IPv4_Rx | IFCAP_CSUM_IPv4_Tx | IFCAP_CSUM_TCPv4_Rx | IFCAP_CSUM_TCPv4_Tx | Index: dev/pci/ixgbe/ixgbe.c =================================================================== RCS file: /cvsroot/src/sys/dev/pci/ixgbe/ixgbe.c,v retrieving revision 1.323 diff -u -p -r1.323 ixgbe.c --- dev/pci/ixgbe/ixgbe.c 6 Jul 2022 06:31:47 -0000 1.323 +++ dev/pci/ixgbe/ixgbe.c 15 Oct 2022 15:25:38 -0000 @@ -226,7 +226,7 @@ static void ixgbe_eitr_write(struct adap static void ixgbe_setup_vlan_hw_tagging(struct adapter *); static void ixgbe_setup_vlan_hw_support(struct adapter *); -static int ixgbe_vlan_cb(struct ethercom *, uint16_t, bool); +static int ixgbe_vlan_cb(struct ifnet *, struct vlancom *, uint16_t, bool); static int ixgbe_register_vlan(struct adapter *, u16); static int ixgbe_unregister_vlan(struct adapter *, u16); @@ -1417,13 +1417,13 @@ ixgbe_setup_interface(device_t dev, stru | IFCAP_TSOv6; ifp->if_capenable = 0; - ec->ec_capabilities |= ETHERCAP_VLAN_HWTAGGING - | ETHERCAP_VLAN_HWCSUM - | ETHERCAP_JUMBO_MTU - | ETHERCAP_VLAN_MTU; + ec->ec_capabilities |= ETHERCAP_JUMBO_MTU; + ec->ec_vlan.vc_capabilities |= VLANCAP_HWTAGGING + | VLANCAP_VLAN_MTU; /* Enable the above capabilities by default */ ec->ec_capenable = ec->ec_capabilities; + ec->ec_vlan.vc_capenable = ec->ec_vlan.vc_capabilities; /* * Don't turn this on by default, if vlans are @@ -1433,7 +1433,7 @@ ixgbe_setup_interface(device_t dev, stru * using vlans directly on the ixgbe driver you can * enable this and get full hardware tag filtering. */ - ec->ec_capabilities |= ETHERCAP_VLAN_HWFILTER; + ec->ec_vlan.vc_capabilities |= VLANCAP_HWFILTER; /* * Specify the media types supported by this adapter and register @@ -2391,9 +2391,8 @@ ixgbe_sysctl_rdt_handler(SYSCTLFN_ARGS) } /* ixgbe_sysctl_rdt_handler */ static int -ixgbe_vlan_cb(struct ethercom *ec, uint16_t vid, bool set) +ixgbe_vlan_cb(struct ifnet *ifp, struct vlancom *vc, uint16_t vid, bool set) { - struct ifnet *ifp = &ec->ec_if; struct adapter *adapter = ifp->if_softc; int rv; @@ -2409,7 +2408,8 @@ ixgbe_vlan_cb(struct ethercom *ec, uint1 * Control VLAN HW tagging when ec_nvlan is changed from 1 to 0 * or 0 to 1. */ - if ((set && (ec->ec_nvlans == 1)) || (!set && (ec->ec_nvlans == 0))) + if ((set && (vc->vc_nvlans == 1)) || + (!set && (vc->vc_nvlans == 0))) ixgbe_setup_vlan_hw_tagging(adapter); return rv; @@ -2483,7 +2483,7 @@ ixgbe_setup_vlan_hw_tagging(struct adapt bool hwtagging; /* Enable HW tagging only if any vlan is attached */ - hwtagging = (ec->ec_capenable & ETHERCAP_VLAN_HWTAGGING) + hwtagging = (ec->ec_vlan.vc_capenable & VLANCAP_HWTAGGING) && VLAN_ATTACHED(ec); /* Setup the queues for vlans */ @@ -2543,7 +2543,7 @@ ixgbe_setup_vlan_hw_support(struct adapt adapter->shadow_vfta[i] = 0; /* Generate shadow_vfta from ec_vids */ ETHER_LOCK(ec); - SIMPLEQ_FOREACH(vlanidp, &ec->ec_vids, vid_list) { + SIMPLEQ_FOREACH(vlanidp, &ec->ec_vlan.vc_vids, vid_list) { uint32_t idx; idx = vlanidp->vid / 32; @@ -2556,7 +2556,7 @@ ixgbe_setup_vlan_hw_support(struct adapt ctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL); /* Enable the Filter Table if enabled */ - if (ec->ec_capenable & ETHERCAP_VLAN_HWFILTER) + if (ec->ec_vlan.vc_capenable & VLANCAP_HWFILTER) ctrl |= IXGBE_VLNCTRL_VFE; else ctrl &= ~IXGBE_VLNCTRL_VFE; @@ -6455,10 +6455,9 @@ ixgbe_ifflags_cb(struct ethercom *ec) ixgbe_set_rxfilter(adapter); /* Check for ec_capenable. */ - change = ec->ec_capenable ^ adapter->ec_capenable; - adapter->ec_capenable = ec->ec_capenable; - if ((change & ~(ETHERCAP_VLAN_MTU | ETHERCAP_VLAN_HWTAGGING - | ETHERCAP_VLAN_HWFILTER)) != 0) { + change = ec->ec_vlan.vc_capenable ^ adapter->ec_capenable; + adapter->ec_capenable = ec->ec_vlan.vc_capenable; + if ((change & ~(VLANCAP_VLAN_MTU | VLANCAP_HWFILTER)) != 0) { rv = ENETRESET; goto out; } @@ -6469,7 +6468,7 @@ ixgbe_ifflags_cb(struct ethercom *ec) */ /* Set up VLAN support and filter */ - if ((change & (ETHERCAP_VLAN_HWTAGGING | ETHERCAP_VLAN_HWFILTER)) != 0) + if ((change & (VLANCAP_HWTAGGING | VLANCAP_HWFILTER)) != 0) ixgbe_setup_vlan_hw_support(adapter); out: Index: dev/pci/ixgbe/ixgbe_netbsd.h =================================================================== RCS file: /cvsroot/src/sys/dev/pci/ixgbe/ixgbe_netbsd.h,v retrieving revision 1.17 diff -u -p -r1.17 ixgbe_netbsd.h --- dev/pci/ixgbe/ixgbe_netbsd.h 16 Sep 2022 03:05:51 -0000 1.17 +++ dev/pci/ixgbe/ixgbe_netbsd.h 15 Oct 2022 15:25:38 -0000 @@ -39,7 +39,6 @@ #define IXGBE_LEGACY_TX 1 #endif -#define ETHERCAP_VLAN_HWCSUM 0 #define MJUM9BYTES (9 * 1024) #define MJUM16BYTES (16 * 1024) #define MJUMPAGESIZE PAGE_SIZE Index: dev/pci/ixgbe/ixv.c =================================================================== RCS file: /cvsroot/src/sys/dev/pci/ixgbe/ixv.c,v retrieving revision 1.183 diff -u -p -r1.183 ixv.c --- dev/pci/ixgbe/ixv.c 6 Jul 2022 06:31:47 -0000 1.183 +++ dev/pci/ixgbe/ixv.c 15 Oct 2022 15:25:38 -0000 @@ -126,7 +126,7 @@ static void ixv_eitr_write(struct adapte static void ixv_setup_vlan_tagging(struct adapter *); static int ixv_setup_vlan_support(struct adapter *); -static int ixv_vlan_cb(struct ethercom *, uint16_t, bool); +static int ixv_vlan_cb(struct ifnet *, struct vlancom *, uint16_t, bool); static int ixv_register_vlan(struct adapter *, u16); static int ixv_unregister_vlan(struct adapter *, u16); @@ -1673,11 +1673,10 @@ ixv_setup_interface(device_t dev, struct | IFCAP_TSOv6; ifp->if_capenable = 0; - ec->ec_capabilities |= ETHERCAP_VLAN_HWFILTER - | ETHERCAP_VLAN_HWTAGGING - | ETHERCAP_VLAN_HWCSUM - | ETHERCAP_JUMBO_MTU - | ETHERCAP_VLAN_MTU; + ec->ec_capabilities |= ETHERCAP_JUMBO_MTU; + ec->ec_vlan.vc_capabilities |= VLANCAP_HWFILTER + | VLANCAP_HWTAGGING + | VLANCAP_VLAN_MTU; /* Enable the above capabilities by default */ ec->ec_capenable = ec->ec_capabilities; @@ -2100,7 +2099,9 @@ ixv_sysctl_rdt_handler(SYSCTLFN_ARGS) static void ixv_setup_vlan_tagging(struct adapter *adapter) { +#if !__NetBSD__ struct ethercom *ec = &adapter->osdep.ec; +#endif struct ixgbe_hw *hw = &adapter->hw; struct rx_ring *rxr; u32 ctrl; @@ -2108,8 +2109,12 @@ ixv_setup_vlan_tagging(struct adapter *a bool hwtagging; /* Enable HW tagging only if any vlan is attached */ +#if __NetBSD__ + hwtagging = false; +#else hwtagging = (ec->ec_capenable & ETHERCAP_VLAN_HWTAGGING) && VLAN_ATTACHED(ec); +#endif /* Enable the queues */ for (i = 0; i < adapter->num_queues; i++) { @@ -2163,7 +2168,7 @@ ixv_setup_vlan_support(struct adapter *a adapter->shadow_vfta[i] = 0; /* Generate shadow_vfta from ec_vids */ ETHER_LOCK(ec); - SIMPLEQ_FOREACH(vlanidp, &ec->ec_vids, vid_list) { + SIMPLEQ_FOREACH(vlanidp, &ec->ec_vlan.vc_vids, vid_list) { uint32_t idx; idx = vlanidp->vid / 32; @@ -2212,9 +2217,8 @@ ixv_setup_vlan_support(struct adapter *a } /* ixv_setup_vlan_support */ static int -ixv_vlan_cb(struct ethercom *ec, uint16_t vid, bool set) +ixv_vlan_cb(struct ifnet *ifp, struct vlancom *vc, uint16_t vid, bool set) { - struct ifnet *ifp = &ec->ec_if; struct adapter *adapter = ifp->if_softc; int rv; @@ -2230,7 +2234,7 @@ ixv_vlan_cb(struct ethercom *ec, uint16_ * Control VLAN HW tagging when ec_nvlan is changed from 1 to 0 * or 0 to 1. */ - if ((set && (ec->ec_nvlans == 1)) || (!set && (ec->ec_nvlans == 0))) + if ((set && (vc->vc_nvlans == 1)) || (!set && (vc->vc_nvlans == 0))) ixv_setup_vlan_tagging(adapter); return rv; @@ -3107,10 +3111,9 @@ ixv_ifflags_cb(struct ethercom *ec) } /* Check for ec_capenable. */ - change = ec->ec_capenable ^ adapter->ec_capenable; - adapter->ec_capenable = ec->ec_capenable; - if ((change & ~(ETHERCAP_VLAN_MTU | ETHERCAP_VLAN_HWTAGGING - | ETHERCAP_VLAN_HWFILTER)) != 0) { + change = ec->ec_vlan.vc_capenable ^ adapter->ec_capenable; + adapter->ec_capenable = ec->ec_vlan.vc_capenable; + if ((change & ~(VLANCAP_VLAN_MTU | VLANCAP_HWFILTER)) != 0) { rv = ENETRESET; goto out; } @@ -3121,7 +3124,7 @@ ixv_ifflags_cb(struct ethercom *ec) */ /* Set up VLAN support and filter */ - if ((change & (ETHERCAP_VLAN_HWTAGGING | ETHERCAP_VLAN_HWFILTER)) != 0) + if ((change & VLANCAP_HWFILTER) != 0) rv = ixv_setup_vlan_support(adapter); out: Index: dev/pcmcia/if_xi.c =================================================================== RCS file: /cvsroot/src/sys/dev/pcmcia/if_xi.c,v retrieving revision 1.96 diff -u -p -r1.96 if_xi.c --- dev/pcmcia/if_xi.c 25 Sep 2022 21:53:54 -0000 1.96 +++ dev/pcmcia/if_xi.c 15 Oct 2022 15:25:38 -0000 @@ -214,7 +214,7 @@ xi_attach(struct xi_softc *sc, uint8_t * IFQ_SET_READY(&ifp->if_snd); /* 802.1q capability */ - sc->sc_ethercom.ec_capabilities |= ETHERCAP_VLAN_MTU; + sc->sc_ethercom.ec_vlan.vc_capabilities |= VLANCAP_VLAN_MTU; /* Attach the interface. */ if_attach(ifp); Index: dev/usb/if_axe.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/if_axe.c,v retrieving revision 1.151 diff -u -p -r1.151 if_axe.c --- dev/usb/if_axe.c 20 Aug 2022 14:08:59 -0000 1.151 +++ dev/usb/if_axe.c 15 Oct 2022 15:25:38 -0000 @@ -964,7 +964,7 @@ axe_attach(device_t parent, device_t sel } if (!AXE_IS_172(un)) - usbnet_ec(un)->ec_capabilities = ETHERCAP_VLAN_MTU; + usbnet_ec(un)->ec_vlan.vc_capabilities = VLANCAP_VLAN_MTU; if (un->un_flags & AX772B) { struct ifnet *ifp = usbnet_ifp(un); Index: dev/usb/if_axen.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/if_axen.c,v retrieving revision 1.94 diff -u -p -r1.94 if_axen.c --- dev/usb/if_axen.c 20 Aug 2022 14:08:59 -0000 1.94 +++ dev/usb/if_axen.c 15 Oct 2022 15:25:38 -0000 @@ -672,7 +672,7 @@ axen_attach(device_t parent, device_t se aprint_normal_dev(self, "(unknown)\n"); struct ethercom *ec = usbnet_ec(un); - ec->ec_capabilities = ETHERCAP_VLAN_MTU; + ec->ec_vlan.vc_capabilities = VLANCAP_VLAN_MTU; /* Adapter does not support TSOv6 (They call it LSOv2). */ struct ifnet *ifp = usbnet_ifp(un); Index: dev/usb/if_mos.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/if_mos.c,v retrieving revision 1.24 diff -u -p -r1.24 if_mos.c --- dev/usb/if_mos.c 10 Oct 2022 18:30:28 -0000 1.24 +++ dev/usb/if_mos.c 15 Oct 2022 15:25:38 -0000 @@ -653,7 +653,7 @@ mos_attach(device_t parent, device_t sel } struct ethercom *ec = usbnet_ec(un); - ec->ec_capabilities = ETHERCAP_VLAN_MTU; + ec->ec_vlan.vc_capabilities = VLANCAP_VLAN_MTU; usbnet_attach_ifp(un, IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST, 0, &unm); Index: dev/usb/if_mue.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/if_mue.c,v retrieving revision 1.82 diff -u -p -r1.82 if_mue.c --- dev/usb/if_mue.c 20 Aug 2022 14:08:59 -0000 1.82 +++ dev/usb/if_mue.c 15 Oct 2022 15:25:39 -0000 @@ -886,7 +886,7 @@ mue_attach(device_t parent, device_t sel IFCAP_CSUM_UDPv6_Tx | IFCAP_CSUM_UDPv6_Rx; struct ethercom *ec = usbnet_ec(un); - ec->ec_capabilities = ETHERCAP_VLAN_MTU; + ec->ec_vlan.vc_capabilities = VLANCAP_VLAN_MTU; #if 0 /* XXX not yet */ ec->ec_capabilities = ETHERCAP_VLAN_MTU | ETHERCAP_JUMBO_MTU; #endif Index: dev/usb/if_smsc.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/if_smsc.c,v retrieving revision 1.93 diff -u -p -r1.93 if_smsc.c --- dev/usb/if_smsc.c 20 Aug 2022 14:08:59 -0000 1.93 +++ dev/usb/if_smsc.c 15 Oct 2022 15:25:39 -0000 @@ -839,7 +839,7 @@ smsc_attach(device_t parent, device_t se /*IFCAP_CSUM_UDPv4_Tx |*/ IFCAP_CSUM_UDPv4_Rx; #endif struct ethercom *ec = usbnet_ec(un); - ec->ec_capabilities = ETHERCAP_VLAN_MTU; + ec->ec_vlan.vc_capabilities = VLANCAP_VLAN_MTU; /* Setup some of the basics */ un->un_phyno = 1; Index: dev/usb/if_ure.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/if_ure.c,v retrieving revision 1.58 diff -u -p -r1.58 if_ure.c --- dev/usb/if_ure.c 16 Sep 2022 07:34:36 -0000 1.58 +++ dev/usb/if_ure.c 15 Oct 2022 15:25:39 -0000 @@ -929,7 +929,7 @@ ure_attach(device_t parent, device_t sel IFCAP_CSUM_TCPv6_Rx | IFCAP_CSUM_UDPv6_Rx; } struct ethercom *ec = usbnet_ec(un); - ec->ec_capabilities = ETHERCAP_VLAN_MTU; + ec->ec_vlan.vc_capabilities = VLANCAP_VLAN_MTU; #ifdef notyet ec->ec_capabilities |= ETHERCAP_JUMBO_MTU; #endif Index: net/if.c =================================================================== RCS file: /cvsroot/src/sys/net/if.c,v retrieving revision 1.526 diff -u -p -r1.526 if.c --- net/if.c 20 Sep 2022 02:23:37 -0000 1.526 +++ net/if.c 15 Oct 2022 15:25:40 -0000 @@ -2811,9 +2811,10 @@ ifpromisc(struct ifnet *ifp, int pswitch * Apply an ioctl command to the interface. Returns 0 on success, * nonzero errno(3) number on failure. * - * For SIOCADDMULTI/SIOCDELMULTI, caller need not hold locks -- it - * is the driver's responsibility to take any internal locks. - * (Kernel logic should generally invoke these only through + * For SIOCADDMULTI, SIOCDELMULTI and SIOCGETVLANCOM, caller need not + * hold locks - it is the driver's responsibility to take any internal + * locks. + * (Kernel logic should generally invoke the first two only through * if_mcast_op.) * * For all other ioctls, caller must hold ifp->if_ioctl_lock, @@ -2826,6 +2827,7 @@ if_ioctl(struct ifnet *ifp, u_long cmd, switch (cmd) { case SIOCADDMULTI: case SIOCDELMULTI: + case SIOCGETVLANCOM: break; default: KASSERTMSG(IFNET_LOCKED(ifp), "%s", ifp->if_xname); @@ -3983,6 +3985,22 @@ if_mcast_op(ifnet_t *ifp, const unsigned return rc; } +/* + * if_get_vlancom(ifp) - returns the vlancom structure if the interface + * supports vlan(4). + */ +struct vlancom * +if_get_vlancom(ifnet_t *ifp) +{ + struct ifrvlan r; + + memset(&r, 0, sizeof(r)); + if (if_ioctl(ifp, SIOCGETVLANCOM, &r) != 0) + return NULL; + + return r.ifv_vc; +} + static void sysctl_sndq_setup(struct sysctllog **clog, const char *ifname, struct ifaltq *ifq) Index: net/if.h =================================================================== RCS file: /cvsroot/src/sys/net/if.h,v retrieving revision 1.302 diff -u -p -r1.302 if.h --- net/if.h 18 Sep 2022 16:58:54 -0000 1.302 +++ net/if.h 15 Oct 2022 15:25:40 -0000 @@ -819,6 +819,14 @@ struct if_announcemsghdr { #undef __align64 /* + * Structure used for in-kernel ioctl operations to fetch struct vlancom + * from interfaces. + */ +struct ifrvlan { + struct vlancom *ifv_vc; +}; + +/* * Interface request structure used for socket * ioctl's. All interface ioctl's must have parameter * definitions which begin with ifr_name. The @@ -1131,6 +1139,10 @@ int if_mcast_op(ifnet_t *, const unsigne int if_flags_set(struct ifnet *, const u_short); int if_clone_list(int, char *, int *); +struct vlancom; +struct vlancom *if_get_vlancom(ifnet_t *); +int if_vlan_caps_changed(ifnet_t *); + int if_ioctl(struct ifnet *, u_long, void *); int if_init(struct ifnet *); void if_stop(struct ifnet *, int); Index: net/if_ether.h =================================================================== RCS file: /cvsroot/src/sys/net/if_ether.h,v retrieving revision 1.89 diff -u -p -r1.89 if_ether.h --- net/if_ether.h 20 Jun 2022 08:14:48 -0000 1.89 +++ net/if_ether.h 15 Oct 2022 15:25:40 -0000 @@ -161,9 +161,37 @@ do { \ struct mii_data; struct ethercom; +struct vlancom; typedef int (*ether_cb_t)(struct ethercom *); -typedef int (*ether_vlancb_t)(struct ethercom *, uint16_t, bool); +typedef int (*vlan_cb_t)(struct ifnet *, struct vlancom *, uint16_t, bool); + +/* + * Structure shared between all interfaces that support vlans + * and the generic vlan code. + */ +struct vlancom { + int vc_nvlans; /* # VLANs on this interface */ + SIMPLEQ_HEAD(, vlanid_list) vc_vids; /* list of VLAN IDs */ + int vc_capabilities; /* capabilities, provided by + driver */ + int vc_capenable; /* tells hardware which + capabilities to enable */ + /* + * Called whenever a vlan interface is configured or unconfigured. + * Args include the vlan tag and a flag indicating whether the tag is + * being added or removed. + */ + vlan_cb_t vc_vlan_cb; + /* + * if this struct is part of ethercom, the lock is shared + */ + kmutex_t *vc_lock; +}; + +#define VLANCAP_VLAN_MTU 0x00000001 /* VLAN-compatible MTU */ +#define VLANCAP_HWTAGGING 0x00000002 /* hardware VLAN tag support */ +#define VLANCAP_HWFILTER 0x00000004 /* iface hw can filter vlan tag */ /* * Structure shared between the ethernet driver modules and @@ -181,8 +209,8 @@ struct ethercom { int ec_capenable; /* tells hardware which capabilities to enable */ - int ec_nvlans; /* # VLANs on this interface */ - SIMPLEQ_HEAD(, vlanid_list) ec_vids; /* list of VLAN IDs */ + struct vlancom ec_vlan; + /* The device handle for the MII bus child device. */ struct mii_data *ec_mii; struct ifmedia *ec_ifmedia; @@ -192,12 +220,6 @@ struct ethercom { * ec_if.if_init, 0 on success, not 0 on failure. */ ether_cb_t ec_ifflags_cb; - /* - * Called whenever a vlan interface is configured or unconfigured. - * Args include the vlan tag and a flag indicating whether the tag is - * being added or removed. - */ - ether_vlancb_t ec_vlan_cb; /* Hooks called at the beginning of detach of this interface */ khook_list_t *ec_ifdetach_hooks; kmutex_t *ec_lock; @@ -209,13 +231,11 @@ struct ethercom { #endif }; -#define ETHERCAP_VLAN_MTU 0x00000001 /* VLAN-compatible MTU */ -#define ETHERCAP_VLAN_HWTAGGING 0x00000002 /* hardware VLAN tag support */ -#define ETHERCAP_JUMBO_MTU 0x00000004 /* 9000 byte MTU supported */ -#define ETHERCAP_VLAN_HWFILTER 0x00000008 /* iface hw can filter vlan tag */ -#define ETHERCAP_EEE 0x00000010 /* Energy Efficiency Ethernet */ -#define ETHERCAP_MASK 0x0000001f +#define ETHERCAP_JUMBO_MTU 0x00000001 /* 9000 byte MTU supported */ +#define ETHERCAP_EEE 0x00000002 /* Energy Efficiency Ethernet */ +#define ETHERCAP_MASK 0x00000003 +/* vlan and ether capabiliites when queried/set from userland */ #define ECCAPBITS \ "\020" \ "\1VLAN_MTU" \ @@ -224,6 +244,12 @@ struct ethercom { "\4VLAN_HWFILTER" \ "\5EEE" +#define ECCAPBITS_VLAN_MTU 0x01 +#define ECCAPBITS_VLAN_HWTAGGING 0x02 +#define ECCAPBITS_JUMBO_MTU 0x04 +#define ECCAPBITS_VLAN_HWFILTER 0x08 +#define ECCAPBITS_EEE 0x10 + /* ioctl() for Ethernet capabilities */ struct eccapreq { char eccr_name[IFNAMSIZ]; /* if name, e.g. "en0" */ @@ -251,7 +277,7 @@ extern const uint8_t ether_ipmulticast_m extern const uint8_t ether_ipmulticast_max[ETHER_ADDR_LEN]; void ether_set_ifflags_cb(struct ethercom *, ether_cb_t); -void ether_set_vlan_cb(struct ethercom *, ether_vlancb_t); +void ether_set_vlan_cb(struct ethercom *, vlan_cb_t); int ether_ioctl(struct ifnet *, u_long, void *); int ether_addmulti(const struct sockaddr *, struct ethercom *); int ether_delmulti(const struct sockaddr *, struct ethercom *); @@ -343,6 +369,9 @@ ether_first_multi(struct ether_multistep #define ETHER_LOCK(ec) mutex_enter((ec)->ec_lock) #define ETHER_UNLOCK(ec) mutex_exit((ec)->ec_lock) +#define VLAN_LOCK(vc) mutex_enter((vc)->vc_lock) +#define VLAN_UNLOCK(vc) mutex_exit((vc)->vc_lock) + /* * Ethernet 802.1Q VLAN structures. */ @@ -382,16 +411,16 @@ vlan_has_tag(struct mbuf *m) static __inline bool vlan_is_hwtag_enabled(struct ifnet *_ifp) { - struct ethercom *ec = (void *)_ifp; + struct vlancom *vc = if_get_vlancom(_ifp); - if (ec->ec_capenable & ETHERCAP_VLAN_HWTAGGING) + if (vc->vc_capenable & VLANCAP_HWTAGGING) return true; return false; } /* test if any VLAN is configured for this interface */ -#define VLAN_ATTACHED(ec) ((ec)->ec_nvlans > 0) +#define VLAN_ATTACHED(ec) ((ec)->ec_vlan.vc_nvlans > 0) void etherinit(void); void ether_ifattach(struct ifnet *, const uint8_t *); @@ -417,6 +446,7 @@ int ether_del_vlantag(struct ifnet *, ui int ether_inject_vlantag(struct mbuf **, uint16_t, uint16_t); struct mbuf * ether_strip_vlantag(struct mbuf *); +int ether_eccapreq_from_caps(int, int); #else /* * Prototype ethers(3) functions. Index: net/if_ethersubr.c =================================================================== RCS file: /cvsroot/src/sys/net/if_ethersubr.c,v retrieving revision 1.320 diff -u -p -r1.320 if_ethersubr.c --- net/if_ethersubr.c 3 Sep 2022 02:47:59 -0000 1.320 +++ net/if_ethersubr.c 15 Oct 2022 15:25:40 -0000 @@ -788,7 +788,7 @@ ether_input(struct ifnet *ifp, struct mb m->m_flags &= ~M_VLANTAG; } else { #if NVLAN > 0 - if (ec->ec_nvlans > 0) { + if (ec->ec_vlan.vc_nvlans > 0) { m = vlan_input(ifp, m); /* vlan_input() called ether_input() recursively */ @@ -1042,8 +1042,9 @@ ether_ifattach(struct ifnet *ifp, const if_set_sadl(ifp, lla, ETHER_ADDR_LEN, !ETHER_IS_LOCAL(lla)); LIST_INIT(&ec->ec_multiaddrs); - SIMPLEQ_INIT(&ec->ec_vids); - ec->ec_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_NET); + SIMPLEQ_INIT(&ec->ec_vlan.vc_vids); + ec->ec_vlan.vc_lock = ec->ec_lock = + mutex_obj_alloc(MUTEX_DEFAULT, IPL_NET); ec->ec_flags = 0; ifp->if_broadcastaddr = etherbroadcastaddr; bpf_attach(ifp, DLT_EN10MB, sizeof(struct ether_header)); @@ -1083,7 +1084,7 @@ ether_ifdetach(struct ifnet *ifp) bpf_detach(ifp); ETHER_LOCK(ec); - KASSERT(ec->ec_nvlans == 0); + KASSERT(ec->ec_vlan.vc_nvlans == 0); while ((enm = LIST_FIRST(&ec->ec_multiaddrs)) != NULL) { LIST_REMOVE(enm, enm_list); kmem_free(enm, sizeof(*enm)); @@ -1092,7 +1093,7 @@ ether_ifdetach(struct ifnet *ifp) ETHER_UNLOCK(ec); mutex_obj_free(ec->ec_lock); - ec->ec_lock = NULL; + ec->ec_vlan.vc_lock = ec->ec_lock = NULL; ifp->if_mowner = NULL; MOWNER_DETACH(&ec->ec_rx_mowner); @@ -1445,10 +1446,10 @@ ether_set_ifflags_cb(struct ethercom *ec } void -ether_set_vlan_cb(struct ethercom *ec, ether_vlancb_t cb) +ether_set_vlan_cb(struct ethercom *ec, vlan_cb_t cb) { - ec->ec_vlan_cb = cb; + ec->ec_vlan.vc_vlan_cb = cb; } static int @@ -1495,6 +1496,50 @@ ether_ioctl_reinit(struct ethercom *ec) return 0; } +static int +ethercaps_from_eccapreq(int v) +{ + int res = 0; + + if (v & ETHERCAP_JUMBO_MTU) + res |= ETHERCAP_JUMBO_MTU; + if (v & ECCAPBITS_EEE) + res |= ETHERCAP_EEE; + return res; +} + +static int +vlancaps_from_eccapreq(int v) +{ + int res = 0; + + if (v & ECCAPBITS_VLAN_MTU) + res |= VLANCAP_VLAN_MTU; + if (v & ECCAPBITS_VLAN_HWTAGGING) + res |= VLANCAP_HWTAGGING; + if (v & ECCAPBITS_VLAN_HWFILTER) + res |= VLANCAP_HWFILTER; + return res; +} + +int +ether_eccapreq_from_caps(int ether_caps, int vlan_caps) +{ + int res = 0; + + if (vlan_caps & VLANCAP_VLAN_MTU) + res |= ECCAPBITS_VLAN_MTU; + if (vlan_caps & VLANCAP_HWTAGGING) + res |= ECCAPBITS_VLAN_HWTAGGING; + if (vlan_caps & VLANCAP_HWFILTER) + res |= ECCAPBITS_VLAN_HWFILTER; + if (ether_caps & ETHERCAP_JUMBO_MTU) + res |= ECCAPBITS_JUMBO_MTU; + if (ether_caps & ETHERCAP_EEE) + res |= ECCAPBITS_EEE; + return res; +} + /* * Common ioctls for Ethernet interfaces. Note, we must be * called at splnet(). @@ -1504,11 +1549,12 @@ ether_ioctl(struct ifnet *ifp, u_long cm { struct ethercom *ec = (void *)ifp; struct eccapreq *eccr; + struct ifrvlan *ifrvl; struct ifreq *ifr = (struct ifreq *)data; struct if_laddrreq *iflr = data; const struct sockaddr_dl *sdl; static const uint8_t zero[ETHER_ADDR_LEN]; - int error; + int error, capabilities; switch (cmd) { case SIOCINITIFADDR: @@ -1560,22 +1606,39 @@ ether_ioctl(struct ifnet *ifp, u_long cm IFF_ALLMULTI : 0; } return error; + case SIOCGETVLANCOM: + ifrvl = (struct ifrvlan*)data; + if (0 == 0) { // XXX how to check? + /* this ioctl is in-kernel only */ + ifrvl->ifv_vc = &ec->ec_vlan; + return 0; + } + return EINVAL; case SIOCGETHERCAP: eccr = (struct eccapreq *)data; - eccr->eccr_capabilities = ec->ec_capabilities; - eccr->eccr_capenable = ec->ec_capenable; + eccr->eccr_capabilities = ether_eccapreq_from_caps( + ec->ec_capabilities, ec->ec_vlan.vc_capabilities); + eccr->eccr_capenable = ether_eccapreq_from_caps( + ec->ec_capenable, ec->ec_vlan.vc_capenable); return 0; case SIOCSETHERCAP: eccr = (struct eccapreq *)data; - if ((eccr->eccr_capenable & ~ec->ec_capabilities) != 0) + capabilities = ether_eccapreq_from_caps(ec->ec_capabilities, + ec->ec_vlan.vc_capabilities); + if ((eccr->eccr_capenable & ~capabilities) != 0) return EINVAL; - if (eccr->eccr_capenable == ec->ec_capenable) + capabilities = ether_eccapreq_from_caps(ec->ec_capenable, + ec->ec_vlan.vc_capenable); + if (eccr->eccr_capenable == capabilities) return 0; #if 0 /* notyet */ ec->ec_capenable = (ec->ec_capenable & ETHERCAP_CANTCHANGE) | (eccr->eccr_capenable & ~ETHERCAP_CANTCHANGE); #else - ec->ec_capenable = eccr->eccr_capenable; + ec->ec_capenable = ethercaps_from_eccapreq( + eccr->eccr_capenable); + ec->ec_vlan.vc_capenable = vlancaps_from_eccapreq( + eccr->eccr_capenable); #endif return ether_ioctl_reinit(ec); case SIOCADDMULTI: @@ -1618,10 +1681,13 @@ int ether_enable_vlan_mtu(struct ifnet *ifp) { int error; - struct ethercom *ec = (void *)ifp; + struct vlancom *vc = if_get_vlancom(ifp); + + if (vc == NULL) + return ENOTTY; /* Parent does not support VLAN's */ - if ((ec->ec_capabilities & ETHERCAP_VLAN_MTU) == 0) + if ((vc->vc_capabilities & VLANCAP_VLAN_MTU) == 0) return -1; /* @@ -1629,7 +1695,7 @@ ether_enable_vlan_mtu(struct ifnet *ifp) * i.e. can Tx/Rx larger than ETHER_MAX_LEN frames; * enable it. */ - ec->ec_capenable |= ETHERCAP_VLAN_MTU; + vc->vc_capenable |= VLANCAP_VLAN_MTU; /* Interface is down, defer for later */ if ((ifp->if_flags & IFF_UP) == 0) @@ -1638,7 +1704,7 @@ ether_enable_vlan_mtu(struct ifnet *ifp) if ((error = if_flags_set(ifp, ifp->if_flags)) == 0) return 0; - ec->ec_capenable &= ~ETHERCAP_VLAN_MTU; + vc->vc_capenable &= ~VLANCAP_VLAN_MTU; return error; } @@ -1646,20 +1712,23 @@ int ether_disable_vlan_mtu(struct ifnet *ifp) { int error; - struct ethercom *ec = (void *)ifp; + struct vlancom *vc = if_get_vlancom(ifp); + + if (vc == NULL) + return ENOTTY; /* We still have VLAN's, defer for later */ - if (ec->ec_nvlans != 0) + if (vc->vc_nvlans != 0) return 0; /* Parent does not support VLAB's, nothing to do. */ - if ((ec->ec_capenable & ETHERCAP_VLAN_MTU) == 0) + if ((vc->vc_capenable & VLANCAP_VLAN_MTU) == 0) return -1; /* * Disable Tx/Rx of VLAN-sized frames. */ - ec->ec_capenable &= ~ETHERCAP_VLAN_MTU; + vc->vc_capenable &= ~VLANCAP_VLAN_MTU; /* Interface is down, defer for later */ if ((ifp->if_flags & IFF_UP) == 0) @@ -1668,7 +1737,7 @@ ether_disable_vlan_mtu(struct ifnet *ifp if ((error = if_flags_set(ifp, ifp->if_flags)) == 0) return 0; - ec->ec_capenable |= ETHERCAP_VLAN_MTU; + vc->vc_capenable |= VLANCAP_VLAN_MTU; return error; } @@ -1678,24 +1747,27 @@ ether_disable_vlan_mtu(struct ifnet *ifp int ether_add_vlantag(struct ifnet *ifp, uint16_t vtag, bool *vlanmtu_status) { - struct ethercom *ec = (void *)ifp; + struct vlancom *vc = if_get_vlancom(ifp); struct vlanid_list *vidp; bool vlanmtu_enabled; uint16_t vid = EVL_VLANOFTAG(vtag); int error; + if (vc == NULL) + return ENOTTY; + vlanmtu_enabled = false; /* Add a vid to the list */ vidp = kmem_alloc(sizeof(*vidp), KM_SLEEP); vidp->vid = vid; - ETHER_LOCK(ec); - ec->ec_nvlans++; - SIMPLEQ_INSERT_TAIL(&ec->ec_vids, vidp, vid_list); - ETHER_UNLOCK(ec); + VLAN_LOCK(vc); + vc->vc_nvlans++; + SIMPLEQ_INSERT_TAIL(&vc->vc_vids, vidp, vid_list); + VLAN_UNLOCK(vc); - if (ec->ec_nvlans == 1) { + if (vc->vc_nvlans == 1) { IFNET_LOCK(ifp); error = ether_enable_vlan_mtu(ifp); IFNET_UNLOCK(ifp); @@ -1707,8 +1779,8 @@ ether_add_vlantag(struct ifnet *ifp, uin } } - if (ec->ec_vlan_cb != NULL) { - error = (*ec->ec_vlan_cb)(ec, vid, true); + if (vc->vc_vlan_cb != NULL) { + error = (*vc->vc_vlan_cb)(ifp, vc, vid, true); if (error != 0) goto fail; } @@ -1718,10 +1790,10 @@ ether_add_vlantag(struct ifnet *ifp, uin return 0; fail: - ETHER_LOCK(ec); - ec->ec_nvlans--; - SIMPLEQ_REMOVE(&ec->ec_vids, vidp, vlanid_list, vid_list); - ETHER_UNLOCK(ec); + VLAN_LOCK(vc); + vc->vc_nvlans--; + SIMPLEQ_REMOVE(&vc->vc_vids, vidp, vlanid_list, vid_list); + VLAN_UNLOCK(vc); if (vlanmtu_enabled) { IFNET_LOCK(ifp); @@ -1737,29 +1809,32 @@ fail: int ether_del_vlantag(struct ifnet *ifp, uint16_t vtag) { - struct ethercom *ec = (void *)ifp; + struct vlancom *vc = if_get_vlancom(ifp); struct vlanid_list *vidp; uint16_t vid = EVL_VLANOFTAG(vtag); - ETHER_LOCK(ec); - SIMPLEQ_FOREACH(vidp, &ec->ec_vids, vid_list) { + if (vc == NULL) + return ENOTTY; + + VLAN_LOCK(vc); + SIMPLEQ_FOREACH(vidp, &vc->vc_vids, vid_list) { if (vidp->vid == vid) { - SIMPLEQ_REMOVE(&ec->ec_vids, vidp, + SIMPLEQ_REMOVE(&vc->vc_vids, vidp, vlanid_list, vid_list); - ec->ec_nvlans--; + vc->vc_nvlans--; break; } } - ETHER_UNLOCK(ec); + VLAN_UNLOCK(vc); if (vidp == NULL) return ENOENT; - if (ec->ec_vlan_cb != NULL) { - (void)(*ec->ec_vlan_cb)(ec, vidp->vid, false); + if (vc->vc_vlan_cb != NULL) { + (void)(*vc->vc_vlan_cb)(ifp, vc, vidp->vid, false); } - if (ec->ec_nvlans == 0) { + if (vc->vc_nvlans == 0) { IFNET_LOCK(ifp); (void)ether_disable_vlan_mtu(ifp); IFNET_UNLOCK(ifp); Index: net/if_tap.c =================================================================== RCS file: /cvsroot/src/sys/net/if_tap.c,v retrieving revision 1.127 diff -u -p -r1.127 if_tap.c --- net/if_tap.c 10 Apr 2022 09:50:46 -0000 1.127 +++ net/if_tap.c 15 Oct 2022 15:25:41 -0000 @@ -334,7 +334,8 @@ tap_attach(device_t parent, device_t sel ifp->if_init = tap_init; IFQ_SET_READY(&ifp->if_snd); - sc->sc_ec.ec_capabilities = ETHERCAP_VLAN_MTU | ETHERCAP_JUMBO_MTU; + sc->sc_ec.ec_capabilities = ETHERCAP_JUMBO_MTU; + sc->sc_ec.ec_vlan.vc_capabilities = VLANCAP_VLAN_MTU; /* Those steps are mandatory for an Ethernet driver. */ if_initialize(ifp); Index: net/if_vether.c =================================================================== RCS file: /cvsroot/src/sys/net/if_vether.c,v retrieving revision 1.1 diff -u -p -r1.1 if_vether.c --- net/if_vether.c 27 Sep 2020 13:31:04 -0000 1.1 +++ net/if_vether.c 15 Oct 2022 15:25:41 -0000 @@ -75,7 +75,8 @@ vether_clone_create(struct if_clone *ifc IFQ_SET_MAXLEN(&ifp->if_snd, IFQ_MAXLEN); IFQ_SET_READY(&ifp->if_snd); - sc->sc_ec.ec_capabilities = ETHERCAP_VLAN_MTU | ETHERCAP_JUMBO_MTU; + sc->sc_ec.ec_capabilities = ETHERCAP_JUMBO_MTU; + sc->sc_ec.ec_vlan.vc_capabilities = VLANCAP_VLAN_MTU; /* * In order to obtain unique initial Ethernet address on a host, Index: net/if_vlan.c =================================================================== RCS file: /cvsroot/src/sys/net/if_vlan.c,v retrieving revision 1.170 diff -u -p -r1.170 if_vlan.c --- net/if_vlan.c 20 Jun 2022 08:14:48 -0000 1.170 +++ net/if_vlan.c 15 Oct 2022 15:25:41 -0000 @@ -429,7 +429,9 @@ vlan_config(struct ifvlan *ifv, struct i switch (p->if_type) { case IFT_ETHER: { - struct ethercom *ec = (void *)p; + struct vlancom *vc; + + vc = if_get_vlancom(p); nmib->ifvm_msw = &vlan_ether_multisw; nmib->ifvm_mintu = ETHERMIN; @@ -438,7 +440,7 @@ vlan_config(struct ifvlan *ifv, struct i if (error != 0) goto done; - if (ec->ec_capenable & ETHERCAP_VLAN_MTU) { + if (vc->vc_capenable & VLANCAP_VLAN_MTU) { nmib->ifvm_mtufudge = 0; } else { /* @@ -457,7 +459,7 @@ vlan_config(struct ifvlan *ifv, struct i * assisted checksumming flags and tcp segmentation * offload. */ - if (ec->ec_capabilities & ETHERCAP_VLAN_HWTAGGING) { + if (vc->vc_capabilities & VLANCAP_HWTAGGING) { ifp->if_capabilities = p->if_capabilities & (IFCAP_TSOv4 | IFCAP_TSOv6 | IFCAP_CSUM_IPv4_Tx | IFCAP_CSUM_IPv4_Rx | @@ -1195,7 +1197,7 @@ vlan_start(struct ifnet *ifp) { struct ifvlan *ifv = ifp->if_softc; struct ifnet *p; - struct ethercom *ec; + struct vlancom *vc; struct mbuf *m; struct ifvlan_linkmib *mib; struct psref psref; @@ -1216,7 +1218,7 @@ vlan_start(struct ifnet *ifp) } p = mib->ifvm_p; - ec = (void *)mib->ifvm_p; + vc = if_get_vlancom(mib->ifvm_p); ifp->if_flags |= IFF_OACTIVE; @@ -1269,7 +1271,7 @@ vlan_start(struct ifnet *ifp) * If the parent can insert the tag itself, just mark * the tag in the mbuf header. */ - if (ec->ec_capenable & ETHERCAP_VLAN_HWTAGGING) { + if (vc->vc_capenable & VLANCAP_HWTAGGING) { vlan_set_tag(m, mib->ifvm_tag); } else { /* @@ -1318,7 +1320,7 @@ vlan_transmit(struct ifnet *ifp, struct { struct ifvlan *ifv = ifp->if_softc; struct ifnet *p; - struct ethercom *ec; + struct vlancom *vc; struct ifvlan_linkmib *mib; struct psref psref; struct ether_header *eh; @@ -1357,7 +1359,7 @@ vlan_transmit(struct ifnet *ifp, struct } p = mib->ifvm_p; - ec = (void *)mib->ifvm_p; + vc = if_get_vlancom(mib->ifvm_p); bpf_mtap(ifp, m, BPF_D_OUT); @@ -1370,7 +1372,7 @@ vlan_transmit(struct ifnet *ifp, struct * If the parent can insert the tag itself, just mark * the tag in the mbuf header. */ - if (ec->ec_capenable & ETHERCAP_VLAN_HWTAGGING) { + if (vc->vc_capenable & VLANCAP_HWTAGGING) { vlan_set_tag(m, mib->ifvm_tag); } else { /* Index: net/agr/if_agr.c =================================================================== RCS file: /cvsroot/src/sys/net/agr/if_agr.c,v retrieving revision 1.56 diff -u -p -r1.56 if_agr.c --- net/agr/if_agr.c 18 Sep 2022 19:24:14 -0000 1.56 +++ net/agr/if_agr.c 15 Oct 2022 15:25:41 -0000 @@ -167,7 +167,7 @@ agr_input(struct ifnet *ifp_port, struct * see if the device performed the decapsulation and * provided us with the tag. */ - if (ec->ec_nvlans && vlan_has_tag(m) && + if (ec->ec_vlan.vc_nvlans && vlan_has_tag(m) && EVL_VLANOFTAG(vlan_get_tag(m)) != 0) { MODULE_HOOK_CALL(if_vlan_vlan_input_hook, (ifp, m), m, m); @@ -258,15 +258,15 @@ agr_vlan_check(struct ifnet *ifp, struct struct ethercom *ec = (void *)ifp; /* vlans in sync? */ - if (sc->sc_nvlans == ec->ec_nvlans) { + if (sc->sc_nvlans == ec->ec_vlan.vc_nvlans) { return; } if (sc->sc_nvlans == 0) { /* vlan added */ agr_port_foreach(sc, agr_vlan_add, NULL); - sc->sc_nvlans = ec->ec_nvlans; - } else if (ec->ec_nvlans == 0) { + sc->sc_nvlans = ec->ec_vlan.vc_nvlans; + } else if (ec->ec_vlan.vc_nvlans == 0) { bool force_zero = false; /* vlan removed */ agr_port_foreach(sc, agr_vlan_del, &force_zero); Index: net/agr/if_agrether.c =================================================================== RCS file: /cvsroot/src/sys/net/agr/if_agrether.c,v retrieving revision 1.12 diff -u -p -r1.12 if_agrether.c --- net/agr/if_agrether.c 30 Nov 2021 01:17:02 -0000 1.12 +++ net/agr/if_agrether.c 15 Oct 2022 15:25:41 -0000 @@ -110,8 +110,8 @@ agrether_ctor(struct agr_softc *sc, stru IFCAP_CSUM_UDPv6_Tx | IFCAP_CSUM_UDPv6_Rx); ether_ifattach(ifp, CLLADDR(ifp_port->if_sadl)); - ec->ec_capabilities = - ETHERCAP_VLAN_MTU | ETHERCAP_VLAN_HWTAGGING | ETHERCAP_JUMBO_MTU; + ec->ec_capabilities = ETHERCAP_JUMBO_MTU; + ec->ec_vlan.vc_capabilities = VLANCAP_VLAN_MTU | VLANCAP_HWTAGGING; ieee8023ad_ctor(sc); @@ -152,18 +152,18 @@ agrether_portinit(struct agr_softc *sc, */ if (ec->ec_capabilities & - ~ec_port->ec_capabilities & - (ETHERCAP_VLAN_MTU | ETHERCAP_VLAN_HWTAGGING)) { - if (ec->ec_nvlans > 0) { + ~ec_port->ec_vlan.vc_capabilities & + (VLANCAP_VLAN_MTU | VLANCAP_HWTAGGING)) { + if (ec->ec_vlan.vc_nvlans > 0) { return EINVAL; } - ec->ec_capabilities &= - ec_port->ec_capabilities | - ~(ETHERCAP_VLAN_MTU | ETHERCAP_VLAN_HWTAGGING); + ec->ec_vlan.vc_capabilities &= + ec_port->ec_vlan.vc_capabilities | + ~(VLANCAP_VLAN_MTU | VLANCAP_HWTAGGING); } /* Enable vlan support */ - if (ec->ec_nvlans > 0) { + if (ec->ec_vlan.vc_nvlans > 0) { error = agr_vlan_add(port, NULL); if (error != 0) return error; @@ -208,7 +208,7 @@ agrether_portfini(struct agr_softc *sc, return 0; } - if (ec_port->ec_nvlans > 0) { + if (ec_port->ec_vlan.vc_nvlans > 0) { bool force = true; /* Disable vlan support */ agr_vlan_del(port, &force); Index: net/agr/if_agrsubr.c =================================================================== RCS file: /cvsroot/src/sys/net/agr/if_agrsubr.c,v retrieving revision 1.13 diff -u -p -r1.13 if_agrsubr.c --- net/agr/if_agrsubr.c 10 Nov 2019 21:16:38 -0000 1.13 +++ net/agr/if_agrsubr.c 15 Oct 2022 15:25:41 -0000 @@ -283,21 +283,21 @@ agr_vlan_add(struct agr_port *port, void struct ethercom *ec_port = (void *)ifp; int error=0; - if (ec_port->ec_nvlans++ == 0 && - (ec_port->ec_capabilities & ETHERCAP_VLAN_MTU) != 0) { + if (ec_port->ec_vlan.vc_nvlans++ == 0 && + (ec_port->ec_vlan.vc_capabilities & VLANCAP_VLAN_MTU) != 0) { struct ifnet *p = port->port_ifp; /* * Enable Tx/Rx of VLAN-sized frames. */ - ec_port->ec_capenable |= ETHERCAP_VLAN_MTU; + ec_port->ec_vlan.vc_capenable |= VLANCAP_VLAN_MTU; if (p->if_flags & IFF_UP) { IFNET_LOCK(p); error = if_flags_set(p, p->if_flags); IFNET_UNLOCK(p); if (error) { - if (ec_port->ec_nvlans-- == 1) - ec_port->ec_capenable &= - ~ETHERCAP_VLAN_MTU; + if (ec_port->ec_vlan.vc_nvlans-- == 1) + ec_port->ec_vlan.vc_capenable &= + ~VLANCAP_VLAN_MTU; return (error); } } @@ -318,15 +318,15 @@ agr_vlan_del(struct agr_port *port, void KASSERT(force_zero != NULL); /* Disable vlan support */ - if ((*force_zero && ec_port->ec_nvlans > 0) || - ec_port->ec_nvlans-- == 1) { + if ((*force_zero && ec_port->ec_vlan.vc_nvlans > 0) || + ec_port->ec_vlan.vc_nvlans-- == 1) { struct ifnet *p = port->port_ifp; if (*force_zero) - ec_port->ec_nvlans = 0; + ec_port->ec_vlan.vc_nvlans = 0; /* * Disable Tx/Rx of VLAN-sized frames. */ - ec_port->ec_capenable &= ~ETHERCAP_VLAN_MTU; + ec_port->ec_vlan.vc_capenable &= ~VLANCAP_VLAN_MTU; if (p->if_flags & IFF_UP) { IFNET_LOCK(p); (void)if_flags_set(p, p->if_flags); Index: net/lagg/if_lagg.c =================================================================== RCS file: /cvsroot/src/sys/net/lagg/if_lagg.c,v retrieving revision 1.48 diff -u -p -r1.48 if_lagg.c --- net/lagg/if_lagg.c 26 Jun 2022 17:55:24 -0000 1.48 +++ net/lagg/if_lagg.c 15 Oct 2022 15:25:41 -0000 @@ -145,7 +145,7 @@ static int lagg_transmit(struct ifnet *, static void lagg_start(struct ifnet *); static int lagg_media_change(struct ifnet *); static void lagg_media_status(struct ifnet *, struct ifmediareq *); -static int lagg_vlan_cb(struct ethercom *, uint16_t, bool); +static int lagg_vlan_cb(struct ifnet *, struct vlancom *, uint16_t, bool); static void lagg_linkstate_changed(void *); static void lagg_ifdetach(void *); static struct lagg_softc * @@ -1230,15 +1230,13 @@ lagg_port_vlan_cb(struct lagg_port *lp, } static int -lagg_vlan_cb(struct ethercom *ec, uint16_t vtag, bool set) +lagg_vlan_cb(struct ifnet *ifp, struct vlancom *vc, uint16_t vtag, bool set) { - struct ifnet *ifp; struct lagg_softc *sc; struct lagg_vlantag *lvt, *lvt0; struct lagg_port *lp; int error; - ifp = (struct ifnet *)ec; sc = ifp->if_softc; if (set) { @@ -1845,7 +1843,7 @@ lagg_sync_ifcaps(struct lagg_softc *sc) } static int -lagg_setethcaps(struct lagg_port *lp, int cap) +lagg_setethcaps(struct lagg_port *lp, int eth_cap, int vlan_cap) { struct ethercom *ec; struct eccapreq eccr; @@ -1854,11 +1852,12 @@ lagg_setethcaps(struct lagg_port *lp, in KASSERT(lp->lp_iftype == IFT_ETHER); ec = (struct ethercom *)lp->lp_ifp; - if (ec->ec_capenable == cap) + if (ec->ec_capenable == eth_cap && + ec->ec_vlan.vc_capenable == vlan_cap) return 0; memset(&eccr, 0, sizeof(eccr)); - eccr.eccr_capenable = cap; + eccr.eccr_capenable = ether_eccapreq_from_caps(eth_cap, vlan_cap); IFNET_LOCK(lp->lp_ifp); error = LAGG_PORT_IOCTL(lp, SIOCSETHERCAP, &eccr); @@ -1881,7 +1880,8 @@ lagg_sync_ethcaps(struct lagg_softc *sc) if (lp->lp_iftype != IFT_ETHER) continue; - error = lagg_setethcaps(lp, ec->ec_capenable); + error = lagg_setethcaps(lp, ec->ec_capenable, + ec->ec_vlan.vc_capenable); if (error != 0) { LAGG_LOG(sc, LOG_WARNING, "failed to update ether " @@ -1954,7 +1954,7 @@ lagg_ethercap_update(struct lagg_softc * { struct ethercom *ec; struct lagg_port *lp; - int cap, ena, pena; + int vlan_cap, eth_cap, vlan_ena, eth_ena, eth_pena, vlan_pena; size_t i; KASSERT(LAGG_LOCKED(sc)); @@ -1963,64 +1963,88 @@ lagg_ethercap_update(struct lagg_softc * return; /* Get common enabled capabilities for the lagg ports */ - ena = ~0; - cap = ~0; + eth_ena = vlan_ena = ~0; + eth_cap = vlan_cap = ~0; LAGG_PORTS_FOREACH(sc, lp) { switch (lp->lp_iftype) { case IFT_ETHER: ec = (struct ethercom *)lp->lp_ifp; - ena &= ec->ec_capenable; - cap &= ec->ec_capabilities; + eth_ena &= ec->ec_capenable; + eth_cap &= ec->ec_capabilities; + vlan_ena &= ec->ec_vlan.vc_capenable; + vlan_cap &= ec->ec_vlan.vc_capabilities; break; case IFT_L2TP: - ena &= (ETHERCAP_VLAN_MTU | ETHERCAP_JUMBO_MTU); - cap &= (ETHERCAP_VLAN_MTU | ETHERCAP_JUMBO_MTU); + eth_ena &= ETHERCAP_JUMBO_MTU; + eth_cap &= ETHERCAP_JUMBO_MTU; + vlan_ena &= VLANCAP_VLAN_MTU; + vlan_cap &= VLANCAP_VLAN_MTU; break; default: - ena = 0; - cap = 0; + eth_ena = vlan_ena = 0; + eth_cap = vlan_cap = 0; } } - if (ena == ~0) - ena = 0; - if (cap == ~0) - cap = 0; + if (eth_ena == ~0) + eth_ena = 0; + if (eth_cap == ~0) + eth_cap = 0; + if (vlan_ena == ~0) + vlan_ena = 0; + if (vlan_cap == ~0) + vlan_cap = 0; /* * Apply common enabled capabilities back to the lagg ports. * May require several iterations if they are dependent. */ for (i = 0; i < LAGG_SETCAPS_RETRY; i++) { - pena = ena; + vlan_pena = vlan_ena; + eth_pena = eth_ena; LAGG_PORTS_FOREACH(sc, lp) { if (lp->lp_iftype != IFT_ETHER) continue; ec = (struct ethercom *)lp->lp_ifp; - lagg_setethcaps(lp, ena); - ena &= ec->ec_capenable; + lagg_setethcaps(lp, eth_ena, vlan_ena); + eth_ena &= ec->ec_capenable; + vlan_ena &= ec->ec_vlan.vc_capenable; } - if (pena == ena) + if (eth_pena == eth_ena && vlan_pena == vlan_ena) break; } - if (pena != ena) { + if (eth_pena != eth_ena) { LAGG_LOG(sc, LOG_DEBUG, "couldn't set " - "ether capabilities 0x%08x\n", pena); + "ether capabilities 0x%08x\n", eth_pena); + } + if (vlan_pena != vlan_ena) { + LAGG_LOG(sc, LOG_DEBUG, "couldn't set " + "vlan capabilities 0x%08x\n", vlan_pena); } ec = (struct ethercom *)&sc->sc_if; - if (ec->ec_capabilities != cap || - ec->ec_capenable != ena) { - ec->ec_capabilities = cap; - ec->ec_capenable = ena; + if (ec->ec_capabilities != eth_cap || + ec->ec_capenable != eth_ena) { + ec->ec_capabilities = eth_cap; + ec->ec_capenable = eth_ena; LAGG_LOG(sc, LOG_DEBUG, "ether capabilities 0x%08x" - " enabled 0x%08x\n", cap, ena); + " enabled 0x%08x\n", eth_cap, eth_ena); + } + + if (ec->ec_vlan.vc_capabilities != vlan_cap || + ec->ec_vlan.vc_capenable != vlan_ena) { + ec->ec_vlan.vc_capabilities = vlan_cap; + ec->ec_vlan.vc_capenable = vlan_ena; + + LAGG_LOG(sc, LOG_DEBUG, + "vlan capabilities 0x%08x" + " enabled 0x%08x\n", vlan_cap, vlan_ena); } } @@ -2225,6 +2249,7 @@ lagg_port_setup(struct lagg_softc *sc, lagg_lladdr_cpy(lp->lp_lladdr, CLLADDR(ifp_port->if_sadl)); lp->lp_eccapenable = ec->ec_capenable; + lp->lp_vlan_capenable = ec->ec_vlan.vc_capenable; } /* change callbacks and others */ @@ -2364,7 +2389,8 @@ lagg_port_teardown(struct lagg_softc *sc lagg_unconfig_promisc(sc, lp); lagg_setifcaps(lp, lp->lp_ifcapenable); if (lp->lp_iftype == IFT_ETHER) - lagg_setethcaps(lp, lp->lp_eccapenable); + lagg_setethcaps(lp, lp->lp_eccapenable, + lp->lp_vlan_capenable); } SIMPLEQ_REMOVE(&sc->sc_ports, lp, lagg_port, lp_entry); Index: net/lagg/if_laggproto.h =================================================================== RCS file: /cvsroot/src/sys/net/lagg/if_laggproto.h,v retrieving revision 1.18 diff -u -p -r1.18 if_laggproto.h --- net/lagg/if_laggproto.h 26 Jun 2022 17:55:24 -0000 1.18 +++ net/lagg/if_laggproto.h 15 Oct 2022 15:25:41 -0000 @@ -78,6 +78,7 @@ struct lagg_port { u_char lp_iftype; uint8_t lp_lladdr[ETHER_ADDR_LEN]; int lp_eccapenable; + int lp_vlan_capenable; uint64_t lp_ifcapenable; uint64_t lp_mtu; Index: net80211/ieee80211_ioctl.c =================================================================== RCS file: /cvsroot/src/sys/net80211/ieee80211_ioctl.c,v retrieving revision 1.69 diff -u -p -r1.69 ieee80211_ioctl.c --- net80211/ieee80211_ioctl.c 21 Sep 2021 15:00:34 -0000 1.69 +++ net80211/ieee80211_ioctl.c 15 Oct 2022 15:25:41 -0000 @@ -2569,11 +2569,23 @@ ieee80211_ioctl(struct ieee80211com *ic, struct ieee80211_bssid *bssid; struct ieee80211chanreq *chanreq; struct ieee80211_channel *chan; + struct ifrvlan *vlan; + static struct vlancom dummy_single_vlancom; uint32_t oflags; static const u_int8_t zerobssid[IEEE80211_ADDR_LEN]; u_int8_t tmpkey[IEEE80211_WEP_NKID][IEEE80211_KEYBUF_SIZE]; switch (cmd) { + case SIOCGETVLANCOM: + /* stupid hack for testing only ... */ + if (dummy_single_vlancom.vc_lock == NULL) { + dummy_single_vlancom.vc_lock = + mutex_obj_alloc(MUTEX_DEFAULT, IPL_NET); + SIMPLEQ_INIT(&dummy_single_vlancom.vc_vids); + } + vlan = (struct ifrvlan*)data; + vlan->ifv_vc = &dummy_single_vlancom; + return 0; case SIOCSIFMEDIA: case SIOCGIFMEDIA: error = ifmedia_ioctl(ifp, ifr, &ic->ic_media, cmd); Index: sys/sockio.h =================================================================== RCS file: /cvsroot/src/sys/sys/sockio.h,v retrieving revision 1.40 diff -u -p -r1.40 sockio.h --- sys/sockio.h 2 Aug 2021 12:56:25 -0000 1.40 +++ sys/sockio.h 15 Oct 2022 15:25:41 -0000 @@ -155,4 +155,7 @@ #define SIOCGNBRINFO _IOWR('i', 249, struct in_nbrinfo) /* get IA ND info */ +/* kernel internal only: get vlancom from ifp */ +#define SIOCGETVLANCOM _IOC(IOC_VOID, 'i', 250, sizeof(struct ifrvlan)) + #endif /* !_SYS_SOCKIO_H_ */