]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - drivers/staging/brcm80211/brcmsmac/wlc_main.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6
[karo-tx-linux.git] / drivers / staging / brcm80211 / brcmsmac / wlc_main.c
similarity index 88%
rename from drivers/staging/brcm80211/sys/wlc_mac80211.c
rename to drivers/staging/brcm80211/brcmsmac/wlc_main.c
index aa12d1a65184d97c81639e0dcec4b439101c0390..639b5d7c9603214e182948f4bd0444f12ea3948a 100644 (file)
 #include <linux/kernel.h>
 #include <linux/ctype.h>
 #include <linux/etherdevice.h>
+#include <net/mac80211.h>
+
 #include <bcmdefs.h>
 #include <bcmdevs.h>
-#include <wlc_cfg.h>
-#include <osl.h>
 #include <bcmutils.h>
 #include <bcmwifi.h>
 #include <siutils.h>
-#include <bcmendian.h>
-#include <proto/wpa.h>
 #include <pcicfg.h>
 #include <bcmsrom.h>
 #include <wlioctl.h>
-#include <sbhndpio.h>
 #include <sbhnddma.h>
 #include <hnddma.h>
 #include <hndpmu.h>
-#include <d11.h>
-#include <wlc_rate.h>
-#include <wlc_pub.h>
-#include <wlc_key.h>
-#include <wlc_bsscfg.h>
-#include <wlc_channel.h>
-#include <wlc_event.h>
-#include <wlc_mac80211.h>
-#include <wlc_bmac.h>
-#include <wlc_scb.h>
-#include <wlc_phy_hal.h>
-#include <wlc_phy_shim.h>
-#include <wlc_antsel.h>
-#include <wlc_stf.h>
-#include <wlc_ampdu.h>
-#include <wlc_event.h>
-#include <wl_export.h>
-#include "d11ucode_ext.h"
-#include <wlc_alloc.h>
-#include <net/mac80211.h>
-#include <wl_dbg.h>
 
+#include "d11.h"
+#include "wlc_types.h"
+#include "wlc_cfg.h"
+#include "wlc_rate.h"
+#include "wlc_scb.h"
+#include "wlc_pub.h"
+#include "wlc_key.h"
+#include "wlc_bsscfg.h"
+#include "phy/wlc_phy_hal.h"
+#include "wlc_channel.h"
+#include "wlc_main.h"
+#include "wlc_bmac.h"
+#include "wlc_phy_hal.h"
+#include "wlc_phy_shim.h"
+#include "wlc_antsel.h"
+#include "wlc_stf.h"
+#include "wlc_ampdu.h"
+#include "wl_export.h"
+#include "wlc_alloc.h"
+#include "wl_dbg.h"
+
+/*
+ *     Disable statistics counting for WME
+ */
+#define WLCNTSET(a, b)
+#define WLCNTINCR(a)
+#define WLCNTADD(a, b)
+
+/*
+ * WPA(2) definitions
+ */
+#define RSN_CAP_4_REPLAY_CNTRS         2
+#define RSN_CAP_16_REPLAY_CNTRS                3
+
+#define WPA_CAP_4_REPLAY_CNTRS         RSN_CAP_4_REPLAY_CNTRS
+#define WPA_CAP_16_REPLAY_CNTRS                RSN_CAP_16_REPLAY_CNTRS
+
+/*
+ * Indication for txflowcontrol that all priority bits in
+ * TXQ_STOP_FOR_PRIOFC_MASK are to be considered.
+ */
+#define ALLPRIO                -1
 
 /*
  * buffer length needed for wlc_format_ssid
  * 32 SSID chars, max of 4 chars for each SSID char "\xFF", plus NULL.
  */
-#define SSID_FMT_BUF_LEN       ((4 * DOT11_MAX_SSID_LEN) + 1)
+#define SSID_FMT_BUF_LEN       ((4 * IEEE80211_MAX_SSID_LEN) + 1)
 
 #define        TIMER_INTERVAL_WATCHDOG 1000    /* watchdog timer, in unit of ms */
 #define        TIMER_INTERVAL_RADIOCHK 800     /* radio monitor timer, in unit of ms */
@@ -132,16 +150,17 @@ static struct wlc_info *wlc_info_dbg = (struct wlc_info *) (NULL);
  */
 enum {
        IOV_MPC = 1,
+       IOV_RTSTHRESH,
        IOV_QTXPOWER,
        IOV_BCN_LI_BCN,         /* Beacon listen interval in # of beacons */
        IOV_LAST                /* In case of a need to check max ID number */
 };
 
 const bcm_iovar_t wlc_iovars[] = {
-       {"mpc", IOV_MPC, (IOVF_OPEN_ALLOW), IOVT_BOOL, 0},
-       {"qtxpower", IOV_QTXPOWER, (IOVF_WHL | IOVF_OPEN_ALLOW), IOVT_UINT32,
-        0},
-       {"bcn_li_bcn", IOV_BCN_LI_BCN, 0, IOVT_UINT8, 0},
+       {"mpc", IOV_MPC, (0), IOVT_BOOL, 0},
+       {"rtsthresh", IOV_RTSTHRESH, (IOVF_WHL), IOVT_UINT16, 0},
+       {"qtxpower", IOV_QTXPOWER, (IOVF_WHL), IOVT_UINT32, 0},
+       {"bcn_li_bcn", IOV_BCN_LI_BCN, (0), IOVT_UINT8, 0},
        {NULL, 0, 0, 0, 0}
 };
 
@@ -205,7 +224,8 @@ static bool in_send_q = false;
 #ifdef BCMDBG
 static const char *fifo_names[] = {
        "AC_BK", "AC_BE", "AC_VI", "AC_VO", "BCMC", "ATIM" };
-const char *aci_names[] = { "AC_BE", "AC_BK", "AC_VI", "AC_VO" };
+#else
+static const char fifo_names[6][0];
 #endif
 
 static const u8 acbitmap2maxprio[] = {
@@ -231,6 +251,7 @@ static u16 BCMFASTPATH wlc_d11hdrs_mac80211(struct wlc_info *wlc,
                                               wsec_key_t *key,
                                               ratespec_t rspec_override);
 
+static void wlc_ctrupd_cache(u16 cur_stat, u16 *macstat_snapshot, u32 *macstat);
 static void wlc_bss_default_init(struct wlc_info *wlc);
 static void wlc_ucode_mac_upd(struct wlc_info *wlc);
 static ratespec_t mac80211_wlc_set_nrate(struct wlc_info *wlc,
@@ -238,17 +259,18 @@ static ratespec_t mac80211_wlc_set_nrate(struct wlc_info *wlc,
 static void wlc_tx_prec_map_init(struct wlc_info *wlc);
 static void wlc_watchdog(void *arg);
 static void wlc_watchdog_by_timer(void *arg);
+static u16 wlc_rate_shm_offset(struct wlc_info *wlc, u8 rate);
 static int wlc_set_rateset(struct wlc_info *wlc, wlc_rateset_t *rs_arg);
 static int wlc_iovar_rangecheck(struct wlc_info *wlc, u32 val,
                                const bcm_iovar_t *vi);
 static u8 wlc_local_constraint_qdbm(struct wlc_info *wlc);
 
 /* send and receive */
-static wlc_txq_info_t *wlc_txq_alloc(struct wlc_info *wlc,
-                                    struct osl_info *osh);
-static void wlc_txq_free(struct wlc_info *wlc, struct osl_info *osh,
-                        wlc_txq_info_t *qi);
-static void wlc_txflowcontrol_signal(struct wlc_info *wlc, wlc_txq_info_t *qi,
+static struct wlc_txq_info *wlc_txq_alloc(struct wlc_info *wlc);
+static void wlc_txq_free(struct wlc_info *wlc,
+                        struct wlc_txq_info *qi);
+static void wlc_txflowcontrol_signal(struct wlc_info *wlc,
+                                    struct wlc_txq_info *qi,
                                     bool on, int prio);
 static void wlc_txflowcontrol_reset(struct wlc_info *wlc);
 static u16 wlc_compute_airtime(struct wlc_info *wlc, ratespec_t rspec,
@@ -258,7 +280,7 @@ static void wlc_compute_ofdm_plcp(ratespec_t rate, uint length, u8 *plcp);
 static void wlc_compute_mimo_plcp(ratespec_t rate, uint length, u8 *plcp);
 static u16 wlc_compute_frame_dur(struct wlc_info *wlc, ratespec_t rate,
                                    u8 preamble_type, uint next_frag_len);
-static void wlc_recvctl(struct wlc_info *wlc, struct osl_info *osh,
+static void wlc_recvctl(struct wlc_info *wlc,
                        d11rxhdr_t *rxh, struct sk_buff *p);
 static uint wlc_calc_frame_len(struct wlc_info *wlc, ratespec_t rate,
                               u8 preamble_type, uint dur);
@@ -287,7 +309,6 @@ static void wlc_ht_update_sgi_rx(struct wlc_info *wlc, int val);
 static void wlc_ht_update_ldpc(struct wlc_info *wlc, s8 val);
 static void wlc_war16165(struct wlc_info *wlc, bool tx);
 
-static void wlc_process_eventq(void *arg);
 static void wlc_wme_retries_write(struct wlc_info *wlc);
 static bool wlc_attach_stf_ant_init(struct wlc_info *wlc);
 static uint wlc_attach_module(struct wlc_info *wlc);
@@ -300,30 +321,25 @@ static int _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
                      struct wlc_if *wlcif);
 
 #if defined(BCMDBG)
-void wlc_get_rcmta(struct wlc_info *wlc, int idx, struct ether_addr *addr)
+void wlc_get_rcmta(struct wlc_info *wlc, int idx, u8 *addr)
 {
        d11regs_t *regs = wlc->regs;
        u32 v32;
-       struct osl_info *osh;
 
        WL_TRACE("wl%d: %s\n", WLCWLUNIT(wlc), __func__);
 
-       ASSERT(wlc->pub->corerev > 4);
-
-       osh = wlc->osh;
-
-       W_REG(osh, &regs->objaddr, (OBJADDR_RCMTA_SEL | (idx * 2)));
-       (void)R_REG(osh, &regs->objaddr);
-       v32 = R_REG(osh, &regs->objdata);
-       addr->octet[0] = (u8) v32;
-       addr->octet[1] = (u8) (v32 >> 8);
-       addr->octet[2] = (u8) (v32 >> 16);
-       addr->octet[3] = (u8) (v32 >> 24);
-       W_REG(osh, &regs->objaddr, (OBJADDR_RCMTA_SEL | ((idx * 2) + 1)));
-       (void)R_REG(osh, &regs->objaddr);
-       v32 = R_REG(osh, (volatile u16 *)&regs->objdata);
-       addr->octet[4] = (u8) v32;
-       addr->octet[5] = (u8) (v32 >> 8);
+       W_REG(&regs->objaddr, (OBJADDR_RCMTA_SEL | (idx * 2)));
+       (void)R_REG(&regs->objaddr);
+       v32 = R_REG(&regs->objdata);
+       addr[0] = (u8) v32;
+       addr[1] = (u8) (v32 >> 8);
+       addr[2] = (u8) (v32 >> 16);
+       addr[3] = (u8) (v32 >> 24);
+       W_REG(&regs->objaddr, (OBJADDR_RCMTA_SEL | ((idx * 2) + 1)));
+       (void)R_REG(&regs->objaddr);
+       v32 = R_REG(&regs->objdata);
+       addr[4] = (u8) v32;
+       addr[5] = (u8) (v32 >> 8);
 }
 #endif                         /* defined(BCMDBG) */
 
@@ -338,7 +354,7 @@ bool wlc_stay_awake(struct wlc_info *wlc)
 bool wlc_ps_allowed(struct wlc_info *wlc)
 {
        int idx;
-       wlc_bsscfg_t *cfg;
+       struct wlc_bsscfg *cfg;
 
        /* disallow PS when one of the following global conditions meets */
        if (!wlc->pub->associated || !wlc->PMenabled || wlc->PM_override)
@@ -369,13 +385,11 @@ void wlc_reset(struct wlc_info *wlc)
        wlc->check_for_unaligned_tbtt = false;
 
        /* slurp up hw mac counters before core reset */
-       if (WLC_UPDATE_STATS(wlc)) {
-               wlc_statsupd(wlc);
+       wlc_statsupd(wlc);
 
-               /* reset our snapshot of macstat counters */
-               memset((char *)wlc->core->macstat_snapshot, 0,
-                       sizeof(macstat_t));
-       }
+       /* reset our snapshot of macstat counters */
+       memset((char *)wlc->core->macstat_snapshot, 0,
+               sizeof(macstat_t));
 
        wlc_bmac_reset(wlc->hw);
        wlc_ampdu_reset(wlc->ampdu);
@@ -423,7 +437,7 @@ void wlc_init(struct wlc_info *wlc)
        d11regs_t *regs;
        chanspec_t chanspec;
        int i;
-       wlc_bsscfg_t *bsscfg;
+       struct wlc_bsscfg *bsscfg;
        bool mute = false;
 
        WL_TRACE("wl%d: wlc_init\n", wlc->pub->unit);
@@ -441,7 +455,7 @@ void wlc_init(struct wlc_info *wlc)
        wlc_bmac_init(wlc->hw, chanspec, mute);
 
        wlc->seckeys = wlc_bmac_read_shm(wlc->hw, M_SECRXKEYS_PTR) * 2;
-       if (D11REV_GE(wlc->pub->corerev, 15) && (wlc->machwcap & MCAP_TKIPMIC))
+       if (wlc->machwcap & MCAP_TKIPMIC)
                wlc->tkmickeys =
                    wlc_bmac_read_shm(wlc->hw, M_TKMICKEYS_PTR) * 2;
 
@@ -466,11 +480,13 @@ void wlc_init(struct wlc_info *wlc)
                        if (bsscfg->up) {
                                u32 bi;
 
-                               /* get beacon period from bsscfg and convert to uS */
+                               /* get beacon period and convert to uS */
                                bi = bsscfg->current_bss->beacon_period << 10;
-                               /* update the tsf_cfprep register */
-                               /* since init path would reset to default value */
-                               W_REG(wlc->osh, &regs->tsf_cfprep,
+                               /*
+                                * update since init path would reset
+                                * to default value
+                                */
+                               W_REG(&regs->tsf_cfprep,
                                      (bi << CFPREP_CBI_SHIFT));
 
                                /* Update maccontrol PM related bits */
@@ -507,7 +523,7 @@ void wlc_init(struct wlc_info *wlc)
 
        /* Enable EDCF mode (while the MAC is suspended) */
        if (EDCF_ENAB(wlc->pub)) {
-               OR_REG(wlc->osh, &regs->ifs_ctl, IFS_USEEDCF);
+               OR_REG(&regs->ifs_ctl, IFS_USEEDCF);
                wlc_edcf_setparams(wlc->cfg, false);
        }
 
@@ -531,8 +547,7 @@ void wlc_init(struct wlc_info *wlc)
        wlc->tx_suspended = false;
 
        /* enable the RF Disable Delay timer */
-       if (D11REV_GE(wlc->pub->corerev, 10))
-               W_REG(wlc->osh, &wlc->regs->rfdisabledly, RFDISABLE_DEFAULT);
+       W_REG(&wlc->regs->rfdisabledly, RFDISABLE_DEFAULT);
 
        /* initialize mpc delay */
        wlc->mpc_delay_off = wlc->mpc_dlycnt = WLC_MPC_MIN_DELAYCNT;
@@ -541,7 +556,7 @@ void wlc_init(struct wlc_info *wlc)
         * Initialize WME parameters; if they haven't been set by some other
         * mechanism (IOVar, etc) then read them from the hardware.
         */
-       if (WLC_WME_RETRY_SHORT_GET(wlc, 0) == 0) {     /* Unintialized; read from HW */
+       if (WLC_WME_RETRY_SHORT_GET(wlc, 0) == 0) {     /* Uninitialized; read from HW */
                int ac;
 
                ASSERT(wlc->clk);
@@ -597,12 +612,13 @@ bool wlc_ps_check(struct wlc_info *wlc)
        bool wake_ok;
 
        if (!AP_ACTIVE(wlc)) {
-               volatile u32 tmp;
-               tmp = R_REG(wlc->osh, &wlc->regs->maccontrol);
+               u32 tmp;
+               tmp = R_REG(&wlc->regs->maccontrol);
 
-               /* If deviceremoved is detected, then don't take any action as this can be called
-                * in any context. Assume that caller will take care of the condition. This is just
-                * to avoid assert
+               /*
+                * If deviceremoved is detected, then don't take any action as
+                * this can be called in any context. Assume that caller will
+                * take care of the condition. This is just to avoid assert
                 */
                if (tmp == 0xffffffff) {
                        WL_ERROR("wl%d: %s: dead chip\n",
@@ -614,7 +630,7 @@ bool wlc_ps_check(struct wlc_info *wlc)
 
                if (hps != ((tmp & MCTL_HPS) != 0)) {
                        int idx;
-                       wlc_bsscfg_t *cfg;
+                       struct wlc_bsscfg *cfg;
                        WL_ERROR("wl%d: hps not sync, sw %d, maccontrol 0x%x\n",
                                 wlc->pub->unit, hps, tmp);
                        FOREACH_BSS(wlc, idx, cfg) {
@@ -652,7 +668,7 @@ void wlc_set_ps_ctrl(struct wlc_info *wlc)
        WL_TRACE("wl%d: wlc_set_ps_ctrl: hps %d wake %d\n",
                 wlc->pub->unit, hps, wake);
 
-       v1 = R_REG(wlc->osh, &wlc->regs->maccontrol);
+       v1 = R_REG(&wlc->regs->maccontrol);
        v2 = 0;
        if (hps)
                v2 |= MCTL_HPS;
@@ -672,14 +688,14 @@ void wlc_set_ps_ctrl(struct wlc_info *wlc)
  * Write this BSS config's MAC address to core.
  * Updates RXE match engine.
  */
-int wlc_set_mac(wlc_bsscfg_t *cfg)
+int wlc_set_mac(struct wlc_bsscfg *cfg)
 {
        int err = 0;
        struct wlc_info *wlc = cfg->wlc;
 
        if (cfg == wlc->cfg) {
                /* enter the MAC addr into the RXE match registers */
-               wlc_set_addrmatch(wlc, RCM_MAC_OFFSET, &cfg->cur_etheraddr);
+               wlc_set_addrmatch(wlc, RCM_MAC_OFFSET, cfg->cur_etheraddr);
        }
 
        wlc_ampdu_macaddr_upd(wlc);
@@ -690,13 +706,13 @@ int wlc_set_mac(wlc_bsscfg_t *cfg)
 /* Write the BSS config's BSSID address to core (set_bssid in d11procs.tcl).
  * Updates RXE match engine.
  */
-void wlc_set_bssid(wlc_bsscfg_t *cfg)
+void wlc_set_bssid(struct wlc_bsscfg *cfg)
 {
        struct wlc_info *wlc = cfg->wlc;
 
        /* if primary config, we need to update BSSID in RXE match registers */
        if (cfg == wlc->cfg) {
-               wlc_set_addrmatch(wlc, RCM_BSSID_OFFSET, &cfg->BSSID);
+               wlc_set_addrmatch(wlc, RCM_BSSID_OFFSET, cfg->BSSID);
        }
 #ifdef SUPPORT_HWKEYS
        else if (BSSCFG_STA(cfg) && cfg->BSS) {
@@ -712,7 +728,7 @@ void wlc_set_bssid(wlc_bsscfg_t *cfg)
 void wlc_switch_shortslot(struct wlc_info *wlc, bool shortslot)
 {
        int idx;
-       wlc_bsscfg_t *cfg;
+       struct wlc_bsscfg *cfg;
 
        ASSERT(wlc->band->gmode);
 
@@ -729,9 +745,11 @@ void wlc_switch_shortslot(struct wlc_info *wlc, bool shortslot)
        FOREACH_BSS(wlc, idx, cfg) {
                if (!cfg->associated)
                        continue;
-               cfg->current_bss->capability &= ~DOT11_CAP_SHORTSLOT;
+               cfg->current_bss->capability &=
+                                       ~WLAN_CAPABILITY_SHORT_SLOT_TIME;
                if (wlc->shortslot)
-                       cfg->current_bss->capability |= DOT11_CAP_SHORTSLOT;
+                       cfg->current_bss->capability |=
+                                       WLAN_CAPABILITY_SHORT_SLOT_TIME;
        }
 
        wlc_bmac_set_shortslot(wlc->hw, shortslot);
@@ -768,14 +786,14 @@ void wlc_set_home_chanspec(struct wlc_info *wlc, chanspec_t chanspec)
 {
        if (wlc->home_chanspec != chanspec) {
                int idx;
-               wlc_bsscfg_t *cfg;
+               struct wlc_bsscfg *cfg;
 
                wlc->home_chanspec = chanspec;
 
                FOREACH_BSS(wlc, idx, cfg) {
                        if (!cfg->associated)
                                continue;
-                       cfg->target_bss->chanspec = chanspec;
+
                        cfg->current_bss->chanspec = chanspec;
                }
 
@@ -841,8 +859,7 @@ void wlc_set_chanspec(struct wlc_info *wlc, chanspec_t chanspec)
 
        /* init antenna selection */
        if (CHSPEC_WLC_BW(old_chanspec) != CHSPEC_WLC_BW(chanspec)) {
-               if (WLANTSEL_ENAB(wlc))
-                       wlc_antsel_init(wlc->asi);
+               wlc_antsel_init(wlc->asi);
 
                /* Fix the hardware rateset based on bw.
                 * Mainly add MCS32 for 40Mhz, remove MCS 32 for 20Mhz
@@ -990,7 +1007,7 @@ static int wlc_get_current_txpwr(struct wlc_info *wlc, void *pwr, uint len)
         * or convert to a tx_power_legacy_t struct
         */
        if (!old_power) {
-               bcopy(&power, pwr, sizeof(tx_power_t));
+               memcpy(pwr, &power, sizeof(tx_power_t));
        } else {
                int band_idx = CHSPEC_IS2G(power.chanspec) ? 0 : 1;
 
@@ -1170,9 +1187,12 @@ void wlc_protection_upd(struct wlc_info *wlc, uint idx, int val)
 
 static void wlc_ht_update_sgi_rx(struct wlc_info *wlc, int val)
 {
-       wlc->ht_cap.cap &= ~(HT_CAP_SHORT_GI_20 | HT_CAP_SHORT_GI_40);
-       wlc->ht_cap.cap |= (val & WLC_N_SGI_20) ? HT_CAP_SHORT_GI_20 : 0;
-       wlc->ht_cap.cap |= (val & WLC_N_SGI_40) ? HT_CAP_SHORT_GI_40 : 0;
+       wlc->ht_cap.cap_info &= ~(IEEE80211_HT_CAP_SGI_20 |
+                                       IEEE80211_HT_CAP_SGI_40);
+       wlc->ht_cap.cap_info |= (val & WLC_N_SGI_20) ?
+                                       IEEE80211_HT_CAP_SGI_20 : 0;
+       wlc->ht_cap.cap_info |= (val & WLC_N_SGI_40) ?
+                                       IEEE80211_HT_CAP_SGI_40 : 0;
 
        if (wlc->pub->up) {
                wlc_update_beacon(wlc);
@@ -1184,9 +1204,9 @@ static void wlc_ht_update_ldpc(struct wlc_info *wlc, s8 val)
 {
        wlc->stf->ldpc = val;
 
-       wlc->ht_cap.cap &= ~HT_CAP_LDPC_CODING;
+       wlc->ht_cap.cap_info &= ~IEEE80211_HT_CAP_LDPC_CODING;
        if (wlc->stf->ldpc != OFF)
-               wlc->ht_cap.cap |= HT_CAP_LDPC_CODING;
+               wlc->ht_cap.cap_info |= IEEE80211_HT_CAP_LDPC_CODING;
 
        if (wlc->pub->up) {
                wlc_update_beacon(wlc);
@@ -1285,8 +1305,7 @@ static void WLBANDINITFN(wlc_bsinit) (struct wlc_info *wlc)
        wlc_ucode_mac_upd(wlc);
 
        /* init antenna selection */
-       if (WLANTSEL_ENAB(wlc))
-               wlc_antsel_init(wlc->asi);
+       wlc_antsel_init(wlc->asi);
 
 }
 
@@ -1294,7 +1313,7 @@ static void WLBANDINITFN(wlc_bsinit) (struct wlc_info *wlc)
 static void WLBANDINITFN(wlc_setband) (struct wlc_info *wlc, uint bandunit)
 {
        int idx;
-       wlc_bsscfg_t *cfg;
+       struct wlc_bsscfg *cfg;
 
        ASSERT(NBANDS(wlc) > 1);
        ASSERT(!wlc->bandlocked);
@@ -1327,13 +1346,13 @@ void wlc_wme_initparams_sta(struct wlc_info *wlc, wme_param_ie_t *pe)
                0,
                {
                 {EDCF_AC_BE_ACI_STA, EDCF_AC_BE_ECW_STA,
-                 HTOL16(EDCF_AC_BE_TXOP_STA)},
+                 cpu_to_le16(EDCF_AC_BE_TXOP_STA)},
                 {EDCF_AC_BK_ACI_STA, EDCF_AC_BK_ECW_STA,
-                 HTOL16(EDCF_AC_BK_TXOP_STA)},
+                 cpu_to_le16(EDCF_AC_BK_TXOP_STA)},
                 {EDCF_AC_VI_ACI_STA, EDCF_AC_VI_ECW_STA,
-                 HTOL16(EDCF_AC_VI_TXOP_STA)},
+                 cpu_to_le16(EDCF_AC_VI_TXOP_STA)},
                 {EDCF_AC_VO_ACI_STA, EDCF_AC_VO_ECW_STA,
-                 HTOL16(EDCF_AC_VO_TXOP_STA)}
+                 cpu_to_le16(EDCF_AC_VO_TXOP_STA)}
                 }
        };
 
@@ -1372,7 +1391,7 @@ void wlc_wme_setparams(struct wlc_info *wlc, u16 aci, void *arg, bool suspend)
                /* wlc->wme_admctl |= 1 << aci; *//* should be set ??  seems like off by default */
 
                /* fill in shm ac params struct */
-               acp_shm.txop = ltoh16(params->txop);
+               acp_shm.txop = le16_to_cpu(params->txop);
                /* convert from units of 32us to us for ucode */
                wlc->edcf_txop[aci & 0x3] = acp_shm.txop =
                    EDCF_TXOP2USEC(acp_shm.txop);
@@ -1393,7 +1412,7 @@ void wlc_wme_setparams(struct wlc_info *wlc, u16 aci, void *arg, bool suspend)
                acp_shm.cwmax = params->cw_max;
                acp_shm.cwcur = acp_shm.cwmin;
                acp_shm.bslots =
-                   R_REG(wlc->osh, &wlc->regs->tsf_random) & acp_shm.cwcur;
+                   R_REG(&wlc->regs->tsf_random) & acp_shm.cwcur;
                acp_shm.reggap = acp_shm.bslots + acp_shm.aifs;
                /* Indicate the new params to the ucode */
                acp_shm.status = wlc_read_shm(wlc, (M_EDCF_QINFO +
@@ -1420,7 +1439,7 @@ void wlc_wme_setparams(struct wlc_info *wlc, u16 aci, void *arg, bool suspend)
 
 }
 
-void wlc_edcf_setparams(wlc_bsscfg_t *cfg, bool suspend)
+void wlc_edcf_setparams(struct wlc_bsscfg *cfg, bool suspend)
 {
        struct wlc_info *wlc = cfg->wlc;
        uint aci, i, j;
@@ -1456,7 +1475,7 @@ void wlc_edcf_setparams(wlc_bsscfg_t *cfg, bool suspend)
                }
 
                /* fill in shm ac params struct */
-               acp_shm.txop = ltoh16(edcf_acp->TXOP);
+               acp_shm.txop = le16_to_cpu(edcf_acp->TXOP);
                /* convert from units of 32us to us for ucode */
                wlc->edcf_txop[aci] = acp_shm.txop =
                    EDCF_TXOP2USEC(acp_shm.txop);
@@ -1480,7 +1499,7 @@ void wlc_edcf_setparams(wlc_bsscfg_t *cfg, bool suspend)
                                            >> EDCF_ECWMAX_SHIFT);
                acp_shm.cwcur = acp_shm.cwmin;
                acp_shm.bslots =
-                   R_REG(wlc->osh, &wlc->regs->tsf_random) & acp_shm.cwcur;
+                   R_REG(&wlc->regs->tsf_random) & acp_shm.cwcur;
                acp_shm.reggap = acp_shm.bslots + acp_shm.aifs;
                /* Indicate the new params to the ucode */
                acp_shm.status = wlc_read_shm(wlc, (M_EDCF_QINFO +
@@ -1642,7 +1661,7 @@ void wlc_info_init(struct wlc_info *wlc, int unit)
        wlc->ibss_coalesce_allowed = true;
        wlc->pub->_coex = ON;
 
-       /* intialize mpc delay */
+       /* initialize mpc delay */
        wlc->mpc_delay_off = wlc->mpc_dlycnt = WLC_MPC_MIN_DELAYCNT;
 
        wlc->pr80838_war = true;
@@ -1668,7 +1687,7 @@ static uint wlc_attach_module(struct wlc_info *wlc)
        uint unit;
        unit = wlc->pub->unit;
 
-       wlc->asi = wlc_antsel_attach(wlc, wlc->osh, wlc->pub, wlc->hw);
+       wlc->asi = wlc_antsel_attach(wlc);
        if (wlc->asi == NULL) {
                WL_ERROR("wl%d: wlc_attach: wlc_antsel_attach failed\n", unit);
                err = 44;
@@ -1682,15 +1701,6 @@ static uint wlc_attach_module(struct wlc_info *wlc)
                goto fail;
        }
 
-       /* Initialize event queue; needed before following calls */
-       wlc->eventq =
-           wlc_eventq_attach(wlc->pub, wlc, wlc->wl, wlc_process_eventq);
-       if (wlc->eventq == NULL) {
-               WL_ERROR("wl%d: wlc_attach: wlc_eventq_attachfailed\n", unit);
-               err = 57;
-               goto fail;
-       }
-
        if ((wlc_stf_attach(wlc) != 0)) {
                WL_ERROR("wl%d: wlc_attach: wlc_stf_attach failed\n", unit);
                err = 68;
@@ -1711,14 +1721,13 @@ struct wlc_pub *wlc_pub(void *wlc)
  * The common driver entry routine. Error codes should be unique
  */
 void *wlc_attach(void *wl, u16 vendor, u16 device, uint unit, bool piomode,
-                struct osl_info *osh, void *regsva, uint bustype,
-                void *btparam, uint *perr)
+                void *regsva, uint bustype, void *btparam, uint *perr)
 {
        struct wlc_info *wlc;
        uint err = 0;
        uint j;
        struct wlc_pub *pub;
-       wlc_txq_info_t *qi;
+       struct wlc_txq_info *qi;
        uint n_disabled;
 
        WL_NONE("wl%d: %s: vendor 0x%x device 0x%x\n",
@@ -1728,19 +1737,16 @@ void *wlc_attach(void *wl, u16 vendor, u16 device, uint unit, bool piomode,
        ASSERT(WSEC_MAX_DEFAULT_KEYS == WLC_DEFAULT_KEYS);
 
        /* some code depends on packed structures */
-       ASSERT(sizeof(struct ether_addr) == ETH_ALEN);
-       ASSERT(sizeof(struct ether_header) == ETH_HLEN);
+       ASSERT(sizeof(struct ethhdr) == ETH_HLEN);
        ASSERT(sizeof(d11regs_t) == SI_CORE_SIZE);
        ASSERT(sizeof(ofdm_phy_hdr_t) == D11_PHY_HDR_LEN);
        ASSERT(sizeof(cck_phy_hdr_t) == D11_PHY_HDR_LEN);
        ASSERT(sizeof(d11txh_t) == D11_TXH_LEN);
        ASSERT(sizeof(d11rxhdr_t) == RXHDR_LEN);
-       ASSERT(sizeof(struct dot11_header) == DOT11_A4_HDR_LEN);
-       ASSERT(sizeof(struct dot11_rts_frame) == DOT11_RTS_LEN);
-       ASSERT(sizeof(struct dot11_management_header) == DOT11_MGMT_HDR_LEN);
-       ASSERT(sizeof(struct dot11_bcn_prb) == DOT11_BCN_PRB_LEN);
+       ASSERT(sizeof(struct ieee80211_hdr) == DOT11_A4_HDR_LEN);
+       ASSERT(sizeof(struct ieee80211_rts) == DOT11_RTS_LEN);
        ASSERT(sizeof(tx_status_t) == TXSTATUS_LEN);
-       ASSERT(sizeof(ht_cap_ie_t) == HT_CAP_IE_LEN);
+       ASSERT(sizeof(struct ieee80211_ht_cap) == HT_CAP_IE_LEN);
 #ifdef BRCM_FULLMAC
        ASSERT(offsetof(wl_scan_params_t, channel_list) ==
               WL_SCAN_PARAMS_FIXED_SIZE);
@@ -1761,10 +1767,9 @@ void *wlc_attach(void *wl, u16 vendor, u16 device, uint unit, bool piomode,
                   && 4 == WLC_NUMRXIVS));
 
        /* allocate struct wlc_info state and its substructures */
-       wlc = (struct wlc_info *) wlc_attach_malloc(osh, unit, &err, device);
+       wlc = (struct wlc_info *) wlc_attach_malloc(unit, &err, device);
        if (wlc == NULL)
                goto fail;
-       wlc->osh = osh;
        pub = wlc->pub;
 
 #if defined(BCMDBG)
@@ -1775,7 +1780,6 @@ void *wlc_attach(void *wl, u16 vendor, u16 device, uint unit, bool piomode,
        wlc->core = wlc->corestate;
        wlc->wl = wl;
        pub->unit = unit;
-       pub->osh = osh;
        wlc->btparam = btparam;
        pub->_piomode = piomode;
        wlc->bandinit_pending = false;
@@ -1795,8 +1799,11 @@ void *wlc_attach(void *wl, u16 vendor, u16 device, uint unit, bool piomode,
        wlc_module_register(wlc->pub, wlc_iovars, "wlc_iovars", wlc,
                            wlc_doiovar, NULL, NULL);
 
-       /* low level attach steps(all hw accesses go inside, no more in rest of the attach) */
-       err = wlc_bmac_attach(wlc, vendor, device, unit, piomode, osh, regsva,
+       /*
+        * low level attach steps(all hw accesses go
+        * inside, no more in rest of the attach)
+        */
+       err = wlc_bmac_attach(wlc, vendor, device, unit, piomode, regsva,
                              bustype, btparam);
        if (err)
                goto fail;
@@ -1838,10 +1845,9 @@ void *wlc_attach(void *wl, u16 vendor, u16 device, uint unit, bool piomode,
                        wlc->core->txavail[i] = wlc->hw->txavail[i];
        }
 
-       wlc_bmac_hw_etheraddr(wlc->hw, &wlc->perm_etheraddr);
+       wlc_bmac_hw_etheraddr(wlc->hw, wlc->perm_etheraddr);
 
-       bcopy((char *)&wlc->perm_etheraddr, (char *)&pub->cur_etheraddr,
-             ETH_ALEN);
+       memcpy(&pub->cur_etheraddr, &wlc->perm_etheraddr, ETH_ALEN);
 
        for (j = 0; j < NBANDS(wlc); j++) {
                /* Use band 1 for single band 11a */
@@ -1921,7 +1927,7 @@ void *wlc_attach(void *wl, u16 vendor, u16 device, uint unit, bool piomode,
         */
 
        /* allocate our initial queue */
-       qi = wlc_txq_alloc(wlc, osh);
+       qi = wlc_txq_alloc(wlc);
        if (qi == NULL) {
                WL_ERROR("wl%d: %s: failed to malloc tx queue\n",
                         unit, __func__);
@@ -1935,8 +1941,8 @@ void *wlc_attach(void *wl, u16 vendor, u16 device, uint unit, bool piomode,
        wlc->cfg->wlc = wlc;
        pub->txmaxpkts = MAXTXPKTS;
 
-       WLCNTSET(pub->_cnt->version, WL_CNT_T_VERSION);
-       WLCNTSET(pub->_cnt->length, sizeof(wl_cnt_t));
+       pub->_cnt->version = WL_CNT_T_VERSION;
+       pub->_cnt->length = sizeof(struct wl_cnt);
 
        WLCNTSET(pub->_wme_cnt->version, WL_WME_CNT_VERSION);
        WLCNTSET(pub->_wme_cnt->length, sizeof(wl_wme_cnt_t));
@@ -1944,7 +1950,7 @@ void *wlc_attach(void *wl, u16 vendor, u16 device, uint unit, bool piomode,
        wlc_wme_initparams_sta(wlc, &wlc->wme_param_ie);
 
        wlc->mimoft = FT_HT;
-       wlc->ht_cap.cap = HT_CAP;
+       wlc->ht_cap.cap_info = HT_CAP;
        if (HT_ENAB(wlc->pub))
                wlc->stf->ldpc = AUTO;
 
@@ -1981,27 +1987,25 @@ void *wlc_attach(void *wl, u16 vendor, u16 device, uint unit, bool piomode,
        if (n_disabled & WLFEATURE_DISABLE_11N_STBC_TX) {
                wlc->bandstate[BAND_2G_INDEX]->band_stf_stbc_tx = OFF;
                wlc->bandstate[BAND_5G_INDEX]->band_stf_stbc_tx = OFF;
-               wlc->ht_cap.cap &= ~HT_CAP_TX_STBC;
+               wlc->ht_cap.cap_info &= ~IEEE80211_HT_CAP_TX_STBC;
        }
        if (n_disabled & WLFEATURE_DISABLE_11N_STBC_RX)
                wlc_stf_stbc_rx_set(wlc, HT_CAP_RX_STBC_NO);
 
        /* apply the GF override from nvram conf */
        if (n_disabled & WLFEATURE_DISABLE_11N_GF)
-               wlc->ht_cap.cap &= ~HT_CAP_GF;
+               wlc->ht_cap.cap_info &= ~IEEE80211_HT_CAP_GRN_FLD;
 
        /* initialize radio_mpc_disable according to wlc->mpc */
        wlc_radio_mpc_upd(wlc);
 
-       if (WLANTSEL_ENAB(wlc)) {
-               if ((wlc->pub->sih->chip) == BCM43235_CHIP_ID) {
-                       if ((getintvar(wlc->pub->vars, "aa2g") == 7) ||
-                           (getintvar(wlc->pub->vars, "aa5g") == 7)) {
-                               wlc_bmac_antsel_set(wlc->hw, 1);
-                       }
-               } else {
-                       wlc_bmac_antsel_set(wlc->hw, wlc->asi->antsel_avail);
+       if ((wlc->pub->sih->chip) == BCM43235_CHIP_ID) {
+               if ((getintvar(wlc->pub->vars, "aa2g") == 7) ||
+                   (getintvar(wlc->pub->vars, "aa5g") == 7)) {
+                       wlc_bmac_antsel_set(wlc->hw, 1);
                }
+       } else {
+               wlc_bmac_antsel_set(wlc->hw, wlc->asi->antsel_avail);
        }
 
        if (perr)
@@ -2146,11 +2150,6 @@ uint wlc_detach(struct wlc_info *wlc)
        if (!wlc_radio_monitor_stop(wlc))
                callbacks++;
 
-       if (wlc->eventq) {
-               wlc_eventq_detach(wlc->eventq);
-               wlc->eventq = NULL;
-       }
-
        wlc_channel_mgr_detach(wlc->cmi);
 
        wlc_timers_deinit(wlc);
@@ -2161,15 +2160,13 @@ uint wlc_detach(struct wlc_info *wlc)
 
 
 #ifdef BCMDBG
-       if (wlc->country_ie_override) {
-               kfree(wlc->country_ie_override);
-               wlc->country_ie_override = NULL;
-       }
+       kfree(wlc->country_ie_override);
+       wlc->country_ie_override = NULL;
 #endif                         /* BCMDBG */
 
        {
                /* free dumpcb list */
-               dumpcb_t *prev, *ptr;
+               struct dumpcb_s *prev, *ptr;
                prev = ptr = wlc->dumpcb_head;
                while (ptr) {
                        ptr = prev->next;
@@ -2182,9 +2179,8 @@ uint wlc_detach(struct wlc_info *wlc)
        /* Detach from iovar manager */
        wlc_module_unregister(wlc->pub, "wlc_iovars", wlc);
 
-       while (wlc->tx_queues != NULL) {
-               wlc_txq_free(wlc, wlc->osh, wlc->tx_queues);
-       }
+       while (wlc->tx_queues != NULL)
+               wlc_txq_free(wlc, wlc->tx_queues);
 
        /*
         * consistency check: wlc_module_register/wlc_module_unregister calls
@@ -2193,7 +2189,7 @@ uint wlc_detach(struct wlc_info *wlc)
        for (i = 0; i < WLC_MAXMODULES; i++)
                ASSERT(wlc->modulecb[i].name[0] == '\0');
 
-       wlc_detach_mfree(wlc, wlc->osh);
+       wlc_detach_mfree(wlc);
        return callbacks;
 }
 
@@ -2294,10 +2290,11 @@ void wlc_radio_mpc_upd(struct wlc_info *wlc)
  */
 static void wlc_radio_upd(struct wlc_info *wlc)
 {
-       if (wlc->pub->radio_disabled)
+       if (wlc->pub->radio_disabled) {
                wlc_radio_disable(wlc);
-       else
+       } else {
                wlc_radio_enable(wlc);
+       }
 }
 
 /* maintain LED behavior in down state */
@@ -2314,6 +2311,14 @@ static void wlc_down_led_upd(struct wlc_info *wlc)
        }
 }
 
+/* update hwradio status and return it */
+bool wlc_check_radio_disabled(struct wlc_info *wlc)
+{
+       wlc_radio_hwdisable_upd(wlc);
+
+       return mboolisset(wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE) ? true : false;
+}
+
 void wlc_radio_disable(struct wlc_info *wlc)
 {
        if (!wlc->pub->up) {
@@ -2443,7 +2448,7 @@ static void wlc_watchdog(void *arg)
 {
        struct wlc_info *wlc = (struct wlc_info *) arg;
        int i;
-       wlc_bsscfg_t *cfg;
+       struct wlc_bsscfg *cfg;
 
        WL_TRACE("wl%d: wlc_watchdog\n", wlc->pub->unit);
 
@@ -2485,8 +2490,7 @@ static void wlc_watchdog(void *arg)
        wlc_bmac_watchdog(wlc);
 
        /* occasionally sample mac stat counters to detect 16-bit counter wrap */
-       if ((WLC_UPDATE_STATS(wlc))
-           && (!(wlc->pub->now % SW_TIMER_MAC_STAT_UPD)))
+       if ((wlc->pub->now % SW_TIMER_MAC_STAT_UPD) == 0)
                wlc_statsupd(wlc);
 
        /* Manage TKIP countermeasures timers */
@@ -2560,7 +2564,7 @@ int wlc_up(struct wlc_info *wlc)
                        if (!mboolisset
                            (wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE)) {
                                int idx;
-                               wlc_bsscfg_t *bsscfg;
+                               struct wlc_bsscfg *bsscfg;
                                mboolset(wlc->pub->radio_disabled,
                                         WL_RADIO_HW_DISABLE);
 
@@ -2667,7 +2671,7 @@ uint wlc_down(struct wlc_info *wlc)
        uint callbacks = 0;
        int i;
        bool dev_gone = false;
-       wlc_txq_info_t *qi;
+       struct wlc_txq_info *qi;
 
        WL_TRACE("wl%d: %s:\n", wlc->pub->unit, __func__);
 
@@ -2715,27 +2719,15 @@ uint wlc_down(struct wlc_info *wlc)
 
        /* flush tx queues */
        for (qi = wlc->tx_queues; qi != NULL; qi = qi->next) {
-               pktq_flush(wlc->osh, &qi->q, true, NULL, 0);
+               pktq_flush(&qi->q, true, NULL, 0);
                ASSERT(pktq_empty(&qi->q));
        }
 
-       /* flush event queue.
-        * Should be the last thing done after all the events are generated
-        * Just delivers the events synchronously instead of waiting for a timer
-        */
-       callbacks += wlc_eventq_down(wlc->eventq);
-
        callbacks += wlc_bmac_down_finish(wlc->hw);
 
        /* wlc_bmac_down_finish has done wlc_coredisable(). so clk is off */
        wlc->clk = false;
 
-
-       /* Verify all packets are flushed from the driver */
-       if (wlc->osh->pktalloced != 0) {
-               WL_ERROR("%d packets not freed at wlc_down!!!!!!\n",
-                        wlc->osh->pktalloced);
-       }
 #ifdef BCMDBG
        /* Since all the packets should have been freed,
         * all callbacks should have been called
@@ -2866,16 +2858,17 @@ int wlc_set_gmode(struct wlc_info *wlc, u8 gmode, bool config)
 
        if ((AP_ENAB(wlc->pub) && preamble != WLC_PLCP_LONG)
            || preamble == WLC_PLCP_SHORT)
-               wlc->default_bss->capability |= DOT11_CAP_SHORT;
+               wlc->default_bss->capability |= WLAN_CAPABILITY_SHORT_PREAMBLE;
        else
-               wlc->default_bss->capability &= ~DOT11_CAP_SHORT;
+               wlc->default_bss->capability &= ~WLAN_CAPABILITY_SHORT_PREAMBLE;
 
        /* Update shortslot capability bit for AP and IBSS */
        if ((AP_ENAB(wlc->pub) && shortslot == WLC_SHORTSLOT_AUTO) ||
            shortslot == WLC_SHORTSLOT_ON)
-               wlc->default_bss->capability |= DOT11_CAP_SHORTSLOT;
+               wlc->default_bss->capability |= WLAN_CAPABILITY_SHORT_SLOT_TIME;
        else
-               wlc->default_bss->capability &= ~DOT11_CAP_SHORTSLOT;
+               wlc->default_bss->capability &=
+                                       ~WLAN_CAPABILITY_SHORT_SLOT_TIME;
 
        /* Use the default 11g rateset */
        if (!rs.count)
@@ -2892,8 +2885,8 @@ int wlc_set_gmode(struct wlc_info *wlc, u8 gmode, bool config)
 
        /* Set default bss rateset */
        wlc->default_bss->rateset.count = rs.count;
-       bcopy((char *)rs.rates, (char *)wlc->default_bss->rateset.rates,
-             sizeof(wlc->default_bss->rateset.rates));
+       memcpy(wlc->default_bss->rateset.rates, rs.rates, 
+              sizeof(wlc->default_bss->rateset.rates));
 
        return ret;
 }
@@ -2986,7 +2979,7 @@ static int wlc_set_rateset(struct wlc_info *wlc, wlc_rateset_t *rs_arg)
        wlc_rateset_t rs, new;
        uint bandunit;
 
-       bcopy((char *)rs_arg, (char *)&rs, sizeof(wlc_rateset_t));
+       memcpy(&rs, rs_arg, sizeof(wlc_rateset_t));
 
        /* check for bad count value */
        if ((rs.count == 0) || (rs.count > WLC_NUMRATES))
@@ -2994,7 +2987,7 @@ static int wlc_set_rateset(struct wlc_info *wlc, wlc_rateset_t *rs_arg)
 
        /* try the current band */
        bandunit = wlc->band->bandunit;
-       bcopy((char *)&rs, (char *)&new, sizeof(wlc_rateset_t));
+       memcpy(&new, &rs, sizeof(wlc_rateset_t));
        if (wlc_rate_hwrs_filter_sort_validate
            (&new, &wlc->bandstate[bandunit]->hw_rateset, true,
             wlc->stf->txstreams))
@@ -3003,7 +2996,7 @@ static int wlc_set_rateset(struct wlc_info *wlc, wlc_rateset_t *rs_arg)
        /* try the other band */
        if (IS_MBAND_UNLOCKED(wlc)) {
                bandunit = OTHERBANDUNIT(wlc);
-               bcopy((char *)&rs, (char *)&new, sizeof(wlc_rateset_t));
+               memcpy(&new, &rs, sizeof(wlc_rateset_t));
                if (wlc_rate_hwrs_filter_sort_validate(&new,
                                                       &wlc->
                                                       bandstate[bandunit]->
@@ -3016,10 +3009,9 @@ static int wlc_set_rateset(struct wlc_info *wlc, wlc_rateset_t *rs_arg)
 
  good:
        /* apply new rateset */
-       bcopy((char *)&new, (char *)&wlc->default_bss->rateset,
-             sizeof(wlc_rateset_t));
-       bcopy((char *)&new, (char *)&wlc->bandstate[bandunit]->defrateset,
-             sizeof(wlc_rateset_t));
+       memcpy(&wlc->default_bss->rateset, &new, sizeof(wlc_rateset_t));
+       memcpy(&wlc->bandstate[bandunit]->defrateset, &new,
+              sizeof(wlc_rateset_t));
        return 0;
 }
 
@@ -3071,8 +3063,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
        bool ta_ok;
        uint band;
        rw_reg_t *r;
-       wlc_bsscfg_t *bsscfg;
-       struct osl_info *osh;
+       struct wlc_bsscfg *bsscfg;
        wlc_bss_info_t *current_bss;
 
        /* update bsscfg pointer */
@@ -3099,7 +3090,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
 
        /* This will prevent the misaligned access */
        if (pval && (u32) len >= sizeof(val))
-               bcopy(pval, &val, sizeof(val));
+               memcpy(&val, pval, sizeof(val));
        else
                val = 0;
 
@@ -3112,7 +3103,6 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
 
        bcmerror = 0;
        regs = wlc->regs;
-       osh = wlc->osh;
 
        /* A few commands don't need any arguments; all the others do. */
        switch (cmd) {
@@ -3188,7 +3178,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
 
                        wlc->default_bss->chanspec = chspec;
                        /* wlc_BSSinit() will sanitize the rateset before using it.. */
-                       if (wlc->pub->up && !wlc->pub->associated &&
+                       if (wlc->pub->up &&
                            (WLC_BAND_PI_RADIO_CHANSPEC != chspec)) {
                                wlc_set_home_chanspec(wlc, chspec);
                                wlc_suspend_mac_and_wait(wlc);
@@ -3316,13 +3306,11 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
                }
                if (r->size == sizeof(u32))
                        r->val =
-                           R_REG(osh,
-                                 (u32 *)((unsigned char *)(unsigned long)regs +
+                           R_REG((u32 *)((unsigned char *)(unsigned long)regs +
                                              r->byteoff));
                else if (r->size == sizeof(u16))
                        r->val =
-                           R_REG(osh,
-                                 (u16 *)((unsigned char *)(unsigned long)regs +
+                           R_REG((u16 *)((unsigned char *)(unsigned long)regs +
                                              r->byteoff));
                else
                        bcmerror = BCME_BADADDR;
@@ -3351,12 +3339,10 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
                        break;
                }
                if (r->size == sizeof(u32))
-                       W_REG(osh,
-                             (u32 *)((unsigned char *)(unsigned long) regs +
+                       W_REG((u32 *)((unsigned char *)(unsigned long) regs +
                                          r->byteoff), r->val);
                else if (r->size == sizeof(u16))
-                       W_REG(osh,
-                             (u16 *)((unsigned char *)(unsigned long) regs +
+                       W_REG((u16 *)((unsigned char *)(unsigned long) regs +
                                          r->byteoff), r->val);
                else
                        bcmerror = BCME_BADADDR;
@@ -3426,7 +3412,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
                                break;
                        }
 
-                       rxstatus = R_REG(wlc->osh, &wlc->regs->phyrxstatus0);
+                       rxstatus = R_REG(&wlc->regs->phyrxstatus0);
                        if (rxstatus == 0xdead || rxstatus == (u16) -1) {
                                bcmerror = BCME_ERROR;
                                break;
@@ -3459,15 +3445,8 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
                                break;
                        }
 
-                       /* 4322 supports antdiv in phy, no need to set it to ucode */
-                       if (WLCISNPHY(wlc->band)
-                           && D11REV_IS(wlc->pub->corerev, 16)) {
-                               WL_ERROR("wl%d: can't set ucantdiv for 4322\n",
-                                        wlc->pub->unit);
-                               bcmerror = BCME_UNSUPPORTED;
-                       } else
-                               wlc_mhf(wlc, MHF1, MHF1_ANTDIV,
-                                       (val ? MHF1_ANTDIV : 0), WLC_BAND_AUTO);
+                       wlc_mhf(wlc, MHF1, MHF1_ANTDIV,
+                               (val ? MHF1_ANTDIV : 0), WLC_BAND_AUTO);
                        break;
                }
 #endif                         /* defined(BCMDBG) */
@@ -3595,18 +3574,17 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
                        if (src_key) {
                                key.index = src_key->id;
                                key.len = src_key->len;
-                               bcopy(src_key->data, key.data, key.len);
+                               memcpy(key.data, src_key->data, key.len);
                                key.algo = src_key->algo;
                                if (WSEC_SOFTKEY(wlc, src_key, bsscfg))
                                        key.flags |= WL_SOFT_KEY;
                                if (src_key->flags & WSEC_PRIMARY_KEY)
                                        key.flags |= WL_PRIMARY_KEY;
 
-                               bcopy(src_key->ea.octet, key.ea.octet,
-                                     ETH_ALEN);
+                               memcpy(key.ea, src_key->ea, ETH_ALEN);
                        }
 
-                       bcopy((char *)&key, arg, sizeof(key));
+                       memcpy(arg, &key, sizeof(key));
                } else
                        bcmerror = BCME_BADKEYIDX;
                break;
@@ -3639,7 +3617,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
                                u32 hi;
                                /* group keys in WPA-NONE (IBSS only, AES and TKIP) use a global TXIV */
                                if ((bsscfg->WPA_auth & WPA_AUTH_NONE) &&
-                                   is_zero_ether_addr(key->ea.octet)) {
+                                   is_zero_ether_addr(key->ea)) {
                                        lo = bsscfg->wpa_none_txiv.lo;
                                        hi = bsscfg->wpa_none_txiv.hi;
                                } else {
@@ -3657,7 +3635,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
                                seq[6] = 0;
                                seq[7] = 0;
 
-                               bcopy((char *)seq, arg, sizeof(seq));
+                               memcpy(arg, seq, sizeof(seq));
                        } else {
                                bcmerror = BCME_BADKEYIDX;
                        }
@@ -3680,7 +3658,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
 
                        /* Copy only legacy rateset section */
                        ret_rs->count = rs->count;
-                       bcopy(&rs->rates, &ret_rs->rates, rs->count);
+                       memcpy(&ret_rs->rates, &rs->rates, rs->count);
                        break;
                }
 
@@ -3698,7 +3676,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
 
                        /* Copy only legacy rateset section */
                        ret_rs->count = rs.count;
-                       bcopy(&rs.rates, &ret_rs->rates, rs.count);
+                       memcpy(&ret_rs->rates, &rs.rates, rs.count);
                        break;
                }
 
@@ -3720,16 +3698,18 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
 
                        /* Copy only legacy rateset section */
                        rs.count = in_rs->count;
-                       bcopy(&in_rs->rates, &rs.rates, rs.count);
+                       memcpy(&rs.rates, &in_rs->rates, rs.count);
 
                        /* merge rateset coming in with the current mcsset */
                        if (N_ENAB(wlc->pub)) {
                                if (bsscfg->associated)
-                                       bcopy(&current_bss->rateset.mcs[0],
-                                             rs.mcs, MCSSET_LEN);
+                                       memcpy(rs.mcs,
+                                              &current_bss->rateset.mcs[0],
+                                              MCSSET_LEN);
                                else
-                                       bcopy(&wlc->default_bss->rateset.mcs[0],
-                                             rs.mcs, MCSSET_LEN);
+                                       memcpy(rs.mcs,
+                                              &wlc->default_bss->rateset.mcs[0],
+                                              MCSSET_LEN);
                        }
 
                        bcmerror = wlc_set_rateset(wlc, &rs);
@@ -3838,19 +3818,18 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
 
        case WLC_GET_PKTCNTS:{
                        get_pktcnt_t *pktcnt = (get_pktcnt_t *) pval;
-                       if (WLC_UPDATE_STATS(wlc))
-                               wlc_statsupd(wlc);
-                       pktcnt->rx_good_pkt = WLCNTVAL(wlc->pub->_cnt->rxframe);
-                       pktcnt->rx_bad_pkt = WLCNTVAL(wlc->pub->_cnt->rxerror);
+                       wlc_statsupd(wlc);
+                       pktcnt->rx_good_pkt = wlc->pub->_cnt->rxframe;
+                       pktcnt->rx_bad_pkt = wlc->pub->_cnt->rxerror;
                        pktcnt->tx_good_pkt =
-                           WLCNTVAL(wlc->pub->_cnt->txfrmsnt);
+                           wlc->pub->_cnt->txfrmsnt;
                        pktcnt->tx_bad_pkt =
-                           WLCNTVAL(wlc->pub->_cnt->txerror) +
-                           WLCNTVAL(wlc->pub->_cnt->txfail);
+                           wlc->pub->_cnt->txerror +
+                           wlc->pub->_cnt->txfail;
                        if (len >= (int)sizeof(get_pktcnt_t)) {
                                /* Be backward compatible - only if buffer is large enough  */
                                pktcnt->rx_ocast_good_pkt =
-                                   WLCNTVAL(wlc->pub->_cnt->rxmfrmocast);
+                                   wlc->pub->_cnt->rxmfrmocast;
                        }
                        break;
                }
@@ -4032,7 +4011,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
                                bcmerror = BCME_BUFTOOSHORT;
                                break;
                        }
-                       bcopy((char *)arg, (char *)&rs, sizeof(wlc_rateset_t));
+                       memcpy(&rs, arg, sizeof(wlc_rateset_t));
 
                        /* check for bad count value */
                        if (rs.count > WLC_NUMRATES) {
@@ -4068,7 +4047,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
                        }
 
                        /* apply new rateset to the override */
-                       bcopy((char *)&new, (char *)&wlc->sup_rates_override,
+                       memcpy(&wlc->sup_rates_override, &new,
                              sizeof(wlc_rateset_t));
 
                        /* update bcn and probe resp if needed */
@@ -4092,8 +4071,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
                        bcmerror = BCME_BUFTOOSHORT;
                        break;
                }
-               bcopy((char *)&wlc->sup_rates_override, (char *)arg,
-                     sizeof(wlc_rateset_t));
+               memcpy(arg, &wlc->sup_rates_override, sizeof(wlc_rateset_t));
 
                break;
 
@@ -4351,7 +4329,7 @@ int wlc_module_unregister(struct wlc_pub *pub, const char *name, void *hdl)
        for (i = 0; i < WLC_MAXMODULES; i++) {
                if (!strcmp(wlc->modulecb[i].name, name) &&
                    (wlc->modulecb[i].hdl == hdl)) {
-                       memset(&wlc->modulecb[i], 0, sizeof(modulecb_t));
+                       memset(&wlc->modulecb[i], 0, sizeof(struct modulecb));
                        return 0;
                }
        }
@@ -4502,7 +4480,7 @@ wlc_iovar_check(struct wlc_pub *pub, const bcm_iovar_t *vi, void *arg, int len,
                case IOVT_UINT8:
                case IOVT_UINT16:
                case IOVT_UINT32:
-                       bcopy(arg, &int_val, sizeof(int));
+                       memcpy(&int_val, arg, sizeof(int));
                        err = wlc_iovar_rangecheck(wlc, int_val, vi);
                        break;
                }
@@ -4526,7 +4504,7 @@ wlc_doiovar(void *hdl, const bcm_iovar_t *vi, u32 actionid,
            int val_size, struct wlc_if *wlcif)
 {
        struct wlc_info *wlc = hdl;
-       wlc_bsscfg_t *bsscfg;
+       struct wlc_bsscfg *bsscfg;
        int err = 0;
        s32 int_val = 0;
        s32 int_val2 = 0;
@@ -4546,11 +4524,12 @@ wlc_doiovar(void *hdl, const bcm_iovar_t *vi, u32 actionid,
 
        /* convenience int and bool vals for first 8 bytes of buffer */
        if (p_len >= (int)sizeof(int_val))
-               bcopy(params, &int_val, sizeof(int_val));
+               memcpy(&int_val, params, sizeof(int_val));
 
        if (p_len >= (int)sizeof(int_val) * 2)
-               bcopy((void *)((unsigned long)params + sizeof(int_val)), &int_val2,
-                     sizeof(int_val));
+               memcpy(&int_val2,
+                      (void *)((unsigned long)params + sizeof(int_val)),
+                      sizeof(int_val));
 
        /* convenience int ptr for 4-byte gets (requires int aligned arg) */
        ret_int_ptr = (s32 *) arg;
@@ -4562,6 +4541,9 @@ wlc_doiovar(void *hdl, const bcm_iovar_t *vi, u32 actionid,
                 wlc->pub->unit, __func__, IOV_ID(actionid));
        /* Do the actual parameter implementation */
        switch (actionid) {
+       case IOV_SVAL(IOV_RTSTHRESH):
+               wlc->RTSThresh = int_val;
+               break;
 
        case IOV_GVAL(IOV_QTXPOWER):{
                        uint qdbm;
@@ -4683,19 +4665,21 @@ static const char *supr_reason[] = {
 
 static void wlc_print_txs_status(u16 s)
 {
-       printf("[15:12]  %d  frame attempts\n", (s & TX_STATUS_FRM_RTX_MASK) >>
-              TX_STATUS_FRM_RTX_SHIFT);
-       printf(" [11:8]  %d  rts attempts\n", (s & TX_STATUS_RTS_RTX_MASK) >>
-              TX_STATUS_RTS_RTX_SHIFT);
-       printf("    [7]  %d  PM mode indicated\n",
+       printk(KERN_DEBUG "[15:12]  %d  frame attempts\n",
+              (s & TX_STATUS_FRM_RTX_MASK) >> TX_STATUS_FRM_RTX_SHIFT);
+       printk(KERN_DEBUG " [11:8]  %d  rts attempts\n",
+              (s & TX_STATUS_RTS_RTX_MASK) >> TX_STATUS_RTS_RTX_SHIFT);
+       printk(KERN_DEBUG "    [7]  %d  PM mode indicated\n",
               ((s & TX_STATUS_PMINDCTD) ? 1 : 0));
-       printf("    [6]  %d  intermediate status\n",
+       printk(KERN_DEBUG "    [6]  %d  intermediate status\n",
               ((s & TX_STATUS_INTERMEDIATE) ? 1 : 0));
-       printf("    [5]  %d  AMPDU\n", (s & TX_STATUS_AMPDU) ? 1 : 0);
-       printf("  [4:2]  %d  Frame Suppressed Reason (%s)\n",
+       printk(KERN_DEBUG "    [5]  %d  AMPDU\n",
+              (s & TX_STATUS_AMPDU) ? 1 : 0);
+       printk(KERN_DEBUG "  [4:2]  %d  Frame Suppressed Reason (%s)\n",
               ((s & TX_STATUS_SUPR_MASK) >> TX_STATUS_SUPR_SHIFT),
               supr_reason[(s & TX_STATUS_SUPR_MASK) >> TX_STATUS_SUPR_SHIFT]);
-       printf("    [1]  %d  acked\n", ((s & TX_STATUS_ACK_RCV) ? 1 : 0));
+       printk(KERN_DEBUG "    [1]  %d  acked\n",
+              ((s & TX_STATUS_ACK_RCV) ? 1 : 0));
 }
 #endif                         /* BCMDBG */
 
@@ -4705,30 +4689,47 @@ void wlc_print_txstatus(tx_status_t *txs)
        u16 s = txs->status;
        u16 ackphyrxsh = txs->ackphyrxsh;
 
-       printf("\ntxpkt (MPDU) Complete\n");
+       printk(KERN_DEBUG "\ntxpkt (MPDU) Complete\n");
+
+       printk(KERN_DEBUG "FrameID: %04x   ", txs->frameid);
+       printk(KERN_DEBUG "TxStatus: %04x", s);
+       printk(KERN_DEBUG "\n");
 
-       printf("FrameID: %04x   ", txs->frameid);
-       printf("TxStatus: %04x", s);
-       printf("\n");
-#ifdef BCMDBG
        wlc_print_txs_status(s);
-#endif
-       printf("LastTxTime: %04x ", txs->lasttxtime);
-       printf("Seq: %04x ", txs->sequence);
-       printf("PHYTxStatus: %04x ", txs->phyerr);
-       printf("RxAckRSSI: %04x ",
+
+       printk(KERN_DEBUG "LastTxTime: %04x ", txs->lasttxtime);
+       printk(KERN_DEBUG "Seq: %04x ", txs->sequence);
+       printk(KERN_DEBUG "PHYTxStatus: %04x ", txs->phyerr);
+       printk(KERN_DEBUG "RxAckRSSI: %04x ",
               (ackphyrxsh & PRXS1_JSSI_MASK) >> PRXS1_JSSI_SHIFT);
-       printf("RxAckSQ: %04x", (ackphyrxsh & PRXS1_SQ_MASK) >> PRXS1_SQ_SHIFT);
-       printf("\n");
+       printk(KERN_DEBUG "RxAckSQ: %04x",
+              (ackphyrxsh & PRXS1_SQ_MASK) >> PRXS1_SQ_SHIFT);
+       printk(KERN_DEBUG "\n");
 #endif                         /* defined(BCMDBG) */
 }
 
+static void
+wlc_ctrupd_cache(u16 cur_stat, u16 *macstat_snapshot, u32 *macstat)
+{
+       u16 v;
+       u16 delta;
+
+       v = le16_to_cpu(cur_stat);
+       delta = (u16)(v - *macstat_snapshot);
+
+       if (delta != 0) {
+               *macstat += delta;
+               *macstat_snapshot = v;
+       }
+}
+
 #define MACSTATUPD(name) \
        wlc_ctrupd_cache(macstats.name, &wlc->core->macstat_snapshot->name, &wlc->pub->_cnt->name)
 
 void wlc_statsupd(struct wlc_info *wlc)
 {
        int i;
+       macstat_t macstats;
 #ifdef BCMDBG
        u16 delta;
        u16 rxf0ovfl;
@@ -4748,6 +4749,66 @@ void wlc_statsupd(struct wlc_info *wlc)
                txfunfl[i] = wlc->core->macstat_snapshot->txfunfl[i];
 #endif                         /* BCMDBG */
 
+       /* Read mac stats from contiguous shared memory */
+       wlc_bmac_copyfrom_shm(wlc->hw, M_UCODE_MACSTAT,
+                             &macstats, sizeof(macstat_t));
+
+       /* update mac stats */
+       MACSTATUPD(txallfrm);
+       MACSTATUPD(txrtsfrm);
+       MACSTATUPD(txctsfrm);
+       MACSTATUPD(txackfrm);
+       MACSTATUPD(txdnlfrm);
+       MACSTATUPD(txbcnfrm);
+       for (i = 0; i < NFIFO; i++)
+               MACSTATUPD(txfunfl[i]);
+       MACSTATUPD(txtplunfl);
+       MACSTATUPD(txphyerr);
+       MACSTATUPD(rxfrmtoolong);
+       MACSTATUPD(rxfrmtooshrt);
+       MACSTATUPD(rxinvmachdr);
+       MACSTATUPD(rxbadfcs);
+       MACSTATUPD(rxbadplcp);
+       MACSTATUPD(rxcrsglitch);
+       MACSTATUPD(rxstrt);
+       MACSTATUPD(rxdfrmucastmbss);
+       MACSTATUPD(rxmfrmucastmbss);
+       MACSTATUPD(rxcfrmucast);
+       MACSTATUPD(rxrtsucast);
+       MACSTATUPD(rxctsucast);
+       MACSTATUPD(rxackucast);
+       MACSTATUPD(rxdfrmocast);
+       MACSTATUPD(rxmfrmocast);
+       MACSTATUPD(rxcfrmocast);
+       MACSTATUPD(rxrtsocast);
+       MACSTATUPD(rxctsocast);
+       MACSTATUPD(rxdfrmmcast);
+       MACSTATUPD(rxmfrmmcast);
+       MACSTATUPD(rxcfrmmcast);
+       MACSTATUPD(rxbeaconmbss);
+       MACSTATUPD(rxdfrmucastobss);
+       MACSTATUPD(rxbeaconobss);
+       MACSTATUPD(rxrsptmout);
+       MACSTATUPD(bcntxcancl);
+       MACSTATUPD(rxf0ovfl);
+       MACSTATUPD(rxf1ovfl);
+       MACSTATUPD(rxf2ovfl);
+       MACSTATUPD(txsfovfl);
+       MACSTATUPD(pmqovfl);
+       MACSTATUPD(rxcgprqfrm);
+       MACSTATUPD(rxcgprsqovfl);
+       MACSTATUPD(txcgprsfail);
+       MACSTATUPD(txcgprssuc);
+       MACSTATUPD(prs_timeout);
+       MACSTATUPD(rxnack);
+       MACSTATUPD(frmscons);
+       MACSTATUPD(txnack);
+       MACSTATUPD(txglitch_nack);
+       MACSTATUPD(txburst);
+       MACSTATUPD(phywatchdog);
+       MACSTATUPD(pktengrxducast);
+       MACSTATUPD(pktengrxdmcast);
+
 #ifdef BCMDBG
        /* check for rx fifo 0 overflow */
        delta = (u16) (wlc->core->macstat_snapshot->rxf0ovfl - rxf0ovfl);
@@ -4805,7 +4866,7 @@ void wlc_statsupd(struct wlc_info *wlc)
                 wlc->pub->_cnt->rxgiant + wlc->pub->_cnt->rxnoscb +
                 wlc->pub->_cnt->rxbadsrcmac);
        for (i = 0; i < NFIFO; i++)
-               WLCNTADD(wlc->pub->_cnt->rxerror, wlc->pub->_cnt->rxuflo[i]);
+               wlc->pub->_cnt->rxerror += wlc->pub->_cnt->rxuflo[i];
 }
 
 bool wlc_chipmatch(u16 vendor, u16 device)
@@ -4830,85 +4891,84 @@ bool wlc_chipmatch(u16 vendor, u16 device)
 #if defined(BCMDBG)
 void wlc_print_txdesc(d11txh_t *txh)
 {
-       u16 mtcl = ltoh16(txh->MacTxControlLow);
-       u16 mtch = ltoh16(txh->MacTxControlHigh);
-       u16 mfc = ltoh16(txh->MacFrameControl);
-       u16 tfest = ltoh16(txh->TxFesTimeNormal);
-       u16 ptcw = ltoh16(txh->PhyTxControlWord);
-       u16 ptcw_1 = ltoh16(txh->PhyTxControlWord_1);
-       u16 ptcw_1_Fbr = ltoh16(txh->PhyTxControlWord_1_Fbr);
-       u16 ptcw_1_Rts = ltoh16(txh->PhyTxControlWord_1_Rts);
-       u16 ptcw_1_FbrRts = ltoh16(txh->PhyTxControlWord_1_FbrRts);
-       u16 mainrates = ltoh16(txh->MainRates);
-       u16 xtraft = ltoh16(txh->XtraFrameTypes);
+       u16 mtcl = le16_to_cpu(txh->MacTxControlLow);
+       u16 mtch = le16_to_cpu(txh->MacTxControlHigh);
+       u16 mfc = le16_to_cpu(txh->MacFrameControl);
+       u16 tfest = le16_to_cpu(txh->TxFesTimeNormal);
+       u16 ptcw = le16_to_cpu(txh->PhyTxControlWord);
+       u16 ptcw_1 = le16_to_cpu(txh->PhyTxControlWord_1);
+       u16 ptcw_1_Fbr = le16_to_cpu(txh->PhyTxControlWord_1_Fbr);
+       u16 ptcw_1_Rts = le16_to_cpu(txh->PhyTxControlWord_1_Rts);
+       u16 ptcw_1_FbrRts = le16_to_cpu(txh->PhyTxControlWord_1_FbrRts);
+       u16 mainrates = le16_to_cpu(txh->MainRates);
+       u16 xtraft = le16_to_cpu(txh->XtraFrameTypes);
        u8 *iv = txh->IV;
        u8 *ra = txh->TxFrameRA;
-       u16 tfestfb = ltoh16(txh->TxFesTimeFallback);
+       u16 tfestfb = le16_to_cpu(txh->TxFesTimeFallback);
        u8 *rtspfb = txh->RTSPLCPFallback;
-       u16 rtsdfb = ltoh16(txh->RTSDurFallback);
+       u16 rtsdfb = le16_to_cpu(txh->RTSDurFallback);
        u8 *fragpfb = txh->FragPLCPFallback;
-       u16 fragdfb = ltoh16(txh->FragDurFallback);
-       u16 mmodelen = ltoh16(txh->MModeLen);
-       u16 mmodefbrlen = ltoh16(txh->MModeFbrLen);
-       u16 tfid = ltoh16(txh->TxFrameID);
-       u16 txs = ltoh16(txh->TxStatus);
-       u16 mnmpdu = ltoh16(txh->MaxNMpdus);
-       u16 mabyte = ltoh16(txh->MaxABytes_MRT);
-       u16 mabyte_f = ltoh16(txh->MaxABytes_FBR);
-       u16 mmbyte = ltoh16(txh->MinMBytes);
+       u16 fragdfb = le16_to_cpu(txh->FragDurFallback);
+       u16 mmodelen = le16_to_cpu(txh->MModeLen);
+       u16 mmodefbrlen = le16_to_cpu(txh->MModeFbrLen);
+       u16 tfid = le16_to_cpu(txh->TxFrameID);
+       u16 txs = le16_to_cpu(txh->TxStatus);
+       u16 mnmpdu = le16_to_cpu(txh->MaxNMpdus);
+       u16 mabyte = le16_to_cpu(txh->MaxABytes_MRT);
+       u16 mabyte_f = le16_to_cpu(txh->MaxABytes_FBR);
+       u16 mmbyte = le16_to_cpu(txh->MinMBytes);
 
        u8 *rtsph = txh->RTSPhyHeader;
-       struct dot11_rts_frame rts = txh->rts_frame;
+       struct ieee80211_rts rts = txh->rts_frame;
        char hexbuf[256];
 
        /* add plcp header along with txh descriptor */
        prhex("Raw TxDesc + plcp header", (unsigned char *) txh, sizeof(d11txh_t) + 48);
 
-       printf("TxCtlLow: %04x ", mtcl);
-       printf("TxCtlHigh: %04x ", mtch);
-       printf("FC: %04x ", mfc);
-       printf("FES Time: %04x\n", tfest);
-       printf("PhyCtl: %04x%s ", ptcw,
+       printk(KERN_DEBUG "TxCtlLow: %04x ", mtcl);
+       printk(KERN_DEBUG "TxCtlHigh: %04x ", mtch);
+       printk(KERN_DEBUG "FC: %04x ", mfc);
+       printk(KERN_DEBUG "FES Time: %04x\n", tfest);
+       printk(KERN_DEBUG "PhyCtl: %04x%s ", ptcw,
               (ptcw & PHY_TXC_SHORT_HDR) ? " short" : "");
-       printf("PhyCtl_1: %04x ", ptcw_1);
-       printf("PhyCtl_1_Fbr: %04x\n", ptcw_1_Fbr);
-       printf("PhyCtl_1_Rts: %04x ", ptcw_1_Rts);
-       printf("PhyCtl_1_Fbr_Rts: %04x\n", ptcw_1_FbrRts);
-       printf("MainRates: %04x ", mainrates);
-       printf("XtraFrameTypes: %04x ", xtraft);
-       printf("\n");
+       printk(KERN_DEBUG "PhyCtl_1: %04x ", ptcw_1);
+       printk(KERN_DEBUG "PhyCtl_1_Fbr: %04x\n", ptcw_1_Fbr);
+       printk(KERN_DEBUG "PhyCtl_1_Rts: %04x ", ptcw_1_Rts);
+       printk(KERN_DEBUG "PhyCtl_1_Fbr_Rts: %04x\n", ptcw_1_FbrRts);
+       printk(KERN_DEBUG "MainRates: %04x ", mainrates);
+       printk(KERN_DEBUG "XtraFrameTypes: %04x ", xtraft);
+       printk(KERN_DEBUG "\n");
 
        bcm_format_hex(hexbuf, iv, sizeof(txh->IV));
-       printf("SecIV:       %s\n", hexbuf);
+       printk(KERN_DEBUG "SecIV:       %s\n", hexbuf);
        bcm_format_hex(hexbuf, ra, sizeof(txh->TxFrameRA));
-       printf("RA:          %s\n", hexbuf);
+       printk(KERN_DEBUG "RA:          %s\n", hexbuf);
 
-       printf("Fb FES Time: %04x ", tfestfb);
+       printk(KERN_DEBUG "Fb FES Time: %04x ", tfestfb);
        bcm_format_hex(hexbuf, rtspfb, sizeof(txh->RTSPLCPFallback));
-       printf("RTS PLCP: %s ", hexbuf);
-       printf("RTS DUR: %04x ", rtsdfb);
+       printk(KERN_DEBUG "RTS PLCP: %s ", hexbuf);
+       printk(KERN_DEBUG "RTS DUR: %04x ", rtsdfb);
        bcm_format_hex(hexbuf, fragpfb, sizeof(txh->FragPLCPFallback));
-       printf("PLCP: %s ", hexbuf);
-       printf("DUR: %04x", fragdfb);
-       printf("\n");
+       printk(KERN_DEBUG "PLCP: %s ", hexbuf);
+       printk(KERN_DEBUG "DUR: %04x", fragdfb);
+       printk(KERN_DEBUG "\n");
 
-       printf("MModeLen: %04x ", mmodelen);
-       printf("MModeFbrLen: %04x\n", mmodefbrlen);
+       printk(KERN_DEBUG "MModeLen: %04x ", mmodelen);
+       printk(KERN_DEBUG "MModeFbrLen: %04x\n", mmodefbrlen);
 
-       printf("FrameID:     %04x\n", tfid);
-       printf("TxStatus:    %04x\n", txs);
+       printk(KERN_DEBUG "FrameID:     %04x\n", tfid);
+       printk(KERN_DEBUG "TxStatus:    %04x\n", txs);
 
-       printf("MaxNumMpdu:  %04x\n", mnmpdu);
-       printf("MaxAggbyte:  %04x\n", mabyte);
-       printf("MaxAggbyte_fb:  %04x\n", mabyte_f);
-       printf("MinByte:     %04x\n", mmbyte);
+       printk(KERN_DEBUG "MaxNumMpdu:  %04x\n", mnmpdu);
+       printk(KERN_DEBUG "MaxAggbyte:  %04x\n", mabyte);
+       printk(KERN_DEBUG "MaxAggbyte_fb:  %04x\n", mabyte_f);
+       printk(KERN_DEBUG "MinByte:     %04x\n", mmbyte);
 
        bcm_format_hex(hexbuf, rtsph, sizeof(txh->RTSPhyHeader));
-       printf("RTS PLCP: %s ", hexbuf);
+       printk(KERN_DEBUG "RTS PLCP: %s ", hexbuf);
        bcm_format_hex(hexbuf, (u8 *) &rts, sizeof(txh->rts_frame));
-       printf("RTS Frame: %s", hexbuf);
-       printf("\n");
-
+       printk(KERN_DEBUG "RTS Frame: %s", hexbuf);
+       printk(KERN_DEBUG "\n");
 }
 #endif                         /* defined(BCMDBG) */
 
@@ -4940,13 +5000,14 @@ void wlc_print_rxh(d11rxhdr_t *rxh)
 
        snprintf(lenbuf, sizeof(lenbuf), "0x%x", len);
 
-       printf("RxFrameSize:     %6s (%d)%s\n", lenbuf, len,
+       printk(KERN_DEBUG "RxFrameSize:     %6s (%d)%s\n", lenbuf, len,
               (rxh->PhyRxStatus_0 & PRXS0_SHORTH) ? " short preamble" : "");
-       printf("RxPHYStatus:     %04x %04x %04x %04x\n",
+       printk(KERN_DEBUG "RxPHYStatus:     %04x %04x %04x %04x\n",
               phystatus_0, phystatus_1, phystatus_2, phystatus_3);
-       printf("RxMACStatus:     %x %s\n", macstatus1, flagstr);
-       printf("RXMACaggtype: %x\n", (macstatus2 & RXS_AGGTYPE_MASK));
-       printf("RxTSFTime:       %04x\n", rxh->RxTSFTime);
+       printk(KERN_DEBUG "RxMACStatus:     %x %s\n", macstatus1, flagstr);
+       printk(KERN_DEBUG "RXMACaggtype:    %x\n",
+              (macstatus2 & RXS_AGGTYPE_MASK));
+       printk(KERN_DEBUG "RxTSFTime:       %04x\n", rxh->RxTSFTime);
 }
 #endif                         /* defined(BCMDBG) */
 
@@ -4957,8 +5018,8 @@ int wlc_format_ssid(char *buf, const unsigned char ssid[], uint ssid_len)
        char *p = buf;
        char *endp = buf + SSID_FMT_BUF_LEN;
 
-       if (ssid_len > DOT11_MAX_SSID_LEN)
-               ssid_len = DOT11_MAX_SSID_LEN;
+       if (ssid_len > IEEE80211_MAX_SSID_LEN)
+               ssid_len = IEEE80211_MAX_SSID_LEN;
 
        for (i = 0; i < ssid_len; i++) {
                c = (uint) ssid[i];
@@ -4978,7 +5039,7 @@ int wlc_format_ssid(char *buf, const unsigned char ssid[], uint ssid_len)
 }
 #endif                         /* defined(BCMDBG) */
 
-u16 wlc_rate_shm_offset(struct wlc_info *wlc, u8 rate)
+static u16 wlc_rate_shm_offset(struct wlc_info *wlc, u8 rate)
 {
        return wlc_bmac_rate_shm_offset(wlc->hw, rate);
 }
@@ -5047,12 +5108,10 @@ wlc_prec_enq_head(struct wlc_info *wlc, struct pktq *q, struct sk_buff *pkt,
                                  tx_failed[WME_PRIO2AC(p->priority)].packets);
                        WLCNTADD(wlc->pub->_wme_cnt->
                                 tx_failed[WME_PRIO2AC(p->priority)].bytes,
-                                pkttotlen(wlc->osh, p));
+                                pkttotlen(p));
                }
-
-               ASSERT(0);
-               pkt_buf_free_skb(wlc->osh, p, true);
-               WLCNTINCR(wlc->pub->_cnt->txnobuf);
+               pkt_buf_free_skb(p);
+               wlc->pub->_cnt->txnobuf++;
        }
 
        /* Enqueue */
@@ -5069,7 +5128,7 @@ void BCMFASTPATH wlc_txq_enq(void *ctx, struct scb *scb, struct sk_buff *sdu,
                             uint prec)
 {
        struct wlc_info *wlc = (struct wlc_info *) ctx;
-       wlc_txq_info_t *qi = wlc->active_queue; /* Check me */
+       struct wlc_txq_info *qi = wlc->active_queue;    /* Check me */
        struct pktq *q = &qi->q;
        int prio;
 
@@ -5083,9 +5142,12 @@ void BCMFASTPATH wlc_txq_enq(void *ctx, struct scb *scb, struct sk_buff *sdu,
                        WL_ERROR("wl%d: wlc_txq_enq: txq overflow\n",
                                 wlc->pub->unit);
 
-               /* ASSERT(9 == 8); *//* XXX we might hit this condtion in case packet flooding from mac80211 stack */
-               pkt_buf_free_skb(wlc->osh, sdu, true);
-               WLCNTINCR(wlc->pub->_cnt->txnobuf);
+               /*
+                * XXX we might hit this condtion in case
+                * packet flooding from mac80211 stack
+                */
+               pkt_buf_free_skb(sdu);
+               wlc->pub->_cnt->txnobuf++;
        }
 
        /* Check if flow control needs to be turned on after enqueuing the packet
@@ -5113,16 +5175,13 @@ wlc_sendpkt_mac80211(struct wlc_info *wlc, struct sk_buff *sdu,
        uint fifo;
        void *pkt;
        struct scb *scb = &global_scb;
-       struct dot11_header *d11_header = (struct dot11_header *)(sdu->data);
-       u16 type, fc;
+       struct ieee80211_hdr *d11_header = (struct ieee80211_hdr *)(sdu->data);
 
        ASSERT(sdu);
 
-       fc = ltoh16(d11_header->fc);
-       type = FC_TYPE(fc);
-
        /* 802.11 standard requires management traffic to go at highest priority */
-       prio = (type == FC_TYPE_DATA ? sdu->priority : MAXPRIO);
+       prio = ieee80211_is_data(d11_header->frame_control) ? sdu->priority :
+               MAXPRIO;
        fifo = prio2fifo[prio];
 
        ASSERT((uint) skb_headroom(sdu) >= TXOFF);
@@ -5137,11 +5196,11 @@ wlc_sendpkt_mac80211(struct wlc_info *wlc, struct sk_buff *sdu,
        wlc_txq_enq(wlc, scb, pkt, WLC_PRIO_TO_PREC(prio));
        wlc_send_q(wlc, wlc->active_queue);
 
-       WLCNTINCR(wlc->pub->_cnt->ieee_tx);
+       wlc->pub->_cnt->ieee_tx++;
        return 0;
 }
 
-void BCMFASTPATH wlc_send_q(struct wlc_info *wlc, wlc_txq_info_t *qi)
+void BCMFASTPATH wlc_send_q(struct wlc_info *wlc, struct wlc_txq_info *qi)
 {
        struct sk_buff *pkt[DOT11_MAXNUMFRAGS];
        int prec;
@@ -5216,11 +5275,13 @@ void BCMFASTPATH wlc_send_q(struct wlc_info *wlc, wlc_txq_info_t *qi)
  * for MC frames so is used as part of the sequence number.
  */
 static inline u16
-bcmc_fid_generate(struct wlc_info *wlc, wlc_bsscfg_t *bsscfg, d11txh_t *txh)
+bcmc_fid_generate(struct wlc_info *wlc, struct wlc_bsscfg *bsscfg,
+                 d11txh_t *txh)
 {
        u16 frameid;
 
-       frameid = ltoh16(txh->TxFrameID) & ~(TXFID_SEQ_MASK | TXFID_QUEUE_MASK);
+       frameid = le16_to_cpu(txh->TxFrameID) & ~(TXFID_SEQ_MASK |
+                                                 TXFID_QUEUE_MASK);
        frameid |=
            (((wlc->
               mc_fid_counter++) << TXFID_SEQ_SHIFT) & TXFID_SEQ_MASK) |
@@ -5243,7 +5304,7 @@ wlc_txfifo(struct wlc_info *wlc, uint fifo, struct sk_buff *p, bool commit,
         * ucode or BSS info as appropriate.
         */
        if (fifo == TX_BCMC_FIFO) {
-               frameid = ltoh16(txh->TxFrameID);
+               frameid = le16_to_cpu(txh->TxFrameID);
 
        }
 
@@ -5650,13 +5711,12 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
                     uint nfrags, uint queue, uint next_frag_len,
                     wsec_key_t *key, ratespec_t rspec_override)
 {
-       struct dot11_header *h;
+       struct ieee80211_hdr *h;
        d11txh_t *txh;
        u8 *plcp, plcp_fallback[D11_PHY_HDR_LEN];
-       struct osl_info *osh;
        int len, phylen, rts_phylen;
-       u16 fc, type, frameid, mch, phyctl, xfts, mainrates;
-       u16 seq = 0, mcl = 0, status = 0;
+       u16 mch, phyctl, xfts, mainrates;
+       u16 seq = 0, mcl = 0, status = 0, frameid = 0;
        ratespec_t rspec[2] = { WLC_RATE_1M, WLC_RATE_1M }, rts_rspec[2] = {
        WLC_RATE_1M, WLC_RATE_1M};
        bool use_rts = false;
@@ -5666,17 +5726,15 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
        u8 preamble_type[2] = { WLC_LONG_PREAMBLE, WLC_LONG_PREAMBLE };
        u8 rts_preamble_type[2] = { WLC_LONG_PREAMBLE, WLC_LONG_PREAMBLE };
        u8 *rts_plcp, rts_plcp_fallback[D11_PHY_HDR_LEN];
-       struct dot11_rts_frame *rts = NULL;
+       struct ieee80211_rts *rts = NULL;
        bool qos;
        uint ac;
        u32 rate_val[2];
        bool hwtkmic = false;
        u16 mimo_ctlchbw = PHY_TXC1_BW_20MHZ;
-#ifdef WLANTSEL
 #define ANTCFG_NONE 0xFF
        u8 antcfg = ANTCFG_NONE;
        u8 fbantcfg = ANTCFG_NONE;
-#endif
        uint phyctl1_stf = 0;
        u16 durid = 0;
        struct ieee80211_tx_rate *txrate[2];
@@ -5686,22 +5744,15 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
        u16 mimo_txbw;
        u8 mimo_preamble_type;
 
-       frameid = 0;
-
        ASSERT(queue < NFIFO);
 
-       osh = wlc->osh;
-
        /* locate 802.11 MAC header */
-       h = (struct dot11_header *)(p->data);
-       fc = ltoh16(h->fc);
-       type = FC_TYPE(fc);
-
-       qos = (type == FC_TYPE_DATA && FC_SUBTYPE_ANY_QOS(FC_SUBTYPE(fc)));
+       h = (struct ieee80211_hdr *)(p->data);
+       qos = ieee80211_is_data_qos(h->frame_control);
 
        /* compute length of frame in bytes for use in PLCP computations */
-       len = pkttotlen(osh, p);
-       phylen = len + DOT11_FCS_LEN;
+       len = pkttotlen(p);
+       phylen = len + FCS_LEN;
 
        /* If WEP enabled, add room in phylen for the additional bytes of
         * ICV which MAC generates.  We do NOT add the additional bytes to
@@ -5721,7 +5772,7 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
 
        /* add Broadcom tx descriptor header */
        txh = (d11txh_t *) skb_push(p, D11_TXH_LEN);
-       memset((char *)txh, 0, D11_TXH_LEN);
+       memset(txh, 0, D11_TXH_LEN);
 
        /* setup frameid */
        if (tx_info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) {
@@ -5738,9 +5789,9 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
                        }
 
                        /* extract fragment number from frame first */
-                       seq = ltoh16(seq) & FRAGNUM_MASK;
+                       seq = le16_to_cpu(seq) & FRAGNUM_MASK;
                        seq |= (SCB_SEQNUM(scb, p->priority) << SEQNUM_SHIFT);
-                       h->seq = htol16(seq);
+                       h->seq_ctrl = cpu_to_le16(seq);
 
                        frameid = ((seq << TXFID_SEQ_SHIFT) & TXFID_SEQ_MASK) |
                            (queue & TXFID_QUEUE_MASK);
@@ -5749,7 +5800,7 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
        frameid |= queue & TXFID_QUEUE_MASK;
 
        /* set the ignpmq bit for all pkts tx'd in PS mode and for beacons */
-       if (SCB_PS(scb) || ((fc & FC_KIND_MASK) == FC_BEACON))
+       if (SCB_PS(scb) || ieee80211_is_beacon(h->frame_control))
                mcl |= TXC_IGNOREPMQ;
 
        ASSERT(hw->max_rates <= IEEE80211_TX_MAX_RATES);
@@ -5809,8 +5860,7 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
                        ASSERT(RSPEC_ACTIVE(rspec[k]));
                        rspec[k] = WLC_RATE_1M;
                } else {
-                       if (WLANTSEL_ENAB(wlc) &&
-                           !is_multicast_ether_addr(h->a1.octet)) {
+                       if (!is_multicast_ether_addr(h->addr1)) {
                                /* set tx antenna config */
                                wlc_antsel_antcfg_get(wlc->asi, false, false, 0,
                                                      0, &antcfg, &fbantcfg);
@@ -5954,11 +6004,17 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
        txrate[0]->count = 0;
        txrate[1]->count = 0;
 
+       /* (2) PROTECTION, may change rspec */
+       if ((ieee80211_is_data(h->frame_control) ||
+           ieee80211_is_mgmt(h->frame_control)) &&
+           (phylen > wlc->RTSThresh) && !is_multicast_ether_addr(h->addr1))
+               use_rts = true;
+
        /* (3) PLCP: determine PLCP header and MAC duration, fill d11txh_t */
        wlc_compute_plcp(wlc, rspec[0], phylen, plcp);
        wlc_compute_plcp(wlc, rspec[1], phylen, plcp_fallback);
-       bcopy(plcp_fallback, (char *)&txh->FragPLCPFallback,
-             sizeof(txh->FragPLCPFallback));
+       memcpy(&txh->FragPLCPFallback,
+              plcp_fallback, sizeof(txh->FragPLCPFallback));
 
        /* Length field now put in CCK FBR CRC field */
        if (IS_CCK(rspec[1])) {
@@ -5972,12 +6028,12 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
            plcp[0];
 
        /* DUR field for main rate */
-       if ((fc != FC_PS_POLL) &&
-           !is_multicast_ether_addr(h->a1.octet) && !use_rifs) {
+       if (!ieee80211_is_pspoll(h->frame_control) &&
+           !is_multicast_ether_addr(h->addr1) && !use_rifs) {
                durid =
                    wlc_compute_frame_dur(wlc, rspec[0], preamble_type[0],
                                          next_frag_len);
-               h->durid = htol16(durid);
+               h->duration_id = cpu_to_le16(durid);
        } else if (use_rifs) {
                /* NAV protect to end of next max packet size */
                durid =
@@ -5985,25 +6041,25 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
                                                 preamble_type[0],
                                                 DOT11_MAX_FRAG_LEN);
                durid += RIFS_11N_TIME;
-               h->durid = htol16(durid);
+               h->duration_id = cpu_to_le16(durid);
        }
 
        /* DUR field for fallback rate */
-       if (fc == FC_PS_POLL)
-               txh->FragDurFallback = h->durid;
-       else if (is_multicast_ether_addr(h->a1.octet) || use_rifs)
+       if (ieee80211_is_pspoll(h->frame_control))
+               txh->FragDurFallback = h->duration_id;
+       else if (is_multicast_ether_addr(h->addr1) || use_rifs)
                txh->FragDurFallback = 0;
        else {
                durid = wlc_compute_frame_dur(wlc, rspec[1],
                                              preamble_type[1], next_frag_len);
-               txh->FragDurFallback = htol16(durid);
+               txh->FragDurFallback = cpu_to_le16(durid);
        }
 
        /* (4) MAC-HDR: MacTxControlLow */
        if (frag == 0)
                mcl |= TXC_STARTMSDU;
 
-       if (!is_multicast_ether_addr(h->a1.octet))
+       if (!is_multicast_ether_addr(h->addr1))
                mcl |= TXC_IMMEDACK;
 
        if (BAND_5G(wlc->band->bandtype))
@@ -6016,7 +6072,7 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
        if (hwtkmic)
                mcl |= TXC_AMIC;
 
-       txh->MacTxControlLow = htol16(mcl);
+       txh->MacTxControlLow = cpu_to_le16(mcl);
 
        /* MacTxControlHigh */
        mch = 0;
@@ -6031,33 +6087,29 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
        }
 
        /* MacFrameControl */
-       bcopy((char *)&h->fc, (char *)&txh->MacFrameControl, sizeof(u16));
+       memcpy(&txh->MacFrameControl, &h->frame_control, sizeof(u16));
+       txh->TxFesTimeNormal = cpu_to_le16(0);
 
-       txh->TxFesTimeNormal = htol16(0);
-
-       txh->TxFesTimeFallback = htol16(0);
+       txh->TxFesTimeFallback = cpu_to_le16(0);
 
        /* TxFrameRA */
-       bcopy((char *)&h->a1, (char *)&txh->TxFrameRA, ETH_ALEN);
+       memcpy(&txh->TxFrameRA, &h->addr1, ETH_ALEN);
 
        /* TxFrameID */
-       txh->TxFrameID = htol16(frameid);
+       txh->TxFrameID = cpu_to_le16(frameid);
 
        /* TxStatus, Note the case of recreating the first frag of a suppressed frame
         * then we may need to reset the retry cnt's via the status reg
         */
-       txh->TxStatus = htol16(status);
+       txh->TxStatus = cpu_to_le16(status);
 
-       if (D11REV_GE(wlc->pub->corerev, 16)) {
-               /* extra fields for ucode AMPDU aggregation, the new fields are added to
-                * the END of previous structure so that it's compatible in driver.
-                * In old rev ucode, these fields should be ignored
-                */
-               txh->MaxNMpdus = htol16(0);
-               txh->MaxABytes_MRT = htol16(0);
-               txh->MaxABytes_FBR = htol16(0);
-               txh->MinMBytes = htol16(0);
-       }
+       /* extra fields for ucode AMPDU aggregation, the new fields are added to
+        * the END of previous structure so that it's compatible in driver.
+        */
+       txh->MaxNMpdus = cpu_to_le16(0);
+       txh->MaxABytes_MRT = cpu_to_le16(0);
+       txh->MaxABytes_FBR = cpu_to_le16(0);
+       txh->MinMBytes = cpu_to_le16(0);
 
        /* (5) RTS/CTS: determine RTS/CTS PLCP header and MAC duration, furnish d11txh_t */
        /* RTS PLCP header and RTS frame */
@@ -6087,49 +6139,52 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
 
                /* RTS/CTS additions to MacTxControlLow */
                if (use_cts) {
-                       txh->MacTxControlLow |= htol16(TXC_SENDCTS);
+                       txh->MacTxControlLow |= cpu_to_le16(TXC_SENDCTS);
                } else {
-                       txh->MacTxControlLow |= htol16(TXC_SENDRTS);
-                       txh->MacTxControlLow |= htol16(TXC_LONGFRAME);
+                       txh->MacTxControlLow |= cpu_to_le16(TXC_SENDRTS);
+                       txh->MacTxControlLow |= cpu_to_le16(TXC_LONGFRAME);
                }
 
                /* RTS PLCP header */
                ASSERT(IS_ALIGNED((unsigned long)txh->RTSPhyHeader, sizeof(u16)));
                rts_plcp = txh->RTSPhyHeader;
                if (use_cts)
-                       rts_phylen = DOT11_CTS_LEN + DOT11_FCS_LEN;
+                       rts_phylen = DOT11_CTS_LEN + FCS_LEN;
                else
-                       rts_phylen = DOT11_RTS_LEN + DOT11_FCS_LEN;
+                       rts_phylen = DOT11_RTS_LEN + FCS_LEN;
 
                wlc_compute_plcp(wlc, rts_rspec[0], rts_phylen, rts_plcp);
 
                /* fallback rate version of RTS PLCP header */
                wlc_compute_plcp(wlc, rts_rspec[1], rts_phylen,
                                 rts_plcp_fallback);
-               bcopy(rts_plcp_fallback, (char *)&txh->RTSPLCPFallback,
-                     sizeof(txh->RTSPLCPFallback));
+               memcpy(&txh->RTSPLCPFallback, rts_plcp_fallback,
+                      sizeof(txh->RTSPLCPFallback));
 
                /* RTS frame fields... */
-               rts = (struct dot11_rts_frame *)&txh->rts_frame;
+               rts = (struct ieee80211_rts *)&txh->rts_frame;
 
                durid = wlc_compute_rtscts_dur(wlc, use_cts, rts_rspec[0],
                                               rspec[0], rts_preamble_type[0],
                                               preamble_type[0], phylen, false);
-               rts->durid = htol16(durid);
+               rts->duration = cpu_to_le16(durid);
                /* fallback rate version of RTS DUR field */
                durid = wlc_compute_rtscts_dur(wlc, use_cts,
                                               rts_rspec[1], rspec[1],
                                               rts_preamble_type[1],
                                               preamble_type[1], phylen, false);
-               txh->RTSDurFallback = htol16(durid);
+               txh->RTSDurFallback = cpu_to_le16(durid);
 
                if (use_cts) {
-                       rts->fc = htol16(FC_CTS);
-                       bcopy((char *)&h->a2, (char *)&rts->ra, ETH_ALEN);
+                       rts->frame_control = cpu_to_le16(IEEE80211_FTYPE_CTL |
+                                                        IEEE80211_STYPE_CTS);
+
+                       memcpy(&rts->ra, &h->addr2, ETH_ALEN);
                } else {
-                       rts->fc = htol16((u16) FC_RTS);
-                       bcopy((char *)&h->a1, (char *)&rts->ra,
-                             2 * ETH_ALEN);
+                       rts->frame_control = cpu_to_le16(IEEE80211_FTYPE_CTL |
+                                                        IEEE80211_STYPE_RTS);
+
+                       memcpy(&rts->ra, &h->addr1, 2 * ETH_ALEN);
                }
 
                /* mainrate
@@ -6142,7 +6197,7 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
        } else {
                memset((char *)txh->RTSPhyHeader, 0, D11_PHY_HDR_LEN);
                memset((char *)&txh->rts_frame, 0,
-                       sizeof(struct dot11_rts_frame));
+                       sizeof(struct ieee80211_rts));
                memset((char *)txh->RTSPLCPFallback, 0,
                      sizeof(txh->RTSPLCPFallback));
                txh->RTSDurFallback = 0;
@@ -6157,10 +6212,10 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
 #endif
 
        /* Now that RTS/RTS FB preamble types are updated, write the final value */
-       txh->MacTxControlHigh = htol16(mch);
+       txh->MacTxControlHigh = cpu_to_le16(mch);
 
        /* MainRates (both the rts and frag plcp rates have been calculated now) */
-       txh->MainRates = htol16(mainrates);
+       txh->MainRates = cpu_to_le16(mainrates);
 
        /* XtraFrameTypes */
        xfts = FRAMETYPE(rspec[1], wlc->mimoft);
@@ -6168,7 +6223,7 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
        xfts |= (FRAMETYPE(rts_rspec[1], wlc->mimoft) << XFTS_FBRRTS_FT_SHIFT);
        xfts |=
            CHSPEC_CHANNEL(WLC_BAND_PI_RADIO_CHANSPEC) << XFTS_CHANNEL_SHIFT;
-       txh->XtraFrameTypes = htol16(xfts);
+       txh->XtraFrameTypes = cpu_to_le16(xfts);
 
        /* PhyTxControlWord */
        phyctl = FRAMETYPE(rspec[0], wlc->mimoft);
@@ -6178,27 +6233,27 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
                       || !IS_MCS(rspec[0]));
                if (RSPEC2RATE(rspec[0]) != WLC_RATE_1M)
                        phyctl |= PHY_TXC_SHORT_HDR;
-               WLCNTINCR(wlc->pub->_cnt->txprshort);
+               wlc->pub->_cnt->txprshort++;
        }
 
        /* phytxant is properly bit shifted */
        phyctl |= wlc_stf_d11hdrs_phyctl_txant(wlc, rspec[0]);
-       txh->PhyTxControlWord = htol16(phyctl);
+       txh->PhyTxControlWord = cpu_to_le16(phyctl);
 
        /* PhyTxControlWord_1 */
        if (WLC_PHY_11N_CAP(wlc->band)) {
                u16 phyctl1 = 0;
 
                phyctl1 = wlc_phytxctl1_calc(wlc, rspec[0]);
-               txh->PhyTxControlWord_1 = htol16(phyctl1);
+               txh->PhyTxControlWord_1 = cpu_to_le16(phyctl1);
                phyctl1 = wlc_phytxctl1_calc(wlc, rspec[1]);
-               txh->PhyTxControlWord_1_Fbr = htol16(phyctl1);
+               txh->PhyTxControlWord_1_Fbr = cpu_to_le16(phyctl1);
 
                if (use_rts || use_cts) {
                        phyctl1 = wlc_phytxctl1_calc(wlc, rts_rspec[0]);
-                       txh->PhyTxControlWord_1_Rts = htol16(phyctl1);
+                       txh->PhyTxControlWord_1_Rts = cpu_to_le16(phyctl1);
                        phyctl1 = wlc_phytxctl1_calc(wlc, rts_rspec[1]);
-                       txh->PhyTxControlWord_1_FbrRts = htol16(phyctl1);
+                       txh->PhyTxControlWord_1_FbrRts = cpu_to_le16(phyctl1);
                }
 
                /*
@@ -6209,13 +6264,13 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
                if (IS_MCS(rspec[0]) && (preamble_type[0] == WLC_MM_PREAMBLE)) {
                        u16 mmodelen =
                            wlc_calc_lsig_len(wlc, rspec[0], phylen);
-                       txh->MModeLen = htol16(mmodelen);
+                       txh->MModeLen = cpu_to_le16(mmodelen);
                }
 
                if (IS_MCS(rspec[1]) && (preamble_type[1] == WLC_MM_PREAMBLE)) {
                        u16 mmodefbrlen =
                            wlc_calc_lsig_len(wlc, rspec[1], phylen);
-                       txh->MModeFbrLen = htol16(mmodefbrlen);
+                       txh->MModeFbrLen = cpu_to_le16(mmodefbrlen);
                }
        }
 
@@ -6232,7 +6287,7 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
        if (SCB_WME(scb) && qos && wlc->edcf_txop[ac]) {
                uint frag_dur, dur, dur_fallback;
 
-               ASSERT(!is_multicast_ether_addr(h->a1.octet));
+               ASSERT(!is_multicast_ether_addr(h->addr1));
 
                /* WME: Update TXOP threshold */
                if ((!(tx_info->flags & IEEE80211_TX_CTL_AMPDU)) && (frag == 0)) {
@@ -6249,8 +6304,9 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
                                    wlc_calc_cts_time(wlc, rts_rspec[1],
                                                      rts_preamble_type[1]);
                                /* (SIFS + CTS) + SIFS + frame + SIFS + ACK */
-                               dur += ltoh16(rts->durid);
-                               dur_fallback += ltoh16(txh->RTSDurFallback);
+                               dur += le16_to_cpu(rts->duration);
+                               dur_fallback +=
+                                       le16_to_cpu(txh->RTSDurFallback);
                        } else if (use_rifs) {
                                dur = frag_dur;
                                dur_fallback = 0;
@@ -6270,9 +6326,10 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
                                                          preamble_type[1], 0);
                        }
                        /* NEED to set TxFesTimeNormal (hard) */
-                       txh->TxFesTimeNormal = htol16((u16) dur);
+                       txh->TxFesTimeNormal = cpu_to_le16((u16) dur);
                        /* NEED to set fallback rate version of TxFesTimeNormal (hard) */
-                       txh->TxFesTimeFallback = htol16((u16) dur_fallback);
+                       txh->TxFesTimeFallback =
+                               cpu_to_le16((u16) dur_fallback);
 
                        /* update txop byte threshold (txop minus intraframe overhead) */
                        if (wlc->edcf_txop[ac] >= (dur - frag_dur)) {
@@ -6320,9 +6377,9 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
 
 void wlc_tbtt(struct wlc_info *wlc, d11regs_t *regs)
 {
-       wlc_bsscfg_t *cfg = wlc->cfg;
+       struct wlc_bsscfg *cfg = wlc->cfg;
 
-       WLCNTINCR(wlc->pub->_cnt->tbtt);
+       wlc->pub->_cnt->tbtt++;
 
        if (BSSCFG_STA(cfg)) {
                /* run watchdog here if the watchdog timer is not armed */
@@ -6356,14 +6413,12 @@ void wlc_tbtt(struct wlc_info *wlc, d11regs_t *regs)
 /* GP timer is a freerunning 32 bit counter, decrements at 1 us rate */
 void wlc_hwtimer_gptimer_set(struct wlc_info *wlc, uint us)
 {
-       ASSERT(wlc->pub->corerev >= 3); /* no gptimer in earlier revs */
-       W_REG(wlc->osh, &wlc->regs->gptimer, us);
+       W_REG(&wlc->regs->gptimer, us);
 }
 
 void wlc_hwtimer_gptimer_abort(struct wlc_info *wlc)
 {
-       ASSERT(wlc->pub->corerev >= 3);
-       W_REG(wlc->osh, &wlc->regs->gptimer, 0);
+       W_REG(&wlc->regs->gptimer, 0);
 }
 
 static void wlc_hwtimer_gptimer_cb(struct wlc_info *wlc)
@@ -6371,7 +6426,7 @@ static void wlc_hwtimer_gptimer_cb(struct wlc_info *wlc)
        /* when interrupt is generated, the counter is loaded with last value
         * written and continue to decrement. So it has to be cleaned first
         */
-       W_REG(wlc->osh, &wlc->regs->gptimer, 0);
+       W_REG(&wlc->regs->gptimer, 0);
 }
 
 /*
@@ -6440,7 +6495,7 @@ void wlc_high_dpc(struct wlc_info *wlc, u32 macintstatus)
                                        __func__, wlc->pub->sih->chip,
                                        wlc->pub->sih->chiprev);
 
-               WLCNTINCR(wlc->pub->_cnt->psmwds);
+               wlc->pub->_cnt->psmwds++;
 
                /* big hammer */
                wl_init(wlc->wl);
@@ -6454,11 +6509,11 @@ void wlc_high_dpc(struct wlc_info *wlc, u32 macintstatus)
        if (macintstatus & MI_RFDISABLE) {
                WL_ERROR("wl%d: MAC Detected a change on the RF Disable Input 0x%x\n",
                         wlc->pub->unit,
-                        R_REG(wlc->osh, &regs->phydebug) & PDBG_RFD);
+                        R_REG(&regs->phydebug) & PDBG_RFD);
                /* delay the cleanup to wl_down in IBSS case */
-               if ((R_REG(wlc->osh, &regs->phydebug) & PDBG_RFD)) {
+               if ((R_REG(&regs->phydebug) & PDBG_RFD)) {
                        int idx;
-                       wlc_bsscfg_t *bsscfg;
+                       struct wlc_bsscfg *bsscfg;
                        FOREACH_BSS(wlc, idx, bsscfg) {
                                if (!BSSCFG_STA(bsscfg) || !bsscfg->enable
                                    || !bsscfg->BSS)
@@ -6476,37 +6531,6 @@ void wlc_high_dpc(struct wlc_info *wlc, u32 macintstatus)
        ASSERT(wlc_ps_check(wlc));
 }
 
-static void *wlc_15420war(struct wlc_info *wlc, uint queue)
-{
-       struct hnddma_pub *di;
-       void *p;
-
-       ASSERT(queue < NFIFO);
-
-       if ((D11REV_IS(wlc->pub->corerev, 4))
-           || (D11REV_GT(wlc->pub->corerev, 6)))
-               return NULL;
-
-       di = wlc->hw->di[queue];
-       ASSERT(di != NULL);
-
-       /* get next packet, ignoring XmtStatus.Curr */
-       p = dma_getnexttxp(di, HNDDMA_RANGE_ALL);
-
-       /* sw block tx dma */
-       dma_txblock(di);
-
-       /* if tx ring is now empty, reset and re-init the tx dma channel */
-       if (dma_txactive(wlc->hw->di[queue]) == 0) {
-               WLCNTINCR(wlc->pub->_cnt->txdmawar);
-               if (!dma_txreset(di))
-                       WL_ERROR("wl%d: %s: dma_txreset[%d]: cannot stop dma\n",
-                                wlc->pub->unit, __func__, queue);
-               dma_txinit(di);
-       }
-       return p;
-}
-
 static void wlc_war16165(struct wlc_info *wlc, bool tx)
 {
        if (tx) {
@@ -6530,12 +6554,10 @@ wlc_dotxstatus(struct wlc_info *wlc, tx_status_t *txs, u32 frm_tx2)
        d11txh_t *txh;
        struct scb *scb = NULL;
        bool free_pdu;
-       struct osl_info *osh;
        int tx_rts, tx_frame_count, tx_rts_count;
        uint totlen, supr_status;
        bool lastframe;
-       struct dot11_header *h;
-       u16 fc;
+       struct ieee80211_hdr *h;
        u16 mcl;
        struct ieee80211_tx_info *tx_info;
        struct ieee80211_tx_rate *txrate;
@@ -6558,7 +6580,6 @@ wlc_dotxstatus(struct wlc_info *wlc, tx_status_t *txs, u32 frm_tx2)
                return false;
        }
 
-       osh = wlc->osh;
        queue = txs->frameid & TXFID_QUEUE_MASK;
        ASSERT(queue < NFIFO);
        if (queue >= NFIFO) {
@@ -6569,38 +6590,37 @@ wlc_dotxstatus(struct wlc_info *wlc, tx_status_t *txs, u32 frm_tx2)
        p = GETNEXTTXP(wlc, queue);
        if (WLC_WAR16165(wlc))
                wlc_war16165(wlc, false);
-       if (p == NULL)
-               p = wlc_15420war(wlc, queue);
-       ASSERT(p != NULL);
        if (p == NULL)
                goto fatal;
 
        txh = (d11txh_t *) (p->data);
-       mcl = ltoh16(txh->MacTxControlLow);
+       mcl = le16_to_cpu(txh->MacTxControlLow);
 
        if (txs->phyerr) {
-               WL_ERROR("phyerr 0x%x, rate 0x%x\n",
-                        txs->phyerr, txh->MainRates);
-               wlc_print_txdesc(txh);
+               if (WL_ERROR_ON()) {
+                       WL_ERROR("phyerr 0x%x, rate 0x%x\n",
+                                txs->phyerr, txh->MainRates);
+                       wlc_print_txdesc(txh);
+               }
                wlc_print_txstatus(txs);
        }
 
-       ASSERT(txs->frameid == htol16(txh->TxFrameID));
-       if (txs->frameid != htol16(txh->TxFrameID))
+       ASSERT(txs->frameid == cpu_to_le16(txh->TxFrameID));
+       if (txs->frameid != cpu_to_le16(txh->TxFrameID))
                goto fatal;
 
        tx_info = IEEE80211_SKB_CB(p);
-       h = (struct dot11_header *)((u8 *) (txh + 1) + D11_PHY_HDR_LEN);
-       fc = ltoh16(h->fc);
+       h = (struct ieee80211_hdr *)((u8 *) (txh + 1) + D11_PHY_HDR_LEN);
 
-       scb = (struct scb *)tx_info->control.sta->drv_priv;
+       if (tx_info->control.sta)
+               scb = (struct scb *)tx_info->control.sta->drv_priv;
 
        if (N_ENAB(wlc->pub)) {
                u8 *plcp = (u8 *) (txh + 1);
                if (PLCP3_ISSGI(plcp[3]))
-                       WLCNTINCR(wlc->pub->_cnt->txmpdu_sgi);
+                       wlc->pub->_cnt->txmpdu_sgi++;
                if (PLCP3_ISSTBC(plcp[3]))
-                       WLCNTINCR(wlc->pub->_cnt->txmpdu_stbc);
+                       wlc->pub->_cnt->txmpdu_stbc++;
        }
 
        if (tx_info->flags & IEEE80211_TX_CTL_AMPDU) {
@@ -6614,13 +6634,13 @@ wlc_dotxstatus(struct wlc_info *wlc, tx_status_t *txs, u32 frm_tx2)
                WL_NONE("%s: Pkt tx suppressed, possibly channel %d\n",
                        __func__, CHSPEC_CHANNEL(wlc->default_bss->chanspec));
 
-       tx_rts = htol16(txh->MacTxControlLow) & TXC_SENDRTS;
+       tx_rts = cpu_to_le16(txh->MacTxControlLow) & TXC_SENDRTS;
        tx_frame_count =
            (txs->status & TX_STATUS_FRM_RTX_MASK) >> TX_STATUS_FRM_RTX_SHIFT;
        tx_rts_count =
            (txs->status & TX_STATUS_RTS_RTX_MASK) >> TX_STATUS_RTS_RTX_SHIFT;
 
-       lastframe = (fc & FC_MOREFRAG) == 0;
+       lastframe = !ieee80211_has_morefrags(h->frame_control);
 
        if (!lastframe) {
                WL_ERROR("Not last frame!\n");
@@ -6659,7 +6679,7 @@ wlc_dotxstatus(struct wlc_info *wlc, tx_status_t *txs, u32 frm_tx2)
                        tx_info->flags |= IEEE80211_TX_STAT_ACK;
        }
 
-       totlen = pkttotlen(osh, p);
+       totlen = pkttotlen(p);
        free_pdu = true;
 
        wlc_txfifo_complete(wlc, queue, 1);
@@ -6672,7 +6692,7 @@ wlc_dotxstatus(struct wlc_info *wlc, tx_status_t *txs, u32 frm_tx2)
                skb_pull(p, D11_PHY_HDR_LEN);
                skb_pull(p, D11_TXH_LEN);
                ieee80211_tx_status_irqsafe(wlc->pub->ieee_hw, p);
-               WLCNTINCR(wlc->pub->_cnt->ieee_tx_status);
+               wlc->pub->_cnt->ieee_tx_status++;
        } else {
                WL_ERROR("%s: Not last frame => not calling tx_status\n",
                         __func__);
@@ -6683,7 +6703,7 @@ wlc_dotxstatus(struct wlc_info *wlc, tx_status_t *txs, u32 frm_tx2)
  fatal:
        ASSERT(0);
        if (p)
-               pkt_buf_free_skb(osh, p, true);
+               pkt_buf_free_skb(p);
 
        return true;
 
@@ -6829,13 +6849,14 @@ prep_mac80211_status(struct wlc_info *wlc, d11rxhdr_t *rxh, struct sk_buff *p,
 
        channel = WLC_CHAN_CHANNEL(rxh->RxChan);
 
-       /* XXX  Channel/badn needs to be filtered against whether we are single/dual band card */
        if (channel > 14) {
                rx_status->band = IEEE80211_BAND_5GHZ;
-               rx_status->freq = wf_channel2mhz(channel, WF_CHAN_FACTOR_5_G);
+               rx_status->freq = ieee80211_ofdm_chan_to_freq(
+                                       WF_CHAN_FACTOR_5_G/2, channel);
+
        } else {
                rx_status->band = IEEE80211_BAND_2GHZ;
-               rx_status->freq = wf_channel2mhz(channel, WF_CHAN_FACTOR_2_4_G);
+               rx_status->freq = ieee80211_dsss_chan_to_freq(channel);
        }
 
        rx_status->signal = wlc_rxh->rssi;      /* signal */
@@ -6921,8 +6942,7 @@ prep_mac80211_status(struct wlc_info *wlc, d11rxhdr_t *rxh, struct sk_buff *p,
 }
 
 static void
-wlc_recvctl(struct wlc_info *wlc, struct osl_info *osh, d11rxhdr_t *rxh,
-           struct sk_buff *p)
+wlc_recvctl(struct wlc_info *wlc, d11rxhdr_t *rxh, struct sk_buff *p)
 {
        int len_mpdu;
        struct ieee80211_rx_status rx_status;
@@ -6939,7 +6959,7 @@ wlc_recvctl(struct wlc_info *wlc, struct osl_info *osh, d11rxhdr_t *rxh,
        prep_mac80211_status(wlc, rxh, p, &rx_status);
 
        /* mac header+body length, exclude CRC and plcp header */
-       len_mpdu = p->len - D11_PHY_HDR_LEN - DOT11_FCS_LEN;
+       len_mpdu = p->len - D11_PHY_HDR_LEN - FCS_LEN;
        skb_pull(p, D11_PHY_HDR_LEN);
        __skb_trim(p, len_mpdu);
 
@@ -6951,15 +6971,13 @@ wlc_recvctl(struct wlc_info *wlc, struct osl_info *osh, d11rxhdr_t *rxh,
        memcpy(IEEE80211_SKB_RXCB(p), &rx_status, sizeof(rx_status));
        ieee80211_rx_irqsafe(wlc->pub->ieee_hw, p);
 
-       WLCNTINCR(wlc->pub->_cnt->ieee_rx);
-       osh->pktalloced--;
+       wlc->pub->_cnt->ieee_rx++;
        return;
 }
 
-void wlc_bss_list_free(struct wlc_info *wlc, wlc_bss_list_t *bss_list)
+void wlc_bss_list_free(struct wlc_info *wlc, struct wlc_bss_list *bss_list)
 {
        uint index;
-       wlc_bss_info_t *bi;
 
        if (!bss_list) {
                WL_ERROR("%s: Attempting to free NULL list\n", __func__);
@@ -6967,14 +6985,8 @@ void wlc_bss_list_free(struct wlc_info *wlc, wlc_bss_list_t *bss_list)
        }
        /* inspect all BSS descriptor */
        for (index = 0; index < bss_list->count; index++) {
-               bi = bss_list->ptrs[index];
-               if (bi) {
-                       if (bi->bcn_prb) {
-                               kfree(bi->bcn_prb);
-                       }
-                       kfree(bi);
-                       bss_list->ptrs[index] = NULL;
-               }
+               kfree(bss_list->ptrs[index]);
+               bss_list->ptrs[index] = NULL;
        }
        bss_list->count = 0;
 }
@@ -6988,16 +7000,12 @@ void wlc_bss_list_free(struct wlc_info *wlc, wlc_bss_list_t *bss_list)
 void BCMFASTPATH wlc_recv(struct wlc_info *wlc, struct sk_buff *p)
 {
        d11rxhdr_t *rxh;
-       struct dot11_header *h;
-       struct osl_info *osh;
-       u16 fc;
+       struct ieee80211_hdr *h;
        uint len;
        bool is_amsdu;
 
        WL_TRACE("wl%d: wlc_recv\n", wlc->pub->unit);
 
-       osh = wlc->osh;
-
        /* frame starts with rxhdr */
        rxh = (d11rxhdr_t *) (p->data);
 
@@ -7005,12 +7013,22 @@ void BCMFASTPATH wlc_recv(struct wlc_info *wlc, struct sk_buff *p)
        skb_pull(p, wlc->hwrxoff);
 
        /* fixup rx header endianness */
-       ltoh16_buf((void *)rxh, sizeof(d11rxhdr_t));
+       rxh->RxFrameSize = le16_to_cpu(rxh->RxFrameSize);
+       rxh->PhyRxStatus_0 = le16_to_cpu(rxh->PhyRxStatus_0);
+       rxh->PhyRxStatus_1 = le16_to_cpu(rxh->PhyRxStatus_1);
+       rxh->PhyRxStatus_2 = le16_to_cpu(rxh->PhyRxStatus_2);
+       rxh->PhyRxStatus_3 = le16_to_cpu(rxh->PhyRxStatus_3);
+       rxh->PhyRxStatus_4 = le16_to_cpu(rxh->PhyRxStatus_4);
+       rxh->PhyRxStatus_5 = le16_to_cpu(rxh->PhyRxStatus_5);
+       rxh->RxStatus1 = le16_to_cpu(rxh->RxStatus1);
+       rxh->RxStatus2 = le16_to_cpu(rxh->RxStatus2);
+       rxh->RxTSFTime = le16_to_cpu(rxh->RxTSFTime);
+       rxh->RxChan = le16_to_cpu(rxh->RxChan);
 
        /* MAC inserts 2 pad bytes for a4 headers or QoS or A-MSDU subframes */
        if (rxh->RxStatus1 & RXS_PBPRES) {
                if (p->len < 2) {
-                       WLCNTINCR(wlc->pub->_cnt->rxrunt);
+                       wlc->pub->_cnt->rxrunt++;
                        WL_ERROR("wl%d: wlc_recv: rcvd runt of len %d\n",
                                 wlc->pub->unit, p->len);
                        goto toss;
@@ -7018,7 +7036,7 @@ void BCMFASTPATH wlc_recv(struct wlc_info *wlc, struct sk_buff *p)
                skb_pull(p, 2);
        }
 
-       h = (struct dot11_header *)(p->data + D11_PHY_HDR_LEN);
+       h = (struct ieee80211_hdr *)(p->data + D11_PHY_HDR_LEN);
        len = p->len;
 
        if (rxh->RxStatus1 & RXS_FCSERR) {
@@ -7032,10 +7050,8 @@ void BCMFASTPATH wlc_recv(struct wlc_info *wlc, struct sk_buff *p)
        }
 
        /* check received pkt has at least frame control field */
-       if (len >= D11_PHY_HDR_LEN + sizeof(h->fc)) {
-               fc = ltoh16(h->fc);
-       } else {
-               WLCNTINCR(wlc->pub->_cnt->rxrunt);
+       if (len < D11_PHY_HDR_LEN + sizeof(h->frame_control)) {
+               wlc->pub->_cnt->rxrunt++;
                goto toss;
        }
 
@@ -7044,34 +7060,35 @@ void BCMFASTPATH wlc_recv(struct wlc_info *wlc, struct sk_buff *p)
        /* explicitly test bad src address to avoid sending bad deauth */
        if (!is_amsdu) {
                /* CTS and ACK CTL frames are w/o a2 */
-               if (FC_TYPE(fc) == FC_TYPE_DATA || FC_TYPE(fc) == FC_TYPE_MNG) {
-                       if ((is_zero_ether_addr(h->a2.octet) ||
-                            is_multicast_ether_addr(h->a2.octet))) {
-                               WL_ERROR("wl%d: %s: dropping a frame with invalid src mac address, a2: %pM\n",
-                                        wlc->pub->unit, __func__, &h->a2);
-                               WLCNTINCR(wlc->pub->_cnt->rxbadsrcmac);
+
+               if (ieee80211_is_data(h->frame_control) ||
+                   ieee80211_is_mgmt(h->frame_control)) {
+                       if ((is_zero_ether_addr(h->addr2) ||
+                            is_multicast_ether_addr(h->addr2))) {
+                               WL_ERROR("wl%d: %s: dropping a frame with "
+                                        "invalid src mac address, a2: %pM\n",
+                                        wlc->pub->unit, __func__, h->addr2);
+                               wlc->pub->_cnt->rxbadsrcmac++;
                                goto toss;
                        }
-                       WLCNTINCR(wlc->pub->_cnt->rxfrag);
+                       wlc->pub->_cnt->rxfrag++;
                }
        }
 
        /* due to sheer numbers, toss out probe reqs for now */
-       if (FC_TYPE(fc) == FC_TYPE_MNG) {
-               if ((fc & FC_KIND_MASK) == FC_PROBE_REQ)
-                       goto toss;
-       }
+       if (ieee80211_is_probe_req(h->frame_control))
+               goto toss;
 
        if (is_amsdu) {
                WL_ERROR("%s: is_amsdu causing toss\n", __func__);
                goto toss;
        }
 
-       wlc_recvctl(wlc, osh, rxh, p);
+       wlc_recvctl(wlc, rxh, p);
        return;
 
  toss:
-       pkt_buf_free_skb(osh, p, false);
+       pkt_buf_free_skb(p);
 }
 
 /* calculate frame duration for Mixed-mode L-SIG spoofing, return
@@ -7253,7 +7270,7 @@ wlc_calc_ba_time(struct wlc_info *wlc, ratespec_t rspec, u8 preamble_type)
        /* BA len == 32 == 16(ctl hdr) + 4(ba len) + 8(bitmap) + 4(fcs) */
        return wlc_calc_frame_time(wlc, rspec, preamble_type,
                                   (DOT11_BA_LEN + DOT11_BA_BITMAP_LEN +
-                                   DOT11_FCS_LEN));
+                                   FCS_LEN));
 }
 
 static uint BCMFASTPATH
@@ -7272,7 +7289,7 @@ wlc_calc_ack_time(struct wlc_info *wlc, ratespec_t rspec, u8 preamble_type)
        /* ACK frame len == 14 == 2(fc) + 2(dur) + 6(ra) + 4(fcs) */
        dur =
            wlc_calc_frame_time(wlc, rspec, preamble_type,
-                               (DOT11_ACK_LEN + DOT11_FCS_LEN));
+                               (DOT11_ACK_LEN + FCS_LEN));
        return dur;
 }
 
@@ -7613,17 +7630,19 @@ wlc_compute_bcntsfoff(struct wlc_info *wlc, ratespec_t rspec,
  *     and included up to, but not including, the 4 byte FCS.
  */
 static void
-wlc_bcn_prb_template(struct wlc_info *wlc, uint type, ratespec_t bcn_rspec,
-                    wlc_bsscfg_t *cfg, u16 *buf, int *len)
+wlc_bcn_prb_template(struct wlc_info *wlc, u16 type, ratespec_t bcn_rspec,
+                    struct wlc_bsscfg *cfg, u16 *buf, int *len)
 {
+       static const u8 ether_bcast[ETH_ALEN] = {255, 255, 255, 255, 255, 255};
        cck_phy_hdr_t *plcp;
-       struct dot11_management_header *h;
+       struct ieee80211_mgmt *h;
        int hdr_len, body_len;
 
        ASSERT(*len >= 142);
-       ASSERT(type == FC_BEACON || type == FC_PROBE_RESP);
+       ASSERT(type == IEEE80211_STYPE_BEACON ||
+              type == IEEE80211_STYPE_PROBE_RESP);
 
-       if (MBSS_BCN_ENAB(cfg) && type == FC_BEACON)
+       if (MBSS_BCN_ENAB(cfg) && type == IEEE80211_STYPE_BEACON)
                hdr_len = DOT11_MAC_HDR_LEN;
        else
                hdr_len = D11_PHY_HDR_LEN + DOT11_MAC_HDR_LEN;
@@ -7637,10 +7656,10 @@ wlc_bcn_prb_template(struct wlc_info *wlc, uint type, ratespec_t bcn_rspec,
        plcp = (cck_phy_hdr_t *) buf;
 
        /* PLCP for Probe Response frames are filled in from core's rate table */
-       if (type == FC_BEACON && !MBSS_BCN_ENAB(cfg)) {
+       if (type == IEEE80211_STYPE_BEACON && !MBSS_BCN_ENAB(cfg)) {
                /* fill in PLCP */
                wlc_compute_plcp(wlc, bcn_rspec,
-                                (DOT11_MAC_HDR_LEN + body_len + DOT11_FCS_LEN),
+                                (DOT11_MAC_HDR_LEN + body_len + FCS_LEN),
                                 (u8 *) plcp);
 
        }
@@ -7649,21 +7668,20 @@ wlc_bcn_prb_template(struct wlc_info *wlc, uint type, ratespec_t bcn_rspec,
        if (!SOFTBCN_ENAB(cfg))
                wlc_beacon_phytxctl_txant_upd(wlc, bcn_rspec);
 
-       if (MBSS_BCN_ENAB(cfg) && type == FC_BEACON)
-               h = (struct dot11_management_header *)&plcp[0];
+       if (MBSS_BCN_ENAB(cfg) && type == IEEE80211_STYPE_BEACON)
+               h = (struct ieee80211_mgmt *)&plcp[0];
        else
-               h = (struct dot11_management_header *)&plcp[1];
+               h = (struct ieee80211_mgmt *)&plcp[1];
 
        /* fill in 802.11 header */
-       h->fc = htol16((u16) type);
+       h->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | type);
 
        /* DUR is 0 for multicast bcn, or filled in by MAC for prb resp */
        /* A1 filled in by MAC for prb resp, broadcast for bcn */
-       if (type == FC_BEACON)
-               bcopy((const char *)&ether_bcast, (char *)&h->da,
-                     ETH_ALEN);
-       bcopy((char *)&cfg->cur_etheraddr, (char *)&h->sa, ETH_ALEN);
-       bcopy((char *)&cfg->BSSID, (char *)&h->bssid, ETH_ALEN);
+       if (type == IEEE80211_STYPE_BEACON)
+               memcpy(&h->da, &ether_bcast, ETH_ALEN);
+       memcpy(&h->sa, &cfg->cur_etheraddr, ETH_ALEN);
+       memcpy(&h->bssid, &cfg->BSSID, ETH_ALEN);
 
        /* SEQ filled in by MAC */
 
@@ -7680,7 +7698,7 @@ int wlc_get_header_len()
  * template updated.
  * Otherwise, it updates the hardware template.
  */
-void wlc_bss_update_beacon(struct wlc_info *wlc, wlc_bsscfg_t *cfg)
+void wlc_bss_update_beacon(struct wlc_info *wlc, struct wlc_bsscfg *cfg)
 {
        int len = BCN_TMPL_LEN;
 
@@ -7691,26 +7709,24 @@ void wlc_bss_update_beacon(struct wlc_info *wlc, wlc_bsscfg_t *cfg)
                return;
        }
 
-       if (MBSS_BCN_ENAB(cfg)) {       /* Optimize:  Some of if/else could be combined */
-       } else if (HWBCN_ENAB(cfg)) {   /* Hardware beaconing for this config */
+       /* Optimize:  Some of if/else could be combined */
+       if (!MBSS_BCN_ENAB(cfg) && HWBCN_ENAB(cfg)) {
+               /* Hardware beaconing for this config */
                u16 bcn[BCN_TMPL_LEN / 2];
                u32 both_valid = MCMD_BCN0VLD | MCMD_BCN1VLD;
                d11regs_t *regs = wlc->regs;
-               struct osl_info *osh = NULL;
-
-               osh = wlc->osh;
 
                /* Check if both templates are in use, if so sched. an interrupt
                 *      that will call back into this routine
                 */
-               if ((R_REG(osh, &regs->maccommand) & both_valid) == both_valid) {
+               if ((R_REG(&regs->maccommand) & both_valid) == both_valid) {
                        /* clear any previous status */
-                       W_REG(osh, &regs->macintstatus, MI_BCNTPL);
+                       W_REG(&regs->macintstatus, MI_BCNTPL);
                }
                /* Check that after scheduling the interrupt both of the
                 *      templates are still busy. if not clear the int. & remask
                 */
-               if ((R_REG(osh, &regs->maccommand) & both_valid) == both_valid) {
+               if ((R_REG(&regs->maccommand) & both_valid) == both_valid) {
                        wlc->defmacintmask |= MI_BCNTPL;
                        return;
                }
@@ -7724,8 +7740,8 @@ void wlc_bss_update_beacon(struct wlc_info *wlc, wlc_bsscfg_t *cfg)
                        true));
 
                /* update the template and ucode shm */
-               wlc_bcn_prb_template(wlc, FC_BEACON, wlc->bcn_rspec, cfg, bcn,
-                                    &len);
+               wlc_bcn_prb_template(wlc, IEEE80211_STYPE_BEACON,
+                                    wlc->bcn_rspec, cfg, bcn, &len);
                wlc_write_hw_bcntemplates(wlc, bcn, len, false);
        }
 }
@@ -7736,7 +7752,7 @@ void wlc_bss_update_beacon(struct wlc_info *wlc, wlc_bsscfg_t *cfg)
 void wlc_update_beacon(struct wlc_info *wlc)
 {
        int idx;
-       wlc_bsscfg_t *bsscfg;
+       struct wlc_bsscfg *bsscfg;
 
        /* update AP or IBSS beacons */
        FOREACH_BSS(wlc, idx, bsscfg) {
@@ -7746,17 +7762,17 @@ void wlc_update_beacon(struct wlc_info *wlc)
 }
 
 /* Write ssid into shared memory */
-void wlc_shm_ssid_upd(struct wlc_info *wlc, wlc_bsscfg_t *cfg)
+void wlc_shm_ssid_upd(struct wlc_info *wlc, struct wlc_bsscfg *cfg)
 {
        u8 *ssidptr = cfg->SSID;
        u16 base = M_SSID;
-       u8 ssidbuf[DOT11_MAX_SSID_LEN];
+       u8 ssidbuf[IEEE80211_MAX_SSID_LEN];
 
        /* padding the ssid with zero and copy it into shm */
-       memset(ssidbuf, 0, DOT11_MAX_SSID_LEN);
-       bcopy(ssidptr, ssidbuf, cfg->SSID_len);
+       memset(ssidbuf, 0, IEEE80211_MAX_SSID_LEN);
+       memcpy(ssidbuf, ssidptr, cfg->SSID_len);
 
-       wlc_copyto_shm(wlc, base, ssidbuf, DOT11_MAX_SSID_LEN);
+       wlc_copyto_shm(wlc, base, ssidbuf, IEEE80211_MAX_SSID_LEN);
 
        if (!MBSS_BCN_ENAB(cfg))
                wlc_write_shm(wlc, M_SSIDLEN, (u16) cfg->SSID_len);
@@ -7765,7 +7781,7 @@ void wlc_shm_ssid_upd(struct wlc_info *wlc, wlc_bsscfg_t *cfg)
 void wlc_update_probe_resp(struct wlc_info *wlc, bool suspend)
 {
        int idx;
-       wlc_bsscfg_t *bsscfg;
+       struct wlc_bsscfg *bsscfg;
 
        /* update AP or IBSS probe responses */
        FOREACH_BSS(wlc, idx, bsscfg) {
@@ -7775,7 +7791,8 @@ void wlc_update_probe_resp(struct wlc_info *wlc, bool suspend)
 }
 
 void
-wlc_bss_update_probe_resp(struct wlc_info *wlc, wlc_bsscfg_t *cfg, bool suspend)
+wlc_bss_update_probe_resp(struct wlc_info *wlc, struct wlc_bsscfg *cfg,
+                         bool suspend)
 {
        u16 prb_resp[BCN_TMPL_LEN / 2];
        int len = BCN_TMPL_LEN;
@@ -7784,8 +7801,8 @@ wlc_bss_update_probe_resp(struct wlc_info *wlc, wlc_bsscfg_t *cfg, bool suspend)
        if (!MBSS_PRB_ENAB(cfg)) {
 
                /* create the probe response template */
-               wlc_bcn_prb_template(wlc, FC_PROBE_RESP, 0, cfg, prb_resp,
-                                    &len);
+               wlc_bcn_prb_template(wlc, IEEE80211_STYPE_PROBE_RESP, 0, cfg,
+                                    prb_resp, &len);
 
                if (suspend)
                        wlc_suspend_mac_and_wait(wlc);
@@ -7805,7 +7822,7 @@ wlc_bss_update_probe_resp(struct wlc_info *wlc, wlc_bsscfg_t *cfg, bool suspend)
                 * Use the actual frame length covered by the PLCP header for the call to
                 * wlc_mod_prb_rsp_rate_table() by subtracting the PLCP len and adding the FCS.
                 */
-               len += (-D11_PHY_HDR_LEN + DOT11_FCS_LEN);
+               len += (-D11_PHY_HDR_LEN + FCS_LEN);
                wlc_mod_prb_rsp_rate_table(wlc, (u16) len);
 
                if (suspend)
@@ -7818,24 +7835,19 @@ wlc_bss_update_probe_resp(struct wlc_info *wlc, wlc_bsscfg_t *cfg, bool suspend)
 /* prepares pdu for transmission. returns BCM error codes */
 int wlc_prep_pdu(struct wlc_info *wlc, struct sk_buff *pdu, uint *fifop)
 {
-       struct osl_info *osh;
        uint fifo;
        d11txh_t *txh;
-       struct dot11_header *h;
+       struct ieee80211_hdr *h;
        struct scb *scb;
-       u16 fc;
-
-       osh = wlc->osh;
 
        ASSERT(pdu);
        txh = (d11txh_t *) (pdu->data);
        ASSERT(txh);
-       h = (struct dot11_header *)((u8 *) (txh + 1) + D11_PHY_HDR_LEN);
+       h = (struct ieee80211_hdr *)((u8 *) (txh + 1) + D11_PHY_HDR_LEN);
        ASSERT(h);
-       fc = ltoh16(h->fc);
 
        /* get the pkt queue info. This was put at wlc_sendctl or wlc_send for PDU */
-       fifo = ltoh16(txh->TxFrameID) & TXFID_QUEUE_MASK;
+       fifo = le16_to_cpu(txh->TxFrameID) & TXFID_QUEUE_MASK;
 
        scb = NULL;
 
@@ -7848,8 +7860,8 @@ int wlc_prep_pdu(struct wlc_info *wlc, struct sk_buff *pdu, uint *fifop)
                return BCME_BUSY;
        }
 
-       if (FC_TYPE(ltoh16(txh->MacFrameControl)) != FC_TYPE_DATA)
-               WLCNTINCR(wlc->pub->_cnt->txctl);
+       if (!ieee80211_is_data(txh->MacFrameControl))
+               wlc->pub->_cnt->txctl++;
 
        return 0;
 }
@@ -7858,7 +7870,7 @@ int wlc_prep_pdu(struct wlc_info *wlc, struct sk_buff *pdu, uint *fifop)
 void wlc_reprate_init(struct wlc_info *wlc)
 {
        int i;
-       wlc_bsscfg_t *bsscfg;
+       struct wlc_bsscfg *bsscfg;
 
        FOREACH_BSS(wlc, i, bsscfg) {
                wlc_bsscfg_reprate_init(bsscfg);
@@ -7866,7 +7878,7 @@ void wlc_reprate_init(struct wlc_info *wlc)
 }
 
 /* per bsscfg init tx reported rate mechanism */
-void wlc_bsscfg_reprate_init(wlc_bsscfg_t *bsscfg)
+void wlc_bsscfg_reprate_init(struct wlc_bsscfg *bsscfg)
 {
        bsscfg->txrspecidx = 0;
        memset((char *)bsscfg->txrspec, 0, sizeof(bsscfg->txrspec));
@@ -7952,23 +7964,6 @@ static void wlc_bss_default_init(struct wlc_info *wlc)
                bi->flags |= WLC_BSS_HT;
 }
 
-/* Deferred event processing */
-static void wlc_process_eventq(void *arg)
-{
-       struct wlc_info *wlc = (struct wlc_info *) arg;
-       wlc_event_t *etmp;
-
-       while ((etmp = wlc_eventq_deq(wlc->eventq))) {
-               /* Perform OS specific event processing */
-               wl_event(wlc->wl, etmp->event.ifname, etmp);
-               if (etmp->data) {
-                       kfree(etmp->data);
-                       etmp->data = NULL;
-               }
-               wlc_event_free(wlc->eventq, etmp);
-       }
-}
-
 void
 wlc_uint64_sub(u32 *a_high, u32 *a_low, u32 b_high, u32 b_low)
 {
@@ -8226,12 +8221,14 @@ void wlc_write_hw_bcntemplates(struct wlc_info *wlc, void *bcn, int len,
 
 void
 wlc_set_addrmatch(struct wlc_info *wlc, int match_reg_offset,
-                 const struct ether_addr *addr)
+                 const u8 *addr)
 {
        wlc_bmac_set_addrmatch(wlc->hw, match_reg_offset, addr);
+       if (match_reg_offset == RCM_BSSID_OFFSET)
+               memcpy(wlc->cfg->BSSID, addr, ETH_ALEN);
 }
 
-void wlc_set_rcmta(struct wlc_info *wlc, int idx, const struct ether_addr *addr)
+void wlc_set_rcmta(struct wlc_info *wlc, int idx, const u8 *addr)
 {
        wlc_bmac_set_rcmta(wlc->hw, idx, addr);
 }
@@ -8272,8 +8269,8 @@ void wlc_reset_bmac_done(struct wlc_info *wlc)
 
 void wlc_ht_mimops_cap_update(struct wlc_info *wlc, u8 mimops_mode)
 {
-       wlc->ht_cap.cap &= ~HT_CAP_MIMO_PS_MASK;
-       wlc->ht_cap.cap |= (mimops_mode << HT_CAP_MIMO_PS_SHIFT);
+       wlc->ht_cap.cap_info &= ~IEEE80211_HT_CAP_SM_PS;
+       wlc->ht_cap.cap_info |= (mimops_mode << IEEE80211_HT_CAP_SM_PS_SHIFT);
 
        if (AP_ENAB(wlc->pub) && wlc->clk) {
                wlc_update_beacon(wlc);
@@ -8283,7 +8280,8 @@ void wlc_ht_mimops_cap_update(struct wlc_info *wlc, u8 mimops_mode)
 
 /* check for the particular priority flow control bit being set */
 bool
-wlc_txflowcontrol_prio_isset(struct wlc_info *wlc, wlc_txq_info_t *q, int prio)
+wlc_txflowcontrol_prio_isset(struct wlc_info *wlc, struct wlc_txq_info *q,
+                            int prio)
 {
        uint prio_mask;
 
@@ -8298,13 +8296,13 @@ wlc_txflowcontrol_prio_isset(struct wlc_info *wlc, wlc_txq_info_t *q, int prio)
 }
 
 /* propogate the flow control to all interfaces using the given tx queue */
-void wlc_txflowcontrol(struct wlc_info *wlc, wlc_txq_info_t *qi,
+void wlc_txflowcontrol(struct wlc_info *wlc, struct wlc_txq_info *qi,
                       bool on, int prio)
 {
        uint prio_bits;
        uint cur_bits;
 
-       WL_ERROR("%s: flow control kicks in\n", __func__);
+       WL_TRACE("%s: flow control kicks in\n", __func__);
 
        if (prio == ALLPRIO) {
                prio_bits = TXQ_STOP_FOR_PRIOFC_MASK;
@@ -8341,8 +8339,8 @@ void wlc_txflowcontrol(struct wlc_info *wlc, wlc_txq_info_t *qi,
 }
 
 void
-wlc_txflowcontrol_override(struct wlc_info *wlc, wlc_txq_info_t *qi, bool on,
-                          uint override)
+wlc_txflowcontrol_override(struct wlc_info *wlc, struct wlc_txq_info *qi,
+                          bool on, uint override)
 {
        uint prev_override;
 
@@ -8390,7 +8388,7 @@ wlc_txflowcontrol_override(struct wlc_info *wlc, wlc_txq_info_t *qi, bool on,
 
 static void wlc_txflowcontrol_reset(struct wlc_info *wlc)
 {
-       wlc_txq_info_t *qi;
+       struct wlc_txq_info *qi;
 
        for (qi = wlc->tx_queues; qi != NULL; qi = qi->next) {
                if (qi->stopped) {
@@ -8401,7 +8399,7 @@ static void wlc_txflowcontrol_reset(struct wlc_info *wlc)
 }
 
 static void
-wlc_txflowcontrol_signal(struct wlc_info *wlc, wlc_txq_info_t *qi, bool on,
+wlc_txflowcontrol_signal(struct wlc_info *wlc, struct wlc_txq_info *qi, bool on,
                         int prio)
 {
        struct wlc_if *wlcif;
@@ -8412,40 +8410,38 @@ wlc_txflowcontrol_signal(struct wlc_info *wlc, wlc_txq_info_t *qi, bool on,
        }
 }
 
-static wlc_txq_info_t *wlc_txq_alloc(struct wlc_info *wlc, struct osl_info *osh)
+static struct wlc_txq_info *wlc_txq_alloc(struct wlc_info *wlc)
 {
-       wlc_txq_info_t *qi, *p;
+       struct wlc_txq_info *qi, *p;
 
-       qi = (wlc_txq_info_t *) wlc_calloc(osh, wlc->pub->unit,
-                                          sizeof(wlc_txq_info_t));
-       if (qi == NULL) {
-               return NULL;
-       }
-
-       /* Have enough room for control packets along with HI watermark */
-       /* Also, add room to txq for total psq packets if all the SCBs leave PS mode */
-       /* The watermark for flowcontrol to OS packets will remain the same */
-       pktq_init(&qi->q, WLC_PREC_COUNT,
-                 (2 * wlc->pub->tunables->datahiwat) + PKTQ_LEN_DEFAULT +
-                 wlc->pub->psq_pkts_total);
-
-       /* add this queue to the the global list */
-       p = wlc->tx_queues;
-       if (p == NULL) {
-               wlc->tx_queues = qi;
-       } else {
-               while (p->next != NULL)
-                       p = p->next;
-               p->next = qi;
+       qi = wlc_calloc(wlc->pub->unit, sizeof(struct wlc_txq_info));
+       if (qi != NULL) {
+               /*
+                * Have enough room for control packets along with HI watermark
+                * Also, add room to txq for total psq packets if all the SCBs
+                * leave PS mode. The watermark for flowcontrol to OS packets
+                * will remain the same
+                */
+               pktq_init(&qi->q, WLC_PREC_COUNT,
+                         (2 * wlc->pub->tunables->datahiwat) + PKTQ_LEN_DEFAULT
+                         + wlc->pub->psq_pkts_total);
+
+               /* add this queue to the the global list */
+               p = wlc->tx_queues;
+               if (p == NULL) {
+                       wlc->tx_queues = qi;
+               } else {
+                       while (p->next != NULL)
+                               p = p->next;
+                       p->next = qi;
+               }
        }
-
        return qi;
 }
 
-static void wlc_txq_free(struct wlc_info *wlc, struct osl_info *osh,
-                        wlc_txq_info_t *qi)
+static void wlc_txq_free(struct wlc_info *wlc, struct wlc_txq_info *qi)
 {
-       wlc_txq_info_t *p;
+       struct wlc_txq_info *p;
 
        if (qi == NULL)
                return;
@@ -8477,3 +8473,27 @@ void wlc_scan_stop(struct wlc_info *wlc)
 {
        wlc_phy_hold_upd(wlc->band->pi, PHY_HOLD_FOR_SCAN, false);
 }
+
+void wlc_associate_upd(struct wlc_info *wlc, bool state)
+{
+       wlc->pub->associated = state;
+       wlc->cfg->associated = state;
+}
+
+/*
+ * When a remote STA/AP is removed by Mac80211, or when it can no longer accept
+ * AMPDU traffic, packets pending in hardware have to be invalidated so that
+ * when later on hardware releases them, they can be handled appropriately.
+ */
+void wlc_inval_dma_pkts(struct wlc_hw_info *hw,
+                              struct ieee80211_sta *sta,
+                              void (*dma_callback_fn))
+{
+       struct hnddma_pub *dmah;
+       int i;
+       for (i = 0; i < NFIFO; i++) {
+               dmah = hw->di[i];
+               if (dmah != NULL)
+                       dma_walk_packets(dmah, dma_callback_fn, sta);
+       }
+}