summaryrefslogtreecommitdiffstats
path: root/sys/dev/lnc/if_lnc.c
diff options
context:
space:
mode:
authorbrooks <brooks@FreeBSD.org>2003-10-31 18:32:15 +0000
committerbrooks <brooks@FreeBSD.org>2003-10-31 18:32:15 +0000
commitf1e94c6f29b079e4ad9d9305ef3e90a719bcbbda (patch)
tree4d9e6671d486576767506230a4240131526fea49 /sys/dev/lnc/if_lnc.c
parentbe546fdee455a96afdefee10d0bdba8547399f5b (diff)
downloadFreeBSD-src-f1e94c6f29b079e4ad9d9305ef3e90a719bcbbda.zip
FreeBSD-src-f1e94c6f29b079e4ad9d9305ef3e90a719bcbbda.tar.gz
Replace the if_name and if_unit members of struct ifnet with new members
if_xname, if_dname, and if_dunit. if_xname is the name of the interface and if_dname/unit are the driver name and instance. This change paves the way for interface renaming and enhanced pseudo device creation and configuration symantics. Approved By: re (in principle) Reviewed By: njl, imp Tested On: i386, amd64, sparc64 Obtained From: NetBSD (if_xname)
Diffstat (limited to 'sys/dev/lnc/if_lnc.c')
-rw-r--r--sys/dev/lnc/if_lnc.c83
1 files changed, 35 insertions, 48 deletions
diff --git a/sys/dev/lnc/if_lnc.c b/sys/dev/lnc/if_lnc.c
index e8b526b..3173b0c 100644
--- a/sys/dev/lnc/if_lnc.c
+++ b/sys/dev/lnc/if_lnc.c
@@ -468,14 +468,12 @@ lnc_rint(struct lnc_softc *sc)
#ifdef DIAGNOSTIC
if ((sc->recv_ring + sc->recv_next)->md->md1 & OWN) {
- int unit = ifp->if_unit;
- log(LOG_ERR, "lnc%d: Receive interrupt with buffer still owned by controller -- Resetting\n", unit);
+ log(LOG_ERR, "%s: Receive interrupt with buffer still owned by controller -- Resetting\n", ifp->if_xname);
lnc_reset(sc);
return;
}
if (!((sc->recv_ring + sc->recv_next)->md->md1 & STP)) {
- int unit = ifp->if_unit;
- log(LOG_ERR, "lnc%d: Receive interrupt but not start of packet -- Resetting\n", unit);
+ log(LOG_ERR, "%s: Receive interrupt but not start of packet -- Resetting\n", ifp->if_xname);
lnc_reset(sc);
return;
}
@@ -506,8 +504,7 @@ lnc_rint(struct lnc_softc *sc)
} while (!(flags & (STP | OWN | ENP | MDERR)));
if (flags & STP) {
- int unit = ifp->if_unit;
- log(LOG_ERR, "lnc%d: Start of packet found before end of previous in receive ring -- Resetting\n", unit);
+ log(LOG_ERR, "%s: Start of packet found before end of previous in receive ring -- Resetting\n", ifp->if_xname);
lnc_reset(sc);
return;
}
@@ -520,8 +517,7 @@ lnc_rint(struct lnc_softc *sc)
sc->recv_next = start_of_packet;
break;
} else {
- int unit = ifp->if_unit;
- log(LOG_ERR, "lnc%d: End of received packet not found-- Resetting\n", unit);
+ log(LOG_ERR, "%s: End of received packet not found-- Resetting\n", ifp->if_xname);
lnc_reset(sc);
return;
}
@@ -535,16 +531,16 @@ lnc_rint(struct lnc_softc *sc)
next = sc->recv_ring + sc->recv_next;
if (flags & MDERR) {
- int unit = ifp->if_unit;
+ const char *if_xname = ifp->if_xname;
if (flags & RBUFF) {
LNCSTATS(rbuff)
- log(LOG_ERR, "lnc%d: Receive buffer error\n", unit);
+ log(LOG_ERR, "%s: Receive buffer error\n", if_xname);
}
if (flags & OFLO) {
/* OFLO only valid if ENP is not set */
if (!(flags & ENP)) {
LNCSTATS(oflo)
- log(LOG_ERR, "lnc%d: Receive overflow error \n", unit);
+ log(LOG_ERR, "%s: Receive overflow error \n", if_xname);
}
} else if (flags & ENP) {
if ((ifp->if_flags & IFF_PROMISC)==0) {
@@ -554,14 +550,14 @@ lnc_rint(struct lnc_softc *sc)
*/
if (flags & FRAM) {
LNCSTATS(fram)
- log(LOG_ERR, "lnc%d: Framing error\n", unit);
+ log(LOG_ERR, "%s: Framing error\n", if_xname);
/*
* FRAM is only set if there's a CRC
* error so avoid multiple messages
*/
} else if (flags & CRC) {
LNCSTATS(crc)
- log(LOG_ERR, "lnc%d: Receive CRC error\n", unit);
+ log(LOG_ERR, "%s: Receive CRC error\n", if_xname);
}
}
}
@@ -607,8 +603,7 @@ lnc_rint(struct lnc_softc *sc)
(*ifp->if_input)(ifp, head);
}
} else {
- int unit = ifp->if_unit;
- log(LOG_ERR,"lnc%d: Packet dropped, no mbufs\n",unit);
+ log(LOG_ERR,"%s: Packet dropped, no mbufs\n",ifp->if_xname);
LNCSTATS(drop_packet)
}
}
@@ -649,8 +644,7 @@ lnc_tint(struct lnc_softc *sc)
#ifdef DIAGNOSTIC
if ((sc->trans_ring + sc->trans_next)->md->md1 & OWN) {
- int unit = sc->arpcom.ac_if.if_unit;
- log(LOG_ERR, "lnc%d: Transmit interrupt with buffer still owned by controller -- Resetting\n", unit);
+ log(LOG_ERR, "%s: Transmit interrupt with buffer still owned by controller -- Resetting\n", sc->arpcom.ac_if.if_xname);
lnc_reset(sc);
return;
}
@@ -678,12 +672,11 @@ lnc_tint(struct lnc_softc *sc)
next = sc->trans_ring + sc->trans_next;
#ifdef DIAGNOSTIC
- if (!(next->md->md1 & STP)) {
- int unit = sc->arpcom.ac_if.if_unit;
- log(LOG_ERR, "lnc%d: Transmit interrupt but not start of packet -- Resetting\n", unit);
- lnc_reset(sc);
- return;
- }
+ if (!(next->md->md1 & STP)) {
+ log(LOG_ERR, "%s: Transmit interrupt but not start of packet -- Resetting\n", sc->arpcom.ac_if.if_xname);
+ lnc_reset(sc);
+ return;
+ }
#endif
/*
@@ -697,8 +690,7 @@ lnc_tint(struct lnc_softc *sc)
} while (!(next->md->md1 & (STP | OWN | ENP | MDERR)));
if (next->md->md1 & STP) {
- int unit = sc->arpcom.ac_if.if_unit;
- log(LOG_ERR, "lnc%d: Start of packet found before end of previous in transmit ring -- Resetting\n", unit);
+ log(LOG_ERR, "%s: Start of packet found before end of previous in transmit ring -- Resetting\n", sc->arpcom.ac_if.if_xname);
lnc_reset(sc);
return;
}
@@ -711,8 +703,7 @@ lnc_tint(struct lnc_softc *sc)
sc->trans_next = start_of_packet;
break;
} else {
- int unit = sc->arpcom.ac_if.if_unit;
- log(LOG_ERR, "lnc%d: End of transmitted packet not found -- Resetting\n", unit);
+ log(LOG_ERR, "%s: End of transmitted packet not found -- Resetting\n", sc->arpcom.ac_if.if_xname);
lnc_reset(sc);
return;
}
@@ -724,14 +715,12 @@ lnc_tint(struct lnc_softc *sc)
*/
if (next->md->md1 & MDERR) {
- int unit = sc->arpcom.ac_if.if_unit;
-
LNCSTATS(terr)
sc->arpcom.ac_if.if_oerrors++;
if (next->md->md3 & LCOL) {
LNCSTATS(lcol)
- log(LOG_ERR, "lnc%d: Transmit late collision -- Net error?\n", unit);
+ log(LOG_ERR, "%s: Transmit late collision -- Net error?\n", sc->arpcom.ac_if.if_xname);
sc->arpcom.ac_if.if_collisions++;
/*
* Clear TBUFF since it's not valid when LCOL
@@ -741,11 +730,11 @@ lnc_tint(struct lnc_softc *sc)
}
if (next->md->md3 & LCAR) {
LNCSTATS(lcar)
- log(LOG_ERR, "lnc%d: Loss of carrier during transmit -- Net error?\n", unit);
+ log(LOG_ERR, "%s: Loss of carrier during transmit -- Net error?\n", sc->arpcom.ac_if.if_xname);
}
if (next->md->md3 & RTRY) {
LNCSTATS(rtry)
- log(LOG_ERR, "lnc%d: Transmit of packet failed after 16 attempts -- TDR = %d\n", unit, ((sc->trans_ring + sc->trans_next)->md->md3 & TDR));
+ log(LOG_ERR, "%s: Transmit of packet failed after 16 attempts -- TDR = %d\n", sc->arpcom.ac_if.if_xname, ((sc->trans_ring + sc->trans_next)->md->md3 & TDR));
sc->arpcom.ac_if.if_collisions += 16;
/*
* Clear TBUFF since it's not valid when RTRY
@@ -771,9 +760,9 @@ lnc_tint(struct lnc_softc *sc)
*/
if (next->md->md3 & TBUFF) {
LNCSTATS(tbuff)
- log(LOG_ERR, "lnc%d: Transmit buffer error -- Resetting\n", unit);
+ log(LOG_ERR, "%s: Transmit buffer error -- Resetting\n", sc->arpcom.ac_if.if_xname);
} else
- log(LOG_ERR, "lnc%d: Transmit underflow error -- Resetting\n", unit);
+ log(LOG_ERR, "%s: Transmit underflow error -- Resetting\n", sc->arpcom.ac_if.if_xname);
lnc_reset(sc);
return;
}
@@ -865,7 +854,6 @@ lnc_tint(struct lnc_softc *sc)
int
lnc_attach_common(device_t dev)
{
- int unit = device_get_unit(dev);
lnc_softc_t *sc = device_get_softc(dev);
int i;
int skip;
@@ -886,8 +874,8 @@ lnc_attach_common(device_t dev)
/* Fill in arpcom structure entries */
sc->arpcom.ac_if.if_softc = sc;
- sc->arpcom.ac_if.if_name = "lnc";
- sc->arpcom.ac_if.if_unit = unit;
+ if_initname(&sc->arpcom.ac_if, device_get_name(dev),
+ device_get_unit(dev));
sc->arpcom.ac_if.if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
sc->arpcom.ac_if.if_timer = 0;
sc->arpcom.ac_if.if_output = ether_output;
@@ -907,7 +895,7 @@ lnc_attach_common(device_t dev)
ether_ifattach(&sc->arpcom.ac_if, sc->arpcom.ac_enaddr);
- printf("lnc%d: ", unit);
+ printf("%s: ", sc->arpcom.ac_if.if_xname);
if (sc->nic.ic == LANCE || sc->nic.ic == C_LANCE)
printf("%s (%s)",
nic_ident[sc->nic.ident], ic_ident[sc->nic.ic]);
@@ -1094,8 +1082,8 @@ printf("Enabling lnc interrupts\n");
sc->arpcom.ac_if.if_flags &= ~IFF_OACTIVE;
lnc_start(&sc->arpcom.ac_if);
} else
- log(LOG_ERR, "lnc%d: Initialisation failed\n",
- sc->arpcom.ac_if.if_unit);
+ log(LOG_ERR, "%s: Initialisation failed\n",
+ sc->arpcom.ac_if.if_xname);
splx(s);
}
@@ -1125,7 +1113,6 @@ void
lncintr(void *arg)
{
lnc_softc_t *sc = arg;
- int unit = sc->arpcom.ac_if.if_unit;
u_short csr0;
/*
@@ -1160,21 +1147,21 @@ printf("IDON\n");
if (csr0 & ERR) {
if (csr0 & CERR) {
- log(LOG_ERR, "lnc%d: Heartbeat error -- SQE test failed\n", unit);
+ log(LOG_ERR, "%s: Heartbeat error -- SQE test failed\n", sc->arpcom.ac_if.if_xname);
LNCSTATS(cerr)
}
if (csr0 & BABL) {
- log(LOG_ERR, "lnc%d: Babble error - more than 1519 bytes transmitted\n", unit);
+ log(LOG_ERR, "%s: Babble error - more than 1519 bytes transmitted\n", sc->arpcom.ac_if.if_xname);
LNCSTATS(babl)
sc->arpcom.ac_if.if_oerrors++;
}
if (csr0 & MISS) {
- log(LOG_ERR, "lnc%d: Missed packet -- no receive buffer\n", unit);
+ log(LOG_ERR, "%s: Missed packet -- no receive buffer\n", sc->arpcom.ac_if.if_xname);
LNCSTATS(miss)
sc->arpcom.ac_if.if_ierrors++;
}
if (csr0 & MERR) {
- log(LOG_ERR, "lnc%d: Memory error -- Resetting\n", unit);
+ log(LOG_ERR, "%s: Memory error -- Resetting\n", sc->arpcom.ac_if.if_xname);
LNCSTATS(merr)
lnc_reset(sc);
continue;
@@ -1282,7 +1269,7 @@ lnc_start(struct ifnet *ifp)
if (no_entries_needed > (NDESC(sc->ntdre) - sc->pending_transmits)) {
if (!(head = chain_to_cluster(head))) {
- log(LOG_ERR, "lnc%d: Couldn't get mbuf for transmit packet -- Resetting \n ",ifp->if_unit);
+ log(LOG_ERR, "%s: Couldn't get mbuf for transmit packet -- Resetting \n ",ifp->if_xname);
lnc_reset(sc);
return;
}
@@ -1465,7 +1452,7 @@ lnc_ioctl(struct ifnet * ifp, u_long command, caddr_t data)
static void
lnc_watchdog(struct ifnet *ifp)
{
- log(LOG_ERR, "lnc%d: Device timeout -- Resetting\n", ifp->if_unit);
+ log(LOG_ERR, "%s: Device timeout -- Resetting\n", ifp->if_xname);
ifp->if_oerrors++;
lnc_reset(ifp->if_softc);
}
@@ -1476,7 +1463,7 @@ lnc_dump_state(struct lnc_softc *sc)
{
int i;
- printf("\nDriver/NIC [%d] state dump\n", sc->arpcom.ac_if.if_unit);
+ printf("\nDriver/NIC [%s] state dump\n", sc->arpcom.ac_if.if_xname);
printf("Memory access mode: %b\n", sc->nic.mem_mode, MEM_MODES);
printf("Host memory\n");
printf("-----------\n");
OpenPOWER on IntegriCloud