Module Name: src Committed By: msaitoh Date: Tue Mar 19 03:40:16 UTC 2013
Modified Files: src/sys/dev/pci: if_bge.c if_bgereg.h Log Message: Fix three bugs: - An workaround for TX data corruption is only for 5719 "A0". Fix the wrong evaluation. - Check BGE_RXBDFLAG_IPV6 flag for 5717_PLUS case. Note that {tcp,udp}6csum flag is currently not added in the capability. - Add delay after clearing BGE_MACMODE_TBI_SEND_CFGS for the link checking. FreeBSD has the same delay(). To generate a diff of this commit: cvs rdiff -u -r1.218 -r1.219 src/sys/dev/pci/if_bge.c cvs rdiff -u -r1.64 -r1.65 src/sys/dev/pci/if_bgereg.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/pci/if_bge.c diff -u src/sys/dev/pci/if_bge.c:1.218 src/sys/dev/pci/if_bge.c:1.219 --- src/sys/dev/pci/if_bge.c:1.218 Tue Mar 19 02:56:16 2013 +++ src/sys/dev/pci/if_bge.c Tue Mar 19 03:40:16 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: if_bge.c,v 1.218 2013/03/19 02:56:16 msaitoh Exp $ */ +/* $NetBSD: if_bge.c,v 1.219 2013/03/19 03:40:16 msaitoh Exp $ */ /* * Copyright (c) 2001 Wind River Systems @@ -79,7 +79,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.218 2013/03/19 02:56:16 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.219 2013/03/19 03:40:16 msaitoh Exp $"); #include "vlan.h" @@ -196,6 +196,7 @@ static int bge_get_eaddr_eeprom(struct b static int bge_get_eaddr(struct bge_softc *, uint8_t[]); static void bge_txeof(struct bge_softc *); +static void bge_rxcsum(struct bge_softc *, struct bge_rx_bd *, struct mbuf *); static void bge_rxeof(struct bge_softc *); static void bge_asf_driver_up (struct bge_softc *); @@ -2936,8 +2937,7 @@ bge_blockinit(struct bge_softc *sc) * Adjust tx margin to prevent TX data corruption and * fix internal FIFO overflow. */ - if (BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM5719 || - sc->bge_chipid == BGE_CHIPID_BCM5719_A0) { + if (sc->bge_chipid == BGE_CHIPID_BCM5719_A0) { dmactl &= ~(BGE_RDMA_RSRVCTRL_FIFO_LWM_MASK | BGE_RDMA_RSRVCTRL_FIFO_HWM_MASK | BGE_RDMA_RSRVCTRL_TXMRGN_MASK); @@ -4141,30 +4141,7 @@ bge_rxeof(struct bge_softc *sc) */ bpf_mtap(ifp, m); - m->m_pkthdr.csum_flags = M_CSUM_IPv4; - - if (BGE_IS_5717_PLUS(sc)) { - if ((cur_rx->bge_error_flag & - BGE_RXERRFLAG_IP_CSUM_NOK) != 0) - m->m_pkthdr.csum_flags |= M_CSUM_IPv4_BAD; - } else { - if ((cur_rx->bge_ip_csum ^ 0xffff) != 0) - m->m_pkthdr.csum_flags |= M_CSUM_IPv4_BAD; - } - /* - * Rx transport checksum-offload may also - * have bugs with packets which, when transmitted, - * were `runts' requiring padding. - */ - if (cur_rx->bge_flags & BGE_RXBDFLAG_TCP_UDP_CSUM && - (/* (sc->_bge_quirks & BGE_QUIRK_SHORT_CKSUM_BUG) == 0 ||*/ - m->m_pkthdr.len >= ETHER_MIN_NOPAD)) { - m->m_pkthdr.csum_data = - cur_rx->bge_tcp_udp_csum; - m->m_pkthdr.csum_flags |= - (M_CSUM_TCPv4|M_CSUM_UDPv4| - M_CSUM_DATA); - } + bge_rxcsum(sc, cur_rx, m); /* * If we received a packet with a vlan tag, pass it @@ -4186,6 +4163,47 @@ bge_rxeof(struct bge_softc *sc) } static void +bge_rxcsum(struct bge_softc *sc, struct bge_rx_bd *cur_rx, struct mbuf *m) +{ + + if (BGE_IS_5717_PLUS(sc)) { + if ((cur_rx->bge_flags & BGE_RXBDFLAG_IPV6) == 0) { + if ((cur_rx->bge_flags & BGE_RXBDFLAG_IP_CSUM) != 0) + m->m_pkthdr.csum_flags = M_CSUM_IPv4; + if ((cur_rx->bge_error_flag & + BGE_RXERRFLAG_IP_CSUM_NOK) != 0) + m->m_pkthdr.csum_flags |= M_CSUM_IPv4_BAD; + if (cur_rx->bge_flags & BGE_RXBDFLAG_TCP_UDP_CSUM) { + m->m_pkthdr.csum_data = + cur_rx->bge_tcp_udp_csum; + m->m_pkthdr.csum_flags |= + (M_CSUM_TCPv4|M_CSUM_UDPv4| + M_CSUM_DATA); + } + } + } else { + if ((cur_rx->bge_flags & BGE_RXBDFLAG_IP_CSUM) != 0) + m->m_pkthdr.csum_flags = M_CSUM_IPv4; + if ((cur_rx->bge_ip_csum ^ 0xffff) != 0) + m->m_pkthdr.csum_flags |= M_CSUM_IPv4_BAD; + /* + * Rx transport checksum-offload may also + * have bugs with packets which, when transmitted, + * were `runts' requiring padding. + */ + if (cur_rx->bge_flags & BGE_RXBDFLAG_TCP_UDP_CSUM && + (/* (sc->_bge_quirks & BGE_QUIRK_SHORT_CKSUM_BUG) == 0 ||*/ + m->m_pkthdr.len >= ETHER_MIN_NOPAD)) { + m->m_pkthdr.csum_data = + cur_rx->bge_tcp_udp_csum; + m->m_pkthdr.csum_flags |= + (M_CSUM_TCPv4|M_CSUM_UDPv4| + M_CSUM_DATA); + } + } +} + +static void bge_txeof(struct bge_softc *sc) { struct bge_tx_bd *cur_tx = NULL; @@ -5504,9 +5522,12 @@ bge_link_upd(struct bge_softc *sc) if (status & BGE_MACSTAT_TBI_PCS_SYNCHED) { if (!BGE_STS_BIT(sc, BGE_STS_LINK)) { BGE_STS_SETBIT(sc, BGE_STS_LINK); - if (BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM5704) + if (BGE_ASICREV(sc->bge_chipid) + == BGE_ASICREV_BCM5704) { BGE_CLRBIT(sc, BGE_MAC_MODE, BGE_MACMODE_TBI_SEND_CFGS); + DELAY(40); + } CSR_WRITE_4(sc, BGE_MAC_STS, 0xFFFFFFFF); if_link_state_change(ifp, LINK_STATE_UP); } Index: src/sys/dev/pci/if_bgereg.h diff -u src/sys/dev/pci/if_bgereg.h:1.64 src/sys/dev/pci/if_bgereg.h:1.65 --- src/sys/dev/pci/if_bgereg.h:1.64 Sun Mar 17 18:46:10 2013 +++ src/sys/dev/pci/if_bgereg.h Tue Mar 19 03:40:16 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: if_bgereg.h,v 1.64 2013/03/17 18:46:10 msaitoh Exp $ */ +/* $NetBSD: if_bgereg.h,v 1.65 2013/03/19 03:40:16 msaitoh Exp $ */ /* * Copyright (c) 2001 Wind River Systems * Copyright (c) 1997, 1998, 1999, 2001 @@ -2260,6 +2260,7 @@ struct bge_rx_bd { #define BGE_RXBDFLAG_IP_CSUM 0x1000 #define BGE_RXBDFLAG_TCP_UDP_CSUM 0x2000 #define BGE_RXBDFLAG_TCP_UDP_IS_TCP 0x4000 +#define BGE_RXBDFLAG_IPV6 0x8000 #define BGE_RXERRFLAG_BAD_CRC 0x0001 #define BGE_RXERRFLAG_COLL_DETECT 0x0002