summaryrefslogtreecommitdiffstats
path: root/sys/pci/if_ste.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/pci/if_ste.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/pci/if_ste.c')
-rw-r--r--sys/pci/if_ste.c35
1 files changed, 22 insertions, 13 deletions
diff --git a/sys/pci/if_ste.c b/sys/pci/if_ste.c
index 7c51421..7088ba6 100644
--- a/sys/pci/if_ste.c
+++ b/sys/pci/if_ste.c
@@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$");
#include <net/ethernet.h>
#include <net/if_dl.h>
#include <net/if_media.h>
+#include <net/if_types.h>
#include <net/if_vlan_var.h>
#include <net/bpf.h>
@@ -564,7 +565,7 @@ ste_setmulti(sc)
u_int32_t hashes[2] = { 0, 0 };
struct ifmultiaddr *ifma;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ste_ifp;
if (ifp->if_flags & IFF_ALLMULTI || ifp->if_flags & IFF_PROMISC) {
STE_SETBIT1(sc, STE_RX_MODE, STE_RXMODE_ALLMULTI);
STE_CLRBIT1(sc, STE_RX_MODE, STE_RXMODE_MULTIHASH);
@@ -661,7 +662,7 @@ ste_intr(xsc)
sc = xsc;
STE_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ste_ifp;
#ifdef DEVICE_POLLING
if (ifp->if_flags & IFF_POLLING)
@@ -765,7 +766,7 @@ ste_rxeof(sc)
STE_LOCK_ASSERT(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ste_ifp;
while((rxstat = sc->ste_cdata.ste_rx_head->ste_ptr->ste_status)
& STE_RXSTAT_DMADONE) {
@@ -847,7 +848,7 @@ ste_txeoc(sc)
u_int8_t txstat;
struct ifnet *ifp;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ste_ifp;
while ((txstat = CSR_READ_1(sc, STE_TX_STATUS)) &
STE_TXSTATUS_TXDONE) {
@@ -887,7 +888,7 @@ ste_txeof(sc)
struct ifnet *ifp;
int idx;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ste_ifp;
idx = sc->ste_cdata.ste_tx_cons;
while(idx != sc->ste_cdata.ste_tx_prod) {
@@ -920,7 +921,7 @@ ste_stats_update(xsc)
sc = xsc;
STE_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ste_ifp;
mii = device_get_softc(sc->ste_miibus);
ifp->if_collisions += CSR_READ_1(sc, STE_LATE_COLLS)
@@ -984,6 +985,7 @@ ste_attach(dev)
struct ste_softc *sc;
struct ifnet *ifp;
int unit, error = 0, rid;
+ u_char eaddr[6];
sc = device_get_softc(dev);
unit = device_get_unit(dev);
@@ -1037,7 +1039,7 @@ ste_attach(dev)
/*
* Get station address from the EEPROM.
*/
- if (ste_read_eeprom(sc, (caddr_t)&sc->arpcom.ac_enaddr,
+ if (ste_read_eeprom(sc, eaddr,
STE_EEADDR_NODE0, 3, 0)) {
printf("ste%d: failed to read station address\n", unit);
error = ENXIO;;
@@ -1066,7 +1068,12 @@ ste_attach(dev)
goto fail;
}
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ste_ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ printf("ste%d: can not if_alloc()\n", sc->ste_unit);
+ error = ENOSPC;
+ goto fail;
+ }
ifp->if_softc = sc;
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_mtu = ETHERMTU;
@@ -1084,7 +1091,7 @@ ste_attach(dev)
/*
* Call MI attach routine.
*/
- ether_ifattach(ifp, sc->arpcom.ac_enaddr);
+ ether_ifattach(ifp, eaddr);
/*
* Tell the upper layer(s) we support long frames.
@@ -1103,6 +1110,7 @@ ste_attach(dev)
if (error) {
printf("ste%d: couldn't set up irq\n", unit);
ether_ifdetach(ifp);
+ if_free(ifp);
goto fail;
}
@@ -1130,12 +1138,13 @@ ste_detach(dev)
sc = device_get_softc(dev);
KASSERT(mtx_initialized(&sc->ste_mtx), ("ste mutex not initialized"));
STE_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ste_ifp;
/* These should only be active if attach succeeded */
if (device_is_attached(dev)) {
ste_stop(sc);
ether_ifdetach(ifp);
+ if_free(ifp);
}
if (sc->ste_miibus)
device_delete_child(dev, sc->ste_miibus);
@@ -1266,13 +1275,13 @@ ste_init(xsc)
sc = xsc;
STE_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ste_ifp;
ste_stop(sc);
/* Init our MAC address */
for (i = 0; i < ETHER_ADDR_LEN; i++) {
- CSR_WRITE_1(sc, STE_PAR0 + i, sc->arpcom.ac_enaddr[i]);
+ CSR_WRITE_1(sc, STE_PAR0 + i, IFP2ENADDR(sc->ste_ifp)[i]);
}
/* Init RX list */
@@ -1379,7 +1388,7 @@ ste_stop(sc)
struct ifnet *ifp;
STE_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ste_ifp;
untimeout(ste_stats_update, sc, sc->ste_stat_ch);
ifp->if_flags &= ~(IFF_RUNNING|IFF_OACTIVE);
OpenPOWER on IntegriCloud