1994-04-07 12:10:31 +00:00
|
|
|
/* Copyright (c) 1994, Matthew E. Kimmel. Permission is hereby granted
|
|
|
|
* to use, copy, modify and distribute this software provided that both
|
|
|
|
* the copyright notice and this permission notice appear in all copies
|
|
|
|
* of the software, derivative works or modified versions, and any
|
|
|
|
* portions thereof.
|
|
|
|
*
|
|
|
|
* Questions, comments, bug reports and fixes to kimmel@cs.umass.edu.
|
|
|
|
*/
|
2003-06-02 16:32:55 +00:00
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
1994-04-07 12:10:31 +00:00
|
|
|
/* Except of course for the portions of code lifted from other FreeBSD
|
|
|
|
* drivers (mainly elread, elget and el_ioctl)
|
|
|
|
*/
|
|
|
|
/* 3COM Etherlink 3C501 device driver for FreeBSD */
|
|
|
|
/* Yeah, I know these cards suck, but you can also get them for free
|
|
|
|
* really easily...
|
|
|
|
*/
|
|
|
|
/* Bugs/possible improvements:
|
|
|
|
* - Does not currently support DMA
|
|
|
|
* - Does not currently support multicasts
|
|
|
|
*/
|
1998-01-08 23:42:31 +00:00
|
|
|
#include "opt_inet.h"
|
1997-12-15 20:31:25 +00:00
|
|
|
#include "opt_ipx.h"
|
1994-04-07 12:10:31 +00:00
|
|
|
|
1994-08-13 03:50:34 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
2000-05-28 13:40:48 +00:00
|
|
|
#include <sys/kernel.h>
|
1997-03-24 11:33:46 +00:00
|
|
|
#include <sys/sockio.h>
|
1994-08-13 03:50:34 +00:00
|
|
|
#include <sys/mbuf.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/syslog.h>
|
2000-05-28 13:40:48 +00:00
|
|
|
#include <sys/bus.h>
|
1994-04-07 12:10:31 +00:00
|
|
|
|
1999-08-18 22:14:24 +00:00
|
|
|
#include <net/ethernet.h>
|
1994-08-13 03:50:34 +00:00
|
|
|
#include <net/if.h>
|
1994-04-07 12:10:31 +00:00
|
|
|
|
1999-08-18 22:14:24 +00:00
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <netinet/if_ether.h>
|
|
|
|
|
1994-08-13 03:50:34 +00:00
|
|
|
#include <net/bpf.h>
|
1994-04-07 12:10:31 +00:00
|
|
|
|
2000-12-15 20:09:10 +00:00
|
|
|
#include <machine/bus_pio.h>
|
|
|
|
#include <machine/bus.h>
|
|
|
|
#include <machine/resource.h>
|
|
|
|
#include <sys/bus.h>
|
|
|
|
#include <sys/rman.h>
|
1995-03-28 07:58:53 +00:00
|
|
|
|
2000-12-15 20:09:10 +00:00
|
|
|
#include <isa/isavar.h>
|
1994-04-07 12:10:31 +00:00
|
|
|
|
2000-12-15 20:09:10 +00:00
|
|
|
#include <i386/isa/if_elreg.h>
|
2000-05-28 13:40:48 +00:00
|
|
|
|
1994-04-07 12:10:31 +00:00
|
|
|
/* For debugging convenience */
|
|
|
|
#ifdef EL_DEBUG
|
|
|
|
#define dprintf(x) printf x
|
|
|
|
#else
|
|
|
|
#define dprintf(x)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* el_softc: per line info and status */
|
2000-12-15 20:09:10 +00:00
|
|
|
struct el_softc {
|
1994-04-07 12:10:31 +00:00
|
|
|
struct arpcom arpcom; /* Ethernet common */
|
2000-12-15 20:09:10 +00:00
|
|
|
bus_space_handle_t el_bhandle;
|
|
|
|
bus_space_tag_t el_btag;
|
|
|
|
void *el_intrhand;
|
|
|
|
struct resource *el_irq;
|
|
|
|
struct resource *el_res;
|
|
|
|
struct mtx el_mtx;
|
1994-04-07 12:10:31 +00:00
|
|
|
char el_pktbuf[EL_BUFSIZ]; /* Frame buffer */
|
2000-12-15 20:09:10 +00:00
|
|
|
};
|
1994-04-07 12:10:31 +00:00
|
|
|
|
|
|
|
/* Prototypes */
|
2000-12-15 20:09:10 +00:00
|
|
|
static int el_attach(device_t);
|
|
|
|
static int el_detach(device_t);
|
1999-08-20 14:12:14 +00:00
|
|
|
static void el_init(void *);
|
1998-06-07 17:13:14 +00:00
|
|
|
static int el_ioctl(struct ifnet *,u_long,caddr_t);
|
2000-12-15 20:09:10 +00:00
|
|
|
static int el_probe(device_t);
|
1995-12-10 13:40:44 +00:00
|
|
|
static void el_start(struct ifnet *);
|
1999-08-20 14:12:14 +00:00
|
|
|
static void el_reset(void *);
|
1995-12-10 13:40:44 +00:00
|
|
|
static void el_watchdog(struct ifnet *);
|
2000-12-15 20:09:10 +00:00
|
|
|
static int el_shutdown(device_t);
|
1994-04-07 12:10:31 +00:00
|
|
|
|
1999-08-20 14:12:14 +00:00
|
|
|
static void el_stop(void *);
|
1994-04-07 12:10:31 +00:00
|
|
|
static int el_xmit(struct el_softc *,int);
|
2000-12-15 20:09:10 +00:00
|
|
|
static void elintr(void *);
|
1998-04-15 17:47:40 +00:00
|
|
|
static __inline void elread(struct el_softc *,caddr_t,int);
|
2000-05-14 02:18:43 +00:00
|
|
|
static struct mbuf *elget(caddr_t,int,struct ifnet *);
|
1999-08-20 14:12:14 +00:00
|
|
|
static __inline void el_hardreset(void *);
|
1994-04-07 12:10:31 +00:00
|
|
|
|
2000-12-15 20:09:10 +00:00
|
|
|
static device_method_t el_methods[] = {
|
|
|
|
/* Device interface */
|
|
|
|
DEVMETHOD(device_probe, el_probe),
|
|
|
|
DEVMETHOD(device_attach, el_attach),
|
|
|
|
DEVMETHOD(device_detach, el_detach),
|
|
|
|
DEVMETHOD(device_shutdown, el_shutdown),
|
|
|
|
{ 0, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static driver_t el_driver = {
|
|
|
|
"el",
|
|
|
|
el_methods,
|
|
|
|
sizeof(struct el_softc)
|
1994-04-07 12:10:31 +00:00
|
|
|
};
|
2000-12-15 20:09:10 +00:00
|
|
|
|
|
|
|
static devclass_t el_devclass;
|
|
|
|
|
|
|
|
DRIVER_MODULE(if_el, isa, el_driver, el_devclass, 0, 0);
|
|
|
|
|
|
|
|
#define CSR_WRITE_1(sc, reg, val) \
|
|
|
|
bus_space_write_1(sc->el_btag, sc->el_bhandle, reg, val)
|
|
|
|
#define CSR_READ_1(sc, reg) \
|
|
|
|
bus_space_read_1(sc->el_btag, sc->el_bhandle, reg)
|
|
|
|
|
Change and clean the mutex lock interface.
mtx_enter(lock, type) becomes:
mtx_lock(lock) for sleep locks (MTX_DEF-initialized locks)
mtx_lock_spin(lock) for spin locks (MTX_SPIN-initialized)
similarily, for releasing a lock, we now have:
mtx_unlock(lock) for MTX_DEF and mtx_unlock_spin(lock) for MTX_SPIN.
We change the caller interface for the two different types of locks
because the semantics are entirely different for each case, and this
makes it explicitly clear and, at the same time, it rids us of the
extra `type' argument.
The enter->lock and exit->unlock change has been made with the idea
that we're "locking data" and not "entering locked code" in mind.
Further, remove all additional "flags" previously passed to the
lock acquire/release routines with the exception of two:
MTX_QUIET and MTX_NOSWITCH
The functionality of these flags is preserved and they can be passed
to the lock/unlock routines by calling the corresponding wrappers:
mtx_{lock, unlock}_flags(lock, flag(s)) and
mtx_{lock, unlock}_spin_flags(lock, flag(s)) for MTX_DEF and MTX_SPIN
locks, respectively.
Re-inline some lock acq/rel code; in the sleep lock case, we only
inline the _obtain_lock()s in order to ensure that the inlined code
fits into a cache line. In the spin lock case, we inline recursion and
actually only perform a function call if we need to spin. This change
has been made with the idea that we generally tend to avoid spin locks
and that also the spin locks that we do have and are heavily used
(i.e. sched_lock) do recurse, and therefore in an effort to reduce
function call overhead for some architectures (such as alpha), we
inline recursion for this case.
Create a new malloc type for the witness code and retire from using
the M_DEV type. The new type is called M_WITNESS and is only declared
if WITNESS is enabled.
Begin cleaning up some machdep/mutex.h code - specifically updated the
"optimized" inlined code in alpha/mutex.h and wrote MTX_LOCK_SPIN
and MTX_UNLOCK_SPIN asm macros for the i386/mutex.h as we presently
need those.
Finally, caught up to the interface changes in all sys code.
Contributors: jake, jhb, jasone (in no particular order)
2001-02-09 06:11:45 +00:00
|
|
|
#define EL_LOCK(_sc) mtx_lock(&(_sc)->el_mtx)
|
|
|
|
#define EL_UNLOCK(_sc) mtx_unlock(&(_sc)->el_mtx)
|
1994-04-07 12:10:31 +00:00
|
|
|
|
|
|
|
/* Probe routine. See if the card is there and at the right place. */
|
1995-12-10 13:40:44 +00:00
|
|
|
static int
|
2000-12-15 20:09:10 +00:00
|
|
|
el_probe(device_t dev)
|
1994-04-07 12:10:31 +00:00
|
|
|
{
|
|
|
|
struct el_softc *sc;
|
|
|
|
u_short base; /* Just for convenience */
|
|
|
|
u_char station_addr[ETHER_ADDR_LEN];
|
2000-12-15 20:09:10 +00:00
|
|
|
int i, rid;
|
1994-04-07 12:10:31 +00:00
|
|
|
|
|
|
|
/* Grab some info for our structure */
|
2000-12-15 20:09:10 +00:00
|
|
|
sc = device_get_softc(dev);
|
|
|
|
|
|
|
|
if (isa_get_logicalid(dev)) /* skip PnP probes */
|
|
|
|
return (ENXIO);
|
|
|
|
|
|
|
|
if ((base = bus_get_resource_start(dev, SYS_RES_IOPORT, 0)) == 0)
|
|
|
|
return (ENXIO);
|
1994-04-07 12:10:31 +00:00
|
|
|
|
|
|
|
/* First check the base */
|
|
|
|
if((base < 0x280) || (base > 0x3f0)) {
|
2000-12-15 20:09:10 +00:00
|
|
|
device_printf(dev,
|
|
|
|
"ioaddr must be between 0x280 and 0x3f0\n");
|
|
|
|
return(ENXIO);
|
1994-04-07 12:10:31 +00:00
|
|
|
}
|
|
|
|
|
2000-12-15 20:09:10 +00:00
|
|
|
/* Temporarily map the resources. */
|
|
|
|
rid = 0;
|
|
|
|
sc->el_res = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
|
|
|
|
0, ~0, EL_IOSIZ, RF_ACTIVE);
|
|
|
|
|
|
|
|
if (sc->el_res == NULL)
|
|
|
|
return(ENXIO);
|
|
|
|
|
|
|
|
sc->el_btag = rman_get_bustag(sc->el_res);
|
|
|
|
sc->el_bhandle = rman_get_bushandle(sc->el_res);
|
2002-04-04 21:03:38 +00:00
|
|
|
mtx_init(&sc->el_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK,
|
|
|
|
MTX_DEF | MTX_RECURSE);
|
2000-12-15 20:09:10 +00:00
|
|
|
EL_LOCK(sc);
|
|
|
|
|
1994-04-07 12:10:31 +00:00
|
|
|
/* Now attempt to grab the station address from the PROM
|
|
|
|
* and see if it contains the 3com vendor code.
|
|
|
|
*/
|
|
|
|
dprintf(("Probing 3c501 at 0x%x...\n",base));
|
|
|
|
|
|
|
|
/* Reset the board */
|
|
|
|
dprintf(("Resetting board...\n"));
|
2000-12-15 20:09:10 +00:00
|
|
|
CSR_WRITE_1(sc,EL_AC,EL_AC_RESET);
|
1994-04-07 12:10:31 +00:00
|
|
|
DELAY(5);
|
2000-12-15 20:09:10 +00:00
|
|
|
CSR_WRITE_1(sc,EL_AC,0);
|
1994-04-07 12:10:31 +00:00
|
|
|
dprintf(("Reading station address...\n"));
|
|
|
|
/* Now read the address */
|
|
|
|
for(i=0;i<ETHER_ADDR_LEN;i++) {
|
2000-12-15 20:09:10 +00:00
|
|
|
CSR_WRITE_1(sc,EL_GPBL,i);
|
|
|
|
station_addr[i] = CSR_READ_1(sc,EL_EAW);
|
1994-04-07 12:10:31 +00:00
|
|
|
}
|
2000-12-15 20:09:10 +00:00
|
|
|
|
|
|
|
/* Now release resources */
|
|
|
|
bus_release_resource(dev, SYS_RES_IOPORT, rid, sc->el_res);
|
|
|
|
EL_UNLOCK(sc);
|
|
|
|
mtx_destroy(&sc->el_mtx);
|
|
|
|
|
1996-01-26 09:29:29 +00:00
|
|
|
dprintf(("Address is %6D\n",station_addr, ":"));
|
1994-04-07 12:10:31 +00:00
|
|
|
|
|
|
|
/* If the vendor code is ok, return a 1. We'll assume that
|
|
|
|
* whoever configured this system is right about the IRQ.
|
|
|
|
*/
|
|
|
|
if((station_addr[0] != 0x02) || (station_addr[1] != 0x60)
|
|
|
|
|| (station_addr[2] != 0x8c)) {
|
|
|
|
dprintf(("Bad vendor code.\n"));
|
2000-12-15 20:09:10 +00:00
|
|
|
return(ENXIO);
|
1994-04-07 12:10:31 +00:00
|
|
|
} else {
|
|
|
|
dprintf(("Vendor code ok.\n"));
|
|
|
|
/* Copy the station address into the arpcom structure */
|
|
|
|
bcopy(station_addr,sc->arpcom.ac_enaddr,ETHER_ADDR_LEN);
|
|
|
|
}
|
2000-12-15 20:09:10 +00:00
|
|
|
|
|
|
|
device_set_desc(dev, "3Com 3c501 Ethernet");
|
|
|
|
|
|
|
|
return(0);
|
1994-04-07 12:10:31 +00:00
|
|
|
}
|
|
|
|
|
1999-01-12 01:29:45 +00:00
|
|
|
/* Do a hardware reset of the 3c501. Do not call until after el_probe()! */
|
|
|
|
static __inline void
|
1999-08-20 14:12:14 +00:00
|
|
|
el_hardreset(xsc)
|
|
|
|
void *xsc;
|
1999-01-12 01:29:45 +00:00
|
|
|
{
|
1999-08-20 14:12:14 +00:00
|
|
|
register struct el_softc *sc = xsc;
|
1999-01-12 01:29:45 +00:00
|
|
|
register int j;
|
|
|
|
|
|
|
|
/* First reset the board */
|
2000-12-15 20:09:10 +00:00
|
|
|
CSR_WRITE_1(sc,EL_AC,EL_AC_RESET);
|
1999-01-12 01:29:45 +00:00
|
|
|
DELAY(5);
|
2000-12-15 20:09:10 +00:00
|
|
|
CSR_WRITE_1(sc,EL_AC,0);
|
1999-01-12 01:29:45 +00:00
|
|
|
|
|
|
|
/* Then give it back its ethernet address. Thanks to the mach
|
|
|
|
* source code for this undocumented goodie...
|
|
|
|
*/
|
|
|
|
for(j=0;j<ETHER_ADDR_LEN;j++)
|
2000-12-15 20:09:10 +00:00
|
|
|
CSR_WRITE_1(sc,j,sc->arpcom.ac_enaddr[j]);
|
1999-01-12 01:29:45 +00:00
|
|
|
}
|
|
|
|
|
1994-04-07 12:10:31 +00:00
|
|
|
/* Attach the interface to the kernel data structures. By the time
|
|
|
|
* this is called, we know that the card exists at the given I/O address.
|
|
|
|
* We still assume that the IRQ given is correct.
|
|
|
|
*/
|
1995-12-10 13:40:44 +00:00
|
|
|
static int
|
2000-12-15 20:09:10 +00:00
|
|
|
el_attach(device_t dev)
|
1994-04-07 12:10:31 +00:00
|
|
|
{
|
|
|
|
struct el_softc *sc;
|
|
|
|
struct ifnet *ifp;
|
2000-12-15 20:09:10 +00:00
|
|
|
int rid, error;
|
1994-04-07 12:10:31 +00:00
|
|
|
|
2000-12-15 20:09:10 +00:00
|
|
|
dprintf(("Attaching el%d...\n",device_get_unit(dev)));
|
1994-04-07 12:10:31 +00:00
|
|
|
|
|
|
|
/* Get things pointing to the right places. */
|
2000-12-15 20:09:10 +00:00
|
|
|
sc = device_get_softc(dev);
|
1994-04-07 12:10:31 +00:00
|
|
|
ifp = &sc->arpcom.ac_if;
|
2000-12-15 20:09:10 +00:00
|
|
|
|
|
|
|
rid = 0;
|
|
|
|
sc->el_res = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
|
|
|
|
0, ~0, EL_IOSIZ, RF_ACTIVE);
|
|
|
|
|
|
|
|
if (sc->el_res == NULL)
|
|
|
|
return(ENXIO);
|
|
|
|
|
|
|
|
rid = 0;
|
|
|
|
sc->el_irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0, ~0, 1,
|
|
|
|
RF_SHAREABLE | RF_ACTIVE);
|
|
|
|
|
|
|
|
if (sc->el_irq == NULL) {
|
|
|
|
bus_release_resource(dev, SYS_RES_IOPORT, 0, sc->el_res);
|
|
|
|
return(ENXIO);
|
|
|
|
}
|
|
|
|
|
|
|
|
error = bus_setup_intr(dev, sc->el_irq, INTR_TYPE_NET,
|
|
|
|
elintr, sc, &sc->el_intrhand);
|
|
|
|
|
|
|
|
if (error) {
|
|
|
|
bus_release_resource(dev, SYS_RES_IRQ, 0, sc->el_irq);
|
|
|
|
bus_release_resource(dev, SYS_RES_IOPORT, 0, sc->el_res);
|
|
|
|
return(ENXIO);
|
|
|
|
}
|
1994-04-07 12:10:31 +00:00
|
|
|
|
|
|
|
/* Now reset the board */
|
|
|
|
dprintf(("Resetting board...\n"));
|
1999-08-20 14:12:14 +00:00
|
|
|
el_hardreset(sc);
|
1994-04-07 12:10:31 +00:00
|
|
|
|
|
|
|
/* Initialize ifnet structure */
|
1996-02-06 18:51:28 +00:00
|
|
|
ifp->if_softc = sc;
|
2003-10-31 18:32:15 +00:00
|
|
|
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
|
1994-04-07 12:10:31 +00:00
|
|
|
ifp->if_mtu = ETHERMTU;
|
|
|
|
ifp->if_start = el_start;
|
|
|
|
ifp->if_ioctl = el_ioctl;
|
|
|
|
ifp->if_watchdog = el_watchdog;
|
1999-08-20 14:12:14 +00:00
|
|
|
ifp->if_init = el_init;
|
2000-12-15 20:09:10 +00:00
|
|
|
ifp->if_flags = (IFF_BROADCAST | IFF_MULTICAST | IFF_SIMPLEX);
|
|
|
|
ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
|
1994-04-07 12:10:31 +00:00
|
|
|
|
|
|
|
/* Now we can attach the interface */
|
|
|
|
dprintf(("Attaching interface...\n"));
|
2002-11-15 00:00:15 +00:00
|
|
|
ether_ifattach(ifp, sc->arpcom.ac_enaddr);
|
1994-04-07 12:10:31 +00:00
|
|
|
|
|
|
|
/* Print out some information for the user */
|
2000-12-15 20:09:10 +00:00
|
|
|
device_printf(dev, "3c501 address %6D\n",
|
1996-01-26 09:29:29 +00:00
|
|
|
sc->arpcom.ac_enaddr, ":");
|
1994-04-07 12:10:31 +00:00
|
|
|
|
|
|
|
dprintf(("el_attach() finished.\n"));
|
2000-12-15 20:09:10 +00:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int el_detach(dev)
|
|
|
|
device_t dev;
|
|
|
|
{
|
|
|
|
struct el_softc *sc;
|
|
|
|
struct ifnet *ifp;
|
|
|
|
|
|
|
|
sc = device_get_softc(dev);
|
|
|
|
ifp = &sc->arpcom.ac_if;
|
|
|
|
|
|
|
|
el_stop(sc);
|
|
|
|
EL_LOCK(sc);
|
2002-11-15 00:00:15 +00:00
|
|
|
ether_ifdetach(ifp);
|
2000-12-15 20:09:10 +00:00
|
|
|
bus_teardown_intr(dev, sc->el_irq, sc->el_intrhand);
|
|
|
|
bus_release_resource(dev, SYS_RES_IRQ, 0, sc->el_irq);
|
|
|
|
bus_release_resource(dev, SYS_RES_IOPORT, 0, sc->el_res);
|
|
|
|
EL_UNLOCK(sc);
|
|
|
|
mtx_destroy(&sc->el_mtx);
|
|
|
|
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
el_shutdown(dev)
|
|
|
|
device_t dev;
|
|
|
|
{
|
|
|
|
struct el_softc *sc;
|
|
|
|
|
|
|
|
sc = device_get_softc(dev);
|
|
|
|
el_stop(sc);
|
|
|
|
return(0);
|
1994-04-07 12:10:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* This routine resets the interface. */
|
1995-12-10 13:40:44 +00:00
|
|
|
static void
|
1999-08-20 14:12:14 +00:00
|
|
|
el_reset(xsc)
|
|
|
|
void *xsc;
|
1994-04-07 12:10:31 +00:00
|
|
|
{
|
1999-08-20 14:12:14 +00:00
|
|
|
struct el_softc *sc = xsc;
|
1994-04-07 12:10:31 +00:00
|
|
|
|
|
|
|
dprintf(("elreset()\n"));
|
1999-08-20 14:12:14 +00:00
|
|
|
el_stop(sc);
|
|
|
|
el_init(sc);
|
1994-04-07 12:10:31 +00:00
|
|
|
}
|
|
|
|
|
1999-08-20 14:12:14 +00:00
|
|
|
static void el_stop(xsc)
|
|
|
|
void *xsc;
|
1994-04-07 12:10:31 +00:00
|
|
|
{
|
1999-08-20 14:12:14 +00:00
|
|
|
struct el_softc *sc = xsc;
|
1994-04-07 12:10:31 +00:00
|
|
|
|
2000-12-15 20:09:10 +00:00
|
|
|
EL_LOCK(sc);
|
|
|
|
CSR_WRITE_1(sc,EL_AC,0);
|
|
|
|
el_hardreset(sc);
|
|
|
|
EL_UNLOCK(sc);
|
1994-04-07 12:10:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialize interface. */
|
1995-12-10 13:40:44 +00:00
|
|
|
static void
|
1999-08-20 14:36:40 +00:00
|
|
|
el_init(xsc)
|
1999-08-20 14:12:14 +00:00
|
|
|
void *xsc;
|
1994-04-07 12:10:31 +00:00
|
|
|
{
|
1999-08-20 14:12:14 +00:00
|
|
|
struct el_softc *sc = xsc;
|
1994-04-07 12:10:31 +00:00
|
|
|
struct ifnet *ifp;
|
|
|
|
|
|
|
|
/* Set up pointers */
|
|
|
|
ifp = &sc->arpcom.ac_if;
|
|
|
|
|
|
|
|
/* If address not known, do nothing. */
|
1996-12-13 21:29:07 +00:00
|
|
|
if(TAILQ_EMPTY(&ifp->if_addrhead)) /* XXX unlikely */
|
1994-04-07 12:10:31 +00:00
|
|
|
return;
|
|
|
|
|
2000-12-15 20:09:10 +00:00
|
|
|
EL_LOCK(sc);
|
1994-04-07 12:10:31 +00:00
|
|
|
|
|
|
|
/* First, reset the board. */
|
|
|
|
dprintf(("Resetting board...\n"));
|
1999-08-20 14:12:14 +00:00
|
|
|
el_hardreset(sc);
|
1994-04-07 12:10:31 +00:00
|
|
|
|
|
|
|
/* Configure rx */
|
|
|
|
dprintf(("Configuring rx...\n"));
|
|
|
|
if(ifp->if_flags & IFF_PROMISC)
|
2000-12-15 20:09:10 +00:00
|
|
|
CSR_WRITE_1(sc,EL_RXC,
|
|
|
|
(EL_RXC_PROMISC|EL_RXC_ABROAD|EL_RXC_AMULTI|
|
|
|
|
EL_RXC_AGF|EL_RXC_DSHORT|EL_RXC_DDRIB|EL_RXC_DOFLOW));
|
1994-04-07 12:10:31 +00:00
|
|
|
else
|
2000-12-15 20:09:10 +00:00
|
|
|
CSR_WRITE_1(sc,EL_RXC,
|
|
|
|
(EL_RXC_ABROAD|EL_RXC_AMULTI|
|
|
|
|
EL_RXC_AGF|EL_RXC_DSHORT|EL_RXC_DDRIB|EL_RXC_DOFLOW));
|
|
|
|
CSR_WRITE_1(sc,EL_RBC,0);
|
1994-04-07 12:10:31 +00:00
|
|
|
|
|
|
|
/* Configure TX */
|
|
|
|
dprintf(("Configuring tx...\n"));
|
2000-12-15 20:09:10 +00:00
|
|
|
CSR_WRITE_1(sc,EL_TXC,0);
|
1994-04-07 12:10:31 +00:00
|
|
|
|
|
|
|
/* Start reception */
|
|
|
|
dprintf(("Starting reception...\n"));
|
2000-12-15 20:09:10 +00:00
|
|
|
CSR_WRITE_1(sc,EL_AC,(EL_AC_IRQE|EL_AC_RX));
|
1994-04-07 12:10:31 +00:00
|
|
|
|
|
|
|
/* Set flags appropriately */
|
|
|
|
ifp->if_flags |= IFF_RUNNING;
|
|
|
|
ifp->if_flags &= ~IFF_OACTIVE;
|
|
|
|
|
|
|
|
/* And start output. */
|
|
|
|
el_start(ifp);
|
|
|
|
|
2000-12-15 20:09:10 +00:00
|
|
|
EL_UNLOCK(sc);
|
1994-04-07 12:10:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Start output on interface. Get datagrams from the queue and output
|
|
|
|
* them, giving the receiver a chance between datagrams. Call only
|
|
|
|
* from splimp or interrupt level!
|
|
|
|
*/
|
1995-12-10 13:40:44 +00:00
|
|
|
static void
|
|
|
|
el_start(struct ifnet *ifp)
|
1994-04-07 12:10:31 +00:00
|
|
|
{
|
|
|
|
struct el_softc *sc;
|
|
|
|
struct mbuf *m, *m0;
|
2000-12-15 20:09:10 +00:00
|
|
|
int i, len, retries, done;
|
1994-04-07 12:10:31 +00:00
|
|
|
|
|
|
|
/* Get things pointing in the right directions */
|
1996-02-06 18:51:28 +00:00
|
|
|
sc = ifp->if_softc;
|
1994-04-07 12:10:31 +00:00
|
|
|
|
|
|
|
dprintf(("el_start()...\n"));
|
2000-12-15 20:09:10 +00:00
|
|
|
EL_LOCK(sc);
|
1994-04-07 12:10:31 +00:00
|
|
|
|
|
|
|
/* Don't do anything if output is active */
|
|
|
|
if(sc->arpcom.ac_if.if_flags & IFF_OACTIVE)
|
|
|
|
return;
|
|
|
|
sc->arpcom.ac_if.if_flags |= IFF_OACTIVE;
|
|
|
|
|
|
|
|
/* The main loop. They warned me against endless loops, but
|
|
|
|
* would I listen? NOOO....
|
|
|
|
*/
|
|
|
|
while(1) {
|
|
|
|
/* Dequeue the next datagram */
|
|
|
|
IF_DEQUEUE(&sc->arpcom.ac_if.if_snd,m0);
|
|
|
|
|
|
|
|
/* If there's nothing to send, return. */
|
|
|
|
if(m0 == NULL) {
|
|
|
|
sc->arpcom.ac_if.if_flags &= ~IFF_OACTIVE;
|
2000-12-15 20:09:10 +00:00
|
|
|
EL_UNLOCK(sc);
|
1994-04-07 12:10:31 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Disable the receiver */
|
2000-12-15 20:09:10 +00:00
|
|
|
CSR_WRITE_1(sc,EL_AC,EL_AC_HOST);
|
|
|
|
CSR_WRITE_1(sc,EL_RBC,0);
|
1994-04-07 12:10:31 +00:00
|
|
|
|
|
|
|
/* Copy the datagram to the buffer. */
|
|
|
|
len = 0;
|
|
|
|
for(m = m0; m != NULL; m = m->m_next) {
|
|
|
|
if(m->m_len == 0)
|
|
|
|
continue;
|
|
|
|
bcopy(mtod(m,caddr_t),sc->el_pktbuf+len,m->m_len);
|
|
|
|
len += m->m_len;
|
|
|
|
}
|
|
|
|
m_freem(m0);
|
|
|
|
|
1994-05-26 13:30:20 +00:00
|
|
|
len = max(len,ETHER_MIN_LEN);
|
1994-04-07 12:10:31 +00:00
|
|
|
|
|
|
|
/* Give the packet to the bpf, if any */
|
2002-11-15 00:00:15 +00:00
|
|
|
BPF_TAP(&sc->arpcom.ac_if, sc->el_pktbuf, len);
|
1994-04-07 12:10:31 +00:00
|
|
|
|
|
|
|
/* Transfer datagram to board */
|
|
|
|
dprintf(("el: xfr pkt length=%d...\n",len));
|
|
|
|
i = EL_BUFSIZ - len;
|
2000-12-15 20:09:10 +00:00
|
|
|
CSR_WRITE_1(sc,EL_GPBL,(i & 0xff));
|
|
|
|
CSR_WRITE_1(sc,EL_GPBH,((i>>8)&0xff));
|
|
|
|
bus_space_write_multi_1(sc->el_btag, sc->el_bhandle,
|
|
|
|
EL_BUF, sc->el_pktbuf, len);
|
1994-04-07 12:10:31 +00:00
|
|
|
|
|
|
|
/* Now transmit the datagram */
|
|
|
|
retries=0;
|
|
|
|
done=0;
|
|
|
|
while(!done) {
|
|
|
|
if(el_xmit(sc,len)) { /* Something went wrong */
|
|
|
|
done = -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* Check out status */
|
2000-12-15 20:09:10 +00:00
|
|
|
i = CSR_READ_1(sc,EL_TXS);
|
1994-04-07 12:10:31 +00:00
|
|
|
dprintf(("tx status=0x%x\n",i));
|
|
|
|
if(!(i & EL_TXS_READY)) {
|
|
|
|
dprintf(("el: err txs=%x\n",i));
|
|
|
|
sc->arpcom.ac_if.if_oerrors++;
|
|
|
|
if(i & (EL_TXS_COLL|EL_TXS_COLL16)) {
|
|
|
|
if((!(i & EL_TXC_DCOLL16)) && retries < 15) {
|
|
|
|
retries++;
|
2000-12-15 20:09:10 +00:00
|
|
|
CSR_WRITE_1(sc,EL_AC,EL_AC_HOST);
|
1994-04-07 12:10:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
done = 1;
|
1995-05-30 08:16:23 +00:00
|
|
|
}
|
1994-04-07 12:10:31 +00:00
|
|
|
else {
|
|
|
|
sc->arpcom.ac_if.if_opackets++;
|
|
|
|
done = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(done == -1) /* Packet not transmitted */
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* Now give the card a chance to receive.
|
|
|
|
* Gotta love 3c501s...
|
|
|
|
*/
|
2000-12-15 20:09:10 +00:00
|
|
|
(void)CSR_READ_1(sc,EL_AS);
|
|
|
|
CSR_WRITE_1(sc,EL_AC,(EL_AC_IRQE|EL_AC_RX));
|
|
|
|
EL_UNLOCK(sc);
|
1994-04-07 12:10:31 +00:00
|
|
|
/* Interrupt here */
|
2000-12-15 20:09:10 +00:00
|
|
|
EL_LOCK(sc);
|
1994-04-07 12:10:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This function actually attempts to transmit a datagram downloaded
|
|
|
|
* to the board. Call at splimp or interrupt, after downloading data!
|
|
|
|
* Returns 0 on success, non-0 on failure
|
|
|
|
*/
|
1999-01-12 01:29:45 +00:00
|
|
|
static int
|
|
|
|
el_xmit(struct el_softc *sc,int len)
|
1994-04-07 12:10:31 +00:00
|
|
|
{
|
|
|
|
int gpl;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
gpl = EL_BUFSIZ - len;
|
|
|
|
dprintf(("el: xmit..."));
|
2000-12-15 20:09:10 +00:00
|
|
|
CSR_WRITE_1(sc,EL_GPBL,(gpl & 0xff));
|
|
|
|
CSR_WRITE_1(sc,EL_GPBH,((gpl>>8)&0xff));
|
|
|
|
CSR_WRITE_1(sc,EL_AC,EL_AC_TXFRX);
|
1994-04-07 12:10:31 +00:00
|
|
|
i = 20000;
|
2000-12-15 20:09:10 +00:00
|
|
|
while((CSR_READ_1(sc,EL_AS) & EL_AS_TXBUSY) && (i>0))
|
1994-04-07 12:10:31 +00:00
|
|
|
i--;
|
|
|
|
if(i == 0) {
|
|
|
|
dprintf(("tx not ready\n"));
|
|
|
|
sc->arpcom.ac_if.if_oerrors++;
|
|
|
|
return(-1);
|
|
|
|
}
|
|
|
|
dprintf(("%d cycles.\n",(20000-i)));
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
1999-01-12 01:29:45 +00:00
|
|
|
/* Pass a packet up to the higher levels. */
|
|
|
|
static __inline void
|
|
|
|
elread(struct el_softc *sc,caddr_t buf,int len)
|
|
|
|
{
|
2002-11-15 00:00:15 +00:00
|
|
|
struct ifnet *ifp = &sc->arpcom.ac_if;
|
1999-01-12 01:29:45 +00:00
|
|
|
struct mbuf *m;
|
|
|
|
|
|
|
|
/*
|
2000-05-14 02:18:43 +00:00
|
|
|
* Put packet into an mbuf chain
|
1999-01-12 01:29:45 +00:00
|
|
|
*/
|
2002-11-15 00:00:15 +00:00
|
|
|
m = elget(buf,len,ifp);
|
1999-01-12 01:29:45 +00:00
|
|
|
if(m == 0)
|
|
|
|
return;
|
|
|
|
|
2002-11-15 00:00:15 +00:00
|
|
|
(*ifp->if_input)(ifp,m);
|
1999-01-12 01:29:45 +00:00
|
|
|
}
|
|
|
|
|
1994-04-07 12:10:31 +00:00
|
|
|
/* controller interrupt */
|
1999-01-12 01:29:45 +00:00
|
|
|
static void
|
2000-12-15 20:09:10 +00:00
|
|
|
elintr(void *xsc)
|
1994-04-07 12:10:31 +00:00
|
|
|
{
|
|
|
|
register struct el_softc *sc;
|
|
|
|
int stat, rxstat, len, done;
|
|
|
|
|
|
|
|
|
2000-12-15 20:09:10 +00:00
|
|
|
/* Get things pointing properly */
|
|
|
|
sc = xsc;
|
|
|
|
EL_LOCK(sc);
|
1994-04-07 12:10:31 +00:00
|
|
|
dprintf(("elintr: "));
|
|
|
|
|
|
|
|
/* Check board status */
|
2000-12-15 20:09:10 +00:00
|
|
|
stat = CSR_READ_1(sc,EL_AS);
|
1994-04-07 12:10:31 +00:00
|
|
|
if(stat & EL_AS_RXBUSY) {
|
2000-12-15 20:09:10 +00:00
|
|
|
(void)CSR_READ_1(sc,EL_RXC);
|
|
|
|
CSR_WRITE_1(sc,EL_AC,(EL_AC_IRQE|EL_AC_RX));
|
|
|
|
EL_UNLOCK(sc);
|
1994-04-07 12:10:31 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
done = 0;
|
|
|
|
while(!done) {
|
2000-12-15 20:09:10 +00:00
|
|
|
rxstat = CSR_READ_1(sc,EL_RXS);
|
1994-04-07 12:10:31 +00:00
|
|
|
if(rxstat & EL_RXS_STALE) {
|
2000-12-15 20:09:10 +00:00
|
|
|
(void)CSR_READ_1(sc,EL_RXC);
|
|
|
|
CSR_WRITE_1(sc,EL_AC,(EL_AC_IRQE|EL_AC_RX));
|
|
|
|
EL_UNLOCK(sc);
|
1994-04-07 12:10:31 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If there's an overflow, reinit the board. */
|
|
|
|
if(!(rxstat & EL_RXS_NOFLOW)) {
|
|
|
|
dprintf(("overflow.\n"));
|
1999-08-20 14:12:14 +00:00
|
|
|
el_hardreset(sc);
|
1994-04-07 12:10:31 +00:00
|
|
|
/* Put board back into receive mode */
|
|
|
|
if(sc->arpcom.ac_if.if_flags & IFF_PROMISC)
|
2000-12-15 20:09:10 +00:00
|
|
|
CSR_WRITE_1(sc,EL_RXC,
|
|
|
|
(EL_RXC_PROMISC|EL_RXC_ABROAD|
|
|
|
|
EL_RXC_AMULTI|EL_RXC_AGF|EL_RXC_DSHORT|
|
|
|
|
EL_RXC_DDRIB|EL_RXC_DOFLOW));
|
1994-04-07 12:10:31 +00:00
|
|
|
else
|
2000-12-15 20:09:10 +00:00
|
|
|
CSR_WRITE_1(sc,EL_RXC,
|
|
|
|
(EL_RXC_ABROAD|
|
|
|
|
EL_RXC_AMULTI|EL_RXC_AGF|EL_RXC_DSHORT|
|
|
|
|
EL_RXC_DDRIB|EL_RXC_DOFLOW));
|
|
|
|
(void)CSR_READ_1(sc,EL_AS);
|
|
|
|
CSR_WRITE_1(sc,EL_RBC,0);
|
|
|
|
(void)CSR_READ_1(sc,EL_RXC);
|
|
|
|
CSR_WRITE_1(sc,EL_AC,(EL_AC_IRQE|EL_AC_RX));
|
|
|
|
EL_UNLOCK(sc);
|
1994-04-07 12:10:31 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Incoming packet */
|
2000-12-15 20:09:10 +00:00
|
|
|
len = CSR_READ_1(sc,EL_RBL);
|
|
|
|
len |= CSR_READ_1(sc,EL_RBH) << 8;
|
1994-04-07 12:10:31 +00:00
|
|
|
dprintf(("receive len=%d rxstat=%x ",len,rxstat));
|
2000-12-15 20:09:10 +00:00
|
|
|
CSR_WRITE_1(sc,EL_AC,EL_AC_HOST);
|
1994-04-07 12:10:31 +00:00
|
|
|
|
|
|
|
/* If packet too short or too long, restore rx mode and return
|
|
|
|
*/
|
|
|
|
if((len <= sizeof(struct ether_header)) || (len > ETHER_MAX_LEN)) {
|
|
|
|
if(sc->arpcom.ac_if.if_flags & IFF_PROMISC)
|
2000-12-15 20:09:10 +00:00
|
|
|
CSR_WRITE_1(sc,EL_RXC,
|
|
|
|
(EL_RXC_PROMISC|EL_RXC_ABROAD|
|
|
|
|
EL_RXC_AMULTI|EL_RXC_AGF|EL_RXC_DSHORT|
|
|
|
|
EL_RXC_DDRIB|EL_RXC_DOFLOW));
|
1994-04-07 12:10:31 +00:00
|
|
|
else
|
2000-12-15 20:09:10 +00:00
|
|
|
CSR_WRITE_1(sc,EL_RXC,
|
|
|
|
(EL_RXC_ABROAD|
|
|
|
|
EL_RXC_AMULTI|EL_RXC_AGF|EL_RXC_DSHORT|
|
|
|
|
EL_RXC_DDRIB|EL_RXC_DOFLOW));
|
|
|
|
(void)CSR_READ_1(sc,EL_AS);
|
|
|
|
CSR_WRITE_1(sc,EL_RBC,0);
|
|
|
|
(void)CSR_READ_1(sc,EL_RXC);
|
|
|
|
CSR_WRITE_1(sc,EL_AC,(EL_AC_IRQE|EL_AC_RX));
|
|
|
|
EL_UNLOCK(sc);
|
1994-04-07 12:10:31 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
sc->arpcom.ac_if.if_ipackets++;
|
|
|
|
|
|
|
|
/* Copy the data into our buffer */
|
2000-12-15 20:09:10 +00:00
|
|
|
CSR_WRITE_1(sc,EL_GPBL,0);
|
|
|
|
CSR_WRITE_1(sc,EL_GPBH,0);
|
|
|
|
bus_space_read_multi_1(sc->el_btag, sc->el_bhandle,
|
|
|
|
EL_BUF, sc->el_pktbuf, len);
|
|
|
|
CSR_WRITE_1(sc,EL_RBC,0);
|
|
|
|
CSR_WRITE_1(sc,EL_AC,EL_AC_RX);
|
1996-01-26 09:29:29 +00:00
|
|
|
dprintf(("%6D-->",sc->el_pktbuf+6,":"));
|
|
|
|
dprintf(("%6D\n",sc->el_pktbuf,":"));
|
1994-04-07 12:10:31 +00:00
|
|
|
|
|
|
|
/* Pass data up to upper levels */
|
|
|
|
elread(sc,(caddr_t)(sc->el_pktbuf),len);
|
|
|
|
|
|
|
|
/* Is there another packet? */
|
2000-12-15 20:09:10 +00:00
|
|
|
stat = CSR_READ_1(sc,EL_AS);
|
1994-04-07 12:10:31 +00:00
|
|
|
|
|
|
|
/* If so, do it all again (i.e. don't set done to 1) */
|
1995-05-30 08:16:23 +00:00
|
|
|
if(!(stat & EL_AS_RXBUSY))
|
1994-04-07 12:10:31 +00:00
|
|
|
dprintf(("<rescan> "));
|
|
|
|
else
|
|
|
|
done = 1;
|
|
|
|
}
|
|
|
|
|
2000-12-15 20:09:10 +00:00
|
|
|
(void)CSR_READ_1(sc,EL_RXC);
|
|
|
|
CSR_WRITE_1(sc,EL_AC,(EL_AC_IRQE|EL_AC_RX));
|
|
|
|
EL_UNLOCK(sc);
|
1994-04-07 12:10:31 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2003-01-01 18:49:04 +00:00
|
|
|
* Pull read data off an interface.
|
1994-04-07 12:10:31 +00:00
|
|
|
* Len is length of data, with local net header stripped.
|
|
|
|
*/
|
2000-05-14 02:18:43 +00:00
|
|
|
static struct mbuf *
|
|
|
|
elget(buf, totlen, ifp)
|
1994-04-07 12:10:31 +00:00
|
|
|
caddr_t buf;
|
2000-05-14 02:18:43 +00:00
|
|
|
int totlen;
|
1994-04-07 12:10:31 +00:00
|
|
|
struct ifnet *ifp;
|
|
|
|
{
|
1995-10-28 15:39:31 +00:00
|
|
|
struct mbuf *top, **mp, *m;
|
2000-05-14 02:18:43 +00:00
|
|
|
int len;
|
|
|
|
register caddr_t cp;
|
1994-04-07 12:10:31 +00:00
|
|
|
char *epkt;
|
|
|
|
|
|
|
|
buf += sizeof(struct ether_header);
|
|
|
|
cp = buf;
|
|
|
|
epkt = cp + totlen;
|
|
|
|
|
2003-02-19 05:47:46 +00:00
|
|
|
MGETHDR(m, M_DONTWAIT, MT_DATA);
|
1994-04-07 12:10:31 +00:00
|
|
|
if (m == 0)
|
|
|
|
return (0);
|
|
|
|
m->m_pkthdr.rcvif = ifp;
|
|
|
|
m->m_pkthdr.len = totlen;
|
|
|
|
m->m_len = MHLEN;
|
|
|
|
top = 0;
|
|
|
|
mp = ⊤
|
|
|
|
while (totlen > 0) {
|
|
|
|
if (top) {
|
2003-02-19 05:47:46 +00:00
|
|
|
MGET(m, M_DONTWAIT, MT_DATA);
|
1994-04-07 12:10:31 +00:00
|
|
|
if (m == 0) {
|
|
|
|
m_freem(top);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
m->m_len = MLEN;
|
|
|
|
}
|
|
|
|
len = min(totlen, epkt - cp);
|
|
|
|
if (len >= MINCLSIZE) {
|
2003-02-19 05:47:46 +00:00
|
|
|
MCLGET(m, M_DONTWAIT);
|
1994-04-07 12:10:31 +00:00
|
|
|
if (m->m_flags & M_EXT)
|
|
|
|
m->m_len = len = min(len, MCLBYTES);
|
|
|
|
else
|
|
|
|
len = m->m_len;
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Place initial small packet/header at end of mbuf.
|
|
|
|
*/
|
|
|
|
if (len < m->m_len) {
|
|
|
|
if (top == 0 && len + max_linkhdr <= m->m_len)
|
|
|
|
m->m_data += max_linkhdr;
|
|
|
|
m->m_len = len;
|
|
|
|
} else
|
|
|
|
len = m->m_len;
|
|
|
|
}
|
|
|
|
bcopy(cp, mtod(m, caddr_t), (unsigned)len);
|
|
|
|
cp += len;
|
|
|
|
*mp = m;
|
|
|
|
mp = &m->m_next;
|
|
|
|
totlen -= len;
|
|
|
|
if (cp == epkt)
|
|
|
|
cp = buf;
|
|
|
|
}
|
|
|
|
return (top);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Process an ioctl request. This code needs some work - it looks
|
|
|
|
* pretty ugly.
|
|
|
|
*/
|
1995-12-10 13:40:44 +00:00
|
|
|
static int
|
1994-04-07 12:10:31 +00:00
|
|
|
el_ioctl(ifp, command, data)
|
|
|
|
register struct ifnet *ifp;
|
1998-06-07 17:13:14 +00:00
|
|
|
u_long command;
|
1994-04-07 12:10:31 +00:00
|
|
|
caddr_t data;
|
|
|
|
{
|
2000-12-15 20:09:10 +00:00
|
|
|
int error = 0;
|
|
|
|
struct el_softc *sc;
|
1994-04-07 12:10:31 +00:00
|
|
|
|
2000-12-15 20:09:10 +00:00
|
|
|
sc = ifp->if_softc;
|
|
|
|
EL_LOCK(sc);
|
1994-04-07 12:10:31 +00:00
|
|
|
|
|
|
|
switch (command) {
|
|
|
|
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)) {
|
1999-08-20 14:12:14 +00:00
|
|
|
el_stop(ifp->if_softc);
|
1994-04-07 12:10:31 +00:00
|
|
|
ifp->if_flags &= ~IFF_RUNNING;
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* If interface is marked up and it is stopped, then start it
|
|
|
|
*/
|
|
|
|
if ((ifp->if_flags & IFF_UP) &&
|
|
|
|
((ifp->if_flags & IFF_RUNNING) == 0))
|
1999-08-20 14:12:14 +00:00
|
|
|
el_init(ifp->if_softc);
|
1994-04-07 12:10:31 +00:00
|
|
|
}
|
1995-06-11 19:33:05 +00:00
|
|
|
break;
|
1994-04-07 12:10:31 +00:00
|
|
|
default:
|
2002-11-15 00:00:15 +00:00
|
|
|
error = ether_ioctl(ifp, command, data);
|
|
|
|
break;
|
1994-04-07 12:10:31 +00:00
|
|
|
}
|
2000-12-15 20:09:10 +00:00
|
|
|
EL_UNLOCK(sc);
|
1994-04-07 12:10:31 +00:00
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Device timeout routine */
|
1995-12-10 13:40:44 +00:00
|
|
|
static void
|
|
|
|
el_watchdog(struct ifnet *ifp)
|
1994-04-07 12:10:31 +00:00
|
|
|
{
|
2003-10-31 18:32:15 +00:00
|
|
|
log(LOG_ERR,"%s: device timeout\n", ifp->if_xname);
|
1995-12-05 02:01:59 +00:00
|
|
|
ifp->if_oerrors++;
|
1999-08-20 14:12:14 +00:00
|
|
|
el_reset(ifp->if_softc);
|
1994-04-07 12:10:31 +00:00
|
|
|
}
|