mwifiex: use cfg80211 dynamic scan table and cfg80211_get_bss API
[pandora-kernel.git] / drivers / staging / ath6kl / wlan / include / ieee80211.h
1 //------------------------------------------------------------------------------
2 // <copyright file="ieee80211.h" company="Atheros">
3 //    Copyright (c) 2004-2010 Atheros Corporation.  All rights reserved.
4 // 
5 //
6 // Permission to use, copy, modify, and/or distribute this software for any
7 // purpose with or without fee is hereby granted, provided that the above
8 // copyright notice and this permission notice appear in all copies.
9 //
10 // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 // ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 //
18 //
19 //------------------------------------------------------------------------------
20 //==============================================================================
21 // Author(s): ="Atheros"
22 //==============================================================================
23 #ifndef _NET80211_IEEE80211_H_
24 #define _NET80211_IEEE80211_H_
25
26 /*
27  * 802.11 protocol definitions.
28  */
29 #define IEEE80211_WEP_KEYLEN        5   /* 40bit */
30 #define IEEE80211_WEP_IVLEN         3   /* 24bit */
31 #define IEEE80211_WEP_KIDLEN        1   /* 1 octet */
32 #define IEEE80211_WEP_CRCLEN        4   /* CRC-32 */
33 #define IEEE80211_WEP_NKID          4   /* number of key ids */
34
35 /*
36  * 802.11i defines an extended IV for use with non-WEP ciphers.
37  * When the EXTIV bit is set in the key id byte an additional
38  * 4 bytes immediately follow the IV for TKIP.  For CCMP the
39  * EXTIV bit is likewise set but the 8 bytes represent the
40  * CCMP header rather than IV+extended-IV.
41  */
42 #define IEEE80211_WEP_EXTIV         0x20
43 #define IEEE80211_WEP_EXTIVLEN      4   /* extended IV length */
44 #define IEEE80211_WEP_MICLEN        8   /* trailing MIC */
45
46 #define IEEE80211_CRC_LEN           4
47
48 #ifdef WAPI_ENABLE
49 #define IEEE80211_WAPI_EXTIVLEN      10   /* extended IV length */
50 #endif /* WAPI ENABLE */
51
52
53 #define IEEE80211_ADDR_LEN  6       /* size of 802.11 address */
54 /* is 802.11 address multicast/broadcast? */
55 #define IEEE80211_IS_MULTICAST(_a)  (*(_a) & 0x01)
56 #define IEEE80211_IS_BROADCAST(_a)  (*(_a) == 0xFF)
57 #define WEP_HEADER (IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN)
58 #define WEP_TRAILER IEEE80211_WEP_CRCLEN
59 #define CCMP_HEADER (IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN + \
60                     IEEE80211_WEP_EXTIVLEN)
61 #define CCMP_TRAILER IEEE80211_WEP_MICLEN
62 #define TKIP_HEADER (IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN + \
63                     IEEE80211_WEP_EXTIVLEN)
64 #define TKIP_TRAILER IEEE80211_WEP_CRCLEN
65 #define TKIP_MICLEN  IEEE80211_WEP_MICLEN
66
67
68 #define IEEE80211_ADDR_EQ(addr1, addr2)     \
69     (memcmp(addr1, addr2, IEEE80211_ADDR_LEN) == 0)
70
71 #define IEEE80211_ADDR_COPY(dst,src)    memcpy(dst,src,IEEE80211_ADDR_LEN)
72
73 #define IEEE80211_KEYBUF_SIZE 16
74 #define IEEE80211_MICBUF_SIZE (8+8)  /* space for both tx and rx */
75
76 /*
77  * NB: these values are ordered carefully; there are lots of
78  * of implications in any reordering.  In particular beware
79  * that 4 is not used to avoid conflicting with IEEE80211_F_PRIVACY.
80  */
81 #define IEEE80211_CIPHER_WEP            0
82 #define IEEE80211_CIPHER_TKIP           1
83 #define IEEE80211_CIPHER_AES_OCB        2
84 #define IEEE80211_CIPHER_AES_CCM        3
85 #define IEEE80211_CIPHER_CKIP           5
86 #define IEEE80211_CIPHER_CCKM_KRK       6
87 #define IEEE80211_CIPHER_NONE           7       /* pseudo value */
88
89 #define IEEE80211_CIPHER_MAX            (IEEE80211_CIPHER_NONE+1)
90
91 #define IEEE80211_IS_VALID_WEP_CIPHER_LEN(len) \
92         (((len) == 5) || ((len) == 13) || ((len) == 16))
93
94
95
96 /*
97  * generic definitions for IEEE 802.11 frames
98  */
99 PREPACK struct ieee80211_frame {
100     u8 i_fc[2];
101     u8 i_dur[2];
102     u8 i_addr1[IEEE80211_ADDR_LEN];
103     u8 i_addr2[IEEE80211_ADDR_LEN];
104     u8 i_addr3[IEEE80211_ADDR_LEN];
105     u8 i_seq[2];
106     /* possibly followed by addr4[IEEE80211_ADDR_LEN]; */
107     /* see below */
108 } POSTPACK;
109
110 PREPACK struct ieee80211_qosframe {
111     u8 i_fc[2];
112     u8 i_dur[2];
113     u8 i_addr1[IEEE80211_ADDR_LEN];
114     u8 i_addr2[IEEE80211_ADDR_LEN];
115     u8 i_addr3[IEEE80211_ADDR_LEN];
116     u8 i_seq[2];
117     u8 i_qos[2];
118 } POSTPACK;
119
120 #define IEEE80211_FC0_VERSION_MASK          0x03
121 #define IEEE80211_FC0_VERSION_SHIFT         0
122 #define IEEE80211_FC0_VERSION_0             0x00
123 #define IEEE80211_FC0_TYPE_MASK             0x0c
124 #define IEEE80211_FC0_TYPE_SHIFT            2
125 #define IEEE80211_FC0_TYPE_MGT              0x00
126 #define IEEE80211_FC0_TYPE_CTL              0x04
127 #define IEEE80211_FC0_TYPE_DATA             0x08
128
129 #define IEEE80211_FC0_SUBTYPE_MASK          0xf0
130 #define IEEE80211_FC0_SUBTYPE_SHIFT         4
131 /* for TYPE_MGT */
132 #define IEEE80211_FC0_SUBTYPE_ASSOC_REQ     0x00
133 #define IEEE80211_FC0_SUBTYPE_ASSOC_RESP    0x10
134 #define IEEE80211_FC0_SUBTYPE_REASSOC_REQ   0x20
135 #define IEEE80211_FC0_SUBTYPE_REASSOC_RESP  0x30
136 #define IEEE80211_FC0_SUBTYPE_PROBE_REQ     0x40
137 #define IEEE80211_FC0_SUBTYPE_PROBE_RESP    0x50
138 #define IEEE80211_FC0_SUBTYPE_BEACON        0x80
139 #define IEEE80211_FC0_SUBTYPE_ATIM          0x90
140 #define IEEE80211_FC0_SUBTYPE_DISASSOC      0xa0
141 #define IEEE80211_FC0_SUBTYPE_AUTH          0xb0
142 #define IEEE80211_FC0_SUBTYPE_DEAUTH        0xc0
143 /* for TYPE_CTL */
144 #define IEEE80211_FC0_SUBTYPE_PS_POLL       0xa0
145 #define IEEE80211_FC0_SUBTYPE_RTS           0xb0
146 #define IEEE80211_FC0_SUBTYPE_CTS           0xc0
147 #define IEEE80211_FC0_SUBTYPE_ACK           0xd0
148 #define IEEE80211_FC0_SUBTYPE_CF_END        0xe0
149 #define IEEE80211_FC0_SUBTYPE_CF_END_ACK    0xf0
150 /* for TYPE_DATA (bit combination) */
151 #define IEEE80211_FC0_SUBTYPE_DATA          0x00
152 #define IEEE80211_FC0_SUBTYPE_CF_ACK        0x10
153 #define IEEE80211_FC0_SUBTYPE_CF_POLL       0x20
154 #define IEEE80211_FC0_SUBTYPE_CF_ACPL       0x30
155 #define IEEE80211_FC0_SUBTYPE_NODATA        0x40
156 #define IEEE80211_FC0_SUBTYPE_CFACK         0x50
157 #define IEEE80211_FC0_SUBTYPE_CFPOLL        0x60
158 #define IEEE80211_FC0_SUBTYPE_CF_ACK_CF_ACK 0x70
159 #define IEEE80211_FC0_SUBTYPE_QOS           0x80
160 #define IEEE80211_FC0_SUBTYPE_QOS_NULL      0xc0
161
162 #define IEEE80211_FC1_DIR_MASK              0x03
163 #define IEEE80211_FC1_DIR_NODS              0x00    /* STA->STA */
164 #define IEEE80211_FC1_DIR_TODS              0x01    /* STA->AP  */
165 #define IEEE80211_FC1_DIR_FROMDS            0x02    /* AP ->STA */
166 #define IEEE80211_FC1_DIR_DSTODS            0x03    /* AP ->AP  */
167
168 #define IEEE80211_FC1_MORE_FRAG             0x04
169 #define IEEE80211_FC1_RETRY                 0x08
170 #define IEEE80211_FC1_PWR_MGT               0x10
171 #define IEEE80211_FC1_MORE_DATA             0x20
172 #define IEEE80211_FC1_WEP                   0x40
173 #define IEEE80211_FC1_ORDER                 0x80
174
175 #define IEEE80211_SEQ_FRAG_MASK             0x000f
176 #define IEEE80211_SEQ_FRAG_SHIFT            0
177 #define IEEE80211_SEQ_SEQ_MASK              0xfff0
178 #define IEEE80211_SEQ_SEQ_SHIFT             4
179
180 #define IEEE80211_NWID_LEN                  32
181
182 /*
183  * 802.11 rate set.
184  */
185 #define IEEE80211_RATE_SIZE     8       /* 802.11 standard */
186 #define IEEE80211_RATE_MAXSIZE  15      /* max rates we'll handle */
187
188 #define WMM_NUM_AC                  4   /* 4 AC categories */
189
190 #define WMM_PARAM_ACI_M         0x60    /* Mask for ACI field */
191 #define WMM_PARAM_ACI_S         5   /* Shift for ACI field */
192 #define WMM_PARAM_ACM_M         0x10    /* Mask for ACM bit */
193 #define WMM_PARAM_ACM_S         4       /* Shift for ACM bit */
194 #define WMM_PARAM_AIFSN_M       0x0f    /* Mask for aifsn field */
195 #define WMM_PARAM_LOGCWMIN_M    0x0f    /* Mask for CwMin field (in log) */
196 #define WMM_PARAM_LOGCWMAX_M    0xf0    /* Mask for CwMax field (in log) */
197 #define WMM_PARAM_LOGCWMAX_S    4   /* Shift for CwMax field */
198
199 #define WMM_AC_TO_TID(_ac) (       \
200     ((_ac) == WMM_AC_VO) ? 6 : \
201     ((_ac) == WMM_AC_VI) ? 5 : \
202     ((_ac) == WMM_AC_BK) ? 1 : \
203     0)
204
205 #define TID_TO_WMM_AC(_tid) (      \
206     ((_tid) < 1) ? WMM_AC_BE : \
207     ((_tid) < 3) ? WMM_AC_BK : \
208     ((_tid) < 6) ? WMM_AC_VI : \
209     WMM_AC_VO)
210 /*
211  * Management information element payloads.
212  */
213
214 enum {
215     IEEE80211_ELEMID_SSID       = 0,
216     IEEE80211_ELEMID_RATES      = 1,
217     IEEE80211_ELEMID_FHPARMS    = 2,
218     IEEE80211_ELEMID_DSPARMS    = 3,
219     IEEE80211_ELEMID_CFPARMS    = 4,
220     IEEE80211_ELEMID_TIM        = 5,
221     IEEE80211_ELEMID_IBSSPARMS  = 6,
222     IEEE80211_ELEMID_COUNTRY    = 7,
223     IEEE80211_ELEMID_CHALLENGE  = 16,
224     /* 17-31 reserved for challenge text extension */
225     IEEE80211_ELEMID_PWRCNSTR   = 32,
226     IEEE80211_ELEMID_PWRCAP     = 33,
227     IEEE80211_ELEMID_TPCREQ     = 34,
228     IEEE80211_ELEMID_TPCREP     = 35,
229     IEEE80211_ELEMID_SUPPCHAN   = 36,
230     IEEE80211_ELEMID_CHANSWITCH = 37,
231     IEEE80211_ELEMID_MEASREQ    = 38,
232     IEEE80211_ELEMID_MEASREP    = 39,
233     IEEE80211_ELEMID_QUIET      = 40,
234     IEEE80211_ELEMID_IBSSDFS    = 41,
235     IEEE80211_ELEMID_ERP        = 42,
236     IEEE80211_ELEMID_HTCAP_ANA  = 45,   /* Address ANA, and non-ANA story, for interop. CL#171733 */
237     IEEE80211_ELEMID_RSN        = 48,
238     IEEE80211_ELEMID_XRATES     = 50,
239     IEEE80211_ELEMID_HTINFO_ANA = 61,
240 #ifdef WAPI_ENABLE
241     IEEE80211_ELEMID_WAPI       = 68,
242 #endif
243     IEEE80211_ELEMID_TPC        = 150,
244     IEEE80211_ELEMID_CCKM       = 156,
245     IEEE80211_ELEMID_VENDOR     = 221,  /* vendor private */
246 };
247
248 #define ATH_OUI             0x7f0300        /* Atheros OUI */
249 #define ATH_OUI_TYPE        0x01
250 #define ATH_OUI_SUBTYPE     0x01
251 #define ATH_OUI_VERSION     0x00
252
253 #define WPA_OUI             0xf25000
254 #define WPA_OUI_TYPE        0x01
255 #define WPA_VERSION         1          /* current supported version */
256
257 #define WPA_CSE_NULL        0x00
258 #define WPA_CSE_WEP40       0x01
259 #define WPA_CSE_TKIP        0x02
260 #define WPA_CSE_CCMP        0x04
261 #define WPA_CSE_WEP104      0x05
262
263 #define WPA_ASE_NONE        0x00
264 #define WPA_ASE_8021X_UNSPEC    0x01
265 #define WPA_ASE_8021X_PSK   0x02
266
267 #define RSN_OUI         0xac0f00
268 #define RSN_VERSION     1       /* current supported version */
269
270 #define RSN_CSE_NULL        0x00
271 #define RSN_CSE_WEP40       0x01
272 #define RSN_CSE_TKIP        0x02
273 #define RSN_CSE_WRAP        0x03
274 #define RSN_CSE_CCMP        0x04
275 #define RSN_CSE_WEP104      0x05
276
277 #define RSN_ASE_NONE            0x00
278 #define RSN_ASE_8021X_UNSPEC    0x01
279 #define RSN_ASE_8021X_PSK       0x02
280
281 #define RSN_CAP_PREAUTH         0x01
282
283 #define WMM_OUI                 0xf25000
284 #define WMM_OUI_TYPE            0x02
285 #define WMM_INFO_OUI_SUBTYPE    0x00
286 #define WMM_PARAM_OUI_SUBTYPE   0x01
287 #define WMM_VERSION             1
288
289 /* WMM stream classes */
290 #define WMM_NUM_AC  4
291 #define WMM_AC_BE   0       /* best effort */
292 #define WMM_AC_BK   1       /* background */
293 #define WMM_AC_VI   2       /* video */
294 #define WMM_AC_VO   3       /* voice */
295
296 /* TSPEC related */
297 #define ACTION_CATEGORY_CODE_TSPEC                 17
298 #define ACTION_CODE_TSPEC_ADDTS                    0
299 #define ACTION_CODE_TSPEC_ADDTS_RESP               1
300 #define ACTION_CODE_TSPEC_DELTS                    2
301
302 typedef enum {
303     TSPEC_STATUS_CODE_ADMISSION_ACCEPTED = 0,
304     TSPEC_STATUS_CODE_ADDTS_INVALID_PARAMS = 0x1,
305     TSPEC_STATUS_CODE_ADDTS_REQUEST_REFUSED = 0x3,
306     TSPEC_STATUS_CODE_UNSPECIFIED_QOS_RELATED_FAILURE = 0xC8,
307     TSPEC_STATUS_CODE_REQUESTED_REFUSED_POLICY_CONFIGURATION = 0xC9,
308     TSPEC_STATUS_CODE_INSUFFCIENT_BANDWIDTH = 0xCA,
309     TSPEC_STATUS_CODE_INVALID_PARAMS = 0xCB,
310     TSPEC_STATUS_CODE_DELTS_SENT    = 0x30,
311     TSPEC_STATUS_CODE_DELTS_RECV    = 0x31,
312 } TSPEC_STATUS_CODE;
313
314 #define TSPEC_TSID_MASK             0xF
315 #define TSPEC_TSID_S                1
316
317 /*
318  * WMM/802.11e Tspec Element
319  */
320 typedef PREPACK struct wmm_tspec_ie_t {
321     u8 elementId;
322     u8 len;
323     u8 oui[3];
324     u8 ouiType;
325     u8 ouiSubType;
326     u8 version;
327     u16 tsInfo_info;
328     u8 tsInfo_reserved;
329     u16 nominalMSDU;
330     u16 maxMSDU;
331     u32 minServiceInt;
332     u32 maxServiceInt;
333     u32 inactivityInt;
334     u32 suspensionInt;
335     u32 serviceStartTime;
336     u32 minDataRate;
337     u32 meanDataRate;
338     u32 peakDataRate;
339     u32 maxBurstSize;
340     u32 delayBound;
341     u32 minPhyRate;
342     u16 sba;
343     u16 mediumTime;
344 } POSTPACK WMM_TSPEC_IE;
345
346
347 /*
348  * BEACON management packets
349  *
350  *  octet timestamp[8]
351  *  octet beacon interval[2]
352  *  octet capability information[2]
353  *  information element
354  *      octet elemid
355  *      octet length
356  *      octet information[length]
357  */
358
359 #define IEEE80211_BEACON_INTERVAL(beacon) \
360     ((beacon)[8] | ((beacon)[9] << 8))
361 #define IEEE80211_BEACON_CAPABILITY(beacon) \
362     ((beacon)[10] | ((beacon)[11] << 8))
363
364 #define IEEE80211_CAPINFO_ESS               0x0001
365 #define IEEE80211_CAPINFO_IBSS              0x0002
366 #define IEEE80211_CAPINFO_CF_POLLABLE       0x0004
367 #define IEEE80211_CAPINFO_CF_POLLREQ        0x0008
368 #define IEEE80211_CAPINFO_PRIVACY           0x0010
369 #define IEEE80211_CAPINFO_SHORT_PREAMBLE    0x0020
370 #define IEEE80211_CAPINFO_PBCC              0x0040
371 #define IEEE80211_CAPINFO_CHNL_AGILITY      0x0080
372 /* bits 8-9 are reserved */
373 #define IEEE80211_CAPINFO_SHORT_SLOTTIME    0x0400
374 #define IEEE80211_CAPINFO_APSD              0x0800
375 /* bit 12 is reserved */
376 #define IEEE80211_CAPINFO_DSSSOFDM          0x2000
377 /* bits 14-15 are reserved */
378
379 /*
380  * Authentication Modes
381  */
382
383 enum ieee80211_authmode {
384     IEEE80211_AUTH_NONE     = 0,
385     IEEE80211_AUTH_OPEN     = 1,
386     IEEE80211_AUTH_SHARED   = 2,
387     IEEE80211_AUTH_8021X    = 3,
388     IEEE80211_AUTH_AUTO     = 4,   /* auto-select/accept */
389     /* NB: these are used only for ioctls */
390     IEEE80211_AUTH_WPA      = 5,  /* WPA/RSN  w/ 802.1x */
391     IEEE80211_AUTH_WPA_PSK  = 6,  /* WPA/RSN  w/ PSK */
392     IEEE80211_AUTH_WPA_CCKM = 7,  /* WPA/RSN IE  w/ CCKM */
393 };
394
395 #define IEEE80211_PS_MAX_QUEUE    50 /*Maximum no of buffers that can be queues for PS*/
396
397 #endif /* _NET80211_IEEE80211_H_ */