Source-Changes-HG archive

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

[src/netbsd-1-5]: src/sys/dev/ic Pull up revisions 1.45-1.53, 1.55-1.57, 1.60, 1...



details:   https://anonhg.NetBSD.org/src/rev/aa1e0eae850a
branches:  netbsd-1-5
changeset: 493113:aa1e0eae850a
user:      he <he%NetBSD.org@localhost>
date:      Thu Jun 06 19:41:07 2002 +0000

description:
Pull up revisions 1.45-1.53,1.55-1.57,1.60,1.62-1.63,1.65-1.66 (via patch,
    requested by mycroft):
  Work around a bug which can cause some machines to randomly hang.
  Drag along performance improvements and improved hardware support.

diffstat:

 sys/dev/ic/i82557.c |  905 ++++++++++++++++++++++++++++++---------------------
 1 files changed, 536 insertions(+), 369 deletions(-)

diffs (truncated from 1463 to 300 lines):

diff -r 88c2c78124a7 -r aa1e0eae850a sys/dev/ic/i82557.c
--- a/sys/dev/ic/i82557.c       Thu Jun 06 17:10:37 2002 +0000
+++ b/sys/dev/ic/i82557.c       Thu Jun 06 19:41:07 2002 +0000
@@ -1,7 +1,7 @@
-/*     $NetBSD: i82557.c,v 1.34.2.3 2001/05/06 15:04:55 he Exp $       */
+/*     $NetBSD: i82557.c,v 1.34.2.4 2002/06/06 19:41:07 he Exp $       */
 
 /*-
- * Copyright (c) 1997, 1998, 1999 The NetBSD Foundation, Inc.
+ * Copyright (c) 1997, 1998, 1999, 2001, 2002 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
@@ -39,6 +39,7 @@
 
 /*
  * Copyright (c) 1995, David Greenman
+ * Copyright (c) 2001 Jonathan Lemon <jlemon%freebsd.org@localhost>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -63,7 +64,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *     Id: if_fxp.c,v 1.47 1998/01/08 23:42:29 eivind Exp
+ *     Id: if_fxp.c,v 1.113 2001/05/17 23:50:24 jlemon
  */
 
 /*
@@ -134,71 +135,89 @@
 #define        RFA_ALIGNMENT_FUDGE     2
 
 /*
- * Template for default configuration parameters.
- * See struct fxp_cb_config for the bit definitions.
+ * The configuration byte map has several undefined fields which
+ * must be one or must be zero.  Set up a template for these bits
+ * only (assuming an i82557 chip), leaving the actual configuration
+ * for fxp_init().
+ *
+ * See the definition of struct fxp_cb_config for the bit definitions.
  */
-u_int8_t fxp_cb_config_template[] = {
+const u_int8_t fxp_cb_config_template[] = {
        0x0, 0x0,               /* cb_status */
-       0x80, 0x2,              /* cb_command */
-       0xff, 0xff, 0xff, 0xff, /* link_addr */
-       0x16,   /*  0 */
-       0x8,    /*  1 */
+       0x0, 0x0,               /* cb_command */
+       0x0, 0x0, 0x0, 0x0,     /* link_addr */
+       0x0,    /*  0 */
+       0x0,    /*  1 */
        0x0,    /*  2 */
        0x0,    /*  3 */
        0x0,    /*  4 */
-       0x80,   /*  5 */
-       0xb2,   /*  6 */
-       0x3,    /*  7 */
-       0x1,    /*  8 */
+       0x0,    /*  5 */
+       0x32,   /*  6 */
+       0x0,    /*  7 */
+       0x0,    /*  8 */
        0x0,    /*  9 */
-       0x26,   /* 10 */
+       0x6,    /* 10 */
        0x0,    /* 11 */
-       0x60,   /* 12 */
+       0x0,    /* 12 */
        0x0,    /* 13 */
        0xf2,   /* 14 */
        0x48,   /* 15 */
        0x0,    /* 16 */
        0x40,   /* 17 */
-       0xf3,   /* 18 */
+       0xf0,   /* 18 */
        0x0,    /* 19 */
        0x3f,   /* 20 */
-       0x5     /* 21 */
+       0x5,    /* 21 */
+       0x0,    /* 22 */
+       0x0,    /* 23 */
+       0x0,    /* 24 */
+       0x0,    /* 25 */
+       0x0,    /* 26 */
+       0x0,    /* 27 */
+       0x0,    /* 28 */
+       0x0,    /* 29 */
+       0x0,    /* 30 */
+       0x0,    /* 31 */
 };
 
-void   fxp_mii_initmedia __P((struct fxp_softc *));
-int    fxp_mii_mediachange __P((struct ifnet *));
-void   fxp_mii_mediastatus __P((struct ifnet *, struct ifmediareq *));
+void   fxp_mii_initmedia(struct fxp_softc *);
+int    fxp_mii_mediachange(struct ifnet *);
+void   fxp_mii_mediastatus(struct ifnet *, struct ifmediareq *);
 
-void   fxp_80c24_initmedia __P((struct fxp_softc *));
-int    fxp_80c24_mediachange __P((struct ifnet *));
-void   fxp_80c24_mediastatus __P((struct ifnet *, struct ifmediareq *));
+void   fxp_80c24_initmedia(struct fxp_softc *);
+int    fxp_80c24_mediachange(struct ifnet *);
+void   fxp_80c24_mediastatus(struct ifnet *, struct ifmediareq *);
 
-inline void fxp_scb_wait __P((struct fxp_softc *));
+void   fxp_start(struct ifnet *);
+int    fxp_ioctl(struct ifnet *, u_long, caddr_t);
+void   fxp_watchdog(struct ifnet *);
+int    fxp_init(struct fxp_softc *);
+void   fxp_stop(struct fxp_softc *, int);
 
-void   fxp_start __P((struct ifnet *));
-int    fxp_ioctl __P((struct ifnet *, u_long, caddr_t));
-int    fxp_init __P((struct fxp_softc *));
-void   fxp_rxdrain __P((struct fxp_softc *));
-void   fxp_stop __P((struct fxp_softc *, int));
-void   fxp_watchdog __P((struct ifnet *));
-int    fxp_add_rfabuf __P((struct fxp_softc *, bus_dmamap_t, int));
-int    fxp_mdi_read __P((struct device *, int, int));
-void   fxp_statchg __P((struct device *));
-void   fxp_mdi_write __P((struct device *, int, int, int));
-void   fxp_autosize_eeprom __P((struct fxp_softc*));
-void   fxp_read_eeprom __P((struct fxp_softc *, u_int16_t *, int, int));
-void   fxp_get_info __P((struct fxp_softc *, u_int8_t *));
-void   fxp_tick __P((void *));
-void   fxp_mc_setup __P((struct fxp_softc *));
+void   fxp_txintr(struct fxp_softc *);
+void   fxp_rxintr(struct fxp_softc *);
 
-void   fxp_shutdown __P((void *));
-void   fxp_power __P((int, void *));
+void   fxp_rxdrain(struct fxp_softc *);
+int    fxp_add_rfabuf(struct fxp_softc *, bus_dmamap_t, int);
+int    fxp_mdi_read(struct device *, int, int);
+void   fxp_statchg(struct device *);
+void   fxp_mdi_write(struct device *, int, int, int);
+void   fxp_autosize_eeprom(struct fxp_softc*);
+void   fxp_read_eeprom(struct fxp_softc *, u_int16_t *, int, int);
+void   fxp_write_eeprom(struct fxp_softc *, u_int16_t *, int, int);
+void   fxp_eeprom_update_cksum(struct fxp_softc *);
+void   fxp_get_info(struct fxp_softc *, u_int8_t *);
+void   fxp_tick(void *);
+void   fxp_mc_setup(struct fxp_softc *);
+
+void   fxp_shutdown(void *);
+void   fxp_power(int, void *);
 
 int    fxp_copy_small = 0;
 
 struct fxp_phytype {
        int     fp_phy;         /* type of PHY, -1 for MII at the end. */
-       void    (*fp_init) __P((struct fxp_softc *));
+       void    (*fp_init)(struct fxp_softc *);
 } fxp_phytype_table[] = {
        { FXP_PHY_80C24,                fxp_80c24_initmedia },
        { -1,                           fxp_mii_initmedia },
@@ -215,9 +234,8 @@
  * Wait for the previous command to be accepted (but not necessarily
  * completed).
  */
-inline void
-fxp_scb_wait(sc)
-       struct fxp_softc *sc;
+static __inline void
+fxp_scb_wait(struct fxp_softc *sc)
 {
        int i = 10000;
 
@@ -228,11 +246,20 @@
 }
 
 /*
+ * Submit a command to the i82557.
+ */
+static __inline void
+fxp_scb_cmd(struct fxp_softc *sc, u_int8_t cmd)
+{
+
+       CSR_WRITE_1(sc, FXP_CSR_SCB_COMMAND, cmd);
+}
+
+/*
  * Finish attaching an i82557 interface.  Called by bus-specific front-end.
  */
 void
-fxp_attach(sc)
-       struct fxp_softc *sc;
+fxp_attach(struct fxp_softc *sc)
 {
        u_int8_t enaddr[6];
        struct ifnet *ifp;
@@ -242,6 +269,17 @@
 
        callout_init(&sc->sc_callout);
 
+       /* Start out using the standard RFA. */
+       sc->sc_rfa_size = RFA_SIZE;
+
+       /*
+        * Enable some good stuff on i82558 and later.
+        */
+       if (sc->sc_rev >= FXP_REV_82558_A4) {
+               /* Enable the extended TxCB. */
+               sc->sc_flags |= FXPF_EXT_TXCB;
+       }
+
        /*
         * Allocate the control data structures, and create and load the
         * DMA map for it.
@@ -264,7 +302,7 @@
        sc->sc_cdseg = seg;
        sc->sc_cdnseg = rseg;
 
-       bzero(sc->sc_control_data, sizeof(struct fxp_control_data));
+       memset(sc->sc_control_data, 0, sizeof(struct fxp_control_data));
 
        if ((error = bus_dmamap_create(sc->sc_dmat,
            sizeof(struct fxp_control_data), 1,
@@ -310,8 +348,8 @@
        /* Initialize MAC address and media structures. */
        fxp_get_info(sc, enaddr);
 
-       printf("%s: Ethernet address %s, %s Mb/s\n", sc->sc_dev.dv_xname,
-           ether_sprintf(enaddr), sc->phy_10Mbps_only ? "10" : "10/100");
+       printf("%s: Ethernet address %s\n", sc->sc_dev.dv_xname,
+           ether_sprintf(enaddr));
 
        ifp = &sc->sc_ethercom.ec_if;
 
@@ -325,7 +363,7 @@
                        break;
        (*fp->fp_init)(sc);
 
-       bcopy(sc->sc_dev.dv_xname, ifp->if_xname, IFNAMSIZ);
+       strcpy(ifp->if_xname, sc->sc_dev.dv_xname);
        ifp->if_softc = sc;
        ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
        ifp->if_ioctl = fxp_ioctl;
@@ -351,6 +389,15 @@
            RND_TYPE_NET, 0);
 #endif
 
+#ifdef FXP_EVENT_COUNTERS
+       evcnt_attach_dynamic(&sc->sc_ev_txstall, EVCNT_TYPE_MISC,
+           NULL, sc->sc_dev.dv_xname, "txstall");
+       evcnt_attach_dynamic(&sc->sc_ev_txintr, EVCNT_TYPE_INTR,
+           NULL, sc->sc_dev.dv_xname, "txintr");
+       evcnt_attach_dynamic(&sc->sc_ev_rxintr, EVCNT_TYPE_INTR,
+           NULL, sc->sc_dev.dv_xname, "rxintr");
+#endif /* FXP_EVENT_COUNTERS */
+
        /*
         * Add shutdown hook so that DMA is disabled prior to reboot. Not
         * doing do could allow DMA to corrupt kernel memory during the
@@ -401,8 +448,7 @@
 }
 
 void
-fxp_mii_initmedia(sc)
-       struct fxp_softc *sc;
+fxp_mii_initmedia(struct fxp_softc *sc)
 {
 
        sc->sc_flags |= FXPF_MII;
@@ -426,8 +472,7 @@
 }
 
 void
-fxp_80c24_initmedia(sc)
-       struct fxp_softc *sc;
+fxp_80c24_initmedia(struct fxp_softc *sc)
 {
 
        /*
@@ -450,8 +495,7 @@
  * kernel memory doesn't get clobbered during warmboot.
  */
 void
-fxp_shutdown(arg)
-       void *arg;
+fxp_shutdown(void *arg)
 {
        struct fxp_softc *sc = arg;
 
@@ -468,9 +512,7 @@
  * clobber kernel memory at the wrong time.
  */
 void
-fxp_power(why, arg)
-       int why;
-       void *arg;
+fxp_power(int why, void *arg)
 {
        struct fxp_softc *sc = arg;
        struct ifnet *ifp;
@@ -499,9 +541,7 @@



Home | Main Index | Thread Index | Old Index