brcmu_wifi.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  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_MAX_2G_CHANNEL 14 /* Max channel in 2G band */
  32. #define BRCM_MAX_2G_CHANNEL CH_MAX_2G_CHANNEL /* legacy define */
  33. /* bandstate array indices */
  34. #define BAND_2G_INDEX 0 /* wlc->bandstate[x] index */
  35. #define BAND_5G_INDEX 1 /* wlc->bandstate[x] index */
  36. /*
  37. * max # supported channels. The max channel no is 216, this is that + 1
  38. * rounded up to a multiple of NBBY (8). DO NOT MAKE it > 255: channels are
  39. * u8's all over
  40. */
  41. #define MAXCHANNEL 224
  42. #define WL_CHANSPEC_CHAN_MASK 0x00ff
  43. #define WL_CHANSPEC_CHAN_SHIFT 0
  44. #define WL_CHANSPEC_CTL_SB_MASK 0x0300
  45. #define WL_CHANSPEC_CTL_SB_SHIFT 8
  46. #define WL_CHANSPEC_CTL_SB_LOWER 0x0100
  47. #define WL_CHANSPEC_CTL_SB_UPPER 0x0200
  48. #define WL_CHANSPEC_CTL_SB_NONE 0x0300
  49. #define WL_CHANSPEC_BW_MASK 0x0C00
  50. #define WL_CHANSPEC_BW_SHIFT 10
  51. #define WL_CHANSPEC_BW_10 0x0400
  52. #define WL_CHANSPEC_BW_20 0x0800
  53. #define WL_CHANSPEC_BW_40 0x0C00
  54. #define WL_CHANSPEC_BAND_MASK 0xf000
  55. #define WL_CHANSPEC_BAND_SHIFT 12
  56. #define WL_CHANSPEC_BAND_5G 0x1000
  57. #define WL_CHANSPEC_BAND_2G 0x2000
  58. #define INVCHANSPEC 255
  59. /* used to calculate the chan_freq = chan_factor * 500Mhz + 5 * chan_number */
  60. #define WF_CHAN_FACTOR_2_4_G 4814 /* 2.4 GHz band, 2407 MHz */
  61. #define WF_CHAN_FACTOR_5_G 10000 /* 5 GHz band, 5000 MHz */
  62. #define WF_CHAN_FACTOR_4_G 8000 /* 4.9 GHz band for Japan */
  63. #define CHSPEC_CHANNEL(chspec) ((u8)((chspec) & WL_CHANSPEC_CHAN_MASK))
  64. #define CHSPEC_BAND(chspec) ((chspec) & WL_CHANSPEC_BAND_MASK)
  65. #define CHSPEC_CTL_SB(chspec) ((chspec) & WL_CHANSPEC_CTL_SB_MASK)
  66. #define CHSPEC_BW(chspec) ((chspec) & WL_CHANSPEC_BW_MASK)
  67. #define CHSPEC_IS10(chspec) \
  68. (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_10)
  69. #define CHSPEC_IS20(chspec) \
  70. (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_20)
  71. #ifndef CHSPEC_IS40
  72. #define CHSPEC_IS40(chspec) \
  73. (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_40)
  74. #endif
  75. #define CHSPEC_IS5G(chspec) \
  76. (((chspec) & WL_CHANSPEC_BAND_MASK) == WL_CHANSPEC_BAND_5G)
  77. #define CHSPEC_IS2G(chspec) \
  78. (((chspec) & WL_CHANSPEC_BAND_MASK) == WL_CHANSPEC_BAND_2G)
  79. #define CHSPEC_SB_NONE(chspec) \
  80. (((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_NONE)
  81. #define CHSPEC_SB_UPPER(chspec) \
  82. (((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_UPPER)
  83. #define CHSPEC_SB_LOWER(chspec) \
  84. (((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_LOWER)
  85. #define CHSPEC_CTL_CHAN(chspec) \
  86. ((CHSPEC_SB_LOWER(chspec)) ? \
  87. (lower_20_sb(((chspec) & WL_CHANSPEC_CHAN_MASK))) : \
  88. (upper_20_sb(((chspec) & WL_CHANSPEC_CHAN_MASK))))
  89. #define CHSPEC2BAND(chspec) (CHSPEC_IS5G(chspec) ? BRCM_BAND_5G : BRCM_BAND_2G)
  90. #define CHANSPEC_STR_LEN 8
  91. static inline int lower_20_sb(int channel)
  92. {
  93. return channel > CH_10MHZ_APART ? (channel - CH_10MHZ_APART) : 0;
  94. }
  95. static inline int upper_20_sb(int channel)
  96. {
  97. return (channel < (MAXCHANNEL - CH_10MHZ_APART)) ?
  98. channel + CH_10MHZ_APART : 0;
  99. }
  100. static inline int chspec_bandunit(u16 chspec)
  101. {
  102. return CHSPEC_IS5G(chspec) ? BAND_5G_INDEX : BAND_2G_INDEX;
  103. }
  104. static inline u16 ch20mhz_chspec(int channel)
  105. {
  106. u16 rc = channel <= CH_MAX_2G_CHANNEL ?
  107. WL_CHANSPEC_BAND_2G : WL_CHANSPEC_BAND_5G;
  108. return (u16)((u16)channel | WL_CHANSPEC_BW_20 |
  109. WL_CHANSPEC_CTL_SB_NONE | rc);
  110. }
  111. static inline int next_20mhz_chan(int channel)
  112. {
  113. return channel < (MAXCHANNEL - CH_20MHZ_APART) ?
  114. channel + CH_20MHZ_APART : 0;
  115. }
  116. /* defined rate in 500kbps */
  117. #define BRCM_MAXRATE 108 /* in 500kbps units */
  118. #define BRCM_RATE_1M 2 /* in 500kbps units */
  119. #define BRCM_RATE_2M 4 /* in 500kbps units */
  120. #define BRCM_RATE_5M5 11 /* in 500kbps units */
  121. #define BRCM_RATE_11M 22 /* in 500kbps units */
  122. #define BRCM_RATE_6M 12 /* in 500kbps units */
  123. #define BRCM_RATE_9M 18 /* in 500kbps units */
  124. #define BRCM_RATE_12M 24 /* in 500kbps units */
  125. #define BRCM_RATE_18M 36 /* in 500kbps units */
  126. #define BRCM_RATE_24M 48 /* in 500kbps units */
  127. #define BRCM_RATE_36M 72 /* in 500kbps units */
  128. #define BRCM_RATE_48M 96 /* in 500kbps units */
  129. #define BRCM_RATE_54M 108 /* in 500kbps units */
  130. #define BRCM_2G_25MHZ_OFFSET 5 /* 2.4GHz band channel offset */
  131. #define MCSSET_LEN 16
  132. static inline bool ac_bitmap_tst(u8 bitmap, int prec)
  133. {
  134. return (bitmap & (1 << (prec))) != 0;
  135. }
  136. /* Enumerate crypto algorithms */
  137. #define CRYPTO_ALGO_OFF 0
  138. #define CRYPTO_ALGO_WEP1 1
  139. #define CRYPTO_ALGO_TKIP 2
  140. #define CRYPTO_ALGO_WEP128 3
  141. #define CRYPTO_ALGO_AES_CCM 4
  142. #define CRYPTO_ALGO_AES_RESERVED1 5
  143. #define CRYPTO_ALGO_AES_RESERVED2 6
  144. #define CRYPTO_ALGO_NALG 7
  145. /* wireless security bitvec */
  146. #define WEP_ENABLED 0x0001
  147. #define TKIP_ENABLED 0x0002
  148. #define AES_ENABLED 0x0004
  149. #define WSEC_SWFLAG 0x0008
  150. /* to go into transition mode without setting wep */
  151. #define SES_OW_ENABLED 0x0040
  152. /* WPA authentication mode bitvec */
  153. #define WPA_AUTH_DISABLED 0x0000 /* Legacy (i.e., non-WPA) */
  154. #define WPA_AUTH_NONE 0x0001 /* none (IBSS) */
  155. #define WPA_AUTH_UNSPECIFIED 0x0002 /* over 802.1x */
  156. #define WPA_AUTH_PSK 0x0004 /* Pre-shared key */
  157. #define WPA_AUTH_RESERVED1 0x0008
  158. #define WPA_AUTH_RESERVED2 0x0010
  159. #define WPA2_AUTH_RESERVED1 0x0020
  160. #define WPA2_AUTH_UNSPECIFIED 0x0040 /* over 802.1x */
  161. #define WPA2_AUTH_PSK 0x0080 /* Pre-shared key */
  162. #define WPA2_AUTH_RESERVED3 0x0200
  163. #define WPA2_AUTH_RESERVED4 0x0400
  164. #define WPA2_AUTH_RESERVED5 0x0800
  165. /* pmkid */
  166. #define MAXPMKID 16
  167. #define DOT11_DEFAULT_RTS_LEN 2347
  168. #define DOT11_DEFAULT_FRAG_LEN 2346
  169. #define DOT11_ICV_AES_LEN 8
  170. #define DOT11_QOS_LEN 2
  171. #define DOT11_IV_MAX_LEN 8
  172. #define DOT11_A4_HDR_LEN 30
  173. #define HT_CAP_RX_STBC_NO 0x0
  174. #define HT_CAP_RX_STBC_ONE_STREAM 0x1
  175. struct pmkid {
  176. u8 BSSID[ETH_ALEN];
  177. u8 PMKID[WLAN_PMKID_LEN];
  178. };
  179. struct pmkid_list {
  180. __le32 npmkid;
  181. struct pmkid pmkid[1];
  182. };
  183. struct pmkid_cand {
  184. u8 BSSID[ETH_ALEN];
  185. u8 preauth;
  186. };
  187. struct pmkid_cand_list {
  188. u32 npmkid_cand;
  189. struct pmkid_cand pmkid_cand[1];
  190. };
  191. #endif /* _BRCMU_WIFI_H_ */