summaryrefslogtreecommitdiffstats
path: root/sys/dev/dc
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/dc
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/dc')
-rw-r--r--sys/dev/dc/if_dc.c54
-rw-r--r--sys/dev/dc/if_dcreg.h2
2 files changed, 31 insertions, 25 deletions
diff --git a/sys/dev/dc/if_dc.c b/sys/dev/dc/if_dc.c
index ae92c8d..f86d4e4 100644
--- a/sys/dev/dc/if_dc.c
+++ b/sys/dev/dc/if_dc.c
@@ -1084,7 +1084,7 @@ dc_setfilt_21143(struct dc_softc *sc)
struct ifnet *ifp;
int i;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->dc_ifp;
i = sc->dc_cdata.dc_tx_prod;
DC_INC(sc->dc_cdata.dc_tx_prod, DC_TX_LIST_CNT);
@@ -1124,9 +1124,9 @@ dc_setfilt_21143(struct dc_softc *sc)
}
/* Set our MAC address */
- sp[39] = DC_SP_MAC(((u_int16_t *)sc->arpcom.ac_enaddr)[0]);
- sp[40] = DC_SP_MAC(((u_int16_t *)sc->arpcom.ac_enaddr)[1]);
- sp[41] = DC_SP_MAC(((u_int16_t *)sc->arpcom.ac_enaddr)[2]);
+ sp[39] = DC_SP_MAC(((u_int16_t *)IFP2ENADDR(sc->dc_ifp))[0]);
+ sp[40] = DC_SP_MAC(((u_int16_t *)IFP2ENADDR(sc->dc_ifp))[1]);
+ sp[41] = DC_SP_MAC(((u_int16_t *)IFP2ENADDR(sc->dc_ifp))[2]);
sframe->dc_status = htole32(DC_TXSTAT_OWN);
CSR_WRITE_4(sc, DC_TXSTART, 0xFFFFFFFF);
@@ -1150,11 +1150,11 @@ dc_setfilt_admtek(struct dc_softc *sc)
int h = 0;
u_int32_t hashes[2] = { 0, 0 };
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->dc_ifp;
/* Init our MAC address. */
- CSR_WRITE_4(sc, DC_AL_PAR0, *(u_int32_t *)(&sc->arpcom.ac_enaddr[0]));
- CSR_WRITE_4(sc, DC_AL_PAR1, *(u_int32_t *)(&sc->arpcom.ac_enaddr[4]));
+ CSR_WRITE_4(sc, DC_AL_PAR0, *(u_int32_t *)(&IFP2ENADDR(sc->dc_ifp)[0]));
+ CSR_WRITE_4(sc, DC_AL_PAR1, *(u_int32_t *)(&IFP2ENADDR(sc->dc_ifp)[4]));
/* If we want promiscuous mode, set the allframes bit. */
if (ifp->if_flags & IFF_PROMISC)
@@ -1206,15 +1206,15 @@ dc_setfilt_asix(struct dc_softc *sc)
int h = 0;
u_int32_t hashes[2] = { 0, 0 };
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->dc_ifp;
/* Init our MAC address */
CSR_WRITE_4(sc, DC_AX_FILTIDX, DC_AX_FILTIDX_PAR0);
CSR_WRITE_4(sc, DC_AX_FILTDATA,
- *(u_int32_t *)(&sc->arpcom.ac_enaddr[0]));
+ *(u_int32_t *)(&IFP2ENADDR(sc->dc_ifp)[0]));
CSR_WRITE_4(sc, DC_AX_FILTIDX, DC_AX_FILTIDX_PAR1);
CSR_WRITE_4(sc, DC_AX_FILTDATA,
- *(u_int32_t *)(&sc->arpcom.ac_enaddr[4]));
+ *(u_int32_t *)(&IFP2ENADDR(sc->dc_ifp)[4]));
/* If we want promiscuous mode, set the allframes bit. */
if (ifp->if_flags & IFF_PROMISC)
@@ -1275,7 +1275,7 @@ dc_setfilt_xircom(struct dc_softc *sc)
u_int32_t h, *sp;
int i;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->dc_ifp;
DC_CLRBIT(sc, DC_NETCFG, (DC_NETCFG_TX_ON | DC_NETCFG_RX_ON));
i = sc->dc_cdata.dc_tx_prod;
@@ -1316,9 +1316,9 @@ dc_setfilt_xircom(struct dc_softc *sc)
}
/* Set our MAC address */
- sp[0] = DC_SP_MAC(((u_int16_t *)sc->arpcom.ac_enaddr)[0]);
- sp[1] = DC_SP_MAC(((u_int16_t *)sc->arpcom.ac_enaddr)[1]);
- sp[2] = DC_SP_MAC(((u_int16_t *)sc->arpcom.ac_enaddr)[2]);
+ sp[0] = DC_SP_MAC(((u_int16_t *)IFP2ENADDR(sc->dc_ifp))[0]);
+ sp[1] = DC_SP_MAC(((u_int16_t *)IFP2ENADDR(sc->dc_ifp))[1]);
+ sp[2] = DC_SP_MAC(((u_int16_t *)IFP2ENADDR(sc->dc_ifp))[2]);
DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_TX_ON);
DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_RX_ON);
@@ -2090,7 +2090,6 @@ dc_attach(device_t dev)
}
sc->dc_unit = unit;
- bcopy(eaddr, &sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
/* Allocate a busdma tag and DMA safe memory for TX/RX descriptors. */
error = bus_dma_tag_create(NULL, PAGE_SIZE, 0, BUS_SPACE_MAXADDR_32BIT,
@@ -2180,7 +2179,12 @@ dc_attach(device_t dev)
goto fail;
}
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->dc_ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ printf("dc%d: can not if_alloc()\n", unit);
+ error = ENOSPC;
+ goto fail;
+ }
ifp->if_softc = sc;
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
/* XXX: bleah, MTU gets overwritten in ether_ifattach() */
@@ -2309,6 +2313,7 @@ dc_attach(device_t dev)
if (error) {
printf("dc%d: couldn't set up irq\n", unit);
ether_ifdetach(ifp);
+ if_free(ifp);
goto fail;
}
@@ -2337,12 +2342,13 @@ dc_detach(device_t dev)
KASSERT(mtx_initialized(&sc->dc_mtx), ("dc mutex not initialized"));
DC_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->dc_ifp;
/* These should only be active if attach succeeded */
if (device_is_attached(dev)) {
dc_stop(sc);
ether_ifdetach(ifp);
+ if_free(ifp);
}
if (sc->dc_miibus)
device_delete_child(dev, sc->dc_miibus);
@@ -2687,7 +2693,7 @@ dc_rxeof(struct dc_softc *sc)
DC_LOCK_ASSERT(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->dc_ifp;
i = sc->dc_cdata.dc_rx_prod;
bus_dmamap_sync(sc->dc_ltag, sc->dc_lmap, BUS_DMASYNC_POSTREAD);
@@ -2801,7 +2807,7 @@ dc_txeof(struct dc_softc *sc)
int idx;
u_int32_t ctl, txstat;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->dc_ifp;
/*
* Go through our tx list and free mbufs for those
@@ -2909,7 +2915,7 @@ dc_tick(void *xsc)
sc = xsc;
DC_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->dc_ifp;
mii = device_get_softc(sc->dc_miibus);
if (sc->dc_flags & DC_REDUCED_MII_POLL) {
@@ -3100,7 +3106,7 @@ dc_intr(void *arg)
return;
DC_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->dc_ifp;
#ifdef DEVICE_POLLING
if (ifp->if_flags & IFF_POLLING)
goto done;
@@ -3377,7 +3383,7 @@ static void
dc_init(void *xsc)
{
struct dc_softc *sc = xsc;
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->dc_ifp;
struct mii_data *mii;
DC_LOCK(sc);
@@ -3705,7 +3711,7 @@ dc_stop(struct dc_softc *sc)
DC_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->dc_ifp;
ifp->if_timer = 0;
ld = sc->dc_ldata;
cd = &sc->dc_cdata;
@@ -3791,7 +3797,7 @@ dc_resume(device_t dev)
s = splimp();
sc = device_get_softc(dev);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->dc_ifp;
/* reinitialize interface if necessary */
if (ifp->if_flags & IFF_UP)
diff --git a/sys/dev/dc/if_dcreg.h b/sys/dev/dc/if_dcreg.h
index 5cc5049..a851a72 100644
--- a/sys/dev/dc/if_dcreg.h
+++ b/sys/dev/dc/if_dcreg.h
@@ -716,7 +716,7 @@ struct dc_mii_frame {
struct dc_softc {
- struct arpcom arpcom; /* interface info */
+ struct ifnet *dc_ifp; /* interface info */
bus_space_handle_t dc_bhandle; /* bus space handle */
bus_space_tag_t dc_btag; /* bus space tag */
bus_dma_tag_t dc_ltag; /* tag for descriptor ring */
OpenPOWER on IntegriCloud