main.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
  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. #ifndef _BRCM_MAIN_H_
  17. #define _BRCM_MAIN_H_
  18. #include <linux/etherdevice.h>
  19. #include <brcmu_utils.h>
  20. #include "types.h"
  21. #include "d11.h"
  22. #include "scb.h"
  23. #define INVCHANNEL 255 /* invalid channel */
  24. /* max # brcms_c_module_register() calls */
  25. #define BRCMS_MAXMODULES 22
  26. #define SEQNUM_SHIFT 4
  27. #define SEQNUM_MAX 0x1000
  28. #define NTXRATE 64 /* # tx MPDUs rate is reported for */
  29. /* Maximum wait time for a MAC suspend */
  30. /* uS: 83mS is max packet time (64KB ampdu @ 6Mbps) */
  31. #define BRCMS_MAX_MAC_SUSPEND 83000
  32. /* responses for probe requests older that this are tossed, zero to disable */
  33. #define BRCMS_PRB_RESP_TIMEOUT 0 /* Disable probe response timeout */
  34. /* transmit buffer max headroom for protocol headers */
  35. #define TXOFF (D11_TXH_LEN + D11_PHY_HDR_LEN)
  36. /* Macros for doing definition and get/set of bitfields
  37. * Usage example, e.g. a three-bit field (bits 4-6):
  38. * #define <NAME>_M BITFIELD_MASK(3)
  39. * #define <NAME>_S 4
  40. * ...
  41. * regval = R_REG(osh, &regs->regfoo);
  42. * field = GFIELD(regval, <NAME>);
  43. * regval = SFIELD(regval, <NAME>, 1);
  44. * W_REG(osh, &regs->regfoo, regval);
  45. */
  46. #define BITFIELD_MASK(width) \
  47. (((unsigned)1 << (width)) - 1)
  48. #define GFIELD(val, field) \
  49. (((val) >> field ## _S) & field ## _M)
  50. #define SFIELD(val, field, bits) \
  51. (((val) & (~(field ## _M << field ## _S))) | \
  52. ((unsigned)(bits) << field ## _S))
  53. #define SW_TIMER_MAC_STAT_UPD 30 /* periodic MAC stats update */
  54. /* max # supported core revisions (0 .. MAXCOREREV - 1) */
  55. #define MAXCOREREV 28
  56. /* Double check that unsupported cores are not enabled */
  57. #if CONF_MSK(D11CONF, 0x4f) || CONF_GE(D11CONF, MAXCOREREV)
  58. #error "Configuration for D11CONF includes unsupported versions."
  59. #endif /* Bad versions */
  60. /* values for shortslot_override */
  61. #define BRCMS_SHORTSLOT_AUTO -1 /* Driver will manage Shortslot setting */
  62. #define BRCMS_SHORTSLOT_OFF 0 /* Turn off short slot */
  63. #define BRCMS_SHORTSLOT_ON 1 /* Turn on short slot */
  64. /* value for short/long and mixmode/greenfield preamble */
  65. #define BRCMS_LONG_PREAMBLE (0)
  66. #define BRCMS_SHORT_PREAMBLE (1 << 0)
  67. #define BRCMS_GF_PREAMBLE (1 << 1)
  68. #define BRCMS_MM_PREAMBLE (1 << 2)
  69. #define BRCMS_IS_MIMO_PREAMBLE(_pre) (((_pre) == BRCMS_GF_PREAMBLE) || \
  70. ((_pre) == BRCMS_MM_PREAMBLE))
  71. /* TxFrameID */
  72. /* seq and frag bits: SEQNUM_SHIFT, FRAGNUM_MASK (802.11.h) */
  73. /* rate epoch bits: TXFID_RATE_SHIFT, TXFID_RATE_MASK ((wlc_rate.c) */
  74. #define TXFID_QUEUE_MASK 0x0007 /* Bits 0-2 */
  75. #define TXFID_SEQ_MASK 0x7FE0 /* Bits 5-15 */
  76. #define TXFID_SEQ_SHIFT 5 /* Number of bit shifts */
  77. #define TXFID_RATE_PROBE_MASK 0x8000 /* Bit 15 for rate probe */
  78. #define TXFID_RATE_MASK 0x0018 /* Mask for bits 3 and 4 */
  79. #define TXFID_RATE_SHIFT 3 /* Shift 3 bits for rate mask */
  80. /* promote boardrev */
  81. #define BOARDREV_PROMOTABLE 0xFF /* from */
  82. #define BOARDREV_PROMOTED 1 /* to */
  83. #define DATA_BLOCK_TX_SUPR (1 << 4)
  84. /* Ucode MCTL_WAKE override bits */
  85. #define BRCMS_WAKE_OVERRIDE_CLKCTL 0x01
  86. #define BRCMS_WAKE_OVERRIDE_PHYREG 0x02
  87. #define BRCMS_WAKE_OVERRIDE_MACSUSPEND 0x04
  88. #define BRCMS_WAKE_OVERRIDE_TXFIFO 0x08
  89. #define BRCMS_WAKE_OVERRIDE_FORCEFAST 0x10
  90. /* stuff pulled in from wlc.c */
  91. /* Interrupt bit error summary. Don't include I_RU: we refill DMA at other
  92. * times; and if we run out, constant I_RU interrupts may cause lockup. We
  93. * will still get error counts from rx0ovfl.
  94. */
  95. #define I_ERRORS (I_PC | I_PD | I_DE | I_RO | I_XU)
  96. /* default software intmasks */
  97. #define DEF_RXINTMASK (I_RI) /* enable rx int on rxfifo only */
  98. #define DEF_MACINTMASK (MI_TXSTOP | MI_TBTT | MI_ATIMWINEND | MI_PMQ | \
  99. MI_PHYTXERR | MI_DMAINT | MI_TFS | MI_BG_NOISE | \
  100. MI_CCA | MI_TO | MI_GP0 | MI_RFDISABLE | MI_PWRUP)
  101. #define MAXTXPKTS 6 /* max # pkts pending */
  102. /* frameburst */
  103. #define MAXTXFRAMEBURST 8 /* vanilla xpress mode: max frames/burst */
  104. #define MAXFRAMEBURST_TXOP 10000 /* Frameburst TXOP in usec */
  105. #define NFIFO 6 /* # tx/rx fifopairs */
  106. /* PLL requests */
  107. /* pll is shared on old chips */
  108. #define BRCMS_PLLREQ_SHARED 0x1
  109. /* hold pll for radio monitor register checking */
  110. #define BRCMS_PLLREQ_RADIO_MON 0x2
  111. /* hold/release pll for some short operation */
  112. #define BRCMS_PLLREQ_FLIP 0x4
  113. #define CHANNEL_BANDUNIT(wlc, ch) \
  114. (((ch) <= CH_MAX_2G_CHANNEL) ? BAND_2G_INDEX : BAND_5G_INDEX)
  115. #define OTHERBANDUNIT(wlc) \
  116. ((uint)((wlc)->band->bandunit ? BAND_2G_INDEX : BAND_5G_INDEX))
  117. /*
  118. * 802.11 protection information
  119. *
  120. * _g: use g spec protection, driver internal.
  121. * g_override: override for use of g spec protection.
  122. * gmode_user: user config gmode, operating band->gmode is different.
  123. * overlap: Overlap BSS/IBSS protection for both 11g and 11n.
  124. * nmode_user: user config nmode, operating pub->nmode is different.
  125. * n_cfg: use OFDM protection on MIMO frames.
  126. * n_cfg_override: override for use of N protection.
  127. * nongf: non-GF present protection.
  128. * nongf_override: override for use of GF protection.
  129. * n_pam_override: override for preamble: MM or GF.
  130. * n_obss: indicated OBSS Non-HT STA present.
  131. */
  132. struct brcms_protection {
  133. bool _g;
  134. s8 g_override;
  135. u8 gmode_user;
  136. s8 overlap;
  137. s8 nmode_user;
  138. s8 n_cfg;
  139. s8 n_cfg_override;
  140. bool nongf;
  141. s8 nongf_override;
  142. s8 n_pam_override;
  143. bool n_obss;
  144. };
  145. /*
  146. * anything affecting the single/dual streams/antenna operation
  147. *
  148. * hw_txchain: HW txchain bitmap cfg.
  149. * txchain: txchain bitmap being used.
  150. * txstreams: number of txchains being used.
  151. * hw_rxchain: HW rxchain bitmap cfg.
  152. * rxchain: rxchain bitmap being used.
  153. * rxstreams: number of rxchains being used.
  154. * ant_rx_ovr: rx antenna override.
  155. * txant: userTx antenna setting.
  156. * phytxant: phyTx antenna setting in txheader.
  157. * ss_opmode: singlestream Operational mode, 0:siso; 1:cdd.
  158. * ss_algosel_auto: if true, use wlc->stf->ss_algo_channel;
  159. * else use wlc->band->stf->ss_mode_band.
  160. * ss_algo_channel: ss based on per-channel algo: 0: SISO, 1: CDD 2: STBC.
  161. * rxchain_restore_delay: delay time to restore default rxchain.
  162. * ldpc: AUTO/ON/OFF ldpc cap supported.
  163. * txcore[MAX_STREAMS_SUPPORTED + 1]: bitmap of selected core for each Nsts.
  164. * spatial_policy:
  165. */
  166. struct brcms_stf {
  167. u8 hw_txchain;
  168. u8 txchain;
  169. u8 txstreams;
  170. u8 hw_rxchain;
  171. u8 rxchain;
  172. u8 rxstreams;
  173. u8 ant_rx_ovr;
  174. s8 txant;
  175. u16 phytxant;
  176. u8 ss_opmode;
  177. bool ss_algosel_auto;
  178. u16 ss_algo_channel;
  179. u8 rxchain_restore_delay;
  180. s8 ldpc;
  181. u8 txcore[MAX_STREAMS_SUPPORTED + 1];
  182. s8 spatial_policy;
  183. };
  184. #define BRCMS_STF_SS_STBC_TX(wlc, scb) \
  185. (((wlc)->stf->txstreams > 1) && (((wlc)->band->band_stf_stbc_tx == ON) \
  186. || (((scb)->flags & SCB_STBCCAP) && \
  187. (wlc)->band->band_stf_stbc_tx == AUTO && \
  188. isset(&((wlc)->stf->ss_algo_channel), PHY_TXC1_MODE_STBC))))
  189. #define BRCMS_STBC_CAP_PHY(wlc) (BRCMS_ISNPHY(wlc->band) && \
  190. NREV_GE(wlc->band->phyrev, 3))
  191. #define BRCMS_SGI_CAP_PHY(wlc) ((BRCMS_ISNPHY(wlc->band) && \
  192. NREV_GE(wlc->band->phyrev, 3)) || \
  193. BRCMS_ISLCNPHY(wlc->band))
  194. #define BRCMS_CHAN_PHYTYPE(x) (((x) & RXS_CHAN_PHYTYPE_MASK) \
  195. >> RXS_CHAN_PHYTYPE_SHIFT)
  196. #define BRCMS_CHAN_CHANNEL(x) (((x) & RXS_CHAN_ID_MASK) \
  197. >> RXS_CHAN_ID_SHIFT)
  198. /*
  199. * core state (mac)
  200. */
  201. struct brcms_core {
  202. uint coreidx; /* # sb enumerated core */
  203. /* fifo */
  204. uint *txavail[NFIFO]; /* # tx descriptors available */
  205. struct macstat *macstat_snapshot; /* mac hw prev read values */
  206. };
  207. /*
  208. * band state (phy+ana+radio)
  209. */
  210. struct brcms_band {
  211. int bandtype; /* BRCM_BAND_2G, BRCM_BAND_5G */
  212. uint bandunit; /* bandstate[] index */
  213. u16 phytype; /* phytype */
  214. u16 phyrev;
  215. u16 radioid;
  216. u16 radiorev;
  217. struct brcms_phy_pub *pi; /* pointer to phy specific information */
  218. bool abgphy_encore;
  219. u8 gmode; /* currently active gmode */
  220. struct scb *hwrs_scb; /* permanent scb for hw rateset */
  221. /* band-specific copy of default_bss.rateset */
  222. struct brcms_c_rateset defrateset;
  223. u8 band_stf_ss_mode; /* Configured STF type, 0:siso; 1:cdd */
  224. s8 band_stf_stbc_tx; /* STBC TX 0:off; 1:force on; -1:auto */
  225. /* rates supported by chip (phy-specific) */
  226. struct brcms_c_rateset hw_rateset;
  227. u8 basic_rate[BRCM_MAXRATE + 1]; /* basic rates indexed by rate */
  228. bool mimo_cap_40; /* 40 MHz cap enabled on this band */
  229. s8 antgain; /* antenna gain from srom */
  230. u16 CWmin; /* minimum size of contention window, in unit of aSlotTime */
  231. u16 CWmax; /* maximum size of contention window, in unit of aSlotTime */
  232. struct ieee80211_supported_band band;
  233. };
  234. /* module control blocks */
  235. struct modulecb {
  236. /* module name : NULL indicates empty array member */
  237. char name[32];
  238. /* handle passed when handler 'doiovar' is called */
  239. struct brcms_info *hdl;
  240. int (*down_fn)(void *handle); /* down handler. Note: the int returned
  241. * by the down function is a count of the
  242. * number of timers that could not be
  243. * freed.
  244. */
  245. };
  246. struct brcms_hw_band {
  247. int bandtype; /* BRCM_BAND_2G, BRCM_BAND_5G */
  248. uint bandunit; /* bandstate[] index */
  249. u16 mhfs[MHFMAX]; /* MHF array shadow */
  250. u8 bandhw_stf_ss_mode; /* HW configured STF type, 0:siso; 1:cdd */
  251. u16 CWmin;
  252. u16 CWmax;
  253. u32 core_flags;
  254. u16 phytype; /* phytype */
  255. u16 phyrev;
  256. u16 radioid;
  257. u16 radiorev;
  258. struct brcms_phy_pub *pi; /* pointer to phy specific information */
  259. bool abgphy_encore;
  260. };
  261. struct brcms_hardware {
  262. bool _piomode; /* true if pio mode */
  263. struct brcms_c_info *wlc;
  264. /* fifo */
  265. struct dma_pub *di[NFIFO]; /* dma handles, per fifo */
  266. uint unit; /* device instance number */
  267. /* version info */
  268. u16 vendorid; /* PCI vendor id */
  269. u16 deviceid; /* PCI device id */
  270. uint corerev; /* core revision */
  271. u8 sromrev; /* version # of the srom */
  272. u16 boardrev; /* version # of particular board */
  273. u32 boardflags; /* Board specific flags from srom */
  274. u32 boardflags2; /* More board flags if sromrev >= 4 */
  275. u32 machwcap; /* MAC capabilities */
  276. u32 machwcap_backup; /* backup of machwcap */
  277. struct si_pub *sih; /* SI handle (cookie for siutils calls) */
  278. struct bcma_device *d11core; /* pointer to 802.11 core */
  279. struct phy_shim_info *physhim; /* phy shim layer handler */
  280. struct shared_phy *phy_sh; /* pointer to shared phy state */
  281. struct brcms_hw_band *band;/* pointer to active per-band state */
  282. /* band state per phy/radio */
  283. struct brcms_hw_band *bandstate[MAXBANDS];
  284. u16 bmac_phytxant; /* cache of high phytxant state */
  285. bool shortslot; /* currently using 11g ShortSlot timing */
  286. u16 SRL; /* 802.11 dot11ShortRetryLimit */
  287. u16 LRL; /* 802.11 dot11LongRetryLimit */
  288. u16 SFBL; /* Short Frame Rate Fallback Limit */
  289. u16 LFBL; /* Long Frame Rate Fallback Limit */
  290. bool up; /* d11 hardware up and running */
  291. uint now; /* # elapsed seconds */
  292. uint _nbands; /* # bands supported */
  293. u16 chanspec; /* bmac chanspec shadow */
  294. uint *txavail[NFIFO]; /* # tx descriptors available */
  295. const u16 *xmtfifo_sz; /* fifo size in 256B for each xmt fifo */
  296. u32 pllreq; /* pll requests to keep PLL on */
  297. u8 suspended_fifos; /* Which TX fifo to remain awake for */
  298. u32 maccontrol; /* Cached value of maccontrol */
  299. uint mac_suspend_depth; /* current depth of mac_suspend levels */
  300. u32 wake_override; /* bit flags to force MAC to WAKE mode */
  301. u32 mute_override; /* Prevent ucode from sending beacons */
  302. u8 etheraddr[ETH_ALEN]; /* currently configured ethernet address */
  303. bool noreset; /* true= do not reset hw, used by WLC_OUT */
  304. bool forcefastclk; /* true if h/w is forcing to use fast clk */
  305. bool clk; /* core is out of reset and has clock */
  306. bool sbclk; /* sb has clock */
  307. bool phyclk; /* phy is out of reset and has clock */
  308. bool ucode_loaded; /* true after ucode downloaded */
  309. u8 hw_stf_ss_opmode; /* STF single stream operation mode */
  310. u8 antsel_type; /* Type of boardlevel mimo antenna switch-logic
  311. * 0 = N/A, 1 = 2x4 board, 2 = 2x3 CB2 board
  312. */
  313. u32 antsel_avail; /*
  314. * put struct antsel_info here if more info is
  315. * needed
  316. */
  317. };
  318. /*
  319. * Principal common driver data structure.
  320. *
  321. * pub: pointer to driver public state.
  322. * wl: pointer to specific private state.
  323. * hw: HW related state.
  324. * clkreq_override: setting for clkreq for PCIE : Auto, 0, 1.
  325. * fastpwrup_dly: time in us needed to bring up d11 fast clock.
  326. * macintstatus: bit channel between isr and dpc.
  327. * macintmask: sw runtime master macintmask value.
  328. * defmacintmask: default "on" macintmask value.
  329. * clk: core is out of reset and has clock.
  330. * core: pointer to active io core.
  331. * band: pointer to active per-band state.
  332. * corestate: per-core state (one per hw core).
  333. * bandstate: per-band state (one per phy/radio).
  334. * qvalid: DirFrmQValid and BcMcFrmQValid.
  335. * ampdu: ampdu module handler.
  336. * asi: antsel module handler.
  337. * cmi: channel manager module handler.
  338. * vendorid: PCI vendor id.
  339. * deviceid: PCI device id.
  340. * ucode_rev: microcode revision.
  341. * machwcap: MAC capabilities, BMAC shadow.
  342. * perm_etheraddr: original sprom local ethernet address.
  343. * bandlocked: disable auto multi-band switching.
  344. * bandinit_pending: track band init in auto band.
  345. * radio_monitor: radio timer is running.
  346. * going_down: down path intermediate variable.
  347. * wdtimer: timer for watchdog routine.
  348. * radio_timer: timer for hw radio button monitor routine.
  349. * monitor: monitor (MPDU sniffing) mode.
  350. * bcnmisc_monitor: bcns promisc mode override for monitor.
  351. * _rifs: enable per-packet rifs.
  352. * bcn_li_bcn: beacon listen interval in # beacons.
  353. * bcn_li_dtim: beacon listen interval in # dtims.
  354. * WDarmed: watchdog timer is armed.
  355. * WDlast: last time wlc_watchdog() was called.
  356. * edcf_txop[IEEE80211_NUM_ACS]: current txop for each ac.
  357. * wme_retries: per-AC retry limits.
  358. * bsscfg: set of BSS configurations, idx 0 is default and always valid.
  359. * cfg: the primary bsscfg (can be AP or STA).
  360. * modulecb:
  361. * mimoft: SIGN or 11N.
  362. * cck_40txbw: 11N, cck tx b/w override when in 40MHZ mode.
  363. * ofdm_40txbw: 11N, ofdm tx b/w override when in 40MHZ mode.
  364. * mimo_40txbw: 11N, mimo tx b/w override when in 40MHZ mode.
  365. * default_bss: configured BSS parameters.
  366. * mc_fid_counter: BC/MC FIFO frame ID counter.
  367. * country_default: saved country for leaving 802.11d auto-country mode.
  368. * autocountry_default: initial country for 802.11d auto-country mode.
  369. * prb_resp_timeout: do not send prb resp if request older
  370. * than this, 0 = disable.
  371. * home_chanspec: shared home chanspec.
  372. * chanspec: target operational channel.
  373. * usr_fragthresh: user configured fragmentation threshold.
  374. * fragthresh[NFIFO]: per-fifo fragmentation thresholds.
  375. * RTSThresh: 802.11 dot11RTSThreshold.
  376. * SRL: 802.11 dot11ShortRetryLimit.
  377. * LRL: 802.11 dot11LongRetryLimit.
  378. * SFBL: Short Frame Rate Fallback Limit.
  379. * LFBL: Long Frame Rate Fallback Limit.
  380. * shortslot: currently using 11g ShortSlot timing.
  381. * shortslot_override: 11g ShortSlot override.
  382. * include_legacy_erp: include Legacy ERP info elt ID 47 as well as g ID 42.
  383. * PLCPHdr_override: 802.11b Preamble Type override.
  384. * stf:
  385. * bcn_rspec: save bcn ratespec purpose.
  386. * tempsense_lasttime;
  387. * tx_duty_cycle_ofdm: maximum allowed duty cycle for OFDM.
  388. * tx_duty_cycle_cck: maximum allowed duty cycle for CCK.
  389. * wiphy:
  390. * pri_scb: primary Station Control Block
  391. */
  392. struct brcms_c_info {
  393. struct brcms_pub *pub;
  394. struct brcms_info *wl;
  395. struct brcms_hardware *hw;
  396. /* clock */
  397. u16 fastpwrup_dly;
  398. /* interrupt */
  399. u32 macintstatus;
  400. u32 macintmask;
  401. u32 defmacintmask;
  402. bool clk;
  403. /* multiband */
  404. struct brcms_core *core;
  405. struct brcms_band *band;
  406. struct brcms_core *corestate;
  407. struct brcms_band *bandstate[MAXBANDS];
  408. /* packet queue */
  409. uint qvalid;
  410. struct ampdu_info *ampdu;
  411. struct antsel_info *asi;
  412. struct brcms_cm_info *cmi;
  413. u16 vendorid;
  414. u16 deviceid;
  415. uint ucode_rev;
  416. u8 perm_etheraddr[ETH_ALEN];
  417. bool bandlocked;
  418. bool bandinit_pending;
  419. bool radio_monitor;
  420. bool going_down;
  421. bool beacon_template_virgin;
  422. struct brcms_timer *wdtimer;
  423. struct brcms_timer *radio_timer;
  424. /* promiscuous */
  425. uint filter_flags;
  426. /* driver feature */
  427. bool _rifs;
  428. /* AP-STA synchronization, power save */
  429. u8 bcn_li_bcn;
  430. u8 bcn_li_dtim;
  431. bool WDarmed;
  432. u32 WDlast;
  433. /* WME */
  434. u16 edcf_txop[IEEE80211_NUM_ACS];
  435. u16 wme_retries[IEEE80211_NUM_ACS];
  436. struct brcms_bss_cfg *bsscfg;
  437. struct modulecb *modulecb;
  438. u8 mimoft;
  439. s8 cck_40txbw;
  440. s8 ofdm_40txbw;
  441. s8 mimo_40txbw;
  442. struct brcms_bss_info *default_bss;
  443. u16 mc_fid_counter;
  444. char country_default[BRCM_CNTRY_BUF_SZ];
  445. char autocountry_default[BRCM_CNTRY_BUF_SZ];
  446. u16 prb_resp_timeout;
  447. u16 home_chanspec;
  448. /* PHY parameters */
  449. u16 chanspec;
  450. u16 usr_fragthresh;
  451. u16 fragthresh[NFIFO];
  452. u16 RTSThresh;
  453. u16 SRL;
  454. u16 LRL;
  455. u16 SFBL;
  456. u16 LFBL;
  457. /* network config */
  458. bool shortslot;
  459. s8 shortslot_override;
  460. bool include_legacy_erp;
  461. struct brcms_protection *protection;
  462. s8 PLCPHdr_override;
  463. struct brcms_stf *stf;
  464. u32 bcn_rspec;
  465. uint tempsense_lasttime;
  466. u16 tx_duty_cycle_ofdm;
  467. u16 tx_duty_cycle_cck;
  468. struct wiphy *wiphy;
  469. struct scb pri_scb;
  470. struct ieee80211_vif *vif;
  471. struct sk_buff *beacon;
  472. u16 beacon_tim_offset;
  473. u16 beacon_dtim_period;
  474. struct sk_buff *probe_resp;
  475. };
  476. /* antsel module specific state */
  477. struct antsel_info {
  478. struct brcms_c_info *wlc; /* pointer to main wlc structure */
  479. struct brcms_pub *pub; /* pointer to public fn */
  480. u8 antsel_type; /* Type of boardlevel mimo antenna switch-logic
  481. * 0 = N/A, 1 = 2x4 board, 2 = 2x3 CB2 board
  482. */
  483. u8 antsel_antswitch; /* board level antenna switch type */
  484. bool antsel_avail; /* Ant selection availability (SROM based) */
  485. struct brcms_antselcfg antcfg_11n; /* antenna configuration */
  486. struct brcms_antselcfg antcfg_cur; /* current antenna config (auto) */
  487. };
  488. enum brcms_bss_type {
  489. BRCMS_TYPE_STATION,
  490. BRCMS_TYPE_AP,
  491. BRCMS_TYPE_ADHOC,
  492. };
  493. /*
  494. * BSS configuration state
  495. *
  496. * wlc: wlc to which this bsscfg belongs to.
  497. * type: interface type
  498. * SSID_len: the length of SSID
  499. * SSID: SSID string
  500. *
  501. *
  502. * BSSID: BSSID (associated)
  503. * cur_etheraddr: h/w address
  504. * flags: BSSCFG flags; see below
  505. *
  506. * current_bss: BSS parms in ASSOCIATED state
  507. *
  508. *
  509. * ID: 'unique' ID of this bsscfg, assigned at bsscfg allocation
  510. */
  511. struct brcms_bss_cfg {
  512. struct brcms_c_info *wlc;
  513. enum brcms_bss_type type;
  514. u8 SSID_len;
  515. u8 SSID[IEEE80211_MAX_SSID_LEN];
  516. u8 BSSID[ETH_ALEN];
  517. struct brcms_bss_info *current_bss;
  518. };
  519. int brcms_c_txfifo(struct brcms_c_info *wlc, uint fifo, struct sk_buff *p);
  520. int brcms_b_xmtfifo_sz_get(struct brcms_hardware *wlc_hw, uint fifo,
  521. uint *blocks);
  522. int brcms_c_set_gmode(struct brcms_c_info *wlc, u8 gmode, bool config);
  523. void brcms_c_mac_promisc(struct brcms_c_info *wlc, uint filter_flags);
  524. u16 brcms_c_calc_lsig_len(struct brcms_c_info *wlc, u32 ratespec, uint mac_len);
  525. u32 brcms_c_rspec_to_rts_rspec(struct brcms_c_info *wlc, u32 rspec,
  526. bool use_rspec, u16 mimo_ctlchbw);
  527. u16 brcms_c_compute_rtscts_dur(struct brcms_c_info *wlc, bool cts_only,
  528. u32 rts_rate, u32 frame_rate,
  529. u8 rts_preamble_type, u8 frame_preamble_type,
  530. uint frame_len, bool ba);
  531. void brcms_c_inval_dma_pkts(struct brcms_hardware *hw,
  532. struct ieee80211_sta *sta, void (*dma_callback_fn));
  533. void brcms_c_update_probe_resp(struct brcms_c_info *wlc, bool suspend);
  534. int brcms_c_set_nmode(struct brcms_c_info *wlc);
  535. void brcms_c_beacon_phytxctl_txant_upd(struct brcms_c_info *wlc, u32 bcn_rate);
  536. void brcms_b_antsel_type_set(struct brcms_hardware *wlc_hw, u8 antsel_type);
  537. void brcms_b_set_chanspec(struct brcms_hardware *wlc_hw, u16 chanspec,
  538. bool mute, struct txpwr_limits *txpwr);
  539. void brcms_b_write_shm(struct brcms_hardware *wlc_hw, uint offset, u16 v);
  540. u16 brcms_b_read_shm(struct brcms_hardware *wlc_hw, uint offset);
  541. void brcms_b_mhf(struct brcms_hardware *wlc_hw, u8 idx, u16 mask, u16 val,
  542. int bands);
  543. void brcms_b_corereset(struct brcms_hardware *wlc_hw, u32 flags);
  544. void brcms_b_mctrl(struct brcms_hardware *wlc_hw, u32 mask, u32 val);
  545. void brcms_b_phy_reset(struct brcms_hardware *wlc_hw);
  546. void brcms_b_bw_set(struct brcms_hardware *wlc_hw, u16 bw);
  547. void brcms_b_core_phypll_reset(struct brcms_hardware *wlc_hw);
  548. void brcms_c_ucode_wake_override_set(struct brcms_hardware *wlc_hw,
  549. u32 override_bit);
  550. void brcms_c_ucode_wake_override_clear(struct brcms_hardware *wlc_hw,
  551. u32 override_bit);
  552. void brcms_b_write_template_ram(struct brcms_hardware *wlc_hw, int offset,
  553. int len, void *buf);
  554. u16 brcms_b_rate_shm_offset(struct brcms_hardware *wlc_hw, u8 rate);
  555. void brcms_b_copyto_objmem(struct brcms_hardware *wlc_hw, uint offset,
  556. const void *buf, int len, u32 sel);
  557. void brcms_b_copyfrom_objmem(struct brcms_hardware *wlc_hw, uint offset,
  558. void *buf, int len, u32 sel);
  559. void brcms_b_switch_macfreq(struct brcms_hardware *wlc_hw, u8 spurmode);
  560. u16 brcms_b_get_txant(struct brcms_hardware *wlc_hw);
  561. void brcms_b_phyclk_fgc(struct brcms_hardware *wlc_hw, bool clk);
  562. void brcms_b_macphyclk_set(struct brcms_hardware *wlc_hw, bool clk);
  563. void brcms_b_core_phypll_ctl(struct brcms_hardware *wlc_hw, bool on);
  564. void brcms_b_txant_set(struct brcms_hardware *wlc_hw, u16 phytxant);
  565. void brcms_b_band_stf_ss_set(struct brcms_hardware *wlc_hw, u8 stf_mode);
  566. void brcms_c_init_scb(struct scb *scb);
  567. #endif /* _BRCM_MAIN_H_ */