Home | History | Annotate | Line # | Download | only in ic
seeq8005.c revision 1.37
      1  1.37    perry /* $NetBSD: seeq8005.c,v 1.37 2005/02/27 00:27:02 perry Exp $ */
      2   1.1    bjh21 
      3   1.1    bjh21 /*
      4  1.27    bjh21  * Copyright (c) 2000, 2001 Ben Harris
      5  1.11    bjh21  * Copyright (c) 1995-1998 Mark Brinicombe
      6   1.1    bjh21  * All rights reserved.
      7   1.1    bjh21  *
      8   1.1    bjh21  * Redistribution and use in source and binary forms, with or without
      9   1.1    bjh21  * modification, are permitted provided that the following conditions
     10   1.1    bjh21  * are met:
     11   1.1    bjh21  * 1. Redistributions of source code must retain the above copyright
     12   1.1    bjh21  *    notice, this list of conditions and the following disclaimer.
     13   1.1    bjh21  * 2. Redistributions in binary form must reproduce the above copyright
     14   1.1    bjh21  *    notice, this list of conditions and the following disclaimer in the
     15   1.1    bjh21  *    documentation and/or other materials provided with the distribution.
     16   1.1    bjh21  * 3. All advertising materials mentioning features or use of this software
     17   1.1    bjh21  *    must display the following acknowledgement:
     18  1.11    bjh21  *	This product includes software developed by Mark Brinicombe
     19  1.11    bjh21  *	for the NetBSD Project.
     20   1.1    bjh21  * 4. The name of the company nor the name of the author may be used to
     21   1.1    bjh21  *    endorse or promote products derived from this software without specific
     22   1.1    bjh21  *    prior written permission.
     23   1.1    bjh21  *
     24   1.1    bjh21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
     25   1.1    bjh21  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
     26   1.1    bjh21  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     27   1.1    bjh21  * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
     28   1.1    bjh21  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     29   1.1    bjh21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     30   1.1    bjh21  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     31   1.1    bjh21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     32   1.1    bjh21  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     33   1.1    bjh21  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     34   1.1    bjh21  * SUCH DAMAGE.
     35   1.1    bjh21  */
     36   1.1    bjh21 /*
     37   1.2    bjh21  * seeq8005.c - SEEQ 8005 device driver
     38   1.2    bjh21  */
     39   1.2    bjh21 /*
     40  1.24    bjh21  * This driver currently supports the following chips:
     41   1.2    bjh21  * SEEQ 8005 Advanced Ethernet Data Link Controller
     42  1.20    bjh21  * SEEQ 80C04 Ethernet Data Link Controller
     43  1.20    bjh21  * SEEQ 80C04A AutoDUPLEX CMOS Ethernet Data Link Controller
     44   1.2    bjh21  */
     45   1.2    bjh21 /*
     46  1.11    bjh21  * More information on the 8004 and 8005 AEDLC controllers can be found in
     47  1.11    bjh21  * the SEEQ Technology Inc 1992 Data Comm Devices data book.
     48  1.11    bjh21  *
     49  1.11    bjh21  * This data book may no longer be available as these are rather old chips
     50  1.11    bjh21  * (1991 - 1993)
     51  1.11    bjh21  */
     52  1.11    bjh21 /*
     53   1.2    bjh21  * This driver is based on the arm32 ea(4) driver, hence the names of many
     54   1.2    bjh21  * of the functions.
     55   1.1    bjh21  */
     56   1.1    bjh21 /*
     57   1.1    bjh21  * Bugs/possible improvements:
     58   1.1    bjh21  *	- Does not currently support DMA
     59   1.1    bjh21  *	- Does not transmit multiple packets in one go
     60   1.1    bjh21  *	- Does not support 8-bit busses
     61   1.1    bjh21  */
     62   1.1    bjh21 
     63  1.31    lukem #include <sys/cdefs.h>
     64  1.37    perry __KERNEL_RCSID(0, "$NetBSD: seeq8005.c,v 1.37 2005/02/27 00:27:02 perry Exp $");
     65  1.31    lukem 
     66   1.1    bjh21 #include <sys/param.h>
     67   1.1    bjh21 #include <sys/systm.h>
     68   1.1    bjh21 #include <sys/endian.h>
     69   1.1    bjh21 #include <sys/errno.h>
     70   1.1    bjh21 #include <sys/ioctl.h>
     71   1.1    bjh21 #include <sys/mbuf.h>
     72   1.1    bjh21 #include <sys/socket.h>
     73   1.1    bjh21 #include <sys/syslog.h>
     74   1.1    bjh21 #include <sys/device.h>
     75   1.1    bjh21 
     76   1.1    bjh21 #include <net/if.h>
     77   1.1    bjh21 #include <net/if_dl.h>
     78   1.1    bjh21 #include <net/if_types.h>
     79   1.1    bjh21 #include <net/if_ether.h>
     80  1.11    bjh21 #include <net/if_media.h>
     81   1.1    bjh21 
     82   1.1    bjh21 #include "bpfilter.h"
     83   1.1    bjh21 #if NBPFILTER > 0
     84   1.1    bjh21 #include <net/bpf.h>
     85   1.1    bjh21 #include <net/bpfdesc.h>
     86   1.1    bjh21 #endif
     87   1.1    bjh21 
     88  1.30    bjh21 #include "rnd.h"
     89  1.30    bjh21 #if NRND > 0
     90  1.30    bjh21 #include <sys/rnd.h>
     91  1.30    bjh21 #endif
     92  1.30    bjh21 
     93   1.1    bjh21 #include <machine/bus.h>
     94   1.1    bjh21 #include <machine/intr.h>
     95   1.1    bjh21 
     96   1.1    bjh21 #include <dev/ic/seeq8005reg.h>
     97   1.1    bjh21 #include <dev/ic/seeq8005var.h>
     98   1.1    bjh21 
     99  1.10    bjh21 /*#define SEEQ_DEBUG*/
    100   1.1    bjh21 
    101   1.1    bjh21 /* for debugging convenience */
    102  1.16    bjh21 #ifdef SEEQ8005_DEBUG
    103  1.11    bjh21 #define SEEQ_DEBUG_MISC		1
    104  1.11    bjh21 #define SEEQ_DEBUG_TX		2
    105  1.11    bjh21 #define SEEQ_DEBUG_RX		4
    106  1.11    bjh21 #define SEEQ_DEBUG_PKT		8
    107  1.11    bjh21 #define SEEQ_DEBUG_TXINT	16
    108  1.11    bjh21 #define SEEQ_DEBUG_RXINT	32
    109  1.16    bjh21 int seeq8005_debug = 0;
    110  1.16    bjh21 #define DPRINTF(f, x) { if (seeq8005_debug & (f)) printf x; }
    111   1.1    bjh21 #else
    112  1.11    bjh21 #define DPRINTF(f, x)
    113   1.1    bjh21 #endif
    114  1.11    bjh21 
    115  1.27    bjh21 #define	SEEQ_TX_BUFFER_SIZE		0x800		/* (> ETHER_MAX_LEN) */
    116   1.1    bjh21 
    117  1.24    bjh21 #define SEEQ_READ16(sc, iot, ioh, reg)					\
    118  1.24    bjh21 	((sc)->sc_flags & SF_8BIT ?					\
    119  1.24    bjh21 	    (bus_space_read_1((iot), (ioh), (reg)) |			\
    120  1.24    bjh21 	     (bus_space_read_1((iot), (ioh), (reg) + 1) << 8)) :	\
    121  1.24    bjh21 	    (bus_space_read_2((iot), (ioh), (reg))))
    122  1.24    bjh21 
    123  1.24    bjh21 #define SEEQ_WRITE16(sc, iot, ioh, reg, val) do {			\
    124  1.24    bjh21 	if ((sc)->sc_flags & SF_8BIT) {					\
    125  1.24    bjh21 		bus_space_write_1((iot), (ioh), (reg), (val) & 0xff);	\
    126  1.24    bjh21 		bus_space_write_1((iot), (ioh), (reg) + 1, (val) >> 8);	\
    127  1.24    bjh21 	} else								\
    128  1.24    bjh21 		bus_space_write_2((iot), (ioh), (reg), (val));		\
    129  1.24    bjh21 } while (/*CONSTCOND*/0)
    130  1.24    bjh21 
    131   1.1    bjh21 /*
    132   1.1    bjh21  * prototypes
    133   1.1    bjh21  */
    134   1.1    bjh21 
    135   1.5    bjh21 static int ea_init(struct ifnet *);
    136   1.1    bjh21 static int ea_ioctl(struct ifnet *, u_long, caddr_t);
    137   1.1    bjh21 static void ea_start(struct ifnet *);
    138   1.1    bjh21 static void ea_watchdog(struct ifnet *);
    139   1.1    bjh21 static void ea_chipreset(struct seeq8005_softc *);
    140   1.1    bjh21 static void ea_ramtest(struct seeq8005_softc *);
    141   1.1    bjh21 static int ea_stoptx(struct seeq8005_softc *);
    142   1.1    bjh21 static int ea_stoprx(struct seeq8005_softc *);
    143   1.5    bjh21 static void ea_stop(struct ifnet *, int);
    144   1.1    bjh21 static void ea_await_fifo_empty(struct seeq8005_softc *);
    145   1.1    bjh21 static void ea_await_fifo_full(struct seeq8005_softc *);
    146  1.11    bjh21 static void ea_writebuf(struct seeq8005_softc *, u_char *, int, size_t);
    147  1.11    bjh21 static void ea_readbuf(struct seeq8005_softc *, u_char *, int, size_t);
    148   1.3    bjh21 static void ea_select_buffer(struct seeq8005_softc *, int);
    149   1.5    bjh21 static void ea_set_address(struct seeq8005_softc *, int, const u_int8_t *);
    150  1.11    bjh21 static void ea_read(struct seeq8005_softc *, int, int);
    151  1.11    bjh21 static struct mbuf *ea_get(struct seeq8005_softc *, int, int, struct ifnet *);
    152  1.20    bjh21 static void ea_txint(struct seeq8005_softc *);
    153  1.20    bjh21 static void ea_rxint(struct seeq8005_softc *);
    154   1.1    bjh21 static void eatxpacket(struct seeq8005_softc *);
    155  1.12    bjh21 static int ea_writembuf(struct seeq8005_softc *, struct mbuf *, int);
    156   1.5    bjh21 static void ea_mc_reset(struct seeq8005_softc *);
    157  1.11    bjh21 static void ea_mc_reset_8004(struct seeq8005_softc *);
    158  1.11    bjh21 static void ea_mc_reset_8005(struct seeq8005_softc *);
    159  1.11    bjh21 static int ea_mediachange(struct ifnet *);
    160  1.11    bjh21 static void ea_mediastatus(struct ifnet *, struct ifmediareq *);
    161   1.1    bjh21 
    162  1.35   bouyer static char* padbuf = NULL;
    163  1.35   bouyer 
    164   1.1    bjh21 
    165   1.1    bjh21 /*
    166   1.1    bjh21  * Attach chip.
    167   1.1    bjh21  */
    168   1.1    bjh21 
    169   1.1    bjh21 void
    170  1.11    bjh21 seeq8005_attach(struct seeq8005_softc *sc, const u_int8_t *myaddr, int *media,
    171  1.11    bjh21     int nmedia, int defmedia)
    172   1.1    bjh21 {
    173   1.1    bjh21 	struct ifnet *ifp = &sc->sc_ethercom.ec_if;
    174  1.24    bjh21 	bus_space_tag_t iot = sc->sc_iot;
    175  1.24    bjh21 	bus_space_handle_t ioh = sc->sc_ioh;
    176   1.2    bjh21 	u_int id;
    177   1.2    bjh21 
    178  1.11    bjh21 	KASSERT(myaddr != NULL);
    179   1.2    bjh21 	printf(" address %s", ether_sprintf(myaddr));
    180   1.2    bjh21 
    181   1.3    bjh21 	/* Stop the board. */
    182   1.3    bjh21 
    183   1.3    bjh21 	ea_chipreset(sc);
    184   1.3    bjh21 
    185  1.24    bjh21 	/* Work out data bus width. */
    186  1.24    bjh21 	SEEQ_WRITE16(sc, iot, ioh, SEEQ_RX_PTR, 0x1234);
    187  1.25    bjh21 	if (SEEQ_READ16(sc, iot, ioh, SEEQ_RX_PTR) != 0x1234) {
    188  1.24    bjh21 		/* Try 8-bit mode */
    189  1.24    bjh21 		sc->sc_flags |= SF_8BIT;
    190  1.24    bjh21 		SEEQ_WRITE16(sc, iot, ioh, SEEQ_RX_PTR, 0x1234);
    191  1.25    bjh21 		if (SEEQ_READ16(sc, iot, ioh, SEEQ_RX_PTR) != 0x1234) {
    192  1.24    bjh21 			printf("\n%s: Cannot determine data bus width\n",
    193  1.24    bjh21 			    sc->sc_dev.dv_xname);
    194  1.24    bjh21 			return;
    195  1.24    bjh21 		}
    196  1.24    bjh21 	}
    197  1.24    bjh21 
    198  1.24    bjh21 	printf(", %d-bit", sc->sc_flags & SF_8BIT ? 8 : 16);
    199  1.24    bjh21 
    200   1.2    bjh21 	/* Get the product ID */
    201  1.37    perry 
    202  1.10    bjh21 	ea_select_buffer(sc, SEEQ_BUFCODE_PRODUCTID);
    203  1.24    bjh21 	id = SEEQ_READ16(sc, sc->sc_iot, sc->sc_ioh, SEEQ_BUFWIN);
    204   1.2    bjh21 
    205  1.11    bjh21 	switch (id & SEEQ_PRODUCTID_MASK) {
    206  1.11    bjh21 	case SEEQ_PRODUCTID_8004:
    207  1.11    bjh21 		sc->sc_variant = SEEQ_8004;
    208  1.20    bjh21 		switch (id & SEEQ_PRODUCTID_REV_MASK) {
    209  1.20    bjh21 		case SEEQ_PRODUCTID_REV_80C04:
    210  1.20    bjh21 			printf(", SEEQ 80C04\n");
    211  1.20    bjh21 			break;
    212  1.20    bjh21 		case SEEQ_PRODUCTID_REV_80C04A:
    213  1.20    bjh21 			printf(", SEEQ 80C04A\n");
    214  1.20    bjh21 			break;
    215  1.20    bjh21 		default:
    216  1.20    bjh21 			/* Unknown SEEQ 8004 variants */
    217  1.20    bjh21 			printf(", SEEQ 8004 rev %x\n",
    218  1.20    bjh21 			    id & SEEQ_PRODUCTID_REV_MASK);
    219  1.20    bjh21 			break;
    220  1.20    bjh21 		}
    221  1.11    bjh21 		break;
    222  1.11    bjh21 	default:	/* XXX */
    223  1.11    bjh21 		sc->sc_variant = SEEQ_8005;
    224  1.20    bjh21 		printf(", SEEQ 8005\n");
    225  1.11    bjh21 		break;
    226  1.11    bjh21 	}
    227  1.11    bjh21 
    228  1.11    bjh21 	/* Both the 8004 and 8005 are designed for 64K Buffer memory */
    229  1.11    bjh21 	sc->sc_buffersize = SEEQ_MAX_BUFFER_SIZE;
    230  1.11    bjh21 
    231  1.11    bjh21 	/*
    232  1.11    bjh21 	 * Set up tx and rx buffers.
    233  1.11    bjh21 	 *
    234  1.12    bjh21 	 * We use approximately a quarter of the packet memory for TX
    235  1.11    bjh21 	 * buffers and the rest for RX buffers
    236  1.11    bjh21 	 */
    237  1.12    bjh21 	/* sc->sc_tx_bufs = sc->sc_buffersize / SEEQ_TX_BUFFER_SIZE / 4; */
    238  1.12    bjh21 	sc->sc_tx_bufs = 1;
    239  1.11    bjh21 	sc->sc_tx_bufsize = sc->sc_tx_bufs * SEEQ_TX_BUFFER_SIZE;
    240  1.11    bjh21 	sc->sc_rx_bufsize = sc->sc_buffersize - sc->sc_tx_bufsize;
    241  1.11    bjh21 	sc->sc_enabled = 0;
    242  1.11    bjh21 
    243  1.11    bjh21 	/* Test the RAM */
    244  1.11    bjh21 	ea_ramtest(sc);
    245  1.11    bjh21 
    246  1.11    bjh21 	printf("%s: %dKB packet memory, txbuf=%dKB (%d buffers), rxbuf=%dKB",
    247  1.11    bjh21 	    sc->sc_dev.dv_xname, sc->sc_buffersize >> 10,
    248  1.37    perry 	    sc->sc_tx_bufsize >> 10, sc->sc_tx_bufs, sc->sc_rx_bufsize >> 10);
    249   1.1    bjh21 
    250  1.35   bouyer 	if (padbuf == NULL) {
    251  1.35   bouyer 		padbuf = malloc(ETHER_MIN_LEN - ETHER_CRC_LEN, M_DEVBUF,
    252  1.35   bouyer 		    M_ZERO | M_NOWAIT);
    253  1.35   bouyer 		if (padbuf == NULL) {
    254  1.35   bouyer 			printf("%s: can't allocate pad buffer\n",
    255  1.35   bouyer 			    sc->sc_dev.dv_xname);
    256  1.35   bouyer 			return;
    257  1.35   bouyer 		}
    258  1.35   bouyer 	}
    259  1.35   bouyer 
    260   1.1    bjh21 	/* Initialise ifnet structure. */
    261   1.1    bjh21 
    262  1.29  thorpej 	strcpy(ifp->if_xname, sc->sc_dev.dv_xname);
    263   1.1    bjh21 	ifp->if_softc = sc;
    264   1.1    bjh21 	ifp->if_start = ea_start;
    265   1.1    bjh21 	ifp->if_ioctl = ea_ioctl;
    266   1.5    bjh21 	ifp->if_init = ea_init;
    267   1.5    bjh21 	ifp->if_stop = ea_stop;
    268   1.1    bjh21 	ifp->if_watchdog = ea_watchdog;
    269   1.5    bjh21 	ifp->if_flags = IFF_BROADCAST | IFF_MULTICAST | IFF_NOTRAILERS;
    270  1.11    bjh21 	if (sc->sc_variant == SEEQ_8004)
    271  1.11    bjh21 		ifp->if_flags |= IFF_SIMPLEX;
    272   1.7  thorpej 	IFQ_SET_READY(&ifp->if_snd);
    273   1.1    bjh21 
    274  1.11    bjh21 	/* Initialize media goo. */
    275  1.11    bjh21 	ifmedia_init(&sc->sc_media, 0, ea_mediachange, ea_mediastatus);
    276  1.11    bjh21 	if (media != NULL) {
    277  1.11    bjh21 		int i;
    278  1.11    bjh21 
    279  1.11    bjh21 		for (i = 0; i < nmedia; i++)
    280  1.11    bjh21 			ifmedia_add(&sc->sc_media, media[i], 0, NULL);
    281  1.11    bjh21 		ifmedia_set(&sc->sc_media, defmedia);
    282  1.11    bjh21 	} else {
    283  1.11    bjh21 		ifmedia_add(&sc->sc_media, IFM_ETHER|IFM_MANUAL, 0, NULL);
    284  1.11    bjh21 		ifmedia_set(&sc->sc_media, IFM_ETHER|IFM_MANUAL);
    285  1.11    bjh21 	}
    286  1.11    bjh21 
    287  1.27    bjh21 	/* We can support 802.1Q VLAN-sized frames. */
    288  1.27    bjh21 	sc->sc_ethercom.ec_capabilities |= ETHERCAP_VLAN_MTU;
    289  1.27    bjh21 
    290   1.1    bjh21 	/* Now we can attach the interface. */
    291   1.1    bjh21 
    292   1.1    bjh21 	if_attach(ifp);
    293   1.1    bjh21 	ether_ifattach(ifp, myaddr);
    294   1.1    bjh21 
    295  1.11    bjh21 	printf("\n");
    296  1.30    bjh21 
    297  1.30    bjh21 #if NRND > 0
    298  1.30    bjh21 	/* After \n because it can print a line of its own. */
    299  1.30    bjh21 	rnd_attach_source(&sc->rnd_source, sc->sc_dev.dv_xname,
    300  1.30    bjh21 	    RND_TYPE_NET, 0);
    301  1.30    bjh21 #endif
    302  1.11    bjh21 }
    303  1.11    bjh21 
    304  1.11    bjh21 /*
    305  1.11    bjh21  * Media change callback.
    306  1.11    bjh21  */
    307  1.11    bjh21 static int
    308  1.11    bjh21 ea_mediachange(struct ifnet *ifp)
    309  1.11    bjh21 {
    310  1.11    bjh21 	struct seeq8005_softc *sc = ifp->if_softc;
    311   1.8    bjh21 
    312  1.11    bjh21 	if (sc->sc_mediachange)
    313  1.11    bjh21 		return ((*sc->sc_mediachange)(sc));
    314  1.11    bjh21 	return (EINVAL);
    315   1.1    bjh21 }
    316   1.1    bjh21 
    317  1.11    bjh21 /*
    318  1.11    bjh21  * Media status callback.
    319  1.11    bjh21  */
    320  1.11    bjh21 static void
    321  1.11    bjh21 ea_mediastatus(struct ifnet *ifp, struct ifmediareq *ifmr)
    322  1.11    bjh21 {
    323  1.11    bjh21 	struct seeq8005_softc *sc = ifp->if_softc;
    324  1.11    bjh21 
    325  1.11    bjh21 	if (sc->sc_enabled == 0) {
    326  1.11    bjh21 		ifmr->ifm_active = IFM_ETHER | IFM_NONE;
    327  1.11    bjh21 		ifmr->ifm_status = 0;
    328  1.11    bjh21 		return;
    329  1.11    bjh21 	}
    330  1.11    bjh21 
    331  1.11    bjh21 	if (sc->sc_mediastatus)
    332  1.11    bjh21 		(*sc->sc_mediastatus)(sc, ifmr);
    333  1.11    bjh21 }
    334   1.1    bjh21 
    335   1.1    bjh21 /*
    336   1.1    bjh21  * Test the RAM on the ethernet card.
    337   1.1    bjh21  */
    338   1.1    bjh21 
    339   1.1    bjh21 void
    340   1.1    bjh21 ea_ramtest(struct seeq8005_softc *sc)
    341   1.1    bjh21 {
    342   1.1    bjh21 	bus_space_tag_t iot = sc->sc_iot;
    343   1.1    bjh21 	bus_space_handle_t ioh = sc->sc_ioh;
    344   1.1    bjh21 	int loop;
    345   1.1    bjh21 	u_int sum = 0;
    346   1.1    bjh21 
    347   1.1    bjh21 	/*
    348   1.1    bjh21 	 * Test the buffer memory on the board.
    349   1.1    bjh21 	 * Write simple pattens to it and read them back.
    350   1.1    bjh21 	 */
    351   1.1    bjh21 
    352   1.1    bjh21 	/* Set up the whole buffer RAM for writing */
    353   1.1    bjh21 
    354  1.10    bjh21 	ea_select_buffer(sc, SEEQ_BUFCODE_TX_EAP);
    355  1.24    bjh21 	SEEQ_WRITE16(sc, iot, ioh, SEEQ_BUFWIN, (SEEQ_MAX_BUFFER_SIZE >> 8) - 1);
    356  1.24    bjh21 	SEEQ_WRITE16(sc, iot, ioh, SEEQ_TX_PTR, 0x0000);
    357  1.24    bjh21 	SEEQ_WRITE16(sc, iot, ioh, SEEQ_RX_PTR, SEEQ_MAX_BUFFER_SIZE - 2);
    358   1.1    bjh21 
    359  1.10    bjh21 #define SEEQ_RAMTEST_LOOP(value)						\
    360   1.3    bjh21 do {									\
    361   1.3    bjh21 	/* Set the write start address and write a pattern */		\
    362   1.3    bjh21 	ea_writebuf(sc, NULL, 0x0000, 0);				\
    363  1.10    bjh21 	for (loop = 0; loop < SEEQ_MAX_BUFFER_SIZE; loop += 2)		\
    364  1.24    bjh21 		SEEQ_WRITE16(sc, iot, ioh, SEEQ_BUFWIN, (value));	\
    365   1.3    bjh21 									\
    366   1.3    bjh21 	/* Set the read start address and verify the pattern */		\
    367   1.3    bjh21 	ea_readbuf(sc, NULL, 0x0000, 0);				\
    368  1.10    bjh21 	for (loop = 0; loop < SEEQ_MAX_BUFFER_SIZE; loop += 2)		\
    369  1.24    bjh21 		if (SEEQ_READ16(sc, iot, ioh, SEEQ_BUFWIN) != (value)) \
    370   1.3    bjh21 			++sum;						\
    371   1.3    bjh21 } while (/*CONSTCOND*/0)
    372   1.3    bjh21 
    373  1.10    bjh21 	SEEQ_RAMTEST_LOOP(loop);
    374  1.10    bjh21 	SEEQ_RAMTEST_LOOP(loop ^ (SEEQ_MAX_BUFFER_SIZE - 1));
    375  1.10    bjh21 	SEEQ_RAMTEST_LOOP(0xaa55);
    376  1.10    bjh21 	SEEQ_RAMTEST_LOOP(0x55aa);
    377   1.1    bjh21 
    378   1.1    bjh21 	/* Report */
    379   1.1    bjh21 
    380   1.2    bjh21 	if (sum > 0)
    381   1.2    bjh21 		printf("%s: buffer RAM failed self test, %d faults\n",
    382   1.2    bjh21 		       sc->sc_dev.dv_xname, sum);
    383   1.1    bjh21 }
    384   1.1    bjh21 
    385   1.1    bjh21 
    386   1.1    bjh21 /*
    387   1.1    bjh21  * Stop the tx interface.
    388   1.1    bjh21  *
    389   1.1    bjh21  * Returns 0 if the tx was already stopped or 1 if it was active
    390   1.1    bjh21  */
    391   1.1    bjh21 
    392   1.1    bjh21 static int
    393   1.1    bjh21 ea_stoptx(struct seeq8005_softc *sc)
    394   1.1    bjh21 {
    395   1.1    bjh21 	bus_space_tag_t iot = sc->sc_iot;
    396   1.1    bjh21 	bus_space_handle_t ioh = sc->sc_ioh;
    397   1.1    bjh21 	int timeout;
    398   1.1    bjh21 	int status;
    399   1.1    bjh21 
    400  1.16    bjh21 	DPRINTF(SEEQ_DEBUG_TX, ("ea_stoptx()\n"));
    401  1.11    bjh21 
    402  1.11    bjh21 	sc->sc_enabled = 0;
    403   1.1    bjh21 
    404  1.24    bjh21 	status = SEEQ_READ16(sc, iot, ioh, SEEQ_STATUS);
    405  1.10    bjh21 	if (!(status & SEEQ_STATUS_TX_ON))
    406   1.1    bjh21 		return 0;
    407   1.1    bjh21 
    408   1.1    bjh21 	/* Stop any tx and wait for confirmation */
    409  1.24    bjh21 	SEEQ_WRITE16(sc, iot, ioh, SEEQ_COMMAND,
    410  1.10    bjh21 			  sc->sc_command | SEEQ_CMD_TX_OFF);
    411   1.1    bjh21 
    412   1.1    bjh21 	timeout = 20000;
    413   1.1    bjh21 	do {
    414  1.24    bjh21 		status = SEEQ_READ16(sc, iot, ioh, SEEQ_STATUS);
    415  1.11    bjh21 		delay(1);
    416  1.10    bjh21 	} while ((status & SEEQ_STATUS_TX_ON) && --timeout > 0);
    417  1.11    bjh21  	if (timeout == 0)
    418  1.11    bjh21 		log(LOG_ERR, "%s: timeout waiting for tx termination\n",
    419  1.11    bjh21 		    sc->sc_dev.dv_xname);
    420   1.1    bjh21 
    421   1.1    bjh21 	/* Clear any pending tx interrupt */
    422  1.24    bjh21 	SEEQ_WRITE16(sc, iot, ioh, SEEQ_COMMAND,
    423  1.10    bjh21 		   sc->sc_command | SEEQ_CMD_TX_INTACK);
    424   1.1    bjh21 	return 1;
    425   1.1    bjh21 }
    426   1.1    bjh21 
    427   1.1    bjh21 
    428   1.1    bjh21 /*
    429   1.1    bjh21  * Stop the rx interface.
    430   1.1    bjh21  *
    431   1.1    bjh21  * Returns 0 if the tx was already stopped or 1 if it was active
    432   1.1    bjh21  */
    433   1.1    bjh21 
    434   1.1    bjh21 static int
    435   1.1    bjh21 ea_stoprx(struct seeq8005_softc *sc)
    436   1.1    bjh21 {
    437   1.1    bjh21 	bus_space_tag_t iot = sc->sc_iot;
    438   1.1    bjh21 	bus_space_handle_t ioh = sc->sc_ioh;
    439   1.1    bjh21 	int timeout;
    440   1.1    bjh21 	int status;
    441   1.1    bjh21 
    442  1.16    bjh21 	DPRINTF(SEEQ_DEBUG_RX, ("ea_stoprx()\n"));
    443   1.1    bjh21 
    444  1.24    bjh21 	status = SEEQ_READ16(sc, iot, ioh, SEEQ_STATUS);
    445  1.10    bjh21 	if (!(status & SEEQ_STATUS_RX_ON))
    446   1.1    bjh21 		return 0;
    447   1.1    bjh21 
    448   1.1    bjh21 	/* Stop any rx and wait for confirmation */
    449   1.1    bjh21 
    450  1.24    bjh21 	SEEQ_WRITE16(sc, iot, ioh, SEEQ_COMMAND,
    451  1.10    bjh21 			  sc->sc_command | SEEQ_CMD_RX_OFF);
    452   1.1    bjh21 
    453   1.1    bjh21 	timeout = 20000;
    454   1.1    bjh21 	do {
    455  1.24    bjh21 		status = SEEQ_READ16(sc, iot, ioh, SEEQ_STATUS);
    456  1.10    bjh21 	} while ((status & SEEQ_STATUS_RX_ON) && --timeout > 0);
    457   1.1    bjh21 	if (timeout == 0)
    458  1.11    bjh21 		log(LOG_ERR, "%s: timeout waiting for rx termination\n",
    459  1.11    bjh21 		    sc->sc_dev.dv_xname);
    460   1.1    bjh21 
    461   1.1    bjh21 	/* Clear any pending rx interrupt */
    462   1.1    bjh21 
    463  1.24    bjh21 	SEEQ_WRITE16(sc, iot, ioh, SEEQ_COMMAND,
    464  1.10    bjh21 		   sc->sc_command | SEEQ_CMD_RX_INTACK);
    465   1.1    bjh21 	return 1;
    466   1.1    bjh21 }
    467   1.1    bjh21 
    468   1.1    bjh21 
    469   1.1    bjh21 /*
    470   1.1    bjh21  * Stop interface.
    471   1.1    bjh21  * Stop all IO and shut the interface down
    472   1.1    bjh21  */
    473   1.1    bjh21 
    474  1.34    bjh21 /* ARGSUSED */
    475   1.1    bjh21 static void
    476   1.5    bjh21 ea_stop(struct ifnet *ifp, int disable)
    477   1.1    bjh21 {
    478   1.5    bjh21 	struct seeq8005_softc *sc = ifp->if_softc;
    479   1.1    bjh21 	bus_space_tag_t iot = sc->sc_iot;
    480   1.1    bjh21 	bus_space_handle_t ioh = sc->sc_ioh;
    481  1.37    perry 
    482  1.16    bjh21 	DPRINTF(SEEQ_DEBUG_MISC, ("ea_stop()\n"));
    483   1.1    bjh21 
    484   1.1    bjh21 	/* Stop all IO */
    485   1.1    bjh21 	ea_stoptx(sc);
    486   1.1    bjh21 	ea_stoprx(sc);
    487   1.1    bjh21 
    488   1.1    bjh21 	/* Disable rx and tx interrupts */
    489  1.10    bjh21 	sc->sc_command &= (SEEQ_CMD_RX_INTEN | SEEQ_CMD_TX_INTEN);
    490   1.1    bjh21 
    491   1.1    bjh21 	/* Clear any pending interrupts */
    492  1.24    bjh21 	SEEQ_WRITE16(sc, iot, ioh, SEEQ_COMMAND,
    493  1.10    bjh21 			  sc->sc_command | SEEQ_CMD_RX_INTACK |
    494  1.10    bjh21 			  SEEQ_CMD_TX_INTACK | SEEQ_CMD_DMA_INTACK |
    495  1.10    bjh21 			  SEEQ_CMD_BW_INTACK);
    496  1.11    bjh21 
    497  1.11    bjh21 	if (sc->sc_variant == SEEQ_8004) {
    498  1.11    bjh21 		/* Put the chip to sleep */
    499  1.11    bjh21 		ea_select_buffer(sc, SEEQ_BUFCODE_CONFIG3);
    500  1.24    bjh21 		SEEQ_WRITE16(sc, iot, ioh, SEEQ_BUFWIN,
    501  1.11    bjh21 		    sc->sc_config3 | SEEQ_CFG3_SLEEP);
    502  1.11    bjh21 	}
    503   1.1    bjh21 
    504   1.1    bjh21 	/* Cancel any watchdog timer */
    505   1.1    bjh21        	sc->sc_ethercom.ec_if.if_timer = 0;
    506   1.1    bjh21 }
    507   1.1    bjh21 
    508   1.1    bjh21 
    509   1.1    bjh21 /*
    510   1.1    bjh21  * Reset the chip
    511   1.1    bjh21  * Following this the software registers are reset
    512   1.1    bjh21  */
    513   1.1    bjh21 
    514   1.1    bjh21 static void
    515   1.1    bjh21 ea_chipreset(struct seeq8005_softc *sc)
    516   1.1    bjh21 {
    517   1.1    bjh21 	bus_space_tag_t iot = sc->sc_iot;
    518   1.1    bjh21 	bus_space_handle_t ioh = sc->sc_ioh;
    519   1.1    bjh21 
    520  1.16    bjh21 	DPRINTF(SEEQ_DEBUG_MISC, ("ea_chipreset()\n"));
    521   1.1    bjh21 
    522   1.1    bjh21 	/* Reset the controller. Min of 4us delay here */
    523   1.1    bjh21 
    524  1.24    bjh21 	/*
    525  1.24    bjh21 	 * This can be called before we know whether the chip is in 8- or
    526  1.24    bjh21 	 * 16-bit mode, so we do a reset in both modes.  The 16-bit reset is
    527  1.24    bjh21 	 * harmless in 8-bit mode, so we do that second.
    528  1.24    bjh21 	 */
    529  1.24    bjh21 
    530  1.24    bjh21 	/* In 16-bit mode, this will munge the PreamSelect bit. */
    531  1.24    bjh21 	bus_space_write_1(iot, ioh, SEEQ_CONFIG2 + 1, SEEQ_CFG2_RESET >> 8);
    532  1.24    bjh21 	delay(4);
    533  1.24    bjh21 	/* In 8-bit mode, this will zero the bottom half of config reg 2. */
    534  1.10    bjh21 	bus_space_write_2(iot, ioh, SEEQ_CONFIG2, SEEQ_CFG2_RESET);
    535   1.3    bjh21 	delay(4);
    536   1.1    bjh21 
    537   1.1    bjh21 	sc->sc_command = 0;
    538   1.1    bjh21 	sc->sc_config1 = 0;
    539   1.1    bjh21 	sc->sc_config2 = 0;
    540  1.11    bjh21 	sc->sc_config3 = 0;
    541   1.1    bjh21 }
    542   1.1    bjh21 
    543   1.1    bjh21 
    544   1.1    bjh21 /*
    545   1.1    bjh21  * If the DMA FIFO's in write mode, wait for it to empty.  Needed when
    546   1.1    bjh21  * switching the FIFO from write to read.  We also use it when changing
    547   1.1    bjh21  * the address for writes.
    548   1.1    bjh21  */
    549   1.1    bjh21 static void
    550   1.1    bjh21 ea_await_fifo_empty(struct seeq8005_softc *sc)
    551   1.1    bjh21 {
    552   1.1    bjh21 	bus_space_tag_t iot = sc->sc_iot;
    553   1.1    bjh21 	bus_space_handle_t ioh = sc->sc_ioh;
    554   1.1    bjh21 	int timeout;
    555  1.37    perry 
    556   1.1    bjh21 	timeout = 20000;
    557  1.24    bjh21 	if ((SEEQ_READ16(sc, iot, ioh, SEEQ_STATUS) &
    558  1.10    bjh21 	     SEEQ_STATUS_FIFO_DIR) != 0)
    559   1.1    bjh21 		return; /* FIFO is reading anyway. */
    560  1.18    bjh21 	while (--timeout > 0)
    561  1.24    bjh21 		if (SEEQ_READ16(sc, iot, ioh, SEEQ_STATUS) &
    562  1.18    bjh21 		    SEEQ_STATUS_FIFO_EMPTY)
    563  1.18    bjh21 			return;
    564  1.18    bjh21 	log(LOG_ERR, "%s: DMA FIFO failed to empty\n", sc->sc_dev.dv_xname);
    565   1.1    bjh21 }
    566   1.1    bjh21 
    567   1.1    bjh21 /*
    568   1.1    bjh21  * Wait for the DMA FIFO to fill before reading from it.
    569   1.1    bjh21  */
    570   1.1    bjh21 static void
    571   1.1    bjh21 ea_await_fifo_full(struct seeq8005_softc *sc)
    572   1.1    bjh21 {
    573   1.1    bjh21 	bus_space_tag_t iot = sc->sc_iot;
    574   1.1    bjh21 	bus_space_handle_t ioh = sc->sc_ioh;
    575   1.1    bjh21 	int timeout;
    576   1.1    bjh21 
    577   1.1    bjh21 	timeout = 20000;
    578  1.18    bjh21 	while (--timeout > 0)
    579  1.24    bjh21 		if (SEEQ_READ16(sc, iot, ioh, SEEQ_STATUS) &
    580  1.18    bjh21 		    SEEQ_STATUS_FIFO_FULL)
    581  1.18    bjh21 			return;
    582  1.18    bjh21 	log(LOG_ERR, "%s: DMA FIFO failed to fill\n", sc->sc_dev.dv_xname);
    583   1.1    bjh21 }
    584   1.1    bjh21 
    585   1.1    bjh21 /*
    586   1.1    bjh21  * write to the buffer memory on the interface
    587   1.1    bjh21  *
    588   1.1    bjh21  * The buffer address is set to ADDR.
    589   1.1    bjh21  * If len != 0 then data is copied from the address starting at buf
    590   1.1    bjh21  * to the interface buffer.
    591   1.1    bjh21  * BUF must be usable as a u_int16_t *.
    592   1.1    bjh21  * If LEN is odd, it must be safe to overwrite one extra byte.
    593   1.1    bjh21  */
    594   1.1    bjh21 
    595   1.1    bjh21 static void
    596  1.11    bjh21 ea_writebuf(struct seeq8005_softc *sc, u_char *buf, int addr, size_t len)
    597   1.1    bjh21 {
    598   1.1    bjh21 	bus_space_tag_t iot = sc->sc_iot;
    599   1.1    bjh21 	bus_space_handle_t ioh = sc->sc_ioh;
    600   1.1    bjh21 
    601  1.16    bjh21 	DPRINTF(SEEQ_DEBUG_MISC, ("writebuf: st=%04x\n",
    602  1.24    bjh21 	    SEEQ_READ16(sc, iot, ioh, SEEQ_STATUS)));
    603   1.1    bjh21 
    604   1.1    bjh21 #ifdef DIAGNOSTIC
    605   1.1    bjh21 	if (__predict_false(!ALIGNED_POINTER(buf, u_int16_t)))
    606   1.1    bjh21 		panic("%s: unaligned writebuf", sc->sc_dev.dv_xname);
    607  1.10    bjh21 	if (__predict_false(addr >= SEEQ_MAX_BUFFER_SIZE))
    608   1.1    bjh21 		panic("%s: writebuf out of range", sc->sc_dev.dv_xname);
    609  1.14    bjh21 #endif
    610   1.1    bjh21 
    611  1.11    bjh21 	if (addr != -1) {
    612  1.11    bjh21 		ea_await_fifo_empty(sc);
    613   1.1    bjh21 
    614  1.11    bjh21 		ea_select_buffer(sc, SEEQ_BUFCODE_LOCAL_MEM);
    615  1.24    bjh21 		SEEQ_WRITE16(sc, iot, ioh, SEEQ_COMMAND,
    616  1.11    bjh21 		    sc->sc_command | SEEQ_CMD_FIFO_WRITE);
    617  1.24    bjh21 		SEEQ_WRITE16(sc, iot, ioh, SEEQ_DMA_ADDR, addr);
    618  1.11    bjh21 	}
    619   1.1    bjh21 
    620  1.24    bjh21 	if (len > 0) {
    621  1.24    bjh21 		if (sc->sc_flags & SF_8BIT)
    622  1.24    bjh21 			bus_space_write_multi_1(iot, ioh, SEEQ_BUFWIN,
    623  1.24    bjh21 			    (u_int8_t *)buf, len);
    624  1.24    bjh21 		else
    625  1.24    bjh21 			bus_space_write_multi_2(iot, ioh, SEEQ_BUFWIN,
    626  1.34    bjh21 			    /* LINTED: alignment checked above */
    627  1.24    bjh21 			    (u_int16_t *)buf, len / 2);
    628  1.24    bjh21 	}
    629  1.33    bjh21 	if (!(sc->sc_flags & SF_8BIT) && len % 2) {
    630  1.33    bjh21 		/* Write the last byte */
    631  1.33    bjh21 		bus_space_write_2(iot, ioh, SEEQ_BUFWIN, buf[len - 1]);
    632  1.33    bjh21 	}
    633   1.1    bjh21 	/* Leave FIFO to empty in the background */
    634   1.1    bjh21 }
    635   1.1    bjh21 
    636   1.1    bjh21 
    637   1.1    bjh21 /*
    638   1.1    bjh21  * read from the buffer memory on the interface
    639   1.1    bjh21  *
    640   1.1    bjh21  * The buffer address is set to ADDR.
    641   1.1    bjh21  * If len != 0 then data is copied from the interface buffer to the
    642   1.1    bjh21  * address starting at buf.
    643   1.1    bjh21  * BUF must be usable as a u_int16_t *.
    644   1.1    bjh21  * If LEN is odd, it must be safe to overwrite one extra byte.
    645   1.1    bjh21  */
    646   1.1    bjh21 
    647   1.1    bjh21 static void
    648  1.11    bjh21 ea_readbuf(struct seeq8005_softc *sc, u_char *buf, int addr, size_t len)
    649   1.1    bjh21 {
    650   1.1    bjh21 	bus_space_tag_t iot = sc->sc_iot;
    651   1.1    bjh21 	bus_space_handle_t ioh = sc->sc_ioh;
    652  1.19    bjh21 	int runup;
    653   1.1    bjh21 
    654  1.16    bjh21 	DPRINTF(SEEQ_DEBUG_MISC, ("readbuf: st=%04x addr=%04x len=%d\n",
    655  1.24    bjh21 	    SEEQ_READ16(sc, iot, ioh, SEEQ_STATUS), addr, len));
    656   1.1    bjh21 
    657   1.1    bjh21 #ifdef DIAGNOSTIC
    658  1.14    bjh21 	if (__predict_false(!ALIGNED_POINTER(buf, u_int16_t)))
    659   1.1    bjh21 		panic("%s: unaligned readbuf", sc->sc_dev.dv_xname);
    660  1.14    bjh21 	if (__predict_false(addr >= SEEQ_MAX_BUFFER_SIZE))
    661  1.14    bjh21 		panic("%s: readbuf out of range", sc->sc_dev.dv_xname);
    662   1.1    bjh21 #endif
    663   1.1    bjh21 
    664  1.11    bjh21 	if (addr != -1) {
    665  1.19    bjh21 		/*
    666  1.19    bjh21 		 * SEEQ 80C04 bug:
    667  1.19    bjh21 		 * Starting reading from certain addresses seems to cause
    668  1.19    bjh21 		 * us to get bogus results, so we avoid them.
    669  1.19    bjh21 		 */
    670  1.19    bjh21 		runup = 0;
    671  1.19    bjh21 		if (sc->sc_variant == SEEQ_8004 &&
    672  1.19    bjh21 		    ((addr & 0x00ff) == 0x00ea ||
    673  1.19    bjh21 		     (addr & 0x00ff) == 0x00ee ||
    674  1.19    bjh21 		     (addr & 0x00ff) == 0x00f0))
    675  1.19    bjh21 			runup = (addr & 0x00ff) - 0x00e8;
    676  1.19    bjh21 
    677  1.11    bjh21 		ea_await_fifo_empty(sc);
    678   1.1    bjh21 
    679  1.11    bjh21 		ea_select_buffer(sc, SEEQ_BUFCODE_LOCAL_MEM);
    680  1.21    bjh21 
    681  1.21    bjh21 		/*
    682  1.21    bjh21 		 * 80C04 bug workaround.  I found this in the old arm32 "eb"
    683  1.21    bjh21 		 * driver.  I've no idea what it does, but it seems to stop
    684  1.21    bjh21 		 * the chip mangling data so often.
    685  1.21    bjh21 		 */
    686  1.24    bjh21 		SEEQ_WRITE16(sc, iot, ioh, SEEQ_COMMAND,
    687  1.21    bjh21 		    sc->sc_command | SEEQ_CMD_FIFO_WRITE);
    688  1.21    bjh21 		ea_await_fifo_empty(sc);
    689  1.21    bjh21 
    690  1.24    bjh21 		SEEQ_WRITE16(sc, iot, ioh, SEEQ_DMA_ADDR, addr - runup);
    691  1.24    bjh21 		SEEQ_WRITE16(sc, iot, ioh, SEEQ_COMMAND,
    692  1.11    bjh21 		    sc->sc_command | SEEQ_CMD_FIFO_READ);
    693   1.1    bjh21 
    694  1.11    bjh21 		ea_await_fifo_full(sc);
    695  1.19    bjh21 		while (runup > 0) {
    696  1.34    bjh21 			/* LINTED: Reading a volatile _does_ have an effect */
    697  1.24    bjh21 			(void)SEEQ_READ16(sc, iot, ioh, SEEQ_BUFWIN);
    698  1.19    bjh21 			runup -= 2;
    699  1.19    bjh21 		}
    700  1.11    bjh21 	}
    701   1.1    bjh21 
    702  1.24    bjh21 	if (len > 0) {
    703  1.24    bjh21 		if (sc->sc_flags & SF_8BIT)
    704  1.24    bjh21 			bus_space_read_multi_1(iot, ioh, SEEQ_BUFWIN,
    705  1.24    bjh21 			    (u_int8_t *)buf, len);
    706  1.24    bjh21 		else
    707  1.24    bjh21 			bus_space_read_multi_2(iot, ioh, SEEQ_BUFWIN,
    708  1.34    bjh21 			    /* LINTED: pointer alignment checked above */
    709  1.24    bjh21 			    (u_int16_t *)buf, len / 2);
    710  1.33    bjh21 	}
    711  1.33    bjh21 	if (!(sc->sc_flags & SF_8BIT) && len % 2) {
    712  1.33    bjh21 		/* Read the last byte */
    713  1.33    bjh21 		buf[len - 1] = bus_space_read_2(iot, ioh, SEEQ_BUFWIN);
    714  1.24    bjh21 	}
    715   1.1    bjh21 }
    716   1.1    bjh21 
    717   1.3    bjh21 static void
    718   1.3    bjh21 ea_select_buffer(struct seeq8005_softc *sc, int bufcode)
    719   1.3    bjh21 {
    720   1.3    bjh21 
    721  1.24    bjh21 	SEEQ_WRITE16(sc, sc->sc_iot, sc->sc_ioh, SEEQ_CONFIG1,
    722   1.3    bjh21 			  sc->sc_config1 | bufcode);
    723   1.3    bjh21 }
    724   1.1    bjh21 
    725   1.5    bjh21 /* Must be called at splnet */
    726   1.5    bjh21 static void
    727   1.5    bjh21 ea_set_address(struct seeq8005_softc *sc, int which, u_int8_t const *ea)
    728   1.5    bjh21 {
    729   1.5    bjh21 	int i;
    730   1.5    bjh21 
    731  1.10    bjh21 	ea_select_buffer(sc, SEEQ_BUFCODE_STATION_ADDR0 + which);
    732   1.5    bjh21 	for (i = 0; i < ETHER_ADDR_LEN; ++i)
    733  1.24    bjh21 		SEEQ_WRITE16(sc, sc->sc_iot, sc->sc_ioh, SEEQ_BUFWIN,
    734   1.5    bjh21 				  ea[i]);
    735   1.5    bjh21 }
    736   1.5    bjh21 
    737   1.1    bjh21 /*
    738   1.1    bjh21  * Initialize interface.
    739   1.1    bjh21  *
    740   1.1    bjh21  * This should leave the interface in a state for packet reception and
    741   1.1    bjh21  * transmission.
    742   1.1    bjh21  */
    743   1.1    bjh21 
    744   1.1    bjh21 static int
    745   1.5    bjh21 ea_init(struct ifnet *ifp)
    746   1.1    bjh21 {
    747   1.5    bjh21 	struct seeq8005_softc *sc = ifp->if_softc;
    748   1.1    bjh21 	bus_space_tag_t iot = sc->sc_iot;
    749   1.1    bjh21 	bus_space_handle_t ioh = sc->sc_ioh;
    750   1.5    bjh21 	int s;
    751   1.1    bjh21 
    752  1.16    bjh21 	DPRINTF(SEEQ_DEBUG_MISC, ("ea_init()\n"));
    753   1.1    bjh21 
    754   1.1    bjh21 	s = splnet();
    755   1.1    bjh21 
    756   1.1    bjh21 	/* First, reset the board. */
    757   1.1    bjh21 
    758   1.3    bjh21 	ea_chipreset(sc);
    759   1.3    bjh21 
    760   1.3    bjh21 	/* Set up defaults for the registers */
    761   1.3    bjh21 
    762  1.11    bjh21 	sc->sc_command = 0;
    763  1.11    bjh21 	sc->sc_config1 = 0;
    764   1.3    bjh21 #if BYTE_ORDER == BIG_ENDIAN
    765  1.11    bjh21 	sc->sc_config2 = SEEQ_CFG2_BYTESWAP;
    766   1.3    bjh21 #else
    767   1.3    bjh21 	sc->sc_config2 = 0;
    768   1.3    bjh21 #endif
    769  1.11    bjh21 	sc->sc_config3 = 0;
    770   1.1    bjh21 
    771  1.24    bjh21 	SEEQ_WRITE16(sc, iot, ioh, SEEQ_COMMAND, sc->sc_command);
    772  1.24    bjh21 	SEEQ_WRITE16(sc, iot, ioh, SEEQ_CONFIG1, sc->sc_config1);
    773  1.24    bjh21 	SEEQ_WRITE16(sc, iot, ioh, SEEQ_CONFIG2, sc->sc_config2);
    774  1.11    bjh21 	if (sc->sc_variant == SEEQ_8004) {
    775  1.11    bjh21 		ea_select_buffer(sc, SEEQ_BUFCODE_CONFIG3);
    776  1.24    bjh21 		SEEQ_WRITE16(sc, iot, ioh, SEEQ_BUFWIN, sc->sc_config3);
    777  1.11    bjh21 	}
    778  1.11    bjh21 
    779  1.11    bjh21 	/* Write the station address - the receiver must be off */
    780  1.34    bjh21 	ea_set_address(sc, 0, (u_int8_t *)LLADDR(ifp->if_sadl));
    781   1.3    bjh21 
    782   1.3    bjh21 	/* Split board memory into Rx and Tx. */
    783  1.10    bjh21 	ea_select_buffer(sc, SEEQ_BUFCODE_TX_EAP);
    784  1.24    bjh21 	SEEQ_WRITE16(sc, iot, ioh, SEEQ_BUFWIN, (sc->sc_tx_bufsize>> 8) - 1);
    785   1.3    bjh21 
    786  1.27    bjh21 	if (sc->sc_variant == SEEQ_8004) {
    787  1.27    bjh21 		/* Make the interface IFF_SIMPLEX. */
    788  1.11    bjh21 		sc->sc_config2 |= SEEQ_CFG2_RX_TX_DISABLE;
    789  1.27    bjh21 		/* Enable reception of long packets (for vlan(4)). */
    790  1.27    bjh21 		sc->sc_config2 |= SEEQ_CFG2_PASS_LONGSHORT;
    791  1.27    bjh21 	}
    792   1.1    bjh21 
    793   1.1    bjh21 	/* Configure rx. */
    794  1.13    bjh21 	ea_mc_reset(sc);
    795   1.1    bjh21 	if (ifp->if_flags & IFF_PROMISC)
    796  1.10    bjh21 		sc->sc_config1 = SEEQ_CFG1_PROMISCUOUS;
    797  1.13    bjh21 	else if ((ifp->if_flags & IFF_ALLMULTI) || sc->sc_variant == SEEQ_8004)
    798  1.10    bjh21 		sc->sc_config1 = SEEQ_CFG1_MULTICAST;
    799   1.1    bjh21 	else
    800  1.10    bjh21 		sc->sc_config1 = SEEQ_CFG1_BROADCAST;
    801  1.10    bjh21 	sc->sc_config1 |= SEEQ_CFG1_STATION_ADDR0;
    802  1.24    bjh21 	SEEQ_WRITE16(sc, iot, ioh, SEEQ_CONFIG1, sc->sc_config1);
    803   1.3    bjh21 
    804   1.3    bjh21 	/* Setup the Rx pointers */
    805  1.11    bjh21 	sc->sc_rx_ptr = sc->sc_tx_bufsize;
    806   1.3    bjh21 
    807  1.24    bjh21 	SEEQ_WRITE16(sc, iot, ioh, SEEQ_RX_PTR, sc->sc_rx_ptr);
    808  1.24    bjh21 	SEEQ_WRITE16(sc, iot, ioh, SEEQ_RX_END, sc->sc_rx_ptr >> 8);
    809   1.3    bjh21 
    810   1.3    bjh21 
    811   1.3    bjh21 	/* Place a NULL header at the beginning of the receive area */
    812   1.3    bjh21 	ea_writebuf(sc, NULL, sc->sc_rx_ptr, 0);
    813  1.37    perry 
    814  1.24    bjh21 	SEEQ_WRITE16(sc, iot, ioh, SEEQ_BUFWIN, 0x0000);
    815  1.24    bjh21 	SEEQ_WRITE16(sc, iot, ioh, SEEQ_BUFWIN, 0x0000);
    816   1.1    bjh21 
    817   1.3    bjh21 
    818   1.1    bjh21 	/* Configure TX. */
    819  1.16    bjh21 	DPRINTF(SEEQ_DEBUG_MISC, ("Configuring tx...\n"));
    820   1.1    bjh21 
    821  1.24    bjh21 	SEEQ_WRITE16(sc, iot, ioh, SEEQ_TX_PTR, 0x0000);
    822   1.1    bjh21 
    823  1.10    bjh21 	sc->sc_config2 |= SEEQ_CFG2_OUTPUT;
    824  1.24    bjh21 	SEEQ_WRITE16(sc, iot, ioh, SEEQ_CONFIG2, sc->sc_config2);
    825   1.1    bjh21 
    826  1.11    bjh21 	/* Reset tx buffer pointers */
    827  1.11    bjh21 	sc->sc_tx_cur = 0;
    828  1.11    bjh21 	sc->sc_tx_used = 0;
    829  1.11    bjh21 	sc->sc_tx_next = 0;
    830   1.1    bjh21 
    831   1.1    bjh21 	/* Place a NULL header at the beginning of the transmit area */
    832   1.1    bjh21 	ea_writebuf(sc, NULL, 0x0000, 0);
    833  1.37    perry 
    834  1.24    bjh21 	SEEQ_WRITE16(sc, iot, ioh, SEEQ_BUFWIN, 0x0000);
    835  1.24    bjh21 	SEEQ_WRITE16(sc, iot, ioh, SEEQ_BUFWIN, 0x0000);
    836   1.1    bjh21 
    837  1.10    bjh21 	sc->sc_command |= SEEQ_CMD_TX_INTEN;
    838  1.24    bjh21 	SEEQ_WRITE16(sc, iot, ioh, SEEQ_COMMAND, sc->sc_command);
    839   1.1    bjh21 
    840  1.11    bjh21 	/* Turn on Rx */
    841  1.11    bjh21 	sc->sc_command |= SEEQ_CMD_RX_INTEN;
    842  1.24    bjh21 	SEEQ_WRITE16(sc, iot, ioh, SEEQ_COMMAND,
    843  1.11    bjh21 			  sc->sc_command | SEEQ_CMD_RX_ON);
    844  1.11    bjh21 
    845   1.3    bjh21 	/* TX_ON gets set by ea_txpacket when there's something to transmit. */
    846   1.1    bjh21 
    847   1.1    bjh21 
    848   1.1    bjh21 	/* Set flags appropriately. */
    849   1.1    bjh21 	ifp->if_flags |= IFF_RUNNING;
    850   1.1    bjh21 	ifp->if_flags &= ~IFF_OACTIVE;
    851  1.11    bjh21 	sc->sc_enabled = 1;
    852   1.1    bjh21 
    853   1.1    bjh21 	/* And start output. */
    854   1.1    bjh21 	ea_start(ifp);
    855   1.1    bjh21 
    856   1.1    bjh21 	splx(s);
    857   1.1    bjh21 	return 0;
    858   1.1    bjh21 }
    859   1.1    bjh21 
    860   1.1    bjh21 /*
    861   1.1    bjh21  * Start output on interface. Get datagrams from the queue and output them,
    862   1.1    bjh21  * giving the receiver a chance between datagrams. Call only from splnet or
    863   1.1    bjh21  * interrupt level!
    864   1.1    bjh21  */
    865   1.1    bjh21 
    866   1.1    bjh21 static void
    867   1.1    bjh21 ea_start(struct ifnet *ifp)
    868   1.1    bjh21 {
    869   1.1    bjh21 	struct seeq8005_softc *sc = ifp->if_softc;
    870   1.1    bjh21 	int s;
    871   1.1    bjh21 
    872   1.1    bjh21 	s = splnet();
    873  1.16    bjh21 	DPRINTF(SEEQ_DEBUG_TX, ("ea_start()...\n"));
    874   1.1    bjh21 
    875  1.14    bjh21 	/*
    876  1.14    bjh21 	 * Don't do anything if output is active.  seeq8005intr() will call
    877  1.14    bjh21 	 * us (actually eatxpacket()) back when the card's ready for more
    878  1.14    bjh21 	 * frames.
    879  1.14    bjh21 	 */
    880   1.1    bjh21 	if (ifp->if_flags & IFF_OACTIVE)
    881   1.1    bjh21 		return;
    882   1.1    bjh21 
    883   1.1    bjh21 	/* Mark interface as output active */
    884  1.37    perry 
    885   1.1    bjh21 	ifp->if_flags |= IFF_OACTIVE;
    886   1.1    bjh21 
    887   1.1    bjh21 	/* tx packets */
    888   1.1    bjh21 
    889   1.1    bjh21 	eatxpacket(sc);
    890   1.1    bjh21 	splx(s);
    891   1.1    bjh21 }
    892   1.1    bjh21 
    893   1.1    bjh21 
    894   1.1    bjh21 /*
    895   1.1    bjh21  * Transfer a packet to the interface buffer and start transmission
    896   1.1    bjh21  *
    897   1.1    bjh21  * Called at splnet()
    898   1.1    bjh21  */
    899  1.37    perry 
    900   1.1    bjh21 void
    901   1.1    bjh21 eatxpacket(struct seeq8005_softc *sc)
    902   1.1    bjh21 {
    903   1.1    bjh21 	bus_space_tag_t iot = sc->sc_iot;
    904   1.1    bjh21 	bus_space_handle_t ioh = sc->sc_ioh;
    905  1.12    bjh21 	struct mbuf *m0;
    906   1.1    bjh21 	struct ifnet *ifp;
    907   1.1    bjh21 
    908   1.1    bjh21 	ifp = &sc->sc_ethercom.ec_if;
    909   1.1    bjh21 
    910   1.1    bjh21 	/* Dequeue the next packet. */
    911   1.7  thorpej 	IFQ_DEQUEUE(&ifp->if_snd, m0);
    912   1.1    bjh21 
    913   1.1    bjh21 	/* If there's nothing to send, return. */
    914   1.1    bjh21 	if (!m0) {
    915   1.1    bjh21 		ifp->if_flags &= ~IFF_OACTIVE;
    916  1.10    bjh21 		sc->sc_config2 |= SEEQ_CFG2_OUTPUT;
    917  1.24    bjh21 		SEEQ_WRITE16(sc, iot, ioh, SEEQ_CONFIG2, sc->sc_config2);
    918  1.16    bjh21 		DPRINTF(SEEQ_DEBUG_TX, ("tx finished\n"));
    919   1.1    bjh21 		return;
    920   1.1    bjh21 	}
    921   1.1    bjh21 
    922   1.1    bjh21 #if NBPFILTER > 0
    923   1.1    bjh21 	/* Give the packet to the bpf, if any. */
    924   1.1    bjh21 	if (ifp->if_bpf)
    925   1.1    bjh21 		bpf_mtap(ifp->if_bpf, m0);
    926   1.1    bjh21 #endif
    927   1.1    bjh21 
    928  1.16    bjh21 	DPRINTF(SEEQ_DEBUG_TX, ("Tx new packet\n"));
    929   1.1    bjh21 
    930  1.10    bjh21 	sc->sc_config2 &= ~SEEQ_CFG2_OUTPUT;
    931  1.24    bjh21 	SEEQ_WRITE16(sc, iot, ioh, SEEQ_CONFIG2, sc->sc_config2);
    932   1.1    bjh21 
    933  1.12    bjh21 	ea_writembuf(sc, m0, 0x0000);
    934  1.12    bjh21 	m_freem(m0);
    935  1.12    bjh21 
    936  1.24    bjh21 	SEEQ_WRITE16(sc, iot, ioh, SEEQ_TX_PTR, 0x0000);
    937  1.12    bjh21 
    938  1.12    bjh21 	/* Now transmit the datagram. */
    939  1.24    bjh21 	SEEQ_WRITE16(sc, iot, ioh, SEEQ_COMMAND,
    940  1.12    bjh21 			  sc->sc_command | SEEQ_CMD_TX_ON);
    941  1.15    bjh21 
    942  1.15    bjh21 	/* Make sure we notice if the chip goes silent on us. */
    943  1.15    bjh21 	ifp->if_timer = 5;
    944  1.15    bjh21 
    945  1.16    bjh21 	DPRINTF(SEEQ_DEBUG_TX,
    946  1.24    bjh21 	    ("st=%04x\n", SEEQ_READ16(sc, iot, ioh, SEEQ_STATUS)));
    947  1.16    bjh21 	DPRINTF(SEEQ_DEBUG_TX, ("tx: queued\n"));
    948  1.12    bjh21 }
    949  1.12    bjh21 
    950  1.12    bjh21 /*
    951  1.12    bjh21  * Copy a packet from an mbuf to the transmit buffer on the card.
    952  1.12    bjh21  *
    953  1.12    bjh21  * Puts a valid Tx header at the start of the packet, and a null header at
    954  1.12    bjh21  * the end.
    955  1.12    bjh21  */
    956  1.12    bjh21 static int
    957  1.12    bjh21 ea_writembuf(struct seeq8005_softc *sc, struct mbuf *m0, int bufstart)
    958  1.12    bjh21 {
    959  1.12    bjh21 	struct mbuf *m;
    960  1.12    bjh21 	int len, nextpacket;
    961  1.12    bjh21 	u_int8_t hdr[4];
    962  1.12    bjh21 
    963   1.1    bjh21 	/*
    964  1.12    bjh21 	 * Copy the datagram to the packet buffer.
    965   1.1    bjh21 	 */
    966   1.1    bjh21 	len = 0;
    967   1.1    bjh21 	for (m = m0; m; m = m->m_next) {
    968   1.1    bjh21 		if (m->m_len == 0)
    969   1.1    bjh21 			continue;
    970  1.34    bjh21 		ea_writebuf(sc, mtod(m, u_char *), bufstart + 4 + len,
    971  1.22    bjh21 		    m->m_len);
    972   1.1    bjh21 		len += m->m_len;
    973   1.1    bjh21 	}
    974   1.1    bjh21 
    975  1.35   bouyer 	if (len < ETHER_MIN_LEN) {
    976  1.35   bouyer 		ea_writebuf(sc, padbuf, bufstart + 4 + len,
    977  1.35   bouyer 		    ETHER_MIN_LEN - len);
    978  1.35   bouyer 		len = ETHER_MIN_LEN;
    979  1.35   bouyer 	}
    980   1.1    bjh21 
    981   1.1    bjh21 	/* Follow it with a NULL packet header */
    982  1.22    bjh21 	memset(hdr, 0, 4);
    983  1.22    bjh21 	ea_writebuf(sc, hdr, bufstart + 4 + len, 4);
    984  1.24    bjh21 	SEEQ_WRITE16(sc, sc->sc_iot, sc->sc_ioh, SEEQ_BUFWIN, 0x0000);
    985  1.24    bjh21 	SEEQ_WRITE16(sc, sc->sc_iot, sc->sc_ioh, SEEQ_BUFWIN, 0x0000);
    986   1.1    bjh21 
    987  1.12    bjh21 	/* Ok we now have a packet len bytes long in our packet buffer */
    988  1.16    bjh21 	DPRINTF(SEEQ_DEBUG_TX, ("ea_writembuf: length=%d\n", len));
    989   1.1    bjh21 
    990   1.1    bjh21 	/* Write the packet header */
    991   1.1    bjh21 	nextpacket = len + 4;
    992   1.1    bjh21 	hdr[0] = (nextpacket >> 8) & 0xff;
    993   1.1    bjh21 	hdr[1] = nextpacket & 0xff;
    994  1.10    bjh21 	hdr[2] = SEEQ_PKTCMD_TX | SEEQ_PKTCMD_DATA_FOLLOWS |
    995  1.10    bjh21 		SEEQ_TXCMD_XMIT_SUCCESS_INT | SEEQ_TXCMD_COLLISION_INT;
    996   1.1    bjh21 	hdr[3] = 0; /* Status byte -- will be update by hardware. */
    997   1.1    bjh21 	ea_writebuf(sc, hdr, 0x0000, 4);
    998   1.1    bjh21 
    999  1.12    bjh21 	return len;
   1000   1.1    bjh21 }
   1001   1.1    bjh21 
   1002   1.1    bjh21 /*
   1003   1.1    bjh21  * Ethernet controller interrupt.
   1004   1.1    bjh21  */
   1005   1.1    bjh21 
   1006   1.1    bjh21 int
   1007   1.1    bjh21 seeq8005intr(void *arg)
   1008   1.1    bjh21 {
   1009   1.1    bjh21 	struct seeq8005_softc *sc = arg;
   1010   1.1    bjh21 	bus_space_tag_t iot = sc->sc_iot;
   1011   1.1    bjh21 	bus_space_handle_t ioh = sc->sc_ioh;
   1012  1.11    bjh21 	int status, handled;
   1013   1.1    bjh21 
   1014   1.1    bjh21 	handled = 0;
   1015   1.1    bjh21 
   1016   1.1    bjh21 	/* Get the controller status */
   1017  1.24    bjh21 	status = SEEQ_READ16(sc, iot, ioh, SEEQ_STATUS);
   1018   1.1    bjh21 
   1019   1.1    bjh21 	/* Tx interrupt ? */
   1020  1.10    bjh21 	if (status & SEEQ_STATUS_TX_INT) {
   1021   1.1    bjh21 		handled = 1;
   1022   1.1    bjh21 
   1023   1.1    bjh21 		/* Acknowledge the interrupt */
   1024  1.24    bjh21 		SEEQ_WRITE16(sc, iot, ioh, SEEQ_COMMAND,
   1025  1.10    bjh21 				  sc->sc_command | SEEQ_CMD_TX_INTACK);
   1026   1.1    bjh21 
   1027  1.20    bjh21 		ea_txint(sc);
   1028   1.1    bjh21 	}
   1029   1.1    bjh21 
   1030   1.1    bjh21 
   1031   1.1    bjh21 	/* Rx interrupt ? */
   1032  1.10    bjh21 	if (status & SEEQ_STATUS_RX_INT) {
   1033   1.1    bjh21 		handled = 1;
   1034   1.1    bjh21 
   1035   1.1    bjh21 		/* Acknowledge the interrupt */
   1036  1.24    bjh21 		SEEQ_WRITE16(sc, iot, ioh, SEEQ_COMMAND,
   1037  1.10    bjh21 				  sc->sc_command | SEEQ_CMD_RX_INTACK);
   1038   1.1    bjh21 
   1039   1.1    bjh21 		/* Processes the received packets */
   1040  1.20    bjh21 		ea_rxint(sc);
   1041  1.20    bjh21 	}
   1042   1.1    bjh21 
   1043  1.30    bjh21 #if NRND > 0
   1044  1.30    bjh21 	if (handled)
   1045  1.30    bjh21 		rnd_add_uint32(&sc->rnd_source, status);
   1046  1.30    bjh21 #endif
   1047  1.20    bjh21 	return handled;
   1048  1.20    bjh21 }
   1049   1.1    bjh21 
   1050  1.20    bjh21 static void
   1051  1.20    bjh21 ea_txint(struct seeq8005_softc *sc)
   1052  1.20    bjh21 {
   1053  1.20    bjh21 	struct ifnet *ifp = &sc->sc_ethercom.ec_if;
   1054  1.20    bjh21 	bus_space_tag_t iot = sc->sc_iot;
   1055  1.20    bjh21 	bus_space_handle_t ioh = sc->sc_ioh;
   1056  1.20    bjh21 	u_int8_t txhdr[4];
   1057  1.20    bjh21 	u_int txstatus;
   1058  1.20    bjh21 
   1059  1.20    bjh21 	ea_readbuf(sc, txhdr, 0x0000, 4);
   1060  1.20    bjh21 
   1061  1.20    bjh21 	DPRINTF(SEEQ_DEBUG_TX, ("txstatus=%02x %02x %02x %02x\n",
   1062  1.20    bjh21 	    txhdr[0], txhdr[1], txhdr[2], txhdr[3]));
   1063  1.20    bjh21 	txstatus = txhdr[3];
   1064  1.20    bjh21 
   1065  1.20    bjh21 	/*
   1066  1.20    bjh21 	 * If SEEQ_TXSTAT_COLLISION is set then we received at least
   1067  1.20    bjh21 	 * one collision. On the 8004 we can find out exactly how many
   1068  1.20    bjh21 	 * collisions occurred.
   1069  1.20    bjh21 	 *
   1070  1.20    bjh21 	 * The SEEQ_PKTSTAT_DONE will be set if the transmission has
   1071  1.20    bjh21 	 * completed.
   1072  1.20    bjh21 	 *
   1073  1.20    bjh21 	 * If SEEQ_TXSTAT_COLLISION16 is set then 16 collisions
   1074  1.20    bjh21 	 * occurred and the packet transmission was aborted.
   1075  1.20    bjh21 	 * This situation is untested as present.
   1076  1.20    bjh21 	 *
   1077  1.27    bjh21 	 * The SEEQ_TXSTAT_BABBLE is untested as it should only be set
   1078  1.27    bjh21 	 * when we deliberately transmit oversized packets (e.g. for
   1079  1.27    bjh21 	 * 802.1Q).
   1080  1.20    bjh21 	 */
   1081  1.20    bjh21 	if (txstatus & SEEQ_TXSTAT_COLLISION) {
   1082  1.20    bjh21 		switch (sc->sc_variant) {
   1083  1.20    bjh21 		case SEEQ_8004: {
   1084  1.20    bjh21 			int colls;
   1085  1.20    bjh21 
   1086  1.20    bjh21 			/*
   1087  1.20    bjh21 			 * The 8004 contains a 4 bit collision count
   1088  1.20    bjh21 			 * in the status register.
   1089  1.20    bjh21 			 */
   1090  1.20    bjh21 
   1091  1.20    bjh21 			/* This appears to be broken on 80C04.AE */
   1092  1.20    bjh21 /*			ifp->if_collisions +=
   1093  1.20    bjh21 			    (txstatus >> SEEQ_TXSTAT_COLLISIONS_SHIFT)
   1094  1.20    bjh21 			    & SEEQ_TXSTAT_COLLISION_MASK;*/
   1095  1.37    perry 
   1096  1.20    bjh21 			/* Use the TX Collision register */
   1097  1.20    bjh21 			ea_select_buffer(sc, SEEQ_BUFCODE_TX_COLLS);
   1098  1.20    bjh21 			colls = bus_space_read_1(iot, ioh, SEEQ_BUFWIN);
   1099  1.20    bjh21 			ifp->if_collisions += colls;
   1100  1.20    bjh21 			break;
   1101   1.1    bjh21 		}
   1102  1.20    bjh21 		case SEEQ_8005:
   1103  1.20    bjh21 			/* We known there was at least 1 collision */
   1104  1.20    bjh21 			ifp->if_collisions++;
   1105  1.20    bjh21 			break;
   1106  1.20    bjh21 		}
   1107  1.20    bjh21 	} else if (txstatus & SEEQ_TXSTAT_COLLISION16) {
   1108  1.20    bjh21 		printf("seeq_intr: col16 %x\n", txstatus);
   1109  1.20    bjh21 		ifp->if_collisions += 16;
   1110  1.20    bjh21 		ifp->if_oerrors++;
   1111   1.1    bjh21 	}
   1112   1.1    bjh21 
   1113  1.20    bjh21 	/* Have we completed transmission on the packet ? */
   1114  1.20    bjh21 	if (txstatus & SEEQ_PKTSTAT_DONE) {
   1115  1.20    bjh21 		/* Clear watchdog timer. */
   1116  1.20    bjh21 		ifp->if_timer = 0;
   1117  1.20    bjh21 		ifp->if_flags &= ~IFF_OACTIVE;
   1118  1.20    bjh21 
   1119  1.20    bjh21 		/* Update stats */
   1120  1.20    bjh21 		ifp->if_opackets++;
   1121  1.20    bjh21 
   1122  1.20    bjh21 		/* Tx next packet */
   1123  1.20    bjh21 
   1124  1.20    bjh21 		eatxpacket(sc);
   1125  1.20    bjh21 	}
   1126   1.1    bjh21 }
   1127   1.1    bjh21 
   1128   1.1    bjh21 void
   1129  1.20    bjh21 ea_rxint(struct seeq8005_softc *sc)
   1130   1.1    bjh21 {
   1131   1.1    bjh21 	bus_space_tag_t iot = sc->sc_iot;
   1132   1.1    bjh21 	bus_space_handle_t ioh = sc->sc_ioh;
   1133   1.1    bjh21 	u_int addr;
   1134   1.1    bjh21 	int len;
   1135   1.1    bjh21 	int ctrl;
   1136   1.1    bjh21 	int ptr;
   1137   1.1    bjh21 	int status;
   1138   1.1    bjh21 	u_int8_t rxhdr[4];
   1139   1.1    bjh21 	struct ifnet *ifp;
   1140   1.1    bjh21 
   1141   1.1    bjh21 	ifp = &sc->sc_ethercom.ec_if;
   1142   1.1    bjh21 
   1143   1.1    bjh21 
   1144   1.1    bjh21 	/* We start from the last rx pointer position */
   1145   1.1    bjh21 	addr = sc->sc_rx_ptr;
   1146  1.10    bjh21 	sc->sc_config2 &= ~SEEQ_CFG2_OUTPUT;
   1147  1.24    bjh21 	SEEQ_WRITE16(sc, iot, ioh, SEEQ_CONFIG2, sc->sc_config2);
   1148   1.1    bjh21 
   1149   1.1    bjh21 	do {
   1150   1.1    bjh21 		/* Read rx header */
   1151   1.1    bjh21 		ea_readbuf(sc, rxhdr, addr, 4);
   1152  1.37    perry 
   1153   1.1    bjh21 		/* Split the packet header */
   1154   1.1    bjh21 		ptr = (rxhdr[0] << 8) | rxhdr[1];
   1155   1.1    bjh21 		ctrl = rxhdr[2];
   1156   1.1    bjh21 		status = rxhdr[3];
   1157   1.1    bjh21 
   1158  1.16    bjh21 		DPRINTF(SEEQ_DEBUG_RX,
   1159  1.16    bjh21 		    ("addr=%04x ptr=%04x ctrl=%02x status=%02x\n",
   1160  1.16    bjh21 			addr, ptr, ctrl, status));
   1161   1.1    bjh21 
   1162   1.1    bjh21 		/* Zero packet ptr ? then must be null header so exit */
   1163   1.1    bjh21 		if (ptr == 0) break;
   1164   1.1    bjh21 
   1165  1.15    bjh21 		/* Sanity-check the next-packet pointer and flags. */
   1166  1.15    bjh21 		if (__predict_false(ptr < sc->sc_tx_bufsize ||
   1167  1.15    bjh21 		    (ctrl & SEEQ_PKTCMD_TX))) {
   1168  1.15    bjh21 			++ifp->if_ierrors;
   1169  1.15    bjh21 			log(LOG_ERR,
   1170  1.15    bjh21 			    "%s: Rx chain corrupt at %04x (ptr = %04x)\n",
   1171  1.15    bjh21 			    sc->sc_dev.dv_xname, addr, ptr);
   1172  1.15    bjh21 			ea_init(ifp);
   1173  1.15    bjh21 			return;
   1174  1.15    bjh21 		}
   1175   1.1    bjh21 
   1176   1.1    bjh21 		/* Get packet length */
   1177   1.1    bjh21        		len = (ptr - addr) - 4;
   1178   1.1    bjh21 
   1179   1.1    bjh21 		if (len < 0)
   1180  1.11    bjh21 			len += sc->sc_rx_bufsize;
   1181  1.16    bjh21 		DPRINTF(SEEQ_DEBUG_RX, ("len=%04x\n", len));
   1182   1.1    bjh21 
   1183   1.1    bjh21 		/* Has the packet rx completed ? if not then exit */
   1184  1.10    bjh21 		if ((status & SEEQ_PKTSTAT_DONE) == 0)
   1185   1.1    bjh21 			break;
   1186   1.1    bjh21 
   1187   1.1    bjh21 		/*
   1188   1.1    bjh21 		 * Did we have any errors? then note error and go to
   1189   1.1    bjh21 		 * next packet
   1190   1.1    bjh21 		 */
   1191  1.27    bjh21 		if (__predict_false(status &
   1192  1.27    bjh21 			(SEEQ_RXSTAT_CRC_ERROR | SEEQ_RXSTAT_DRIBBLE_ERROR |
   1193  1.27    bjh21 			 SEEQ_RXSTAT_SHORT_FRAME))) {
   1194   1.1    bjh21 			++ifp->if_ierrors;
   1195   1.1    bjh21 			log(LOG_WARNING,
   1196  1.17    bjh21 			    "%s: rx packet error at %04x (err=%02x)\n",
   1197  1.17    bjh21 			    sc->sc_dev.dv_xname, addr, status & 0x0f);
   1198  1.19    bjh21 			/* XXX shouldn't need to reset if it's genuine. */
   1199  1.19    bjh21 			ea_init(ifp);
   1200  1.19    bjh21 			return;
   1201   1.1    bjh21 		}
   1202   1.1    bjh21 		/*
   1203  1.27    bjh21 		 * Is the packet too big?  We allow slightly oversize packets
   1204  1.27    bjh21 		 * for vlan(4) and tcpdump purposes, but the rest of the world
   1205  1.27    bjh21 		 * wants incoming packets in a single mbuf cluster.
   1206   1.1    bjh21 		 */
   1207  1.27    bjh21 		if (__predict_false(len > MCLBYTES)) {
   1208   1.1    bjh21 			++ifp->if_ierrors;
   1209  1.17    bjh21 			log(LOG_ERR,
   1210  1.17    bjh21 			    "%s: rx packet size error at %04x (len=%d)\n",
   1211  1.17    bjh21 			    sc->sc_dev.dv_xname, addr, len);
   1212  1.10    bjh21 			sc->sc_config2 |= SEEQ_CFG2_OUTPUT;
   1213  1.24    bjh21 			SEEQ_WRITE16(sc, iot, ioh, SEEQ_CONFIG2,
   1214   1.1    bjh21 					  sc->sc_config2);
   1215   1.5    bjh21 			ea_init(ifp);
   1216   1.1    bjh21 			return;
   1217   1.1    bjh21 		}
   1218   1.1    bjh21 
   1219   1.1    bjh21 		ifp->if_ipackets++;
   1220   1.1    bjh21 		/* Pass data up to upper levels. */
   1221  1.11    bjh21 		ea_read(sc, addr + 4, len);
   1222   1.1    bjh21 
   1223   1.1    bjh21 		addr = ptr;
   1224   1.1    bjh21 	} while (len != 0);
   1225   1.1    bjh21 
   1226  1.10    bjh21 	sc->sc_config2 |= SEEQ_CFG2_OUTPUT;
   1227  1.24    bjh21 	SEEQ_WRITE16(sc, iot, ioh, SEEQ_CONFIG2, sc->sc_config2);
   1228   1.1    bjh21 
   1229  1.16    bjh21 	DPRINTF(SEEQ_DEBUG_RX, ("new rx ptr=%04x\n", addr));
   1230   1.1    bjh21 
   1231   1.1    bjh21 	/* Store new rx pointer */
   1232   1.1    bjh21 	sc->sc_rx_ptr = addr;
   1233  1.24    bjh21 	SEEQ_WRITE16(sc, iot, ioh, SEEQ_RX_END, sc->sc_rx_ptr >> 8);
   1234   1.1    bjh21 
   1235   1.1    bjh21 	/* Make sure the receiver is on */
   1236  1.24    bjh21 	SEEQ_WRITE16(sc, iot, ioh, SEEQ_COMMAND,
   1237  1.10    bjh21 			  sc->sc_command | SEEQ_CMD_RX_ON);
   1238   1.1    bjh21 }
   1239   1.1    bjh21 
   1240   1.1    bjh21 
   1241   1.1    bjh21 /*
   1242   1.1    bjh21  * Pass a packet up to the higher levels.
   1243   1.1    bjh21  */
   1244   1.1    bjh21 
   1245   1.1    bjh21 static void
   1246  1.11    bjh21 ea_read(struct seeq8005_softc *sc, int addr, int len)
   1247   1.1    bjh21 {
   1248   1.1    bjh21 	struct mbuf *m;
   1249   1.1    bjh21 	struct ifnet *ifp;
   1250   1.1    bjh21 
   1251   1.1    bjh21 	ifp = &sc->sc_ethercom.ec_if;
   1252   1.1    bjh21 
   1253   1.1    bjh21 	/* Pull packet off interface. */
   1254  1.11    bjh21 	m = ea_get(sc, addr, len, ifp);
   1255   1.1    bjh21 	if (m == 0)
   1256   1.1    bjh21 		return;
   1257   1.1    bjh21 
   1258   1.1    bjh21 #if NBPFILTER > 0
   1259   1.1    bjh21 	/*
   1260   1.1    bjh21 	 * Check if there's a BPF listener on this interface.
   1261   1.1    bjh21 	 * If so, hand off the raw packet to bpf.
   1262   1.1    bjh21 	 */
   1263   1.4  thorpej 	if (ifp->if_bpf)
   1264   1.1    bjh21 		bpf_mtap(ifp->if_bpf, m);
   1265   1.1    bjh21 #endif
   1266   1.1    bjh21 
   1267   1.1    bjh21 	(*ifp->if_input)(ifp, m);
   1268   1.1    bjh21 }
   1269   1.1    bjh21 
   1270   1.1    bjh21 /*
   1271   1.1    bjh21  * Pull read data off a interface.  Len is length of data, with local net
   1272   1.1    bjh21  * header stripped.  We copy the data into mbufs.  When full cluster sized
   1273   1.1    bjh21  * units are present we copy into clusters.
   1274   1.1    bjh21  */
   1275   1.1    bjh21 
   1276   1.1    bjh21 struct mbuf *
   1277  1.11    bjh21 ea_get(struct seeq8005_softc *sc, int addr, int totlen, struct ifnet *ifp)
   1278   1.1    bjh21 {
   1279   1.1    bjh21         struct mbuf *top, **mp, *m;
   1280   1.1    bjh21         int len;
   1281   1.1    bjh21         u_int cp, epkt;
   1282   1.1    bjh21 
   1283   1.1    bjh21         cp = addr;
   1284   1.1    bjh21         epkt = cp + totlen;
   1285   1.1    bjh21 
   1286   1.1    bjh21         MGETHDR(m, M_DONTWAIT, MT_DATA);
   1287   1.1    bjh21         if (m == 0)
   1288   1.1    bjh21                 return 0;
   1289   1.1    bjh21         m->m_pkthdr.rcvif = ifp;
   1290   1.1    bjh21         m->m_pkthdr.len = totlen;
   1291   1.1    bjh21         m->m_len = MHLEN;
   1292   1.1    bjh21         top = 0;
   1293   1.1    bjh21         mp = &top;
   1294   1.1    bjh21 
   1295   1.1    bjh21         while (totlen > 0) {
   1296   1.1    bjh21                 if (top) {
   1297   1.1    bjh21                         MGET(m, M_DONTWAIT, MT_DATA);
   1298   1.1    bjh21                         if (m == 0) {
   1299   1.1    bjh21                                 m_freem(top);
   1300   1.1    bjh21                                 return 0;
   1301   1.1    bjh21                         }
   1302   1.1    bjh21                         m->m_len = MLEN;
   1303   1.1    bjh21                 }
   1304   1.1    bjh21                 len = min(totlen, epkt - cp);
   1305   1.1    bjh21                 if (len >= MINCLSIZE) {
   1306   1.1    bjh21                         MCLGET(m, M_DONTWAIT);
   1307   1.1    bjh21                         if (m->m_flags & M_EXT)
   1308   1.1    bjh21                                 m->m_len = len = min(len, MCLBYTES);
   1309   1.1    bjh21                         else
   1310   1.1    bjh21                                 len = m->m_len;
   1311   1.1    bjh21                 } else {
   1312   1.1    bjh21                         /*
   1313   1.1    bjh21                          * Place initial small packet/header at end of mbuf.
   1314   1.1    bjh21                          */
   1315   1.1    bjh21                         if (len < m->m_len) {
   1316   1.1    bjh21                                 if (top == 0 && len + max_linkhdr <= m->m_len)
   1317   1.1    bjh21                                         m->m_data += max_linkhdr;
   1318   1.1    bjh21                                 m->m_len = len;
   1319   1.1    bjh21                         } else
   1320   1.1    bjh21                                 len = m->m_len;
   1321   1.1    bjh21                 }
   1322   1.1    bjh21 		if (top == 0) {
   1323   1.1    bjh21 			/* Make sure the payload is aligned */
   1324   1.1    bjh21 			caddr_t newdata = (caddr_t)
   1325   1.1    bjh21 			    ALIGN(m->m_data + sizeof(struct ether_header)) -
   1326   1.1    bjh21 			    sizeof(struct ether_header);
   1327   1.1    bjh21 			len -= newdata - m->m_data;
   1328   1.1    bjh21 			m->m_len = len;
   1329   1.1    bjh21 			m->m_data = newdata;
   1330   1.1    bjh21 		}
   1331   1.1    bjh21                 ea_readbuf(sc, mtod(m, u_char *),
   1332  1.11    bjh21 		    cp < SEEQ_MAX_BUFFER_SIZE ? cp : cp - sc->sc_rx_bufsize,
   1333  1.11    bjh21 		    len);
   1334   1.1    bjh21                 cp += len;
   1335   1.1    bjh21                 *mp = m;
   1336   1.1    bjh21                 mp = &m->m_next;
   1337   1.1    bjh21                 totlen -= len;
   1338   1.1    bjh21                 if (cp == epkt)
   1339   1.1    bjh21                         cp = addr;
   1340   1.1    bjh21         }
   1341   1.1    bjh21 
   1342   1.1    bjh21         return top;
   1343   1.1    bjh21 }
   1344   1.1    bjh21 
   1345   1.1    bjh21 /*
   1346   1.3    bjh21  * Process an ioctl request.  Mostly boilerplate.
   1347   1.1    bjh21  */
   1348   1.1    bjh21 static int
   1349   1.1    bjh21 ea_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
   1350   1.1    bjh21 {
   1351   1.1    bjh21 	struct seeq8005_softc *sc = ifp->if_softc;
   1352   1.1    bjh21 	int s, error = 0;
   1353   1.1    bjh21 
   1354   1.1    bjh21 	s = splnet();
   1355   1.1    bjh21 	switch (cmd) {
   1356   1.1    bjh21 
   1357   1.5    bjh21 	default:
   1358   1.5    bjh21 		error = ether_ioctl(ifp, cmd, data);
   1359   1.5    bjh21 		if (error == ENETRESET) {
   1360   1.1    bjh21 			/*
   1361   1.5    bjh21 			 * Multicast list has changed; set the hardware filter
   1362   1.5    bjh21 			 * accordingly.
   1363   1.1    bjh21 			 */
   1364  1.36  thorpej 			if (ifp->if_flags & IFF_RUNNING)
   1365  1.36  thorpej 				ea_mc_reset(sc);
   1366   1.5    bjh21 			error = 0;
   1367   1.1    bjh21 		}
   1368   1.1    bjh21 		break;
   1369   1.1    bjh21 	}
   1370   1.1    bjh21 
   1371   1.1    bjh21 	splx(s);
   1372   1.1    bjh21 	return error;
   1373   1.1    bjh21 }
   1374   1.1    bjh21 
   1375   1.5    bjh21 /* Must be called at splnet() */
   1376  1.11    bjh21 
   1377   1.5    bjh21 static void
   1378   1.5    bjh21 ea_mc_reset(struct seeq8005_softc *sc)
   1379   1.5    bjh21 {
   1380  1.11    bjh21 
   1381  1.11    bjh21 	switch (sc->sc_variant) {
   1382  1.11    bjh21 	case SEEQ_8004:
   1383  1.11    bjh21 		ea_mc_reset_8004(sc);
   1384  1.11    bjh21 		return;
   1385  1.11    bjh21 	case SEEQ_8005:
   1386  1.11    bjh21 		ea_mc_reset_8005(sc);
   1387  1.11    bjh21 		return;
   1388  1.11    bjh21 	}
   1389  1.11    bjh21 }
   1390  1.11    bjh21 
   1391  1.11    bjh21 static void
   1392  1.11    bjh21 ea_mc_reset_8004(struct seeq8005_softc *sc)
   1393  1.11    bjh21 {
   1394  1.11    bjh21 	struct ethercom *ec = &sc->sc_ethercom;
   1395  1.11    bjh21 	struct ifnet *ifp = &ec->ec_if;
   1396  1.11    bjh21 	struct ether_multi *enm;
   1397  1.25    bjh21         u_int32_t crc;
   1398  1.26    bjh21         int i;
   1399  1.25    bjh21         struct ether_multistep step;
   1400  1.25    bjh21         u_int8_t af[8];
   1401  1.11    bjh21 
   1402  1.11    bjh21 	/*
   1403  1.11    bjh21 	 * Set up multicast address filter by passing all multicast addresses
   1404  1.11    bjh21 	 * through a crc generator, and then using bits 2 - 7 as an index
   1405  1.11    bjh21 	 * into the 64 bit logical address filter.  The high order bits
   1406  1.11    bjh21 	 * selects the word, while the rest of the bits select the bit within
   1407  1.11    bjh21 	 * the word.
   1408  1.11    bjh21 	 */
   1409  1.11    bjh21 
   1410  1.11    bjh21 	if (ifp->if_flags & IFF_PROMISC) {
   1411  1.11    bjh21 		ifp->if_flags |= IFF_ALLMULTI;
   1412  1.11    bjh21 		for (i = 0; i < 8; i++)
   1413  1.11    bjh21 			af[i] = 0xff;
   1414  1.11    bjh21 		return;
   1415  1.11    bjh21 	}
   1416  1.11    bjh21 	for (i = 0; i < 8; i++)
   1417  1.11    bjh21 		af[i] = 0;
   1418  1.11    bjh21 	ETHER_FIRST_MULTI(step, ec, enm);
   1419  1.11    bjh21 	while (enm != NULL) {
   1420  1.28  thorpej 		if (memcmp(enm->enm_addrlo, enm->enm_addrhi,
   1421  1.11    bjh21 		    sizeof(enm->enm_addrlo)) != 0) {
   1422  1.11    bjh21 			/*
   1423  1.11    bjh21 			 * We must listen to a range of multicast addresses.
   1424  1.11    bjh21 			 * For now, just accept all multicasts, rather than
   1425  1.11    bjh21 			 * trying to set only those filter bits needed to match
   1426  1.11    bjh21 			 * the range.  (At this time, the only use of address
   1427  1.11    bjh21 			 * ranges is for IP multicast routing, for which the
   1428  1.11    bjh21 			 * range is big enough to require all bits set.)
   1429  1.11    bjh21 			 */
   1430  1.11    bjh21 			ifp->if_flags |= IFF_ALLMULTI;
   1431  1.11    bjh21 			for (i = 0; i < 8; i++)
   1432  1.11    bjh21 				af[i] = 0xff;
   1433  1.13    bjh21 			break;
   1434  1.11    bjh21 		}
   1435  1.26    bjh21 
   1436  1.26    bjh21 		crc = ether_crc32_be(enm->enm_addrlo, sizeof(enm->enm_addrlo));
   1437  1.26    bjh21 
   1438  1.11    bjh21 		/* Just want the 6 most significant bits. */
   1439  1.11    bjh21 		crc = (crc >> 2) & 0x3f;
   1440  1.11    bjh21 
   1441  1.11    bjh21 		/* Turn on the corresponding bit in the filter. */
   1442  1.11    bjh21 		af[crc >> 3] |= 1 << (crc & 0x7);
   1443  1.11    bjh21 
   1444  1.11    bjh21 		ETHER_NEXT_MULTI(step, enm);
   1445  1.11    bjh21 	}
   1446  1.11    bjh21 	ifp->if_flags &= ~IFF_ALLMULTI;
   1447  1.11    bjh21 
   1448  1.11    bjh21 	ea_select_buffer(sc, SEEQ_BUFCODE_MULTICAST);
   1449  1.11    bjh21 		for (i = 0; i < 8; ++i)
   1450  1.11    bjh21 			bus_space_write_1(sc->sc_iot, sc->sc_ioh,
   1451  1.11    bjh21 			    SEEQ_BUFWIN, af[i]);
   1452  1.11    bjh21 }
   1453  1.11    bjh21 
   1454  1.11    bjh21 static void
   1455  1.11    bjh21 ea_mc_reset_8005(struct seeq8005_softc *sc)
   1456  1.11    bjh21 {
   1457   1.5    bjh21 	struct ether_multi *enm;
   1458   1.5    bjh21 	struct ether_multistep step;
   1459   1.5    bjh21 	int naddr, maxaddrs;
   1460   1.5    bjh21 
   1461   1.5    bjh21 	naddr = 0;
   1462  1.11    bjh21 	maxaddrs = 5;
   1463   1.5    bjh21 	ETHER_FIRST_MULTI(step, &sc->sc_ethercom, enm);
   1464   1.5    bjh21 	while (enm != NULL) {
   1465   1.5    bjh21 		/* Have we got space? */
   1466   1.5    bjh21 		if (naddr >= maxaddrs ||
   1467  1.28  thorpej 		    memcmp(enm->enm_addrlo, enm->enm_addrhi, 6) != 0) {
   1468   1.5    bjh21 			sc->sc_ethercom.ec_if.if_flags |= IFF_ALLMULTI;
   1469   1.5    bjh21 			ea_ioctl(&sc->sc_ethercom.ec_if, SIOCSIFFLAGS, NULL);
   1470   1.5    bjh21 			return;
   1471   1.5    bjh21 		}
   1472  1.11    bjh21 		ea_set_address(sc, 1 + naddr, enm->enm_addrlo);
   1473  1.11    bjh21 		sc->sc_config1 |= SEEQ_CFG1_STATION_ADDR1 << naddr;
   1474   1.5    bjh21 		naddr++;
   1475   1.5    bjh21 		ETHER_NEXT_MULTI(step, enm);
   1476   1.5    bjh21 	}
   1477   1.5    bjh21 	for (; naddr < maxaddrs; naddr++)
   1478  1.11    bjh21 		sc->sc_config1 &= ~(SEEQ_CFG1_STATION_ADDR1 << naddr);
   1479  1.24    bjh21 	SEEQ_WRITE16(sc, sc->sc_iot, sc->sc_ioh, SEEQ_CONFIG1,
   1480   1.5    bjh21 			  sc->sc_config1);
   1481   1.5    bjh21 }
   1482   1.5    bjh21 
   1483   1.1    bjh21 /*
   1484   1.1    bjh21  * Device timeout routine.
   1485   1.1    bjh21  */
   1486   1.1    bjh21 
   1487   1.1    bjh21 static void
   1488   1.1    bjh21 ea_watchdog(struct ifnet *ifp)
   1489   1.1    bjh21 {
   1490   1.1    bjh21 	struct seeq8005_softc *sc = ifp->if_softc;
   1491   1.1    bjh21 
   1492  1.15    bjh21 	log(LOG_ERR, "%s: lost Tx interrupt (status = 0x%04x)\n",
   1493  1.15    bjh21 	    sc->sc_dev.dv_xname,
   1494  1.24    bjh21 	    SEEQ_READ16(sc, sc->sc_iot, sc->sc_ioh, SEEQ_STATUS));
   1495   1.1    bjh21 	ifp->if_oerrors++;
   1496   1.1    bjh21 
   1497   1.1    bjh21 	/* Kick the interface */
   1498   1.1    bjh21 
   1499   1.5    bjh21 	ea_init(ifp);
   1500   1.1    bjh21 
   1501   1.1    bjh21 	ifp->if_timer = 0;
   1502   1.1    bjh21 }
   1503   1.1    bjh21 
   1504   1.1    bjh21 /* End of if_ea.c */
   1505