blob: ffde19c5ac5c312665fc4e3f293d54ce057babfd [file] [log] [blame]
Henry Ptasinskia9533e72010-09-08 21:04:42 -07001/*
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 _802_11_H_
18#define _802_11_H_
19
Henry Ptasinskia9533e72010-09-08 21:04:42 -070020#include <proto/wpa.h>
Henry Ptasinskia9533e72010-09-08 21:04:42 -070021#include <packed_section_start.h>
22
Henry Ptasinskia9533e72010-09-08 21:04:42 -070023#define DOT11_A3_HDR_LEN 24
24#define DOT11_A4_HDR_LEN 30
25#define DOT11_MAC_HDR_LEN DOT11_A3_HDR_LEN
26#define DOT11_FCS_LEN 4
Henry Ptasinskia9533e72010-09-08 21:04:42 -070027#define DOT11_ICV_AES_LEN 8
28#define DOT11_QOS_LEN 2
Henry Ptasinskia9533e72010-09-08 21:04:42 -070029
Henry Ptasinskia9533e72010-09-08 21:04:42 -070030#define DOT11_IV_MAX_LEN 8
31
Henry Ptasinskia9533e72010-09-08 21:04:42 -070032#define DOT11_MAX_SSID_LEN 32
33
34#define DOT11_DEFAULT_RTS_LEN 2347
Henry Ptasinskia9533e72010-09-08 21:04:42 -070035
36#define DOT11_MIN_FRAG_LEN 256
37#define DOT11_MAX_FRAG_LEN 2346
38#define DOT11_DEFAULT_FRAG_LEN 2346
39
40#define DOT11_MIN_BEACON_PERIOD 1
41#define DOT11_MAX_BEACON_PERIOD 0xFFFF
42
43#define DOT11_MIN_DTIM_PERIOD 1
44#define DOT11_MAX_DTIM_PERIOD 0xFF
45
Henry Ptasinskia9533e72010-09-08 21:04:42 -070046#define DOT11_OUI_LEN 3
Henry Ptasinskia9533e72010-09-08 21:04:42 -070047
48BWL_PRE_PACKED_STRUCT struct dot11_header {
Greg Kroah-Hartman7d4df482010-10-07 17:04:47 -070049 u16 fc;
50 u16 durid;
Henry Ptasinskia9533e72010-09-08 21:04:42 -070051 struct ether_addr a1;
52 struct ether_addr a2;
53 struct ether_addr a3;
Greg Kroah-Hartman7d4df482010-10-07 17:04:47 -070054 u16 seq;
Henry Ptasinskia9533e72010-09-08 21:04:42 -070055 struct ether_addr a4;
56} BWL_POST_PACKED_STRUCT;
57
58BWL_PRE_PACKED_STRUCT struct dot11_rts_frame {
Greg Kroah-Hartman7d4df482010-10-07 17:04:47 -070059 u16 fc;
60 u16 durid;
Henry Ptasinskia9533e72010-09-08 21:04:42 -070061 struct ether_addr ra;
62 struct ether_addr ta;
63} BWL_POST_PACKED_STRUCT;
Henry Ptasinski34a5fa92010-10-01 14:05:25 -070064
Henry Ptasinskia9533e72010-09-08 21:04:42 -070065#define DOT11_RTS_LEN 16
Henry Ptasinskia9533e72010-09-08 21:04:42 -070066#define DOT11_CTS_LEN 10
Henry Ptasinskia9533e72010-09-08 21:04:42 -070067#define DOT11_ACK_LEN 10
68
Henry Ptasinski34a5fa92010-10-01 14:05:25 -070069#define DOT11_BA_BITMAP_LEN 128
Henry Ptasinskia9533e72010-09-08 21:04:42 -070070#define DOT11_BA_LEN 4
71
72BWL_PRE_PACKED_STRUCT struct dot11_management_header {
Greg Kroah-Hartman7d4df482010-10-07 17:04:47 -070073 u16 fc;
74 u16 durid;
Henry Ptasinskia9533e72010-09-08 21:04:42 -070075 struct ether_addr da;
76 struct ether_addr sa;
77 struct ether_addr bssid;
Greg Kroah-Hartman7d4df482010-10-07 17:04:47 -070078 u16 seq;
Henry Ptasinskia9533e72010-09-08 21:04:42 -070079} BWL_POST_PACKED_STRUCT;
80#define DOT11_MGMT_HDR_LEN 24
81
82BWL_PRE_PACKED_STRUCT struct dot11_bcn_prb {
Greg Kroah-Hartman66cbd3a2010-10-08 11:05:47 -070083 u32 timestamp[2];
Greg Kroah-Hartman7d4df482010-10-07 17:04:47 -070084 u16 beacon_interval;
85 u16 capability;
Henry Ptasinskia9533e72010-09-08 21:04:42 -070086} BWL_POST_PACKED_STRUCT;
87#define DOT11_BCN_PRB_LEN 12
Henry Ptasinskia9533e72010-09-08 21:04:42 -070088
89#define WME_OUI "\x00\x50\xf2"
90#define WME_VER 1
91#define WME_TYPE 2
Henry Ptasinskia9533e72010-09-08 21:04:42 -070092#define WME_SUBTYPE_PARAM_IE 1
Henry Ptasinskia9533e72010-09-08 21:04:42 -070093
94#define AC_BE 0
95#define AC_BK 1
96#define AC_VI 2
97#define AC_VO 3
98#define AC_COUNT 4
99
Greg Kroah-Hartmande9bca62010-10-05 10:23:40 -0700100typedef u8 ac_bitmap_t;
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700101
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700102#define AC_BITMAP_ALL 0xf
103#define AC_BITMAP_TST(ab, ac) (((ab) & (1 << (ac))) != 0)
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700104
105BWL_PRE_PACKED_STRUCT struct edcf_acparam {
Greg Kroah-Hartmande9bca62010-10-05 10:23:40 -0700106 u8 ACI;
107 u8 ECW;
Greg Kroah-Hartman7d4df482010-10-07 17:04:47 -0700108 u16 TXOP;
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700109} BWL_POST_PACKED_STRUCT;
110typedef struct edcf_acparam edcf_acparam_t;
111
112BWL_PRE_PACKED_STRUCT struct wme_param_ie {
Greg Kroah-Hartmande9bca62010-10-05 10:23:40 -0700113 u8 oui[3];
114 u8 type;
115 u8 subtype;
116 u8 version;
117 u8 qosinfo;
118 u8 rsvd;
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700119 edcf_acparam_t acparam[AC_COUNT];
120} BWL_POST_PACKED_STRUCT;
121typedef struct wme_param_ie wme_param_ie_t;
122#define WME_PARAM_IE_LEN 24
123
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700124#define EDCF_AIFSN_MIN 1
125#define EDCF_AIFSN_MAX 15
126#define EDCF_AIFSN_MASK 0x0f
127#define EDCF_ACM_MASK 0x10
128#define EDCF_ACI_MASK 0x60
129#define EDCF_ACI_SHIFT 5
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700130
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700131#define EDCF_ECW2CW(exp) ((1 << (exp)) - 1)
132#define EDCF_ECWMIN_MASK 0x0f
133#define EDCF_ECWMAX_MASK 0xf0
134#define EDCF_ECWMAX_SHIFT 4
135
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700136#define EDCF_TXOP2USEC(txop) ((txop) << 5)
137
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700138#define EDCF_AC_BE_ACI_STA 0x03
139#define EDCF_AC_BE_ECW_STA 0xA4
140#define EDCF_AC_BE_TXOP_STA 0x0000
141#define EDCF_AC_BK_ACI_STA 0x27
142#define EDCF_AC_BK_ECW_STA 0xA4
143#define EDCF_AC_BK_TXOP_STA 0x0000
144#define EDCF_AC_VI_ACI_STA 0x42
145#define EDCF_AC_VI_ECW_STA 0x43
146#define EDCF_AC_VI_TXOP_STA 0x005e
147#define EDCF_AC_VO_ACI_STA 0x62
148#define EDCF_AC_VO_ECW_STA 0x32
149#define EDCF_AC_VO_TXOP_STA 0x002f
150
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700151#define EDCF_AC_VO_TXOP_AP 0x002f
152
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700153#define DOT11_OPEN_SYSTEM 0
154#define DOT11_SHARED_KEY 1
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700155
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700156#define FC_TYPE_MASK 0xC
157#define FC_TYPE_SHIFT 2
158#define FC_SUBTYPE_MASK 0xF0
159#define FC_SUBTYPE_SHIFT 4
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700160#define FC_MOREFRAG 0x400
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700161
162#define SEQNUM_SHIFT 4
163#define SEQNUM_MAX 0x1000
164#define FRAGNUM_MASK 0xF
165
166#define FC_TYPE_MNG 0
167#define FC_TYPE_CTL 1
168#define FC_TYPE_DATA 2
169
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700170#define FC_SUBTYPE_PROBE_REQ 4
171#define FC_SUBTYPE_PROBE_RESP 5
172#define FC_SUBTYPE_BEACON 8
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700173#define FC_SUBTYPE_PS_POLL 10
174#define FC_SUBTYPE_RTS 11
175#define FC_SUBTYPE_CTS 12
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700176
177#define FC_SUBTYPE_ANY_QOS(s) (((s) & 8) != 0)
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700178
179#define FC_KIND_MASK (FC_TYPE_MASK | FC_SUBTYPE_MASK)
180
181#define FC_KIND(t, s) (((t) << FC_TYPE_SHIFT) | ((s) << FC_SUBTYPE_SHIFT))
182
183#define FC_SUBTYPE(fc) (((fc) & FC_SUBTYPE_MASK) >> FC_SUBTYPE_SHIFT)
184#define FC_TYPE(fc) (((fc) & FC_TYPE_MASK) >> FC_TYPE_SHIFT)
185
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700186#define FC_PROBE_REQ FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_PROBE_REQ)
187#define FC_PROBE_RESP FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_PROBE_RESP)
188#define FC_BEACON FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_BEACON)
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700189#define FC_PS_POLL FC_KIND(FC_TYPE_CTL, FC_SUBTYPE_PS_POLL)
190#define FC_RTS FC_KIND(FC_TYPE_CTL, FC_SUBTYPE_RTS)
191#define FC_CTS FC_KIND(FC_TYPE_CTL, FC_SUBTYPE_CTS)
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700192
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700193#define TLV_LEN_OFF 1
194#define TLV_HDR_LEN 2
195#define TLV_BODY_OFF 2
196
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700197#define DOT11_MNG_RSN_ID 48
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700198#define DOT11_MNG_WPA_ID 221
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700199#define DOT11_MNG_VS_ID 221
200
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700201#define DOT11_CAP_ESS 0x0001
202#define DOT11_CAP_IBSS 0x0002
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700203#define DOT11_CAP_PRIVACY 0x0010
204#define DOT11_CAP_SHORT 0x0020
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700205#define DOT11_CAP_SHORTSLOT 0x0400
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700206
207#define DOT11_BSSTYPE_INFRASTRUCTURE 0
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700208#define DOT11_BSSTYPE_ANY 2
209#define DOT11_SCANTYPE_ACTIVE 0
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700210
211#define PREN_PREAMBLE 24
212#define PREN_MM_EXT 12
213#define PREN_PREAMBLE_EXT 4
214
215#define RIFS_11N_TIME 2
216
217#define APHY_SLOT_TIME 9
218#define APHY_SIFS_TIME 16
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700219#define APHY_PREAMBLE_TIME 16
220#define APHY_SIGNAL_TIME 4
221#define APHY_SYMBOL_TIME 4
222#define APHY_SERVICE_NBITS 16
223#define APHY_TAIL_NBITS 6
224#define APHY_CWMIN 15
225
226#define BPHY_SLOT_TIME 20
227#define BPHY_SIFS_TIME 10
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700228#define BPHY_PLCP_TIME 192
229#define BPHY_PLCP_SHORT_TIME 96
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700230
231#define DOT11_OFDM_SIGNAL_EXTENSION 6
232
233#define PHY_CWMAX 1023
234
235#define DOT11_MAXNUMFRAGS 16
236
237typedef struct d11cnt {
Greg Kroah-Hartman66cbd3a2010-10-08 11:05:47 -0700238 u32 txfrag;
239 u32 txmulti;
240 u32 txfail;
241 u32 txretry;
242 u32 txretrie;
243 u32 rxdup;
244 u32 txrts;
245 u32 txnocts;
246 u32 txnoack;
247 u32 rxfrag;
248 u32 rxmulti;
249 u32 rxcrc;
250 u32 txfrmsnt;
251 u32 rxundec;
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700252} d11cnt_t;
253
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700254#define MCSSET_LEN 16
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700255
256BWL_PRE_PACKED_STRUCT struct ht_cap_ie {
Greg Kroah-Hartman7d4df482010-10-07 17:04:47 -0700257 u16 cap;
Greg Kroah-Hartmande9bca62010-10-05 10:23:40 -0700258 u8 params;
259 u8 supp_mcs[MCSSET_LEN];
Greg Kroah-Hartman7d4df482010-10-07 17:04:47 -0700260 u16 ext_htcap;
Greg Kroah-Hartman66cbd3a2010-10-08 11:05:47 -0700261 u32 txbf_cap;
Greg Kroah-Hartmande9bca62010-10-05 10:23:40 -0700262 u8 as_cap;
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700263} BWL_POST_PACKED_STRUCT;
264typedef struct ht_cap_ie ht_cap_ie_t;
265
266#define HT_CAP_IE_LEN 26
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700267
268#define HT_CAP_LDPC_CODING 0x0001
269#define HT_CAP_40MHZ 0x0002
270#define HT_CAP_MIMO_PS_MASK 0x000C
271#define HT_CAP_MIMO_PS_SHIFT 0x0002
272#define HT_CAP_MIMO_PS_OFF 0x0003
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700273#define HT_CAP_MIMO_PS_ON 0x0000
274#define HT_CAP_GF 0x0010
275#define HT_CAP_SHORT_GI_20 0x0020
276#define HT_CAP_SHORT_GI_40 0x0040
277#define HT_CAP_TX_STBC 0x0080
278#define HT_CAP_RX_STBC_MASK 0x0300
279#define HT_CAP_RX_STBC_SHIFT 8
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700280#define HT_CAP_MAX_AMSDU 0x0800
281#define HT_CAP_DSSS_CCK 0x1000
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700282#define HT_CAP_40MHZ_INTOLERANT 0x4000
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700283
284#define HT_CAP_RX_STBC_NO 0x0
285#define HT_CAP_RX_STBC_ONE_STREAM 0x1
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700286
287#define HT_PARAMS_RX_FACTOR_MASK 0x03
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700288
289#define AMPDU_MAX_MPDU_DENSITY 7
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700290#define AMPDU_RX_FACTOR_16K 1
291#define AMPDU_RX_FACTOR_32K 2
292#define AMPDU_RX_FACTOR_64K 3
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700293
294#define AMPDU_DELIMITER_LEN 4
295
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700296#define DOT11N_TXBURST 0x0008
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700297
298#define WPA_VERSION 1
299#define WPA_OUI "\x00\x50\xF2"
300
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700301#define WFA_OUI "\x00\x50\xF2"
302#define WFA_OUI_LEN 3
303
304#define WFA_OUI_TYPE_WPA 1
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700305
306#define RSN_AKM_NONE 0
307#define RSN_AKM_UNSPECIFIED 1
308#define RSN_AKM_PSK 2
309
310#define DOT11_MAX_DEFAULT_KEYS 4
311#define DOT11_MAX_KEY_SIZE 32
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700312#define DOT11_WPA_KEY_RSC_LEN 8
313
314#define WEP1_KEY_SIZE 5
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700315#define WEP128_KEY_SIZE 13
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700316#define TKIP_KEY_SIZE 32
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700317#define AES_KEY_SIZE 16
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700318
Henry Ptasinskicf2b4482010-09-20 22:33:12 -0700319#define BRCM_OUI "\x00\x10\x18"
Henry Ptasinskia9533e72010-09-08 21:04:42 -0700320#include <packed_section_end.h>
321
322#endif /* _802_11_H_ */