1998-07-05 10:49:00 +04:00
|
|
|
/* $NetBSD: if_es.c,v 1.22 1998/07/05 06:49:03 jonathan Exp $ */
|
1995-02-13 03:27:08 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 1995 Michael L. Hitch
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by Michael L. Hitch.
|
|
|
|
* 4. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* SMC 91C90 Single-Chip Ethernet Controller
|
|
|
|
*/
|
1998-07-05 02:18:13 +04:00
|
|
|
#include "opt_ddb.h"
|
1998-07-05 04:51:04 +04:00
|
|
|
#include "opt_inet.h"
|
1998-07-05 10:49:00 +04:00
|
|
|
#include "opt_ns.h"
|
1995-02-13 03:27:08 +03:00
|
|
|
|
1995-08-18 19:27:29 +04:00
|
|
|
#include "bpfilter.h"
|
|
|
|
|
1995-02-13 03:27:08 +03:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/mbuf.h>
|
|
|
|
#include <sys/buf.h>
|
|
|
|
#include <sys/protosw.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/syslog.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/errno.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
|
|
|
|
#include <net/if.h>
|
1997-03-17 20:55:54 +03:00
|
|
|
#include <net/if_dl.h>
|
1997-03-15 21:09:08 +03:00
|
|
|
#include <net/if_ether.h>
|
1995-02-13 03:27:08 +03:00
|
|
|
|
|
|
|
#ifdef INET
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <netinet/in_systm.h>
|
|
|
|
#include <netinet/in_var.h>
|
|
|
|
#include <netinet/ip.h>
|
1997-03-15 21:09:08 +03:00
|
|
|
#include <netinet/if_inarp.h>
|
1995-02-13 03:27:08 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef NS
|
|
|
|
#include <netns/ns.h>
|
|
|
|
#include <netns/ns_if.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <machine/cpu.h>
|
|
|
|
#include <machine/mtpr.h>
|
|
|
|
#include <amiga/amiga/device.h>
|
|
|
|
#include <amiga/amiga/isr.h>
|
|
|
|
#include <amiga/dev/zbusvar.h>
|
|
|
|
#include <amiga/dev/if_esreg.h>
|
|
|
|
|
|
|
|
#define SWAP(x) (((x & 0xff) << 8) | ((x >> 8) & 0xff))
|
|
|
|
|
|
|
|
#define USEPKTBUF
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Ethernet software status per interface.
|
|
|
|
*
|
|
|
|
* Each interface is referenced by a network interface structure,
|
|
|
|
* es_if, which the routing code uses to locate the interface.
|
|
|
|
* This structure contains the output queue for the interface, its address, ...
|
|
|
|
*/
|
|
|
|
struct es_softc {
|
|
|
|
struct device sc_dev;
|
|
|
|
struct isr sc_isr;
|
1997-03-15 21:09:08 +03:00
|
|
|
struct ethercom sc_ethercom; /* common Ethernet structures */
|
1996-05-01 19:55:28 +04:00
|
|
|
void *sc_base; /* base address of board */
|
1995-02-13 03:27:08 +03:00
|
|
|
short sc_iflags;
|
|
|
|
unsigned short sc_intctl;
|
|
|
|
#ifdef ESDEBUG
|
|
|
|
int sc_debug;
|
1996-05-01 19:55:28 +04:00
|
|
|
short sc_intbusy; /* counter for interrupt rentered */
|
|
|
|
short sc_smcbusy; /* counter for other rentry checks */
|
1995-02-13 03:27:08 +03:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
#if NBPFILTER > 0
|
|
|
|
#include <net/bpf.h>
|
|
|
|
#include <net/bpfdesc.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef ESDEBUG
|
|
|
|
/* console error messages */
|
|
|
|
int esdebug = 0;
|
1995-08-18 19:27:29 +04:00
|
|
|
int estxints = 0; /* IST_TX with TX enabled */
|
|
|
|
int estxint2 = 0; /* IST_TX active after IST_TX_EMPTY */
|
|
|
|
int estxint3 = 0; /* IST_TX interrupt processed */
|
|
|
|
int estxint4 = 0; /* ~TEMPTY counts */
|
|
|
|
int estxint5 = 0; /* IST_TX_EMPTY interrupts */
|
1996-04-22 01:10:48 +04:00
|
|
|
void es_dump_smcregs __P((char *, union smcregs *));
|
1995-02-13 03:27:08 +03:00
|
|
|
#endif
|
|
|
|
|
1996-04-22 01:10:48 +04:00
|
|
|
int esintr __P((void *));
|
1995-04-11 09:58:58 +04:00
|
|
|
void esstart __P((struct ifnet *));
|
1996-05-07 04:46:37 +04:00
|
|
|
void eswatchdog __P((struct ifnet *));
|
1995-02-13 03:27:08 +03:00
|
|
|
int esioctl __P((struct ifnet *, u_long, caddr_t));
|
|
|
|
void esrint __P((struct es_softc *));
|
|
|
|
void estint __P((struct es_softc *));
|
|
|
|
void esinit __P((struct es_softc *));
|
|
|
|
void esreset __P((struct es_softc *));
|
1996-04-22 01:10:48 +04:00
|
|
|
void esstop __P((struct es_softc *));
|
1995-02-13 03:27:08 +03:00
|
|
|
|
1996-12-23 12:09:49 +03:00
|
|
|
int esmatch __P((struct device *, struct cfdata *, void *));
|
1995-02-13 03:27:08 +03:00
|
|
|
void esattach __P((struct device *, struct device *, void *));
|
|
|
|
|
1996-03-17 04:16:48 +03:00
|
|
|
struct cfattach es_ca = {
|
1996-03-17 08:53:57 +03:00
|
|
|
sizeof(struct es_softc), esmatch, esattach
|
1996-03-17 04:16:48 +03:00
|
|
|
};
|
|
|
|
|
1995-02-13 03:27:08 +03:00
|
|
|
int
|
1996-12-23 12:09:49 +03:00
|
|
|
esmatch(parent, cfp, aux)
|
1995-04-11 09:58:58 +04:00
|
|
|
struct device *parent;
|
1996-12-23 12:09:49 +03:00
|
|
|
struct cfdata *cfp;
|
|
|
|
void *aux;
|
1995-02-13 03:27:08 +03:00
|
|
|
{
|
1995-04-11 09:58:58 +04:00
|
|
|
struct zbus_args *zap = aux;
|
1995-02-13 03:27:08 +03:00
|
|
|
|
|
|
|
/* Ameristar A4066 ethernet card */
|
1995-04-11 09:58:58 +04:00
|
|
|
if (zap->manid == 1053 && zap->prodid == 10)
|
1995-02-13 03:27:08 +03:00
|
|
|
return(1);
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Interface exists: make available by filling in network interface
|
|
|
|
* record. System will initialize the interface when it is ready
|
|
|
|
* to accept packets.
|
|
|
|
*/
|
|
|
|
void
|
1995-04-11 09:58:58 +04:00
|
|
|
esattach(parent, self, aux)
|
|
|
|
struct device *parent, *self;
|
|
|
|
void *aux;
|
1995-02-13 03:27:08 +03:00
|
|
|
{
|
1995-04-11 09:58:58 +04:00
|
|
|
struct es_softc *sc = (void *)self;
|
|
|
|
struct zbus_args *zap = aux;
|
1997-03-15 21:09:08 +03:00
|
|
|
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
|
1995-02-13 03:27:08 +03:00
|
|
|
unsigned long ser;
|
1997-03-15 21:09:08 +03:00
|
|
|
u_int8_t myaddr[ETHER_ADDR_LEN];
|
1995-02-13 03:27:08 +03:00
|
|
|
|
|
|
|
sc->sc_base = zap->va;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Manufacturer decides the 3 first bytes, i.e. ethernet vendor ID.
|
|
|
|
* (Currently only Ameristar.)
|
|
|
|
*/
|
1997-03-15 21:09:08 +03:00
|
|
|
myaddr[0] = 0x00;
|
|
|
|
myaddr[1] = 0x00;
|
|
|
|
myaddr[2] = 0x9f;
|
1995-02-13 03:27:08 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Serial number for board contains last 3 bytes.
|
|
|
|
*/
|
|
|
|
ser = (unsigned long) zap->serno;
|
|
|
|
|
1997-03-15 21:09:08 +03:00
|
|
|
myaddr[3] = (ser >> 16) & 0xff;
|
|
|
|
myaddr[4] = (ser >> 8) & 0xff;
|
|
|
|
myaddr[5] = (ser ) & 0xff;
|
1995-02-13 03:27:08 +03:00
|
|
|
|
1995-04-11 09:58:58 +04:00
|
|
|
/* Initialize ifnet structure. */
|
1996-05-07 04:46:37 +04:00
|
|
|
bcopy(sc->sc_dev.dv_xname, ifp->if_xname, IFNAMSIZ);
|
|
|
|
ifp->if_softc = sc;
|
1995-08-18 19:27:29 +04:00
|
|
|
ifp->if_output = ether_output;
|
1995-02-13 03:27:08 +03:00
|
|
|
ifp->if_ioctl = esioctl;
|
|
|
|
ifp->if_start = esstart;
|
|
|
|
ifp->if_watchdog = eswatchdog;
|
|
|
|
/* XXX IFF_MULTICAST */
|
|
|
|
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS;
|
|
|
|
|
1995-04-11 09:58:58 +04:00
|
|
|
/* Attach the interface. */
|
1995-02-13 03:27:08 +03:00
|
|
|
if_attach(ifp);
|
1997-03-15 21:09:08 +03:00
|
|
|
ether_ifattach(ifp, myaddr);
|
1995-04-11 09:58:58 +04:00
|
|
|
|
|
|
|
/* Print additional info when attached. */
|
1997-03-15 21:09:08 +03:00
|
|
|
printf(": address %s\n", ether_sprintf(myaddr));
|
1995-04-11 09:58:58 +04:00
|
|
|
|
1995-02-13 03:27:08 +03:00
|
|
|
#if NBPFILTER > 0
|
1995-04-11 09:58:58 +04:00
|
|
|
bpfattach(&ifp->if_bpf, ifp, DLT_EN10MB, sizeof(struct ether_header));
|
1995-02-13 03:27:08 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
sc->sc_isr.isr_intr = esintr;
|
|
|
|
sc->sc_isr.isr_arg = sc;
|
|
|
|
sc->sc_isr.isr_ipl = 2;
|
1995-04-11 09:58:58 +04:00
|
|
|
add_isr(&sc->sc_isr);
|
1995-02-13 03:27:08 +03:00
|
|
|
}
|
|
|
|
|
1995-08-18 19:27:29 +04:00
|
|
|
#ifdef ESDEBUG
|
|
|
|
void
|
|
|
|
es_dump_smcregs(where, smc)
|
|
|
|
char *where;
|
|
|
|
union smcregs *smc;
|
|
|
|
{
|
1996-05-01 19:55:28 +04:00
|
|
|
u_short cur_bank = smc->b0.bsr & BSR_MASK;
|
1995-08-18 19:27:29 +04:00
|
|
|
|
1996-10-13 07:05:43 +04:00
|
|
|
printf("SMC registers %p from %s bank %04x\n", smc, where,
|
1995-08-18 19:27:29 +04:00
|
|
|
smc->b0.bsr);
|
|
|
|
smc->b0.bsr = BSR_BANK0;
|
1996-10-13 07:05:43 +04:00
|
|
|
printf("TCR %04x EPHSR %04x RCR %04x ECR %04x MIR %04x MCR %04x\n",
|
1995-08-18 19:27:29 +04:00
|
|
|
SWAP(smc->b0.tcr), SWAP(smc->b0.ephsr), SWAP(smc->b0.rcr),
|
|
|
|
SWAP(smc->b0.ecr), SWAP(smc->b0.mir), SWAP(smc->b0.mcr));
|
|
|
|
smc->b1.bsr = BSR_BANK1;
|
1996-10-13 07:05:43 +04:00
|
|
|
printf("CR %04x BAR %04x IAR %04x %04x %04x GPR %04x CTR %04x\n",
|
1995-08-18 19:27:29 +04:00
|
|
|
SWAP(smc->b1.cr), SWAP(smc->b1.bar), smc->b1.iar[0], smc->b1.iar[1],
|
|
|
|
smc->b1.iar[2], smc->b1.gpr, SWAP(smc->b1.ctr));
|
|
|
|
smc->b2.bsr = BSR_BANK2;
|
1996-10-13 07:05:43 +04:00
|
|
|
printf("MMUCR %04x PNR %02x ARR %02x FIFO %04x PTR %04x",
|
1995-08-18 19:27:29 +04:00
|
|
|
SWAP(smc->b2.mmucr), smc->b2.pnr, smc->b2.arr, smc->b2.fifo,
|
|
|
|
SWAP(smc->b2.ptr));
|
1996-10-13 07:05:43 +04:00
|
|
|
printf(" DATA %04x %04x IST %02x MSK %02x\n", smc->b2.data,
|
1995-08-18 19:27:29 +04:00
|
|
|
smc->b2.datax, smc->b2.ist, smc->b2.msk);
|
|
|
|
smc->b3.bsr = BSR_BANK3;
|
1996-10-13 07:05:43 +04:00
|
|
|
printf("MT %04x %04x %04x %04x\n",
|
1995-08-18 19:27:29 +04:00
|
|
|
smc->b3.mt[0], smc->b3.mt[1], smc->b3.mt[2], smc->b3.mt[3]);
|
|
|
|
smc->b3.bsr = cur_bank;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1995-04-14 21:29:50 +04:00
|
|
|
void
|
|
|
|
esstop(sc)
|
|
|
|
struct es_softc* sc;
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
1995-02-13 03:27:08 +03:00
|
|
|
void
|
|
|
|
esinit(sc)
|
|
|
|
struct es_softc *sc;
|
|
|
|
{
|
1997-03-15 21:09:08 +03:00
|
|
|
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
|
1995-02-13 03:27:08 +03:00
|
|
|
union smcregs *smc = sc->sc_base;
|
|
|
|
int s;
|
|
|
|
|
1995-12-24 05:29:35 +03:00
|
|
|
s = splnet();
|
1995-02-13 03:27:08 +03:00
|
|
|
|
1995-08-18 19:27:29 +04:00
|
|
|
#ifdef ESDEBUG
|
|
|
|
if (ifp->if_flags & IFF_RUNNING)
|
|
|
|
es_dump_smcregs("esinit", smc);
|
|
|
|
#endif
|
1995-04-11 09:58:58 +04:00
|
|
|
smc->b0.bsr = BSR_BANK0; /* Select bank 0 */
|
1995-02-13 03:27:08 +03:00
|
|
|
smc->b0.rcr = RCR_EPH_RST;
|
|
|
|
smc->b0.rcr = 0;
|
1995-04-11 09:58:58 +04:00
|
|
|
smc->b3.bsr = BSR_BANK3; /* Select bank 3 */
|
1995-02-13 03:27:08 +03:00
|
|
|
smc->b3.mt[0] = 0; /* clear Multicast table */
|
|
|
|
smc->b3.mt[1] = 0;
|
|
|
|
smc->b3.mt[2] = 0;
|
|
|
|
smc->b3.mt[3] = 0;
|
|
|
|
/* XXX set Multicast table from Multicast list */
|
1995-04-11 09:58:58 +04:00
|
|
|
smc->b1.bsr = BSR_BANK1; /* Select bank 1 */
|
1995-02-13 03:27:08 +03:00
|
|
|
smc->b1.cr = CR_RAM32K | CR_NO_WAIT_ST | CR_SET_SQLCH;
|
|
|
|
smc->b1.ctr = CTR_AUTO_RLSE;
|
1997-03-15 21:09:08 +03:00
|
|
|
smc->b1.iar[0] = *((unsigned short *) &LLADDR(ifp->if_sadl)[0]);
|
|
|
|
smc->b1.iar[1] = *((unsigned short *) &LLADDR(ifp->if_sadl)[2]);
|
|
|
|
smc->b1.iar[2] = *((unsigned short *) &LLADDR(ifp->if_sadl)[4]);
|
1995-04-11 09:58:58 +04:00
|
|
|
smc->b2.bsr = BSR_BANK2; /* Select bank 2 */
|
1995-02-13 03:27:08 +03:00
|
|
|
smc->b2.mmucr = MMUCR_RESET;
|
1995-04-11 09:58:58 +04:00
|
|
|
smc->b0.bsr = BSR_BANK0; /* Select bank 0 */
|
|
|
|
smc->b0.mcr = SWAP(0x0020); /* reserve 8K for transmit buffers */
|
1996-04-22 01:10:48 +04:00
|
|
|
smc->b0.tcr = TCR_PAD_EN | (TCR_TXENA + TCR_MON_CSN);
|
1995-02-13 03:27:08 +03:00
|
|
|
smc->b0.rcr = RCR_FILT_CAR | RCR_STRIP_CRC | RCR_RXEN;
|
|
|
|
/* XXX add multicast/promiscuous flags */
|
1995-04-11 09:58:58 +04:00
|
|
|
smc->b2.bsr = BSR_BANK2; /* Select bank 2 */
|
1995-02-13 03:27:08 +03:00
|
|
|
smc->b2.msk = sc->sc_intctl = MSK_RX_OVRN | MSK_RX;
|
|
|
|
|
|
|
|
/* Interface is now 'running', with no output active. */
|
|
|
|
ifp->if_flags |= IFF_RUNNING;
|
|
|
|
ifp->if_flags &= ~IFF_OACTIVE;
|
|
|
|
|
|
|
|
/* Attempt to start output, if any. */
|
|
|
|
esstart(ifp);
|
|
|
|
|
|
|
|
splx(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1996-04-22 01:10:48 +04:00
|
|
|
esintr(arg)
|
|
|
|
void *arg;
|
1995-02-13 03:27:08 +03:00
|
|
|
{
|
1996-04-22 01:10:48 +04:00
|
|
|
struct es_softc *sc = arg;
|
1997-03-15 21:09:08 +03:00
|
|
|
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
|
1995-04-03 00:38:09 +04:00
|
|
|
u_short intsts, intact;
|
1995-02-13 03:27:08 +03:00
|
|
|
union smcregs *smc;
|
1995-12-24 05:29:35 +03:00
|
|
|
int s = splnet();
|
1995-02-13 03:27:08 +03:00
|
|
|
|
|
|
|
smc = sc->sc_base;
|
1995-08-18 19:27:29 +04:00
|
|
|
#ifdef ESDEBUG
|
1996-05-01 19:55:28 +04:00
|
|
|
while ((smc->b2.bsr & BSR_MASK) != BSR_BANK2 &&
|
1997-03-15 21:09:08 +03:00
|
|
|
ifp->if_flags & IFF_RUNNING) {
|
1996-10-13 07:05:43 +04:00
|
|
|
printf("%s: intr BSR not 2: %04x\n", sc->sc_dev.dv_xname,
|
1995-08-18 19:27:29 +04:00
|
|
|
smc->b2.bsr);
|
|
|
|
smc->b2.bsr = BSR_BANK2;
|
|
|
|
}
|
|
|
|
#endif
|
1995-04-03 00:38:09 +04:00
|
|
|
intsts = smc->b2.ist;
|
|
|
|
intact = smc->b2.msk & intsts;
|
1995-08-18 19:27:29 +04:00
|
|
|
if ((intact) == 0) {
|
|
|
|
splx(s);
|
1995-02-13 03:27:08 +03:00
|
|
|
return (0);
|
1995-08-18 19:27:29 +04:00
|
|
|
}
|
1995-02-13 03:27:08 +03:00
|
|
|
#ifdef ESDEBUG
|
|
|
|
if (esdebug)
|
1996-10-13 07:05:43 +04:00
|
|
|
printf ("%s: esintr ist %02x msk %02x",
|
1995-04-03 00:38:09 +04:00
|
|
|
sc->sc_dev.dv_xname, intsts, smc->b2.msk);
|
1995-08-18 19:27:29 +04:00
|
|
|
if (sc->sc_intbusy++) {
|
1996-10-13 07:05:43 +04:00
|
|
|
printf("%s: esintr re-entered\n", sc->sc_dev.dv_xname);
|
1995-08-18 19:27:29 +04:00
|
|
|
panic("esintr re-entered");
|
|
|
|
}
|
1996-05-01 19:55:28 +04:00
|
|
|
if (sc->sc_smcbusy)
|
1996-10-13 07:05:43 +04:00
|
|
|
printf("%s: esintr interrupted busy %d\n", sc->sc_dev.dv_xname,
|
1996-05-01 19:55:28 +04:00
|
|
|
sc->sc_smcbusy);
|
1995-02-13 03:27:08 +03:00
|
|
|
#endif
|
|
|
|
smc->b2.msk = 0;
|
|
|
|
#ifdef ESDEBUG
|
|
|
|
if (esdebug)
|
1996-10-13 07:05:43 +04:00
|
|
|
printf ("=>%02x%02x pnr %02x arr %02x fifo %04x\n",
|
1995-02-13 03:27:08 +03:00
|
|
|
smc->b2.ist, smc->b2.ist, smc->b2.pnr, smc->b2.arr,
|
|
|
|
smc->b2.fifo);
|
|
|
|
#endif
|
1995-04-03 00:38:09 +04:00
|
|
|
if (intact & IST_ALLOC) {
|
1995-02-13 03:27:08 +03:00
|
|
|
sc->sc_intctl &= ~MSK_ALLOC;
|
|
|
|
#ifdef ESDEBUG
|
|
|
|
if (esdebug || 1)
|
1996-10-13 07:05:43 +04:00
|
|
|
printf ("%s: ist %02x", sc->sc_dev.dv_xname,
|
1995-04-03 00:38:09 +04:00
|
|
|
intsts);
|
1995-02-13 03:27:08 +03:00
|
|
|
#endif
|
|
|
|
if ((smc->b2.arr & ARR_FAILED) == 0) {
|
1995-08-18 19:27:29 +04:00
|
|
|
u_char save_pnr;
|
1995-02-13 03:27:08 +03:00
|
|
|
#ifdef ESDEBUG
|
|
|
|
if (esdebug || 1)
|
1996-10-13 07:05:43 +04:00
|
|
|
printf (" arr %02x\n", smc->b2.arr);
|
1995-02-13 03:27:08 +03:00
|
|
|
#endif
|
1995-08-18 19:27:29 +04:00
|
|
|
save_pnr = smc->b2.pnr;
|
1995-02-13 03:27:08 +03:00
|
|
|
smc->b2.pnr = smc->b2.arr;
|
|
|
|
smc->b2.mmucr = MMUCR_RLSPKT;
|
|
|
|
while (smc->b2.mmucr & MMUCR_BUSY)
|
|
|
|
;
|
1995-08-18 19:27:29 +04:00
|
|
|
smc->b2.pnr = save_pnr;
|
1997-03-15 21:09:08 +03:00
|
|
|
ifp->if_flags &= ~IFF_OACTIVE;
|
1995-02-13 03:27:08 +03:00
|
|
|
}
|
1995-08-18 19:27:29 +04:00
|
|
|
#ifdef ESDEBUG
|
|
|
|
else if (esdebug || 1)
|
1996-10-13 07:05:43 +04:00
|
|
|
printf (" IST_ALLOC with ARR_FAILED?\n");
|
1995-08-18 19:27:29 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#ifdef ESDEBUG
|
1996-05-01 19:55:28 +04:00
|
|
|
while ((smc->b2.bsr & BSR_MASK) != BSR_BANK2) {
|
1996-10-13 07:05:43 +04:00
|
|
|
printf("%s: intr+ BSR not 2: %04x\n", sc->sc_dev.dv_xname,
|
1995-08-18 19:27:29 +04:00
|
|
|
smc->b2.bsr);
|
|
|
|
smc->b2.bsr = BSR_BANK2;
|
1995-02-13 03:27:08 +03:00
|
|
|
}
|
1995-08-18 19:27:29 +04:00
|
|
|
#endif
|
1995-02-13 03:27:08 +03:00
|
|
|
while ((smc->b2.fifo & FIFO_REMPTY) == 0) {
|
|
|
|
esrint(sc);
|
|
|
|
}
|
1995-08-18 19:27:29 +04:00
|
|
|
#ifdef ESDEBUG
|
1996-05-01 19:55:28 +04:00
|
|
|
while ((smc->b2.bsr & BSR_MASK) != BSR_BANK2) {
|
1996-10-13 07:05:43 +04:00
|
|
|
printf("%s: intr++ BSR not 2: %04x\n", sc->sc_dev.dv_xname,
|
1995-08-18 19:27:29 +04:00
|
|
|
smc->b2.bsr);
|
|
|
|
smc->b2.bsr = BSR_BANK2;
|
|
|
|
}
|
|
|
|
#endif
|
1995-04-03 00:38:09 +04:00
|
|
|
if (intact & IST_RX_OVRN) {
|
1996-10-13 07:05:43 +04:00
|
|
|
printf ("%s: Overrun ist %02x", sc->sc_dev.dv_xname,
|
1995-04-03 00:38:09 +04:00
|
|
|
intsts);
|
1995-02-13 03:27:08 +03:00
|
|
|
smc->b2.ist = ACK_RX_OVRN;
|
1996-10-13 07:05:43 +04:00
|
|
|
printf ("->%02x\n", smc->b2.ist);
|
1997-03-15 21:09:08 +03:00
|
|
|
ifp->if_ierrors++;
|
1995-02-13 03:27:08 +03:00
|
|
|
}
|
1995-04-03 00:38:09 +04:00
|
|
|
if (intact & IST_TX_EMPTY) {
|
1995-02-13 03:27:08 +03:00
|
|
|
u_short ecr;
|
|
|
|
#ifdef ESDEBUG
|
|
|
|
if (esdebug)
|
1996-10-13 07:05:43 +04:00
|
|
|
printf ("%s: TX EMPTY %02x",
|
1995-04-03 00:38:09 +04:00
|
|
|
sc->sc_dev.dv_xname, intsts);
|
1995-08-18 19:27:29 +04:00
|
|
|
++estxint5; /* count # IST_TX_EMPTY ints */
|
1995-02-13 03:27:08 +03:00
|
|
|
#endif
|
|
|
|
smc->b2.ist = ACK_TX_EMPTY;
|
1995-08-18 19:27:29 +04:00
|
|
|
sc->sc_intctl &= ~(MSK_TX_EMPTY | MSK_TX);
|
1995-02-13 03:27:08 +03:00
|
|
|
#ifdef ESDEBUG
|
|
|
|
if (esdebug)
|
1996-10-13 07:05:43 +04:00
|
|
|
printf ("->%02x intcl %x pnr %02x arr %02x\n",
|
1995-02-13 03:27:08 +03:00
|
|
|
smc->b2.ist, sc->sc_intctl, smc->b2.pnr,
|
|
|
|
smc->b2.arr);
|
|
|
|
#endif
|
1995-08-18 19:27:29 +04:00
|
|
|
if (smc->b2.ist & IST_TX) {
|
|
|
|
intact |= IST_TX;
|
|
|
|
#ifdef ESDEBUG
|
|
|
|
++estxint2; /* count # TX after TX_EMPTY */
|
|
|
|
#endif
|
|
|
|
} else {
|
|
|
|
smc->b0.bsr = BSR_BANK0;
|
|
|
|
ecr = smc->b0.ecr; /* Get error counters */
|
|
|
|
if (ecr & 0xff00)
|
1997-03-15 21:09:08 +03:00
|
|
|
ifp->if_collisions += ((ecr >> 8) & 15) +
|
1995-08-18 19:27:29 +04:00
|
|
|
((ecr >> 11) & 0x1e);
|
|
|
|
smc->b2.bsr = BSR_BANK2;
|
|
|
|
#if 0
|
|
|
|
smc->b2.mmucr = MMUCR_RESET_TX; /* XXX reset TX FIFO */
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (intact & IST_TX) {
|
|
|
|
u_char tx_pnr, save_pnr;
|
|
|
|
u_short save_ptr, ephsr, tcr;
|
|
|
|
int n = 0;
|
|
|
|
#ifdef ESDEBUG
|
|
|
|
if (esdebug) {
|
1996-10-13 07:05:43 +04:00
|
|
|
printf ("%s: TX INT ist %02x",
|
1995-08-18 19:27:29 +04:00
|
|
|
sc->sc_dev.dv_xname, intsts);
|
1996-10-13 07:05:43 +04:00
|
|
|
printf ("->%02x\n", smc->b2.ist);
|
1995-08-18 19:27:29 +04:00
|
|
|
}
|
|
|
|
++estxint3; /* count # IST_TX */
|
|
|
|
#endif
|
|
|
|
zzzz:
|
1996-05-01 19:55:28 +04:00
|
|
|
#ifdef ESDEBUG
|
1995-08-18 19:27:29 +04:00
|
|
|
++estxint4; /* count # ~TEMPTY */
|
1996-05-01 19:55:28 +04:00
|
|
|
#endif
|
1995-04-11 09:58:58 +04:00
|
|
|
smc->b0.bsr = BSR_BANK0;
|
1995-08-18 19:27:29 +04:00
|
|
|
ephsr = smc->b0.ephsr; /* get EPHSR */
|
|
|
|
tcr = smc->b0.tcr; /* and TCR */
|
1995-04-11 09:58:58 +04:00
|
|
|
smc->b2.bsr = BSR_BANK2;
|
1995-08-18 19:27:29 +04:00
|
|
|
save_ptr = smc->b2.ptr;
|
|
|
|
save_pnr = smc->b2.pnr;
|
|
|
|
tx_pnr = smc->b2.fifo >> 8; /* pktno from completion fifo */
|
|
|
|
smc->b2.pnr = tx_pnr; /* set TX packet number */
|
|
|
|
smc->b2.ptr = PTR_READ; /* point to status word */
|
|
|
|
#if 0 /* XXXX */
|
1996-10-13 07:05:43 +04:00
|
|
|
printf("%s: esintr TXINT IST %02x PNR %02x(%d)",
|
1995-08-18 19:27:29 +04:00
|
|
|
sc->sc_dev.dv_xname, smc->b2.ist,
|
|
|
|
tx_pnr, n);
|
1996-10-13 07:05:43 +04:00
|
|
|
printf(" Status %04x", smc->b2.data);
|
|
|
|
printf(" EPHSR %04x\n", ephsr);
|
1995-08-18 19:27:29 +04:00
|
|
|
#endif
|
|
|
|
if ((smc->b2.data & EPHSR_TX_SUC) == 0 && (tcr & TCR_TXENA) == 0) {
|
|
|
|
/*
|
|
|
|
* Transmitter was stopped for some error. Enqueue
|
|
|
|
* the packet again and restart the transmitter.
|
|
|
|
* May need some check to limit the number of retries.
|
|
|
|
*/
|
|
|
|
smc->b2.mmucr = MMUCR_ENQ_TX;
|
|
|
|
smc->b0.bsr = BSR_BANK0;
|
|
|
|
smc->b0.tcr |= TCR_TXENA;
|
|
|
|
smc->b2.bsr = BSR_BANK2;
|
1997-03-15 21:09:08 +03:00
|
|
|
ifp->if_oerrors++;
|
1995-08-18 19:27:29 +04:00
|
|
|
sc->sc_intctl |= MSK_TX_EMPTY | MSK_TX;
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* This shouldn't have happened: IST_TX indicates
|
|
|
|
* the TX completion FIFO is not empty, but the
|
|
|
|
* status for the packet on the completion FIFO
|
|
|
|
* shows that the transmit was sucessful. Since
|
|
|
|
* AutoRelease is being used, a sucessful transmit
|
|
|
|
* should not result in a packet on the completion
|
|
|
|
* FIFO. Also, that packet doesn't seem to want
|
|
|
|
* to be acknowledged. If this occurs, just reset
|
|
|
|
* the TX FIFOs.
|
|
|
|
*/
|
|
|
|
#if 1
|
|
|
|
if (smc->b2.ist & IST_TX_EMPTY) {
|
|
|
|
smc->b2.mmucr = MMUCR_RESET_TX;
|
|
|
|
sc->sc_intctl &= ~(MSK_TX_EMPTY | MSK_TX);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#ifdef ESDEBUG
|
|
|
|
++estxints; /* count IST_TX with TX enabled */
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
smc->b2.pnr = save_pnr;
|
|
|
|
smc->b2.ptr = save_ptr;
|
|
|
|
smc->b2.ist = ACK_TX;
|
|
|
|
|
|
|
|
if ((smc->b2.fifo & FIFO_TEMPTY) == 0 && n++ < 32) {
|
|
|
|
#if 0 /* XXXX */
|
1996-10-13 07:05:43 +04:00
|
|
|
printf("%s: multiple TX int(%2d) pnr %02x ist %02x fifo %04x",
|
1995-08-18 19:27:29 +04:00
|
|
|
sc->sc_dev.dv_xname, n, tx_pnr, smc->b2.ist, smc->b2.fifo);
|
|
|
|
smc->w2.istmsk = ACK_TX << 8;
|
1996-10-13 07:05:43 +04:00
|
|
|
printf(" %04x\n", smc->b2.fifo);
|
1995-08-18 19:27:29 +04:00
|
|
|
#endif
|
|
|
|
if (tx_pnr != (smc->b2.fifo >> 8))
|
|
|
|
goto zzzz;
|
|
|
|
}
|
1995-02-13 03:27:08 +03:00
|
|
|
}
|
|
|
|
/* output packets */
|
|
|
|
estint(sc);
|
1995-08-18 19:27:29 +04:00
|
|
|
#ifdef ESDEBUG
|
1996-05-01 19:55:28 +04:00
|
|
|
while ((smc->b2.bsr & BSR_MASK) != BSR_BANK2) {
|
1996-10-13 07:05:43 +04:00
|
|
|
printf("%s: intr+++ BSR not 2: %04x\n", sc->sc_dev.dv_xname,
|
1995-08-18 19:27:29 +04:00
|
|
|
smc->b2.bsr);
|
|
|
|
smc->b2.bsr = BSR_BANK2;
|
|
|
|
}
|
|
|
|
#endif
|
1995-02-13 03:27:08 +03:00
|
|
|
smc->b2.msk = sc->sc_intctl;
|
1995-08-18 19:27:29 +04:00
|
|
|
#ifdef ESDEBUG
|
|
|
|
if (--sc->sc_intbusy) {
|
1996-10-13 07:05:43 +04:00
|
|
|
printf("%s: esintr busy on exit\n", sc->sc_dev.dv_xname);
|
1995-08-18 19:27:29 +04:00
|
|
|
panic("esintr busy on exit");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
splx(s);
|
1995-02-13 03:27:08 +03:00
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1995-04-11 09:58:58 +04:00
|
|
|
esrint(sc)
|
1995-02-13 03:27:08 +03:00
|
|
|
struct es_softc *sc;
|
|
|
|
{
|
|
|
|
union smcregs *smc = sc->sc_base;
|
|
|
|
u_short len;
|
|
|
|
short cnt;
|
|
|
|
u_short pktctlw, pktlen, *buf;
|
|
|
|
volatile u_short *data;
|
1996-04-22 01:10:48 +04:00
|
|
|
#if 0
|
|
|
|
u_long *lbuf;
|
1995-02-13 03:27:08 +03:00
|
|
|
volatile u_long *ldata;
|
1996-04-22 01:10:48 +04:00
|
|
|
#endif
|
1995-02-13 03:27:08 +03:00
|
|
|
struct ifnet *ifp;
|
|
|
|
struct mbuf *top, **mp, *m;
|
|
|
|
struct ether_header *eh;
|
|
|
|
#ifdef USEPKTBUF
|
|
|
|
u_char *b, pktbuf[1530];
|
|
|
|
#endif
|
1996-05-01 19:55:28 +04:00
|
|
|
#ifdef ESDEBUG
|
|
|
|
int i;
|
|
|
|
#endif
|
1995-02-13 03:27:08 +03:00
|
|
|
|
1997-03-15 21:09:08 +03:00
|
|
|
ifp = &sc->sc_ethercom.ec_if;
|
1995-02-13 03:27:08 +03:00
|
|
|
#ifdef ESDEBUG
|
|
|
|
if (esdebug)
|
1996-10-13 07:05:43 +04:00
|
|
|
printf ("%s: esrint fifo %04x", sc->sc_dev.dv_xname,
|
1995-02-13 03:27:08 +03:00
|
|
|
smc->b2.fifo);
|
1995-08-18 19:27:29 +04:00
|
|
|
if (sc->sc_smcbusy++) {
|
1996-10-13 07:05:43 +04:00
|
|
|
printf("%s: esrint re-entered\n", sc->sc_dev.dv_xname);
|
1995-08-18 19:27:29 +04:00
|
|
|
panic("esrint re-entered");
|
|
|
|
}
|
1996-05-01 19:55:28 +04:00
|
|
|
while ((smc->b2.bsr & BSR_MASK) != BSR_BANK2) {
|
1996-10-13 07:05:43 +04:00
|
|
|
printf("%s: rint BSR not 2: %04x\n", sc->sc_dev.dv_xname,
|
1995-08-18 19:27:29 +04:00
|
|
|
smc->b2.bsr);
|
|
|
|
smc->b2.bsr = BSR_BANK2;
|
|
|
|
}
|
1995-02-13 03:27:08 +03:00
|
|
|
#endif
|
|
|
|
data = (u_short *)&smc->b2.data;
|
1995-04-11 09:58:58 +04:00
|
|
|
smc->b2.ptr = PTR_RCV | PTR_AUTOINCR | PTR_READ | SWAP(0x0002);
|
1995-02-13 03:27:08 +03:00
|
|
|
(void) smc->b2.mmucr;
|
|
|
|
#ifdef ESDEBUG
|
|
|
|
if (esdebug)
|
1996-10-13 07:05:43 +04:00
|
|
|
printf ("->%04x", smc->b2.fifo);
|
1995-02-13 03:27:08 +03:00
|
|
|
#endif
|
|
|
|
len = *data;
|
1995-04-11 09:58:58 +04:00
|
|
|
len = SWAP(len); /* Careful of macro side-effects */
|
1995-02-13 03:27:08 +03:00
|
|
|
#ifdef ESDEBUG
|
|
|
|
if (esdebug)
|
1996-10-13 07:05:43 +04:00
|
|
|
printf (" length %d", len);
|
1995-02-13 03:27:08 +03:00
|
|
|
#endif
|
1996-04-22 01:10:48 +04:00
|
|
|
smc->b2.ptr = PTR_RCV | (PTR_AUTOINCR + PTR_READ) | SWAP(0x0000);
|
1995-02-13 03:27:08 +03:00
|
|
|
(void) smc->b2.mmucr;
|
|
|
|
pktctlw = *data;
|
|
|
|
pktlen = *data;
|
1995-04-11 09:58:58 +04:00
|
|
|
pktctlw = SWAP(pktctlw);
|
|
|
|
pktlen = SWAP(pktlen) - 6;
|
1995-02-13 03:27:08 +03:00
|
|
|
if (pktctlw & RFSW_ODDFRM)
|
|
|
|
pktlen++;
|
1995-08-18 19:27:29 +04:00
|
|
|
if (len > 1530) {
|
1996-10-13 07:05:43 +04:00
|
|
|
printf("%s: Corrupted packet length-sts %04x bytcnt %04x len %04x bank %04x\n",
|
1995-08-18 19:27:29 +04:00
|
|
|
sc->sc_dev.dv_xname, pktctlw, pktlen, len, smc->b2.bsr);
|
|
|
|
/* XXX ignore packet, or just truncate? */
|
|
|
|
#if defined(ESDEBUG) && defined(DDB)
|
1996-05-01 19:55:28 +04:00
|
|
|
if ((smc->b2.bsr & BSR_MASK) != BSR_BANK2)
|
1995-08-18 19:27:29 +04:00
|
|
|
Debugger();
|
|
|
|
#endif
|
|
|
|
smc->b2.bsr = BSR_BANK2;
|
|
|
|
smc->b2.mmucr = MMUCR_REMRLS_RX;
|
|
|
|
while (smc->b2.mmucr & MMUCR_BUSY)
|
|
|
|
;
|
1997-03-15 21:09:08 +03:00
|
|
|
++ifp->if_ierrors;
|
1995-08-18 19:27:29 +04:00
|
|
|
#ifdef ESDEBUG
|
|
|
|
if (--sc->sc_smcbusy) {
|
1996-10-13 07:05:43 +04:00
|
|
|
printf("%s: esrintr busy on bad packet exit\n",
|
1995-08-18 19:27:29 +04:00
|
|
|
sc->sc_dev.dv_xname);
|
|
|
|
panic("esrintr busy on exit");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return;
|
|
|
|
}
|
1995-02-13 03:27:08 +03:00
|
|
|
#ifdef USEPKTBUF
|
1995-08-18 19:27:29 +04:00
|
|
|
#if 0
|
1995-02-13 03:27:08 +03:00
|
|
|
lbuf = (u_long *) pktbuf;
|
|
|
|
ldata = (u_long *)data;
|
|
|
|
cnt = (len - 4) / 4;
|
|
|
|
while (cnt--)
|
|
|
|
*lbuf++ = *ldata;
|
|
|
|
if ((len - 4) & 2) {
|
|
|
|
buf = (u_short *) lbuf;
|
|
|
|
*buf = *data;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
buf = (u_short *)pktbuf;
|
|
|
|
cnt = (len - 4) / 2;
|
|
|
|
while (cnt--)
|
|
|
|
*buf++ = *data;
|
|
|
|
#endif
|
|
|
|
smc->b2.mmucr = MMUCR_REMRLS_RX;
|
|
|
|
while (smc->b2.mmucr & MMUCR_BUSY)
|
|
|
|
;
|
|
|
|
#ifdef ESDEBUG
|
|
|
|
if (pktctlw & (RFSW_ALGNERR | RFSW_BADCRC | RFSW_TOOLNG | RFSW_TOOSHORT)) {
|
1996-10-13 07:05:43 +04:00
|
|
|
printf ("%s: Packet error %04x\n", sc->sc_dev.dv_xname, pktctlw);
|
1995-02-13 03:27:08 +03:00
|
|
|
/* count input error? */
|
|
|
|
}
|
|
|
|
if (esdebug) {
|
1996-10-13 07:05:43 +04:00
|
|
|
printf (" pktctlw %04x pktlen %04x fifo %04x\n", pktctlw, pktlen,
|
1995-02-13 03:27:08 +03:00
|
|
|
smc->b2.fifo);
|
|
|
|
for (i = 0; i < pktlen; ++i)
|
1996-10-13 07:05:43 +04:00
|
|
|
printf ("%02x%s", pktbuf[i], ((i & 31) == 31) ? "\n" :
|
1995-02-13 03:27:08 +03:00
|
|
|
"");
|
|
|
|
if (i & 31)
|
1996-10-13 07:05:43 +04:00
|
|
|
printf ("\n");
|
1995-02-13 03:27:08 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#else /* USEPKTBUF */
|
1995-08-18 19:27:29 +04:00
|
|
|
/* XXX copy directly from controller to mbuf */
|
1995-02-13 03:27:08 +03:00
|
|
|
#ifdef ESDEBUG
|
|
|
|
if (pktctlw & (RFSW_ALGNERR | RFSW_BADCRC | RFSW_TOOLNG | RFSW_TOOSHORT)) {
|
1996-10-13 07:05:43 +04:00
|
|
|
printf ("%s: Packet error %04x\n", sc->sc_dev.dv_xname, pktctlw);
|
1995-02-13 03:27:08 +03:00
|
|
|
/* count input error? */
|
|
|
|
}
|
|
|
|
if (esdebug) {
|
1996-10-13 07:05:43 +04:00
|
|
|
printf (" pktctlw %04x pktlen %04x fifo %04x\n", pktctlw, pktlen,
|
1995-02-13 03:27:08 +03:00
|
|
|
smc->b2.fifo);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif /* USEPKTBUF */
|
|
|
|
ifp->if_ipackets++;
|
|
|
|
MGETHDR(m, M_DONTWAIT, MT_DATA);
|
|
|
|
if (m == NULL)
|
|
|
|
return;
|
|
|
|
m->m_pkthdr.rcvif = ifp;
|
|
|
|
m->m_pkthdr.len = pktlen;
|
|
|
|
len = MHLEN;
|
|
|
|
top = NULL;
|
|
|
|
mp = ⊤
|
|
|
|
#ifdef USEPKTBUF
|
|
|
|
b = pktbuf;
|
|
|
|
#endif
|
|
|
|
while (pktlen > 0) {
|
|
|
|
if (top) {
|
|
|
|
MGET(m, M_DONTWAIT, MT_DATA);
|
|
|
|
if (m == 0) {
|
|
|
|
m_freem(top);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
len = MLEN;
|
|
|
|
}
|
|
|
|
if (pktlen >= MINCLSIZE) {
|
|
|
|
MCLGET(m, M_DONTWAIT);
|
|
|
|
if (m->m_flags & M_EXT)
|
|
|
|
len = MCLBYTES;
|
|
|
|
}
|
|
|
|
m->m_len = len = min(pktlen, len);
|
|
|
|
#ifdef USEPKTBUF
|
|
|
|
bcopy((caddr_t)b, mtod(m, caddr_t), len);
|
|
|
|
b += len;
|
|
|
|
#else /* USEPKTBUF */
|
|
|
|
buf = mtod(m, u_short *);
|
|
|
|
cnt = len / 2;
|
|
|
|
while (cnt--)
|
|
|
|
*buf++ = *data;
|
|
|
|
if (len & 1)
|
|
|
|
*buf = *data; /* XXX should be byte store */
|
|
|
|
#ifdef ESDEBUG
|
|
|
|
if (esdebug) {
|
|
|
|
buf = mtod(m, u_short *);
|
|
|
|
for (i = 0; i < len; ++i)
|
1996-10-13 07:05:43 +04:00
|
|
|
printf ("%02x%s", ((u_char *)buf)[i],
|
1995-02-13 03:27:08 +03:00
|
|
|
((i & 31) == 31) ? "\n" : "");
|
|
|
|
if (i & 31)
|
1996-10-13 07:05:43 +04:00
|
|
|
printf ("\n");
|
1995-02-13 03:27:08 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif /* USEPKTBUF */
|
|
|
|
pktlen -= len;
|
|
|
|
*mp = m;
|
|
|
|
mp = &m->m_next;
|
|
|
|
}
|
|
|
|
#ifndef USEPKTBUF
|
|
|
|
smc->b2.mmucr = MMUCR_REMRLS_RX;
|
|
|
|
while (smc->b2.mmucr & MMUCR_BUSY)
|
|
|
|
;
|
|
|
|
#endif
|
|
|
|
eh = mtod(top, struct ether_header *);
|
1995-08-18 19:27:29 +04:00
|
|
|
#if NBPFILTER > 0
|
|
|
|
/*
|
|
|
|
* Check if there's a BPF listener on this interface. If so, hand off
|
|
|
|
* the raw packet to bpf.
|
|
|
|
*/
|
1997-03-15 21:09:08 +03:00
|
|
|
if (ifp->if_bpf) {
|
|
|
|
bpf_mtap(ifp->if_bpf, top);
|
1995-08-18 19:27:29 +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.
|
|
|
|
*/
|
1997-03-15 21:09:08 +03:00
|
|
|
if ((sc->sc_ethercom.ec_if.if_flags & IFF_PROMISC) &&
|
1995-08-18 19:27:29 +04:00
|
|
|
(eh->ether_dhost[0] & 1) == 0 && /* !mcast and !bcast */
|
1997-03-15 21:09:08 +03:00
|
|
|
bcmp(eh->ether_dhost, LLADDR(ifp->if_sadl),
|
1995-08-18 19:27:29 +04:00
|
|
|
sizeof(eh->ether_dhost)) != 0) {
|
|
|
|
m_freem(top);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
1995-02-13 03:27:08 +03:00
|
|
|
top->m_pkthdr.len -= sizeof (*eh);
|
|
|
|
top->m_len -= sizeof (*eh);
|
|
|
|
top->m_data += sizeof (*eh);
|
|
|
|
|
|
|
|
ether_input(ifp, eh, top);
|
1995-08-18 19:27:29 +04:00
|
|
|
#ifdef ESDEBUG
|
|
|
|
if (--sc->sc_smcbusy) {
|
1996-10-13 07:05:43 +04:00
|
|
|
printf("%s: esintr busy on exit\n", sc->sc_dev.dv_xname);
|
1995-08-18 19:27:29 +04:00
|
|
|
panic("esintr busy on exit");
|
|
|
|
}
|
|
|
|
#endif
|
1995-02-13 03:27:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1995-04-11 09:58:58 +04:00
|
|
|
estint(sc)
|
1995-02-13 03:27:08 +03:00
|
|
|
struct es_softc *sc;
|
|
|
|
{
|
1995-04-11 09:58:58 +04:00
|
|
|
|
1997-03-15 21:09:08 +03:00
|
|
|
esstart(&sc->sc_ethercom.ec_if);
|
1995-02-13 03:27:08 +03:00
|
|
|
}
|
|
|
|
|
1995-04-11 09:58:58 +04:00
|
|
|
void
|
1995-02-13 03:27:08 +03:00
|
|
|
esstart(ifp)
|
|
|
|
struct ifnet *ifp;
|
|
|
|
{
|
1996-05-07 04:46:37 +04:00
|
|
|
struct es_softc *sc = ifp->if_softc;
|
1995-02-13 03:27:08 +03:00
|
|
|
union smcregs *smc = sc->sc_base;
|
|
|
|
struct mbuf *m0, *m;
|
|
|
|
#ifdef USEPKTBUF
|
1995-04-11 09:58:58 +04:00
|
|
|
u_short pktbuf[ETHERMTU + 2];
|
1995-08-18 19:27:29 +04:00
|
|
|
#else
|
|
|
|
u_short oddbyte, needbyte;
|
1995-02-13 03:27:08 +03:00
|
|
|
#endif
|
|
|
|
u_short pktctlw, pktlen;
|
|
|
|
u_short *buf;
|
|
|
|
volatile u_short *data;
|
1996-04-22 01:10:48 +04:00
|
|
|
#if 0
|
1995-02-13 03:27:08 +03:00
|
|
|
u_long *lbuf;
|
|
|
|
volatile u_long *ldata;
|
1996-04-22 01:10:48 +04:00
|
|
|
#endif
|
1995-02-13 03:27:08 +03:00
|
|
|
short cnt;
|
|
|
|
int i;
|
1995-08-18 19:27:29 +04:00
|
|
|
u_char active_pnr;
|
1995-02-13 03:27:08 +03:00
|
|
|
|
1997-03-15 21:09:08 +03:00
|
|
|
if ((sc->sc_ethercom.ec_if.if_flags & (IFF_RUNNING | IFF_OACTIVE)) !=
|
1995-02-13 03:27:08 +03:00
|
|
|
IFF_RUNNING)
|
|
|
|
return;
|
|
|
|
|
1995-08-18 19:27:29 +04:00
|
|
|
#ifdef ESDEBUG
|
|
|
|
if (sc->sc_smcbusy++) {
|
1996-10-13 07:05:43 +04:00
|
|
|
printf("%s: esstart re-entered\n", sc->sc_dev.dv_xname);
|
1995-08-18 19:27:29 +04:00
|
|
|
panic("esstart re-entred");
|
|
|
|
}
|
1996-05-01 19:55:28 +04:00
|
|
|
while ((smc->b2.bsr & BSR_MASK) != BSR_BANK2) {
|
1996-10-13 07:05:43 +04:00
|
|
|
printf("%s: esstart BSR not 2: %04x\n", sc->sc_dev.dv_xname,
|
1995-08-18 19:27:29 +04:00
|
|
|
smc->b2.bsr);
|
|
|
|
smc->b2.bsr = BSR_BANK2;
|
|
|
|
}
|
|
|
|
#endif
|
1995-02-13 03:27:08 +03:00
|
|
|
for (;;) {
|
1996-05-01 19:55:28 +04:00
|
|
|
#ifdef ESDEBUG
|
|
|
|
u_short start_ptr, end_ptr;
|
|
|
|
#endif
|
1995-02-13 03:27:08 +03:00
|
|
|
/*
|
|
|
|
* Sneak a peek at the next packet to get the length
|
|
|
|
* and see if the SMC 91C90 can accept it.
|
|
|
|
*/
|
1997-03-15 21:09:08 +03:00
|
|
|
m = sc->sc_ethercom.ec_if.if_snd.ifq_head;
|
1995-02-13 03:27:08 +03:00
|
|
|
if (!m)
|
|
|
|
break;
|
|
|
|
#ifdef ESDEBUG
|
1996-05-01 19:55:28 +04:00
|
|
|
if (esdebug && (m->m_next || m->m_len & 1))
|
1996-10-13 07:05:43 +04:00
|
|
|
printf("%s: esstart m_next %p m_len %d\n",
|
1996-05-01 19:55:28 +04:00
|
|
|
sc->sc_dev.dv_xname, m->m_next, m->m_len);
|
1995-02-13 03:27:08 +03:00
|
|
|
#endif
|
|
|
|
for (m0 = m, pktlen = 0; m0; m0 = m0->m_next)
|
|
|
|
pktlen += m0->m_len;
|
|
|
|
pktctlw = 0;
|
|
|
|
pktlen += 4;
|
|
|
|
if (pktlen & 1)
|
|
|
|
++pktlen; /* control byte after last byte */
|
|
|
|
else
|
|
|
|
pktlen += 2; /* control byte after pad byte */
|
|
|
|
smc->b2.mmucr = MMUCR_ALLOC | (pktlen & 0x0700);
|
|
|
|
for (i = 0; i <= 5; ++i)
|
|
|
|
if ((smc->b2.arr & ARR_FAILED) == 0)
|
|
|
|
break;
|
|
|
|
if (smc->b2.arr & ARR_FAILED) {
|
1997-03-15 21:09:08 +03:00
|
|
|
sc->sc_ethercom.ec_if.if_flags |= IFF_OACTIVE;
|
1995-04-03 00:38:09 +04:00
|
|
|
sc->sc_intctl |= MSK_ALLOC;
|
1995-02-13 03:27:08 +03:00
|
|
|
break;
|
|
|
|
}
|
1995-08-18 19:27:29 +04:00
|
|
|
active_pnr = smc->b2.pnr = smc->b2.arr;
|
1995-02-13 03:27:08 +03:00
|
|
|
|
1995-08-18 19:27:29 +04:00
|
|
|
#ifdef ESDEBUG
|
1996-05-01 19:55:28 +04:00
|
|
|
while ((smc->b2.bsr & BSR_MASK) != BSR_BANK2) {
|
1996-10-13 07:05:43 +04:00
|
|
|
printf("%s: esstart+ BSR not 2: %04x\n", sc->sc_dev.dv_xname,
|
1995-08-18 19:27:29 +04:00
|
|
|
smc->b2.bsr);
|
|
|
|
smc->b2.bsr = BSR_BANK2;
|
|
|
|
}
|
|
|
|
#endif
|
1997-03-15 21:09:08 +03:00
|
|
|
IF_DEQUEUE(&sc->sc_ethercom.ec_if.if_snd, m);
|
1995-02-13 03:27:08 +03:00
|
|
|
smc->b2.ptr = PTR_AUTOINCR;
|
|
|
|
(void) smc->b2.mmucr;
|
|
|
|
data = (u_short *)&smc->b2.data;
|
1995-04-11 09:58:58 +04:00
|
|
|
*data = SWAP(pktctlw);
|
|
|
|
*data = SWAP(pktlen);
|
1995-08-18 19:27:29 +04:00
|
|
|
#ifdef ESDEBUG
|
1996-05-01 19:55:28 +04:00
|
|
|
while ((smc->b2.bsr & BSR_MASK) != BSR_BANK2) {
|
1996-10-13 07:05:43 +04:00
|
|
|
printf("%s: esstart++ BSR not 2: %04x\n", sc->sc_dev.dv_xname,
|
1995-08-18 19:27:29 +04:00
|
|
|
smc->b2.bsr);
|
|
|
|
smc->b2.bsr = BSR_BANK2;
|
|
|
|
}
|
|
|
|
#endif
|
1995-02-13 03:27:08 +03:00
|
|
|
#ifdef USEPKTBUF
|
|
|
|
i = 0;
|
|
|
|
for (m0 = m; m; m = m->m_next) {
|
|
|
|
bcopy(mtod(m, caddr_t), (char *)pktbuf + i, m->m_len);
|
|
|
|
i += m->m_len;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i & 1) /* Figure out where to put control byte */
|
|
|
|
pktbuf[i/2] = (pktbuf[i/2] & 0xff00) | CTLB_ODD;
|
|
|
|
else
|
|
|
|
pktbuf[i/2] = 0;
|
1995-08-18 19:27:29 +04:00
|
|
|
pktlen -= 4;
|
1995-02-13 03:27:08 +03:00
|
|
|
#ifdef ESDEBUG
|
1996-05-01 19:55:28 +04:00
|
|
|
if (pktlen > sizeof(pktbuf) && i > (sizeof(pktbuf) * 2))
|
1996-10-13 07:05:43 +04:00
|
|
|
printf("%s: esstart packet longer than pktbuf\n",
|
1995-08-18 19:27:29 +04:00
|
|
|
sc->sc_dev.dv_xname);
|
1995-02-13 03:27:08 +03:00
|
|
|
#endif
|
|
|
|
#if 0 /* doesn't quite work? */
|
|
|
|
lbuf = (u_long *)(pktbuf);
|
|
|
|
ldata = (u_long *)data;
|
|
|
|
cnt = pktlen / 4;
|
|
|
|
while(cnt--)
|
|
|
|
*ldata = *lbuf++;
|
|
|
|
if (pktlen & 2) {
|
|
|
|
buf = (u_short *)lbuf;
|
|
|
|
*data = *buf;
|
|
|
|
}
|
|
|
|
#else
|
1996-05-01 19:55:28 +04:00
|
|
|
#ifdef ESDEBUG
|
|
|
|
while ((smc->b2.bsr & BSR_MASK) != BSR_BANK2) {
|
1996-10-13 07:05:43 +04:00
|
|
|
printf("%s: esstart++2 BSR not 2: %04x\n", sc->sc_dev.dv_xname,
|
1996-05-01 19:55:28 +04:00
|
|
|
smc->b2.bsr);
|
|
|
|
smc->b2.bsr = BSR_BANK2;
|
|
|
|
}
|
|
|
|
start_ptr = SWAP(smc->b2.ptr); /* save PTR before copy */
|
|
|
|
#endif
|
1995-02-13 03:27:08 +03:00
|
|
|
buf = pktbuf;
|
|
|
|
cnt = pktlen / 2;
|
|
|
|
while (cnt--)
|
|
|
|
*data = *buf++;
|
1996-05-01 19:55:28 +04:00
|
|
|
#ifdef ESDEBUG
|
|
|
|
end_ptr = SWAP(smc->b2.ptr); /* save PTR after copy */
|
|
|
|
#endif
|
1995-02-13 03:27:08 +03:00
|
|
|
#endif
|
|
|
|
#else /* USEPKTBUF */
|
|
|
|
pktctlw = 0;
|
1995-08-18 19:27:29 +04:00
|
|
|
oddbyte = needbyte = 0;
|
1995-02-13 03:27:08 +03:00
|
|
|
for (m0 = m; m; m = m->m_next) {
|
|
|
|
buf = mtod(m, u_short *);
|
|
|
|
cnt = m->m_len / 2;
|
1995-08-18 19:27:29 +04:00
|
|
|
if (needbyte) {
|
|
|
|
oddbyte |= *buf >> 8;
|
|
|
|
*data = oddbyte;
|
|
|
|
}
|
1995-02-13 03:27:08 +03:00
|
|
|
while (cnt--)
|
|
|
|
*data = *buf++;
|
|
|
|
if (m->m_len & 1)
|
|
|
|
pktctlw = (*buf & 0xff00) | CTLB_ODD;
|
1995-08-18 19:27:29 +04:00
|
|
|
if (m->m_len & 1 && m->m_next)
|
1996-10-13 07:05:43 +04:00
|
|
|
printf("%s: esstart odd byte count in mbuf\n",
|
1995-08-18 19:27:29 +04:00
|
|
|
sc->sc_dev.dv_xname);
|
1995-02-13 03:27:08 +03:00
|
|
|
}
|
|
|
|
*data = pktctlw;
|
|
|
|
#endif /* USEPKTBUF */
|
1996-05-01 19:55:28 +04:00
|
|
|
while ((smc->b2.bsr & BSR_MASK) != BSR_BANK2) {
|
|
|
|
/*
|
|
|
|
* The bank select register has changed. This seems
|
|
|
|
* to happen with my A2000/Zeus once in a while. It
|
|
|
|
* appears that the Ethernet chip resets while
|
|
|
|
* copying the transmit buffer. Requeue the current
|
|
|
|
* transmit buffer and reinitialize the interface.
|
|
|
|
* The initialize routine will take care of
|
|
|
|
* retransmitting the buffer. mhitch
|
|
|
|
*/
|
|
|
|
#ifdef DIAGNOSTIC
|
1996-10-13 07:05:43 +04:00
|
|
|
printf("%s: esstart+++ BSR not 2: %04x\n",
|
1996-05-01 19:55:28 +04:00
|
|
|
sc->sc_dev.dv_xname, smc->b2.bsr);
|
|
|
|
#endif
|
1995-08-18 19:27:29 +04:00
|
|
|
smc->b2.bsr = BSR_BANK2;
|
1996-05-01 19:55:28 +04:00
|
|
|
#ifdef ESDEBUG
|
1996-10-13 07:05:43 +04:00
|
|
|
printf("start_ptr %04x end_ptr %04x cur ptr %04x\n",
|
1996-05-01 19:55:28 +04:00
|
|
|
start_ptr, end_ptr, SWAP(smc->b2.ptr));
|
|
|
|
--sc->sc_smcbusy;
|
1995-02-13 03:27:08 +03:00
|
|
|
#endif
|
1997-03-15 21:09:08 +03:00
|
|
|
IF_PREPEND(&sc->sc_ethercom.ec_if.if_snd, m0);
|
1996-05-01 19:55:28 +04:00
|
|
|
esinit(sc); /* It's really hosed - reset */
|
|
|
|
return;
|
|
|
|
}
|
1995-08-18 19:27:29 +04:00
|
|
|
smc->b2.mmucr = MMUCR_ENQ_TX;
|
|
|
|
if (smc->b2.pnr != active_pnr)
|
1996-10-13 07:05:43 +04:00
|
|
|
printf("%s: esstart - PNR changed %x->%x\n",
|
1995-08-18 19:27:29 +04:00
|
|
|
sc->sc_dev.dv_xname, active_pnr, smc->b2.pnr);
|
1995-02-13 03:27:08 +03:00
|
|
|
#if NBPFILTER > 0
|
1997-03-15 21:09:08 +03:00
|
|
|
if (sc->sc_ethercom.ec_if.if_bpf)
|
|
|
|
bpf_mtap(sc->sc_ethercom.ec_if.if_bpf, m0);
|
1995-02-13 03:27:08 +03:00
|
|
|
#endif
|
|
|
|
m_freem(m0);
|
1997-03-15 21:09:08 +03:00
|
|
|
sc->sc_ethercom.ec_if.if_opackets++; /* move to interrupt? */
|
1995-04-03 00:38:09 +04:00
|
|
|
sc->sc_intctl |= MSK_TX_EMPTY | MSK_TX;
|
1995-02-13 03:27:08 +03:00
|
|
|
}
|
|
|
|
smc->b2.msk = sc->sc_intctl;
|
1995-08-18 19:27:29 +04:00
|
|
|
#ifdef ESDEBUG
|
1996-05-01 19:55:28 +04:00
|
|
|
while ((smc->b2.bsr & BSR_MASK) != BSR_BANK2) {
|
1996-10-13 07:05:43 +04:00
|
|
|
printf("%s: esstart++++ BSR not 2: %04x\n", sc->sc_dev.dv_xname,
|
1995-08-18 19:27:29 +04:00
|
|
|
smc->b2.bsr);
|
|
|
|
smc->b2.bsr = BSR_BANK2;
|
|
|
|
}
|
|
|
|
if (--sc->sc_smcbusy) {
|
1996-10-13 07:05:43 +04:00
|
|
|
printf("%s: esstart busy on exit\n", sc->sc_dev.dv_xname);
|
1995-08-18 19:27:29 +04:00
|
|
|
panic("esstart busy on exit");
|
|
|
|
}
|
|
|
|
#endif
|
1995-02-13 03:27:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1995-04-11 09:58:58 +04:00
|
|
|
esioctl(ifp, command, data)
|
|
|
|
register struct ifnet *ifp;
|
|
|
|
u_long command;
|
1995-02-13 03:27:08 +03:00
|
|
|
caddr_t data;
|
|
|
|
{
|
1996-05-07 04:46:37 +04:00
|
|
|
struct es_softc *sc = ifp->if_softc;
|
1995-04-11 09:58:58 +04:00
|
|
|
register struct ifaddr *ifa = (struct ifaddr *)data;
|
1995-02-13 03:27:08 +03:00
|
|
|
struct ifreq *ifr = (struct ifreq *)data;
|
|
|
|
int s, error = 0;
|
|
|
|
|
1995-12-24 05:29:35 +03:00
|
|
|
s = splnet();
|
1995-02-13 03:27:08 +03:00
|
|
|
|
1995-04-11 09:58:58 +04:00
|
|
|
switch (command) {
|
|
|
|
|
1995-02-13 03:27:08 +03:00
|
|
|
case SIOCSIFADDR:
|
|
|
|
ifp->if_flags |= IFF_UP;
|
|
|
|
|
|
|
|
switch (ifa->ifa_addr->sa_family) {
|
|
|
|
#ifdef INET
|
|
|
|
case AF_INET:
|
|
|
|
esinit(sc);
|
1997-03-15 21:09:08 +03:00
|
|
|
arp_ifinit(ifp, ifa);
|
1995-02-13 03:27:08 +03:00
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
#ifdef NS
|
|
|
|
case AF_NS:
|
|
|
|
{
|
|
|
|
register struct ns_addr *ina = &IA_SNS(ifa)->sns_addr;
|
|
|
|
|
|
|
|
if (ns_nullhost(*ina))
|
|
|
|
ina->x_host =
|
1997-03-15 21:09:08 +03:00
|
|
|
*(union ns_host *)LLADDR(ifp->if_sadl);
|
1995-02-13 03:27:08 +03:00
|
|
|
else
|
|
|
|
bcopy(ina->x_host.c_host,
|
1997-03-15 21:09:08 +03:00
|
|
|
LLADDR(ifp->if_sadl), ETHER_ADDR_LEN);
|
1995-04-11 09:58:58 +04:00
|
|
|
/* Set new address. */
|
1995-02-13 03:27:08 +03:00
|
|
|
esinit(sc);
|
|
|
|
break;
|
1996-04-22 01:10:48 +04:00
|
|
|
}
|
1995-02-13 03:27:08 +03:00
|
|
|
#endif
|
|
|
|
default:
|
|
|
|
esinit(sc);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
1995-04-11 09:58:58 +04:00
|
|
|
|
1995-02-13 03:27:08 +03:00
|
|
|
case SIOCSIFFLAGS:
|
|
|
|
/*
|
|
|
|
* If interface is marked down and it is running, then stop it
|
|
|
|
*/
|
|
|
|
if ((ifp->if_flags & IFF_UP) == 0 &&
|
|
|
|
(ifp->if_flags & IFF_RUNNING) != 0) {
|
|
|
|
/*
|
|
|
|
* If interface is marked down and it is running, then
|
|
|
|
* stop it.
|
|
|
|
*/
|
1995-04-11 09:58:58 +04:00
|
|
|
esstop(sc);
|
1995-02-13 03:27:08 +03:00
|
|
|
ifp->if_flags &= ~IFF_RUNNING;
|
|
|
|
} else if ((ifp->if_flags & IFF_UP) != 0 &&
|
|
|
|
(ifp->if_flags & IFF_RUNNING) == 0) {
|
|
|
|
/*
|
|
|
|
* If interface is marked up and it is stopped, then
|
|
|
|
* start it.
|
|
|
|
*/
|
|
|
|
esinit(sc);
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Reset the interface to pick up changes in any other
|
|
|
|
* flags that affect hardware registers.
|
|
|
|
*/
|
1995-04-11 09:58:58 +04:00
|
|
|
esstop(sc);
|
1995-02-13 03:27:08 +03:00
|
|
|
esinit(sc);
|
|
|
|
}
|
|
|
|
#ifdef ESDEBUG
|
|
|
|
if (ifp->if_flags & IFF_DEBUG)
|
|
|
|
esdebug = sc->sc_debug = 1;
|
|
|
|
else
|
|
|
|
esdebug = sc->sc_debug = 0;
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
|
1995-08-18 19:27:29 +04:00
|
|
|
case SIOCADDMULTI:
|
|
|
|
case SIOCDELMULTI:
|
|
|
|
error = (command == SIOCADDMULTI) ?
|
1997-03-15 21:09:08 +03:00
|
|
|
ether_addmulti(ifr, &sc->sc_ethercom) :
|
|
|
|
ether_delmulti(ifr, &sc->sc_ethercom);
|
1995-08-18 19:27:29 +04:00
|
|
|
|
|
|
|
if (error == ENETRESET) {
|
|
|
|
/*
|
|
|
|
* Multicast list has changed; set the hardware filter
|
|
|
|
* accordingly.
|
|
|
|
*/
|
|
|
|
/* XXX */
|
|
|
|
error = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1995-02-13 03:27:08 +03:00
|
|
|
default:
|
|
|
|
error = EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
splx(s);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
esreset(sc)
|
|
|
|
struct es_softc *sc;
|
|
|
|
{
|
|
|
|
int s;
|
|
|
|
|
1995-12-24 05:29:35 +03:00
|
|
|
s = splnet();
|
1995-04-11 09:58:58 +04:00
|
|
|
esstop(sc);
|
1995-02-13 03:27:08 +03:00
|
|
|
esinit(sc);
|
|
|
|
splx(s);
|
|
|
|
}
|
|
|
|
|
1995-04-11 09:58:58 +04:00
|
|
|
void
|
1996-05-07 04:46:37 +04:00
|
|
|
eswatchdog(ifp)
|
|
|
|
struct ifnet *ifp;
|
1995-02-13 03:27:08 +03:00
|
|
|
{
|
1996-05-07 04:46:37 +04:00
|
|
|
struct es_softc *sc = ifp->if_softc;
|
1995-02-13 03:27:08 +03:00
|
|
|
|
|
|
|
log(LOG_ERR, "%s: device timeout\n", sc->sc_dev.dv_xname);
|
1997-03-15 21:09:08 +03:00
|
|
|
++ifp->if_oerrors;
|
1995-04-11 09:58:58 +04:00
|
|
|
|
1995-02-13 03:27:08 +03:00
|
|
|
esreset(sc);
|
|
|
|
}
|