1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
28
29
30#define BRCMS_MAXMODULES 22
31
32#define SEQNUM_SHIFT 4
33#define SEQNUM_MAX 0x1000
34
35#define NTXRATE 64
36
37
38
39#define BRCMS_MAX_MAC_SUSPEND 83000
40
41
42#define BRCMS_PRB_RESP_TIMEOUT 0
43
44
45#define TXOFF (D11_TXH_LEN + D11_PHY_HDR_LEN)
46
47
48
49
50
51
52
53
54
55
56
57#define BITFIELD_MASK(width) \
58 (((unsigned)1 << (width)) - 1)
59#define GFIELD(val, field) \
60 (((val) >> field ## _S) & field ## _M)
61#define SFIELD(val, field, bits) \
62 (((val) & (~(field ## _M << field ## _S))) | \
63 ((unsigned)(bits) << field ## _S))
64
65#define SW_TIMER_MAC_STAT_UPD 30
66
67
68#define MAXCOREREV 28
69
70
71#if CONF_MSK(D11CONF, 0x4f) || CONF_GE(D11CONF, MAXCOREREV)
72#error "Configuration for D11CONF includes unsupported versions."
73#endif
74
75
76#define BRCMS_SHORTSLOT_AUTO -1
77#define BRCMS_SHORTSLOT_OFF 0
78#define BRCMS_SHORTSLOT_ON 1
79
80
81#define BRCMS_LONG_PREAMBLE (0)
82#define BRCMS_SHORT_PREAMBLE (1 << 0)
83#define BRCMS_GF_PREAMBLE (1 << 1)
84#define BRCMS_MM_PREAMBLE (1 << 2)
85#define BRCMS_IS_MIMO_PREAMBLE(_pre) (((_pre) == BRCMS_GF_PREAMBLE) || \
86 ((_pre) == BRCMS_MM_PREAMBLE))
87
88
89
90
91#define TXFID_QUEUE_MASK 0x0007
92#define TXFID_SEQ_MASK 0x7FE0
93#define TXFID_SEQ_SHIFT 5
94#define TXFID_RATE_PROBE_MASK 0x8000
95#define TXFID_RATE_MASK 0x0018
96#define TXFID_RATE_SHIFT 3
97
98
99#define BOARDREV_PROMOTABLE 0xFF
100#define BOARDREV_PROMOTED 1
101
102#define DATA_BLOCK_TX_SUPR (1 << 4)
103
104
105#define BRCMS_WAKE_OVERRIDE_CLKCTL 0x01
106#define BRCMS_WAKE_OVERRIDE_PHYREG 0x02
107#define BRCMS_WAKE_OVERRIDE_MACSUSPEND 0x04
108#define BRCMS_WAKE_OVERRIDE_TXFIFO 0x08
109#define BRCMS_WAKE_OVERRIDE_FORCEFAST 0x10
110
111
112
113
114
115
116
117#define I_ERRORS (I_PC | I_PD | I_DE | I_RO | I_XU)
118
119#define DEF_RXINTMASK (I_RI)
120#define DEF_MACINTMASK (MI_TXSTOP | MI_TBTT | MI_ATIMWINEND | MI_PMQ | \
121 MI_PHYTXERR | MI_DMAINT | MI_TFS | MI_BG_NOISE | \
122 MI_CCA | MI_TO | MI_GP0 | MI_RFDISABLE | MI_PWRUP)
123
124#define MAXTXPKTS 6
125
126
127#define MAXTXFRAMEBURST 8
128#define MAXFRAMEBURST_TXOP 10000
129
130#define NFIFO 6
131
132
133
134
135#define BRCMS_PLLREQ_SHARED 0x1
136
137#define BRCMS_PLLREQ_RADIO_MON 0x2
138
139#define BRCMS_PLLREQ_FLIP 0x4
140
141#define CHANNEL_BANDUNIT(wlc, ch) \
142 (((ch) <= CH_MAX_2G_CHANNEL) ? BAND_2G_INDEX : BAND_5G_INDEX)
143
144#define OTHERBANDUNIT(wlc) \
145 ((uint)((wlc)->band->bandunit ? BAND_2G_INDEX : BAND_5G_INDEX))
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162struct brcms_protection {
163 bool _g;
164 s8 g_override;
165 u8 gmode_user;
166 s8 overlap;
167 s8 nmode_user;
168 s8 n_cfg;
169 s8 n_cfg_override;
170 bool nongf;
171 s8 nongf_override;
172 s8 n_pam_override;
173 bool n_obss;
174};
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197struct brcms_stf {
198 u8 hw_txchain;
199 u8 txchain;
200 u8 txstreams;
201 u8 hw_rxchain;
202 u8 rxchain;
203 u8 rxstreams;
204 u8 ant_rx_ovr;
205 s8 txant;
206 u16 phytxant;
207 u8 ss_opmode;
208 bool ss_algosel_auto;
209 u16 ss_algo_channel;
210 u8 rxchain_restore_delay;
211 s8 ldpc;
212 u8 txcore[MAX_STREAMS_SUPPORTED + 1];
213 s8 spatial_policy;
214};
215
216#define BRCMS_STF_SS_STBC_TX(wlc, scb) \
217 (((wlc)->stf->txstreams > 1) && (((wlc)->band->band_stf_stbc_tx == ON) \
218 || (((scb)->flags & SCB_STBCCAP) && \
219 (wlc)->band->band_stf_stbc_tx == AUTO && \
220 isset(&((wlc)->stf->ss_algo_channel), PHY_TXC1_MODE_STBC))))
221
222#define BRCMS_STBC_CAP_PHY(wlc) (BRCMS_ISNPHY(wlc->band) && \
223 NREV_GE(wlc->band->phyrev, 3))
224
225#define BRCMS_SGI_CAP_PHY(wlc) ((BRCMS_ISNPHY(wlc->band) && \
226 NREV_GE(wlc->band->phyrev, 3)) || \
227 BRCMS_ISLCNPHY(wlc->band))
228
229#define BRCMS_CHAN_PHYTYPE(x) (((x) & RXS_CHAN_PHYTYPE_MASK) \
230 >> RXS_CHAN_PHYTYPE_SHIFT)
231#define BRCMS_CHAN_CHANNEL(x) (((x) & RXS_CHAN_ID_MASK) \
232 >> RXS_CHAN_ID_SHIFT)
233
234
235
236
237struct brcms_core {
238 uint coreidx;
239
240
241 uint *txavail[NFIFO];
242
243 struct macstat *macstat_snapshot;
244};
245
246
247
248
249struct brcms_band {
250 int bandtype;
251 uint bandunit;
252
253 u16 phytype;
254 u16 phyrev;
255 u16 radioid;
256 u16 radiorev;
257 struct brcms_phy_pub *pi;
258 bool abgphy_encore;
259
260 u8 gmode;
261
262 struct scb *hwrs_scb;
263
264
265 struct brcms_c_rateset defrateset;
266
267 u8 band_stf_ss_mode;
268 s8 band_stf_stbc_tx;
269
270 struct brcms_c_rateset hw_rateset;
271 u8 basic_rate[BRCM_MAXRATE + 1];
272 bool mimo_cap_40;
273 s8 antgain;
274
275 u16 CWmin;
276 u16 CWmax;
277 struct ieee80211_supported_band band;
278};
279
280
281struct modulecb {
282
283 char name[32];
284
285 struct brcms_info *hdl;
286
287 int (*down_fn)(void *handle);
288
289
290
291
292
293};
294
295struct brcms_hw_band {
296 int bandtype;
297 uint bandunit;
298 u16 mhfs[MHFMAX];
299 u8 bandhw_stf_ss_mode;
300 u16 CWmin;
301 u16 CWmax;
302 u32 core_flags;
303
304 u16 phytype;
305 u16 phyrev;
306 u16 radioid;
307 u16 radiorev;
308 struct brcms_phy_pub *pi;
309 bool abgphy_encore;
310};
311
312struct brcms_hardware {
313 bool _piomode;
314 struct brcms_c_info *wlc;
315
316
317 struct dma_pub *di[NFIFO];
318
319 uint unit;
320
321
322 u16 vendorid;
323 u16 deviceid;
324 uint corerev;
325 u8 sromrev;
326 u16 boardrev;
327 u32 boardflags;
328 u32 boardflags2;
329 u32 machwcap;
330 u32 machwcap_backup;
331
332 struct si_pub *sih;
333 struct bcma_device *d11core;
334 struct phy_shim_info *physhim;
335 struct shared_phy *phy_sh;
336 struct brcms_hw_band *band;
337
338 struct brcms_hw_band *bandstate[MAXBANDS];
339 u16 bmac_phytxant;
340 bool shortslot;
341 u16 SRL;
342 u16 LRL;
343 u16 SFBL;
344 u16 LFBL;
345
346 bool up;
347 uint now;
348 uint _nbands;
349 u16 chanspec;
350
351 uint *txavail[NFIFO];
352 const u16 *xmtfifo_sz;
353
354 u32 pllreq;
355
356 u8 suspended_fifos;
357 u32 maccontrol;
358 uint mac_suspend_depth;
359 u32 wake_override;
360 u32 mute_override;
361 u8 etheraddr[ETH_ALEN];
362 bool noreset;
363 bool forcefastclk;
364 bool clk;
365 bool sbclk;
366 bool phyclk;
367
368 bool ucode_loaded;
369
370
371 u8 hw_stf_ss_opmode;
372 u8 antsel_type;
373
374
375 u32 antsel_avail;
376
377
378
379};
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455struct brcms_c_info {
456 struct brcms_pub *pub;
457 struct brcms_info *wl;
458 struct brcms_hardware *hw;
459
460
461 u16 fastpwrup_dly;
462
463
464 u32 macintstatus;
465 u32 macintmask;
466 u32 defmacintmask;
467
468 bool clk;
469
470
471 struct brcms_core *core;
472 struct brcms_band *band;
473 struct brcms_core *corestate;
474 struct brcms_band *bandstate[MAXBANDS];
475
476
477 uint qvalid;
478
479 struct ampdu_info *ampdu;
480 struct antsel_info *asi;
481 struct brcms_cm_info *cmi;
482
483 u16 vendorid;
484 u16 deviceid;
485 uint ucode_rev;
486
487 u8 perm_etheraddr[ETH_ALEN];
488
489 bool bandlocked;
490 bool bandinit_pending;
491
492 bool radio_monitor;
493 bool going_down;
494
495 bool beacon_template_virgin;
496
497 struct brcms_timer *wdtimer;
498 struct brcms_timer *radio_timer;
499
500
501 uint filter_flags;
502
503
504 bool _rifs;
505
506
507 u8 bcn_li_bcn;
508 u8 bcn_li_dtim;
509
510 bool WDarmed;
511 u32 WDlast;
512
513
514 u16 edcf_txop[IEEE80211_NUM_ACS];
515
516 u16 wme_retries[IEEE80211_NUM_ACS];
517
518 struct brcms_bss_cfg *bsscfg;
519
520 struct modulecb *modulecb;
521
522 u8 mimoft;
523 s8 cck_40txbw;
524 s8 ofdm_40txbw;
525 s8 mimo_40txbw;
526
527 struct brcms_bss_info *default_bss;
528
529 u16 mc_fid_counter;
530
531 char country_default[BRCM_CNTRY_BUF_SZ];
532 char autocountry_default[BRCM_CNTRY_BUF_SZ];
533 u16 prb_resp_timeout;
534
535 u16 home_chanspec;
536
537
538 u16 chanspec;
539 u16 usr_fragthresh;
540 u16 fragthresh[NFIFO];
541 u16 RTSThresh;
542 u16 SRL;
543 u16 LRL;
544 u16 SFBL;
545 u16 LFBL;
546
547
548 bool shortslot;
549 s8 shortslot_override;
550 bool include_legacy_erp;
551
552 struct brcms_protection *protection;
553 s8 PLCPHdr_override;
554
555 struct brcms_stf *stf;
556
557 u32 bcn_rspec;
558
559 uint tempsense_lasttime;
560
561 u16 tx_duty_cycle_ofdm;
562 u16 tx_duty_cycle_cck;
563
564 struct wiphy *wiphy;
565 struct scb pri_scb;
566
567 struct sk_buff *beacon;
568 u16 beacon_tim_offset;
569 u16 beacon_dtim_period;
570 struct sk_buff *probe_resp;
571};
572
573
574struct antsel_info {
575 struct brcms_c_info *wlc;
576 struct brcms_pub *pub;
577 u8 antsel_type;
578
579
580 u8 antsel_antswitch;
581 bool antsel_avail;
582 struct brcms_antselcfg antcfg_11n;
583 struct brcms_antselcfg antcfg_cur;
584};
585
586enum brcms_bss_type {
587 BRCMS_TYPE_STATION,
588 BRCMS_TYPE_AP,
589 BRCMS_TYPE_ADHOC,
590};
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610struct brcms_bss_cfg {
611 struct brcms_c_info *wlc;
612 enum brcms_bss_type type;
613 u8 SSID_len;
614 u8 SSID[IEEE80211_MAX_SSID_LEN];
615 u8 BSSID[ETH_ALEN];
616 struct brcms_bss_info *current_bss;
617};
618
619int brcms_c_txfifo(struct brcms_c_info *wlc, uint fifo, struct sk_buff *p);
620int brcms_b_xmtfifo_sz_get(struct brcms_hardware *wlc_hw, uint fifo,
621 uint *blocks);
622
623int brcms_c_set_gmode(struct brcms_c_info *wlc, u8 gmode, bool config);
624void brcms_c_mac_promisc(struct brcms_c_info *wlc, uint filter_flags);
625u16 brcms_c_calc_lsig_len(struct brcms_c_info *wlc, u32 ratespec, uint mac_len);
626u32 brcms_c_rspec_to_rts_rspec(struct brcms_c_info *wlc, u32 rspec,
627 bool use_rspec, u16 mimo_ctlchbw);
628u16 brcms_c_compute_rtscts_dur(struct brcms_c_info *wlc, bool cts_only,
629 u32 rts_rate, u32 frame_rate,
630 u8 rts_preamble_type, u8 frame_preamble_type,
631 uint frame_len, bool ba);
632void brcms_c_inval_dma_pkts(struct brcms_hardware *hw,
633 struct ieee80211_sta *sta, void (*dma_callback_fn));
634void brcms_c_update_probe_resp(struct brcms_c_info *wlc, bool suspend);
635int brcms_c_set_nmode(struct brcms_c_info *wlc);
636void brcms_c_beacon_phytxctl_txant_upd(struct brcms_c_info *wlc, u32 bcn_rate);
637void brcms_b_antsel_type_set(struct brcms_hardware *wlc_hw, u8 antsel_type);
638void brcms_b_set_chanspec(struct brcms_hardware *wlc_hw, u16 chanspec,
639 bool mute, struct txpwr_limits *txpwr);
640void brcms_b_write_shm(struct brcms_hardware *wlc_hw, uint offset, u16 v);
641u16 brcms_b_read_shm(struct brcms_hardware *wlc_hw, uint offset);
642void brcms_b_mhf(struct brcms_hardware *wlc_hw, u8 idx, u16 mask, u16 val,
643 int bands);
644void brcms_b_corereset(struct brcms_hardware *wlc_hw, u32 flags);
645void brcms_b_mctrl(struct brcms_hardware *wlc_hw, u32 mask, u32 val);
646void brcms_b_phy_reset(struct brcms_hardware *wlc_hw);
647void brcms_b_bw_set(struct brcms_hardware *wlc_hw, u16 bw);
648void brcms_b_core_phypll_reset(struct brcms_hardware *wlc_hw);
649void brcms_c_ucode_wake_override_set(struct brcms_hardware *wlc_hw,
650 u32 override_bit);
651void brcms_c_ucode_wake_override_clear(struct brcms_hardware *wlc_hw,
652 u32 override_bit);
653void brcms_b_write_template_ram(struct brcms_hardware *wlc_hw, int offset,
654 int len, void *buf);
655u16 brcms_b_rate_shm_offset(struct brcms_hardware *wlc_hw, u8 rate);
656void brcms_b_copyto_objmem(struct brcms_hardware *wlc_hw, uint offset,
657 const void *buf, int len, u32 sel);
658void brcms_b_copyfrom_objmem(struct brcms_hardware *wlc_hw, uint offset,
659 void *buf, int len, u32 sel);
660void brcms_b_switch_macfreq(struct brcms_hardware *wlc_hw, u8 spurmode);
661u16 brcms_b_get_txant(struct brcms_hardware *wlc_hw);
662void brcms_b_phyclk_fgc(struct brcms_hardware *wlc_hw, bool clk);
663void brcms_b_macphyclk_set(struct brcms_hardware *wlc_hw, bool clk);
664void brcms_b_core_phypll_ctl(struct brcms_hardware *wlc_hw, bool on);
665void brcms_b_txant_set(struct brcms_hardware *wlc_hw, u16 phytxant);
666void brcms_b_band_stf_ss_set(struct brcms_hardware *wlc_hw, u8 stf_mode);
667void brcms_c_init_scb(struct scb *scb);
668
669#endif
670