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