summaryrefslogtreecommitdiffstats
path: root/sys/dev/gem
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/gem
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/gem')
-rw-r--r--sys/dev/gem/if_gem.c34
-rw-r--r--sys/dev/gem/if_gem_pci.c2
-rw-r--r--sys/dev/gem/if_gemvar.h3
3 files changed, 24 insertions, 15 deletions
diff --git a/sys/dev/gem/if_gem.c b/sys/dev/gem/if_gem.c
index 6ec46bb..08a8b98 100644
--- a/sys/dev/gem/if_gem.c
+++ b/sys/dev/gem/if_gem.c
@@ -56,6 +56,7 @@ __FBSDID("$FreeBSD$");
#include <net/if_arp.h>
#include <net/if_dl.h>
#include <net/if_media.h>
+#include <net/if_types.h>
#include <machine/bus.h>
@@ -124,11 +125,15 @@ int
gem_attach(sc)
struct gem_softc *sc;
{
- struct ifnet *ifp = &sc->sc_arpcom.ac_if;
+ struct ifnet *ifp;
struct mii_softc *child;
int i, error;
u_int32_t v;
+ ifp = sc->sc_ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL)
+ return (ENOSPC);
+
/* Make sure the chip is stopped. */
ifp->if_softc = sc;
gem_reset(sc);
@@ -137,7 +142,7 @@ gem_attach(sc)
BUS_SPACE_MAXADDR, NULL, NULL, MCLBYTES, GEM_NSEGS,
BUS_SPACE_MAXSIZE_32BIT, 0, NULL, NULL, &sc->sc_pdmatag);
if (error)
- return (error);
+ goto fail_ifnet;
error = bus_dma_tag_create(sc->sc_pdmatag, 1, 0,
BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, MAXBSIZE,
@@ -301,7 +306,7 @@ gem_attach(sc)
bus_space_write_4(sc->sc_bustag, sc->sc_h, GEM_MIF_CONFIG,
sc->sc_mif_config);
/* Attach the interface. */
- ether_ifattach(ifp, sc->sc_arpcom.ac_enaddr);
+ ether_ifattach(ifp, sc->sc_enaddr);
#if notyet
/*
@@ -346,6 +351,8 @@ fail_rtag:
bus_dma_tag_destroy(sc->sc_rdmatag);
fail_ptag:
bus_dma_tag_destroy(sc->sc_pdmatag);
+fail_ifnet:
+ if_free(ifp);
return (error);
}
@@ -353,10 +360,11 @@ void
gem_detach(sc)
struct gem_softc *sc;
{
- struct ifnet *ifp = &sc->sc_arpcom.ac_if;
+ struct ifnet *ifp = sc->sc_ifp;
int i;
ether_ifdetach(ifp);
+ if_free(ifp);
gem_stop(ifp, 1);
device_delete_child(sc->sc_dev, sc->sc_miibus);
@@ -385,7 +393,7 @@ void
gem_suspend(sc)
struct gem_softc *sc;
{
- struct ifnet *ifp = &sc->sc_arpcom.ac_if;
+ struct ifnet *ifp = sc->sc_ifp;
gem_stop(ifp, 0);
}
@@ -394,7 +402,7 @@ void
gem_resume(sc)
struct gem_softc *sc;
{
- struct ifnet *ifp = &sc->sc_arpcom.ac_if;
+ struct ifnet *ifp = sc->sc_ifp;
if (ifp->if_flags & IFF_UP)
gem_init(ifp);
@@ -847,7 +855,7 @@ gem_init(xsc)
void *xsc;
{
struct gem_softc *sc = (struct gem_softc *)xsc;
- struct ifnet *ifp = &sc->sc_arpcom.ac_if;
+ struct ifnet *ifp = sc->sc_ifp;
bus_space_tag_t t = sc->sc_bustag;
bus_space_handle_t h = sc->sc_h;
int s;
@@ -866,7 +874,7 @@ gem_init(xsc)
*/
/* step 1 & 2. Reset the Ethernet Channel */
- gem_stop(&sc->sc_arpcom.ac_if, 0);
+ gem_stop(sc->sc_ifp, 0);
gem_reset(sc);
#ifdef GEM_DEBUG
CTR1(KTR_GEM, "%s: gem_init: restarting", device_get_name(sc->sc_dev));
@@ -1019,7 +1027,7 @@ gem_init_regs(sc)
{
bus_space_tag_t t = sc->sc_bustag;
bus_space_handle_t h = sc->sc_h;
- const u_char *laddr = sc->sc_arpcom.ac_enaddr;
+ const u_char *laddr = IFP2ENADDR(sc->sc_ifp);
u_int32_t v;
/* These regs are not cleared on reset */
@@ -1198,7 +1206,7 @@ static void
gem_tint(sc)
struct gem_softc *sc;
{
- struct ifnet *ifp = &sc->sc_arpcom.ac_if;
+ struct ifnet *ifp = sc->sc_ifp;
bus_space_tag_t t = sc->sc_bustag;
bus_space_handle_t mac = sc->sc_h;
struct gem_txsoft *txs;
@@ -1342,7 +1350,7 @@ static void
gem_rint(sc)
struct gem_softc *sc;
{
- struct ifnet *ifp = &sc->sc_arpcom.ac_if;
+ struct ifnet *ifp = sc->sc_ifp;
bus_space_tag_t t = sc->sc_bustag;
bus_space_handle_t h = sc->sc_h;
struct gem_rxsoft *rxs;
@@ -1843,7 +1851,7 @@ static void
gem_setladrf(sc)
struct gem_softc *sc;
{
- struct ifnet *ifp = &sc->sc_arpcom.ac_if;
+ struct ifnet *ifp = sc->sc_ifp;
struct ifmultiaddr *inm;
bus_space_tag_t t = sc->sc_bustag;
bus_space_handle_t h = sc->sc_h;
@@ -1886,7 +1894,7 @@ gem_setladrf(sc)
/* Clear hash table */
memset(hash, 0, sizeof(hash));
- TAILQ_FOREACH(inm, &sc->sc_arpcom.ac_if.if_multiaddrs, ifma_link) {
+ TAILQ_FOREACH(inm, &ifp->if_multiaddrs, ifma_link) {
if (inm->ifma_addr->sa_family != AF_LINK)
continue;
crc = ether_crc32_le(LLADDR((struct sockaddr_dl *)
diff --git a/sys/dev/gem/if_gem_pci.c b/sys/dev/gem/if_gem_pci.c
index 57c95c7..5347ee9 100644
--- a/sys/dev/gem/if_gem_pci.c
+++ b/sys/dev/gem/if_gem_pci.c
@@ -195,7 +195,7 @@ gem_pci_attach(dev)
sc->sc_h = rman_get_bushandle(gsc->gsc_sres);
/* All platform that this driver is used on must provide this. */
- OF_getetheraddr(dev, sc->sc_arpcom.ac_enaddr);
+ OF_getetheraddr(dev, sc->sc_enaddr);
/*
* call the main configure
diff --git a/sys/dev/gem/if_gemvar.h b/sys/dev/gem/if_gemvar.h
index 07d71e1..ed3eb7a 100644
--- a/sys/dev/gem/if_gemvar.h
+++ b/sys/dev/gem/if_gemvar.h
@@ -123,10 +123,11 @@ struct gem_rxsoft {
* Software state per device.
*/
struct gem_softc {
- struct arpcom sc_arpcom; /* arp common data */
+ struct ifnet *sc_ifp;
device_t sc_miibus;
struct mii_data *sc_mii; /* MII media control */
device_t sc_dev; /* generic device information */
+ u_char sc_enaddr[6];
struct callout sc_tick_ch; /* tick callout */
struct callout sc_rx_ch; /* delayed rx callout */
OpenPOWER on IntegriCloud