0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #ifndef _BRCM_MAIN_H_
0018 #define _BRCM_MAIN_H_
0019
0020 #include <linux/etherdevice.h>
0021
0022 #include <brcmu_utils.h>
0023 #include "types.h"
0024 #include "d11.h"
0025 #include "scb.h"
0026
0027 #define INVCHANNEL 255
0028
0029
0030 #define BRCMS_MAXMODULES 22
0031
0032 #define SEQNUM_SHIFT 4
0033 #define SEQNUM_MAX 0x1000
0034
0035 #define NTXRATE 64
0036
0037
0038
0039 #define BRCMS_MAX_MAC_SUSPEND 83000
0040
0041
0042 #define BRCMS_PRB_RESP_TIMEOUT 0
0043
0044
0045 #define TXOFF (D11_TXH_LEN + D11_PHY_HDR_LEN)
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057 #define BITFIELD_MASK(width) \
0058 (((unsigned)1 << (width)) - 1)
0059 #define GFIELD(val, field) \
0060 (((val) >> field ## _S) & field ## _M)
0061 #define SFIELD(val, field, bits) \
0062 (((val) & (~(field ## _M << field ## _S))) | \
0063 ((unsigned)(bits) << field ## _S))
0064
0065 #define SW_TIMER_MAC_STAT_UPD 30
0066
0067
0068 #define MAXCOREREV 28
0069
0070
0071 #if CONF_MSK(D11CONF, 0x4f) || CONF_GE(D11CONF, MAXCOREREV)
0072 #error "Configuration for D11CONF includes unsupported versions."
0073 #endif
0074
0075
0076 #define BRCMS_SHORTSLOT_AUTO -1
0077 #define BRCMS_SHORTSLOT_OFF 0
0078 #define BRCMS_SHORTSLOT_ON 1
0079
0080
0081 #define BRCMS_LONG_PREAMBLE (0)
0082 #define BRCMS_SHORT_PREAMBLE (1 << 0)
0083 #define BRCMS_GF_PREAMBLE (1 << 1)
0084 #define BRCMS_MM_PREAMBLE (1 << 2)
0085 #define BRCMS_IS_MIMO_PREAMBLE(_pre) (((_pre) == BRCMS_GF_PREAMBLE) || \
0086 ((_pre) == BRCMS_MM_PREAMBLE))
0087
0088
0089
0090
0091 #define TXFID_QUEUE_MASK 0x0007
0092 #define TXFID_SEQ_MASK 0x7FE0
0093 #define TXFID_SEQ_SHIFT 5
0094 #define TXFID_RATE_PROBE_MASK 0x8000
0095 #define TXFID_RATE_MASK 0x0018
0096 #define TXFID_RATE_SHIFT 3
0097
0098
0099 #define BOARDREV_PROMOTABLE 0xFF
0100 #define BOARDREV_PROMOTED 1
0101
0102 #define DATA_BLOCK_TX_SUPR (1 << 4)
0103
0104
0105 #define BRCMS_WAKE_OVERRIDE_CLKCTL 0x01
0106 #define BRCMS_WAKE_OVERRIDE_PHYREG 0x02
0107 #define BRCMS_WAKE_OVERRIDE_MACSUSPEND 0x04
0108 #define BRCMS_WAKE_OVERRIDE_TXFIFO 0x08
0109 #define BRCMS_WAKE_OVERRIDE_FORCEFAST 0x10
0110
0111
0112
0113
0114
0115
0116
0117 #define I_ERRORS (I_PC | I_PD | I_DE | I_RO | I_XU)
0118
0119 #define DEF_RXINTMASK (I_RI)
0120 #define DEF_MACINTMASK (MI_TXSTOP | MI_TBTT | MI_ATIMWINEND | MI_PMQ | \
0121 MI_PHYTXERR | MI_DMAINT | MI_TFS | MI_BG_NOISE | \
0122 MI_CCA | MI_TO | MI_GP0 | MI_RFDISABLE | MI_PWRUP)
0123
0124 #define MAXTXPKTS 6
0125
0126
0127 #define MAXTXFRAMEBURST 8
0128 #define MAXFRAMEBURST_TXOP 10000
0129
0130 #define NFIFO 6
0131
0132
0133
0134
0135 #define BRCMS_PLLREQ_SHARED 0x1
0136
0137 #define BRCMS_PLLREQ_RADIO_MON 0x2
0138
0139 #define BRCMS_PLLREQ_FLIP 0x4
0140
0141 #define CHANNEL_BANDUNIT(wlc, ch) \
0142 (((ch) <= CH_MAX_2G_CHANNEL) ? BAND_2G_INDEX : BAND_5G_INDEX)
0143
0144 #define OTHERBANDUNIT(wlc) \
0145 ((uint)((wlc)->band->bandunit ? BAND_2G_INDEX : BAND_5G_INDEX))
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162 struct brcms_protection {
0163 bool _g;
0164 s8 g_override;
0165 u8 gmode_user;
0166 s8 overlap;
0167 s8 nmode_user;
0168 s8 n_cfg;
0169 s8 n_cfg_override;
0170 bool nongf;
0171 s8 nongf_override;
0172 s8 n_pam_override;
0173 bool n_obss;
0174 };
0175
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197 struct brcms_stf {
0198 u8 hw_txchain;
0199 u8 txchain;
0200 u8 txstreams;
0201 u8 hw_rxchain;
0202 u8 rxchain;
0203 u8 rxstreams;
0204 u8 ant_rx_ovr;
0205 s8 txant;
0206 u16 phytxant;
0207 u8 ss_opmode;
0208 bool ss_algosel_auto;
0209 u16 ss_algo_channel;
0210 u8 rxchain_restore_delay;
0211 s8 ldpc;
0212 u8 txcore[MAX_STREAMS_SUPPORTED + 1];
0213 s8 spatial_policy;
0214 };
0215
0216 #define BRCMS_STF_SS_STBC_TX(wlc, scb) \
0217 (((wlc)->stf->txstreams > 1) && (((wlc)->band->band_stf_stbc_tx == ON) \
0218 || (((scb)->flags & SCB_STBCCAP) && \
0219 (wlc)->band->band_stf_stbc_tx == AUTO && \
0220 isset(&((wlc)->stf->ss_algo_channel), PHY_TXC1_MODE_STBC))))
0221
0222 #define BRCMS_STBC_CAP_PHY(wlc) (BRCMS_ISNPHY(wlc->band) && \
0223 NREV_GE(wlc->band->phyrev, 3))
0224
0225 #define BRCMS_SGI_CAP_PHY(wlc) ((BRCMS_ISNPHY(wlc->band) && \
0226 NREV_GE(wlc->band->phyrev, 3)) || \
0227 BRCMS_ISLCNPHY(wlc->band))
0228
0229 #define BRCMS_CHAN_PHYTYPE(x) (((x) & RXS_CHAN_PHYTYPE_MASK) \
0230 >> RXS_CHAN_PHYTYPE_SHIFT)
0231 #define BRCMS_CHAN_CHANNEL(x) (((x) & RXS_CHAN_ID_MASK) \
0232 >> RXS_CHAN_ID_SHIFT)
0233
0234
0235
0236
0237 struct brcms_core {
0238 uint coreidx;
0239
0240
0241 uint *txavail[NFIFO];
0242
0243 struct macstat *macstat_snapshot;
0244 };
0245
0246
0247
0248
0249 struct brcms_band {
0250 int bandtype;
0251 uint bandunit;
0252
0253 u16 phytype;
0254 u16 phyrev;
0255 u16 radioid;
0256 u16 radiorev;
0257 struct brcms_phy_pub *pi;
0258 bool abgphy_encore;
0259
0260 u8 gmode;
0261
0262 struct scb *hwrs_scb;
0263
0264
0265 struct brcms_c_rateset defrateset;
0266
0267 u8 band_stf_ss_mode;
0268 s8 band_stf_stbc_tx;
0269
0270 struct brcms_c_rateset hw_rateset;
0271 u8 basic_rate[BRCM_MAXRATE + 1];
0272 bool mimo_cap_40;
0273 s8 antgain;
0274
0275 u16 CWmin;
0276 u16 CWmax;
0277 struct ieee80211_supported_band band;
0278 };
0279
0280
0281 struct modulecb {
0282
0283 char name[32];
0284
0285 struct brcms_info *hdl;
0286
0287 int (*down_fn)(void *handle);
0288
0289
0290
0291
0292
0293 };
0294
0295 struct brcms_hw_band {
0296 int bandtype;
0297 uint bandunit;
0298 u16 mhfs[MHFMAX];
0299 u8 bandhw_stf_ss_mode;
0300 u16 CWmin;
0301 u16 CWmax;
0302 u32 core_flags;
0303
0304 u16 phytype;
0305 u16 phyrev;
0306 u16 radioid;
0307 u16 radiorev;
0308 struct brcms_phy_pub *pi;
0309 bool abgphy_encore;
0310 };
0311
0312 struct brcms_hardware {
0313 bool _piomode;
0314 struct brcms_c_info *wlc;
0315
0316
0317 struct dma_pub *di[NFIFO];
0318
0319 uint unit;
0320
0321
0322 u16 vendorid;
0323 u16 deviceid;
0324 uint corerev;
0325 u8 sromrev;
0326 u16 boardrev;
0327 u32 boardflags;
0328 u32 boardflags2;
0329 u32 machwcap;
0330 u32 machwcap_backup;
0331
0332 struct si_pub *sih;
0333 struct bcma_device *d11core;
0334 struct phy_shim_info *physhim;
0335 struct shared_phy *phy_sh;
0336 struct brcms_hw_band *band;
0337
0338 struct brcms_hw_band *bandstate[MAXBANDS];
0339 u16 bmac_phytxant;
0340 bool shortslot;
0341 u16 SRL;
0342 u16 LRL;
0343 u16 SFBL;
0344 u16 LFBL;
0345
0346 bool up;
0347 uint now;
0348 uint _nbands;
0349 u16 chanspec;
0350
0351 uint *txavail[NFIFO];
0352 const u16 *xmtfifo_sz;
0353
0354 u32 pllreq;
0355
0356 u8 suspended_fifos;
0357 u32 maccontrol;
0358 uint mac_suspend_depth;
0359 u32 wake_override;
0360 u32 mute_override;
0361 u8 etheraddr[ETH_ALEN];
0362 bool noreset;
0363 bool forcefastclk;
0364 bool clk;
0365 bool sbclk;
0366 bool phyclk;
0367
0368 bool ucode_loaded;
0369
0370
0371 u8 hw_stf_ss_opmode;
0372 u8 antsel_type;
0373
0374
0375 u32 antsel_avail;
0376
0377
0378
0379 };
0380
0381
0382
0383
0384
0385
0386
0387
0388
0389
0390
0391
0392
0393
0394
0395
0396
0397
0398
0399
0400
0401
0402
0403
0404
0405
0406
0407
0408
0409
0410
0411
0412
0413
0414
0415
0416
0417
0418
0419
0420
0421
0422
0423
0424
0425
0426
0427
0428
0429
0430
0431
0432
0433
0434
0435
0436
0437
0438
0439
0440
0441
0442
0443
0444
0445
0446
0447
0448
0449
0450
0451
0452
0453
0454
0455 struct brcms_c_info {
0456 struct brcms_pub *pub;
0457 struct brcms_info *wl;
0458 struct brcms_hardware *hw;
0459
0460
0461 u16 fastpwrup_dly;
0462
0463
0464 u32 macintstatus;
0465 u32 macintmask;
0466 u32 defmacintmask;
0467
0468 bool clk;
0469
0470
0471 struct brcms_core *core;
0472 struct brcms_band *band;
0473 struct brcms_core *corestate;
0474 struct brcms_band *bandstate[MAXBANDS];
0475
0476
0477 uint qvalid;
0478
0479 struct ampdu_info *ampdu;
0480 struct antsel_info *asi;
0481 struct brcms_cm_info *cmi;
0482
0483 u16 vendorid;
0484 u16 deviceid;
0485 uint ucode_rev;
0486
0487 u8 perm_etheraddr[ETH_ALEN];
0488
0489 bool bandlocked;
0490 bool bandinit_pending;
0491
0492 bool radio_monitor;
0493 bool going_down;
0494
0495 bool beacon_template_virgin;
0496
0497 struct brcms_timer *wdtimer;
0498 struct brcms_timer *radio_timer;
0499
0500
0501 uint filter_flags;
0502
0503
0504 bool _rifs;
0505
0506
0507 u8 bcn_li_bcn;
0508 u8 bcn_li_dtim;
0509
0510 bool WDarmed;
0511 u32 WDlast;
0512
0513
0514 u16 edcf_txop[IEEE80211_NUM_ACS];
0515
0516 u16 wme_retries[IEEE80211_NUM_ACS];
0517
0518 struct brcms_bss_cfg *bsscfg;
0519
0520 struct modulecb *modulecb;
0521
0522 u8 mimoft;
0523 s8 cck_40txbw;
0524 s8 ofdm_40txbw;
0525 s8 mimo_40txbw;
0526
0527 struct brcms_bss_info *default_bss;
0528
0529 u16 mc_fid_counter;
0530
0531 char country_default[BRCM_CNTRY_BUF_SZ];
0532 char autocountry_default[BRCM_CNTRY_BUF_SZ];
0533 u16 prb_resp_timeout;
0534
0535 u16 home_chanspec;
0536
0537
0538 u16 chanspec;
0539 u16 usr_fragthresh;
0540 u16 fragthresh[NFIFO];
0541 u16 RTSThresh;
0542 u16 SRL;
0543 u16 LRL;
0544 u16 SFBL;
0545 u16 LFBL;
0546
0547
0548 bool shortslot;
0549 s8 shortslot_override;
0550 bool include_legacy_erp;
0551
0552 struct brcms_protection *protection;
0553 s8 PLCPHdr_override;
0554
0555 struct brcms_stf *stf;
0556
0557 u32 bcn_rspec;
0558
0559 uint tempsense_lasttime;
0560
0561 u16 tx_duty_cycle_ofdm;
0562 u16 tx_duty_cycle_cck;
0563
0564 struct wiphy *wiphy;
0565 struct scb pri_scb;
0566 struct ieee80211_vif *vif;
0567
0568 struct sk_buff *beacon;
0569 u16 beacon_tim_offset;
0570 u16 beacon_dtim_period;
0571 struct sk_buff *probe_resp;
0572 };
0573
0574
0575 struct antsel_info {
0576 struct brcms_c_info *wlc;
0577 struct brcms_pub *pub;
0578 u8 antsel_type;
0579
0580
0581 u8 antsel_antswitch;
0582 bool antsel_avail;
0583 struct brcms_antselcfg antcfg_11n;
0584 struct brcms_antselcfg antcfg_cur;
0585 };
0586
0587 enum brcms_bss_type {
0588 BRCMS_TYPE_STATION,
0589 BRCMS_TYPE_AP,
0590 BRCMS_TYPE_ADHOC,
0591 };
0592
0593
0594
0595
0596
0597
0598
0599
0600
0601
0602
0603
0604
0605
0606
0607
0608
0609
0610
0611 struct brcms_bss_cfg {
0612 struct brcms_c_info *wlc;
0613 enum brcms_bss_type type;
0614 u8 SSID_len;
0615 u8 SSID[IEEE80211_MAX_SSID_LEN];
0616 u8 BSSID[ETH_ALEN];
0617 struct brcms_bss_info *current_bss;
0618 };
0619
0620 int brcms_c_txfifo(struct brcms_c_info *wlc, uint fifo, struct sk_buff *p);
0621 int brcms_b_xmtfifo_sz_get(struct brcms_hardware *wlc_hw, uint fifo,
0622 uint *blocks);
0623
0624 int brcms_c_set_gmode(struct brcms_c_info *wlc, u8 gmode, bool config);
0625 void brcms_c_mac_promisc(struct brcms_c_info *wlc, uint filter_flags);
0626 u16 brcms_c_calc_lsig_len(struct brcms_c_info *wlc, u32 ratespec, uint mac_len);
0627 u32 brcms_c_rspec_to_rts_rspec(struct brcms_c_info *wlc, u32 rspec,
0628 bool use_rspec, u16 mimo_ctlchbw);
0629 u16 brcms_c_compute_rtscts_dur(struct brcms_c_info *wlc, bool cts_only,
0630 u32 rts_rate, u32 frame_rate,
0631 u8 rts_preamble_type, u8 frame_preamble_type,
0632 uint frame_len, bool ba);
0633 void brcms_c_inval_dma_pkts(struct brcms_hardware *hw,
0634 struct ieee80211_sta *sta, void (*dma_callback_fn));
0635 void brcms_c_update_probe_resp(struct brcms_c_info *wlc, bool suspend);
0636 int brcms_c_set_nmode(struct brcms_c_info *wlc);
0637 void brcms_c_beacon_phytxctl_txant_upd(struct brcms_c_info *wlc, u32 bcn_rate);
0638 void brcms_b_antsel_type_set(struct brcms_hardware *wlc_hw, u8 antsel_type);
0639 void brcms_b_set_chanspec(struct brcms_hardware *wlc_hw, u16 chanspec,
0640 bool mute, struct txpwr_limits *txpwr);
0641 void brcms_b_write_shm(struct brcms_hardware *wlc_hw, uint offset, u16 v);
0642 u16 brcms_b_read_shm(struct brcms_hardware *wlc_hw, uint offset);
0643 void brcms_b_mhf(struct brcms_hardware *wlc_hw, u8 idx, u16 mask, u16 val,
0644 int bands);
0645 void brcms_b_corereset(struct brcms_hardware *wlc_hw, u32 flags);
0646 void brcms_b_mctrl(struct brcms_hardware *wlc_hw, u32 mask, u32 val);
0647 void brcms_b_phy_reset(struct brcms_hardware *wlc_hw);
0648 void brcms_b_bw_set(struct brcms_hardware *wlc_hw, u16 bw);
0649 void brcms_b_core_phypll_reset(struct brcms_hardware *wlc_hw);
0650 void brcms_c_ucode_wake_override_set(struct brcms_hardware *wlc_hw,
0651 u32 override_bit);
0652 void brcms_c_ucode_wake_override_clear(struct brcms_hardware *wlc_hw,
0653 u32 override_bit);
0654 void brcms_b_write_template_ram(struct brcms_hardware *wlc_hw, int offset,
0655 int len, void *buf);
0656 u16 brcms_b_rate_shm_offset(struct brcms_hardware *wlc_hw, u8 rate);
0657 void brcms_b_copyto_objmem(struct brcms_hardware *wlc_hw, uint offset,
0658 const void *buf, int len, u32 sel);
0659 void brcms_b_copyfrom_objmem(struct brcms_hardware *wlc_hw, uint offset,
0660 void *buf, int len, u32 sel);
0661 void brcms_b_switch_macfreq(struct brcms_hardware *wlc_hw, u8 spurmode);
0662 u16 brcms_b_get_txant(struct brcms_hardware *wlc_hw);
0663 void brcms_b_phyclk_fgc(struct brcms_hardware *wlc_hw, bool clk);
0664 void brcms_b_macphyclk_set(struct brcms_hardware *wlc_hw, bool clk);
0665 void brcms_b_core_phypll_ctl(struct brcms_hardware *wlc_hw, bool on);
0666 void brcms_b_txant_set(struct brcms_hardware *wlc_hw, u16 phytxant);
0667 void brcms_b_band_stf_ss_set(struct brcms_hardware *wlc_hw, u8 stf_mode);
0668 void brcms_c_init_scb(struct scb *scb);
0669
0670 #endif