diff options
| author | tsutsui <tsutsui@NetBSD.org> | 2006-12-16 02:52:17 +0000 |
|---|---|---|
| committer | tsutsui <tsutsui@NetBSD.org> | 2006-12-16 02:52:17 +0000 |
| commit | b2261339c58baaba07d722576dd47f920c8a25b2 (patch) | |
| tree | defdd97df1437657d6a7711cc6e0f7f6fd26d72a /sys/dev | |
| parent | 6f4d1070fdc609015e8453ba0a2fe3f8ccb83d53 (diff) | |
Fix and reenable HW VLAN tagging on re(4):
- clear re_vlanctl in DMA descriptors before starting TX and RX
to avoid stale tags
- use bswap16() rather than be16toh() or htons() on VLAN tag access
since we already use htole32()
Closes PR kern/32643 and also fixes HW VLAN tagging on big endian machines.
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/ic/rtl8169.c | 30 |
1 files changed, 8 insertions, 22 deletions
diff --git a/sys/dev/ic/rtl8169.c b/sys/dev/ic/rtl8169.c index 349f6cc3e0f..225e895692f 100644 --- a/sys/dev/ic/rtl8169.c +++ b/sys/dev/ic/rtl8169.c @@ -1,4 +1,4 @@ -/* $NetBSD: rtl8169.c,v 1.73 2006/12/06 13:52:46 tsutsui Exp $ */ +/* $NetBSD: rtl8169.c,v 1.74 2006/12/16 02:52:17 tsutsui Exp $ */ /* * Copyright (c) 1997, 1998-2003 @@ -754,16 +754,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; - - /* - * This is a way to disable hw VLAN tagging by default - * (RE_VLAN is undefined), as it is problematic. PR 32643 - */ - -#ifdef RE_VLAN - sc->ethercom.ec_capabilities |= ETHERCAP_VLAN_HWTAGGING; -#endif + sc->ethercom.ec_capabilities |= + ETHERCAP_VLAN_MTU | ETHERCAP_VLAN_HWTAGGING; ifp->if_start = re_start; ifp->if_stop = re_stop; @@ -1078,6 +1070,7 @@ re_newbuf(struct rtk_softc *sc, int idx, struct mbuf *m) rxs->rxs_mbuf = m; + d->re_vlanctl = 0; cmdstat = map->dm_segs[0].ds_len; if (idx == (RE_RX_DESC_CNT - 1)) cmdstat |= RE_RDESC_CMD_EOR; @@ -1299,13 +1292,11 @@ re_rxeof(struct rtk_softc *sc) m->m_pkthdr.csum_flags |= M_CSUM_TCP_UDP_BAD; } -#ifdef RE_VLAN if (rxvlan & RE_RDESC_VLANCTL_TAG) { VLAN_INPUT_TAG(ifp, m, - be16toh(rxvlan & RE_RDESC_VLANCTL_DATA), + bswap16(rxvlan & RE_RDESC_VLANCTL_DATA), continue); } -#endif #if NBPFILTER > 0 if (ifp->if_bpf) bpf_mtap(ifp->if_bpf, m); @@ -1529,9 +1520,7 @@ re_start(struct ifnet *ifp) bus_dmamap_t map; struct re_txq *txq; struct re_desc *d; -#ifdef RE_VLAN struct m_tag *mtag; -#endif uint32_t cmdstat, re_flags; int ofree, idx, error, nsegs, seg; int startdesc, curdesc, lastdesc; @@ -1657,6 +1646,7 @@ re_start(struct ifnet *ifp) } #endif + d->re_vlanctl = 0; re_set_bufaddr(d, map->dm_segs[seg].ds_addr); cmdstat = re_flags | map->dm_segs[seg].ds_len; if (seg == 0) @@ -1677,6 +1667,7 @@ re_start(struct ifnet *ifp) bus_addr_t paddaddr; d = &sc->re_ldata.re_tx_list[curdesc]; + d->re_vlanctl = 0; paddaddr = RE_TXPADDADDR(sc); re_set_bufaddr(d, paddaddr); cmdstat = re_flags | @@ -1697,14 +1688,11 @@ re_start(struct ifnet *ifp) * appear in the first descriptor of a multi-descriptor * transmission attempt. */ - -#ifdef RE_VLAN if ((mtag = VLAN_OUTPUT_TAG(&sc->ethercom, m)) != NULL) { sc->re_ldata.re_tx_list[startdesc].re_vlanctl = - htole32(htons(VLAN_TAG_VALUE(mtag)) | + htole32(bswap16(VLAN_TAG_VALUE(mtag)) | RE_TDESC_VLANCTL_TAG); } -#endif /* Transfer ownership of packet to the chip. */ @@ -1807,9 +1795,7 @@ re_init(struct ifnet *ifp) if (1) {/* not for 8169S ? */ reg |= -#ifdef RE_VLAN RTK_CPLUSCMD_VLANSTRIP | -#endif (ifp->if_capenable & (IFCAP_CSUM_IPv4_Rx | IFCAP_CSUM_TCPv4_Rx | IFCAP_CSUM_UDPv4_Rx) ? |
