]> git.karo-electronics.de Git - mv-sheeva.git/blob - drivers/net/wireless/brcm80211/brcmsmac/main.h
c0e0fcfdfaf8e7988e5ec6d22919df019218f08e
[mv-sheeva.git] / drivers / net / wireless / brcm80211 / brcmsmac / main.h
1 /*
2  * Copyright (c) 2010 Broadcom Corporation
3  *
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.
7  *
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.
15  */
16
17 #ifndef _BRCM_MAIN_H_
18 #define _BRCM_MAIN_H_
19
20 #include <linux/etherdevice.h>
21
22 #include <brcmu_utils.h>
23 #include "types.h"
24 #include "d11.h"
25 #include "scb.h"
26
27 #define INVCHANNEL              255     /* invalid channel */
28
29 /* max # brcms_c_module_register() calls */
30 #define BRCMS_MAXMODULES        22
31
32 #define SEQNUM_SHIFT            4
33 #define SEQNUM_MAX              0x1000
34
35 #define NTXRATE                 64      /* # tx MPDUs rate is reported for */
36
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
40
41 /* responses for probe requests older that this are tossed, zero to disable */
42 #define BRCMS_PRB_RESP_TIMEOUT  0       /* Disable probe response timeout */
43
44 /* transmit buffer max headroom for protocol headers */
45 #define TXOFF (D11_TXH_LEN + D11_PHY_HDR_LEN)
46
47 #define AC_COUNT                4
48
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);
58  */
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))
66
67 #define SW_TIMER_MAC_STAT_UPD           30      /* periodic MAC stats update */
68
69 /* max # supported core revisions (0 .. MAXCOREREV - 1) */
70 #define MAXCOREREV              28
71
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 */
76
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 */
81
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))
89
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 */
99
100 /* promote boardrev */
101 #define BOARDREV_PROMOTABLE     0xFF    /* from */
102 #define BOARDREV_PROMOTED       1       /* to */
103
104 #define DATA_BLOCK_TX_SUPR      (1 << 4)
105
106 /* 802.1D Priority to TX FIFO number for wme */
107 extern const u8 prio2fifo[];
108
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
115
116 /* stuff pulled in from wlc.c */
117
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.
121  */
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)
128
129 #define MAXTXPKTS               6       /* max # pkts pending */
130
131 /* frameburst */
132 #define MAXTXFRAMEBURST         8 /* vanilla xpress mode: max frames/burst */
133 #define MAXFRAMEBURST_TXOP      10000   /* Frameburst TXOP in usec */
134
135 #define NFIFO                   6       /* # tx/rx fifopairs */
136
137 /* PLL requests */
138
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
145
146 #define CHANNEL_BANDUNIT(wlc, ch) \
147         (((ch) <= CH_MAX_2G_CHANNEL) ? BAND_2G_INDEX : BAND_5G_INDEX)
148
149 #define OTHERBANDUNIT(wlc) \
150         ((uint)((wlc)->band->bandunit ? BAND_2G_INDEX : BAND_5G_INDEX))
151
152 /*
153  * 802.11 protection information
154  *
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.
166 */
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;
179 };
180
181 /*
182  * anything affecting the single/dual streams/antenna operation
183  *
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:
201  */
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;
219 };
220
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))))
226
227 #define BRCMS_STBC_CAP_PHY(wlc) (BRCMS_ISNPHY(wlc->band) && \
228                                  NREV_GE(wlc->band->phyrev, 3))
229
230 #define BRCMS_SGI_CAP_PHY(wlc) ((BRCMS_ISNPHY(wlc->band) && \
231                                  NREV_GE(wlc->band->phyrev, 3)) || \
232                                 BRCMS_ISLCNPHY(wlc->band))
233
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)
238
239 /*
240  * core state (mac)
241  */
242 struct brcms_core {
243         uint coreidx;           /* # sb enumerated core */
244
245         /* fifo */
246         uint *txavail[NFIFO];   /* # tx descriptors available */
247         s16 txpktpend[NFIFO];   /* tx admission control */
248
249         struct macstat *macstat_snapshot;       /* mac hw prev read values */
250 };
251
252 /*
253  * band state (phy+ana+radio)
254  */
255 struct brcms_band {
256         int bandtype;           /* BRCM_BAND_2G, BRCM_BAND_5G */
257         uint bandunit;          /* bandstate[] index */
258
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;
265
266         u8 gmode;               /* currently active gmode */
267
268         struct scb *hwrs_scb;   /* permanent scb for hw rateset */
269
270         /* band-specific copy of default_bss.rateset */
271         struct brcms_c_rateset defrateset;
272
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 */
280
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;
284 };
285
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;
292
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.
297                                        */
298
299 };
300
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;
309
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;
316 };
317
318 struct brcms_hardware {
319         bool _piomode;          /* true if pio mode */
320         struct brcms_c_info *wlc;
321
322         /* fifo */
323         struct dma_pub *di[NFIFO];      /* dma handles, per fifo */
324
325         uint unit;              /* device instance number */
326
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 */
337
338         struct si_pub *sih;     /* SI handle (cookie for siutils calls) */
339         struct d11regs __iomem *regs;   /* pointer to device registers */
340         struct phy_shim_info *physhim; /* phy shim layer handler */
341         struct shared_phy *phy_sh;      /* pointer to shared phy state */
342         struct brcms_hw_band *band;/* pointer to active per-band state */
343         /* band state per phy/radio */
344         struct brcms_hw_band *bandstate[MAXBANDS];
345         u16 bmac_phytxant;      /* cache of high phytxant state */
346         bool shortslot;         /* currently using 11g ShortSlot timing */
347         u16 SRL;                /* 802.11 dot11ShortRetryLimit */
348         u16 LRL;                /* 802.11 dot11LongRetryLimit */
349         u16 SFBL;               /* Short Frame Rate Fallback Limit */
350         u16 LFBL;               /* Long Frame Rate Fallback Limit */
351
352         bool up;                /* d11 hardware up and running */
353         uint now;               /* # elapsed seconds */
354         uint _nbands;           /* # bands supported */
355         u16 chanspec;   /* bmac chanspec shadow */
356
357         uint *txavail[NFIFO];   /* # tx descriptors available */
358         const u16 *xmtfifo_sz;  /* fifo size in 256B for each xmt fifo */
359
360         u32 pllreq;             /* pll requests to keep PLL on */
361
362         u8 suspended_fifos;     /* Which TX fifo to remain awake for */
363         u32 maccontrol; /* Cached value of maccontrol */
364         uint mac_suspend_depth; /* current depth of mac_suspend levels */
365         u32 wake_override;      /* bit flags to force MAC to WAKE mode */
366         u32 mute_override;      /* Prevent ucode from sending beacons */
367         u8 etheraddr[ETH_ALEN]; /* currently configured ethernet address */
368         bool noreset;           /* true= do not reset hw, used by WLC_OUT */
369         bool forcefastclk;      /* true if h/w is forcing to use fast clk */
370         bool clk;               /* core is out of reset and has clock */
371         bool sbclk;             /* sb has clock */
372         bool phyclk;            /* phy is out of reset and has clock */
373
374         bool ucode_loaded;      /* true after ucode downloaded */
375
376
377         u8 hw_stf_ss_opmode;    /* STF single stream operation mode */
378         u8 antsel_type; /* Type of boardlevel mimo antenna switch-logic
379                                  * 0 = N/A, 1 = 2x4 board, 2 = 2x3 CB2 board
380                                  */
381         u32 antsel_avail;       /*
382                                  * put struct antsel_info here if more info is
383                                  * needed
384                                  */
385 };
386
387 /* TX Queue information
388  *
389  * Each flow of traffic out of the device has a TX Queue with independent
390  * flow control. Several interfaces may be associated with a single TX Queue
391  * if they belong to the same flow of traffic from the device. For multi-channel
392  * operation there are independent TX Queues for each channel.
393  */
394 struct brcms_txq_info {
395         struct brcms_txq_info *next;
396         struct pktq q;
397         uint stopped;           /* tx flow control bits */
398 };
399
400 /*
401  * Principal common driver data structure.
402  *
403  * pub: pointer to driver public state.
404  * wl: pointer to specific private state.
405  * regs: pointer to device registers.
406  * hw: HW related state.
407  * clkreq_override: setting for clkreq for PCIE : Auto, 0, 1.
408  * fastpwrup_dly: time in us needed to bring up d11 fast clock.
409  * macintstatus: bit channel between isr and dpc.
410  * macintmask: sw runtime master macintmask value.
411  * defmacintmask: default "on" macintmask value.
412  * clk: core is out of reset and has clock.
413  * core: pointer to active io core.
414  * band: pointer to active per-band state.
415  * corestate: per-core state (one per hw core).
416  * bandstate: per-band state (one per phy/radio).
417  * qvalid: DirFrmQValid and BcMcFrmQValid.
418  * ampdu: ampdu module handler.
419  * asi: antsel module handler.
420  * cmi: channel manager module handler.
421  * vendorid: PCI vendor id.
422  * deviceid: PCI device id.
423  * ucode_rev: microcode revision.
424  * machwcap: MAC capabilities, BMAC shadow.
425  * perm_etheraddr: original sprom local ethernet address.
426  * bandlocked: disable auto multi-band switching.
427  * bandinit_pending: track band init in auto band.
428  * radio_monitor: radio timer is running.
429  * going_down: down path intermediate variable.
430  * mpc: enable minimum power consumption.
431  * mpc_dlycnt: # of watchdog cnt before turn disable radio.
432  * mpc_offcnt: # of watchdog cnt that radio is disabled.
433  * mpc_delay_off: delay radio disable by # of watchdog cnt.
434  * prev_non_delay_mpc: prev state brcms_c_is_non_delay_mpc.
435  * wdtimer: timer for watchdog routine.
436  * radio_timer: timer for hw radio button monitor routine.
437  * monitor: monitor (MPDU sniffing) mode.
438  * bcnmisc_monitor: bcns promisc mode override for monitor.
439  * _rifs: enable per-packet rifs.
440  * bcn_li_bcn: beacon listen interval in # beacons.
441  * bcn_li_dtim: beacon listen interval in # dtims.
442  * WDarmed: watchdog timer is armed.
443  * WDlast: last time wlc_watchdog() was called.
444  * edcf_txop[AC_COUNT]: current txop for each ac.
445  * wme_retries: per-AC retry limits.
446  * tx_prec_map: Precedence map based on HW FIFO space.
447  * fifo2prec_map[NFIFO]: pointer to fifo2_prec map based on WME.
448  * bsscfg: set of BSS configurations, idx 0 is default and always valid.
449  * cfg: the primary bsscfg (can be AP or STA).
450  * tx_queues: common TX Queue list.
451  * modulecb:
452  * mimoft: SIGN or 11N.
453  * cck_40txbw: 11N, cck tx b/w override when in 40MHZ mode.
454  * ofdm_40txbw: 11N, ofdm tx b/w override when in 40MHZ mode.
455  * mimo_40txbw: 11N, mimo tx b/w override when in 40MHZ mode.
456  * default_bss: configured BSS parameters.
457  * mc_fid_counter: BC/MC FIFO frame ID counter.
458  * country_default: saved country for leaving 802.11d auto-country mode.
459  * autocountry_default: initial country for 802.11d auto-country mode.
460  * prb_resp_timeout: do not send prb resp if request older
461  *                   than this, 0 = disable.
462  * home_chanspec: shared home chanspec.
463  * chanspec: target operational channel.
464  * usr_fragthresh: user configured fragmentation threshold.
465  * fragthresh[NFIFO]: per-fifo fragmentation thresholds.
466  * RTSThresh: 802.11 dot11RTSThreshold.
467  * SRL: 802.11 dot11ShortRetryLimit.
468  * LRL: 802.11 dot11LongRetryLimit.
469  * SFBL: Short Frame Rate Fallback Limit.
470  * LFBL: Long Frame Rate Fallback Limit.
471  * shortslot: currently using 11g ShortSlot timing.
472  * shortslot_override: 11g ShortSlot override.
473  * include_legacy_erp: include Legacy ERP info elt ID 47 as well as g ID 42.
474  * PLCPHdr_override: 802.11b Preamble Type override.
475  * stf:
476  * bcn_rspec: save bcn ratespec purpose.
477  * tempsense_lasttime;
478  * tx_duty_cycle_ofdm: maximum allowed duty cycle for OFDM.
479  * tx_duty_cycle_cck: maximum allowed duty cycle for CCK.
480  * pkt_queue: txq for transmit packets.
481  * wiphy:
482  * pri_scb: primary Station Control Block
483  */
484 struct brcms_c_info {
485         struct brcms_pub *pub;
486         struct brcms_info *wl;
487         struct d11regs __iomem *regs;
488         struct brcms_hardware *hw;
489
490         /* clock */
491         u16 fastpwrup_dly;
492
493         /* interrupt */
494         u32 macintstatus;
495         u32 macintmask;
496         u32 defmacintmask;
497
498         bool clk;
499
500         /* multiband */
501         struct brcms_core *core;
502         struct brcms_band *band;
503         struct brcms_core *corestate;
504         struct brcms_band *bandstate[MAXBANDS];
505
506         /* packet queue */
507         uint qvalid;
508
509         struct ampdu_info *ampdu;
510         struct antsel_info *asi;
511         struct brcms_cm_info *cmi;
512
513         u16 vendorid;
514         u16 deviceid;
515         uint ucode_rev;
516
517         u8 perm_etheraddr[ETH_ALEN];
518
519         bool bandlocked;
520         bool bandinit_pending;
521
522         bool radio_monitor;
523         bool going_down;
524
525         bool mpc;
526         u8 mpc_dlycnt;
527         u8 mpc_offcnt;
528         u8 mpc_delay_off;
529         u8 prev_non_delay_mpc;
530
531         struct brcms_timer *wdtimer;
532         struct brcms_timer *radio_timer;
533
534         /* promiscuous */
535         bool monitor;
536         bool bcnmisc_monitor;
537
538         /* driver feature */
539         bool _rifs;
540
541         /* AP-STA synchronization, power save */
542         u8 bcn_li_bcn;
543         u8 bcn_li_dtim;
544
545         bool WDarmed;
546         u32 WDlast;
547
548         /* WME */
549         u16 edcf_txop[AC_COUNT];
550
551         u16 wme_retries[AC_COUNT];
552         u16 tx_prec_map;
553         u16 fifo2prec_map[NFIFO];
554
555         struct brcms_bss_cfg *bsscfg;
556
557         /* tx queue */
558         struct brcms_txq_info *tx_queues;
559
560         struct modulecb *modulecb;
561
562         u8 mimoft;
563         s8 cck_40txbw;
564         s8 ofdm_40txbw;
565         s8 mimo_40txbw;
566
567         struct brcms_bss_info *default_bss;
568
569         u16 mc_fid_counter;
570
571         char country_default[BRCM_CNTRY_BUF_SZ];
572         char autocountry_default[BRCM_CNTRY_BUF_SZ];
573         u16 prb_resp_timeout;
574
575         u16 home_chanspec;
576
577         /* PHY parameters */
578         u16 chanspec;
579         u16 usr_fragthresh;
580         u16 fragthresh[NFIFO];
581         u16 RTSThresh;
582         u16 SRL;
583         u16 LRL;
584         u16 SFBL;
585         u16 LFBL;
586
587         /* network config */
588         bool shortslot;
589         s8 shortslot_override;
590         bool include_legacy_erp;
591
592         struct brcms_protection *protection;
593         s8 PLCPHdr_override;
594
595         struct brcms_stf *stf;
596
597         u32 bcn_rspec;
598
599         uint tempsense_lasttime;
600
601         u16 tx_duty_cycle_ofdm;
602         u16 tx_duty_cycle_cck;
603
604         struct brcms_txq_info *pkt_queue;
605         struct wiphy *wiphy;
606         struct scb pri_scb;
607 };
608
609 /* antsel module specific state */
610 struct antsel_info {
611         struct brcms_c_info *wlc;       /* pointer to main wlc structure */
612         struct brcms_pub *pub;          /* pointer to public fn */
613         u8 antsel_type; /* Type of boardlevel mimo antenna switch-logic
614                                  * 0 = N/A, 1 = 2x4 board, 2 = 2x3 CB2 board
615                                  */
616         u8 antsel_antswitch;    /* board level antenna switch type */
617         bool antsel_avail;      /* Ant selection availability (SROM based) */
618         struct brcms_antselcfg antcfg_11n; /* antenna configuration */
619         struct brcms_antselcfg antcfg_cur; /* current antenna config (auto) */
620 };
621
622 /*
623  * BSS configuration state
624  *
625  * wlc: wlc to which this bsscfg belongs to.
626  * up: is this configuration up operational
627  * enable: is this configuration enabled
628  * associated: is BSS in ASSOCIATED state
629  * BSS: infraustructure or adhoc
630  * SSID_len: the length of SSID
631  * SSID: SSID string
632  *
633  *
634  * BSSID: BSSID (associated)
635  * cur_etheraddr: h/w address
636  * flags: BSSCFG flags; see below
637  *
638  * current_bss: BSS parms in ASSOCIATED state
639  *
640  *
641  * ID: 'unique' ID of this bsscfg, assigned at bsscfg allocation
642  */
643 struct brcms_bss_cfg {
644         struct brcms_c_info *wlc;
645         bool up;
646         bool enable;
647         bool associated;
648         bool BSS;
649         u8 SSID_len;
650         u8 SSID[IEEE80211_MAX_SSID_LEN];
651         u8 BSSID[ETH_ALEN];
652         u8 cur_etheraddr[ETH_ALEN];
653         struct brcms_bss_info *current_bss;
654 };
655
656 extern void brcms_c_txfifo(struct brcms_c_info *wlc, uint fifo,
657                            struct sk_buff *p,
658                            bool commit, s8 txpktpend);
659 extern void brcms_c_txfifo_complete(struct brcms_c_info *wlc, uint fifo,
660                                     s8 txpktpend);
661 extern void brcms_c_txq_enq(struct brcms_c_info *wlc, struct scb *scb,
662                             struct sk_buff *sdu, uint prec);
663 extern void brcms_c_print_txstatus(struct tx_status *txs);
664 extern int brcms_b_xmtfifo_sz_get(struct brcms_hardware *wlc_hw, uint fifo,
665                    uint *blocks);
666
667 #if defined(BCMDBG)
668 extern void brcms_c_print_txdesc(struct d11txh *txh);
669 #else
670 #define brcms_c_print_txdesc(a)
671 #endif
672
673 extern int brcms_c_set_gmode(struct brcms_c_info *wlc, u8 gmode, bool config);
674 extern void brcms_c_mac_bcn_promisc_change(struct brcms_c_info *wlc,
675                                            bool promisc);
676 extern void brcms_c_send_q(struct brcms_c_info *wlc);
677 extern int brcms_c_prep_pdu(struct brcms_c_info *wlc, struct sk_buff *pdu,
678                             uint *fifo);
679 extern u16 brcms_c_calc_lsig_len(struct brcms_c_info *wlc, u32 ratespec,
680                                 uint mac_len);
681 extern u32 brcms_c_rspec_to_rts_rspec(struct brcms_c_info *wlc,
682                                              u32 rspec,
683                                              bool use_rspec, u16 mimo_ctlchbw);
684 extern u16 brcms_c_compute_rtscts_dur(struct brcms_c_info *wlc, bool cts_only,
685                                       u32 rts_rate,
686                                       u32 frame_rate,
687                                       u8 rts_preamble_type,
688                                       u8 frame_preamble_type, uint frame_len,
689                                       bool ba);
690 extern void brcms_c_inval_dma_pkts(struct brcms_hardware *hw,
691                                struct ieee80211_sta *sta,
692                                void (*dma_callback_fn));
693 extern void brcms_c_update_beacon(struct brcms_c_info *wlc);
694 extern void brcms_c_update_probe_resp(struct brcms_c_info *wlc, bool suspend);
695 extern int brcms_c_set_nmode(struct brcms_c_info *wlc);
696 extern void brcms_c_beacon_phytxctl_txant_upd(struct brcms_c_info *wlc,
697                                           u32 bcn_rate);
698 extern void brcms_b_antsel_type_set(struct brcms_hardware *wlc_hw,
699                                      u8 antsel_type);
700 extern void brcms_b_set_chanspec(struct brcms_hardware *wlc_hw,
701                                   u16 chanspec,
702                                   bool mute, struct txpwr_limits *txpwr);
703 extern void brcms_b_write_shm(struct brcms_hardware *wlc_hw, uint offset,
704                               u16 v);
705 extern u16 brcms_b_read_shm(struct brcms_hardware *wlc_hw, uint offset);
706 extern void brcms_b_mhf(struct brcms_hardware *wlc_hw, u8 idx, u16 mask,
707                         u16 val, int bands);
708 extern void brcms_b_corereset(struct brcms_hardware *wlc_hw, u32 flags);
709 extern void brcms_b_mctrl(struct brcms_hardware *wlc_hw, u32 mask, u32 val);
710 extern void brcms_b_phy_reset(struct brcms_hardware *wlc_hw);
711 extern void brcms_b_bw_set(struct brcms_hardware *wlc_hw, u16 bw);
712 extern void brcms_b_core_phypll_reset(struct brcms_hardware *wlc_hw);
713 extern void brcms_c_ucode_wake_override_set(struct brcms_hardware *wlc_hw,
714                                         u32 override_bit);
715 extern void brcms_c_ucode_wake_override_clear(struct brcms_hardware *wlc_hw,
716                                           u32 override_bit);
717 extern void brcms_b_write_template_ram(struct brcms_hardware *wlc_hw,
718                                        int offset, int len, void *buf);
719 extern u16 brcms_b_rate_shm_offset(struct brcms_hardware *wlc_hw, u8 rate);
720 extern void brcms_b_copyto_objmem(struct brcms_hardware *wlc_hw,
721                                    uint offset, const void *buf, int len,
722                                    u32 sel);
723 extern void brcms_b_copyfrom_objmem(struct brcms_hardware *wlc_hw, uint offset,
724                                      void *buf, int len, u32 sel);
725 extern void brcms_b_switch_macfreq(struct brcms_hardware *wlc_hw, u8 spurmode);
726 extern u16 brcms_b_get_txant(struct brcms_hardware *wlc_hw);
727 extern void brcms_b_phyclk_fgc(struct brcms_hardware *wlc_hw, bool clk);
728 extern void brcms_b_macphyclk_set(struct brcms_hardware *wlc_hw, bool clk);
729 extern void brcms_b_core_phypll_ctl(struct brcms_hardware *wlc_hw, bool on);
730 extern void brcms_b_txant_set(struct brcms_hardware *wlc_hw, u16 phytxant);
731 extern void brcms_b_band_stf_ss_set(struct brcms_hardware *wlc_hw,
732                                     u8 stf_mode);
733 extern void brcms_c_init_scb(struct scb *scb);
734
735 #endif                          /* _BRCM_MAIN_H_ */