staging: brcm80211: cleanup of transmit buffer size related wrapper function
[zen-stable.git] / drivers / staging / brcm80211 / brcmsmac / main.h
bloba71c509910967e153853d6be0e3ca36f85e3c82e
1 /*
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.
17 #ifndef _BRCM_MAIN_H_
18 #define _BRCM_MAIN_H_
20 #include <linux/etherdevice.h>
22 #include <brcmu_utils.h>
23 #include "types.h"
24 #include "d11.h"
25 #include "scb.h"
27 #define INVCHANNEL 255 /* invalid channel */
29 /* max # brcms_c_module_register() calls */
30 #define BRCMS_MAXMODULES 22
32 #define SEQNUM_SHIFT 4
33 #define SEQNUM_MAX 0x1000
35 #define NTXRATE 64 /* # tx MPDUs rate is reported for */
37 /* Maximum wait time for a MAC suspend */
38 /* uS: 83mS is max packet time (64KB ampdu @ 6Mbps) */
39 #define BRCMS_MAX_MAC_SUSPEND 83000
41 /* responses for probe requests older that this are tossed, zero to disable */
42 #define BRCMS_PRB_RESP_TIMEOUT 0 /* Disable probe response timeout */
44 /* transmit buffer max headroom for protocol headers */
45 #define TXOFF (D11_TXH_LEN + D11_PHY_HDR_LEN)
47 #define AC_COUNT 4
49 /* Macros for doing definition and get/set of bitfields
50 * Usage example, e.g. a three-bit field (bits 4-6):
51 * #define <NAME>_M BITFIELD_MASK(3)
52 * #define <NAME>_S 4
53 * ...
54 * regval = R_REG(osh, &regs->regfoo);
55 * field = GFIELD(regval, <NAME>);
56 * regval = SFIELD(regval, <NAME>, 1);
57 * W_REG(osh, &regs->regfoo, regval);
59 #define BITFIELD_MASK(width) \
60 (((unsigned)1 << (width)) - 1)
61 #define GFIELD(val, field) \
62 (((val) >> field ## _S) & field ## _M)
63 #define SFIELD(val, field, bits) \
64 (((val) & (~(field ## _M << field ## _S))) | \
65 ((unsigned)(bits) << field ## _S))
67 #define SW_TIMER_MAC_STAT_UPD 30 /* periodic MAC stats update */
69 /* max # supported core revisions (0 .. MAXCOREREV - 1) */
70 #define MAXCOREREV 28
72 /* Double check that unsupported cores are not enabled */
73 #if CONF_MSK(D11CONF, 0x4f) || CONF_GE(D11CONF, MAXCOREREV)
74 #error "Configuration for D11CONF includes unsupported versions."
75 #endif /* Bad versions */
77 /* values for shortslot_override */
78 #define BRCMS_SHORTSLOT_AUTO -1 /* Driver will manage Shortslot setting */
79 #define BRCMS_SHORTSLOT_OFF 0 /* Turn off short slot */
80 #define BRCMS_SHORTSLOT_ON 1 /* Turn on short slot */
82 /* value for short/long and mixmode/greenfield preamble */
83 #define BRCMS_LONG_PREAMBLE (0)
84 #define BRCMS_SHORT_PREAMBLE (1 << 0)
85 #define BRCMS_GF_PREAMBLE (1 << 1)
86 #define BRCMS_MM_PREAMBLE (1 << 2)
87 #define BRCMS_IS_MIMO_PREAMBLE(_pre) (((_pre) == BRCMS_GF_PREAMBLE) || \
88 ((_pre) == BRCMS_MM_PREAMBLE))
90 /* TxFrameID */
91 /* seq and frag bits: SEQNUM_SHIFT, FRAGNUM_MASK (802.11.h) */
92 /* rate epoch bits: TXFID_RATE_SHIFT, TXFID_RATE_MASK ((wlc_rate.c) */
93 #define TXFID_QUEUE_MASK 0x0007 /* Bits 0-2 */
94 #define TXFID_SEQ_MASK 0x7FE0 /* Bits 5-15 */
95 #define TXFID_SEQ_SHIFT 5 /* Number of bit shifts */
96 #define TXFID_RATE_PROBE_MASK 0x8000 /* Bit 15 for rate probe */
97 #define TXFID_RATE_MASK 0x0018 /* Mask for bits 3 and 4 */
98 #define TXFID_RATE_SHIFT 3 /* Shift 3 bits for rate mask */
100 /* promote boardrev */
101 #define BOARDREV_PROMOTABLE 0xFF /* from */
102 #define BOARDREV_PROMOTED 1 /* to */
104 #define DATA_BLOCK_TX_SUPR (1 << 4)
106 /* 802.1D Priority to TX FIFO number for wme */
107 extern const u8 prio2fifo[];
109 /* Ucode MCTL_WAKE override bits */
110 #define BRCMS_WAKE_OVERRIDE_CLKCTL 0x01
111 #define BRCMS_WAKE_OVERRIDE_PHYREG 0x02
112 #define BRCMS_WAKE_OVERRIDE_MACSUSPEND 0x04
113 #define BRCMS_WAKE_OVERRIDE_TXFIFO 0x08
114 #define BRCMS_WAKE_OVERRIDE_FORCEFAST 0x10
116 /* stuff pulled in from wlc.c */
118 /* Interrupt bit error summary. Don't include I_RU: we refill DMA at other
119 * times; and if we run out, constant I_RU interrupts may cause lockup. We
120 * will still get error counts from rx0ovfl.
122 #define I_ERRORS (I_PC | I_PD | I_DE | I_RO | I_XU)
123 /* default software intmasks */
124 #define DEF_RXINTMASK (I_RI) /* enable rx int on rxfifo only */
125 #define DEF_MACINTMASK (MI_TXSTOP | MI_TBTT | MI_ATIMWINEND | MI_PMQ | \
126 MI_PHYTXERR | MI_DMAINT | MI_TFS | MI_BG_NOISE | \
127 MI_CCA | MI_TO | MI_GP0 | MI_RFDISABLE | MI_PWRUP)
129 #define MAXTXPKTS 6 /* max # pkts pending */
131 /* frameburst */
132 #define MAXTXFRAMEBURST 8 /* vanilla xpress mode: max frames/burst */
133 #define MAXFRAMEBURST_TXOP 10000 /* Frameburst TXOP in usec */
135 #define NFIFO 6 /* # tx/rx fifopairs */
137 /* PLL requests */
139 /* pll is shared on old chips */
140 #define BRCMS_PLLREQ_SHARED 0x1
141 /* hold pll for radio monitor register checking */
142 #define BRCMS_PLLREQ_RADIO_MON 0x2
143 /* hold/release pll for some short operation */
144 #define BRCMS_PLLREQ_FLIP 0x4
146 #define CHANNEL_BANDUNIT(wlc, ch) \
147 (((ch) <= CH_MAX_2G_CHANNEL) ? BAND_2G_INDEX : BAND_5G_INDEX)
149 #define OTHERBANDUNIT(wlc) \
150 ((uint)((wlc)->band->bandunit ? BAND_2G_INDEX : BAND_5G_INDEX))
153 * 802.11 protection information
155 * _g: use g spec protection, driver internal.
156 * g_override: override for use of g spec protection.
157 * gmode_user: user config gmode, operating band->gmode is different.
158 * overlap: Overlap BSS/IBSS protection for both 11g and 11n.
159 * nmode_user: user config nmode, operating pub->nmode is different.
160 * n_cfg: use OFDM protection on MIMO frames.
161 * n_cfg_override: override for use of N protection.
162 * nongf: non-GF present protection.
163 * nongf_override: override for use of GF protection.
164 * n_pam_override: override for preamble: MM or GF.
165 * n_obss: indicated OBSS Non-HT STA present.
167 struct brcms_protection {
168 bool _g;
169 s8 g_override;
170 u8 gmode_user;
171 s8 overlap;
172 s8 nmode_user;
173 s8 n_cfg;
174 s8 n_cfg_override;
175 bool nongf;
176 s8 nongf_override;
177 s8 n_pam_override;
178 bool n_obss;
182 * anything affecting the single/dual streams/antenna operation
184 * hw_txchain: HW txchain bitmap cfg.
185 * txchain: txchain bitmap being used.
186 * txstreams: number of txchains being used.
187 * hw_rxchain: HW rxchain bitmap cfg.
188 * rxchain: rxchain bitmap being used.
189 * rxstreams: number of rxchains being used.
190 * ant_rx_ovr: rx antenna override.
191 * txant: userTx antenna setting.
192 * phytxant: phyTx antenna setting in txheader.
193 * ss_opmode: singlestream Operational mode, 0:siso; 1:cdd.
194 * ss_algosel_auto: if true, use wlc->stf->ss_algo_channel;
195 * else use wlc->band->stf->ss_mode_band.
196 * ss_algo_channel: ss based on per-channel algo: 0: SISO, 1: CDD 2: STBC.
197 * rxchain_restore_delay: delay time to restore default rxchain.
198 * ldpc: AUTO/ON/OFF ldpc cap supported.
199 * txcore[MAX_STREAMS_SUPPORTED + 1]: bitmap of selected core for each Nsts.
200 * spatial_policy:
202 struct brcms_stf {
203 u8 hw_txchain;
204 u8 txchain;
205 u8 txstreams;
206 u8 hw_rxchain;
207 u8 rxchain;
208 u8 rxstreams;
209 u8 ant_rx_ovr;
210 s8 txant;
211 u16 phytxant;
212 u8 ss_opmode;
213 bool ss_algosel_auto;
214 u16 ss_algo_channel;
215 u8 rxchain_restore_delay;
216 s8 ldpc;
217 u8 txcore[MAX_STREAMS_SUPPORTED + 1];
218 s8 spatial_policy;
221 #define BRCMS_STF_SS_STBC_TX(wlc, scb) \
222 (((wlc)->stf->txstreams > 1) && (((wlc)->band->band_stf_stbc_tx == ON) \
223 || (((scb)->flags & SCB_STBCCAP) && \
224 (wlc)->band->band_stf_stbc_tx == AUTO && \
225 isset(&((wlc)->stf->ss_algo_channel), PHY_TXC1_MODE_STBC))))
227 #define BRCMS_STBC_CAP_PHY(wlc) (BRCMS_ISNPHY(wlc->band) && \
228 NREV_GE(wlc->band->phyrev, 3))
230 #define BRCMS_SGI_CAP_PHY(wlc) ((BRCMS_ISNPHY(wlc->band) && \
231 NREV_GE(wlc->band->phyrev, 3)) || \
232 BRCMS_ISLCNPHY(wlc->band))
234 #define BRCMS_CHAN_PHYTYPE(x) (((x) & RXS_CHAN_PHYTYPE_MASK) \
235 >> RXS_CHAN_PHYTYPE_SHIFT)
236 #define BRCMS_CHAN_CHANNEL(x) (((x) & RXS_CHAN_ID_MASK) \
237 >> RXS_CHAN_ID_SHIFT)
240 * core state (mac)
242 struct brcms_core {
243 uint coreidx; /* # sb enumerated core */
245 /* fifo */
246 uint *txavail[NFIFO]; /* # tx descriptors available */
247 s16 txpktpend[NFIFO]; /* tx admission control */
249 struct macstat *macstat_snapshot; /* mac hw prev read values */
253 * band state (phy+ana+radio)
255 struct brcms_band {
256 int bandtype; /* BRCM_BAND_2G, BRCM_BAND_5G */
257 uint bandunit; /* bandstate[] index */
259 u16 phytype; /* phytype */
260 u16 phyrev;
261 u16 radioid;
262 u16 radiorev;
263 struct brcms_phy_pub *pi; /* pointer to phy specific information */
264 bool abgphy_encore;
266 u8 gmode; /* currently active gmode */
268 struct scb *hwrs_scb; /* permanent scb for hw rateset */
270 /* band-specific copy of default_bss.rateset */
271 struct brcms_c_rateset defrateset;
273 u8 band_stf_ss_mode; /* Configured STF type, 0:siso; 1:cdd */
274 s8 band_stf_stbc_tx; /* STBC TX 0:off; 1:force on; -1:auto */
275 /* rates supported by chip (phy-specific) */
276 struct brcms_c_rateset hw_rateset;
277 u8 basic_rate[BRCM_MAXRATE + 1]; /* basic rates indexed by rate */
278 bool mimo_cap_40; /* 40 MHz cap enabled on this band */
279 s8 antgain; /* antenna gain from srom */
281 u16 CWmin; /* minimum size of contention window, in unit of aSlotTime */
282 u16 CWmax; /* maximum size of contention window, in unit of aSlotTime */
283 struct ieee80211_supported_band band;
286 /* module control blocks */
287 struct modulecb {
288 /* module name : NULL indicates empty array member */
289 char name[32];
290 /* handle passed when handler 'doiovar' is called */
291 struct brcms_info *hdl;
293 int (*down_fn)(void *handle); /* down handler. Note: the int returned
294 * by the down function is a count of the
295 * number of timers that could not be
296 * freed.
301 struct brcms_hw_band {
302 int bandtype; /* BRCM_BAND_2G, BRCM_BAND_5G */
303 uint bandunit; /* bandstate[] index */
304 u16 mhfs[MHFMAX]; /* MHF array shadow */
305 u8 bandhw_stf_ss_mode; /* HW configured STF type, 0:siso; 1:cdd */
306 u16 CWmin;
307 u16 CWmax;
308 u32 core_flags;
310 u16 phytype; /* phytype */
311 u16 phyrev;
312 u16 radioid;
313 u16 radiorev;
314 struct brcms_phy_pub *pi; /* pointer to phy specific information */
315 bool abgphy_encore;
318 struct brcms_hardware {
319 bool _piomode; /* true if pio mode */
320 struct brcms_c_info *wlc;
322 /* fifo */
323 struct dma_pub *di[NFIFO]; /* dma handles, per fifo */
325 uint unit; /* device instance number */
327 /* version info */
328 u16 vendorid; /* PCI vendor id */
329 u16 deviceid; /* PCI device id */
330 uint corerev; /* core revision */
331 u8 sromrev; /* version # of the srom */
332 u16 boardrev; /* version # of particular board */
333 u32 boardflags; /* Board specific flags from srom */
334 u32 boardflags2; /* More board flags if sromrev >= 4 */
335 u32 machwcap; /* MAC capabilities */
336 u32 machwcap_backup; /* backup of machwcap */
338 struct si_pub *sih; /* SI handle (cookie for siutils calls) */
339 char *vars; /* "environment" name=value */
340 uint vars_size; /* size of vars, free vars on detach */
341 struct d11regs __iomem *regs; /* pointer to device registers */
342 struct phy_shim_info *physhim; /* phy shim layer handler */
343 struct shared_phy *phy_sh; /* pointer to shared phy state */
344 struct brcms_hw_band *band;/* pointer to active per-band state */
345 /* band state per phy/radio */
346 struct brcms_hw_band *bandstate[MAXBANDS];
347 u16 bmac_phytxant; /* cache of high phytxant state */
348 bool shortslot; /* currently using 11g ShortSlot timing */
349 u16 SRL; /* 802.11 dot11ShortRetryLimit */
350 u16 LRL; /* 802.11 dot11LongRetryLimit */
351 u16 SFBL; /* Short Frame Rate Fallback Limit */
352 u16 LFBL; /* Long Frame Rate Fallback Limit */
354 bool up; /* d11 hardware up and running */
355 uint now; /* # elapsed seconds */
356 uint _nbands; /* # bands supported */
357 u16 chanspec; /* bmac chanspec shadow */
359 uint *txavail[NFIFO]; /* # tx descriptors available */
360 const u16 *xmtfifo_sz; /* fifo size in 256B for each xmt fifo */
362 u32 pllreq; /* pll requests to keep PLL on */
364 u8 suspended_fifos; /* Which TX fifo to remain awake for */
365 u32 maccontrol; /* Cached value of maccontrol */
366 uint mac_suspend_depth; /* current depth of mac_suspend levels */
367 u32 wake_override; /* bit flags to force MAC to WAKE mode */
368 u32 mute_override; /* Prevent ucode from sending beacons */
369 u8 etheraddr[ETH_ALEN]; /* currently configured ethernet address */
370 bool noreset; /* true= do not reset hw, used by WLC_OUT */
371 bool forcefastclk; /* true if h/w is forcing to use fast clk */
372 bool clk; /* core is out of reset and has clock */
373 bool sbclk; /* sb has clock */
374 bool phyclk; /* phy is out of reset and has clock */
376 bool ucode_loaded; /* true after ucode downloaded */
379 u8 hw_stf_ss_opmode; /* STF single stream operation mode */
380 u8 antsel_type; /* Type of boardlevel mimo antenna switch-logic
381 * 0 = N/A, 1 = 2x4 board, 2 = 2x3 CB2 board
383 u32 antsel_avail; /*
384 * put struct antsel_info here if more info is
385 * needed
389 /* TX Queue information
391 * Each flow of traffic out of the device has a TX Queue with independent
392 * flow control. Several interfaces may be associated with a single TX Queue
393 * if they belong to the same flow of traffic from the device. For multi-channel
394 * operation there are independent TX Queues for each channel.
396 struct brcms_txq_info {
397 struct brcms_txq_info *next;
398 struct pktq q;
399 uint stopped; /* tx flow control bits */
403 * Principal common driver data structure.
405 * pub: pointer to driver public state.
406 * wl: pointer to specific private state.
407 * regs: pointer to device registers.
408 * hw: HW related state.
409 * clkreq_override: setting for clkreq for PCIE : Auto, 0, 1.
410 * fastpwrup_dly: time in us needed to bring up d11 fast clock.
411 * macintstatus: bit channel between isr and dpc.
412 * macintmask: sw runtime master macintmask value.
413 * defmacintmask: default "on" macintmask value.
414 * clk: core is out of reset and has clock.
415 * core: pointer to active io core.
416 * band: pointer to active per-band state.
417 * corestate: per-core state (one per hw core).
418 * bandstate: per-band state (one per phy/radio).
419 * qvalid: DirFrmQValid and BcMcFrmQValid.
420 * ampdu: ampdu module handler.
421 * asi: antsel module handler.
422 * cmi: channel manager module handler.
423 * vars_size: size of vars, free vars on detach.
424 * vendorid: PCI vendor id.
425 * deviceid: PCI device id.
426 * ucode_rev: microcode revision.
427 * machwcap: MAC capabilities, BMAC shadow.
428 * perm_etheraddr: original sprom local ethernet address.
429 * bandlocked: disable auto multi-band switching.
430 * bandinit_pending: track band init in auto band.
431 * radio_monitor: radio timer is running.
432 * going_down: down path intermediate variable.
433 * mpc: enable minimum power consumption.
434 * mpc_dlycnt: # of watchdog cnt before turn disable radio.
435 * mpc_offcnt: # of watchdog cnt that radio is disabled.
436 * mpc_delay_off: delay radio disable by # of watchdog cnt.
437 * prev_non_delay_mpc: prev state brcms_c_is_non_delay_mpc.
438 * wdtimer: timer for watchdog routine.
439 * radio_timer: timer for hw radio button monitor routine.
440 * monitor: monitor (MPDU sniffing) mode.
441 * bcnmisc_monitor: bcns promisc mode override for monitor.
442 * _rifs: enable per-packet rifs.
443 * bcn_li_bcn: beacon listen interval in # beacons.
444 * bcn_li_dtim: beacon listen interval in # dtims.
445 * WDarmed: watchdog timer is armed.
446 * WDlast: last time wlc_watchdog() was called.
447 * edcf_txop[AC_COUNT]: current txop for each ac.
448 * wme_retries: per-AC retry limits.
449 * tx_prec_map: Precedence map based on HW FIFO space.
450 * fifo2prec_map[NFIFO]: pointer to fifo2_prec map based on WME.
451 * bsscfg: set of BSS configurations, idx 0 is default and always valid.
452 * cfg: the primary bsscfg (can be AP or STA).
453 * tx_queues: common TX Queue list.
454 * modulecb:
455 * mimoft: SIGN or 11N.
456 * cck_40txbw: 11N, cck tx b/w override when in 40MHZ mode.
457 * ofdm_40txbw: 11N, ofdm tx b/w override when in 40MHZ mode.
458 * mimo_40txbw: 11N, mimo tx b/w override when in 40MHZ mode.
459 * default_bss: configured BSS parameters.
460 * mc_fid_counter: BC/MC FIFO frame ID counter.
461 * country_default: saved country for leaving 802.11d auto-country mode.
462 * autocountry_default: initial country for 802.11d auto-country mode.
463 * prb_resp_timeout: do not send prb resp if request older
464 * than this, 0 = disable.
465 * home_chanspec: shared home chanspec.
466 * chanspec: target operational channel.
467 * usr_fragthresh: user configured fragmentation threshold.
468 * fragthresh[NFIFO]: per-fifo fragmentation thresholds.
469 * RTSThresh: 802.11 dot11RTSThreshold.
470 * SRL: 802.11 dot11ShortRetryLimit.
471 * LRL: 802.11 dot11LongRetryLimit.
472 * SFBL: Short Frame Rate Fallback Limit.
473 * LFBL: Long Frame Rate Fallback Limit.
474 * shortslot: currently using 11g ShortSlot timing.
475 * shortslot_override: 11g ShortSlot override.
476 * include_legacy_erp: include Legacy ERP info elt ID 47 as well as g ID 42.
477 * PLCPHdr_override: 802.11b Preamble Type override.
478 * stf:
479 * bcn_rspec: save bcn ratespec purpose.
480 * tempsense_lasttime;
481 * tx_duty_cycle_ofdm: maximum allowed duty cycle for OFDM.
482 * tx_duty_cycle_cck: maximum allowed duty cycle for CCK.
483 * pkt_queue: txq for transmit packets.
484 * wiphy:
485 * pri_scb: primary Station Control Block
487 struct brcms_c_info {
488 struct brcms_pub *pub;
489 struct brcms_info *wl;
490 struct d11regs __iomem *regs;
491 struct brcms_hardware *hw;
493 /* clock */
494 u16 fastpwrup_dly;
496 /* interrupt */
497 u32 macintstatus;
498 u32 macintmask;
499 u32 defmacintmask;
501 bool clk;
503 /* multiband */
504 struct brcms_core *core;
505 struct brcms_band *band;
506 struct brcms_core *corestate;
507 struct brcms_band *bandstate[MAXBANDS];
509 /* packet queue */
510 uint qvalid;
512 struct ampdu_info *ampdu;
513 struct antsel_info *asi;
514 struct brcms_cm_info *cmi;
516 uint vars_size;
518 u16 vendorid;
519 u16 deviceid;
520 uint ucode_rev;
522 u32 machwcap;
524 u8 perm_etheraddr[ETH_ALEN];
526 bool bandlocked;
527 bool bandinit_pending;
529 bool radio_monitor;
530 bool going_down;
532 bool mpc;
533 u8 mpc_dlycnt;
534 u8 mpc_offcnt;
535 u8 mpc_delay_off;
536 u8 prev_non_delay_mpc;
538 struct brcms_timer *wdtimer;
539 struct brcms_timer *radio_timer;
541 /* promiscuous */
542 bool monitor;
543 bool bcnmisc_monitor;
545 /* driver feature */
546 bool _rifs;
548 /* AP-STA synchronization, power save */
549 u8 bcn_li_bcn;
550 u8 bcn_li_dtim;
552 bool WDarmed;
553 u32 WDlast;
555 /* WME */
556 u16 edcf_txop[AC_COUNT];
558 u16 wme_retries[AC_COUNT];
559 u16 tx_prec_map;
560 u16 fifo2prec_map[NFIFO];
562 struct brcms_bss_cfg *bsscfg;
564 /* tx queue */
565 struct brcms_txq_info *tx_queues;
567 struct modulecb *modulecb;
569 u8 mimoft;
570 s8 cck_40txbw;
571 s8 ofdm_40txbw;
572 s8 mimo_40txbw;
574 struct brcms_bss_info *default_bss;
576 u16 mc_fid_counter;
578 char country_default[BRCM_CNTRY_BUF_SZ];
579 char autocountry_default[BRCM_CNTRY_BUF_SZ];
580 u16 prb_resp_timeout;
582 u16 home_chanspec;
584 /* PHY parameters */
585 u16 chanspec;
586 u16 usr_fragthresh;
587 u16 fragthresh[NFIFO];
588 u16 RTSThresh;
589 u16 SRL;
590 u16 LRL;
591 u16 SFBL;
592 u16 LFBL;
594 /* network config */
595 bool shortslot;
596 s8 shortslot_override;
597 bool include_legacy_erp;
599 struct brcms_protection *protection;
600 s8 PLCPHdr_override;
602 struct brcms_stf *stf;
604 u32 bcn_rspec;
606 uint tempsense_lasttime;
608 u16 tx_duty_cycle_ofdm;
609 u16 tx_duty_cycle_cck;
611 struct brcms_txq_info *pkt_queue;
612 struct wiphy *wiphy;
613 struct scb pri_scb;
616 /* antsel module specific state */
617 struct antsel_info {
618 struct brcms_c_info *wlc; /* pointer to main wlc structure */
619 struct brcms_pub *pub; /* pointer to public fn */
620 u8 antsel_type; /* Type of boardlevel mimo antenna switch-logic
621 * 0 = N/A, 1 = 2x4 board, 2 = 2x3 CB2 board
623 u8 antsel_antswitch; /* board level antenna switch type */
624 bool antsel_avail; /* Ant selection availability (SROM based) */
625 struct brcms_antselcfg antcfg_11n; /* antenna configuration */
626 struct brcms_antselcfg antcfg_cur; /* current antenna config (auto) */
630 * BSS configuration state
632 * wlc: wlc to which this bsscfg belongs to.
633 * up: is this configuration up operational
634 * enable: is this configuration enabled
635 * associated: is BSS in ASSOCIATED state
636 * BSS: infraustructure or adhoc
637 * SSID_len: the length of SSID
638 * SSID: SSID string
641 * BSSID: BSSID (associated)
642 * cur_etheraddr: h/w address
643 * flags: BSSCFG flags; see below
645 * current_bss: BSS parms in ASSOCIATED state
648 * ID: 'unique' ID of this bsscfg, assigned at bsscfg allocation
650 struct brcms_bss_cfg {
651 struct brcms_c_info *wlc;
652 bool up;
653 bool enable;
654 bool associated;
655 bool BSS;
656 u8 SSID_len;
657 u8 SSID[IEEE80211_MAX_SSID_LEN];
658 u8 BSSID[ETH_ALEN];
659 u8 cur_etheraddr[ETH_ALEN];
660 struct brcms_bss_info *current_bss;
663 extern void brcms_c_fatal_error(struct brcms_c_info *wlc);
664 extern void brcms_b_rpc_watchdog(struct brcms_c_info *wlc);
665 extern void brcms_c_recv(struct brcms_c_info *wlc, struct sk_buff *p);
666 extern void brcms_c_txfifo(struct brcms_c_info *wlc, uint fifo,
667 struct sk_buff *p,
668 bool commit, s8 txpktpend);
669 extern void brcms_c_txfifo_complete(struct brcms_c_info *wlc, uint fifo,
670 s8 txpktpend);
671 extern void brcms_c_txq_enq(struct brcms_c_info *wlc, struct scb *scb,
672 struct sk_buff *sdu, uint prec);
673 extern void brcms_c_info_init(struct brcms_c_info *wlc, int unit);
674 extern void brcms_c_print_txstatus(struct tx_status *txs);
675 extern int brcms_b_xmtfifo_sz_get(struct brcms_hardware *wlc_hw, uint fifo,
676 uint *blocks);
677 extern void brcms_c_write_template_ram(struct brcms_c_info *wlc, int offset,
678 int len, void *buf);
679 extern void brcms_c_pllreq(struct brcms_c_info *wlc, bool set, u32 req_bit);
681 #if defined(BCMDBG)
682 extern void brcms_c_print_rxh(struct d11rxhdr *rxh);
683 extern void brcms_c_print_txdesc(struct d11txh *txh);
684 #else
685 #define brcms_c_print_txdesc(a)
686 #endif
688 extern void brcms_c_setxband(struct brcms_hardware *wlc_hw, uint bandunit);
689 extern void brcms_c_coredisable(struct brcms_hardware *wlc_hw);
691 extern bool brcms_c_valid_rate(struct brcms_c_info *wlc, u32 rate,
692 int band, bool verbose);
693 extern void brcms_c_ap_upd(struct brcms_c_info *wlc);
695 /* helper functions */
696 extern void brcms_c_shm_ssid_upd(struct brcms_c_info *wlc,
697 struct brcms_bss_cfg *cfg);
698 extern int brcms_c_set_gmode(struct brcms_c_info *wlc, u8 gmode, bool config);
700 extern void brcms_c_mac_bcn_promisc_change(struct brcms_c_info *wlc,
701 bool promisc);
702 extern void brcms_c_mac_bcn_promisc(struct brcms_c_info *wlc);
703 extern void brcms_c_mac_promisc(struct brcms_c_info *wlc);
704 extern void brcms_c_txflowcontrol(struct brcms_c_info *wlc,
705 struct brcms_txq_info *qi,
706 bool on, int prio);
707 extern void brcms_c_txflowcontrol_override(struct brcms_c_info *wlc,
708 struct brcms_txq_info *qi,
709 bool on, uint override);
710 extern bool brcms_c_txflowcontrol_prio_isset(struct brcms_c_info *wlc,
711 struct brcms_txq_info *qi,
712 int prio);
713 extern void brcms_c_send_q(struct brcms_c_info *wlc);
714 extern int brcms_c_prep_pdu(struct brcms_c_info *wlc, struct sk_buff *pdu,
715 uint *fifo);
717 extern u16 brcms_c_calc_lsig_len(struct brcms_c_info *wlc, u32 ratespec,
718 uint mac_len);
719 extern u32 brcms_c_rspec_to_rts_rspec(struct brcms_c_info *wlc,
720 u32 rspec,
721 bool use_rspec, u16 mimo_ctlchbw);
722 extern u16 brcms_c_compute_rtscts_dur(struct brcms_c_info *wlc, bool cts_only,
723 u32 rts_rate,
724 u32 frame_rate,
725 u8 rts_preamble_type,
726 u8 frame_preamble_type, uint frame_len,
727 bool ba);
729 extern void brcms_c_tbtt(struct brcms_c_info *wlc);
730 extern void brcms_c_inval_dma_pkts(struct brcms_hardware *hw,
731 struct ieee80211_sta *sta,
732 void (*dma_callback_fn));
734 /* Shared memory access */
735 extern void brcms_c_copyto_shm(struct brcms_c_info *wlc, uint offset,
736 const void *buf, int len);
738 extern void brcms_c_update_beacon(struct brcms_c_info *wlc);
740 extern void brcms_c_update_probe_resp(struct brcms_c_info *wlc, bool suspend);
741 extern void brcms_c_bss_update_probe_resp(struct brcms_c_info *wlc,
742 struct brcms_bss_cfg *cfg,
743 bool suspend);
744 extern bool brcms_c_ismpc(struct brcms_c_info *wlc);
745 extern bool brcms_c_is_non_delay_mpc(struct brcms_c_info *wlc);
746 extern void brcms_c_radio_mpc_upd(struct brcms_c_info *wlc);
747 extern bool brcms_c_prec_enq_head(struct brcms_c_info *wlc, struct pktq *q,
748 struct sk_buff *pkt, int prec, bool head);
749 extern u16 brcms_c_phytxctl1_calc(struct brcms_c_info *wlc, u32 rspec);
750 extern void brcms_c_compute_plcp(struct brcms_c_info *wlc, u32 rate,
751 uint length, u8 *plcp);
752 extern uint brcms_c_calc_frame_time(struct brcms_c_info *wlc,
753 u32 ratespec,
754 u8 preamble_type, uint mac_len);
756 extern void brcms_c_set_chanspec(struct brcms_c_info *wlc,
757 u16 chanspec);
759 extern bool brcms_c_timers_init(struct brcms_c_info *wlc, int unit);
761 extern int brcms_c_set_nmode(struct brcms_c_info *wlc);
762 extern void brcms_c_mimops_action_ht_send(struct brcms_c_info *wlc,
763 struct brcms_bss_cfg *bsscfg,
764 u8 mimops_mode);
766 extern void brcms_c_switch_shortslot(struct brcms_c_info *wlc, bool shortslot);
767 extern void brcms_c_set_bssid(struct brcms_bss_cfg *cfg);
768 extern void brcms_c_edcf_setparams(struct brcms_c_info *wlc, bool suspend);
770 extern void brcms_c_set_ratetable(struct brcms_c_info *wlc);
771 extern int brcms_c_set_mac(struct brcms_bss_cfg *cfg);
772 extern void brcms_c_beacon_phytxctl_txant_upd(struct brcms_c_info *wlc,
773 u32 bcn_rate);
774 extern void brcms_c_mod_prb_rsp_rate_table(struct brcms_c_info *wlc,
775 uint frame_len);
776 extern u32 brcms_c_lowest_basic_rspec(struct brcms_c_info *wlc,
777 struct brcms_c_rateset *rs);
778 extern void brcms_c_radio_disable(struct brcms_c_info *wlc);
779 extern void brcms_c_bcn_li_upd(struct brcms_c_info *wlc);
780 extern void brcms_c_set_home_chanspec(struct brcms_c_info *wlc,
781 u16 chanspec);
782 extern bool brcms_c_ps_allowed(struct brcms_c_info *wlc);
783 extern bool brcms_c_stay_awake(struct brcms_c_info *wlc);
785 extern void brcms_b_antsel_type_set(struct brcms_hardware *wlc_hw,
786 u8 antsel_type);
788 /* chanspec, ucode interface */
789 extern void brcms_b_set_chanspec(struct brcms_hardware *wlc_hw,
790 u16 chanspec,
791 bool mute, struct txpwr_limits *txpwr);
793 extern void brcms_b_write_shm(struct brcms_hardware *wlc_hw, uint offset,
794 u16 v);
795 extern u16 brcms_b_read_shm(struct brcms_hardware *wlc_hw, uint offset);
797 extern void brcms_b_mhf(struct brcms_hardware *wlc_hw, u8 idx, u16 mask,
798 u16 val, int bands);
800 extern void brcms_b_corereset(struct brcms_hardware *wlc_hw, u32 flags);
802 extern void brcms_b_mctrl(struct brcms_hardware *wlc_hw, u32 mask, u32 val);
804 extern void brcms_b_phy_reset(struct brcms_hardware *wlc_hw);
805 extern void brcms_b_bw_set(struct brcms_hardware *wlc_hw, u16 bw);
806 extern void brcms_b_core_phypll_reset(struct brcms_hardware *wlc_hw);
807 extern void brcms_c_ucode_wake_override_set(struct brcms_hardware *wlc_hw,
808 u32 override_bit);
809 extern void brcms_c_ucode_wake_override_clear(struct brcms_hardware *wlc_hw,
810 u32 override_bit);
811 extern void brcms_b_write_template_ram(struct brcms_hardware *wlc_hw,
812 int offset, int len, void *buf);
813 extern u16 brcms_b_rate_shm_offset(struct brcms_hardware *wlc_hw, u8 rate);
814 extern void brcms_b_copyto_objmem(struct brcms_hardware *wlc_hw,
815 uint offset, const void *buf, int len,
816 u32 sel);
817 extern void brcms_b_copyfrom_objmem(struct brcms_hardware *wlc_hw, uint offset,
818 void *buf, int len, u32 sel);
819 extern void brcms_b_switch_macfreq(struct brcms_hardware *wlc_hw, u8 spurmode);
820 extern u16 brcms_b_get_txant(struct brcms_hardware *wlc_hw);
821 extern void brcms_b_phyclk_fgc(struct brcms_hardware *wlc_hw, bool clk);
822 extern void brcms_b_macphyclk_set(struct brcms_hardware *wlc_hw, bool clk);
823 extern void brcms_b_core_phypll_ctl(struct brcms_hardware *wlc_hw, bool on);
824 extern void brcms_b_txant_set(struct brcms_hardware *wlc_hw, u16 phytxant);
825 extern void brcms_b_band_stf_ss_set(struct brcms_hardware *wlc_hw,
826 u8 stf_mode);
827 extern void brcms_c_init_scb(struct scb *scb);
829 #endif /* _BRCM_MAIN_H_ */