diff options
author | brooks <brooks@FreeBSD.org> | 2005-06-10 16:49:24 +0000 |
---|---|---|
committer | brooks <brooks@FreeBSD.org> | 2005-06-10 16:49:24 +0000 |
commit | 567ba9b00a248431e7c1147c4e079fd7a11b9ecf (patch) | |
tree | f65b6d7834b40dfcd48534829a0a1e9529ab87ee /sys/dev/ppbus/if_plip.c | |
parent | 3eaa67c3ad947d85be5350e0e184cd6ee5b93a52 (diff) | |
download | FreeBSD-src-567ba9b00a248431e7c1147c4e079fd7a11b9ecf.zip FreeBSD-src-567ba9b00a248431e7c1147c4e079fd7a11b9ecf.tar.gz |
Stop embedding struct ifnet at the top of driver softcs. Instead the
struct ifnet or the layer 2 common structure it was embedded in have
been replaced with a struct ifnet pointer to be filled by a call to the
new function, if_alloc(). The layer 2 common structure is also allocated
via if_alloc() based on the interface type. It is hung off the new
struct ifnet member, if_l2com.
This change removes the size of these structures from the kernel ABI and
will allow us to better manage them as interfaces come and go.
Other changes of note:
- Struct arpcom is no longer referenced in normal interface code.
Instead the Ethernet address is accessed via the IFP2ENADDR() macro.
To enforce this ac_enaddr has been renamed to _ac_enaddr.
- The second argument to ether_ifattach is now always the mac address
from driver private storage rather than sometimes being ac_enaddr.
Reviewed by: sobomax, sam
Diffstat (limited to 'sys/dev/ppbus/if_plip.c')
-rw-r--r-- | sys/dev/ppbus/if_plip.c | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/sys/dev/ppbus/if_plip.c b/sys/dev/ppbus/if_plip.c index 5b05812..59bb5d6 100644 --- a/sys/dev/ppbus/if_plip.c +++ b/sys/dev/ppbus/if_plip.c @@ -146,7 +146,7 @@ static int volatile lptflag = 0; #endif struct lp_data { - struct ifnet sc_if; + struct ifnet *sc_ifp; u_char *sc_ifbuf; int sc_iferrs; @@ -232,7 +232,12 @@ static int lp_attach (device_t dev) { struct lp_data *lp = DEVTOSOFTC(dev); - struct ifnet *ifp = &lp->sc_if; + struct ifnet *ifp; + + ifp = lp->sc_ifp = if_alloc(IFT_PARA); + if (ifp == NULL) { + return (ENOSPC); + } ifp->if_softc = lp; if_initname(ifp, device_get_name(dev), device_get_unit(dev)); @@ -241,7 +246,6 @@ lp_attach (device_t dev) IFF_NEEDSGIANT; ifp->if_ioctl = lpioctl; ifp->if_output = lpoutput; - ifp->if_type = IFT_PARA; ifp->if_hdrlen = 0; ifp->if_addrlen = 0; ifp->if_snd.ifq_maxlen = IFQ_MAXLEN; @@ -343,7 +347,7 @@ lpioctl (struct ifnet *ifp, u_long cmd, caddr_t data) return ENOBUFS; } - sc->sc_ifbuf = malloc(sc->sc_if.if_mtu + MLPIPHDRLEN, + sc->sc_ifbuf = malloc(sc->sc_ifp->if_mtu + MLPIPHDRLEN, M_DEVBUF, M_WAITOK); if (!sc->sc_ifbuf) { ppb_release_bus(ppbus, dev); @@ -371,11 +375,11 @@ lpioctl (struct ifnet *ifp, u_long cmd, caddr_t data) } if (ptr) free(ptr,M_DEVBUF); - sc->sc_if.if_mtu = ifr->ifr_mtu; + sc->sc_ifp->if_mtu = ifr->ifr_mtu; break; case SIOCGIFMTU: - ifr->ifr_mtu = sc->sc_if.if_mtu; + ifr->ifr_mtu = sc->sc_ifp->if_mtu; break; case SIOCADDMULTI: @@ -465,7 +469,7 @@ lp_intr (void *arg) s = splhigh(); - if (sc->sc_if.if_flags & IFF_LINK0) { + if (sc->sc_ifp->if_flags & IFF_LINK0) { /* Ack. the request */ ppb_wdtr(ppbus, 0x01); @@ -479,7 +483,7 @@ lp_intr (void *arg) if (j == -1) goto err; len = len + (j << 8); - if (len > sc->sc_if.if_mtu + MLPIPHDRLEN) + if (len > sc->sc_ifp->if_mtu + MLPIPHDRLEN) goto err; bp = sc->sc_ifbuf; @@ -504,18 +508,18 @@ lp_intr (void *arg) sc->sc_iferrs = 0; len -= CLPIPHDRLEN; - sc->sc_if.if_ipackets++; - sc->sc_if.if_ibytes += len; - top = m_devget(sc->sc_ifbuf + CLPIPHDRLEN, len, 0, &sc->sc_if, 0); + sc->sc_ifp->if_ipackets++; + sc->sc_ifp->if_ibytes += len; + top = m_devget(sc->sc_ifbuf + CLPIPHDRLEN, len, 0, sc->sc_ifp, 0); if (top) { - if (sc->sc_if.if_bpf) - lptap(&sc->sc_if, top); + if (sc->sc_ifp->if_bpf) + lptap(sc->sc_ifp, top); netisr_queue(NETISR_IP, top); /* mbuf is free'd on failure. */ } goto done; } while ((ppb_rstr(ppbus) & LPIP_SHAKE)) { - len = sc->sc_if.if_mtu + LPIPHDRLEN; + len = sc->sc_ifp->if_mtu + LPIPHDRLEN; bp = sc->sc_ifbuf; while (len--) { @@ -549,12 +553,12 @@ lp_intr (void *arg) sc->sc_iferrs = 0; len -= LPIPHDRLEN; - sc->sc_if.if_ipackets++; - sc->sc_if.if_ibytes += len; - top = m_devget(sc->sc_ifbuf + LPIPHDRLEN, len, 0, &sc->sc_if, 0); + sc->sc_ifp->if_ipackets++; + sc->sc_ifp->if_ibytes += len; + top = m_devget(sc->sc_ifbuf + LPIPHDRLEN, len, 0, sc->sc_ifp, 0); if (top) { - if (sc->sc_if.if_bpf) - lptap(&sc->sc_if, top); + if (sc->sc_ifp->if_bpf) + lptap(sc->sc_ifp, top); netisr_queue(NETISR_IP, top); /* mbuf is free'd on failure. */ } } @@ -563,7 +567,7 @@ lp_intr (void *arg) err: ppb_wdtr(ppbus, 0); lprintf("R"); - sc->sc_if.if_ierrors++; + sc->sc_ifp->if_ierrors++; sc->sc_iferrs++; /* @@ -573,7 +577,7 @@ lp_intr (void *arg) if (sc->sc_iferrs > LPMAXERRS) { printf("lp%d: Too many errors, Going off-line.\n", device_get_unit(dev)); ppb_wctr(ppbus, 0x00); - sc->sc_if.if_flags &= ~IFF_RUNNING; + sc->sc_ifp->if_flags &= ~IFF_RUNNING; sc->sc_iferrs=0; } |