main.h 24 KB

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