diff options
author | Brad Smith <brad@cvs.openbsd.org> | 2008-10-28 05:09:44 +0000 |
---|---|---|
committer | Brad Smith <brad@cvs.openbsd.org> | 2008-10-28 05:09:44 +0000 |
commit | 438ce56ad8a077dbd92742cb81a43f0c97599434 (patch) | |
tree | 669598dbb3f450dbd8a6ef5447ffb2c57ae162fe /sys/dev/pci | |
parent | efbaca61be12a1fd03213155b0a27313e54a293b (diff) |
Re-add support for RX VLAN tag stripping.
Diffstat (limited to 'sys/dev/pci')
-rw-r--r-- | sys/dev/pci/if_nfe.c | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/sys/dev/pci/if_nfe.c b/sys/dev/pci/if_nfe.c index 0552416b24c..5e5bd195a25 100644 --- a/sys/dev/pci/if_nfe.c +++ b/sys/dev/pci/if_nfe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_nfe.c,v 1.83 2008/10/16 19:18:03 naddy Exp $ */ +/* $OpenBSD: if_nfe.c,v 1.84 2008/10/28 05:09:43 brad Exp $ */ /*- * Copyright (c) 2006, 2007 Damien Bergamini <damien.bergamini@free.fr> @@ -327,6 +327,7 @@ nfe_attach(struct device *parent, struct device *self, void *aux) if (sc->sc_flags & NFE_HW_VLAN) ifp->if_capabilities |= IFCAP_VLAN_HWTAGGING; #endif + if (sc->sc_flags & NFE_HW_CSUM) { ifp->if_capabilities |= IFCAP_CSUM_IPv4 | IFCAP_CSUM_TCPv4 | IFCAP_CSUM_UDPv4; @@ -672,6 +673,9 @@ nfe_rxeof(struct nfe_softc *sc) struct nfe_jbuf *jbuf; struct mbuf *m, *mnew; bus_addr_t physaddr; +#if NVLAN > 0 + uint32_t vtag; +#endif uint16_t flags; int error, len; @@ -684,6 +688,9 @@ nfe_rxeof(struct nfe_softc *sc) flags = letoh16(desc64->flags); len = letoh16(desc64->length) & 0x3fff; +#if NVLAN > 0 + vtag = letoh32(desc64->physaddr[1]); +#endif } else { desc32 = &sc->rxq.desc32[sc->rxq.cur]; nfe_rxdesc32_sync(sc, desc32, BUS_DMASYNC_POSTREAD); @@ -797,6 +804,13 @@ nfe_rxeof(struct nfe_softc *sc) m->m_pkthdr.csum_flags |= M_TCP_CSUM_IN_OK; } +#if NVLAN > 0 + if ((vtag & NFE_RX_VTAG) && (sc->sc_flags & NFE_HW_VLAN)) { + m->m_pkthdr.ether_vtag = vtag & 0xffff; + m->m_flags |= M_VLANTAG; + } +#endif + #if NBPFILTER > 0 if (ifp->if_bpf) bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_IN); @@ -912,9 +926,7 @@ nfe_encap(struct nfe_softc *sc, struct mbuf *m0) struct nfe_tx_data *data; bus_dmamap_t map; uint16_t flags = 0; -#if NVLAN > 0 uint32_t vtag = 0; -#endif int error, i, first = sc->txq.cur; map = sc->txq.data[first].map; @@ -934,7 +946,7 @@ nfe_encap(struct nfe_softc *sc, struct mbuf *m0) #if NVLAN > 0 /* setup h/w VLAN tagging */ if (m0->m_flags & M_VLANTAG) - vtag = NFE_TX_VTAG | htons(m0->m_pkthdr.ether_vtag); + vtag = NFE_TX_VTAG | m0->m_pkthdr.ether_vtag; #endif if (m0->m_pkthdr.csum_flags & M_IPV4_CSUM_OUT) flags |= NFE_TX_IP_CSUM; @@ -954,9 +966,7 @@ nfe_encap(struct nfe_softc *sc, struct mbuf *m0) htole32(map->dm_segs[i].ds_addr & 0xffffffff); desc64->length = htole16(map->dm_segs[i].ds_len - 1); desc64->flags = htole16(flags); -#if NVLAN > 0 desc64->vtag = htole32(vtag); -#endif } else { desc32 = &sc->txq.desc32[sc->txq.cur]; @@ -971,9 +981,8 @@ nfe_encap(struct nfe_softc *sc, struct mbuf *m0) * only. */ flags &= ~(NFE_TX_IP_CSUM | NFE_TX_TCP_UDP_CSUM); -#if NVLAN > 0 vtag = 0; -#endif + /* * Setting of the valid bit in the first descriptor is * deferred until the whole chain is fully setup. @@ -1087,17 +1096,12 @@ nfe_init(struct ifnet *ifp) sc->rxtxctl |= NFE_RXTX_V3MAGIC; else if (sc->sc_flags & NFE_JUMBO_SUP) sc->rxtxctl |= NFE_RXTX_V2MAGIC; + if (sc->sc_flags & NFE_HW_CSUM) sc->rxtxctl |= NFE_RXTX_RXCSUM; -#if NVLAN > 0 - /* - * Although the adapter is capable of stripping VLAN tags from received - * frames (NFE_RXTX_VTAG_STRIP), we do not enable this functionality on - * purpose. This will be done in software by our network stack. - */ - if (sc->sc_flags & NFE_HW_VLAN) - sc->rxtxctl |= NFE_RXTX_VTAG_INSERT; -#endif + if (ifp->if_capabilities & IFCAP_VLAN_HWTAGGING) + sc->rxtxctl |= NFE_RXTX_VTAG_INSERT | NFE_RXTX_VTAG_STRIP; + NFE_WRITE(sc, NFE_RXTX_CTL, NFE_RXTX_RESET | sc->rxtxctl); DELAY(10); NFE_WRITE(sc, NFE_RXTX_CTL, sc->rxtxctl); |