summaryrefslogtreecommitdiffstats
path: root/sys/dev/nve
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/nve
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/nve')
-rw-r--r--sys/dev/nve/if_nve.c40
-rw-r--r--sys/dev/nve/if_nvereg.h5
2 files changed, 24 insertions, 21 deletions
diff --git a/sys/dev/nve/if_nve.c b/sys/dev/nve/if_nve.c
index 0963a6b..131502d 100644
--- a/sys/dev/nve/if_nve.c
+++ b/sys/dev/nve/if_nve.c
@@ -92,6 +92,7 @@ __FBSDID("$FreeBSD$");
#include <net/ethernet.h>
#include <net/if_dl.h>
#include <net/if_media.h>
+#include <net/if_types.h>
#include <net/bpf.h>
#include <net/if_vlan_var.h>
@@ -487,10 +488,9 @@ nve_attach(device_t dev)
eaddr[i] = sc->original_mac_addr[5 - i];
}
sc->hwapi->pfnSetNodeAddress(sc->hwapi->pADCX, eaddr);
- bcopy(eaddr, (char *)&sc->sc_macaddr, ETHER_ADDR_LEN);
/* Display ethernet address ,... */
- device_printf(dev, "Ethernet address %6D\n", sc->sc_macaddr, ":");
+ device_printf(dev, "Ethernet address %6D\n", eaddr, ":");
DEBUGOUT(NVE_DEBUG_INIT, "nve: do mii_phy_probe\n");
@@ -501,7 +501,12 @@ nve_attach(device_t dev)
goto fail;
}
/* Setup interface parameters */
- ifp = &sc->sc_if;
+ ifp = sc->ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ device_printf(dev, "can not if_alloc()\n");
+ error = ENOSPC;
+ goto fail;
+ }
ifp->if_softc = sc;
if_initname(ifp, "nve", unit);
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
@@ -517,7 +522,7 @@ nve_attach(device_t dev)
ifp->if_capabilities |= IFCAP_VLAN_MTU;
/* Attach to OS's managers. */
- ether_ifattach(ifp, sc->sc_macaddr);
+ ether_ifattach(ifp, eaddr);
callout_handle_init(&sc->stat_ch);
/* Activate our interrupt handler. - attach last to avoid lock */
@@ -548,11 +553,12 @@ nve_detach(device_t dev)
DEBUGOUT(NVE_DEBUG_DEINIT, "nve: nve_detach - entry\n");
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ifp;
if (device_is_attached(dev)) {
nve_stop(sc);
ether_ifdetach(ifp);
+ if_free(ifp);
}
if (sc->miibus)
@@ -610,7 +616,7 @@ nve_init(void *xsc)
NVE_LOCK(sc);
DEBUGOUT(NVE_DEBUG_INIT, "nve: nve_init - entry (%d)\n", sc->linkup);
- ifp = &sc->sc_if;
+ ifp = sc->ifp;
/* Do nothing if already running */
if (ifp->if_flags & IFF_RUNNING)
@@ -633,7 +639,7 @@ nve_init(void *xsc)
goto fail;
}
/* Set the MAC address */
- sc->hwapi->pfnSetNodeAddress(sc->hwapi->pADCX, sc->sc_macaddr);
+ sc->hwapi->pfnSetNodeAddress(sc->hwapi->pADCX, IFP2ENADDR(sc->ifp));
sc->hwapi->pfnEnableInterrupts(sc->hwapi->pADCX);
sc->hwapi->pfnStart(sc->hwapi->pADCX);
@@ -665,7 +671,7 @@ nve_stop(struct nve_softc *sc)
DEBUGOUT(NVE_DEBUG_RUNNING, "nve: nve_stop - entry\n");
- ifp = &sc->sc_if;
+ ifp = sc->ifp;
ifp->if_timer = 0;
/* Cancel tick timer */
@@ -1010,7 +1016,7 @@ static void
nve_intr(void *arg)
{
struct nve_softc *sc = arg;
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = sc->ifp;
DEBUGOUT(NVE_DEBUG_INTERRUPT, "nve: nve_intr - entry\n");
@@ -1028,7 +1034,7 @@ nve_intr(void *arg)
/* If no pending packets we don't need a timeout */
if (sc->pending_txs == 0)
- sc->sc_if.if_timer = 0;
+ sc->ifp->if_timer = 0;
DEBUGOUT(NVE_DEBUG_INTERRUPT, "nve: nve_intr - exit\n");
@@ -1049,7 +1055,7 @@ nve_setmulti(struct nve_softc *sc)
DEBUGOUT(NVE_DEBUG_RUNNING, "nve: nve_setmulti - entry\n");
- ifp = &sc->sc_if;
+ ifp = sc->ifp;
/* Initialize filter */
hwfilter.ulFilterFlags = 0;
@@ -1146,7 +1152,7 @@ nve_tick(void *xsc)
NVE_LOCK(sc);
- ifp = &sc->sc_if;
+ ifp = sc->ifp;
nve_update_stats(sc);
mii = device_get_softc(sc->miibus);
@@ -1168,7 +1174,7 @@ nve_tick(void *xsc)
static void
nve_update_stats(struct nve_softc *sc)
{
- struct ifnet *ifp = &sc->sc_if;
+ struct ifnet *ifp = sc->ifp;
ADAPTER_STATS stats;
NVE_LOCK(sc);
@@ -1466,7 +1472,7 @@ nve_ospackettx(PNV_VOID ctx, PNV_VOID id, NV_UINT32 success)
DEBUGOUT(NVE_DEBUG_API, "nve: nve_ospackettx\n");
- ifp = &sc->sc_if;
+ ifp = sc->ifp;
buf = &desc->buf;
sc->pending_txs--;
@@ -1481,7 +1487,7 @@ nve_ospackettx(PNV_VOID ctx, PNV_VOID id, NV_UINT32 success)
/* Send more packets if we have them */
if (sc->pending_txs < TX_RING_SIZE)
- sc->sc_if.if_flags &= ~IFF_OACTIVE;
+ sc->ifp->if_flags &= ~IFF_OACTIVE;
if (ifp->if_snd.ifq_head != NULL && sc->pending_txs < TX_RING_SIZE)
nve_ifstart(ifp);
@@ -1508,7 +1514,7 @@ nve_ospacketrx(PNV_VOID ctx, PNV_VOID data, NV_UINT32 success, NV_UINT8 *newbuf,
DEBUGOUT(NVE_DEBUG_API, "nve: nve_ospacketrx\n");
- ifp = &sc->sc_if;
+ ifp = sc->ifp;
readdata = (ADAPTER_READ_DATA *) data;
desc = readdata->pvID;
@@ -1557,7 +1563,7 @@ nve_oslinkchg(PNV_VOID ctx, NV_SINT32 enabled)
DEBUGOUT(NVE_DEBUG_API, "nve: nve_oslinkchg\n");
- ifp = &sc->sc_if;
+ ifp = sc->ifp;
if (enabled)
ifp->if_flags |= IFF_UP;
diff --git a/sys/dev/nve/if_nvereg.h b/sys/dev/nve/if_nvereg.h
index 320e298..ae6303e 100644
--- a/sys/dev/nve/if_nvereg.h
+++ b/sys/dev/nve/if_nvereg.h
@@ -108,7 +108,7 @@ struct nve_tx_desc {
};
struct nve_softc {
- struct arpcom arpcom; /* interface info */
+ struct ifnet *ifp; /* interface info */
struct resource *res;
struct resource *irq;
@@ -165,9 +165,6 @@ struct nve_type {
char *name;
};
-#define sc_if arpcom.ac_if
-#define sc_macaddr arpcom.ac_enaddr
-
#define NVE_LOCK(_sc) mtx_lock(&(_sc)->mtx)
#define NVE_UNLOCK(_sc) mtx_unlock(&(_sc)->mtx)
#define NVE_OSLOCK(_sc) mtx_lock_spin(&(_sc)->osmtx)
OpenPOWER on IntegriCloud