staging: brcm80211: remove usage of struct osl_info for register access
[deliverable/linux.git] / drivers / staging / brcm80211 / brcmsmac / wlc_mac80211.c
index d64171ff12aa88e0f93834fea9684ed3aa5be0f9..c00051bcf9a7d27dae5f06cb3901a48e3b51e90d 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 <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_mac80211.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 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.
@@ -214,7 +225,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[] = {
@@ -248,17 +260,19 @@ 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 struct wlc_txq_info *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,
+                        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,
@@ -297,7 +311,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);
@@ -318,20 +331,18 @@ void wlc_get_rcmta(struct wlc_info *wlc, int idx, u8 *addr)
 
        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);
+       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(osh, &regs->objaddr, (OBJADDR_RCMTA_SEL | ((idx * 2) + 1)));
-       (void)R_REG(osh, &regs->objaddr);
-       v32 = R_REG(osh, (volatile u16 *)&regs->objdata);
+       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);
 }
@@ -379,13 +390,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);
@@ -451,7 +460,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;
 
@@ -476,11 +485,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 */
@@ -517,7 +528,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);
        }
 
@@ -541,8 +552,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;
@@ -551,7 +561,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);
@@ -607,12 +617,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",
@@ -662,7 +673,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;
@@ -787,7 +798,7 @@ void wlc_set_home_chanspec(struct wlc_info *wlc, chanspec_t chanspec)
                FOREACH_BSS(wlc, idx, cfg) {
                        if (!cfg->associated)
                                continue;
-                       cfg->target_bss->chanspec = chanspec;
+
                        cfg->current_bss->chanspec = chanspec;
                }
 
@@ -853,8 +864,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
@@ -1002,7 +1012,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;
 
@@ -1300,8 +1310,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);
 
 }
 
@@ -1342,13 +1351,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)}
                 }
        };
 
@@ -1387,7 +1396,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);
@@ -1408,7 +1417,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 +
@@ -1471,7 +1480,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);
@@ -1495,7 +1504,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 +
@@ -1657,7 +1666,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;
@@ -1697,15 +1706,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;
@@ -1733,7 +1733,7 @@ void *wlc_attach(void *wl, u16 vendor, u16 device, uint unit, bool piomode,
        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",
@@ -1773,7 +1773,7 @@ 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;
@@ -1852,8 +1852,7 @@ void *wlc_attach(void *wl, u16 vendor, u16 device, uint unit, bool piomode,
 
        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 */
@@ -1947,8 +1946,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));
@@ -2005,15 +2004,13 @@ void *wlc_attach(void *wl, u16 vendor, u16 device, uint unit, bool piomode,
        /* 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)
@@ -2158,11 +2155,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);
@@ -2181,7 +2173,7 @@ uint wlc_detach(struct wlc_info *wlc)
 
        {
                /* free dumpcb list */
-               dumpcb_t *prev, *ptr;
+               struct dumpcb_s *prev, *ptr;
                prev = ptr = wlc->dumpcb_head;
                while (ptr) {
                        ptr = prev->next;
@@ -2205,7 +2197,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;
 }
 
@@ -2306,6 +2298,11 @@ void wlc_radio_mpc_upd(struct wlc_info *wlc)
  */
 static void wlc_radio_upd(struct wlc_info *wlc)
 {
+       if (wlc->pub->radio_disabled) {
+               wlc_radio_disable(wlc);
+       } else {
+               wlc_radio_enable(wlc);
+       }
 }
 
 /* maintain LED behavior in down state */
@@ -2501,8 +2498,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 */
@@ -2683,7 +2679,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__);
 
@@ -2735,12 +2731,6 @@ uint wlc_down(struct wlc_info *wlc)
                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 */
@@ -2909,8 +2899,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;
 }
@@ -3003,7 +2993,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))
@@ -3011,7 +3001,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))
@@ -3020,7 +3010,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]->
@@ -3033,10 +3023,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;
 }
 
@@ -3116,7 +3105,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;
 
@@ -3205,7 +3194,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);
@@ -3333,13 +3322,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;
@@ -3368,12 +3355,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;
@@ -3443,7 +3428,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;
@@ -3476,15 +3461,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) */
@@ -3612,18 +3590,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, key.ea,
-                                     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;
@@ -3674,7 +3651,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;
                        }
@@ -3697,7 +3674,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;
                }
 
@@ -3715,7 +3692,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;
                }
 
@@ -3737,16 +3714,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);
@@ -3855,19 +3834,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;
                }
@@ -4049,7 +4027,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) {
@@ -4085,7 +4063,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 */
@@ -4109,8 +4087,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;
 
@@ -4368,7 +4345,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;
                }
        }
@@ -4519,7 +4496,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;
                }
@@ -4563,11 +4540,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;
@@ -4703,19 +4681,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 */
 
@@ -4725,30 +4705,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;
@@ -4768,6 +4765,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);
@@ -4825,7 +4882,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)
@@ -4850,32 +4907,32 @@ 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 ieee80211_rts rts = txh->rts_frame;
@@ -4884,51 +4941,50 @@ void wlc_print_txdesc(d11txh_t *txh)
        /* 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) */
 
@@ -4960,13 +5016,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) */
 
@@ -4998,7 +5055,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);
 }
@@ -5067,12 +5124,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);
+               wlc->pub->_cnt->txnobuf++;
        }
 
        /* Enqueue */
@@ -5089,7 +5144,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;
 
@@ -5105,7 +5160,7 @@ void BCMFASTPATH wlc_txq_enq(void *ctx, struct scb *scb, struct sk_buff *sdu,
 
                /* 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);
+               wlc->pub->_cnt->txnobuf++;
        }
 
        /* Check if flow control needs to be turned on after enqueuing the packet
@@ -5138,7 +5193,7 @@ wlc_sendpkt_mac80211(struct wlc_info *wlc, struct sk_buff *sdu,
 
        ASSERT(sdu);
 
-       fc = ltoh16(d11_header->frame_control);
+       fc = le16_to_cpu(d11_header->frame_control);
        type = (fc & IEEE80211_FCTL_FTYPE);
 
        /* 802.11 standard requires management traffic to go at highest priority */
@@ -5157,11 +5212,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;
@@ -5240,7 +5295,8 @@ bcmc_fid_generate(struct wlc_info *wlc, wlc_bsscfg_t *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) |
@@ -5263,7 +5319,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);
 
        }
 
@@ -5692,11 +5748,9 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
        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];
@@ -5714,14 +5768,14 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
 
        /* locate 802.11 MAC header */
        h = (struct ieee80211_hdr *)(p->data);
-       fc = ltoh16(h->frame_control);
+       fc = le16_to_cpu(h->frame_control);
        type = (fc & IEEE80211_FCTL_FTYPE);
 
        qos = (type == IEEE80211_FTYPE_DATA &&
               FC_SUBTYPE_ANY_QOS(fc));
 
        /* compute length of frame in bytes for use in PLCP computations */
-       len = pkttotlen(osh, p);
+       len = pkttotlen(p);
        phylen = len + FCS_LEN;
 
        /* If WEP enabled, add room in phylen for the additional bytes of
@@ -5742,7 +5796,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) {
@@ -5759,9 +5813,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_ctrl = htol16(seq);
+                       h->seq_ctrl = cpu_to_le16(seq);
 
                        frameid = ((seq << TXFID_SEQ_SHIFT) & TXFID_SEQ_MASK) |
                            (queue & TXFID_QUEUE_MASK);
@@ -5830,8 +5884,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->addr1)) {
+                       if (!is_multicast_ether_addr(h->addr1)) {
                                /* set tx antenna config */
                                wlc_antsel_antcfg_get(wlc->asi, false, false, 0,
                                                      0, &antcfg, &fbantcfg);
@@ -5983,8 +6036,8 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
        /* (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])) {
@@ -6003,7 +6056,7 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
                durid =
                    wlc_compute_frame_dur(wlc, rspec[0], preamble_type[0],
                                          next_frag_len);
-               h->duration_id = htol16(durid);
+               h->duration_id = cpu_to_le16(durid);
        } else if (use_rifs) {
                /* NAV protect to end of next max packet size */
                durid =
@@ -6011,7 +6064,7 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
                                                 preamble_type[0],
                                                 DOT11_MAX_FRAG_LEN);
                durid += RIFS_11N_TIME;
-               h->duration_id = htol16(durid);
+               h->duration_id = cpu_to_le16(durid);
        }
 
        /* DUR field for fallback rate */
@@ -6022,7 +6075,7 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
        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 */
@@ -6042,7 +6095,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;
@@ -6057,33 +6110,29 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
        }
 
        /* MacFrameControl */
-       bcopy((char *)&h->frame_control, (char *)&txh->MacFrameControl,
-           sizeof(u16));
-       txh->TxFesTimeNormal = htol16(0);
+       memcpy(&txh->MacFrameControl, &h->frame_control, sizeof(u16));
+       txh->TxFesTimeNormal = cpu_to_le16(0);
 
-       txh->TxFesTimeFallback = htol16(0);
+       txh->TxFesTimeFallback = cpu_to_le16(0);
 
        /* TxFrameRA */
-       bcopy((char *)&h->addr1, (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 */
@@ -6113,10 +6162,10 @@ 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 */
@@ -6132,8 +6181,8 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
                /* 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 ieee80211_rts *)&txh->rts_frame;
@@ -6141,21 +6190,20 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
                durid = wlc_compute_rtscts_dur(wlc, use_cts, rts_rspec[0],
                                               rspec[0], rts_preamble_type[0],
                                               preamble_type[0], phylen, false);
-               rts->duration = 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->frame_control = htol16(FC_CTS);
-                       bcopy((char *)&h->addr2, (char *)&rts->ra, ETH_ALEN);
+                       rts->frame_control = cpu_to_le16(FC_CTS);
+                       memcpy(&rts->ra, &h->addr2, ETH_ALEN);
                } else {
-                       rts->frame_control = htol16((u16) FC_RTS);
-                       bcopy((char *)&h->addr1, (char *)&rts->ra,
-                             2 * ETH_ALEN);
+                       rts->frame_control = cpu_to_le16((u16) FC_RTS);
+                       memcpy(&rts->ra, &h->addr1, 2 * ETH_ALEN);
                }
 
                /* mainrate
@@ -6183,10 +6231,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);
@@ -6194,7 +6242,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);
@@ -6204,27 +6252,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);
                }
 
                /*
@@ -6235,13 +6283,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);
                }
        }
 
@@ -6275,8 +6323,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->duration);
-                               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;
@@ -6296,9 +6345,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)) {
@@ -6348,7 +6398,7 @@ void wlc_tbtt(struct wlc_info *wlc, d11regs_t *regs)
 {
        wlc_bsscfg_t *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 */
@@ -6382,14 +6432,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)
@@ -6397,7 +6445,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);
 }
 
 /*
@@ -6466,7 +6514,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);
@@ -6480,9 +6528,9 @@ 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;
                        FOREACH_BSS(wlc, idx, bsscfg) {
@@ -6502,37 +6550,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) {
@@ -6595,38 +6612,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 ieee80211_hdr *)((u8 *) (txh + 1) + D11_PHY_HDR_LEN);
-       fc = ltoh16(h->frame_control);
+       fc = le16_to_cpu(h->frame_control);
 
        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) {
@@ -6640,7 +6656,7 @@ 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 =
@@ -6685,7 +6701,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);
@@ -6698,7 +6714,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__);
@@ -6976,15 +6992,14 @@ 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);
+       wlc->pub->_cnt->ieee_rx++;
        osh->pktalloced--;
        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__);
@@ -6992,11 +7007,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) {
-                       kfree(bi);
-                       bss_list->ptrs[index] = NULL;
-               }
+               kfree(bss_list->ptrs[index]);
+               bss_list->ptrs[index] = NULL;
        }
        bss_list->count = 0;
 }
@@ -7027,12 +7039,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;
@@ -7055,9 +7077,9 @@ 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->frame_control)) {
-               fc = ltoh16(h->frame_control);
+               fc = le16_to_cpu(h->frame_control);
        } else {
-               WLCNTINCR(wlc->pub->_cnt->rxrunt);
+               wlc->pub->_cnt->rxrunt++;
                goto toss;
        }
 
@@ -7073,10 +7095,10 @@ void BCMFASTPATH wlc_recv(struct wlc_info *wlc, struct sk_buff *p)
                                WL_ERROR("wl%d: %s: dropping a frame with "
                                         "invalid src mac address, a2: %pM\n",
                                         wlc->pub->unit, __func__, h->addr2);
-                               WLCNTINCR(wlc->pub->_cnt->rxbadsrcmac);
+                               wlc->pub->_cnt->rxbadsrcmac++;
                                goto toss;
                        }
-                       WLCNTINCR(wlc->pub->_cnt->rxfrag);
+                       wlc->pub->_cnt->rxfrag++;
                }
        }
 
@@ -7680,15 +7702,14 @@ wlc_bcn_prb_template(struct wlc_info *wlc, uint type, ratespec_t bcn_rspec,
                h = (struct ieee80211_mgmt *)&plcp[1];
 
        /* fill in 802.11 header */
-       h->frame_control = htol16((u16) type);
+       h->frame_control = cpu_to_le16((u16) 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);
+               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 */
 
@@ -7716,8 +7737,9 @@ 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;
@@ -7728,14 +7750,14 @@ void wlc_bss_update_beacon(struct wlc_info *wlc, wlc_bsscfg_t *cfg)
                /* 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;
                }
@@ -7779,7 +7801,7 @@ void wlc_shm_ssid_upd(struct wlc_info *wlc, wlc_bsscfg_t *cfg)
 
        /* padding the ssid with zero and copy it into shm */
        memset(ssidbuf, 0, IEEE80211_MAX_SSID_LEN);
-       bcopy(ssidptr, ssidbuf, cfg->SSID_len);
+       memcpy(ssidbuf, ssidptr, cfg->SSID_len);
 
        wlc_copyto_shm(wlc, base, ssidbuf, IEEE80211_MAX_SSID_LEN);
 
@@ -7857,10 +7879,10 @@ int wlc_prep_pdu(struct wlc_info *wlc, struct sk_buff *pdu, uint *fifop)
        ASSERT(txh);
        h = (struct ieee80211_hdr *)((u8 *) (txh + 1) + D11_PHY_HDR_LEN);
        ASSERT(h);
-       fc = ltoh16(h->frame_control);
+       fc = le16_to_cpu(h->frame_control);
 
        /* 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;
 
@@ -7873,9 +7895,8 @@ int wlc_prep_pdu(struct wlc_info *wlc, struct sk_buff *pdu, uint *fifop)
                return BCME_BUSY;
        }
 
-       if ((ltoh16(txh->MacFrameControl) & IEEE80211_FCTL_FTYPE) !=
-           IEEE80211_FTYPE_DATA)
-               WLCNTINCR(wlc->pub->_cnt->txctl);
+       if (!ieee80211_is_data(txh->MacFrameControl))
+               wlc->pub->_cnt->txctl++;
 
        return 0;
 }
@@ -7978,23 +7999,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)
 {
@@ -8255,6 +8259,8 @@ wlc_set_addrmatch(struct wlc_info *wlc, int match_reg_offset,
                  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 u8 *addr)
@@ -8298,7 +8304,7 @@ 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_info &= ~HT_CAP_MIMO_PS_MASK;
+       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) {
@@ -8309,7 +8315,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;
 
@@ -8324,13 +8331,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;
@@ -8367,8 +8374,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;
 
@@ -8416,7 +8423,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) {
@@ -8427,7 +8434,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;
@@ -8438,40 +8445,40 @@ 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,
+                                         struct osl_info *osh)
 {
-       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)
+                        struct wlc_txq_info *qi)
 {
-       wlc_txq_info_t *p;
+       struct wlc_txq_info *p;
 
        if (qi == NULL)
                return;
@@ -8490,3 +8497,22 @@ static void wlc_txq_free(struct wlc_info *wlc, struct osl_info *osh,
 
        kfree(qi);
 }
+
+/*
+ * Flag 'scan in progress' to withold dynamic phy calibration
+ */
+void wlc_scan_start(struct wlc_info *wlc)
+{
+       wlc_phy_hold_upd(wlc->band->pi, PHY_HOLD_FOR_SCAN, true);
+}
+
+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;
+}
This page took 0.063381 seconds and 5 git commands to generate.