main.h 23 KB

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