summaryrefslogtreecommitdiffstats
path: root/sys/dev/hme
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/hme
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/hme')
-rw-r--r--sys/dev/hme/if_hme.c39
-rw-r--r--sys/dev/hme/if_hme_pci.c4
-rw-r--r--sys/dev/hme/if_hme_sbus.c2
-rw-r--r--sys/dev/hme/if_hmevar.h3
4 files changed, 28 insertions, 20 deletions
diff --git a/sys/dev/hme/if_hme.c b/sys/dev/hme/if_hme.c
index c5c66d5..d564bb4 100644
--- a/sys/dev/hme/if_hme.c
+++ b/sys/dev/hme/if_hme.c
@@ -82,6 +82,7 @@ __FBSDID("$FreeBSD$");
#include <net/if_arp.h>
#include <net/if_dl.h>
#include <net/if_media.h>
+#include <net/if_types.h>
#include <net/if_vlan_var.h>
#include <netinet/in.h>
@@ -105,7 +106,7 @@ static int hme_ioctl(struct ifnet *, u_long, caddr_t);
static void hme_tick(void *);
static void hme_watchdog(struct ifnet *);
static void hme_init(void *);
-static void hme_init_locked(void *);
+static void hme_init_locked(struct hme_softc *);
static int hme_add_rxbuf(struct hme_softc *, unsigned int, int);
static int hme_meminit(struct hme_softc *);
static int hme_mac_bitflip(struct hme_softc *, u_int32_t, u_int32_t,
@@ -170,11 +171,15 @@ MODULE_DEPEND(hme, miibus, 1, 1, 1);
int
hme_config(struct hme_softc *sc)
{
- struct ifnet *ifp = &sc->sc_arpcom.ac_if;
+ struct ifnet *ifp;
struct mii_softc *child;
bus_size_t size;
int error, rdesc, tdesc, i;
+ ifp = sc->sc_ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL)
+ return (ENOSPC);
+
/*
* HME common initialization.
*
@@ -214,7 +219,7 @@ hme_config(struct hme_softc *sc)
BUS_SPACE_MAXADDR, NULL, NULL, size, HME_NTXDESC + HME_NRXDESC + 1,
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, 2048, 0,
BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, size,
@@ -333,7 +338,7 @@ hme_config(struct hme_softc *sc)
}
/* Attach the interface. */
- ether_ifattach(ifp, sc->sc_arpcom.ac_enaddr);
+ ether_ifattach(ifp, sc->sc_enaddr);
/*
* Tell the upper layer(s) we support long frames/checksum offloads.
@@ -368,18 +373,21 @@ fail_ctag:
bus_dma_tag_destroy(sc->sc_cdmatag);
fail_ptag:
bus_dma_tag_destroy(sc->sc_pdmatag);
+fail_ifnet:
+ if_free(ifp);
return (error);
}
void
hme_detach(struct hme_softc *sc)
{
- struct ifnet *ifp = &sc->sc_arpcom.ac_if;
+ struct ifnet *ifp = sc->sc_ifp;
int i;
HME_LOCK_ASSERT(sc, MA_NOTOWNED);
ether_ifdetach(ifp);
+ if_free(ifp);
HME_LOCK(sc);
hme_stop(sc);
HME_UNLOCK(sc);
@@ -416,11 +424,11 @@ hme_suspend(struct hme_softc *sc)
void
hme_resume(struct hme_softc *sc)
{
- struct ifnet *ifp = &sc->sc_arpcom.ac_if;
+ struct ifnet *ifp = sc->sc_ifp;
HME_LOCK(sc);
if ((ifp->if_flags & IFF_UP) != 0)
- hme_init_locked(ifp);
+ hme_init_locked(sc);
HME_UNLOCK(sc);
}
@@ -682,10 +690,9 @@ hme_init(void *xsc)
}
static void
-hme_init_locked(void *xsc)
+hme_init_locked(struct hme_softc *sc)
{
- struct hme_softc *sc = (struct hme_softc *)xsc;
- struct ifnet *ifp = &sc->sc_arpcom.ac_if;
+ struct ifnet *ifp = sc->sc_ifp;
u_int8_t *ea;
u_int32_t n, v;
@@ -722,7 +729,7 @@ hme_init_locked(void *xsc)
HME_MAC_WRITE_4(sc, HME_MACI_TXSIZE, HME_MAX_FRAMESIZE);
/* Load station MAC address */
- ea = sc->sc_arpcom.ac_enaddr;
+ ea = IFP2ENADDR(sc->sc_ifp);
HME_MAC_WRITE_4(sc, HME_MACI_MACADDR0, (ea[0] << 8) | ea[1]);
HME_MAC_WRITE_4(sc, HME_MACI_MACADDR1, (ea[2] << 8) | ea[3]);
HME_MAC_WRITE_4(sc, HME_MACI_MACADDR2, (ea[4] << 8) | ea[5]);
@@ -1041,7 +1048,7 @@ fail:
static void
hme_read(struct hme_softc *sc, int ix, int len, u_int32_t flags)
{
- struct ifnet *ifp = &sc->sc_arpcom.ac_if;
+ struct ifnet *ifp = sc->sc_ifp;
struct mbuf *m;
if (len <= sizeof(struct ether_header) ||
@@ -1139,7 +1146,7 @@ hme_start_locked(struct ifnet *ifp)
static void
hme_tint(struct hme_softc *sc)
{
- struct ifnet *ifp = &sc->sc_arpcom.ac_if;
+ struct ifnet *ifp = sc->sc_ifp;
struct hme_txdesc *htx;
unsigned int ri, txflags;
@@ -1282,7 +1289,7 @@ static void
hme_rint(struct hme_softc *sc)
{
caddr_t xdr = sc->sc_rb.rb_rxd;
- struct ifnet *ifp = &sc->sc_arpcom.ac_if;
+ struct ifnet *ifp = sc->sc_ifp;
unsigned int ri, len;
int progress = 0;
u_int32_t flags;
@@ -1619,7 +1626,7 @@ hme_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
static void
hme_setladrf(struct hme_softc *sc, int reenable)
{
- struct ifnet *ifp = &sc->sc_arpcom.ac_if;
+ struct ifnet *ifp = sc->sc_ifp;
struct ifmultiaddr *inm;
u_int32_t crc;
u_int32_t hash[4];
@@ -1672,7 +1679,7 @@ hme_setladrf(struct hme_softc *sc, int reenable)
* the word.
*/
- TAILQ_FOREACH(inm, &sc->sc_arpcom.ac_if.if_multiaddrs, ifma_link) {
+ TAILQ_FOREACH(inm, &sc->sc_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/hme/if_hme_pci.c b/sys/dev/hme/if_hme_pci.c
index a2833f2..8d77846 100644
--- a/sys/dev/hme/if_hme_pci.c
+++ b/sys/dev/hme/if_hme_pci.c
@@ -222,7 +222,7 @@ hme_pci_attach(device_t dev)
&sc->sc_mifh);
#if defined(__powerpc__) || defined(__sparc64__)
- OF_getetheraddr(dev, sc->sc_arpcom.ac_enaddr);
+ OF_getetheraddr(dev, sc->sc_enaddr);
#else
/*
* Dig out VPD (vital product data) and read NA (network address).
@@ -329,7 +329,7 @@ hme_pci_attach(device_t dev)
error = ENXIO;
goto fail_rres;
}
- bcopy(buf + 3 + sizeof(struct pci_vpd), sc->sc_arpcom.ac_enaddr,
+ bcopy(buf + 3 + sizeof(struct pci_vpd), sc->sc_enaddr,
ETHER_ADDR_LEN);
fail_rres:
diff --git a/sys/dev/hme/if_hme_sbus.c b/sys/dev/hme/if_hme_sbus.c
index ff3bfe7..300abc1 100644
--- a/sys/dev/hme/if_hme_sbus.c
+++ b/sys/dev/hme/if_hme_sbus.c
@@ -247,7 +247,7 @@ hme_sbus_attach(device_t dev)
goto fail_mif_res;
}
- OF_getetheraddr(dev, sc->sc_arpcom.ac_enaddr);
+ OF_getetheraddr(dev, sc->sc_enaddr);
burst = sbus_get_burstsz(dev);
/* Translate into plain numerical format */
diff --git a/sys/dev/hme/if_hmevar.h b/sys/dev/hme/if_hmevar.h
index fe752b1..25b0552 100644
--- a/sys/dev/hme/if_hmevar.h
+++ b/sys/dev/hme/if_hmevar.h
@@ -108,11 +108,12 @@ struct hme_ring {
};
struct hme_softc {
- struct arpcom sc_arpcom;
+ struct ifnet *sc_ifp;
struct ifmedia sc_ifmedia;
device_t sc_dev;
device_t sc_miibus;
struct mii_data *sc_mii; /* MII media control */
+ u_char sc_enaddr[6];
struct callout sc_tick_ch; /* tick callout */
/* The following bus handles are to be provided by the bus front-end */
OpenPOWER on IntegriCloud