xref: /OK3568_Linux_fs/kernel/drivers/net/wireless/rockchip_wlan/rtl8821cs/include/ieee80211_ext.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /******************************************************************************
3  *
4  * Copyright(c) 2007 - 2017 Realtek Corporation.
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms of version 2 of the GNU General Public License as
8  * published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13  * more details.
14  *
15  *****************************************************************************/
16 #ifndef __IEEE80211_EXT_H
17 #define __IEEE80211_EXT_H
18 
19 #include <drv_conf.h>
20 #include <osdep_service.h>
21 #include <drv_types.h>
22 
23 #define WMM_OUI_TYPE 2
24 #define WMM_OUI_SUBTYPE_INFORMATION_ELEMENT 0
25 #define WMM_OUI_SUBTYPE_PARAMETER_ELEMENT 1
26 #define WMM_OUI_SUBTYPE_TSPEC_ELEMENT 2
27 #define WMM_VERSION 1
28 
29 #define WPA_PROTO_WPA BIT(0)
30 #define WPA_PROTO_RSN BIT(1)
31 
32 #define WPA_KEY_MGMT_IEEE8021X BIT(0)
33 #define WPA_KEY_MGMT_PSK BIT(1)
34 #define WPA_KEY_MGMT_NONE BIT(2)
35 #define WPA_KEY_MGMT_IEEE8021X_NO_WPA BIT(3)
36 #define WPA_KEY_MGMT_WPA_NONE BIT(4)
37 
38 
39 #define WPA_CAPABILITY_PREAUTH BIT(0)
40 #define WPA_CAPABILITY_MGMT_FRAME_PROTECTION BIT(6)
41 #define WPA_CAPABILITY_PEERKEY_ENABLED BIT(9)
42 
43 
44 #define PMKID_LEN 16
45 
46 
47 #ifdef PLATFORM_LINUX
48 struct wpa_ie_hdr {
49 	u8 elem_id;
50 	u8 len;
51 	u8 oui[4]; /* 24-bit OUI followed by 8-bit OUI type */
52 	u8 version[2]; /* little endian */
53 } __attribute__((packed));
54 
55 struct rsn_ie_hdr {
56 	u8 elem_id; /* WLAN_EID_RSN */
57 	u8 len;
58 	u8 version[2]; /* little endian */
59 } __attribute__((packed));
60 
61 struct wme_ac_parameter {
62 #if defined(CONFIG_LITTLE_ENDIAN)
63 	/* byte 1 */
64 	u8	aifsn:4,
65 	     acm:1,
66 	     aci:2,
67 	     reserved:1;
68 
69 	/* byte 2 */
70 	u8	eCWmin:4,
71 	     eCWmax:4;
72 #elif defined(CONFIG_BIG_ENDIAN)
73 	/* byte 1 */
74 	u8	reserved:1,
75 	     aci:2,
76 	     acm:1,
77 	     aifsn:4;
78 
79 	/* byte 2 */
80 	u8	eCWmax:4,
81 	     eCWmin:4;
82 #else
83 #error	"Please fix <endian.h>"
84 #endif
85 
86 	/* bytes 3 & 4 */
87 	u16 txopLimit;
88 } __attribute__((packed));
89 
90 struct wme_parameter_element {
91 	/* required fields for WME version 1 */
92 	u8 oui[3];
93 	u8 oui_type;
94 	u8 oui_subtype;
95 	u8 version;
96 	u8 acInfo;
97 	u8 reserved;
98 	struct wme_ac_parameter ac[4];
99 
100 } __attribute__((packed));
101 
102 #endif
103 
104 #define WPA_PUT_LE16(a, val)			\
105 	do {					\
106 		(a)[1] = ((u16) (val)) >> 8;	\
107 		(a)[0] = ((u16) (val)) & 0xff;	\
108 	} while (0)
109 
110 #define WPA_PUT_BE32(a, val)					\
111 	do {							\
112 		(a)[0] = (u8) ((((u32) (val)) >> 24) & 0xff);	\
113 		(a)[1] = (u8) ((((u32) (val)) >> 16) & 0xff);	\
114 		(a)[2] = (u8) ((((u32) (val)) >> 8) & 0xff);	\
115 		(a)[3] = (u8) (((u32) (val)) & 0xff);		\
116 	} while (0)
117 
118 #define WPA_PUT_LE32(a, val)					\
119 	do {							\
120 		(a)[3] = (u8) ((((u32) (val)) >> 24) & 0xff);	\
121 		(a)[2] = (u8) ((((u32) (val)) >> 16) & 0xff);	\
122 		(a)[1] = (u8) ((((u32) (val)) >> 8) & 0xff);	\
123 		(a)[0] = (u8) (((u32) (val)) & 0xff);		\
124 	} while (0)
125 
126 #define RSN_SELECTOR_PUT(a, val) WPA_PUT_BE32((u8 *) (a), (val))
127 /* #define RSN_SELECTOR_PUT(a, val) WPA_PUT_LE32((u8 *) (a), (val)) */
128 
129 
130 
131 /* Action category code */
132 enum ieee80211_category {
133 	WLAN_CATEGORY_SPECTRUM_MGMT = 0,
134 	WLAN_CATEGORY_QOS = 1,
135 	WLAN_CATEGORY_DLS = 2,
136 	WLAN_CATEGORY_BACK = 3,
137 	WLAN_CATEGORY_HT = 7,
138 	WLAN_CATEGORY_WMM = 17,
139 };
140 
141 /* SPECTRUM_MGMT action code */
142 enum ieee80211_spectrum_mgmt_actioncode {
143 	WLAN_ACTION_SPCT_MSR_REQ = 0,
144 	WLAN_ACTION_SPCT_MSR_RPRT = 1,
145 	WLAN_ACTION_SPCT_TPC_REQ = 2,
146 	WLAN_ACTION_SPCT_TPC_RPRT = 3,
147 	WLAN_ACTION_SPCT_CHL_SWITCH = 4,
148 	WLAN_ACTION_SPCT_EXT_CHL_SWITCH = 5,
149 };
150 
151 /* BACK action code */
152 enum ieee80211_back_actioncode {
153 	WLAN_ACTION_ADDBA_REQ = 0,
154 	WLAN_ACTION_ADDBA_RESP = 1,
155 	WLAN_ACTION_DELBA = 2,
156 };
157 
158 /* HT features action code */
159 enum ieee80211_ht_actioncode {
160 	WLAN_ACTION_NOTIFY_CH_WIDTH = 0,
161 	WLAN_ACTION_SM_PS = 1,
162 	WLAN_ACTION_PSPM = 2,
163 	WLAN_ACTION_PCO_PHASE = 3,
164 	WLAN_ACTION_MIMO_CSI_MX = 4,
165 	WLAN_ACTION_MIMO_NONCP_BF = 5,
166 	WLAN_ACTION_MIMP_CP_BF = 6,
167 	WLAN_ACTION_ASEL_INDICATES_FB = 7,
168 	WLAN_ACTION_HI_INFO_EXCHG = 8,
169 };
170 
171 /* BACK (block-ack) parties */
172 enum ieee80211_back_parties {
173 	WLAN_BACK_RECIPIENT = 0,
174 	WLAN_BACK_INITIATOR = 1,
175 	WLAN_BACK_TIMER = 2,
176 };
177 
178 #ifdef PLATFORM_LINUX
179 
180 struct ieee80211_mgmt {
181 	u16 frame_control;
182 	u16 duration;
183 	u8 da[6];
184 	u8 sa[6];
185 	u8 bssid[6];
186 	u16 seq_ctrl;
187 	union {
188 		struct {
189 			u16 auth_alg;
190 			u16 auth_transaction;
191 			u16 status_code;
192 			/* possibly followed by Challenge text */
193 			u8 variable[0];
194 		}  __attribute__((packed)) auth;
195 		struct {
196 			u16 reason_code;
197 		}  __attribute__((packed)) deauth;
198 		struct {
199 			u16 capab_info;
200 			u16 listen_interval;
201 			/* followed by SSID and Supported rates */
202 			u8 variable[0];
203 		}  __attribute__((packed)) assoc_req;
204 		struct {
205 			u16 capab_info;
206 			u16 status_code;
207 			u16 aid;
208 			/* followed by Supported rates */
209 			u8 variable[0];
210 		}  __attribute__((packed)) assoc_resp, reassoc_resp;
211 		struct {
212 			u16 capab_info;
213 			u16 listen_interval;
214 			u8 current_ap[6];
215 			/* followed by SSID and Supported rates */
216 			u8 variable[0];
217 		}  __attribute__((packed)) reassoc_req;
218 		struct {
219 			u16 reason_code;
220 		}  __attribute__((packed)) disassoc;
221 		struct {
222 			__le64 timestamp;
223 			u16 beacon_int;
224 			u16 capab_info;
225 			/* followed by some of SSID, Supported rates,
226 			 * FH Params, DS Params, CF Params, IBSS Params, TIM */
227 			u8 variable[0];
228 		}  __attribute__((packed)) beacon;
229 		struct {
230 			/* only variable items: SSID, Supported rates */
231 			u8 variable[0];
232 		}  __attribute__((packed)) probe_req;
233 		struct {
234 			__le64 timestamp;
235 			u16 beacon_int;
236 			u16 capab_info;
237 			/* followed by some of SSID, Supported rates,
238 			 * FH Params, DS Params, CF Params, IBSS Params */
239 			u8 variable[0];
240 		}  __attribute__((packed)) probe_resp;
241 		struct {
242 			u8 category;
243 			union {
244 				struct {
245 					u8 action_code;
246 					u8 dialog_token;
247 					u8 status_code;
248 					u8 variable[0];
249 				}  __attribute__((packed)) wme_action;
250 #if 0
251 				struct {
252 					u8 action_code;
253 					u8 element_id;
254 					u8 length;
255 					struct ieee80211_channel_sw_ie sw_elem;
256 				}  __attribute__((packed)) chan_switch;
257 				struct {
258 					u8 action_code;
259 					u8 dialog_token;
260 					u8 element_id;
261 					u8 length;
262 					struct ieee80211_msrment_ie msr_elem;
263 				}  __attribute__((packed)) measurement;
264 #endif
265 				struct {
266 					u8 action_code;
267 					u8 dialog_token;
268 					u16 capab;
269 					u16 timeout;
270 					u16 start_seq_num;
271 				}  __attribute__((packed)) addba_req;
272 				struct {
273 					u8 action_code;
274 					u8 dialog_token;
275 					u16 status;
276 					u16 capab;
277 					u16 timeout;
278 				}  __attribute__((packed)) addba_resp;
279 				struct {
280 					u8 action_code;
281 					u16 params;
282 					u16 reason_code;
283 				}  __attribute__((packed)) delba;
284 				struct {
285 					u8 action_code;
286 					/* capab_info for open and confirm,
287 					 * reason for close
288 					 */
289 					u16 aux;
290 					/* Followed in plink_confirm by status
291 					 * code, AID and supported rates,
292 					 * and directly by supported rates in
293 					 * plink_open and plink_close
294 					 */
295 					u8 variable[0];
296 				}  __attribute__((packed)) plink_action;
297 				struct {
298 					u8 action_code;
299 					u8 variable[0];
300 				}  __attribute__((packed)) mesh_action;
301 			} __attribute__((packed)) u;
302 		}  __attribute__((packed)) action;
303 	} __attribute__((packed)) u;
304 } __attribute__((packed));
305 
306 #endif
307 
308 /* mgmt header + 1 byte category code */
309 #define IEEE80211_MIN_ACTION_SIZE FIELD_OFFSET(struct ieee80211_mgmt, u.action.u)
310 
311 
312 
313 #endif
314