brcmu_wifi.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  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. #define CHSPEC_CHANNEL(chspec) ((u8)((chspec) & WL_CHANSPEC_CHAN_MASK))
  60. #define CHSPEC_BAND(chspec) ((chspec) & WL_CHANSPEC_BAND_MASK)
  61. #define CHSPEC_CTL_SB(chspec) ((chspec) & WL_CHANSPEC_CTL_SB_MASK)
  62. #define CHSPEC_BW(chspec) ((chspec) & WL_CHANSPEC_BW_MASK)
  63. #define CHSPEC_IS10(chspec) \
  64. (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_10)
  65. #define CHSPEC_IS20(chspec) \
  66. (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_20)
  67. #ifndef CHSPEC_IS40
  68. #define CHSPEC_IS40(chspec) \
  69. (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_40)
  70. #endif
  71. #define CHSPEC_IS5G(chspec) \
  72. (((chspec) & WL_CHANSPEC_BAND_MASK) == WL_CHANSPEC_BAND_5G)
  73. #define CHSPEC_IS2G(chspec) \
  74. (((chspec) & WL_CHANSPEC_BAND_MASK) == WL_CHANSPEC_BAND_2G)
  75. #define CHSPEC_SB_NONE(chspec) \
  76. (((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_NONE)
  77. #define CHSPEC_SB_UPPER(chspec) \
  78. (((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_UPPER)
  79. #define CHSPEC_SB_LOWER(chspec) \
  80. (((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_LOWER)
  81. #define CHSPEC_CTL_CHAN(chspec) \
  82. ((CHSPEC_SB_LOWER(chspec)) ? \
  83. (lower_20_sb(((chspec) & WL_CHANSPEC_CHAN_MASK))) : \
  84. (upper_20_sb(((chspec) & WL_CHANSPEC_CHAN_MASK))))
  85. #define CHSPEC2BAND(chspec) (CHSPEC_IS5G(chspec) ? BRCM_BAND_5G : BRCM_BAND_2G)
  86. #define CHANSPEC_STR_LEN 8
  87. static inline int lower_20_sb(int channel)
  88. {
  89. return channel > CH_10MHZ_APART ? (channel - CH_10MHZ_APART) : 0;
  90. }
  91. static inline int upper_20_sb(int channel)
  92. {
  93. return (channel < (MAXCHANNEL - CH_10MHZ_APART)) ?
  94. channel + CH_10MHZ_APART : 0;
  95. }
  96. static inline int chspec_bandunit(u16 chspec)
  97. {
  98. return CHSPEC_IS5G(chspec) ? BAND_5G_INDEX : BAND_2G_INDEX;
  99. }
  100. static inline u16 ch20mhz_chspec(int channel)
  101. {
  102. u16 rc = channel <= CH_MAX_2G_CHANNEL ?
  103. WL_CHANSPEC_BAND_2G : WL_CHANSPEC_BAND_5G;
  104. return (u16)((u16)channel | WL_CHANSPEC_BW_20 |
  105. WL_CHANSPEC_CTL_SB_NONE | rc);
  106. }
  107. static inline int next_20mhz_chan(int channel)
  108. {
  109. return channel < (MAXCHANNEL - CH_20MHZ_APART) ?
  110. channel + CH_20MHZ_APART : 0;
  111. }
  112. /* defined rate in 500kbps */
  113. #define BRCM_MAXRATE 108 /* in 500kbps units */
  114. #define BRCM_RATE_1M 2 /* in 500kbps units */
  115. #define BRCM_RATE_2M 4 /* in 500kbps units */
  116. #define BRCM_RATE_5M5 11 /* in 500kbps units */
  117. #define BRCM_RATE_11M 22 /* in 500kbps units */
  118. #define BRCM_RATE_6M 12 /* in 500kbps units */
  119. #define BRCM_RATE_9M 18 /* in 500kbps units */
  120. #define BRCM_RATE_12M 24 /* in 500kbps units */
  121. #define BRCM_RATE_18M 36 /* in 500kbps units */
  122. #define BRCM_RATE_24M 48 /* in 500kbps units */
  123. #define BRCM_RATE_36M 72 /* in 500kbps units */
  124. #define BRCM_RATE_48M 96 /* in 500kbps units */
  125. #define BRCM_RATE_54M 108 /* in 500kbps units */
  126. #define BRCM_2G_25MHZ_OFFSET 5 /* 2.4GHz band channel offset */
  127. #define MCSSET_LEN 16
  128. static inline bool ac_bitmap_tst(u8 bitmap, int prec)
  129. {
  130. return (bitmap & (1 << (prec))) != 0;
  131. }
  132. /* Enumerate crypto algorithms */
  133. #define CRYPTO_ALGO_OFF 0
  134. #define CRYPTO_ALGO_WEP1 1
  135. #define CRYPTO_ALGO_TKIP 2
  136. #define CRYPTO_ALGO_WEP128 3
  137. #define CRYPTO_ALGO_AES_CCM 4
  138. #define CRYPTO_ALGO_AES_RESERVED1 5
  139. #define CRYPTO_ALGO_AES_RESERVED2 6
  140. #define CRYPTO_ALGO_NALG 7
  141. /* wireless security bitvec */
  142. #define WEP_ENABLED 0x0001
  143. #define TKIP_ENABLED 0x0002
  144. #define AES_ENABLED 0x0004
  145. #define WSEC_SWFLAG 0x0008
  146. /* to go into transition mode without setting wep */
  147. #define SES_OW_ENABLED 0x0040
  148. /* WPA authentication mode bitvec */
  149. #define WPA_AUTH_DISABLED 0x0000 /* Legacy (i.e., non-WPA) */
  150. #define WPA_AUTH_NONE 0x0001 /* none (IBSS) */
  151. #define WPA_AUTH_UNSPECIFIED 0x0002 /* over 802.1x */
  152. #define WPA_AUTH_PSK 0x0004 /* Pre-shared key */
  153. #define WPA_AUTH_RESERVED1 0x0008
  154. #define WPA_AUTH_RESERVED2 0x0010
  155. #define WPA2_AUTH_RESERVED1 0x0020
  156. #define WPA2_AUTH_UNSPECIFIED 0x0040 /* over 802.1x */
  157. #define WPA2_AUTH_PSK 0x0080 /* Pre-shared key */
  158. #define WPA2_AUTH_RESERVED3 0x0200
  159. #define WPA2_AUTH_RESERVED4 0x0400
  160. #define WPA2_AUTH_RESERVED5 0x0800
  161. /* pmkid */
  162. #define MAXPMKID 16
  163. #define DOT11_DEFAULT_RTS_LEN 2347
  164. #define DOT11_DEFAULT_FRAG_LEN 2346
  165. #define DOT11_ICV_AES_LEN 8
  166. #define DOT11_QOS_LEN 2
  167. #define DOT11_IV_MAX_LEN 8
  168. #define DOT11_A4_HDR_LEN 30
  169. #define HT_CAP_RX_STBC_NO 0x0
  170. #define HT_CAP_RX_STBC_ONE_STREAM 0x1
  171. struct pmkid {
  172. u8 BSSID[ETH_ALEN];
  173. u8 PMKID[WLAN_PMKID_LEN];
  174. };
  175. struct pmkid_list {
  176. __le32 npmkid;
  177. struct pmkid pmkid[1];
  178. };
  179. struct pmkid_cand {
  180. u8 BSSID[ETH_ALEN];
  181. u8 preauth;
  182. };
  183. struct pmkid_cand_list {
  184. u32 npmkid_cand;
  185. struct pmkid_cand pmkid_cand[1];
  186. };
  187. #endif /* _BRCMU_WIFI_H_ */