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 #define MA_WINDOW_SZ 8 /* moving average window size */
21 #define WL_HWRXOFF 38 /* chip rx buffer offset */
22 #define INVCHANNEL 255 /* invalid channel */
23 #define MAXCOREREV 28 /* max # supported core revisions (0 .. MAXCOREREV - 1) */
24 #define WLC_MAXMODULES 22 /* max # wlc_module_register() calls */
26 #define SEQNUM_SHIFT 4
27 #define AMPDU_DELIMITER_LEN 4
28 #define SEQNUM_MAX 0x1000
31 #define PHY_CWMAX 1023
33 #define EDCF_AIFSN_MIN 1
34 #define FRAGNUM_MASK 0xF
36 #define WLC_BITSCNT(x) bcm_bitcount((u8 *)&(x), sizeof(u8))
38 /* Maximum wait time for a MAC suspend */
39 #define WLC_MAX_MAC_SUSPEND 83000 /* uS: 83mS is max packet time (64KB ampdu @ 6Mbps) */
41 /* Probe Response timeout - responses for probe requests older that this are tossed, zero to disable
43 #define WLC_PRB_RESP_TIMEOUT 0 /* Disable probe response timeout */
45 /* transmit buffer max headroom for protocol headers */
46 #define TXOFF (D11_TXH_LEN + D11_PHY_HDR_LEN)
50 /* For managing scan result lists */
53 bool beacon; /* set for beacon, cleared for probe response */
54 wlc_bss_info_t *ptrs[MAXBSS];
57 #define SW_TIMER_MAC_STAT_UPD 30 /* periodic MAC stats update */
59 /* Double check that unsupported cores are not enabled */
60 #if CONF_MSK(D11CONF, 0x4f) || CONF_GE(D11CONF, MAXCOREREV)
61 #error "Configuration for D11CONF includes unsupported versions."
62 #endif /* Bad versions */
64 #define VALID_COREREV(corerev) CONF_HAS(D11CONF, corerev)
66 /* values for shortslot_override */
67 #define WLC_SHORTSLOT_AUTO -1 /* Driver will manage Shortslot setting */
68 #define WLC_SHORTSLOT_OFF 0 /* Turn off short slot */
69 #define WLC_SHORTSLOT_ON 1 /* Turn on short slot */
71 /* value for short/long and mixmode/greenfield preamble */
73 #define WLC_LONG_PREAMBLE (0)
74 #define WLC_SHORT_PREAMBLE (1 << 0)
75 #define WLC_GF_PREAMBLE (1 << 1)
76 #define WLC_MM_PREAMBLE (1 << 2)
77 #define WLC_IS_MIMO_PREAMBLE(_pre) (((_pre) == WLC_GF_PREAMBLE) || ((_pre) == WLC_MM_PREAMBLE))
79 /* values for barker_preamble */
80 #define WLC_BARKER_SHORT_ALLOWED 0 /* Short pre-amble allowed */
82 /* A fifo is full. Clear precedences related to that FIFO */
83 #define WLC_TX_FIFO_CLEAR(wlc, fifo) ((wlc)->tx_prec_map &= ~(wlc)->fifo2prec_map[fifo])
85 /* Fifo is NOT full. Enable precedences for that FIFO */
86 #define WLC_TX_FIFO_ENAB(wlc, fifo) ((wlc)->tx_prec_map |= (wlc)->fifo2prec_map[fifo])
89 /* seq and frag bits: SEQNUM_SHIFT, FRAGNUM_MASK (802.11.h) */
90 /* rate epoch bits: TXFID_RATE_SHIFT, TXFID_RATE_MASK ((wlc_rate.c) */
91 #define TXFID_QUEUE_MASK 0x0007 /* Bits 0-2 */
92 #define TXFID_SEQ_MASK 0x7FE0 /* Bits 5-15 */
93 #define TXFID_SEQ_SHIFT 5 /* Number of bit shifts */
94 #define TXFID_RATE_PROBE_MASK 0x8000 /* Bit 15 for rate probe */
95 #define TXFID_RATE_MASK 0x0018 /* Mask for bits 3 and 4 */
96 #define TXFID_RATE_SHIFT 3 /* Shift 3 bits for rate mask */
98 /* promote boardrev */
99 #define BOARDREV_PROMOTABLE 0xFF /* from */
100 #define BOARDREV_PROMOTED 1 /* to */
102 /* if wpa is in use then portopen is true when the group key is plumbed otherwise it is always true
104 #define WSEC_ENABLED(wsec) ((wsec) & (WEP_ENABLED | TKIP_ENABLED | AES_ENABLED))
105 #define WLC_SW_KEYS(wlc, bsscfg) ((((wlc)->wsec_swkeys) || \
106 ((bsscfg)->wsec & WSEC_SWFLAG)))
108 #define WLC_PORTOPEN(cfg) \
109 (((cfg)->WPA_auth != WPA_AUTH_DISABLED && WSEC_ENABLED((cfg)->wsec)) ? \
110 (cfg)->wsec_portopen : true)
112 #define PS_ALLOWED(wlc) wlc_ps_allowed(wlc)
114 #define DATA_BLOCK_TX_SUPR (1 << 4)
116 /* 802.1D Priority to TX FIFO number for wme */
117 extern const u8 prio2fifo[];
119 /* Ucode MCTL_WAKE override bits */
120 #define WLC_WAKE_OVERRIDE_CLKCTL 0x01
121 #define WLC_WAKE_OVERRIDE_PHYREG 0x02
122 #define WLC_WAKE_OVERRIDE_MACSUSPEND 0x04
123 #define WLC_WAKE_OVERRIDE_TXFIFO 0x08
124 #define WLC_WAKE_OVERRIDE_FORCEFAST 0x10
126 /* stuff pulled in from wlc.c */
128 /* Interrupt bit error summary. Don't include I_RU: we refill DMA at other
129 * times; and if we run out, constant I_RU interrupts may cause lockup. We
130 * will still get error counts from rx0ovfl.
132 #define I_ERRORS (I_PC | I_PD | I_DE | I_RO | I_XU)
133 /* default software intmasks */
134 #define DEF_RXINTMASK (I_RI) /* enable rx int on rxfifo only */
135 #define DEF_MACINTMASK (MI_TXSTOP | MI_TBTT | MI_ATIMWINEND | MI_PMQ | \
136 MI_PHYTXERR | MI_DMAINT | MI_TFS | MI_BG_NOISE | \
137 MI_CCA | MI_TO | MI_GP0 | MI_RFDISABLE | MI_PWRUP)
139 #define RETRY_SHORT_DEF 7 /* Default Short retry Limit */
140 #define RETRY_SHORT_MAX 255 /* Maximum Short retry Limit */
141 #define RETRY_LONG_DEF 4 /* Default Long retry count */
142 #define RETRY_SHORT_FB 3 /* Short retry count for fallback rate */
143 #define RETRY_LONG_FB 2 /* Long retry count for fallback rate */
145 #define MAXTXPKTS 6 /* max # pkts pending */
148 #define MAXTXFRAMEBURST 8 /* vanilla xpress mode: max frames/burst */
149 #define MAXFRAMEBURST_TXOP 10000 /* Frameburst TXOP in usec */
151 /* Per-AC retry limit register definitions; uses bcmdefs.h bitfield macros */
152 #define EDCF_SHORT_S 0
154 #define EDCF_LONG_S 8
155 #define EDCF_LFB_S 12
156 #define EDCF_SHORT_M BITFIELD_MASK(4)
157 #define EDCF_SFB_M BITFIELD_MASK(4)
158 #define EDCF_LONG_M BITFIELD_MASK(4)
159 #define EDCF_LFB_M BITFIELD_MASK(4)
161 #define WLC_WME_RETRY_SHORT_GET(wlc, ac) GFIELD(wlc->wme_retries[ac], EDCF_SHORT)
162 #define WLC_WME_RETRY_SFB_GET(wlc, ac) GFIELD(wlc->wme_retries[ac], EDCF_SFB)
163 #define WLC_WME_RETRY_LONG_GET(wlc, ac) GFIELD(wlc->wme_retries[ac], EDCF_LONG)
164 #define WLC_WME_RETRY_LFB_GET(wlc, ac) GFIELD(wlc->wme_retries[ac], EDCF_LFB)
166 #define WLC_WME_RETRY_SHORT_SET(wlc, ac, val) \
167 (wlc->wme_retries[ac] = SFIELD(wlc->wme_retries[ac], EDCF_SHORT, val))
168 #define WLC_WME_RETRY_SFB_SET(wlc, ac, val) \
169 (wlc->wme_retries[ac] = SFIELD(wlc->wme_retries[ac], EDCF_SFB, val))
170 #define WLC_WME_RETRY_LONG_SET(wlc, ac, val) \
171 (wlc->wme_retries[ac] = SFIELD(wlc->wme_retries[ac], EDCF_LONG, val))
172 #define WLC_WME_RETRY_LFB_SET(wlc, ac, val) \
173 (wlc->wme_retries[ac] = SFIELD(wlc->wme_retries[ac], EDCF_LFB, val))
176 #define WLC_PLLREQ_SHARED 0x1 /* pll is shared on old chips */
177 #define WLC_PLLREQ_RADIO_MON 0x2 /* hold pll for radio monitor register checking */
178 #define WLC_PLLREQ_FLIP 0x4 /* hold/release pll for some short operation */
181 * Macros to check if AP or STA is active.
182 * AP Active means more than just configured: driver and BSS are "up";
183 * that is, we are beaconing/responding as an AP (aps_associated).
184 * STA Active similarly means the driver is up and a configured STA BSS
185 * is up: either associated (stas_associated) or trying.
187 * Macro definitions vary as per AP/STA ifdefs, allowing references to
188 * ifdef'd structure fields and constant values (0) for optimization.
189 * Make sure to enclose blocks of code such that any routines they
190 * reference can also be unused and optimized out by the linker.
192 /* NOTE: References structure fields defined in wlc.h */
193 #define AP_ACTIVE(wlc) (0)
196 * Detect Card removed.
197 * Even checking an sbconfig register read will not false trigger when the core is in reset.
198 * it breaks CF address mechanism. Accessing gphy phyversion will cause SB error if aphy
199 * is in reset on 4306B0-DB. Need a simple accessible reg with fixed 0/1 pattern
200 * (some platforms return all 0).
201 * If clocks are present, call the sb routine which will figure out if the device is removed.
203 #define DEVICEREMOVED(wlc) \
205 ((R_REG(&wlc->hw->regs->maccontrol) & \
206 (MCTL_PSM_JMP_0 | MCTL_IHR_EN)) != MCTL_IHR_EN) : \
207 (ai_deviceremoved(wlc->hw->sih)))
209 #define WLCWLUNIT(wlc) ((wlc)->pub->unit)
211 struct wlc_protection {
212 bool _g; /* use g spec protection, driver internal */
213 s8 g_override; /* override for use of g spec protection */
214 u8 gmode_user; /* user config gmode, operating band->gmode is different */
215 s8 overlap; /* Overlap BSS/IBSS protection for both 11g and 11n */
216 s8 nmode_user; /* user config nmode, operating pub->nmode is different */
217 s8 n_cfg; /* use OFDM protection on MIMO frames */
218 s8 n_cfg_override; /* override for use of N protection */
219 bool nongf; /* non-GF present protection */
220 s8 nongf_override; /* override for use of GF protection */
221 s8 n_pam_override; /* override for preamble: MM or GF */
222 bool n_obss; /* indicated OBSS Non-HT STA present */
225 /* anything affects the single/dual streams/antenna operation */
227 u8 hw_txchain; /* HW txchain bitmap cfg */
228 u8 txchain; /* txchain bitmap being used */
229 u8 txstreams; /* number of txchains being used */
231 u8 hw_rxchain; /* HW rxchain bitmap cfg */
232 u8 rxchain; /* rxchain bitmap being used */
233 u8 rxstreams; /* number of rxchains being used */
235 u8 ant_rx_ovr; /* rx antenna override */
236 s8 txant; /* userTx antenna setting */
237 u16 phytxant; /* phyTx antenna setting in txheader */
239 u8 ss_opmode; /* singlestream Operational mode, 0:siso; 1:cdd */
240 bool ss_algosel_auto; /* if true, use wlc->stf->ss_algo_channel; */
241 /* else use wlc->band->stf->ss_mode_band; */
242 u16 ss_algo_channel; /* ss based on per-channel algo: 0: SISO, 1: CDD 2: STBC */
243 u8 no_cddstbc; /* stf override, 1: no CDD (or STBC) allowed */
245 u8 rxchain_restore_delay; /* delay time to restore default rxchain */
247 s8 ldpc; /* AUTO/ON/OFF ldpc cap supported */
248 u8 txcore[MAX_STREAMS_SUPPORTED + 1]; /* bitmap of selected core for each Nsts */
252 #define WLC_STF_SS_STBC_TX(wlc, scb) \
253 (((wlc)->stf->txstreams > 1) && (((wlc)->band->band_stf_stbc_tx == ON) || \
254 (SCB_STBC_CAP((scb)) && \
255 (wlc)->band->band_stf_stbc_tx == AUTO && \
256 isset(&((wlc)->stf->ss_algo_channel), PHY_TXC1_MODE_STBC))))
258 #define WLC_STBC_CAP_PHY(wlc) (WLCISNPHY(wlc->band) && NREV_GE(wlc->band->phyrev, 3))
260 #define WLC_SGI_CAP_PHY(wlc) ((WLCISNPHY(wlc->band) && NREV_GE(wlc->band->phyrev, 3)) || \
261 WLCISLCNPHY(wlc->band))
263 #define WLC_CHAN_PHYTYPE(x) (((x) & RXS_CHAN_PHYTYPE_MASK) >> RXS_CHAN_PHYTYPE_SHIFT)
264 #define WLC_CHAN_CHANNEL(x) (((x) & RXS_CHAN_ID_MASK) >> RXS_CHAN_ID_SHIFT)
265 #define WLC_RX_CHANNEL(rxh) (WLC_CHAN_CHANNEL((rxh)->RxChan))
267 /* wlc_bss_info flag bit values */
268 #define WLC_BSS_HT 0x0020 /* BSS is HT (MIMO) capable */
270 /* Flags used in wlc_txq_info.stopped */
271 #define TXQ_STOP_FOR_PRIOFC_MASK 0x000000FF /* per prio flow control bits */
272 #define TXQ_STOP_FOR_PKT_DRAIN 0x00000100 /* stop txq enqueue for packet drain */
273 #define TXQ_STOP_FOR_AMPDU_FLOW_CNTRL 0x00000200 /* stop txq enqueue for ampdu flow control */
275 #define WLC_HT_WEP_RESTRICT 0x01 /* restrict HT with WEP */
276 #define WLC_HT_TKIP_RESTRICT 0x02 /* restrict HT with TKIP */
282 uint coreidx; /* # sb enumerated core */
285 uint *txavail[NFIFO]; /* # tx descriptors available */
286 s16 txpktpend[NFIFO]; /* tx admission control */
288 macstat_t *macstat_snapshot; /* mac hw prev read values */
292 * band state (phy+ana+radio)
295 int bandtype; /* WLC_BAND_2G, WLC_BAND_5G */
296 uint bandunit; /* bandstate[] index */
298 u16 phytype; /* phytype */
302 wlc_phy_t *pi; /* pointer to phy specific information */
305 u8 gmode; /* currently active gmode */
307 struct scb *hwrs_scb; /* permanent scb for hw rateset */
309 wlc_rateset_t defrateset; /* band-specific copy of default_bss.rateset */
311 ratespec_t rspec_override; /* 802.11 rate override */
312 ratespec_t mrspec_override; /* multicast rate override */
313 u8 band_stf_ss_mode; /* Configured STF type, 0:siso; 1:cdd */
314 s8 band_stf_stbc_tx; /* STBC TX 0:off; 1:force on; -1:auto */
315 wlc_rateset_t hw_rateset; /* rates supported by chip (phy-specific) */
316 u8 basic_rate[WLC_MAXRATE + 1]; /* basic rates indexed by rate */
317 bool mimo_cap_40; /* 40 MHz cap enabled on this band */
318 s8 antgain; /* antenna gain from srom */
320 u16 CWmin; /* The minimum size of contention window, in unit of aSlotTime */
321 u16 CWmax; /* The maximum size of contention window, in unit of aSlotTime */
322 u16 bcntsfoff; /* beacon tsf offset */
325 /* tx completion callback takes 3 args */
326 typedef void (*pkcb_fn_t) (struct wlc_info *wlc, uint txstatus, void *arg);
329 pkcb_fn_t fn; /* function to call when tx frame completes */
330 void *arg; /* void arg for fn */
331 u8 nextidx; /* index of next call back if threading */
332 bool entered; /* recursion check */
335 /* module control blocks */
337 char name[32]; /* module name : NULL indicates empty array member */
338 const bcm_iovar_t *iovars; /* iovar table */
339 void *hdl; /* handle passed when handler 'doiovar' is called */
340 watchdog_fn_t watchdog_fn; /* watchdog handler */
341 iovar_fn_t iovar_fn; /* iovar handler */
342 down_fn_t down_fn; /* down handler. Note: the int returned
343 * by the down function is a count of the
344 * number of timers that could not be
349 /* dump control blocks */
351 const char *name; /* dump name */
352 dump_fn_t dump_fn; /* 'wl dump' handler */
354 struct dumpcb_s *next;
357 struct edcf_acparam {
361 } __attribute__((packed));
362 typedef struct edcf_acparam edcf_acparam_t;
364 struct wme_param_ie {
371 edcf_acparam_t acparam[AC_COUNT];
372 } __attribute__((packed));
373 typedef struct wme_param_ie wme_param_ie_t;
375 /* virtual interface */
378 u8 type; /* WLC_IFTYPE_BSS or WLC_IFTYPE_WDS */
379 u8 index; /* assigned in wl_add_if(), index of the wlif if any,
380 * not necessarily corresponding to bsscfg._idx or
383 u8 flags; /* flags for the interface */
384 struct wl_if *wlif; /* pointer to wlif */
385 struct wlc_txq_info *qi; /* pointer to associated tx queue */
387 struct scb *scb; /* pointer to scb if WLC_IFTYPE_WDS */
388 struct wlc_bsscfg *bsscfg; /* pointer to bsscfg if WLC_IFTYPE_BSS */
392 /* flags for the interface */
393 #define WLC_IF_LINKED 0x02 /* this interface is linked to a wl_if */
396 int bandtype; /* WLC_BAND_2G, WLC_BAND_5G */
397 uint bandunit; /* bandstate[] index */
398 u16 mhfs[MHFMAX]; /* MHF array shadow */
399 u8 bandhw_stf_ss_mode; /* HW configured STF type, 0:siso; 1:cdd */
404 u16 phytype; /* phytype */
408 wlc_phy_t *pi; /* pointer to phy specific information */
413 bool _piomode; /* true if pio mode */
414 struct wlc_info *wlc;
417 struct dma_pub *di[NFIFO]; /* dma handles, per fifo */
419 uint unit; /* device instance number */
422 u16 vendorid; /* PCI vendor id */
423 u16 deviceid; /* PCI device id */
424 uint corerev; /* core revision */
425 u8 sromrev; /* version # of the srom */
426 u16 boardrev; /* version # of particular board */
427 u32 boardflags; /* Board specific flags from srom */
428 u32 boardflags2; /* More board flags if sromrev >= 4 */
429 u32 machwcap; /* MAC capabilities */
430 u32 machwcap_backup; /* backup of machwcap */
431 u16 ucode_dbgsel; /* dbgsel for ucode debug(config gpio) */
433 si_t *sih; /* SB handle (cookie for siutils calls) */
434 char *vars; /* "environment" name=value */
435 uint vars_size; /* size of vars, free vars on detach */
436 d11regs_t *regs; /* pointer to device registers */
437 void *physhim; /* phy shim layer handler */
438 void *phy_sh; /* pointer to shared phy state */
439 struct wlc_hwband *band;/* pointer to active per-band state */
440 struct wlc_hwband *bandstate[MAXBANDS];/* band state per phy/radio */
441 u16 bmac_phytxant; /* cache of high phytxant state */
442 bool shortslot; /* currently using 11g ShortSlot timing */
443 u16 SRL; /* 802.11 dot11ShortRetryLimit */
444 u16 LRL; /* 802.11 dot11LongRetryLimit */
445 u16 SFBL; /* Short Frame Rate Fallback Limit */
446 u16 LFBL; /* Long Frame Rate Fallback Limit */
448 bool up; /* d11 hardware up and running */
449 uint now; /* # elapsed seconds */
450 uint _nbands; /* # bands supported */
451 chanspec_t chanspec; /* bmac chanspec shadow */
453 uint *txavail[NFIFO]; /* # tx descriptors available */
454 u16 *xmtfifo_sz; /* fifo size in 256B for each xmt fifo */
456 mbool pllreq; /* pll requests to keep PLL on */
458 u8 suspended_fifos; /* Which TX fifo to remain awake for */
459 u32 maccontrol; /* Cached value of maccontrol */
460 uint mac_suspend_depth; /* current depth of mac_suspend levels */
461 u32 wake_override; /* Various conditions to force MAC to WAKE mode */
462 u32 mute_override; /* Prevent ucode from sending beacons */
463 u8 etheraddr[ETH_ALEN]; /* currently configured ethernet address */
464 u32 led_gpio_mask; /* LED GPIO Mask */
465 bool noreset; /* true= do not reset hw, used by WLC_OUT */
466 bool forcefastclk; /* true if the h/w is forcing the use of fast clk */
467 bool clk; /* core is out of reset and has clock */
468 bool sbclk; /* sb has clock */
469 struct bmac_pmq *bmac_pmq; /* bmac PM states derived from ucode PMQ */
470 bool phyclk; /* phy is out of reset and has clock */
471 bool dma_lpbk; /* core is in DMA loopback */
473 bool ucode_loaded; /* true after ucode downloaded */
476 u8 hw_stf_ss_opmode; /* STF single stream operation mode */
477 u8 antsel_type; /* Type of boardlevel mimo antenna switch-logic
478 * 0 = N/A, 1 = 2x4 board, 2 = 2x3 CB2 board
481 * put struct antsel_info here if more info is
486 /* TX Queue information
488 * Each flow of traffic out of the device has a TX Queue with independent
489 * flow control. Several interfaces may be associated with a single TX Queue
490 * if they belong to the same flow of traffic from the device. For multi-channel
491 * operation there are independent TX Queues for each channel.
493 struct wlc_txq_info {
494 struct wlc_txq_info *next;
496 uint stopped; /* tx flow control bits */
500 * Principal common (os-independent) software data structure.
503 struct wlc_pub *pub; /* pointer to wlc public state */
504 struct wl_info *wl; /* pointer to os-specific private state */
505 d11regs_t *regs; /* pointer to device registers */
507 struct wlc_hw_info *hw; /* HW related state used primarily by BMAC */
510 int clkreq_override; /* setting for clkreq for PCIE : Auto, 0, 1 */
511 u16 fastpwrup_dly; /* time in us needed to bring up d11 fast clock */
514 u32 macintstatus; /* bit channel between isr and dpc */
515 u32 macintmask; /* sw runtime master macintmask value */
516 u32 defmacintmask; /* default "on" macintmask value */
519 bool device_present; /* (removable) device is present */
521 bool clk; /* core is out of reset and has clock */
524 struct wlccore *core; /* pointer to active io core */
525 struct wlcband *band; /* pointer to active per-band state */
526 struct wlccore *corestate; /* per-core state (one per hw core) */
527 /* per-band state (one per phy/radio): */
528 struct wlcband *bandstate[MAXBANDS];
530 bool war16165; /* PCI slow clock 16165 war flag */
532 bool tx_suspended; /* data fifos need to remain suspended */
537 uint qvalid; /* DirFrmQValid and BcMcFrmQValid */
539 /* Regulatory power limits */
540 s8 txpwr_local_max; /* regulatory local txpwr max */
541 u8 txpwr_local_constraint; /* local power contraint in dB */
544 struct ampdu_info *ampdu; /* ampdu module handler */
545 struct antsel_info *asi; /* antsel module handler */
546 wlc_cm_info_t *cmi; /* channel manager module handler */
548 uint vars_size; /* size of vars, free vars on detach */
550 u16 vendorid; /* PCI vendor id */
551 u16 deviceid; /* PCI device id */
552 uint ucode_rev; /* microcode revision */
554 u32 machwcap; /* MAC capabilities, BMAC shadow */
556 u8 perm_etheraddr[ETH_ALEN]; /* original sprom local ethernet address */
558 bool bandlocked; /* disable auto multi-band switching */
559 bool bandinit_pending; /* track band init in auto band */
561 bool radio_monitor; /* radio timer is running */
562 bool going_down; /* down path intermediate variable */
564 bool mpc; /* enable minimum power consumption */
565 u8 mpc_dlycnt; /* # of watchdog cnt before turn disable radio */
566 u8 mpc_offcnt; /* # of watchdog cnt that radio is disabled */
567 u8 mpc_delay_off; /* delay radio disable by # of watchdog cnt */
568 u8 prev_non_delay_mpc; /* prev state wlc_is_non_delay_mpc */
571 struct wl_timer *wdtimer; /* timer for watchdog routine */
572 struct wl_timer *radio_timer; /* timer for hw radio button monitor routine */
575 bool monitor; /* monitor (MPDU sniffing) mode */
576 bool bcnmisc_ibss; /* bcns promisc mode override for IBSS */
577 bool bcnmisc_scan; /* bcns promisc mode override for scan */
578 bool bcnmisc_monitor; /* bcns promisc mode override for monitor */
581 bool _rifs; /* enable per-packet rifs */
582 s8 sgi_tx; /* sgi tx */
584 /* AP-STA synchronization, power save */
585 u8 bcn_li_bcn; /* beacon listen interval in # beacons */
586 u8 bcn_li_dtim; /* beacon listen interval in # dtims */
588 bool WDarmed; /* watchdog timer is armed */
589 u32 WDlast; /* last time wlc_watchdog() was called */
592 ac_bitmap_t wme_dp; /* Discard (oldest first) policy per AC */
593 u16 edcf_txop[AC_COUNT]; /* current txop for each ac */
594 wme_param_ie_t wme_param_ie; /* WME parameter info element, which on STA
595 * contains parameters in use locally, and on
596 * AP contains parameters advertised to STA
597 * in beacons and assoc responses.
599 u16 wme_retries[AC_COUNT]; /* per-AC retry limits */
601 u16 tx_prec_map; /* Precedence map based on HW FIFO space */
602 u16 fifo2prec_map[NFIFO]; /* pointer to fifo2_prec map based on WME */
605 * BSS Configurations set of BSS configurations, idx 0 is default and
608 struct wlc_bsscfg *bsscfg[WLC_MAXBSSCFG];
609 struct wlc_bsscfg *cfg; /* the primary bsscfg (can be AP or STA) */
612 struct wlc_txq_info *tx_queues; /* common TX Queue list */
615 wsec_key_t *wsec_keys[WSEC_MAX_KEYS]; /* dynamic key storage */
616 wsec_key_t *wsec_def_keys[WLC_DEFAULT_KEYS]; /* default key storage */
617 bool wsec_swkeys; /* indicates that all keys should be
618 * treated as sw keys (used for debugging)
620 struct modulecb *modulecb;
622 u8 mimoft; /* SIGN or 11N */
623 s8 cck_40txbw; /* 11N, cck tx b/w override when in 40MHZ mode */
624 s8 ofdm_40txbw; /* 11N, ofdm tx b/w override when in 40MHZ mode */
625 s8 mimo_40txbw; /* 11N, mimo tx b/w override when in 40MHZ mode */
626 /* HT CAP IE being advertised by this node: */
627 struct ieee80211_ht_cap ht_cap;
629 wlc_bss_info_t *default_bss; /* configured BSS parameters */
631 u16 mc_fid_counter; /* BC/MC FIFO frame ID counter */
633 char country_default[WLC_CNTRY_BUF_SZ]; /* saved country for leaving 802.11d
636 char autocountry_default[WLC_CNTRY_BUF_SZ]; /* initial country for 802.11d
639 u16 prb_resp_timeout; /* do not send prb resp if request older than this,
643 wlc_rateset_t sup_rates_override; /* use only these rates in 11g supported rates if
647 chanspec_t home_chanspec; /* shared home chanspec */
650 chanspec_t chanspec; /* target operational channel */
651 u16 usr_fragthresh; /* user configured fragmentation threshold */
652 u16 fragthresh[NFIFO]; /* per-fifo fragmentation thresholds */
653 u16 RTSThresh; /* 802.11 dot11RTSThreshold */
654 u16 SRL; /* 802.11 dot11ShortRetryLimit */
655 u16 LRL; /* 802.11 dot11LongRetryLimit */
656 u16 SFBL; /* Short Frame Rate Fallback Limit */
657 u16 LFBL; /* Long Frame Rate Fallback Limit */
660 bool shortslot; /* currently using 11g ShortSlot timing */
661 s8 shortslot_override; /* 11g ShortSlot override */
662 bool include_legacy_erp; /* include Legacy ERP info elt ID 47 as well as g ID 42 */
664 struct wlc_protection *protection;
665 s8 PLCPHdr_override; /* 802.11b Preamble Type override */
669 ratespec_t bcn_rspec; /* save bcn ratespec purpose */
671 uint tempsense_lasttime;
673 u16 tx_duty_cycle_ofdm; /* maximum allowed duty cycle for OFDM */
674 u16 tx_duty_cycle_cck; /* maximum allowed duty cycle for CCK */
678 struct wlc_txq_info *pkt_queue; /* txq for transmit packets */
679 u32 mpc_dur; /* total time (ms) in mpc mode except for the
680 * portion since radio is turned off last time
682 u32 mpc_laston_ts; /* timestamp (ms) when radio is turned off last
688 /* antsel module specific state */
690 struct wlc_info *wlc; /* pointer to main wlc structure */
691 struct wlc_pub *pub; /* pointer to public fn */
692 u8 antsel_type; /* Type of boardlevel mimo antenna switch-logic
693 * 0 = N/A, 1 = 2x4 board, 2 = 2x3 CB2 board
695 u8 antsel_antswitch; /* board level antenna switch type */
696 bool antsel_avail; /* Ant selection availability (SROM based) */
697 wlc_antselcfg_t antcfg_11n; /* antenna configuration */
698 wlc_antselcfg_t antcfg_cur; /* current antenna config (auto) */
701 #define CHANNEL_BANDUNIT(wlc, ch) (((ch) <= CH_MAX_2G_CHANNEL) ? BAND_2G_INDEX : BAND_5G_INDEX)
702 #define OTHERBANDUNIT(wlc) ((uint)((wlc)->band->bandunit ? BAND_2G_INDEX : BAND_5G_INDEX))
704 #define IS_MBAND_UNLOCKED(wlc) \
705 ((NBANDS(wlc) > 1) && !(wlc)->bandlocked)
707 #define WLC_BAND_PI_RADIO_CHANSPEC wlc_phy_chanspec_get(wlc->band->pi)
709 /* sum the individual fifo tx pending packet counts */
710 #define TXPKTPENDTOT(wlc) ((wlc)->core->txpktpend[0] + (wlc)->core->txpktpend[1] + \
711 (wlc)->core->txpktpend[2] + (wlc)->core->txpktpend[3])
712 #define TXPKTPENDGET(wlc, fifo) ((wlc)->core->txpktpend[(fifo)])
713 #define TXPKTPENDINC(wlc, fifo, val) ((wlc)->core->txpktpend[(fifo)] += (val))
714 #define TXPKTPENDDEC(wlc, fifo, val) ((wlc)->core->txpktpend[(fifo)] -= (val))
715 #define TXPKTPENDCLR(wlc, fifo) ((wlc)->core->txpktpend[(fifo)] = 0)
716 #define TXAVAIL(wlc, fifo) (*(wlc)->core->txavail[(fifo)])
717 #define GETNEXTTXP(wlc, _queue) \
718 dma_getnexttxp((wlc)->hw->di[(_queue)], HNDDMA_RANGE_TRANSMITTED)
720 #define WLC_IS_MATCH_SSID(wlc, ssid1, ssid2, len1, len2) \
721 ((len1 == len2) && !memcmp(ssid1, ssid2, len1))
723 extern void wlc_fatal_error(struct wlc_info *wlc);
724 extern void wlc_bmac_rpc_watchdog(struct wlc_info *wlc);
725 extern void wlc_recv(struct wlc_info *wlc, struct sk_buff *p);
726 extern bool wlc_dotxstatus(struct wlc_info *wlc, tx_status_t *txs, u32 frm_tx2);
727 extern void wlc_txfifo(struct wlc_info *wlc, uint fifo, struct sk_buff *p,
728 bool commit, s8 txpktpend);
729 extern void wlc_txfifo_complete(struct wlc_info *wlc, uint fifo, s8 txpktpend);
730 extern void wlc_txq_enq(void *ctx, struct scb *scb, struct sk_buff *sdu,
732 extern void wlc_info_init(struct wlc_info *wlc, int unit);
733 extern void wlc_print_txstatus(tx_status_t *txs);
734 extern int wlc_xmtfifo_sz_get(struct wlc_info *wlc, uint fifo, uint *blocks);
735 extern void wlc_write_template_ram(struct wlc_info *wlc, int offset, int len,
737 extern void wlc_write_hw_bcntemplates(struct wlc_info *wlc, void *bcn, int len,
739 extern void wlc_pllreq(struct wlc_info *wlc, bool set, mbool req_bit);
740 extern void wlc_reset_bmac_done(struct wlc_info *wlc);
743 extern void wlc_print_rxh(d11rxhdr_t *rxh);
744 extern void wlc_print_hdrs(struct wlc_info *wlc, const char *prefix, u8 *frame,
745 d11txh_t *txh, d11rxhdr_t *rxh, uint len);
746 extern void wlc_print_txdesc(d11txh_t *txh);
748 #define wlc_print_txdesc(a)
751 extern void wlc_print_dot11_mac_hdr(u8 *buf, int len);
754 extern void wlc_setxband(struct wlc_hw_info *wlc_hw, uint bandunit);
755 extern void wlc_coredisable(struct wlc_hw_info *wlc_hw);
757 extern bool wlc_valid_rate(struct wlc_info *wlc, ratespec_t rate, int band,
759 extern void wlc_ap_upd(struct wlc_info *wlc);
761 /* helper functions */
762 extern void wlc_shm_ssid_upd(struct wlc_info *wlc, struct wlc_bsscfg *cfg);
763 extern int wlc_set_gmode(struct wlc_info *wlc, u8 gmode, bool config);
765 extern void wlc_mac_bcn_promisc_change(struct wlc_info *wlc, bool promisc);
766 extern void wlc_mac_bcn_promisc(struct wlc_info *wlc);
767 extern void wlc_mac_promisc(struct wlc_info *wlc);
768 extern void wlc_txflowcontrol(struct wlc_info *wlc, struct wlc_txq_info *qi,
770 extern void wlc_txflowcontrol_override(struct wlc_info *wlc,
771 struct wlc_txq_info *qi,
772 bool on, uint override);
773 extern bool wlc_txflowcontrol_prio_isset(struct wlc_info *wlc,
774 struct wlc_txq_info *qi, int prio);
775 extern void wlc_send_q(struct wlc_info *wlc);
776 extern int wlc_prep_pdu(struct wlc_info *wlc, struct sk_buff *pdu, uint *fifo);
778 extern u16 wlc_calc_lsig_len(struct wlc_info *wlc, ratespec_t ratespec,
780 extern ratespec_t wlc_rspec_to_rts_rspec(struct wlc_info *wlc, ratespec_t rspec,
781 bool use_rspec, u16 mimo_ctlchbw);
782 extern u16 wlc_compute_rtscts_dur(struct wlc_info *wlc, bool cts_only,
783 ratespec_t rts_rate, ratespec_t frame_rate,
784 u8 rts_preamble_type,
785 u8 frame_preamble_type, uint frame_len,
788 extern void wlc_tbtt(struct wlc_info *wlc, d11regs_t *regs);
789 extern void wlc_inval_dma_pkts(struct wlc_hw_info *hw,
790 struct ieee80211_sta *sta,
791 void (*dma_callback_fn));
794 extern void wlc_dump_ie(struct wlc_info *wlc, bcm_tlv_t *ie,
795 struct bcmstrbuf *b);
798 extern void wlc_reprate_init(struct wlc_info *wlc);
799 extern void wlc_bsscfg_reprate_init(struct wlc_bsscfg *bsscfg);
801 /* Shared memory access */
802 extern void wlc_write_shm(struct wlc_info *wlc, uint offset, u16 v);
803 extern u16 wlc_read_shm(struct wlc_info *wlc, uint offset);
804 extern void wlc_copyto_shm(struct wlc_info *wlc, uint offset, const void *buf,
807 extern void wlc_update_beacon(struct wlc_info *wlc);
808 extern void wlc_bss_update_beacon(struct wlc_info *wlc,
809 struct wlc_bsscfg *bsscfg);
811 extern void wlc_update_probe_resp(struct wlc_info *wlc, bool suspend);
812 extern void wlc_bss_update_probe_resp(struct wlc_info *wlc,
813 struct wlc_bsscfg *cfg, bool suspend);
815 extern bool wlc_ismpc(struct wlc_info *wlc);
816 extern bool wlc_is_non_delay_mpc(struct wlc_info *wlc);
817 extern void wlc_radio_mpc_upd(struct wlc_info *wlc);
818 extern bool wlc_prec_enq(struct wlc_info *wlc, struct pktq *q, void *pkt,
820 extern bool wlc_prec_enq_head(struct wlc_info *wlc, struct pktq *q,
821 struct sk_buff *pkt, int prec, bool head);
822 extern u16 wlc_phytxctl1_calc(struct wlc_info *wlc, ratespec_t rspec);
823 extern void wlc_compute_plcp(struct wlc_info *wlc, ratespec_t rate, uint length,
825 extern uint wlc_calc_frame_time(struct wlc_info *wlc, ratespec_t ratespec,
826 u8 preamble_type, uint mac_len);
828 extern void wlc_set_chanspec(struct wlc_info *wlc, chanspec_t chanspec);
830 extern bool wlc_timers_init(struct wlc_info *wlc, int unit);
833 extern void wlc_print_ies(struct wlc_info *wlc, u8 *ies, uint ies_len);
836 extern int wlc_set_nmode(struct wlc_info *wlc, s32 nmode);
837 extern void wlc_mimops_action_ht_send(struct wlc_info *wlc,
838 struct wlc_bsscfg *bsscfg,
841 extern void wlc_switch_shortslot(struct wlc_info *wlc, bool shortslot);
842 extern void wlc_set_bssid(struct wlc_bsscfg *cfg);
843 extern void wlc_edcf_setparams(struct wlc_info *wlc, bool suspend);
845 extern void wlc_set_ratetable(struct wlc_info *wlc);
846 extern int wlc_set_mac(struct wlc_bsscfg *cfg);
847 extern void wlc_beacon_phytxctl_txant_upd(struct wlc_info *wlc,
848 ratespec_t bcn_rate);
849 extern void wlc_mod_prb_rsp_rate_table(struct wlc_info *wlc, uint frame_len);
850 extern ratespec_t wlc_lowest_basic_rspec(struct wlc_info *wlc,
852 extern void wlc_radio_disable(struct wlc_info *wlc);
853 extern void wlc_bcn_li_upd(struct wlc_info *wlc);
854 extern void wlc_set_home_chanspec(struct wlc_info *wlc, chanspec_t chanspec);
855 extern bool wlc_ps_allowed(struct wlc_info *wlc);
856 extern bool wlc_stay_awake(struct wlc_info *wlc);
857 extern void wlc_wme_initparams_sta(struct wlc_info *wlc, wme_param_ie_t *pe);