Changed struct ifnet to have a pointer to the softc of the underlying

device and a printable "external name" (name + unit number), thus eliminating
if_name and if_unit.  Updated interface to (*if_watchdog)() and (*if_start)()
to take a struct ifnet *, rather than a unit number.
This commit is contained in:
thorpej 1996-05-07 01:35:48 +00:00
parent 0584bf86a8
commit 69351e2be6
3 changed files with 47 additions and 57 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_ie.c,v 1.10 1996/03/26 22:04:14 gwr Exp $ */
/* $NetBSD: if_ie.c,v 1.11 1996/05/07 01:35:48 thorpej Exp $ */
/*-
* Copyright (c) 1993, 1994, 1995 Charles Hannum.
@ -167,7 +167,7 @@ static struct mbuf *last_not_for_us;
#define ETHER_MAX_LEN 1518
#define ETHER_ADDR_LEN 6
void iewatchdog __P(( /* short */ ));
void iewatchdog __P((struct ifnet *));
int ieinit __P((struct ie_softc *));
int ieioctl __P((struct ifnet *, u_long, caddr_t));
void iestart __P((struct ifnet *));
@ -298,8 +298,8 @@ ie_attach(sc)
/*
* Initialize and attach S/W interface
*/
ifp->if_unit = sc->sc_dev.dv_unit;
ifp->if_name = ie_cd.cd_name;
bcopy(sc->sc_dev.dv_xname, ifp->if_xname, IFNAMSIZ);
ifp->if_softc = sc;
ifp->if_start = iestart;
ifp->if_ioctl = ieioctl;
ifp->if_watchdog = iewatchdog;
@ -319,10 +319,10 @@ ie_attach(sc)
* generate an interrupt after a transmit has been started on it.
*/
void
iewatchdog(unit)
short unit;
iewatchdog(ifp)
struct ifnet *ifp;
{
struct ie_softc *sc = ie_cd.cd_devs[unit];
struct ie_softc *sc = ifp->if_unit;
log(LOG_ERR, "%s: device timeout\n", sc->sc_dev.dv_xname);
++sc->sc_arpcom.ac_if.if_oerrors;
@ -1042,7 +1042,7 @@ void
iestart(ifp)
struct ifnet *ifp;
{
struct ie_softc *sc = ie_cd.cd_devs[ifp->if_unit];
struct ie_softc *sc = ifp->if_softc;
struct mbuf *m0, *m;
u_char *buffer;
u_short len;
@ -1561,7 +1561,7 @@ ieioctl(ifp, cmd, data)
u_long cmd;
caddr_t data;
{
struct ie_softc *sc = ie_cd.cd_devs[ifp->if_unit];
struct ie_softc *sc = ifp->if_softc;
struct ifaddr *ifa = (struct ifaddr *) data;
struct ifreq *ifr = (struct ifreq *) data;
int s, error = 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_de.c,v 1.19 1996/04/08 18:34:54 ragge Exp $ */
/* $NetBSD: if_de.c,v 1.20 1996/05/07 01:37:33 thorpej Exp $ */
/*
* Copyright (c) 1982, 1986, 1989 Regents of the University of California.
@ -143,13 +143,13 @@ struct de_softc {
int dematch __P((struct device *, void *, void *));
void deattach __P((struct device *, struct device *, void *));
int dewait __P((struct de_softc *, char *));
void deinit __P((int));
void deinit __P((struct de_softc *));
int deioctl __P((struct ifnet *, u_long, caddr_t));
void dereset __P((int));
void destart __P((struct ifnet *));
void deread __P((struct de_softc *, struct ifrw *, int));
void derecv __P((int));
void de_setaddr __P((u_char *, int));
void de_setaddr __P((u_char *, struct de_softc *));
void deintr __P((int));
@ -179,8 +179,8 @@ deattach(parent, self, aux)
printf("\n");
addr = (struct dedevice *)ua->ua_addr;
ds->ds_vaddr = addr;
ifp->if_unit = ds->ds_device.dv_unit;
ifp->if_name = "de";
bcopy(ds->ds_device.dv_xname, ifp->if_xname, IFNAMSIZ);
ifp->if_softc = ds;
ifp->if_flags = IFF_BROADCAST | IFF_NOTRAILERS;
/*
@ -247,7 +247,7 @@ dereset(unit)
sc->ds_flags &= ~DSF_RUNNING;
addr->pcsr0 = PCSR0_RSET;
(void)dewait(sc, "reset");
deinit(unit);
deinit(sc);
}
/*
@ -255,20 +255,16 @@ dereset(unit)
* operations, and reinitialize UNIBUS usage.
*/
void
deinit(unit)
int unit;
{
deinit(ds)
struct de_softc *ds;
{
volatile struct dedevice *addr;
struct ifnet *ifp = &ds->ds_if;
struct ifrw *ifrw;
struct ifxmt *ifxp;
struct ifnet *ifp;
struct de_ring *rp;
int s,incaddr;
ds = (struct de_softc *)de_cd.cd_devs[unit];
ifp = &ds->ds_if;
/* not yet, if address still unknown */
if (ifp->if_addrlist.tqh_first == (struct ifaddr *)0)
return;
@ -349,7 +345,7 @@ deinit(unit)
destart(&ds->ds_if); /* queue output packets */
ds->ds_flags |= DSF_RUNNING; /* need before de_setaddr */
if (ds->ds_flags & DSF_SETADDR)
de_setaddr(ds->ds_addr, unit);
de_setaddr(ds->ds_addr, ds);
addr->pclow = CMD_START | PCSR0_INTE;
splx(s);
}
@ -365,7 +361,7 @@ destart(ifp)
struct ifnet *ifp;
{
int len;
register struct de_softc *ds = de_cd.cd_devs[ifp->if_unit];
register struct de_softc *ds = ifp->if_softc;
volatile struct dedevice *addr = ds->ds_vaddr;
register struct de_ring *rp;
struct mbuf *m;
@ -577,14 +573,14 @@ deioctl(ifp, cmd, data)
caddr_t data;
{
register struct ifaddr *ifa = (struct ifaddr *)data;
register struct de_softc *ds = de_cd.cd_devs[ifp->if_unit];
register struct de_softc *ds = ifp->if_softc;
int s = splnet(), error = 0;
switch (cmd) {
case SIOCSIFADDR:
ifp->if_flags |= IFF_UP;
deinit(ifp->if_unit);
deinit(ds);
switch (ifa->ifa_addr->sa_family) {
#ifdef INET
@ -600,7 +596,7 @@ deioctl(ifp, cmd, data)
if (ns_nullhost(*ina))
ina->x_host = *(union ns_host *)(ds->ds_addr);
else
de_setaddr(ina->x_host.c_host,ifp->if_unit);
de_setaddr(ina->x_host.c_host, ds);
break;
}
#endif
@ -617,7 +613,7 @@ deioctl(ifp, cmd, data)
ds->ds_if.if_flags &= ~IFF_OACTIVE;
} else if (ifp->if_flags & IFF_UP &&
(ds->ds_flags & DSF_RUNNING) == 0)
deinit(ifp->if_unit);
deinit(ds);
break;
default:
@ -631,11 +627,10 @@ deioctl(ifp, cmd, data)
* set ethernet address for unit
*/
void
de_setaddr(physaddr, unit)
de_setaddr(physaddr, ds)
u_char *physaddr;
int unit;
struct de_softc *ds;
{
register struct de_softc *ds = de_cd.cd_devs[unit];
volatile struct dedevice *addr= ds->ds_vaddr;
if (! (ds->ds_flags & DSF_RUNNING))

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_qe.c,v 1.13 1996/03/18 16:47:25 ragge Exp $ */
/* $NetBSD: if_qe.c,v 1.14 1996/05/07 01:37:34 thorpej Exp $ */
/*
* Copyright (c) 1988 Regents of the University of California.
@ -191,8 +191,6 @@ extern char all_es_snpa[], all_is_snpa[], all_l1is_snpa[], all_l2is_snpa[];
#define MINDATA 60
void qetimeout(int);
/*
* Ethernet software status per interface.
*
@ -233,17 +231,17 @@ struct qe_softc {
int qematch __P((struct device *, void *, void *));
void qeattach __P((struct device *, struct device *, void *));
void qereset __P((int));
void qeinit __P((int));
void qeinit __P((struct qe_softc *));
void qestart __P((struct ifnet *));
void qeintr __P((int));
void qetint __P((int));
void qerint __P((int));
int qeioctl __P((struct ifnet *, u_long, caddr_t));
void qe_setaddr __P((u_char *, int));
void qe_setaddr __P((u_char *, struct qe_softc *));
void qeinitdesc __P((struct qe_ring *, caddr_t, int));
void qesetup __P((struct qe_softc *));
void qeread __P((struct qe_softc *, struct ifrw *, int));
void qetimeout __P((int));
void qetimeout __P((struct ifnet *));
void qerestart __P((struct qe_softc *));
struct cfdriver qe_cd = {
@ -365,8 +363,8 @@ qeattach(parent, self, aux)
printf("\n");
sc->qe_vaddr = addr;
ifp->if_unit = sc->qe_dev.dv_unit;
ifp->if_name = "qe";
bcopy(sc->sc_dev.dv_xname, ifp->if_xname, IFNAMSIZ);
ifp->if_softc = sc;
/*
* The Deqna is cable of transmitting broadcasts, but
* doesn't listen to its own.
@ -409,17 +407,16 @@ qereset(unit)
printf(" %s", sc->qe_dev.dv_xname);
sc->qe_if.if_flags &= ~IFF_RUNNING;
qeinit(unit);
qeinit(sc);
}
/*
* Initialization of interface.
*/
void
qeinit(unit)
int unit;
qeinit(sc)
struct qe_softc *sc;
{
struct qe_softc *sc = (struct qe_softc *)qe_cd.cd_devs[unit];
struct qedevice *addr = sc->qe_vaddr;
struct ifnet *ifp = (struct ifnet *)&sc->qe_if;
int i;
@ -515,7 +512,7 @@ void
qestart(ifp)
struct ifnet *ifp;
{
register struct qe_softc *sc = qe_cd.cd_devs[ifp->if_unit];
register struct qe_softc *sc = ifp->if_softc;
volatile struct qedevice *addr = sc->qe_vaddr;
register struct qe_ring *rp;
register index;
@ -767,7 +764,7 @@ qeioctl(ifp, cmd, data)
u_long cmd;
caddr_t data;
{
struct qe_softc *sc = qe_cd.cd_devs[ifp->if_unit];
struct qe_softc *sc = ifp->if_softc;
struct ifaddr *ifa = (struct ifaddr *)data;
int s = splnet(), error = 0;
@ -775,7 +772,7 @@ qeioctl(ifp, cmd, data)
case SIOCSIFADDR:
ifp->if_flags |= IFF_UP;
qeinit(ifp->if_unit);
qeinit(sc);
switch(ifa->ifa_addr->sa_family) {
#ifdef INET
case AF_INET:
@ -790,7 +787,7 @@ qeioctl(ifp, cmd, data)
if (ns_nullhost(*ina))
ina->x_host = *(union ns_host *)(sc->qe_addr);
else
qe_setaddr(ina->x_host.c_host, ifp->if_unit);
qe_setaddr(ina->x_host.c_host, sc);
break;
}
#endif
@ -819,11 +816,10 @@ qeioctl(ifp, cmd, data)
* set ethernet address for unit
*/
void
qe_setaddr(physaddr, unit)
qe_setaddr(physaddr, sc)
u_char *physaddr;
int unit;
struct qe_softc *sc;
{
register struct qe_softc *sc = qe_cd.cd_devs[unit];
register int i;
for (i = 0; i < 6; i++)
@ -831,7 +827,7 @@ qe_setaddr(physaddr, unit)
sc->qe_flags |= QEF_SETADDR;
if (sc->qe_if.if_flags & IFF_RUNNING)
qesetup(sc);
qeinit(unit);
qeinit(sc);
}
@ -939,15 +935,14 @@ if (m) {
* the hang up and restarts the device.
*/
void
qetimeout(unit)
int unit;
qetimeout(ifp)
struct ifnet *ifp;
{
register struct qe_softc *sc;
register struct qe_softc *sc = ifp->if_softc;
sc = qe_cd.cd_devs[unit];
#ifdef notdef
log(LOG_ERR, "qe%d: transmit timeout, restarted %d\n",
unit, sc->qe_restarts++);
log(LOG_ERR, "%s: transmit timeout, restarted %d\n",
sc->sc_dev.dv_xname, sc->qe_restarts++);
#endif
qerestart(sc);
}