summaryrefslogtreecommitdiffstats
path: root/sys/dev/usb/if_axe.c
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/usb/if_axe.c
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/usb/if_axe.c')
-rw-r--r--sys/dev/usb/if_axe.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/sys/dev/usb/if_axe.c b/sys/dev/usb/if_axe.c
index f4bb89f..9551649 100644
--- a/sys/dev/usb/if_axe.c
+++ b/sys/dev/usb/if_axe.c
@@ -81,6 +81,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>
@@ -324,7 +325,7 @@ axe_setmulti(struct axe_softc *sc)
u_int16_t rxmode;
u_int8_t hashtbl[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->axe_ifp;
AXE_LOCK(sc);
axe_cmd(sc, AXE_CMD_RXCTL_READ, 0, 0, (void *)&rxmode);
@@ -479,9 +480,11 @@ USB_ATTACH(axe)
*/
sc->axe_phyaddrs[0] = sc->axe_phyaddrs[1] = 0xFF;
- bcopy(eaddr, (char *)&sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
-
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->axe_ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ printf("axe%d: can not if_alloc()\n", sc->axe_unit);
+ USB_ATTACH_ERROR_RETURN;
+ }
ifp->if_softc = sc;
if_initname(ifp, "axe", sc->axe_unit);
ifp->if_mtu = ETHERMTU;
@@ -534,7 +537,7 @@ axe_detach(device_ptr_t dev)
sc = device_get_softc(dev);
AXE_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->axe_ifp;
sc->axe_dying = 1;
untimeout(axe_tick, sc, sc->axe_stat_ch);
@@ -542,6 +545,7 @@ axe_detach(device_ptr_t dev)
ether_ifdetach(ifp);
#else
ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
+ if_free(ifp);
#endif
if (sc->axe_ep[AXE_ENDPT_TX] != NULL)
@@ -604,7 +608,7 @@ axe_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
c = priv;
sc = c->ue_sc;
AXE_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->axe_ifp;
if (!(ifp->if_flags & IFF_RUNNING)) {
AXE_UNLOCK(sc);
@@ -634,7 +638,7 @@ axe_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
}
ifp->if_ipackets++;
- m->m_pkthdr.rcvif = (struct ifnet *)&sc->axe_qdat;
+ m->m_pkthdr.rcvif = (void *)&sc->axe_qdat;
m->m_pkthdr.len = m->m_len = total_len;
/* Put the packet on the special USB input queue. */
@@ -669,7 +673,7 @@ axe_txeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
c = priv;
sc = c->ue_sc;
AXE_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->axe_ifp;
if (status != USBD_NORMAL_COMPLETION) {
if (status == USBD_NOT_STARTED || status == USBD_CANCELLED) {
@@ -718,7 +722,7 @@ axe_tick(void *xsc)
AXE_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->axe_ifp;
mii = GET_MII(sc);
if (mii == NULL) {
AXE_UNLOCK(sc);
@@ -824,7 +828,7 @@ Static void
axe_init(void *xsc)
{
struct axe_softc *sc = xsc;
- struct ifnet *ifp = &sc->arpcom.ac_if;
+ struct ifnet *ifp = sc->axe_ifp;
struct ue_chain *c;
usbd_status err;
int i;
@@ -843,7 +847,7 @@ axe_init(void *xsc)
#ifdef notdef
/* Set MAC address */
- axe_mac(sc, sc->arpcom.ac_enaddr, 1);
+ axe_mac(sc, IFP2ENADDR(sc->axe_ifp), 1);
#endif
/* Enable RX logic. */
@@ -1023,7 +1027,7 @@ axe_stop(struct axe_softc *sc)
AXE_LOCK(sc);
- ifp = &sc->arpcom.ac_if;
+ ifp = sc->axe_ifp;
ifp->if_timer = 0;
untimeout(axe_tick, sc, sc->axe_stat_ch);
OpenPOWER on IntegriCloud