1995-07-24 00:36:51 +04:00
|
|
|
/* $NetBSD: if_ed.c,v 1.79 1995/07/23 20:36:51 mycroft Exp $ */
|
1994-10-27 07:14:23 +03:00
|
|
|
|
1993-07-03 16:19:36 +04:00
|
|
|
/*
|
1993-10-01 05:01:43 +03:00
|
|
|
* Device driver for National Semiconductor DS8390/WD83C690 based ethernet
|
1994-02-13 06:49:24 +03:00
|
|
|
* adapters.
|
|
|
|
*
|
1995-04-11 08:38:42 +04:00
|
|
|
* Copyright (c) 1994, 1995 Charles M. Hannum. All rights reserved.
|
1993-07-03 16:19:36 +04:00
|
|
|
*
|
1994-02-12 10:16:24 +03:00
|
|
|
* Copyright (C) 1993, David Greenman. 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.
|
1993-07-03 16:19:36 +04:00
|
|
|
*
|
1994-10-01 10:13:32 +03:00
|
|
|
* Currently supports the Western Digital/SMC 8003 and 8013 series, the SMC
|
|
|
|
* Elite Ultra (8216), the 3Com 3c503, the NE1000 and NE2000, and a variety of
|
|
|
|
* similar clones.
|
1993-07-03 16:19:36 +04:00
|
|
|
*/
|
1994-02-12 10:16:24 +03:00
|
|
|
|
1993-09-09 13:40:56 +04:00
|
|
|
#include "bpfilter.h"
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1993-12-20 12:05:17 +03:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/errno.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/mbuf.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/syslog.h>
|
1994-02-15 22:37:12 +03:00
|
|
|
#include <sys/device.h>
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1993-12-20 12:05:17 +03:00
|
|
|
#include <net/if.h>
|
|
|
|
#include <net/if_dl.h>
|
|
|
|
#include <net/if_types.h>
|
|
|
|
#include <net/netisr.h>
|
1993-07-03 16:19:36 +04:00
|
|
|
|
|
|
|
#ifdef INET
|
1993-12-20 12:05:17 +03:00
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <netinet/in_systm.h>
|
|
|
|
#include <netinet/in_var.h>
|
|
|
|
#include <netinet/ip.h>
|
|
|
|
#include <netinet/if_ether.h>
|
1993-07-03 16:19:36 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef NS
|
1993-12-20 12:05:17 +03:00
|
|
|
#include <netns/ns.h>
|
|
|
|
#include <netns/ns_if.h>
|
1993-07-03 16:19:36 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if NBPFILTER > 0
|
1993-12-20 12:05:17 +03:00
|
|
|
#include <net/bpf.h>
|
|
|
|
#include <net/bpfdesc.h>
|
1993-07-03 16:19:36 +04:00
|
|
|
#endif
|
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
#include <machine/cpu.h>
|
1993-12-20 12:05:17 +03:00
|
|
|
#include <machine/pio.h>
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1995-04-17 16:06:30 +04:00
|
|
|
#include <dev/isa/isareg.h>
|
|
|
|
#include <dev/isa/isavar.h>
|
|
|
|
#include <i386/isa/isa_machdep.h> /* XXX USES ISA HOLE DIRECTLY */
|
1995-06-28 08:30:30 +04:00
|
|
|
#include <dev/ic/dp8390reg.h>
|
1995-01-29 10:36:54 +03:00
|
|
|
#include <dev/isa/if_edreg.h>
|
1993-07-03 16:19:36 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* ed_softc: per line info and status
|
|
|
|
*/
|
1994-03-29 08:35:37 +04:00
|
|
|
struct ed_softc {
|
1994-02-15 22:37:12 +03:00
|
|
|
struct device sc_dev;
|
1995-04-17 16:06:30 +04:00
|
|
|
void *sc_ih;
|
1994-02-15 22:37:12 +03:00
|
|
|
|
|
|
|
struct arpcom sc_arpcom; /* ethernet common */
|
1993-07-03 16:19:36 +04:00
|
|
|
|
|
|
|
char *type_str; /* pointer to type string */
|
|
|
|
u_char vendor; /* interface vendor */
|
|
|
|
u_char type; /* interface type code */
|
|
|
|
|
1994-11-19 00:57:40 +03:00
|
|
|
int asic_addr; /* ASIC I/O bus address */
|
|
|
|
int nic_addr; /* NIC (DS8390) I/O bus address */
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1993-10-01 05:01:43 +03:00
|
|
|
/*
|
|
|
|
* The following 'proto' variable is part of a work-around for 8013EBT asics
|
1994-02-12 10:16:24 +03:00
|
|
|
* being write-only. It's sort of a prototype/shadow of the real thing.
|
1993-10-01 05:01:43 +03:00
|
|
|
*/
|
|
|
|
u_char wd_laar_proto;
|
1994-04-28 08:53:09 +04:00
|
|
|
/*
|
|
|
|
* This `proto' variable is so we can turn MENB on and off without reading
|
|
|
|
* the value back from the card all the time.
|
|
|
|
*/
|
|
|
|
u_char wd_msr_proto;
|
1995-04-11 08:38:42 +04:00
|
|
|
u_char cr_proto; /* values always set in CR */
|
1993-10-01 05:01:43 +03:00
|
|
|
u_char isa16bit; /* width of access to card 0=8 or 1=16 */
|
1994-02-12 10:16:24 +03:00
|
|
|
u_char is790; /* set by probe if NIC is a 790 */
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1993-10-01 05:01:43 +03:00
|
|
|
caddr_t mem_start; /* NIC memory start address */
|
|
|
|
caddr_t mem_end; /* NIC memory end address */
|
|
|
|
u_long mem_size; /* total NIC memory size */
|
|
|
|
caddr_t mem_ring; /* start of RX ring-buffer (in NIC mem) */
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1993-10-01 05:01:43 +03:00
|
|
|
u_char mem_shared; /* NIC memory is shared with host */
|
1993-07-03 16:19:36 +04:00
|
|
|
u_char xmit_busy; /* transmitter is busy */
|
1993-10-01 05:01:43 +03:00
|
|
|
u_char txb_cnt; /* number of transmit buffers */
|
|
|
|
u_char txb_inuse; /* number of TX buffers currently in-use*/
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1993-10-01 05:01:43 +03:00
|
|
|
u_char txb_new; /* pointer to where new buffer will be added */
|
|
|
|
u_char txb_next_tx; /* pointer to next buffer ready to xmit */
|
|
|
|
u_short txb_len[8]; /* buffered xmit buffer lengths */
|
|
|
|
u_char tx_page_start; /* first page of TX buffer area */
|
1993-07-03 16:19:36 +04:00
|
|
|
u_char rec_page_start; /* first page of RX ring-buffer */
|
|
|
|
u_char rec_page_stop; /* last page of RX ring-buffer */
|
|
|
|
u_char next_packet; /* pointer to next unread RX packet */
|
1994-03-29 08:35:37 +04:00
|
|
|
};
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1994-11-04 02:08:27 +03:00
|
|
|
int edprobe __P((struct device *, void *, void *));
|
|
|
|
void edattach __P((struct device *, struct device *, void *));
|
1995-04-17 16:06:30 +04:00
|
|
|
int edintr __P((void *));
|
1994-10-31 00:43:03 +03:00
|
|
|
int ed_ioctl __P((struct ifnet *, u_long, caddr_t));
|
1995-04-10 22:21:42 +04:00
|
|
|
void ed_start __P((struct ifnet *));
|
1995-04-17 16:06:30 +04:00
|
|
|
void ed_watchdog __P((int));
|
1994-02-12 10:16:24 +03:00
|
|
|
void ed_reset __P((struct ed_softc *));
|
|
|
|
void ed_init __P((struct ed_softc *));
|
|
|
|
void ed_stop __P((struct ed_softc *));
|
1994-02-15 02:56:16 +03:00
|
|
|
void ed_getmcaf __P((struct arpcom *, u_long *));
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
#define inline /* XXX for debugging porpoises */
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1995-04-17 16:06:30 +04:00
|
|
|
void ed_get_packet __P((struct ed_softc *, caddr_t, u_short));
|
1994-02-12 10:16:24 +03:00
|
|
|
static inline void ed_rint __P((struct ed_softc *));
|
1994-02-15 22:37:12 +03:00
|
|
|
static inline void ed_xmit __P((struct ed_softc *));
|
1995-04-17 16:06:30 +04:00
|
|
|
static inline caddr_t ed_ring_copy __P((struct ed_softc *, caddr_t, caddr_t,
|
|
|
|
u_short));
|
1993-10-01 05:01:43 +03:00
|
|
|
|
1995-04-17 16:06:30 +04:00
|
|
|
void ed_pio_readmem __P((struct ed_softc *, u_short, caddr_t, u_short));
|
|
|
|
void ed_pio_writemem __P((struct ed_softc *, caddr_t, u_short, u_short));
|
|
|
|
u_short ed_pio_write_mbufs __P((struct ed_softc *, struct mbuf *, u_short));
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1994-03-29 08:35:37 +04:00
|
|
|
struct cfdriver edcd = {
|
|
|
|
NULL, "ed", edprobe, edattach, DV_IFNET, sizeof(struct ed_softc)
|
1993-07-03 16:19:36 +04:00
|
|
|
};
|
1994-02-12 10:16:24 +03:00
|
|
|
|
1993-07-03 16:19:36 +04:00
|
|
|
#define ETHER_MIN_LEN 64
|
|
|
|
#define ETHER_MAX_LEN 1518
|
|
|
|
#define ETHER_ADDR_LEN 6
|
|
|
|
|
1995-04-11 08:38:42 +04:00
|
|
|
#define NIC_PUT(sc, off, val) outb(sc->nic_addr + off, val)
|
|
|
|
#define NIC_GET(sc, off) inb(sc->nic_addr + off)
|
|
|
|
|
1993-07-03 16:19:36 +04:00
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* Determine if the device is present.
|
1993-07-03 16:19:36 +04:00
|
|
|
*/
|
|
|
|
int
|
1994-11-04 02:08:27 +03:00
|
|
|
edprobe(parent, match, aux)
|
|
|
|
struct device *parent;
|
|
|
|
void *match, *aux;
|
1993-07-03 16:19:36 +04:00
|
|
|
{
|
1994-11-04 02:08:27 +03:00
|
|
|
struct ed_softc *sc = match;
|
1994-03-29 08:35:37 +04:00
|
|
|
struct cfdata *cf = sc->sc_dev.dv_cfdata;
|
|
|
|
struct isa_attach_args *ia = aux;
|
|
|
|
|
|
|
|
if (ed_probe_WD80x3(sc, cf, ia))
|
1994-10-01 10:13:32 +03:00
|
|
|
return (1);
|
1994-03-29 08:35:37 +04:00
|
|
|
if (ed_probe_3Com(sc, cf, ia))
|
1994-10-01 10:13:32 +03:00
|
|
|
return (1);
|
1994-03-29 08:35:37 +04:00
|
|
|
if (ed_probe_Novell(sc, cf, ia))
|
1994-10-01 10:13:32 +03:00
|
|
|
return (1);
|
|
|
|
return (0);
|
1993-09-09 13:40:56 +04:00
|
|
|
}
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1993-10-01 05:01:43 +03:00
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* Generic probe routine for testing for the existance of a DS8390. Must be
|
|
|
|
* called after the NIC has just been reset. This routine works by looking at
|
1995-02-27 12:10:24 +03:00
|
|
|
* certain register values that are guaranteed to be initialized a certain way
|
1994-02-12 10:16:24 +03:00
|
|
|
* after power-up or reset. Seems not to currently work on the 83C690.
|
1993-10-01 05:01:43 +03:00
|
|
|
*
|
|
|
|
* Specifically:
|
|
|
|
*
|
|
|
|
* Register reset bits set bits
|
|
|
|
* Command Register (CR) TXP, STA RD2, STP
|
|
|
|
* Interrupt Status (ISR) RST
|
|
|
|
* Interrupt Mask (IMR) All bits
|
|
|
|
* Data Control (DCR) LAS
|
|
|
|
* Transmit Config. (TCR) LB1, LB0
|
|
|
|
*
|
1994-02-12 10:16:24 +03:00
|
|
|
* We only look at the CR and ISR registers, however, because looking at the
|
1994-10-01 10:13:32 +03:00
|
|
|
* others would require changing register pages (which would be intrusive if
|
1994-02-12 10:16:24 +03:00
|
|
|
* this isn't an 8390).
|
1993-10-01 05:01:43 +03:00
|
|
|
*
|
1995-04-11 08:38:42 +04:00
|
|
|
* Return 1 if 8390 was found, 0 if not.
|
1993-10-01 05:01:43 +03:00
|
|
|
*/
|
|
|
|
int
|
|
|
|
ed_probe_generic8390(sc)
|
|
|
|
struct ed_softc *sc;
|
|
|
|
{
|
1994-03-29 08:35:37 +04:00
|
|
|
|
1995-04-11 08:38:42 +04:00
|
|
|
if ((NIC_GET(sc, ED_P0_CR) &
|
1994-10-01 10:13:32 +03:00
|
|
|
(ED_CR_RD2 | ED_CR_TXP | ED_CR_STA | ED_CR_STP)) !=
|
1994-02-12 10:16:24 +03:00
|
|
|
(ED_CR_RD2 | ED_CR_STP))
|
1994-10-01 10:13:32 +03:00
|
|
|
return (0);
|
1995-04-11 08:38:42 +04:00
|
|
|
if ((NIC_GET(sc, ED_P0_ISR) & ED_ISR_RST) != ED_ISR_RST)
|
1994-10-01 10:13:32 +03:00
|
|
|
return (0);
|
1993-10-01 05:01:43 +03:00
|
|
|
|
1994-10-01 10:13:32 +03:00
|
|
|
return (1);
|
1993-10-01 05:01:43 +03:00
|
|
|
}
|
1995-04-11 08:38:42 +04:00
|
|
|
|
1995-01-02 23:32:55 +03:00
|
|
|
int ed_wd584_irq[] = { 9, 3, 5, 7, 10, 11, 15, 4 };
|
|
|
|
int ed_wd790_irq[] = { IRQUNK, 9, 3, 5, 7, 10, 11, 15 };
|
|
|
|
|
1993-09-09 13:40:56 +04:00
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* Probe and vendor-specific initialization routine for SMC/WD80x3 boards.
|
1993-09-09 13:40:56 +04:00
|
|
|
*/
|
|
|
|
int
|
1994-03-29 08:35:37 +04:00
|
|
|
ed_probe_WD80x3(sc, cf, ia)
|
|
|
|
struct ed_softc *sc;
|
|
|
|
struct cfdata *cf;
|
|
|
|
struct isa_attach_args *ia;
|
1993-09-09 13:40:56 +04:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
u_int memsize;
|
1993-10-01 05:01:43 +03:00
|
|
|
u_char iptr, isa16bit, sum;
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1994-03-29 08:35:37 +04:00
|
|
|
sc->asic_addr = ia->ia_iobase;
|
1993-07-03 16:19:36 +04:00
|
|
|
sc->nic_addr = sc->asic_addr + ED_WD_NIC_OFFSET;
|
1994-02-12 10:16:24 +03:00
|
|
|
sc->is790 = 0;
|
|
|
|
|
|
|
|
#ifdef TOSH_ETHER
|
|
|
|
outb(sc->asic_addr + ED_WD_MSR, ED_WD_MSR_POW);
|
1994-03-06 20:18:43 +03:00
|
|
|
delay(10000);
|
1994-02-12 10:16:24 +03:00
|
|
|
#endif
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1993-10-01 05:01:43 +03:00
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* Attempt to do a checksum over the station address PROM. If it
|
|
|
|
* fails, it's probably not a SMC/WD board. There is a problem with
|
|
|
|
* this, though: some clone WD boards don't pass the checksum test.
|
|
|
|
* Danpex boards for one.
|
1993-10-01 05:01:43 +03:00
|
|
|
*/
|
|
|
|
for (sum = 0, i = 0; i < 8; ++i)
|
|
|
|
sum += inb(sc->asic_addr + ED_WD_PROM + i);
|
|
|
|
|
|
|
|
if (sum != ED_WD_ROM_CHECKSUM_TOTAL) {
|
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* Checksum is invalid. This often happens with cheap WD8003E
|
|
|
|
* clones. In this case, the checksum byte (the eighth byte)
|
|
|
|
* seems to always be zero.
|
1993-10-01 05:01:43 +03:00
|
|
|
*/
|
|
|
|
if (inb(sc->asic_addr + ED_WD_CARD_ID) != ED_TYPE_WD8003E ||
|
1994-02-12 10:16:24 +03:00
|
|
|
inb(sc->asic_addr + ED_WD_PROM + 7) != 0)
|
1994-10-01 10:13:32 +03:00
|
|
|
return (0);
|
1993-10-01 05:01:43 +03:00
|
|
|
}
|
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Reset card to force it into a known state. */
|
|
|
|
#ifdef TOSH_ETHER
|
|
|
|
outb(sc->asic_addr + ED_WD_MSR, ED_WD_MSR_RST | ED_WD_MSR_POW);
|
|
|
|
#else
|
1993-07-03 16:19:36 +04:00
|
|
|
outb(sc->asic_addr + ED_WD_MSR, ED_WD_MSR_RST);
|
1994-02-12 10:16:24 +03:00
|
|
|
#endif
|
1994-03-06 20:18:43 +03:00
|
|
|
delay(100);
|
1994-02-12 10:16:24 +03:00
|
|
|
outb(sc->asic_addr + ED_WD_MSR,
|
|
|
|
inb(sc->asic_addr + ED_WD_MSR) & ~ED_WD_MSR_RST);
|
|
|
|
/* Wait in the case this card is reading it's EEROM. */
|
1994-03-06 20:18:43 +03:00
|
|
|
delay(5000);
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1993-10-01 05:01:43 +03:00
|
|
|
sc->vendor = ED_VENDOR_WD_SMC;
|
|
|
|
sc->type = inb(sc->asic_addr + ED_WD_CARD_ID);
|
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Set initial values for width/size. */
|
1994-03-03 01:47:36 +03:00
|
|
|
memsize = 8192;
|
|
|
|
isa16bit = 0;
|
1993-07-03 16:19:36 +04:00
|
|
|
switch (sc->type) {
|
|
|
|
case ED_TYPE_WD8003S:
|
|
|
|
sc->type_str = "WD8003S";
|
|
|
|
break;
|
|
|
|
case ED_TYPE_WD8003E:
|
|
|
|
sc->type_str = "WD8003E";
|
1994-03-03 01:47:36 +03:00
|
|
|
break;
|
|
|
|
case ED_TYPE_WD8003EB:
|
|
|
|
sc->type_str = "WD8003EB";
|
|
|
|
break;
|
|
|
|
case ED_TYPE_WD8003W:
|
|
|
|
sc->type_str = "WD8003W";
|
1993-07-03 16:19:36 +04:00
|
|
|
break;
|
|
|
|
case ED_TYPE_WD8013EBT:
|
|
|
|
sc->type_str = "WD8013EBT";
|
|
|
|
memsize = 16384;
|
1993-10-01 05:01:43 +03:00
|
|
|
isa16bit = 1;
|
1993-07-03 16:19:36 +04:00
|
|
|
break;
|
1994-02-12 10:16:24 +03:00
|
|
|
case ED_TYPE_WD8013W:
|
|
|
|
sc->type_str = "WD8013W";
|
|
|
|
memsize = 16384;
|
|
|
|
isa16bit = 1;
|
|
|
|
break;
|
1993-09-09 13:40:56 +04:00
|
|
|
case ED_TYPE_WD8013EP: /* also WD8003EP */
|
1994-02-12 10:16:24 +03:00
|
|
|
if (inb(sc->asic_addr + ED_WD_ICR) & ED_WD_ICR_16BIT) {
|
1993-10-01 05:01:43 +03:00
|
|
|
isa16bit = 1;
|
1993-07-03 16:19:36 +04:00
|
|
|
memsize = 16384;
|
1993-09-09 13:40:56 +04:00
|
|
|
sc->type_str = "WD8013EP";
|
1994-03-03 01:47:36 +03:00
|
|
|
} else
|
1993-10-01 05:01:43 +03:00
|
|
|
sc->type_str = "WD8003EP";
|
1993-07-03 16:19:36 +04:00
|
|
|
break;
|
1993-09-09 13:40:56 +04:00
|
|
|
case ED_TYPE_WD8013WC:
|
|
|
|
sc->type_str = "WD8013WC";
|
|
|
|
memsize = 16384;
|
1993-10-01 05:01:43 +03:00
|
|
|
isa16bit = 1;
|
1993-09-09 13:40:56 +04:00
|
|
|
break;
|
1993-07-03 16:19:36 +04:00
|
|
|
case ED_TYPE_WD8013EBP:
|
|
|
|
sc->type_str = "WD8013EBP";
|
|
|
|
memsize = 16384;
|
1993-10-01 05:01:43 +03:00
|
|
|
isa16bit = 1;
|
1993-07-03 16:19:36 +04:00
|
|
|
break;
|
|
|
|
case ED_TYPE_WD8013EPC:
|
|
|
|
sc->type_str = "WD8013EPC";
|
|
|
|
memsize = 16384;
|
1993-10-01 05:01:43 +03:00
|
|
|
isa16bit = 1;
|
1993-07-03 16:19:36 +04:00
|
|
|
break;
|
1994-02-12 10:16:24 +03:00
|
|
|
case ED_TYPE_SMC8216C:
|
|
|
|
sc->type_str = "SMC8216/SMC8216C";
|
|
|
|
memsize = 16384;
|
|
|
|
isa16bit = 1;
|
|
|
|
sc->is790 = 1;
|
|
|
|
break;
|
|
|
|
case ED_TYPE_SMC8216T:
|
|
|
|
sc->type_str = "SMC8216T";
|
|
|
|
memsize = 16384;
|
|
|
|
isa16bit = 1;
|
|
|
|
sc->is790 = 1;
|
|
|
|
break;
|
|
|
|
#ifdef TOSH_ETHER
|
|
|
|
case ED_TYPE_TOSHIBA1:
|
|
|
|
sc->type_str = "Toshiba1";
|
|
|
|
memsize = 32768;
|
|
|
|
isa16bit = 1;
|
|
|
|
break;
|
|
|
|
case ED_TYPE_TOSHIBA4:
|
|
|
|
sc->type_str = "Toshiba4";
|
|
|
|
memsize = 32768;
|
|
|
|
isa16bit = 1;
|
|
|
|
break;
|
|
|
|
#endif
|
1993-07-03 16:19:36 +04:00
|
|
|
default:
|
1994-02-12 10:16:24 +03:00
|
|
|
sc->type_str = NULL;
|
1993-07-03 16:19:36 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* Make some adjustments to initial values depending on what is found
|
|
|
|
* in the ICR.
|
1993-07-03 16:19:36 +04:00
|
|
|
*/
|
1994-02-12 10:16:24 +03:00
|
|
|
if (isa16bit && (sc->type != ED_TYPE_WD8013EBT) &&
|
|
|
|
#ifdef TOSH_ETHER
|
|
|
|
(sc->type != ED_TYPE_TOSHIBA1) && (sc->type != ED_TYPE_TOSHIBA4) &&
|
|
|
|
#endif
|
|
|
|
((inb(sc->asic_addr + ED_WD_ICR) & ED_WD_ICR_16BIT) == 0)) {
|
1993-10-01 05:01:43 +03:00
|
|
|
isa16bit = 0;
|
1993-07-03 16:19:36 +04:00
|
|
|
memsize = 8192;
|
|
|
|
}
|
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
#ifdef ED_DEBUG
|
|
|
|
printf("type=%x type_str=%s isa16bit=%d memsize=%d id_msize=%d\n",
|
|
|
|
sc->type, sc->type_str ?: "unknown", isa16bit, memsize,
|
1994-03-29 08:35:37 +04:00
|
|
|
ia->ia_msize);
|
1994-02-12 10:16:24 +03:00
|
|
|
for (i = 0; i < 8; i++)
|
1993-07-03 16:19:36 +04:00
|
|
|
printf("%x -> %x\n", i, inb(sc->asic_addr + i));
|
|
|
|
#endif
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Allow the user to override the autoconfiguration. */
|
1994-03-29 08:35:37 +04:00
|
|
|
if (ia->ia_msize)
|
|
|
|
memsize = ia->ia_msize;
|
1993-07-28 06:20:34 +04:00
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* (Note that if the user specifies both of the following flags that
|
|
|
|
* '8-bit' mode intentionally has precedence.)
|
1993-07-28 06:20:34 +04:00
|
|
|
*/
|
1994-03-29 08:35:37 +04:00
|
|
|
if (cf->cf_flags & ED_FLAGS_FORCE_16BIT_MODE)
|
1993-10-01 05:01:43 +03:00
|
|
|
isa16bit = 1;
|
1994-03-29 08:35:37 +04:00
|
|
|
if (cf->cf_flags & ED_FLAGS_FORCE_8BIT_MODE)
|
1993-10-01 05:01:43 +03:00
|
|
|
isa16bit = 0;
|
1993-07-28 06:20:34 +04:00
|
|
|
|
1993-07-03 16:19:36 +04:00
|
|
|
/*
|
1995-01-02 23:32:55 +03:00
|
|
|
* If possible, get the assigned interrupt number from the card and
|
|
|
|
* use it.
|
1994-02-12 10:16:24 +03:00
|
|
|
*/
|
|
|
|
if (sc->is790) {
|
1994-04-14 07:54:07 +04:00
|
|
|
u_char x;
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Assemble together the encoded interrupt number. */
|
1994-04-14 07:54:07 +04:00
|
|
|
outb(ia->ia_iobase + ED_WD790_HWR,
|
|
|
|
inb(ia->ia_iobase + ED_WD790_HWR) | ED_WD790_HWR_SWH);
|
|
|
|
x = inb(ia->ia_iobase + ED_WD790_GCR);
|
|
|
|
iptr = ((x & ED_WD790_GCR_IR2) >> 4) |
|
|
|
|
((x & (ED_WD790_GCR_IR1|ED_WD790_GCR_IR0)) >> 2);
|
|
|
|
outb(ia->ia_iobase + ED_WD790_HWR,
|
|
|
|
inb(ia->ia_iobase + ED_WD790_HWR) & ~ED_WD790_HWR_SWH);
|
1993-07-03 16:19:36 +04:00
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* Translate it using translation table, and check for
|
|
|
|
* correctness.
|
1993-07-03 16:19:36 +04:00
|
|
|
*/
|
1995-01-02 23:32:55 +03:00
|
|
|
if (ia->ia_irq != IRQUNK) {
|
|
|
|
if (ia->ia_irq != ed_wd790_irq[iptr]) {
|
|
|
|
printf("%s: irq mismatch; kernel configured %d != board configured %d\n",
|
|
|
|
sc->sc_dev.dv_xname, ia->ia_irq,
|
|
|
|
ed_wd790_irq[iptr]);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
ia->ia_irq = ed_wd790_irq[iptr];
|
1994-02-20 07:05:26 +03:00
|
|
|
/* Enable the interrupt. */
|
1994-04-14 07:54:07 +04:00
|
|
|
outb(ia->ia_iobase + ED_WD790_ICR,
|
|
|
|
inb(ia->ia_iobase + ED_WD790_ICR) | ED_WD790_ICR_EIL);
|
1994-02-12 10:16:24 +03:00
|
|
|
} else if (sc->type & ED_WD_SOFTCONFIG) {
|
|
|
|
/* Assemble together the encoded interrupt number. */
|
1994-03-29 08:35:37 +04:00
|
|
|
iptr = (inb(ia->ia_iobase + ED_WD_ICR) & ED_WD_ICR_IR2) |
|
|
|
|
((inb(ia->ia_iobase + ED_WD_IRR) &
|
1994-10-01 10:13:32 +03:00
|
|
|
(ED_WD_IRR_IR0 | ED_WD_IRR_IR1)) >> 5);
|
1993-07-03 16:19:36 +04:00
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* Translate it using translation table, and check for
|
|
|
|
* correctness.
|
1993-07-03 16:19:36 +04:00
|
|
|
*/
|
1995-01-02 23:32:55 +03:00
|
|
|
if (ia->ia_irq != IRQUNK) {
|
|
|
|
if (ia->ia_irq != ed_wd584_irq[iptr]) {
|
|
|
|
printf("%s: irq mismatch; kernel configured %d != board configured %d\n",
|
|
|
|
sc->sc_dev.dv_xname, ia->ia_irq,
|
|
|
|
ed_wd584_irq[iptr]);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
ia->ia_irq = ed_wd584_irq[iptr];
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Enable the interrupt. */
|
1994-03-29 08:35:37 +04:00
|
|
|
outb(ia->ia_iobase + ED_WD_IRR,
|
|
|
|
inb(ia->ia_iobase + ED_WD_IRR) | ED_WD_IRR_IEN);
|
1995-01-02 23:32:55 +03:00
|
|
|
} else {
|
|
|
|
if (ia->ia_irq == IRQUNK) {
|
|
|
|
printf("%s: %s does not have soft configuration\n",
|
|
|
|
sc->sc_dev.dv_xname, sc->type_str);
|
|
|
|
return (0);
|
|
|
|
}
|
1993-07-03 16:19:36 +04:00
|
|
|
}
|
|
|
|
|
1995-01-02 23:32:55 +03:00
|
|
|
/* XXX Figure out the shared memory address. */
|
|
|
|
|
1993-10-01 05:01:43 +03:00
|
|
|
sc->isa16bit = isa16bit;
|
|
|
|
sc->mem_shared = 1;
|
1994-03-29 08:35:37 +04:00
|
|
|
ia->ia_msize = memsize;
|
1995-01-02 23:32:55 +03:00
|
|
|
sc->mem_start = ISA_HOLE_VADDR(ia->ia_maddr);
|
1993-10-01 05:01:43 +03:00
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Allocate one xmit buffer if < 16k, two buffers otherwise. */
|
1994-03-29 08:35:37 +04:00
|
|
|
if ((memsize < 16384) || (cf->cf_flags & ED_FLAGS_NO_MULTI_BUFFERING))
|
1993-07-03 16:19:36 +04:00
|
|
|
sc->txb_cnt = 1;
|
1994-02-12 10:16:24 +03:00
|
|
|
else
|
1993-07-03 16:19:36 +04:00
|
|
|
sc->txb_cnt = 2;
|
1994-02-12 10:16:24 +03:00
|
|
|
|
|
|
|
sc->tx_page_start = ED_WD_PAGE_OFFSET;
|
|
|
|
sc->rec_page_start = sc->tx_page_start + sc->txb_cnt * ED_TXBUF_SIZE;
|
1994-10-24 00:22:13 +03:00
|
|
|
sc->rec_page_stop = sc->tx_page_start + (memsize >> ED_PAGE_SHIFT);
|
|
|
|
sc->mem_ring = sc->mem_start + (sc->rec_page_start << ED_PAGE_SHIFT);
|
1993-10-01 05:01:43 +03:00
|
|
|
sc->mem_size = memsize;
|
|
|
|
sc->mem_end = sc->mem_start + memsize;
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Get station address from on-board ROM. */
|
1993-07-03 16:19:36 +04:00
|
|
|
for (i = 0; i < ETHER_ADDR_LEN; ++i)
|
1994-02-15 22:37:12 +03:00
|
|
|
sc->sc_arpcom.ac_enaddr[i] =
|
|
|
|
inb(sc->asic_addr + ED_WD_PROM + i);
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1994-10-01 10:13:32 +03:00
|
|
|
/*
|
|
|
|
* Set upper address bits and 8/16 bit access to shared memory.
|
|
|
|
*/
|
|
|
|
if (isa16bit) {
|
|
|
|
if (sc->is790) {
|
|
|
|
sc->wd_laar_proto =
|
|
|
|
inb(sc->asic_addr + ED_WD_LAAR) &
|
|
|
|
~ED_WD_LAAR_M16EN;
|
|
|
|
} else {
|
|
|
|
sc->wd_laar_proto =
|
|
|
|
ED_WD_LAAR_L16EN |
|
|
|
|
((kvtop(sc->mem_start) >> 19) &
|
|
|
|
ED_WD_LAAR_ADDRHI);
|
|
|
|
}
|
|
|
|
outb(sc->asic_addr + ED_WD_LAAR,
|
|
|
|
sc->wd_laar_proto | ED_WD_LAAR_M16EN);
|
|
|
|
} else {
|
|
|
|
if ((sc->type & ED_WD_SOFTCONFIG) ||
|
1994-02-12 10:16:24 +03:00
|
|
|
#ifdef TOSH_ETHER
|
1994-10-01 10:13:32 +03:00
|
|
|
(sc->type == ED_TYPE_TOSHIBA1) ||
|
|
|
|
(sc->type == ED_TYPE_TOSHIBA4) ||
|
1994-02-12 10:16:24 +03:00
|
|
|
#endif
|
1994-10-01 10:13:32 +03:00
|
|
|
(sc->type == ED_TYPE_WD8013EBT) && !sc->is790) {
|
|
|
|
sc->wd_laar_proto =
|
|
|
|
((kvtop(sc->mem_start) >> 19) &
|
|
|
|
ED_WD_LAAR_ADDRHI);
|
|
|
|
outb(sc->asic_addr + ED_WD_LAAR,
|
|
|
|
sc->wd_laar_proto);
|
1993-07-03 16:19:36 +04:00
|
|
|
}
|
1994-10-01 10:13:32 +03:00
|
|
|
}
|
1994-05-19 11:47:34 +04:00
|
|
|
|
1994-10-01 10:13:32 +03:00
|
|
|
/*
|
|
|
|
* Set address and enable interface shared memory.
|
|
|
|
*/
|
|
|
|
if (!sc->is790) {
|
1994-05-19 11:47:34 +04:00
|
|
|
#ifdef TOSH_ETHER
|
1994-10-01 10:13:32 +03:00
|
|
|
outb(sc->asic_addr + ED_WD_MSR + 1,
|
|
|
|
((kvtop(sc->mem_start) >> 8) & 0xe0) | 4);
|
|
|
|
outb(sc->asic_addr + ED_WD_MSR + 2,
|
|
|
|
((kvtop(sc->mem_start) >> 16) & 0x0f));
|
|
|
|
sc->wd_msr_proto = ED_WD_MSR_POW;
|
1994-05-19 11:47:34 +04:00
|
|
|
#else
|
1994-10-01 10:13:32 +03:00
|
|
|
sc->wd_msr_proto =
|
|
|
|
(kvtop(sc->mem_start) >> 13) & ED_WD_MSR_ADDR;
|
1994-05-19 11:47:34 +04:00
|
|
|
#endif
|
1994-10-01 10:13:32 +03:00
|
|
|
sc->cr_proto = ED_CR_RD2;
|
|
|
|
} else {
|
|
|
|
outb(sc->asic_addr + 0x04,
|
|
|
|
inb(sc->asic_addr + 0x04) | 0x80);
|
|
|
|
outb(sc->asic_addr + 0x0b,
|
|
|
|
((kvtop(sc->mem_start) >> 13) & 0x0f) |
|
|
|
|
((kvtop(sc->mem_start) >> 11) & 0x40) |
|
|
|
|
(inb(sc->asic_addr + 0x0b) & 0xb0));
|
|
|
|
outb(sc->asic_addr + 0x04,
|
|
|
|
inb(sc->asic_addr + 0x04) & ~0x80);
|
|
|
|
sc->wd_msr_proto = 0x00;
|
|
|
|
sc->cr_proto = 0;
|
|
|
|
}
|
|
|
|
outb(sc->asic_addr + ED_WD_MSR,
|
|
|
|
sc->wd_msr_proto | ED_WD_MSR_MENB);
|
|
|
|
|
|
|
|
(void) inb(0x84);
|
|
|
|
(void) inb(0x84);
|
|
|
|
|
|
|
|
/* Now zero memory and verify that it is clear. */
|
|
|
|
bzero(sc->mem_start, memsize);
|
|
|
|
|
|
|
|
for (i = 0; i < memsize; ++i)
|
|
|
|
if (sc->mem_start[i]) {
|
|
|
|
printf("%s: failed to clear shared memory at %x - check configuration\n",
|
|
|
|
sc->sc_dev.dv_xname,
|
|
|
|
kvtop(sc->mem_start + i));
|
|
|
|
|
|
|
|
/* Disable 16 bit access to shared memory. */
|
|
|
|
outb(sc->asic_addr + ED_WD_MSR,
|
|
|
|
sc->wd_msr_proto);
|
|
|
|
if (isa16bit)
|
|
|
|
outb(sc->asic_addr + ED_WD_LAAR,
|
|
|
|
sc->wd_laar_proto);
|
|
|
|
(void) inb(0x84);
|
|
|
|
(void) inb(0x84);
|
|
|
|
return (0);
|
1994-05-19 11:47:34 +04:00
|
|
|
}
|
1995-04-11 08:38:42 +04:00
|
|
|
|
1994-10-01 10:13:32 +03:00
|
|
|
/*
|
|
|
|
* Disable 16bit access to shared memory - we leave it disabled
|
|
|
|
* so that 1) machines reboot properly when the board is set 16
|
|
|
|
* 16 bit mode and there are conflicting 8bit devices/ROMS in
|
|
|
|
* the same 128k address space as this boards shared memory,
|
|
|
|
* and 2) so that other 8 bit devices with shared memory can be
|
|
|
|
* used in this 128k region, too.
|
|
|
|
*/
|
|
|
|
outb(sc->asic_addr + ED_WD_MSR, sc->wd_msr_proto);
|
|
|
|
if (isa16bit)
|
|
|
|
outb(sc->asic_addr + ED_WD_LAAR, sc->wd_laar_proto);
|
|
|
|
(void) inb(0x84);
|
|
|
|
(void) inb(0x84);
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1994-03-29 08:35:37 +04:00
|
|
|
ia->ia_iosize = ED_WD_IO_PORTS;
|
1994-10-01 10:13:32 +03:00
|
|
|
return (1);
|
1993-09-09 13:40:56 +04:00
|
|
|
}
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1995-01-02 23:32:55 +03:00
|
|
|
int ed_3com_iobase[] = {0x2e0, 0x2a0, 0x280, 0x250, 0x350, 0x330, 0x310, 0x300};
|
|
|
|
int ed_3com_maddr[] = {MADDRUNK, MADDRUNK, MADDRUNK, MADDRUNK, 0xc8000, 0xcc000, 0xd8000, 0xdc000};
|
|
|
|
#if 0
|
|
|
|
int ed_3com_irq[] = {IRQUNK, IRQUNK, IRQUNK, IRQUNK, 9, 3, 4, 5};
|
|
|
|
#endif
|
|
|
|
|
1993-09-09 13:40:56 +04:00
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* Probe and vendor-specific initialization routine for 3Com 3c503 boards.
|
1993-09-09 13:40:56 +04:00
|
|
|
*/
|
1993-10-01 05:01:43 +03:00
|
|
|
int
|
1994-03-29 08:35:37 +04:00
|
|
|
ed_probe_3Com(sc, cf, ia)
|
|
|
|
struct ed_softc *sc;
|
|
|
|
struct cfdata *cf;
|
|
|
|
struct isa_attach_args *ia;
|
1993-09-09 13:40:56 +04:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
u_int memsize;
|
1995-01-02 23:32:55 +03:00
|
|
|
u_char isa16bit, sum, x;
|
|
|
|
int ptr;
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1994-03-29 08:35:37 +04:00
|
|
|
sc->asic_addr = ia->ia_iobase + ED_3COM_ASIC_OFFSET;
|
|
|
|
sc->nic_addr = ia->ia_iobase + ED_3COM_NIC_OFFSET;
|
1993-07-03 16:19:36 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Verify that the kernel configured I/O address matches the board
|
1994-02-12 10:16:24 +03:00
|
|
|
* configured address.
|
|
|
|
*
|
|
|
|
* This is really only useful to see if something that looks like the
|
|
|
|
* board is there; after all, we are already talking it at that
|
|
|
|
* address.
|
1993-07-03 16:19:36 +04:00
|
|
|
*/
|
1995-01-02 23:32:55 +03:00
|
|
|
x = inb(sc->asic_addr + ED_3COM_BCFR);
|
|
|
|
if (x == 0 || (x & (x - 1)) != 0)
|
1994-10-01 10:13:32 +03:00
|
|
|
return (0);
|
1995-01-02 23:32:55 +03:00
|
|
|
ptr = ffs(x) - 1;
|
|
|
|
if (ia->ia_iobase != IOBASEUNK) {
|
|
|
|
if (ia->ia_iobase != ed_3com_iobase[ptr]) {
|
|
|
|
printf("%s: %s mismatch; kernel configured %x != board configured %x\n",
|
|
|
|
"iobase", sc->sc_dev.dv_xname, ia->ia_iobase,
|
|
|
|
ed_3com_iobase[ptr]);
|
1994-10-01 10:13:32 +03:00
|
|
|
return (0);
|
1995-01-02 23:32:55 +03:00
|
|
|
}
|
|
|
|
} else
|
|
|
|
ia->ia_iobase = ed_3com_iobase[ptr];
|
|
|
|
|
|
|
|
x = inb(sc->asic_addr + ED_3COM_PCFR);
|
|
|
|
if (x == 0 || (x & (x - 1)) != 0)
|
1994-10-01 10:13:32 +03:00
|
|
|
return (0);
|
1995-01-02 23:32:55 +03:00
|
|
|
ptr = ffs(x) - 1;
|
|
|
|
if (ia->ia_maddr != MADDRUNK) {
|
|
|
|
if (ia->ia_maddr != ed_3com_maddr[ptr]) {
|
|
|
|
printf("%s: %s mismatch; kernel configured %x != board configured %x\n",
|
|
|
|
"maddr", sc->sc_dev.dv_xname, ia->ia_maddr,
|
|
|
|
ed_3com_maddr[ptr]);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
ia->ia_maddr = ed_3com_maddr[ptr];
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1995-01-02 23:32:55 +03:00
|
|
|
#if 0
|
|
|
|
x = inb(sc->asic_addr + ED_3COM_IDCFR) & ED_3COM_IDCFR_IRQ;
|
|
|
|
if (x == 0 || (x & (x - 1)) != 0)
|
|
|
|
return (0);
|
|
|
|
ptr = ffs(x) - 1;
|
|
|
|
if (ia->ia_irq != IRQUNK) {
|
|
|
|
if (ia->ia_irq != ed_3com_irq[ptr]) {
|
|
|
|
printf("%s: irq mismatch; kernel configured %d != board configured %d\n",
|
|
|
|
sc->sc_dev.dv_xname, ia->ia_irq,
|
|
|
|
ed_3com_irq[ptr]);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
ia->ia_irq = ed_3com_irq[ptr];
|
|
|
|
#endif
|
1995-04-11 08:38:42 +04:00
|
|
|
|
1993-07-03 16:19:36 +04:00
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* Reset NIC and ASIC. Enable on-board transceiver throughout reset
|
|
|
|
* sequence because it'll lock up if the cable isn't connected if we
|
|
|
|
* don't.
|
1993-07-03 16:19:36 +04:00
|
|
|
*/
|
1993-09-09 13:40:56 +04:00
|
|
|
outb(sc->asic_addr + ED_3COM_CR, ED_3COM_CR_RST | ED_3COM_CR_XSEL);
|
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Wait for a while, then un-reset it. */
|
1994-03-06 20:18:43 +03:00
|
|
|
delay(50);
|
1994-10-01 10:13:32 +03:00
|
|
|
|
1993-09-09 13:40:56 +04:00
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* The 3Com ASIC defaults to rather strange settings for the CR after a
|
|
|
|
* reset - it's important to set it again after the following outb
|
|
|
|
* (this is done when we map the PROM below).
|
1993-09-09 13:40:56 +04:00
|
|
|
*/
|
|
|
|
outb(sc->asic_addr + ED_3COM_CR, ED_3COM_CR_XSEL);
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Wait a bit for the NIC to recover from the reset. */
|
1994-03-06 20:18:43 +03:00
|
|
|
delay(5000);
|
1993-10-01 05:01:43 +03:00
|
|
|
|
|
|
|
sc->vendor = ED_VENDOR_3COM;
|
|
|
|
sc->type_str = "3c503";
|
|
|
|
sc->mem_shared = 1;
|
1994-10-01 10:13:32 +03:00
|
|
|
sc->cr_proto = ED_CR_RD2;
|
1993-10-01 05:01:43 +03:00
|
|
|
|
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* Hmmm...a 16bit 3Com board has 16k of memory, but only an 8k window
|
|
|
|
* to it.
|
1993-10-01 05:01:43 +03:00
|
|
|
*/
|
|
|
|
memsize = 8192;
|
1993-07-03 16:19:36 +04:00
|
|
|
|
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* Get station address from on-board ROM.
|
|
|
|
*
|
1993-09-09 13:40:56 +04:00
|
|
|
* First, map ethernet address PROM over the top of where the NIC
|
1994-02-12 10:16:24 +03:00
|
|
|
* registers normally appear.
|
1993-09-09 13:40:56 +04:00
|
|
|
*/
|
|
|
|
outb(sc->asic_addr + ED_3COM_CR, ED_3COM_CR_EALO | ED_3COM_CR_XSEL);
|
|
|
|
|
|
|
|
for (i = 0; i < ETHER_ADDR_LEN; ++i)
|
1995-04-11 08:38:42 +04:00
|
|
|
sc->sc_arpcom.ac_enaddr[i] = NIC_GET(sc, i);
|
1993-09-09 13:40:56 +04:00
|
|
|
|
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* Unmap PROM - select NIC registers. The proper setting of the
|
|
|
|
* tranceiver is set in ed_init so that the attach code is given a
|
|
|
|
* chance to set the default based on a compile-time config option.
|
1993-09-09 13:40:56 +04:00
|
|
|
*/
|
|
|
|
outb(sc->asic_addr + ED_3COM_CR, ED_3COM_CR_XSEL);
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Determine if this is an 8bit or 16bit board. */
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Select page 0 registers. */
|
1995-04-11 08:38:42 +04:00
|
|
|
NIC_PUT(sc, ED_P0_CR, ED_CR_RD2 | ED_CR_PAGE_0 | ED_CR_STP);
|
1993-07-03 16:19:36 +04:00
|
|
|
|
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* Attempt to clear WTS bit. If it doesn't clear, then this is a
|
|
|
|
* 16-bit board.
|
1993-07-03 16:19:36 +04:00
|
|
|
*/
|
1995-04-11 08:38:42 +04:00
|
|
|
NIC_PUT(sc, ED_P0_DCR, 0);
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Select page 2 registers. */
|
1995-04-11 08:38:42 +04:00
|
|
|
NIC_PUT(sc, ED_P0_CR, ED_CR_RD2 | ED_CR_PAGE_2 | ED_CR_STP);
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* The 3c503 forces the WTS bit to a one if this is a 16bit board. */
|
1995-04-11 08:38:42 +04:00
|
|
|
if (NIC_GET(sc, ED_P2_DCR) & ED_DCR_WTS)
|
1993-10-01 05:01:43 +03:00
|
|
|
isa16bit = 1;
|
1993-07-03 16:19:36 +04:00
|
|
|
else
|
1993-10-01 05:01:43 +03:00
|
|
|
isa16bit = 0;
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Select page 0 registers. */
|
1995-04-11 08:38:42 +04:00
|
|
|
NIC_PUT(sc, ED_P2_CR, ED_CR_RD2 | ED_CR_PAGE_0 | ED_CR_STP);
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1995-01-02 23:32:55 +03:00
|
|
|
sc->mem_start = ISA_HOLE_VADDR(ia->ia_maddr);
|
1993-10-01 05:01:43 +03:00
|
|
|
sc->mem_size = memsize;
|
|
|
|
sc->mem_end = sc->mem_start + memsize;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We have an entire 8k window to put the transmit buffers on the
|
1994-02-12 10:16:24 +03:00
|
|
|
* 16-bit boards. But since the 16bit 3c503's shared memory is only
|
|
|
|
* fast enough to overlap the loading of one full-size packet, trying
|
|
|
|
* to load more than 2 buffers can actually leave the transmitter idle
|
|
|
|
* during the load. So 2 seems the best value. (Although a mix of
|
|
|
|
* variable-sized packets might change this assumption. Nonetheless,
|
|
|
|
* we optimize for linear transfers of same-size packets.)
|
1993-10-01 05:01:43 +03:00
|
|
|
*/
|
|
|
|
if (isa16bit) {
|
1994-03-29 08:35:37 +04:00
|
|
|
if (cf->cf_flags & ED_FLAGS_NO_MULTI_BUFFERING)
|
1993-10-01 05:01:43 +03:00
|
|
|
sc->txb_cnt = 1;
|
|
|
|
else
|
|
|
|
sc->txb_cnt = 2;
|
|
|
|
|
|
|
|
sc->tx_page_start = ED_3COM_TX_PAGE_OFFSET_16BIT;
|
|
|
|
sc->rec_page_start = ED_3COM_RX_PAGE_OFFSET_16BIT;
|
1994-02-12 10:16:24 +03:00
|
|
|
sc->rec_page_stop =
|
1994-10-24 00:22:13 +03:00
|
|
|
(memsize >> ED_PAGE_SHIFT) + ED_3COM_RX_PAGE_OFFSET_16BIT;
|
1993-10-01 05:01:43 +03:00
|
|
|
sc->mem_ring = sc->mem_start;
|
|
|
|
} else {
|
|
|
|
sc->txb_cnt = 1;
|
|
|
|
sc->tx_page_start = ED_3COM_TX_PAGE_OFFSET_8BIT;
|
1994-02-12 10:16:24 +03:00
|
|
|
sc->rec_page_start =
|
|
|
|
ED_TXBUF_SIZE + ED_3COM_TX_PAGE_OFFSET_8BIT;
|
|
|
|
sc->rec_page_stop =
|
1994-10-24 00:22:13 +03:00
|
|
|
(memsize >> ED_PAGE_SHIFT) + ED_3COM_TX_PAGE_OFFSET_8BIT;
|
|
|
|
sc->mem_ring =
|
|
|
|
sc->mem_start + (ED_TXBUF_SIZE << ED_PAGE_SHIFT);
|
1993-10-01 05:01:43 +03:00
|
|
|
}
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1993-10-01 05:01:43 +03:00
|
|
|
sc->isa16bit = isa16bit;
|
1993-07-03 16:19:36 +04:00
|
|
|
|
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* Initialize GA page start/stop registers. Probably only needed if
|
|
|
|
* doing DMA, but what the Hell.
|
1993-07-03 16:19:36 +04:00
|
|
|
*/
|
|
|
|
outb(sc->asic_addr + ED_3COM_PSTR, sc->rec_page_start);
|
|
|
|
outb(sc->asic_addr + ED_3COM_PSPR, sc->rec_page_stop);
|
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Set IRQ. 3c503 only allows a choice of irq 3-5 or 9. */
|
1994-03-29 08:35:37 +04:00
|
|
|
switch (ia->ia_irq) {
|
1994-11-04 21:34:50 +03:00
|
|
|
case 9:
|
1993-07-03 16:19:36 +04:00
|
|
|
outb(sc->asic_addr + ED_3COM_IDCFR, ED_3COM_IDCFR_IRQ2);
|
|
|
|
break;
|
1994-11-04 21:34:50 +03:00
|
|
|
case 3:
|
1993-07-03 16:19:36 +04:00
|
|
|
outb(sc->asic_addr + ED_3COM_IDCFR, ED_3COM_IDCFR_IRQ3);
|
|
|
|
break;
|
1994-11-04 21:34:50 +03:00
|
|
|
case 4:
|
1993-07-03 16:19:36 +04:00
|
|
|
outb(sc->asic_addr + ED_3COM_IDCFR, ED_3COM_IDCFR_IRQ4);
|
|
|
|
break;
|
1994-11-04 21:34:50 +03:00
|
|
|
case 5:
|
1993-07-03 16:19:36 +04:00
|
|
|
outb(sc->asic_addr + ED_3COM_IDCFR, ED_3COM_IDCFR_IRQ5);
|
|
|
|
break;
|
|
|
|
default:
|
1994-02-15 22:37:12 +03:00
|
|
|
printf("%s: invalid irq configuration (%d) must be 3-5 or 9 for 3c503\n",
|
1994-11-04 21:34:50 +03:00
|
|
|
sc->sc_dev.dv_xname, ia->ia_irq);
|
1994-10-01 10:13:32 +03:00
|
|
|
return (0);
|
1993-07-03 16:19:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* Initialize GA configuration register. Set bank and enable shared
|
|
|
|
* mem.
|
1993-07-03 16:19:36 +04:00
|
|
|
*/
|
1994-02-12 10:16:24 +03:00
|
|
|
outb(sc->asic_addr + ED_3COM_GACFR,
|
|
|
|
ED_3COM_GACFR_RSEL | ED_3COM_GACFR_MBS0);
|
1993-07-03 16:19:36 +04:00
|
|
|
|
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* Initialize "Vector Pointer" registers. These gawd-awful things are
|
|
|
|
* compared to 20 bits of the address on ISA, and if they match, the
|
|
|
|
* shared memory is disabled. We set them to 0xffff0...allegedly the
|
|
|
|
* reset vector.
|
1993-07-03 16:19:36 +04:00
|
|
|
*/
|
|
|
|
outb(sc->asic_addr + ED_3COM_VPTR2, 0xff);
|
|
|
|
outb(sc->asic_addr + ED_3COM_VPTR1, 0xff);
|
|
|
|
outb(sc->asic_addr + ED_3COM_VPTR0, 0x00);
|
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Zero memory and verify that it is clear. */
|
1993-10-01 05:01:43 +03:00
|
|
|
bzero(sc->mem_start, memsize);
|
1993-07-03 16:19:36 +04:00
|
|
|
|
|
|
|
for (i = 0; i < memsize; ++i)
|
1993-10-01 05:01:43 +03:00
|
|
|
if (sc->mem_start[i]) {
|
1994-02-15 22:37:12 +03:00
|
|
|
printf("%s: failed to clear shared memory at %x - check configuration\n",
|
|
|
|
sc->sc_dev.dv_xname, kvtop(sc->mem_start + i));
|
1994-10-01 10:13:32 +03:00
|
|
|
return (0);
|
1993-07-03 16:19:36 +04:00
|
|
|
}
|
|
|
|
|
1994-03-29 08:35:37 +04:00
|
|
|
ia->ia_msize = memsize;
|
|
|
|
ia->ia_iosize = ED_3COM_IO_PORTS;
|
1994-10-01 10:13:32 +03:00
|
|
|
return (1);
|
1993-07-03 16:19:36 +04:00
|
|
|
}
|
1993-10-01 05:01:43 +03:00
|
|
|
|
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* Probe and vendor-specific initialization routine for NE1000/2000 boards.
|
1993-10-01 05:01:43 +03:00
|
|
|
*/
|
|
|
|
int
|
1994-03-29 08:35:37 +04:00
|
|
|
ed_probe_Novell(sc, cf, ia)
|
|
|
|
struct ed_softc *sc;
|
|
|
|
struct cfdata *cf;
|
|
|
|
struct isa_attach_args *ia;
|
1993-10-01 05:01:43 +03:00
|
|
|
{
|
|
|
|
u_int memsize, n;
|
|
|
|
u_char romdata[16], isa16bit = 0, tmp;
|
1994-02-12 10:16:24 +03:00
|
|
|
static u_char test_pattern[32] = "THIS is A memory TEST pattern";
|
|
|
|
u_char test_buffer[32];
|
1993-10-01 05:01:43 +03:00
|
|
|
|
1994-03-29 08:35:37 +04:00
|
|
|
sc->asic_addr = ia->ia_iobase + ED_NOVELL_ASIC_OFFSET;
|
|
|
|
sc->nic_addr = ia->ia_iobase + ED_NOVELL_NIC_OFFSET;
|
1993-10-01 05:01:43 +03:00
|
|
|
|
|
|
|
/* XXX - do Novell-specific probe here */
|
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Reset the board. */
|
1994-10-01 10:13:32 +03:00
|
|
|
#ifdef GWETHER
|
|
|
|
outb(sc->asic_addr + ED_NOVELL_RESET, 0);
|
|
|
|
delay(200);
|
|
|
|
#endif /* GWETHER */
|
1993-10-01 05:01:43 +03:00
|
|
|
tmp = inb(sc->asic_addr + ED_NOVELL_RESET);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* I don't know if this is necessary; probably cruft leftover from
|
1994-02-12 10:16:24 +03:00
|
|
|
* Clarkson packet driver code. Doesn't do a thing on the boards I've
|
|
|
|
* tested. -DG [note that a outb(0x84, 0) seems to work here, and is
|
|
|
|
* non-invasive...but some boards don't seem to reset and I don't have
|
|
|
|
* complete documentation on what the 'right' thing to do is...so we do
|
|
|
|
* the invasive thing for now. Yuck.]
|
1993-10-01 05:01:43 +03:00
|
|
|
*/
|
|
|
|
outb(sc->asic_addr + ED_NOVELL_RESET, tmp);
|
1994-03-06 20:18:43 +03:00
|
|
|
delay(5000);
|
1993-10-01 05:01:43 +03:00
|
|
|
|
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* This is needed because some NE clones apparently don't reset the NIC
|
|
|
|
* properly (or the NIC chip doesn't reset fully on power-up)
|
1993-10-23 07:59:41 +03:00
|
|
|
* XXX - this makes the probe invasive! ...Done against my better
|
1994-02-12 10:16:24 +03:00
|
|
|
* judgement. -DLG
|
1993-10-01 05:01:43 +03:00
|
|
|
*/
|
1995-04-11 08:38:42 +04:00
|
|
|
NIC_PUT(sc, ED_P0_CR, ED_CR_RD2 | ED_CR_PAGE_0 | ED_CR_STP);
|
1993-10-01 05:01:43 +03:00
|
|
|
|
1994-03-06 20:18:43 +03:00
|
|
|
delay(5000);
|
1993-10-23 07:59:41 +03:00
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Make sure that we really have an 8390 based board. */
|
1993-10-23 07:59:41 +03:00
|
|
|
if (!ed_probe_generic8390(sc))
|
1994-10-01 10:13:32 +03:00
|
|
|
return (0);
|
1993-10-23 07:59:41 +03:00
|
|
|
|
1993-10-01 05:01:43 +03:00
|
|
|
sc->vendor = ED_VENDOR_NOVELL;
|
|
|
|
sc->mem_shared = 0;
|
1994-10-01 10:13:32 +03:00
|
|
|
sc->cr_proto = ED_CR_RD2;
|
1994-03-29 08:35:37 +04:00
|
|
|
ia->ia_msize = 0;
|
1993-10-01 05:01:43 +03:00
|
|
|
|
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* Test the ability to read and write to the NIC memory. This has the
|
|
|
|
* side affect of determining if this is an NE1000 or an NE2000.
|
1993-10-01 05:01:43 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* This prevents packets from being stored in the NIC memory when the
|
|
|
|
* readmem routine turns on the start bit in the CR.
|
1993-10-01 05:01:43 +03:00
|
|
|
*/
|
1995-04-11 08:38:42 +04:00
|
|
|
NIC_PUT(sc, ED_P0_RCR, ED_RCR_MON);
|
1993-10-01 05:01:43 +03:00
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Temporarily initialize DCR for byte operations. */
|
1995-04-11 08:38:42 +04:00
|
|
|
NIC_PUT(sc, ED_P0_DCR, ED_DCR_FT1 | ED_DCR_LS);
|
1993-10-01 05:01:43 +03:00
|
|
|
|
1995-04-11 08:38:42 +04:00
|
|
|
NIC_PUT(sc, ED_P0_PSTART, 8192 >> ED_PAGE_SHIFT);
|
|
|
|
NIC_PUT(sc, ED_P0_PSTOP, 16384 >> ED_PAGE_SHIFT);
|
1993-10-01 05:01:43 +03:00
|
|
|
|
|
|
|
sc->isa16bit = 0;
|
|
|
|
|
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* Write a test pattern in byte mode. If this fails, then there
|
|
|
|
* probably isn't any memory at 8k - which likely means that the board
|
|
|
|
* is an NE2000.
|
1993-10-01 05:01:43 +03:00
|
|
|
*/
|
|
|
|
ed_pio_writemem(sc, test_pattern, 8192, sizeof(test_pattern));
|
|
|
|
ed_pio_readmem(sc, 8192, test_buffer, sizeof(test_pattern));
|
|
|
|
|
|
|
|
if (bcmp(test_pattern, test_buffer, sizeof(test_pattern))) {
|
|
|
|
/* not an NE1000 - try NE2000 */
|
|
|
|
|
1995-04-11 08:38:42 +04:00
|
|
|
NIC_PUT(sc, ED_P0_DCR,
|
1994-02-12 10:16:24 +03:00
|
|
|
ED_DCR_WTS | ED_DCR_FT1 | ED_DCR_LS);
|
1995-04-11 08:38:42 +04:00
|
|
|
NIC_PUT(sc, ED_P0_PSTART, 16384 >> ED_PAGE_SHIFT);
|
|
|
|
NIC_PUT(sc, ED_P0_PSTOP, 32768 >> ED_PAGE_SHIFT);
|
1993-10-01 05:01:43 +03:00
|
|
|
|
|
|
|
sc->isa16bit = 1;
|
1994-10-01 10:13:32 +03:00
|
|
|
|
1993-10-01 05:01:43 +03:00
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* Write a test pattern in word mode. If this also fails, then
|
|
|
|
* we don't know what this board is.
|
1993-10-01 05:01:43 +03:00
|
|
|
*/
|
|
|
|
ed_pio_writemem(sc, test_pattern, 16384, sizeof(test_pattern));
|
|
|
|
ed_pio_readmem(sc, 16384, test_buffer, sizeof(test_pattern));
|
|
|
|
|
|
|
|
if (bcmp(test_pattern, test_buffer, sizeof(test_pattern)))
|
1994-10-01 10:13:32 +03:00
|
|
|
return (0); /* not an NE2000 either */
|
1993-10-01 05:01:43 +03:00
|
|
|
|
|
|
|
sc->type = ED_TYPE_NE2000;
|
|
|
|
sc->type_str = "NE2000";
|
|
|
|
} else {
|
|
|
|
sc->type = ED_TYPE_NE1000;
|
|
|
|
sc->type_str = "NE1000";
|
|
|
|
}
|
1995-04-11 08:38:42 +04:00
|
|
|
|
1995-01-02 23:32:55 +03:00
|
|
|
if (ia->ia_irq == IRQUNK) {
|
|
|
|
printf("%s: %s does not have soft configuration\n",
|
|
|
|
sc->sc_dev.dv_xname, sc->type_str);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* 8k of memory plus an additional 8k if 16-bit. */
|
1993-10-01 05:01:43 +03:00
|
|
|
memsize = 8192 + sc->isa16bit * 8192;
|
|
|
|
|
|
|
|
#if 0 /* probably not useful - NE boards only come two ways */
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Allow kernel config file overrides. */
|
1994-03-29 08:35:37 +04:00
|
|
|
if (ia->ia_msize)
|
|
|
|
memsize = ia->ia_msize;
|
1993-10-01 05:01:43 +03:00
|
|
|
#endif
|
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* NIC memory doesn't start at zero on an NE board. */
|
|
|
|
/* The start address is tied to the bus width. */
|
1994-10-01 10:13:32 +03:00
|
|
|
sc->mem_start = (caddr_t)(8192 + sc->isa16bit * 8192);
|
1994-10-24 00:22:13 +03:00
|
|
|
sc->tx_page_start = memsize >> ED_PAGE_SHIFT;
|
1993-10-01 05:01:43 +03:00
|
|
|
|
1994-10-01 10:13:32 +03:00
|
|
|
#ifdef GWETHER
|
|
|
|
{
|
|
|
|
int x, i, mstart = 0;
|
|
|
|
char pbuf0[ED_PAGE_SIZE], pbuf[ED_PAGE_SIZE], tbuf[ED_PAGE_SIZE];
|
|
|
|
|
|
|
|
for (i = 0; i < ED_PAGE_SIZE; i++)
|
|
|
|
pbuf0[i] = 0;
|
|
|
|
|
|
|
|
/* Search for the start of RAM. */
|
|
|
|
for (x = 1; x < 256; x++) {
|
1994-10-24 00:22:13 +03:00
|
|
|
ed_pio_writemem(sc, pbuf0, x << ED_PAGE_SHIFT, ED_PAGE_SIZE);
|
|
|
|
ed_pio_readmem(sc, x << ED_PAGE_SHIFT, tbuf, ED_PAGE_SIZE);
|
1994-10-01 10:13:32 +03:00
|
|
|
if (!bcmp(pbuf0, tbuf, ED_PAGE_SIZE)) {
|
|
|
|
for (i = 0; i < ED_PAGE_SIZE; i++)
|
|
|
|
pbuf[i] = 255 - x;
|
1994-10-24 00:22:13 +03:00
|
|
|
ed_pio_writemem(sc, pbuf, x << ED_PAGE_SHIFT, ED_PAGE_SIZE);
|
|
|
|
ed_pio_readmem(sc, x << ED_PAGE_SHIFT, tbuf, ED_PAGE_SIZE);
|
1994-10-01 10:13:32 +03:00
|
|
|
if (!bcmp(pbuf, tbuf, ED_PAGE_SIZE)) {
|
1994-10-24 00:22:13 +03:00
|
|
|
mstart = x << ED_PAGE_SHIFT;
|
1994-10-01 10:13:32 +03:00
|
|
|
memsize = ED_PAGE_SIZE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mstart == 0) {
|
|
|
|
printf("%s: cannot find start of RAM\n",
|
|
|
|
sc->sc_dev.dv_xname);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Search for the end of RAM. */
|
1994-10-24 00:22:13 +03:00
|
|
|
for (++x; x < 256; x++) {
|
|
|
|
ed_pio_writemem(sc, pbuf0, x << ED_PAGE_SHIFT, ED_PAGE_SIZE);
|
|
|
|
ed_pio_readmem(sc, x << ED_PAGE_SHIFT, tbuf, ED_PAGE_SIZE);
|
1994-10-01 10:13:32 +03:00
|
|
|
if (!bcmp(pbuf0, tbuf, ED_PAGE_SIZE)) {
|
|
|
|
for (i = 0; i < ED_PAGE_SIZE; i++)
|
|
|
|
pbuf[i] = 255 - x;
|
1994-10-24 00:22:13 +03:00
|
|
|
ed_pio_writemem(sc, pbuf, x << ED_PAGE_SHIFT, ED_PAGE_SIZE);
|
|
|
|
ed_pio_readmem(sc, x << ED_PAGE_SHIFT, tbuf, ED_PAGE_SIZE);
|
1994-10-01 10:13:32 +03:00
|
|
|
if (!bcmp(pbuf, tbuf, ED_PAGE_SIZE))
|
|
|
|
memsize += ED_PAGE_SIZE;
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
} else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("%s: RAM start %x, size %d\n",
|
|
|
|
sc->sc_dev.dv_xname, mstart, memsize);
|
|
|
|
|
|
|
|
sc->mem_start = (caddr_t)mstart;
|
1994-10-24 00:22:13 +03:00
|
|
|
sc->tx_page_start = mstart >> ED_PAGE_SHIFT;
|
1994-10-01 10:13:32 +03:00
|
|
|
}
|
|
|
|
#endif /* GWETHER */
|
|
|
|
|
|
|
|
sc->mem_size = memsize;
|
|
|
|
sc->mem_end = sc->mem_start + memsize;
|
|
|
|
|
1993-10-01 05:01:43 +03:00
|
|
|
/*
|
|
|
|
* Use one xmit buffer if < 16k, two buffers otherwise (if not told
|
1994-02-12 10:16:24 +03:00
|
|
|
* otherwise).
|
1993-10-01 05:01:43 +03:00
|
|
|
*/
|
1994-03-29 08:35:37 +04:00
|
|
|
if ((memsize < 16384) || (cf->cf_flags & ED_FLAGS_NO_MULTI_BUFFERING))
|
1993-10-01 05:01:43 +03:00
|
|
|
sc->txb_cnt = 1;
|
|
|
|
else
|
|
|
|
sc->txb_cnt = 2;
|
|
|
|
|
|
|
|
sc->rec_page_start = sc->tx_page_start + sc->txb_cnt * ED_TXBUF_SIZE;
|
1994-10-24 00:22:13 +03:00
|
|
|
sc->rec_page_stop = sc->tx_page_start + (memsize >> ED_PAGE_SHIFT);
|
1993-10-01 05:01:43 +03:00
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
sc->mem_ring =
|
1994-10-24 00:22:13 +03:00
|
|
|
sc->mem_start + ((sc->txb_cnt * ED_TXBUF_SIZE) << ED_PAGE_SHIFT);
|
1993-10-01 05:01:43 +03:00
|
|
|
|
|
|
|
ed_pio_readmem(sc, 0, romdata, 16);
|
1993-10-23 07:59:41 +03:00
|
|
|
for (n = 0; n < ETHER_ADDR_LEN; n++)
|
1994-02-15 22:37:12 +03:00
|
|
|
sc->sc_arpcom.ac_enaddr[n] = romdata[n*(sc->isa16bit+1)];
|
1993-10-01 05:01:43 +03:00
|
|
|
|
1994-10-01 10:13:32 +03:00
|
|
|
#ifdef GWETHER
|
|
|
|
if (sc->arpcom.ac_enaddr[2] == 0x86)
|
|
|
|
sc->type_str = "Gateway AT";
|
|
|
|
#endif /* GWETHER */
|
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Clear any pending interrupts that might have occurred above. */
|
1995-04-11 08:38:42 +04:00
|
|
|
NIC_PUT(sc, ED_P0_ISR, 0xff);
|
1993-10-01 05:01:43 +03:00
|
|
|
|
1994-03-29 08:35:37 +04:00
|
|
|
ia->ia_iosize = ED_NOVELL_IO_PORTS;
|
1994-10-01 10:13:32 +03:00
|
|
|
return (1);
|
1993-10-01 05:01:43 +03:00
|
|
|
}
|
1995-04-11 08:38:42 +04:00
|
|
|
|
1993-07-03 16:19:36 +04:00
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* Install interface into kernel networking data structures.
|
1993-07-03 16:19:36 +04:00
|
|
|
*/
|
1994-03-29 08:35:37 +04:00
|
|
|
void
|
|
|
|
edattach(parent, self, aux)
|
|
|
|
struct device *parent, *self;
|
|
|
|
void *aux;
|
1993-07-03 16:19:36 +04:00
|
|
|
{
|
1994-03-29 08:35:37 +04:00
|
|
|
struct ed_softc *sc = (void *)self;
|
1994-04-07 10:48:19 +04:00
|
|
|
struct isa_attach_args *ia = aux;
|
1994-03-29 08:35:37 +04:00
|
|
|
struct cfdata *cf = sc->sc_dev.dv_cfdata;
|
1994-02-15 22:37:12 +03:00
|
|
|
struct ifnet *ifp = &sc->sc_arpcom.ac_if;
|
1995-04-11 08:38:42 +04:00
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Set interface to stopped condition (reset). */
|
|
|
|
ed_stop(sc);
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Initialize ifnet structure. */
|
1994-02-15 22:37:12 +03:00
|
|
|
ifp->if_unit = sc->sc_dev.dv_unit;
|
1994-03-29 08:35:37 +04:00
|
|
|
ifp->if_name = edcd.cd_name;
|
1993-07-03 16:19:36 +04:00
|
|
|
ifp->if_start = ed_start;
|
|
|
|
ifp->if_ioctl = ed_ioctl;
|
|
|
|
ifp->if_watchdog = ed_watchdog;
|
1994-02-12 10:16:24 +03:00
|
|
|
ifp->if_flags =
|
|
|
|
IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS | IFF_MULTICAST;
|
1993-07-03 16:19:36 +04:00
|
|
|
|
|
|
|
/*
|
1994-02-26 02:09:26 +03:00
|
|
|
* Set default state for LINK0 flag (used to disable the tranceiver
|
1994-02-12 10:16:24 +03:00
|
|
|
* for AUI operation), based on compile-time config option.
|
1993-07-03 16:19:36 +04:00
|
|
|
*/
|
1994-04-28 08:53:09 +04:00
|
|
|
switch (sc->vendor) {
|
|
|
|
case ED_VENDOR_3COM:
|
|
|
|
if (cf->cf_flags & ED_FLAGS_DISABLE_TRANCEIVER)
|
|
|
|
ifp->if_flags |= IFF_LINK0;
|
|
|
|
break;
|
|
|
|
case ED_VENDOR_WD_SMC:
|
1994-05-05 06:20:44 +04:00
|
|
|
if ((sc->type & ED_WD_SOFTCONFIG) == 0)
|
|
|
|
break;
|
1994-04-28 08:53:09 +04:00
|
|
|
if ((inb(sc->asic_addr + ED_WD_IRR) & ED_WD_IRR_OUT2) == 0)
|
|
|
|
ifp->if_flags |= IFF_LINK0;
|
|
|
|
break;
|
|
|
|
}
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Attach the interface. */
|
1993-07-03 16:19:36 +04:00
|
|
|
if_attach(ifp);
|
1994-05-13 10:13:43 +04:00
|
|
|
ether_ifattach(ifp);
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Print additional info when attached. */
|
1994-03-29 08:35:37 +04:00
|
|
|
printf(": address %s, ", ether_sprintf(sc->sc_arpcom.ac_enaddr));
|
1993-10-01 05:01:43 +03:00
|
|
|
|
1994-10-01 10:13:32 +03:00
|
|
|
if (sc->type_str)
|
1993-10-01 05:01:43 +03:00
|
|
|
printf("type %s ", sc->type_str);
|
|
|
|
else
|
|
|
|
printf("type unknown (0x%x) ", sc->type);
|
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
printf("%s", sc->isa16bit ? "(16-bit)" : "(8-bit)");
|
1993-10-01 05:01:43 +03:00
|
|
|
|
1994-04-28 08:53:09 +04:00
|
|
|
switch (sc->vendor) {
|
|
|
|
case ED_VENDOR_WD_SMC:
|
1994-05-05 06:20:44 +04:00
|
|
|
if ((sc->type & ED_WD_SOFTCONFIG) == 0)
|
|
|
|
break;
|
|
|
|
case ED_VENDOR_3COM:
|
1994-04-28 08:53:09 +04:00
|
|
|
if (ifp->if_flags & IFF_LINK0)
|
|
|
|
printf(" aui");
|
|
|
|
else
|
|
|
|
printf(" bnc");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("\n");
|
1993-07-12 17:13:41 +04:00
|
|
|
|
|
|
|
#if NBPFILTER > 0
|
1994-05-13 10:13:43 +04:00
|
|
|
bpfattach(&ifp->if_bpf, ifp, DLT_EN10MB, sizeof(struct ether_header));
|
1993-07-12 17:13:41 +04:00
|
|
|
#endif
|
1994-04-07 10:48:19 +04:00
|
|
|
|
1995-04-17 16:06:30 +04:00
|
|
|
sc->sc_ih = isa_intr_establish(ia->ia_irq, ISA_IST_EDGE, ISA_IPL_NET,
|
|
|
|
edintr, sc);
|
1993-07-03 16:19:36 +04:00
|
|
|
}
|
1995-04-11 08:38:42 +04:00
|
|
|
|
1993-07-03 16:19:36 +04:00
|
|
|
/*
|
|
|
|
* Reset interface.
|
|
|
|
*/
|
1994-02-12 10:16:24 +03:00
|
|
|
void
|
|
|
|
ed_reset(sc)
|
|
|
|
struct ed_softc *sc;
|
1993-07-03 16:19:36 +04:00
|
|
|
{
|
|
|
|
int s;
|
|
|
|
|
1994-03-08 15:21:10 +03:00
|
|
|
s = splimp();
|
1994-02-12 10:16:24 +03:00
|
|
|
ed_stop(sc);
|
|
|
|
ed_init(sc);
|
|
|
|
splx(s);
|
1993-07-03 16:19:36 +04:00
|
|
|
}
|
1995-04-11 08:38:42 +04:00
|
|
|
|
1993-07-03 16:19:36 +04:00
|
|
|
/*
|
|
|
|
* Take interface offline.
|
|
|
|
*/
|
|
|
|
void
|
1994-02-12 10:16:24 +03:00
|
|
|
ed_stop(sc)
|
|
|
|
struct ed_softc *sc;
|
1993-07-03 16:19:36 +04:00
|
|
|
{
|
|
|
|
int n = 5000;
|
1995-04-11 08:38:42 +04:00
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Stop everything on the interface, and select page 0 registers. */
|
1995-04-11 08:38:42 +04:00
|
|
|
NIC_PUT(sc, ED_P0_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STP);
|
1993-07-03 16:19:36 +04:00
|
|
|
|
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* Wait for interface to enter stopped state, but limit # of checks to
|
1994-10-01 10:13:32 +03:00
|
|
|
* 'n' (about 5ms). It shouldn't even take 5us on modern DS8390's, but
|
|
|
|
* just in case it's an old one.
|
1993-07-03 16:19:36 +04:00
|
|
|
*/
|
1995-04-11 08:38:42 +04:00
|
|
|
while (((NIC_GET(sc, ED_P0_ISR) & ED_ISR_RST) == 0) && --n);
|
1993-07-03 16:19:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* Device timeout/watchdog routine. Entered if the device neglects to generate
|
|
|
|
* an interrupt after a transmit has been started on it.
|
1993-07-03 16:19:36 +04:00
|
|
|
*/
|
1995-04-10 22:21:42 +04:00
|
|
|
void
|
1993-07-03 16:19:36 +04:00
|
|
|
ed_watchdog(unit)
|
1995-04-17 16:06:30 +04:00
|
|
|
int unit;
|
1993-07-03 16:19:36 +04:00
|
|
|
{
|
1994-03-29 08:35:37 +04:00
|
|
|
struct ed_softc *sc = edcd.cd_devs[unit];
|
1993-10-23 07:59:41 +03:00
|
|
|
|
1994-02-15 22:37:12 +03:00
|
|
|
log(LOG_ERR, "%s: device timeout\n", sc->sc_dev.dv_xname);
|
|
|
|
++sc->sc_arpcom.ac_if.if_oerrors;
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
ed_reset(sc);
|
1993-07-03 16:19:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1995-04-11 08:38:42 +04:00
|
|
|
* Initialize device.
|
1993-07-03 16:19:36 +04:00
|
|
|
*/
|
1994-02-12 10:16:24 +03:00
|
|
|
void
|
|
|
|
ed_init(sc)
|
|
|
|
struct ed_softc *sc;
|
1993-07-03 16:19:36 +04:00
|
|
|
{
|
1994-02-15 22:37:12 +03:00
|
|
|
struct ifnet *ifp = &sc->sc_arpcom.ac_if;
|
1995-07-24 00:36:51 +04:00
|
|
|
int i;
|
1994-02-12 10:16:24 +03:00
|
|
|
u_char command;
|
1994-02-17 10:20:06 +03:00
|
|
|
u_long mcaf[2];
|
1993-07-03 16:19:36 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize the NIC in the exact order outlined in the NS manual.
|
1994-02-12 10:16:24 +03:00
|
|
|
* This init procedure is "mandatory"...don't change what or when
|
|
|
|
* things happen.
|
1993-07-03 16:19:36 +04:00
|
|
|
*/
|
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Reset transmitter flags. */
|
1993-07-03 16:19:36 +04:00
|
|
|
sc->xmit_busy = 0;
|
1994-02-15 22:37:12 +03:00
|
|
|
sc->sc_arpcom.ac_if.if_timer = 0;
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1993-10-01 05:01:43 +03:00
|
|
|
sc->txb_inuse = 0;
|
|
|
|
sc->txb_new = 0;
|
|
|
|
sc->txb_next_tx = 0;
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Set interface for page 0, remote DMA complete, stopped. */
|
1995-04-11 08:38:42 +04:00
|
|
|
NIC_PUT(sc, ED_P0_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STP);
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1993-10-01 05:01:43 +03:00
|
|
|
if (sc->isa16bit) {
|
1993-07-03 16:19:36 +04:00
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* Set FIFO threshold to 8, No auto-init Remote DMA, byte
|
|
|
|
* order=80x86, word-wide DMA xfers,
|
1993-07-03 16:19:36 +04:00
|
|
|
*/
|
1995-04-11 08:38:42 +04:00
|
|
|
NIC_PUT(sc, ED_P0_DCR, ED_DCR_FT1 | ED_DCR_WTS | ED_DCR_LS);
|
1993-07-03 16:19:36 +04:00
|
|
|
} else {
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Same as above, but byte-wide DMA xfers. */
|
1995-04-11 08:38:42 +04:00
|
|
|
NIC_PUT(sc, ED_P0_DCR, ED_DCR_FT1 | ED_DCR_LS);
|
1993-07-03 16:19:36 +04:00
|
|
|
}
|
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Clear remote byte count registers. */
|
1995-04-11 08:38:42 +04:00
|
|
|
NIC_PUT(sc, ED_P0_RBCR0, 0);
|
|
|
|
NIC_PUT(sc, ED_P0_RBCR1, 0);
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Tell RCR to do nothing for now. */
|
1995-04-11 08:38:42 +04:00
|
|
|
NIC_PUT(sc, ED_P0_RCR, ED_RCR_MON);
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Place NIC in internal loopback mode. */
|
1995-04-11 08:38:42 +04:00
|
|
|
NIC_PUT(sc, ED_P0_TCR, ED_TCR_LB0);
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Set lower bits of byte addressable framing to 0. */
|
|
|
|
if (sc->is790)
|
1995-04-11 08:38:42 +04:00
|
|
|
NIC_PUT(sc, 0x09, 0);
|
1994-02-12 10:16:24 +03:00
|
|
|
|
1994-10-24 02:24:56 +03:00
|
|
|
/* Initialize receive buffer ring. */
|
1995-04-11 08:38:42 +04:00
|
|
|
NIC_PUT(sc, ED_P0_BNRY, sc->rec_page_start);
|
|
|
|
NIC_PUT(sc, ED_P0_PSTART, sc->rec_page_start);
|
|
|
|
NIC_PUT(sc, ED_P0_PSTOP, sc->rec_page_stop);
|
1993-07-03 16:19:36 +04:00
|
|
|
|
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* Clear all interrupts. A '1' in each bit position clears the
|
|
|
|
* corresponding flag.
|
1993-07-03 16:19:36 +04:00
|
|
|
*/
|
1995-04-11 08:38:42 +04:00
|
|
|
NIC_PUT(sc, ED_P0_ISR, 0xff);
|
1993-07-03 16:19:36 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Enable the following interrupts: receive/transmit complete,
|
1994-02-12 10:16:24 +03:00
|
|
|
* receive/transmit error, and Receiver OverWrite.
|
1993-07-03 16:19:36 +04:00
|
|
|
*
|
|
|
|
* Counter overflow and Remote DMA complete are *not* enabled.
|
|
|
|
*/
|
1995-04-11 08:38:42 +04:00
|
|
|
NIC_PUT(sc, ED_P0_IMR,
|
1994-02-12 10:16:24 +03:00
|
|
|
ED_IMR_PRXE | ED_IMR_PTXE | ED_IMR_RXEE | ED_IMR_TXEE |
|
|
|
|
ED_IMR_OVWE);
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Program command register for page 1. */
|
1995-04-11 08:38:42 +04:00
|
|
|
NIC_PUT(sc, ED_P0_CR, sc->cr_proto | ED_CR_PAGE_1 | ED_CR_STP);
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Copy out our station address. */
|
1993-07-03 16:19:36 +04:00
|
|
|
for (i = 0; i < ETHER_ADDR_LEN; ++i)
|
1995-04-11 08:38:42 +04:00
|
|
|
NIC_PUT(sc, ED_P1_PAR0 + i, sc->sc_arpcom.ac_enaddr[i]);
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1994-02-17 10:20:06 +03:00
|
|
|
/* Set multicast filter on chip. */
|
|
|
|
ed_getmcaf(&sc->sc_arpcom, mcaf);
|
|
|
|
for (i = 0; i < 8; i++)
|
1995-04-11 08:38:42 +04:00
|
|
|
NIC_PUT(sc, ED_P1_MAR0 + i, ((u_char *)mcaf)[i]);
|
1994-02-12 10:16:24 +03:00
|
|
|
|
1994-10-24 02:24:56 +03:00
|
|
|
/*
|
|
|
|
* Set current page pointer to one page after the boundary pointer, as
|
|
|
|
* recommended in the National manual.
|
|
|
|
*/
|
|
|
|
sc->next_packet = sc->rec_page_start + 1;
|
1995-04-11 08:38:42 +04:00
|
|
|
NIC_PUT(sc, ED_P1_CURR, sc->next_packet);
|
1994-10-24 02:24:56 +03:00
|
|
|
|
1994-10-01 10:19:32 +03:00
|
|
|
/* Program command register for page 0. */
|
1995-04-11 08:38:42 +04:00
|
|
|
NIC_PUT(sc, ED_P1_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STP);
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1994-10-01 10:13:32 +03:00
|
|
|
i = ED_RCR_AB | ED_RCR_AM;
|
|
|
|
if (ifp->if_flags & IFF_PROMISC) {
|
|
|
|
/*
|
|
|
|
* Set promiscuous mode. Multicast filter was set earlier so
|
|
|
|
* that we should receive all multicast packets.
|
|
|
|
*/
|
1994-10-12 16:42:00 +03:00
|
|
|
i |= ED_RCR_PRO | ED_RCR_AR | ED_RCR_SEP;
|
1994-10-01 10:13:32 +03:00
|
|
|
}
|
1995-04-11 08:38:42 +04:00
|
|
|
NIC_PUT(sc, ED_P0_RCR, i);
|
1993-12-10 08:37:33 +03:00
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Take interface out of loopback. */
|
1995-04-11 08:38:42 +04:00
|
|
|
NIC_PUT(sc, ED_P0_TCR, 0);
|
1993-07-03 16:19:36 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If this is a 3Com board, the tranceiver must be software enabled
|
1994-02-12 10:16:24 +03:00
|
|
|
* (there is no settable hardware default).
|
1993-07-03 16:19:36 +04:00
|
|
|
*/
|
1994-04-28 08:53:09 +04:00
|
|
|
switch (sc->vendor) {
|
|
|
|
u_char x;
|
|
|
|
case ED_VENDOR_3COM:
|
1994-02-26 02:09:26 +03:00
|
|
|
if (ifp->if_flags & IFF_LINK0)
|
1993-07-28 06:20:34 +04:00
|
|
|
outb(sc->asic_addr + ED_3COM_CR, 0);
|
1994-02-08 06:06:20 +03:00
|
|
|
else
|
1993-07-28 06:20:34 +04:00
|
|
|
outb(sc->asic_addr + ED_3COM_CR, ED_3COM_CR_XSEL);
|
1994-04-28 08:53:09 +04:00
|
|
|
break;
|
|
|
|
case ED_VENDOR_WD_SMC:
|
1994-05-05 06:20:44 +04:00
|
|
|
if ((sc->type & ED_WD_SOFTCONFIG) == 0)
|
|
|
|
break;
|
1994-04-28 08:53:09 +04:00
|
|
|
x = inb(sc->asic_addr + ED_WD_IRR);
|
|
|
|
if (ifp->if_flags & IFF_LINK0)
|
|
|
|
x &= ~ED_WD_IRR_OUT2;
|
|
|
|
else
|
|
|
|
x |= ED_WD_IRR_OUT2;
|
|
|
|
outb(sc->asic_addr + ED_WD_IRR, x);
|
|
|
|
break;
|
1993-07-03 16:19:36 +04:00
|
|
|
}
|
|
|
|
|
1994-10-01 10:19:32 +03:00
|
|
|
/* Fire up the interface. */
|
1995-04-11 08:38:42 +04:00
|
|
|
NIC_PUT(sc, ED_P0_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STA);
|
1993-12-10 08:37:33 +03:00
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Set 'running' flag, and clear output active flag. */
|
1993-07-03 16:19:36 +04:00
|
|
|
ifp->if_flags |= IFF_RUNNING;
|
|
|
|
ifp->if_flags &= ~IFF_OACTIVE;
|
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* ...and attempt to start output. */
|
1993-07-03 16:19:36 +04:00
|
|
|
ed_start(ifp);
|
|
|
|
}
|
1995-04-11 08:38:42 +04:00
|
|
|
|
1993-07-03 16:19:36 +04:00
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* This routine actually starts the transmission on the interface.
|
1993-07-03 16:19:36 +04:00
|
|
|
*/
|
1994-02-15 22:37:12 +03:00
|
|
|
static inline void
|
|
|
|
ed_xmit(sc)
|
|
|
|
struct ed_softc *sc;
|
1993-07-03 16:19:36 +04:00
|
|
|
{
|
1994-02-15 22:37:12 +03:00
|
|
|
struct ifnet *ifp = &sc->sc_arpcom.ac_if;
|
1994-02-12 10:16:24 +03:00
|
|
|
u_short len;
|
1993-10-01 05:01:43 +03:00
|
|
|
|
|
|
|
len = sc->txb_len[sc->txb_next_tx];
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Set NIC for page 0 register access. */
|
1995-04-11 08:38:42 +04:00
|
|
|
NIC_PUT(sc, ED_P0_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STA);
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Set TX buffer start page. */
|
1995-04-11 08:38:42 +04:00
|
|
|
NIC_PUT(sc, ED_P0_TPSR, sc->tx_page_start +
|
1994-02-12 10:16:24 +03:00
|
|
|
sc->txb_next_tx * ED_TXBUF_SIZE);
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Set TX length. */
|
1995-04-11 08:38:42 +04:00
|
|
|
NIC_PUT(sc, ED_P0_TBCR0, len);
|
|
|
|
NIC_PUT(sc, ED_P0_TBCR1, len >> 8);
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Set page 0, remote DMA complete, transmit packet, and *start*. */
|
1995-04-11 08:38:42 +04:00
|
|
|
NIC_PUT(sc, ED_P0_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_TXP | ED_CR_STA);
|
1993-07-03 16:19:36 +04:00
|
|
|
sc->xmit_busy = 1;
|
1995-04-11 08:38:42 +04:00
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Point to next transmit buffer slot and wrap if necessary. */
|
1993-10-01 05:01:43 +03:00
|
|
|
sc->txb_next_tx++;
|
|
|
|
if (sc->txb_next_tx == sc->txb_cnt)
|
|
|
|
sc->txb_next_tx = 0;
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Set a timer just in case we never hear from the board again. */
|
1993-07-03 16:19:36 +04:00
|
|
|
ifp->if_timer = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Start output on interface.
|
|
|
|
* We make two assumptions here:
|
1994-03-08 15:21:10 +03:00
|
|
|
* 1) that the current priority is set to splimp _before_ this code
|
1993-07-03 16:19:36 +04:00
|
|
|
* is called *and* is returned to the appropriate priority after
|
|
|
|
* return
|
|
|
|
* 2) that the IFF_OACTIVE flag is checked before this code is called
|
|
|
|
* (i.e. that the output part of the interface is idle)
|
|
|
|
*/
|
1995-04-10 22:21:42 +04:00
|
|
|
void
|
1993-07-03 16:19:36 +04:00
|
|
|
ed_start(ifp)
|
|
|
|
struct ifnet *ifp;
|
|
|
|
{
|
1994-03-29 08:35:37 +04:00
|
|
|
struct ed_softc *sc = edcd.cd_devs[ifp->if_unit];
|
1993-07-03 16:19:36 +04:00
|
|
|
struct mbuf *m0, *m;
|
|
|
|
caddr_t buffer;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
outloop:
|
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* First, see if there are buffered packets and an idle transmitter -
|
|
|
|
* should never happen at this point.
|
1993-07-03 16:19:36 +04:00
|
|
|
*/
|
1993-10-01 05:01:43 +03:00
|
|
|
if (sc->txb_inuse && (sc->xmit_busy == 0)) {
|
1994-10-01 10:13:32 +03:00
|
|
|
printf("%s: packets buffered, but transmitter idle\n",
|
1994-02-15 22:37:12 +03:00
|
|
|
sc->sc_dev.dv_xname);
|
|
|
|
ed_xmit(sc);
|
1993-10-01 05:01:43 +03:00
|
|
|
}
|
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* See if there is room to put another packet in the buffer. */
|
1993-10-01 05:01:43 +03:00
|
|
|
if (sc->txb_inuse == sc->txb_cnt) {
|
1994-02-12 10:16:24 +03:00
|
|
|
/* No room. Indicate this to the outside world and exit. */
|
1993-10-01 05:01:43 +03:00
|
|
|
ifp->if_flags |= IFF_OACTIVE;
|
|
|
|
return;
|
|
|
|
}
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1994-02-15 22:37:12 +03:00
|
|
|
IF_DEQUEUE(&sc->sc_arpcom.ac_if.if_snd, m);
|
1993-07-03 16:19:36 +04:00
|
|
|
if (m == 0) {
|
1994-02-12 10:16:24 +03:00
|
|
|
/*
|
|
|
|
* We are using the !OACTIVE flag to indicate to the outside
|
|
|
|
* world that we can accept an additional packet rather than
|
|
|
|
* that the transmitter is _actually_ active. Indeed, the
|
1994-10-01 10:13:32 +03:00
|
|
|
* transmitter may be active, but if we haven't filled all the
|
|
|
|
* buffers with data then we still want to accept more.
|
1994-02-12 10:16:24 +03:00
|
|
|
*/
|
1993-07-03 16:19:36 +04:00
|
|
|
ifp->if_flags &= ~IFF_OACTIVE;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1995-07-23 20:32:33 +04:00
|
|
|
/* We need to use m->m_pkthdr.len, so require the header */
|
|
|
|
if ((m->m_flags & M_PKTHDR) == 0)
|
|
|
|
panic("ed_start: no header mbuf");
|
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Copy the mbuf chain into the transmit buffer. */
|
1993-10-23 07:59:41 +03:00
|
|
|
m0 = m;
|
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* txb_new points to next open buffer slot. */
|
1994-10-24 00:22:13 +03:00
|
|
|
buffer = sc->mem_start + ((sc->txb_new * ED_TXBUF_SIZE) << ED_PAGE_SHIFT);
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1993-10-01 05:01:43 +03:00
|
|
|
if (sc->mem_shared) {
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Special case setup for 16 bit boards... */
|
1994-04-28 08:53:09 +04:00
|
|
|
switch (sc->vendor) {
|
|
|
|
/*
|
|
|
|
* For 16bit 3Com boards (which have 16k of memory), we
|
|
|
|
* have the xmit buffers in a different page of memory
|
|
|
|
* ('page 0') - so change pages.
|
|
|
|
*/
|
|
|
|
case ED_VENDOR_3COM:
|
|
|
|
if (sc->isa16bit)
|
1993-10-01 05:01:43 +03:00
|
|
|
outb(sc->asic_addr + ED_3COM_GACFR,
|
1994-02-12 10:16:24 +03:00
|
|
|
ED_3COM_GACFR_RSEL);
|
1994-04-28 08:53:09 +04:00
|
|
|
break;
|
|
|
|
/*
|
|
|
|
* Enable 16bit access to shared memory on WD/SMC
|
1994-10-12 16:42:00 +03:00
|
|
|
* boards.
|
1994-04-28 08:53:09 +04:00
|
|
|
*/
|
|
|
|
case ED_VENDOR_WD_SMC:
|
|
|
|
if (sc->isa16bit)
|
1993-10-01 05:01:43 +03:00
|
|
|
outb(sc->asic_addr + ED_WD_LAAR,
|
1994-04-28 08:53:09 +04:00
|
|
|
sc->wd_laar_proto | ED_WD_LAAR_M16EN);
|
|
|
|
outb(sc->asic_addr + ED_WD_MSR,
|
|
|
|
sc->wd_msr_proto | ED_WD_MSR_MENB);
|
|
|
|
(void) inb(0x84);
|
|
|
|
(void) inb(0x84);
|
|
|
|
break;
|
1993-07-03 16:19:36 +04:00
|
|
|
}
|
|
|
|
|
1995-07-23 20:32:33 +04:00
|
|
|
for (; m; m = m->m_next) {
|
1993-10-01 05:01:43 +03:00
|
|
|
bcopy(mtod(m, caddr_t), buffer, m->m_len);
|
|
|
|
buffer += m->m_len;
|
|
|
|
}
|
1995-07-23 20:32:33 +04:00
|
|
|
len = m->m_pkthdr.len;
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Restore previous shared memory access. */
|
1994-04-28 08:53:09 +04:00
|
|
|
switch (sc->vendor) {
|
|
|
|
case ED_VENDOR_3COM:
|
|
|
|
if (sc->isa16bit)
|
1993-10-01 05:01:43 +03:00
|
|
|
outb(sc->asic_addr + ED_3COM_GACFR,
|
1994-02-12 10:16:24 +03:00
|
|
|
ED_3COM_GACFR_RSEL | ED_3COM_GACFR_MBS0);
|
1994-04-28 08:53:09 +04:00
|
|
|
break;
|
|
|
|
case ED_VENDOR_WD_SMC:
|
1994-05-19 11:47:34 +04:00
|
|
|
outb(sc->asic_addr + ED_WD_MSR,
|
|
|
|
sc->wd_msr_proto);
|
1994-04-28 08:53:09 +04:00
|
|
|
if (sc->isa16bit)
|
1994-02-12 10:16:24 +03:00
|
|
|
outb(sc->asic_addr + ED_WD_LAAR,
|
|
|
|
sc->wd_laar_proto);
|
1994-04-28 08:53:09 +04:00
|
|
|
(void) inb(0x84);
|
|
|
|
(void) inb(0x84);
|
|
|
|
break;
|
1993-10-01 05:01:43 +03:00
|
|
|
}
|
1994-02-12 10:16:24 +03:00
|
|
|
} else
|
1995-04-17 16:06:30 +04:00
|
|
|
len = ed_pio_write_mbufs(sc, m, (long)buffer);
|
1995-04-11 08:38:42 +04:00
|
|
|
|
1994-05-24 06:35:53 +04:00
|
|
|
sc->txb_len[sc->txb_new] = max(len, ETHER_MIN_LEN);
|
1993-10-01 05:01:43 +03:00
|
|
|
sc->txb_inuse++;
|
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Point to next buffer slot and wrap if necessary. */
|
|
|
|
if (++sc->txb_new == sc->txb_cnt)
|
1993-10-01 05:01:43 +03:00
|
|
|
sc->txb_new = 0;
|
1993-07-03 16:19:36 +04:00
|
|
|
|
|
|
|
if (sc->xmit_busy == 0)
|
1994-02-15 22:37:12 +03:00
|
|
|
ed_xmit(sc);
|
|
|
|
|
|
|
|
#if NBPFILTER > 0
|
1994-10-12 16:42:00 +03:00
|
|
|
/* Tap off here if there is a BPF listener. */
|
1994-05-13 10:13:43 +04:00
|
|
|
if (sc->sc_arpcom.ac_if.if_bpf)
|
|
|
|
bpf_mtap(sc->sc_arpcom.ac_if.if_bpf, m0);
|
1993-07-03 16:19:36 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
m_freem(m0);
|
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Loop back to the top to possibly buffer more packets. */
|
1993-10-01 05:01:43 +03:00
|
|
|
goto outloop;
|
1993-07-03 16:19:36 +04:00
|
|
|
}
|
1995-04-11 08:38:42 +04:00
|
|
|
|
1993-07-03 16:19:36 +04:00
|
|
|
/*
|
|
|
|
* Ethernet interface receiver interrupt.
|
|
|
|
*/
|
1993-10-01 05:01:43 +03:00
|
|
|
static inline void
|
1994-02-12 10:16:24 +03:00
|
|
|
ed_rint(sc)
|
|
|
|
struct ed_softc *sc;
|
1993-07-03 16:19:36 +04:00
|
|
|
{
|
1994-02-13 06:49:24 +03:00
|
|
|
u_char boundary, current;
|
1993-07-03 16:19:36 +04:00
|
|
|
u_short len;
|
1994-10-24 00:22:13 +03:00
|
|
|
u_char nlen;
|
1993-10-01 05:01:43 +03:00
|
|
|
struct ed_ring packet_hdr;
|
1994-02-12 10:16:24 +03:00
|
|
|
caddr_t packet_ptr;
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1994-10-24 02:24:56 +03:00
|
|
|
loop:
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Set NIC to page 1 registers to get 'current' pointer. */
|
1995-04-11 08:38:42 +04:00
|
|
|
NIC_PUT(sc, ED_P0_CR, sc->cr_proto | ED_CR_PAGE_1 | ED_CR_STA);
|
1993-07-03 16:19:36 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 'sc->next_packet' is the logical beginning of the ring-buffer - i.e.
|
1994-02-12 10:16:24 +03:00
|
|
|
* it points to where new data has been buffered. The 'CURR' (current)
|
|
|
|
* register points to the logical end of the ring-buffer - i.e. it
|
|
|
|
* points to where additional new data will be added. We loop here
|
|
|
|
* until the logical beginning equals the logical end (or in other
|
|
|
|
* words, until the ring-buffer is empty).
|
1993-07-03 16:19:36 +04:00
|
|
|
*/
|
1995-04-11 08:38:42 +04:00
|
|
|
current = NIC_GET(sc, ED_P1_CURR);
|
1994-10-24 02:24:56 +03:00
|
|
|
if (sc->next_packet == current)
|
|
|
|
return;
|
|
|
|
|
1995-04-11 08:38:42 +04:00
|
|
|
/* Set NIC to page 0 registers to update boundary register. */
|
|
|
|
NIC_PUT(sc, ED_P1_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STA);
|
|
|
|
|
1994-10-24 02:24:56 +03:00
|
|
|
do {
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Get pointer to this buffer's header structure. */
|
1993-10-01 05:01:43 +03:00
|
|
|
packet_ptr = sc->mem_ring +
|
1994-10-24 00:22:13 +03:00
|
|
|
((sc->next_packet - sc->rec_page_start) << ED_PAGE_SHIFT);
|
1993-07-03 16:19:36 +04:00
|
|
|
|
|
|
|
/*
|
1994-10-01 10:13:32 +03:00
|
|
|
* The byte count includes a 4 byte header that was added by
|
|
|
|
* the NIC.
|
1993-07-03 16:19:36 +04:00
|
|
|
*/
|
1993-10-01 05:01:43 +03:00
|
|
|
if (sc->mem_shared)
|
|
|
|
packet_hdr = *(struct ed_ring *)packet_ptr;
|
|
|
|
else
|
1995-04-17 16:06:30 +04:00
|
|
|
ed_pio_readmem(sc, (long)packet_ptr,
|
1994-02-12 10:16:24 +03:00
|
|
|
(caddr_t) &packet_hdr, sizeof(packet_hdr));
|
1993-10-01 05:01:43 +03:00
|
|
|
len = packet_hdr.count;
|
1994-10-24 00:22:13 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Try do deal with old, buggy chips that sometimes duplicate
|
|
|
|
* the low byte of the length into the high byte. We do this
|
|
|
|
* by simply ignoring the high byte of the length and always
|
|
|
|
* recalculating it.
|
|
|
|
*
|
|
|
|
* NOTE: sc->next_packet is pointing at the current packet.
|
|
|
|
*/
|
|
|
|
if (packet_hdr.next_packet >= sc->next_packet)
|
|
|
|
nlen = (packet_hdr.next_packet - sc->next_packet);
|
|
|
|
else
|
|
|
|
nlen = ((packet_hdr.next_packet - sc->rec_page_start) +
|
|
|
|
(sc->rec_page_stop - sc->next_packet));
|
|
|
|
--nlen;
|
|
|
|
if ((len & ED_PAGE_MASK) + sizeof(packet_hdr) > ED_PAGE_SIZE)
|
|
|
|
--nlen;
|
1994-10-24 00:38:00 +03:00
|
|
|
len = (len & ED_PAGE_MASK) | (nlen << ED_PAGE_SHIFT);
|
1994-10-24 00:22:13 +03:00
|
|
|
#ifdef DIAGNOSTIC
|
1994-10-24 00:38:00 +03:00
|
|
|
if (len != packet_hdr.count) {
|
1994-10-24 00:22:13 +03:00
|
|
|
printf("%s: length does not match next packet pointer\n",
|
|
|
|
sc->sc_dev.dv_xname);
|
1995-02-19 21:05:45 +03:00
|
|
|
printf("%s: len %04x nlen %04x start %02x first %02x curr %02x next %02x stop %02x\n",
|
1994-10-24 00:38:00 +03:00
|
|
|
sc->sc_dev.dv_xname, packet_hdr.count, len,
|
1995-02-19 21:05:45 +03:00
|
|
|
sc->rec_page_start, sc->next_packet, current,
|
1994-10-24 00:38:00 +03:00
|
|
|
packet_hdr.next_packet, sc->rec_page_stop);
|
1994-10-12 16:42:00 +03:00
|
|
|
}
|
1994-10-24 00:38:00 +03:00
|
|
|
#endif
|
1994-10-24 00:22:13 +03:00
|
|
|
|
1994-10-12 16:42:00 +03:00
|
|
|
/*
|
|
|
|
* Be fairly liberal about what we allow as a "reasonable"
|
|
|
|
* length so that a [crufty] packet will make it to BPF (and
|
|
|
|
* can thus be analyzed). Note that all that is really
|
|
|
|
* important is that we have a length that will fit into one
|
|
|
|
* mbuf cluster or less; the upper layer protocols can then
|
|
|
|
* figure out the length from their own length field(s).
|
|
|
|
*/
|
|
|
|
if (len <= MCLBYTES &&
|
|
|
|
packet_hdr.next_packet >= sc->rec_page_start &&
|
|
|
|
packet_hdr.next_packet < sc->rec_page_stop) {
|
1994-10-01 10:13:32 +03:00
|
|
|
/* Go get packet. */
|
|
|
|
ed_get_packet(sc, packet_ptr + sizeof(struct ed_ring),
|
|
|
|
len - sizeof(struct ed_ring));
|
1994-02-15 22:37:12 +03:00
|
|
|
++sc->sc_arpcom.ac_if.if_ipackets;
|
1993-07-03 16:19:36 +04:00
|
|
|
} else {
|
1994-10-12 16:42:00 +03:00
|
|
|
/* Really BAD. The ring pointers are corrupted. */
|
1993-07-03 16:19:36 +04:00
|
|
|
log(LOG_ERR,
|
1994-02-15 22:37:12 +03:00
|
|
|
"%s: NIC memory corrupt - invalid packet length %d\n",
|
|
|
|
sc->sc_dev.dv_xname, len);
|
|
|
|
++sc->sc_arpcom.ac_if.if_ierrors;
|
1994-02-12 10:16:24 +03:00
|
|
|
ed_reset(sc);
|
1993-07-03 16:19:36 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Update next packet pointer. */
|
1993-10-01 05:01:43 +03:00
|
|
|
sc->next_packet = packet_hdr.next_packet;
|
1993-07-03 16:19:36 +04:00
|
|
|
|
|
|
|
/*
|
1994-02-13 06:49:24 +03:00
|
|
|
* Update NIC boundary pointer - being careful to keep it one
|
1994-02-12 10:16:24 +03:00
|
|
|
* buffer behind (as recommended by NS databook).
|
1993-07-03 16:19:36 +04:00
|
|
|
*/
|
1994-02-13 06:49:24 +03:00
|
|
|
boundary = sc->next_packet - 1;
|
|
|
|
if (boundary < sc->rec_page_start)
|
|
|
|
boundary = sc->rec_page_stop - 1;
|
1995-04-11 08:38:42 +04:00
|
|
|
NIC_PUT(sc, ED_P0_BNRY, boundary);
|
1994-10-24 02:24:56 +03:00
|
|
|
} while (sc->next_packet != current);
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1994-10-24 02:24:56 +03:00
|
|
|
goto loop;
|
1993-07-03 16:19:36 +04:00
|
|
|
}
|
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Ethernet interface interrupt processor. */
|
1993-07-03 16:19:36 +04:00
|
|
|
int
|
1995-04-17 16:06:30 +04:00
|
|
|
edintr(arg)
|
|
|
|
void *arg;
|
1993-07-03 16:19:36 +04:00
|
|
|
{
|
1995-04-17 16:06:30 +04:00
|
|
|
struct ed_softc *sc = arg;
|
1993-07-03 16:19:36 +04:00
|
|
|
u_char isr;
|
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Set NIC to page 0 registers. */
|
1995-04-11 08:38:42 +04:00
|
|
|
NIC_PUT(sc, ED_P0_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STA);
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1995-04-11 08:38:42 +04:00
|
|
|
isr = NIC_GET(sc, ED_P0_ISR);
|
1994-04-08 21:16:39 +04:00
|
|
|
if (!isr)
|
1994-10-01 10:13:32 +03:00
|
|
|
return (0);
|
1994-04-08 21:16:39 +04:00
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Loop until there are no more new interrupts. */
|
1994-04-08 21:16:39 +04:00
|
|
|
for (;;) {
|
1993-07-03 16:19:36 +04:00
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* Reset all the bits that we are 'acknowledging' by writing a
|
|
|
|
* '1' to each bit position that was set.
|
|
|
|
* (Writing a '1' *clears* the bit.)
|
1993-07-03 16:19:36 +04:00
|
|
|
*/
|
1995-04-11 08:38:42 +04:00
|
|
|
NIC_PUT(sc, ED_P0_ISR, isr);
|
1993-07-03 16:19:36 +04:00
|
|
|
|
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* Handle transmitter interrupts. Handle these first because
|
|
|
|
* the receiver will reset the board under some conditions.
|
1993-07-03 16:19:36 +04:00
|
|
|
*/
|
1994-02-12 10:16:24 +03:00
|
|
|
if (isr & (ED_ISR_PTX | ED_ISR_TXE)) {
|
1995-04-11 08:38:42 +04:00
|
|
|
u_char collisions = NIC_GET(sc, ED_P0_NCR) & 0x0f;
|
1993-07-03 16:19:36 +04:00
|
|
|
|
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* Check for transmit error. If a TX completed with an
|
|
|
|
* error, we end up throwing the packet away. Really
|
1993-10-01 05:01:43 +03:00
|
|
|
* the only error that is possible is excessive
|
|
|
|
* collisions, and in this case it is best to allow the
|
1994-02-12 10:16:24 +03:00
|
|
|
* automatic mechanisms of TCP to backoff the flow. Of
|
1993-10-01 05:01:43 +03:00
|
|
|
* course, with UDP we're screwed, but this is expected
|
|
|
|
* when a network is heavily loaded.
|
1993-07-03 16:19:36 +04:00
|
|
|
*/
|
1995-04-11 08:38:42 +04:00
|
|
|
(void) NIC_GET(sc, ED_P0_TSR);
|
1993-10-01 05:01:43 +03:00
|
|
|
if (isr & ED_ISR_TXE) {
|
1993-07-03 16:19:36 +04:00
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* Excessive collisions (16).
|
1993-07-03 16:19:36 +04:00
|
|
|
*/
|
1995-04-11 08:38:42 +04:00
|
|
|
if ((NIC_GET(sc, ED_P0_TSR) & ED_TSR_ABT)
|
1994-02-12 10:16:24 +03:00
|
|
|
&& (collisions == 0)) {
|
1993-10-01 05:01:43 +03:00
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* When collisions total 16, the P0_NCR
|
|
|
|
* will indicate 0, and the TSR_ABT is
|
|
|
|
* set.
|
1993-10-01 05:01:43 +03:00
|
|
|
*/
|
|
|
|
collisions = 16;
|
|
|
|
}
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Update output errors counter. */
|
1994-02-15 22:37:12 +03:00
|
|
|
++sc->sc_arpcom.ac_if.if_oerrors;
|
1993-10-01 05:01:43 +03:00
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Update total number of successfully
|
1994-02-12 10:16:24 +03:00
|
|
|
* transmitted packets.
|
1993-10-01 05:01:43 +03:00
|
|
|
*/
|
1994-02-15 22:37:12 +03:00
|
|
|
++sc->sc_arpcom.ac_if.if_opackets;
|
1993-10-01 05:01:43 +03:00
|
|
|
}
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Reset TX busy and output active flags. */
|
1993-07-03 16:19:36 +04:00
|
|
|
sc->xmit_busy = 0;
|
1994-02-15 22:37:12 +03:00
|
|
|
sc->sc_arpcom.ac_if.if_flags &= ~IFF_OACTIVE;
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Clear watchdog timer. */
|
1994-02-15 22:37:12 +03:00
|
|
|
sc->sc_arpcom.ac_if.if_timer = 0;
|
1993-07-03 16:19:36 +04:00
|
|
|
|
|
|
|
/*
|
1993-10-01 05:01:43 +03:00
|
|
|
* Add in total number of collisions on last
|
1994-02-12 10:16:24 +03:00
|
|
|
* transmission.
|
1993-07-03 16:19:36 +04:00
|
|
|
*/
|
1994-02-15 22:37:12 +03:00
|
|
|
sc->sc_arpcom.ac_if.if_collisions += collisions;
|
1993-10-01 05:01:43 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Decrement buffer in-use count if not zero (can only
|
1994-02-12 10:16:24 +03:00
|
|
|
* be zero if a transmitter interrupt occured while not
|
|
|
|
* actually transmitting).
|
1993-10-01 05:01:43 +03:00
|
|
|
* If data is ready to transmit, start it transmitting,
|
1994-02-12 10:16:24 +03:00
|
|
|
* otherwise defer until after handling receiver.
|
1993-10-01 05:01:43 +03:00
|
|
|
*/
|
|
|
|
if (sc->txb_inuse && --sc->txb_inuse)
|
1994-02-15 22:37:12 +03:00
|
|
|
ed_xmit(sc);
|
1993-07-03 16:19:36 +04:00
|
|
|
}
|
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Handle receiver interrupts. */
|
|
|
|
if (isr & (ED_ISR_PRX | ED_ISR_RXE | ED_ISR_OVW)) {
|
|
|
|
/*
|
|
|
|
* Overwrite warning. In order to make sure that a
|
|
|
|
* lockup of the local DMA hasn't occurred, we reset
|
|
|
|
* and re-init the NIC. The NSC manual suggests only a
|
|
|
|
* partial reset/re-init is necessary - but some chips
|
|
|
|
* seem to want more. The DMA lockup has been seen
|
|
|
|
* only with early rev chips - Methinks this bug was
|
|
|
|
* fixed in later revs. -DG
|
|
|
|
*/
|
1993-10-01 05:01:43 +03:00
|
|
|
if (isr & ED_ISR_OVW) {
|
1994-02-15 22:37:12 +03:00
|
|
|
++sc->sc_arpcom.ac_if.if_ierrors;
|
1993-10-01 05:01:43 +03:00
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
log(LOG_WARNING,
|
1994-02-15 22:37:12 +03:00
|
|
|
"%s: warning - receiver ring buffer overrun\n",
|
|
|
|
sc->sc_dev.dv_xname);
|
1993-10-01 05:01:43 +03:00
|
|
|
#endif
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Stop/reset/re-init NIC. */
|
|
|
|
ed_reset(sc);
|
|
|
|
} else {
|
1993-10-01 05:01:43 +03:00
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* Receiver Error. One or more of: CRC error,
|
|
|
|
* frame alignment error FIFO overrun, or
|
|
|
|
* missed packet.
|
1993-10-01 05:01:43 +03:00
|
|
|
*/
|
|
|
|
if (isr & ED_ISR_RXE) {
|
1994-02-15 22:37:12 +03:00
|
|
|
++sc->sc_arpcom.ac_if.if_ierrors;
|
1993-10-01 05:01:43 +03:00
|
|
|
#ifdef ED_DEBUG
|
1994-02-15 22:37:12 +03:00
|
|
|
printf("%s: receive error %x\n",
|
|
|
|
sc->sc_dev.dv_xname,
|
1995-04-11 08:38:42 +04:00
|
|
|
NIC_GET(sc, ED_P0_RSR));
|
1993-10-01 05:01:43 +03:00
|
|
|
#endif
|
|
|
|
}
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1993-10-01 05:01:43 +03:00
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* Go get the packet(s).
|
1993-10-01 05:01:43 +03:00
|
|
|
* XXX - Doing this on an error is dubious
|
1994-02-12 10:16:24 +03:00
|
|
|
* because there shouldn't be any data to get
|
|
|
|
* (we've configured the interface to not
|
|
|
|
* accept packets with errors).
|
1993-10-01 05:01:43 +03:00
|
|
|
*/
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1993-10-01 05:01:43 +03:00
|
|
|
/*
|
|
|
|
* Enable 16bit access to shared memory first
|
1994-02-12 10:16:24 +03:00
|
|
|
* on WD/SMC boards.
|
1993-10-01 05:01:43 +03:00
|
|
|
*/
|
1994-04-28 08:53:09 +04:00
|
|
|
if (sc->vendor == ED_VENDOR_WD_SMC) {
|
|
|
|
if (sc->isa16bit)
|
|
|
|
outb(sc->asic_addr + ED_WD_LAAR,
|
|
|
|
sc->wd_laar_proto | ED_WD_LAAR_M16EN);
|
|
|
|
outb(sc->asic_addr + ED_WD_MSR,
|
|
|
|
sc->wd_msr_proto | ED_WD_MSR_MENB);
|
|
|
|
(void) inb(0x84);
|
1994-04-14 07:54:07 +04:00
|
|
|
(void) inb(0x84);
|
1993-07-03 16:19:36 +04:00
|
|
|
}
|
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
ed_rint(sc);
|
1993-10-01 05:01:43 +03:00
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Disable 16-bit access. */
|
1994-04-28 08:53:09 +04:00
|
|
|
if (sc->vendor == ED_VENDOR_WD_SMC) {
|
1994-05-19 11:47:34 +04:00
|
|
|
outb(sc->asic_addr + ED_WD_MSR,
|
|
|
|
sc->wd_msr_proto);
|
1994-04-28 08:53:09 +04:00
|
|
|
if (sc->isa16bit)
|
|
|
|
outb(sc->asic_addr + ED_WD_LAAR,
|
|
|
|
sc->wd_laar_proto);
|
|
|
|
(void) inb(0x84);
|
1994-04-14 07:54:07 +04:00
|
|
|
(void) inb(0x84);
|
1993-07-03 16:19:36 +04:00
|
|
|
}
|
1993-10-01 05:01:43 +03:00
|
|
|
}
|
1993-07-03 16:19:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* If it looks like the transmitter can take more data, attempt
|
|
|
|
* to start output on the interface. This is done after
|
|
|
|
* handling the receiver to give the receiver priority.
|
1993-07-03 16:19:36 +04:00
|
|
|
*/
|
1994-02-15 22:37:12 +03:00
|
|
|
if ((sc->sc_arpcom.ac_if.if_flags & IFF_OACTIVE) == 0)
|
|
|
|
ed_start(&sc->sc_arpcom.ac_if);
|
1993-07-03 16:19:36 +04:00
|
|
|
|
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* Return NIC CR to standard state: page 0, remote DMA
|
|
|
|
* complete, start (toggling the TXP bit off, even if was just
|
|
|
|
* set in the transmit routine, is *okay* - it is 'edge'
|
|
|
|
* triggered from low to high).
|
1993-07-03 16:19:36 +04:00
|
|
|
*/
|
1995-04-11 08:38:42 +04:00
|
|
|
NIC_PUT(sc, ED_P0_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STA);
|
1993-07-28 06:20:34 +04:00
|
|
|
|
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* If the Network Talley Counters overflow, read them to reset
|
|
|
|
* them. It appears that old 8390's won't clear the ISR flag
|
|
|
|
* otherwise - resulting in an infinite loop.
|
1993-07-28 06:20:34 +04:00
|
|
|
*/
|
|
|
|
if (isr & ED_ISR_CNT) {
|
1995-04-11 08:38:42 +04:00
|
|
|
(void) NIC_GET(sc, ED_P0_CNTR0);
|
|
|
|
(void) NIC_GET(sc, ED_P0_CNTR1);
|
|
|
|
(void) NIC_GET(sc, ED_P0_CNTR2);
|
1993-07-28 06:20:34 +04:00
|
|
|
}
|
1994-04-08 21:16:39 +04:00
|
|
|
|
1995-04-11 08:38:42 +04:00
|
|
|
isr = NIC_GET(sc, ED_P0_ISR);
|
1994-04-08 21:16:39 +04:00
|
|
|
if (!isr)
|
1994-10-01 10:13:32 +03:00
|
|
|
return (1);
|
1993-07-03 16:19:36 +04:00
|
|
|
}
|
|
|
|
}
|
1995-04-11 08:38:42 +04:00
|
|
|
|
1993-07-03 16:19:36 +04:00
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* Process an ioctl request. This code needs some work - it looks pretty ugly.
|
1993-07-03 16:19:36 +04:00
|
|
|
*/
|
|
|
|
int
|
|
|
|
ed_ioctl(ifp, command, data)
|
|
|
|
register struct ifnet *ifp;
|
1994-10-31 00:43:03 +03:00
|
|
|
u_long command;
|
1993-07-03 16:19:36 +04:00
|
|
|
caddr_t data;
|
|
|
|
{
|
1994-03-29 08:35:37 +04:00
|
|
|
struct ed_softc *sc = edcd.cd_devs[ifp->if_unit];
|
1994-02-15 22:37:12 +03:00
|
|
|
register struct ifaddr *ifa = (struct ifaddr *)data;
|
1993-07-03 16:19:36 +04:00
|
|
|
struct ifreq *ifr = (struct ifreq *)data;
|
|
|
|
int s, error = 0;
|
|
|
|
|
1994-03-08 15:21:10 +03:00
|
|
|
s = splimp();
|
1993-07-03 16:19:36 +04:00
|
|
|
|
|
|
|
switch (command) {
|
|
|
|
|
|
|
|
case SIOCSIFADDR:
|
|
|
|
ifp->if_flags |= IFF_UP;
|
|
|
|
|
|
|
|
switch (ifa->ifa_addr->sa_family) {
|
|
|
|
#ifdef INET
|
|
|
|
case AF_INET:
|
1995-04-11 08:38:42 +04:00
|
|
|
ed_init(sc);
|
|
|
|
arp_ifinit(&sc->sc_arpcom, ifa);
|
1993-07-03 16:19:36 +04:00
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
#ifdef NS
|
1994-02-12 10:16:24 +03:00
|
|
|
/* XXX - This code is probably wrong. */
|
1993-07-03 16:19:36 +04:00
|
|
|
case AF_NS:
|
|
|
|
{
|
1994-02-15 22:37:12 +03:00
|
|
|
register struct ns_addr *ina = &IA_SNS(ifa)->sns_addr;
|
1993-07-03 16:19:36 +04:00
|
|
|
|
|
|
|
if (ns_nullhost(*ina))
|
|
|
|
ina->x_host =
|
1994-02-15 22:37:12 +03:00
|
|
|
*(union ns_host *)(sc->sc_arpcom.ac_enaddr);
|
1994-10-01 10:13:32 +03:00
|
|
|
else
|
1994-02-15 22:37:12 +03:00
|
|
|
bcopy(ina->x_host.c_host,
|
|
|
|
sc->sc_arpcom.ac_enaddr,
|
|
|
|
sizeof(sc->sc_arpcom.ac_enaddr));
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Set new address. */
|
|
|
|
ed_init(sc);
|
1993-07-03 16:19:36 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
default:
|
1994-02-12 10:16:24 +03:00
|
|
|
ed_init(sc);
|
1993-07-03 16:19:36 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SIOCSIFFLAGS:
|
1994-02-12 10:16:24 +03:00
|
|
|
if ((ifp->if_flags & IFF_UP) == 0 &&
|
|
|
|
(ifp->if_flags & IFF_RUNNING) != 0) {
|
1994-02-08 06:06:20 +03:00
|
|
|
/*
|
|
|
|
* If interface is marked down and it is running, then
|
|
|
|
* stop it.
|
|
|
|
*/
|
1994-02-12 10:16:24 +03:00
|
|
|
ed_stop(sc);
|
1993-07-03 16:19:36 +04:00
|
|
|
ifp->if_flags &= ~IFF_RUNNING;
|
1994-02-12 10:16:24 +03:00
|
|
|
} else if ((ifp->if_flags & IFF_UP) != 0 &&
|
|
|
|
(ifp->if_flags & IFF_RUNNING) == 0) {
|
1994-02-08 06:06:20 +03:00
|
|
|
/*
|
|
|
|
* If interface is marked up and it is stopped, then
|
|
|
|
* start it.
|
|
|
|
*/
|
1994-02-12 10:16:24 +03:00
|
|
|
ed_init(sc);
|
1993-07-03 16:19:36 +04:00
|
|
|
} else {
|
1994-02-08 06:06:20 +03:00
|
|
|
/*
|
|
|
|
* Reset the interface to pick up changes in any other
|
|
|
|
* flags that affect hardware registers.
|
|
|
|
*/
|
1994-02-12 10:16:24 +03:00
|
|
|
ed_stop(sc);
|
|
|
|
ed_init(sc);
|
1993-07-03 16:19:36 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1993-12-10 08:37:33 +03:00
|
|
|
case SIOCADDMULTI:
|
|
|
|
case SIOCDELMULTI:
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Update our multicast list. */
|
|
|
|
error = (command == SIOCADDMULTI) ?
|
1994-02-15 22:37:12 +03:00
|
|
|
ether_addmulti(ifr, &sc->sc_arpcom) :
|
|
|
|
ether_delmulti(ifr, &sc->sc_arpcom);
|
1993-12-10 08:37:33 +03:00
|
|
|
|
|
|
|
if (error == ENETRESET) {
|
|
|
|
/*
|
|
|
|
* Multicast list has changed; set the hardware filter
|
|
|
|
* accordingly.
|
|
|
|
*/
|
1994-02-12 10:16:24 +03:00
|
|
|
ed_stop(sc); /* XXX for ds_setmcaf? */
|
|
|
|
ed_init(sc);
|
1993-12-10 08:37:33 +03:00
|
|
|
error = 0;
|
|
|
|
}
|
|
|
|
break;
|
1995-04-11 08:38:42 +04:00
|
|
|
|
1993-07-03 16:19:36 +04:00
|
|
|
default:
|
|
|
|
error = EINVAL;
|
|
|
|
}
|
1995-04-11 08:38:42 +04:00
|
|
|
|
|
|
|
splx(s);
|
1994-10-01 10:13:32 +03:00
|
|
|
return (error);
|
1993-07-03 16:19:36 +04:00
|
|
|
}
|
1995-04-11 08:38:42 +04:00
|
|
|
|
1993-07-03 16:19:36 +04:00
|
|
|
/*
|
|
|
|
* Retreive packet from shared memory and send to the next level up via
|
1994-02-12 10:16:24 +03:00
|
|
|
* ether_input(). If there is a BPF listener, give a copy to BPF, too.
|
1993-07-03 16:19:36 +04:00
|
|
|
*/
|
1994-02-12 10:16:24 +03:00
|
|
|
void
|
1993-07-03 16:19:36 +04:00
|
|
|
ed_get_packet(sc, buf, len)
|
|
|
|
struct ed_softc *sc;
|
1994-02-12 10:16:24 +03:00
|
|
|
caddr_t buf;
|
1993-07-03 16:19:36 +04:00
|
|
|
u_short len;
|
|
|
|
{
|
|
|
|
struct ether_header *eh;
|
1994-10-12 16:42:00 +03:00
|
|
|
struct mbuf *m, *ed_ring_to_mbuf();
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Allocate a header mbuf. */
|
1993-07-03 16:19:36 +04:00
|
|
|
MGETHDR(m, M_DONTWAIT, MT_DATA);
|
|
|
|
if (m == 0)
|
1994-10-12 16:42:00 +03:00
|
|
|
return;
|
1994-02-15 22:37:12 +03:00
|
|
|
m->m_pkthdr.rcvif = &sc->sc_arpcom.ac_if;
|
1993-07-03 16:19:36 +04:00
|
|
|
m->m_pkthdr.len = len;
|
|
|
|
m->m_len = 0;
|
|
|
|
|
1994-10-01 10:13:32 +03:00
|
|
|
/* The following silliness is to make NFS happy. */
|
1993-07-03 16:19:36 +04:00
|
|
|
#define EROUND ((sizeof(struct ether_header) + 3) & ~3)
|
|
|
|
#define EOFF (EROUND - sizeof(struct ether_header))
|
|
|
|
|
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* The following assumes there is room for the ether header in the
|
|
|
|
* header mbuf.
|
1993-07-03 16:19:36 +04:00
|
|
|
*/
|
1994-10-12 16:42:00 +03:00
|
|
|
m->m_data += EOFF;
|
|
|
|
eh = mtod(m, struct ether_header *);
|
1993-10-01 05:01:43 +03:00
|
|
|
|
|
|
|
if (sc->mem_shared)
|
1994-10-12 16:42:00 +03:00
|
|
|
bcopy(buf, mtod(m, caddr_t), sizeof(struct ether_header));
|
1993-10-01 05:01:43 +03:00
|
|
|
else
|
1995-04-17 16:06:30 +04:00
|
|
|
ed_pio_readmem(sc, (long)buf, mtod(m, caddr_t),
|
1994-02-12 10:16:24 +03:00
|
|
|
sizeof(struct ether_header));
|
1993-07-03 16:19:36 +04:00
|
|
|
buf += sizeof(struct ether_header);
|
1994-10-12 16:42:00 +03:00
|
|
|
m->m_len += sizeof(struct ether_header);
|
1993-07-03 16:19:36 +04:00
|
|
|
len -= sizeof(struct ether_header);
|
|
|
|
|
1994-05-13 10:13:43 +04:00
|
|
|
/* Pull packet off interface. */
|
1994-10-12 16:42:00 +03:00
|
|
|
if (ed_ring_to_mbuf(sc, buf, m, len) == 0) {
|
|
|
|
m_freem(m);
|
|
|
|
return;
|
|
|
|
}
|
1993-07-03 16:19:36 +04:00
|
|
|
|
|
|
|
#if NBPFILTER > 0
|
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* Check if there's a BPF listener on this interface. If so, hand off
|
1995-04-11 08:38:42 +04:00
|
|
|
* the raw packet to bpf.
|
1993-07-03 16:19:36 +04:00
|
|
|
*/
|
1994-05-13 10:13:43 +04:00
|
|
|
if (sc->sc_arpcom.ac_if.if_bpf) {
|
1994-10-12 16:42:00 +03:00
|
|
|
bpf_mtap(sc->sc_arpcom.ac_if.if_bpf, m);
|
1993-07-03 16:19:36 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Note that the interface cannot be in promiscuous mode if
|
|
|
|
* there are no BPF listeners. And if we are in promiscuous
|
|
|
|
* mode, we have to check if this packet is really ours.
|
|
|
|
*/
|
1994-02-15 22:37:12 +03:00
|
|
|
if ((sc->sc_arpcom.ac_if.if_flags & IFF_PROMISC) &&
|
1994-02-13 06:49:24 +03:00
|
|
|
(eh->ether_dhost[0] & 1) == 0 && /* !mcast and !bcast */
|
1994-02-15 22:37:12 +03:00
|
|
|
bcmp(eh->ether_dhost, sc->sc_arpcom.ac_enaddr,
|
1994-02-12 10:16:24 +03:00
|
|
|
sizeof(eh->ether_dhost)) != 0) {
|
1994-10-12 16:42:00 +03:00
|
|
|
m_freem(m);
|
1993-07-03 16:19:36 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Fix up data start offset in mbuf to point past ether header. */
|
1994-10-12 16:42:00 +03:00
|
|
|
m_adj(m, sizeof(struct ether_header));
|
|
|
|
ether_input(&sc->sc_arpcom.ac_if, eh, m);
|
1993-07-03 16:19:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* Supporting routines.
|
1993-07-03 16:19:36 +04:00
|
|
|
*/
|
|
|
|
|
1993-10-01 05:01:43 +03:00
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* Given a NIC memory source address and a host memory destination address,
|
|
|
|
* copy 'amount' from NIC to host using Programmed I/O. The 'amount' is
|
|
|
|
* rounded up to a word - okay as long as mbufs are word sized.
|
|
|
|
* This routine is currently Novell-specific.
|
1993-10-01 05:01:43 +03:00
|
|
|
*/
|
|
|
|
void
|
1994-02-12 10:16:24 +03:00
|
|
|
ed_pio_readmem(sc, src, dst, amount)
|
|
|
|
struct ed_softc *sc;
|
|
|
|
u_short src;
|
|
|
|
caddr_t dst;
|
|
|
|
u_short amount;
|
1993-10-01 05:01:43 +03:00
|
|
|
{
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Select page 0 registers. */
|
1995-04-11 08:38:42 +04:00
|
|
|
NIC_PUT(sc, ED_P0_CR, ED_CR_RD2 | ED_CR_PAGE_0 | ED_CR_STA);
|
1993-10-01 05:01:43 +03:00
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Round up to a word. */
|
|
|
|
if (amount & 1)
|
|
|
|
++amount;
|
1993-10-01 05:01:43 +03:00
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Set up DMA byte count. */
|
1995-04-11 08:38:42 +04:00
|
|
|
NIC_PUT(sc, ED_P0_RBCR0, amount);
|
|
|
|
NIC_PUT(sc, ED_P0_RBCR1, amount >> 8);
|
1993-10-01 05:01:43 +03:00
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Set up source address in NIC mem. */
|
1995-04-11 08:38:42 +04:00
|
|
|
NIC_PUT(sc, ED_P0_RSAR0, src);
|
|
|
|
NIC_PUT(sc, ED_P0_RSAR1, src >> 8);
|
1993-10-01 05:01:43 +03:00
|
|
|
|
1995-04-11 08:38:42 +04:00
|
|
|
NIC_PUT(sc, ED_P0_CR, ED_CR_RD0 | ED_CR_PAGE_0 | ED_CR_STA);
|
1993-10-01 05:01:43 +03:00
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
if (sc->isa16bit)
|
1994-10-01 10:13:32 +03:00
|
|
|
insw(sc->asic_addr + ED_NOVELL_DATA, dst, amount / 2);
|
1994-02-12 10:16:24 +03:00
|
|
|
else
|
1993-10-01 05:01:43 +03:00
|
|
|
insb(sc->asic_addr + ED_NOVELL_DATA, dst, amount);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* Stripped down routine for writing a linear buffer to NIC memory. Only used
|
|
|
|
* in the probe routine to test the memory. 'len' must be even.
|
1993-10-01 05:01:43 +03:00
|
|
|
*/
|
|
|
|
void
|
1994-02-12 10:16:24 +03:00
|
|
|
ed_pio_writemem(sc, src, dst, len)
|
1993-10-01 05:01:43 +03:00
|
|
|
struct ed_softc *sc;
|
1994-02-12 10:16:24 +03:00
|
|
|
caddr_t src;
|
|
|
|
u_short dst;
|
|
|
|
u_short len;
|
1993-10-01 05:01:43 +03:00
|
|
|
{
|
1994-02-12 10:16:24 +03:00
|
|
|
int maxwait = 100; /* about 120us */
|
1993-10-01 05:01:43 +03:00
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Select page 0 registers. */
|
1995-04-11 08:38:42 +04:00
|
|
|
NIC_PUT(sc, ED_P0_CR, ED_CR_RD2 | ED_CR_PAGE_0 | ED_CR_STA);
|
1993-10-01 05:01:43 +03:00
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Reset remote DMA complete flag. */
|
1995-04-11 08:38:42 +04:00
|
|
|
NIC_PUT(sc, ED_P0_ISR, ED_ISR_RDC);
|
1993-10-01 05:01:43 +03:00
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Set up DMA byte count. */
|
1995-04-11 08:38:42 +04:00
|
|
|
NIC_PUT(sc, ED_P0_RBCR0, len);
|
|
|
|
NIC_PUT(sc, ED_P0_RBCR1, len >> 8);
|
1993-10-01 05:01:43 +03:00
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Set up destination address in NIC mem. */
|
1995-04-11 08:38:42 +04:00
|
|
|
NIC_PUT(sc, ED_P0_RSAR0, dst);
|
|
|
|
NIC_PUT(sc, ED_P0_RSAR1, dst >> 8);
|
1993-10-01 05:01:43 +03:00
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Set remote DMA write. */
|
1995-04-11 08:38:42 +04:00
|
|
|
NIC_PUT(sc, ED_P0_CR, ED_CR_RD1 | ED_CR_PAGE_0 | ED_CR_STA);
|
1993-10-01 05:01:43 +03:00
|
|
|
|
|
|
|
if (sc->isa16bit)
|
1994-10-01 10:13:32 +03:00
|
|
|
outsw(sc->asic_addr + ED_NOVELL_DATA, src, len / 2);
|
1993-10-01 05:01:43 +03:00
|
|
|
else
|
|
|
|
outsb(sc->asic_addr + ED_NOVELL_DATA, src, len);
|
1994-02-12 10:16:24 +03:00
|
|
|
|
1993-10-01 05:01:43 +03:00
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* Wait for remote DMA complete. This is necessary because on the
|
|
|
|
* transmit side, data is handled internally by the NIC in bursts and
|
|
|
|
* we can't start another remote DMA until this one completes. Not
|
|
|
|
* waiting causes really bad things to happen - like the NIC
|
|
|
|
* irrecoverably jamming the ISA bus.
|
1993-10-01 05:01:43 +03:00
|
|
|
*/
|
1995-04-11 08:38:42 +04:00
|
|
|
while (((NIC_GET(sc, ED_P0_ISR) & ED_ISR_RDC) != ED_ISR_RDC) && --maxwait);
|
1993-10-01 05:01:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* Write an mbuf chain to the destination NIC memory address using programmed
|
|
|
|
* I/O.
|
1993-10-01 05:01:43 +03:00
|
|
|
*/
|
|
|
|
u_short
|
1994-02-12 10:16:24 +03:00
|
|
|
ed_pio_write_mbufs(sc, m, dst)
|
1993-10-01 05:01:43 +03:00
|
|
|
struct ed_softc *sc;
|
|
|
|
struct mbuf *m;
|
1994-02-12 10:16:24 +03:00
|
|
|
u_short dst;
|
1993-10-01 05:01:43 +03:00
|
|
|
{
|
1994-10-14 16:05:13 +03:00
|
|
|
u_short len;
|
1993-10-01 05:01:43 +03:00
|
|
|
struct mbuf *mp;
|
1994-02-12 10:16:24 +03:00
|
|
|
int maxwait = 100; /* about 120us */
|
1993-10-01 05:01:43 +03:00
|
|
|
|
1995-07-23 20:32:33 +04:00
|
|
|
len = m->m_pkthdr.len;
|
1995-04-11 08:38:42 +04:00
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Select page 0 registers. */
|
1995-04-11 08:38:42 +04:00
|
|
|
NIC_PUT(sc, ED_P0_CR, ED_CR_RD2 | ED_CR_PAGE_0 | ED_CR_STA);
|
1993-10-01 05:01:43 +03:00
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Reset remote DMA complete flag. */
|
1995-04-11 08:38:42 +04:00
|
|
|
NIC_PUT(sc, ED_P0_ISR, ED_ISR_RDC);
|
1993-10-01 05:01:43 +03:00
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Set up DMA byte count. */
|
1995-04-11 08:38:42 +04:00
|
|
|
NIC_PUT(sc, ED_P0_RBCR0, len);
|
|
|
|
NIC_PUT(sc, ED_P0_RBCR1, len >> 8);
|
1993-10-01 05:01:43 +03:00
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Set up destination address in NIC mem. */
|
1995-04-11 08:38:42 +04:00
|
|
|
NIC_PUT(sc, ED_P0_RSAR0, dst);
|
|
|
|
NIC_PUT(sc, ED_P0_RSAR1, dst >> 8);
|
1993-10-01 05:01:43 +03:00
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Set remote DMA write. */
|
1995-04-11 08:38:42 +04:00
|
|
|
NIC_PUT(sc, ED_P0_CR, ED_CR_RD1 | ED_CR_PAGE_0 | ED_CR_STA);
|
1993-10-01 05:01:43 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Transfer the mbuf chain to the NIC memory.
|
1994-10-14 16:05:13 +03:00
|
|
|
* 16-bit cards require that data be transferred as words, and only
|
|
|
|
* words, so that case requires some extra code to patch over
|
|
|
|
* odd-length mbufs.
|
1993-10-01 05:01:43 +03:00
|
|
|
*/
|
1994-10-14 16:05:13 +03:00
|
|
|
if (!sc->isa16bit) {
|
|
|
|
/* NE1000s are easy. */
|
|
|
|
for (; m != 0; m = m->m_next) {
|
|
|
|
if (m->m_len) {
|
|
|
|
outsb(sc->asic_addr + ED_NOVELL_DATA,
|
|
|
|
mtod(m, u_char *), m->m_len);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* NE2000s are a bit trickier. */
|
|
|
|
u_char *data, savebyte[2];
|
|
|
|
int len, wantbyte;
|
|
|
|
|
|
|
|
wantbyte = 0;
|
|
|
|
for (; m != 0; m = m->m_next) {
|
|
|
|
len = m->m_len;
|
1995-05-01 06:39:30 +04:00
|
|
|
if (len == 0)
|
|
|
|
continue;
|
|
|
|
data = mtod(m, u_char *);
|
|
|
|
/* Finish the last word. */
|
|
|
|
if (wantbyte) {
|
|
|
|
savebyte[1] = *data;
|
|
|
|
outw(sc->asic_addr + ED_NOVELL_DATA,
|
|
|
|
*(u_short *)savebyte);
|
|
|
|
data++;
|
|
|
|
len--;
|
|
|
|
wantbyte = 0;
|
|
|
|
}
|
|
|
|
/* Output contiguous words. */
|
|
|
|
if (len > 1)
|
|
|
|
outsw(sc->asic_addr + ED_NOVELL_DATA,
|
|
|
|
data, len >> 1);
|
|
|
|
/* Save last byte, if necessary. */
|
|
|
|
if (len & 1) {
|
|
|
|
data += len & ~1;
|
|
|
|
savebyte[0] = *data;
|
|
|
|
wantbyte = 1;
|
1994-10-14 16:05:13 +03:00
|
|
|
}
|
|
|
|
}
|
1993-10-01 05:01:43 +03:00
|
|
|
|
1994-10-14 16:05:13 +03:00
|
|
|
if (wantbyte) {
|
|
|
|
savebyte[1] = 0;
|
|
|
|
outw(sc->asic_addr + ED_NOVELL_DATA,
|
|
|
|
*(u_short *)savebyte);
|
1993-10-01 05:01:43 +03:00
|
|
|
}
|
|
|
|
}
|
1995-04-11 08:38:42 +04:00
|
|
|
|
1993-10-01 05:01:43 +03:00
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* Wait for remote DMA complete. This is necessary because on the
|
|
|
|
* transmit side, data is handled internally by the NIC in bursts and
|
|
|
|
* we can't start another remote DMA until this one completes. Not
|
|
|
|
* waiting causes really bad things to happen - like the NIC
|
|
|
|
* irrecoverably jamming the ISA bus.
|
1993-10-01 05:01:43 +03:00
|
|
|
*/
|
1995-04-11 08:38:42 +04:00
|
|
|
while (((NIC_GET(sc, ED_P0_ISR) & ED_ISR_RDC) != ED_ISR_RDC) && --maxwait);
|
1993-10-01 05:01:43 +03:00
|
|
|
|
|
|
|
if (!maxwait) {
|
1994-02-12 10:16:24 +03:00
|
|
|
log(LOG_WARNING,
|
1994-02-15 22:37:12 +03:00
|
|
|
"%s: remote transmit DMA failed to complete\n",
|
|
|
|
sc->sc_dev.dv_xname);
|
1994-02-12 10:16:24 +03:00
|
|
|
ed_reset(sc);
|
1993-10-01 05:01:43 +03:00
|
|
|
}
|
|
|
|
|
1994-10-01 10:13:32 +03:00
|
|
|
return (len);
|
1993-10-01 05:01:43 +03:00
|
|
|
}
|
1995-04-11 08:38:42 +04:00
|
|
|
|
1993-07-03 16:19:36 +04:00
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* Given a source and destination address, copy 'amount' of a packet from the
|
|
|
|
* ring buffer into a linear destination buffer. Takes into account ring-wrap.
|
1993-07-03 16:19:36 +04:00
|
|
|
*/
|
1995-04-11 08:38:42 +04:00
|
|
|
static inline caddr_t
|
1994-02-12 10:16:24 +03:00
|
|
|
ed_ring_copy(sc, src, dst, amount)
|
1993-07-03 16:19:36 +04:00
|
|
|
struct ed_softc *sc;
|
1995-04-11 08:38:42 +04:00
|
|
|
caddr_t src, dst;
|
1993-07-03 16:19:36 +04:00
|
|
|
u_short amount;
|
|
|
|
{
|
|
|
|
u_short tmp_amount;
|
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Does copy wrap to lower addr in ring buffer? */
|
1993-10-01 05:01:43 +03:00
|
|
|
if (src + amount > sc->mem_end) {
|
|
|
|
tmp_amount = sc->mem_end - src;
|
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
/* Copy amount up to end of NIC memory. */
|
1993-10-01 05:01:43 +03:00
|
|
|
if (sc->mem_shared)
|
1994-02-12 10:16:24 +03:00
|
|
|
bcopy(src, dst, tmp_amount);
|
1993-10-01 05:01:43 +03:00
|
|
|
else
|
1995-04-17 16:06:30 +04:00
|
|
|
ed_pio_readmem(sc, (long)src, dst, tmp_amount);
|
1993-10-01 05:01:43 +03:00
|
|
|
|
1993-07-03 16:19:36 +04:00
|
|
|
amount -= tmp_amount;
|
1993-10-01 05:01:43 +03:00
|
|
|
src = sc->mem_ring;
|
1993-07-03 16:19:36 +04:00
|
|
|
dst += tmp_amount;
|
|
|
|
}
|
|
|
|
|
1993-10-01 05:01:43 +03:00
|
|
|
if (sc->mem_shared)
|
|
|
|
bcopy(src, dst, amount);
|
|
|
|
else
|
1995-04-17 16:06:30 +04:00
|
|
|
ed_pio_readmem(sc, (long)src, dst, amount);
|
1993-07-03 16:19:36 +04:00
|
|
|
|
1994-10-01 10:13:32 +03:00
|
|
|
return (src + amount);
|
1993-07-03 16:19:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* Copy data from receive buffer to end of mbuf chain allocate additional mbufs
|
|
|
|
* as needed. Return pointer to last mbuf in chain.
|
1993-07-03 16:19:36 +04:00
|
|
|
* sc = ed info (softc)
|
|
|
|
* src = pointer in ed ring buffer
|
|
|
|
* dst = pointer to last mbuf in mbuf chain to copy to
|
|
|
|
* amount = amount of data to copy
|
|
|
|
*/
|
|
|
|
struct mbuf *
|
1994-02-12 10:16:24 +03:00
|
|
|
ed_ring_to_mbuf(sc, src, dst, total_len)
|
1993-07-03 16:19:36 +04:00
|
|
|
struct ed_softc *sc;
|
1994-02-12 10:16:24 +03:00
|
|
|
caddr_t src;
|
1993-07-03 16:19:36 +04:00
|
|
|
struct mbuf *dst;
|
|
|
|
u_short total_len;
|
|
|
|
{
|
|
|
|
register struct mbuf *m = dst;
|
|
|
|
|
|
|
|
while (total_len) {
|
|
|
|
register u_short amount = min(total_len, M_TRAILINGSPACE(m));
|
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
if (amount == 0) {
|
1993-07-03 16:19:36 +04:00
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* No more data in this mbuf; alloc another.
|
|
|
|
*
|
1993-07-03 16:19:36 +04:00
|
|
|
* If there is enough data for an mbuf cluster, attempt
|
1994-02-12 10:16:24 +03:00
|
|
|
* to allocate one of those, otherwise, a regular mbuf
|
|
|
|
* will do.
|
1993-07-03 16:19:36 +04:00
|
|
|
* Note that a regular mbuf is always required, even if
|
1994-02-12 10:16:24 +03:00
|
|
|
* we get a cluster - getting a cluster does not
|
|
|
|
* allocate any mbufs, and one is needed to assign the
|
|
|
|
* cluster to. The mbuf that has a cluster extension
|
|
|
|
* can not be used to contain data - only the cluster
|
|
|
|
* can contain data.
|
1995-04-11 08:38:42 +04:00
|
|
|
*/
|
1993-07-03 16:19:36 +04:00
|
|
|
dst = m;
|
|
|
|
MGET(m, M_DONTWAIT, MT_DATA);
|
|
|
|
if (m == 0)
|
1994-10-01 10:13:32 +03:00
|
|
|
return (0);
|
1993-07-03 16:19:36 +04:00
|
|
|
|
|
|
|
if (total_len >= MINCLSIZE)
|
|
|
|
MCLGET(m, M_DONTWAIT);
|
|
|
|
|
|
|
|
m->m_len = 0;
|
|
|
|
dst->m_next = m;
|
|
|
|
amount = min(total_len, M_TRAILINGSPACE(m));
|
|
|
|
}
|
|
|
|
|
1994-02-12 10:16:24 +03:00
|
|
|
src = ed_ring_copy(sc, src, mtod(m, caddr_t) + m->m_len,
|
|
|
|
amount);
|
1993-07-03 16:19:36 +04:00
|
|
|
|
|
|
|
m->m_len += amount;
|
|
|
|
total_len -= amount;
|
|
|
|
}
|
1994-10-01 10:13:32 +03:00
|
|
|
return (m);
|
1993-07-03 16:19:36 +04:00
|
|
|
}
|
1993-12-10 08:37:33 +03:00
|
|
|
|
|
|
|
/*
|
1994-02-12 10:16:24 +03:00
|
|
|
* Compute the multicast address filter from the list of multicast addresses we
|
|
|
|
* need to listen to.
|
1993-12-10 08:37:33 +03:00
|
|
|
*/
|
|
|
|
void
|
1994-02-15 02:56:16 +03:00
|
|
|
ed_getmcaf(ac, af)
|
|
|
|
struct arpcom *ac;
|
|
|
|
u_long *af;
|
1993-12-10 08:37:33 +03:00
|
|
|
{
|
1994-02-15 02:56:16 +03:00
|
|
|
struct ifnet *ifp = &ac->ac_if;
|
|
|
|
struct ether_multi *enm;
|
|
|
|
register u_char *cp, c;
|
|
|
|
register u_long crc;
|
|
|
|
register int i, len;
|
|
|
|
struct ether_multistep step;
|
1994-02-12 10:16:24 +03:00
|
|
|
|
1994-02-15 02:56:16 +03:00
|
|
|
/*
|
|
|
|
* Set up multicast address filter by passing all multicast addresses
|
|
|
|
* through a crc generator, and then using the high order 6 bits as an
|
|
|
|
* index into the 64 bit logical address filter. The high order bit
|
|
|
|
* selects the word, while the rest of the bits select the bit within
|
|
|
|
* the word.
|
|
|
|
*/
|
|
|
|
|
1994-02-16 23:22:04 +03:00
|
|
|
if (ifp->if_flags & IFF_PROMISC) {
|
1994-02-16 23:15:18 +03:00
|
|
|
ifp->if_flags |= IFF_ALLMULTI;
|
1994-02-15 02:56:16 +03:00
|
|
|
af[0] = af[1] = 0xffffffff;
|
|
|
|
return;
|
|
|
|
}
|
1994-02-12 10:16:24 +03:00
|
|
|
|
1994-02-15 02:56:16 +03:00
|
|
|
af[0] = af[1] = 0;
|
|
|
|
ETHER_FIRST_MULTI(step, ac, enm);
|
1993-12-10 08:37:33 +03:00
|
|
|
while (enm != NULL) {
|
1994-02-15 02:56:16 +03:00
|
|
|
if (bcmp(enm->enm_addrlo, enm->enm_addrhi,
|
|
|
|
sizeof(enm->enm_addrlo)) != 0) {
|
|
|
|
/*
|
|
|
|
* We must listen to a range of multicast addresses.
|
|
|
|
* For now, just accept all multicasts, rather than
|
|
|
|
* trying to set only those filter bits needed to match
|
|
|
|
* the range. (At this time, the only use of address
|
|
|
|
* ranges is for IP multicast routing, for which the
|
|
|
|
* range is big enough to require all bits set.)
|
|
|
|
*/
|
1994-02-16 23:15:18 +03:00
|
|
|
ifp->if_flags |= IFF_ALLMULTI;
|
1994-02-15 02:56:16 +03:00
|
|
|
af[0] = af[1] = 0xffffffff;
|
1993-12-10 08:37:33 +03:00
|
|
|
return;
|
|
|
|
}
|
1994-02-15 02:56:16 +03:00
|
|
|
|
|
|
|
cp = enm->enm_addrlo;
|
|
|
|
crc = 0xffffffff;
|
|
|
|
for (len = sizeof(enm->enm_addrlo); --len >= 0;) {
|
|
|
|
c = *cp++;
|
|
|
|
for (i = 8; --i >= 0;) {
|
|
|
|
if (((crc & 0x80000000) ? 1 : 0) ^ (c & 0x01)) {
|
|
|
|
crc <<= 1;
|
|
|
|
crc ^= 0x04c11db6 | 1;
|
|
|
|
} else
|
|
|
|
crc <<= 1;
|
|
|
|
c >>= 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Just want the 6 most significant bits. */
|
|
|
|
crc >>= 26;
|
|
|
|
|
|
|
|
/* Turn on the corresponding bit in the filter. */
|
1995-05-28 15:29:46 +04:00
|
|
|
af[crc >> 5] |= 1 << ((crc & 0x1f) ^ 0);
|
1994-02-12 10:16:24 +03:00
|
|
|
|
1993-12-10 08:37:33 +03:00
|
|
|
ETHER_NEXT_MULTI(step, enm);
|
|
|
|
}
|
1994-02-16 23:15:18 +03:00
|
|
|
ifp->if_flags &= ~IFF_ALLMULTI;
|
1993-12-10 08:37:33 +03:00
|
|
|
}
|