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)
This commit is contained in:
Brooks Davis 2003-10-31 18:32:15 +00:00
parent dc6279b887
commit 9bf40ede4a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=121816
171 changed files with 773 additions and 921 deletions

View File

@ -17,6 +17,14 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 5.x IS SLOW:
developers choose to disable these features on build machines
to maximize performance.
20031031:
The API and ABI of struct ifnet have been changed by removing
the if_name and if_unit members and replacing them with
if_xname, if_dname, and if_dunit. All network drivers and most
userland programs which include net/if_var.h must be updated
and recompiled. __FreeBSD_version has been bumped to 501113 to
reflect this change.
20030928:
Changes to the cdevsw default functions have been made to remove
the need to specify nullopen() and nullclose() explicitly.

View File

@ -187,15 +187,9 @@ print_port(prot, port, comma)
static void
print_iface(char *key, union ip6_fw_if *un, int byname)
{
char ifnb[IP6FW_IFNLEN+1];
if (byname) {
strncpy(ifnb, un->fu_via_if.name, IP6FW_IFNLEN);
ifnb[IP6FW_IFNLEN]='\0';
if (un->fu_via_if.unit == -1)
printf(" %s %s*", key, ifnb);
else
printf(" %s %s%d", key, ifnb, un->fu_via_if.unit);
printf(" %s %s", key, un->fu_via_if.name);
} else if (!IN6_IS_ADDR_UNSPECIFIED(&un->fu_via_ip6)) {
printf(" %s %s", key, inet_ntop(AF_INET6,&un->fu_via_ip6,ntop_buf,sizeof(ntop_buf)));
} else
@ -825,13 +819,7 @@ verify_interface(union ip6_fw_if *ifu)
{
struct ifreq ifr;
/*
* If a unit was specified, check for that exact interface.
* If a wildcard was specified, check for unit 0.
*/
snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "%s%d",
ifu->fu_via_if.name,
ifu->fu_via_if.unit == -1 ? 0 : ifu->fu_via_if.unit);
strlcpy(ifr.ifr_name, ifu->fu_via_if.name, sizeof(ifr.ifr_name));
if (ioctl(s, SIOCGIFFLAGS, &ifr) < 0)
warnx("warning: interface ``%s'' does not exist", ifr.ifr_name);
@ -851,14 +839,17 @@ fill_iface(char *which, union ip6_fw_if *ifu, int *byname, int ac, char *arg)
char *q;
*byname = 1;
strncpy(ifu->fu_via_if.name, arg, sizeof(ifu->fu_via_if.name));
ifu->fu_via_if.name[sizeof(ifu->fu_via_if.name) - 1] = '\0';
for (q = ifu->fu_via_if.name;
*q && !isdigit(*q) && *q != '*'; q++)
continue;
ifu->fu_via_if.unit = (*q == '*') ? -1 : atoi(q);
*q = '\0';
verify_interface(ifu);
strlcpy(ifu->fu_via_if.name, arg, sizeof(ifu->fu_via_if.name));
/*
* We assume that strings containing '*', '?', or '['
* are ment to be shell pattern.
*/
if (strpbrk(arg, "*?[") != NULL) {
ifu->fu_via_if.glob = 1;
} else {
ifu->fu_via_if.glob = 0;
verify_interface(ifu);
}
} else if (inet_pton(AF_INET6, arg, &ifu->fu_via_ip6) != 1) {
show_usage("bad ip6 address ``%s''", arg);
} else

View File

@ -1156,11 +1156,7 @@ show_ipfw(struct ip_fw *rule, int pcwidth, int bcwidth)
if (cmdif->name[0] == '\0')
printf(" %s %s", s,
inet_ntoa(cmdif->p.ip));
else if (cmdif->p.unit == -1)
printf(" %s %s*", s, cmdif->name);
else
printf(" %s %s%d", s, cmdif->name,
cmdif->p.unit);
printf(" %s %s", s, cmdif->name);
}
break;
@ -2144,7 +2140,8 @@ delete(int ac, char *av[])
* fill the interface structure. We do not check the name as we can
* create interfaces dynamically, so checking them at insert time
* makes relatively little sense.
* A '*' following the name means any unit.
* Interface names containing '*', '?', or '[' are assumed to be shell
* patterns which match interfaces.
*/
static void
fill_iface(ipfw_insn_if *cmd, char *arg)
@ -2156,15 +2153,8 @@ fill_iface(ipfw_insn_if *cmd, char *arg)
if (!strcmp(arg, "any"))
cmd->o.len = 0; /* effectively ignore this command */
else if (!isdigit(*arg)) {
char *q;
strncpy(cmd->name, arg, sizeof(cmd->name));
cmd->name[sizeof(cmd->name) - 1] = '\0';
/* find first digit or wildcard */
for (q = cmd->name; *q && !isdigit(*q) && *q != '*'; q++)
continue;
cmd->p.unit = (*q == '*') ? -1 : atoi(q);
*q = '\0';
strlcpy(cmd->name, arg, sizeof(cmd->name));
cmd->p.glob = strpbrk(arg, "*?[") != NULL ? 1 : 0;
} else if (!inet_aton(arg, &cmd->p.ip))
errx(EX_DATAERR, "bad ip address ``%s''", arg);
}

View File

@ -216,18 +216,30 @@ are as follows:
.Pq Vt "void *"
A pointer to the driver's private state block.
(Initialized by driver.)
.It Va if_name
.Pq Vt "char *"
The name of the interface, not including the unit number
(e.g.,
.Dq Li de
or
.Dq Li lo ) .
(Initialized by driver.)
.It Va if_link
.Pq Fn TAILQ_ENTRY ifnet
.Xr queue 3
macro glue.
.It Va if_xname
.Pq Vt "char *"
The name of the interface,
(e.g.,
.Dq Li fxp0
or
.Dq Li lo0) .
(Initialized by driver.)
.It Va if_dname
.Pq Vt "const char *"
The name of the driver.
(Initialized by driver.)
.It Va if_dunit
.Pq Vt int
A unique number assigned to each interface managed by a particular
driver.
Drivers may choose to set this to
.Dv IF_DUNIT_NONE
if a unit number is not associated with the device.
(Initialized by driver.)
.It Va if_addrhead
.Pq Vt "struct ifaddrhead"
The head of the
@ -255,14 +267,6 @@ This number can be used in a
to refer to a particular interface by index
(see
.Xr link_addr 3 ) .
.It Va if_unit
.Pq Vt short
A unique number assigned to each interface managed by a particular
driver, usually related to the unit number of a physical device in the
kernel configuration file
(see
.Xr config 8 ) .
(Initialized by driver.)
.It Va if_timer
.Pq Vt short
Number of seconds until the watchdog timer

View File

@ -207,7 +207,7 @@ osf1_ioctl_i(td, uap, cmd, dir, len)
* because osf/1 doesn't know about most of them.
*/
if (ifp->if_type == IFT_ETHER
&& strcmp(ifp->if_name, "ti") != 0) { /* looks good */
&& strcmp(ifp->if_dname, "ti") != 0) { /* looks good */
/* walk the address list */
TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
if ((sdl = (struct sockaddr_dl *)ifa->ifa_addr) /* we have an address structure */

View File

@ -1881,8 +1881,7 @@ linux_ifname(struct ifnet *ifp, char *buffer, size_t buflen)
/* Short-circuit non ethernet interfaces */
if (!IFP_IS_ETH(ifp))
return (snprintf(buffer, buflen, "%s%d", ifp->if_name,
ifp->if_unit));
return (strlcpy(buffer, ifp->if_xname, buflen));
/* Determine the (relative) unit number for ethernet interfaces */
ethno = 0;
@ -1932,15 +1931,14 @@ ifname_linux_to_bsd(const char *lxname, char *bsdname)
* we never have an interface named "eth", so don't make
* the test optional based on is_eth.
*/
if (ifp->if_unit == unit && ifp->if_name[len] == '\0' &&
strncmp(ifp->if_name, lxname, len) == 0)
if (strncmp(ifp->if_xname, lxname, LINUX_IFNAMSIZ) == 0)
break;
if (is_eth && IFP_IS_ETH(ifp) && unit == index++)
break;
}
IFNET_RUNLOCK();
if (ifp != NULL)
snprintf(bsdname, IFNAMSIZ, "%s%d", ifp->if_name, ifp->if_unit);
strlcpy(bsdname, ifp->if_xname, IFNAMSIZ);
return (ifp);
}
@ -1988,8 +1986,7 @@ linux_ifconf(struct thread *td, struct ifconf *uifc)
snprintf(ifr.ifr_name, LINUX_IFNAMSIZ, "eth%d",
ethno++);
else
snprintf(ifr.ifr_name, LINUX_IFNAMSIZ, "%s%d",
ifp->if_name, ifp->if_unit);
strlcpy(ifr.ifr_name, ifp->if_xname, LINUX_IFNAMSIZ);
/* Walk the address list */
TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {

View File

@ -394,8 +394,7 @@ oltr_pci_attach(device_t dev)
* Do the ifnet initialization
*/
ifp->if_softc = sc;
ifp->if_unit = device_get_unit(dev);
ifp->if_name = "oltr";
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_init = oltr_init;
ifp->if_start = oltr_start;
ifp->if_ioctl = oltr_ioctl;

View File

@ -542,7 +542,8 @@ extern ill_t *get_unit __P((char *, int));
# ifndef linux
# define GETUNIT(n, v) ifunit(n)
# if (defined(NetBSD) && (NetBSD <= 1991011) && (NetBSD >= 199606)) || \
(defined(OpenBSD) && (OpenBSD >= 199603))
(defined(OpenBSD) && (OpenBSD >= 199603)) || \
(defined(__FreeBSD__) && (__FreeBSD_version >= 501113))
# define IFNAME(x) ((struct ifnet *)x)->if_xname
# else
# define USE_GETIFNAME 1

View File

@ -2075,7 +2075,8 @@ ip_t *ip;
int fd;
# if (defined(NetBSD) && (NetBSD <= 1991011) && (NetBSD >= 199606)) || \
(defined(OpenBSD) && (OpenBSD >= 199603))
(defined(OpenBSD) && (OpenBSD >= 199603)) || \
(defined(__FreeBSD__) && (__FreeBSD_version >= 501113))
sprintf(fname, "%s", ifp->if_xname);
# else
sprintf(fname, "%s%d", ifp->if_name, ifp->if_unit);
@ -2095,7 +2096,8 @@ char *get_ifname(ifp)
struct ifnet *ifp;
{
# if (defined(NetBSD) && (NetBSD <= 1991011) && (NetBSD >= 199606)) || \
(defined(OpenBSD) && (OpenBSD >= 199603))
(defined(OpenBSD) && (OpenBSD >= 199603)) || \
(defined(__FreeBSD__) && (__FreeBSD_version >= 501113))
return ifp->if_xname;
# else
static char fullifname[LIFNAMSIZ];
@ -2114,7 +2116,8 @@ int v;
for (ifa = ifneta; ifa && (ifp = *ifa); ifa++) {
# if (defined(NetBSD) && (NetBSD <= 1991011) && (NetBSD >= 199606)) || \
(defined(OpenBSD) && (OpenBSD >= 199603))
(defined(OpenBSD) && (OpenBSD >= 199603)) || \
(defined(__FreeBSD__) && (__FreeBSD_version >= 501113))
if (!strncmp(ifname, ifp->if_xname, sizeof(ifp->if_xname)))
# else
char fullname[LIFNAMSIZ];
@ -2156,7 +2159,8 @@ int v;
ifp = ifneta[nifs - 1];
# if (defined(NetBSD) && (NetBSD <= 1991011) && (NetBSD >= 199606)) || \
(defined(OpenBSD) && (OpenBSD >= 199603))
(defined(OpenBSD) && (OpenBSD >= 199603)) || \
(defined(__FreeBSD__) && (__FreeBSD_version >= 501113))
strncpy(ifp->if_xname, ifname, sizeof(ifp->if_xname));
# else
ifp->if_name = strdup(ifname);
@ -2183,7 +2187,8 @@ void init_ifp()
int fd;
# if (defined(NetBSD) && (NetBSD <= 1991011) && (NetBSD >= 199606)) || \
(defined(OpenBSD) && (OpenBSD >= 199603))
(defined(OpenBSD) && (OpenBSD >= 199603)) || \
(defined(__FreeBSD__) && (__FreeBSD_version >= 501113))
for (ifa = ifneta; ifa && (ifp = *ifa); ifa++) {
ifp->if_output = write_output;
sprintf(fname, "/tmp/%s", ifp->if_xname);

View File

@ -253,7 +253,8 @@ mb_t *m;
mlen = (flags & FR_LOGBODY) ? MIN(msgdsize(m) - hlen, 128) : 0;
# else
# if (defined(NetBSD) && (NetBSD <= 1991011) && (NetBSD >= 199603)) || \
(defined(OpenBSD) && (OpenBSD >= 199603))
(defined(OpenBSD) && (OpenBSD >= 199603) || \
(defined(__FreeBSD__) && (__FreeBSD_version >= 501113)) )
strncpy(ipfl.fl_ifname, ifp->if_xname, IFNAMSIZ);
# else
ipfl.fl_unit = (u_char)ifp->if_unit;

View File

@ -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;

View File

@ -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;

View File

@ -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) {

View File

@ -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,

View File

@ -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;

View File

@ -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;

View File

@ -96,7 +96,7 @@ cm_isa_attach(dev)
return (error);
}
return cm_attach(sc, device_get_unit(dev));
return cm_attach(dev);
}
static int

View File

@ -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;
}

View File

@ -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);

View File

@ -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);

View File

@ -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)

View File

@ -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[] = {

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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);
}

View File

@ -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

View File

@ -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[] = {

View File

@ -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. */

View File

@ -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);
}

View File

@ -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);

View File

@ -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;

View File

@ -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.

View File

@ -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) {

View File

@ -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;

View File

@ -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;
}

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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 {

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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");

View File

@ -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))

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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");

View File

@ -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");

View File

@ -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"

View File

@ -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

View File

@ -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;

View File

@ -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) +

View File

@ -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;

View File

@ -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++;
}

View File

@ -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 */

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -151,7 +151,7 @@ vx_pci_attach(
vxintr, sc, &sc->vx_intrhand))
goto bad;
if (vxattach(sc) == 0) {
if (vxattach(dev) == 0) {
goto bad;
}

View File

@ -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 *);

View File

@ -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;

View File

@ -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 */

View File

@ -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;

View File

@ -285,11 +285,11 @@ cxioctl (dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td)
master = *o->master ? ifunit (o->master) : c->ifp;
if (! master)
return (EINVAL);
m = cxchan[master->if_unit];
m = cxchan[master->if_dunit];
/* Leave the previous master queue. */
if (c->master != c->ifp) {
cx_chan_t *p = cxchan[c->master->if_unit];
cx_chan_t *p = cxchan[c->master->if_dunit];
for (; p; p=p->slaveq)
if (p->slaveq == c)
@ -355,9 +355,8 @@ cxioctl (dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td)
case 8: o->iftype = c->board->if8type; break;
}
if (c->master != c->ifp)
snprintf (o->master, sizeof(o->master),
"%s%d", c->master->if_name,
c->master->if_unit);
strlcpy(o->master, c->master->if_xname,
sizeof(o->master));
else
*o->master = 0;
break;

View File

@ -269,8 +269,7 @@ cxattach (struct isa_device *id)
bzero (c->ifp, IFSTRUCTSZ);
c->master = c->ifp;
c->ifp->if_softc = c;
c->ifp->if_unit = u;
c->ifp->if_name = "cx";
if_initname(c->ifp, "cx", u);
c->ifp->if_mtu = PP_MTU;
c->ifp->if_flags = IFF_POINTOPOINT | IFF_MULTICAST;
c->ifp->if_ioctl = cxsioctl;

View File

@ -264,8 +264,7 @@ el_attach(device_t dev)
/* Initialize ifnet structure */
ifp->if_softc = sc;
ifp->if_unit = device_get_unit(dev);;
ifp->if_name = "el";
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_mtu = ETHERMTU;
ifp->if_start = el_start;
ifp->if_ioctl = el_ioctl;
@ -765,7 +764,7 @@ el_ioctl(ifp, command, data)
static void
el_watchdog(struct ifnet *ifp)
{
log(LOG_ERR,"el%d: device timeout\n", ifp->if_unit);
log(LOG_ERR,"%s: device timeout\n", ifp->if_xname);
ifp->if_oerrors++;
el_reset(ifp->if_softc);
}

View File

@ -196,6 +196,7 @@ static void (*le_intrvec[NLE])(le_softc_t *sc);
*/
struct le_softc {
struct arpcom le_ac; /* Common Ethernet/ARP Structure */
int le_unit; /* Unit number */
void (*if_init)(void *);/* Interface init routine */
void (*if_reset)(le_softc_t *);/* Interface reset routine */
caddr_t le_membase; /* Starting memory address (virtual) */
@ -319,8 +320,7 @@ le_probe(
sc->le_iobase = dvp->id_iobase;
sc->le_membase = (u_char *) dvp->id_maddr;
sc->le_irq = dvp->id_irq;
sc->le_if.if_name = (char *)(uintptr_t)(const void *)ledriver.name;
sc->le_if.if_unit = dvp->id_unit;
sc->le_unit = dvp->id_unit;
/*
* Find and Initialize board..
@ -346,7 +346,7 @@ le_attach(
dvp->id_ointr = le_intr;
ifp->if_softc = sc;
ifp->if_unit = dvp->id_unit;
if_initname(ifp, ledriver.name, dvp->id_unit);
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_ioctl = le_ioctl;
ifp->if_init = sc->if_init;
@ -704,7 +704,7 @@ lemac_probe(
sc->le_mcmask = (1 << LEMAC_MCTBL_BITS) - 1;
sc->lemac_txmax = lemac_deftxmax;
*msize = 2048;
le_intrvec[sc->le_if.if_unit] = lemac_intr;
le_intrvec[sc->le_unit] = lemac_intr;
return LEMAC_IOSPACE;
}
@ -1346,7 +1346,7 @@ depca_probe(
*/
DEPCA_WRNICSR(sc, DEPCA_RDNICSR(sc) | DEPCA_NICSR_SHE);
le_intrvec[sc->le_if.if_unit] = depca_intr;
le_intrvec[sc->le_unit] = depca_intr;
if (!lance_init_adapmem(sc))
return 0;

View File

@ -595,8 +595,7 @@ rdp_attach(struct isa_device *isa_dev)
* Initialize ifnet structure
*/
ifp->if_softc = sc;
ifp->if_unit = unit;
ifp->if_name = "rdp";
if_initname(ifp, "rdp", unit);
ifp->if_start = rdp_start;
ifp->if_ioctl = rdp_ioctl;
ifp->if_watchdog = rdp_watchdog;
@ -668,7 +667,7 @@ static void
rdp_watchdog(struct ifnet *ifp)
{
log(LOG_ERR, "rdp%d: device timeout\n", ifp->if_unit);
log(LOG_ERR, "%s: device timeout\n", ifp->if_xname);
ifp->if_oerrors++;
rdp_reset(ifp);

View File

@ -203,8 +203,8 @@ i4biprattach(void *dummy)
sc->sc_if.if_softc = sc;
sc->sc_state = ST_IDLE;
sc->sc_if.if_name = "ipr";
sc->sc_if.if_unit = i;
if_initname(&sc->sc_if, "ipr", i);
#ifdef IPR_VJ
sc->sc_if.if_flags = IFF_POINTOPOINT | IFF_SIMPLEX | IPR_AUTOCOMP;
@ -287,8 +287,8 @@ i4biproutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
s = SPLI4B();
unit = ifp->if_unit;
sc = ifp->if_softc;
unit = ifp->if_dunit;
/* check for IP */
@ -435,7 +435,8 @@ i4biprioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
if(sc->sc_if.if_flags & IFF_RUNNING)
{
/* disconnect ISDN line */
i4b_l4_drvrdisc(BDRV_IPR, ifp->if_unit);
i4b_l4_drvrdisc(BDRV_IPR,
ifp->if_dunit);
sc->sc_if.if_flags &= ~IFF_RUNNING;
}
@ -513,7 +514,7 @@ iprclearqueues(struct ipr_softc *sc)
static void
iprwatchdog(struct ifnet *ifp)
{
int unit = ifp->if_unit;
int unit = ifp->if_dunit;
struct ipr_softc *sc = ifp->if_softc;
bchan_statistics_t bs;
@ -560,7 +561,7 @@ i4bipr_connect_startio(struct ipr_softc *sc)
if(sc->sc_state == ST_CONNECTED_W)
{
sc->sc_state = ST_CONNECTED_A;
ipr_tx_queue_empty(sc->sc_if.if_unit);
ipr_tx_queue_empty(sc->sc_if.if_dunit);
}
splx(s);

View File

@ -68,9 +68,9 @@ __FBSDID("$FreeBSD$");
#include <i4b/layer4/i4b_l4.h>
#define ISPPP_FMT "isp%d: "
#define ISPPP_ARG(sc) ((sc)->sc_if.if_unit)
#define ISPPP_ARG(sc) ((sc)->sc_if.if_dunit)
#define PDEVSTATIC static
#define IFP2UNIT(ifp) (ifp)->if_unit
#define IFP2UNIT(ifp) (ifp)->if_dunit
# define CALLOUT_INIT(chan) callout_handle_init(chan)
# define TIMEOUT(fun, arg, chan, tick) chan = timeout(fun, arg, tick)
@ -170,8 +170,7 @@ i4bispppattach(void *dummy)
i4bisppp_init_linktab(i);
sc->sc_if.if_softc = sc;
sc->sc_if.if_name = "isp";
sc->sc_if.if_unit = i;
if_initname(&sc->sc_if, "isp", i);
sc->sc_if.if_mtu = PP_MTU;
sc->sc_if.if_flags = IFF_SIMPLEX | IFF_POINTOPOINT;
sc->sc_if.if_type = IFT_ISDNBASIC;

View File

@ -785,8 +785,8 @@ bpfioctl(dev, cmd, addr, flags, td)
struct ifnet *const ifp = d->bd_bif->bif_ifp;
struct ifreq *const ifr = (struct ifreq *)addr;
snprintf(ifr->ifr_name, sizeof(ifr->ifr_name),
"%s%d", ifp->if_name, ifp->if_unit);
strlcpy(ifr->ifr_name, ifp->if_xname,
sizeof(ifr->ifr_name));
}
break;
@ -1425,8 +1425,7 @@ bpfdetach(ifp)
/* Interface wasn't attached */
if ((bp == NULL) || (bp->bif_ifp == NULL)) {
mtx_unlock(&bpf_mtx);
printf("bpfdetach: %s%d was not attached\n", ifp->if_name,
ifp->if_unit);
printf("bpfdetach: %s was not attached\n", ifp->if_xname);
return;
}

View File

@ -390,8 +390,8 @@ bridge_off(void)
if ( b->flags & IFF_BDG_PROMISC ) {
ifpromisc(ifp, 0);
b->flags &= ~(IFF_BDG_PROMISC|IFF_MUTE) ;
DPRINTF(("%s: %s%d promisc OFF if_flags 0x%x "
"bdg_flags 0x%x\n", __func__, ifp->if_name, ifp->if_unit,
DPRINTF(("%s: %s promisc OFF if_flags 0x%x "
"bdg_flags 0x%x\n", __func__, ifp->if_xname,
ifp->if_flags, b->flags));
}
b->flags &= ~(IFF_USED) ;
@ -433,12 +433,11 @@ bridge_on(void)
if ( !(b->flags & IFF_BDG_PROMISC) ) {
(void) ifpromisc(ifp, 1);
b->flags |= IFF_BDG_PROMISC ;
DPRINTF(("%s: %s%d promisc ON if_flags 0x%x bdg_flags 0x%x\n",
__func__, ifp->if_name, ifp->if_unit, ifp->if_flags, b->flags));
DPRINTF(("%s: %s promisc ON if_flags 0x%x bdg_flags 0x%x\n",
__func__, ifp->if_xname, ifp->if_flags, b->flags));
}
if (b->flags & IFF_MUTE) {
DPRINTF(("%s: unmuting %s%d\n", __func__,
ifp->if_name, ifp->if_unit));
DPRINTF(("%s: unmuting %s\n", __func__, ifp->if_xname));
b->flags &= ~IFF_MUTE;
}
}
@ -522,23 +521,22 @@ parse_bdg_cfg(void)
*/
IFNET_RLOCK(); /* could sleep XXX */
TAILQ_FOREACH(ifp, &ifnet, if_link) {
char buf[IFNAMSIZ];
snprintf(buf, sizeof(buf), "%s%d", ifp->if_name, ifp->if_unit);
if (!strncmp(beg, buf, max(l, strlen(buf)))) {
if (!strncmp(beg, ifp->if_xname, max(l, strlen(ifp->if_xname)))) {
struct bdg_softc *b = &ifp2sc[ifp->if_index];
if (ifp->if_type != IFT_ETHER && ifp->if_type != IFT_L2VLAN) {
printf("%s is not an ethernet, continue\n", buf);
printf("%s is not an ethernet, continue\n", ifp->if_xname);
continue;
}
if (b->flags & IFF_USED) {
printf("%s already used, skipping\n", buf);
printf("%s already used, skipping\n", ifp->if_xname);
break;
}
b->cluster = add_cluster(htons(cluster), (struct arpcom *)ifp);
b->flags |= IFF_USED ;
sprintf(bdg_stats.s[ifp->if_index].name,
"%s%d:%d", ifp->if_name, ifp->if_unit, cluster);
snprintf(bdg_stats.s[ifp->if_index].name,
sizeof(bdg_stats.s[ifp->if_index].name),
"%s:%d", ifp->if_xname, cluster);
DPRINTF(("%s: found %s next c %d\n", __func__,
bdg_stats.s[ifp->if_index].name, c));
@ -793,10 +791,9 @@ bridge_in(struct ifnet *ifp, struct ether_header *eh)
* from the old interface.
*/
bt->name = ifp; /* relocate address */
printf("-- loop (%d) %6D to %s%d from %s%d (%s)\n",
printf("-- loop (%d) %6D to %s from %s (%s)\n",
bdg_loops, eh->ether_shost, ".",
ifp->if_name, ifp->if_unit,
old->if_name, old->if_unit,
ifp->if_xname, old->if_xname,
BDG_MUTED(old) ? "muted":"active");
dropit = 1;
if (!BDG_MUTED(old)) {
@ -810,8 +807,8 @@ bridge_in(struct ifnet *ifp, struct ether_header *eh)
* now write the source address into the table
*/
if (bt->name == NULL) {
DPRINTF(("%s: new addr %6D at %d for %s%d\n",
__func__, eh->ether_shost, ".", index, ifp->if_name, ifp->if_unit));
DPRINTF(("%s: new addr %6D at %d for %s\n",
__func__, eh->ether_shost, ".", index, ifp->if_xname));
ETHER_ADDR_COPY(bt->etheraddr, eh->ether_shost);
bt->name = ifp;
}
@ -853,13 +850,12 @@ bridge_in(struct ifnet *ifp, struct ether_header *eh)
if (dst == ifp)
dst = BDG_DROP;
}
DPRINTF(("%s: %6D ->%6D ty 0x%04x dst %s%d\n", __func__,
DPRINTF(("%s: %6D ->%6D ty 0x%04x dst %s\n", __func__,
eh->ether_shost, ".",
eh->ether_dhost, ".",
ntohs(eh->ether_type),
(dst <= BDG_FORWARD) ? bdg_dst_names[(uintptr_t)dst] :
dst->if_name,
(dst <= BDG_FORWARD) ? 0 : dst->if_unit));
dst->if_xname));
return dst;
}

View File

@ -325,7 +325,7 @@ if_findindex(struct ifnet *ifp)
eaddr[0] = '\0';
break;
}
snprintf(devname, 32, "%s%d", ifp->if_name, ifp->if_unit);
strlcpy(devname, ifp->if_xname, sizeof(devname));
name = net_cdevsw.d_name;
i = 0;
while ((resource_find_dev(&i, name, &unit, NULL, NULL)) == 0) {
@ -364,7 +364,6 @@ if_attach(struct ifnet *ifp)
{
unsigned socksize, ifasize;
int namelen, masklen;
char workbuf[64];
struct sockaddr_dl *sdl;
struct ifaddr *ifa;
@ -399,18 +398,17 @@ if_attach(struct ifnet *ifp)
ifnet_byindex(ifp->if_index) = ifp;
ifdev_byindex(ifp->if_index) = make_dev(&net_cdevsw, ifp->if_index,
UID_ROOT, GID_WHEEL, 0600, "%s/%s%d",
net_cdevsw.d_name, ifp->if_name, ifp->if_unit);
UID_ROOT, GID_WHEEL, 0600, "%s/%s",
net_cdevsw.d_name, ifp->if_xname);
make_dev_alias(ifdev_byindex(ifp->if_index), "%s%d",
net_cdevsw.d_name, ifp->if_index);
mtx_init(&ifp->if_snd.ifq_mtx, ifp->if_name, "if send queue", MTX_DEF);
mtx_init(&ifp->if_snd.ifq_mtx, ifp->if_xname, "if send queue", MTX_DEF);
/*
* create a Link Level name for this device
*/
namelen = snprintf(workbuf, sizeof(workbuf),
"%s%d", ifp->if_name, ifp->if_unit);
namelen = strlen(ifp->if_xname);
#define _offsetof(t, m) ((int)((caddr_t)&((t *)0)->m))
masklen = _offsetof(struct sockaddr_dl, sdl_data[0]) + namelen;
socksize = masklen + ifp->if_addrlen;
@ -425,7 +423,7 @@ if_attach(struct ifnet *ifp)
sdl = (struct sockaddr_dl *)(ifa + 1);
sdl->sdl_len = socksize;
sdl->sdl_family = AF_LINK;
bcopy(workbuf, sdl->sdl_data, namelen);
bcopy(ifp->if_xname, sdl->sdl_data, namelen);
sdl->sdl_nlen = namelen;
sdl->sdl_index = ifp->if_index;
sdl->sdl_type = ifp->if_type;
@ -881,8 +879,7 @@ if_clone_list(struct if_clonereq *ifcr)
for (ifc = LIST_FIRST(&if_cloners); ifc != NULL && count != 0;
ifc = LIST_NEXT(ifc, ifc_list), count--, dst += IFNAMSIZ) {
strncpy(outbuf, ifc->ifc_name, IFNAMSIZ);
outbuf[IFNAMSIZ - 1] = '\0'; /* sanity */
strlcpy(outbuf, ifc->ifc_name, IFNAMSIZ);
error = copyout(outbuf, dst, IFNAMSIZ);
if (error)
break;
@ -1643,8 +1640,8 @@ ifpromisc(struct ifnet *ifp, int pswitch)
ifr.ifr_flagshigh = ifp->if_flags >> 16;
error = (*ifp->if_ioctl)(ifp, SIOCSIFFLAGS, (caddr_t)&ifr);
if (error == 0) {
log(LOG_INFO, "%s%d: promiscuous mode %s\n",
ifp->if_name, ifp->if_unit,
log(LOG_INFO, "%s: promiscuous mode %s\n",
ifp->if_xname,
(ifp->if_flags & IFF_PROMISC) ? "enabled" : "disabled");
rt_ifmsg(ifp);
} else {
@ -1673,18 +1670,14 @@ ifconf(u_long cmd, caddr_t data)
ifrp = ifc->ifc_req;
IFNET_RLOCK(); /* could sleep XXX */
TAILQ_FOREACH(ifp, &ifnet, if_link) {
char workbuf[64];
int ifnlen, addrs;
int addrs;
if (space < sizeof(ifr))
break;
ifnlen = snprintf(workbuf, sizeof(workbuf),
"%s%d", ifp->if_name, ifp->if_unit);
if(ifnlen + 1 > sizeof ifr.ifr_name) {
if (strlcpy(ifr.ifr_name, ifp->if_xname, sizeof(ifr.ifr_name))
>= sizeof(ifr.ifr_name)) {
error = ENAMETOOLONG;
break;
} else {
strcpy(ifr.ifr_name, workbuf);
}
addrs = 0;
@ -2019,13 +2012,30 @@ ifmaof_ifpforaddr(struct sockaddr *sa, struct ifnet *ifp)
return ifma;
}
/*
* The name argument must be a pointer to storage which will last as
* long as the interface does. For physical devices, the result of
* device_get_name(dev) is a good choice and for pseudo-devices a
* static string works well.
*/
void
if_initname(struct ifnet *ifp, const char *name, int unit)
{
ifp->if_dname = name;
ifp->if_dunit = unit;
if (unit != IF_DUNIT_NONE)
snprintf(ifp->if_xname, IFNAMSIZ, "%s%d", name, unit);
else
strlcpy(ifp->if_xname, name, IFNAMSIZ);
}
int
if_printf(struct ifnet *ifp, const char * fmt, ...)
{
va_list ap;
int retval;
retval = printf("%s%d: ", ifp->if_name, ifp->if_unit);
retval = printf("%s: ", ifp->if_xname);
va_start(ap, fmt);
retval += vprintf(fmt, ap);
va_end(ap);

View File

@ -62,7 +62,7 @@ struct ifnet;
#define IF_NAMESIZE 16
#if __BSD_VISIBLE
#define IFNAMSIZ IF_NAMESIZE
#define IF_MAXUNIT 0x7fff /* ifp->if_unit is only 15 bits */
#define IF_MAXUNIT 0x7fff /* historical value */
#endif
#ifdef _KERNEL

View File

@ -474,8 +474,8 @@ arc_defrag(ifp, m)
if (m)
m_freem(m);
log(LOG_INFO,"%s%d: got out of seq. packet: %s\n",
ifp->if_name, ifp->if_unit, s);
log(LOG_INFO,"%s: got out of seq. packet: %s\n",
ifp->if_xname, s);
return NULL;
}
@ -648,8 +648,8 @@ arc_ifattach(ifp, lla)
ac->ac_seqid = (time_second) & 0xFFFF; /* try to make seqid unique */
if (lla == 0) {
/* XXX this message isn't entirely clear, to me -- cgd */
log(LOG_ERR,"%s%d: link address 0 reserved for broadcasts. Please change it and ifconfig %s%d down up\n",
ifp->if_name, ifp->if_unit, ifp->if_name, ifp->if_unit);
log(LOG_ERR,"%s: link address 0 reserved for broadcasts. Please change it and ifconfig %s down up\n",
ifp->if_xname, ifp->if_xname);
}
arc_storelladdr(ifp, lla);

View File

@ -181,7 +181,8 @@ atm_output(struct ifnet *ifp, struct mbuf *m0, struct sockaddr *dst,
break;
default:
#if defined(__NetBSD__) || defined(__OpenBSD__)
#if (defined(__FreeBSD__) && __FreeBSD_version >= 501113) || \
defined(__NetBSD__) || defined(__OpenBSD__)
printf("%s: can't handle af%d\n", ifp->if_xname,
dst->sa_family);
#elif defined(__FreeBSD__) || defined(__bsdi__)
@ -301,7 +302,8 @@ atm_input(struct ifnet *ifp, struct atm_pseudohdr *ah, struct mbuf *m,
return; /* failed */
alc = mtod(m, struct atmllc *);
if (bcmp(alc, ATMLLC_HDR, 6)) {
#if defined(__NetBSD__) || defined(__OpenBSD__)
#if (defined(__FreeBSD__) && __FreeBSD_version >= 501113) || \
defined(__NetBSD__) || defined(__OpenBSD__)
printf("%s: recv'd invalid LLC/SNAP frame "
"[vp=%d,vc=%d]\n", ifp->if_xname,
ATM_PH_VPI(ah), ATM_PH_VCI(ah));

View File

@ -93,8 +93,7 @@ disc_clone_create(struct if_clone *ifc, int unit)
ifp = &sc->sc_if;
ifp->if_softc = sc;
ifp->if_name = DISCNAME;
ifp->if_unit = unit;
if_initname(ifp, ifc->ifc_name, unit);
ifp->if_mtu = DSMTU;
ifp->if_flags = IFF_LOOPBACK | IFF_MULTICAST;
ifp->if_ioctl = discioctl;

Some files were not shown because too many files have changed in this diff Show More