From f329739cdc520e8487b07473b0d8e3fae04a3eb0 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Tue, 17 Jul 2018 20:05:35 -0400 Subject: [PATCH] marvell88w8363: Sync with FreeBSD 11.1. Untested, but the changes are mostly adapations to the new KPIs. --- .../kernel/drivers/network/wlan/Jamfile | 2 +- .../network/wlan/marvell88w8363/Jamfile | 18 +- .../wlan/marvell88w8363/dev/mwl/if_mwl.c | 855 +++++++----------- .../wlan/marvell88w8363/dev/mwl/if_mwl_pci.c | 10 +- .../wlan/marvell88w8363/dev/mwl/if_mwlioctl.h | 2 +- .../wlan/marvell88w8363/dev/mwl/if_mwlvar.h | 19 +- .../wlan/marvell88w8363/dev/mwl/mwldiag.h | 2 +- .../wlan/marvell88w8363/dev/mwl/mwlhal.c | 45 +- .../wlan/marvell88w8363/dev/mwl/mwlhal.h | 6 +- .../wlan/marvell88w8363/dev/mwl/mwlreg.h | 2 +- 10 files changed, 372 insertions(+), 589 deletions(-) diff --git a/src/add-ons/kernel/drivers/network/wlan/Jamfile b/src/add-ons/kernel/drivers/network/wlan/Jamfile index 7d722b67b6..2ef364d709 100644 --- a/src/add-ons/kernel/drivers/network/wlan/Jamfile +++ b/src/add-ons/kernel/drivers/network/wlan/Jamfile @@ -2,7 +2,6 @@ SubDir HAIKU_TOP src add-ons kernel drivers network wlan ; # FreeBSD 9.3 drivers SubInclude HAIKU_TOP src add-ons kernel drivers network wlan broadcom43xx ; -SubInclude HAIKU_TOP src add-ons kernel drivers network wlan marvell88w8363 ; SubInclude HAIKU_TOP src add-ons kernel drivers network wlan wavelanwifi ; # FreeBSD 11.1 drivers @@ -12,6 +11,7 @@ SubInclude HAIKU_TOP src add-ons kernel drivers network wlan iprowifi2100 ; SubInclude HAIKU_TOP src add-ons kernel drivers network wlan iprowifi3945 ; SubInclude HAIKU_TOP src add-ons kernel drivers network wlan iprowifi4965 ; SubInclude HAIKU_TOP src add-ons kernel drivers network wlan marvell88w8335 ; +SubInclude HAIKU_TOP src add-ons kernel drivers network wlan marvell88w8363 ; SubInclude HAIKU_TOP src add-ons kernel drivers network wlan ralinkwifi ; # FreeBSD 11.2 drivers diff --git a/src/add-ons/kernel/drivers/network/wlan/marvell88w8363/Jamfile b/src/add-ons/kernel/drivers/network/wlan/marvell88w8363/Jamfile index ec81c80de8..0bb9516526 100644 --- a/src/add-ons/kernel/drivers/network/wlan/marvell88w8363/Jamfile +++ b/src/add-ons/kernel/drivers/network/wlan/marvell88w8363/Jamfile @@ -1,17 +1,15 @@ SubDir HAIKU_TOP src add-ons kernel drivers network wlan marvell88w8363 ; -UseHeaders [ FDirName $(HAIKU_TOP) src libs compat freebsd_network compat ] +UseHeaders [ FDirName $(HAIKU_TOP) src libs compat freebsd11_network compat ] : true ; -UseHeaders [ FDirName $(HAIKU_TOP) src libs compat freebsd_wlan ] : true ; +UseHeaders [ FDirName $(HAIKU_TOP) src libs compat freebsd11_wlan ] : true ; UsePrivateHeaders net system ; UsePrivateKernelHeaders ; -## TODO once all driver are updated to their FreeBSD 8 version this define -## can be omitted -SubDirCcFlags [ FDefines _KERNEL=1 FBSD_DRIVER=1 __FreeBSD_version__=8 - _XOPEN_SOURCE ] - -Wno-format - -Wno-unused +SubDirCcFlags [ FDefines _KERNEL=1 FBSD_DRIVER=1 + _XOPEN_SOURCE ] + -Wno-format + -Wno-unused -Wno-uninitialized ; UseHeaders [ FDirName $(SUBDIR) ] : true ; @@ -24,8 +22,8 @@ KernelAddon marvell88w8363 : mwlhal.c glue.c : - libfreebsd_wlan.a - libfreebsd_network.a + libfreebsd11_wlan.a + libfreebsd11_network.a ; HAIKU_WIFI_FIRMWARE_PACKAGE on marvell88w8363 = "" ; diff --git a/src/add-ons/kernel/drivers/network/wlan/marvell88w8363/dev/mwl/if_mwl.c b/src/add-ons/kernel/drivers/network/wlan/marvell88w8363/dev/mwl/if_mwl.c index f6e9e3660f..24c38c5f8c 100644 --- a/src/add-ons/kernel/drivers/network/wlan/marvell88w8363/dev/mwl/if_mwl.c +++ b/src/add-ons/kernel/drivers/network/wlan/marvell88w8363/dev/mwl/if_mwl.c @@ -29,7 +29,7 @@ */ #include -__FBSDID("$FreeBSD$"); +__FBSDID("$FreeBSD: releng/11.1/sys/dev/mwl/if_mwl.c 300241 2016-05-19 22:28:46Z avos $"); /* * Driver for the Marvell 88W8363 Wireless LAN controller. @@ -39,9 +39,9 @@ __FBSDID("$FreeBSD$"); #include "opt_mwl.h" #include -#include +#include #include -#include +#include #include #include #include @@ -56,8 +56,9 @@ __FBSDID("$FreeBSD$"); #include #include - + #include +#include #include #include #include @@ -68,6 +69,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #ifdef INET @@ -89,17 +91,17 @@ static struct ieee80211vap *mwl_vap_create(struct ieee80211com *, static void mwl_vap_delete(struct ieee80211vap *); static int mwl_setupdma(struct mwl_softc *); static int mwl_hal_reset(struct mwl_softc *sc); -static int mwl_init_locked(struct mwl_softc *); -static void mwl_init(void *); -static void mwl_stop_locked(struct ifnet *, int); +static int mwl_init(struct mwl_softc *); +static void mwl_parent(struct ieee80211com *); static int mwl_reset(struct ieee80211vap *, u_long); -static void mwl_stop(struct ifnet *, int); -static void mwl_start(struct ifnet *); +static void mwl_stop(struct mwl_softc *); +static void mwl_start(struct mwl_softc *); +static int mwl_transmit(struct ieee80211com *, struct mbuf *); static int mwl_raw_xmit(struct ieee80211_node *, struct mbuf *, const struct ieee80211_bpf_params *); static int mwl_media_change(struct ifnet *); static void mwl_watchdog(void *); -static int mwl_ioctl(struct ifnet *, u_long, caddr_t); +static int mwl_ioctl(struct ieee80211com *, u_long, void *); static void mwl_radar_proc(void *, int); static void mwl_chanswitch_proc(void *, int); static void mwl_bawatchdog_proc(void *, int); @@ -108,12 +110,15 @@ static int mwl_key_alloc(struct ieee80211vap *, ieee80211_keyix *, ieee80211_keyix *); static int mwl_key_delete(struct ieee80211vap *, const struct ieee80211_key *); -static int mwl_key_set(struct ieee80211vap *, const struct ieee80211_key *, +static int mwl_key_set(struct ieee80211vap *, + const struct ieee80211_key *); +static int _mwl_key_set(struct ieee80211vap *, + const struct ieee80211_key *, const uint8_t mac[IEEE80211_ADDR_LEN]); static int mwl_mode_init(struct mwl_softc *); -static void mwl_update_mcast(struct ifnet *); -static void mwl_update_promisc(struct ifnet *); -static void mwl_updateslot(struct ifnet *); +static void mwl_update_mcast(struct ieee80211com *); +static void mwl_update_promisc(struct ieee80211com *); +static void mwl_updateslot(struct ieee80211com *); static int mwl_beacon_setup(struct ieee80211vap *); static void mwl_beacon_update(struct ieee80211vap *, int); #ifdef MWL_HOST_PS_SUPPORT @@ -186,31 +191,25 @@ static int mwl_rxdesc = MWL_RXDESC; /* # rx desc's to allocate */ SYSCTL_INT(_hw_mwl, OID_AUTO, rxdesc, CTLFLAG_RW, &mwl_rxdesc, 0, "rx descriptors allocated"); static int mwl_rxbuf = MWL_RXBUF; /* # rx buffers to allocate */ -SYSCTL_INT(_hw_mwl, OID_AUTO, rxbuf, CTLFLAG_RW, &mwl_rxbuf, +SYSCTL_INT(_hw_mwl, OID_AUTO, rxbuf, CTLFLAG_RWTUN, &mwl_rxbuf, 0, "rx buffers allocated"); -TUNABLE_INT("hw.mwl.rxbuf", &mwl_rxbuf); static int mwl_txbuf = MWL_TXBUF; /* # tx buffers to allocate */ -SYSCTL_INT(_hw_mwl, OID_AUTO, txbuf, CTLFLAG_RW, &mwl_txbuf, +SYSCTL_INT(_hw_mwl, OID_AUTO, txbuf, CTLFLAG_RWTUN, &mwl_txbuf, 0, "tx buffers allocated"); -TUNABLE_INT("hw.mwl.txbuf", &mwl_txbuf); static int mwl_txcoalesce = 8; /* # tx packets to q before poking f/w*/ -SYSCTL_INT(_hw_mwl, OID_AUTO, txcoalesce, CTLFLAG_RW, &mwl_txcoalesce, +SYSCTL_INT(_hw_mwl, OID_AUTO, txcoalesce, CTLFLAG_RWTUN, &mwl_txcoalesce, 0, "tx buffers to send at once"); -TUNABLE_INT("hw.mwl.txcoalesce", &mwl_txcoalesce); static int mwl_rxquota = MWL_RXBUF; /* # max buffers to process */ -SYSCTL_INT(_hw_mwl, OID_AUTO, rxquota, CTLFLAG_RW, &mwl_rxquota, +SYSCTL_INT(_hw_mwl, OID_AUTO, rxquota, CTLFLAG_RWTUN, &mwl_rxquota, 0, "max rx buffers to process per interrupt"); -TUNABLE_INT("hw.mwl.rxquota", &mwl_rxquota); static int mwl_rxdmalow = 3; /* # min buffers for wakeup */ -SYSCTL_INT(_hw_mwl, OID_AUTO, rxdmalow, CTLFLAG_RW, &mwl_rxdmalow, +SYSCTL_INT(_hw_mwl, OID_AUTO, rxdmalow, CTLFLAG_RWTUN, &mwl_rxdmalow, 0, "min free rx buffers before restarting traffic"); -TUNABLE_INT("hw.mwl.rxdmalow", &mwl_rxdmalow); #ifdef MWL_DEBUG static int mwl_debug = 0; -SYSCTL_INT(_hw_mwl, OID_AUTO, debug, CTLFLAG_RW, &mwl_debug, +SYSCTL_INT(_hw_mwl, OID_AUTO, debug, CTLFLAG_RWTUN, &mwl_debug, 0, "control debugging printfs"); -TUNABLE_INT("hw.mwl.debug", &mwl_debug); enum { MWL_DEBUG_XMIT = 0x00000001, /* basic xmit operation */ MWL_DEBUG_XMIT_DESC = 0x00000002, /* xmit descriptors */ @@ -233,12 +232,11 @@ enum { ((wh->i_fc[0] & (IEEE80211_FC0_TYPE_MASK|IEEE80211_FC0_SUBTYPE_MASK)) == \ (IEEE80211_FC0_TYPE_MGT|IEEE80211_FC0_SUBTYPE_BEACON)) #define IFF_DUMPPKTS_RECV(sc, wh) \ - (((sc->sc_debug & MWL_DEBUG_RECV) && \ - ((sc->sc_debug & MWL_DEBUG_RECV_ALL) || !IS_BEACON(wh))) || \ - (sc->sc_ifp->if_flags & (IFF_DEBUG|IFF_LINK2)) == (IFF_DEBUG|IFF_LINK2)) + ((sc->sc_debug & MWL_DEBUG_RECV) && \ + ((sc->sc_debug & MWL_DEBUG_RECV_ALL) || !IS_BEACON(wh))) #define IFF_DUMPPKTS_XMIT(sc) \ - ((sc->sc_debug & MWL_DEBUG_XMIT) || \ - (sc->sc_ifp->if_flags & (IFF_DEBUG|IFF_LINK2)) == (IFF_DEBUG|IFF_LINK2)) + (sc->sc_debug & MWL_DEBUG_XMIT) + #define DPRINTF(sc, m, fmt, ...) do { \ if (sc->sc_debug & (m)) \ printf(fmt, __VA_ARGS__); \ @@ -250,16 +248,10 @@ enum { static void mwl_printrxbuf(const struct mwl_rxbuf *bf, u_int ix); static void mwl_printtxbuf(const struct mwl_txbuf *bf, u_int qnum, u_int ix); #else -#define IFF_DUMPPKTS_RECV(sc, wh) \ - ((sc->sc_ifp->if_flags & (IFF_DEBUG|IFF_LINK2)) == (IFF_DEBUG|IFF_LINK2)) -#define IFF_DUMPPKTS_XMIT(sc) \ - ((sc->sc_ifp->if_flags & (IFF_DEBUG|IFF_LINK2)) == (IFF_DEBUG|IFF_LINK2)) -#define DPRINTF(sc, m, fmt, ...) do { \ - (void) sc; \ -} while (0) -#define KEYPRINTF(sc, k, mac) do { \ - (void) sc; \ -} while (0) +#define IFF_DUMPPKTS_RECV(sc, wh) 0 +#define IFF_DUMPPKTS_XMIT(sc) 0 +#define DPRINTF(sc, m, fmt, ...) do { (void )sc; } while (0) +#define KEYPRINTF(sc, k, mac) do { (void )sc; } while (0) #endif static MALLOC_DEFINE(M_MWLDEV, "mwldev", "mwl driver dma buffers"); @@ -297,28 +289,22 @@ WR4(struct mwl_softc *sc, bus_size_t off, uint32_t val) int mwl_attach(uint16_t devid, struct mwl_softc *sc) { - struct ifnet *ifp; - struct ieee80211com *ic; + struct ieee80211com *ic = &sc->sc_ic; struct mwl_hal *mh; int error = 0; DPRINTF(sc, MWL_DEBUG_ANY, "%s: devid 0x%x\n", __func__, devid); - ifp = sc->sc_ifp = if_alloc(IFT_IEEE80211); - if (ifp == NULL) { - device_printf(sc->sc_dev, "cannot if_alloc()\n"); - return ENOSPC; - } - ic = ifp->if_l2com; - - /* set these up early for if_printf use */ - if_initname(ifp, device_get_name(sc->sc_dev), - device_get_unit(sc->sc_dev)); + /* + * Setup the RX free list lock early, so it can be consistently + * removed. + */ + MWL_RXFREE_INIT(sc); mh = mwl_hal_attach(sc->sc_dev, devid, sc->sc_io1h, sc->sc_io1t, sc->sc_dmat); if (mh == NULL) { - if_printf(ifp, "unable to attach HAL\n"); + device_printf(sc->sc_dev, "unable to attach HAL\n"); error = EIO; goto bad; } @@ -329,12 +315,12 @@ mwl_attach(uint16_t devid, struct mwl_softc *sc) * needed so setting up the wrong mode isn't a big deal. */ if (mwl_hal_fwload(mh, NULL) != 0) { - if_printf(ifp, "unable to setup builtin firmware\n"); + device_printf(sc->sc_dev, "unable to setup builtin firmware\n"); error = EIO; goto bad1; } if (mwl_hal_gethwspecs(mh, &sc->sc_hwspecs) != 0) { - if_printf(ifp, "unable to fetch h/w specs\n"); + device_printf(sc->sc_dev, "unable to fetch h/w specs\n"); error = EIO; goto bad1; } @@ -354,20 +340,22 @@ mwl_attach(uint16_t devid, struct mwl_softc *sc) */ error = mwl_dma_setup(sc); if (error != 0) { - if_printf(ifp, "failed to setup descriptors: %d\n", error); + device_printf(sc->sc_dev, "failed to setup descriptors: %d\n", + error); goto bad1; } error = mwl_setupdma(sc); /* push to firmware */ if (error != 0) /* NB: mwl_setupdma prints msg */ goto bad1; - callout_init(&sc->sc_timer, CALLOUT_MPSAFE); + callout_init(&sc->sc_timer, 1); callout_init_mtx(&sc->sc_watchdog, &sc->sc_mtx, 0); + mbufq_init(&sc->sc_snd, ifqmaxlen); sc->sc_tq = taskqueue_create("mwl_taskq", M_NOWAIT, taskqueue_thread_enqueue, &sc->sc_tq); taskqueue_start_threads(&sc->sc_tq, 1, PI_NET, - "%s taskq", ifp->if_xname); + "%s taskq", device_get_nameunit(sc->sc_dev)); TASK_INIT(&sc->sc_rxtask, 0, mwl_rx_proc, sc); TASK_INIT(&sc->sc_radartask, 0, mwl_radar_proc, sc); @@ -376,8 +364,9 @@ mwl_attach(uint16_t devid, struct mwl_softc *sc) /* NB: insure BK queue is the lowest priority h/w queue */ if (!mwl_tx_setup(sc, WME_AC_BK, MWL_WME_AC_BK)) { - if_printf(ifp, "unable to setup xmit queue for %s traffic!\n", - ieee80211_wme_acnames[WME_AC_BK]); + device_printf(sc->sc_dev, + "unable to setup xmit queue for %s traffic!\n", + ieee80211_wme_acnames[WME_AC_BK]); error = EIO; goto bad2; } @@ -401,16 +390,8 @@ mwl_attach(uint16_t devid, struct mwl_softc *sc) } TASK_INIT(&sc->sc_txtask, 0, mwl_tx_proc, sc); - ifp->if_softc = sc; - ifp->if_flags = IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST; - ifp->if_start = mwl_start; - ifp->if_ioctl = mwl_ioctl; - ifp->if_init = mwl_init; - IFQ_SET_MAXLEN(&ifp->if_snd, ifqmaxlen); - ifp->if_snd.ifq_drv_maxlen = ifqmaxlen; - IFQ_SET_READY(&ifp->if_snd); - - ic->ic_ifp = ifp; + ic->ic_softc = sc; + ic->ic_name = device_get_nameunit(sc->sc_dev); /* XXX not right but it's not used anywhere important */ ic->ic_phytype = IEEE80211_T_OFDM; ic->ic_opmode = IEEE80211_M_STA; @@ -471,13 +452,15 @@ mwl_attach(uint16_t devid, struct mwl_softc *sc) * format transmit record and optional padding between * this record and the payload. Ask the net80211 layer * to arrange this when encapsulating packets so we can - * add it efficiently. + * add it efficiently. */ ic->ic_headroom = sizeof(struct mwltxrec) - sizeof(struct ieee80211_frame); + IEEE80211_ADDR_COPY(ic->ic_macaddr, sc->sc_hwspecs.macAddr); + /* call MI attach routine. */ - ieee80211_ifattach(ic, sc->sc_hwspecs.macAddr); + ieee80211_ifattach(ic); ic->ic_setregdomain = mwl_setregdomain; ic->ic_getradiocaps = mwl_getradiocaps; /* override default methods */ @@ -487,6 +470,9 @@ mwl_attach(uint16_t devid, struct mwl_softc *sc) ic->ic_update_mcast = mwl_update_mcast; ic->ic_update_promisc = mwl_update_promisc; ic->ic_wme.wme_update = mwl_wme_update; + ic->ic_transmit = mwl_transmit; + ic->ic_ioctl = mwl_ioctl; + ic->ic_parent = mwl_parent; ic->ic_node_alloc = mwl_node_alloc; sc->sc_node_cleanup = ic->ic_node_cleanup; @@ -532,7 +518,7 @@ bad2: bad1: mwl_hal_detach(mh); bad: - if_free(ifp); + MWL_RXFREE_DESTROY(sc); sc->sc_invalid = 1; return error; } @@ -540,13 +526,11 @@ bad: int mwl_detach(struct mwl_softc *sc) { - struct ifnet *ifp = sc->sc_ifp; - struct ieee80211com *ic = ifp->if_l2com; + struct ieee80211com *ic = &sc->sc_ic; - DPRINTF(sc, MWL_DEBUG_ANY, "%s: if_flags %x\n", - __func__, ifp->if_flags); - - mwl_stop(ifp, 1); + MWL_LOCK(sc); + mwl_stop(sc); + MWL_UNLOCK(sc); /* * NB: the order of these is important: * o call the 802.11 layer before detaching the hal to @@ -562,9 +546,10 @@ mwl_detach(struct mwl_softc *sc) ieee80211_ifdetach(ic); callout_drain(&sc->sc_watchdog); mwl_dma_cleanup(sc); + MWL_RXFREE_DESTROY(sc); mwl_tx_cleanup(sc); mwl_hal_detach(sc->sc_mh); - if_free(ifp); + mbufq_drain(&sc->sc_snd); return 0; } @@ -595,7 +580,7 @@ assign_address(struct mwl_softc *sc, uint8_t mac[IEEE80211_ADDR_LEN], int clone) } static void -reclaim_address(struct mwl_softc *sc, uint8_t mac[IEEE80211_ADDR_LEN]) +reclaim_address(struct mwl_softc *sc, const uint8_t mac[IEEE80211_ADDR_LEN]) { int i = mac[0] >> 2; if (i != 0 || --sc->sc_nbssid0 == 0) @@ -608,8 +593,7 @@ mwl_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ], int unit, const uint8_t bssid[IEEE80211_ADDR_LEN], const uint8_t mac0[IEEE80211_ADDR_LEN]) { - struct ifnet *ifp = ic->ic_ifp; - struct mwl_softc *sc = ifp->if_softc; + struct mwl_softc *sc = ic->ic_softc; struct mwl_hal *mh = sc->sc_mh; struct ieee80211vap *vap, *apvap; struct mwl_hal_vap *hvap; @@ -655,17 +639,7 @@ mwl_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ], int unit, return NULL; } - mvp = (struct mwl_vap *) malloc(sizeof(struct mwl_vap), - M_80211_VAP, M_NOWAIT | M_ZERO); - if (mvp == NULL) { - if (hvap != NULL) { - mwl_hal_delvap(hvap); - if ((flags & IEEE80211_CLONE_MACADDR) == 0) - reclaim_address(sc, mac); - } - /* XXX msg */ - return NULL; - } + mvp = malloc(sizeof(struct mwl_vap), M_80211_VAP, M_WAITOK | M_ZERO); mvp->mv_hvap = hvap; if (opmode == IEEE80211_M_WDS) { /* @@ -680,9 +654,7 @@ mwl_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ], int unit, KASSERT(mvp->mv_ap_hvap != NULL, ("no ap vap")); } vap = &mvp->mv_vap; - ieee80211_vap_setup(ic, vap, name, unit, opmode, flags, bssid, mac); - if (hvap != NULL) - IEEE80211_ADDR_COPY(vap->iv_myaddr, mac); + ieee80211_vap_setup(ic, vap, name, unit, opmode, flags, bssid); /* override with driver methods */ mvp->mv_newstate = vap->iv_newstate; vap->iv_newstate = mwl_newstate; @@ -707,7 +679,8 @@ mwl_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ], int unit, vap->iv_ampdu_density = IEEE80211_HTCAP_MPDUDENSITY_4; /* complete setup */ - ieee80211_vap_attach(vap, mwl_media_change, ieee80211_media_status); + ieee80211_vap_attach(vap, mwl_media_change, ieee80211_media_status, + mac); switch (vap->iv_opmode) { case IEEE80211_M_HOSTAP: @@ -746,14 +719,13 @@ static void mwl_vap_delete(struct ieee80211vap *vap) { struct mwl_vap *mvp = MWL_VAP(vap); - struct ifnet *parent = vap->iv_ic->ic_ifp; - struct mwl_softc *sc = parent->if_softc; + struct mwl_softc *sc = vap->iv_ic->ic_softc; struct mwl_hal *mh = sc->sc_mh; struct mwl_hal_vap *hvap = mvp->mv_hvap; enum ieee80211_opmode opmode = vap->iv_opmode; /* XXX disallow ap vap delete if WDS still present */ - if (parent->if_drv_flags & IFF_DRV_RUNNING) { + if (sc->sc_running) { /* quiesce h/w while we remove the vap */ mwl_hal_intrset(mh, 0); /* disable interrupts */ } @@ -780,31 +752,31 @@ mwl_vap_delete(struct ieee80211vap *vap) } mwl_cleartxq(sc, vap); free(mvp, M_80211_VAP); - if (parent->if_drv_flags & IFF_DRV_RUNNING) + if (sc->sc_running) mwl_hal_intrset(mh, sc->sc_imask); } void mwl_suspend(struct mwl_softc *sc) { - struct ifnet *ifp = sc->sc_ifp; - DPRINTF(sc, MWL_DEBUG_ANY, "%s: if_flags %x\n", - __func__, ifp->if_flags); - - mwl_stop(ifp, 1); + MWL_LOCK(sc); + mwl_stop(sc); + MWL_UNLOCK(sc); } void mwl_resume(struct mwl_softc *sc) { - struct ifnet *ifp = sc->sc_ifp; + int error = EDOOFUS; - DPRINTF(sc, MWL_DEBUG_ANY, "%s: if_flags %x\n", - __func__, ifp->if_flags); + MWL_LOCK(sc); + if (sc->sc_ic.ic_nrunning > 0) + error = mwl_init(sc); + MWL_UNLOCK(sc); - if (ifp->if_flags & IFF_UP) - mwl_init(sc); + if (error == 0) + ieee80211_start_all(&sc->sc_ic); /* start all vap's */ } void @@ -812,7 +784,9 @@ mwl_shutdown(void *arg) { struct mwl_softc *sc = arg; - mwl_stop(sc->sc_ifp, 1); + MWL_LOCK(sc); + mwl_stop(sc); + MWL_UNLOCK(sc); } /* @@ -882,8 +856,7 @@ static void mwl_radar_proc(void *arg, int pending) { struct mwl_softc *sc = arg; - struct ifnet *ifp = sc->sc_ifp; - struct ieee80211com *ic = ifp->if_l2com; + struct ieee80211com *ic = &sc->sc_ic; DPRINTF(sc, MWL_DEBUG_ANY, "%s: radar detected, pending %u\n", __func__, pending); @@ -900,8 +873,7 @@ static void mwl_chanswitch_proc(void *arg, int pending) { struct mwl_softc *sc = arg; - struct ifnet *ifp = sc->sc_ifp; - struct ieee80211com *ic = ifp->if_l2com; + struct ieee80211com *ic = &sc->sc_ic; DPRINTF(sc, MWL_DEBUG_ANY, "%s: channel switch notice, pending %u\n", __func__, pending); @@ -1029,8 +1001,7 @@ mwl_setupdma(struct mwl_softc *sc) static int mwl_setcurchanrates(struct mwl_softc *sc) { - struct ifnet *ifp = sc->sc_ifp; - struct ieee80211com *ic = ifp->if_l2com; + struct ieee80211com *ic = &sc->sc_ic; const struct ieee80211_rateset *rs; MWL_HAL_TXRATE rates; @@ -1143,8 +1114,7 @@ mwl_map2regioncode(const struct ieee80211_regdomain *rd) static int mwl_hal_reset(struct mwl_softc *sc) { - struct ifnet *ifp = sc->sc_ifp; - struct ieee80211com *ic = ifp->if_l2com; + struct ieee80211com *ic = &sc->sc_ic; struct mwl_hal *mh = sc->sc_mh; mwl_hal_setantenna(mh, WL_ANTENNATYPE_RX, sc->sc_rxantenna); @@ -1166,28 +1136,24 @@ mwl_hal_reset(struct mwl_softc *sc) } static int -mwl_init_locked(struct mwl_softc *sc) +mwl_init(struct mwl_softc *sc) { - struct ifnet *ifp = sc->sc_ifp; struct mwl_hal *mh = sc->sc_mh; int error = 0; - DPRINTF(sc, MWL_DEBUG_ANY, "%s: if_flags 0x%x\n", - __func__, ifp->if_flags); - MWL_LOCK_ASSERT(sc); /* * Stop anything previously setup. This is safe * whether this is the first time through or not. */ - mwl_stop_locked(ifp, 0); + mwl_stop(sc); /* * Push vap-independent state to the firmware. */ if (!mwl_hal_reset(sc)) { - if_printf(ifp, "unable to reset hardware\n"); + device_printf(sc->sc_dev, "unable to reset hardware\n"); return EIO; } @@ -1196,7 +1162,7 @@ mwl_init_locked(struct mwl_softc *sc) */ error = mwl_startrecv(sc); if (error != 0) { - if_printf(ifp, "unable to start recv logic\n"); + device_printf(sc->sc_dev, "unable to start recv logic\n"); return error; } @@ -1219,7 +1185,7 @@ mwl_init_locked(struct mwl_softc *sc) | MACREQ_A2HRIC_BIT_TX_ACK ; - ifp->if_drv_flags |= IFF_DRV_RUNNING; + sc->sc_running = 1; mwl_hal_intrset(mh, sc->sc_imask); callout_reset(&sc->sc_watchdog, hz, mwl_watchdog, sc); @@ -1227,54 +1193,21 @@ mwl_init_locked(struct mwl_softc *sc) } static void -mwl_init(void *arg) +mwl_stop(struct mwl_softc *sc) { - struct mwl_softc *sc = arg; - struct ifnet *ifp = sc->sc_ifp; - struct ieee80211com *ic = ifp->if_l2com; - int error = 0; - - DPRINTF(sc, MWL_DEBUG_ANY, "%s: if_flags 0x%x\n", - __func__, ifp->if_flags); - - MWL_LOCK(sc); - error = mwl_init_locked(sc); - MWL_UNLOCK(sc); - - if (error == 0) - ieee80211_start_all(ic); /* start all vap's */ -} - -static void -mwl_stop_locked(struct ifnet *ifp, int disable) -{ - struct mwl_softc *sc = ifp->if_softc; - - DPRINTF(sc, MWL_DEBUG_ANY, "%s: invalid %u if_flags 0x%x\n", - __func__, sc->sc_invalid, ifp->if_flags); MWL_LOCK_ASSERT(sc); - if (ifp->if_drv_flags & IFF_DRV_RUNNING) { + if (sc->sc_running) { /* * Shutdown the hardware and driver. */ - ifp->if_drv_flags &= ~IFF_DRV_RUNNING; + sc->sc_running = 0; callout_stop(&sc->sc_watchdog); sc->sc_tx_timer = 0; mwl_draintxq(sc); } } -static void -mwl_stop(struct ifnet *ifp, int disable) -{ - struct mwl_softc *sc = ifp->if_softc; - - MWL_LOCK(sc); - mwl_stop_locked(ifp, disable); - MWL_UNLOCK(sc); -} - static int mwl_reset_vap(struct ieee80211vap *vap, int state) { @@ -1317,8 +1250,7 @@ mwl_reset(struct ieee80211vap *vap, u_long cmd) if (hvap != NULL) { /* WDS, MONITOR, etc. */ struct ieee80211com *ic = vap->iv_ic; - struct ifnet *ifp = ic->ic_ifp; - struct mwl_softc *sc = ifp->if_softc; + struct mwl_softc *sc = ic->ic_softc; struct mwl_hal *mh = sc->sc_mh; /* XXX handle DWDS sta vap change */ @@ -1384,24 +1316,41 @@ mwl_puttxbuf_tail(struct mwl_txq *txq, struct mwl_txbuf *bf) MWL_TXQ_UNLOCK(txq); } -static void -mwl_start(struct ifnet *ifp) +static int +mwl_transmit(struct ieee80211com *ic, struct mbuf *m) +{ + struct mwl_softc *sc = ic->ic_softc; + int error; + + MWL_LOCK(sc); + if (!sc->sc_running) { + MWL_UNLOCK(sc); + return (ENXIO); + } + error = mbufq_enqueue(&sc->sc_snd, m); + if (error) { + MWL_UNLOCK(sc); + return (error); + } + mwl_start(sc); + MWL_UNLOCK(sc); + return (0); +} + +static void +mwl_start(struct mwl_softc *sc) { - struct mwl_softc *sc = ifp->if_softc; struct ieee80211_node *ni; struct mwl_txbuf *bf; struct mbuf *m; struct mwl_txq *txq = NULL; /* XXX silence gcc */ int nqueued; - if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0 || sc->sc_invalid) + MWL_LOCK_ASSERT(sc); + if (!sc->sc_running || sc->sc_invalid) return; nqueued = 0; - for (;;) { - bf = NULL; - IFQ_DEQUEUE(&ifp->if_snd, m); - if (m == NULL) - break; + while ((m = mbufq_dequeue(&sc->sc_snd)) != NULL) { /* * Grab the node for the destination. */ @@ -1419,8 +1368,6 @@ mwl_start(struct ifnet *ifp) ieee80211_free_node(ni); #ifdef MWL_TX_NODROP sc->sc_stats.mst_tx_qstop++; - /* XXX blocks other traffic */ - ifp->if_drv_flags |= IFF_DRV_OACTIVE; break; #else DPRINTF(sc, MWL_DEBUG_XMIT, @@ -1434,7 +1381,8 @@ mwl_start(struct ifnet *ifp) * Pass the frame to the h/w for transmission. */ if (mwl_tx_start(sc, ni, bf, m)) { - ifp->if_oerrors++; + if_inc_counter(ni->ni_vap->iv_ifp, + IFCOUNTER_OERRORS, 1); mwl_puttxbuf_head(txq, bf); ieee80211_free_node(ni); continue; @@ -1472,13 +1420,11 @@ mwl_raw_xmit(struct ieee80211_node *ni, struct mbuf *m, const struct ieee80211_bpf_params *params) { struct ieee80211com *ic = ni->ni_ic; - struct ifnet *ifp = ic->ic_ifp; - struct mwl_softc *sc = ifp->if_softc; + struct mwl_softc *sc = ic->ic_softc; struct mwl_txbuf *bf; struct mwl_txq *txq; - if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0 || sc->sc_invalid) { - ieee80211_free_node(ni); + if (!sc->sc_running || sc->sc_invalid) { m_freem(m); return ENETDOWN; } @@ -1494,9 +1440,6 @@ mwl_raw_xmit(struct ieee80211_node *ni, struct mbuf *m, bf = mwl_gettxbuf(sc, txq); if (bf == NULL) { sc->sc_stats.mst_tx_qstop++; - /* XXX blocks other traffic */ - ifp->if_drv_flags |= IFF_DRV_OACTIVE; - ieee80211_free_node(ni); m_freem(m); return ENOBUFS; } @@ -1504,10 +1447,8 @@ mwl_raw_xmit(struct ieee80211_node *ni, struct mbuf *m, * Pass the frame to the h/w for transmission. */ if (mwl_tx_start(sc, ni, bf, m)) { - ifp->if_oerrors++; mwl_puttxbuf_head(txq, bf); - ieee80211_free_node(ni); return EIO; /* XXX */ } /* @@ -1579,7 +1520,7 @@ static int mwl_key_alloc(struct ieee80211vap *vap, struct ieee80211_key *k, ieee80211_keyix *keyix, ieee80211_keyix *rxkeyix) { - struct mwl_softc *sc = vap->iv_ic->ic_ifp->if_softc; + struct mwl_softc *sc = vap->iv_ic->ic_softc; if (k->wk_keyix != IEEE80211_KEYIX_NONE || (k->wk_flags & IEEE80211_KEY_GROUP)) { @@ -1607,7 +1548,7 @@ mwl_key_alloc(struct ieee80211vap *vap, struct ieee80211_key *k, static int mwl_key_delete(struct ieee80211vap *vap, const struct ieee80211_key *k) { - struct mwl_softc *sc = vap->iv_ic->ic_ifp->if_softc; + struct mwl_softc *sc = vap->iv_ic->ic_softc; struct mwl_hal_vap *hvap = MWL_VAP(vap)->mv_hvap; MWL_HAL_KEYVAL hk; const uint8_t bcastaddr[IEEE80211_ADDR_LEN] = @@ -1666,7 +1607,13 @@ addgroupflags(MWL_HAL_KEYVAL *hk, const struct ieee80211_key *k) * slot(s) must already have been allocated by mwl_key_alloc. */ static int -mwl_key_set(struct ieee80211vap *vap, const struct ieee80211_key *k, +mwl_key_set(struct ieee80211vap *vap, const struct ieee80211_key *k) +{ + return (_mwl_key_set(vap, k, k->wk_macaddr)); +} + +static int +_mwl_key_set(struct ieee80211vap *vap, const struct ieee80211_key *k, const uint8_t mac[IEEE80211_ADDR_LEN]) { #define GRPXMIT (IEEE80211_KEY_XMIT | IEEE80211_KEY_GROUP) @@ -1674,7 +1621,7 @@ mwl_key_set(struct ieee80211vap *vap, const struct ieee80211_key *k, #define IEEE80211_IS_STATICKEY(k) \ (((k)->wk_flags & (GRPXMIT|IEEE80211_KEY_RECV)) == \ (GRPXMIT|IEEE80211_KEY_RECV)) - struct mwl_softc *sc = vap->iv_ic->ic_ifp->if_softc; + struct mwl_softc *sc = vap->iv_ic->ic_softc; struct mwl_hal_vap *hvap = MWL_VAP(vap)->mv_hvap; const struct ieee80211_cipher *cip = k->wk_cipher; const uint8_t *macaddr; @@ -1770,18 +1717,6 @@ mwl_key_set(struct ieee80211vap *vap, const struct ieee80211_key *k, #undef GRPXMIT } -/* unaligned little endian access */ -#define LE_READ_2(p) \ - ((uint16_t) \ - ((((const uint8_t *)(p))[0] ) | \ - (((const uint8_t *)(p))[1] << 8))) -#define LE_READ_4(p) \ - ((uint32_t) \ - ((((const uint8_t *)(p))[0] ) | \ - (((const uint8_t *)(p))[1] << 8) | \ - (((const uint8_t *)(p))[2] << 16) | \ - (((const uint8_t *)(p))[3] << 24))) - /* * Set the multicast filter contents into the hardware. * XXX f/w has no support; just defer to the os. @@ -1789,7 +1724,6 @@ mwl_key_set(struct ieee80211vap *vap, const struct ieee80211_key *k, static void mwl_setmcastfilter(struct mwl_softc *sc) { - struct ifnet *ifp = sc->sc_ifp; #if 0 struct ether_multi *enm; struct ether_multistep estep; @@ -1813,27 +1747,16 @@ mwl_setmcastfilter(struct mwl_softc *sc) } ifp->if_flags &= ~IFF_ALLMULTI; mwl_hal_setmcast(sc->sc_mh, nmc, macs); -#else - /* XXX no mcast filter support; we get everything */ - ifp->if_flags |= IFF_ALLMULTI; #endif } static int mwl_mode_init(struct mwl_softc *sc) { - struct ifnet *ifp = sc->sc_ifp; - struct ieee80211com *ic = ifp->if_l2com; + struct ieee80211com *ic = &sc->sc_ic; struct mwl_hal *mh = sc->sc_mh; - /* - * NB: Ignore promisc in hostap mode; it's set by the - * bridge. This is wrong but we have no way to - * identify internal requests (from the bridge) - * versus external requests such as for tcpdump. - */ - mwl_hal_setpromisc(mh, (ifp->if_flags & IFF_PROMISC) && - ic->ic_opmode != IEEE80211_M_HOSTAP); + mwl_hal_setpromisc(mh, ic->ic_promisc > 0); mwl_setmcastfilter(sc); return 0; @@ -1843,9 +1766,9 @@ mwl_mode_init(struct mwl_softc *sc) * Callback from the 802.11 layer after a multicast state change. */ static void -mwl_update_mcast(struct ifnet *ifp) +mwl_update_mcast(struct ieee80211com *ic) { - struct mwl_softc *sc = ifp->if_softc; + struct mwl_softc *sc = ic->ic_softc; mwl_setmcastfilter(sc); } @@ -1858,11 +1781,11 @@ mwl_update_mcast(struct ifnet *ifp) * mode when operating in hostap mode to do ACS). */ static void -mwl_update_promisc(struct ifnet *ifp) +mwl_update_promisc(struct ieee80211com *ic) { - struct mwl_softc *sc = ifp->if_softc; + struct mwl_softc *sc = ic->ic_softc; - mwl_hal_setpromisc(sc->sc_mh, (ifp->if_flags & IFF_PROMISC) != 0); + mwl_hal_setpromisc(sc->sc_mh, ic->ic_promisc > 0); } /* @@ -1872,15 +1795,14 @@ mwl_update_promisc(struct ifnet *ifp) * like slot time and preamble. */ static void -mwl_updateslot(struct ifnet *ifp) +mwl_updateslot(struct ieee80211com *ic) { - struct mwl_softc *sc = ifp->if_softc; - struct ieee80211com *ic = ifp->if_l2com; + struct mwl_softc *sc = ic->ic_softc; struct mwl_hal *mh = sc->sc_mh; int prot; /* NB: can be called early; suppress needless cmds */ - if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) + if (!sc->sc_running) return; /* @@ -1914,10 +1836,9 @@ mwl_beacon_setup(struct ieee80211vap *vap) { struct mwl_hal_vap *hvap = MWL_VAP(vap)->mv_hvap; struct ieee80211_node *ni = vap->iv_bss; - struct ieee80211_beacon_offsets bo; struct mbuf *m; - m = ieee80211_beacon_alloc(ni, &bo); + m = ieee80211_beacon_alloc(ni); if (m == NULL) return ENOBUFS; mwl_hal_setbeacon(hvap, mtod(m, const void *), m->m_len); @@ -1938,7 +1859,7 @@ mwl_beacon_update(struct ieee80211vap *vap, int item) KASSERT(hvap != NULL, ("no beacon")); switch (item) { case IEEE80211_BEACON_ERP: - mwl_updateslot(ic->ic_ifp); + mwl_updateslot(ic); break; case IEEE80211_BEACON_HTINFO: mwl_hal_setnprotmode(hvap, @@ -2002,7 +1923,6 @@ mwl_desc_setup(struct mwl_softc *sc, const char *name, struct mwl_descdma *dd, int nbuf, size_t bufsize, int ndesc, size_t descsize) { - struct ifnet *ifp = sc->sc_ifp; uint8_t *ds; int error; @@ -2030,23 +1950,16 @@ mwl_desc_setup(struct mwl_softc *sc, const char *name, NULL, /* lockarg */ &dd->dd_dmat); if (error != 0) { - if_printf(ifp, "cannot allocate %s DMA tag\n", dd->dd_name); + device_printf(sc->sc_dev, "cannot allocate %s DMA tag\n", dd->dd_name); return error; } /* allocate descriptors */ - error = bus_dmamap_create(dd->dd_dmat, BUS_DMA_NOWAIT, &dd->dd_dmamap); - if (error != 0) { - if_printf(ifp, "unable to create dmamap for %s descriptors, " - "error %u\n", dd->dd_name, error); - goto fail0; - } - error = bus_dmamem_alloc(dd->dd_dmat, (void**) &dd->dd_desc, - BUS_DMA_NOWAIT | BUS_DMA_COHERENT, + BUS_DMA_NOWAIT | BUS_DMA_COHERENT, &dd->dd_dmamap); if (error != 0) { - if_printf(ifp, "unable to alloc memory for %u %s descriptors, " + device_printf(sc->sc_dev, "unable to alloc memory for %u %s descriptors, " "error %u\n", nbuf * ndesc, dd->dd_name, error); goto fail1; } @@ -2056,23 +1969,22 @@ mwl_desc_setup(struct mwl_softc *sc, const char *name, mwl_load_cb, &dd->dd_desc_paddr, BUS_DMA_NOWAIT); if (error != 0) { - if_printf(ifp, "unable to map %s descriptors, error %u\n", + device_printf(sc->sc_dev, "unable to map %s descriptors, error %u\n", dd->dd_name, error); goto fail2; } ds = dd->dd_desc; memset(ds, 0, dd->dd_desc_len); - DPRINTF(sc, MWL_DEBUG_RESET, "%s: %s DMA map: %p (%lu) -> %p (%lu)\n", + DPRINTF(sc, MWL_DEBUG_RESET, + "%s: %s DMA map: %p (%lu) -> 0x%jx (%lu)\n", __func__, dd->dd_name, ds, (u_long) dd->dd_desc_len, - (caddr_t) dd->dd_desc_paddr, /*XXX*/ (u_long) dd->dd_desc_len); + (uintmax_t) dd->dd_desc_paddr, /*XXX*/ (u_long) dd->dd_desc_len); return 0; fail2: bus_dmamem_free(dd->dd_dmat, dd->dd_desc, dd->dd_dmamap); fail1: - bus_dmamap_destroy(dd->dd_dmat, dd->dd_dmamap); -fail0: bus_dma_tag_destroy(dd->dd_dmat); memset(dd, 0, sizeof(*dd)); return error; @@ -2084,13 +1996,12 @@ mwl_desc_cleanup(struct mwl_softc *sc, struct mwl_descdma *dd) { bus_dmamap_unload(dd->dd_dmat, dd->dd_dmamap); bus_dmamem_free(dd->dd_dmat, dd->dd_desc, dd->dd_dmamap); - bus_dmamap_destroy(dd->dd_dmat, dd->dd_dmamap); bus_dma_tag_destroy(dd->dd_dmat); memset(dd, 0, sizeof(*dd)); } -/* +/* * Construct a tx q's free list. The order of entries on * the list must reflect the physical layout of tx descriptors * because the firmware pre-fetches descriptors. @@ -2116,7 +2027,6 @@ mwl_txq_reset(struct mwl_softc *sc, struct mwl_txq *txq) static int mwl_txdma_setup(struct mwl_softc *sc, struct mwl_txq *txq) { - struct ifnet *ifp = sc->sc_ifp; int error, bsize, i; struct mwl_txbuf *bf; struct mwl_txdesc *ds; @@ -2131,7 +2041,7 @@ mwl_txdma_setup(struct mwl_softc *sc, struct mwl_txq *txq) bsize = mwl_txbuf * sizeof(struct mwl_txbuf); bf = malloc(bsize, M_MWLDEV, M_NOWAIT | M_ZERO); if (bf == NULL) { - if_printf(ifp, "malloc of %u tx buffers failed\n", + device_printf(sc->sc_dev, "malloc of %u tx buffers failed\n", mwl_txbuf); return ENOMEM; } @@ -2144,7 +2054,7 @@ mwl_txdma_setup(struct mwl_softc *sc, struct mwl_txq *txq) error = bus_dmamap_create(sc->sc_dmat, BUS_DMA_NOWAIT, &bf->bf_dmamap); if (error != 0) { - if_printf(ifp, "unable to create dmamap for tx " + device_printf(sc->sc_dev, "unable to create dmamap for tx " "buffer %u, error %u\n", i, error); return error; } @@ -2179,7 +2089,6 @@ mwl_txdma_cleanup(struct mwl_softc *sc, struct mwl_txq *txq) static int mwl_rxdma_setup(struct mwl_softc *sc) { - struct ifnet *ifp = sc->sc_ifp; int error, jumbosize, bsize, i; struct mwl_rxbuf *bf; struct mwl_jumbo *rbuf; @@ -2203,7 +2112,7 @@ mwl_rxdma_setup(struct mwl_softc *sc) * us while frames are processed. */ if (mwl_rxbuf < 2*mwl_rxdesc) { - if_printf(ifp, + device_printf(sc->sc_dev, "too few rx dma buffers (%d); increasing to %d\n", mwl_rxbuf, 2*mwl_rxdesc); mwl_rxbuf = 2*mwl_rxdesc; @@ -2223,17 +2132,16 @@ mwl_rxdma_setup(struct mwl_softc *sc) NULL, /* lockfunc */ NULL, /* lockarg */ &sc->sc_rxdmat); - error = bus_dmamap_create(sc->sc_rxdmat, BUS_DMA_NOWAIT, &sc->sc_rxmap); if (error != 0) { - if_printf(ifp, "could not create rx DMA map\n"); + device_printf(sc->sc_dev, "could not create rx DMA tag\n"); return error; } error = bus_dmamem_alloc(sc->sc_rxdmat, (void**) &sc->sc_rxmem, - BUS_DMA_NOWAIT | BUS_DMA_COHERENT, + BUS_DMA_NOWAIT | BUS_DMA_COHERENT, &sc->sc_rxmap); if (error != 0) { - if_printf(ifp, "could not alloc %ju bytes of rx DMA memory\n", + device_printf(sc->sc_dev, "could not alloc %ju bytes of rx DMA memory\n", (uintmax_t) sc->sc_rxmemsize); return error; } @@ -2243,7 +2151,7 @@ mwl_rxdma_setup(struct mwl_softc *sc) mwl_load_cb, &sc->sc_rxmem_paddr, BUS_DMA_NOWAIT); if (error != 0) { - if_printf(ifp, "could not load rx DMA map\n"); + device_printf(sc->sc_dev, "could not load rx DMA map\n"); return error; } @@ -2253,7 +2161,7 @@ mwl_rxdma_setup(struct mwl_softc *sc) bsize = mwl_rxdesc * sizeof(struct mwl_rxbuf); bf = malloc(bsize, M_MWLDEV, M_NOWAIT | M_ZERO); if (bf == NULL) { - if_printf(ifp, "malloc of %u rx buffers failed\n", bsize); + device_printf(sc->sc_dev, "malloc of %u rx buffers failed\n", bsize); return error; } sc->sc_rxdma.dd_bufptr = bf; @@ -2279,7 +2187,6 @@ mwl_rxdma_setup(struct mwl_softc *sc) SLIST_INSERT_HEAD(&sc->sc_rxfree, rbuf, next); sc->sc_nrxfree++; } - MWL_RXFREE_INIT(sc); return 0; } #undef DS2PHYS @@ -2287,23 +2194,20 @@ mwl_rxdma_setup(struct mwl_softc *sc) static void mwl_rxdma_cleanup(struct mwl_softc *sc) { - if (sc->sc_rxmap != NULL) + if (sc->sc_rxmem_paddr != 0) { bus_dmamap_unload(sc->sc_rxdmat, sc->sc_rxmap); + sc->sc_rxmem_paddr = 0; + } if (sc->sc_rxmem != NULL) { bus_dmamem_free(sc->sc_rxdmat, sc->sc_rxmem, sc->sc_rxmap); sc->sc_rxmem = NULL; } - if (sc->sc_rxmap != NULL) { - bus_dmamap_destroy(sc->sc_rxdmat, sc->sc_rxmap); - sc->sc_rxmap = NULL; - } if (sc->sc_rxdma.dd_bufptr != NULL) { free(sc->sc_rxdma.dd_bufptr, M_MWLDEV); sc->sc_rxdma.dd_bufptr = NULL; } if (sc->sc_rxdma.dd_desc_len != 0) mwl_desc_cleanup(sc, &sc->sc_rxdma); - MWL_RXFREE_DESTROY(sc); } static int @@ -2341,7 +2245,7 @@ static struct ieee80211_node * mwl_node_alloc(struct ieee80211vap *vap, const uint8_t mac[IEEE80211_ADDR_LEN]) { struct ieee80211com *ic = vap->iv_ic; - struct mwl_softc *sc = ic->ic_ifp->if_softc; + struct mwl_softc *sc = ic->ic_softc; const size_t space = sizeof(struct mwl_node); struct mwl_node *mn; @@ -2358,7 +2262,7 @@ static void mwl_node_cleanup(struct ieee80211_node *ni) { struct ieee80211com *ic = ni->ni_ic; - struct mwl_softc *sc = ic->ic_ifp->if_softc; + struct mwl_softc *sc = ic->ic_softc; struct mwl_node *mn = MWL_NODE(ni); DPRINTF(sc, MWL_DEBUG_NODE, "%s: ni %p ic %p staid %d\n", @@ -2453,7 +2357,7 @@ static void mwl_node_drain(struct ieee80211_node *ni) { struct ieee80211com *ic = ni->ni_ic; - struct mwl_softc *sc = ic->ic_ifp->if_softc; + struct mwl_softc *sc = ic->ic_softc; struct mwl_node *mn = MWL_NODE(ni); DPRINTF(sc, MWL_DEBUG_NODE, "%s: ni %p vap %p staid %d\n", @@ -2518,9 +2422,9 @@ mwl_node_getmimoinfo(const struct ieee80211_node *ni, (_dst) = (_dst) > 64 ? 127 : ((_dst) << 1); \ } while (0) static const int8_t logdbtbl[32] = { - 0, 0, 24, 38, 48, 56, 62, 68, - 72, 76, 80, 83, 86, 89, 92, 94, - 96, 98, 100, 102, 104, 106, 107, 109, + 0, 0, 24, 38, 48, 56, 62, 68, + 72, 76, 80, 83, 86, 89, 92, 94, + 96, 98, 100, 102, 104, 106, 107, 109, 110, 112, 113, 115, 116, 117, 118, 119 }; const struct mwl_node *mn = MWL_NODE_CONST(ni); @@ -2621,7 +2525,7 @@ mwl_rxbuf_init(struct mwl_softc *sc, struct mwl_rxbuf *bf) } static void -mwl_ext_free(void *data, void *arg) +mwl_ext_free(struct mbuf *m, void *data, void *arg) { struct mwl_softc *sc = arg; @@ -2705,11 +2609,8 @@ cvtrssi(uint8_t ssi) static void mwl_rx_proc(void *arg, int npending) { -#define IEEE80211_DIR_DSTODS(wh) \ - ((((const struct ieee80211_frame *)wh)->i_fc[1] & IEEE80211_FC1_DIR_MASK) == IEEE80211_FC1_DIR_DSTODS) struct mwl_softc *sc = arg; - struct ifnet *ifp = sc->sc_ifp; - struct ieee80211com *ic = ifp->if_l2com; + struct ieee80211com *ic = &sc->sc_ic; struct mwl_rxbuf *bf; struct mwl_rxdesc *ds; struct mbuf *m; @@ -2739,7 +2640,7 @@ mwl_rx_proc(void *arg, int npending) * Note the firmware will not advance to the next * descriptor with a dma buffer so we must mimic * this or we'll get out of sync. - */ + */ DPRINTF(sc, MWL_DEBUG_ANY, "%s: rx buf w/o dma memory\n", __func__); (void) mwl_rxbuf_init(sc, bf); @@ -2756,7 +2657,7 @@ mwl_rx_proc(void *arg, int npending) #endif status = ds->Status; if (status & EAGLE_RXD_STATUS_DECRYPT_ERR_MASK) { - ifp->if_ierrors++; + counter_u64_add(ic->ic_ierrors, 1); sc->sc_stats.mst_rx_crypto++; /* * NB: Check EAGLE_RXD_STATUS_GENERAL_DECRYPT_ERR @@ -2852,7 +2753,6 @@ mwl_rx_proc(void *arg, int npending) data, sc, 0, EXT_NET_DRV); m->m_data += off - hdrlen; m->m_pkthdr.len = m->m_len = pktlen; - m->m_pkthdr.rcvif = ifp; /* NB: dma buffer assumed read-only */ /* @@ -2863,7 +2763,7 @@ mwl_rx_proc(void *arg, int npending) /* XXX special case so we can memcpy after m_devget? */ ovbcopy(data + sizeof(uint16_t), wh, hdrlen); if (IEEE80211_QOS_HAS_SEQ(wh)) { - if (IEEE80211_DIR_DSTODS(wh)) { + if (IEEE80211_IS_DSTODS(wh)) { wh4 = mtod(m, struct ieee80211_qosframe_addr4*); *(uint16_t *)wh4->i_qos = ds->QosCtrl; @@ -2881,12 +2781,13 @@ mwl_rx_proc(void *arg, int npending) * upper layer to put a station in power save * (except when configured with MWL_HOST_PS_SUPPORT). */ - if (wh->i_fc[1] & IEEE80211_FC1_WEP) + if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) m->m_flags |= M_WEP; #ifdef MWL_HOST_PS_SUPPORT - wh->i_fc[1] &= ~IEEE80211_FC1_WEP; + wh->i_fc[1] &= ~IEEE80211_FC1_PROTECTED; #else - wh->i_fc[1] &= ~(IEEE80211_FC1_WEP | IEEE80211_FC1_PWR_MGT); + wh->i_fc[1] &= ~(IEEE80211_FC1_PROTECTED | + IEEE80211_FC1_PWR_MGT); #endif if (ieee80211_radiotap_active(ic)) { @@ -2901,8 +2802,6 @@ mwl_rx_proc(void *arg, int npending) ieee80211_dump_pkt(ic, mtod(m, caddr_t), len, ds->Rate, rssi); } - ifp->if_ipackets++; - /* dispatch */ ni = ieee80211_find_rxnode(ic, (const struct ieee80211_frame_min *) wh); @@ -2929,13 +2828,11 @@ rx_next: rx_stop: sc->sc_rxnext = bf; - if ((ifp->if_drv_flags & IFF_DRV_OACTIVE) == 0 && - !IFQ_IS_EMPTY(&ifp->if_snd)) { + if (mbufq_first(&sc->sc_snd) != NULL) { /* NB: kick fw; the tx thread may have been preempted */ mwl_hal_txstart(sc->sc_mh, 0); - mwl_start(ifp); + mwl_start(sc); } -#undef IEEE80211_DIR_DSTODS } static void @@ -2971,12 +2868,11 @@ mwl_txq_init(struct mwl_softc *sc, struct mwl_txq *txq, int qnum) static int mwl_tx_setup(struct mwl_softc *sc, int ac, int mvtype) { -#define N(a) (sizeof(a)/sizeof(a[0])) struct mwl_txq *txq; - if (ac >= N(sc->sc_ac2q)) { + if (ac >= nitems(sc->sc_ac2q)) { device_printf(sc->sc_dev, "AC %u out of range, max %zu!\n", - ac, N(sc->sc_ac2q)); + ac, nitems(sc->sc_ac2q)); return 0; } if (mvtype >= MWL_NUM_TX_QUEUES) { @@ -2988,7 +2884,6 @@ mwl_tx_setup(struct mwl_softc *sc, int ac, int mvtype) mwl_txq_init(sc, txq, mvtype); sc->sc_ac2q[ac] = txq; return 1; -#undef N } /* @@ -2998,8 +2893,7 @@ static int mwl_txq_update(struct mwl_softc *sc, int ac) { #define MWL_EXPONENT_TO_VALUE(v) ((1<sc_ifp; - struct ieee80211com *ic = ifp->if_l2com; + struct ieee80211com *ic = &sc->sc_ic; struct mwl_txq *txq = sc->sc_ac2q[ac]; struct wmeParams *wmep = &ic->ic_wme.wme_chanParams.cap_wmeParams[ac]; struct mwl_hal *mh = sc->sc_mh; @@ -3027,7 +2921,7 @@ mwl_txq_update(struct mwl_softc *sc, int ac) static int mwl_wme_update(struct ieee80211com *ic) { - struct mwl_softc *sc = ic->ic_ifp->if_softc; + struct mwl_softc *sc = ic->ic_softc; return !mwl_txq_update(sc, WME_AC_BE) || !mwl_txq_update(sc, WME_AC_BK) || @@ -3182,10 +3076,7 @@ static int mwl_tx_start(struct mwl_softc *sc, struct ieee80211_node *ni, struct mwl_txbuf *bf, struct mbuf *m0) { -#define IEEE80211_DIR_DSTODS(wh) \ - ((wh->i_fc[1] & IEEE80211_FC1_DIR_MASK) == IEEE80211_FC1_DIR_DSTODS) - struct ifnet *ifp = sc->sc_ifp; - struct ieee80211com *ic = ifp->if_l2com; + struct ieee80211com *ic = &sc->sc_ic; struct ieee80211vap *vap = ni->ni_vap; int error, iswep, ismcast; int hdrlen, copyhdrlen, pktlen; @@ -3200,13 +3091,13 @@ mwl_tx_start(struct mwl_softc *sc, struct ieee80211_node *ni, struct mwl_txbuf * #endif wh = mtod(m0, struct ieee80211_frame *); - iswep = wh->i_fc[1] & IEEE80211_FC1_WEP; + iswep = wh->i_fc[1] & IEEE80211_FC1_PROTECTED; ismcast = IEEE80211_IS_MULTICAST(wh->i_addr1); hdrlen = ieee80211_anyhdrsize(wh); copyhdrlen = hdrlen; pktlen = m0->m_pkthdr.len; if (IEEE80211_QOS_HAS_SEQ(wh)) { - if (IEEE80211_DIR_DSTODS(wh)) { + if (IEEE80211_IS_DSTODS(wh)) { qos = *(uint16_t *) (((struct ieee80211_qosframe_addr4 *) wh)->i_qos); copyhdrlen -= sizeof(qos); @@ -3402,7 +3293,7 @@ mwl_tx_start(struct mwl_softc *sc, struct ieee80211_node *ni, struct mwl_txbuf * ds->TxPriority = txq->qnum; break; default: - if_printf(ifp, "bogus frame type 0x%x (%s)\n", + device_printf(sc->sc_dev, "bogus frame type 0x%x (%s)\n", wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK, __func__); sc->sc_stats.mst_tx_badframetype++; m_freem(m0); @@ -3419,22 +3310,18 @@ mwl_tx_start(struct mwl_softc *sc, struct ieee80211_node *ni, struct mwl_txbuf * STAILQ_INSERT_TAIL(&txq->active, bf, bf_list); MWL_TXDESC_SYNC(txq, ds, BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); - ifp->if_opackets++; sc->sc_tx_timer = 5; MWL_TXQ_UNLOCK(txq); return 0; -#undef IEEE80211_DIR_DSTODS } static __inline int mwl_cvtlegacyrix(int rix) { -#define N(x) (sizeof(x)/sizeof(x[0])) static const int ieeerates[] = { 2, 4, 11, 22, 44, 12, 18, 24, 36, 48, 72, 96, 108 }; - return (rix < N(ieeerates) ? ieeerates[rix] : 0); -#undef N + return (rix < nitems(ieeerates) ? ieeerates[rix] : 0); } /* @@ -3445,8 +3332,7 @@ mwl_tx_processq(struct mwl_softc *sc, struct mwl_txq *txq) { #define EAGLE_TXD_STATUS_MCAST \ (EAGLE_TXD_STATUS_MULTICAST_TX | EAGLE_TXD_STATUS_BROADCAST_TX) - struct ifnet *ifp = sc->sc_ifp; - struct ieee80211com *ic = ifp->if_l2com; + struct ieee80211com *ic = &sc->sc_ic; struct mwl_txbuf *bf; struct mwl_txdesc *ds; struct ieee80211_node *ni; @@ -3508,32 +3394,18 @@ mwl_tx_processq(struct mwl_softc *sc, struct mwl_txq *txq) if (bf->bf_m->m_flags & M_FF) sc->sc_stats.mst_ff_txerr++; } - /* - * Do any tx complete callback. Note this must - * be done before releasing the node reference. - * XXX no way to figure out if frame was ACK'd - */ - if (bf->bf_m->m_flags & M_TXCB) { + if (bf->bf_m->m_flags & M_TXCB) /* XXX strip fw len in case header inspected */ m_adj(bf->bf_m, sizeof(uint16_t)); - ieee80211_process_callback(ni, bf->bf_m, - (status & EAGLE_TXD_STATUS_OK) == 0); - } - /* - * Reclaim reference to node. - * - * NB: the node may be reclaimed here if, for example - * this is a DEAUTH message that was sent and the - * node was timed out due to inactivity. - */ - ieee80211_free_node(ni); - } + ieee80211_tx_complete(ni, bf->bf_m, + (status & EAGLE_TXD_STATUS_OK) == 0); + } else + m_freem(bf->bf_m); ds->Status = htole32(EAGLE_TXD_STATUS_IDLE); bus_dmamap_sync(sc->sc_dmat, bf->bf_dmamap, BUS_DMASYNC_POSTWRITE); bus_dmamap_unload(sc->sc_dmat, bf->bf_dmamap); - m_freem(bf->bf_m); mwl_puttxbuf_tail(txq, bf); } @@ -3549,7 +3421,6 @@ static void mwl_tx_proc(void *arg, int npending) { struct mwl_softc *sc = arg; - struct ifnet *ifp = sc->sc_ifp; int nreaped; /* @@ -3566,12 +3437,11 @@ mwl_tx_proc(void *arg, int npending) nreaped += mwl_tx_processq(sc, &sc->sc_txq[3]); if (nreaped != 0) { - ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; sc->sc_tx_timer = 0; - if (!IFQ_IS_EMPTY(&ifp->if_snd)) { + if (mbufq_first(&sc->sc_snd) != NULL) { /* NB: kick fw; the tx thread may have been preempted */ mwl_hal_txstart(sc->sc_mh, 0); - mwl_start(ifp); + mwl_start(sc); } } } @@ -3598,8 +3468,7 @@ mwl_tx_draintxq(struct mwl_softc *sc, struct mwl_txq *txq) MWL_TXQ_UNLOCK(txq); #ifdef MWL_DEBUG if (sc->sc_debug & MWL_DEBUG_RESET) { - struct ifnet *ifp = sc->sc_ifp; - struct ieee80211com *ic = ifp->if_l2com; + struct ieee80211com *ic = &sc->sc_ic; const struct mwltxrec *tr = mtod(bf->bf_m, const struct mwltxrec *); mwl_printtxbuf(bf, txq->qnum, ix); @@ -3627,12 +3496,10 @@ mwl_tx_draintxq(struct mwl_softc *sc, struct mwl_txq *txq) static void mwl_draintxq(struct mwl_softc *sc) { - struct ifnet *ifp = sc->sc_ifp; int i; for (i = 0; i < MWL_NUM_TX_QUEUES; i++) mwl_tx_draintxq(sc, &sc->sc_txq[i]); - ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; sc->sc_tx_timer = 0; } @@ -3682,7 +3549,7 @@ static int mwl_recv_action(struct ieee80211_node *ni, const struct ieee80211_frame *wh, const uint8_t *frm, const uint8_t *efrm) { - struct mwl_softc *sc = ni->ni_ic->ic_ifp->if_softc; + struct mwl_softc *sc = ni->ni_ic->ic_softc; const struct ieee80211_action *ia; ia = (const struct ieee80211_action *) frm; @@ -3703,7 +3570,7 @@ static int mwl_addba_request(struct ieee80211_node *ni, struct ieee80211_tx_ampdu *tap, int dialogtoken, int baparamset, int batimeout) { - struct mwl_softc *sc = ni->ni_ic->ic_ifp->if_softc; + struct mwl_softc *sc = ni->ni_ic->ic_softc; struct ieee80211vap *vap = ni->ni_vap; struct mwl_node *mn = MWL_NODE(ni); struct mwl_bastate *bas; @@ -3732,7 +3599,7 @@ mwl_addba_request(struct ieee80211_node *ni, struct ieee80211_tx_ampdu *tap, #if MWL_MAXBA > 0 if (mn->mn_ba[0].bastream == NULL) bas = &mn->mn_ba[0]; - else + else #endif { /* sta already has max BA streams */ @@ -3745,7 +3612,7 @@ mwl_addba_request(struct ieee80211_node *ni, struct ieee80211_tx_ampdu *tap, /* NB: no held reference to ni */ sp = mwl_hal_bastream_alloc(MWL_VAP(vap)->mv_hvap, (baparamset & IEEE80211_BAPS_POLICY_IMMEDIATE) != 0, - ni->ni_macaddr, WME_AC_TO_TID(tap->txa_ac), ni->ni_htparam, + ni->ni_macaddr, tap->txa_tid, ni->ni_htparam, ni, tap); if (sp == NULL) { /* @@ -3775,15 +3642,15 @@ static int mwl_addba_response(struct ieee80211_node *ni, struct ieee80211_tx_ampdu *tap, int code, int baparamset, int batimeout) { - struct mwl_softc *sc = ni->ni_ic->ic_ifp->if_softc; + struct mwl_softc *sc = ni->ni_ic->ic_softc; struct mwl_bastate *bas; bas = tap->txa_private; if (bas == NULL) { /* XXX should not happen */ DPRINTF(sc, MWL_DEBUG_AMPDU, - "%s: no BA stream allocated, AC %d\n", - __func__, tap->txa_ac); + "%s: no BA stream allocated, TID %d\n", + __func__, tap->txa_tid); sc->sc_stats.mst_addba_nostream++; return 0; } @@ -3811,18 +3678,18 @@ mwl_addba_response(struct ieee80211_node *ni, struct ieee80211_tx_ampdu *tap, tap->txa_private = NULL; DPRINTF(sc, MWL_DEBUG_AMPDU, - "%s: create failed, error %d, bufsiz %d AC %d " + "%s: create failed, error %d, bufsiz %d TID %d " "htparam 0x%x\n", __func__, error, bufsiz, - tap->txa_ac, ni->ni_htparam); + tap->txa_tid, ni->ni_htparam); sc->sc_stats.mst_bacreate_failed++; return 0; } /* NB: cache txq to avoid ptr indirect */ - mwl_bastream_setup(bas, tap->txa_ac, bas->bastream->txq); + mwl_bastream_setup(bas, tap->txa_tid, bas->bastream->txq); DPRINTF(sc, MWL_DEBUG_AMPDU, - "%s: bastream %p assigned to txq %d AC %d bufsiz %d " + "%s: bastream %p assigned to txq %d TID %d bufsiz %d " "htparam 0x%x\n", __func__, bas->bastream, - bas->txq, tap->txa_ac, bufsiz, ni->ni_htparam); + bas->txq, tap->txa_tid, bufsiz, ni->ni_htparam); } else { /* * Other side NAK'd us; return the resources. @@ -3841,7 +3708,7 @@ mwl_addba_response(struct ieee80211_node *ni, struct ieee80211_tx_ampdu *tap, static void mwl_addba_stop(struct ieee80211_node *ni, struct ieee80211_tx_ampdu *tap) { - struct mwl_softc *sc = ni->ni_ic->ic_ifp->if_softc; + struct mwl_softc *sc = ni->ni_ic->ic_softc; struct mwl_bastate *bas; bas = tap->txa_private; @@ -3934,8 +3801,7 @@ static int mwl_chan_set(struct mwl_softc *sc, struct ieee80211_channel *chan) { struct mwl_hal *mh = sc->sc_mh; - struct ifnet *ifp = sc->sc_ifp; - struct ieee80211com *ic = ifp->if_l2com; + struct ieee80211com *ic = &sc->sc_ic; MWL_HAL_CHANNEL hchan; int maxtxpow; @@ -3991,8 +3857,7 @@ mwl_chan_set(struct mwl_softc *sc, struct ieee80211_channel *chan) static void mwl_scan_start(struct ieee80211com *ic) { - struct ifnet *ifp = ic->ic_ifp; - struct mwl_softc *sc = ifp->if_softc; + struct mwl_softc *sc = ic->ic_softc; DPRINTF(sc, MWL_DEBUG_STATE, "%s\n", __func__); } @@ -4000,8 +3865,7 @@ mwl_scan_start(struct ieee80211com *ic) static void mwl_scan_end(struct ieee80211com *ic) { - struct ifnet *ifp = ic->ic_ifp; - struct mwl_softc *sc = ifp->if_softc; + struct mwl_softc *sc = ic->ic_softc; DPRINTF(sc, MWL_DEBUG_STATE, "%s\n", __func__); } @@ -4009,13 +3873,12 @@ mwl_scan_end(struct ieee80211com *ic) static void mwl_set_channel(struct ieee80211com *ic) { - struct ifnet *ifp = ic->ic_ifp; - struct mwl_softc *sc = ifp->if_softc; + struct mwl_softc *sc = ic->ic_softc; (void) mwl_chan_set(sc, ic->ic_curchan); } -/* +/* * Handle a channel switch request. We inform the firmware * and mark the global state to suppress various actions. * NB: we issue only one request to the fw; we may be called @@ -4025,7 +3888,7 @@ static void mwl_startcsa(struct ieee80211vap *vap) { struct ieee80211com *ic = vap->iv_ic; - struct mwl_softc *sc = ic->ic_ifp->if_softc; + struct mwl_softc *sc = ic->ic_softc; MWL_HAL_CHANNEL hchan; if (sc->sc_csapending) @@ -4049,7 +3912,8 @@ mwl_setanywepkey(struct ieee80211vap *vap, const uint8_t mac[IEEE80211_ADDR_LEN] IEEE80211_F_PRIVACY && vap->iv_def_txkey != IEEE80211_KEYIX_NONE && vap->iv_nw_keys[vap->iv_def_txkey].wk_keyix != IEEE80211_KEYIX_NONE) - (void) mwl_key_set(vap, &vap->iv_nw_keys[vap->iv_def_txkey], mac); + (void) _mwl_key_set(vap, &vap->iv_nw_keys[vap->iv_def_txkey], + mac); } static int @@ -4094,7 +3958,7 @@ mwl_setglobalkeys(struct ieee80211vap *vap) wk = &vap->iv_nw_keys[0]; for (; wk < &vap->iv_nw_keys[IEEE80211_WEP_NKID]; wk++) if (wk->wk_keyix != IEEE80211_KEYIX_NONE) - (void) mwl_key_set(vap, wk, vap->iv_myaddr); + (void) _mwl_key_set(vap, wk, vap->iv_myaddr); } /* @@ -4159,7 +4023,7 @@ mkpeerinfo(MWL_HAL_PEERINFO *pi, const struct ieee80211_node *ni) /* HT capabilities, etc */ pi->HTCapabilitiesInfo = ni->ni_htcap; /* XXX pi.HTCapabilitiesInfo */ - pi->MacHTParamInfo = ni->ni_htparam; + pi->MacHTParamInfo = ni->ni_htparam; pi->HTRateBitMap = get_htrate_bitmap(&ni->ni_htrates); pi->AddHtInfo.ControlChan = ni->ni_htctlchan; pi->AddHtInfo.AddChan = ni->ni_ht2ndchan; @@ -4226,8 +4090,7 @@ mwl_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg) struct mwl_hal_vap *hvap = mvp->mv_hvap; struct ieee80211com *ic = vap->iv_ic; struct ieee80211_node *ni = NULL; - struct ifnet *ifp = ic->ic_ifp; - struct mwl_softc *sc = ifp->if_softc; + struct mwl_softc *sc = ic->ic_softc; struct mwl_hal *mh = sc->sc_mh; enum ieee80211_state ostate = vap->iv_state; int error; @@ -4409,7 +4272,7 @@ static void mwl_newassoc(struct ieee80211_node *ni, int isnew) { struct ieee80211vap *vap = ni->ni_vap; - struct mwl_softc *sc = vap->iv_ic->ic_ifp->if_softc; + struct mwl_softc *sc = vap->iv_ic->ic_softc; struct mwl_node *mn = MWL_NODE(ni); MWL_HAL_PEERINFO pi; uint16_t aid; @@ -4465,7 +4328,7 @@ static int mwl_setregdomain(struct ieee80211com *ic, struct ieee80211_regdomain *rd, int nchan, struct ieee80211_channel chans[]) { - struct mwl_softc *sc = ic->ic_ifp->if_softc; + struct mwl_softc *sc = ic->ic_softc; struct mwl_hal *mh = sc->sc_mh; const MWL_HAL_CHANNELINFO *ci; int i; @@ -4483,12 +4346,12 @@ mwl_setregdomain(struct ieee80211com *ic, struct ieee80211_regdomain *rd, IEEE80211_IS_CHAN_HT40(c) ? MWL_CH_40_MHz_WIDTH : MWL_CH_20_MHz_WIDTH, &ci); } else { - if_printf(ic->ic_ifp, + device_printf(sc->sc_dev, "%s: channel %u freq %u/0x%x not 2.4/5GHz\n", __func__, c->ic_ieee, c->ic_freq, c->ic_flags); return EINVAL; } - /* + /* * Verify channel has cal data and cap tx power. */ hc = findhalchannel(ci, c->ic_ieee); @@ -4509,7 +4372,7 @@ mwl_setregdomain(struct ieee80211com *ic, struct ieee80211_regdomain *rd, goto next; } } - if_printf(ic->ic_ifp, + device_printf(sc->sc_dev, "%s: no cal data for channel %u ext %u freq %u/0x%x\n", __func__, c->ic_ieee, c->ic_extieee, c->ic_freq, c->ic_flags); @@ -4523,114 +4386,34 @@ mwl_setregdomain(struct ieee80211com *ic, struct ieee80211_regdomain *rd, #define IEEE80211_CHAN_HTG (IEEE80211_CHAN_HT|IEEE80211_CHAN_G) #define IEEE80211_CHAN_HTA (IEEE80211_CHAN_HT|IEEE80211_CHAN_A) -static void -addchan(struct ieee80211_channel *c, int freq, int flags, int ieee, int txpow) -{ - c->ic_freq = freq; - c->ic_flags = flags; - c->ic_ieee = ieee; - c->ic_minpower = 0; - c->ic_maxpower = 2*txpow; - c->ic_maxregpower = txpow; -} - -static const struct ieee80211_channel * -findchannel(const struct ieee80211_channel chans[], int nchans, - int freq, int flags) -{ - const struct ieee80211_channel *c; - int i; - - for (i = 0; i < nchans; i++) { - c = &chans[i]; - if (c->ic_freq == freq && c->ic_flags == flags) - return c; - } - return NULL; -} - static void addht40channels(struct ieee80211_channel chans[], int maxchans, int *nchans, const MWL_HAL_CHANNELINFO *ci, int flags) { - struct ieee80211_channel *c; - const struct ieee80211_channel *extc; - const struct mwl_hal_channel *hc; - int i; + int i, error; - c = &chans[*nchans]; - - flags &= ~IEEE80211_CHAN_HT; for (i = 0; i < ci->nchannels; i++) { - /* - * Each entry defines an HT40 channel pair; find the - * extension channel above and the insert the pair. - */ - hc = &ci->channels[i]; - extc = findchannel(chans, *nchans, hc->freq+20, - flags | IEEE80211_CHAN_HT20); - if (extc != NULL) { - if (*nchans >= maxchans) - break; - addchan(c, hc->freq, flags | IEEE80211_CHAN_HT40U, - hc->ieee, hc->maxTxPow); - c->ic_extieee = extc->ic_ieee; - c++, (*nchans)++; - if (*nchans >= maxchans) - break; - addchan(c, extc->ic_freq, flags | IEEE80211_CHAN_HT40D, - extc->ic_ieee, hc->maxTxPow); - c->ic_extieee = hc->ieee; - c++, (*nchans)++; - } + const struct mwl_hal_channel *hc = &ci->channels[i]; + + error = ieee80211_add_channel_ht40(chans, maxchans, nchans, + hc->ieee, hc->maxTxPow, flags); + if (error != 0 && error != ENOENT) + break; } } static void addchannels(struct ieee80211_channel chans[], int maxchans, int *nchans, - const MWL_HAL_CHANNELINFO *ci, int flags) + const MWL_HAL_CHANNELINFO *ci, const uint8_t bands[]) { - struct ieee80211_channel *c; - int i; + int i, error; - c = &chans[*nchans]; + error = 0; + for (i = 0; i < ci->nchannels && error == 0; i++) { + const struct mwl_hal_channel *hc = &ci->channels[i]; - for (i = 0; i < ci->nchannels; i++) { - const struct mwl_hal_channel *hc; - - hc = &ci->channels[i]; - if (*nchans >= maxchans) - break; - addchan(c, hc->freq, flags, hc->ieee, hc->maxTxPow); - c++, (*nchans)++; - if (flags == IEEE80211_CHAN_G || flags == IEEE80211_CHAN_HTG) { - /* g channel have a separate b-only entry */ - if (*nchans >= maxchans) - break; - c[0] = c[-1]; - c[-1].ic_flags = IEEE80211_CHAN_B; - c++, (*nchans)++; - } - if (flags == IEEE80211_CHAN_HTG) { - /* HT g channel have a separate g-only entry */ - if (*nchans >= maxchans) - break; - c[-1].ic_flags = IEEE80211_CHAN_G; - c[0] = c[-1]; - c[0].ic_flags &= ~IEEE80211_CHAN_HT; - c[0].ic_flags |= IEEE80211_CHAN_HT20; /* HT20 */ - c++, (*nchans)++; - } - if (flags == IEEE80211_CHAN_HTA) { - /* HT a channel have a separate a-only entry */ - if (*nchans >= maxchans) - break; - c[-1].ic_flags = IEEE80211_CHAN_A; - c[0] = c[-1]; - c[0].ic_flags &= ~IEEE80211_CHAN_HT; - c[0].ic_flags |= IEEE80211_CHAN_HT20; /* HT20 */ - c++, (*nchans)++; - } + error = ieee80211_add_channel(chans, maxchans, nchans, + hc->ieee, hc->freq, hc->maxTxPow, 0, bands); } } @@ -4639,6 +4422,7 @@ getchannels(struct mwl_softc *sc, int maxchans, int *nchans, struct ieee80211_channel chans[]) { const MWL_HAL_CHANNELINFO *ci; + uint8_t bands[IEEE80211_MODE_BYTES]; /* * Use the channel info from the hal to craft the @@ -4648,11 +4432,20 @@ getchannels(struct mwl_softc *sc, int maxchans, int *nchans, */ *nchans = 0; if (mwl_hal_getchannelinfo(sc->sc_mh, - MWL_FREQ_BAND_2DOT4GHZ, MWL_CH_20_MHz_WIDTH, &ci) == 0) - addchannels(chans, maxchans, nchans, ci, IEEE80211_CHAN_HTG); + MWL_FREQ_BAND_2DOT4GHZ, MWL_CH_20_MHz_WIDTH, &ci) == 0) { + memset(bands, 0, sizeof(bands)); + setbit(bands, IEEE80211_MODE_11B); + setbit(bands, IEEE80211_MODE_11G); + setbit(bands, IEEE80211_MODE_11NG); + addchannels(chans, maxchans, nchans, ci, bands); + } if (mwl_hal_getchannelinfo(sc->sc_mh, - MWL_FREQ_BAND_5GHZ, MWL_CH_20_MHz_WIDTH, &ci) == 0) - addchannels(chans, maxchans, nchans, ci, IEEE80211_CHAN_HTA); + MWL_FREQ_BAND_5GHZ, MWL_CH_20_MHz_WIDTH, &ci) == 0) { + memset(bands, 0, sizeof(bands)); + setbit(bands, IEEE80211_MODE_11A); + setbit(bands, IEEE80211_MODE_11NA); + addchannels(chans, maxchans, nchans, ci, bands); + } if (mwl_hal_getchannelinfo(sc->sc_mh, MWL_FREQ_BAND_2DOT4GHZ, MWL_CH_40_MHz_WIDTH, &ci) == 0) addht40channels(chans, maxchans, nchans, ci, IEEE80211_CHAN_HTG); @@ -4665,7 +4458,7 @@ static void mwl_getradiocaps(struct ieee80211com *ic, int maxchans, int *nchans, struct ieee80211_channel chans[]) { - struct mwl_softc *sc = ic->ic_ifp->if_softc; + struct mwl_softc *sc = ic->ic_softc; getchannels(sc, maxchans, nchans, chans); } @@ -4673,8 +4466,7 @@ mwl_getradiocaps(struct ieee80211com *ic, static int mwl_getchannels(struct mwl_softc *sc) { - struct ifnet *ifp = sc->sc_ifp; - struct ieee80211com *ic = ifp->if_l2com; + struct ieee80211com *ic = &sc->sc_ic; /* * Use the channel info from the hal to craft the @@ -4702,11 +4494,10 @@ mwl_printrxbuf(const struct mwl_rxbuf *bf, u_int ix) const struct mwl_rxdesc *ds = bf->bf_desc; uint32_t status = le32toh(ds->Status); - printf("R[%2u] (DS.V:%p DS.P:%p) NEXT:%08x DATA:%08x RC:%02x%s\n" + printf("R[%2u] (DS.V:%p DS.P:0x%jx) NEXT:%08x DATA:%08x RC:%02x%s\n" " STAT:%02x LEN:%04x RSSI:%02x CHAN:%02x RATE:%02x QOS:%04x HT:%04x\n", - ix, ds, (const struct mwl_desc *)bf->bf_daddr, - le32toh(ds->pPhysNext), le32toh(ds->pPhysBuffData), - ds->RxControl, + ix, ds, (uintmax_t)bf->bf_daddr, le32toh(ds->pPhysNext), + le32toh(ds->pPhysBuffData), ds->RxControl, ds->RxControl != EAGLE_RXD_CTRL_DRIVER_OWN ? "" : (status & EAGLE_RXD_STATUS_OK) ? " *" : " !", ds->Status, le16toh(ds->PktLen), ds->RSSI, ds->Channel, @@ -4720,8 +4511,7 @@ mwl_printtxbuf(const struct mwl_txbuf *bf, u_int qnum, u_int ix) uint32_t status = le32toh(ds->Status); printf("Q%u[%3u]", qnum, ix); - printf(" (DS.V:%p DS.P:%p)\n", - ds, (const struct mwl_txdesc *)bf->bf_daddr); + printf(" (DS.V:%p DS.P:0x%jx)\n", ds, (uintmax_t)bf->bf_daddr); printf(" NEXT:%08x DATA:%08x LEN:%04x STAT:%08x%s\n", le32toh(ds->pPhysNext), le32toh(ds->PktPtr), le16toh(ds->PktLen), status, @@ -4781,25 +4571,24 @@ mwl_txq_dump(struct mwl_txq *txq) static void mwl_watchdog(void *arg) { - struct mwl_softc *sc; - struct ifnet *ifp; + struct mwl_softc *sc = arg; - sc = arg; callout_reset(&sc->sc_watchdog, hz, mwl_watchdog, sc); if (sc->sc_tx_timer == 0 || --sc->sc_tx_timer > 0) return; - ifp = sc->sc_ifp; - if ((ifp->if_drv_flags & IFF_DRV_RUNNING) && !sc->sc_invalid) { + if (sc->sc_running && !sc->sc_invalid) { if (mwl_hal_setkeepalive(sc->sc_mh)) - if_printf(ifp, "transmit timeout (firmware hung?)\n"); + device_printf(sc->sc_dev, + "transmit timeout (firmware hung?)\n"); else - if_printf(ifp, "transmit timeout\n"); + device_printf(sc->sc_dev, + "transmit timeout\n"); #if 0 - mwl_reset(ifp); + mwl_reset(sc); mwl_txq_dump(&sc->sc_txq[0]);/*XXX*/ #endif - ifp->if_oerrors++; + counter_u64_add(sc->sc_ic.ic_oerrors, 1); sc->sc_stats.mst_watchdog++; } } @@ -4809,7 +4598,7 @@ mwl_txq_dump(&sc->sc_txq[0]);/*XXX*/ * Diagnostic interface to the HAL. This is used by various * tools to do things like retrieve register contents for * debugging. The mechanism is intentionally opaque so that - * it can change frequently w/o concern for compatiblity. + * it can change frequently w/o concern for compatibility. */ static int mwl_ioctl_diag(struct mwl_softc *sc, struct mwl_diag *md) @@ -4898,28 +4687,22 @@ mwl_ioctl_reset(struct mwl_softc *sc, struct mwl_diag *md) } #endif /* MWL_DIAGAPI */ -static int -mwl_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) +static void +mwl_parent(struct ieee80211com *ic) { -#define IS_RUNNING(ifp) \ - ((ifp->if_flags & IFF_UP) && (ifp->if_drv_flags & IFF_DRV_RUNNING)) - struct mwl_softc *sc = ifp->if_softc; - struct ieee80211com *ic = ifp->if_l2com; - struct ifreq *ifr = (struct ifreq *)data; - int error = 0, startall; + struct mwl_softc *sc = ic->ic_softc; + int startall = 0; - switch (cmd) { - case SIOCSIFFLAGS: - MWL_LOCK(sc); - startall = 0; - if (IS_RUNNING(ifp)) { + MWL_LOCK(sc); + if (ic->ic_nrunning > 0) { + if (sc->sc_running) { /* * To avoid rescanning another access point, * do not call mwl_init() here. Instead, * only reflect promisc mode settings. */ mwl_mode_init(sc); - } else if (ifp->if_flags & IFF_UP) { + } else { /* * Beware of being called during attach/detach * to reset promiscuous mode. In that case we @@ -4930,28 +4713,42 @@ mwl_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) * probably a better way to deal with this. */ if (!sc->sc_invalid) { - mwl_init_locked(sc); /* XXX lose error */ + mwl_init(sc); /* XXX lose error */ startall = 1; } - } else - mwl_stop_locked(ifp, 1); - MWL_UNLOCK(sc); - if (startall) - ieee80211_start_all(ic); - break; + } + } else + mwl_stop(sc); + MWL_UNLOCK(sc); + if (startall) + ieee80211_start_all(ic); +} + +static int +mwl_ioctl(struct ieee80211com *ic, u_long cmd, void *data) +{ + struct mwl_softc *sc = ic->ic_softc; + struct ifreq *ifr = data; + int error = 0; + + switch (cmd) { case SIOCGMVSTATS: mwl_hal_gethwstats(sc->sc_mh, &sc->sc_stats.hw_stats); +#if 0 /* NB: embed these numbers to get a consistent view */ - sc->sc_stats.mst_tx_packets = ifp->if_opackets; - sc->sc_stats.mst_rx_packets = ifp->if_ipackets; + sc->sc_stats.mst_tx_packets = + ifp->if_get_counter(ifp, IFCOUNTER_OPACKETS); + sc->sc_stats.mst_rx_packets = + ifp->if_get_counter(ifp, IFCOUNTER_IPACKETS); +#endif /* * NB: Drop the softc lock in case of a page fault; * we'll accept any potential inconsisentcy in the * statistics. The alternative is to copy the data * to a local structure. */ - return copyout(&sc->sc_stats, - ifr->ifr_data, sizeof (sc->sc_stats)); + return (copyout(&sc->sc_stats, + ifr->ifr_data, sizeof (sc->sc_stats))); #ifdef MWL_DIAGAPI case SIOCGMVDIAG: /* XXX check privs */ @@ -4959,22 +4756,15 @@ mwl_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) case SIOCGMVRESET: /* XXX check privs */ MWL_LOCK(sc); - error = mwl_ioctl_reset(sc,(struct mwl_diag *) ifr); + error = mwl_ioctl_reset(sc,(struct mwl_diag *) ifr); MWL_UNLOCK(sc); break; #endif /* MWL_DIAGAPI */ - case SIOCGIFMEDIA: - error = ifmedia_ioctl(ifp, ifr, &ic->ic_media, cmd); - break; - case SIOCGIFADDR: - error = ether_ioctl(ifp, cmd, data); - break; default: - error = EINVAL; + error = ENOTTY; break; } - return error; -#undef IS_RUNNING + return (error); } #ifdef MWL_DEBUG @@ -5014,9 +4804,8 @@ mwl_sysctlattach(struct mwl_softc *sc) static void mwl_announce(struct mwl_softc *sc) { - struct ifnet *ifp = sc->sc_ifp; - if_printf(ifp, "Rev A%d hardware, v%d.%d.%d.%d firmware (regioncode %d)\n", + device_printf(sc->sc_dev, "Rev A%d hardware, v%d.%d.%d.%d firmware (regioncode %d)\n", sc->sc_hwspecs.hwVersion, (sc->sc_hwspecs.fwReleaseNumber>>24) & 0xff, (sc->sc_hwspecs.fwReleaseNumber>>16) & 0xff, @@ -5029,20 +4818,20 @@ mwl_announce(struct mwl_softc *sc) int i; for (i = 0; i <= WME_AC_VO; i++) { struct mwl_txq *txq = sc->sc_ac2q[i]; - if_printf(ifp, "Use hw queue %u for %s traffic\n", + device_printf(sc->sc_dev, "Use hw queue %u for %s traffic\n", txq->qnum, ieee80211_wme_acnames[i]); } } if (bootverbose || mwl_rxdesc != MWL_RXDESC) - if_printf(ifp, "using %u rx descriptors\n", mwl_rxdesc); + device_printf(sc->sc_dev, "using %u rx descriptors\n", mwl_rxdesc); if (bootverbose || mwl_rxbuf != MWL_RXBUF) - if_printf(ifp, "using %u rx buffers\n", mwl_rxbuf); + device_printf(sc->sc_dev, "using %u rx buffers\n", mwl_rxbuf); if (bootverbose || mwl_txbuf != MWL_TXBUF) - if_printf(ifp, "using %u tx buffers\n", mwl_txbuf); + device_printf(sc->sc_dev, "using %u tx buffers\n", mwl_txbuf); if (bootverbose && mwl_hal_ismbsscapable(sc->sc_mh)) - if_printf(ifp, "multi-bss support\n"); + device_printf(sc->sc_dev, "multi-bss support\n"); #ifdef MWL_TX_NODROP if (bootverbose) - if_printf(ifp, "no tx drop\n"); + device_printf(sc->sc_dev, "no tx drop\n"); #endif } diff --git a/src/add-ons/kernel/drivers/network/wlan/marvell88w8363/dev/mwl/if_mwl_pci.c b/src/add-ons/kernel/drivers/network/wlan/marvell88w8363/dev/mwl/if_mwl_pci.c index d4d00dc95f..3068812a50 100644 --- a/src/add-ons/kernel/drivers/network/wlan/marvell88w8363/dev/mwl/if_mwl_pci.c +++ b/src/add-ons/kernel/drivers/network/wlan/marvell88w8363/dev/mwl/if_mwl_pci.c @@ -30,7 +30,7 @@ #include #ifdef __FreeBSD__ -__FBSDID("$FreeBSD$"); +__FBSDID("$FreeBSD: releng/11.1/sys/dev/mwl/if_mwl_pci.c 287197 2015-08-27 08:56:39Z glebius $"); #endif /* @@ -42,6 +42,8 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include #include #include @@ -52,9 +54,11 @@ __FBSDID("$FreeBSD$"); #include +#include #include #include #include +#include #include @@ -175,9 +179,9 @@ mwl_pci_attach(device_t dev) BUS_SPACE_MAXADDR_32BIT, /* lowaddr */ BUS_SPACE_MAXADDR, /* highaddr */ NULL, NULL, /* filter, filterarg */ - BUS_SPACE_MAXADDR, /* maxsize */ + BUS_SPACE_MAXSIZE, /* maxsize */ MWL_TXDESC, /* nsegments */ - BUS_SPACE_MAXADDR, /* maxsegsize */ + BUS_SPACE_MAXSIZE, /* maxsegsize */ 0, /* flags */ NULL, /* lockfunc */ NULL, /* lockarg */ diff --git a/src/add-ons/kernel/drivers/network/wlan/marvell88w8363/dev/mwl/if_mwlioctl.h b/src/add-ons/kernel/drivers/network/wlan/marvell88w8363/dev/mwl/if_mwlioctl.h index e0760194c4..1ea5c72673 100644 --- a/src/add-ons/kernel/drivers/network/wlan/marvell88w8363/dev/mwl/if_mwlioctl.h +++ b/src/add-ons/kernel/drivers/network/wlan/marvell88w8363/dev/mwl/if_mwlioctl.h @@ -27,7 +27,7 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGES. * - * $FreeBSD$ + * $FreeBSD: releng/11.1/sys/dev/mwl/if_mwlioctl.h 193240 2009-06-01 18:07:01Z sam $ */ /* diff --git a/src/add-ons/kernel/drivers/network/wlan/marvell88w8363/dev/mwl/if_mwlvar.h b/src/add-ons/kernel/drivers/network/wlan/marvell88w8363/dev/mwl/if_mwlvar.h index 0c43434739..0645acd46e 100644 --- a/src/add-ons/kernel/drivers/network/wlan/marvell88w8363/dev/mwl/if_mwlvar.h +++ b/src/add-ons/kernel/drivers/network/wlan/marvell88w8363/dev/mwl/if_mwlvar.h @@ -27,7 +27,7 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGES. * - * $FreeBSD$ + * $FreeBSD: releng/11.1/sys/dev/mwl/if_mwlvar.h 298955 2016-05-03 03:41:25Z pfg $ */ /* @@ -37,6 +37,7 @@ #define _DEV_MWL_MVVAR_H #include +#include #include #include #include @@ -64,9 +65,9 @@ #define MWL_TXDESC 1 /* max tx descriptors/segments */ #endif #ifndef MWL_AGGR_SIZE -#define MWL_AGGR_SIZE 3839 /* max tx agregation size */ +#define MWL_AGGR_SIZE 3839 /* max tx aggregation size */ #endif -#define MWL_AGEINTERVAL 1 /* poke f/w every sec to age q's */ +#define MWL_AGEINTERVAL 1 /* poke f/w every sec to age q's */ #define MWL_MAXSTAID 64 /* max of 64 stations */ /* @@ -178,7 +179,7 @@ typedef STAILQ_HEAD(, mwl_rxbuf) mwl_rxbufhead; * to identify which BA stream to use (assigning the h/w q to * the TxPriority field of the descriptor). * - * NB: Each station may have at most MWL_MAXBA streams at one time. + * NB: Each station may have at most MWL_MAXBA streams at one time. */ struct mwl_bastate { uint16_t qos; /* QoS ctl for BA stream */ @@ -187,10 +188,10 @@ struct mwl_bastate { }; static __inline__ void -mwl_bastream_setup(struct mwl_bastate *bas, int ac, int txq) +mwl_bastream_setup(struct mwl_bastate *bas, int tid, int txq) { bas->txq = txq; - bas->qos = htole16(WME_AC_TO_TID(ac) | IEEE80211_QOS_ACKPOLICY_BA); + bas->qos = htole16(tid | IEEE80211_QOS_ACKPOLICY_BA); } static __inline__ void @@ -244,7 +245,8 @@ struct mwl_vap { #define MWL_VAP_CONST(vap) ((const struct mwl_vap *)(vap)) struct mwl_softc { - struct ifnet *sc_ifp; /* interface common */ + struct ieee80211com sc_ic; + struct mbufq sc_snd; struct mwl_stats sc_stats; /* interface statistics */ int sc_debug; device_t sc_dev; @@ -257,7 +259,8 @@ struct mwl_softc { struct taskqueue *sc_tq; /* private task queue */ struct callout sc_watchdog; int sc_tx_timer; - unsigned int sc_invalid : 1, /* disable hardware accesses */ + unsigned int sc_running : 1, + sc_invalid : 1, /* disable hardware accesses */ sc_recvsetup:1, /* recv setup */ sc_csapending:1,/* 11h channel switch pending */ sc_radarena : 1,/* radar detection enabled */ diff --git a/src/add-ons/kernel/drivers/network/wlan/marvell88w8363/dev/mwl/mwldiag.h b/src/add-ons/kernel/drivers/network/wlan/marvell88w8363/dev/mwl/mwldiag.h index 65c8eb5941..8e57c87ac2 100644 --- a/src/add-ons/kernel/drivers/network/wlan/marvell88w8363/dev/mwl/mwldiag.h +++ b/src/add-ons/kernel/drivers/network/wlan/marvell88w8363/dev/mwl/mwldiag.h @@ -27,7 +27,7 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGES. * - * $FreeBSD$ + * $FreeBSD: releng/11.1/sys/dev/mwl/mwldiag.h 193240 2009-06-01 18:07:01Z sam $ */ #ifndef _MWL_DIAG_H_ diff --git a/src/add-ons/kernel/drivers/network/wlan/marvell88w8363/dev/mwl/mwlhal.c b/src/add-ons/kernel/drivers/network/wlan/marvell88w8363/dev/mwl/mwlhal.c index 55870afafc..cf60b4de59 100644 --- a/src/add-ons/kernel/drivers/network/wlan/marvell88w8363/dev/mwl/mwlhal.c +++ b/src/add-ons/kernel/drivers/network/wlan/marvell88w8363/dev/mwl/mwlhal.c @@ -27,11 +27,11 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGES. * - * $FreeBSD$ + * $FreeBSD: releng/11.1/sys/dev/mwl/mwlhal.c 300077 2016-05-17 20:53:56Z avos $ */ #include -#include +#include #include #include #include @@ -309,21 +309,14 @@ mwl_hal_attach(device_t dev, uint16_t devid, NULL, /* lockarg */ &mh->mh_dmat); if (error != 0) { - device_printf(dev, "unable to allocate memory for cmd buffer, " + device_printf(dev, "unable to allocate memory for cmd tag, " "error %u\n", error); goto fail0; } /* allocate descriptors */ - error = bus_dmamap_create(mh->mh_dmat, BUS_DMA_NOWAIT, &mh->mh_dmamap); - if (error != 0) { - device_printf(dev, "unable to create dmamap for cmd buffers, " - "error %u\n", error); - goto fail0; - } - error = bus_dmamem_alloc(mh->mh_dmat, (void**) &mh->mh_cmdbuf, - BUS_DMA_NOWAIT | BUS_DMA_COHERENT, + BUS_DMA_NOWAIT | BUS_DMA_COHERENT, &mh->mh_dmamap); if (error != 0) { device_printf(dev, "unable to allocate memory for cmd buffer, " @@ -365,9 +358,8 @@ mwl_hal_attach(device_t dev, uint16_t devid, fail2: bus_dmamem_free(mh->mh_dmat, mh->mh_cmdbuf, mh->mh_dmamap); fail1: - bus_dmamap_destroy(mh->mh_dmat, mh->mh_dmamap); -fail0: bus_dma_tag_destroy(mh->mh_dmat); +fail0: mtx_destroy(&mh->mh_mtx); free(mh, M_DEVBUF); return NULL; @@ -379,7 +371,6 @@ mwl_hal_detach(struct mwl_hal *mh0) struct mwl_hal_priv *mh = MWLPRIV(mh0); bus_dmamem_free(mh->mh_dmat, mh->mh_cmdbuf, mh->mh_dmamap); - bus_dmamap_destroy(mh->mh_dmat, mh->mh_dmamap); bus_dma_tag_destroy(mh->mh_dmat); mtx_destroy(&mh->mh_mtx); free(mh, M_DEVBUF); @@ -850,7 +841,7 @@ mwl_hal_setradardetection(struct mwl_hal *mh0, MWL_HAL_RADAR action) retval = mwlExecuteCmd(mh, HostCmd_CMD_802_11H_DETECT_RADAR); MWL_HAL_UNLOCK(mh); return retval; -} +} /* * Convert public channel flags definition to a @@ -1000,7 +991,7 @@ mwl_hal_settxrate(struct mwl_hal_vap *vap, MWL_HAL_TXRATE_HANDLING handling, n++; } pCmd->EntryCount = htole32(n); - } else + } else pCmd->Action = htole32(HostCmd_ACT_NOT_USE_FIXED_RATE); retval = mwlExecuteCmd(mh, HostCmd_CMD_SET_FIXED_RATE); @@ -1400,7 +1391,7 @@ bastream_check_available(struct mwl_hal_vap *vap, int qid, _VCMD_SETUP(vap, pCmd, HostCmd_FW_BASTREAM, HostCmd_CMD_BASTREAM); pCmd->ActionType = htole32(BaCheckCreateStream); pCmd->BaInfo.CreateParams.BarThrs = htole32(63); - pCmd->BaInfo.CreateParams.WindowSize = htole32(64); + pCmd->BaInfo.CreateParams.WindowSize = htole32(64); pCmd->BaInfo.CreateParams.IdleThrs = htole32(0x22000); IEEE80211_ADDR_COPY(&pCmd->BaInfo.CreateParams.PeerMacAddr[0], Macaddr); pCmd->BaInfo.CreateParams.DialogToken = 10; @@ -1460,7 +1451,7 @@ mwl_hal_bastream_alloc(struct mwl_hal_vap *vap, int ba_policy, sp->setup = 0; sp->ba_policy = ba_policy; MWL_HAL_UNLOCK(mh); - return sp != NULL ? &sp->public : NULL; + return &sp->public; } const MWL_HAL_BASTREAM * @@ -1584,7 +1575,7 @@ mwl_hal_bastream_get_seqno(struct mwl_hal *mh0, *pseqno = le16toh(pCmd->SeqNo); MWL_HAL_UNLOCK(mh); return retval; -} +} int mwl_hal_getwatchdogbitmap(struct mwl_hal *mh0, uint8_t bitmap[1]) @@ -1626,7 +1617,7 @@ mwl_hal_setaggampduratemode(struct mwl_hal *mh0, int mode, int threshold) pCmd->Threshold = htole32(threshold); retval = mwlExecuteCmd(mh, HostCmd_CMD_AMPDU_RETRY_RATEDROP_MODE); - MWL_HAL_UNLOCK(mh); + MWL_HAL_UNLOCK(mh); return retval; } @@ -1643,7 +1634,7 @@ mwl_hal_getaggampduratemode(struct mwl_hal *mh0, int *mode, int *threshold) pCmd->Action = htole16(0); retval = mwlExecuteCmd(mh, HostCmd_CMD_AMPDU_RETRY_RATEDROP_MODE); - MWL_HAL_UNLOCK(mh); + MWL_HAL_UNLOCK(mh); *mode = le32toh(pCmd->Option); *threshold = le32toh(pCmd->Threshold); return retval; @@ -1665,7 +1656,7 @@ mwl_hal_setcfend(struct mwl_hal *mh0, int ena) pCmd->Enable = htole32(ena); retval = mwlExecuteCmd(mh, HostCmd_CMD_CFEND_ENABLE); - MWL_HAL_UNLOCK(mh); + MWL_HAL_UNLOCK(mh); return retval; } @@ -1701,7 +1692,7 @@ cvtPeerInfo(PeerInfo_t *to, const MWL_HAL_PEERINFO *from) /* XXX station id must be in [0..63] */ int mwl_hal_newstation(struct mwl_hal_vap *vap, - const uint8_t addr[IEEE80211_ADDR_LEN], uint16_t aid, uint16_t sid, + const uint8_t addr[IEEE80211_ADDR_LEN], uint16_t aid, uint16_t sid, const MWL_HAL_PEERINFO *peer, int isQosSta, int wmeInfo) { struct mwl_hal_priv *mh = MWLVAP(vap); @@ -2022,7 +2013,7 @@ mwlGetCalTable(struct mwl_hal_priv *mh, uint8_t annex, uint8_t index) pCmd->calTbl[0] != annex && annex != 0 && annex != 255) retval = EIO; return retval; -} +} /* * Calculate the max tx power from the channel's cal data. @@ -2227,7 +2218,7 @@ mwl_hal_GetBeacon(struct mwl_hal *mh0, uint8_t *pBcn, uint16_t *pLen) } MWL_HAL_UNLOCK(mh); return retval; -} +} int mwl_hal_SetRifs(struct mwl_hal *mh0, uint8_t QNum) @@ -2439,9 +2430,9 @@ mwlExecuteCmd(struct mwl_hal_priv *mh, unsigned short cmd) /* * Firmware download support. */ -#define FW_DOWNLOAD_BLOCK_SIZE 256 +#define FW_DOWNLOAD_BLOCK_SIZE 256 #define FW_CHECK_USECS (5*1000) /* 5ms */ -#define FW_MAX_NUM_CHECKS 200 +#define FW_MAX_NUM_CHECKS 200 #if 0 /* XXX read f/w from file */ diff --git a/src/add-ons/kernel/drivers/network/wlan/marvell88w8363/dev/mwl/mwlhal.h b/src/add-ons/kernel/drivers/network/wlan/marvell88w8363/dev/mwl/mwlhal.h index 25b8b07c48..2f5dc95ec8 100644 --- a/src/add-ons/kernel/drivers/network/wlan/marvell88w8363/dev/mwl/mwlhal.h +++ b/src/add-ons/kernel/drivers/network/wlan/marvell88w8363/dev/mwl/mwlhal.h @@ -27,7 +27,7 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGES. * - * $FreeBSD$ + * $FreeBSD: releng/11.1/sys/dev/mwl/mwlhal.h 298915 2016-05-02 04:15:15Z adrian $ */ #ifndef _MWL_HAL_H_ @@ -71,15 +71,13 @@ enum { MWL_WME_AC_VO = 3, /* voice access category */ }; -struct device; - struct mwl_hal { bus_space_handle_t mh_ioh; /* BAR 1 copied from softc */ bus_space_tag_t mh_iot; uint32_t mh_imask; /* interrupt mask */ /* remainder is opaque to driver */ }; -struct mwl_hal *mwl_hal_attach(struct device *dev, uint16_t devid, +struct mwl_hal *mwl_hal_attach(device_t dev, uint16_t devid, bus_space_handle_t ioh, bus_space_tag_t iot, bus_dma_tag_t tag); void mwl_hal_detach(struct mwl_hal *); diff --git a/src/add-ons/kernel/drivers/network/wlan/marvell88w8363/dev/mwl/mwlreg.h b/src/add-ons/kernel/drivers/network/wlan/marvell88w8363/dev/mwl/mwlreg.h index a8186b174e..eb82ac7e2b 100644 --- a/src/add-ons/kernel/drivers/network/wlan/marvell88w8363/dev/mwl/mwlreg.h +++ b/src/add-ons/kernel/drivers/network/wlan/marvell88w8363/dev/mwl/mwlreg.h @@ -27,7 +27,7 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGES. * - * $FreeBSD$ + * $FreeBSD: releng/11.1/sys/dev/mwl/mwlreg.h 195171 2009-06-29 18:42:54Z sam $ */ /*