New, improved "le" driver from Charles Hannum and Paul Richards.

This commit is contained in:
gwr 1995-01-03 15:43:36 +00:00
parent 7e8a9d0d4c
commit 0969e0306d
5 changed files with 877 additions and 935 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,51 +1,28 @@
/* $NetBSD: if_le.h,v 1.5 1994/12/12 18:59:14 gwr Exp $ */
/* $NetBSD: if_le.h,v 1.6 1995/01/03 15:43:38 gwr Exp $ */
/*
* Ethernet software status per interface.
*/
/* Per interface statistics */
struct lestats {
long lexints; /* transmitter interrupts */
long lerints; /* receiver interrupts */
long lerbufs; /* total buffers received during interrupts */
long lerhits; /* times current rbuf was full */
long lerscans; /* rbufs scanned before finding first full */
};
/*
*
* Each interface is referenced by a network interface structure,
* le_if, which the routing code uses to locate the interface.
* arpcom, which the routing code uses to locate the interface.
* This structure contains the output queue for the interface,
* its address, ...
*/
struct le_softc {
struct device sc_dev; /* base device */
struct arpcom sc_ac; /* common Ethernet structures */
#define sc_if sc_ac.ac_if /* network-visible interface */
#define sc_addr sc_ac.ac_enaddr /* hardware Ethernet address */
#define sc_if sc_ac.ac_if /* network-visible interface */
#define sc_enaddr sc_ac.ac_enaddr /* hardware Ethernet address */
struct evcnt sc_intrcnt; /* # of interrupts, per le */
struct evcnt sc_errcnt; /* # of errors, per le */
volatile struct le_regs *sc_regs; /* LANCE registers */
void *sc_mem; /* Shared RAM */
volatile struct lereg1 *sc_r1; /* LANCE registers */
volatile struct lereg2 *sc_r2; /* dual-port RAM */
int sc_rmd; /* predicted next rmd to process */
int sc_runt;
int sc_jab;
int sc_merr;
int sc_babl;
int sc_cerr;
int sc_miss;
int sc_xint;
int sc_xown;
int sc_uflo;
int sc_rxlen;
int sc_rxoff;
int sc_txoff;
int sc_busy;
short sc_iflags;
struct lestats sc_lestats; /* per interface statistics */
volatile struct init_block *sc_init; /* Lance init. block */
volatile struct mds *sc_rd, *sc_td;
u_char *sc_rbuf, *sc_tbuf;
int sc_last_rd, sc_last_td;
int sc_no_td;
#ifdef LEDEBUG
int sc_debug;
#endif
};

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_le_subr.c,v 1.10 1994/12/13 18:31:51 gwr Exp $ */
/* $NetBSD: if_le_subr.c,v 1.11 1995/01/03 15:43:39 gwr Exp $ */
/*
* Copyright (c) 1994 Gordon W. Ross
@ -61,6 +61,8 @@
#include "if_le.h"
#include "if_le_subr.h"
extern caddr_t dvma_malloc(); /* XXX */
int
le_md_match(parent, vcf, args)
struct device *parent;
@ -75,7 +77,7 @@ le_md_match(parent, vcf, args)
if (ca->ca_intpri == -1)
ca->ca_intpri = 3;
/* The peek returns non-zero on bus error. */
/* The peek returns -1 on bus error. */
x = bus_peek(ca->ca_bustype, ca->ca_paddr, 1);
return (x != -1);
}
@ -91,17 +93,17 @@ le_md_attach(parent, self, args)
caddr_t p;
/* register access */
sc->sc_r1 = (struct lereg1 *)
sc->sc_regs = (struct le_regs *)
obio_alloc(ca->ca_paddr, OBIO_AMD_ETHER_SIZE);
if (!sc->sc_r1)
if (sc->sc_regs == NULL)
panic(": not enough obio space\n");
/* allocate "shared" memory */
sc->sc_r2 = (struct lereg2 *) dvma_malloc(sizeof(struct lereg2));
if (!sc->sc_r2)
sc->sc_mem = dvma_malloc(MEMSIZE);
if (sc->sc_mem == NULL)
panic(": not enough dvma space");
/* Install interrupt handler. */
isr_add_autovect(le_intr, (void *)sc, ca->ca_intpri);
idprom_etheraddr(sc->sc_addr); /* ethernet addr */
isr_add_autovect(leintr, (void *)sc, ca->ca_intpri);
idprom_etheraddr(sc->sc_enaddr); /* ethernet addr */
}

View File

@ -1,8 +1,8 @@
/* $NetBSD: if_le_subr.h,v 1.6 1994/12/12 18:59:16 gwr Exp $ */
/* $NetBSD: if_le_subr.h,v 1.7 1995/01/03 15:43:40 gwr Exp $ */
/* One might also set: LE_C3_ACON | LE_C3_BCON */
#define LE_C3_CONFIG LE_C3_BSWP
/* One might also set: LE_ACON | LE_BCON */
#define LE_CONF3 (LE_BSWP)
extern int le_md_match(struct device *, void *, void *args);
extern void le_md_attach(struct device *, struct device *, void *);
extern int le_intr(void *);
extern int leintr(void *);

View File

@ -1,167 +1,127 @@
/* $NetBSD: if_lereg.h,v 1.8 1994/12/12 18:59:17 gwr Exp $ */
/* $NetBSD: if_lereg.h,v 1.9 1995/01/03 15:43:41 gwr Exp $ */
/*-
* Copyright (c) 1982, 1992, 1993
* The Regents of the University of California. All rights reserved.
/*
* LANCE Ethernet driver header file
*
* 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 University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* Copyright (c) 1995 Gordon W. Ross
* Copyright (c) 1994 Charles Hannum.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
*
* @(#)if_lereg.h 8.2 (Berkeley) 10/30/93
* Copyright (C) 1993, Paul Richards. This software may be used, modified,
* copied, distributed, and sold, in both source and binary form provided
* that the above copyright and these terms are retained. Under no
* circumstances is the author responsible for the proper functioning
* of this software, nor does the author assume any responsibility
* for damages incurred with its use.
*/
#define LEMTU 1518
#define LEMINSIZE 60 /* should be 64 if mode DTCR is set */
#define LERBUF 8
#define LERBUFLOG2 3
#define LE_RLEN (LERBUFLOG2 << 13)
#define LETBUF 1
#define LETBUFLOG2 0
#define LE_TLEN (LETBUFLOG2 << 13)
/* Declarations specific to this driver */
#define NTBUF 2
#define TLEN 1
#define NRBUF 8
#define RLEN 3
#define BUFSIZE 1518
#define MEMSIZE 0x4000
/* Local Area Network Controller for Ethernet (LANCE) registers */
struct lereg1 {
u_short ler1_rdp; /* register data port */
u_short ler1_rap; /* register address port */
struct le_regs {
u_short lereg_data; /* data port */
u_short lereg_addr; /* address port */
};
/* register addresses */
#define LE_CSR0 0 /* Control and status register */
#define LE_CSR1 1 /* low address of init block */
#define LE_CSR2 2 /* high address of init block */
#define LE_CSR3 3 /* Bus master and control */
/* Control and status register 0 (csr0) */
#define LE_C0_ERR 0x8000 /* error summary */
#define LE_C0_BABL 0x4000 /* transmitter timeout error */
#define LE_C0_CERR 0x2000 /* collision */
#define LE_C0_MISS 0x1000 /* missed a packet */
#define LE_C0_MERR 0x0800 /* memory error */
#define LE_C0_RINT 0x0400 /* receiver interrupt */
#define LE_C0_TINT 0x0200 /* transmitter interrupt */
#define LE_C0_IDON 0x0100 /* initalization done */
#define LE_C0_INTR 0x0080 /* interrupt condition */
#define LE_C0_INEA 0x0040 /* interrupt enable */
#define LE_C0_RXON 0x0020 /* receiver on */
#define LE_C0_TXON 0x0010 /* transmitter on */
#define LE_C0_TDMD 0x0008 /* transmit demand */
#define LE_C0_STOP 0x0004 /* disable all external activity */
#define LE_C0_STRT 0x0002 /* enable external activity */
#define LE_C0_INIT 0x0001 /* begin initalization */
#define LE_C0_BITS \
"\20\20ERR\17BABL\16CERR\15MISS\14MERR\13RINT\
\12TINT\11IDON\10INTR\07INEA\06RXON\05TXON\04TDMD\03STOP\02STRT\01INIT"
/* Control and status register 3 (csr3) */
#define LE_C3_BSWP 0x4 /* byte swap */
#define LE_C3_ACON 0x2 /* ALE control, eh? */
#define LE_C3_BCON 0x1 /* byte control */
/*
* Current size is 13,758 bytes with 8 x 1518 receive buffers and
* 1 x 1518 transmit buffer.
* Control and status bits
*/
struct lereg2 {
/* initialization block */
u_short ler2_mode; /* mode */
u_char ler2_padr[6]; /* physical address */
u_short ler2_ladrf[4]; /* logical address filter */
u_short ler2_rdra; /* receive descriptor addr */
u_short ler2_rlen; /* rda high and ring size */
u_short ler2_tdra; /* transmit descriptor addr */
u_short ler2_tlen; /* tda high and ring size */
/* receive message descriptors. bits/hadr are byte order dependent. */
struct lermd {
u_short rmd0; /* low address of packet */
u_char rmd1_bits; /* descriptor bits */
u_char rmd1_hadr; /* high address of packet */
short rmd2; /* buffer byte count */
u_short rmd3; /* message byte count */
} ler2_rmd[LERBUF];
/* transmit message descriptors */
struct letmd {
u_short tmd0; /* low address of packet */
u_char tmd1_bits; /* descriptor bits */
u_char tmd1_hadr; /* high address of packet */
short tmd2; /* buffer byte count */
u_short tmd3; /* transmit error bits */
} ler2_tmd[LETBUF];
char ler2_rbuf[LERBUF][LEMTU];
char ler2_tbuf[LETBUF][LEMTU];
#define LE_SERR 0x8000
#define LE_BABL 0x4000
#define LE_CERR 0x2000
#define LE_MISS 0x1000
#define LE_MERR 0x0800
#define LE_RINT 0x0400
#define LE_TINT 0x0200
#define LE_IDON 0x0100
#define LE_INTR 0x0080
#define LE_INEA 0x0040
#define LE_RXON 0x0020
#define LE_TXON 0x0010
#define LE_TDMD 0x0008
#define LE_STOP 0x0004
#define LE_STRT 0x0002
#define LE_INIT 0x0001
#define LE_BSWP 0x0004
#define LE_ACON 0x0002
#define LE_BCON 0x0001
/*
* LANCE initialization block
*/
struct init_block {
u_short mode; /* mode register */
u_char padr[6]; /* ethernet address */
u_long ladrf[2]; /* logical address filter (multicast) */
u_short rdra; /* low order pointer to receive ring */
u_short rlen; /* high order pointer and no. rings */
u_short tdra; /* low order pointer to transmit ring */
u_short tlen; /* high order pointer and no rings */
};
/* Initialzation block (mode) */
#define LE_MODE_PROM 0x8000 /* promiscuous mode */
/* 0x7f80 reserved, must be zero */
#define LE_MODE_INTL 0x0040 /* internal loopback */
#define LE_MODE_DRTY 0x0020 /* disable retry */
#define LE_MODE_COLL 0x0010 /* force a collision */
#define LE_MODE_DTCR 0x0008 /* disable transmit CRC */
#define LE_MODE_LOOP 0x0004 /* loopback mode */
#define LE_MODE_DTX 0x0002 /* disable transmitter */
#define LE_MODE_DRX 0x0001 /* disable receiver */
#define LE_MODE_NORMAL 0 /* none of the above */
/*
* Mode bits -- init_block
*/
#define LE_PROM 0x8000 /* promiscuous */
#define LE_INTL 0x0040 /* internal loopback */
#define LE_DRTY 0x0020 /* disable retry */
#define LE_COLL 0x0010 /* force collision */
#define LE_DTCR 0x0008 /* disable transmit crc */
#define LE_LOOP 0x0004 /* loopback */
#define LE_DTX 0x0002 /* disable transmitter */
#define LE_DRX 0x0001 /* disable receiver */
#define LE_NORMAL 0x0000
/*
* Message descriptor
*/
struct mds {
u_short addr;
u_short flags;
u_short bcnt;
u_short mcnt;
};
/* Message descriptor flags */
#define LE_OWN 0x8000 /* owner bit, 0=host, 1=LANCE */
#define LE_ERR 0x4000 /* error */
#define LE_STP 0x0200 /* start of packet */
#define LE_ENP 0x0100 /* end of packet */
/* Receive ring status flags */
#define LE_FRAM 0x2000 /* framing error error */
#define LE_OFLO 0x1000 /* silo overflow */
#define LE_CRC 0x0800 /* CRC error */
#define LE_RBUFF 0x0400 /* buffer error */
/* Transmit ring status flags */
#define LE_MORE 0x1000 /* more than 1 retry */
#define LE_ONE 0x0800 /* one retry */
#define LE_DEF 0x0400 /* deferred transmit */
/* Transmit errors */
#define LE_TBUFF 0x8000 /* buffer error */
#define LE_UFLO 0x4000 /* silo underflow */
#define LE_LCOL 0x1000 /* late collision */
#define LE_LCAR 0x0800 /* loss of carrier */
#define LE_RTRY 0x0400 /* tried 16 times */
/* Receive message descriptor 1 (rmd1_bits) */
#define LE_R1_OWN 0x80 /* LANCE owns the packet */
#define LE_R1_ERR 0x40 /* error summary */
#define LE_R1_FRAM 0x20 /* framing error */
#define LE_R1_OFLO 0x10 /* overflow error */
#define LE_R1_CRC 0x08 /* CRC error */
#define LE_R1_BUFF 0x04 /* buffer error */
#define LE_R1_STP 0x02 /* start of packet */
#define LE_R1_ENP 0x01 /* end of packet */
/* DEPCA-specific definitions */
#define DEPCA_CSR 0x0
#define DEPCA_CSR_SHE 0x80 /* Shared memory enabled */
#define DEPCA_CSR_SWAP32 0x40 /* Byte swapped */
#define DEPCA_CSR_DUM 0x08 /* rev E compatibility */
#define DEPCA_CSR_IM 0x04 /* Interrupt masked */
#define DEPCA_CSR_IEN 0x02 /* Interrupt enabled */
#define DEPCA_CSR_NORMAL \
(DEPCA_CSR_SHE | DEPCA_CSR_DUM | DEPCA_CSR_IEN)
#define LE_R1_BITS \
"\20\10OWN\7ERR\6FRAM\5OFLO\4CRC\3BUFF\2STP\1ENP"
/* Transmit message descriptor 1 (tmd1_bits) */
#define LE_T1_OWN 0x80 /* LANCE owns the packet */
#define LE_T1_ERR 0x40 /* error summary */
#define LE_T1_MORE 0x10 /* multiple collisions */
#define LE_T1_ONE 0x08 /* single collision */
#define LE_T1_DEF 0x04 /* defferred transmit */
#define LE_T1_STP 0x02 /* start of packet */
#define LE_T1_ENP 0x01 /* end of packet */
#define LE_T1_BITS \
"\20\10OWN\7ERR\6RES\5MORE\4ONE\3DEF\2STP\1ENP"
/* Transmit message descriptor 3 (tmd3) */
#define LE_T3_BUFF 0x8000 /* buffer error */
#define LE_T3_UFLO 0x4000 /* underflow error */
#define LE_T3_LCOL 0x1000 /* late collision */
#define LE_T3_LCAR 0x0800 /* loss of carrier */
#define LE_T3_RTRY 0x0400 /* retry error */
#define LE_T3_TDR_MASK 0x03ff /* time domain reflectometry counter */
#define LE_XMD2_ONES 0xf000
#define LE_T3_BITS \
"\20\20BUFF\17UFLO\16RES\15LCOL\14LCAR\13RTRY"
#define DEPCA_ADP 0xc