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/snc | |
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/snc')
-rw-r--r-- | sys/dev/snc/dp83932.c | 42 | ||||
-rw-r--r-- | sys/dev/snc/dp83932var.h | 3 |
2 files changed, 24 insertions, 21 deletions
diff --git a/sys/dev/snc/dp83932.c b/sys/dev/snc/dp83932.c index 9080699..23fea5e 100644 --- a/sys/dev/snc/dp83932.c +++ b/sys/dev/snc/dp83932.c @@ -79,6 +79,7 @@ #include <net/if_arp.h> #include <net/if_dl.h> #include <net/if_media.h> +#include <net/if_types.h> #include <net/bpf.h> @@ -154,7 +155,7 @@ sncconfig(sc, media, nmedia, defmedia, myea) int *media, nmedia, defmedia; u_int8_t *myea; { - struct ifnet *ifp = &sc->sc_if; + struct ifnet *ifp; int i; #ifdef SNCDEBUG @@ -163,6 +164,10 @@ sncconfig(sc, media, nmedia, defmedia, myea) } #endif + ifp = sc->sc_ifp = if_alloc(IFT_ETHER); + if (ifp == NULL) + panic("%s: can not if_alloc()\n", device_get_nameunit(dev)); + #ifdef SNCDEBUG device_printf(sc->sc_dev, "buffers: rra=0x%x cda=0x%x rda=0x%x tda=0x%x\n", @@ -181,7 +186,6 @@ sncconfig(sc, media, nmedia, defmedia, myea) ifp->if_init = sncinit; ifp->if_mtu = ETHERMTU; ifp->if_snd.ifq_maxlen = IFQ_MAXLEN; - bcopy(myea, sc->sc_ethercom.ac_enaddr, ETHER_ADDR_LEN); /* Initialize media goo. */ ifmedia_init(&sc->sc_media, 0, snc_mediachange, @@ -394,7 +398,7 @@ sncinit(xsc) u_long s_rcr; int s; - if (sc->sc_if.if_flags & IFF_RUNNING) + if (sc->sc_ifp->if_flags & IFF_RUNNING) /* already running */ return; @@ -408,9 +412,9 @@ sncinit(xsc) NIC_PUT(sc, SNCR_DCR2, sc->sncr_dcr2); s_rcr = RCR_BRD | RCR_LBNONE; - if (sc->sc_if.if_flags & IFF_PROMISC) + if (sc->sc_ifp->if_flags & IFF_PROMISC) s_rcr |= RCR_PRO; - if (sc->sc_if.if_flags & IFF_ALLMULTI) + if (sc->sc_ifp->if_flags & IFF_ALLMULTI) s_rcr |= RCR_AMC; NIC_PUT(sc, SNCR_RCR, s_rcr); @@ -446,8 +450,8 @@ sncinit(xsc) wbflush(); /* flag interface as "running" */ - sc->sc_if.if_flags |= IFF_RUNNING; - sc->sc_if.if_flags &= ~IFF_OACTIVE; + sc->sc_ifp->if_flags |= IFF_RUNNING; + sc->sc_ifp->if_flags &= ~IFF_OACTIVE; splx(s); return; @@ -479,8 +483,8 @@ sncstop(sc) if (++sc->mtd_hw == NTDA) sc->mtd_hw = 0; } - sc->sc_if.if_timer = 0; - sc->sc_if.if_flags &= ~(IFF_RUNNING | IFF_UP); + sc->sc_ifp->if_timer = 0; + sc->sc_ifp->if_flags &= ~(IFF_RUNNING | IFF_UP); splx(s); return (0); @@ -596,7 +600,7 @@ sonicput(sc, m0, mtd_next) wbflush(); NIC_PUT(sc, SNCR_CR, CR_TXP); wbflush(); - sc->sc_if.if_timer = 5; /* 5 seconds to watch for failing to transmit */ + sc->sc_ifp->if_timer = 5; /* 5 seconds to watch for failing to transmit */ return (totlen); } @@ -660,10 +664,10 @@ camprogram(sc) caminitialise(sc); - ifp = &sc->sc_if; + ifp = sc->sc_ifp; /* Always load our own address first. */ - camentry (sc, mcount, sc->sc_ethercom.ac_enaddr); + camentry (sc, mcount, IFP2ENADDR(sc->sc_ifp)); mcount++; /* Assume we won't need allmulti bit. */ @@ -879,7 +883,7 @@ sncintr(arg) sc->sc_mptally++; #endif } - sncstart(&sc->sc_if); + sncstart(sc->sc_ifp); #if NRND > 0 if (isr) @@ -900,7 +904,7 @@ sonictxint(sc) u_int32_t txp; unsigned short txp_status; int mtd_hw; - struct ifnet *ifp = &sc->sc_if; + struct ifnet *ifp = sc->sc_ifp; mtd_hw = sc->mtd_hw; @@ -997,11 +1001,11 @@ sonicrxint(sc) u_int32_t pkt = sc->rbuf[orra & RBAMASK] + (rxpkt_ptr & PGOFSET); if (sonic_read(sc, pkt, len)) - sc->sc_if.if_ipackets++; + sc->sc_ifp->if_ipackets++; else - sc->sc_if.if_ierrors++; + sc->sc_ifp->if_ierrors++; } else - sc->sc_if.if_ierrors++; + sc->sc_ifp->if_ierrors++; /* * give receive buffer area back to chip. @@ -1069,7 +1073,7 @@ sonic_read(sc, pkt, len) u_int32_t pkt; int len; { - struct ifnet *ifp = &sc->sc_if; + struct ifnet *ifp = sc->sc_ifp; struct ether_header *et; struct mbuf *m; @@ -1124,7 +1128,7 @@ sonic_get(sc, pkt, datalen) MGETHDR(m, M_DONTWAIT, MT_DATA); if (m == 0) return (0); - m->m_pkthdr.rcvif = &sc->sc_if; + m->m_pkthdr.rcvif = sc->sc_ifp; m->m_pkthdr.len = datalen; len = MHLEN; top = 0; diff --git a/sys/dev/snc/dp83932var.h b/sys/dev/snc/dp83932var.h index f621397..9570162 100644 --- a/sys/dev/snc/dp83932var.h +++ b/sys/dev/snc/dp83932var.h @@ -130,8 +130,7 @@ typedef struct mtd { * The snc_softc for PC-98 if_snc. */ typedef struct snc_softc { - struct arpcom sc_ethercom; -#define sc_if sc_ethercom.ac_if /* network visible interface */ + struct ifnet * sc_ifp; device_t sc_dev; |