summaryrefslogtreecommitdiffstats
path: root/sys/dev/ed/if_ed.c
diff options
context:
space:
mode:
authorbrooks <brooks@FreeBSD.org>2005-06-10 16:49:24 +0000
committerbrooks <brooks@FreeBSD.org>2005-06-10 16:49:24 +0000
commit567ba9b00a248431e7c1147c4e079fd7a11b9ecf (patch)
treef65b6d7834b40dfcd48534829a0a1e9529ab87ee /sys/dev/ed/if_ed.c
parent3eaa67c3ad947d85be5350e0e184cd6ee5b93a52 (diff)
downloadFreeBSD-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/ed/if_ed.c')
-rw-r--r--sys/dev/ed/if_ed.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/sys/dev/ed/if_ed.c b/sys/dev/ed/if_ed.c
index 37f8eca..a58023b 100644
--- a/sys/dev/ed/if_ed.c
+++ b/sys/dev/ed/if_ed.c
@@ -60,6 +60,7 @@ __FBSDID("$FreeBSD$");
#include <net/if_dl.h>
#include <net/if_mib.h>
#include <net/if_media.h>
+#include <net/if_types.h>
#ifndef ED_NO_MIIBUS
#include <dev/mii/mii.h>
@@ -254,7 +255,13 @@ int
ed_attach(device_t dev)
{
struct ed_softc *sc = device_get_softc(dev);
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp;
+
+ ifp = sc->ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ device_printf(dev, "can not if_alloc()\n");
+ return (ENOSPC);
+ }
callout_handle_init(&sc->tick_ch);
/*
@@ -304,7 +311,7 @@ ed_attach(device_t dev)
/*
* Attach the interface
*/
- ether_ifattach(ifp, sc->arpcom.ac_enaddr);
+ ether_ifattach(ifp, sc->enaddr);
/* device attach does transition from UNCONFIGURED to IDLE state */
if (bootverbose || 1) {
@@ -341,13 +348,14 @@ int
ed_detach(device_t dev)
{
struct ed_softc *sc = device_get_softc(dev);
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
if (sc->gone)
return (0);
ed_stop(sc);
ifp->if_flags &= ~IFF_RUNNING;
ether_ifdetach(ifp);
+ if_free(ifp);
sc->gone = 1;
bus_teardown_intr(dev, sc->irq_res, sc->irq_handle);
ed_release_resources(dev);
@@ -451,7 +459,7 @@ static void
ed_init(void *xsc)
{
struct ed_softc *sc = xsc;
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
int i, s;
if (sc->gone)
@@ -547,7 +555,7 @@ ed_init(void *xsc)
* Copy out our station address
*/
for (i = 0; i < ETHER_ADDR_LEN; ++i)
- ed_nic_outb(sc, ED_P1_PAR(i), sc->arpcom.ac_enaddr[i]);
+ ed_nic_outb(sc, ED_P1_PAR(i), IFP2ENADDR(sc->ifp)[i]);
/*
* Set Current Page pointer to next_packet (initialized above)
@@ -820,7 +828,7 @@ outloop:
static __inline void
ed_rint(struct ed_softc *sc)
{
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
u_char boundry;
u_short len;
struct ed_ring packet_hdr;
@@ -1329,7 +1337,7 @@ ed_ring_copy(struct ed_softc *sc, char *src, char *dst, u_short amount)
static void
ed_get_packet(struct ed_softc *sc, char *buf, u_short len)
{
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
struct ether_header *eh;
struct mbuf *m;
@@ -1770,7 +1778,7 @@ ed_ds_getmcaf(struct ed_softc *sc, uint32_t *mcaf)
mcaf[0] = 0;
mcaf[1] = 0;
- TAILQ_FOREACH(ifma, &sc->arpcom.ac_if.if_multiaddrs, ifma_link) {
+ TAILQ_FOREACH(ifma, &sc->ifp->if_multiaddrs, ifma_link) {
if (ifma->ifma_addr->sa_family != AF_LINK)
continue;
index = ether_crc32_be(LLADDR((struct sockaddr_dl *)
OpenPOWER on IntegriCloud