summaryrefslogtreecommitdiffstats
path: root/sys/dev/ex
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/ex
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/ex')
-rw-r--r--sys/dev/ex/if_ex.c29
-rw-r--r--sys/dev/ex/if_ex_isa.c2
-rw-r--r--sys/dev/ex/if_ex_pccard.c2
-rw-r--r--sys/dev/ex/if_exvar.h3
4 files changed, 22 insertions, 14 deletions
diff --git a/sys/dev/ex/if_ex.c b/sys/dev/ex/if_ex.c
index 33598ba..300e433 100644
--- a/sys/dev/ex/if_ex.c
+++ b/sys/dev/ex/if_ex.c
@@ -59,6 +59,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/ethernet.h>
#include <net/bpf.h>
@@ -202,12 +203,17 @@ int
ex_attach(device_t dev)
{
struct ex_softc * sc = device_get_softc(dev);
- struct ifnet * ifp = &sc->arpcom.ac_if;
+ struct ifnet * ifp;
struct ifmedia * ifm;
uint16_t temp;
+ ifp = sc->ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ device_printf(dev, "can not if_alloc()\n");
+ return (ENOSPC);
+ }
/* work out which set of irq <-> internal tables to use */
- if (ex_card_type(sc->arpcom.ac_enaddr) == CARD_TYPE_EX_10_PLUS) {
+ if (ex_card_type(sc->enaddr) == CARD_TYPE_EX_10_PLUS) {
sc->irq2ee = plus_irq2eemap;
sc->ee2irq = plus_ee2irqmap;
} else {
@@ -252,7 +258,7 @@ ex_attach(device_t dev)
/*
* Attach the interface.
*/
- ether_ifattach(ifp, sc->arpcom.ac_enaddr);
+ ether_ifattach(ifp, sc->enaddr);
return(0);
}
@@ -264,12 +270,13 @@ ex_detach(device_t dev)
struct ifnet *ifp;
sc = device_get_softc(dev);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ifp;
ex_stop(sc);
ifp->if_flags &= ~IFF_RUNNING;
ether_ifdetach(ifp);
+ if_free(ifp);
ex_release_resources(dev);
@@ -280,7 +287,7 @@ static void
ex_init(void *xsc)
{
struct ex_softc * sc = (struct ex_softc *) xsc;
- struct ifnet * ifp = &sc->arpcom.ac_if;
+ struct ifnet * ifp = sc->ifp;
int s;
int i;
unsigned short temp_reg;
@@ -299,7 +306,7 @@ ex_init(void *xsc)
CSR_WRITE_1(sc, EEPROM_REG, temp_reg & ~Trnoff_Enable);
}
for (i = 0; i < ETHER_ADDR_LEN; i++) {
- CSR_WRITE_1(sc, I_ADDR_REG0 + i, sc->arpcom.ac_enaddr[i]);
+ CSR_WRITE_1(sc, I_ADDR_REG0 + i, IFP2ENADDR(sc->ifp)[i]);
}
/*
* - Setup transmit chaining and discard bad received frames.
@@ -574,7 +581,7 @@ void
ex_intr(void *arg)
{
struct ex_softc *sc = (struct ex_softc *)arg;
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->ifp;
int int_status, send_pkts;
int loops = 100;
@@ -613,7 +620,7 @@ ex_intr(void *arg)
static void
ex_tx_intr(struct ex_softc *sc)
{
- struct ifnet * ifp = &sc->arpcom.ac_if;
+ struct ifnet * ifp = sc->ifp;
int tx_status;
DODEBUG(Start_End, printf("ex_tx_intr%d: start\n", unit););
@@ -660,7 +667,7 @@ ex_tx_intr(struct ex_softc *sc)
static void
ex_rx_intr(struct ex_softc *sc)
{
- struct ifnet * ifp = &sc->arpcom.ac_if;
+ struct ifnet * ifp = sc->ifp;
int rx_status;
int pkt_len;
int QQQ;
@@ -830,7 +837,7 @@ ex_setmulti(struct ex_softc *sc)
int count;
int timeout, status;
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->ifp;
count = 0;
TAILQ_FOREACH(maddr, &ifp->if_multiaddrs, ifma_link) {
@@ -879,7 +886,7 @@ ex_setmulti(struct ex_softc *sc)
/* Program our MAC address as well */
/* XXX: Is this necessary? The Linux driver does this
* but the NetBSD driver does not */
- addr = (uint16_t*)(&sc->arpcom.ac_enaddr);
+ addr = (uint16_t*)(&IFP2ENADDR(sc->ifp));
CSR_WRITE_2(sc, IO_PORT_REG, *addr++);
CSR_WRITE_2(sc, IO_PORT_REG, *addr++);
CSR_WRITE_2(sc, IO_PORT_REG, *addr++);
diff --git a/sys/dev/ex/if_ex_isa.c b/sys/dev/ex/if_ex_isa.c
index 310f554..214a53e 100644
--- a/sys/dev/ex/if_ex_isa.c
+++ b/sys/dev/ex/if_ex_isa.c
@@ -296,7 +296,7 @@ ex_isa_attach(device_t dev)
*/
sc->irq_no = rman_get_start(sc->irq);
- ex_get_address(sc, sc->arpcom.ac_enaddr);
+ ex_get_address(sc, sc->enaddr);
temp = ex_eeprom_read(sc, EE_W0);
device_printf(sc->dev, "%s config, %s bus, ",
diff --git a/sys/dev/ex/if_ex_pccard.c b/sys/dev/ex/if_ex_pccard.c
index 16b9d20..8671e87 100644
--- a/sys/dev/ex/if_ex_pccard.c
+++ b/sys/dev/ex/if_ex_pccard.c
@@ -231,7 +231,7 @@ ex_pccard_attach(device_t dev)
error = ENXIO;
goto bad;
}
- bcopy(ether_addr, sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
+ bcopy(ether_addr, sc->enaddr, ETHER_ADDR_LEN);
if ((error = ex_attach(dev)) != 0) {
device_printf(dev, "ex_attach() failed!\n");
diff --git a/sys/dev/ex/if_exvar.h b/sys/dev/ex/if_exvar.h
index 6427f1f..5e2f001 100644
--- a/sys/dev/ex/if_exvar.h
+++ b/sys/dev/ex/if_exvar.h
@@ -30,8 +30,9 @@
*/
struct ex_softc {
- struct arpcom arpcom; /* Ethernet common data */
+ struct ifnet *ifp;
struct ifmedia ifmedia;
+ u_char enaddr[6];
device_t dev;
struct resource *ioport;
OpenPOWER on IntegriCloud