staging: brcm80211: prepared header files for file rename
[deliverable/linux.git] / drivers / staging / brcm80211 / brcmsmac / wlc_main.c
index 4b4a31eff90c9f7cd2f4ae69552e2d47460d9faa..7c86abc1e0470d51f532dbe183abe4e2ee6b967f 100644 (file)
 
 #include <bcmdefs.h>
 #include <bcmdevs.h>
-#include <bcmutils.h>
-#include <bcmwifi.h>
-#include <bcmnvram.h>
+#include <brcmu_utils.h>
+#include <brcmu_wifi.h>
 #include <aiutils.h>
-#include <pcicfg.h>
 #include <bcmsrom.h>
-#include <wlioctl.h>
-#include <sbhnddma.h>
-#include <hnddma.h>
+#include "bcmdma.h"
+#include <bcmdma.h>
 
 #include "wlc_pmu.h"
 #include "d11.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"
-
-#include "wl_mac80211.h"
+#include "brcms_mac80211.h"
 
 /*
  * WPA(2) definitions
@@ -71,7 +64,6 @@
 #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 * IEEE80211_MAX_SSID_LEN) + 1)
 
 #define        TBTT_ALIGN_LEEWAY_US    100     /* min leeway before first TBTT in us */
 
+/* Software feature flag defines used by wlfeatureflag */
+#define WL_SWFL_NOHWRADIO      0x0004
+#define WL_SWFL_FLOWCONTROL     0x0008 /* Enable backpressure to OS stack */
+#define WL_SWFL_WLBSSSORT      0x0010  /* Per-port supports sorting of BSS */
+
+/* n-mode support capability */
+/* 2x2 includes both 1x1 & 2x2 devices
+ * reserved #define 2 for future when we want to separate 1x1 & 2x2 and
+ * control it independently
+ */
+#define WL_11N_2x2                     1
+#define WL_11N_3x3                     3
+#define WL_11N_4x4                     4
+
+/* define 11n feature disable flags */
+#define WLFEATURE_DISABLE_11N          0x00000001
+#define WLFEATURE_DISABLE_11N_STBC_TX  0x00000002
+#define WLFEATURE_DISABLE_11N_STBC_RX  0x00000004
+#define WLFEATURE_DISABLE_11N_SGI_TX   0x00000008
+#define WLFEATURE_DISABLE_11N_SGI_RX   0x00000010
+#define WLFEATURE_DISABLE_11N_AMPDU_TX 0x00000020
+#define WLFEATURE_DISABLE_11N_AMPDU_RX 0x00000040
+#define WLFEATURE_DISABLE_11N_GF       0x00000080
+
+#define EDCF_ACI_MASK                0x60
+#define EDCF_ACI_SHIFT               5
+#define EDCF_ECWMIN_MASK             0x0f
+#define EDCF_ECWMAX_SHIFT            4
+#define EDCF_AIFSN_MASK              0x0f
+#define EDCF_AIFSN_MAX               15
+#define EDCF_ECWMAX_MASK             0xf0
+
+#define EDCF_AC_BE_TXOP_STA          0x0000
+#define EDCF_AC_BK_TXOP_STA          0x0000
+#define EDCF_AC_VO_ACI_STA           0x62
+#define EDCF_AC_VO_ECW_STA           0x32
+#define EDCF_AC_VI_ACI_STA           0x42
+#define EDCF_AC_VI_ECW_STA           0x43
+#define EDCF_AC_BK_ECW_STA           0xA4
+#define EDCF_AC_VI_TXOP_STA          0x005e
+#define EDCF_AC_VO_TXOP_STA          0x002f
+#define EDCF_AC_BE_ACI_STA           0x03
+#define EDCF_AC_BE_ECW_STA           0xA4
+#define EDCF_AC_BK_ACI_STA           0x27
+#define EDCF_AC_VO_TXOP_AP           0x002f
+
+#define EDCF_TXOP2USEC(txop)         ((txop) << 5)
+#define EDCF_ECW2CW(exp)             ((1 << (exp)) - 1)
+
+#define APHY_SYMBOL_TIME       4
+#define APHY_PREAMBLE_TIME     16
+#define APHY_SIGNAL_TIME       4
+#define APHY_SIFS_TIME         16
+#define APHY_SERVICE_NBITS     16
+#define APHY_TAIL_NBITS                6
+#define BPHY_SIFS_TIME         10
+#define BPHY_PLCP_SHORT_TIME   96
+
+#define PREN_PREAMBLE          24
+#define PREN_MM_EXT            12
+#define PREN_PREAMBLE_EXT      4
+
+#define DOT11_MAC_HDR_LEN              24
+#define        DOT11_ACK_LEN           10
+#define DOT11_BA_LEN           4
+#define DOT11_OFDM_SIGNAL_EXTENSION    6
+#define DOT11_MIN_FRAG_LEN             256
+#define        DOT11_RTS_LEN           16
+#define        DOT11_CTS_LEN           10
+#define DOT11_BA_BITMAP_LEN            128
+#define DOT11_MIN_BEACON_PERIOD                1
+#define DOT11_MAX_BEACON_PERIOD                0xFFFF
+#define        DOT11_MAXNUMFRAGS       16
+#define DOT11_MAX_FRAG_LEN             2346
+
+#define BPHY_PLCP_TIME         192
+#define RIFS_11N_TIME          2
+
+#define WME_VER                        1
+#define WME_SUBTYPE_PARAM_IE   1
+#define WME_TYPE               2
+#define WME_OUI                        "\x00\x50\xf2"
+
+#define AC_BE                  0
+#define AC_BK                  1
+#define AC_VI                  2
+#define AC_VO                  3
+
 /*
  * driver maintains internal 'tick'(wlc->pub->now) which increments in 1s OS timer(soft
  * watchdog) it is not a wall clock and won't increment when driver is in "down" state
  * calibration and scb update
  */
 
-/* watchdog trigger mode: OSL timer or TBTT */
-#define WLC_WATCHDOG_TBTT(wlc) \
-       (wlc->stas_associated > 0 && wlc->PM != PM_OFF && wlc->pub->align_wd_tbtt)
-
 /* To inform the ucode of the last mcast frame posted so that it can clear moredata bit */
 #define BCMCFID(wlc, fid) wlc_bmac_write_shm((wlc)->hw, M_BCMC_FID, (fid))
 
                                (!AP_ENAB(wlc->pub)) && (wlc->war16165))
 
 /* debug/trace */
-uint wl_msg_level =
+uint brcm_msg_level =
 #if defined(BCMDBG)
-    WL_ERROR_VAL;
+       LOG_ERROR_VAL;
 #else
-    0;
+       0;
 #endif                         /* BCMDBG */
 
 /* Find basic rate for a given rate */
@@ -139,28 +215,6 @@ uint wl_msg_level =
 static struct wlc_info *wlc_info_dbg = (struct wlc_info *) (NULL);
 #endif
 
-/* IOVar table */
-
-/* Parameter IDs, for use only internally to wlc -- in the wlc_iovars
- * table and by the wlc_doiovar() function.  No ordering is imposed:
- * the table is keyed by name, and the function uses a switch.
- */
-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, (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}
-};
-
 const u8 prio2fifo[NUMPRIO] = {
        TX_AC_BE_FIFO,          /* 0    BE      AC_BE   Best Effort */
        TX_AC_BK_FIFO,          /* 1    BK      AC_BK   Background */
@@ -256,8 +310,6 @@ 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 */
@@ -323,14 +375,12 @@ bool wlc_ps_allowed(struct wlc_info *wlc)
        struct wlc_bsscfg *cfg;
 
        /* disallow PS when one of the following global conditions meets */
-       if (!wlc->pub->associated || !wlc->PMenabled || wlc->PM_override)
+       if (!wlc->pub->associated)
                return false;
 
        /* disallow PS when one of these meets when not scanning */
-       if (!wlc->PMblocked) {
-               if (AP_ACTIVE(wlc) || wlc->monitor)
-                       return false;
-       }
+       if (AP_ACTIVE(wlc) || wlc->monitor)
+               return false;
 
        FOREACH_AS_STA(wlc, idx, cfg) {
                /* disallow PS when one of the following bsscfg specific conditions meets */
@@ -348,8 +398,6 @@ void wlc_reset(struct wlc_info *wlc)
 {
        BCMMSG(wlc->wiphy, "wl%d\n", wlc->pub->unit);
 
-       wlc->check_for_unaligned_tbtt = false;
-
        /* slurp up hw mac counters before core reset */
        wlc_statsupd(wlc);
 
@@ -358,15 +406,13 @@ void wlc_reset(struct wlc_info *wlc)
                sizeof(macstat_t));
 
        wlc_bmac_reset(wlc->hw);
-       wlc->txretried = 0;
-
 }
 
 void wlc_fatal_error(struct wlc_info *wlc)
 {
        wiphy_err(wlc->wiphy, "wl%d: fatal error, reinitializing\n",
                  wlc->pub->unit);
-       wl_init(wlc->wl);
+       brcms_init(wlc->wl);
 }
 
 /* Return the channel the driver should initialize during wlc_init.
@@ -415,15 +461,8 @@ 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 (wlc->machwcap & MCAP_TKIPMIC)
-               wlc->tkmickeys =
-                   wlc_bmac_read_shm(wlc->hw, M_TKMICKEYS_PTR) * 2;
-
        /* update beacon listen interval */
        wlc_bcn_li_upd(wlc);
-       wlc->bcn_wait_prd =
-           (u8) (wlc_bmac_read_shm(wlc->hw, M_NOSLPZNATDTIM) >> 10);
 
        /* the world is new again, so is our reported rate */
        wlc_reprate_init(wlc);
@@ -550,7 +589,7 @@ void wlc_mac_promisc(struct wlc_info *wlc)
         * Note: APs get all BSS traffic without the need to set the MCTL_PROMISC bit
         * since all BSS data traffic is directed at the AP
         */
-       if (PROMISC_ENAB(wlc->pub) && !AP_ENAB(wlc->pub) && !wlc->wet)
+       if (PROMISC_ENAB(wlc->pub) && !AP_ENAB(wlc->pub))
                promisc_bits |= MCTL_PROMISC;
 
        /* monitor mode needs both MCTL_PROMISC and MCTL_KEEPCONTROL
@@ -664,8 +703,8 @@ static u8 wlc_local_constraint_qdbm(struct wlc_info *wlc)
 
        local = WLC_TXPWR_MAX;
        if (wlc->pub->associated &&
-           (bcm_chspec_ctlchan(wlc->chanspec) ==
-            bcm_chspec_ctlchan(wlc->home_chanspec))) {
+           (brcmu_chspec_ctlchan(wlc->chanspec) ==
+            brcmu_chspec_ctlchan(wlc->home_chanspec))) {
 
                /* get the local power constraint if we are on the AP's
                 * channel [802.11h, 7.3.2.13]
@@ -774,224 +813,6 @@ void wlc_set_chanspec(struct wlc_info *wlc, chanspec_t chanspec)
        wlc_ucode_mac_upd(wlc);
 }
 
-#if defined(BCMDBG)
-static int wlc_get_current_txpwr(struct wlc_info *wlc, void *pwr, uint len)
-{
-       txpwr_limits_t txpwr;
-       tx_power_t power;
-       tx_power_legacy_t *old_power = NULL;
-       int r, c;
-       uint qdbm;
-       bool override;
-
-       if (len == sizeof(tx_power_legacy_t))
-               old_power = (tx_power_legacy_t *) pwr;
-       else if (len < sizeof(tx_power_t))
-               return -EOVERFLOW;
-
-       memset(&power, 0, sizeof(tx_power_t));
-
-       power.chanspec = WLC_BAND_PI_RADIO_CHANSPEC;
-       if (wlc->pub->associated)
-               power.local_chanspec = wlc->home_chanspec;
-
-       /* Return the user target tx power limits for the various rates.  Note  wlc_phy.c's
-        * public interface only implements getting and setting a single value for all of
-        * rates, so we need to fill the array ourselves.
-        */
-       wlc_phy_txpower_get(wlc->band->pi, &qdbm, &override);
-       for (r = 0; r < WL_TX_POWER_RATES; r++) {
-               power.user_limit[r] = (u8) qdbm;
-       }
-
-       power.local_max = wlc->txpwr_local_max * WLC_TXPWR_DB_FACTOR;
-       power.local_constraint =
-           wlc->txpwr_local_constraint * WLC_TXPWR_DB_FACTOR;
-
-       power.antgain[0] = wlc->bandstate[BAND_2G_INDEX]->antgain;
-       power.antgain[1] = wlc->bandstate[BAND_5G_INDEX]->antgain;
-
-       wlc_channel_reg_limits(wlc->cmi, power.chanspec, &txpwr);
-
-#if WL_TX_POWER_CCK_NUM != WLC_NUM_RATES_CCK
-#error "WL_TX_POWER_CCK_NUM != WLC_NUM_RATES_CCK"
-#endif
-
-       /* CCK tx power limits */
-       for (c = 0, r = WL_TX_POWER_CCK_FIRST; c < WL_TX_POWER_CCK_NUM;
-            c++, r++)
-               power.reg_limit[r] = txpwr.cck[c];
-
-#if WL_TX_POWER_OFDM_NUM != WLC_NUM_RATES_OFDM
-#error "WL_TX_POWER_OFDM_NUM != WLC_NUM_RATES_OFDM"
-#endif
-
-       /* 20 MHz OFDM SISO tx power limits */
-       for (c = 0, r = WL_TX_POWER_OFDM_FIRST; c < WL_TX_POWER_OFDM_NUM;
-            c++, r++)
-               power.reg_limit[r] = txpwr.ofdm[c];
-
-       if (WLC_PHY_11N_CAP(wlc->band)) {
-
-               /* 20 MHz OFDM CDD tx power limits */
-               for (c = 0, r = WL_TX_POWER_OFDM20_CDD_FIRST;
-                    c < WL_TX_POWER_OFDM_NUM; c++, r++)
-                       power.reg_limit[r] = txpwr.ofdm_cdd[c];
-
-               /* 40 MHz OFDM SISO tx power limits */
-               for (c = 0, r = WL_TX_POWER_OFDM40_SISO_FIRST;
-                    c < WL_TX_POWER_OFDM_NUM; c++, r++)
-                       power.reg_limit[r] = txpwr.ofdm_40_siso[c];
-
-               /* 40 MHz OFDM CDD tx power limits */
-               for (c = 0, r = WL_TX_POWER_OFDM40_CDD_FIRST;
-                    c < WL_TX_POWER_OFDM_NUM; c++, r++)
-                       power.reg_limit[r] = txpwr.ofdm_40_cdd[c];
-
-#if WL_TX_POWER_MCS_1_STREAM_NUM != WLC_NUM_RATES_MCS_1_STREAM
-#error "WL_TX_POWER_MCS_1_STREAM_NUM != WLC_NUM_RATES_MCS_1_STREAM"
-#endif
-
-               /* 20MHz MCS0-7 SISO tx power limits */
-               for (c = 0, r = WL_TX_POWER_MCS20_SISO_FIRST;
-                    c < WLC_NUM_RATES_MCS_1_STREAM; c++, r++)
-                       power.reg_limit[r] = txpwr.mcs_20_siso[c];
-
-               /* 20MHz MCS0-7 CDD tx power limits */
-               for (c = 0, r = WL_TX_POWER_MCS20_CDD_FIRST;
-                    c < WLC_NUM_RATES_MCS_1_STREAM; c++, r++)
-                       power.reg_limit[r] = txpwr.mcs_20_cdd[c];
-
-               /* 20MHz MCS0-7 STBC tx power limits */
-               for (c = 0, r = WL_TX_POWER_MCS20_STBC_FIRST;
-                    c < WLC_NUM_RATES_MCS_1_STREAM; c++, r++)
-                       power.reg_limit[r] = txpwr.mcs_20_stbc[c];
-
-               /* 40MHz MCS0-7 SISO tx power limits */
-               for (c = 0, r = WL_TX_POWER_MCS40_SISO_FIRST;
-                    c < WLC_NUM_RATES_MCS_1_STREAM; c++, r++)
-                       power.reg_limit[r] = txpwr.mcs_40_siso[c];
-
-               /* 40MHz MCS0-7 CDD tx power limits */
-               for (c = 0, r = WL_TX_POWER_MCS40_CDD_FIRST;
-                    c < WLC_NUM_RATES_MCS_1_STREAM; c++, r++)
-                       power.reg_limit[r] = txpwr.mcs_40_cdd[c];
-
-               /* 40MHz MCS0-7 STBC tx power limits */
-               for (c = 0, r = WL_TX_POWER_MCS40_STBC_FIRST;
-                    c < WLC_NUM_RATES_MCS_1_STREAM; c++, r++)
-                       power.reg_limit[r] = txpwr.mcs_40_stbc[c];
-
-#if WL_TX_POWER_MCS_2_STREAM_NUM != WLC_NUM_RATES_MCS_2_STREAM
-#error "WL_TX_POWER_MCS_2_STREAM_NUM != WLC_NUM_RATES_MCS_2_STREAM"
-#endif
-
-               /* 20MHz MCS8-15 SDM tx power limits */
-               for (c = 0, r = WL_TX_POWER_MCS20_SDM_FIRST;
-                    c < WLC_NUM_RATES_MCS_2_STREAM; c++, r++)
-                       power.reg_limit[r] = txpwr.mcs_20_mimo[c];
-
-               /* 40MHz MCS8-15 SDM tx power limits */
-               for (c = 0, r = WL_TX_POWER_MCS40_SDM_FIRST;
-                    c < WLC_NUM_RATES_MCS_2_STREAM; c++, r++)
-                       power.reg_limit[r] = txpwr.mcs_40_mimo[c];
-
-               /* MCS 32 */
-               power.reg_limit[WL_TX_POWER_MCS_32] = txpwr.mcs32;
-       }
-
-       wlc_phy_txpower_get_current(wlc->band->pi, &power,
-                                   CHSPEC_CHANNEL(power.chanspec));
-
-       /* copy the tx_power_t struct to the return buffer,
-        * or convert to a tx_power_legacy_t struct
-        */
-       if (!old_power) {
-               memcpy(pwr, &power, sizeof(tx_power_t));
-       } else {
-               int band_idx = CHSPEC_IS2G(power.chanspec) ? 0 : 1;
-
-               memset(old_power, 0, sizeof(tx_power_legacy_t));
-
-               old_power->txpwr_local_max = power.local_max;
-               old_power->txpwr_local_constraint = power.local_constraint;
-               if (CHSPEC_IS2G(power.chanspec)) {
-                       old_power->txpwr_chan_reg_max = txpwr.cck[0];
-                       old_power->txpwr_est_Pout[band_idx] =
-                           power.est_Pout_cck;
-                       old_power->txpwr_est_Pout_gofdm = power.est_Pout[0];
-               } else {
-                       old_power->txpwr_chan_reg_max = txpwr.ofdm[0];
-                       old_power->txpwr_est_Pout[band_idx] = power.est_Pout[0];
-               }
-               old_power->txpwr_antgain[0] = power.antgain[0];
-               old_power->txpwr_antgain[1] = power.antgain[1];
-
-               for (r = 0; r < NUM_PWRCTRL_RATES; r++) {
-                       old_power->txpwr_band_max[r] = power.user_limit[r];
-                       old_power->txpwr_limit[r] = power.reg_limit[r];
-                       old_power->txpwr_target[band_idx][r] = power.target[r];
-                       if (CHSPEC_IS2G(power.chanspec))
-                               old_power->txpwr_bphy_cck_max[r] =
-                                   power.board_limit[r];
-                       else
-                               old_power->txpwr_aphy_max[r] =
-                                   power.board_limit[r];
-               }
-       }
-
-       return 0;
-}
-#endif                         /* defined(BCMDBG) */
-
-static u32 wlc_watchdog_backup_bi(struct wlc_info *wlc)
-{
-       u32 bi;
-       bi = 2 * wlc->cfg->current_bss->dtim_period *
-           wlc->cfg->current_bss->beacon_period;
-       if (wlc->bcn_li_dtim)
-               bi *= wlc->bcn_li_dtim;
-       else if (wlc->bcn_li_bcn)
-               /* recalculate bi based on bcn_li_bcn */
-               bi = 2 * wlc->bcn_li_bcn * wlc->cfg->current_bss->beacon_period;
-
-       if (bi < 2 * TIMER_INTERVAL_WATCHDOG)
-               bi = 2 * TIMER_INTERVAL_WATCHDOG;
-       return bi;
-}
-
-/* Change to run the watchdog either from a periodic timer or from tbtt handler.
- * Call watchdog from tbtt handler if tbtt is true, watchdog timer otherwise.
- */
-void wlc_watchdog_upd(struct wlc_info *wlc, bool tbtt)
-{
-       /* make sure changing watchdog driver is allowed */
-       if (!wlc->pub->up || !wlc->pub->align_wd_tbtt)
-               return;
-       if (!tbtt && wlc->WDarmed) {
-               wl_del_timer(wlc->wl, wlc->wdtimer);
-               wlc->WDarmed = false;
-       }
-
-       /* stop watchdog timer and use tbtt interrupt to drive watchdog */
-       if (tbtt && wlc->WDarmed) {
-               wl_del_timer(wlc->wl, wlc->wdtimer);
-               wlc->WDarmed = false;
-               wlc->WDlast = OSL_SYSUPTIME();
-       }
-       /* arm watchdog timer and drive the watchdog there */
-       else if (!tbtt && !wlc->WDarmed) {
-               wl_add_timer(wlc->wl, wlc->wdtimer, TIMER_INTERVAL_WATCHDOG,
-                            true);
-               wlc->WDarmed = true;
-       }
-       if (tbtt && !wlc->WDarmed) {
-               wl_add_timer(wlc->wl, wlc->wdtimer, wlc_watchdog_backup_bi(wlc),
-                            true);
-               wlc->WDarmed = true;
-       }
-}
-
 ratespec_t wlc_lowest_basic_rspec(struct wlc_info *wlc, wlc_rateset_t *rs)
 {
        ratespec_t lowest_basic_rspec;
@@ -1218,7 +1039,6 @@ static void WLBANDINITFN(wlc_setband) (struct wlc_info *wlc, uint bandunit)
                return;
 
        /* wait for at least one beacon before entering sleeping state */
-       wlc->PMawakebcn = true;
        FOREACH_AS_STA(wlc, idx, cfg)
            cfg->PMawakebcn = true;
        wlc_set_ps_ctrl(wlc);
@@ -1266,8 +1086,6 @@ void wlc_wme_setparams(struct wlc_info *wlc, u16 aci,
                return;
        }
 
-       wlc->wme_admctl = 0;
-
        do {
                memset((char *)&acp_shm, 0, sizeof(shm_acparams_t));
                /* fill in shm ac params struct */
@@ -1339,10 +1157,6 @@ void wlc_edcf_setparams(struct wlc_info *wlc, bool suspend)
        for (i_ac = 0; i_ac < AC_COUNT; i_ac++, edcf_acp++) {
                /* find out which ac this set of params applies to */
                aci = (edcf_acp->ACI & EDCF_ACI_MASK) >> EDCF_ACI_SHIFT;
-               /* set the admission control policy for this AC */
-               if (edcf_acp->ACI & EDCF_ACM_MASK) {
-                       wlc->wme_admctl |= 1 << aci;
-               }
 
                /* fill in shm ac params struct */
                params->txop = edcf_acp->TXOP;
@@ -1371,7 +1185,7 @@ void wlc_edcf_setparams(struct wlc_info *wlc, bool suspend)
 
 bool wlc_timers_init(struct wlc_info *wlc, int unit)
 {
-       wlc->wdtimer = wl_init_timer(wlc->wl, wlc_watchdog_by_timer,
+       wlc->wdtimer = brcms_init_timer(wlc->wl, wlc_watchdog_by_timer,
                wlc, "watchdog");
        if (!wlc->wdtimer) {
                wiphy_err(wlc->wiphy, "wl%d:  wl_init_timer for wdtimer "
@@ -1379,7 +1193,7 @@ bool wlc_timers_init(struct wlc_info *wlc, int unit)
                goto fail;
        }
 
-       wlc->radio_timer = wl_init_timer(wlc->wl, wlc_radio_timer,
+       wlc->radio_timer = brcms_init_timer(wlc->wl, wlc_radio_timer,
                wlc, "radio");
        if (!wlc->radio_timer) {
                wiphy_err(wlc->wiphy, "wl%d:  wl_init_timer for radio_timer "
@@ -1403,25 +1217,13 @@ void wlc_info_init(struct wlc_info *wlc, int unit)
        /* Assume the device is there until proven otherwise */
        wlc->device_present = true;
 
-       /* set default power output percentage to 100 percent */
-       wlc->txpwr_percent = 100;
-
        /* Save our copy of the chanspec */
        wlc->chanspec = CH20MHZ_CHSPEC(1);
 
-       /* initialize CCK preamble mode to unassociated state */
-       wlc->shortpreamble = false;
-
-       wlc->legacy_probe = true;
-
        /* various 802.11g modes */
        wlc->shortslot = false;
        wlc->shortslot_override = WLC_SHORTSLOT_AUTO;
 
-       wlc->barker_overlap_control = true;
-       wlc->barker_preamble = WLC_BARKER_SHORT_ALLOWED;
-       wlc->txburst_limit_override = AUTO;
-
        wlc_protection_upd(wlc, WLC_PROT_G_OVR, WLC_PROTECTION_AUTO);
        wlc_protection_upd(wlc, WLC_PROT_G_SPEC, false);
 
@@ -1454,30 +1256,6 @@ void wlc_info_init(struct wlc_info *wlc, int unit)
        wlc->SRL = RETRY_SHORT_DEF;
        wlc->LRL = RETRY_LONG_DEF;
 
-       /* init PM state */
-       wlc->PM = PM_OFF;       /* User's setting of PM mode through IOCTL */
-       wlc->PM_override = false;       /* Prevents from going to PM if our AP is 'ill' */
-       wlc->PMenabled = false; /* Current PM state */
-       wlc->PMpending = false; /* Tracks whether STA indicated PM in the last attempt */
-       wlc->PMblocked = false; /* To allow blocking going into PM during RM and scans */
-
-       /* In WMM Auto mode, PM is allowed if association is a UAPSD association */
-       wlc->WME_PM_blocked = false;
-
-       /* Init wme queuing method */
-       wlc->wme_prec_queuing = false;
-
-       /* Overrides for the core to stay awake under zillion conditions Look for STAY_AWAKE */
-       wlc->wake = false;
-       /* Are we waiting for a response to PS-Poll that we sent */
-       wlc->PSpoll = false;
-
-       /* APSD defaults */
-       wlc->wme_apsd = true;
-       wlc->apsd_sta_usp = false;
-       wlc->apsd_trigger_timeout = 0;  /* disable the trigger timer */
-       wlc->apsd_trigger_ac = AC_BITMAP_ALL;
-
        /* Set flag to indicate that hw keys should be used when available. */
        wlc->wsec_swkeys = false;
 
@@ -1487,8 +1265,6 @@ void wlc_info_init(struct wlc_info *wlc, int unit)
                wlc->wsec_keys[i]->idx = (u8) i;
        }
 
-       wlc->_regulatory_domain = false;        /* 802.11d */
-
        /* WME QoS mode is Auto by default */
        wlc->pub->_wme = AUTO;
 
@@ -1498,14 +1274,10 @@ void wlc_info_init(struct wlc_info *wlc, int unit)
 
        wlc->pub->_ampdu = AMPDU_AGG_HOST;
        wlc->pub->bcmerror = 0;
-       wlc->ibss_allowed = true;
-       wlc->ibss_coalesce_allowed = true;
        wlc->pub->_coex = ON;
 
        /* initialize mpc delay */
        wlc->mpc_delay_off = wlc->mpc_dlycnt = WLC_MPC_MIN_DELAYCNT;
-
-       wlc->pr80838_war = true;
 }
 
 static bool wlc_state_bmac_sync(struct wlc_info *wlc)
@@ -1564,7 +1336,7 @@ struct wlc_pub *wlc_pub(void *wlc)
 /*
  * The common driver entry routine. Error codes should be unique
  */
-void *wlc_attach(struct wl_info *wl, u16 vendor, u16 device, uint unit,
+void *wlc_attach(struct brcms_info *wl, u16 vendor, u16 device, uint unit,
                 bool piomode, void *regsva, uint bustype, void *btparam,
                 uint *perr)
 {
@@ -1589,11 +1361,8 @@ void *wlc_attach(struct wl_info *wl, u16 vendor, u16 device, uint unit,
        wlc->core = wlc->corestate;
        wlc->wl = wl;
        pub->unit = unit;
-       wlc->btparam = btparam;
        pub->_piomode = piomode;
        wlc->bandinit_pending = false;
-       /* By default restrict TKIP associations from 11n STA's */
-       wlc->ht_wsec_restriction = WLC_HT_TKIP_RESTRICT;
 
        /* populate struct wlc_info with default values  */
        wlc_info_init(wlc, unit);
@@ -1604,10 +1373,6 @@ void *wlc_attach(struct wl_info *wl, u16 vendor, u16 device, uint unit,
        /* 11n_disable nvram */
        n_disabled = getintvar(pub->vars, "11n_disable");
 
-       /* register a module (to handle iovars) */
-       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)
@@ -1762,9 +1527,6 @@ void *wlc_attach(struct wl_info *wl, u16 vendor, u16 device, uint unit,
        wlc->cck_40txbw = AUTO;
        wlc_update_mimo_band_bwcap(wlc, WLC_N_BW_20IN2G_40IN5G);
 
-       /* Enable setting the RIFS Mode bit by default in HT Info IE */
-       wlc->rifs_advert = AUTO;
-
        /* Set default values of SGI */
        if (WLC_SGI_CAP_PHY(wlc)) {
                wlc_ht_update_sgi_rx(wlc, (WLC_N_SGI_20 | WLC_N_SGI_40));
@@ -1904,11 +1666,11 @@ static void wlc_timers_deinit(struct wlc_info *wlc)
 {
        /* free timer state */
        if (wlc->wdtimer) {
-               wl_free_timer(wlc->wl, wlc->wdtimer);
+               brcms_free_timer(wlc->wl, wlc->wdtimer);
                wlc->wdtimer = NULL;
        }
        if (wlc->radio_timer) {
-               wl_free_timer(wlc->wl, wlc->radio_timer);
+               brcms_free_timer(wlc->wl, wlc->radio_timer);
                wlc->radio_timer = NULL;
        }
 }
@@ -1957,28 +1719,6 @@ uint wlc_detach(struct wlc_info *wlc)
 
        wlc_detach_module(wlc);
 
-       /* free other state */
-
-
-#ifdef BCMDBG
-       kfree(wlc->country_ie_override);
-       wlc->country_ie_override = NULL;
-#endif                         /* BCMDBG */
-
-       {
-               /* free dumpcb list */
-               struct dumpcb_s *prev, *ptr;
-               prev = ptr = wlc->dumpcb_head;
-               while (ptr) {
-                       ptr = prev->next;
-                       kfree(prev);
-                       prev = ptr;
-               }
-               wlc->dumpcb_head = NULL;
-       }
-
-       /* Detach from iovar manager */
-       wlc_module_unregister(wlc->pub, "wlc_iovars", wlc);
 
        while (wlc->tx_queues != NULL)
                wlc_txq_free(wlc, wlc->tx_queues);
@@ -1995,9 +1735,6 @@ void wlc_ap_upd(struct wlc_info *wlc)
        else
                wlc->PLCPHdr_override = WLC_PLCP_SHORT; /* STA-BSS; short capable */
 
-       /* disable vlan_mode on AP since some legacy STAs cannot rx tagged pkts */
-       wlc->vlan_mode = AP_ENAB(wlc->pub) ? OFF : AUTO;
-
        /* fixup mpc */
        wlc->mpc = true;
 }
@@ -2119,7 +1856,7 @@ void wlc_radio_disable(struct wlc_info *wlc)
        }
 
        wlc_radio_monitor_start(wlc);
-       wl_down(wlc->wl);
+       brcms_down(wlc->wl);
 }
 
 static void wlc_radio_enable(struct wlc_info *wlc)
@@ -2130,9 +1867,7 @@ static void wlc_radio_enable(struct wlc_info *wlc)
        if (DEVICEREMOVED(wlc))
                return;
 
-       if (!wlc->down_override) {      /* imposed by wl down/out ioctl */
-               wl_up(wlc->wl);
-       }
+       brcms_up(wlc->wl);
 }
 
 /* periodical query hw radio button while driver is "down" */
@@ -2143,7 +1878,7 @@ static void wlc_radio_timer(void *arg)
        if (DEVICEREMOVED(wlc)) {
                wiphy_err(wlc->wiphy, "wl%d: %s: dead chip\n", wlc->pub->unit,
                        __func__);
-               wl_down(wlc->wl);
+               brcms_down(wlc->wl);
                return;
        }
 
@@ -2163,7 +1898,8 @@ static bool wlc_radio_monitor_start(struct wlc_info *wlc)
 
        wlc->radio_monitor = true;
        wlc_pllreq(wlc, true, WLC_PLLREQ_RADIO_MON);
-       wl_add_timer(wlc->wl, wlc->radio_timer, TIMER_INTERVAL_RADIOCHK, true);
+       brcms_add_timer(wlc->wl, wlc->radio_timer, TIMER_INTERVAL_RADIOCHK,
+                       true);
        return true;
 }
 
@@ -2174,19 +1910,12 @@ bool wlc_radio_monitor_stop(struct wlc_info *wlc)
 
        wlc->radio_monitor = false;
        wlc_pllreq(wlc, false, WLC_PLLREQ_RADIO_MON);
-       return wl_del_timer(wlc->wl, wlc->radio_timer);
+       return brcms_del_timer(wlc->wl, wlc->radio_timer);
 }
 
 static void wlc_watchdog_by_timer(void *arg)
 {
-       struct wlc_info *wlc = (struct wlc_info *) arg;
        wlc_watchdog(arg);
-       if (WLC_WATCHDOG_TBTT(wlc)) {
-               /* set to normal osl watchdog period */
-               wl_del_timer(wlc->wl, wlc->wdtimer);
-               wl_add_timer(wlc->wl, wlc->wdtimer, TIMER_INTERVAL_WATCHDOG,
-                            true);
-       }
 }
 
 /* common watchdog code */
@@ -2204,7 +1933,7 @@ static void wlc_watchdog(void *arg)
        if (DEVICEREMOVED(wlc)) {
                wiphy_err(wlc->wiphy, "wl%d: %s: dead chip\n", wlc->pub->unit,
                          __func__);
-               wl_down(wlc->wl);
+               brcms_down(wlc->wl);
                return;
        }
 
@@ -2339,7 +2068,7 @@ int wlc_up(struct wlc_info *wlc)
                wlc_mhf(wlc, MHF2, MHF2_PCISLOWCLKWAR, MHF2_PCISLOWCLKWAR,
                        WLC_BAND_ALL);
 
-       wl_init(wlc->wl);
+       brcms_init(wlc->wl);
        wlc->pub->up = true;
 
        if (wlc->bandinit_pending) {
@@ -2359,7 +2088,7 @@ int wlc_up(struct wlc_info *wlc)
        wlc_wme_retries_write(wlc);
 
        /* start one second watchdog timer */
-       wl_add_timer(wlc->wl, wlc->wdtimer, TIMER_INTERVAL_WATCHDOG, true);
+       brcms_add_timer(wlc->wl, wlc->wdtimer, TIMER_INTERVAL_WATCHDOG, true);
        wlc->WDarmed = true;
 
        /* ensure antenna config is up to date */
@@ -2437,7 +2166,7 @@ uint wlc_down(struct wlc_info *wlc)
 
        /* cancel the watchdog timer */
        if (wlc->WDarmed) {
-               if (!wl_del_timer(wlc->wl, wlc->wdtimer))
+               if (!brcms_del_timer(wlc->wl, wlc->wdtimer))
                        callbacks++;
                wlc->WDarmed = false;
        }
@@ -2453,7 +2182,7 @@ uint wlc_down(struct wlc_info *wlc)
 
        /* flush tx queues */
        for (qi = wlc->tx_queues; qi != NULL; qi = qi->next) {
-               bcm_pktq_flush(&qi->q, true, NULL, NULL);
+               brcmu_pktq_flush(&qi->q, true, NULL, NULL);
        }
 
        callbacks += wlc_bmac_down_finish(wlc->hw);
@@ -2475,7 +2204,6 @@ int wlc_set_gmode(struct wlc_info *wlc, u8 gmode, bool config)
        s8 shortslot = WLC_SHORTSLOT_AUTO;      /* Advertise and use shortslot (-1/0/1 Auto/Off/On) */
        bool shortslot_restrict = false;        /* Restrict association to stations that support shortslot
                                                 */
-       bool ignore_bcns = true;        /* Ignore legacy beacons on the same channel */
        bool ofdm_basic = false;        /* Make 6, 12, and 24 basic rates */
        int preamble = WLC_PLCP_LONG;   /* Advertise and use short preambles (-1/0/1 Auto/Off/On) */
        bool preamble_restrict = false; /* Restrict association to stations that support short
@@ -2571,8 +2299,6 @@ int wlc_set_gmode(struct wlc_info *wlc, u8 gmode, bool config)
 
        band->gmode = gmode;
 
-       wlc->ignore_bcns = ignore_bcns;
-
        wlc->shortslot_override = shortslot;
 
        if (AP_ENAB(wlc->pub)) {
@@ -2781,11 +2507,9 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
        bool bool_val;
        int bcmerror;
        d11regs_t *regs;
-       uint i;
        struct scb *nextscb;
        bool ta_ok;
        uint band;
-       rw_reg_t *r;
        struct wlc_bsscfg *bsscfg;
        wlc_bss_info_t *current_bss;
 
@@ -2797,13 +2521,12 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
        nextscb = NULL;
        ta_ok = false;
        band = 0;
-       r = NULL;
 
        /* If the device is turned off, then it's not "removed" */
        if (!wlc->pub->hw_off && DEVICEREMOVED(wlc)) {
                wiphy_err(wlc->wiphy, "wl%d: %s: dead chip\n", wlc->pub->unit,
                          __func__);
-               wl_down(wlc->wl);
+               brcms_down(wlc->wl);
                return -EBADE;
        }
 
@@ -2821,61 +2544,15 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
        bcmerror = 0;
        regs = wlc->regs;
 
-       /* A few commands don't need any arguments; all the others do. */
-       switch (cmd) {
-       case WLC_UP:
-       case WLC_OUT:
-       case WLC_DOWN:
-       case WLC_DISASSOC:
-       case WLC_RESTART:
-       case WLC_REBOOT:
-       case WLC_START_CHANNEL_QA:
-       case WLC_INIT:
-               break;
-
-       default:
-               if ((arg == NULL) || (len <= 0)) {
-                       wiphy_err(wlc->wiphy, "wl%d: %s: Command %d needs "
-                                 "arguments\n",
-                                 wlc->pub->unit, __func__, cmd);
-                       bcmerror = -EINVAL;
-                       goto done;
-               }
+       if ((arg == NULL) || (len <= 0)) {
+               wiphy_err(wlc->wiphy, "wl%d: %s: Command %d needs arguments\n",
+                         wlc->pub->unit, __func__, cmd);
+               bcmerror = -EINVAL;
+               goto done;
        }
 
        switch (cmd) {
 
-#if defined(BCMDBG)
-       case WLC_GET_MSGLEVEL:
-               *pval = wl_msg_level;
-               break;
-
-       case WLC_SET_MSGLEVEL:
-               wl_msg_level = val;
-               break;
-#endif
-
-       case WLC_GET_INSTANCE:
-               *pval = wlc->pub->unit;
-               break;
-
-       case WLC_GET_CHANNEL:{
-                       channel_info_t *ci = (channel_info_t *) arg;
-
-                       if (len <= (int)sizeof(ci)) {
-                               bcmerror = EOVERFLOW;
-                               goto done;
-                       }
-
-                       ci->hw_channel =
-                           CHSPEC_CHANNEL(WLC_BAND_PI_RADIO_CHANSPEC);
-                       ci->target_channel =
-                           CHSPEC_CHANNEL(wlc->default_bss->chanspec);
-                       ci->scan_channel = 0;
-
-                       break;
-               }
-
        case WLC_SET_CHANNEL:{
                        chanspec_t chspec = CH20MHZ_CHSPEC(val);
 
@@ -2909,982 +2586,157 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
                        break;
                }
 
-#if defined(BCMDBG)
-       case WLC_GET_UCFLAGS:
-               if (!wlc->pub->up) {
-                       bcmerror = -ENOLINK;
-                       break;
-               }
-
-               /* optional band is stored in the second integer of incoming buffer */
-               band =
-                   (len <
-                    (int)(2 * sizeof(int))) ? WLC_BAND_AUTO : ((int *)arg)[1];
+       case WLC_SET_SRL:
+               if (val >= 1 && val <= RETRY_SHORT_MAX) {
+                       int ac;
+                       wlc->SRL = (u16) val;
 
-               /* bcmerror checking */
-               bcmerror = wlc_iocregchk(wlc, band);
-               if (bcmerror)
-                       break;
+                       wlc_bmac_retrylimit_upd(wlc->hw, wlc->SRL, wlc->LRL);
 
-               if (val >= MHFMAX) {
+                       for (ac = 0; ac < AC_COUNT; ac++) {
+                               WLC_WME_RETRY_SHORT_SET(wlc, ac, wlc->SRL);
+                       }
+                       wlc_wme_retries_write(wlc);
+               } else
                        bcmerror = -EINVAL;
-                       break;
-               }
-
-               *pval = wlc_bmac_mhf_get(wlc->hw, (u8) val, WLC_BAND_AUTO);
                break;
 
-       case WLC_SET_UCFLAGS:
-               if (!wlc->pub->up) {
-                       bcmerror = -ENOLINK;
-                       break;
-               }
-
-               /* optional band is stored in the second integer of incoming buffer */
-               band =
-                   (len <
-                    (int)(2 * sizeof(int))) ? WLC_BAND_AUTO : ((int *)arg)[1];
+       case WLC_SET_LRL:
+               if (val >= 1 && val <= 255) {
+                       int ac;
+                       wlc->LRL = (u16) val;
 
-               /* bcmerror checking */
-               bcmerror = wlc_iocregchk(wlc, band);
-               if (bcmerror)
-                       break;
+                       wlc_bmac_retrylimit_upd(wlc->hw, wlc->SRL, wlc->LRL);
 
-               i = (u16) val;
-               if (i >= MHFMAX) {
+                       for (ac = 0; ac < AC_COUNT; ac++) {
+                               WLC_WME_RETRY_LONG_SET(wlc, ac, wlc->LRL);
+                       }
+                       wlc_wme_retries_write(wlc);
+               } else
                        bcmerror = -EINVAL;
-                       break;
-               }
-
-               wlc_mhf(wlc, (u8) i, 0xffff, (u16) (val >> NBITS(u16)),
-                       WLC_BAND_AUTO);
                break;
 
-       case WLC_GET_SHMEM:
-               ta_ok = true;
+       case WLC_GET_CURR_RATESET:{
+                       wl_rateset_t *ret_rs = (wl_rateset_t *) arg;
+                       wlc_rateset_t *rs;
 
-               /* optional band is stored in the second integer of incoming buffer */
-               band =
-                   (len <
-                    (int)(2 * sizeof(int))) ? WLC_BAND_AUTO : ((int *)arg)[1];
+                       if (wlc->pub->associated)
+                               rs = &current_bss->rateset;
+                       else
+                               rs = &wlc->default_bss->rateset;
 
-               /* bcmerror checking */
-               bcmerror = wlc_iocregchk(wlc, band);
-               if (bcmerror)
-                       break;
+                       if (len < (int)(rs->count + sizeof(rs->count))) {
+                               bcmerror = -EOVERFLOW;
+                               break;
+                       }
 
-               if (val & 1) {
-                       bcmerror = -EINVAL;
+                       /* Copy only legacy rateset section */
+                       ret_rs->count = rs->count;
+                       memcpy(&ret_rs->rates, &rs->rates, rs->count);
                        break;
                }
 
-               *pval = wlc_read_shm(wlc, (u16) val);
-               break;
-
-       case WLC_SET_SHMEM:
-               ta_ok = true;
-
-               /* optional band is stored in the second integer of incoming buffer */
-               band =
-                   (len <
-                    (int)(2 * sizeof(int))) ? WLC_BAND_AUTO : ((int *)arg)[1];
+       case WLC_SET_RATESET:{
+                       wlc_rateset_t rs;
+                       wl_rateset_t *in_rs = (wl_rateset_t *) arg;
 
-               /* bcmerror checking */
-               bcmerror = wlc_iocregchk(wlc, band);
-               if (bcmerror)
-                       break;
+                       if (len < (int)(in_rs->count + sizeof(in_rs->count))) {
+                               bcmerror = -EOVERFLOW;
+                               break;
+                       }
 
-               if (val & 1) {
-                       bcmerror = -EINVAL;
-                       break;
-               }
+                       if (in_rs->count > WLC_NUMRATES) {
+                               bcmerror = -ENOBUFS;
+                               break;
+                       }
 
-               wlc_write_shm(wlc, (u16) val,
-                             (u16) (val >> NBITS(u16)));
-               break;
+                       memset(&rs, 0, sizeof(wlc_rateset_t));
 
-       case WLC_R_REG: /* MAC registers */
-               ta_ok = true;
-               r = (rw_reg_t *) arg;
-               band = WLC_BAND_AUTO;
+                       /* Copy only legacy rateset section */
+                       rs.count = in_rs->count;
+                       memcpy(&rs.rates, &in_rs->rates, rs.count);
 
-               if (len < (int)(sizeof(rw_reg_t) - sizeof(uint))) {
-                       bcmerror = -EOVERFLOW;
-                       break;
-               }
+                       /* merge rateset coming in with the current mcsset */
+                       if (N_ENAB(wlc->pub)) {
+                               if (bsscfg->associated)
+                                       memcpy(rs.mcs,
+                                              &current_bss->rateset.mcs[0],
+                                              MCSSET_LEN);
+                               else
+                                       memcpy(rs.mcs,
+                                              &wlc->default_bss->rateset.mcs[0],
+                                              MCSSET_LEN);
+                       }
 
-               if (len >= (int)sizeof(rw_reg_t))
-                       band = r->band;
+                       bcmerror = wlc_set_rateset(wlc, &rs);
 
-               /* bcmerror checking */
-               bcmerror = wlc_iocregchk(wlc, band);
-               if (bcmerror)
-                       break;
+                       if (!bcmerror)
+                               wlc_ofdm_rateset_war(wlc);
 
-               if ((r->byteoff + r->size) > sizeof(d11regs_t)) {
-                       bcmerror = -EINVAL;
                        break;
                }
-               if (r->size == sizeof(u32))
-                       r->val =
-                           R_REG((u32 *)((unsigned char *)(unsigned long)regs +
-                                             r->byteoff));
-               else if (r->size == sizeof(u16))
-                       r->val =
-                           R_REG((u16 *)((unsigned char *)(unsigned long)regs +
-                                             r->byteoff));
-               else
+
+       case WLC_SET_BCNPRD:
+               /* range [1, 0xffff] */
+               if (val >= DOT11_MIN_BEACON_PERIOD
+                   && val <= DOT11_MAX_BEACON_PERIOD) {
+                       wlc->default_bss->beacon_period = (u16) val;
+               } else
                        bcmerror = -EINVAL;
                break;
 
-       case WLC_W_REG:
-               ta_ok = true;
-               r = (rw_reg_t *) arg;
-               band = WLC_BAND_AUTO;
+       case WLC_GET_PHYLIST:
+               {
+                       unsigned char *cp = arg;
+                       if (len < 3) {
+                               bcmerror = -EOVERFLOW;
+                               break;
+                       }
 
-               if (len < (int)(sizeof(rw_reg_t) - sizeof(uint))) {
-                       bcmerror = -EOVERFLOW;
+                       if (WLCISNPHY(wlc->band)) {
+                               *cp++ = 'n';
+                       } else if (WLCISLCNPHY(wlc->band)) {
+                               *cp++ = 'c';
+                       } else if (WLCISSSLPNPHY(wlc->band)) {
+                               *cp++ = 's';
+                       }
+                       *cp = '\0';
                        break;
                }
 
-               if (len >= (int)sizeof(rw_reg_t))
-                       band = r->band;
-
-               /* bcmerror checking */
-               bcmerror = wlc_iocregchk(wlc, band);
-               if (bcmerror)
-                       break;
-
-               if (r->byteoff + r->size > sizeof(d11regs_t)) {
-                       bcmerror = -EINVAL;
-                       break;
-               }
-               if (r->size == sizeof(u32))
-                       W_REG((u32 *)((unsigned char *)(unsigned long) regs +
-                                         r->byteoff), r->val);
-               else if (r->size == sizeof(u16))
-                       W_REG((u16 *)((unsigned char *)(unsigned long) regs +
-                                         r->byteoff), r->val);
-               else
-                       bcmerror = -EINVAL;
-               break;
-#endif                         /* BCMDBG */
-
-       case WLC_GET_TXANT:
-               *pval = wlc->stf->txant;
-               break;
-
-       case WLC_SET_TXANT:
-               bcmerror = wlc_stf_ant_txant_validate(wlc, (s8) val);
-               if (bcmerror < 0)
-                       break;
-
-               wlc->stf->txant = (s8) val;
-
-               /* if down, we are done */
-               if (!wlc->pub->up)
-                       break;
-
-               wlc_suspend_mac_and_wait(wlc);
-
-               wlc_stf_phy_txant_upd(wlc);
-               wlc_beacon_phytxctl_txant_upd(wlc, wlc->bcn_rspec);
-
-               wlc_enable_mac(wlc);
-
-               break;
-
-       case WLC_GET_ANTDIV:{
-                       u8 phy_antdiv;
-
-                       /* return configured value if core is down */
-                       if (!wlc->pub->up) {
-                               *pval = wlc->stf->ant_rx_ovr;
-
-                       } else {
-                               if (wlc_phy_ant_rxdiv_get
-                                   (wlc->band->pi, &phy_antdiv))
-                                       *pval = (int)phy_antdiv;
-                               else
-                                       *pval = (int)wlc->stf->ant_rx_ovr;
-                       }
-
-                       break;
-               }
-       case WLC_SET_ANTDIV:
-               /* values are -1=driver default, 0=force0, 1=force1, 2=start1, 3=start0 */
-               if ((val < -1) || (val > 3)) {
-                       bcmerror = -EINVAL;
-                       break;
-               }
-
-               if (val == -1)
-                       val = ANT_RX_DIV_DEF;
-
-               wlc->stf->ant_rx_ovr = (u8) val;
-               wlc_phy_ant_rxdiv_set(wlc->band->pi, (u8) val);
-               break;
-
-       case WLC_GET_RX_ANT:{   /* get latest used rx antenna */
-                       u16 rxstatus;
-
-                       if (!wlc->pub->up) {
-                               bcmerror = -ENOLINK;
-                               break;
-                       }
-
-                       rxstatus = R_REG(&wlc->regs->phyrxstatus0);
-                       if (rxstatus == 0xdead || rxstatus == (u16) -1) {
-                               bcmerror = -EBADE;
-                               break;
-                       }
-                       *pval = (rxstatus & PRXS0_RXANT_UPSUBBAND) ? 1 : 0;
-                       break;
-               }
-
-#if defined(BCMDBG)
-       case WLC_GET_UCANTDIV:
-               if (!wlc->clk) {
-                       bcmerror = -EIO;
-                       break;
-               }
-
-               *pval =
-                   (wlc_bmac_mhf_get(wlc->hw, MHF1, WLC_BAND_AUTO) &
-                    MHF1_ANTDIV);
-               break;
-
-       case WLC_SET_UCANTDIV:{
-                       if (!wlc->pub->up) {
-                               bcmerror = -ENOLINK;
-                               break;
-                       }
-
-                       /* if multiband, band must be locked */
-                       if (IS_MBAND_UNLOCKED(wlc)) {
-                               bcmerror = -ENOMEDIUM;
-                               break;
-                       }
-
-                       wlc_mhf(wlc, MHF1, MHF1_ANTDIV,
-                               (val ? MHF1_ANTDIV : 0), WLC_BAND_AUTO);
-                       break;
-               }
-#endif                         /* defined(BCMDBG) */
-
-       case WLC_GET_SRL:
-               *pval = wlc->SRL;
-               break;
-
-       case WLC_SET_SRL:
-               if (val >= 1 && val <= RETRY_SHORT_MAX) {
-                       int ac;
-                       wlc->SRL = (u16) val;
-
-                       wlc_bmac_retrylimit_upd(wlc->hw, wlc->SRL, wlc->LRL);
-
-                       for (ac = 0; ac < AC_COUNT; ac++) {
-                               WLC_WME_RETRY_SHORT_SET(wlc, ac, wlc->SRL);
-                       }
-                       wlc_wme_retries_write(wlc);
-               } else
-                       bcmerror = -EINVAL;
-               break;
-
-       case WLC_GET_LRL:
-               *pval = wlc->LRL;
-               break;
-
-       case WLC_SET_LRL:
-               if (val >= 1 && val <= 255) {
-                       int ac;
-                       wlc->LRL = (u16) val;
-
-                       wlc_bmac_retrylimit_upd(wlc->hw, wlc->SRL, wlc->LRL);
-
-                       for (ac = 0; ac < AC_COUNT; ac++) {
-                               WLC_WME_RETRY_LONG_SET(wlc, ac, wlc->LRL);
-                       }
-                       wlc_wme_retries_write(wlc);
-               } else
-                       bcmerror = -EINVAL;
-               break;
-
-       case WLC_GET_CWMIN:
-               *pval = wlc->band->CWmin;
-               break;
-
-       case WLC_SET_CWMIN:
-               if (!wlc->clk) {
-                       bcmerror = -EIO;
-                       break;
-               }
-
-               if (val >= 1 && val <= 255) {
-                       wlc_set_cwmin(wlc, (u16) val);
-               } else
-                       bcmerror = -EINVAL;
-               break;
-
-       case WLC_GET_CWMAX:
-               *pval = wlc->band->CWmax;
-               break;
-
-       case WLC_SET_CWMAX:
-               if (!wlc->clk) {
-                       bcmerror = -EIO;
-                       break;
-               }
-
-               if (val >= 255 && val <= 2047) {
-                       wlc_set_cwmax(wlc, (u16) val);
-               } else
-                       bcmerror = -EINVAL;
-               break;
-
-       case WLC_GET_RADIO:     /* use mask if don't want to expose some internal bits */
-               *pval = wlc->pub->radio_disabled;
-               break;
-
-       case WLC_SET_RADIO:{    /* 32 bits input, higher 16 bits are mask, lower 16 bits are value to
-                                * set
-                                */
-                       u16 radiomask, radioval;
-                       uint validbits =
-                           WL_RADIO_SW_DISABLE | WL_RADIO_HW_DISABLE;
-                       mbool new = 0;
-
-                       radiomask = (val & 0xffff0000) >> 16;
-                       radioval = val & 0x0000ffff;
-
-                       if ((radiomask == 0) || (radiomask & ~validbits)
-                           || (radioval & ~validbits)
-                           || ((radioval & ~radiomask) != 0)) {
-                               wiphy_err(wlc->wiphy, "SET_RADIO with wrong "
-                                         "bits 0x%x\n", val);
-                               bcmerror = -EINVAL;
-                               break;
-                       }
-
-                       new =
-                           (wlc->pub->radio_disabled & ~radiomask) | radioval;
-                       wlc->pub->radio_disabled = new;
-
-                       wlc_radio_hwdisable_upd(wlc);
-                       wlc_radio_upd(wlc);
-                       break;
-               }
-
-       case WLC_GET_PHYTYPE:
-               *pval = WLC_PHYTYPE(wlc->band->phytype);
-               break;
-
-#if defined(BCMDBG)
-       case WLC_GET_KEY:
-               if ((val >= 0) && (val < WLC_MAX_WSEC_KEYS(wlc))) {
-                       wl_wsec_key_t key;
-
-                       wsec_key_t *src_key = wlc->wsec_keys[val];
-
-                       if (len < (int)sizeof(key)) {
-                               bcmerror = -EOVERFLOW;
-                               break;
-                       }
-
-                       memset((char *)&key, 0, sizeof(key));
-                       if (src_key) {
-                               key.index = src_key->id;
-                               key.len = src_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;
-
-                               memcpy(key.ea, src_key->ea, ETH_ALEN);
-                       }
-
-                       memcpy(arg, &key, sizeof(key));
-               } else
-                       bcmerror = -EINVAL;
-               break;
-#endif                         /* defined(BCMDBG) */
-
-       case WLC_SET_KEY:
-               bcmerror =
-                   wlc_iovar_op(wlc, "wsec_key", NULL, 0, arg, len, IOV_SET,
-                                wlcif);
-               break;
-
-       case WLC_GET_KEY_SEQ:{
-                       wsec_key_t *key;
-
-                       if (len < DOT11_WPA_KEY_RSC_LEN) {
-                               bcmerror = -EOVERFLOW;
-                               break;
-                       }
-
-                       /* Return the key's tx iv as an EAPOL sequence counter.
-                        * This will be used to supply the RSC value to a supplicant.
-                        * The format is 8 bytes, with least significant in seq[0].
-                        */
-
-                       key = WSEC_KEY(wlc, val);
-                       if ((val >= 0) && (val < WLC_MAX_WSEC_KEYS(wlc)) &&
-                               (key != NULL)) {
-                               u8 seq[DOT11_WPA_KEY_RSC_LEN];
-                               u16 lo;
-                               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)) {
-                                       lo = bsscfg->wpa_none_txiv.lo;
-                                       hi = bsscfg->wpa_none_txiv.hi;
-                               } else {
-                                       lo = key->txiv.lo;
-                                       hi = key->txiv.hi;
-                               }
-
-                               /* format the buffer, low to high */
-                               seq[0] = lo & 0xff;
-                               seq[1] = (lo >> 8) & 0xff;
-                               seq[2] = hi & 0xff;
-                               seq[3] = (hi >> 8) & 0xff;
-                               seq[4] = (hi >> 16) & 0xff;
-                               seq[5] = (hi >> 24) & 0xff;
-                               seq[6] = 0;
-                               seq[7] = 0;
-
-                               memcpy(arg, seq, sizeof(seq));
-                       } else {
-                               bcmerror = -EINVAL;
-                       }
-                       break;
-               }
-
-       case WLC_GET_CURR_RATESET:{
-                       wl_rateset_t *ret_rs = (wl_rateset_t *) arg;
-                       wlc_rateset_t *rs;
-
-                       if (wlc->pub->associated)
-                               rs = &current_bss->rateset;
-                       else
-                               rs = &wlc->default_bss->rateset;
-
-                       if (len < (int)(rs->count + sizeof(rs->count))) {
-                               bcmerror = -EOVERFLOW;
-                               break;
-                       }
-
-                       /* Copy only legacy rateset section */
-                       ret_rs->count = rs->count;
-                       memcpy(&ret_rs->rates, &rs->rates, rs->count);
-                       break;
-               }
-
-       case WLC_GET_RATESET:{
-                       wlc_rateset_t rs;
-                       wl_rateset_t *ret_rs = (wl_rateset_t *) arg;
-
-                       memset(&rs, 0, sizeof(wlc_rateset_t));
-                       wlc_default_rateset(wlc, (wlc_rateset_t *) &rs);
-
-                       if (len < (int)(rs.count + sizeof(rs.count))) {
-                               bcmerror = -EOVERFLOW;
-                               break;
-                       }
-
-                       /* Copy only legacy rateset section */
-                       ret_rs->count = rs.count;
-                       memcpy(&ret_rs->rates, &rs.rates, rs.count);
-                       break;
-               }
-
-       case WLC_SET_RATESET:{
-                       wlc_rateset_t rs;
-                       wl_rateset_t *in_rs = (wl_rateset_t *) arg;
-
-                       if (len < (int)(in_rs->count + sizeof(in_rs->count))) {
-                               bcmerror = -EOVERFLOW;
-                               break;
-                       }
-
-                       if (in_rs->count > WLC_NUMRATES) {
-                               bcmerror = -ENOBUFS;
-                               break;
-                       }
-
-                       memset(&rs, 0, sizeof(wlc_rateset_t));
-
-                       /* Copy only legacy rateset section */
-                       rs.count = in_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)
-                                       memcpy(rs.mcs,
-                                              &current_bss->rateset.mcs[0],
-                                              MCSSET_LEN);
-                               else
-                                       memcpy(rs.mcs,
-                                              &wlc->default_bss->rateset.mcs[0],
-                                              MCSSET_LEN);
-                       }
-
-                       bcmerror = wlc_set_rateset(wlc, &rs);
-
-                       if (!bcmerror)
-                               wlc_ofdm_rateset_war(wlc);
-
-                       break;
-               }
-
-       case WLC_GET_BCNPRD:
-               if (BSSCFG_STA(bsscfg) && bsscfg->BSS && bsscfg->associated)
-                       *pval = current_bss->beacon_period;
-               else
-                       *pval = wlc->default_bss->beacon_period;
-               break;
-
-       case WLC_SET_BCNPRD:
-               /* range [1, 0xffff] */
-               if (val >= DOT11_MIN_BEACON_PERIOD
-                   && val <= DOT11_MAX_BEACON_PERIOD) {
-                       wlc->default_bss->beacon_period = (u16) val;
-               } else
-                       bcmerror = -EINVAL;
-               break;
-
-       case WLC_GET_DTIMPRD:
-               if (BSSCFG_STA(bsscfg) && bsscfg->BSS && bsscfg->associated)
-                       *pval = current_bss->dtim_period;
-               else
-                       *pval = wlc->default_bss->dtim_period;
-               break;
-
-       case WLC_SET_DTIMPRD:
-               /* range [1, 0xff] */
-               if (val >= DOT11_MIN_DTIM_PERIOD
-                   && val <= DOT11_MAX_DTIM_PERIOD) {
-                       wlc->default_bss->dtim_period = (u8) val;
-               } else
-                       bcmerror = -EINVAL;
-               break;
-
-#ifdef SUPPORT_PS
-       case WLC_GET_PM:
-               *pval = wlc->PM;
-               break;
-
-       case WLC_SET_PM:
-               if ((val >= PM_OFF) && (val <= PM_MAX)) {
-                       wlc->PM = (u8) val;
-                       if (wlc->pub->up) {
-                       }
-                       /* Change watchdog driver to align watchdog with tbtt if possible */
-                       wlc_watchdog_upd(wlc, PS_ALLOWED(wlc));
-               } else
-                       bcmerror = -EBADE;
-               break;
-#endif                         /* SUPPORT_PS */
-
-#ifdef SUPPORT_PS
-#ifdef BCMDBG
-       case WLC_GET_WAKE:
-               if (AP_ENAB(wlc->pub)) {
-                       bcmerror = -BCME_NOTSTA;
-                       break;
-               }
-               *pval = wlc->wake;
-               break;
-
-       case WLC_SET_WAKE:
-               if (AP_ENAB(wlc->pub)) {
-                       bcmerror = -BCME_NOTSTA;
-                       break;
-               }
-
-               wlc->wake = val ? true : false;
-
-               /* if down, we're done */
-               if (!wlc->pub->up)
-                       break;
-
-               /* apply to the mac */
-               wlc_set_ps_ctrl(wlc);
-               break;
-#endif                         /* BCMDBG */
-#endif                         /* SUPPORT_PS */
-
-       case WLC_GET_REVINFO:
-               bcmerror = wlc_get_revision_info(wlc, arg, (uint) len);
-               break;
-
-       case WLC_GET_AP:
-               *pval = (int)AP_ENAB(wlc->pub);
-               break;
-
-       case WLC_GET_ATIM:
-               if (bsscfg->associated)
-                       *pval = (int)current_bss->atim_window;
-               else
-                       *pval = (int)wlc->default_bss->atim_window;
-               break;
-
-       case WLC_SET_ATIM:
-               wlc->default_bss->atim_window = (u32) val;
-               break;
-
-#ifdef SUPPORT_HWKEY
-       case WLC_GET_WSEC:
-               bcmerror =
-                   wlc_iovar_op(wlc, "wsec", NULL, 0, arg, len, IOV_GET,
-                                wlcif);
-               break;
-
-       case WLC_SET_WSEC:
-               bcmerror =
-                   wlc_iovar_op(wlc, "wsec", NULL, 0, arg, len, IOV_SET,
-                                wlcif);
-               break;
-
-       case WLC_GET_WPA_AUTH:
-               *pval = (int)bsscfg->WPA_auth;
-               break;
-
-       case WLC_SET_WPA_AUTH:
-               /* change of WPA_Auth modifies the PS_ALLOWED state */
-               if (BSSCFG_STA(bsscfg)) {
-                       bsscfg->WPA_auth = (u16) val;
-               } else
-                       bsscfg->WPA_auth = (u16) val;
-               break;
-#endif                         /* SUPPORT_HWKEY */
-
-       case WLC_GET_BANDLIST:
-               /* count of number of bands, followed by each band type */
-               *pval++ = NBANDS(wlc);
-               *pval++ = wlc->band->bandtype;
-               if (NBANDS(wlc) > 1)
-                       *pval++ = wlc->bandstate[OTHERBANDUNIT(wlc)]->bandtype;
-               break;
-
-       case WLC_GET_BAND:
-               *pval = wlc->bandlocked ? wlc->band->bandtype : WLC_BAND_AUTO;
-               break;
-
-       case WLC_GET_PHYLIST:
-               {
-                       unsigned char *cp = arg;
-                       if (len < 3) {
-                               bcmerror = -EOVERFLOW;
-                               break;
-                       }
-
-                       if (WLCISNPHY(wlc->band)) {
-                               *cp++ = 'n';
-                       } else if (WLCISLCNPHY(wlc->band)) {
-                               *cp++ = 'c';
-                       } else if (WLCISSSLPNPHY(wlc->band)) {
-                               *cp++ = 's';
-                       }
-                       *cp = '\0';
-                       break;
-               }
-
-       case WLC_GET_SHORTSLOT:
-               *pval = wlc->shortslot;
-               break;
-
-       case WLC_GET_SHORTSLOT_OVERRIDE:
-               *pval = wlc->shortslot_override;
-               break;
-
-       case WLC_SET_SHORTSLOT_OVERRIDE:
-               if ((val != WLC_SHORTSLOT_AUTO) &&
-                   (val != WLC_SHORTSLOT_OFF) && (val != WLC_SHORTSLOT_ON)) {
+       case WLC_SET_SHORTSLOT_OVERRIDE:
+               if ((val != WLC_SHORTSLOT_AUTO) &&
+                   (val != WLC_SHORTSLOT_OFF) && (val != WLC_SHORTSLOT_ON)) {
                        bcmerror = -EINVAL;
                        break;
                }
 
                wlc->shortslot_override = (s8) val;
 
-               /* shortslot is an 11g feature, so no more work if we are
-                * currently on the 5G band
-                */
-               if (BAND_5G(wlc->band->bandtype))
-                       break;
-
-               if (wlc->pub->up && wlc->pub->associated) {
-                       /* let watchdog or beacon processing update shortslot */
-               } else if (wlc->pub->up) {
-                       /* unassociated shortslot is off */
-                       wlc_switch_shortslot(wlc, false);
-               } else {
-                       /* driver is down, so just update the wlc_info value */
-                       if (wlc->shortslot_override == WLC_SHORTSLOT_AUTO) {
-                               wlc->shortslot = false;
-                       } else {
-                               wlc->shortslot =
-                                   (wlc->shortslot_override ==
-                                    WLC_SHORTSLOT_ON);
-                       }
-               }
-
-               break;
-
-       case WLC_GET_LEGACY_ERP:
-               *pval = wlc->include_legacy_erp;
-               break;
-
-       case WLC_SET_LEGACY_ERP:
-               if (wlc->include_legacy_erp == bool_val)
-                       break;
-
-               wlc->include_legacy_erp = bool_val;
-
-               if (AP_ENAB(wlc->pub) && wlc->clk) {
-                       wlc_update_beacon(wlc);
-                       wlc_update_probe_resp(wlc, true);
-               }
-               break;
-
-       case WLC_GET_GMODE:
-               if (wlc->band->bandtype == WLC_BAND_2G)
-                       *pval = wlc->band->gmode;
-               else if (NBANDS(wlc) > 1)
-                       *pval = wlc->bandstate[OTHERBANDUNIT(wlc)]->gmode;
-               break;
-
-       case WLC_SET_GMODE:
-               if (!wlc->pub->associated)
-                       bcmerror = wlc_set_gmode(wlc, (u8) val, true);
-               else {
-                       bcmerror = -EISCONN;
-                       break;
-               }
-               break;
-
-       case WLC_GET_GMODE_PROTECTION:
-               *pval = wlc->protection->_g;
-               break;
-
-       case WLC_GET_PROTECTION_CONTROL:
-               *pval = wlc->protection->overlap;
-               break;
-
-       case WLC_SET_PROTECTION_CONTROL:
-               if ((val != WLC_PROTECTION_CTL_OFF) &&
-                   (val != WLC_PROTECTION_CTL_LOCAL) &&
-                   (val != WLC_PROTECTION_CTL_OVERLAP)) {
-                       bcmerror = -EINVAL;
-                       break;
-               }
-
-               wlc_protection_upd(wlc, WLC_PROT_OVERLAP, (s8) val);
-
-               /* Current g_protection will sync up to the specified control alg in watchdog
-                * if the driver is up and associated.
-                * If the driver is down or not associated, the control setting has no effect.
-                */
-               break;
-
-       case WLC_GET_GMODE_PROTECTION_OVERRIDE:
-               *pval = wlc->protection->g_override;
-               break;
-
-       case WLC_SET_GMODE_PROTECTION_OVERRIDE:
-               if ((val != WLC_PROTECTION_AUTO) &&
-                   (val != WLC_PROTECTION_OFF) && (val != WLC_PROTECTION_ON)) {
-                       bcmerror = -EINVAL;
-                       break;
-               }
-
-               wlc_protection_upd(wlc, WLC_PROT_G_OVR, (s8) val);
-
-               break;
-
-       case WLC_SET_SUP_RATESET_OVERRIDE:{
-                       wlc_rateset_t rs, new;
-
-                       /* copyin */
-                       if (len < (int)sizeof(wlc_rateset_t)) {
-                               bcmerror = -EOVERFLOW;
-                               break;
-                       }
-                       memcpy(&rs, arg, sizeof(wlc_rateset_t));
-
-                       /* check for bad count value */
-                       if (rs.count > WLC_NUMRATES) {
-                               bcmerror = -EINVAL;
-                               break;
-                       }
-
-                       /* this command is only appropriate for gmode operation */
-                       if (!(wlc->band->gmode ||
-                             ((NBANDS(wlc) > 1)
-                              && wlc->bandstate[OTHERBANDUNIT(wlc)]->gmode))) {
-                               /* gmode only command when not in gmode */
-                               bcmerror = -EINVAL;
-                               break;
-                       }
-
-                       /* check for an empty rateset to clear the override */
-                       if (rs.count == 0) {
-                               memset(&wlc->sup_rates_override, 0,
-                                     sizeof(wlc_rateset_t));
-                               break;
-                       }
-
-                       /*
-                        * validate rateset by comparing pre and
-                        * post sorted against 11g hw rates
-                        */
-                       wlc_rateset_filter(&rs, &new, false,
-                                          WLC_RATES_CCK_OFDM, WLC_RATE_MASK,
-                                          BSS_N_ENAB(wlc, bsscfg));
-                       wlc_rate_hwrs_filter_sort_validate(&new,
-                                                          &cck_ofdm_rates,
-                                                          false,
-                                                          wlc->stf->txstreams);
-                       if (rs.count != new.count) {
-                               bcmerror = -EINVAL;
-                               break;
-                       }
-
-                       /* apply new rateset to the override */
-                       memcpy(&wlc->sup_rates_override, &new,
-                             sizeof(wlc_rateset_t));
-
-                       /* update bcn and probe resp if needed */
-                       if (wlc->pub->up && AP_ENAB(wlc->pub)
-                           && wlc->pub->associated) {
-                               wlc_update_beacon(wlc);
-                               wlc_update_probe_resp(wlc, true);
-                       }
-                       break;
-               }
-
-       case WLC_GET_SUP_RATESET_OVERRIDE:
-               /* this command is only appropriate for gmode operation */
-               if (!(wlc->band->gmode ||
-                     ((NBANDS(wlc) > 1)
-                      && wlc->bandstate[OTHERBANDUNIT(wlc)]->gmode))) {
-                       /* gmode only command when not in gmode */
-                       bcmerror = -EINVAL;
-                       break;
-               }
-               if (len < (int)sizeof(wlc_rateset_t)) {
-                       bcmerror = -EOVERFLOW;
-                       break;
-               }
-               memcpy(arg, &wlc->sup_rates_override, sizeof(wlc_rateset_t));
-
-               break;
-
-       case WLC_GET_PRB_RESP_TIMEOUT:
-               *pval = wlc->prb_resp_timeout;
-               break;
-
-       case WLC_SET_PRB_RESP_TIMEOUT:
-               if (wlc->pub->up) {
-                       bcmerror = -EISCONN;
-                       break;
-               }
-               if (val < 0 || val >= 0xFFFF) {
-                       bcmerror = -EINVAL;     /* bad value */
-                       break;
-               }
-               wlc->prb_resp_timeout = (u16) val;
-               break;
-
-       case WLC_GET_KEY_PRIMARY:{
-                       wsec_key_t *key;
-
-                       /* treat the 'val' parm as the key id */
-                       key = WSEC_BSS_DEFAULT_KEY(bsscfg);
-                       if (key != NULL) {
-                               *pval = key->id == val ? true : false;
-                       } else {
-                               bcmerror = -EINVAL;
-                       }
-                       break;
-               }
-
-       case WLC_SET_KEY_PRIMARY:{
-                       wsec_key_t *key, *old_key;
-
-                       bcmerror = -EINVAL;
-
-                       /* treat the 'val' parm as the key id */
-                       for (i = 0; i < WSEC_MAX_DEFAULT_KEYS; i++) {
-                               key = bsscfg->bss_def_keys[i];
-                               if (key != NULL && key->id == val) {
-                                       old_key = WSEC_BSS_DEFAULT_KEY(bsscfg);
-                                       if (old_key != NULL)
-                                               old_key->flags &=
-                                                   ~WSEC_PRIMARY_KEY;
-                                       key->flags |= WSEC_PRIMARY_KEY;
-                                       bsscfg->wsec_index = i;
-                                       bcmerror = 0;
-                               }
-                       }
-                       break;
-               }
-
-#ifdef BCMDBG
-       case WLC_INIT:
-               wl_init(wlc->wl);
-               break;
-#endif
-
-       case WLC_SET_VAR:
-       case WLC_GET_VAR:{
-                       char *name;
-                       /* validate the name value */
-                       name = (char *)arg;
-                       for (i = 0; i < (uint) len && *name != '\0';
-                            i++, name++)
-                               ;
-
-                       if (i == (uint) len) {
-                               bcmerror = -EOVERFLOW;
-                               break;
-                       }
-                       i++;    /* include the null in the string length */
-
-                       if (cmd == WLC_GET_VAR) {
-                               bcmerror =
-                                   wlc_iovar_op(wlc, arg,
-                                                (void *)((s8 *) arg + i),
-                                                len - i, arg, len, IOV_GET,
-                                                wlcif);
-                       } else
-                               bcmerror =
-                                   wlc_iovar_op(wlc, arg, NULL, 0,
-                                                (void *)((s8 *) arg + i),
-                                                len - i, IOV_SET, wlcif);
-
+               /* shortslot is an 11g feature, so no more work if we are
+                * currently on the 5G band
+                */
+               if (BAND_5G(wlc->band->bandtype))
                        break;
-               }
 
-       case WLC_SET_WSEC_PMK:
-               bcmerror = -ENOTSUPP;
-               break;
+               if (wlc->pub->up && wlc->pub->associated) {
+                       /* let watchdog or beacon processing update shortslot */
+               } else if (wlc->pub->up) {
+                       /* unassociated shortslot is off */
+                       wlc_switch_shortslot(wlc, false);
+               } else {
+                       /* driver is down, so just update the wlc_info value */
+                       if (wlc->shortslot_override == WLC_SHORTSLOT_AUTO) {
+                               wlc->shortslot = false;
+                       } else {
+                               wlc->shortslot =
+                                   (wlc->shortslot_override ==
+                                    WLC_SHORTSLOT_ON);
+                       }
+               }
 
-#if defined(BCMDBG)
-       case WLC_CURRENT_PWR:
-               if (!wlc->pub->up)
-                       bcmerror = -ENOLINK;
-               else
-                       bcmerror = wlc_get_current_txpwr(wlc, arg, len);
                break;
-#endif
 
-       case WLC_LAST:
-               wiphy_err(wlc->wiphy, "%s: WLC_LAST\n", __func__);
        }
  done:
 
@@ -3894,70 +2746,11 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
        return bcmerror;
 }
 
-#if defined(BCMDBG)
-/* consolidated register access ioctl error checking */
-int wlc_iocregchk(struct wlc_info *wlc, uint band)
-{
-       /* if band is specified, it must be the current band */
-       if ((band != WLC_BAND_AUTO) && (band != (uint) wlc->band->bandtype))
-               return -EINVAL;
-
-       /* if multiband and band is not specified, band must be locked */
-       if ((band == WLC_BAND_AUTO) && IS_MBAND_UNLOCKED(wlc))
-               return -ENOMEDIUM;
-
-       /* must have core clocks */
-       if (!wlc->clk)
-               return -EIO;
-
-       return 0;
-}
-#endif                         /* defined(BCMDBG) */
-
-/* Look up the given var name in the given table */
-static const bcm_iovar_t *wlc_iovar_lookup(const bcm_iovar_t *table,
-                                          const char *name)
-{
-       const bcm_iovar_t *vi;
-       const char *lookup_name;
-
-       /* skip any ':' delimited option prefixes */
-       lookup_name = strrchr(name, ':');
-       if (lookup_name != NULL)
-               lookup_name++;
-       else
-               lookup_name = name;
-
-       for (vi = table; vi->name; vi++) {
-               if (!strcmp(vi->name, lookup_name))
-                       return vi;
-       }
-       /* ran to end of table */
-
-       return NULL;            /* var name not found */
-}
-
-/* simplified integer get interface for common WLC_GET_VAR ioctl handler */
-int wlc_iovar_getint(struct wlc_info *wlc, const char *name, int *arg)
-{
-       return wlc_iovar_op(wlc, name, NULL, 0, arg, sizeof(s32), IOV_GET,
-                           NULL);
-}
-
-/* simplified integer set interface for common WLC_SET_VAR ioctl handler */
-int wlc_iovar_setint(struct wlc_info *wlc, const char *name, int arg)
-{
-       return wlc_iovar_op(wlc, name, NULL, 0, (void *)&arg, sizeof(arg),
-                           IOV_SET, NULL);
-}
-
 /*
- * register iovar table, watchdog and down handlers.
- * calling function must keep 'iovars' until wlc_module_unregister is called.
- * 'iovar' must have the last entry's name field being NULL as terminator.
+ * register watchdog and down handlers.
  */
-int wlc_module_register(struct wlc_pub *pub, const bcm_iovar_t *iovars,
-                       const char *name, void *hdl, iovar_fn_t i_fn,
+int wlc_module_register(struct wlc_pub *pub,
+                       const char *name, void *hdl,
                        watchdog_fn_t w_fn, down_fn_t d_fn)
 {
        struct wlc_info *wlc = (struct wlc_info *) pub->wlc;
@@ -3968,9 +2761,7 @@ int wlc_module_register(struct wlc_pub *pub, const bcm_iovar_t *iovars,
                if (wlc->modulecb[i].name[0] == '\0') {
                        strncpy(wlc->modulecb[i].name, name,
                                sizeof(wlc->modulecb[i].name) - 1);
-                       wlc->modulecb[i].iovars = iovars;
                        wlc->modulecb[i].hdl = hdl;
-                       wlc->modulecb[i].iovar_fn = i_fn;
                        wlc->modulecb[i].watchdog_fn = w_fn;
                        wlc->modulecb[i].down_fn = d_fn;
                        return 0;
@@ -4015,295 +2806,6 @@ static void wlc_wme_retries_write(struct wlc_info *wlc)
        }
 }
 
-/* Get or set an iovar.  The params/p_len pair specifies any additional
- * qualifying parameters (e.g. an "element index") for a get, while the
- * arg/len pair is the buffer for the value to be set or retrieved.
- * Operation (get/set) is specified by the last argument.
- * interface context provided by wlcif
- *
- * All pointers may point into the same buffer.
- */
-int
-wlc_iovar_op(struct wlc_info *wlc, const char *name,
-            void *params, int p_len, void *arg, int len,
-            bool set, struct wlc_if *wlcif)
-{
-       int err = 0;
-       int val_size;
-       const bcm_iovar_t *vi = NULL;
-       u32 actionid;
-       int i;
-
-       if (!set && (len == sizeof(int)) &&
-           !(IS_ALIGNED((unsigned long)(arg), (uint) sizeof(int)))) {
-               wiphy_err(wlc->wiphy, "wl%d: %s unaligned get ptr for %s\n",
-                         wlc->pub->unit, __func__, name);
-               return -ENOTSUPP;
-       }
-
-       /* find the given iovar name */
-       for (i = 0; i < WLC_MAXMODULES; i++) {
-               if (!wlc->modulecb[i].iovars)
-                       continue;
-               vi = wlc_iovar_lookup(wlc->modulecb[i].iovars, name);
-               if (vi)
-                       break;
-       }
-       /* iovar name not found */
-       if (i >= WLC_MAXMODULES) {
-               return -ENOTSUPP;
-       }
-
-       /* set up 'params' pointer in case this is a set command so that
-        * the convenience int and bool code can be common to set and get
-        */
-       if (params == NULL) {
-               params = arg;
-               p_len = len;
-       }
-
-       if (vi->type == IOVT_VOID)
-               val_size = 0;
-       else if (vi->type == IOVT_BUFFER)
-               val_size = len;
-       else
-               /* all other types are integer sized */
-               val_size = sizeof(int);
-
-       actionid = set ? IOV_SVAL(vi->varid) : IOV_GVAL(vi->varid);
-
-       /* Do the actual parameter implementation */
-       err = wlc->modulecb[i].iovar_fn(wlc->modulecb[i].hdl, vi, actionid,
-                                       name, params, p_len, arg, len, val_size,
-                                       wlcif);
-       return err;
-}
-
-int
-wlc_iovar_check(struct wlc_pub *pub, const bcm_iovar_t *vi, void *arg, int len,
-               bool set)
-{
-       struct wlc_info *wlc = (struct wlc_info *) pub->wlc;
-       int err = 0;
-       s32 int_val = 0;
-
-       /* check generic condition flags */
-       if (set) {
-               if (((vi->flags & IOVF_SET_DOWN) && wlc->pub->up) ||
-                   ((vi->flags & IOVF_SET_UP) && !wlc->pub->up)) {
-                       err = (wlc->pub->up ? -EISCONN : -ENOLINK);
-               } else if ((vi->flags & IOVF_SET_BAND)
-                          && IS_MBAND_UNLOCKED(wlc)) {
-                       err = -ENOMEDIUM;
-               } else if ((vi->flags & IOVF_SET_CLK) && !wlc->clk) {
-                       err = -EIO;
-               }
-       } else {
-               if (((vi->flags & IOVF_GET_DOWN) && wlc->pub->up) ||
-                   ((vi->flags & IOVF_GET_UP) && !wlc->pub->up)) {
-                       err = (wlc->pub->up ? -EISCONN : -ENOLINK);
-               } else if ((vi->flags & IOVF_GET_BAND)
-                          && IS_MBAND_UNLOCKED(wlc)) {
-                       err = -ENOMEDIUM;
-               } else if ((vi->flags & IOVF_GET_CLK) && !wlc->clk) {
-                       err = -EIO;
-               }
-       }
-
-       if (err)
-               goto exit;
-
-       /* length check on io buf */
-       err = bcm_iovar_lencheck(vi, arg, len, set);
-       if (err)
-               goto exit;
-
-       /* On set, check value ranges for integer types */
-       if (set) {
-               switch (vi->type) {
-               case IOVT_BOOL:
-               case IOVT_INT8:
-               case IOVT_INT16:
-               case IOVT_INT32:
-               case IOVT_UINT8:
-               case IOVT_UINT16:
-               case IOVT_UINT32:
-                       memcpy(&int_val, arg, sizeof(int));
-                       err = wlc_iovar_rangecheck(wlc, int_val, vi);
-                       break;
-               }
-       }
- exit:
-       return err;
-}
-
-/* handler for iovar table wlc_iovars */
-/*
- * IMPLEMENTATION NOTE: In order to avoid checking for get/set in each
- * iovar case, the switch statement maps the iovar id into separate get
- * and set values.  If you add a new iovar to the switch you MUST use
- * IOV_GVAL and/or IOV_SVAL in the case labels to avoid conflict with
- * another case.
- * Please use params for additional qualifying parameters.
- */
-int
-wlc_doiovar(void *hdl, const bcm_iovar_t *vi, u32 actionid,
-           const char *name, void *params, uint p_len, void *arg, int len,
-           int val_size, struct wlc_if *wlcif)
-{
-       struct wlc_info *wlc = hdl;
-       struct wlc_bsscfg *bsscfg;
-       int err = 0;
-       s32 int_val = 0;
-       s32 int_val2 = 0;
-       s32 *ret_int_ptr;
-       bool bool_val;
-       bool bool_val2;
-       wlc_bss_info_t *current_bss;
-
-       BCMMSG(wlc->wiphy, "wl%d\n", wlc->pub->unit);
-
-       bsscfg = NULL;
-       current_bss = NULL;
-
-       err = wlc_iovar_check(wlc->pub, vi, arg, len, IOV_ISSET(actionid));
-       if (err != 0)
-               return err;
-
-       /* convenience int and bool vals for first 8 bytes of buffer */
-       if (p_len >= (int)sizeof(int_val))
-               memcpy(&int_val, params, sizeof(int_val));
-
-       if (p_len >= (int)sizeof(int_val) * 2)
-               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;
-
-       bool_val = (int_val != 0) ? true : false;
-       bool_val2 = (int_val2 != 0) ? true : false;
-
-       BCMMSG(wlc->wiphy, "wl%d: id %d\n", wlc->pub->unit, 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;
-                       bool override;
-
-                       err = wlc_phy_txpower_get(wlc->band->pi, &qdbm,
-                               &override);
-                       if (err != 0)
-                               return err;
-
-                       /* Return qdbm units */
-                       *ret_int_ptr =
-                           qdbm | (override ? WL_TXPWR_OVERRIDE : 0);
-                       break;
-               }
-
-               /* As long as override is false, this only sets the *user* targets.
-                  User can twiddle this all he wants with no harm.
-                  wlc_phy_txpower_set() explicitly sets override to false if
-                  not internal or test.
-                */
-       case IOV_SVAL(IOV_QTXPOWER):{
-                       u8 qdbm;
-                       bool override;
-
-                       /* Remove override bit and clip to max qdbm value */
-                       qdbm = (u8)min_t(u32, (int_val & ~WL_TXPWR_OVERRIDE), 0xff);
-                       /* Extract override setting */
-                       override = (int_val & WL_TXPWR_OVERRIDE) ? true : false;
-                       err =
-                           wlc_phy_txpower_set(wlc->band->pi, qdbm, override);
-                       break;
-               }
-
-       case IOV_GVAL(IOV_MPC):
-               *ret_int_ptr = (s32) wlc->mpc;
-               break;
-
-       case IOV_SVAL(IOV_MPC):
-               wlc->mpc = bool_val;
-               wlc_radio_mpc_upd(wlc);
-
-               break;
-
-       case IOV_GVAL(IOV_BCN_LI_BCN):
-               *ret_int_ptr = wlc->bcn_li_bcn;
-               break;
-
-       case IOV_SVAL(IOV_BCN_LI_BCN):
-               wlc->bcn_li_bcn = (u8) int_val;
-               if (wlc->pub->up)
-                       wlc_bcn_li_upd(wlc);
-               break;
-
-       default:
-               wiphy_err(wlc->wiphy, "wl%d: %s: unsupported\n",
-                         wlc->pub->unit, __func__);
-               err = -ENOTSUPP;
-               break;
-       }
-
-       goto exit;              /* avoid unused label warning */
-
- exit:
-       return err;
-}
-
-static int
-wlc_iovar_rangecheck(struct wlc_info *wlc, u32 val, const bcm_iovar_t *vi)
-{
-       int err = 0;
-       u32 min_val = 0;
-       u32 max_val = 0;
-
-       /* Only ranged integers are checked */
-       switch (vi->type) {
-       case IOVT_INT32:
-               max_val |= 0x7fffffff;
-               /* fall through */
-       case IOVT_INT16:
-               max_val |= 0x00007fff;
-               /* fall through */
-       case IOVT_INT8:
-               max_val |= 0x0000007f;
-               min_val = ~max_val;
-               if (vi->flags & IOVF_NTRL)
-                       min_val = 1;
-               else if (vi->flags & IOVF_WHL)
-                       min_val = 0;
-               /* Signed values are checked against max_val and min_val */
-               if ((s32) val < (s32) min_val
-                   || (s32) val > (s32) max_val)
-                       err = -EINVAL;
-               break;
-
-       case IOVT_UINT32:
-               max_val |= 0xffffffff;
-               /* fall through */
-       case IOVT_UINT16:
-               max_val |= 0x0000ffff;
-               /* fall through */
-       case IOVT_UINT8:
-               max_val |= 0x000000ff;
-               if (vi->flags & IOVF_NTRL)
-                       min_val = 1;
-               if ((val < min_val) || (val > max_val))
-                       err = -EINVAL;
-               break;
-       }
-
-       return err;
-}
-
 #ifdef BCMDBG
 static const char *supr_reason[] = {
        "None", "PMQ Entry", "Flush request",
@@ -4416,9 +2918,10 @@ bool wlc_chipmatch(u16 vendor, u16 device)
                return false;
        }
 
+       if (device == BCM43224_D11N_ID_VEN1)
+               return true;
        if ((device == BCM43224_D11N_ID) || (device == BCM43225_D11N2G_ID))
                return true;
-
        if (device == BCM4313_D11N2G_ID)
                return true;
        if ((device == BCM43236_D11N_ID) || (device == BCM43236_D11N2G_ID))
@@ -4481,16 +2984,16 @@ void wlc_print_txdesc(d11txh_t *txh)
        printk(KERN_DEBUG "XtraFrameTypes: %04x ", xtraft);
        printk(KERN_DEBUG "\n");
 
-       bcm_format_hex(hexbuf, iv, sizeof(txh->IV));
+       brcmu_format_hex(hexbuf, iv, sizeof(txh->IV));
        printk(KERN_DEBUG "SecIV:       %s\n", hexbuf);
-       bcm_format_hex(hexbuf, ra, sizeof(txh->TxFrameRA));
+       brcmu_format_hex(hexbuf, ra, sizeof(txh->TxFrameRA));
        printk(KERN_DEBUG "RA:          %s\n", hexbuf);
 
        printk(KERN_DEBUG "Fb FES Time: %04x ", tfestfb);
-       bcm_format_hex(hexbuf, rtspfb, sizeof(txh->RTSPLCPFallback));
+       brcmu_format_hex(hexbuf, rtspfb, sizeof(txh->RTSPLCPFallback));
        printk(KERN_DEBUG "RTS PLCP: %s ", hexbuf);
        printk(KERN_DEBUG "RTS DUR: %04x ", rtsdfb);
-       bcm_format_hex(hexbuf, fragpfb, sizeof(txh->FragPLCPFallback));
+       brcmu_format_hex(hexbuf, fragpfb, sizeof(txh->FragPLCPFallback));
        printk(KERN_DEBUG "PLCP: %s ", hexbuf);
        printk(KERN_DEBUG "DUR: %04x", fragdfb);
        printk(KERN_DEBUG "\n");
@@ -4506,9 +3009,9 @@ void wlc_print_txdesc(d11txh_t *txh)
        printk(KERN_DEBUG "MaxAggbyte_fb:  %04x\n", mabyte_f);
        printk(KERN_DEBUG "MinByte:     %04x\n", mmbyte);
 
-       bcm_format_hex(hexbuf, rtsph, sizeof(txh->RTSPhyHeader));
+       brcmu_format_hex(hexbuf, rtsph, sizeof(txh->RTSPhyHeader));
        printk(KERN_DEBUG "RTS PLCP: %s ", hexbuf);
-       bcm_format_hex(hexbuf, (u8 *) &rts, sizeof(txh->rts_frame));
+       brcmu_format_hex(hexbuf, (u8 *) &rts, sizeof(txh->rts_frame));
        printk(KERN_DEBUG "RTS Frame: %s", hexbuf);
        printk(KERN_DEBUG "\n");
 }
@@ -4526,7 +3029,7 @@ void wlc_print_rxh(d11rxhdr_t *rxh)
        u16 macstatus2 = rxh->RxStatus2;
        char flagstr[64];
        char lenbuf[20];
-       static const bcm_bit_desc_t macstat_flags[] = {
+       static const struct brcmu_bit_desc macstat_flags[] = {
                {RXS_FCSERR, "FCSErr"},
                {RXS_RESPFRAMETX, "Reply"},
                {RXS_PBPRES, "PADDING"},
@@ -4539,7 +3042,7 @@ void wlc_print_rxh(d11rxhdr_t *rxh)
        printk(KERN_DEBUG "Raw RxDesc:\n");
        print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, rxh, sizeof(d11rxhdr_t));
 
-       bcm_format_flags(macstat_flags, macstatus1, flagstr, 64);
+       brcmu_format_flags(macstat_flags, macstatus1, flagstr, 64);
 
        snprintf(lenbuf, sizeof(lenbuf), "0x%x", len);
 
@@ -4554,32 +3057,6 @@ void wlc_print_rxh(d11rxhdr_t *rxh)
 }
 #endif                         /* defined(BCMDBG) */
 
-#if defined(BCMDBG)
-int wlc_format_ssid(char *buf, const unsigned char ssid[], uint ssid_len)
-{
-       uint i, c;
-       char *p = buf;
-       char *endp = buf + SSID_FMT_BUF_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];
-               if (c == '\\') {
-                       *p++ = '\\';
-                       *p++ = '\\';
-               } else if (isprint((unsigned char) c)) {
-                       *p++ = (char)c;
-               } else {
-                       p += snprintf(p, (endp - p), "\\x%02X", c);
-               }
-       }
-       *p = '\0';
-       return (int)(p - buf);
-}
-#endif                         /* defined(BCMDBG) */
-
 static u16 wlc_rate_shm_offset(struct wlc_info *wlc, u8 rate)
 {
        return wlc_bmac_rate_shm_offset(wlc->hw, rate);
@@ -4613,7 +3090,7 @@ wlc_prec_enq_head(struct wlc_info *wlc, struct pktq *q, struct sk_buff *pkt,
        if (pktq_pfull(q, prec))
                eprec = prec;
        else if (pktq_full(q)) {
-               p = bcm_pktq_peek_tail(q, &eprec);
+               p = brcmu_pktq_peek_tail(q, &eprec);
                if (eprec > prec) {
                        wiphy_err(wlc->wiphy, "%s: Failing: eprec %d > prec %d"
                                  "\n", __func__, eprec, prec);
@@ -4635,16 +3112,16 @@ wlc_prec_enq_head(struct wlc_info *wlc, struct pktq *q, struct sk_buff *pkt,
                }
 
                /* Evict packet according to discard policy */
-               p = discard_oldest ? bcm_pktq_pdeq(q, eprec) :
-                       bcm_pktq_pdeq_tail(q, eprec);
-               bcm_pkt_buf_free_skb(p);
+               p = discard_oldest ? brcmu_pktq_pdeq(q, eprec) :
+                       brcmu_pktq_pdeq_tail(q, eprec);
+               brcmu_pkt_buf_free_skb(p);
        }
 
        /* Enqueue */
        if (head)
-               p = bcm_pktq_penq_head(q, prec, pkt);
+               p = brcmu_pktq_penq_head(q, prec, pkt);
        else
-               p = bcm_pktq_penq(q, prec, pkt);
+               p = brcmu_pktq_penq(q, prec, pkt);
 
        return true;
 }
@@ -4669,7 +3146,7 @@ void wlc_txq_enq(void *ctx, struct scb *scb, struct sk_buff *sdu,
                 * XXX we might hit this condtion in case
                 * packet flooding from mac80211 stack
                 */
-               bcm_pkt_buf_free_skb(sdu);
+               brcmu_pkt_buf_free_skb(sdu);
        }
 
        /* Check if flow control needs to be turned on after enqueuing the packet
@@ -4733,7 +3210,7 @@ void wlc_send_q(struct wlc_info *wlc)
        /* Send all the enq'd pkts that we can.
         * Dequeue packets with precedence with empty HW fifo only
         */
-       while (prec_map && (pkt[0] = bcm_pktq_mdeq(q, prec_map, &prec))) {
+       while (prec_map && (pkt[0] = brcmu_pktq_mdeq(q, prec_map, &prec))) {
                tx_info = IEEE80211_SKB_CB(pkt[0]);
                if (tx_info->flags & IEEE80211_TX_CTL_AMPDU) {
                        err = wlc_sendampdu(wlc->ampdu, qi, pkt, prec);
@@ -4748,7 +3225,7 @@ void wlc_send_q(struct wlc_info *wlc)
                }
 
                if (err == -EBUSY) {
-                       bcm_pktq_penq_head(q, prec, pkt[0]);
+                       brcmu_pktq_penq_head(q, prec, pkt[0]);
                        /* If send failed due to any other reason than a change in
                         * HW FIFO condition, quit. Otherwise, read the new prec_map!
                         */
@@ -5171,7 +3648,7 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
        qos = ieee80211_is_data_qos(h->frame_control);
 
        /* compute length of frame in bytes for use in PLCP computations */
-       len = bcm_pkttotlen(p);
+       len = brcmu_pkttotlen(p);
        phylen = len + FCS_LEN;
 
        /* If WEP enabled, add room in phylen for the additional bytes of
@@ -5763,29 +4240,6 @@ void wlc_tbtt(struct wlc_info *wlc, d11regs_t *regs)
 {
        struct wlc_bsscfg *cfg = wlc->cfg;
 
-       if (BSSCFG_STA(cfg)) {
-               /* run watchdog here if the watchdog timer is not armed */
-               if (WLC_WATCHDOG_TBTT(wlc)) {
-                       u32 cur, delta;
-                       if (wlc->WDarmed) {
-                               wl_del_timer(wlc->wl, wlc->wdtimer);
-                               wlc->WDarmed = false;
-                       }
-
-                       cur = OSL_SYSUPTIME();
-                       delta = cur > wlc->WDlast ? cur - wlc->WDlast :
-                           (u32) ~0 - wlc->WDlast + cur + 1;
-                       if (delta >= TIMER_INTERVAL_WATCHDOG) {
-                               wlc_watchdog((void *)wlc);
-                               wlc->WDlast = cur;
-                       }
-
-                       wl_add_timer(wlc->wl, wlc->wdtimer,
-                                    wlc_watchdog_backup_bi(wlc), true);
-                       wlc->WDarmed = true;
-               }
-       }
-
        if (!cfg->BSS) {
                /* DirFrmQ is now valid...defer setting until end of ATIM window */
                wlc->qvalid |= MCMD_DIRFRMQVAL;
@@ -5926,7 +4380,7 @@ wlc_dotxstatus(struct wlc_info *wlc, tx_status_t *txs, u32 frm_tx2)
                        tx_info->flags |= IEEE80211_TX_STAT_ACK;
        }
 
-       totlen = bcm_pkttotlen(p);
+       totlen = brcmu_pkttotlen(p);
        free_pdu = true;
 
        wlc_txfifo_complete(wlc, queue, 1);
@@ -5934,7 +4388,6 @@ wlc_dotxstatus(struct wlc_info *wlc, tx_status_t *txs, u32 frm_tx2)
        if (lastframe) {
                p->next = NULL;
                p->prev = NULL;
-               wlc->txretried = 0;
                /* remove PLCP & Broadcom tx descriptor header */
                skb_pull(p, D11_PHY_HDR_LEN);
                skb_pull(p, D11_TXH_LEN);
@@ -5948,7 +4401,7 @@ wlc_dotxstatus(struct wlc_info *wlc, tx_status_t *txs, u32 frm_tx2)
 
  fatal:
        if (p)
-               bcm_pkt_buf_free_skb(p);
+               brcmu_pkt_buf_free_skb(p);
 
        return true;
 
@@ -5964,15 +4417,9 @@ wlc_txfifo_complete(struct wlc_info *wlc, uint fifo, s8 txpktpend)
        /* There is more room; mark precedences related to this FIFO sendable */
        WLC_TX_FIFO_ENAB(wlc, fifo);
 
-       if (!TXPKTPENDTOT(wlc)) {
-               if (wlc->block_datafifo & DATA_BLOCK_TX_SUPR)
-                       wlc_bsscfg_tx_check(wlc);
-       }
-
        /* Clear MHF2_TXBCMC_NOW flag if BCMC fifo has drained */
        if (AP_ENAB(wlc->pub) &&
-           wlc->bcmcfifo_drain && !TXPKTPENDGET(wlc, TX_BCMC_FIFO)) {
-               wlc->bcmcfifo_drain = false;
+           !TXPKTPENDGET(wlc, TX_BCMC_FIFO)) {
                wlc_mhf(wlc, MHF2, MHF2_TXBCMC_NOW, 0, WLC_BAND_AUTO);
        }
 
@@ -6178,7 +4625,7 @@ void wlc_recv(struct wlc_info *wlc, struct sk_buff *p)
        rxh = (d11rxhdr_t *) (p->data);
 
        /* strip off rxhdr */
-       skb_pull(p, wlc->hwrxoff);
+       skb_pull(p, WL_HWRXOFF);
 
        /* fixup rx header endianness */
        rxh->RxFrameSize = le16_to_cpu(rxh->RxFrameSize);
@@ -6252,7 +4699,7 @@ void wlc_recv(struct wlc_info *wlc, struct sk_buff *p)
        return;
 
  toss:
-       bcm_pkt_buf_free_skb(p);
+       brcmu_pkt_buf_free_skb(p);
 }
 
 /* calculate frame duration for Mixed-mode L-SIG spoofing, return
@@ -6690,8 +5137,6 @@ static void wlc_update_mimo_band_bwcap(struct wlc_info *wlc, u8 bwcap)
                                band->mimo_cap_40 = false;
                }
        }
-
-       wlc->mimo_band_bwcap = bwcap;
 }
 
 void wlc_mod_prb_rsp_rate_table(struct wlc_info *wlc, uint frame_len)
@@ -6985,43 +5430,6 @@ void wlc_bsscfg_reprate_init(struct wlc_bsscfg *bsscfg)
        memset((char *)bsscfg->txrspec, 0, sizeof(bsscfg->txrspec));
 }
 
-/* Retrieve a consolidated set of revision information,
- * typically for the WLC_GET_REVINFO ioctl
- */
-int wlc_get_revision_info(struct wlc_info *wlc, void *buf, uint len)
-{
-       wlc_rev_info_t *rinfo = (wlc_rev_info_t *) buf;
-
-       if (len < WL_REV_INFO_LEGACY_LENGTH)
-               return -EOVERFLOW;
-
-       rinfo->vendorid = wlc->vendorid;
-       rinfo->deviceid = wlc->deviceid;
-       rinfo->radiorev = (wlc->band->radiorev << IDCODE_REV_SHIFT) |
-           (wlc->band->radioid << IDCODE_ID_SHIFT);
-       rinfo->chiprev = wlc->pub->sih->chiprev;
-       rinfo->corerev = wlc->pub->corerev;
-       rinfo->boardid = wlc->pub->sih->boardtype;
-       rinfo->boardvendor = wlc->pub->sih->boardvendor;
-       rinfo->boardrev = wlc->pub->boardrev;
-       rinfo->ucoderev = wlc->ucode_rev;
-       rinfo->driverrev = EPI_VERSION_NUM;
-       rinfo->bus = wlc->pub->sih->bustype;
-       rinfo->chipnum = wlc->pub->sih->chip;
-
-       if (len >= (offsetof(wlc_rev_info_t, chippkg))) {
-               rinfo->phytype = wlc->band->phytype;
-               rinfo->phyrev = wlc->band->phyrev;
-               rinfo->anarev = 0;      /* obsolete stuff, suppress */
-       }
-
-       if (len >= sizeof(*rinfo)) {
-               rinfo->chippkg = wlc->pub->sih->chippkg;
-       }
-
-       return 0;
-}
-
 void wlc_default_rateset(struct wlc_info *wlc, wlc_rateset_t *rs)
 {
        wlc_rateset_default(rs, NULL, wlc->band->phytype, wlc->band->bandtype,
@@ -7273,20 +5681,6 @@ wlc_set_addrmatch(struct wlc_info *wlc, int match_reg_offset,
                memcpy(wlc->cfg->BSSID, addr, ETH_ALEN);
 }
 
-void wlc_set_cwmin(struct wlc_info *wlc, u16 newmin)
-{
-       wlc->band->CWmin = newmin;
-       wlc_bmac_set_cwmin(wlc->hw, newmin);
-}
-
-void wlc_set_cwmax(struct wlc_info *wlc, u16 newmax)
-{
-       wlc->band->CWmax = newmax;
-       wlc_bmac_set_cwmax(wlc->hw, newmax);
-}
-
-/* Search mem rw utilities */
-
 void wlc_pllreq(struct wlc_info *wlc, bool set, mbool req_bit)
 {
        wlc_bmac_pllreq(wlc->hw, set, req_bit);
@@ -7415,12 +5809,15 @@ static void
 wlc_txflowcontrol_signal(struct wlc_info *wlc, struct wlc_txq_info *qi, bool on,
                         int prio)
 {
+#ifdef NON_FUNCTIONAL
+       /* wlcif_list is never filled so this function is not functional */
        struct wlc_if *wlcif;
 
        for (wlcif = wlc->wlcif_list; wlcif != NULL; wlcif = wlcif->next) {
                if (wlcif->qi == qi && wlcif->flags & WLC_IF_LINKED)
-                       wl_txflowcontrol(wlc->wl, wlcif->wlif, on, prio);
+                       brcms_txflowcontrol(wlc->wl, wlcif->wlif, on, prio);
        }
+#endif
 }
 
 static struct wlc_txq_info *wlc_txq_alloc(struct wlc_info *wlc)
@@ -7435,7 +5832,7 @@ static struct wlc_txq_info *wlc_txq_alloc(struct wlc_info *wlc)
                 * leave PS mode. The watermark for flowcontrol to OS packets
                 * will remain the same
                 */
-               bcm_pktq_init(&qi->q, WLC_PREC_COUNT,
+               brcmu_pktq_init(&qi->q, WLC_PREC_COUNT,
                          (2 * wlc->pub->tunables->datahiwat) + PKTQ_LEN_DEFAULT
                          + wlc->pub->psq_pkts_total);
 
@@ -7501,7 +5898,7 @@ void wlc_inval_dma_pkts(struct wlc_hw_info *hw,
                               struct ieee80211_sta *sta,
                               void (*dma_callback_fn))
 {
-       struct hnddma_pub *dmah;
+       struct dma_pub *dmah;
        int i;
        for (i = 0; i < NFIFO; i++) {
                dmah = hw->di[i];
@@ -7519,11 +5916,122 @@ void wlc_wait_for_tx_completion(struct wlc_info *wlc, bool drop)
 {
        /* flush packet queue when requested */
        if (drop)
-               bcm_pktq_flush(&wlc->pkt_queue->q, false, NULL, NULL);
+               brcmu_pktq_flush(&wlc->pkt_queue->q, false, NULL, NULL);
 
        /* wait for queue and DMA fifos to run dry */
        while (!pktq_empty(&wlc->pkt_queue->q) ||
               TXPKTPENDTOT(wlc) > 0) {
-               wl_msleep(wlc->wl, 1);
+               brcms_msleep(wlc->wl, 1);
+       }
+}
+
+int wlc_set_par(struct wlc_info *wlc, enum wlc_par_id par_id, int int_val)
+{
+       int err = 0;
+
+       switch (par_id) {
+       case IOV_BCN_LI_BCN:
+               wlc->bcn_li_bcn = (u8) int_val;
+               if (wlc->pub->up)
+                       wlc_bcn_li_upd(wlc);
+               break;
+               /* As long as override is false, this only sets the *user*
+                  targets. User can twiddle this all he wants with no harm.
+                  wlc_phy_txpower_set() explicitly sets override to false if
+                  not internal or test.
+                */
+       case IOV_QTXPOWER:{
+               u8 qdbm;
+               bool override;
+
+               /* Remove override bit and clip to max qdbm value */
+               qdbm = (u8)min_t(u32, (int_val & ~WL_TXPWR_OVERRIDE), 0xff);
+               /* Extract override setting */
+               override = (int_val & WL_TXPWR_OVERRIDE) ? true : false;
+               err =
+                   wlc_phy_txpower_set(wlc->band->pi, qdbm, override);
+               break;
+               }
+       case IOV_MPC:
+               wlc->mpc = (bool)int_val;
+               wlc_radio_mpc_upd(wlc);
+               break;
+       default:
+               err = -ENOTSUPP;
+       }
+       return err;
+}
+
+int wlc_get_par(struct wlc_info *wlc, enum wlc_par_id par_id, int *ret_int_ptr)
+{
+       int err = 0;
+
+       switch (par_id) {
+       case IOV_BCN_LI_BCN:
+               *ret_int_ptr = wlc->bcn_li_bcn;
+               break;
+       case IOV_QTXPOWER: {
+               uint qdbm;
+               bool override;
+
+               err = wlc_phy_txpower_get(wlc->band->pi, &qdbm,
+                       &override);
+               if (err != 0)
+                       return err;
+
+               /* Return qdbm units */
+               *ret_int_ptr =
+                   qdbm | (override ? WL_TXPWR_OVERRIDE : 0);
+               break;
+               }
+       case IOV_MPC:
+               *ret_int_ptr = (s32) wlc->mpc;
+               break;
+       default:
+               err = -ENOTSUPP;
+       }
+       return err;
+}
+
+/*
+ * Search the name=value vars for a specific one and return its value.
+ * Returns NULL if not found.
+ */
+char *getvar(char *vars, const char *name)
+{
+       char *s;
+       int len;
+
+       if (!name)
+               return NULL;
+
+       len = strlen(name);
+       if (len == 0)
+               return NULL;
+
+       /* first look in vars[] */
+       for (s = vars; s && *s;) {
+               if ((memcmp(s, name, len) == 0) && (s[len] == '='))
+                       return &s[len + 1];
+
+               while (*s++)
+                       ;
        }
+       /* nothing found */
+       return NULL;
+}
+
+/*
+ * Search the vars for a specific one and return its value as
+ * an integer. Returns 0 if not found.
+ */
+int getintvar(char *vars, const char *name)
+{
+       char *val;
+
+       val = getvar(vars, name);
+       if (val == NULL)
+               return 0;
+
+       return simple_strtoul(val, NULL, 0);
 }
This page took 0.06719 seconds and 5 git commands to generate.