diff options
author | brooks <brooks@FreeBSD.org> | 2003-10-31 18:32:15 +0000 |
---|---|---|
committer | brooks <brooks@FreeBSD.org> | 2003-10-31 18:32:15 +0000 |
commit | f1e94c6f29b079e4ad9d9305ef3e90a719bcbbda (patch) | |
tree | 4d9e6671d486576767506230a4240131526fea49 /sys/dev | |
parent | be546fdee455a96afdefee10d0bdba8547399f5b (diff) | |
download | FreeBSD-src-f1e94c6f29b079e4ad9d9305ef3e90a719bcbbda.zip FreeBSD-src-f1e94c6f29b079e4ad9d9305ef3e90a719bcbbda.tar.gz |
Replace the if_name and if_unit members of struct ifnet with new members
if_xname, if_dname, and if_dunit. if_xname is the name of the interface
and if_dname/unit are the driver name and instance.
This change paves the way for interface renaming and enhanced pseudo
device creation and configuration symantics.
Approved By: re (in principle)
Reviewed By: njl, imp
Tested On: i386, amd64, sparc64
Obtained From: NetBSD (if_xname)
Diffstat (limited to 'sys/dev')
76 files changed, 298 insertions, 362 deletions
diff --git a/sys/dev/an/if_an.c b/sys/dev/an/if_an.c index cdf85e9..15cd3e0 100644 --- a/sys/dev/an/if_an.c +++ b/sys/dev/an/if_an.c @@ -752,8 +752,9 @@ an_attach(sc, unit, flags) sc->arpcom.ac_enaddr, ":"); ifp->if_softc = sc; - ifp->if_unit = sc->an_unit = unit; - ifp->if_name = "an"; + sc->an_unit = unit; + if_initname(ifp, device_get_name(sc->an_dev), + device_get_unit(sc->an_dev)); ifp->if_mtu = ETHERMTU; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = an_ioctl; diff --git a/sys/dev/ar/if_ar.c b/sys/dev/ar/if_ar.c index 17181f5..edba0ba 100644 --- a/sys/dev/ar/if_ar.c +++ b/sys/dev/ar/if_ar.c @@ -293,8 +293,8 @@ ar_attach(device_t device) ifp = &sc->ifsppp.pp_if; ifp->if_softc = sc; - ifp->if_unit = sc->unit; - ifp->if_name = "ar"; + if_initname(ifp, device_get_name(device), + device_get_unit(device)); ifp->if_mtu = PP_MTU; ifp->if_flags = IFF_POINTOPOINT | IFF_MULTICAST; ifp->if_ioctl = arioctl; diff --git a/sys/dev/ath/if_ath.c b/sys/dev/ath/if_ath.c index c968179..f464f96 100644 --- a/sys/dev/ath/if_ath.c +++ b/sys/dev/ath/if_ath.c @@ -186,8 +186,8 @@ ath_attach(u_int16_t devid, struct ath_softc *sc) DPRINTF(("ath_attach: devid 0x%x\n", devid)); /* set these up early for if_printf use */ - ifp->if_unit = device_get_unit(sc->sc_dev); - ifp->if_name = "ath"; + if_initname(ifp, device_get_name(sc->sc_dev), + device_get_unit(sc->sc_dev)); ah = ath_hal_attach(devid, sc, sc->sc_st, sc->sc_sh, &status); if (ah == NULL) { diff --git a/sys/dev/awi/if_awi_pccard.c b/sys/dev/awi/if_awi_pccard.c index 346802e..4b0887c 100644 --- a/sys/dev/awi/if_awi_pccard.c +++ b/sys/dev/awi/if_awi_pccard.c @@ -141,10 +141,9 @@ awi_pccard_attach(device_t dev) psc->sc_mem_res = 0; psc->sc_intrhand = 0; - ifp->if_name = "awi"; - ifp->if_unit = device_get_unit(dev); - snprintf(sc->sc_dev.dv_xname, sizeof(sc->sc_dev.dv_xname), - "%s%d", ifp->if_name, ifp->if_unit); + if_initname(ifp, device_get_name(dev), device_get_unit(dev)); + strlcpy(sc->sc_dev.dv_xname, ifp->if_xname, + sizeof(sc->sc_dev.dv_xname)); psc->sc_port_rid = 0; psc->sc_port_res = bus_alloc_resource(dev, SYS_RES_IOPORT, diff --git a/sys/dev/bfe/if_bfe.c b/sys/dev/bfe/if_bfe.c index b830c8c..3d5a7e7 100644 --- a/sys/dev/bfe/if_bfe.c +++ b/sys/dev/bfe/if_bfe.c @@ -368,8 +368,7 @@ bfe_attach(device_t dev) /* Set up ifnet structure */ ifp = &sc->arpcom.ac_if; ifp->if_softc = sc; - ifp->if_unit = sc->bfe_unit; - ifp->if_name = "bfe"; + if_initname(ifp, device_get_name(dev), device_get_unit(dev)); ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = bfe_ioctl; ifp->if_output = ether_output; diff --git a/sys/dev/bge/if_bge.c b/sys/dev/bge/if_bge.c index 8d7850f..dcb289e 100644 --- a/sys/dev/bge/if_bge.c +++ b/sys/dev/bge/if_bge.c @@ -2365,8 +2365,7 @@ bge_attach(dev) /* Set up ifnet structure */ ifp = &sc->arpcom.ac_if; ifp->if_softc = sc; - ifp->if_unit = sc->bge_unit; - ifp->if_name = "bge"; + if_initname(ifp, device_get_name(dev), device_get_unit(dev)); ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = bge_ioctl; ifp->if_output = ether_output; diff --git a/sys/dev/cm/if_cm_isa.c b/sys/dev/cm/if_cm_isa.c index a478406..8f7732f 100644 --- a/sys/dev/cm/if_cm_isa.c +++ b/sys/dev/cm/if_cm_isa.c @@ -96,7 +96,7 @@ cm_isa_attach(dev) return (error); } - return cm_attach(sc, device_get_unit(dev)); + return cm_attach(dev); } static int diff --git a/sys/dev/cm/smc90cx6.c b/sys/dev/cm/smc90cx6.c index ff4bfe9..89a3415 100644 --- a/sys/dev/cm/smc90cx6.c +++ b/sys/dev/cm/smc90cx6.c @@ -274,10 +274,10 @@ cm_release_resources(dev) } int -cm_attach(sc, unit) - struct cm_softc *sc; - int unit; +cm_attach(dev) + device_t dev; { + struct cm_softc *sc = device_get_softc(dev); struct ifnet *ifp = &sc->sc_arccom.ac_if; int s; u_int8_t linkaddress; @@ -313,8 +313,7 @@ cm_attach(sc, unit) cm_stop(sc); ifp->if_softc = sc; - ifp->if_unit = unit; - ifp->if_name = "cm"; + if_initname(ifp, device_get_name(dev), device_get_unit(dev)); ifp->if_output = arc_output; ifp->if_start = cm_start; ifp->if_ioctl = cm_ioctl; @@ -841,8 +840,8 @@ cmintr(arg) */ PUTREG(CMCMD, CM_CLR(CLR_POR)); log(LOG_WARNING, - "%s%d: intr: got spurious power on reset int\n", - ifp->if_name, ifp->if_unit); + "%s: intr: got spurious power on reset int\n", + ifp->if_xname); } if (maskedisr & CM_RECON) { @@ -872,9 +871,9 @@ cmintr(arg) if ((newsec - sc->sc_recontime <= 2) && (++sc->sc_reconcount == ARC_EXCESSIVE_RECONS)) { log(LOG_WARNING, - "%s%d: excessive token losses, " + "%s: excessive token losses, " "cable problem?\n", - ifp->if_name, ifp->if_unit); + ifp->if_xname); } sc->sc_recontime = newsec; callout_reset(&sc->sc_recon_ch, 15 * hz, @@ -895,8 +894,8 @@ cmintr(arg) * configured sender) */ log(LOG_WARNING, - "%s%d: spurious RX interupt or sender 0 " - " (ignored)\n", ifp->if_name, ifp->if_unit); + "%s: spurious RX interupt or sender 0 " + " (ignored)\n", ifp->if_xname); /* * restart receiver on same buffer. * XXX maybe better reset interface? @@ -958,8 +957,8 @@ cm_reconwatch(arg) if (sc->sc_reconcount >= ARC_EXCESSIVE_RECONS) { sc->sc_reconcount = 0; - log(LOG_WARNING, "%s%d: token valid again.\n", - ifp->if_name, ifp->if_unit); + log(LOG_WARNING, "%s: token valid again.\n", + ifp->if_xname); } sc->sc_reconcount = 0; } diff --git a/sys/dev/cm/smc90cx6var.h b/sys/dev/cm/smc90cx6var.h index ad6d09a..1703145 100644 --- a/sys/dev/cm/smc90cx6var.h +++ b/sys/dev/cm/smc90cx6var.h @@ -87,7 +87,7 @@ struct cm_softc { u_char sc_retransmits[2]; /* unused at the moment */ }; -int cm_attach(struct cm_softc *, int unit); +int cm_attach(device_t dev); void cmintr(void *); int cm_probe(device_t dev); diff --git a/sys/dev/cnw/if_cnw.c b/sys/dev/cnw/if_cnw.c index bbf2a6b..6aedca3 100644 --- a/sys/dev/cnw/if_cnw.c +++ b/sys/dev/cnw/if_cnw.c @@ -1632,8 +1632,7 @@ static int cnw_pccard_attach(device_t dev) sc->arpcom.ac_enaddr, ":"); ifp->if_softc = sc; - ifp->if_name = "cnw"; - ifp->if_unit = device_get_unit(dev); + if_initname(ifp, device_get_name(dev), device_get_unit(dev)); ifp->if_timer = 0; ifp->if_mtu = ETHERMTU; ifp->if_flags = (IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST); diff --git a/sys/dev/cs/if_cs.c b/sys/dev/cs/if_cs.c index f09bb3d..c67b328 100644 --- a/sys/dev/cs/if_cs.c +++ b/sys/dev/cs/if_cs.c @@ -575,16 +575,16 @@ void cs_release_resources(device_t dev) * Install the interface into kernel networking data structures */ int -cs_attach(struct cs_softc *sc, int unit, int flags) +cs_attach(device_t dev) { int media=0; + struct cs_softc *sc = device_get_softc(dev);; struct ifnet *ifp = &(sc->arpcom.ac_if); cs_stop( sc ); ifp->if_softc=sc; - ifp->if_unit=unit; - ifp->if_name="cs"; + if_initname(ifp, device_get_name(dev), device_get_unit(dev)); ifp->if_output=ether_output; ifp->if_start=cs_start; ifp->if_ioctl=cs_ioctl; @@ -607,8 +607,8 @@ cs_attach(struct cs_softc *sc, int unit, int flags) sc->recv_ring=malloc(CS_DMA_BUFFER_SIZE<<1, M_DEVBUF, M_NOWAIT); if (sc->recv_ring == NULL) { - log(LOG_ERR,CS_NAME - "%d: Couldn't allocate memory for NIC\n", unit); + log(LOG_ERR, + "%s: Couldn't allocate memory for NIC\n", ifp->if_xname); return(0); } if ((sc->recv_ring-(sc->recv_ring & 0x1FFFF)) @@ -1137,7 +1137,7 @@ cs_watchdog(struct ifnet *ifp) struct cs_softc *sc = ifp->if_softc; ifp->if_oerrors++; - log(LOG_ERR, CS_NAME"%d: device timeout\n", ifp->if_unit); + log(LOG_ERR, "%s: device timeout\n", ifp->if_xname); /* Reset the interface */ if (ifp->if_flags & IFF_UP) diff --git a/sys/dev/cs/if_cs_isa.c b/sys/dev/cs/if_cs_isa.c index 7b93f07..dcbd02f 100644 --- a/sys/dev/cs/if_cs_isa.c +++ b/sys/dev/cs/if_cs_isa.c @@ -90,7 +90,6 @@ static int cs_isa_attach(device_t dev) { struct cs_softc *sc = device_get_softc(dev); - int flags = device_get_flags(dev); int error; cs_alloc_port(dev, 0, CS_89x0_IO_PORTS); @@ -106,7 +105,7 @@ cs_isa_attach(device_t dev) return (error); } - return (cs_attach(sc, device_get_unit(dev), flags)); + return (cs_attach(dev)); } static device_method_t cs_isa_methods[] = { diff --git a/sys/dev/cs/if_cs_pccard.c b/sys/dev/cs/if_cs_pccard.c index 2b1f3e8..499cf8f 100644 --- a/sys/dev/cs/if_cs_pccard.c +++ b/sys/dev/cs/if_cs_pccard.c @@ -81,7 +81,6 @@ static int cs_pccard_attach(device_t dev) { struct cs_softc *sc = device_get_softc(dev); - int flags = device_get_flags(dev); int error; error = cs_alloc_port(dev, sc->port_rid, CS_89x0_IO_PORTS); @@ -95,7 +94,7 @@ cs_pccard_attach(device_t dev) if (error != 0) goto bad; - return (cs_attach(sc, device_get_unit(dev), flags)); + return (cs_attach(dev)); bad: cs_release_resources(dev); return (error); diff --git a/sys/dev/cs/if_csvar.h b/sys/dev/cs/if_csvar.h index 719a8db..0f62c62 100644 --- a/sys/dev/cs/if_csvar.h +++ b/sys/dev/cs/if_csvar.h @@ -70,7 +70,7 @@ struct cs_softc { int cs_alloc_port(device_t dev, int rid, int size); int cs_alloc_memory(device_t dev, int rid, int size); int cs_alloc_irq(device_t dev, int rid, int flags); -int cs_attach(struct cs_softc *, int, int); +int cs_attach(device_t dev); int cs_cs89x0_probe(device_t dev); void cs_release_resources(device_t dev); driver_intr_t csintr; diff --git a/sys/dev/dc/if_dc.c b/sys/dev/dc/if_dc.c index f6ebbb3..f483505 100644 --- a/sys/dev/dc/if_dc.c +++ b/sys/dev/dc/if_dc.c @@ -2228,8 +2228,7 @@ dc_attach(device_t dev) ifp = &sc->arpcom.ac_if; ifp->if_softc = sc; - ifp->if_unit = unit; - ifp->if_name = "dc"; + if_initname(ifp, device_get_name(dev), device_get_unit(dev)); /* XXX: bleah, MTU gets overwritten in ether_ifattach() */ ifp->if_mtu = ETHERMTU; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; diff --git a/sys/dev/de/if_de.c b/sys/dev/de/if_de.c index 3a3d242..248101e 100644 --- a/sys/dev/de/if_de.c +++ b/sys/dev/de/if_de.c @@ -383,12 +383,12 @@ tulip_media_print( if ((sc->tulip_flags & TULIP_LINKUP) == 0) return; if (sc->tulip_flags & TULIP_PRINTMEDIA) { - printf("%s%d: enabling %s port\n", - sc->tulip_name, sc->tulip_unit, + printf("%s: enabling %s port\n", + sc->tulip_xname, tulip_mediums[sc->tulip_media]); sc->tulip_flags &= ~(TULIP_PRINTMEDIA|TULIP_PRINTLINKUP); } else if (sc->tulip_flags & TULIP_PRINTLINKUP) { - printf("%s%d: link up\n", sc->tulip_name, sc->tulip_unit); + printf("%s: link up\n", sc->tulip_xname); sc->tulip_flags &= ~TULIP_PRINTLINKUP; } } @@ -435,8 +435,8 @@ tulip_21140_gpr_media_sense( continue; #if defined(TULIP_DEBUG) - printf("%s%d: gpr_media_sense: %s: 0x%02x & 0x%02x == 0x%02x\n", - sc->tulip_name, sc->tulip_unit, tulip_mediums[media], + printf("%s: gpr_media_sense: %s: 0x%02x & 0x%02x == 0x%02x\n", + sc->tulip_xname, tulip_mediums[media], TULIP_CSR_READ(sc, csr_gp) & 0xFF, mi->mi_actmask, mi->mi_actdata); #endif @@ -499,8 +499,8 @@ tulip_media_link_monitor( abilities = (abilities << 6) & status; if (abilities != sc->tulip_abilities) { #if defined(TULIP_DEBUG) - loudprintf("%s%d(phy%d): autonegotiation changed: 0x%04x -> 0x%04x\n", - sc->tulip_name, sc->tulip_unit, sc->tulip_phyaddr, + loudprintf("%s(phy%d): autonegotiation changed: 0x%04x -> 0x%04x\n", + sc->tulip_xname, sc->tulip_phyaddr, sc->tulip_abilities, abilities); #endif if (tulip_mii_map_abilities(sc, abilities)) { @@ -542,8 +542,8 @@ tulip_media_link_monitor( linkup = TULIP_LINK_UP; #if defined(TULIP_DEBUG) if (sc->tulip_probe_timeout <= 0) - printf("%s%d: sia status = 0x%08x\n", sc->tulip_name, - sc->tulip_unit, TULIP_CSR_READ(sc, csr_sia_status)); + printf("%s: sia status = 0x%08x\n", sc->tulip_xname, + TULIP_CSR_READ(sc, csr_sia_status)); #endif } else if (mi->mi_type == TULIP_MEDIAINFO_SYM) { return TULIP_LINK_UNKNOWN; @@ -558,7 +558,7 @@ tulip_media_link_monitor( return TULIP_LINK_UP; sc->tulip_flags &= ~TULIP_LINKUP; - printf("%s%d: link down: cable problem?\n", sc->tulip_name, sc->tulip_unit); + printf("%s: link down: cable problem?\n", sc->tulip_xname); } #if defined(TULIP_DEBUG) sc->tulip_dbg.dbg_link_downed++; @@ -689,8 +689,8 @@ tulip_media_poll( if (sc->tulip_probe_timeout > 0) { tulip_media_t new_probe_media = tulip_21140_gpr_media_sense(sc); #if defined(TULIP_DEBUG) - printf("%s%d: media_poll: gpr sensing = %s\n", - sc->tulip_name, sc->tulip_unit, tulip_mediums[new_probe_media]); + printf("%s: media_poll: gpr sensing = %s\n", + sc->tulip_xname, tulip_mediums[new_probe_media]); #endif if (new_probe_media != TULIP_MEDIA_UNKNOWN) { if (new_probe_media == sc->tulip_probe_media) { @@ -776,8 +776,8 @@ tulip_media_poll( if (/* event == TULIP_MEDIAPOLL_TXPROBE_FAILED || */ sc->tulip_probe_timeout <= 0) { #if defined(TULIP_DEBUG) if (sc->tulip_probe_media == TULIP_MEDIA_UNKNOWN) { - printf("%s%d: poll media unknown!\n", - sc->tulip_name, sc->tulip_unit); + printf("%s: poll media unknown!\n", + sc->tulip_xname); sc->tulip_probe_media = TULIP_MEDIA_MAX; } #endif @@ -789,8 +789,8 @@ tulip_media_poll( sc->tulip_probe_media -= 1; if (sc->tulip_probe_media == TULIP_MEDIA_UNKNOWN) { if (++sc->tulip_probe_passes == 3) { - printf("%s%d: autosense failed: cable problem?\n", - sc->tulip_name, sc->tulip_unit); + printf("%s: autosense failed: cable problem?\n", + sc->tulip_xname); if ((sc->tulip_if.if_flags & IFF_UP) == 0) { sc->tulip_if.if_flags &= ~IFF_RUNNING; sc->tulip_probe_state = TULIP_PROBE_INACTIVE; @@ -806,7 +806,7 @@ tulip_media_poll( || TULIP_IS_MEDIA_FD(sc->tulip_probe_media)); #if defined(TULIP_DEBUG) - printf("%s%d: %s: probing %s\n", sc->tulip_name, sc->tulip_unit, + printf("%s: %s: probing %s\n", sc->tulip_xname, event == TULIP_MEDIAPOLL_TXPROBE_FAILED ? "txprobe failed" : "timeout", tulip_mediums[sc->tulip_probe_media]); #endif @@ -1135,8 +1135,8 @@ tulip_21041_media_poll( sc->tulip_flags &= ~TULIP_WANTRXACT; sc->tulip_probe_timeout = TULIP_21041_PROBE_AUIBNC_TIMEOUT; } else { - printf("%s%d: autosense failed: cable problem?\n", - sc->tulip_name, sc->tulip_unit); + printf("%s: autosense failed: cable problem?\n", + sc->tulip_xname); if ((sc->tulip_if.if_flags & IFF_UP) == 0) { sc->tulip_if.if_flags &= ~IFF_RUNNING; sc->tulip_probe_state = TULIP_PROBE_INACTIVE; @@ -1347,8 +1347,8 @@ tulip_mii_autonegotiate( tulip_timeout(sc); return; } - printf("%s%d(phy%d): error: reset of PHY never completed!\n", - sc->tulip_name, sc->tulip_unit, phyaddr); + printf("%s(phy%d): error: reset of PHY never completed!\n", + sc->tulip_xname, phyaddr); sc->tulip_flags &= ~TULIP_TXPROBE_ACTIVE; sc->tulip_probe_state = TULIP_PROBE_FAILED; sc->tulip_if.if_flags &= ~(IFF_UP|IFF_RUNNING); @@ -1357,8 +1357,8 @@ tulip_mii_autonegotiate( status = tulip_mii_readreg(sc, phyaddr, PHYREG_STATUS); if ((status & PHYSTS_CAN_AUTONEG) == 0) { #if defined(TULIP_DEBUG) - loudprintf("%s%d(phy%d): autonegotiation disabled\n", - sc->tulip_name, sc->tulip_unit, phyaddr); + loudprintf("%s(phy%d): autonegotiation disabled\n", + sc->tulip_xname, phyaddr); #endif sc->tulip_flags &= ~TULIP_DIDNWAY; sc->tulip_probe_state = TULIP_PROBE_MEDIATEST; @@ -1370,11 +1370,11 @@ tulip_mii_autonegotiate( data = tulip_mii_readreg(sc, phyaddr, PHYREG_CONTROL); #if defined(TULIP_DEBUG) if ((data & PHYCTL_AUTONEG_ENABLE) == 0) - loudprintf("%s%d(phy%d): oops: enable autonegotiation failed: 0x%04x\n", - sc->tulip_name, sc->tulip_unit, phyaddr, data); + loudprintf("%s(phy%d): oops: enable autonegotiation failed: 0x%04x\n", + sc->tulip_xname, phyaddr, data); else - loudprintf("%s%d(phy%d): autonegotiation restarted: 0x%04x\n", - sc->tulip_name, sc->tulip_unit, phyaddr, data); + loudprintf("%s(phy%d): autonegotiation restarted: 0x%04x\n", + sc->tulip_xname, phyaddr, data); sc->tulip_dbg.dbg_nway_starts++; #endif sc->tulip_probe_state = TULIP_PROBE_PHYAUTONEG; @@ -1390,8 +1390,8 @@ tulip_mii_autonegotiate( return; } #if defined(TULIP_DEBUG) - loudprintf("%s%d(phy%d): autonegotiation timeout: sts=0x%04x, ctl=0x%04x\n", - sc->tulip_name, sc->tulip_unit, phyaddr, status, + loudprintf("%s(phy%d): autonegotiation timeout: sts=0x%04x, ctl=0x%04x\n", + sc->tulip_xname, phyaddr, status, tulip_mii_readreg(sc, phyaddr, PHYREG_CONTROL)); #endif sc->tulip_flags &= ~TULIP_DIDNWAY; @@ -1400,8 +1400,8 @@ tulip_mii_autonegotiate( } data = tulip_mii_readreg(sc, phyaddr, PHYREG_AUTONEG_ABILITIES); #if defined(TULIP_DEBUG) - loudprintf("%s%d(phy%d): autonegotiation complete: 0x%04x\n", - sc->tulip_name, sc->tulip_unit, phyaddr, data); + loudprintf("%s(phy%d): autonegotiation complete: 0x%04x\n", + sc->tulip_xname, phyaddr, data); #endif data = (data << 6) & status; if (!tulip_mii_map_abilities(sc, data)) @@ -1416,8 +1416,8 @@ tulip_mii_autonegotiate( } } #if defined(TULIP_DEBUG) - loudprintf("%s%d(phy%d): autonegotiation failure: state = %d\n", - sc->tulip_name, sc->tulip_unit, phyaddr, sc->tulip_probe_state); + loudprintf("%s(phy%d): autonegotiation failure: state = %d\n", + sc->tulip_xname, phyaddr, sc->tulip_probe_state); sc->tulip_dbg.dbg_nway_failures++; #endif } @@ -1452,8 +1452,8 @@ tulip_2114x_media_preset( } #if defined(TULIP_DEBUG) } else { - printf("%s%d: preset: bad media %d!\n", - sc->tulip_name, sc->tulip_unit, media); + printf("%s: preset: bad media %d!\n", + sc->tulip_xname, media); } #endif } @@ -1508,8 +1508,8 @@ tulip_null_media_poll( sc->tulip_dbg.dbg_events[event]++; #endif #if defined(DIAGNOSTIC) - printf("%s%d: botch(media_poll) at line %d\n", - sc->tulip_name, sc->tulip_unit, __LINE__); + printf("%s: botch(media_poll) at line %d\n", + sc->tulip_xname, __LINE__); #endif } @@ -2276,7 +2276,7 @@ tulip_identify_asante_nic( mi->mi_phyaddr = tulip_mii_get_phyaddr(sc, 0); } if (mi->mi_phyaddr == TULIP_MII_NOPHY) { - printf("%s%d: can't find phy 0\n", sc->tulip_name, sc->tulip_unit); + printf("%s: can't find phy 0\n", sc->tulip_xname); return; } @@ -2326,8 +2326,8 @@ tulip_identify_compex_nic( sc->tulip_slaves = root_sc->tulip_slaves; root_sc->tulip_slaves = sc; } else if(sc->tulip_features & TULIP_HAVE_SLAVEDINTR) { - printf("\nCannot find master device for de%d interrupts", - sc->tulip_unit); + printf("\nCannot find master device for %s interrupts", + sc->tulip_xname); } } else { strcat(sc->tulip_boardid, "unknown "); @@ -2529,8 +2529,8 @@ tulip_srom_decode( } if (mi->mi_phyaddr == TULIP_MII_NOPHY) { #if defined(TULIP_DEBUG) - printf("%s%d: can't find phy %d\n", - sc->tulip_name, sc->tulip_unit, phyno); + printf("%s: can't find phy %d\n", + sc->tulip_xname, phyno); #endif break; } @@ -2630,8 +2630,8 @@ tulip_srom_decode( } if (mi->mi_phyaddr == TULIP_MII_NOPHY) { #if defined(TULIP_DEBUG) - printf("%s%d: can't find phy %d\n", - sc->tulip_name, sc->tulip_unit, phyno); + printf("%s: can't find phy %d\n", + sc->tulip_xname, phyno); #endif break; } @@ -3274,8 +3274,8 @@ tulip_reset( (*sc->tulip_boardsw->bd_media_select)(sc); #if defined(TULIP_DEBUG) if ((sc->tulip_flags & TULIP_NEEDRESET) == TULIP_NEEDRESET) - printf("%s%d: tulip_reset: additional reset needed?!?\n", - sc->tulip_name, sc->tulip_unit); + printf("%s: tulip_reset: additional reset needed?!?\n", + sc->tulip_xname); #endif tulip_media_print(sc); if (sc->tulip_features & TULIP_HAVE_DUALSENSE) @@ -3503,8 +3503,8 @@ tulip_rx_intr( } #if defined(TULIP_VERBOSE) if (error != NULL && (sc->tulip_flags & TULIP_NOMESSAGES) == 0) { - printf("%s%d: receive: %6D: %s\n", - sc->tulip_name, sc->tulip_unit, + printf("%s: receive: %6D: %s\n", + sc->tulip_xname, mtod(ms, u_char *) + 6, ":", error); sc->tulip_flags |= TULIP_NOMESSAGES; @@ -3615,8 +3615,8 @@ tulip_rx_intr( error = bus_dmamap_load(sc->tulip_dmatag, map, mtod(ms, void *), TULIP_RX_BUFLEN, NULL, BUS_DMA_NOWAIT); if (error) { - printf("%s%d: unable to load rx map, " - "error = %d\n", sc->tulip_name, sc->tulip_unit, error); + printf("%s: unable to load rx map, " + "error = %d\n", sc->tulip_xname, error); panic("tulip_rx_intr"); /* XXX */ } nextout->d_addr1 = map->dm_segs[0].ds_addr; @@ -3707,8 +3707,8 @@ tulip_tx_intr( m_freem(m); #if defined(TULIP_DEBUG) } else { - printf("%s%d: tx_intr: failed to dequeue mbuf?!?\n", - sc->tulip_name, sc->tulip_unit); + printf("%s: tx_intr: failed to dequeue mbuf?!?\n", + sc->tulip_xname); #endif } if (sc->tulip_flags & TULIP_TXPROBE_ACTIVE) { @@ -3797,7 +3797,7 @@ tulip_print_abnormal_interrupt( const char thrsh[] = "72|128\0\0\0" "96|256\0\0\0" "128|512\0\0" "160|1024"; csr &= (1 << (sizeof(tulip_status_bits)/sizeof(tulip_status_bits[0]))) - 1; - printf("%s%d: abnormal interrupt:", sc->tulip_name, sc->tulip_unit); + printf("%s: abnormal interrupt:", sc->tulip_xname); for (sep = " ", mask = 1; mask <= csr; mask <<= 1, msgp++) { if ((csr & mask) && *msgp != NULL) { printf("%s%s", sep, *msgp); @@ -3833,8 +3833,8 @@ tulip_intr_handler( if (sc->tulip_flags & TULIP_NOMESSAGES) { sc->tulip_flags |= TULIP_SYSTEMERROR; } else { - printf("%s%d: system error: %s\n", - sc->tulip_name, sc->tulip_unit, + printf("%s: system error: %s\n", + sc->tulip_xname, tulip_system_errors[sc->tulip_last_system_error]); } sc->tulip_flags |= TULIP_NEEDRESET; @@ -4130,8 +4130,8 @@ tulip_txput( #if defined(TULIP_DEBUG) if ((sc->tulip_cmdmode & TULIP_CMD_TXRUN) == 0) { - printf("%s%d: txput%s: tx not running\n", - sc->tulip_name, sc->tulip_unit, + printf("%s: txput%s: tx not running\n", + sc->tulip_xname, (sc->tulip_flags & TULIP_TXPROBE_ACTIVE) ? "(probe)" : ""); sc->tulip_flags |= TULIP_WANTTXSTART; sc->tulip_dbg.dbg_txput_finishes[0]++; @@ -4202,8 +4202,8 @@ tulip_txput( error = bus_dmamap_load_mbuf(sc->tulip_dmatag, map, m, BUS_DMA_NOWAIT); } if (error != 0) { - printf("%s%d: unable to load tx map, " - "error = %d\n", sc->tulip_name, sc->tulip_unit, error); + printf("%s: unable to load tx map, " + "error = %d\n", sc->tulip_xname, error); #if defined(TULIP_DEBUG) sc->tulip_dbg.dbg_txput_finishes[3]++; #endif @@ -4455,8 +4455,8 @@ tulip_txput_setup( #if defined(TULIP_DEBUG) if ((sc->tulip_cmdmode & TULIP_CMD_TXRUN) == 0) { - printf("%s%d: txput_setup: tx not running\n", - sc->tulip_name, sc->tulip_unit); + printf("%s: txput_setup: tx not running\n", + sc->tulip_xname); sc->tulip_flags |= TULIP_WANTTXSTART; sc->tulip_if.if_start = tulip_ifstart; return; @@ -4705,8 +4705,8 @@ tulip_ifwatchdog( tulip_rx_intr(sc); if (sc->tulip_flags & TULIP_SYSTEMERROR) { - printf("%s%d: %d system errors: last was %s\n", - sc->tulip_name, sc->tulip_unit, sc->tulip_system_errors, + printf("%s: %d system errors: last was %s\n", + sc->tulip_xname, sc->tulip_system_errors, tulip_system_errors[sc->tulip_last_system_error]); } if (sc->tulip_statusbits) { @@ -4720,7 +4720,7 @@ tulip_ifwatchdog( if (sc->tulip_txtimer) tulip_tx_intr(sc); if (sc->tulip_txtimer && --sc->tulip_txtimer == 0) { - printf("%s%d: transmission timeout\n", sc->tulip_name, sc->tulip_unit); + printf("%s: transmission timeout\n", sc->tulip_xname); if (TULIP_DO_AUTOSENSE(sc)) { sc->tulip_media = TULIP_MEDIA_UNKNOWN; sc->tulip_probe_state = TULIP_PROBE_INACTIVE; @@ -4766,6 +4766,9 @@ tulip_attach( { struct ifnet * const ifp = &sc->tulip_if; + /* XXX: driver name/unit should be set some other way */ + ifp->if_dname = "de"; + ifp->if_dunit = sc->tulip_unit; ifp->if_flags = IFF_BROADCAST|IFF_SIMPLEX|IFF_MULTICAST; ifp->if_ioctl = tulip_ifioctl; ifp->if_start = tulip_ifstart; @@ -4774,16 +4777,16 @@ tulip_attach( ifp->if_output = ether_output; ifp->if_init = tulip_ifinit; - printf("%s%d: %s%s pass %d.%d%s\n", - sc->tulip_name, sc->tulip_unit, + printf("%s: %s%s pass %d.%d%s\n", + sc->tulip_xname, sc->tulip_boardid, tulip_chipdescs[sc->tulip_chipid], (sc->tulip_revinfo & 0xF0) >> 4, sc->tulip_revinfo & 0x0F, (sc->tulip_features & (TULIP_HAVE_ISVSROM|TULIP_HAVE_OKSROM)) == TULIP_HAVE_ISVSROM ? " (invalid EESPROM checksum)" : ""); - printf("%s%d: address %6D\n", - sc->tulip_name, sc->tulip_unit, sc->tulip_enaddr, ":"); + printf("%s: address %6D\n", + sc->tulip_xname, sc->tulip_enaddr, ":"); #if defined(__alpha__) /* @@ -5142,7 +5145,7 @@ tulip_pci_attach(device_t dev) #endif sc->tulip_unit = unit; - sc->tulip_name = "de"; + snprintf(sc->tulip_xname, IFNAMSIZ, "de%d", sc->tulip_unit); sc->tulip_revinfo = revinfo; sc->tulip_if.if_softc = sc; #if defined(TULIP_IOMAPPED) @@ -5194,16 +5197,16 @@ tulip_pci_attach(device_t dev) bit longer anyways) */ if ((retval = tulip_read_macaddr(sc)) < 0) { - printf("%s%d", sc->tulip_name, sc->tulip_unit); + printf("%s", sc->tulip_xname); printf(": can't read ENET ROM (why=%d) (", retval); for (idx = 0; idx < 32; idx++) printf("%02x", sc->tulip_rombuf[idx]); printf("\n"); - printf("%s%d: %s%s pass %d.%d\n", - sc->tulip_name, sc->tulip_unit, + printf("%s: %s%s pass %d.%d\n", + sc->tulip_xname, sc->tulip_boardid, tulip_chipdescs[sc->tulip_chipid], (sc->tulip_revinfo & 0xF0) >> 4, sc->tulip_revinfo & 0x0F); - printf("%s%d: address unknown\n", sc->tulip_name, sc->tulip_unit); + printf("%s: address unknown\n", sc->tulip_xname); } else { int s; void (*intr_rtn)(void *) = tulip_intr_normal; @@ -5219,8 +5222,8 @@ tulip_pci_attach(device_t dev) 0, ~0, 1, RF_SHAREABLE | RF_ACTIVE); if (res == 0 || bus_setup_intr(dev, res, INTR_TYPE_NET, intr_rtn, sc, &ih)) { - printf("%s%d: couldn't map interrupt\n", - sc->tulip_name, sc->tulip_unit); + printf("%s: couldn't map interrupt\n", + sc->tulip_xname); free((caddr_t) sc->tulip_rxdescs, M_DEVBUF); free((caddr_t) sc->tulip_txdescs, M_DEVBUF); return ENXIO; diff --git a/sys/dev/de/if_devar.h b/sys/dev/de/if_devar.h index 13d2357..9b47cca 100644 --- a/sys/dev/de/if_devar.h +++ b/sys/dev/de/if_devar.h @@ -431,6 +431,7 @@ typedef struct { */ struct _tulip_softc_t { struct ifmedia tulip_ifmedia; + int tulip_unit; #if defined(TULIP_BUS_DMA) bus_dma_tag_t tulip_dmatag; /* bus DMA tag */ #if !defined(TULIP_BUS_DMA_NOTX) @@ -850,10 +851,7 @@ NETISR_SET(NETISR_DE, tulip_softintr); #ifndef tulip_if #define tulip_if tulip_ac.ac_if #endif -#ifndef tulip_unit -#define tulip_unit tulip_if.if_unit -#endif -#define tulip_name tulip_if.if_name +#define tulip_xname tulip_if.if_xname #ifndef tulip_enaddr #define tulip_enaddr tulip_ac.ac_enaddr #endif diff --git a/sys/dev/ed/if_ed.c b/sys/dev/ed/if_ed.c index 0c6a0f6..1ec954f 100644 --- a/sys/dev/ed/if_ed.c +++ b/sys/dev/ed/if_ed.c @@ -1700,11 +1700,10 @@ ed_release_resources(dev) * Install interface into kernel networking data structures */ int -ed_attach(sc, unit, flags) - struct ed_softc *sc; - int unit; - int flags; +ed_attach(dev) + device_t dev; { + struct ed_softc *sc = device_get_softc(dev); struct ifnet *ifp = &sc->arpcom.ac_if; callout_handle_init(&sc->tick_ch); @@ -1717,8 +1716,7 @@ ed_attach(sc, unit, flags) * Initialize ifnet structure */ ifp->if_softc = sc; - ifp->if_unit = unit; - ifp->if_name = "ed"; + if_initname(ifp, device_get_name(dev), device_get_unit(dev)); ifp->if_output = ether_output; ifp->if_start = ed_start; ifp->if_ioctl = ed_ioctl; @@ -1745,7 +1743,7 @@ ed_attach(sc, unit, flags) * tranceiver for AUI operation), based on compile-time * config option. */ - if (flags & ED_FLAGS_DISABLE_TRANCEIVER) + if (device_get_flags(dev) & ED_FLAGS_DISABLE_TRANCEIVER) ifp->if_flags = (IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST | IFF_ALTPHYS); else @@ -1846,7 +1844,7 @@ ed_watchdog(ifp) if (sc->gone) return; - log(LOG_ERR, "ed%d: device timeout\n", ifp->if_unit); + log(LOG_ERR, "%s: device timeout\n", ifp->if_xname); ifp->if_oerrors++; ed_reset(ifp); @@ -2349,8 +2347,8 @@ ed_rint(sc) * Really BAD. The ring pointers are corrupted. */ log(LOG_ERR, - "ed%d: NIC memory corrupt - invalid packet length %d\n", - ifp->if_unit, len); + "%s: NIC memory corrupt - invalid packet length %d\n", + ifp->if_xname, len); ifp->if_ierrors++; ed_reset(ifp); return; @@ -2554,8 +2552,8 @@ edintr(arg) ifp->if_ierrors++; #ifdef DIAGNOSTIC log(LOG_WARNING, - "ed%d: warning - receiver ring buffer overrun\n", - ifp->if_unit); + "%s: warning - receiver ring buffer overrun\n", + ifp->if_xname); #endif /* @@ -3057,8 +3055,8 @@ ed_pio_write_mbufs(sc, m, dst) while (((ed_nic_inb(sc, ED_P0_ISR) & ED_ISR_RDC) != ED_ISR_RDC) && --maxwait); if (!maxwait) { - log(LOG_WARNING, "ed%d: remote transmit DMA failed to complete\n", - ifp->if_unit); + log(LOG_WARNING, "%s: remote transmit DMA failed to complete\n", + ifp->if_xname); ed_reset(ifp); return(0); } diff --git a/sys/dev/ed/if_ed_cbus.c b/sys/dev/ed/if_ed_cbus.c index d6c37f2..40f114b 100644 --- a/sys/dev/ed/if_ed_cbus.c +++ b/sys/dev/ed/if_ed_cbus.c @@ -277,7 +277,7 @@ ed_isa_attach(dev) return (error); } - return ed_attach(sc, device_get_unit(dev), flags); + return ed_attach(dev); } #ifdef PC98 diff --git a/sys/dev/ed/if_ed_isa.c b/sys/dev/ed/if_ed_isa.c index bc5e397..69da715 100644 --- a/sys/dev/ed/if_ed_isa.c +++ b/sys/dev/ed/if_ed_isa.c @@ -125,7 +125,6 @@ ed_isa_attach(dev) device_t dev; { struct ed_softc *sc = device_get_softc(dev); - int flags = device_get_flags(dev); int error; if (sc->port_used > 0) @@ -142,7 +141,7 @@ ed_isa_attach(dev) return (error); } - return ed_attach(sc, device_get_unit(dev), flags); + return ed_attach(dev); } static device_method_t ed_isa_methods[] = { diff --git a/sys/dev/ed/if_ed_pccard.c b/sys/dev/ed/if_ed_pccard.c index 1930b1f..8b9f52d 100644 --- a/sys/dev/ed/if_ed_pccard.c +++ b/sys/dev/ed/if_ed_pccard.c @@ -246,7 +246,6 @@ static int ed_pccard_attach(device_t dev) { int error; - int flags = device_get_flags(dev); int i; struct ed_softc *sc = device_get_softc(dev); u_char sum; @@ -274,7 +273,7 @@ ed_pccard_attach(device_t dev) bcopy(ether_addr, sc->arpcom.ac_enaddr, ETHER_ADDR_LEN); } - error = ed_attach(sc, device_get_unit(dev), flags); + error = ed_attach(dev); #ifndef ED_NO_MIIBUS if (error == 0 && sc->vendor == ED_VENDOR_LINKSYS) { /* Probe for an MII bus, but ignore errors. */ diff --git a/sys/dev/ed/if_ed_pci.c b/sys/dev/ed/if_ed_pci.c index 87ac950..3d775be 100644 --- a/sys/dev/ed/if_ed_pci.c +++ b/sys/dev/ed/if_ed_pci.c @@ -101,7 +101,7 @@ ed_pci_attach(device_t dev) return (error); } - error = ed_attach(sc, device_get_unit(dev), flags); + error = ed_attach(dev); return (error); } diff --git a/sys/dev/ed/if_edvar.h b/sys/dev/ed/if_edvar.h index 3b71c8c..d1f903d 100644 --- a/sys/dev/ed/if_edvar.h +++ b/sys/dev/ed/if_edvar.h @@ -204,7 +204,7 @@ int ed_probe_Novell (device_t, int, int); int ed_probe_Novell_generic (device_t, int); int ed_probe_HP_pclanp (device_t, int, int); -int ed_attach (struct ed_softc *, int, int); +int ed_attach (device_t); void ed_stop (struct ed_softc *); void ed_pio_readmem (struct ed_softc *, int, unsigned char *, unsigned short); diff --git a/sys/dev/em/if_em.c b/sys/dev/em/if_em.c index 27b9d6c..295fdb6 100644 --- a/sys/dev/em/if_em.c +++ b/sys/dev/em/if_em.c @@ -1816,8 +1816,7 @@ em_setup_interface(device_t dev, struct adapter * adapter) INIT_DEBUGOUT("em_setup_interface: begin"); ifp = &adapter->interface_data.ac_if; - ifp->if_unit = adapter->unit; - ifp->if_name = "em"; + if_initname(ifp, device_get_name(dev), device_get_unit(dev)); ifp->if_mtu = ETHERMTU; ifp->if_output = ether_output; ifp->if_baudrate = 1000000000; diff --git a/sys/dev/en/if_en_pci.c b/sys/dev/en/if_en_pci.c index b535d58..dac053e 100644 --- a/sys/dev/en/if_en_pci.c +++ b/sys/dev/en/if_en_pci.c @@ -193,14 +193,13 @@ en_pci_attach(device_t dev) struct en_softc *sc; struct en_pci_softc *scp; u_long val; - int rid, unit, error = 0; + int rid, error = 0; sc = device_get_softc(dev); scp = (struct en_pci_softc *)sc; - unit = device_get_unit(dev); - sc->ifatm.ifnet.if_unit = unit; - sc->ifatm.ifnet.if_name = "en"; + if_initname(&(sc->ifatm.ifnet), device_get_name(dev), + device_get_unit(dev)); /* * Enable bus mastering. diff --git a/sys/dev/en/midway.c b/sys/dev/en/midway.c index bfb503d..48df206 100644 --- a/sys/dev/en/midway.c +++ b/sys/dev/en/midway.c @@ -1827,9 +1827,8 @@ en_rx_drain(struct en_softc *sc, u_int drq) m = NULL; /* assume "JK" trash DMA */ if (EN_DQ_LEN(drq) != 0) { _IF_DEQUEUE(&slot->indma, m); - KASSERT(m != NULL, ("drqsync: %s%d: lost mbuf in slot %zu!", - sc->ifatm.ifnet.if_name, sc->ifatm.ifnet.if_unit, - slot - sc->rxslot)); + KASSERT(m != NULL, ("drqsync: %s: lost mbuf in slot %zu!", + sc->ifatm.ifnet.if_xname, slot - sc->rxslot)); uma_zfree(sc->map_zone, (struct en_map *)m->m_pkthdr.rcvif); } if ((vc = slot->vcc) == NULL) { diff --git a/sys/dev/ep/if_ep.c b/sys/dev/ep/if_ep.c index 32683c3..4fd8e33 100644 --- a/sys/dev/ep/if_ep.c +++ b/sys/dev/ep/if_ep.c @@ -292,8 +292,7 @@ ep_attach(struct ep_softc *sc) attached = (ifp->if_softc != 0); ifp->if_softc = sc; - ifp->if_unit = sc->unit; - ifp->if_name = "ep"; + if_initname(ifp, device_get_name(sc->dev), device_get_unit(sc->dev)); ifp->if_mtu = ETHERMTU; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_output = ether_output; diff --git a/sys/dev/ex/if_ex.c b/sys/dev/ex/if_ex.c index 1a5e25d..b4b1bc3 100644 --- a/sys/dev/ex/if_ex.c +++ b/sys/dev/ex/if_ex.c @@ -221,7 +221,6 @@ ex_attach(device_t dev) struct ex_softc * sc = device_get_softc(dev); struct ifnet * ifp = &sc->arpcom.ac_if; struct ifmedia * ifm; - int unit = device_get_unit(dev); u_int16_t temp; /* work out which set of irq <-> internal tables to use */ @@ -239,8 +238,7 @@ ex_attach(device_t dev) * Initialize the ifnet structure. */ ifp->if_softc = sc; - ifp->if_unit = unit; - ifp->if_name = "ex"; + if_initname(ifp, device_get_name(dev), device_get_unit(dev)); ifp->if_mtu = ETHERMTU; ifp->if_flags = IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST; ifp->if_output = ether_output; @@ -308,7 +306,7 @@ ex_init(void *xsc) register int iobase = sc->iobase; unsigned short temp_reg; - DODEBUG(Start_End, printf("ex_init%d: start\n", ifp->if_unit);); + DODEBUG(Start_End, printf("%s: ex_init: start\n", ifp->if_xname);); if (TAILQ_FIRST(&ifp->if_addrhead) == NULL) { return; @@ -389,7 +387,7 @@ ex_init(void *xsc) ex_start(ifp); splx(s); - DODEBUG(Start_End, printf("ex_init%d: finish\n", ifp->if_unit);); + DODEBUG(Start_End, printf("%s: ex_init: finish\n", ifp->if_xname);); } @@ -809,7 +807,7 @@ ex_ioctl(register struct ifnet *ifp, u_long cmd, caddr_t data) int s; int error = 0; - DODEBUG(Start_End, printf("ex_ioctl%d: start ", ifp->if_unit);); + DODEBUG(Start_End, printf("%s: ex_ioctl: start ", ifp->if_xname);); s = splimp(); @@ -854,7 +852,7 @@ ex_ioctl(register struct ifnet *ifp, u_long cmd, caddr_t data) splx(s); - DODEBUG(Start_End, printf("\nex_ioctl%d: finish\n", ifp->if_unit);); + DODEBUG(Start_End, printf("\n%s: ex_ioctl: finish\n", ifp->if_xname);); return(error); } @@ -977,7 +975,7 @@ ex_watchdog(struct ifnet *ifp) { struct ex_softc * sc = ifp->if_softc; - DODEBUG(Start_End, printf("ex_watchdog%d: start\n", ifp->if_unit);); + DODEBUG(Start_End, printf("%s: ex_watchdog: start\n", ifp->if_xname);); ifp->if_flags &= ~IFF_OACTIVE; @@ -987,7 +985,7 @@ ex_watchdog(struct ifnet *ifp) ex_reset(sc); ex_start(ifp); - DODEBUG(Start_End, printf("ex_watchdog%d: finish\n", ifp->if_unit);); + DODEBUG(Start_End, printf("%s: ex_watchdog: finish\n", ifp->if_xname);); return; } diff --git a/sys/dev/fatm/if_fatm.c b/sys/dev/fatm/if_fatm.c index cdba704..258e8a7 100644 --- a/sys/dev/fatm/if_fatm.c +++ b/sys/dev/fatm/if_fatm.c @@ -2805,8 +2805,7 @@ fatm_attach(device_t dev) */ ifp = &sc->ifatm.ifnet; ifp->if_softc = sc; - ifp->if_unit = unit; - ifp->if_name = "fatm"; + if_initname(ifp, device_get_name(dev), device_get_unit(dev)); ifp->if_flags = IFF_SIMPLEX; ifp->if_ioctl = fatm_ioctl; ifp->if_start = fatm_start; diff --git a/sys/dev/fe/if_fe.c b/sys/dev/fe/if_fe.c index 0a21324..8e9c69e 100644 --- a/sys/dev/fe/if_fe.c +++ b/sys/dev/fe/if_fe.c @@ -423,8 +423,8 @@ fe_read_eeprom_jli (struct fe_softc * sc, u_char * data) int i; data -= JLI_EEPROM_SIZE; for (i = 0; i < JLI_EEPROM_SIZE; i += 16) { - printf("fe%d: EEPROM(JLI):%3x: %16D\n", - sc->sc_unit, i, data + i, " "); + printf("%s: EEPROM(JLI):%3x: %16D\n", + sc->sc_xname, i, data + i, " "); } } #endif @@ -539,8 +539,8 @@ fe_read_eeprom_ssi (struct fe_softc *sc, u_char *data) int i; data -= SSI_EEPROM_SIZE; for (i = 0; i < SSI_EEPROM_SIZE; i += 16) { - printf("fe%d: EEPROM(SSI):%3x: %16D\n", - sc->sc_unit, i, data + i, " "); + printf("%s: EEPROM(SSI):%3x: %16D\n", + sc->sc_xname, i, data + i, " "); } } #endif @@ -641,8 +641,8 @@ fe_read_eeprom_lnx (struct fe_softc *sc, u_char *data) this board was not a TDK/LANX) or not working properly. */ if (bootverbose) { - printf("fe%d: no ACK received from EEPROM(LNX)\n", - sc->sc_unit); + printf("%s: no ACK received from EEPROM(LNX)\n", + sc->sc_xname); } /* Clear the given buffer to indicate we could not get any info. and return. */ @@ -680,8 +680,8 @@ fe_read_eeprom_lnx (struct fe_softc *sc, u_char *data) if (bootverbose) { data -= LNX_EEPROM_SIZE; for (i = 0; i < LNX_EEPROM_SIZE; i += 16) { - printf("fe%d: EEPROM(LNX):%3x: %16D\n", - sc->sc_unit, i, data + i, " "); + printf("%s: EEPROM(LNX):%3x: %16D\n", + sc->sc_xname, i, data + i, " "); } } #endif @@ -739,8 +739,7 @@ fe_attach (device_t dev) * Initialize ifnet structure */ sc->sc_if.if_softc = sc; - sc->sc_if.if_unit = sc->sc_unit; - sc->sc_if.if_name = "fe"; + if_initname(&sc->sc_if, device_get_name(dev), device_get_unit(dev)); sc->sc_if.if_output = ether_output; sc->sc_if.if_start = fe_start; sc->sc_if.if_ioctl = fe_ioctl; @@ -791,8 +790,8 @@ fe_attach (device_t dev) default: /* Oops, we can't work with single buffer configuration. */ if (bootverbose) { - printf("fe%d: strange TXBSIZ config; fixing\n", - sc->sc_unit); + printf("%s: strange TXBSIZ config; fixing\n", + sc->sc_xname); } sc->proto_dlcr6 &= ~FE_D6_TXBSIZ; sc->proto_dlcr6 |= FE_D6_TXBSIZ_2x2KB; @@ -1013,7 +1012,7 @@ fe_init (void * xsc) /* We need an address. */ if (TAILQ_EMPTY(&sc->sc_if.if_addrhead)) { /* XXX unlikely */ #ifdef DIAGNOSTIC - printf("fe%d: init() without any address\n", sc->sc_unit); + printf("%s: init() without any address\n", sc->sc_xname); #endif return; } @@ -1098,8 +1097,8 @@ fe_init (void * xsc) * The following message helps discovering the fact. FIXME. */ if (!(fe_inb(sc, FE_DLCR5) & FE_D5_BUFEMP)) { - printf("fe%d: receive buffer has some data after reset\n", - sc->sc_unit); + printf("%s: receive buffer has some data after reset\n", + sc->sc_xname); fe_emptybuffer(sc); } @@ -1366,7 +1365,7 @@ fe_emptybuffer (struct fe_softc * sc) u_char saved_dlcr5; #ifdef FE_DEBUG - printf("fe%d: emptying receive buffer\n", sc->sc_unit); + printf("%s: emptying receive buffer\n", sc->sc_xname); #endif /* @@ -1402,7 +1401,7 @@ fe_emptybuffer (struct fe_softc * sc) * Double check. */ if (fe_inb(sc, FE_DLCR5) & FE_D5_BUFEMP) { - printf("fe%d: could not empty receive buffer\n", sc->sc_unit); + printf("%s: could not empty receive buffer\n", sc->sc_xname); /* Hmm. What should I do if this happens? FIXME. */ } @@ -1433,8 +1432,8 @@ fe_tint (struct fe_softc * sc, u_char tstat) * are left unsent in transmission buffer. */ left = fe_inb(sc, FE_BMPR10); - printf("fe%d: excessive collision (%d/%d)\n", - sc->sc_unit, left, sc->txb_sched); + printf("%s: excessive collision (%d/%d)\n", + sc->sc_xname, left, sc->txb_sched); /* * Clear the collision flag (in 86960) here @@ -1636,7 +1635,7 @@ fe_rint (struct fe_softc * sc, u_char rstat) if ((status & 0xF0) != 0x20 || len > ETHER_MAX_LEN - ETHER_CRC_LEN || len < ETHER_MIN_LEN - ETHER_CRC_LEN) { - printf("fe%d: RX buffer out-of-sync\n", sc->sc_unit); + printf("%s: RX buffer out-of-sync\n", sc->sc_xname); sc->sc_if.if_ierrors++; sc->mibdata.dot3StatsInternalMacReceiveErrors++; fe_reset(sc); @@ -1666,7 +1665,7 @@ fe_rint (struct fe_softc * sc, u_char rstat) /* Maximum number of frames has been received. Something strange is happening here... */ - printf("fe%d: unusual receive flood\n", sc->sc_unit); + printf("%s: unusual receive flood\n", sc->sc_xname); sc->mibdata.dot3StatsInternalMacReceiveErrors++; fe_reset(sc); } @@ -1740,7 +1739,7 @@ fe_intr (void *arg) fe_start(&sc->sc_if); } - printf("fe%d: too many loops\n", sc->sc_unit); + printf("%s: too many loops\n", sc->sc_xname); } /* @@ -1918,7 +1917,7 @@ fe_write_mbufs (struct fe_softc *sc, struct mbuf *m) /* Check if this matches the one in the packet header. */ if (length != m->m_pkthdr.len) { - printf("fe%d: packet length mismatch? (%d/%d)\n", sc->sc_unit, + printf("%s: packet length mismatch? (%d/%d)\n", sc->sc_xname, length, m->m_pkthdr.len); } #else @@ -1934,8 +1933,8 @@ fe_write_mbufs (struct fe_softc *sc, struct mbuf *m) */ if (length < ETHER_HDR_LEN || length > ETHER_MAX_LEN - ETHER_CRC_LEN) { - printf("fe%d: got an out-of-spec packet (%u bytes) to send\n", - sc->sc_unit, length); + printf("%s: got an out-of-spec packet (%u bytes) to send\n", + sc->sc_xname, length); sc->sc_if.if_oerrors++; sc->mibdata.dot3StatsInternalMacTransmitErrors++; return; @@ -2086,8 +2085,8 @@ fe_mcaf ( struct fe_softc *sc ) continue; index = fe_hash(LLADDR((struct sockaddr_dl *)ifma->ifma_addr)); #ifdef FE_DEBUG - printf("fe%d: hash(%6D) == %d\n", - sc->sc_unit, enm->enm_addrlo , ":", index); + printf("%s: hash(%6D) == %d\n", + sc->sc_xname, enm->enm_addrlo , ":", index); #endif filter.data[index >> 3] |= 1 << (index & 7); @@ -2229,8 +2228,8 @@ fe_medchange (struct ifnet *ifp) if (bit2media[b] == sc->media.ifm_media) break; } if (((1 << b) & sc->mbitmap) == 0) { - printf("fe%d: got an unsupported media request (0x%x)\n", - sc->sc_unit, sc->media.ifm_media); + printf("%s: got an unsupported media request (0x%x)\n", + sc->sc_xname, sc->media.ifm_media); return EINVAL; } #endif diff --git a/sys/dev/fe/if_fevar.h b/sys/dev/fe/if_fevar.h index 37842b2..c8fd355 100644 --- a/sys/dev/fe/if_fevar.h +++ b/sys/dev/fe/if_fevar.h @@ -69,6 +69,7 @@ struct fe_softc { /* Used by "common" codes. */ struct arpcom arpcom; /* Ethernet common */ + int sc_unit; /* Used by config codes. */ int type; @@ -118,7 +119,7 @@ struct fe_softc { }; #define sc_if arpcom.ac_if -#define sc_unit arpcom.ac_if.if_unit +#define sc_xname arpcom.ac_if.if_xname #define sc_enaddr arpcom.ac_enaddr diff --git a/sys/dev/firewire/if_fwe.c b/sys/dev/firewire/if_fwe.c index b076497..92c0314 100644 --- a/sys/dev/firewire/if_fwe.c +++ b/sys/dev/firewire/if_fwe.c @@ -186,8 +186,7 @@ fwe_attach(device_t dev) ifp = &fwe->fwe_if; ifp->if_softc = &fwe->eth_softc; - ifp->if_unit = unit; - ifp->if_name = "fwe"; + if_initname(ifp, device_get_name(dev), device_get_unit(dev)); ifp->if_init = fwe_init; ifp->if_output = ether_output; ifp->if_start = fwe_start; @@ -211,7 +210,7 @@ fwe_attach(device_t dev) #endif - FWEDEBUG("interface %s%d created.\n", ifp->if_name, ifp->if_unit); + FWEDEBUG("interface %s created.\n", ifp->if_xname); return 0; } @@ -287,7 +286,7 @@ fwe_init(void *arg) struct mbuf *m; int i; - FWEDEBUG("initializing %s%d\n", ifp->if_name, ifp->if_unit); + FWEDEBUG("initializing %s\n", ifp->if_xname); /* XXX keep promiscoud mode */ ifp->if_flags |= IFF_PROMISC; @@ -464,12 +463,12 @@ fwe_start(struct ifnet *ifp) struct fwe_softc *fwe = ((struct fwe_eth_softc *)ifp->if_softc)->fwe; int s; - FWEDEBUG("%s%d starting\n", ifp->if_name, ifp->if_unit); + FWEDEBUG("%s starting\n", ifp->if_xname); if (fwe->dma_ch < 0) { struct mbuf *m = NULL; - FWEDEBUG("%s%d not ready.\n", ifp->if_name, ifp->if_unit); + FWEDEBUG("%s not ready.\n", ifp->if_xname); s = splimp(); do { diff --git a/sys/dev/fxp/if_fxp.c b/sys/dev/fxp/if_fxp.c index 7fa3e88..39a42d0 100644 --- a/sys/dev/fxp/if_fxp.c +++ b/sys/dev/fxp/if_fxp.c @@ -793,8 +793,7 @@ fxp_attach(device_t dev) } ifp = &sc->arpcom.ac_if; - ifp->if_unit = device_get_unit(dev); - ifp->if_name = "fxp"; + if_initname(ifp, device_get_name(dev), device_get_unit(dev)); ifp->if_output = ether_output; ifp->if_baudrate = 100000000; ifp->if_init = fxp_init; diff --git a/sys/dev/gem/if_gem.c b/sys/dev/gem/if_gem.c index 3ae3c3e..5809e7b 100644 --- a/sys/dev/gem/if_gem.c +++ b/sys/dev/gem/if_gem.c @@ -250,8 +250,8 @@ gem_attach(sc) /* Initialize ifnet structure. */ ifp->if_softc = sc; - ifp->if_unit = device_get_unit(sc->sc_dev); - ifp->if_name = "gem"; + if_initname(ifp, device_get_name(sc->sc_dev), + device_get_unit(sc->sc_dev)); ifp->if_mtu = ETHERMTU; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_start = gem_start; diff --git a/sys/dev/gx/if_gx.c b/sys/dev/gx/if_gx.c index 3573a78..4b5955f 100644 --- a/sys/dev/gx/if_gx.c +++ b/sys/dev/gx/if_gx.c @@ -341,8 +341,7 @@ gx_attach(device_t dev) /* Set up ifnet structure */ ifp = &gx->arpcom.ac_if; ifp->if_softc = gx; - ifp->if_unit = device_get_unit(dev); - ifp->if_name = "gx"; + if_initname(ifp, device_get_name(dev), device_get_unit(dev)); ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = gx_ioctl; ifp->if_output = ether_output; diff --git a/sys/dev/harp/if_harp.c b/sys/dev/harp/if_harp.c index 02e1aa7..ac38b02 100644 --- a/sys/dev/harp/if_harp.c +++ b/sys/dev/harp/if_harp.c @@ -160,7 +160,7 @@ static const struct { static int harp_check_if(const struct ifnet *ifp) { - if (ifp->if_type == IFT_ATM && strcmp(ifp->if_name, "en")) + if (ifp->if_type == IFT_ATM && strcmp(ifp->if_dname, "en")) return (0); else return (-1); @@ -386,7 +386,7 @@ harp_attach(struct ifnet *parent) sc = malloc(sizeof(*sc), M_HARP, M_WAITOK | M_ZERO); sc->parent = parent; - sc->cmn.cu_unit = parent->if_unit; + sc->cmn.cu_unit = parent->if_dunit; sc->cmn.cu_mtu = HARP_MTU; sc->cmn.cu_ioctl = harp_ioctl; sc->cmn.cu_instvcc = harp_instvcc; @@ -469,10 +469,10 @@ harp_attach(struct ifnet *parent) sc->cmn.cu_config.ac_macaddr.ma_data[5] = sc->cmn.cu_pif.pif_macaddr.ma_data[5] = mib->esi[5]; - error = atm_physif_register(&sc->cmn, parent->if_name, harp_services); + error = atm_physif_register(&sc->cmn, parent->if_dname, harp_services); if (error) { log(LOG_ERR, "%s: pif registration failed %d\n", - parent->if_name, error); + parent->if_dname, error); free(sc, M_HARP); return; } @@ -498,7 +498,7 @@ harp_detach(struct ifnet *ifp) error = atm_physif_deregister(&sc->cmn); if (error) - log(LOG_ERR, "%s: de-registration failed %d\n", ifp->if_name, + log(LOG_ERR, "%s: de-registration failed %d\n", ifp->if_dname, error); LIST_REMOVE(sc, link); diff --git a/sys/dev/hatm/if_hatm.c b/sys/dev/hatm/if_hatm.c index 5295ee0..cb1b23b 100644 --- a/sys/dev/hatm/if_hatm.c +++ b/sys/dev/hatm/if_hatm.c @@ -1639,13 +1639,11 @@ static int hatm_attach(device_t dev) { struct hatm_softc *sc; - int unit; int error; uint32_t v; struct ifnet *ifp; sc = device_get_softc(dev); - unit = device_get_unit(dev); sc->dev = dev; sc->ifatm.mib.device = ATM_DEVICE_HE155; @@ -1760,8 +1758,7 @@ hatm_attach(device_t dev) ifp = &sc->ifatm.ifnet; ifp->if_softc = sc; - ifp->if_unit = unit; - ifp->if_name = "hatm"; + if_initname(ifp, device_get_name(dev), device_get_unit(dev)); /* * Make the sysctl tree diff --git a/sys/dev/hme/if_hme.c b/sys/dev/hme/if_hme.c index 718a921..bbb428b 100644 --- a/sys/dev/hme/if_hme.c +++ b/sys/dev/hme/if_hme.c @@ -268,8 +268,8 @@ hme_config(struct hme_softc *sc) /* Initialize ifnet structure. */ ifp->if_softc = sc; - ifp->if_unit = device_get_unit(sc->sc_dev); - ifp->if_name = "hme"; + if_initname(ifp, device_get_name(sc->sc_dev), + device_get_unit(sc->sc_dev)); ifp->if_mtu = ETHERMTU; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX |IFF_MULTICAST; ifp->if_start = hme_start; diff --git a/sys/dev/ie/if_ie.c b/sys/dev/ie/if_ie.c index 2ebc298..4251738 100644 --- a/sys/dev/ie/if_ie.c +++ b/sys/dev/ie/if_ie.c @@ -307,8 +307,7 @@ ie_attach(device_t dev) ie_hardware_names[sc->hard_type], sc->hard_vers + 1); ifp->if_softc = sc; - ifp->if_unit = sc->unit; - ifp->if_name = "ie"; + if_initname(ifp, device_get_name(dev), device_get_unit(dev)); ifp->if_mtu = ETHERMTU; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_start = iestart; diff --git a/sys/dev/iicbus/if_ic.c b/sys/dev/iicbus/if_ic.c index d09973a..a98720f 100644 --- a/sys/dev/iicbus/if_ic.c +++ b/sys/dev/iicbus/if_ic.c @@ -134,8 +134,7 @@ icattach(device_t dev) sc->ic_addr = PCF_MASTER_ADDRESS; /* XXX only PCF masters */ ifp->if_softc = sc; - ifp->if_name = "ic"; - ifp->if_unit = device_get_unit(dev); + if_initname(ifp, device_get_name(dev), device_get_unit(dev)); ifp->if_mtu = ICMTU; ifp->if_flags = IFF_SIMPLEX | IFF_POINTOPOINT | IFF_MULTICAST; ifp->if_ioctl = icioctl; @@ -158,7 +157,7 @@ icattach(device_t dev) static int icioctl(struct ifnet *ifp, u_long cmd, caddr_t data) { - device_t icdev = devclass_get_device(ic_devclass, ifp->if_unit); + device_t icdev = devclass_get_device(ic_devclass, ifp->if_dunit); device_t parent = device_get_parent(icdev); struct ic_softc *sc = (struct ic_softc *)device_get_softc(icdev); @@ -363,7 +362,7 @@ static int icoutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, struct rtentry *rt) { - device_t icdev = devclass_get_device(ic_devclass, ifp->if_unit); + device_t icdev = devclass_get_device(ic_devclass, ifp->if_dunit); device_t parent = device_get_parent(icdev); struct ic_softc *sc = (struct ic_softc *)device_get_softc(icdev); diff --git a/sys/dev/lge/if_lge.c b/sys/dev/lge/if_lge.c index 1af3725..bd545e3 100644 --- a/sys/dev/lge/if_lge.c +++ b/sys/dev/lge/if_lge.c @@ -615,8 +615,7 @@ lge_attach(dev) ifp = &sc->arpcom.ac_if; ifp->if_softc = sc; - ifp->if_unit = unit; - ifp->if_name = "lge"; + if_initname(ifp, device_get_name(dev), device_get_unit(dev)); ifp->if_mtu = ETHERMTU; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = lge_ioctl; diff --git a/sys/dev/lnc/if_lnc.c b/sys/dev/lnc/if_lnc.c index e8b526b..3173b0c 100644 --- a/sys/dev/lnc/if_lnc.c +++ b/sys/dev/lnc/if_lnc.c @@ -468,14 +468,12 @@ lnc_rint(struct lnc_softc *sc) #ifdef DIAGNOSTIC if ((sc->recv_ring + sc->recv_next)->md->md1 & OWN) { - int unit = ifp->if_unit; - log(LOG_ERR, "lnc%d: Receive interrupt with buffer still owned by controller -- Resetting\n", unit); + log(LOG_ERR, "%s: Receive interrupt with buffer still owned by controller -- Resetting\n", ifp->if_xname); lnc_reset(sc); return; } if (!((sc->recv_ring + sc->recv_next)->md->md1 & STP)) { - int unit = ifp->if_unit; - log(LOG_ERR, "lnc%d: Receive interrupt but not start of packet -- Resetting\n", unit); + log(LOG_ERR, "%s: Receive interrupt but not start of packet -- Resetting\n", ifp->if_xname); lnc_reset(sc); return; } @@ -506,8 +504,7 @@ lnc_rint(struct lnc_softc *sc) } while (!(flags & (STP | OWN | ENP | MDERR))); if (flags & STP) { - int unit = ifp->if_unit; - log(LOG_ERR, "lnc%d: Start of packet found before end of previous in receive ring -- Resetting\n", unit); + log(LOG_ERR, "%s: Start of packet found before end of previous in receive ring -- Resetting\n", ifp->if_xname); lnc_reset(sc); return; } @@ -520,8 +517,7 @@ lnc_rint(struct lnc_softc *sc) sc->recv_next = start_of_packet; break; } else { - int unit = ifp->if_unit; - log(LOG_ERR, "lnc%d: End of received packet not found-- Resetting\n", unit); + log(LOG_ERR, "%s: End of received packet not found-- Resetting\n", ifp->if_xname); lnc_reset(sc); return; } @@ -535,16 +531,16 @@ lnc_rint(struct lnc_softc *sc) next = sc->recv_ring + sc->recv_next; if (flags & MDERR) { - int unit = ifp->if_unit; + const char *if_xname = ifp->if_xname; if (flags & RBUFF) { LNCSTATS(rbuff) - log(LOG_ERR, "lnc%d: Receive buffer error\n", unit); + log(LOG_ERR, "%s: Receive buffer error\n", if_xname); } if (flags & OFLO) { /* OFLO only valid if ENP is not set */ if (!(flags & ENP)) { LNCSTATS(oflo) - log(LOG_ERR, "lnc%d: Receive overflow error \n", unit); + log(LOG_ERR, "%s: Receive overflow error \n", if_xname); } } else if (flags & ENP) { if ((ifp->if_flags & IFF_PROMISC)==0) { @@ -554,14 +550,14 @@ lnc_rint(struct lnc_softc *sc) */ if (flags & FRAM) { LNCSTATS(fram) - log(LOG_ERR, "lnc%d: Framing error\n", unit); + log(LOG_ERR, "%s: Framing error\n", if_xname); /* * FRAM is only set if there's a CRC * error so avoid multiple messages */ } else if (flags & CRC) { LNCSTATS(crc) - log(LOG_ERR, "lnc%d: Receive CRC error\n", unit); + log(LOG_ERR, "%s: Receive CRC error\n", if_xname); } } } @@ -607,8 +603,7 @@ lnc_rint(struct lnc_softc *sc) (*ifp->if_input)(ifp, head); } } else { - int unit = ifp->if_unit; - log(LOG_ERR,"lnc%d: Packet dropped, no mbufs\n",unit); + log(LOG_ERR,"%s: Packet dropped, no mbufs\n",ifp->if_xname); LNCSTATS(drop_packet) } } @@ -649,8 +644,7 @@ lnc_tint(struct lnc_softc *sc) #ifdef DIAGNOSTIC if ((sc->trans_ring + sc->trans_next)->md->md1 & OWN) { - int unit = sc->arpcom.ac_if.if_unit; - log(LOG_ERR, "lnc%d: Transmit interrupt with buffer still owned by controller -- Resetting\n", unit); + log(LOG_ERR, "%s: Transmit interrupt with buffer still owned by controller -- Resetting\n", sc->arpcom.ac_if.if_xname); lnc_reset(sc); return; } @@ -678,12 +672,11 @@ lnc_tint(struct lnc_softc *sc) next = sc->trans_ring + sc->trans_next; #ifdef DIAGNOSTIC - if (!(next->md->md1 & STP)) { - int unit = sc->arpcom.ac_if.if_unit; - log(LOG_ERR, "lnc%d: Transmit interrupt but not start of packet -- Resetting\n", unit); - lnc_reset(sc); - return; - } + if (!(next->md->md1 & STP)) { + log(LOG_ERR, "%s: Transmit interrupt but not start of packet -- Resetting\n", sc->arpcom.ac_if.if_xname); + lnc_reset(sc); + return; + } #endif /* @@ -697,8 +690,7 @@ lnc_tint(struct lnc_softc *sc) } while (!(next->md->md1 & (STP | OWN | ENP | MDERR))); if (next->md->md1 & STP) { - int unit = sc->arpcom.ac_if.if_unit; - log(LOG_ERR, "lnc%d: Start of packet found before end of previous in transmit ring -- Resetting\n", unit); + log(LOG_ERR, "%s: Start of packet found before end of previous in transmit ring -- Resetting\n", sc->arpcom.ac_if.if_xname); lnc_reset(sc); return; } @@ -711,8 +703,7 @@ lnc_tint(struct lnc_softc *sc) sc->trans_next = start_of_packet; break; } else { - int unit = sc->arpcom.ac_if.if_unit; - log(LOG_ERR, "lnc%d: End of transmitted packet not found -- Resetting\n", unit); + log(LOG_ERR, "%s: End of transmitted packet not found -- Resetting\n", sc->arpcom.ac_if.if_xname); lnc_reset(sc); return; } @@ -724,14 +715,12 @@ lnc_tint(struct lnc_softc *sc) */ if (next->md->md1 & MDERR) { - int unit = sc->arpcom.ac_if.if_unit; - LNCSTATS(terr) sc->arpcom.ac_if.if_oerrors++; if (next->md->md3 & LCOL) { LNCSTATS(lcol) - log(LOG_ERR, "lnc%d: Transmit late collision -- Net error?\n", unit); + log(LOG_ERR, "%s: Transmit late collision -- Net error?\n", sc->arpcom.ac_if.if_xname); sc->arpcom.ac_if.if_collisions++; /* * Clear TBUFF since it's not valid when LCOL @@ -741,11 +730,11 @@ lnc_tint(struct lnc_softc *sc) } if (next->md->md3 & LCAR) { LNCSTATS(lcar) - log(LOG_ERR, "lnc%d: Loss of carrier during transmit -- Net error?\n", unit); + log(LOG_ERR, "%s: Loss of carrier during transmit -- Net error?\n", sc->arpcom.ac_if.if_xname); } if (next->md->md3 & RTRY) { LNCSTATS(rtry) - log(LOG_ERR, "lnc%d: Transmit of packet failed after 16 attempts -- TDR = %d\n", unit, ((sc->trans_ring + sc->trans_next)->md->md3 & TDR)); + log(LOG_ERR, "%s: Transmit of packet failed after 16 attempts -- TDR = %d\n", sc->arpcom.ac_if.if_xname, ((sc->trans_ring + sc->trans_next)->md->md3 & TDR)); sc->arpcom.ac_if.if_collisions += 16; /* * Clear TBUFF since it's not valid when RTRY @@ -771,9 +760,9 @@ lnc_tint(struct lnc_softc *sc) */ if (next->md->md3 & TBUFF) { LNCSTATS(tbuff) - log(LOG_ERR, "lnc%d: Transmit buffer error -- Resetting\n", unit); + log(LOG_ERR, "%s: Transmit buffer error -- Resetting\n", sc->arpcom.ac_if.if_xname); } else - log(LOG_ERR, "lnc%d: Transmit underflow error -- Resetting\n", unit); + log(LOG_ERR, "%s: Transmit underflow error -- Resetting\n", sc->arpcom.ac_if.if_xname); lnc_reset(sc); return; } @@ -865,7 +854,6 @@ lnc_tint(struct lnc_softc *sc) int lnc_attach_common(device_t dev) { - int unit = device_get_unit(dev); lnc_softc_t *sc = device_get_softc(dev); int i; int skip; @@ -886,8 +874,8 @@ lnc_attach_common(device_t dev) /* Fill in arpcom structure entries */ sc->arpcom.ac_if.if_softc = sc; - sc->arpcom.ac_if.if_name = "lnc"; - sc->arpcom.ac_if.if_unit = unit; + if_initname(&sc->arpcom.ac_if, device_get_name(dev), + device_get_unit(dev)); sc->arpcom.ac_if.if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; sc->arpcom.ac_if.if_timer = 0; sc->arpcom.ac_if.if_output = ether_output; @@ -907,7 +895,7 @@ lnc_attach_common(device_t dev) ether_ifattach(&sc->arpcom.ac_if, sc->arpcom.ac_enaddr); - printf("lnc%d: ", unit); + printf("%s: ", sc->arpcom.ac_if.if_xname); if (sc->nic.ic == LANCE || sc->nic.ic == C_LANCE) printf("%s (%s)", nic_ident[sc->nic.ident], ic_ident[sc->nic.ic]); @@ -1094,8 +1082,8 @@ printf("Enabling lnc interrupts\n"); sc->arpcom.ac_if.if_flags &= ~IFF_OACTIVE; lnc_start(&sc->arpcom.ac_if); } else - log(LOG_ERR, "lnc%d: Initialisation failed\n", - sc->arpcom.ac_if.if_unit); + log(LOG_ERR, "%s: Initialisation failed\n", + sc->arpcom.ac_if.if_xname); splx(s); } @@ -1125,7 +1113,6 @@ void lncintr(void *arg) { lnc_softc_t *sc = arg; - int unit = sc->arpcom.ac_if.if_unit; u_short csr0; /* @@ -1160,21 +1147,21 @@ printf("IDON\n"); if (csr0 & ERR) { if (csr0 & CERR) { - log(LOG_ERR, "lnc%d: Heartbeat error -- SQE test failed\n", unit); + log(LOG_ERR, "%s: Heartbeat error -- SQE test failed\n", sc->arpcom.ac_if.if_xname); LNCSTATS(cerr) } if (csr0 & BABL) { - log(LOG_ERR, "lnc%d: Babble error - more than 1519 bytes transmitted\n", unit); + log(LOG_ERR, "%s: Babble error - more than 1519 bytes transmitted\n", sc->arpcom.ac_if.if_xname); LNCSTATS(babl) sc->arpcom.ac_if.if_oerrors++; } if (csr0 & MISS) { - log(LOG_ERR, "lnc%d: Missed packet -- no receive buffer\n", unit); + log(LOG_ERR, "%s: Missed packet -- no receive buffer\n", sc->arpcom.ac_if.if_xname); LNCSTATS(miss) sc->arpcom.ac_if.if_ierrors++; } if (csr0 & MERR) { - log(LOG_ERR, "lnc%d: Memory error -- Resetting\n", unit); + log(LOG_ERR, "%s: Memory error -- Resetting\n", sc->arpcom.ac_if.if_xname); LNCSTATS(merr) lnc_reset(sc); continue; @@ -1282,7 +1269,7 @@ lnc_start(struct ifnet *ifp) if (no_entries_needed > (NDESC(sc->ntdre) - sc->pending_transmits)) { if (!(head = chain_to_cluster(head))) { - log(LOG_ERR, "lnc%d: Couldn't get mbuf for transmit packet -- Resetting \n ",ifp->if_unit); + log(LOG_ERR, "%s: Couldn't get mbuf for transmit packet -- Resetting \n ",ifp->if_xname); lnc_reset(sc); return; } @@ -1465,7 +1452,7 @@ lnc_ioctl(struct ifnet * ifp, u_long command, caddr_t data) static void lnc_watchdog(struct ifnet *ifp) { - log(LOG_ERR, "lnc%d: Device timeout -- Resetting\n", ifp->if_unit); + log(LOG_ERR, "%s: Device timeout -- Resetting\n", ifp->if_xname); ifp->if_oerrors++; lnc_reset(ifp->if_softc); } @@ -1476,7 +1463,7 @@ lnc_dump_state(struct lnc_softc *sc) { int i; - printf("\nDriver/NIC [%d] state dump\n", sc->arpcom.ac_if.if_unit); + printf("\nDriver/NIC [%s] state dump\n", sc->arpcom.ac_if.if_xname); printf("Memory access mode: %b\n", sc->nic.mem_mode, MEM_MODES); printf("Host memory\n"); printf("-----------\n"); diff --git a/sys/dev/mii/brgphy.c b/sys/dev/mii/brgphy.c index 29e1f72..6b4d38f 100644 --- a/sys/dev/mii/brgphy.c +++ b/sys/dev/mii/brgphy.c @@ -199,7 +199,7 @@ brgphy_attach(dev) bge_sc = mii->mii_ifp->if_softc; - if (strcmp(mii->mii_ifp->if_name, "bge") == 0 && + if (strcmp(mii->mii_ifp->if_dname, "bge") == 0 && pci_get_vendor(bge_sc->bge_dev) == BCOM_VENDORID && (pci_get_device(bge_sc->bge_dev) == BCOM_DEVICEID_BCM5901 || pci_get_device(bge_sc->bge_dev) == BCOM_DEVICEID_BCM5901A2)) @@ -613,7 +613,7 @@ brgphy_reset(struct mii_softc *sc) * on "bge" NICs, since other drivers may use this same * PHY subdriver. */ - if (strcmp(ifp->if_name, "bge") == 0 && + if (strcmp(ifp->if_dname, "bge") == 0 && (bge_sc->bge_asicrev == BGE_ASICREV_BCM5700 || bge_sc->bge_chipid == BGE_CHIPID_BCM5705_A1 || bge_sc->bge_chipid == BGE_CHIPID_BCM5705_A2)) diff --git a/sys/dev/my/if_my.c b/sys/dev/my/if_my.c index 2f87fa8..d580e9c 100644 --- a/sys/dev/my/if_my.c +++ b/sys/dev/my/if_my.c @@ -994,8 +994,7 @@ my_attach(device_t dev) ifp = &sc->arpcom.ac_if; ifp->if_softc = sc; - ifp->if_unit = unit; - ifp->if_name = "my"; + if_initname(ifp, device_get_name(dev), device_get_unit(dev)); ifp->if_mtu = ETHERMTU; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = my_ioctl; diff --git a/sys/dev/nge/if_nge.c b/sys/dev/nge/if_nge.c index fb154a6..0fca198 100644 --- a/sys/dev/nge/if_nge.c +++ b/sys/dev/nge/if_nge.c @@ -948,8 +948,7 @@ nge_attach(dev) ifp = &sc->arpcom.ac_if; ifp->if_softc = sc; - ifp->if_unit = unit; - ifp->if_name = "nge"; + if_initname(ifp, device_get_name(dev), device_get_unit(dev)); ifp->if_mtu = ETHERMTU; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = nge_ioctl; diff --git a/sys/dev/patm/if_patm_attach.c b/sys/dev/patm/if_patm_attach.c index f0730ba..37814bc 100644 --- a/sys/dev/patm/if_patm_attach.c +++ b/sys/dev/patm/if_patm_attach.c @@ -192,8 +192,7 @@ patm_attach(device_t dev) ifp = &sc->ifatm.ifnet; ifp->if_softc = sc; - ifp->if_unit = device_get_unit(dev); - ifp->if_name = "patm"; + if_initname(ifp, device_get_name(dev), device_get_unit(dev)); ifp->if_flags = IFF_SIMPLEX; ifp->if_watchdog = NULL; ifp->if_init = patm_init; diff --git a/sys/dev/pdq/if_fea.c b/sys/dev/pdq/if_fea.c index 95200f7..2c1dc43 100644 --- a/sys/dev/pdq/if_fea.c +++ b/sys/dev/pdq/if_fea.c @@ -223,12 +223,11 @@ pdq_eisa_attach (dev) goto bad; } - ifp->if_name = "fea"; - ifp->if_unit = device_get_unit(dev); + if_initname(ifp, device_get_name(dev), device_get_unit(dev)); pdq_eisa_devinit(sc); sc->sc_pdq = pdq_initialize(sc->mem_bst, sc->mem_bsh, - ifp->if_name, ifp->if_unit, + ifp->if_xname, -1, (void *)sc, PDQ_DEFEA); if (sc->sc_pdq == NULL) { device_printf(dev, "Initialization failed.\n"); diff --git a/sys/dev/pdq/if_fpa.c b/sys/dev/pdq/if_fpa.c index 8aeccbf..997f0cc 100644 --- a/sys/dev/pdq/if_fpa.c +++ b/sys/dev/pdq/if_fpa.c @@ -149,11 +149,10 @@ pdq_pci_attach(device_t dev) goto bad; } - ifp->if_name = "fpa"; - ifp->if_unit = device_get_unit(dev); + if_initname(ifp, device_get_name(dev), device_get_unit(dev)); sc->sc_pdq = pdq_initialize(sc->mem_bst, sc->mem_bsh, - ifp->if_name, ifp->if_unit, + ifp->if_xname, -1, (void *)sc, PDQ_DEFPA); if (sc->sc_pdq == NULL) { device_printf(dev, "Initialization failed.\n"); diff --git a/sys/dev/pdq/pdq_freebsd.h b/sys/dev/pdq/pdq_freebsd.h index f43f3e3..c86b14b 100644 --- a/sys/dev/pdq/pdq_freebsd.h +++ b/sys/dev/pdq/pdq_freebsd.h @@ -158,8 +158,8 @@ typedef struct _pdq_os_ctx_t { #if defined(PDQ_HWSUPPORT) -#define PDQ_OS_PREFIX "%s%d: " -#define PDQ_OS_PREFIX_ARGS pdq->pdq_os_name, pdq->pdq_unit +#define PDQ_OS_PREFIX "%s: " +#define PDQ_OS_PREFIX_ARGS pdq->pdq_os_name #define PDQ_OS_PTR_FMT "%p" #define PDQ_OS_CSR_FMT "0x%x" diff --git a/sys/dev/pdq/pdqvar.h b/sys/dev/pdq/pdqvar.h index 09358d8..1ac3d85 100644 --- a/sys/dev/pdq/pdqvar.h +++ b/sys/dev/pdq/pdqvar.h @@ -73,7 +73,7 @@ enum _pdq_type_t { #include <vm/vm_kern.h> #define PDQ_USE_MBUFS -#if defined(__NetBSD__) +#if defined(__NetBSD__) || defined(__FreeBSD__) #define PDQ_OS_PREFIX "%s: " #define PDQ_OS_PREFIX_ARGS pdq->pdq_os_name #else diff --git a/sys/dev/ppbus/if_plip.c b/sys/dev/ppbus/if_plip.c index ad2c3be..ab02841 100644 --- a/sys/dev/ppbus/if_plip.c +++ b/sys/dev/ppbus/if_plip.c @@ -233,8 +233,7 @@ lp_attach (device_t dev) struct ifnet *ifp = &lp->sc_if; ifp->if_softc = lp; - ifp->if_name = "lp"; - ifp->if_unit = device_get_unit(dev); + if_initname(ifp, device_get_name(dev), device_get_unit(dev)); ifp->if_mtu = LPMTU; ifp->if_flags = IFF_SIMPLEX | IFF_POINTOPOINT | IFF_MULTICAST; ifp->if_ioctl = lpioctl; @@ -295,7 +294,7 @@ lpinittables (void) static int lpioctl (struct ifnet *ifp, u_long cmd, caddr_t data) { - device_t dev = UNITODEVICE(ifp->if_unit); + device_t dev = UNITODEVICE(ifp->if_dunit); device_t ppbus = device_get_parent(dev); struct lp_data *sc = DEVTOSOFTC(dev); struct ifaddr *ifa = (struct ifaddr *)data; @@ -609,7 +608,7 @@ static int lpoutput (struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, struct rtentry *rt) { - device_t dev = UNITODEVICE(ifp->if_unit); + device_t dev = UNITODEVICE(ifp->if_dunit); device_t ppbus = device_get_parent(dev); int s, err; struct mbuf *mm; diff --git a/sys/dev/ray/if_ray.c b/sys/dev/ray/if_ray.c index b37f9c3..3319396 100644 --- a/sys/dev/ray/if_ray.c +++ b/sys/dev/ray/if_ray.c @@ -503,8 +503,7 @@ ray_attach(device_t dev) bcopy((char *)&ep->e_station_addr, (char *)&sc->arpcom.ac_enaddr, ETHER_ADDR_LEN); ifp->if_softc = sc; - ifp->if_name = "ray"; - ifp->if_unit = device_get_unit(dev); + if_initname(ifp, device_get_name(dev), device_get_unit(dev)); ifp->if_timer = 0; ifp->if_flags = (IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST); ifp->if_hdrlen = sizeof(struct ieee80211_frame) + diff --git a/sys/dev/re/if_re.c b/sys/dev/re/if_re.c index 004c4c6..549d3ae 100644 --- a/sys/dev/re/if_re.c +++ b/sys/dev/re/if_re.c @@ -1254,8 +1254,7 @@ re_attach(dev) ifp = &sc->arpcom.ac_if; ifp->if_softc = sc; - ifp->if_unit = unit; - ifp->if_name = "re"; + if_initname(ifp, device_get_name(dev), device_get_unit(dev)); ifp->if_mtu = ETHERMTU; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = re_ioctl; diff --git a/sys/dev/sbni/if_sbni.c b/sys/dev/sbni/if_sbni.c index 1697a41..dad1dce 100644 --- a/sys/dev/sbni/if_sbni.c +++ b/sys/dev/sbni/if_sbni.c @@ -228,8 +228,7 @@ sbni_attach(struct sbni_softc *sc, int unit, struct sbni_flags flags) callout_handle_init(&sc->wch); /* Initialize ifnet structure */ ifp->if_softc = sc; - ifp->if_unit = unit; - ifp->if_name = "sbni"; + if_initname(ifp, "sbni", unit); ifp->if_init = sbni_init; ifp->if_start = sbni_start; ifp->if_output = ether_output; @@ -926,7 +925,7 @@ card_start(struct sbni_softc *sc) static void sbni_watchdog(struct ifnet *ifp) { - log(LOG_ERR, "sbni%d: device timeout\n", ifp->if_unit); + log(LOG_ERR, "%s: device timeout\n", ifp->if_xname); ifp->if_oerrors++; } diff --git a/sys/dev/sbni/if_sbni_isa.c b/sys/dev/sbni/if_sbni_isa.c index 6da8b32..cb7b02c 100644 --- a/sys/dev/sbni/if_sbni_isa.c +++ b/sys/dev/sbni/if_sbni_isa.c @@ -156,8 +156,8 @@ sbni_attach_isa(device_t dev) dev, SYS_RES_IOPORT, sc->io_rid, sc->io_res); return (ENXIO); } else { - printf(" shared irq with sbni%d\n", - master->arpcom.ac_if.if_unit); + printf(" shared irq with %s\n", + master->arpcom.ac_if.if_xname); } } #endif /* SBNI_DUAL_COMPOUND */ diff --git a/sys/dev/sbsh/if_sbsh.c b/sys/dev/sbsh/if_sbsh.c index 9678e10..0360e20 100644 --- a/sys/dev/sbsh/if_sbsh.c +++ b/sys/dev/sbsh/if_sbsh.c @@ -268,8 +268,7 @@ sbsh_attach(device_t dev) ifp = &sc->arpcom.ac_if; ifp->if_softc = sc; - ifp->if_unit = unit; - ifp->if_name = "sbsh"; + if_initname(ifp, device_get_name(dev), device_get_unit(dev)); ifp->if_mtu = ETHERMTU; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = sbsh_ioctl; diff --git a/sys/dev/sf/if_sf.c b/sys/dev/sf/if_sf.c index fcd05ff..6642809 100644 --- a/sys/dev/sf/if_sf.c +++ b/sys/dev/sf/if_sf.c @@ -770,8 +770,7 @@ sf_attach(dev) ifp = &sc->arpcom.ac_if; ifp->if_softc = sc; - ifp->if_unit = unit; - ifp->if_name = "sf"; + if_initname(ifp, device_get_name(dev), device_get_unit(dev)); ifp->if_mtu = ETHERMTU; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = sf_ioctl; diff --git a/sys/dev/sk/if_sk.c b/sys/dev/sk/if_sk.c index 813c94d..2773236 100644 --- a/sys/dev/sk/if_sk.c +++ b/sys/dev/sk/if_sk.c @@ -1394,8 +1394,7 @@ sk_attach(dev) ifp = &sc_if->arpcom.ac_if; ifp->if_softc = sc_if; - ifp->if_unit = sc_if->sk_unit; - ifp->if_name = "sk"; + if_initname(ifp, device_get_name(dev), device_get_unit(dev)); ifp->if_mtu = ETHERMTU; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = sk_ioctl; diff --git a/sys/dev/sn/if_sn.c b/sys/dev/sn/if_sn.c index 5cb968a..49cd843 100644 --- a/sys/dev/sn/if_sn.c +++ b/sys/dev/sn/if_sn.c @@ -203,8 +203,7 @@ sn_attach(device_t dev) } printf(" MAC address %6D\n", sc->arpcom.ac_enaddr, ":"); ifp->if_softc = sc; - ifp->if_unit = device_get_unit(dev); - ifp->if_name = "sn"; + if_initname(ifp, device_get_name(dev), device_get_unit(dev)); ifp->if_mtu = ETHERMTU; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_output = ether_output; diff --git a/sys/dev/sr/if_sr.c b/sys/dev/sr/if_sr.c index d315a4f..745dada 100644 --- a/sys/dev/sr/if_sr.c +++ b/sys/dev/sr/if_sr.c @@ -419,8 +419,8 @@ sr_attach(device_t device) #ifndef NETGRAPH ifp = &sc->ifsppp.pp_if; ifp->if_softc = sc; - ifp->if_unit = sc->unit; - ifp->if_name = "sr"; + if_initname(ifp, device_get_name(device), + device_get_unit(device)); ifp->if_mtu = PP_MTU; ifp->if_flags = IFF_POINTOPOINT | IFF_MULTICAST; ifp->if_ioctl = srioctl; diff --git a/sys/dev/ti/if_ti.c b/sys/dev/ti/if_ti.c index 95bbfc4..4cbea9b 100644 --- a/sys/dev/ti/if_ti.c +++ b/sys/dev/ti/if_ti.c @@ -2187,8 +2187,7 @@ ti_attach(dev) /* Set up ifnet structure */ ifp = &sc->arpcom.ac_if; ifp->if_softc = sc; - ifp->if_unit = sc->ti_unit; - ifp->if_name = "ti"; + if_initname(ifp, device_get_name(dev), device_get_unit(dev)); ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; tis[unit] = sc; ifp->if_ioctl = ti_ioctl; @@ -2810,7 +2809,7 @@ static void ti_init2(sc) ifp = &sc->arpcom.ac_if; /* Specify MTU and interface index. */ - CSR_WRITE_4(sc, TI_GCR_IFINDEX, ifp->if_unit); + CSR_WRITE_4(sc, TI_GCR_IFINDEX, sc->ti_unit); CSR_WRITE_4(sc, TI_GCR_IFMTU, ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN + ETHER_VLAN_ENCAP_LEN); TI_DO_CMD(TI_CMD_UPDATE_GENCOM, 0, 0); diff --git a/sys/dev/tx/if_tx.c b/sys/dev/tx/if_tx.c index 4afcd0a..634e971 100644 --- a/sys/dev/tx/if_tx.c +++ b/sys/dev/tx/if_tx.c @@ -242,8 +242,7 @@ epic_attach(dev) /* Fill ifnet structure. */ ifp = &sc->sc_if; - ifp->if_unit = unit; - ifp->if_name = "tx"; + if_initname(ifp, device_get_name(dev), device_get_unit(dev)); ifp->if_softc = sc; ifp->if_flags = IFF_BROADCAST|IFF_SIMPLEX|IFF_MULTICAST; ifp->if_ioctl = epic_ifioctl; diff --git a/sys/dev/txp/if_txp.c b/sys/dev/txp/if_txp.c index dfc81b5..d5161ea 100644 --- a/sys/dev/txp/if_txp.c +++ b/sys/dev/txp/if_txp.c @@ -355,8 +355,7 @@ txp_attach(dev) ifp = &sc->sc_arpcom.ac_if; ifp->if_softc = sc; - ifp->if_unit = unit; - ifp->if_name = "txp"; + if_initname(ifp, device_get_name(dev), device_get_unit(dev)); ifp->if_mtu = ETHERMTU; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = txp_ioctl; diff --git a/sys/dev/usb/if_aue.c b/sys/dev/usb/if_aue.c index b584b6f..bbb5669 100644 --- a/sys/dev/usb/if_aue.c +++ b/sys/dev/usb/if_aue.c @@ -739,8 +739,7 @@ USB_ATTACH(aue) ifp = &sc->arpcom.ac_if; ifp->if_softc = sc; - ifp->if_unit = sc->aue_unit; - ifp->if_name = "aue"; + if_initname(ifp, "aue", sc->aue_unit); ifp->if_mtu = ETHERMTU; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = aue_ioctl; diff --git a/sys/dev/usb/if_axe.c b/sys/dev/usb/if_axe.c index a808754..b4df6e6 100644 --- a/sys/dev/usb/if_axe.c +++ b/sys/dev/usb/if_axe.c @@ -509,8 +509,7 @@ USB_ATTACH(axe) ifp = &sc->arpcom.ac_if; ifp->if_softc = sc; - ifp->if_unit = sc->axe_unit; - ifp->if_name = "axe"; + if_initname(ifp, "axe", sc->axe_unit); ifp->if_mtu = ETHERMTU; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = axe_ioctl; diff --git a/sys/dev/usb/if_cue.c b/sys/dev/usb/if_cue.c index 9497aab..54d887e 100644 --- a/sys/dev/usb/if_cue.c +++ b/sys/dev/usb/if_cue.c @@ -520,8 +520,7 @@ USB_ATTACH(cue) ifp = &sc->arpcom.ac_if; ifp->if_softc = sc; - ifp->if_unit = sc->cue_unit; - ifp->if_name = "cue"; + if_initname(ifp, "cue", sc->cue_unit); ifp->if_mtu = ETHERMTU; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = cue_ioctl; diff --git a/sys/dev/usb/if_kue.c b/sys/dev/usb/if_kue.c index 28140d8..2be9b50 100644 --- a/sys/dev/usb/if_kue.c +++ b/sys/dev/usb/if_kue.c @@ -489,8 +489,7 @@ USB_ATTACH(kue) ifp = &sc->arpcom.ac_if; ifp->if_softc = sc; - ifp->if_unit = sc->kue_unit; - ifp->if_name = "kue"; + if_initname(ifp, "kue", sc->kue_unit); ifp->if_mtu = ETHERMTU; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = kue_ioctl; diff --git a/sys/dev/usb/if_rue.c b/sys/dev/usb/if_rue.c index 53b3b77..b23184c 100644 --- a/sys/dev/usb/if_rue.c +++ b/sys/dev/usb/if_rue.c @@ -661,8 +661,7 @@ USB_ATTACH(rue) ifp = &sc->arpcom.ac_if; ifp->if_softc = sc; - ifp->if_unit = sc->rue_unit; - ifp->if_name = "rue"; + if_initname(ifp, "rue", sc->rue_unit); ifp->if_mtu = ETHERMTU; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = rue_ioctl; diff --git a/sys/dev/vr/if_vr.c b/sys/dev/vr/if_vr.c index 35343da..ffd2c3e 100644 --- a/sys/dev/vr/if_vr.c +++ b/sys/dev/vr/if_vr.c @@ -849,8 +849,7 @@ vr_attach(dev) ifp = &sc->arpcom.ac_if; ifp->if_softc = sc; - ifp->if_unit = unit; - ifp->if_name = "vr"; + if_initname(ifp, device_get_name(dev), device_get_unit(dev)); ifp->if_mtu = ETHERMTU; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = vr_ioctl; diff --git a/sys/dev/vx/if_vx.c b/sys/dev/vx/if_vx.c index 7c6e8a9..5f17e22 100644 --- a/sys/dev/vx/if_vx.c +++ b/sys/dev/vx/if_vx.c @@ -72,6 +72,8 @@ __FBSDID("$FreeBSD$"); #include <machine/bus_pio.h> #include <machine/bus.h> +#include <sys/bus.h> + #include <net/bpf.h> #include <dev/vx/if_vxreg.h> @@ -122,9 +124,10 @@ static void vxsetlink(struct vx_softc *); int -vxattach(sc) - struct vx_softc *sc; +vxattach(dev) + device_t dev; { + struct vx_softc *sc = device_get_softc(dev); struct ifnet *ifp = &sc->arpcom.ac_if; int i; @@ -154,8 +157,7 @@ vxattach(sc) printf(" address %6D\n", sc->arpcom.ac_enaddr, ":"); - ifp->if_unit = sc->unit; - ifp->if_name = "vx"; + if_initname(ifp, device_get_name(dev), device_get_unit(dev)); ifp->if_mtu = ETHERMTU; ifp->if_snd.ifq_maxlen = IFQ_MAXLEN; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; diff --git a/sys/dev/vx/if_vx_eisa.c b/sys/dev/vx/if_vx_eisa.c index 95e5554..4c8931d 100644 --- a/sys/dev/vx/if_vx_eisa.c +++ b/sys/dev/vx/if_vx_eisa.c @@ -155,7 +155,7 @@ vx_eisa_attach(device_t dev) /* Now the registers are availible through the lower ioport */ - vxattach(sc); + vxattach(dev); if (bus_setup_intr(dev, irq, INTR_TYPE_NET, vxintr, sc, &ih)) { goto bad; diff --git a/sys/dev/vx/if_vx_pci.c b/sys/dev/vx/if_vx_pci.c index 201b4ea..ff4f1fb 100644 --- a/sys/dev/vx/if_vx_pci.c +++ b/sys/dev/vx/if_vx_pci.c @@ -151,7 +151,7 @@ vx_pci_attach( vxintr, sc, &sc->vx_intrhand)) goto bad; - if (vxattach(sc) == 0) { + if (vxattach(dev) == 0) { goto bad; } diff --git a/sys/dev/vx/if_vxvar.h b/sys/dev/vx/if_vxvar.h index 712e9f5..e8a7a32 100644 --- a/sys/dev/vx/if_vxvar.h +++ b/sys/dev/vx/if_vxvar.h @@ -70,7 +70,7 @@ struct vx_softc { bus_space_read_1(sc->bst, sc->bsh, reg) extern void vxfree(struct vx_softc *); -extern int vxattach(struct vx_softc *); +extern int vxattach(device_t); extern void vxstop(struct vx_softc *); extern void vxintr(void *); extern int vxbusyeeprom(struct vx_softc *); diff --git a/sys/dev/wi/if_wi.c b/sys/dev/wi/if_wi.c index e70698d..770353b 100644 --- a/sys/dev/wi/if_wi.c +++ b/sys/dev/wi/if_wi.c @@ -300,8 +300,7 @@ wi_attach(device_t dev) wi_read_nicid(sc); ifp->if_softc = sc; - ifp->if_unit = sc->sc_unit; - ifp->if_name = "wi"; + if_initname(ifp, device_get_name(dev), device_get_unit(dev)); ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = wi_ioctl; ifp->if_start = wi_start; diff --git a/sys/dev/wl/if_wl.c b/sys/dev/wl/if_wl.c index f1f4027..e25f965 100644 --- a/sys/dev/wl/if_wl.c +++ b/sys/dev/wl/if_wl.c @@ -554,8 +554,7 @@ wlattach(device_t device) #if MULTICAST ifp->if_flags |= IFF_MULTICAST; #endif /* MULTICAST */ - ifp->if_name = "wl"; - ifp->if_unit = unit; + if_initname(ifp, device_get_name(device), device_get_unit(device)); ifp->if_init = wlinit; ifp->if_output = ether_output; ifp->if_start = wlstart; @@ -570,7 +569,7 @@ wlattach(device_t device) ether_ifattach(ifp, &sc->wl_addr[0]); bcopy(&sc->wl_addr[0], sc->wl_ac.ac_enaddr, WAVELAN_ADDR_SIZE); - printf("%s%d: address %6D, NWID 0x%02x%02x", ifp->if_name, ifp->if_unit, + printf("%s: address %6D, NWID 0x%02x%02x", ifp->if_xname, sc->wl_ac.ac_enaddr, ":", sc->nwid[0], sc->nwid[1]); if (sc->freq24) printf(", Freq %d MHz",sc->freq24); /* 2.4 Gz */ @@ -966,7 +965,6 @@ wlbldcu(struct wl_softc *sc) static void wlstart(struct ifnet *ifp) { - int unit = ifp->if_unit; struct mbuf *m; struct wl_softc *sc = ifp->if_softc; short base = sc->base; @@ -975,7 +973,7 @@ wlstart(struct ifnet *ifp) WL_LOCK(sc); #ifdef WLDEBUG if (sc->wl_if.if_flags & IFF_DEBUG) - printf("wl%d: entered wlstart()\n",unit); + printf("%s: entered wlstart()\n", ifp->if_xname); #endif outw(PIOR1(base), OFFSET_CU); @@ -1000,8 +998,8 @@ wlstart(struct ifnet *ifp) * became idle but WE have masked interrupts so ... */ #ifdef WLDEBUG - printf("wl%d: CU idle, scb %04x %04x cu %04x\n", - unit, scb_status, scb_command, cu_status); + printf("%s: CU idle, scb %04x %04x cu %04x\n", + ifp->if_xname, scb_status, scb_command, cu_status); #endif if (xmt_watch) printf("!!"); } else { @@ -1011,10 +1009,10 @@ wlstart(struct ifnet *ifp) } else if ((scb_status & 0x0700) == SCB_CUS_ACTV || (cu_status & AC_SW_B)){ #ifdef WLDEBUG - printf("wl%d: CU unexpectedly busy; scb %04x cu %04x\n", - unit, scb_status, cu_status); + printf("%s: CU unexpectedly busy; scb %04x cu %04x\n", + ifp->if_xname, scb_status, cu_status); #endif - if (xmt_watch) printf("wl%d: busy?!",unit); + if (xmt_watch) printf("%s: busy?!",ifp->if_xname); WL_UNLOCK(sc); return; /* hey, why are we busy? */ } @@ -1078,7 +1076,7 @@ wlread(struct wl_softc *sc, u_short fd_p) printf("wl%d: entered wlread()\n", sc->unit); #endif if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING)) { - printf("wl%d read(): board is not running.\n", sc->unit); + printf("%s read(): board is not running.\n", ifp->if_xname); sc->hacr &= ~HACR_INTRON; CMD(sc); /* turn off interrupts */ } @@ -1235,7 +1233,6 @@ static int wlioctl(struct ifnet *ifp, u_long cmd, caddr_t data) { struct ifreq *ifr = (struct ifreq *)data; - int unit = ifp->if_unit; struct wl_softc *sc = ifp->if_softc; short base = sc->base; short mode = 0; @@ -1251,7 +1248,7 @@ wlioctl(struct ifnet *ifp, u_long cmd, caddr_t data) WL_LOCK(sc); #ifdef WLDEBUG if (sc->wl_if.if_flags & IFF_DEBUG) - printf("wl%d: entered wlioctl()\n",unit); + printf("%s: entered wlioctl()\n", ifp->if_xname); #endif opri = splimp(); switch (cmd) { @@ -1282,7 +1279,7 @@ wlioctl(struct ifnet *ifp, u_long cmd, caddr_t data) * stop it. */ if ((ifp->if_flags & IFF_UP) == 0 && sc->flags & DSF_RUNNING) { - printf("wl%d ioctl(): board is not running\n", unit); + printf("%s ioctl(): board is not running\n", ifp->if_xname); sc->flags &= ~DSF_RUNNING; sc->hacr &= ~HACR_INTRON; CMD(sc); /* turn off interrupts */ @@ -1768,7 +1765,7 @@ static int xmt_debug = 0; * locations on the WaveLAN board and starts the board off on * the transmit. * - * input : board number of interest, and a pointer to the mbuf + * input : pointers to board of interest's softc and the mbuf * output : board memory and registers are set for xfer and attention * */ @@ -1789,7 +1786,7 @@ wlxmt(struct wl_softc *sc, struct mbuf *m) #ifdef WLDEBUG if (sc->wl_if.if_flags & IFF_DEBUG) - printf("wl%d: entered wlxmt()\n", sc->unit); + printf("%s: entered wlxmt()\n", sc->wl_if.if_xname); #endif cb.ac_status = 0; @@ -1899,7 +1896,7 @@ wlxmt(struct wl_softc *sc, struct mbuf *m) break; } if ((spin == 0) && xmt_watch) { /* not waking up, and we care */ - printf("wl%d: slow accepting xmit\n", sc->unit); + printf("%s: slow accepting xmit\n", sc->wl_if.if_xname); } } outw(PIOP0(base), SCB_CU_STRT); /* new command */ diff --git a/sys/dev/xe/if_xe.c b/sys/dev/xe/if_xe.c index 6158e7d..e4fc724 100644 --- a/sys/dev/xe/if_xe.c +++ b/sys/dev/xe/if_xe.c @@ -219,8 +219,7 @@ xe_attach (device_t dev) /* Initialise the ifnet structure */ scp->ifp->if_softc = scp; - scp->ifp->if_name = "xe"; - scp->ifp->if_unit = device_get_unit(dev); + if_initname(scp->ifp, device_get_name(dev), device_get_unit(dev)); scp->ifp->if_timer = 0; scp->ifp->if_flags = (IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST); scp->ifp->if_linkmib = &scp->mibdata; |