diff options
author | Christian Weisgerber <naddy@cvs.openbsd.org> | 2008-10-16 19:16:22 +0000 |
---|---|---|
committer | Christian Weisgerber <naddy@cvs.openbsd.org> | 2008-10-16 19:16:22 +0000 |
commit | bd4e71e6bed07a52899e9b2eb7b4088e57f0a007 (patch) | |
tree | 7d8fd5fb7d332b5c26271e072add15c3be9a679f /sys | |
parent | c73f03f7f8fc0a3ad3cd779e5c9e0cefdfa342f2 (diff) |
Convert RX tag stripping to storing the tag in the mbuf header and
enable RX tag stripping for re(4).
ok brad@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/ic/re.c | 11 | ||||
-rw-r--r-- | sys/dev/pci/if_bnx.c | 20 | ||||
-rw-r--r-- | sys/dev/pci/if_ix.c | 19 | ||||
-rw-r--r-- | sys/dev/pci/if_txp.c | 48 |
4 files changed, 33 insertions, 65 deletions
diff --git a/sys/dev/ic/re.c b/sys/dev/ic/re.c index c1b54c09189..35520604f42 100644 --- a/sys/dev/ic/re.c +++ b/sys/dev/ic/re.c @@ -1,4 +1,4 @@ -/* $OpenBSD: re.c,v 1.94 2008/10/11 23:49:05 brad Exp $ */ +/* $OpenBSD: re.c,v 1.95 2008/10/16 19:16:21 naddy Exp $ */ /* $FreeBSD: if_re.c,v 1.31 2004/09/04 07:54:05 ru Exp $ */ /* * Copyright (c) 1997, 1998-2003 @@ -1461,6 +1461,13 @@ re_rxeof(struct rl_softc *sc) m->m_pkthdr.csum_flags |= M_TCP_CSUM_IN_OK | M_UDP_CSUM_IN_OK; } +#if NVLAN > 0 + if (rxvlan & RL_RDESC_VLANCTL_TAG) { + m->m_pkthdr.ether_vtag = + ntohs((rxvlan & RL_RDESC_VLANCTL_DATA)); + m->m_flags |= M_VLANTAG; + } +#endif #if NBPFILTER > 0 if (ifp->if_bpf) @@ -1917,6 +1924,8 @@ re_init(struct ifnet *ifp) cfg = RL_CPLUSCMD_PCI_MRW; if (ifp->if_capabilities & IFCAP_CSUM_IPv4) cfg |= RL_CPLUSCMD_RXCSUM_ENB; + if (ifp->if_capabilities & IFCAP_VLAN_HWTAGGING) + cfg |= RL_CPLUSCMD_VLANSTRIP; if (sc->rl_flags & RL_FLAG_MACSTAT) { cfg |= RL_CPLUSCMD_MACSTAT_DIS; /* XXX magic. */ diff --git a/sys/dev/pci/if_bnx.c b/sys/dev/pci/if_bnx.c index aea799bddb6..b5fc6269d48 100644 --- a/sys/dev/pci/if_bnx.c +++ b/sys/dev/pci/if_bnx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_bnx.c,v 1.66 2008/10/02 20:21:14 brad Exp $ */ +/* $OpenBSD: if_bnx.c,v 1.67 2008/10/16 19:16:21 naddy Exp $ */ /*- * Copyright (c) 2006 Broadcom Corporation @@ -4014,26 +4014,14 @@ bnx_rx_intr(struct bnx_softc *sc) if ((status & L2_FHDR_STATUS_L2_VLAN_TAG) && !(sc->rx_mode & BNX_EMAC_RX_MODE_KEEP_VLAN_TAG)) { #if NVLAN > 0 - struct ether_vlan_header vh; - DBPRINT(sc, BNX_VERBOSE_SEND, "%s(): VLAN tag = 0x%04X\n", __FUNCTION__, l2fhdr->l2_fhdr_vlan_tag); - if (m->m_pkthdr.len < ETHER_HDR_LEN) { - m_freem(m); - goto bnx_rx_int_next_rx; - } - m_copydata(m, 0, ETHER_HDR_LEN, (caddr_t)&vh); - vh.evl_proto = vh.evl_encap_proto; - vh.evl_tag = htons(l2fhdr->l2_fhdr_vlan_tag); - vh.evl_encap_proto = htons(ETHERTYPE_VLAN); - m_adj(m, ETHER_HDR_LEN); - M_PREPEND(m, sizeof(vh), M_DONTWAIT); - if (m == NULL) - goto bnx_rx_int_next_rx; - m_copyback(m, 0, sizeof(vh), &vh); + m->m_pkthdr.ether_vtag = + l2fhdr->l2_fhdr_vlan_tag; + m->m_flags |= M_VLANTAG; #else m_freem(m); goto bnx_rx_int_next_rx; diff --git a/sys/dev/pci/if_ix.c b/sys/dev/pci/if_ix.c index 0ba819967e7..f7d962f8f54 100644 --- a/sys/dev/pci/if_ix.c +++ b/sys/dev/pci/if_ix.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ix.c,v 1.10 2008/10/11 20:31:50 miod Exp $ */ +/* $OpenBSD: if_ix.c,v 1.11 2008/10/16 19:16:21 naddy Exp $ */ /****************************************************************************** @@ -2791,22 +2791,9 @@ ixgbe_rxeof(struct rx_ring *rxr, int count) #if NVLAN > 0 && defined(IX_CSUM_OFFLOAD) if (staterr & IXGBE_RXD_STAT_VP) { - struct ether_vlan_header vh; - - if (m->m_pkthdr.len < ETHER_HDR_LEN) - goto discard; - m_copydata(m, 0, - ETHER_HDR_LEN, (caddr_t)&vh); - vh.evl_proto = vh.evl_encap_proto; - vh.evl_tag = + m->m_pkthdr.ether_vtag = letoh16(cur->wb.upper.vlan); - vh.evl_encap_proto = - htons(ETHERTYPE_VLAN); - m_adj(m, ETHER_HDR_LEN); - M_PREPEND(m, sizeof(vh), M_DONTWAIT); - if (m == NULL) - goto discard; - m_copyback(m, 0, sizeof(vh), &vh); + m->m_flags |= M_VLANTAG; } #endif rxr->fmp = NULL; diff --git a/sys/dev/pci/if_txp.c b/sys/dev/pci/if_txp.c index ba6043f8172..24d1547b530 100644 --- a/sys/dev/pci/if_txp.c +++ b/sys/dev/pci/if_txp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_txp.c,v 1.95 2008/10/02 20:21:14 brad Exp $ */ +/* $OpenBSD: if_txp.c,v 1.96 2008/10/16 19:16:21 naddy Exp $ */ /* * Copyright (c) 2001 @@ -641,31 +641,6 @@ txp_rx_reclaim(struct txp_softc *sc, struct txp_rx_ring *r, free(sd, M_DEVBUF); m->m_pkthdr.len = m->m_len = letoh16(rxd->rx_len); -#if NVLAN > 0 - /* - * XXX Another firmware bug: the vlan encapsulation - * is always removed, even when we tell the card not - * to do that. Restore the vlan encapsulation below. - */ - if (rxd->rx_stat & htole32(RX_STAT_VLAN)) { - struct ether_vlan_header vh; - - if (m->m_pkthdr.len < ETHER_HDR_LEN) { - m_freem(m); - goto next; - } - m_copydata(m, 0, ETHER_HDR_LEN, (caddr_t)&vh); - vh.evl_proto = vh.evl_encap_proto; - vh.evl_tag = rxd->rx_vlan >> 16; - vh.evl_encap_proto = htons(ETHERTYPE_VLAN); - m_adj(m, ETHER_HDR_LEN); - M_PREPEND(m, sizeof(vh), M_DONTWAIT); - if (m == NULL) - goto next; - m_copyback(m, 0, sizeof(vh), &vh); - } -#endif - #ifdef __STRICT_ALIGNMENT { /* @@ -698,6 +673,18 @@ txp_rx_reclaim(struct txp_softc *sc, struct txp_rx_ring *r, } #endif +#if NVLAN > 0 + /* + * XXX Another firmware bug: the vlan encapsulation + * is always removed, even when we tell the card not + * to do that. Restore the vlan encapsulation below. + */ + if (rxd->rx_stat & htole32(RX_STAT_VLAN)) { + m->m_pkthdr.ether_vtag = ntohs(rxd->rx_vlan >> 16); + m->m_flags |= M_VLANTAG; + } +#endif + #if NBPFILTER > 0 /* * Handle BPF listeners. Let the BPF user see the packet. @@ -775,10 +762,8 @@ txp_rxbuf_reclaim(struct txp_softc *sc) MCLGET(sd->sd_mbuf, M_DONTWAIT); if ((sd->sd_mbuf->m_flags & M_EXT) == 0) goto err_mbuf; - /* reserve some space for a possible VLAN header */ - sd->sd_mbuf->m_data += 8; - sd->sd_mbuf->m_pkthdr.len = sd->sd_mbuf->m_len = MCLBYTES - 8; sd->sd_mbuf->m_pkthdr.rcvif = ifp; + sd->sd_mbuf->m_pkthdr.len = sd->sd_mbuf->m_len = MCLBYTES; if (bus_dmamap_create(sc->sc_dmat, TXP_MAX_PKTLEN, 1, TXP_MAX_PKTLEN, 0, BUS_DMA_NOWAIT, &sd->sd_map)) goto err_mbuf; @@ -1059,9 +1044,7 @@ txp_alloc_rings(struct txp_softc *sc) if ((sd->sd_mbuf->m_flags & M_EXT) == 0) { goto bail_rxbufring; } - /* reserve some space for a possible VLAN header */ - sd->sd_mbuf->m_data += 8; - sd->sd_mbuf->m_pkthdr.len = sd->sd_mbuf->m_len = MCLBYTES - 8; + sd->sd_mbuf->m_pkthdr.len = sd->sd_mbuf->m_len = MCLBYTES; sd->sd_mbuf->m_pkthdr.rcvif = ifp; if (bus_dmamap_create(sc->sc_dmat, TXP_MAX_PKTLEN, 1, TXP_MAX_PKTLEN, 0, BUS_DMA_NOWAIT, &sd->sd_map)) { @@ -1971,6 +1954,7 @@ txp_capabilities(struct txp_softc *sc) #if NVLAN > 0 if (rsp->rsp_par2 & rsp->rsp_par3 & OFFLOAD_VLAN) { sc->sc_tx_capability |= OFFLOAD_VLAN; + sc->sc_rx_capability |= OFFLOAD_VLAN; ifp->if_capabilities |= IFCAP_VLAN_HWTAGGING; } #endif |