brcmu_wifi.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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 _BRCMU_WIFI_H_
  17. #define _BRCMU_WIFI_H_
  18. #include <linux/if_ether.h> /* for ETH_ALEN */
  19. #include <linux/ieee80211.h> /* for WLAN_PMKID_LEN */
  20. /*
  21. * A chanspec (u16) holds the channel number, band, bandwidth and control
  22. * sideband
  23. */
  24. /* channel defines */
  25. #define CH_UPPER_SB 0x01
  26. #define CH_LOWER_SB 0x02
  27. #define CH_EWA_VALID 0x04
  28. #define CH_20MHZ_APART 4
  29. #define CH_10MHZ_APART 2
  30. #define CH_5MHZ_APART 1 /* 2G band channels are 5 Mhz apart */
  31. #define CH_MIN_2G_CHANNEL 1
  32. #define CH_MAX_2G_CHANNEL 14 /* Max channel in 2G band */
  33. #define CH_MIN_5G_CHANNEL 34
  34. /* bandstate array indices */
  35. #define BAND_2G_INDEX 0 /* wlc->bandstate[x] index */
  36. #define BAND_5G_INDEX 1 /* wlc->bandstate[x] index */
  37. /*
  38. * max # supported channels. The max channel no is 216, this is that + 1
  39. * rounded up to a multiple of NBBY (8). DO NOT MAKE it > 255: channels are
  40. * u8's all over
  41. */
  42. #define MAXCHANNEL 224
  43. #define WL_CHANSPEC_CHAN_MASK 0x00ff
  44. #define WL_CHANSPEC_CHAN_SHIFT 0
  45. #define WL_CHANSPEC_CTL_SB_MASK 0x0300
  46. #define WL_CHANSPEC_CTL_SB_SHIFT 8
  47. #define WL_CHANSPEC_CTL_SB_LOWER 0x0100
  48. #define WL_CHANSPEC_CTL_SB_UPPER 0x0200
  49. #define WL_CHANSPEC_CTL_SB_NONE 0x0300
  50. #define WL_CHANSPEC_BW_MASK 0x0C00
  51. #define WL_CHANSPEC_BW_SHIFT 10
  52. #define WL_CHANSPEC_BW_10 0x0400
  53. #define WL_CHANSPEC_BW_20 0x0800
  54. #define WL_CHANSPEC_BW_40 0x0C00
  55. #define WL_CHANSPEC_BW_80 0x2000
  56. #define WL_CHANSPEC_BAND_MASK 0xf000
  57. #define WL_CHANSPEC_BAND_SHIFT 12
  58. #define WL_CHANSPEC_BAND_5G 0x1000
  59. #define WL_CHANSPEC_BAND_2G 0x2000
  60. #define INVCHANSPEC 255
  61. #define WL_CHAN_VALID_HW (1 << 0) /* valid with current HW */
  62. #define WL_CHAN_VALID_SW (1 << 1) /* valid with country sett. */
  63. #define WL_CHAN_BAND_5G (1 << 2) /* 5GHz-band channel */
  64. #define WL_CHAN_RADAR (1 << 3) /* radar sensitive channel */
  65. #define WL_CHAN_INACTIVE (1 << 4) /* inactive due to radar */
  66. #define WL_CHAN_PASSIVE (1 << 5) /* channel in passive mode */
  67. #define WL_CHAN_RESTRICTED (1 << 6) /* restricted use channel */
  68. /* values for band specific 40MHz capabilities */
  69. #define WLC_N_BW_20ALL 0
  70. #define WLC_N_BW_40ALL 1
  71. #define WLC_N_BW_20IN2G_40IN5G 2
  72. /* band types */
  73. #define WLC_BAND_AUTO 0 /* auto-select */
  74. #define WLC_BAND_5G 1 /* 5 Ghz */
  75. #define WLC_BAND_2G 2 /* 2.4 Ghz */
  76. #define WLC_BAND_ALL 3 /* all bands */
  77. #define CHSPEC_CHANNEL(chspec) ((u8)((chspec) & WL_CHANSPEC_CHAN_MASK))
  78. #define CHSPEC_BAND(chspec) ((chspec) & WL_CHANSPEC_BAND_MASK)
  79. #define CHSPEC_CTL_SB(chspec) ((chspec) & WL_CHANSPEC_CTL_SB_MASK)
  80. #define CHSPEC_BW(chspec) ((chspec) & WL_CHANSPEC_BW_MASK)
  81. #define CHSPEC_IS10(chspec) \
  82. (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_10)
  83. #define CHSPEC_IS20(chspec) \
  84. (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_20)
  85. #define CHSPEC_IS40(chspec) \
  86. (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_40)
  87. #define CHSPEC_IS80(chspec) \
  88. (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_80)
  89. #define CHSPEC_IS5G(chspec) \
  90. (((chspec) & WL_CHANSPEC_BAND_MASK) == WL_CHANSPEC_BAND_5G)
  91. #define CHSPEC_IS2G(chspec) \
  92. (((chspec) & WL_CHANSPEC_BAND_MASK) == WL_CHANSPEC_BAND_2G)
  93. #define CHSPEC_SB_NONE(chspec) \
  94. (((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_NONE)
  95. #define CHSPEC_SB_UPPER(chspec) \
  96. (((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_UPPER)
  97. #define CHSPEC_SB_LOWER(chspec) \
  98. (((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_LOWER)
  99. #define CHSPEC_CTL_CHAN(chspec) \
  100. ((CHSPEC_SB_LOWER(chspec)) ? \
  101. (lower_20_sb(((chspec) & WL_CHANSPEC_CHAN_MASK))) : \
  102. (upper_20_sb(((chspec) & WL_CHANSPEC_CHAN_MASK))))
  103. #define CHSPEC2BAND(chspec) (CHSPEC_IS5G(chspec) ? BRCM_BAND_5G : BRCM_BAND_2G)
  104. #define CHANSPEC_STR_LEN 8
  105. static inline int lower_20_sb(int channel)
  106. {
  107. return channel > CH_10MHZ_APART ? (channel - CH_10MHZ_APART) : 0;
  108. }
  109. static inline int upper_20_sb(int channel)
  110. {
  111. return (channel < (MAXCHANNEL - CH_10MHZ_APART)) ?
  112. channel + CH_10MHZ_APART : 0;
  113. }
  114. static inline int chspec_bandunit(u16 chspec)
  115. {
  116. return CHSPEC_IS5G(chspec) ? BAND_5G_INDEX : BAND_2G_INDEX;
  117. }
  118. static inline u16 ch20mhz_chspec(int channel)
  119. {
  120. u16 rc = channel <= CH_MAX_2G_CHANNEL ?
  121. WL_CHANSPEC_BAND_2G : WL_CHANSPEC_BAND_5G;
  122. return (u16)((u16)channel | WL_CHANSPEC_BW_20 |
  123. WL_CHANSPEC_CTL_SB_NONE | rc);
  124. }
  125. static inline int next_20mhz_chan(int channel)
  126. {
  127. return channel < (MAXCHANNEL - CH_20MHZ_APART) ?
  128. channel + CH_20MHZ_APART : 0;
  129. }
  130. /* defined rate in 500kbps */
  131. #define BRCM_MAXRATE 108 /* in 500kbps units */
  132. #define BRCM_RATE_1M 2 /* in 500kbps units */
  133. #define BRCM_RATE_2M 4 /* in 500kbps units */
  134. #define BRCM_RATE_5M5 11 /* in 500kbps units */
  135. #define BRCM_RATE_11M 22 /* in 500kbps units */
  136. #define BRCM_RATE_6M 12 /* in 500kbps units */
  137. #define BRCM_RATE_9M 18 /* in 500kbps units */
  138. #define BRCM_RATE_12M 24 /* in 500kbps units */
  139. #define BRCM_RATE_18M 36 /* in 500kbps units */
  140. #define BRCM_RATE_24M 48 /* in 500kbps units */
  141. #define BRCM_RATE_36M 72 /* in 500kbps units */
  142. #define BRCM_RATE_48M 96 /* in 500kbps units */
  143. #define BRCM_RATE_54M 108 /* in 500kbps units */
  144. #define BRCM_2G_25MHZ_OFFSET 5 /* 2.4GHz band channel offset */
  145. #define MCSSET_LEN 16
  146. static inline bool ac_bitmap_tst(u8 bitmap, int prec)
  147. {
  148. return (bitmap & (1 << (prec))) != 0;
  149. }
  150. /* Enumerate crypto algorithms */
  151. #define CRYPTO_ALGO_OFF 0
  152. #define CRYPTO_ALGO_WEP1 1
  153. #define CRYPTO_ALGO_TKIP 2
  154. #define CRYPTO_ALGO_WEP128 3
  155. #define CRYPTO_ALGO_AES_CCM 4
  156. #define CRYPTO_ALGO_AES_RESERVED1 5
  157. #define CRYPTO_ALGO_AES_RESERVED2 6
  158. #define CRYPTO_ALGO_NALG 7
  159. /* wireless security bitvec */
  160. #define WEP_ENABLED 0x0001
  161. #define TKIP_ENABLED 0x0002
  162. #define AES_ENABLED 0x0004
  163. #define WSEC_SWFLAG 0x0008
  164. /* to go into transition mode without setting wep */
  165. #define SES_OW_ENABLED 0x0040
  166. /* WPA authentication mode bitvec */
  167. #define WPA_AUTH_DISABLED 0x0000 /* Legacy (i.e., non-WPA) */
  168. #define WPA_AUTH_NONE 0x0001 /* none (IBSS) */
  169. #define WPA_AUTH_UNSPECIFIED 0x0002 /* over 802.1x */
  170. #define WPA_AUTH_PSK 0x0004 /* Pre-shared key */
  171. #define WPA_AUTH_RESERVED1 0x0008
  172. #define WPA_AUTH_RESERVED2 0x0010
  173. #define WPA2_AUTH_RESERVED1 0x0020
  174. #define WPA2_AUTH_UNSPECIFIED 0x0040 /* over 802.1x */
  175. #define WPA2_AUTH_PSK 0x0080 /* Pre-shared key */
  176. #define WPA2_AUTH_RESERVED3 0x0200
  177. #define WPA2_AUTH_RESERVED4 0x0400
  178. #define WPA2_AUTH_RESERVED5 0x0800
  179. /* pmkid */
  180. #define MAXPMKID 16
  181. #define DOT11_DEFAULT_RTS_LEN 2347
  182. #define DOT11_DEFAULT_FRAG_LEN 2346
  183. #define DOT11_ICV_AES_LEN 8
  184. #define DOT11_QOS_LEN 2
  185. #define DOT11_IV_MAX_LEN 8
  186. #define DOT11_A4_HDR_LEN 30
  187. #define HT_CAP_RX_STBC_NO 0x0
  188. #define HT_CAP_RX_STBC_ONE_STREAM 0x1
  189. struct pmkid {
  190. u8 BSSID[ETH_ALEN];
  191. u8 PMKID[WLAN_PMKID_LEN];
  192. };
  193. struct pmkid_list {
  194. __le32 npmkid;
  195. struct pmkid pmkid[1];
  196. };
  197. struct pmkid_cand {
  198. u8 BSSID[ETH_ALEN];
  199. u8 preauth;
  200. };
  201. struct pmkid_cand_list {
  202. u32 npmkid_cand;
  203. struct pmkid_cand pmkid_cand[1];
  204. };
  205. #endif /* _BRCMU_WIFI_H_ */