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:43:13 +00:00
parent 16e78eb3fb
commit 300992c9ba
4 changed files with 35 additions and 32 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: elink3.c,v 1.4 1996/05/03 19:08:47 christos Exp $ */
/* $NetBSD: elink3.c,v 1.5 1996/05/07 01:43:13 thorpej Exp $ */
/*
* Copyright (c) 1994 Herb Peyerl <hpeyerl@novatel.ca>
@ -85,7 +85,7 @@ static int epstatus __P((struct ep_softc *));
void epinit __P((struct ep_softc *));
int epioctl __P((struct ifnet *, u_long, caddr_t));
void epstart __P((struct ifnet *));
void epwatchdog __P((int));
void epwatchdog __P((struct ifnet *));
void epreset __P((struct ep_softc *));
void epread __P((struct ep_softc *));
struct mbuf *epget __P((struct ep_softc *, int));
@ -101,12 +101,11 @@ epconfig(sc, conn)
struct ep_softc *sc;
u_int conn;
{
struct ifnet *ifp = &sc->sc_arpcom.ac_if;
bus_chipset_tag_t bc = sc->sc_bc;
bus_io_handle_t ioh = sc->sc_ioh;
u_short i;
struct ifnet *ifp = &sc->sc_arpcom.ac_if;
sc->ep_connectors = 0;
printf("%s: ", sc->sc_dev.dv_xname);
if (conn & IS_AUI) {
@ -145,8 +144,8 @@ epconfig(sc, conn)
printf(" address %s\n", ether_sprintf(sc->sc_arpcom.ac_enaddr));
ifp->if_unit = sc->sc_dev.dv_unit;
ifp->if_name = ep_cd.cd_name;
bcopy(sc->sc_dev.dv_xname, ifp->if_xname, IFNAMSIZ);
ifp->if_softc = sc;
ifp->if_start = epstart;
ifp->if_ioctl = epioctl;
ifp->if_watchdog = epwatchdog;
@ -300,7 +299,7 @@ void
epstart(ifp)
struct ifnet *ifp;
{
register struct ep_softc *sc = ep_cd.cd_devs[ifp->if_unit];
register struct ep_softc *sc = ifp->if_softc;
bus_chipset_tag_t bc = sc->sc_bc;
bus_io_handle_t ioh = sc->sc_ioh;
struct mbuf *m, *m0;
@ -804,7 +803,7 @@ epioctl(ifp, cmd, data)
u_long cmd;
caddr_t data;
{
struct ep_softc *sc = ep_cd.cd_devs[ifp->if_unit];
struct ep_softc *sc = ifp->if_softc;
struct ifaddr *ifa = (struct ifaddr *)data;
struct ifreq *ifr = (struct ifreq *)data;
int s, error = 0;
@ -911,10 +910,10 @@ epreset(sc)
}
void
epwatchdog(unit)
int unit;
epwatchdog(ifp)
struct ifnet *ifp;
{
struct ep_softc *sc = ep_cd.cd_devs[unit];
struct ep_softc *sc = ifp->if_softc;
log(LOG_ERR, "%s: device timeout\n", sc->sc_dev.dv_xname);
++sc->sc_arpcom.ac_if.if_oerrors;

View File

@ -1,4 +1,4 @@
/* $NetBSD: pdq_ifsubr.c,v 1.2 1996/03/11 21:41:32 thorpej Exp $ */
/* $NetBSD: pdq_ifsubr.c,v 1.3 1996/05/07 01:43:15 thorpej Exp $ */
/*-
* Copyright (c) 1995 Matt Thomas (thomas@lkg.dec.com)
@ -406,8 +406,8 @@ pdq_ifioctl(
void
pdq_ifattach(
pdq_softc_t *sc,
ifnet_ret_t (*ifinit)(int unit),
ifnet_ret_t (*ifwatchdog)(int unit))
pdq_ifinit_t ifinit,
pdq_ifwatchdog_t ifwatchdog)
{
struct ifnet *ifp = &sc->sc_if;

View File

@ -1,4 +1,4 @@
/* $NetBSD: pdqvar.h,v 1.4 1996/03/11 21:41:35 thorpej Exp $ */
/* $NetBSD: pdqvar.h,v 1.5 1996/05/07 01:43:17 thorpej Exp $ */
/*-
* Copyright (c) 1995 Matt Thomas (thomas@lkg.dec.com)
@ -141,13 +141,21 @@ typedef struct {
#define sc_if sc_ac.ac_if
#define sc_bpf sc_if.if_bpf
#if defined(__NetBSD__)
typedef ifnet_ret_t (*pdq_ifwatchdog_t)(struct ifnet *ifp);
typedef ifnet_ret_t (*pdq_ifinit_t)(struct ifnet *ifp);
#else
typedef ifnet_ret_t (*pdq_ifwatchdog_t)(int unit);
typedef ifnet_ret_t (*pdq_ifinit_t)(int unit);
#endif
extern void pdq_ifreset(pdq_softc_t *sc);
extern void pdq_ifinit(pdq_softc_t *sc);
extern void pdq_ifwatchdog(pdq_softc_t *sc);
extern ifnet_ret_t pdq_ifstart(struct ifnet *ifp);
extern int pdq_ifioctl(struct ifnet *ifp, ioctl_cmd_t cmd, caddr_t data);
extern void pdq_ifattach(pdq_softc_t *sc, ifnet_ret_t (*ifinit)(int unit),
ifnet_ret_t (*ifwatchdog)(int unit));
extern void pdq_ifattach(pdq_softc_t *sc, pdq_ifinit_t ifinit,
pdq_ifwatchdog_t ifwatchdog);
#endif /* PDQ_HWSUPPORT */
#elif defined(DLPI_PDQ)
#include <sys/param.h>

View File

@ -1,4 +1,4 @@
/* $NetBSD: smc90cx6.c,v 1.16 1996/03/20 13:28:50 is Exp $ */
/* $NetBSD: smc90cx6.c,v 1.17 1996/05/07 01:43:18 thorpej Exp $ */
/*
* Copyright (c) 1994, 1995 Ignatios Souvatzis
@ -183,7 +183,7 @@ void bah_stop __P((struct bah_softc *));
void bah_start __P((struct ifnet *));
int bahintr __P((struct bah_softc *sc));
int bah_ioctl __P((struct ifnet *, unsigned long, caddr_t));
void bah_watchdog __P((int));
void bah_watchdog __P((struct ifnet *));
void movepout __P((u_char *from, u_char __volatile *to, int len));
void movepin __P((u_char __volatile *from, u_char *to, int len));
void bah_srint __P((void *vsc, void *dummy));
@ -272,8 +272,8 @@ bah_zbus_attach(parent, self, aux)
*/
bah_stop(sc);
ifp->if_unit = sc->sc_dev.dv_unit;
ifp->if_name = bah_cd.cd_name;
bcopy(sc->sc_dev.dv_xname, ifp->if_xname, IFNAMSIZ);
ifp->if_softc = sc;
ifp->if_output = arc_output;
ifp->if_start = bah_start;
ifp->if_ioctl = bah_ioctl;
@ -360,8 +360,8 @@ bah_reset(sc)
linkaddress = sc->sc_base->dipswitches;
#if defined(BAH_DEBUG) && (BAH_DEBUG > 2)
printf("bah%ld: reset: card reset, link addr = 0x%02x (%ld)\n",
ifp->if_unit, linkaddress, linkaddress);
printf("%s: reset: card reset, link addr = 0x%02x (%ld)\n",
sc->sc_dev.dv_xname, linkaddress, linkaddress);
#endif
sc->sc_arccom.ac_anaddr = linkaddress;
@ -540,7 +540,7 @@ bah_start(ifp)
u_long copystart, lencopy, perbyte;
#endif
sc = bah_cd.cd_devs[ifp->if_unit];
sc = ifp->if_softc;
#if defined(BAH_DEBUG) && (BAH_DEBUG > 3)
printf("%s: start(0x%x)\n", sc->sc_dev.dv_xname, ifp);
@ -1150,7 +1150,7 @@ bah_ioctl(ifp, command, data)
int s, error;
error = 0;
sc = bah_cd.cd_devs[ifp->if_unit];
sc = ifp->if_softc;
ifa = (struct ifaddr *)data;
s = splnet();
@ -1217,14 +1217,10 @@ bah_ioctl(ifp, command, data)
*/
void
bah_watchdog(unit)
int unit;
{
struct bah_softc *sc;
bah_watchdog(ifp)
struct ifnet *ifp;
sc = bah_cd.cd_devs[unit];
ifp = &(sc->sc_arccom.ac_if);
{
struct bah_softc *sc = ifp->if_softc;
sc->sc_base->command = ARC_TXDIS;
return;