2 * Copyright (c) 2010 Broadcom Corporation
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 #include <linux/etherdevice.h>
22 #include <brcmu_utils.h>
26 #define MA_WINDOW_SZ 8 /* moving average window size */
27 #define BRCMS_HWRXOFF 38 /* chip rx buffer offset */
28 #define INVCHANNEL 255 /* invalid channel */
29 /* max # supported core revisions (0 .. MAXCOREREV - 1) */
31 /* max # brcms_c_module_register() calls */
32 #define BRCMS_MAXMODULES 22
34 #define SEQNUM_SHIFT 4
35 #define AMPDU_DELIMITER_LEN 4
36 #define SEQNUM_MAX 0x1000
39 #define PHY_CWMAX 1023
41 #define EDCF_AIFSN_MIN 1
42 #define FRAGNUM_MASK 0xF
44 #define NTXRATE 64 /* # tx MPDUs rate is reported for */
46 #define BRCMS_BITSCNT(x) brcmu_bitcount((u8 *)&(x), sizeof(u8))
48 /* Maximum wait time for a MAC suspend */
49 /* uS: 83mS is max packet time (64KB ampdu @ 6Mbps) */
50 #define BRCMS_MAX_MAC_SUSPEND 83000
52 /* Probe Response timeout - responses for probe requests older that this are tossed, zero to disable
54 #define BRCMS_PRB_RESP_TIMEOUT 0 /* Disable probe response timeout */
56 /* transmit buffer max headroom for protocol headers */
57 #define TXOFF (D11_TXH_LEN + D11_PHY_HDR_LEN)
61 /* Macros for doing definition and get/set of bitfields
62 * Usage example, e.g. a three-bit field (bits 4-6):
63 * #define <NAME>_M BITFIELD_MASK(3)
66 * regval = R_REG(osh, ®s->regfoo);
67 * field = GFIELD(regval, <NAME>);
68 * regval = SFIELD(regval, <NAME>, 1);
69 * W_REG(osh, ®s->regfoo, regval);
71 #define BITFIELD_MASK(width) \
72 (((unsigned)1 << (width)) - 1)
73 #define GFIELD(val, field) \
74 (((val) >> field ## _S) & field ## _M)
75 #define SFIELD(val, field, bits) \
76 (((val) & (~(field ## _M << field ## _S))) | \
77 ((unsigned)(bits) << field ## _S))
79 #define SW_TIMER_MAC_STAT_UPD 30 /* periodic MAC stats update */
81 /* Double check that unsupported cores are not enabled */
82 #if CONF_MSK(D11CONF, 0x4f) || CONF_GE(D11CONF, MAXCOREREV)
83 #error "Configuration for D11CONF includes unsupported versions."
84 #endif /* Bad versions */
86 #define VALID_COREREV(corerev) CONF_HAS(D11CONF, corerev)
88 /* values for shortslot_override */
89 #define BRCMS_SHORTSLOT_AUTO -1 /* Driver will manage Shortslot setting */
90 #define BRCMS_SHORTSLOT_OFF 0 /* Turn off short slot */
91 #define BRCMS_SHORTSLOT_ON 1 /* Turn on short slot */
93 /* value for short/long and mixmode/greenfield preamble */
94 #define BRCMS_LONG_PREAMBLE (0)
95 #define BRCMS_SHORT_PREAMBLE (1 << 0)
96 #define BRCMS_GF_PREAMBLE (1 << 1)
97 #define BRCMS_MM_PREAMBLE (1 << 2)
98 #define BRCMS_IS_MIMO_PREAMBLE(_pre) (((_pre) == BRCMS_GF_PREAMBLE) || \
99 ((_pre) == BRCMS_MM_PREAMBLE))
101 /* values for barker_preamble */
102 #define BRCMS_BARKER_SHORT_ALLOWED 0 /* Short pre-amble allowed */
104 /* A fifo is full. Clear precedences related to that FIFO */
105 #define BRCMS_TX_FIFO_CLEAR(wlc, fifo) \
106 ((wlc)->tx_prec_map &= ~(wlc)->fifo2prec_map[fifo])
108 /* Fifo is NOT full. Enable precedences for that FIFO */
109 #define BRCMS_TX_FIFO_ENAB(wlc, fifo) \
110 ((wlc)->tx_prec_map |= (wlc)->fifo2prec_map[fifo])
113 /* seq and frag bits: SEQNUM_SHIFT, FRAGNUM_MASK (802.11.h) */
114 /* rate epoch bits: TXFID_RATE_SHIFT, TXFID_RATE_MASK ((wlc_rate.c) */
115 #define TXFID_QUEUE_MASK 0x0007 /* Bits 0-2 */
116 #define TXFID_SEQ_MASK 0x7FE0 /* Bits 5-15 */
117 #define TXFID_SEQ_SHIFT 5 /* Number of bit shifts */
118 #define TXFID_RATE_PROBE_MASK 0x8000 /* Bit 15 for rate probe */
119 #define TXFID_RATE_MASK 0x0018 /* Mask for bits 3 and 4 */
120 #define TXFID_RATE_SHIFT 3 /* Shift 3 bits for rate mask */
122 /* promote boardrev */
123 #define BOARDREV_PROMOTABLE 0xFF /* from */
124 #define BOARDREV_PROMOTED 1 /* to */
126 /* if wpa is in use then portopen is true when the group key is plumbed otherwise it is always true
128 #define WSEC_ENABLED(wsec) ((wsec) & (WEP_ENABLED | TKIP_ENABLED | AES_ENABLED))
129 #define BRCMS_SW_KEYS(wlc, bsscfg) ((((wlc)->wsec_swkeys) || \
130 ((bsscfg)->wsec & WSEC_SWFLAG)))
132 #define BRCMS_PORTOPEN(cfg) \
133 (((cfg)->WPA_auth != WPA_AUTH_DISABLED && WSEC_ENABLED((cfg)->wsec)) ? \
134 (cfg)->wsec_portopen : true)
136 #define PS_ALLOWED(wlc) brcms_c_ps_allowed(wlc)
138 #define DATA_BLOCK_TX_SUPR (1 << 4)
140 /* 802.1D Priority to TX FIFO number for wme */
141 extern const u8 prio2fifo
[];
143 /* Ucode MCTL_WAKE override bits */
144 #define BRCMS_WAKE_OVERRIDE_CLKCTL 0x01
145 #define BRCMS_WAKE_OVERRIDE_PHYREG 0x02
146 #define BRCMS_WAKE_OVERRIDE_MACSUSPEND 0x04
147 #define BRCMS_WAKE_OVERRIDE_TXFIFO 0x08
148 #define BRCMS_WAKE_OVERRIDE_FORCEFAST 0x10
150 /* stuff pulled in from wlc.c */
152 /* Interrupt bit error summary. Don't include I_RU: we refill DMA at other
153 * times; and if we run out, constant I_RU interrupts may cause lockup. We
154 * will still get error counts from rx0ovfl.
156 #define I_ERRORS (I_PC | I_PD | I_DE | I_RO | I_XU)
157 /* default software intmasks */
158 #define DEF_RXINTMASK (I_RI) /* enable rx int on rxfifo only */
159 #define DEF_MACINTMASK (MI_TXSTOP | MI_TBTT | MI_ATIMWINEND | MI_PMQ | \
160 MI_PHYTXERR | MI_DMAINT | MI_TFS | MI_BG_NOISE | \
161 MI_CCA | MI_TO | MI_GP0 | MI_RFDISABLE | MI_PWRUP)
163 #define RETRY_SHORT_DEF 7 /* Default Short retry Limit */
164 #define RETRY_SHORT_MAX 255 /* Maximum Short retry Limit */
165 #define RETRY_LONG_DEF 4 /* Default Long retry count */
166 #define RETRY_SHORT_FB 3 /* Short retry count for fallback rate */
167 #define RETRY_LONG_FB 2 /* Long retry count for fallback rate */
169 #define MAXTXPKTS 6 /* max # pkts pending */
172 #define MAXTXFRAMEBURST 8 /* vanilla xpress mode: max frames/burst */
173 #define MAXFRAMEBURST_TXOP 10000 /* Frameburst TXOP in usec */
175 /* Per-AC retry limit register definitions; uses defs.h bitfield macros */
176 #define EDCF_SHORT_S 0
178 #define EDCF_LONG_S 8
179 #define EDCF_LFB_S 12
180 #define EDCF_SHORT_M BITFIELD_MASK(4)
181 #define EDCF_SFB_M BITFIELD_MASK(4)
182 #define EDCF_LONG_M BITFIELD_MASK(4)
183 #define EDCF_LFB_M BITFIELD_MASK(4)
185 #define NFIFO 6 /* # tx/rx fifopairs */
187 #define BRCMS_WME_RETRY_SHORT_GET(wlc, ac) \
188 GFIELD(wlc->wme_retries[ac], EDCF_SHORT)
189 #define BRCMS_WME_RETRY_SFB_GET(wlc, ac) \
190 GFIELD(wlc->wme_retries[ac], EDCF_SFB)
191 #define BRCMS_WME_RETRY_LONG_GET(wlc, ac) \
192 GFIELD(wlc->wme_retries[ac], EDCF_LONG)
193 #define BRCMS_WME_RETRY_LFB_GET(wlc, ac) \
194 GFIELD(wlc->wme_retries[ac], EDCF_LFB)
196 #define BRCMS_WME_RETRY_SHORT_SET(wlc, ac, val) \
197 (wlc->wme_retries[ac] = SFIELD(wlc->wme_retries[ac], EDCF_SHORT, val))
198 #define BRCMS_WME_RETRY_SFB_SET(wlc, ac, val) \
199 (wlc->wme_retries[ac] = SFIELD(wlc->wme_retries[ac], EDCF_SFB, val))
200 #define BRCMS_WME_RETRY_LONG_SET(wlc, ac, val) \
201 (wlc->wme_retries[ac] = SFIELD(wlc->wme_retries[ac], EDCF_LONG, val))
202 #define BRCMS_WME_RETRY_LFB_SET(wlc, ac, val) \
203 (wlc->wme_retries[ac] = SFIELD(wlc->wme_retries[ac], EDCF_LFB, val))
207 /* pll is shared on old chips */
208 #define BRCMS_PLLREQ_SHARED 0x1
209 /* hold pll for radio monitor register checking */
210 #define BRCMS_PLLREQ_RADIO_MON 0x2
211 /* hold/release pll for some short operation */
212 #define BRCMS_PLLREQ_FLIP 0x4
215 * Macros to check if AP or STA is active.
216 * AP Active means more than just configured: driver and BSS are "up";
217 * that is, we are beaconing/responding as an AP (aps_associated).
218 * STA Active similarly means the driver is up and a configured STA BSS
219 * is up: either associated (stas_associated) or trying.
221 * Macro definitions vary as per AP/STA ifdefs, allowing references to
222 * ifdef'd structure fields and constant values (0) for optimization.
223 * Make sure to enclose blocks of code such that any routines they
224 * reference can also be unused and optimized out by the linker.
226 /* NOTE: References structure fields defined in wlc.h */
227 #define AP_ACTIVE(wlc) (0)
230 * Detect Card removed.
231 * Even checking an sbconfig register read will not false trigger when the core is in reset.
232 * it breaks CF address mechanism. Accessing gphy phyversion will cause SB error if aphy
233 * is in reset on 4306B0-DB. Need a simple accessible reg with fixed 0/1 pattern
234 * (some platforms return all 0).
235 * If clocks are present, call the sb routine which will figure out if the device is removed.
237 #define DEVICEREMOVED(wlc) \
239 ((R_REG(&wlc->hw->regs->maccontrol) & \
240 (MCTL_PSM_JMP_0 | MCTL_IHR_EN)) != MCTL_IHR_EN) : \
241 (ai_deviceremoved(wlc->hw->sih)))
243 #define BRCMS_UNIT(wlc) ((wlc)->pub->unit)
245 struct brcms_protection
{
246 bool _g
; /* use g spec protection, driver internal */
247 s8 g_override
; /* override for use of g spec protection */
248 u8 gmode_user
; /* user config gmode, operating band->gmode is different */
249 s8 overlap
; /* Overlap BSS/IBSS protection for both 11g and 11n */
250 s8 nmode_user
; /* user config nmode, operating pub->nmode is different */
251 s8 n_cfg
; /* use OFDM protection on MIMO frames */
252 s8 n_cfg_override
; /* override for use of N protection */
253 bool nongf
; /* non-GF present protection */
254 s8 nongf_override
; /* override for use of GF protection */
255 s8 n_pam_override
; /* override for preamble: MM or GF */
256 bool n_obss
; /* indicated OBSS Non-HT STA present */
259 /* anything affects the single/dual streams/antenna operation */
261 u8 hw_txchain
; /* HW txchain bitmap cfg */
262 u8 txchain
; /* txchain bitmap being used */
263 u8 txstreams
; /* number of txchains being used */
265 u8 hw_rxchain
; /* HW rxchain bitmap cfg */
266 u8 rxchain
; /* rxchain bitmap being used */
267 u8 rxstreams
; /* number of rxchains being used */
269 u8 ant_rx_ovr
; /* rx antenna override */
270 s8 txant
; /* userTx antenna setting */
271 u16 phytxant
; /* phyTx antenna setting in txheader */
273 u8 ss_opmode
; /* singlestream Operational mode, 0:siso; 1:cdd */
274 bool ss_algosel_auto
; /* if true, use wlc->stf->ss_algo_channel; */
275 /* else use wlc->band->stf->ss_mode_band; */
276 u16 ss_algo_channel
; /* ss based on per-channel algo: 0: SISO, 1: CDD 2: STBC */
277 u8 no_cddstbc
; /* stf override, 1: no CDD (or STBC) allowed */
279 u8 rxchain_restore_delay
; /* delay time to restore default rxchain */
281 s8 ldpc
; /* AUTO/ON/OFF ldpc cap supported */
282 u8 txcore
[MAX_STREAMS_SUPPORTED
+ 1]; /* bitmap of selected core for each Nsts */
286 #define BRCMS_STF_SS_STBC_TX(wlc, scb) \
287 (((wlc)->stf->txstreams > 1) && (((wlc)->band->band_stf_stbc_tx == ON) || \
288 (SCB_STBC_CAP((scb)) && \
289 (wlc)->band->band_stf_stbc_tx == AUTO && \
290 isset(&((wlc)->stf->ss_algo_channel), PHY_TXC1_MODE_STBC))))
292 #define BRCMS_STBC_CAP_PHY(wlc) (BRCMS_ISNPHY(wlc->band) && \
293 NREV_GE(wlc->band->phyrev, 3))
295 #define BRCMS_SGI_CAP_PHY(wlc) ((BRCMS_ISNPHY(wlc->band) && \
296 NREV_GE(wlc->band->phyrev, 3)) || \
297 BRCMS_ISLCNPHY(wlc->band))
299 #define BRCMS_CHAN_PHYTYPE(x) (((x) & RXS_CHAN_PHYTYPE_MASK) \
300 >> RXS_CHAN_PHYTYPE_SHIFT)
301 #define BRCMS_CHAN_CHANNEL(x) (((x) & RXS_CHAN_ID_MASK) \
302 >> RXS_CHAN_ID_SHIFT)
303 #define BRCMS_RX_CHANNEL(rxh) (BRCMS_CHAN_CHANNEL((rxh)->RxChan))
305 /* brcms_bss_info flag bit values */
306 #define BRCMS_BSS_HT 0x0020 /* BSS is HT (MIMO) capable */
308 /* Flags used in brcms_c_txq_info.stopped */
309 #define TXQ_STOP_FOR_PRIOFC_MASK 0x000000FF /* per prio flow control bits */
310 #define TXQ_STOP_FOR_PKT_DRAIN 0x00000100 /* stop txq enqueue for packet drain */
311 #define TXQ_STOP_FOR_AMPDU_FLOW_CNTRL 0x00000200 /* stop txq enqueue for ampdu flow control */
313 #define BRCMS_HT_WEP_RESTRICT 0x01 /* restrict HT with WEP */
314 #define BRCMS_HT_TKIP_RESTRICT 0x02 /* restrict HT with TKIP */
316 /* Maximum # of keys that wl driver supports in S/W.
317 * Keys supported in H/W is less than or equal to WSEC_MAX_KEYS.
319 #define WSEC_MAX_KEYS 54 /* Max # of keys (50 + 4 default keys) */
320 #define BRCMS_DEFAULT_KEYS 4 /* Default # of keys */
323 * Max # of keys currently supported:
325 * s/w keys if WSEC_SW(wlc->wsec).
326 * h/w keys otherwise.
328 #define BRCMS_MAX_WSEC_KEYS(wlc) WSEC_MAX_KEYS
330 /* number of 802.11 default (non-paired, group keys) */
331 #define WSEC_MAX_DEFAULT_KEYS 4 /* # of default keys */
334 u32 hi
; /* upper 32 bits of IV */
335 u16 lo
; /* lower 16 bits of IV */
338 #define BRCMS_NUMRXIVS 16 /* # rx IVs (one per 802.11e TID) */
341 u8 ea
[ETH_ALEN
]; /* per station */
342 u8 idx
; /* key index in wsec_keys array */
343 u8 id
; /* key ID [0-3] */
344 u8 algo
; /* CRYPTO_ALGO_AES_CCM, CRYPTO_ALGO_WEP128, etc */
345 u8 rcmta
; /* rcmta entry index, same as idx by default */
346 u16 flags
; /* misc flags */
347 u8 algo_hw
; /* cache for hw register */
348 u8 aes_mode
; /* cache for hw register */
349 s8 iv_len
; /* IV length */
350 s8 icv_len
; /* ICV length */
351 u32 len
; /* key length..don't move this var */
352 /* data is 4byte aligned */
353 u8 data
[WLAN_MAX_KEY_LEN
]; /* key data */
354 struct wsec_iv rxiv
[BRCMS_NUMRXIVS
]; /* Rx IV (one per TID) */
355 struct wsec_iv txiv
; /* Tx IV */
362 uint coreidx
; /* # sb enumerated core */
365 uint
*txavail
[NFIFO
]; /* # tx descriptors available */
366 s16 txpktpend
[NFIFO
]; /* tx admission control */
368 struct macstat
*macstat_snapshot
; /* mac hw prev read values */
372 * band state (phy+ana+radio)
375 int bandtype
; /* BRCM_BAND_2G, BRCM_BAND_5G */
376 uint bandunit
; /* bandstate[] index */
378 u16 phytype
; /* phytype */
382 struct brcms_phy_pub
*pi
; /* pointer to phy specific information */
385 u8 gmode
; /* currently active gmode */
387 struct scb
*hwrs_scb
; /* permanent scb for hw rateset */
389 wlc_rateset_t defrateset
; /* band-specific copy of default_bss.rateset */
391 ratespec_t rspec_override
; /* 802.11 rate override */
392 ratespec_t mrspec_override
; /* multicast rate override */
393 u8 band_stf_ss_mode
; /* Configured STF type, 0:siso; 1:cdd */
394 s8 band_stf_stbc_tx
; /* STBC TX 0:off; 1:force on; -1:auto */
395 wlc_rateset_t hw_rateset
; /* rates supported by chip (phy-specific) */
396 u8 basic_rate
[BRCM_MAXRATE
+ 1]; /* basic rates indexed by rate */
397 bool mimo_cap_40
; /* 40 MHz cap enabled on this band */
398 s8 antgain
; /* antenna gain from srom */
400 u16 CWmin
; /* The minimum size of contention window, in unit of aSlotTime */
401 u16 CWmax
; /* The maximum size of contention window, in unit of aSlotTime */
402 u16 bcntsfoff
; /* beacon tsf offset */
405 /* tx completion callback takes 3 args */
406 typedef void (*pkcb_fn_t
) (struct brcms_c_info
*wlc
, uint txstatus
, void *arg
);
409 pkcb_fn_t fn
; /* function to call when tx frame completes */
410 void *arg
; /* void arg for fn */
411 u8 nextidx
; /* index of next call back if threading */
412 bool entered
; /* recursion check */
415 /* module control blocks */
417 char name
[32]; /* module name : NULL indicates empty array member */
418 const struct brcmu_iovar
*iovars
; /* iovar table */
419 void *hdl
; /* handle passed when handler 'doiovar' is called */
420 watchdog_fn_t watchdog_fn
; /* watchdog handler */
421 iovar_fn_t iovar_fn
; /* iovar handler */
422 down_fn_t down_fn
; /* down handler. Note: the int returned
423 * by the down function is a count of the
424 * number of timers that could not be
429 /* dump control blocks */
431 const char *name
; /* dump name */
432 dump_fn_t dump_fn
; /* 'wl dump' handler */
434 struct dumpcb_s
*next
;
437 struct edcf_acparam
{
443 struct wme_param_ie
{
450 struct edcf_acparam acparam
[AC_COUNT
];
453 /* virtual interface */
455 struct brcms_c_if
*next
;
456 u8 type
; /* BSS or WDS */
457 u8 index
; /* assigned in wl_add_if(), index of the wlif if any,
458 * not necessarily corresponding to bsscfg._idx or
461 u8 flags
; /* flags for the interface */
462 struct brcms_if
*wlif
; /* pointer to wlif */
463 struct brcms_txq_info
*qi
; /* pointer to associated tx queue */
465 /* pointer to scb if WDS */
467 /* pointer to bsscfg if BSS */
468 struct brcms_bss_cfg
*bsscfg
;
472 /* flags for the interface, this interface is linked to a brcms_if */
473 #define BRCMS_IF_LINKED 0x02
475 struct brcms_hw_band
{
476 int bandtype
; /* BRCM_BAND_2G, BRCM_BAND_5G */
477 uint bandunit
; /* bandstate[] index */
478 u16 mhfs
[MHFMAX
]; /* MHF array shadow */
479 u8 bandhw_stf_ss_mode
; /* HW configured STF type, 0:siso; 1:cdd */
484 u16 phytype
; /* phytype */
488 struct brcms_phy_pub
*pi
; /* pointer to phy specific information */
492 struct brcms_hardware
{
493 bool _piomode
; /* true if pio mode */
494 struct brcms_c_info
*wlc
;
497 struct dma_pub
*di
[NFIFO
]; /* dma handles, per fifo */
499 uint unit
; /* device instance number */
502 u16 vendorid
; /* PCI vendor id */
503 u16 deviceid
; /* PCI device id */
504 uint corerev
; /* core revision */
505 u8 sromrev
; /* version # of the srom */
506 u16 boardrev
; /* version # of particular board */
507 u32 boardflags
; /* Board specific flags from srom */
508 u32 boardflags2
; /* More board flags if sromrev >= 4 */
509 u32 machwcap
; /* MAC capabilities */
510 u32 machwcap_backup
; /* backup of machwcap */
511 u16 ucode_dbgsel
; /* dbgsel for ucode debug(config gpio) */
513 struct si_pub
*sih
; /* SI handle (cookie for siutils calls) */
514 char *vars
; /* "environment" name=value */
515 uint vars_size
; /* size of vars, free vars on detach */
516 d11regs_t
*regs
; /* pointer to device registers */
517 void *physhim
; /* phy shim layer handler */
518 void *phy_sh
; /* pointer to shared phy state */
519 struct brcms_hw_band
*band
;/* pointer to active per-band state */
520 /* band state per phy/radio */
521 struct brcms_hw_band
*bandstate
[MAXBANDS
];
522 u16 bmac_phytxant
; /* cache of high phytxant state */
523 bool shortslot
; /* currently using 11g ShortSlot timing */
524 u16 SRL
; /* 802.11 dot11ShortRetryLimit */
525 u16 LRL
; /* 802.11 dot11LongRetryLimit */
526 u16 SFBL
; /* Short Frame Rate Fallback Limit */
527 u16 LFBL
; /* Long Frame Rate Fallback Limit */
529 bool up
; /* d11 hardware up and running */
530 uint now
; /* # elapsed seconds */
531 uint _nbands
; /* # bands supported */
532 chanspec_t chanspec
; /* bmac chanspec shadow */
534 uint
*txavail
[NFIFO
]; /* # tx descriptors available */
535 u16
*xmtfifo_sz
; /* fifo size in 256B for each xmt fifo */
537 mbool pllreq
; /* pll requests to keep PLL on */
539 u8 suspended_fifos
; /* Which TX fifo to remain awake for */
540 u32 maccontrol
; /* Cached value of maccontrol */
541 uint mac_suspend_depth
; /* current depth of mac_suspend levels */
542 u32 wake_override
; /* Various conditions to force MAC to WAKE mode */
543 u32 mute_override
; /* Prevent ucode from sending beacons */
544 u8 etheraddr
[ETH_ALEN
]; /* currently configured ethernet address */
545 u32 led_gpio_mask
; /* LED GPIO Mask */
546 bool noreset
; /* true= do not reset hw, used by WLC_OUT */
547 bool forcefastclk
; /* true if the h/w is forcing the use of fast clk */
548 bool clk
; /* core is out of reset and has clock */
549 bool sbclk
; /* sb has clock */
550 struct bmac_pmq
*bmac_pmq
; /* bmac PM states derived from ucode PMQ */
551 bool phyclk
; /* phy is out of reset and has clock */
552 bool dma_lpbk
; /* core is in DMA loopback */
554 bool ucode_loaded
; /* true after ucode downloaded */
557 u8 hw_stf_ss_opmode
; /* STF single stream operation mode */
558 u8 antsel_type
; /* Type of boardlevel mimo antenna switch-logic
559 * 0 = N/A, 1 = 2x4 board, 2 = 2x3 CB2 board
562 * put struct antsel_info here if more info is
567 /* TX Queue information
569 * Each flow of traffic out of the device has a TX Queue with independent
570 * flow control. Several interfaces may be associated with a single TX Queue
571 * if they belong to the same flow of traffic from the device. For multi-channel
572 * operation there are independent TX Queues for each channel.
574 struct brcms_txq_info
{
575 struct brcms_txq_info
*next
;
577 uint stopped
; /* tx flow control bits */
581 * Principal common (os-independent) software data structure.
583 struct brcms_c_info
{
584 struct brcms_pub
*pub
; /* pointer to wlc public state */
585 struct brcms_info
*wl
; /* pointer to os-specific private state */
586 d11regs_t
*regs
; /* pointer to device registers */
588 /* HW related state used primarily by BMAC */
589 struct brcms_hardware
*hw
;
592 int clkreq_override
; /* setting for clkreq for PCIE : Auto, 0, 1 */
593 u16 fastpwrup_dly
; /* time in us needed to bring up d11 fast clock */
596 u32 macintstatus
; /* bit channel between isr and dpc */
597 u32 macintmask
; /* sw runtime master macintmask value */
598 u32 defmacintmask
; /* default "on" macintmask value */
601 bool device_present
; /* (removable) device is present */
603 bool clk
; /* core is out of reset and has clock */
606 struct brcms_core
*core
; /* pointer to active io core */
607 struct brcms_band
*band
; /* pointer to active per-band state */
608 struct brcms_core
*corestate
; /* per-core state (one per hw core) */
609 /* per-band state (one per phy/radio): */
610 struct brcms_band
*bandstate
[MAXBANDS
];
612 bool war16165
; /* PCI slow clock 16165 war flag */
614 bool tx_suspended
; /* data fifos need to remain suspended */
619 uint qvalid
; /* DirFrmQValid and BcMcFrmQValid */
621 /* Regulatory power limits */
622 s8 txpwr_local_max
; /* regulatory local txpwr max */
623 u8 txpwr_local_constraint
; /* local power contraint in dB */
626 struct ampdu_info
*ampdu
; /* ampdu module handler */
627 struct antsel_info
*asi
; /* antsel module handler */
628 struct brcms_cm_info
*cmi
; /* channel manager module handler */
630 uint vars_size
; /* size of vars, free vars on detach */
632 u16 vendorid
; /* PCI vendor id */
633 u16 deviceid
; /* PCI device id */
634 uint ucode_rev
; /* microcode revision */
636 u32 machwcap
; /* MAC capabilities, BMAC shadow */
638 u8 perm_etheraddr
[ETH_ALEN
]; /* original sprom local ethernet address */
640 bool bandlocked
; /* disable auto multi-band switching */
641 bool bandinit_pending
; /* track band init in auto band */
643 bool radio_monitor
; /* radio timer is running */
644 bool going_down
; /* down path intermediate variable */
646 bool mpc
; /* enable minimum power consumption */
647 u8 mpc_dlycnt
; /* # of watchdog cnt before turn disable radio */
648 u8 mpc_offcnt
; /* # of watchdog cnt that radio is disabled */
649 u8 mpc_delay_off
; /* delay radio disable by # of watchdog cnt */
650 u8 prev_non_delay_mpc
; /* prev state brcms_c_is_non_delay_mpc */
652 /* timer for watchdog routine */
653 struct brcms_timer
*wdtimer
;
654 /* timer for hw radio button monitor routine */
655 struct brcms_timer
*radio_timer
;
658 bool monitor
; /* monitor (MPDU sniffing) mode */
659 bool bcnmisc_ibss
; /* bcns promisc mode override for IBSS */
660 bool bcnmisc_scan
; /* bcns promisc mode override for scan */
661 bool bcnmisc_monitor
; /* bcns promisc mode override for monitor */
664 bool _rifs
; /* enable per-packet rifs */
665 s8 sgi_tx
; /* sgi tx */
667 /* AP-STA synchronization, power save */
668 u8 bcn_li_bcn
; /* beacon listen interval in # beacons */
669 u8 bcn_li_dtim
; /* beacon listen interval in # dtims */
671 bool WDarmed
; /* watchdog timer is armed */
672 u32 WDlast
; /* last time wlc_watchdog() was called */
675 ac_bitmap_t wme_dp
; /* Discard (oldest first) policy per AC */
676 u16 edcf_txop
[AC_COUNT
]; /* current txop for each ac */
679 * WME parameter info element, which on STA contains parameters in use
680 * locally, and on AP contains parameters advertised to STA in beacons
681 * and assoc responses.
683 struct wme_param_ie wme_param_ie
;
684 u16 wme_retries
[AC_COUNT
]; /* per-AC retry limits */
686 u16 tx_prec_map
; /* Precedence map based on HW FIFO space */
687 u16 fifo2prec_map
[NFIFO
]; /* pointer to fifo2_prec map based on WME */
690 * BSS Configurations set of BSS configurations, idx 0 is default and
693 struct brcms_bss_cfg
*bsscfg
[BRCMS_MAXBSSCFG
];
694 struct brcms_bss_cfg
*cfg
; /* the primary bsscfg (can be AP or STA) */
697 struct brcms_txq_info
*tx_queues
; /* common TX Queue list */
700 struct wsec_key
*wsec_keys
[WSEC_MAX_KEYS
]; /* dynamic key storage */
701 /* default key storage */
702 struct wsec_key
*wsec_def_keys
[BRCMS_DEFAULT_KEYS
];
703 bool wsec_swkeys
; /* indicates that all keys should be
704 * treated as sw keys (used for debugging)
706 struct modulecb
*modulecb
;
708 u8 mimoft
; /* SIGN or 11N */
709 s8 cck_40txbw
; /* 11N, cck tx b/w override when in 40MHZ mode */
710 s8 ofdm_40txbw
; /* 11N, ofdm tx b/w override when in 40MHZ mode */
711 s8 mimo_40txbw
; /* 11N, mimo tx b/w override when in 40MHZ mode */
712 /* HT CAP IE being advertised by this node: */
713 struct ieee80211_ht_cap ht_cap
;
715 struct brcms_bss_info
*default_bss
; /* configured BSS parameters */
717 u16 mc_fid_counter
; /* BC/MC FIFO frame ID counter */
719 /* saved country for leaving 802.11d auto-country mode */
720 char country_default
[BRCM_CNTRY_BUF_SZ
];
721 /* initial country for 802.11d auto-country mode */
722 char autocountry_default
[BRCM_CNTRY_BUF_SZ
];
723 u16 prb_resp_timeout
; /* do not send prb resp if request older than this,
727 wlc_rateset_t sup_rates_override
; /* use only these rates in 11g supported rates if
731 chanspec_t home_chanspec
; /* shared home chanspec */
734 chanspec_t chanspec
; /* target operational channel */
735 u16 usr_fragthresh
; /* user configured fragmentation threshold */
736 u16 fragthresh
[NFIFO
]; /* per-fifo fragmentation thresholds */
737 u16 RTSThresh
; /* 802.11 dot11RTSThreshold */
738 u16 SRL
; /* 802.11 dot11ShortRetryLimit */
739 u16 LRL
; /* 802.11 dot11LongRetryLimit */
740 u16 SFBL
; /* Short Frame Rate Fallback Limit */
741 u16 LFBL
; /* Long Frame Rate Fallback Limit */
744 bool shortslot
; /* currently using 11g ShortSlot timing */
745 s8 shortslot_override
; /* 11g ShortSlot override */
746 bool include_legacy_erp
; /* include Legacy ERP info elt ID 47 as well as g ID 42 */
748 struct brcms_protection
*protection
;
749 s8 PLCPHdr_override
; /* 802.11b Preamble Type override */
751 struct brcms_stf
*stf
;
753 ratespec_t bcn_rspec
; /* save bcn ratespec purpose */
755 uint tempsense_lasttime
;
757 u16 tx_duty_cycle_ofdm
; /* maximum allowed duty cycle for OFDM */
758 u16 tx_duty_cycle_cck
; /* maximum allowed duty cycle for CCK */
762 struct brcms_txq_info
*pkt_queue
; /* txq for transmit packets */
763 u32 mpc_dur
; /* total time (ms) in mpc mode except for the
764 * portion since radio is turned off last time
766 u32 mpc_laston_ts
; /* timestamp (ms) when radio is turned off last
772 /* antsel module specific state */
774 struct brcms_c_info
*wlc
; /* pointer to main wlc structure */
775 struct brcms_pub
*pub
; /* pointer to public fn */
776 u8 antsel_type
; /* Type of boardlevel mimo antenna switch-logic
777 * 0 = N/A, 1 = 2x4 board, 2 = 2x3 CB2 board
779 u8 antsel_antswitch
; /* board level antenna switch type */
780 bool antsel_avail
; /* Ant selection availability (SROM based) */
781 struct brcms_antselcfg antcfg_11n
; /* antenna configuration */
782 struct brcms_antselcfg antcfg_cur
; /* current antenna config (auto) */
785 /* BSS configuration state */
786 struct brcms_bss_cfg
{
787 struct brcms_c_info
*wlc
; /* wlc to which this bsscfg belongs to. */
788 bool up
; /* is this configuration up operational */
789 bool enable
; /* is this configuration enabled */
790 bool associated
; /* is BSS in ASSOCIATED state */
791 bool BSS
; /* infraustructure or adhac */
792 bool dtim_programmed
;
794 u8 SSID_len
; /* the length of SSID */
795 u8 SSID
[IEEE80211_MAX_SSID_LEN
]; /* SSID string */
796 struct scb
*bcmc_scb
[MAXBANDS
]; /* one bcmc_scb per band */
797 s8 _idx
; /* the index of this bsscfg,
798 * assigned at wlc_bsscfg_alloc()
801 uint nmac
; /* # of entries on maclist array */
802 int macmode
; /* allow/deny stations on maclist array */
803 struct ether_addr
*maclist
; /* list of source MAC addrs to match */
806 u32 wsec
; /* wireless security bitvec */
807 s16 auth
; /* 802.11 authentication: Open, Shared Key, WPA */
808 s16 openshared
; /* try Open auth first, then Shared Key */
809 bool wsec_restrict
; /* drop unencrypted packets if wsec is enabled */
810 bool eap_restrict
; /* restrict data until 802.1X auth succeeds */
811 u16 WPA_auth
; /* WPA: authenticated key management */
812 bool wpa2_preauth
; /* default is true, wpa_cap sets value */
813 bool wsec_portopen
; /* indicates keys are plumbed */
814 /* global txiv for WPA_NONE, tkip and aes */
815 struct wsec_iv wpa_none_txiv
;
816 int wsec_index
; /* 0-3: default tx key, -1: not set */
817 /* default key storage: */
818 struct wsec_key
*bss_def_keys
[BRCMS_DEFAULT_KEYS
];
820 /* TKIP countermeasures */
821 bool tkip_countermeasures
; /* flags TKIP no-assoc period */
822 u32 tk_cm_dt
; /* detect timer */
823 u32 tk_cm_bt
; /* blocking timer */
824 u32 tk_cm_bt_tmstmp
; /* Timestamp when TKIP BT is activated */
825 bool tk_cm_activate
; /* activate countermeasures after EAPOL-Key sent */
827 u8 BSSID
[ETH_ALEN
]; /* BSSID (associated) */
828 u8 cur_etheraddr
[ETH_ALEN
]; /* h/w address */
829 u16 bcmc_fid
; /* the last BCMC FID queued to TX_BCMC_FIFO */
830 u16 bcmc_fid_shm
; /* the last BCMC FID written to shared mem */
832 u32 flags
; /* BSSCFG flags; see below */
834 u8
*bcn
; /* AP beacon */
835 uint bcn_len
; /* AP beacon length */
836 bool ar_disassoc
; /* disassociated in associated recreation */
838 int auth_atmptd
; /* auth type (open/shared) attempted */
840 pmkid_cand_t pmkid_cand
[MAXPMKID
]; /* PMKID candidate list */
841 uint npmkid_cand
; /* num PMKID candidates */
842 pmkid_t pmkid
[MAXPMKID
]; /* PMKID cache */
843 uint npmkid
; /* num cached PMKIDs */
845 struct brcms_bss_info
*current_bss
; /* BSS parms in ASSOCIATED state */
848 bool PMawakebcn
; /* bcn recvd during current waking state */
849 bool PMpending
; /* waiting for tx status with PM indicated set */
850 bool priorPMstate
; /* Detecting PM state transitions */
851 bool PSpoll
; /* whether there is an outstanding PS-Poll frame */
853 /* BSSID entry in RCMTA, use the wsec key management infrastructure to
854 * manage the RCMTA entries.
856 struct wsec_key
*rcmta
;
858 /* 'unique' ID of this bsscfg, assigned at bsscfg allocation */
861 uint txrspecidx
; /* index into tx rate circular buffer */
862 ratespec_t txrspec
[NTXRATE
][2]; /* circular buffer of prev MPDUs tx rates */
865 #define CHANNEL_BANDUNIT(wlc, ch) (((ch) <= CH_MAX_2G_CHANNEL) ? BAND_2G_INDEX : BAND_5G_INDEX)
866 #define OTHERBANDUNIT(wlc) ((uint)((wlc)->band->bandunit ? BAND_2G_INDEX : BAND_5G_INDEX))
868 #define IS_MBAND_UNLOCKED(wlc) \
869 ((NBANDS(wlc) > 1) && !(wlc)->bandlocked)
871 #define BRCMS_BAND_PI_RADIO_CHANSPEC wlc_phy_chanspec_get(wlc->band->pi)
873 /* sum the individual fifo tx pending packet counts */
874 #define TXPKTPENDTOT(wlc) ((wlc)->core->txpktpend[0] + (wlc)->core->txpktpend[1] + \
875 (wlc)->core->txpktpend[2] + (wlc)->core->txpktpend[3])
876 #define TXPKTPENDGET(wlc, fifo) ((wlc)->core->txpktpend[(fifo)])
877 #define TXPKTPENDINC(wlc, fifo, val) ((wlc)->core->txpktpend[(fifo)] += (val))
878 #define TXPKTPENDDEC(wlc, fifo, val) ((wlc)->core->txpktpend[(fifo)] -= (val))
879 #define TXPKTPENDCLR(wlc, fifo) ((wlc)->core->txpktpend[(fifo)] = 0)
880 #define TXAVAIL(wlc, fifo) (*(wlc)->core->txavail[(fifo)])
881 #define GETNEXTTXP(wlc, _queue) \
882 dma_getnexttxp((wlc)->hw->di[(_queue)], DMA_RANGE_TRANSMITTED)
884 #define BRCMS_IS_MATCH_SSID(wlc, ssid1, ssid2, len1, len2) \
885 ((len1 == len2) && !memcmp(ssid1, ssid2, len1))
887 extern void brcms_c_fatal_error(struct brcms_c_info
*wlc
);
888 extern void brcms_b_rpc_watchdog(struct brcms_c_info
*wlc
);
889 extern void brcms_c_recv(struct brcms_c_info
*wlc
, struct sk_buff
*p
);
890 extern bool brcms_c_dotxstatus(struct brcms_c_info
*wlc
, struct tx_status
*txs
,
892 extern void brcms_c_txfifo(struct brcms_c_info
*wlc
, uint fifo
,
894 bool commit
, s8 txpktpend
);
895 extern void brcms_c_txfifo_complete(struct brcms_c_info
*wlc
, uint fifo
,
897 extern void brcms_c_txq_enq(void *ctx
, struct scb
*scb
, struct sk_buff
*sdu
,
899 extern void brcms_c_info_init(struct brcms_c_info
*wlc
, int unit
);
900 extern void brcms_c_print_txstatus(struct tx_status
*txs
);
901 extern int brcms_c_xmtfifo_sz_get(struct brcms_c_info
*wlc
, uint fifo
,
903 extern void brcms_c_write_template_ram(struct brcms_c_info
*wlc
, int offset
,
905 extern void brcms_c_write_hw_bcntemplates(struct brcms_c_info
*wlc
, void *bcn
,
907 extern void brcms_c_pllreq(struct brcms_c_info
*wlc
, bool set
, mbool req_bit
);
908 extern void brcms_c_reset_bmac_done(struct brcms_c_info
*wlc
);
911 extern void brcms_c_print_rxh(struct d11rxhdr
*rxh
);
912 extern void brcms_c_print_txdesc(struct d11txh
*txh
);
914 #define brcms_c_print_txdesc(a)
917 extern void brcms_c_setxband(struct brcms_hardware
*wlc_hw
, uint bandunit
);
918 extern void brcms_c_coredisable(struct brcms_hardware
*wlc_hw
);
920 extern bool brcms_c_valid_rate(struct brcms_c_info
*wlc
, ratespec_t rate
,
921 int band
, bool verbose
);
922 extern void brcms_c_ap_upd(struct brcms_c_info
*wlc
);
924 /* helper functions */
925 extern void brcms_c_shm_ssid_upd(struct brcms_c_info
*wlc
,
926 struct brcms_bss_cfg
*cfg
);
927 extern int brcms_c_set_gmode(struct brcms_c_info
*wlc
, u8 gmode
, bool config
);
929 extern void brcms_c_mac_bcn_promisc_change(struct brcms_c_info
*wlc
,
931 extern void brcms_c_mac_bcn_promisc(struct brcms_c_info
*wlc
);
932 extern void brcms_c_mac_promisc(struct brcms_c_info
*wlc
);
933 extern void brcms_c_txflowcontrol(struct brcms_c_info
*wlc
,
934 struct brcms_txq_info
*qi
,
936 extern void brcms_c_txflowcontrol_override(struct brcms_c_info
*wlc
,
937 struct brcms_txq_info
*qi
,
938 bool on
, uint override
);
939 extern bool brcms_c_txflowcontrol_prio_isset(struct brcms_c_info
*wlc
,
940 struct brcms_txq_info
*qi
,
942 extern void brcms_c_send_q(struct brcms_c_info
*wlc
);
943 extern int brcms_c_prep_pdu(struct brcms_c_info
*wlc
, struct sk_buff
*pdu
,
946 extern u16
brcms_c_calc_lsig_len(struct brcms_c_info
*wlc
, ratespec_t ratespec
,
948 extern ratespec_t
brcms_c_rspec_to_rts_rspec(struct brcms_c_info
*wlc
,
950 bool use_rspec
, u16 mimo_ctlchbw
);
951 extern u16
brcms_c_compute_rtscts_dur(struct brcms_c_info
*wlc
, bool cts_only
,
953 ratespec_t frame_rate
,
954 u8 rts_preamble_type
,
955 u8 frame_preamble_type
, uint frame_len
,
958 extern void brcms_c_tbtt(struct brcms_c_info
*wlc
);
959 extern void brcms_c_inval_dma_pkts(struct brcms_hardware
*hw
,
960 struct ieee80211_sta
*sta
,
961 void (*dma_callback_fn
));
963 extern void brcms_c_reprate_init(struct brcms_c_info
*wlc
);
964 extern void brcms_c_bsscfg_reprate_init(struct brcms_bss_cfg
*bsscfg
);
966 /* Shared memory access */
967 extern void brcms_c_write_shm(struct brcms_c_info
*wlc
, uint offset
, u16 v
);
968 extern u16
brcms_c_read_shm(struct brcms_c_info
*wlc
, uint offset
);
969 extern void brcms_c_copyto_shm(struct brcms_c_info
*wlc
, uint offset
,
970 const void *buf
, int len
);
972 extern void brcms_c_update_beacon(struct brcms_c_info
*wlc
);
973 extern void brcms_c_bss_update_beacon(struct brcms_c_info
*wlc
,
974 struct brcms_bss_cfg
*bsscfg
);
976 extern void brcms_c_update_probe_resp(struct brcms_c_info
*wlc
, bool suspend
);
977 extern void brcms_c_bss_update_probe_resp(struct brcms_c_info
*wlc
,
978 struct brcms_bss_cfg
*cfg
,
980 extern bool brcms_c_ismpc(struct brcms_c_info
*wlc
);
981 extern bool brcms_c_is_non_delay_mpc(struct brcms_c_info
*wlc
);
982 extern void brcms_c_radio_mpc_upd(struct brcms_c_info
*wlc
);
983 extern bool brcms_c_prec_enq(struct brcms_c_info
*wlc
, struct pktq
*q
,
984 void *pkt
, int prec
);
985 extern bool brcms_c_prec_enq_head(struct brcms_c_info
*wlc
, struct pktq
*q
,
986 struct sk_buff
*pkt
, int prec
, bool head
);
987 extern u16
brcms_c_phytxctl1_calc(struct brcms_c_info
*wlc
, ratespec_t rspec
);
988 extern void brcms_c_compute_plcp(struct brcms_c_info
*wlc
, ratespec_t rate
,
989 uint length
, u8
*plcp
);
990 extern uint
brcms_c_calc_frame_time(struct brcms_c_info
*wlc
,
992 u8 preamble_type
, uint mac_len
);
994 extern void brcms_c_set_chanspec(struct brcms_c_info
*wlc
,
995 chanspec_t chanspec
);
997 extern bool brcms_c_timers_init(struct brcms_c_info
*wlc
, int unit
);
999 extern int brcms_c_set_nmode(struct brcms_c_info
*wlc
, s32 nmode
);
1000 extern void brcms_c_mimops_action_ht_send(struct brcms_c_info
*wlc
,
1001 struct brcms_bss_cfg
*bsscfg
,
1004 extern void brcms_c_switch_shortslot(struct brcms_c_info
*wlc
, bool shortslot
);
1005 extern void brcms_c_set_bssid(struct brcms_bss_cfg
*cfg
);
1006 extern void brcms_c_edcf_setparams(struct brcms_c_info
*wlc
, bool suspend
);
1008 extern void brcms_c_set_ratetable(struct brcms_c_info
*wlc
);
1009 extern int brcms_c_set_mac(struct brcms_bss_cfg
*cfg
);
1010 extern void brcms_c_beacon_phytxctl_txant_upd(struct brcms_c_info
*wlc
,
1011 ratespec_t bcn_rate
);
1012 extern void brcms_c_mod_prb_rsp_rate_table(struct brcms_c_info
*wlc
,
1014 extern ratespec_t
brcms_c_lowest_basic_rspec(struct brcms_c_info
*wlc
,
1016 extern void brcms_c_radio_disable(struct brcms_c_info
*wlc
);
1017 extern void brcms_c_bcn_li_upd(struct brcms_c_info
*wlc
);
1018 extern void brcms_c_set_home_chanspec(struct brcms_c_info
*wlc
,
1019 chanspec_t chanspec
);
1020 extern bool brcms_c_ps_allowed(struct brcms_c_info
*wlc
);
1021 extern bool brcms_c_stay_awake(struct brcms_c_info
*wlc
);
1022 extern void brcms_c_wme_initparams_sta(struct brcms_c_info
*wlc
,
1023 struct wme_param_ie
*pe
);
1025 #endif /* _BRCM_MAIN_H_ */