pub.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  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_PUB_H_
  17. #define _BRCM_PUB_H_
  18. #include <linux/bcma/bcma.h>
  19. #include <brcmu_wifi.h>
  20. #include "types.h"
  21. #include "defs.h"
  22. #define BRCMS_NUMRATES 16 /* max # of rates in a rateset */
  23. /* phy types */
  24. #define PHY_TYPE_A 0 /* Phy type A */
  25. #define PHY_TYPE_G 2 /* Phy type G */
  26. #define PHY_TYPE_N 4 /* Phy type N */
  27. #define PHY_TYPE_LP 5 /* Phy type Low Power A/B/G */
  28. #define PHY_TYPE_SSN 6 /* Phy type Single Stream N */
  29. #define PHY_TYPE_LCN 8 /* Phy type Single Stream N */
  30. #define PHY_TYPE_LCNXN 9 /* Phy type 2-stream N */
  31. #define PHY_TYPE_HT 7 /* Phy type 3-Stream N */
  32. /* bw */
  33. #define BRCMS_10_MHZ 10 /* 10Mhz nphy channel bandwidth */
  34. #define BRCMS_20_MHZ 20 /* 20Mhz nphy channel bandwidth */
  35. #define BRCMS_40_MHZ 40 /* 40Mhz nphy channel bandwidth */
  36. #define BRCMS_RSSI_MINVAL -200 /* Low value, e.g. for forcing roam */
  37. #define BRCMS_RSSI_NO_SIGNAL -91 /* NDIS RSSI link quality cutoffs */
  38. #define BRCMS_RSSI_VERY_LOW -80 /* Very low quality cutoffs */
  39. #define BRCMS_RSSI_LOW -70 /* Low quality cutoffs */
  40. #define BRCMS_RSSI_GOOD -68 /* Good quality cutoffs */
  41. #define BRCMS_RSSI_VERY_GOOD -58 /* Very good quality cutoffs */
  42. #define BRCMS_RSSI_EXCELLENT -57 /* Excellent quality cutoffs */
  43. /* a large TX Power as an init value to factor out of min() calculations,
  44. * keep low enough to fit in an s8, units are .25 dBm
  45. */
  46. #define BRCMS_TXPWR_MAX (127) /* ~32 dBm = 1,500 mW */
  47. /* rate related definitions */
  48. #define BRCMS_RATE_FLAG 0x80 /* Flag to indicate it is a basic rate */
  49. #define BRCMS_RATE_MASK 0x7f /* Rate value mask w/o basic rate flag */
  50. /* legacy rx Antenna diversity for SISO rates */
  51. #define ANT_RX_DIV_FORCE_0 0 /* Use antenna 0 */
  52. #define ANT_RX_DIV_FORCE_1 1 /* Use antenna 1 */
  53. #define ANT_RX_DIV_START_1 2 /* Choose starting with 1 */
  54. #define ANT_RX_DIV_START_0 3 /* Choose starting with 0 */
  55. #define ANT_RX_DIV_ENABLE 3 /* APHY bbConfig Enable RX Diversity */
  56. /* default antdiv setting */
  57. #define ANT_RX_DIV_DEF ANT_RX_DIV_START_0
  58. /* legacy rx Antenna diversity for SISO rates */
  59. /* Tx on antenna 0, "legacy term Main" */
  60. #define ANT_TX_FORCE_0 0
  61. /* Tx on antenna 1, "legacy term Aux" */
  62. #define ANT_TX_FORCE_1 1
  63. /* Tx on phy's last good Rx antenna */
  64. #define ANT_TX_LAST_RX 3
  65. /* driver's default tx antenna setting */
  66. #define ANT_TX_DEF 3
  67. /* Tx Chain values */
  68. /* def bitmap of txchain */
  69. #define TXCHAIN_DEF 0x1
  70. /* default bitmap of tx chains for nphy */
  71. #define TXCHAIN_DEF_NPHY 0x3
  72. /* default bitmap of tx chains for nphy */
  73. #define TXCHAIN_DEF_HTPHY 0x7
  74. /* def bitmap of rxchain */
  75. #define RXCHAIN_DEF 0x1
  76. /* default bitmap of rx chains for nphy */
  77. #define RXCHAIN_DEF_NPHY 0x3
  78. /* default bitmap of rx chains for nphy */
  79. #define RXCHAIN_DEF_HTPHY 0x7
  80. /* no antenna switch */
  81. #define ANTSWITCH_NONE 0
  82. /* antenna switch on 4321CB2, 2of3 */
  83. #define ANTSWITCH_TYPE_1 1
  84. /* antenna switch on 4321MPCI, 2of3 */
  85. #define ANTSWITCH_TYPE_2 2
  86. /* antenna switch on 4322, 2of3 */
  87. #define ANTSWITCH_TYPE_3 3
  88. #define RXBUFSZ PKTBUFSZ
  89. #define MAX_STREAMS_SUPPORTED 4 /* max number of streams supported */
  90. struct brcm_rateset {
  91. /* # rates in this set */
  92. u32 count;
  93. /* rates in 500kbps units w/hi bit set if basic */
  94. u8 rates[WL_NUMRATES];
  95. };
  96. struct brcms_c_rateset {
  97. uint count; /* number of rates in rates[] */
  98. /* rates in 500kbps units w/hi bit set if basic */
  99. u8 rates[BRCMS_NUMRATES];
  100. u8 htphy_membership; /* HT PHY Membership */
  101. u8 mcs[MCSSET_LEN]; /* supported mcs index bit map */
  102. };
  103. /* All the HT-specific default advertised capabilities (including AMPDU)
  104. * should be grouped here at one place
  105. */
  106. #define AMPDU_DEF_MPDU_DENSITY 6 /* default mpdu density (110 ==> 4us) */
  107. /* wlc internal bss_info */
  108. struct brcms_bss_info {
  109. u8 BSSID[ETH_ALEN]; /* network BSSID */
  110. u16 flags; /* flags for internal attributes */
  111. u8 SSID_len; /* the length of SSID */
  112. u8 SSID[32]; /* SSID string */
  113. s16 RSSI; /* receive signal strength (in dBm) */
  114. s16 SNR; /* receive signal SNR in dB */
  115. u16 beacon_period; /* units are Kusec */
  116. u16 chanspec; /* Channel num, bw, ctrl_sb and band */
  117. struct brcms_c_rateset rateset; /* supported rates */
  118. };
  119. #define MAC80211_PROMISC_BCNS (1 << 0)
  120. #define MAC80211_SCAN (1 << 1)
  121. /*
  122. * Public portion of common driver state structure.
  123. * The wlc handle points at this.
  124. */
  125. struct brcms_pub {
  126. struct brcms_c_info *wlc;
  127. struct ieee80211_hw *ieee_hw;
  128. struct scb_ampdu *global_ampdu;
  129. uint mac80211_state;
  130. uint unit; /* device instance number */
  131. uint corerev; /* core revision */
  132. struct si_pub *sih; /* SI handle (cookie for siutils calls) */
  133. bool up; /* interface up and running */
  134. bool hw_off; /* HW is off */
  135. bool hw_up; /* one time hw up/down */
  136. bool _piomode; /* true if pio mode */
  137. uint _nbands; /* # bands supported */
  138. uint now; /* # elapsed seconds */
  139. bool delayed_down; /* down delayed */
  140. bool associated; /* true:part of [I]BSS, false: not */
  141. /* (union of stas_associated, aps_associated) */
  142. bool _ampdu; /* ampdu enabled or not */
  143. u8 _n_enab; /* bitmap of 11N + HT support */
  144. u8 cur_etheraddr[ETH_ALEN]; /* our local ethernet address */
  145. u32 radio_disabled; /* bit vector for radio disabled reasons */
  146. u16 boardrev; /* version # of particular board */
  147. u8 sromrev; /* version # of the srom */
  148. char srom_ccode[BRCM_CNTRY_BUF_SZ]; /* Country Code in SROM */
  149. u32 boardflags; /* Board specific flags from srom */
  150. u32 boardflags2; /* More board flags if sromrev >= 4 */
  151. bool phy_11ncapable; /* the PHY/HW is capable of 802.11N */
  152. struct wl_cnt *_cnt; /* low-level counters in driver */
  153. struct dentry *dbgfs_dir;
  154. };
  155. enum wlc_par_id {
  156. IOV_MPC = 1,
  157. IOV_RTSTHRESH,
  158. IOV_QTXPOWER,
  159. IOV_BCN_LI_BCN /* Beacon listen interval in # of beacons */
  160. };
  161. /***********************************************
  162. * Feature-related macros to optimize out code *
  163. * *********************************************
  164. */
  165. #define ENAB_1x1 0x01
  166. #define ENAB_2x2 0x02
  167. #define ENAB_3x3 0x04
  168. #define ENAB_4x4 0x08
  169. #define SUPPORT_11N (ENAB_1x1|ENAB_2x2)
  170. #define SUPPORT_HT (ENAB_1x1|ENAB_2x2|ENAB_3x3)
  171. /* WL11N Support */
  172. #define AMPDU_AGG_HOST 1
  173. /* network protection config */
  174. #define BRCMS_PROT_G_SPEC 1 /* SPEC g protection */
  175. #define BRCMS_PROT_G_OVR 2 /* SPEC g prot override */
  176. #define BRCMS_PROT_G_USER 3 /* gmode specified by user */
  177. #define BRCMS_PROT_OVERLAP 4 /* overlap */
  178. #define BRCMS_PROT_N_USER 10 /* nmode specified by user */
  179. #define BRCMS_PROT_N_CFG 11 /* n protection */
  180. #define BRCMS_PROT_N_CFG_OVR 12 /* n protection override */
  181. #define BRCMS_PROT_N_NONGF 13 /* non-GF protection */
  182. #define BRCMS_PROT_N_NONGF_OVR 14 /* non-GF protection override */
  183. #define BRCMS_PROT_N_PAM_OVR 15 /* n preamble override */
  184. #define BRCMS_PROT_N_OBSS 16 /* non-HT OBSS present */
  185. /*
  186. * 54g modes (basic bits may still be overridden)
  187. *
  188. * GMODE_LEGACY_B
  189. * Rateset: 1b, 2b, 5.5, 11
  190. * Preamble: Long
  191. * Shortslot: Off
  192. * GMODE_AUTO
  193. * Rateset: 1b, 2b, 5.5b, 11b, 18, 24, 36, 54
  194. * Extended Rateset: 6, 9, 12, 48
  195. * Preamble: Long
  196. * Shortslot: Auto
  197. * GMODE_ONLY
  198. * Rateset: 1b, 2b, 5.5b, 11b, 18, 24b, 36, 54
  199. * Extended Rateset: 6b, 9, 12b, 48
  200. * Preamble: Short required
  201. * Shortslot: Auto
  202. * GMODE_B_DEFERRED
  203. * Rateset: 1b, 2b, 5.5b, 11b, 18, 24, 36, 54
  204. * Extended Rateset: 6, 9, 12, 48
  205. * Preamble: Long
  206. * Shortslot: On
  207. * GMODE_PERFORMANCE
  208. * Rateset: 1b, 2b, 5.5b, 6b, 9, 11b, 12b, 18, 24b, 36, 48, 54
  209. * Preamble: Short required
  210. * Shortslot: On and required
  211. * GMODE_LRS
  212. * Rateset: 1b, 2b, 5.5b, 11b
  213. * Extended Rateset: 6, 9, 12, 18, 24, 36, 48, 54
  214. * Preamble: Long
  215. * Shortslot: Auto
  216. */
  217. #define GMODE_LEGACY_B 0
  218. #define GMODE_AUTO 1
  219. #define GMODE_ONLY 2
  220. #define GMODE_B_DEFERRED 3
  221. #define GMODE_PERFORMANCE 4
  222. #define GMODE_LRS 5
  223. #define GMODE_MAX 6
  224. /* MCS values greater than this enable multiple streams */
  225. #define HIGHEST_SINGLE_STREAM_MCS 7
  226. #define MAXBANDS 2 /* Maximum #of bands */
  227. /* max number of antenna configurations */
  228. #define ANT_SELCFG_MAX 4
  229. struct brcms_antselcfg {
  230. u8 ant_config[ANT_SELCFG_MAX]; /* antenna configuration */
  231. u8 num_antcfg; /* number of available antenna configurations */
  232. };
  233. /* common functions for every port */
  234. struct brcms_c_info *brcms_c_attach(struct brcms_info *wl,
  235. struct bcma_device *core, uint unit,
  236. bool piomode, uint *perr);
  237. uint brcms_c_detach(struct brcms_c_info *wlc);
  238. int brcms_c_up(struct brcms_c_info *wlc);
  239. uint brcms_c_down(struct brcms_c_info *wlc);
  240. bool brcms_c_chipmatch(struct bcma_device *core);
  241. void brcms_c_init(struct brcms_c_info *wlc, bool mute_tx);
  242. void brcms_c_reset(struct brcms_c_info *wlc);
  243. void brcms_c_intrson(struct brcms_c_info *wlc);
  244. u32 brcms_c_intrsoff(struct brcms_c_info *wlc);
  245. void brcms_c_intrsrestore(struct brcms_c_info *wlc, u32 macintmask);
  246. bool brcms_c_intrsupd(struct brcms_c_info *wlc);
  247. bool brcms_c_isr(struct brcms_c_info *wlc);
  248. bool brcms_c_dpc(struct brcms_c_info *wlc, bool bounded);
  249. bool brcms_c_sendpkt_mac80211(struct brcms_c_info *wlc, struct sk_buff *sdu,
  250. struct ieee80211_hw *hw);
  251. bool brcms_c_aggregatable(struct brcms_c_info *wlc, u8 tid);
  252. void brcms_c_protection_upd(struct brcms_c_info *wlc, uint idx, int val);
  253. int brcms_c_get_header_len(void);
  254. void brcms_c_set_addrmatch(struct brcms_c_info *wlc, int match_reg_offset,
  255. const u8 *addr);
  256. void brcms_c_wme_setparams(struct brcms_c_info *wlc, u16 aci,
  257. const struct ieee80211_tx_queue_params *arg,
  258. bool suspend);
  259. struct brcms_pub *brcms_c_pub(struct brcms_c_info *wlc);
  260. void brcms_c_ampdu_flush(struct brcms_c_info *wlc, struct ieee80211_sta *sta,
  261. u16 tid);
  262. void brcms_c_ampdu_tx_operational(struct brcms_c_info *wlc, u8 tid,
  263. u8 ba_wsize, uint max_rx_ampdu_bytes);
  264. int brcms_c_module_register(struct brcms_pub *pub, const char *name,
  265. struct brcms_info *hdl,
  266. int (*down_fn)(void *handle));
  267. int brcms_c_module_unregister(struct brcms_pub *pub, const char *name,
  268. struct brcms_info *hdl);
  269. void brcms_c_suspend_mac_and_wait(struct brcms_c_info *wlc);
  270. void brcms_c_enable_mac(struct brcms_c_info *wlc);
  271. void brcms_c_associate_upd(struct brcms_c_info *wlc, bool state);
  272. void brcms_c_scan_start(struct brcms_c_info *wlc);
  273. void brcms_c_scan_stop(struct brcms_c_info *wlc);
  274. int brcms_c_get_curband(struct brcms_c_info *wlc);
  275. int brcms_c_set_channel(struct brcms_c_info *wlc, u16 channel);
  276. int brcms_c_set_rate_limit(struct brcms_c_info *wlc, u16 srl, u16 lrl);
  277. void brcms_c_get_current_rateset(struct brcms_c_info *wlc,
  278. struct brcm_rateset *currs);
  279. int brcms_c_set_rateset(struct brcms_c_info *wlc, struct brcm_rateset *rs);
  280. int brcms_c_set_beacon_period(struct brcms_c_info *wlc, u16 period);
  281. u16 brcms_c_get_phy_type(struct brcms_c_info *wlc, int phyidx);
  282. void brcms_c_set_shortslot_override(struct brcms_c_info *wlc,
  283. s8 sslot_override);
  284. void brcms_c_set_beacon_listen_interval(struct brcms_c_info *wlc, u8 interval);
  285. u64 brcms_c_tsf_get(struct brcms_c_info *wlc);
  286. void brcms_c_tsf_set(struct brcms_c_info *wlc, u64 tsf);
  287. int brcms_c_set_tx_power(struct brcms_c_info *wlc, int txpwr);
  288. int brcms_c_get_tx_power(struct brcms_c_info *wlc);
  289. bool brcms_c_check_radio_disabled(struct brcms_c_info *wlc);
  290. void brcms_c_mute(struct brcms_c_info *wlc, bool on);
  291. bool brcms_c_tx_flush_completed(struct brcms_c_info *wlc);
  292. void brcms_c_start_station(struct brcms_c_info *wlc, u8 *addr);
  293. void brcms_c_start_ap(struct brcms_c_info *wlc, u8 *addr, const u8 *bssid,
  294. u8 *ssid, size_t ssid_len);
  295. void brcms_c_start_adhoc(struct brcms_c_info *wlc, u8 *addr);
  296. void brcms_c_update_beacon(struct brcms_c_info *wlc);
  297. void brcms_c_set_new_beacon(struct brcms_c_info *wlc, struct sk_buff *beacon,
  298. u16 tim_offset, u16 dtim_period);
  299. void brcms_c_set_new_probe_resp(struct brcms_c_info *wlc,
  300. struct sk_buff *probe_resp);
  301. void brcms_c_enable_probe_resp(struct brcms_c_info *wlc, bool enable);
  302. void brcms_c_set_ssid(struct brcms_c_info *wlc, u8 *ssid, size_t ssid_len);
  303. #endif /* _BRCM_PUB_H_ */