1 /*
2  * IEEE 802.11 Frame type definitions
3  * Copyright (c) 2002-2019, Jouni Malinen <j@w1.fi>
4  * Copyright (c) 2007-2008 Intel Corporation
5  *
6  * This software may be distributed under the terms of the BSD license.
7  * See README for more details.
8  */
9 
10 #ifndef IEEE802_11_DEFS_H
11 #define IEEE802_11_DEFS_H
12 
13 #include <utils/common.h>
14 
15 /* IEEE 802.11 defines */
16 
17 #define WLAN_FC_PVER		0x0003
18 #define WLAN_FC_TODS		0x0100
19 #define WLAN_FC_FROMDS		0x0200
20 #define WLAN_FC_MOREFRAG	0x0400
21 #define WLAN_FC_RETRY		0x0800
22 #define WLAN_FC_PWRMGT		0x1000
23 #define WLAN_FC_MOREDATA	0x2000
24 #define WLAN_FC_ISWEP		0x4000
25 #define WLAN_FC_ORDER		0x8000
26 
27 #define WLAN_FC_GET_TYPE(fc)	(((fc) & 0x000c) >> 2)
28 #define WLAN_FC_GET_STYPE(fc)	(((fc) & 0x00f0) >> 4)
29 
30 #define WLAN_GET_SEQ_FRAG(seq) ((seq) & (BIT(3) | BIT(2) | BIT(1) | BIT(0)))
31 #define WLAN_GET_SEQ_SEQ(seq) \
32 	(((seq) & (~(BIT(3) | BIT(2) | BIT(1) | BIT(0)))) >> 4)
33 
34 #define WLAN_FC_TYPE_MGMT		0
35 #define WLAN_FC_TYPE_CTRL		1
36 #define WLAN_FC_TYPE_DATA		2
37 
38 /* management */
39 #define WLAN_FC_STYPE_ASSOC_REQ		0
40 #define WLAN_FC_STYPE_ASSOC_RESP	1
41 #define WLAN_FC_STYPE_REASSOC_REQ	2
42 #define WLAN_FC_STYPE_REASSOC_RESP	3
43 #define WLAN_FC_STYPE_PROBE_REQ		4
44 #define WLAN_FC_STYPE_PROBE_RESP	5
45 #define WLAN_FC_STYPE_BEACON		8
46 #define WLAN_FC_STYPE_ATIM		9
47 #define WLAN_FC_STYPE_DISASSOC		10
48 #define WLAN_FC_STYPE_AUTH		11
49 #define WLAN_FC_STYPE_DEAUTH		12
50 #define WLAN_FC_STYPE_ACTION		13
51 
52 /* control */
53 #define WLAN_FC_STYPE_PSPOLL		10
54 #define WLAN_FC_STYPE_RTS		11
55 #define WLAN_FC_STYPE_CTS		12
56 #define WLAN_FC_STYPE_ACK		13
57 #define WLAN_FC_STYPE_CFEND		14
58 #define WLAN_FC_STYPE_CFENDACK		15
59 
60 /* data */
61 #define WLAN_FC_STYPE_DATA		0
62 #define WLAN_FC_STYPE_DATA_CFACK	1
63 #define WLAN_FC_STYPE_DATA_CFPOLL	2
64 #define WLAN_FC_STYPE_DATA_CFACKPOLL	3
65 #define WLAN_FC_STYPE_NULLFUNC		4
66 #define WLAN_FC_STYPE_CFACK		5
67 #define WLAN_FC_STYPE_CFPOLL		6
68 #define WLAN_FC_STYPE_CFACKPOLL		7
69 #define WLAN_FC_STYPE_QOS_DATA		8
70 
71 /* Authentication algorithms */
72 #define WLAN_AUTH_OPEN			0
73 #define WLAN_AUTH_SHARED_KEY		1
74 #define WLAN_AUTH_FT			2
75 #define WLAN_AUTH_SAE           	3
76 #define WLAN_AUTH_LEAP			128
77 
78 #define WLAN_AUTH_CHALLENGE_LEN 128
79 
80 #define WLAN_CAPABILITY_ESS BIT(0)
81 #define WLAN_CAPABILITY_IBSS BIT(1)
82 #define WLAN_CAPABILITY_CF_POLLABLE BIT(2)
83 #define WLAN_CAPABILITY_CF_POLL_REQUEST BIT(3)
84 #define WLAN_CAPABILITY_PRIVACY BIT(4)
85 #define WLAN_CAPABILITY_SHORT_PREAMBLE BIT(5)
86 #define WLAN_CAPABILITY_PBCC BIT(6)
87 #define WLAN_CAPABILITY_CHANNEL_AGILITY BIT(7)
88 #define WLAN_CAPABILITY_SPECTRUM_MGMT BIT(8)
89 #define WLAN_CAPABILITY_QOS BIT(9)
90 #define WLAN_CAPABILITY_SHORT_SLOT_TIME BIT(10)
91 #define WLAN_CAPABILITY_APSD BIT(11)
92 #define WLAN_CAPABILITY_RADIO_MEASUREMENT BIT(12)
93 #define WLAN_CAPABILITY_DSSS_OFDM BIT(13)
94 #define WLAN_CAPABILITY_DELAYED_BLOCK_ACK BIT(14)
95 #define WLAN_CAPABILITY_IMM_BLOCK_ACK BIT(15)
96 
97 /* Status codes (IEEE Std 802.11-2016, 9.4.1.9, Table 9-46) */
98 #define WLAN_STATUS_SUCCESS 0
99 #define WLAN_STATUS_UNSPECIFIED_FAILURE 1
100 #define WLAN_STATUS_CAPS_UNSUPPORTED 10
101 #define WLAN_STATUS_REASSOC_NO_ASSOC 11
102 #define WLAN_STATUS_ASSOC_DENIED_UNSPEC 12
103 #define WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG 13
104 #define WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION 14
105 #define WLAN_STATUS_CHALLENGE_FAIL 15
106 #define WLAN_STATUS_AUTH_TIMEOUT 16
107 #define WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA 17
108 #define WLAN_STATUS_ASSOC_DENIED_RATES 18
109 #define WLAN_STATUS_ASSOC_DENIED_NOSHORT 19
110 #define WLAN_STATUS_SPEC_MGMT_REQUIRED 22
111 #define WLAN_STATUS_PWR_CAPABILITY_NOT_VALID 23
112 #define WLAN_STATUS_SUPPORTED_CHANNEL_NOT_VALID 24
113 #define WLAN_STATUS_ASSOC_DENIED_NO_SHORT_SLOT_TIME 25
114 #define WLAN_STATUS_ASSOC_DENIED_NO_HT 27
115 #define WLAN_STATUS_R0KH_UNREACHABLE 28
116 #define WLAN_STATUS_ASSOC_DENIED_NO_PCO 29
117 #define WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY 30
118 #define WLAN_STATUS_ROBUST_MGMT_FRAME_POLICY_VIOLATION 31
119 #define WLAN_STATUS_UNSPECIFIED_QOS_FAILURE 32
120 #define WLAN_STATUS_DENIED_INSUFFICIENT_BANDWIDTH 33
121 #define WLAN_STATUS_DENIED_POOR_CHANNEL_CONDITIONS 34
122 #define WLAN_STATUS_DENIED_QOS_NOT_SUPPORTED 35
123 #define WLAN_STATUS_REQUEST_DECLINED 37
124 #define WLAN_STATUS_INVALID_PARAMETERS 38
125 #define WLAN_STATUS_REJECTED_WITH_SUGGESTED_CHANGES 39
126 #define WLAN_STATUS_INVALID_IE 40
127 #define WLAN_STATUS_GROUP_CIPHER_NOT_VALID 41
128 #define WLAN_STATUS_PAIRWISE_CIPHER_NOT_VALID 42
129 #define WLAN_STATUS_AKMP_NOT_VALID 43
130 #define WLAN_STATUS_UNSUPPORTED_RSN_IE_VERSION 44
131 #define WLAN_STATUS_INVALID_RSN_IE_CAPAB 45
132 #define WLAN_STATUS_CIPHER_REJECTED_PER_POLICY 46
133 #define WLAN_STATUS_TS_NOT_CREATED 47
134 #define WLAN_STATUS_DIRECT_LINK_NOT_ALLOWED 48
135 #define WLAN_STATUS_DEST_STA_NOT_PRESENT 49
136 #define WLAN_STATUS_DEST_STA_NOT_QOS_STA 50
137 #define WLAN_STATUS_ASSOC_DENIED_LISTEN_INT_TOO_LARGE 51
138 #define WLAN_STATUS_INVALID_FT_ACTION_FRAME_COUNT 52
139 #define WLAN_STATUS_INVALID_PMKID 53
140 #define WLAN_STATUS_INVALID_MDIE 54
141 #define WLAN_STATUS_INVALID_FTIE 55
142 #define WLAN_STATUS_GAS_ADV_PROTO_NOT_SUPPORTED 59
143 #define WLAN_STATUS_NO_OUTSTANDING_GAS_REQ 60
144 #define WLAN_STATUS_GAS_RESP_NOT_RECEIVED 61
145 #define WLAN_STATUS_STA_TIMED_OUT_WAITING_FOR_GAS_RESP 62
146 #define WLAN_STATUS_GAS_RESP_LARGER_THAN_LIMIT 63
147 #define WLAN_STATUS_REQ_REFUSED_HOME 64
148 #define WLAN_STATUS_ADV_SRV_UNREACHABLE 65
149 #define WLAN_STATUS_REQ_REFUSED_SSPN 67
150 #define WLAN_STATUS_REQ_REFUSED_UNAUTH_ACCESS 68
151 #define WLAN_STATUS_INVALID_RSNIE 72
152 #define WLAN_STATUS_ANTI_CLOGGING_TOKEN_REQ 76
153 #define WLAN_STATUS_FINITE_CYCLIC_GROUP_NOT_SUPPORTED 77
154 #define WLAN_STATUS_TRANSMISSION_FAILURE 79
155 #define WLAN_STATUS_REJECTED_WITH_SUGGESTED_BSS_TRANSITION 82
156 #define WLAN_STATUS_PENDING_ADMITTING_FST_SESSION 86
157 #define WLAN_STATUS_QUERY_RESP_OUTSTANDING 95
158 #define WLAN_STATUS_DENIED_WITH_SUGGESTED_BAND_AND_CHANNEL 99
159 #define WLAN_STATUS_ASSOC_DENIED_NO_VHT 104
160 #define WLAN_STATUS_UNKNOWN_PASSWORD_IDENTIFIER 123
161 #define WLAN_STATUS_SAE_HASH_TO_ELEMENT 126
162 #define WLAN_STATUS_SAE_PK 127
163 
164 /* Reason codes (IEEE Std 802.11-2016, 9.4.1.7, Table 9-45) */
165 #define WLAN_REASON_UNSPECIFIED 1
166 #define WLAN_REASON_PREV_AUTH_NOT_VALID 2
167 #define WLAN_REASON_DEAUTH_LEAVING 3
168 #define WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY 4
169 #define WLAN_REASON_DISASSOC_AP_BUSY 5
170 #define WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA 6
171 #define WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA 7
172 #define WLAN_REASON_DISASSOC_STA_HAS_LEFT 8
173 #define WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH 9
174 #define WLAN_REASON_PWR_CAPABILITY_NOT_VALID 10
175 #define WLAN_REASON_SUPPORTED_CHANNEL_NOT_VALID 11
176 #define WLAN_REASON_BSS_TRANSITION_DISASSOC 12
177 #define WLAN_REASON_INVALID_IE 13
178 #define WLAN_REASON_MICHAEL_MIC_FAILURE 14
179 #define WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT 15
180 #define WLAN_REASON_GROUP_KEY_UPDATE_TIMEOUT 16
181 #define WLAN_REASON_IE_IN_4WAY_DIFFERS 17
182 #define WLAN_REASON_GROUP_CIPHER_NOT_VALID 18
183 #define WLAN_REASON_PAIRWISE_CIPHER_NOT_VALID 19
184 #define WLAN_REASON_AKMP_NOT_VALID 20
185 #define WLAN_REASON_UNSUPPORTED_RSN_IE_VERSION 21
186 #define WLAN_REASON_INVALID_RSN_IE_CAPAB 22
187 #define WLAN_REASON_IEEE_802_1X_AUTH_FAILED 23
188 #define WLAN_REASON_CIPHER_SUITE_REJECTED 24
189 
190 /* Information Element IDs (IEEE Std 802.11-2016, 9.4.2.1, Table 9-77) */
191 #define WLAN_EID_SSID 0
192 #define WLAN_EID_SUPP_RATES 1
193 #define WLAN_EID_DS_PARAMS 3
194 #define WLAN_EID_CF_PARAMS 4
195 #define WLAN_EID_TIM 5
196 #define WLAN_EID_IBSS_PARAMS 6
197 #define WLAN_EID_COUNTRY 7
198 #define WLAN_EID_CHALLENGE 16
199 #define WLAN_EID_PWR_CONSTRAINT 32
200 #define WLAN_EID_PWR_CAPABILITY 33
201 #define WLAN_EID_TPC_REQUEST 34
202 #define WLAN_EID_TPC_REPORT 35
203 #define WLAN_EID_SUPPORTED_CHANNELS 36
204 #define WLAN_EID_CHANNEL_SWITCH 37
205 #define WLAN_EID_MEASURE_REQUEST 38
206 #define WLAN_EID_MEASURE_REPORT 39
207 #define WLAN_EID_QUIET 40
208 #define WLAN_EID_IBSS_DFS 41
209 #define WLAN_EID_ERP_INFO 42
210 #define WLAN_EID_HT_CAP 45
211 #define WLAN_EID_RSN 48
212 #define WLAN_EID_EXT_SUPP_RATES 50
213 #define WLAN_EID_NEIGHBOR_REPORT 52
214 #define WLAN_EID_MOBILITY_DOMAIN 54
215 #define WLAN_EID_FAST_BSS_TRANSITION 55
216 #define WLAN_EID_TIMEOUT_INTERVAL 56
217 #define WLAN_EID_RIC_DATA 57
218 #define WLAN_EID_SUPPORTED_OPERATING_CLASSES 59
219 #define WLAN_EID_HT_OPERATION 61
220 #define WLAN_EID_SECONDARY_CHANNEL_OFFSET 62
221 #define WLAN_EID_WAPI 68
222 #define WLAN_EID_RRM_ENABLED_CAPABILITIES 70
223 #define WLAN_EID_20_40_BSS_COEXISTENCE 72
224 #define WLAN_EID_20_40_BSS_INTOLERANT 73
225 #define WLAN_EID_OVERLAPPING_BSS_SCAN_PARAMS 74
226 #define WLAN_EID_MMIE 76
227 #define WLAN_EID_EXT_CAPAB 127
228 #define WLAN_EID_VENDOR_SPECIFIC 221
229 #define WLAN_EID_CAG_NUMBER 237
230 #define WLAN_EID_AP_CSN 239
231 #define WLAN_EID_FILS_INDICATION 240
232 #define WLAN_EID_DILS 241
233 #define WLAN_EID_FRAGMENT 242
234 #define WLAN_EID_RSNX 244
235 #define WLAN_EID_EXTENSION 255
236 
237 /* Element ID Extension (EID 255) values */
238 #define WLAN_EID_EXT_ASSOC_DELAY_INFO 1
239 #define WLAN_EID_EXT_FILS_REQ_PARAMS 2
240 #define WLAN_EID_EXT_FILS_KEY_CONFIRM 3
241 #define WLAN_EID_EXT_FILS_SESSION 4
242 #define WLAN_EID_EXT_FILS_HLP_CONTAINER 5
243 #define WLAN_EID_EXT_FILS_IP_ADDR_ASSIGN 6
244 #define WLAN_EID_EXT_KEY_DELIVERY 7
245 #define WLAN_EID_EXT_WRAPPED_DATA 8
246 #define WLAN_EID_EXT_FTM_SYNC_INFO 9
247 #define WLAN_EID_EXT_EXTENDED_REQUEST 10
248 #define WLAN_EID_EXT_ESTIMATED_SERVICE_PARAMS 11
249 #define WLAN_EID_EXT_FILS_PUBLIC_KEY 12
250 #define WLAN_EID_EXT_FILS_NONCE 13
251 #define WLAN_EID_EXT_FUTURE_CHANNEL_GUIDANCE 14
252 #define WLAN_EID_EXT_OWE_DH_PARAM 32
253 #define WLAN_EID_EXT_PASSWORD_IDENTIFIER 33
254 #define WLAN_EID_EXT_HE_CAPABILITIES 35
255 #define WLAN_EID_EXT_HE_OPERATION 36
256 #define WLAN_EID_EXT_REJECTED_GROUPS 92
257 #define WLAN_EID_EXT_ANTI_CLOGGING_TOKEN 93
258 
259 /* Extended RSN Capabilities */
260 /* bits 0-3: Field length (n-1) */
261 #define WLAN_RSNX_CAPAB_SAE_H2E 5
262 #define WLAN_RSNX_CAPAB_SAE_PK 6
263 
264 #define WLAN_EXT_CAPAB_BSS_TRANSITION 19
265 
266 /* Action frame categories (IEEE Std 802.11-2016, 9.4.1.11, Table 9-76) */
267 #define WLAN_ACTION_SPECTRUM_MGMT 0
268 #define WLAN_ACTION_QOS 1
269 #define WLAN_ACTION_DLS 2
270 #define WLAN_ACTION_BLOCK_ACK 3
271 #define WLAN_ACTION_PUBLIC 4
272 #define WLAN_ACTION_RADIO_MEASUREMENT 5
273 #define WLAN_ACTION_FT 6
274 #define WLAN_ACTION_HT 7
275 #define WLAN_ACTION_SA_QUERY 8
276 #define WLAN_ACTION_WNM 10
277 #define WLAN_ACTION_UNPROTECTED_WNM 11
278 #define WLAN_ACTION_WMM 17 /* WMM Specification 1.1 */
279 
280 /* Public action codes (IEEE Std 802.11-2016, 9.6.8.1, Table 9-307) */
281 #define WLAN_PA_VENDOR_SPECIFIC 9
282 #define WLAN_PA_GAS_INITIAL_REQ 10
283 #define WLAN_PA_GAS_INITIAL_RESP 11
284 #define WLAN_PA_GAS_COMEBACK_REQ 12
285 #define WLAN_PA_GAS_COMEBACK_RESP 13
286 
287 /* SA Query Action frame (IEEE 802.11w/D8.0, 7.4.9) */
288 #define WLAN_SA_QUERY_REQUEST 0
289 #define WLAN_SA_QUERY_RESPONSE 1
290 
291 #define WLAN_SA_QUERY_TR_ID_LEN 2
292 
293 /* Timeout Interval Type */
294 #define WLAN_TIMEOUT_REASSOC_DEADLINE 1
295 #define WLAN_TIMEOUT_KEY_LIFETIME 2
296 #define WLAN_TIMEOUT_ASSOC_COMEBACK 3
297 
298 #define OUI_WFA 0x506f9a
299 #define DPP_OUI_TYPE 0x1A
300 
301 #ifdef _MSC_VER
302 #pragma pack(push, 1)
303 #endif /* _MSC_VER */
304 
305 struct ieee80211_hdr {
306 	le16 frame_control;
307 	le16 duration_id;
308 	u8 addr1[6];
309 	u8 addr2[6];
310 	u8 addr3[6];
311 	le16 seq_ctrl;
312 	/* followed by 'u8 addr4[6];' if ToDS and FromDS is set in data frame
313 	 */
314 } STRUCT_PACKED;
315 
316 #define IEEE80211_DA_FROMDS addr1
317 #define IEEE80211_BSSID_FROMDS addr2
318 #define IEEE80211_SA_FROMDS addr3
319 
320 #define IEEE80211_HDRLEN (sizeof(struct ieee80211_hdr))
321 
322 #define IEEE80211_FC(type, stype) host_to_le16((type << 2) | (stype << 4))
323 /* Radio Measurement Action codes */
324 #define WLAN_RRM_RADIO_MEASUREMENT_REQUEST 0
325 #define WLAN_RRM_RADIO_MEASUREMENT_REPORT 1
326 #define WLAN_RRM_LINK_MEASUREMENT_REQUEST 2
327 #define WLAN_RRM_LINK_MEASUREMENT_REPORT 3
328 #define WLAN_RRM_NEIGHBOR_REPORT_REQUEST 4
329 #define WLAN_RRM_NEIGHBOR_REPORT_RESPONSE 5
330 
331 /* Radio Measurement capabilities (from RM Enabled Capabilities element)
332  * IEEE Std 802.11-2016, 9.4.2.45, Table 9-157 */
333 /* byte 1 (out of 5) */
334 #define WLAN_RRM_CAPS_LINK_MEASUREMENT BIT(0)
335 #define WLAN_RRM_CAPS_NEIGHBOR_REPORT BIT(1)
336 #define WLAN_RRM_CAPS_BEACON_REPORT_PASSIVE BIT(4)
337 #define WLAN_RRM_CAPS_BEACON_REPORT_ACTIVE BIT(5)
338 #define WLAN_RRM_CAPS_BEACON_REPORT_TABLE BIT(6)
339 
340 /*
341  * IEEE P802.11-REVmc/D5.0 Table 9-81 - Measurement type definitions for
342  * measurement requests
343  */
344 enum measure_type {
345 	MEASURE_TYPE_RPI_HIST = 2,
346 	MEASURE_TYPE_BEACON = 5,
347 	MEASURE_TYPE_LCI = 8,
348 	MEASURE_TYPE_LOCATION_CIVIC = 11,
349 	MEASURE_TYPE_MEASURE_PAUSE = 255,
350 };
351 
352 /* IEEE Std 802.11-2012 Table 8-71 - Location subject definition */
353 enum location_subject {
354 	LOCATION_SUBJECT_LOCAL = 0,
355 	LOCATION_SUBJECT_REMOTE = 1,
356 	LOCATION_SUBJECT_3RD_PARTY = 2,
357 };
358 
359 /*
360  * IEEE P802.11-REVmc/D5.0 Table 9-94 - Optional subelement IDs for LCI request
361  */
362 enum lci_req_subelem {
363 	LCI_REQ_SUBELEM_AZIMUTH_REQ = 1,
364 	LCI_REQ_SUBELEM_ORIGINATOR_MAC_ADDR = 2,
365 	LCI_REQ_SUBELEM_TARGET_MAC_ADDR = 3,
366 	LCI_REQ_SUBELEM_MAX_AGE = 4,
367 };
368 
369 #ifdef ESP_SUPPLICANT
370 struct ieee80211_pa_vendor {
371     u8 oui[3];
372     u8 wfa_stype;
373     u8 vendor_data[];
374 } STRUCT_PACKED;
375 
376 struct ieee80211_gas_resp {
377     u8 diag_token;
378     u16 status_code;
379     u16 comeback_delay;
380     u8 type;
381     u8 length;
382     u8 data[];
383 } STRUCT_PACKED;
384 
385 struct ieee80211_public_action {
386     u8 action;
387     union {
388         struct ieee80211_pa_vendor pa_vendor_spec;
389         struct ieee80211_gas_resp pa_gas_resp;
390     } v;
391 } STRUCT_PACKED;
392 
393 struct ieee80211_action {
394     u8 category;
395     union {
396         struct ieee80211_public_action public_action;
397     } u;
398 } STRUCT_PACKED;
399 #endif /* ESP_SUPPLICANT */
400 
401 #define IEEE80211_MAX_MMPDU_SIZE 2304
402 struct ieee80211_ht_capabilities {
403 	le16 ht_capabilities_info;
404 	u8 a_mpdu_params;
405 	u8 supported_mcs_set[16];
406 	le16 ht_extended_capabilities;
407 	le32 tx_bf_capability_info;
408 	u8 asel_capabilities;
409 } STRUCT_PACKED;
410 
411 
412 /* HT Operation element */
413 struct ieee80211_ht_operation {
414 	u8 primary_chan;
415 	/* Five octets of HT Operation Information */
416 	u8 ht_param; /* B0..B7 */
417 	le16 operation_mode; /* B8..B23 */
418 	le16 param; /* B24..B39 */
419 	u8 basic_mcs_set[16];
420 } STRUCT_PACKED;
421 
422 #ifdef _MSC_VER
423 #pragma pack(pop)
424 #endif /* _MSC_VER */
425 
426 #define ERP_INFO_NON_ERP_PRESENT BIT(0)
427 #define ERP_INFO_USE_PROTECTION BIT(1)
428 #define ERP_INFO_BARKER_PREAMBLE_MODE BIT(2)
429 
430 #define OVERLAPPING_BSS_TRANS_DELAY_FACTOR 5
431 
432 /* HT Capabilities Info field within HT Capabilities element */
433 #define HT_CAP_INFO_LDPC_CODING_CAP		((u16) BIT(0))
434 #define HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET	((u16) BIT(1))
435 #define HT_CAP_INFO_SMPS_MASK			((u16) (BIT(2) | BIT(3)))
436 #define HT_CAP_INFO_SMPS_STATIC			((u16) 0)
437 #define HT_CAP_INFO_SMPS_DYNAMIC		((u16) BIT(2))
438 #define HT_CAP_INFO_SMPS_DISABLED		((u16) (BIT(2) | BIT(3)))
439 #define HT_CAP_INFO_GREEN_FIELD			((u16) BIT(4))
440 #define HT_CAP_INFO_SHORT_GI20MHZ		((u16) BIT(5))
441 #define HT_CAP_INFO_SHORT_GI40MHZ		((u16) BIT(6))
442 #define HT_CAP_INFO_TX_STBC			((u16) BIT(7))
443 #define HT_CAP_INFO_RX_STBC_MASK		((u16) (BIT(8) | BIT(9)))
444 #define HT_CAP_INFO_RX_STBC_1			((u16) BIT(8))
445 #define HT_CAP_INFO_RX_STBC_12			((u16) BIT(9))
446 #define HT_CAP_INFO_RX_STBC_123			((u16) (BIT(8) | BIT(9)))
447 #define HT_CAP_INFO_DELAYED_BA			((u16) BIT(10))
448 #define HT_CAP_INFO_MAX_AMSDU_SIZE		((u16) BIT(11))
449 #define HT_CAP_INFO_DSSS_CCK40MHZ		((u16) BIT(12))
450 /* B13 - Reserved (was PSMP support during P802.11n development) */
451 #define HT_CAP_INFO_40MHZ_INTOLERANT		((u16) BIT(14))
452 #define HT_CAP_INFO_LSIG_TXOP_PROTECT_SUPPORT	((u16) BIT(15))
453 
454 /* HT Extended Capabilities field within HT Capabilities element */
455 #define EXT_HT_CAP_INFO_PCO			((u16) BIT(0))
456 #define EXT_HT_CAP_INFO_PCO_TRANS_TIME_MASK	((u16) (BIT(1) | BIT(2)))
457 #define EXT_HT_CAP_INFO_TRANS_TIME_OFFSET	1
458 /* B3..B7 - Reserved */
459 #define EXT_HT_CAP_INFO_MCS_FEEDBACK_MASK	((u16) (BIT(8) | BIT(9)))
460 #define EXT_HT_CAP_INFO_MCS_FEEDBACK_OFFSET	8
461 #define EXT_HT_CAP_INFO_HTC_SUPPORT		((u16) BIT(10))
462 #define EXT_HT_CAP_INFO_RD_RESPONDER		((u16) BIT(11))
463 /* B12..B15 - Reserved */
464 
465 /* Transmit Beanforming Capabilities within HT Capabilities element */
466 #define TX_BF_CAP_IMPLICIT_TXBF_RX_CAP ((u32) BIT(0))
467 #define TX_BF_CAP_RX_STAGGERED_SOUNDING_CAP ((u32) BIT(1))
468 #define TX_BF_CAP_TX_STAGGERED_SOUNDING_CAP ((u32) BIT(2))
469 #define TX_BF_CAP_RX_NDP_CAP ((u32) BIT(3))
470 #define TX_BF_CAP_TX_NDP_CAP ((u32) BIT(4))
471 #define TX_BF_CAP_IMPLICIT_TX_BF_CAP ((u32) BIT(5))
472 #define TX_BF_CAP_CALIBRATION_MASK ((u32) (BIT(6) | BIT(7))
473 #define TX_BF_CAP_CALIB_OFFSET 6
474 #define TX_BF_CAP_EXPLICIT_CSI_TXBF_CAP ((u32) BIT(8))
475 #define TX_BF_CAP_EXPLICIT_NONCOMPR_STEERING_CAP ((u32) BIT(9))
476 #define TX_BF_CAP_EXPLICIT_COMPR_STEERING_CAP ((u32) BIT(10))
477 #define TX_BF_CAP_EXPLICIT_TX_BF_CSI_FEEDBACK_MASK ((u32) (BIT(10) | BIT(11)))
478 #define TX_BF_CAP_EXPLICIT_BF_CSI_FEEDBACK_OFFSET 11
479 #define TX_BF_CAP_EXPLICIT_UNCOMPR_STEERING_MATRIX_FEEDBACK_OFFSET 13
480 #define TX_BF_CAP_EXPLICIT_COMPRESSED_STEERING_MATRIX_FEEDBACK_OFFSET 15
481 #define TX_BF_CAP_MINIMAL_GROUPING_OFFSET 17
482 #define TX_BF_CAP_CSI_NUM_BEAMFORMER_ANT_OFFSET 19
483 #define TX_BF_CAP_UNCOMPRESSED_STEERING_MATRIX_BEAMFORMER_ANT_OFFSET 21
484 #define TX_BF_CAP_COMPRESSED_STEERING_MATRIX_BEAMFORMER_ANT_OFFSET 23
485 #define TX_BF_CAP_SCI_MAX_OF_ROWS_BEANFORMER_SUPPORTED_OFFSET 25
486 #define TX_BF_CAP_CHANNEL_ESTIMATION_CAP_MASK ((u32) (BIT(27) | BIT(28)))
487 #define TX_BF_CAP_CHANNEL_ESTIMATION_CAP_OFFSET 27
488 /* B29..B31 - Reserved */
489 
490 /* ASEL Capability field within HT Capabilities element */
491 #define ASEL_CAP_ASEL_CAPABLE ((u8) BIT(0))
492 #define ASEL_CAP_EXPLICIT_CSI_FEEDBACK_BASED_TX_AS_CAP ((u8) BIT(1))
493 #define ASEL_CAP_ANT_INDICES_FEEDBACK_BASED_TX_AS_CAP ((u8) BIT(2))
494 #define ASEL_CAP_EXPLICIT_CSI_FEEDBACK_CAP ((u8) BIT(3))
495 #define ASEL_CAP_ANT_INDICES_FEEDBACK_CAP ((u8) BIT(4))
496 #define ASEL_CAP_RX_AS_CAP ((u8) BIT(5))
497 #define ASEL_CAP_TX_SOUNDING_PPDUS_CAP ((u8) BIT(6))
498 /* B7 - Reserved */
499 
500 /* First octet of HT Operation Information within HT Operation element */
501 #define HT_INFO_HT_PARAM_SECONDARY_CHNL_OFF_MASK	((u8) BIT(0) | BIT(1))
502 #define HT_INFO_HT_PARAM_SECONDARY_CHNL_ABOVE		((u8) BIT(0))
503 #define HT_INFO_HT_PARAM_SECONDARY_CHNL_BELOW		((u8) BIT(0) | BIT(1))
504 #define HT_INFO_HT_PARAM_STA_CHNL_WIDTH			((u8) BIT(2))
505 #define HT_INFO_HT_PARAM_RIFS_MODE			((u8) BIT(3))
506 /* B4..B7 - Reserved */
507 
508 /* HT Protection (B8..B9 of HT Operation Information) */
509 #define HT_PROT_NO_PROTECTION           0
510 #define HT_PROT_NONMEMBER_PROTECTION    1
511 #define HT_PROT_20MHZ_PROTECTION        2
512 #define HT_PROT_NON_HT_MIXED            3
513 /* Bits within ieee80211_ht_operation::operation_mode (BIT(0) maps to B8 in
514  * HT Operation Information) */
515 #define HT_OPER_OP_MODE_HT_PROT_MASK ((u16) (BIT(0) | BIT(1))) /* B8..B9 */
516 #define HT_OPER_OP_MODE_NON_GF_HT_STAS_PRESENT	((u16) BIT(2)) /* B10 */
517 /* BIT(3), i.e., B11 in HT Operation Information field - Reserved */
518 #define HT_OPER_OP_MODE_OBSS_NON_HT_STAS_PRESENT	((u16) BIT(4)) /* B12 */
519 /* BIT(5)..BIT(15), i.e., B13..B23 - Reserved */
520 
521 /* Last two octets of HT Operation Information (BIT(0) = B24) */
522 /* B24..B29 - Reserved */
523 #define HT_OPER_PARAM_DUAL_BEACON			((u16) BIT(6))
524 #define HT_OPER_PARAM_DUAL_CTS_PROTECTION		((u16) BIT(7))
525 #define HT_OPER_PARAM_STBC_BEACON			((u16) BIT(8))
526 #define HT_OPER_PARAM_LSIG_TXOP_PROT_FULL_SUPP		((u16) BIT(9))
527 #define HT_OPER_PARAM_PCO_ACTIVE			((u16) BIT(10))
528 #define HT_OPER_PARAM_PCO_PHASE				((u16) BIT(11))
529 /* B36..B39 - Reserved */
530 
531 #define MULTI_AP_SUB_ELEM_TYPE 0x06
532 #define MULTI_AP_TEAR_DOWN BIT(4)
533 #define MULTI_AP_FRONTHAUL_BSS BIT(5)
534 #define MULTI_AP_BACKHAUL_BSS BIT(6)
535 #define MULTI_AP_BACKHAUL_STA BIT(7)
536 
537 #define WMM_OUI_TYPE 2
538 #define WMM_OUI_SUBTYPE_INFORMATION_ELEMENT 0
539 #define WMM_OUI_SUBTYPE_PARAMETER_ELEMENT 1
540 #define WMM_OUI_SUBTYPE_TSPEC_ELEMENT 2
541 #define WMM_VERSION 1
542 
543 #define WMM_ACTION_CODE_ADDTS_REQ 0
544 #define WMM_ACTION_CODE_ADDTS_RESP 1
545 #define WMM_ACTION_CODE_DELTS 2
546 
547 #define WMM_ADDTS_STATUS_ADMISSION_ACCEPTED 0
548 #define WMM_ADDTS_STATUS_INVALID_PARAMETERS 1
549 /* 2 - Reserved */
550 #define WMM_ADDTS_STATUS_REFUSED 3
551 /* 4-255 - Reserved */
552 
553 /* WMM TSPEC Direction Field Values */
554 #define WMM_TSPEC_DIRECTION_UPLINK 0
555 #define WMM_TSPEC_DIRECTION_DOWNLINK 1
556 /* 2 - Reserved */
557 #define WMM_TSPEC_DIRECTION_BI_DIRECTIONAL 3
558 
559 #define MBO_IE_VENDOR_TYPE 0x506f9a16
560 #define OSEN_IE_VENDOR_TYPE 0x506f9a12
561 #define SAE_PK_IE_VENDOR_TYPE 0x506f9a1f
562 #define SAE_PK_OUI_TYPE 0x1f
563 #define MBO_OUI_TYPE 22
564 #define OCE_STA BIT(0)
565 #define OCE_STA_CFON BIT(1)
566 #define OCE_AP BIT(2)
567 
568 /*
569  * WMM Information Element (used in (Re)Association Request frames; may also be
570  * used in Beacon frames)
571  */
572 struct wmm_information_element {
573 	/* Element ID: 221 (0xdd); Length: 7 */
574 	/* required fields for WMM version 1 */
575 	u8 oui[3]; /* 00:50:f2 */
576 	u8 oui_type; /* 2 */
577 	u8 oui_subtype; /* 0 */
578 	u8 version; /* 1 for WMM version 1.0 */
579 	u8 qos_info; /* AP/STA specific QoS info */
580 
581 } STRUCT_PACKED;
582 
583 #define WMM_AC_AIFSN_MASK 0x0f
584 #define WMM_AC_AIFNS_SHIFT 0
585 #define WMM_AC_ACM 0x10
586 #define WMM_AC_ACI_MASK 0x60
587 #define WMM_AC_ACI_SHIFT 5
588 
589 #define WMM_AC_ECWMIN_MASK 0x0f
590 #define WMM_AC_ECWMIN_SHIFT 0
591 #define WMM_AC_ECWMAX_MASK 0xf0
592 #define WMM_AC_ECWMAX_SHIFT 4
593 
594 struct wmm_ac_parameter {
595 	u8 aci_aifsn; /* AIFSN, ACM, ACI */
596 	u8 cw; /* ECWmin, ECWmax (CW = 2^ECW - 1) */
597 	le16 txop_limit;
598 }  STRUCT_PACKED;
599 
600 /*
601  * WMM Parameter Element (used in Beacon, Probe Response, and (Re)Association
602  * Response frmaes)
603  */
604 struct wmm_parameter_element {
605 	/* Element ID: 221 (0xdd); Length: 24 */
606 	/* required fields for WMM version 1 */
607 	u8 oui[3]; /* 00:50:f2 */
608 	u8 oui_type; /* 2 */
609 	u8 oui_subtype; /* 1 */
610 	u8 version; /* 1 for WMM version 1.0 */
611 	u8 qos_info; /* AP/STA specific QoS info */
612 	u8 reserved; /* 0 */
613 	struct wmm_ac_parameter ac[4]; /* AC_BE, AC_BK, AC_VI, AC_VO */
614 
615 } STRUCT_PACKED;
616 
617 /* WMM TSPEC Element */
618 struct wmm_tspec_element {
619 	u8 eid; /* 221 = 0xdd */
620 	u8 length; /* 6 + 55 = 61 */
621 	u8 oui[3]; /* 00:50:f2 */
622 	u8 oui_type; /* 2 */
623 	u8 oui_subtype; /* 2 */
624 	u8 version; /* 1 */
625 	/* WMM TSPEC body (55 octets): */
626 	u8 ts_info[3];
627 	le16 nominal_msdu_size;
628 	le16 maximum_msdu_size;
629 	le32 minimum_service_interval;
630 	le32 maximum_service_interval;
631 	le32 inactivity_interval;
632 	le32 suspension_interval;
633 	le32 service_start_time;
634 	le32 minimum_data_rate;
635 	le32 mean_data_rate;
636 	le32 peak_data_rate;
637 	le32 maximum_burst_size;
638 	le32 delay_bound;
639 	le32 minimum_phy_rate;
640 	le16 surplus_bandwidth_allowance;
641 	le16 medium_time;
642 } STRUCT_PACKED;
643 
644 
645 /* Access Categories / ACI to AC coding */
646 enum wmm_ac {
647 	WMM_AC_BE = 0 /* Best Effort */,
648 	WMM_AC_BK = 1 /* Background */,
649 	WMM_AC_VI = 2 /* Video */,
650 	WMM_AC_VO = 3 /* Voice */,
651 	WMM_AC_NUM = 4
652 };
653 
654 /* MBO v0.0_r19, 4.2: MBO Attributes */
655 /* Table 4-5: MBO Attributes */
656 /* OCE v0.0.10, Table 4-3: OCE Attributes */
657 enum mbo_attr_id {
658 	MBO_ATTR_ID_AP_CAPA_IND = 1,
659 	MBO_ATTR_ID_NON_PREF_CHAN_REPORT = 2,
660 	MBO_ATTR_ID_CELL_DATA_CAPA = 3,
661 	MBO_ATTR_ID_ASSOC_DISALLOW = 4,
662 	MBO_ATTR_ID_CELL_DATA_PREF = 5,
663 	MBO_ATTR_ID_TRANSITION_REASON = 6,
664 	MBO_ATTR_ID_TRANSITION_REJECT_REASON = 7,
665 	MBO_ATTR_ID_ASSOC_RETRY_DELAY = 8,
666 	OCE_ATTR_ID_CAPA_IND = 101,
667 	OCE_ATTR_ID_RSSI_BASED_ASSOC_REJECT = 102,
668 	OCE_ATTR_ID_REDUCED_WAN_METRICS = 103,
669 	OCE_ATTR_ID_RNR_COMPLETENESS = 104,
670 };
671 
672 /* MBO v0.0_r19, 4.2.1: MBO AP Capability Indication Attribute */
673 /* Table 4-7: MBO AP Capability Indication Field Values */
674 #define MBO_AP_CAPA_CELL_AWARE BIT(6)
675 
676 /* MBO v0.0_r19, 4.2.2: Non-preferred Channel Report Attribute */
677 /* Table 4-10: Reason Code Field Values */
678 enum mbo_non_pref_chan_reason {
679 	MBO_NON_PREF_CHAN_REASON_UNSPECIFIED = 0,
680 	MBO_NON_PREF_CHAN_REASON_RSSI = 1,
681 	MBO_NON_PREF_CHAN_REASON_EXT_INTERFERENCE = 2,
682 	MBO_NON_PREF_CHAN_REASON_INT_INTERFERENCE = 3,
683 };
684 
685 /* MBO v0.0_r19, 4.2.3: Cellular Data Capabilities Attribute */
686 /* Table 4-13: Cellular Data Connectivity Field */
687 enum mbo_cellular_capa {
688 	MBO_CELL_CAPA_AVAILABLE = 1,
689 	MBO_CELL_CAPA_NOT_AVAILABLE = 2,
690 	MBO_CELL_CAPA_NOT_SUPPORTED = 3,
691 };
692 
693 /* MBO v0.0_r19, 4.2.7: Transition Rejection Reason Code Attribute */
694 /* Table 4-21: Transition Rejection Reason Code Field Values */
695 enum mbo_transition_reject_reason {
696 	MBO_TRANSITION_REJECT_REASON_UNSPECIFIED = 0,
697 	MBO_TRANSITION_REJECT_REASON_FRAME_LOSS = 1,
698 	MBO_TRANSITION_REJECT_REASON_DELAY = 2,
699 	MBO_TRANSITION_REJECT_REASON_QOS_CAPACITY = 3,
700 	MBO_TRANSITION_REJECT_REASON_RSSI = 4,
701 	MBO_TRANSITION_REJECT_REASON_INTERFERENCE = 5,
702 	MBO_TRANSITION_REJECT_REASON_SERVICES = 6,
703 };
704 
705 /* OCE v0.0.10, 4.2.1: OCE Capability Indication Attribute */
706 #define OCE_RELEASE 1
707 #define OCE_RELEASE_MASK (BIT(0) | BIT(1) | BIT(2))
708 #define OCE_IS_STA_CFON BIT(3)
709 #define OCE_IS_NON_OCE_AP_PRESENT BIT(4)
710 
711 /* IEEE 802.11v - WNM Action field values */
712 enum wnm_action {
713 	WNM_EVENT_REQ = 0,
714 	WNM_EVENT_REPORT = 1,
715 	WNM_DIAGNOSTIC_REQ = 2,
716 	WNM_DIAGNOSTIC_REPORT = 3,
717 	WNM_LOCATION_CFG_REQ = 4,
718 	WNM_LOCATION_CFG_RESP = 5,
719 	WNM_BSS_TRANS_MGMT_QUERY = 6,
720 	WNM_BSS_TRANS_MGMT_REQ = 7,
721 	WNM_BSS_TRANS_MGMT_RESP = 8,
722 	WNM_FMS_REQ = 9,
723 	WNM_FMS_RESP = 10,
724 	WNM_COLLOCATED_INTERFERENCE_REQ = 11,
725 	WNM_COLLOCATED_INTERFERENCE_REPORT = 12,
726 	WNM_TFS_REQ = 13,
727 	WNM_TFS_RESP = 14,
728 	WNM_TFS_NOTIFY = 15,
729 	WNM_SLEEP_MODE_REQ = 16,
730 	WNM_SLEEP_MODE_RESP = 17,
731 	WNM_TIM_BROADCAST_REQ = 18,
732 	WNM_TIM_BROADCAST_RESP = 19,
733 	WNM_QOS_TRAFFIC_CAPAB_UPDATE = 20,
734 	WNM_CHANNEL_USAGE_REQ = 21,
735 	WNM_CHANNEL_USAGE_RESP = 22,
736 	WNM_DMS_REQ = 23,
737 	WNM_DMS_RESP = 24,
738 	WNM_TIMING_MEASUREMENT_REQ = 25,
739 	WNM_NOTIFICATION_REQ = 26,
740 	WNM_NOTIFICATION_RESP = 27
741 };
742 
743 /* IEEE 802.11v - BSS Transition Management Request - Request Mode */
744 #define WNM_BSS_TM_REQ_PREF_CAND_LIST_INCLUDED BIT(0)
745 #define WNM_BSS_TM_REQ_ABRIDGED BIT(1)
746 #define WNM_BSS_TM_REQ_DISASSOC_IMMINENT BIT(2)
747 #define WNM_BSS_TM_REQ_BSS_TERMINATION_INCLUDED BIT(3)
748 #define WNM_BSS_TM_REQ_ESS_DISASSOC_IMMINENT BIT(4)
749 
750 /* IEEE Std 802.11-2012 - Table 8-253 */
751 enum bss_trans_mgmt_status_code {
752 	WNM_BSS_TM_ACCEPT = 0,
753 	WNM_BSS_TM_REJECT_UNSPECIFIED = 1,
754 	WNM_BSS_TM_REJECT_INSUFFICIENT_BEACON = 2,
755 	WNM_BSS_TM_REJECT_INSUFFICIENT_CAPABITY = 3,
756 	WNM_BSS_TM_REJECT_UNDESIRED = 4,
757 	WNM_BSS_TM_REJECT_DELAY_REQUEST = 5,
758 	WNM_BSS_TM_REJECT_STA_CANDIDATE_LIST_PROVIDED = 6,
759 	WNM_BSS_TM_REJECT_NO_SUITABLE_CANDIDATES = 7,
760 	WNM_BSS_TM_REJECT_LEAVING_ESS = 8
761 };
762 
763 /*
764  * IEEE P802.11-REVmc/D5.0 Table 9-150 - Optional subelement IDs for
765  * neighbor report
766  */
767 #define WNM_NEIGHBOR_TSF                         1
768 #define WNM_NEIGHBOR_CONDENSED_COUNTRY_STRING    2
769 #define WNM_NEIGHBOR_BSS_TRANSITION_CANDIDATE    3
770 #define WNM_NEIGHBOR_BSS_TERMINATION_DURATION    4
771 #define WNM_NEIGHBOR_BEARING                     5
772 #define WNM_NEIGHBOR_MEASUREMENT_REPORT         39
773 #define WNM_NEIGHBOR_MEASUREMENT_PILOT          66
774 #define WNM_NEIGHBOR_RRM_ENABLED_CAPABILITIES   70
775 #define WNM_NEIGHBOR_MULTIPLE_BSSID             71
776 
777 struct tpc_report {
778 	u8 eid;
779 	u8 len;
780 	u8 tx_power;
781 	u8 link_margin;
782 } STRUCT_PACKED;
783 
784 #define RRM_CAPABILITIES_IE_LEN 5
785 
786 /* IEEE Std 802.11-2012, 8.5.7.4 - Link Measurement Request frame format */
787 struct rrm_link_measurement_request {
788 	u8 dialog_token;
789 	s8 tx_power;
790 	s8 max_tp;
791 	u8 variable[0];
792 } STRUCT_PACKED;
793 
794 /* IEEE Std 802.11-2012, 8.5.7.5 - Link Measurement Report frame format */
795 struct rrm_link_measurement_report {
796 	u8 dialog_token;
797 	struct tpc_report tpc;
798 	u8 rx_ant_id;
799 	u8 tx_ant_id;
800 	u8 rcpi;
801 	u8 rsni;
802 	u8 variable[0];
803 } STRUCT_PACKED;
804 
805 /* IEEE Std 802.11-2016, 9.4.2.21 - Measurement Request element */
806 struct rrm_measurement_request_element {
807 	u8 eid; /* Element ID */
808 	u8 len; /* Length */
809 	u8 token; /* Measurement Token */
810 	u8 mode; /* Measurement Request Mode */
811 	u8 type; /* Measurement Type */
812 	u8 variable[0]; /* Measurement Request */
813 } STRUCT_PACKED;
814 
815 /* IEEE Std 802.11-2016, Figure 9-148 - Measurement Request Mode field */
816 #define MEASUREMENT_REQUEST_MODE_PARALLEL BIT(0)
817 #define MEASUREMENT_REQUEST_MODE_ENABLE BIT(1)
818 #define MEASUREMENT_REQUEST_MODE_REQUEST BIT(2)
819 #define MEASUREMENT_REQUEST_MODE_REPORT BIT(3)
820 #define MEASUREMENT_REQUEST_MODE_DURATION_MANDATORY BIT(4)
821 
822 /* IEEE Std 802.11-2016, 9.4.2.21.7 - Beacon request */
823 struct rrm_measurement_beacon_request {
824 	u8 oper_class; /* Operating Class */
825 	u8 channel; /* Channel Number */
826 	le16 rand_interval; /* Randomization Interval (in TUs) */
827 	le16 duration; /* Measurement Duration (in TUs) */
828 	u8 mode; /* Measurement Mode */
829 	u8 bssid[ETH_ALEN]; /* BSSID */
830 	u8 variable[0]; /* Optional Subelements */
831 } STRUCT_PACKED;
832 
833 /*
834  * IEEE Std 802.11-2016, Table 9-87 - Measurement Mode definitions for Beacon
835  * request
836  */
837 enum beacon_report_mode {
838 	BEACON_REPORT_MODE_PASSIVE = 0,
839 	BEACON_REPORT_MODE_ACTIVE = 1,
840 	BEACON_REPORT_MODE_TABLE = 2,
841 };
842 
843 /* IEEE Std 802.11-2016, Table 9-88 - Beacon Request subelement IDs */
844 /* IEEE P802.11-REVmd/D2.0, Table 9-106 - Optional subelement IDs for
845  * Beacon request */
846 #define WLAN_BEACON_REQUEST_SUBELEM_SSID	0
847 #define WLAN_BEACON_REQUEST_SUBELEM_INFO	1 /* Beacon Reporting */
848 #define WLAN_BEACON_REQUEST_SUBELEM_DETAIL	2 /* Reporting Detail */
849 #define WLAN_BEACON_REQUEST_SUBELEM_REQUEST	10
850 #define WLAN_BEACON_REQUEST_SUBELEM_AP_CHANNEL	51 /* AP Channel Report */
851 #define WLAN_BEACON_REQUEST_SUBELEM_LAST_INDICATION	164
852 #define WLAN_BEACON_REQUEST_SUBELEM_VENDOR	221
853 
854 /*
855  * IEEE Std 802.11-2016, Table 9-90 - Reporting Detail values
856  */
857 enum beacon_report_detail {
858 	/* No fixed-length fields or elements */
859 	BEACON_REPORT_DETAIL_NONE = 0,
860 	/* All fixed-length fields and any requested elements in the Request
861 	 * element if present */
862 	BEACON_REPORT_DETAIL_REQUESTED_ONLY = 1,
863 	/* All fixed-length fields and elements (default, used when Reporting
864 	 * Detail subelement is not included in a Beacon request) */
865 	BEACON_REPORT_DETAIL_ALL_FIELDS_AND_ELEMENTS = 2,
866 };
867 
868 /* IEEE Std 802.11-2016, 9.4.2.22 - Measurement Report element */
869 struct rrm_measurement_report_element {
870 	u8 eid; /* Element ID */
871 	u8 len; /* Length */
872 	u8 token; /* Measurement Token */
873 	u8 mode; /* Measurement Report Mode */
874 	u8 type; /* Measurement Type */
875 	u8 variable[0]; /* Measurement Report */
876 } STRUCT_PACKED;
877 
878 /* IEEE Std 802.11-2016, Figure 9-192 - Measurement Report Mode field */
879 #define MEASUREMENT_REPORT_MODE_ACCEPT 0
880 #define MEASUREMENT_REPORT_MODE_REJECT_LATE BIT(0)
881 #define MEASUREMENT_REPORT_MODE_REJECT_INCAPABLE BIT(1)
882 #define MEASUREMENT_REPORT_MODE_REJECT_REFUSED BIT(2)
883 
884 /* IEEE Std 802.11-2016, 9.4.2.22.7 - Beacon report */
885 struct rrm_measurement_beacon_report {
886 	u8 op_class; /* Operating Class */
887 	u8 channel; /* Channel Number */
888 	le64 start_time; /* Actual Measurement Start Time
889 			  * (in TSF of the BSS requesting the measurement) */
890 	le16 duration; /* in TUs */
891 	u8 report_info; /* Reported Frame Information */
892 	u8 rcpi; /* RCPI */
893 	u8 rsni; /* RSNI */
894 	u8 bssid[ETH_ALEN]; /* BSSID */
895 	u8 antenna_id; /* Antenna ID */
896 	le32 parent_tsf; /* Parent TSF */
897 	u8 variable[0]; /* Optional Subelements */
898 } STRUCT_PACKED;
899 
900 /* IEEE Std 802.11-2016, Table 9-112 - Beacon report Subelement IDs */
901 /* IEEE P802.11-REVmd/D2.0, Table 9-130 - Optional subelement IDs for
902  * Beacon report */
903 #define WLAN_BEACON_REPORT_SUBELEM_FRAME_BODY	1
904 #define WLAN_BEACON_REPORT_SUBELEM_FRAME_BODY_FRAGMENT_ID	2
905 #define WLAN_BEACON_REPORT_SUBELEM_LAST_INDICATION	164
906 
907 /* IEEE P802.11-REVmd/D2.0, Table 9-232 - Data field format of the
908  * Reported Frame Body Fragment ID subelement */
909 #define REPORTED_FRAME_BODY_SUBELEM_LEN		4
910 #define REPORTED_FRAME_BODY_MORE_FRAGMENTS	BIT(7)
911 
912 /* IEEE P802.11-REVmd/D2.0, 9.4.2.21.7 - Beacon report  */
913 #define BEACON_REPORT_LAST_INDICATION_SUBELEM_LEN	3
914 
915 /* IEEE Std 802.11ac-2013, Annex C - dot11PHYType */
916 enum phy_type {
917 	PHY_TYPE_UNSPECIFIED = 0,
918 	PHY_TYPE_FHSS = 1,
919 	PHY_TYPE_DSSS = 2,
920 	PHY_TYPE_IRBASEBAND = 3,
921 	PHY_TYPE_OFDM = 4,
922 	PHY_TYPE_HRDSSS = 5,
923 	PHY_TYPE_ERP = 6,
924 	PHY_TYPE_HT = 7,
925 	PHY_TYPE_DMG = 8,
926 	PHY_TYPE_VHT = 9,
927 };
928 
929 /* IEEE P802.11-REVmc/D5.0, 9.4.2.37 - Neighbor Report element */
930 /* BSSID Information Field */
931 #define NEI_REP_BSSID_INFO_AP_NOT_REACH BIT(0)
932 #define NEI_REP_BSSID_INFO_AP_UNKNOWN_REACH BIT(1)
933 #define NEI_REP_BSSID_INFO_AP_REACHABLE (BIT(0) | BIT(1))
934 #define NEI_REP_BSSID_INFO_SECURITY BIT(2)
935 #define NEI_REP_BSSID_INFO_KEY_SCOPE BIT(3)
936 #define NEI_REP_BSSID_INFO_SPECTRUM_MGMT BIT(4)
937 #define NEI_REP_BSSID_INFO_QOS BIT(5)
938 #define NEI_REP_BSSID_INFO_APSD BIT(6)
939 #define NEI_REP_BSSID_INFO_RM BIT(7)
940 #define NEI_REP_BSSID_INFO_DELAYED_BA BIT(8)
941 #define NEI_REP_BSSID_INFO_IMM_BA BIT(9)
942 #define NEI_REP_BSSID_INFO_MOBILITY_DOMAIN BIT(10)
943 #define NEI_REP_BSSID_INFO_HT BIT(11)
944 #define NEI_REP_BSSID_INFO_VHT BIT(12)
945 #define NEI_REP_BSSID_INFO_FTM BIT(13)
946 
947 #endif /* IEEE802_11_DEFS_H */
948