Source-Changes-HG archive

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

[src/trunk]: src/sys Add MCA ep(4) attachment, for 3Com 3c529-type cards. Tes...



details:   https://anonhg.NetBSD.org/src/rev/c8dc76988302
branches:  trunk
changeset: 507461:c8dc76988302
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Thu Mar 22 16:54:45 2001 +0000

description:
Add MCA ep(4) attachment, for 3Com 3c529-type cards. Tested with 3c529-TP,
provided to me by David Brownlee (thanks!).

Performance of this card is quite poor on my PS/2 with 386DX, like 100KB/s
at best, but as low as 5KB/s when transferring bigger files due to
packet overruns. It would be good to revisit this later, probably by
teaching the ic code to use RX Early.

diffstat:

 sys/arch/i386/conf/PS2  |    3 +-
 sys/dev/ic/elink3.c     |   13 +-
 sys/dev/ic/elink3var.h  |    3 +-
 sys/dev/mca/files.mca   |    8 +-
 sys/dev/mca/if_ep_mca.c |  263 ++++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 281 insertions(+), 9 deletions(-)

diffs (truncated from 364 to 300 lines):

diff -r 62dec2c6efef -r c8dc76988302 sys/arch/i386/conf/PS2
--- a/sys/arch/i386/conf/PS2    Thu Mar 22 15:56:43 2001 +0000
+++ b/sys/arch/i386/conf/PS2    Thu Mar 22 16:54:45 2001 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: PS2,v 1.10 2001/03/19 22:08:17 jdolecek Exp $
+#      $NetBSD: PS2,v 1.11 2001/03/22 16:54:45 jdolecek Exp $
 #
 #      Sample kernel config for PS/2 with MCA bus
 #
@@ -112,6 +112,7 @@
 
 # MCA network devices
 elmc*  at mca? slot ?                  # 3Com EtherLink/MC (3c523)
+ep*    at mca? slot ?                  # 3Com EtherLink III (3c529)
 
 # MCA SCSI controllers
 aha*   at mca? slot ?                  # Adaptec AHA-1640
diff -r 62dec2c6efef -r c8dc76988302 sys/dev/ic/elink3.c
--- a/sys/dev/ic/elink3.c       Thu Mar 22 15:56:43 2001 +0000
+++ b/sys/dev/ic/elink3.c       Thu Mar 22 16:54:45 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: elink3.c,v 1.88 2001/03/22 12:00:26 jdolecek Exp $     */
+/*     $NetBSD: elink3.c,v 1.89 2001/03/22 16:54:46 jdolecek Exp $     */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -585,7 +585,7 @@
  * Use the config_cntrl register  in window 0 instead.
  * Used on original, 10Mbit ISA (3c509), 3c509B, and pre-Demon EISA cards
  * that implement  CONFIG_CTRL.  We don't have a good way to set the
- * default active mediuim; punt to ifconfig  instead.
+ * default active medium; punt to ifconfig  instead.
  */
 void
 ep_509_probemedia(sc)
@@ -772,7 +772,8 @@
         */
        epstop(ifp, 0);
 
-       if (sc->bustype != ELINK_BUS_PCI && sc->bustype != ELINK_BUS_EISA) {
+       if (sc->bustype != ELINK_BUS_PCI && sc->bustype != ELINK_BUS_EISA
+           && sc->bustype != ELINK_BUS_MCA) {
                GO_WINDOW(0);
                bus_space_write_2(iot, ioh, ELINK_W0_CONFIG_CTRL, 0);
                bus_space_write_2(iot, ioh, ELINK_W0_CONFIG_CTRL,
@@ -783,6 +784,12 @@
                bus_space_write_2(iot, ioh, ELINK_W0_RESOURCE_CFG, 0x3f00);
        }
 
+       if (sc->bustype == ELINK_BUS_MCA) {
+               /* use Synchronous Read mode of operation */
+               GO_WINDOW(0);
+               bus_space_write_2(iot, ioh, ELINK_W0_RESOURCE_CFG, 1<<6);
+       }
+
        GO_WINDOW(2);
        for (i = 0; i < 6; i++) /* Reload the ether_addr. */
                bus_space_write_1(iot, ioh, ELINK_W2_ADDR_0 + i,
diff -r 62dec2c6efef -r c8dc76988302 sys/dev/ic/elink3var.h
--- a/sys/dev/ic/elink3var.h    Thu Mar 22 15:56:43 2001 +0000
+++ b/sys/dev/ic/elink3var.h    Thu Mar 22 16:54:45 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: elink3var.h,v 1.27 2001/03/22 12:00:26 jdolecek Exp $  */
+/*     $NetBSD: elink3var.h,v 1.28 2001/03/22 16:54:46 jdolecek Exp $  */
 
 /*
  * Copyright (c) 1994 Herb Peyerl <hpeyerl%beer.org@localhost>
@@ -96,6 +96,7 @@
 #define        ELINK_BUS_PCMCIA                0x1
 #define        ELINK_BUS_EISA          0x2
 #define ELINK_BUS_PCI          0x3
+#define ELINK_BUS_MCA          0x6
 
 #define ELINK_IS_BUS_32(a)     ((a) & 0x2)
        int ep_pktlenshift;             /* scale factor for pkt lengths */
diff -r 62dec2c6efef -r c8dc76988302 sys/dev/mca/files.mca
--- a/sys/dev/mca/files.mca     Thu Mar 22 15:56:43 2001 +0000
+++ b/sys/dev/mca/files.mca     Thu Mar 22 16:54:45 2001 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.mca,v 1.5 2001/03/19 21:58:09 jdolecek Exp $
+# $NetBSD: files.mca,v 1.6 2001/03/22 16:54:46 jdolecek Exp $
 #
 # Config.new file and device description for machine-independent MCA code.
 # Included by ports that need it.
@@ -10,9 +10,9 @@
 file   dev/mca/mca.c                   mca                     needs-flag
 file   dev/mca/mca_subr.c              mca
 
-# 3Com 3C529 (not yet)
-#attach        ep at mca with ep_mca: elink
-#file  dev/mca/if_ep_mca.c             ep_mca
+# 3Com 3C529
+attach ep at mca with ep_mca: elink
+file   dev/mca/if_ep_mca.c             ep_mca
 
 # WD/SMC 80x3/A (not yet)
 #device        we: ether, ifnet, arp, dp8390nic
diff -r 62dec2c6efef -r c8dc76988302 sys/dev/mca/if_ep_mca.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/mca/if_ep_mca.c   Thu Mar 22 16:54:45 2001 +0000
@@ -0,0 +1,263 @@
+/*     $NetBSD: if_ep_mca.c,v 1.1 2001/03/22 16:54:46 jdolecek Exp $   */
+
+/*-
+ * Copyright (c) 2001 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jaromir Dolecek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the NetBSD
+ *     Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Copyright (c) 1997 Jonathan Stone <jonathan%NetBSD.org@localhost>
+ * Copyright (c) 1994 Herb Peyerl <hpeyerl%beer.org@localhost>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by Herb Peyerl.
+ * 4. The name of Herb Peyerl may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Driver for 3Com 3c529 cards.
+ *
+ * Known issues:
+ * - on my 386DX, speed of network is like 100KB/s at best; for bigger
+ *   files fetched e.g. via ftp, I get as low as 5KB/s, mostly due
+ *   to excessive number of overrun packets. Configuring system to
+ *   use smaller TCP window might help, though the performance is
+ *   still expected to be very dependant on CPU speed, especially
+ *   since ISA and PCI attachments are reported to work OK on pentium
+ *   class systems.
+ *   Changing ic/elink3.c to use RX Early might help here potentially.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/mbuf.h> 
+#include <sys/socket.h> 
+#include <sys/ioctl.h>
+#include <sys/errno.h>
+#include <sys/device.h>
+
+#include <net/if.h>
+#include <net/if_ether.h>
+#include <net/if_media.h>
+
+#include <machine/bus.h>
+#include <machine/intr.h>
+
+#include <dev/mii/miivar.h>
+
+#include <dev/ic/elink3var.h>
+#include <dev/ic/elink3reg.h>
+
+#include <dev/mca/mcavar.h>
+#include <dev/mca/mcadevs.h>
+
+/*
+ * MCA constants.
+ */
+#define MCA_CBIO               0x200   /* Configuration Base IO Address */
+#define MCA_IOSZ               0x10    /* I/O space size */
+
+int ep_mca_match __P((struct device *, struct cfdata *, void *));
+void ep_mca_attach __P((struct device *, struct device *, void *));
+
+struct cfattach ep_mca_ca = {
+       sizeof(struct ep_softc), ep_mca_match, ep_mca_attach
+};
+
+const struct ep_mca_product {
+       u_int32_t       epp_prodid;     /* MCA product ID */
+       const char      *epp_name;      /* device name */
+} ep_mca_products[] = {
+       { MCA_PRODUCT_3C529_TP, "3c529-TP Ethernet Adapter" },
+       { MCA_PRODUCT_3C529_TM, "3c529 Ethernet Adapter (test mode)" },
+       { MCA_PRODUCT_3C529_2T, "3c529 Ethernet Adapter (10base2/T)" },
+       { MCA_PRODUCT_3C529_T,  "3c529 Ethernet Adapter (10baseT)"   },
+
+       { 0,                    NULL },
+};
+
+static const struct ep_mca_product *ep_mca_lookup
+    __P((const struct mca_attach_args *));
+
+static const struct ep_mca_product *
+ep_mca_lookup(ma)
+       const struct mca_attach_args *ma;
+{
+       const struct ep_mca_product *epp;
+
+       for (epp = ep_mca_products; epp->epp_name != NULL; epp++)
+               if (ma->ma_id == epp->epp_prodid)
+                       return (epp);
+
+       return (NULL);
+}
+
+int
+ep_mca_match(parent, match, aux)
+       struct device *parent;
+       struct cfdata *match;
+       void *aux;
+{
+       struct mca_attach_args *ma = (struct mca_attach_args *) aux;
+
+       if (ep_mca_lookup(ma) != NULL)
+               return (1);
+
+       return (0);
+}
+
+void
+ep_mca_attach(parent, self, aux)
+       struct device *parent, *self;
+       void *aux;
+{
+       struct ep_softc *sc = (void *)self;
+       struct mca_attach_args *ma = aux;
+       bus_space_handle_t ioh;
+       int pos4, pos5, iobase, irq, media;
+       const struct ep_mca_product *epp;
+
+       pos4 = mca_conf_read(ma->ma_mc, ma->ma_slot, 4);
+       pos5 = mca_conf_read(ma->ma_mc, ma->ma_slot, 5);
+
+       /*
+        * POS register 2: (adf pos0)
+        * 7 6 5 4 3 2 1 0
+        *               \__ enable: 0=adapter disabled, 1=adapter enabled
+        *
+        * POS register 3: (adf pos1)
+        * 
+        * 7 6 5 4 3 2 1 0
+        * \________/
+        *          \_______ Boot ROM Address Range: 0=disabled
+        *                     X=0xc2000-0xc3fff + (x * 0x2000)
+        *
+        * POS register 4: (adf pos2)
+        * 
+        * 7 6 5 4 3 2 1 0
+        * \________/  \_/ 
+        *          \    \__ Transceiver Type: 00=on-board (RJ45), 01=ext(AUI)
+        *           \______ I/O Address Range: 0x200-0x20f + ((x>>2) * 0x400)
+        *
+        * POS register 5: (adf pos3)
+        * 
+        * 7 6 5 4 3 2 1 0
+        *          \____/
+        *               \__ Interrupt level



Home | Main Index | Thread Index | Old Index