Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/ic If we're running on a Connectix Virtual PC, we mi...



details:   https://anonhg.NetBSD.org/src/rev/255156aef37c
branches:  trunk
changeset: 556489:255156aef37c
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Thu Dec 18 18:39:36 2003 +0000

description:
If we're running on a Connectix Virtual PC, we might get a packet longer
than a max size Ethernet frame without getting a frame-too-long error.  VPC
seems to be adding 4 zeros at the end of every frame.  Detect this condition
and simply truncate the packet to a max size Ethernet frame.

I now have no problems with networking on NetBSD inside Virtual PC 6.

diffstat:

 sys/dev/ic/tulip.c    |  32 ++++++++++++++++++++++++++++++--
 sys/dev/ic/tulipvar.h |   3 ++-
 2 files changed, 32 insertions(+), 3 deletions(-)

diffs (77 lines):

diff -r a2f4e125c23d -r 255156aef37c sys/dev/ic/tulip.c
--- a/sys/dev/ic/tulip.c        Thu Dec 18 18:30:18 2003 +0000
+++ b/sys/dev/ic/tulip.c        Thu Dec 18 18:39:36 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tulip.c,v 1.125 2003/10/25 19:12:08 christos Exp $     */
+/*     $NetBSD: tulip.c,v 1.126 2003/12/18 18:39:36 thorpej Exp $      */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2002 The NetBSD Foundation, Inc.
@@ -43,7 +43,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tulip.c,v 1.125 2003/10/25 19:12:08 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tulip.c,v 1.126 2003/12/18 18:39:36 thorpej Exp $");
 
 #include "bpfilter.h"
 
@@ -482,6 +482,13 @@
            ether_sprintf(enaddr));
 
        /*
+        * Check to see if we're the simulated Ethernet on Connectix
+        * Virtual PC.
+        */
+       if (enaddr[0] == 0x00 && enaddr[1] == 0x03 && enaddr[2] == 0xff)
+               sc->sc_flags |= TULIPF_VPC;
+
+       /*
         * Initialize our media structures.  This may probe the MII, if
         * present.
         */
@@ -1356,6 +1363,27 @@
                m->m_pkthdr.rcvif = ifp;
                m->m_pkthdr.len = m->m_len = len;
 
+               /*
+                * XXX Work-around for a weird problem with the emulated
+                * 21041 on Connectix Virtual PC:
+                *
+                * When we receive a full-size TCP segment, we seem to get
+                * a packet there the Rx status says 1522 bytes, yet we do
+                * not get a frame-too-long error from the chip.  The extra
+                * bytes seem to always be zeros.  Perhaps Virtual PC is
+                * inserting 4 bytes of zeros after every packet.  In any
+                * case, let's try and detect this condition and truncate
+                * the length so that it will pass up the stack.
+                */
+               if (__predict_false((sc->sc_flags & TULIPF_VPC) != 0)) {
+                       uint16_t etype = ntohs(eh->ether_type);
+
+                       if (len > ETHER_MAX_FRAME(ifp, etype,
+                                                 M_HASFCS))
+                               m->m_pkthdr.len = m->m_len = len =
+                                   ETHER_MAX_FRAME(ifp, etype, M_HASFCS);
+               }
+
 #if NBPFILTER > 0
                /*
                 * Pass this up to any BPF listeners, but only
diff -r a2f4e125c23d -r 255156aef37c sys/dev/ic/tulipvar.h
--- a/sys/dev/ic/tulipvar.h     Thu Dec 18 18:30:18 2003 +0000
+++ b/sys/dev/ic/tulipvar.h     Thu Dec 18 18:39:36 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tulipvar.h,v 1.49 2003/11/02 11:07:46 wiz Exp $        */
+/*     $NetBSD: tulipvar.h,v 1.50 2003/12/18 18:39:36 thorpej Exp $    */
 
 /*-
  * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc.
@@ -475,6 +475,7 @@
 #define        TULIPF_ENABLED          0x00001000      /* chip is enabled */
 #define        TULIPF_BLE              0x00002000      /* data is big endian */
 #define        TULIPF_DBO              0x00004000      /* descriptor is big endian */
+#define        TULIPF_VPC              0x00008000      /* Virtual PC Ethernet */
 
 #define        TULIP_IS_ENABLED(sc)    ((sc)->sc_flags & TULIPF_ENABLED)
 



Home | Main Index | Thread Index | Old Index