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