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 some logic errors in multi-descriptor pack...



details:   https://anonhg.NetBSD.org/src/rev/3753260e226d
branches:  trunk
changeset: 573503:3753260e226d
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Sun Jan 30 18:56:34 2005 +0000

description:
- Fix some logic errors in multi-descriptor packet reception case for
  DP83820.
- Eliminate use of M_HASFCS.

diffstat:

 sys/dev/pci/if_sip.c |  37 +++++++++++++++----------------------
 1 files changed, 15 insertions(+), 22 deletions(-)

diffs (114 lines):

diff -r 2e5ea0b1b2c8 -r 3753260e226d sys/dev/pci/if_sip.c
--- a/sys/dev/pci/if_sip.c      Sun Jan 30 18:13:04 2005 +0000
+++ b/sys/dev/pci/if_sip.c      Sun Jan 30 18:56:34 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_sip.c,v 1.96 2004/10/30 18:09:22 thorpej Exp $      */
+/*     $NetBSD: if_sip.c,v 1.97 2005/01/30 18:56:34 thorpej Exp $      */
 
 /*-
  * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@@ -80,7 +80,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_sip.c,v 1.96 2004/10/30 18:09:22 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_sip.c,v 1.97 2005/01/30 18:56:34 thorpej Exp $");
 
 #include "bpfilter.h"
 #include "rnd.h"
@@ -1799,9 +1799,9 @@
 {
        struct ifnet *ifp = &sc->sc_ethercom.ec_if;
        struct sip_rxsoft *rxs;
-       struct mbuf *m, *tailm;
+       struct mbuf *m;
        u_int32_t cmdsts, extsts;
-       int i, len, frame_len;
+       int i, len;
 
        for (i = sc->sc_rxptr;; i = SIP_NEXTRX(i)) {
                rxs = &sc->sc_rxsoft[i];
@@ -1810,6 +1810,7 @@
 
                cmdsts = le32toh(sc->sc_rxdescs[i].sipd_cmdsts);
                extsts = le32toh(sc->sc_rxdescs[i].sipd_extsts);
+               len = CMDSTS_SIZE(cmdsts);
 
                /*
                 * NOTE: OWN is set if owned by _consumer_.  We're the
@@ -1859,22 +1860,26 @@
 
                SIP_RXCHAIN_LINK(sc, m);
 
+               m->m_len = len;
+
                /*
                 * If this is not the end of the packet, keep
                 * looking.
                 */
                if (cmdsts & CMDSTS_MORE) {
-                       sc->sc_rxlen += m->m_len;
+                       sc->sc_rxlen += len;
                        continue;
                }
 
                /*
-                * Okay, we have the entire packet now...
+                * Okay, we have the entire packet now.  The chip includes
+                * the FCS, so we need to trim it.
                 */
+               m->m_len -= ETHER_CRC_LEN;
+
                *sc->sc_rxtailp = NULL;
                m = sc->sc_rxhead;
-               tailm = sc->sc_rxtail;
-               frame_len = sc->sc_rxlen;
+               len = m->m_len + sc->sc_rxlen;
 
                SIP_RXCHAIN_RESET(sc);
 
@@ -1904,16 +1909,6 @@
                }
 
                /*
-                * No errors.
-                *
-                * Note, the DP83820 includes the CRC with
-                * every packet.
-                */
-               len = CMDSTS_SIZE(cmdsts);
-               frame_len += len;
-               tailm->m_len = len;
-
-               /*
                 * If the packet is small enough to fit in a
                 * single header mbuf, allocate one and copy
                 * the data into it.  This greatly reduces
@@ -1997,9 +1992,8 @@
                }
 
                ifp->if_ipackets++;
-               m->m_flags |= M_HASFCS;
                m->m_pkthdr.rcvif = ifp;
-               m->m_pkthdr.len = frame_len;
+               m->m_pkthdr.len = len;
 
 #if NBPFILTER > 0
                /*
@@ -2091,7 +2085,7 @@
                 * No errors; receive the packet.  Note, the SiS 900
                 * includes the CRC with every packet.
                 */
-               len = CMDSTS_SIZE(cmdsts);
+               len = CMDSTS_SIZE(cmdsts) - ETHER_CRC_LEN;
 
 #ifdef __NO_STRICT_ALIGNMENT
                /*
@@ -2166,7 +2160,6 @@
 #endif /* __NO_STRICT_ALIGNMENT */
 
                ifp->if_ipackets++;
-               m->m_flags |= M_HASFCS;
                m->m_pkthdr.rcvif = ifp;
                m->m_pkthdr.len = m->m_len = len;
 



Home | Main Index | Thread Index | Old Index