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