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/cnw | |
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/cnw')
-rw-r--r-- | sys/dev/cnw/if_cnw.c | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/sys/dev/cnw/if_cnw.c b/sys/dev/cnw/if_cnw.c index d1891c3..d4f98c7 100644 --- a/sys/dev/cnw/if_cnw.c +++ b/sys/dev/cnw/if_cnw.c @@ -288,7 +288,7 @@ int cnw_skey = CNW_SCRAMBLEKEY; /* Scramble key */ #endif struct cnw_softc { - struct arpcom arpcom; + struct ifnet *sc_ifp; struct ifmedia ifmedia; device_t dev; struct cnwstats sc_stats; @@ -510,7 +510,7 @@ cnw_init(sc) #if !defined(__FreeBSD__) struct ifnet *ifp = &sc->sc_ethercom.ec_if; #else /* FreeBSD */ - struct ifnet *ifp = &sc->arpcom.ac_if; + struct ifnet *ifp = sc->sc_ifp; #endif const u_int8_t rxmode = CNW_RXCONF_RXENA | CNW_RXCONF_BCAST | CNW_RXCONF_AMP; @@ -949,7 +949,7 @@ cnw_read(sc) #if !defined(__FreeBSD__) m->m_pkthdr.rcvif = &sc->sc_ethercom.ec_if; #else /* FreeBSD */ - m->m_pkthdr.rcvif = &sc->arpcom.ac_if; + m->m_pkthdr.rcvif = sc->sc_ifp; #endif m->m_pkthdr.len = totbytes; mbytes = MHLEN; @@ -1024,7 +1024,7 @@ cnw_recv(sc) #if !defined(__FreeBSD__) struct ifnet *ifp = &sc->sc_ethercom.ec_if; #else - struct ifnet *ifp = &sc->arpcom.ac_if; + struct ifnet *ifp = sc->sc_ifp; #endif struct mbuf *m; @@ -1076,7 +1076,7 @@ cnw_intr(arg) #if !defined(__FreeBSD__) struct ifnet *ifp = &sc->sc_ethercom.ec_if; #else - struct ifnet *ifp = &sc->arpcom.ac_if; + struct ifnet *ifp = sc->sc_ifp; #endif int ret, status, rser, tser; @@ -1498,7 +1498,7 @@ static void cnw_freebsd_init(xsc) void *xsc; { struct cnw_softc *sc = xsc; - struct ifnet *ifp = &sc->arpcom.ac_if; + struct ifnet *ifp = sc->sc_ifp; int s; if (sc->cnw_gone) @@ -1534,7 +1534,7 @@ static void cnw_stop(sc) cnw_reset(sc); - ifp = &sc->arpcom.ac_if; + ifp = sc->sc_ifp; ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE); return; @@ -1571,7 +1571,7 @@ static int cnw_pccard_detach(dev) #endif sc = device_get_softc(dev); - ifp = &sc->arpcom.ac_if; + ifp = sc->sc_ifp; if (sc->cnw_gone) { device_printf(dev, "already unloaded\n"); @@ -1581,6 +1581,7 @@ static int cnw_pccard_detach(dev) cnw_stop(sc); ether_ifdetach(ifp); + if_free(ifp); cnw_free(dev); sc->cnw_gone = 1; @@ -1595,9 +1596,15 @@ static int cnw_pccard_attach(device_t dev) struct cnw_softc *sc; struct ifnet *ifp; int i, error; + u_char eaddr[6]; sc = device_get_softc(dev); - ifp = &sc->arpcom.ac_if; + ifp = sc->sc_ifp = if_alloc(IFT_ETHER); + if (ifp == NULL) { + device_printf(dev, "if_alloc() failed\n"); + return (ENOSPC); + } + error = cnw_alloc(dev); if (error) { @@ -1623,8 +1630,7 @@ static int cnw_pccard_attach(device_t dev) /* Get MAC address */ for (i=0; i< ETHER_ADDR_LEN; i++) { - sc->arpcom.ac_enaddr[i] = - bus_space_read_1(sc->sc_memt, sc->sc_memh, + eaddr[i] = bus_space_read_1(sc->sc_memt, sc->sc_memh, sc->sc_memoff + CNW_EREG_PA + i); } @@ -1647,7 +1653,7 @@ static int cnw_pccard_attach(device_t dev) /* * Call MI attach routine. */ - ether_ifattach(ifp, sc->arpcom.ac_enaddr); + ether_ifattach(ifp, eaddr); /* callout_handle_init(&sc->cnw_stat_ch); */ return(0); |