OSDN Git Service

Add rtl8723bu driver version 4.4.5
[android-x86/external-kernel-drivers.git] / rtl8723bu / include / ieee80211_ext.h
1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of version 2 of the GNU General Public License as
7  * published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along with
15  * this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
17  *
18  *
19  ******************************************************************************/
20 #ifndef __IEEE80211_EXT_H
21 #define __IEEE80211_EXT_H
22
23 #include <drv_conf.h>
24 #include <osdep_service.h>
25 #include <drv_types.h>
26
27 #define WMM_OUI_TYPE 2
28 #define WMM_OUI_SUBTYPE_INFORMATION_ELEMENT 0
29 #define WMM_OUI_SUBTYPE_PARAMETER_ELEMENT 1
30 #define WMM_OUI_SUBTYPE_TSPEC_ELEMENT 2
31 #define WMM_VERSION 1
32
33 #define WPA_PROTO_WPA BIT(0)
34 #define WPA_PROTO_RSN BIT(1)
35
36 #define WPA_KEY_MGMT_IEEE8021X BIT(0)
37 #define WPA_KEY_MGMT_PSK BIT(1)
38 #define WPA_KEY_MGMT_NONE BIT(2)
39 #define WPA_KEY_MGMT_IEEE8021X_NO_WPA BIT(3)
40 #define WPA_KEY_MGMT_WPA_NONE BIT(4)
41
42
43 #define WPA_CAPABILITY_PREAUTH BIT(0)
44 #define WPA_CAPABILITY_MGMT_FRAME_PROTECTION BIT(6)
45 #define WPA_CAPABILITY_PEERKEY_ENABLED BIT(9)
46
47
48 #define PMKID_LEN 16
49
50
51 #ifdef PLATFORM_LINUX
52 struct wpa_ie_hdr {
53         u8 elem_id;
54         u8 len;
55         u8 oui[4]; /* 24-bit OUI followed by 8-bit OUI type */
56         u8 version[2]; /* little endian */
57 }__attribute__ ((packed));
58
59 struct rsn_ie_hdr {
60         u8 elem_id; /* WLAN_EID_RSN */
61         u8 len;
62         u8 version[2]; /* little endian */
63 }__attribute__ ((packed));
64
65 struct wme_ac_parameter {
66 #if defined(CONFIG_LITTLE_ENDIAN)
67         /* byte 1 */
68         u8      aifsn:4,
69                 acm:1,
70                 aci:2,
71                 reserved:1;
72
73         /* byte 2 */
74         u8      eCWmin:4,
75                 eCWmax:4;
76 #elif defined(CONFIG_BIG_ENDIAN)
77         /* byte 1 */
78         u8      reserved:1,
79                 aci:2,
80                 acm:1,
81                 aifsn:4;
82
83         /* byte 2 */
84         u8      eCWmax:4,
85                 eCWmin:4;
86 #else
87 #error  "Please fix <endian.h>"
88 #endif
89
90         /* bytes 3 & 4 */
91         u16 txopLimit;
92 } __attribute__ ((packed));
93
94 struct wme_parameter_element {
95         /* required fields for WME version 1 */
96         u8 oui[3];
97         u8 oui_type;
98         u8 oui_subtype;
99         u8 version;
100         u8 acInfo;
101         u8 reserved;
102         struct wme_ac_parameter ac[4];
103
104 } __attribute__ ((packed));
105
106 #endif
107
108 #ifdef PLATFORM_WINDOWS
109
110 #pragma pack(1)
111
112 struct wpa_ie_hdr {
113         u8 elem_id;
114         u8 len;
115         u8 oui[4]; /* 24-bit OUI followed by 8-bit OUI type */
116         u8 version[2]; /* little endian */
117 };
118
119 struct rsn_ie_hdr {
120         u8 elem_id; /* WLAN_EID_RSN */
121         u8 len;
122         u8 version[2]; /* little endian */
123 };
124
125 #pragma pack()
126
127 #endif
128
129 #define WPA_PUT_LE16(a, val)                    \
130         do {                                    \
131                 (a)[1] = ((u16) (val)) >> 8;    \
132                 (a)[0] = ((u16) (val)) & 0xff;  \
133         } while (0)
134
135 #define WPA_PUT_BE32(a, val)                                    \
136         do {                                                    \
137                 (a)[0] = (u8) ((((u32) (val)) >> 24) & 0xff);   \
138                 (a)[1] = (u8) ((((u32) (val)) >> 16) & 0xff);   \
139                 (a)[2] = (u8) ((((u32) (val)) >> 8) & 0xff);    \
140                 (a)[3] = (u8) (((u32) (val)) & 0xff);           \
141         } while (0)
142
143 #define WPA_PUT_LE32(a, val)                                    \
144         do {                                                    \
145                 (a)[3] = (u8) ((((u32) (val)) >> 24) & 0xff);   \
146                 (a)[2] = (u8) ((((u32) (val)) >> 16) & 0xff);   \
147                 (a)[1] = (u8) ((((u32) (val)) >> 8) & 0xff);    \
148                 (a)[0] = (u8) (((u32) (val)) & 0xff);           \
149         } while (0)
150
151 #define RSN_SELECTOR_PUT(a, val) WPA_PUT_BE32((u8 *) (a), (val))
152 //#define RSN_SELECTOR_PUT(a, val) WPA_PUT_LE32((u8 *) (a), (val))
153
154
155
156 /* Action category code */
157 enum ieee80211_category {
158         WLAN_CATEGORY_SPECTRUM_MGMT = 0,
159         WLAN_CATEGORY_QOS = 1,
160         WLAN_CATEGORY_DLS = 2,
161         WLAN_CATEGORY_BACK = 3,
162         WLAN_CATEGORY_HT = 7,
163         WLAN_CATEGORY_WMM = 17,
164 };
165
166 /* SPECTRUM_MGMT action code */
167 enum ieee80211_spectrum_mgmt_actioncode {
168         WLAN_ACTION_SPCT_MSR_REQ = 0,
169         WLAN_ACTION_SPCT_MSR_RPRT = 1,
170         WLAN_ACTION_SPCT_TPC_REQ = 2,
171         WLAN_ACTION_SPCT_TPC_RPRT = 3,
172         WLAN_ACTION_SPCT_CHL_SWITCH = 4,
173         WLAN_ACTION_SPCT_EXT_CHL_SWITCH = 5,
174 };
175
176 /* BACK action code */
177 enum ieee80211_back_actioncode {
178         WLAN_ACTION_ADDBA_REQ = 0,
179         WLAN_ACTION_ADDBA_RESP = 1,
180         WLAN_ACTION_DELBA = 2,
181 };
182
183 /* HT features action code */
184 enum ieee80211_ht_actioncode {
185         WLAN_ACTION_NOTIFY_CH_WIDTH = 0,
186        WLAN_ACTION_SM_PS = 1,
187        WLAN_ACTION_PSPM = 2,
188        WLAN_ACTION_PCO_PHASE = 3,
189        WLAN_ACTION_MIMO_CSI_MX = 4,
190        WLAN_ACTION_MIMO_NONCP_BF = 5,
191        WLAN_ACTION_MIMP_CP_BF = 6,
192        WLAN_ACTION_ASEL_INDICATES_FB = 7,
193        WLAN_ACTION_HI_INFO_EXCHG = 8,
194 };
195
196 /* BACK (block-ack) parties */
197 enum ieee80211_back_parties {
198         WLAN_BACK_RECIPIENT = 0,
199         WLAN_BACK_INITIATOR = 1,
200         WLAN_BACK_TIMER = 2,
201 };
202
203 #ifdef PLATFORM_LINUX
204
205 struct ieee80211_mgmt {
206         u16 frame_control;
207         u16 duration;
208         u8 da[6];
209         u8 sa[6];
210         u8 bssid[6];
211         u16 seq_ctrl;
212         union {
213                 struct {
214                         u16 auth_alg;
215                         u16 auth_transaction;
216                         u16 status_code;
217                         /* possibly followed by Challenge text */
218                         u8 variable[0];
219                 }  __attribute__ ((packed)) auth;
220                 struct {
221                         u16 reason_code;
222                 }  __attribute__ ((packed)) deauth;
223                 struct {
224                         u16 capab_info;
225                         u16 listen_interval;
226                         /* followed by SSID and Supported rates */
227                         u8 variable[0];
228                 }  __attribute__ ((packed)) assoc_req;
229                 struct {
230                         u16 capab_info;
231                         u16 status_code;
232                         u16 aid;
233                         /* followed by Supported rates */
234                         u8 variable[0];
235                 }  __attribute__ ((packed)) assoc_resp, reassoc_resp;
236                 struct {
237                         u16 capab_info;
238                         u16 listen_interval;
239                         u8 current_ap[6];
240                         /* followed by SSID and Supported rates */
241                         u8 variable[0];
242                 }  __attribute__ ((packed)) reassoc_req;
243                 struct {
244                         u16 reason_code;
245                 }  __attribute__ ((packed)) disassoc;
246                 struct {
247                         __le64 timestamp;
248                         u16 beacon_int;
249                         u16 capab_info;
250                         /* followed by some of SSID, Supported rates,
251                          * FH Params, DS Params, CF Params, IBSS Params, TIM */
252                         u8 variable[0];
253                 }  __attribute__ ((packed)) beacon;
254                 struct {
255                         /* only variable items: SSID, Supported rates */
256                         u8 variable[0];
257                 }  __attribute__ ((packed)) probe_req;
258                 struct {
259                         __le64 timestamp;
260                         u16 beacon_int;
261                         u16 capab_info;
262                         /* followed by some of SSID, Supported rates,
263                          * FH Params, DS Params, CF Params, IBSS Params */
264                         u8 variable[0];
265                 }  __attribute__ ((packed)) probe_resp;
266                 struct {
267                         u8 category;
268                         union {
269                                 struct {
270                                         u8 action_code;
271                                         u8 dialog_token;
272                                         u8 status_code;
273                                         u8 variable[0];
274                                 }  __attribute__ ((packed)) wme_action;
275 #if 0
276                                 struct{
277                                         u8 action_code;
278                                         u8 element_id;
279                                         u8 length;
280                                         struct ieee80211_channel_sw_ie sw_elem;
281                                 }  __attribute__ ((packed)) chan_switch;
282                                 struct{
283                                         u8 action_code;
284                                         u8 dialog_token;
285                                         u8 element_id;
286                                         u8 length;
287                                         struct ieee80211_msrment_ie msr_elem;
288                                 }  __attribute__ ((packed)) measurement;
289 #endif
290                                 struct{
291                                         u8 action_code;
292                                         u8 dialog_token;
293                                         u16 capab;
294                                         u16 timeout;
295                                         u16 start_seq_num;
296                                 }  __attribute__ ((packed)) addba_req;
297                                 struct{
298                                         u8 action_code;
299                                         u8 dialog_token;
300                                         u16 status;
301                                         u16 capab;
302                                         u16 timeout;
303                                 }  __attribute__ ((packed)) addba_resp;
304                                 struct{
305                                         u8 action_code;
306                                         u16 params;
307                                         u16 reason_code;
308                                 }  __attribute__ ((packed)) delba;
309                                 struct{
310                                         u8 action_code;
311                                         /* capab_info for open and confirm,
312                                          * reason for close
313                                          */
314                                         u16 aux;
315                                         /* Followed in plink_confirm by status
316                                          * code, AID and supported rates,
317                                          * and directly by supported rates in
318                                          * plink_open and plink_close
319                                          */
320                                         u8 variable[0];
321                                 }  __attribute__ ((packed)) plink_action;
322                                 struct{
323                                         u8 action_code;
324                                         u8 variable[0];
325                                 }  __attribute__ ((packed)) mesh_action;
326                         } __attribute__ ((packed)) u;
327                 }  __attribute__ ((packed)) action;
328         } __attribute__ ((packed)) u;
329 }__attribute__ ((packed));
330
331 #endif
332
333
334 #ifdef PLATFORM_WINDOWS
335
336 #pragma pack(1)
337
338 struct ieee80211_mgmt {
339         u16 frame_control;
340         u16 duration;
341         u8 da[6];
342         u8 sa[6];
343         u8 bssid[6];
344         u16 seq_ctrl;
345         union {
346                 struct {
347                         u16 auth_alg;
348                         u16 auth_transaction;
349                         u16 status_code;
350                         /* possibly followed by Challenge text */
351                         u8 variable[0];
352                 }  auth;
353                 struct {
354                         u16 reason_code;
355                 }  deauth;
356                 struct {
357                         u16 capab_info;
358                         u16 listen_interval;
359                         /* followed by SSID and Supported rates */
360                         u8 variable[0];
361                 }  assoc_req;
362                 struct {
363                         u16 capab_info;
364                         u16 status_code;
365                         u16 aid;
366                         /* followed by Supported rates */
367                         u8 variable[0];
368                 }  assoc_resp, reassoc_resp;
369                 struct {
370                         u16 capab_info;
371                         u16 listen_interval;
372                         u8 current_ap[6];
373                         /* followed by SSID and Supported rates */
374                         u8 variable[0];
375                 }  reassoc_req;
376                 struct {
377                         u16 reason_code;
378                 }  disassoc;
379 #if 0
380                 struct {
381                         __le64 timestamp;
382                         u16 beacon_int;
383                         u16 capab_info;
384                         /* followed by some of SSID, Supported rates,
385                          * FH Params, DS Params, CF Params, IBSS Params, TIM */
386                         u8 variable[0];
387                 }  beacon;
388                 struct {
389                         /* only variable items: SSID, Supported rates */
390                         u8 variable[0];
391                 }  probe_req;
392
393                 struct {
394                         __le64 timestamp;
395                         u16 beacon_int;
396                         u16 capab_info;
397                         /* followed by some of SSID, Supported rates,
398                          * FH Params, DS Params, CF Params, IBSS Params */
399                         u8 variable[0];
400                 }  probe_resp;
401 #endif
402                 struct {
403                         u8 category;
404                         union {
405                                 struct {
406                                         u8 action_code;
407                                         u8 dialog_token;
408                                         u8 status_code;
409                                         u8 variable[0];
410                                 }  wme_action;
411 /*
412                                 struct{
413                                         u8 action_code;
414                                         u8 element_id;
415                                         u8 length;
416                                         struct ieee80211_channel_sw_ie sw_elem;
417                                 }  chan_switch;
418                                 struct{
419                                         u8 action_code;
420                                         u8 dialog_token;
421                                         u8 element_id;
422                                         u8 length;
423                                         struct ieee80211_msrment_ie msr_elem;
424                                 }  measurement;
425 */
426                                 struct{
427                                         u8 action_code;
428                                         u8 dialog_token;
429                                         u16 capab;
430                                         u16 timeout;
431                                         u16 start_seq_num;
432                                 }  addba_req;
433                                 struct{
434                                         u8 action_code;
435                                         u8 dialog_token;
436                                         u16 status;
437                                         u16 capab;
438                                         u16 timeout;
439                                 }  addba_resp;
440                                 struct{
441                                         u8 action_code;
442                                         u16 params;
443                                         u16 reason_code;
444                                 }  delba;
445                                 struct{
446                                         u8 action_code;
447                                         /* capab_info for open and confirm,
448                                          * reason for close
449                                          */
450                                         u16 aux;
451                                         /* Followed in plink_confirm by status
452                                          * code, AID and supported rates,
453                                          * and directly by supported rates in
454                                          * plink_open and plink_close
455                                          */
456                                         u8 variable[0];
457                                 }  plink_action;
458                                 struct{
459                                         u8 action_code;
460                                         u8 variable[0];
461                                 }  mesh_action;
462                         } u;
463                 }  action;
464         } u;
465 } ;
466
467 #pragma pack()
468
469 #endif
470
471 /* mgmt header + 1 byte category code */
472 #define IEEE80211_MIN_ACTION_SIZE FIELD_OFFSET(struct ieee80211_mgmt, u.action.u)
473
474
475
476 #endif