Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci Fix three bugs:



details:   https://anonhg.NetBSD.org/src/rev/132ca04d9583
branches:  trunk
changeset: 785544:132ca04d9583
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Tue Mar 19 03:40:16 2013 +0000

description:
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().

diffstat:

 sys/dev/pci/if_bge.c    |  79 +++++++++++++++++++++++++++++++-----------------
 sys/dev/pci/if_bgereg.h |   3 +-
 2 files changed, 52 insertions(+), 30 deletions(-)

diffs (147 lines):

diff -r 8743aa837431 -r 132ca04d9583 sys/dev/pci/if_bge.c
--- a/sys/dev/pci/if_bge.c      Tue Mar 19 02:56:16 2013 +0000
+++ b/sys/dev/pci/if_bge.c      Tue Mar 19 03:40:16 2013 +0000
@@ -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(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 @@
                 * 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 @@
                 */
                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 @@
 }
 
 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 @@
                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);
                        }
diff -r 8743aa837431 -r 132ca04d9583 sys/dev/pci/if_bgereg.h
--- a/sys/dev/pci/if_bgereg.h   Tue Mar 19 02:56:16 2013 +0000
+++ b/sys/dev/pci/if_bgereg.h   Tue Mar 19 03:40:16 2013 +0000
@@ -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 @@
 #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



Home | Main Index | Thread Index | Old Index