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/en/if_en_pci.c | |
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/en/if_en_pci.c')
-rw-r--r-- | sys/dev/en/if_en_pci.c | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/sys/dev/en/if_en_pci.c b/sys/dev/en/if_en_pci.c index 8409352..c167e2a 100644 --- a/sys/dev/en/if_en_pci.c +++ b/sys/dev/en/if_en_pci.c @@ -65,6 +65,7 @@ __FBSDID("$FreeBSD$"); #include <net/if.h> #include <net/if_atm.h> #include <net/if_media.h> +#include <net/if_types.h> #include <dev/pci/pcivar.h> #include <dev/pci/pcireg.h> @@ -149,7 +150,7 @@ adp_busreset(void *v) dummy = bus_space_read_4(sc->en_memt, sc->en_base, ADP_PCIREG); if ((dummy & (ADP_PCIREG_SWAP_WORD | ADP_PCIREG_SWAP_DMA)) != ADP_PCIREG_SWAP_DMA) - if_printf(&sc->ifatm.ifnet, "adp_busreset: Adaptec ATM did " + if_printf(sc->ifp, "adp_busreset: Adaptec ATM did " "NOT reset!\n"); } @@ -197,8 +198,11 @@ en_pci_attach(device_t dev) sc = device_get_softc(dev); scp = (struct en_pci_softc *)sc; + sc->ifp = if_alloc(IFT_ATM); + if (sc->ifp == NULL) + return (ENOSPC); - if_initname(&(sc->ifatm.ifnet), device_get_name(dev), + if_initname(sc->ifp, device_get_name(dev), device_get_unit(dev)); /* @@ -273,7 +277,8 @@ en_pci_attach(device_t dev) en_intr, sc, &scp->ih); if (error) { en_reset(sc); - atm_ifdetach(&sc->ifatm.ifnet); + atm_ifdetach(sc->ifp); + if_free(sc->ifp); device_printf(dev, "could not setup irq\n"); bus_release_resource(dev, SYS_RES_IRQ, 0, scp->irq); bus_release_resource(dev, SYS_RES_MEMORY, PCI_CBMA, scp->res); @@ -299,16 +304,17 @@ en_pci_detach(device_t dev) /* * Stop DMA and drop transmit queue. */ - if ((sc->ifatm.ifnet.if_flags & IFF_RUNNING)) { - if_printf(&sc->ifatm.ifnet, "still running\n"); - sc->ifatm.ifnet.if_flags &= ~IFF_RUNNING; + if ((sc->ifp->if_flags & IFF_RUNNING)) { + if_printf(sc->ifp, "still running\n"); + sc->ifp->if_flags &= ~IFF_RUNNING; } /* * Close down routes etc. */ en_reset(sc); - atm_ifdetach(&sc->ifatm.ifnet); + atm_ifdetach(sc->ifp); + if_free(sc->ifp); /* * Deallocate resources. @@ -347,8 +353,8 @@ adp_get_macaddr(struct en_pci_softc *scp) struct en_softc * sc = (struct en_softc *)scp; int lcv; - for (lcv = 0; lcv < sizeof(sc->ifatm.mib.esi); lcv++) - sc->ifatm.mib.esi[lcv] = bus_space_read_1(sc->en_memt, + for (lcv = 0; lcv < sizeof(IFP2IFATM(sc->ifp)->mib.esi); lcv++) + IFP2IFATM(sc->ifp)->mib.esi[lcv] = bus_space_read_1(sc->en_memt, sc->en_base, MID_ADPMACOFF + lcv); } @@ -447,13 +453,13 @@ eni_get_macaddr(device_t dev, struct en_pci_softc *scp) data = EN_PROM_MAGIC | EN_PROM_DATA | EN_PROM_CLK; pci_write_config(dev, EN_TONGA, data, 4); - for (i = 0; i < sizeof(sc->ifatm.mib.esi); i ++) - sc->ifatm.mib.esi[i] = eni_get_byte(dev, &data, i + EN_ESI); + for (i = 0; i < sizeof(IFP2IFATM(sc->ifp)->mib.esi); i ++) + IFP2IFATM(sc->ifp)->mib.esi[i] = eni_get_byte(dev, &data, i + EN_ESI); - sc->ifatm.mib.serial = 0; + IFP2IFATM(sc->ifp)->mib.serial = 0; for (i = 0; i < 4; i++) { - sc->ifatm.mib.serial <<= 8; - sc->ifatm.mib.serial |= eni_get_byte(dev, &data, i + EN_SERIAL); + IFP2IFATM(sc->ifp)->mib.serial <<= 8; + IFP2IFATM(sc->ifp)->mib.serial |= eni_get_byte(dev, &data, i + EN_SERIAL); } /* stop operation */ data &= ~EN_PROM_DATA; |