Commit | Line | Data |
---|---|---|
1b4a7c03 LJ |
1 | /* |
2 | * Fundamental types and constants relating to WFA NAN | |
3 | * (Neighbor Awareness Networking) | |
4 | * | |
5 | * Copyright (C) 2020, Broadcom. | |
6 | * | |
7 | * Unless you and Broadcom execute a separate written software license | |
8 | * agreement governing use of this software, this software is licensed to you | |
9 | * under the terms of the GNU General Public License version 2 (the "GPL"), | |
10 | * available at http://www.broadcom.com/licenses/GPLv2.php, with the | |
11 | * following added to such license: | |
12 | * | |
13 | * As a special exception, the copyright holders of this software give you | |
14 | * permission to link this software with independent modules, and to copy and | |
15 | * distribute the resulting executable under terms of your choice, provided that | |
16 | * you also meet, for each linked independent module, the terms and conditions of | |
17 | * the license of that module. An independent module is a module which is not | |
18 | * derived from this software. The special exception does not apply to any | |
19 | * modifications of the software. | |
20 | * | |
21 | * | |
22 | * <<Broadcom-WL-IPTag/Dual:>> | |
23 | */ | |
24 | #ifndef _NAN_H_ | |
25 | #define _NAN_H_ | |
26 | ||
27 | #include <typedefs.h> | |
28 | #include <802.11.h> | |
29 | ||
30 | /* Do we want to include p2p.h for constants like P2P_WFDS_HASH_LEN and | |
31 | * maybe P2P_WFDS_MAX_SVC_NAME_LEN etc.? | |
32 | */ | |
33 | ||
34 | /* This marks the start of a packed structure section. */ | |
35 | #include <packed_section_start.h> | |
36 | ||
37 | /* WiFi NAN OUI values */ | |
38 | #define NAN_OUI "\x50\x6F\x9A" /* WFA OUI. WiFi-Alliance OUI */ | |
39 | /* For oui_type field identifying the type and version of the NAN IE. */ | |
40 | #define NAN_OUI_TYPE 0x13 /* Type/Version */ | |
41 | #define NAN_AF_OUI_TYPE 0x18 /* Type/Version */ | |
42 | /* IEEE 802.11 vendor specific information element. (Same as P2P_IE_ID.) */ | |
43 | #define NAN_IE_ID 0xdd | |
44 | ||
45 | /* Same as P2P_PUB_AF_CATEGORY and DOT11_ACTION_CAT_PUBLIC */ | |
46 | #define NAN_PUB_AF_CATEGORY DOT11_ACTION_CAT_PUBLIC | |
47 | /* Protected dual public action frame category */ | |
48 | #define NAN_PROT_DUAL_PUB_AF_CATEGORY DOT11_ACTION_CAT_PDPA | |
49 | /* IEEE 802.11 Public Action Frame Vendor Specific. (Same as P2P_PUB_AF_ACTION.) */ | |
50 | #define NAN_PUB_AF_ACTION DOT11_PUB_ACTION_VENDOR_SPEC | |
51 | /* Number of octents in hash of service name. (Same as P2P_WFDS_HASH_LEN.) */ | |
52 | #define NAN_SVC_HASH_LEN 6 | |
53 | /* Size of fixed length part of nan_pub_act_frame_t before attributes. */ | |
54 | #define NAN_PUB_ACT_FRAME_FIXED_LEN 6 | |
55 | /* Number of octents in master rank value. */ | |
56 | #define NAN_MASTER_RANK_LEN 8 | |
57 | /* NAN public action frame header size */ | |
58 | #define NAN_PUB_ACT_FRAME_HDR_SIZE (OFFSETOF(nan_pub_act_frame_t, data)) | |
59 | /* NAN network ID */ | |
60 | #define NAN_NETWORK_ID "\x51\x6F\x9A\x01\x00\x00" | |
61 | /* Service Control Type length */ | |
62 | #define NAN_SVC_CONTROL_TYPE_LEN 2 | |
63 | /* Binding Bitmap length */ | |
64 | #define NAN_BINDING_BITMAP_LEN 2 | |
65 | /* Service Response Filter (SRF) control field masks */ | |
66 | #define NAN_SRF_BLOOM_MASK 0x01 | |
67 | #define NAN_SRF_INCLUDE_MASK 0x02 | |
68 | #define NAN_SRF_INDEX_MASK 0x0C | |
69 | /* SRF Bloom Filter index shift */ | |
70 | #define NAN_SRF_BLOOM_SHIFT 2 | |
71 | #define NAN_SRF_INCLUDE_SHIFT 1 | |
72 | /* Mask for CRC32 output, used in hash function for NAN bloom filter */ | |
73 | #define NAN_BLOOM_CRC32_MASK 0xFFFF | |
74 | ||
75 | /* Attribute TLV header size */ | |
76 | #define NAN_ATTR_ID_OFF 0 | |
77 | #define NAN_ATTR_LEN_OFF 1 | |
78 | #define NAN_ATTR_DATA_OFF 3 | |
79 | ||
80 | #define NAN_ATTR_ID_LEN 1u /* ID field length */ | |
81 | #define NAN_ATTR_LEN_LEN 2u /* Length field length */ | |
82 | #define NAN_ATTR_HDR_LEN (NAN_ATTR_ID_LEN + NAN_ATTR_LEN_LEN) | |
83 | #define NAN_ENTRY_CTRL_LEN 1 /* Entry control field length from FAM attribute */ | |
84 | #define NAN_MAP_ID_LEN 1 /* MAP ID length to signify band */ | |
85 | #define NAN_OPERATING_CLASS_LEN 1 /* operating class field length from NAN FAM */ | |
86 | #define NAN_CHANNEL_NUM_LEN 1 /* channel number field length 1 byte */ | |
87 | ||
88 | /* generic nan attribute total length */ | |
89 | #define NAN_ATTR_TOT_LEN(_nan_attr) (ltoh16_ua(((const uint8 *)(_nan_attr)) + \ | |
90 | NAN_ATTR_ID_LEN) + NAN_ATTR_HDR_LEN) | |
91 | ||
92 | /* NAN slot duration / period */ | |
93 | #define NAN_MIN_TU 16 | |
94 | #define NAN_TU_PER_DW 512 | |
95 | #define NAN_MAX_DW 16 | |
96 | #define NAN_MAX_TU (NAN_MAX_DW * NAN_TU_PER_DW) | |
97 | ||
98 | #define NAN_SLOT_DUR_0TU 0 | |
99 | #define NAN_SLOT_DUR_16TU 16 | |
100 | #define NAN_SLOT_DUR_32TU 32 | |
101 | #define NAN_SLOT_DUR_64TU 64 | |
102 | #define NAN_SLOT_DUR_128TU 128 | |
103 | #define NAN_SLOT_DUR_256TU 256 | |
104 | #define NAN_SLOT_DUR_512TU 512 | |
105 | #define NAN_SLOT_DUR_1024TU 1024 | |
106 | #define NAN_SLOT_DUR_2048TU 2048 | |
107 | #define NAN_SLOT_DUR_4096TU 4096 | |
108 | #define NAN_SLOT_DUR_8192TU 8192 | |
109 | ||
110 | #define NAN_SOC_CHAN_2G 6 /* NAN 2.4G discovery channel */ | |
111 | #define NAN_SOC_CHAN_5G_CH149 149 /* NAN 5G discovery channel if upper band allowed */ | |
112 | #define NAN_SOC_CHAN_5G_CH44 44 /* NAN 5G discovery channel if only lower band allowed */ | |
113 | ||
114 | /* size of ndc id */ | |
115 | #define NAN_DATA_NDC_ID_SIZE 6 | |
116 | ||
117 | #define NAN_AVAIL_ENTRY_LEN_RES0 7 /* Avail entry len in FAM attribute for resolution 16TU */ | |
118 | #define NAN_AVAIL_ENTRY_LEN_RES1 5 /* Avail entry len in FAM attribute for resolution 32TU */ | |
119 | #define NAN_AVAIL_ENTRY_LEN_RES2 4 /* Avail entry len in FAM attribute for resolution 64TU */ | |
120 | ||
121 | /* map id field */ | |
122 | #define NAN_MAPID_SPECIFIC_MAP_MASK 0x01 /* apply to specific map */ | |
123 | #define NAN_MAPID_MAPID_MASK 0x1E | |
124 | #define NAN_MAPID_MAPID_SHIFT 1 | |
125 | #define NAN_MAPID_SPECIFIC_MAP(_mapid) ((_mapid) & NAN_MAPID_SPECIFIC_MAP_MASK) | |
126 | #define NAN_MAPID_ALL_MAPS(_mapid) (!NAN_MAPID_SPECIFIC_MAP(_mapid)) | |
127 | #define NAN_MAPID_MAPID(_mapid) (((_mapid) & NAN_MAPID_MAPID_MASK) \ | |
128 | >> NAN_MAPID_MAPID_SHIFT) | |
129 | #define NAN_MAPID_SET_SPECIFIC_MAPID(map_id) ((((map_id) << NAN_MAPID_MAPID_SHIFT) \ | |
130 | & NAN_MAPID_MAPID_MASK) | NAN_MAPID_SPECIFIC_MAP_MASK) | |
131 | ||
132 | /* Vendor-specific public action frame for NAN */ | |
133 | typedef BWL_PRE_PACKED_STRUCT struct nan_pub_act_frame_s { | |
134 | /* NAN_PUB_AF_CATEGORY 0x04 */ | |
135 | uint8 category_id; | |
136 | /* NAN_PUB_AF_ACTION 0x09 */ | |
137 | uint8 action_field; | |
138 | /* NAN_OUI 0x50-6F-9A */ | |
139 | uint8 oui[DOT11_OUI_LEN]; | |
140 | /* NAN_OUI_TYPE 0x13 */ | |
141 | uint8 oui_type; | |
142 | /* One or more NAN Attributes follow */ | |
143 | uint8 data[]; | |
144 | } BWL_POST_PACKED_STRUCT nan_pub_act_frame_t; | |
145 | ||
146 | /* NAN attributes as defined in the nan spec */ | |
147 | enum { | |
148 | NAN_ATTR_MASTER_IND = 0, | |
149 | NAN_ATTR_CLUSTER = 1, | |
150 | NAN_ATTR_SVC_ID_LIST = 2, | |
151 | NAN_ATTR_SVC_DESCRIPTOR = 3, | |
152 | NAN_ATTR_CONN_CAP = 4, | |
153 | NAN_ATTR_INFRA = 5, | |
154 | NAN_ATTR_P2P = 6, | |
155 | NAN_ATTR_IBSS = 7, | |
156 | NAN_ATTR_MESH = 8, | |
157 | NAN_ATTR_FURTHER_NAN_SD = 9, | |
158 | NAN_ATTR_FURTHER_AVAIL = 10, | |
159 | NAN_ATTR_COUNTRY_CODE = 11, | |
160 | NAN_ATTR_RANGING = 12, | |
161 | NAN_ATTR_CLUSTER_DISC = 13, | |
162 | /* nan 2.0 */ | |
163 | NAN_ATTR_SVC_DESC_EXTENSION = 14, | |
164 | NAN_ATTR_NAN_DEV_CAP = 15, | |
165 | NAN_ATTR_NAN_NDP = 16, | |
166 | NAN_ATTR_NAN_NMSG = 17, | |
167 | NAN_ATTR_NAN_AVAIL = 18, | |
168 | NAN_ATTR_NAN_NDC = 19, | |
169 | NAN_ATTR_NAN_NDL = 20, | |
170 | NAN_ATTR_NAN_NDL_QOS = 21, | |
171 | NAN_ATTR_MCAST_SCHED = 22, | |
172 | NAN_ATTR_UNALIGN_SCHED = 23, | |
173 | NAN_ATTR_PAGING_UCAST = 24, | |
174 | NAN_ATTR_PAGING_MCAST = 25, | |
175 | NAN_ATTR_RANGING_INFO = 26, | |
176 | NAN_ATTR_RANGING_SETUP = 27, | |
177 | NAN_ATTR_FTM_RANGE_REPORT = 28, | |
178 | NAN_ATTR_ELEMENT_CONTAINER = 29, | |
179 | NAN_ATTR_WLAN_INFRA_EXT = 30, | |
180 | NAN_ATTR_EXT_P2P_OPER = 31, | |
181 | NAN_ATTR_EXT_IBSS = 32, | |
182 | NAN_ATTR_EXT_MESH = 33, | |
183 | NAN_ATTR_CIPHER_SUITE_INFO = 34, | |
184 | NAN_ATTR_SEC_CTX_ID_INFO = 35, | |
185 | NAN_ATTR_SHARED_KEY_DESC = 36, | |
186 | NAN_ATTR_MCAST_SCHED_CHANGE = 37, | |
187 | NAN_ATTR_MCAST_SCHED_OWNER_CHANGE = 38, | |
188 | NAN_ATTR_PUBLIC_AVAILABILITY = 39, | |
189 | NAN_ATTR_SUB_SVC_ID_LIST = 40, | |
190 | NAN_ATTR_NDPE = 41, | |
191 | /* change NAN_ATTR_MAX_ID to max ids + 1, excluding NAN_ATTR_VENDOR_SPECIFIC. | |
192 | * This is used in nan_parse.c | |
193 | */ | |
194 | NAN_ATTR_MAX_ID = NAN_ATTR_NDPE + 1, | |
195 | ||
196 | NAN_ATTR_VENDOR_SPECIFIC = 221 | |
197 | }; | |
198 | ||
199 | enum wifi_nan_avail_resolution { | |
200 | NAN_AVAIL_RES_16_TU = 0, | |
201 | NAN_AVAIL_RES_32_TU = 1, | |
202 | NAN_AVAIL_RES_64_TU = 2, | |
203 | NAN_AVAIL_RES_INVALID = 255 | |
204 | }; | |
205 | ||
206 | typedef BWL_PRE_PACKED_STRUCT struct wifi_nan_ie_s { | |
207 | uint8 id; /* IE ID: NAN_IE_ID 0xDD */ | |
208 | uint8 len; /* IE length */ | |
209 | uint8 oui[DOT11_OUI_LEN]; /* NAN_OUI 50:6F:9A */ | |
210 | uint8 oui_type; /* NAN_OUI_TYPE 0x13 */ | |
211 | uint8 attr[]; /* var len attributes */ | |
212 | } BWL_POST_PACKED_STRUCT wifi_nan_ie_t; | |
213 | ||
214 | #define NAN_IE_HDR_SIZE (OFFSETOF(wifi_nan_ie_t, attr)) | |
215 | ||
216 | /* master indication record */ | |
217 | typedef BWL_PRE_PACKED_STRUCT struct wifi_nan_master_ind_attr_s { | |
218 | uint8 id; | |
219 | uint16 len; | |
220 | uint8 master_preference; | |
221 | uint8 random_factor; | |
222 | } BWL_POST_PACKED_STRUCT wifi_nan_master_ind_attr_t; | |
223 | ||
224 | /* cluster attr record */ | |
225 | typedef BWL_PRE_PACKED_STRUCT struct wifi_nan_cluster_attr_s { | |
226 | uint8 id; | |
227 | uint16 len; | |
228 | uint8 amr[NAN_MASTER_RANK_LEN]; | |
229 | uint8 hop_count; | |
230 | /* Anchor Master Beacon Transmission Time */ | |
231 | uint32 ambtt; | |
232 | } BWL_POST_PACKED_STRUCT wifi_nan_cluster_attr_t; | |
233 | ||
234 | /* container for service ID records */ | |
235 | typedef BWL_PRE_PACKED_STRUCT struct wifi_nan_svc_id_attr_s { | |
236 | uint8 id; | |
237 | uint16 len; | |
238 | uint8 svcid[0]; /* 6*len of srvc IDs */ | |
239 | } BWL_POST_PACKED_STRUCT wifi_nan_svc_id_attr_t; | |
240 | ||
241 | /* service_control bitmap for wifi_nan_svc_descriptor_attr_t below */ | |
242 | #define NAN_SC_PUBLISH 0x0 | |
243 | #define NAN_SC_SUBSCRIBE 0x1 | |
244 | #define NAN_SC_FOLLOWUP 0x2 | |
245 | /* Set to 1 if a Matching Filter field is included in descriptors. */ | |
246 | #define NAN_SC_MATCHING_FILTER_PRESENT 0x4 | |
247 | /* Set to 1 if a Service Response Filter field is included in descriptors. */ | |
248 | #define NAN_SC_SR_FILTER_PRESENT 0x8 | |
249 | /* Set to 1 if a Service Info field is included in descriptors. */ | |
250 | #define NAN_SC_SVC_INFO_PRESENT 0x10 | |
251 | /* range is close proximity only */ | |
252 | #define NAN_SC_RANGE_LIMITED 0x20 | |
253 | /* Set to 1 if binding bitamp is present in descriptors */ | |
254 | #define NAN_SC_BINDING_BITMAP_PRESENT 0x40 | |
255 | ||
256 | /* Service descriptor */ | |
257 | typedef BWL_PRE_PACKED_STRUCT struct wifi_nan_svc_descriptor_attr_s { | |
258 | /* Attribute ID - 0x03. */ | |
259 | uint8 id; | |
260 | /* Length of the following fields in the attribute */ | |
261 | uint16 len; | |
262 | /* Hash of the Service Name */ | |
263 | uint8 svc_hash[NAN_SVC_HASH_LEN]; | |
264 | /* Publish or subscribe instance id */ | |
265 | uint8 instance_id; | |
266 | /* Requestor Instance ID */ | |
267 | uint8 requestor_id; | |
268 | /* Service Control Bitmask. Also determines what data follows. */ | |
269 | uint8 svc_control; | |
270 | /* Optional fields follow */ | |
271 | } BWL_POST_PACKED_STRUCT wifi_nan_svc_descriptor_attr_t; | |
272 | ||
273 | /* IBSS attribute */ | |
274 | typedef BWL_PRE_PACKED_STRUCT struct wifi_nan_ibss_attr_s { | |
275 | /* Attribute ID - 0x07. */ | |
276 | uint8 id; | |
277 | /* Length of the following fields in the attribute */ | |
278 | uint16 len; | |
279 | /* BSSID of the ibss */ | |
280 | struct ether_addr bssid; | |
281 | /* | |
282 | map control:, bits: | |
283 | [0-3]: Id for associated further avail map attribute | |
284 | [4-5]: avail interval duration: 0:16ms; 1:32ms; 2:64ms; 3:reserved | |
285 | [6] : repeat : 0 - applies to next DW, 1: 16 intervals max? wtf? | |
286 | [7] : reserved | |
287 | */ | |
288 | uint8 map_ctrl; | |
289 | /* avail. intervals bitmap, var len */ | |
290 | uint8 avail_bmp[1]; | |
291 | } BWL_POST_PACKED_STRUCT wifi_nan_ibss_attr_t; | |
292 | ||
293 | /* Country code attribute */ | |
294 | typedef BWL_PRE_PACKED_STRUCT struct wifi_nan_country_code_attr_s { | |
295 | /* Attribute ID - 0x0B. */ | |
296 | uint8 id; | |
297 | /* Length of the following fields in the attribute */ | |
298 | uint16 len; | |
299 | /* Condensed Country String first two octets */ | |
300 | uint8 country_str[2]; | |
301 | } BWL_POST_PACKED_STRUCT wifi_nan_country_code_attr_t; | |
302 | ||
303 | /* Further Availability MAP attr */ | |
304 | typedef BWL_PRE_PACKED_STRUCT struct wifi_nan_favail_attr_s { | |
305 | /* Attribute ID - 0x0A. */ | |
306 | uint8 id; | |
307 | /* Length of the following fields in the attribute */ | |
308 | uint16 len; | |
309 | /* MAP id: val [0..15], values[16-255] reserved */ | |
310 | uint8 map_id; | |
311 | /* availibility entry, var len */ | |
312 | uint8 avil_entry[1]; | |
313 | } BWL_POST_PACKED_STRUCT wifi_nan_favail_attr_t; | |
314 | ||
315 | /* Further Availability MAP attr */ | |
316 | typedef BWL_PRE_PACKED_STRUCT struct wifi_nan_avail_entry_s { | |
317 | /* | |
318 | entry control | |
319 | [0-1]: avail interval duration: 0:16ms; 1:32ms; 2:64ms; | |
320 | [2:7] reserved | |
321 | */ | |
322 | uint8 entry_ctrl; | |
323 | /* operating class: freq band etc IEEE 802.11 */ | |
324 | uint8 opclass; | |
325 | /* channel number */ | |
326 | uint8 chan; | |
327 | /* avail bmp, var len */ | |
328 | uint8 avail_bmp[1]; | |
329 | } BWL_POST_PACKED_STRUCT wifi_nan_avail_entry_t; | |
330 | ||
331 | /* Map control Field */ | |
332 | #define NAN_MAPCTRL_IDMASK 0x7 | |
333 | #define NAN_MAPCTRL_DURSHIFT 4 | |
334 | #define NAN_MAPCTRL_DURMASK 0x30 | |
335 | #define NAN_MAPCTRL_REPEAT 0x40 | |
336 | #define NAN_MAPCTRL_REPEATSHIFT 6 | |
337 | ||
338 | #define NAN_VENDOR_TYPE_RTT 0 | |
339 | #define NAN_VENDOR_TYPE_P2P 1 | |
340 | ||
341 | /* Vendor Specific Attribute - old definition */ | |
342 | /* TODO remove */ | |
343 | typedef BWL_PRE_PACKED_STRUCT struct wifi_nan_vendor_attr_s { | |
344 | uint8 id; /* 0xDD */ | |
345 | uint16 len; /* IE length */ | |
346 | uint8 oui[DOT11_OUI_LEN]; /* 00-90-4C */ | |
347 | uint8 type; /* attribute type */ | |
348 | uint8 attr[1]; /* var len attributes */ | |
349 | } BWL_POST_PACKED_STRUCT wifi_nan_vendor_attr_t; | |
350 | ||
351 | #define NAN_VENDOR_HDR_SIZE (OFFSETOF(wifi_nan_vendor_attr_t, attr)) | |
352 | ||
353 | /* vendor specific attribute */ | |
354 | typedef BWL_PRE_PACKED_STRUCT struct wifi_nan_vndr_attr_s { | |
355 | uint8 id; /* 0xDD */ | |
356 | uint16 len; /* length of following fields */ | |
357 | uint8 oui[DOT11_OUI_LEN]; /* vendor specific OUI */ | |
358 | uint8 body[]; | |
359 | } BWL_POST_PACKED_STRUCT wifi_nan_vndr_attr_t; | |
360 | ||
361 | /* p2p operation attribute */ | |
362 | typedef BWL_PRE_PACKED_STRUCT struct wifi_nan_p2p_op_attr_s { | |
363 | /* Attribute ID - 0x06. */ | |
364 | uint8 id; | |
365 | /* Length of the following fields in the attribute */ | |
366 | uint16 len; | |
367 | /* P2P device role */ | |
368 | uint8 dev_role; | |
369 | /* BSSID of the ibss */ | |
370 | struct ether_addr p2p_dev_addr; | |
371 | /* | |
372 | map control:, bits: | |
373 | [0-3]: Id for associated further avail map attribute | |
374 | [4-5]: avail interval duration: 0:16ms; 1:32ms; 2:64ms; 3:reserved | |
375 | [6] : repeat : 0 - applies to next DW, 1: 16 intervals max? wtf? | |
376 | [7] : reserved | |
377 | */ | |
378 | uint8 map_ctrl; | |
379 | /* avail. intervals bitmap */ | |
380 | uint8 avail_bmp[1]; | |
381 | } BWL_POST_PACKED_STRUCT wifi_nan_p2p_op_attr_t; | |
382 | ||
383 | /* ranging attribute */ | |
384 | #define NAN_RANGING_MAP_CTRL_ID_SHIFT 0 | |
385 | #define NAN_RANGING_MAP_CTRL_ID_MASK 0x0F | |
386 | #define NAN_RANGING_MAP_CTRL_DUR_SHIFT 4 | |
387 | #define NAN_RANGING_MAP_CTRL_DUR_MASK 0x30 | |
388 | #define NAN_RANGING_MAP_CTRL_REPEAT_SHIFT 6 | |
389 | #define NAN_RANGING_MAP_CTRL_REPEAT_MASK 0x40 | |
390 | #define NAN_RANGING_MAP_CTRL_REPEAT_DW(_ctrl) (((_ctrl) & \ | |
391 | NAN_RANGING_MAP_CTRL_DUR_MASK) ? 16 : 1) | |
392 | #define NAN_RANGING_MAP_CTRL(_id, _dur, _repeat) (\ | |
393 | (((_id) << NAN_RANGING_MAP_CTRL_ID_SHIFT) & \ | |
394 | NAN_RANGING_MAP_CTRL_ID_MASK) | \ | |
395 | (((_dur) << NAN_RANGING_MAP_CTRL_DUR_SHIFT) & \ | |
396 | NAN_RANGING_MAP_CTRL_DUR_MASK) | \ | |
397 | (((_repeat) << NAN_RANGING_MAP_CTRL_REPEAT_SHIFT) & \ | |
398 | NAN_RANGING_MAP_CTRL_REPEAT_MASK)) | |
399 | ||
400 | enum { | |
401 | NAN_RANGING_PROTO_FTM = 0 | |
402 | }; | |
403 | ||
404 | typedef BWL_PRE_PACKED_STRUCT struct wifi_nan_ranging_attr_s { | |
405 | uint8 id; /* 0x0C */ | |
406 | uint16 len; /* length that follows */ | |
407 | struct ether_addr dev_addr; /* device mac address */ | |
408 | ||
409 | /* | |
410 | map control:, bits: | |
411 | [0-3]: Id for associated further avail map attribute | |
412 | [4-5]: avail interval duration: 0:16ms; 1:32ms; 2:64ms; 3:reserved | |
413 | [6] : repeat : 0 - applies to next DW, 1: 16 intervals max? wtf? | |
414 | [7] : reserved | |
415 | */ | |
416 | uint8 map_ctrl; | |
417 | ||
418 | uint8 protocol; /* FTM = 0 */ | |
419 | uint32 avail_bmp; /* avail interval bitmap */ | |
420 | } BWL_POST_PACKED_STRUCT wifi_nan_ranging_attr_t; | |
421 | ||
422 | typedef BWL_PRE_PACKED_STRUCT struct wifi_nan_ranging_info_attr_s { | |
423 | uint8 id; /* 0x1A */ | |
424 | uint16 len; /* length that follows */ | |
425 | /* | |
426 | location info availability bit map | |
427 | 0: LCI Local Coordinates | |
428 | 1: Geospatial LCI WGS84 | |
429 | 2: Civi Location | |
430 | 3: Last Movement Indication | |
431 | [4-7]: reserved | |
432 | */ | |
433 | uint8 lc_info_avail; | |
434 | /* | |
435 | Last movement indication | |
436 | present if bit 3 is set in lc_info_avail | |
437 | cluster TSF[29:14] at the last detected platform movement | |
438 | */ | |
439 | uint16 last_movement; | |
440 | ||
441 | } BWL_POST_PACKED_STRUCT wifi_nan_ranging_info_attr_t; | |
442 | ||
443 | typedef BWL_PRE_PACKED_STRUCT struct wifi_nan_ranging_setup_attr_hdr_s { | |
444 | uint8 id; /* 0x1B */ | |
445 | uint16 len; /* length that follows */ | |
446 | uint8 dialog_token; /* Identify req and resp */ | |
447 | uint8 type_status; /* bits 0-3 type, 4-7 status */ | |
448 | /* reason code | |
449 | i. when frm type = response & status = reject | |
450 | ii. frm type = termination | |
451 | */ | |
452 | uint8 reason; | |
453 | } BWL_POST_PACKED_STRUCT wifi_nan_ranging_setup_attr_hdr_t; | |
454 | ||
455 | typedef BWL_PRE_PACKED_STRUCT struct wifi_nan_ranging_setup_attr_s { | |
456 | ||
457 | wifi_nan_ranging_setup_attr_hdr_t setup_attr_hdr; | |
458 | /* Below fields not required when frm type = termination */ | |
459 | uint8 ranging_ctrl; /* Bit 0: ranging report required or not */ | |
460 | uint8 ftm_params[3]; | |
461 | uint8 data[]; /* schedule entry list */ | |
462 | } BWL_POST_PACKED_STRUCT wifi_nan_ranging_setup_attr_t; | |
463 | ||
464 | #define NAN_RANGE_SETUP_ATTR_OFFSET_TBM_INFO (OFFSETOF(wifi_nan_ranging_setup_attr_t, data)) | |
465 | ||
466 | typedef BWL_PRE_PACKED_STRUCT struct wifi_nan_ranging_report_attr_s { | |
467 | uint8 id; /* 0x1C */ | |
468 | uint16 len; /* length that follows */ | |
469 | /* FTM report format in spec. | |
470 | See definition in 9.4.2.22.18 in 802.11mc D5.0 | |
471 | */ | |
472 | uint8 entry_count; | |
473 | uint8 data[]; /* Variable size range entry */ | |
474 | /* | |
475 | dot11_ftm_range_entry_t entries[entry_count]; | |
476 | uint8 error_count; | |
477 | dot11_ftm_error_entry_t errors[error_count]; | |
478 | */ | |
479 | } BWL_POST_PACKED_STRUCT wifi_nan_ranging_report_attr_t; | |
480 | ||
481 | /* Ranging control flags */ | |
482 | #define NAN_RNG_REPORT_REQUIRED 0x01 | |
483 | #define NAN_RNG_FTM_PARAMS_PRESENT 0x02 | |
484 | #define NAN_RNG_SCHED_ENTRY_PRESENT 0X04 | |
485 | ||
486 | /* Location info flags */ | |
487 | #define NAN_RNG_LOCATION_FLAGS_LOCAL_CORD 0x1 | |
488 | #define NAN_RNG_LOCATION_FLAGS_GEO_SPATIAL 0x2 | |
489 | #define NAN_RNG_LOCATION_FLAGS_CIVIC 0x4 | |
490 | #define NAN_RNG_LOCATION_FLAGS_LAST_MVMT 0x8 | |
491 | ||
492 | /* Last movement mask and shift value */ | |
493 | #define NAN_RNG_LOCATION_MASK_LAST_MVT_TSF 0x3FFFC000 | |
494 | #define NAN_RNG_LOCATION_SHIFT_LAST_MVT_TSF 14 | |
495 | ||
496 | /* FTM params shift values */ | |
497 | #define NAN_FTM_MAX_BURST_DUR_SHIFT 0 | |
498 | #define NAN_FTM_MIN_FTM_DELTA_SHIFT 4 | |
499 | #define NAN_FTM_NUM_FTM_SHIFT 10 | |
500 | #define NAN_FTM_FORMAT_BW_SHIFT 15 | |
501 | ||
502 | /* FTM params mask */ | |
503 | #define NAN_FTM_MAX_BURST_DUR_MASK 0x00000F | |
504 | #define NAN_FTM_MIN_FTM_DELTA_MASK 0x00003F | |
505 | #define NAN_FTM_NUM_FTM_MASK 0x00001F | |
506 | #define NAN_FTM_FORMAT_BW_MASK 0x00003F | |
507 | ||
508 | #define FTM_PARAMS_BURSTTMO_FACTOR 250 | |
509 | ||
510 | /* set to value to uint32 */ | |
511 | #define NAN_FTM_SET_BURST_DUR(ftm, dur) (ftm |= (((dur + 2) & NAN_FTM_MAX_BURST_DUR_MASK) <<\ | |
512 | NAN_FTM_MAX_BURST_DUR_SHIFT)) | |
513 | #define NAN_FTM_SET_FTM_DELTA(ftm, delta) (ftm |= (((delta/100) & NAN_FTM_MIN_FTM_DELTA_MASK) <<\ | |
514 | NAN_FTM_MIN_FTM_DELTA_SHIFT)) | |
515 | #define NAN_FTM_SET_NUM_FTM(ftm, delta) (ftm |= ((delta & NAN_FTM_NUM_FTM_MASK) <<\ | |
516 | NAN_FTM_NUM_FTM_SHIFT)) | |
517 | #define NAN_FTM_SET_FORMAT_BW(ftm, delta) (ftm |= ((delta & NAN_FTM_FORMAT_BW_MASK) <<\ | |
518 | NAN_FTM_FORMAT_BW_SHIFT)) | |
519 | /* set uint32 to attribute */ | |
520 | #define NAN_FTM_PARAMS_UINT32_TO_ATTR(ftm_u32, ftm_attr) {ftm_attr[0] = ftm_u32 & 0xFF; \ | |
521 | ftm_attr[1] = (ftm_u32 >> 8) & 0xFF; ftm_attr[2] = (ftm_u32 >> 16) & 0xFF;} | |
522 | ||
523 | /* get atrribute to uint32 */ | |
524 | #define NAN_FTM_PARAMS_ATTR_TO_UINT32(ftm_p, ftm_u32) (ftm_u32 = ftm_p[0] | ftm_p[1] << 8 | \ | |
525 | ftm_p[2] << 16) | |
526 | /* get param values from uint32 */ | |
527 | #define NAN_FTM_GET_BURST_DUR(ftm) (((ftm >> NAN_FTM_MAX_BURST_DUR_SHIFT) &\ | |
528 | NAN_FTM_MAX_BURST_DUR_MASK)) | |
529 | #define NAN_FTM_GET_BURST_DUR_USEC(_val) ((1 << ((_val)-2)) * FTM_PARAMS_BURSTTMO_FACTOR) | |
530 | #define NAN_FTM_GET_FTM_DELTA(ftm) (((ftm >> NAN_FTM_MIN_FTM_DELTA_SHIFT) &\ | |
531 | NAN_FTM_MIN_FTM_DELTA_MASK)*100) | |
532 | #define NAN_FTM_GET_NUM_FTM(ftm) ((ftm >> NAN_FTM_NUM_FTM_SHIFT) &\ | |
533 | NAN_FTM_NUM_FTM_MASK) | |
534 | #define NAN_FTM_GET_FORMAT_BW(ftm) ((ftm >> NAN_FTM_FORMAT_BW_SHIFT) &\ | |
535 | NAN_FTM_FORMAT_BW_MASK) | |
536 | ||
537 | #define NAN_CONN_CAPABILITY_WFD 0x0001 | |
538 | #define NAN_CONN_CAPABILITY_WFDS 0x0002 | |
539 | #define NAN_CONN_CAPABILITY_TDLS 0x0004 | |
540 | #define NAN_CONN_CAPABILITY_INFRA 0x0008 | |
541 | #define NAN_CONN_CAPABILITY_IBSS 0x0010 | |
542 | #define NAN_CONN_CAPABILITY_MESH 0x0020 | |
543 | ||
544 | #define NAN_DEFAULT_MAP_ID 0 /* nan default map id */ | |
545 | #define NAN_DEFAULT_MAP_CTRL 0 /* nan default map control */ | |
546 | ||
547 | typedef BWL_PRE_PACKED_STRUCT struct wifi_nan_conn_cap_attr_s { | |
548 | /* Attribute ID - 0x04. */ | |
549 | uint8 id; | |
550 | /* Length of the following fields in the attribute */ | |
551 | uint16 len; | |
552 | uint16 conn_cap_bmp; /* Connection capability bitmap */ | |
553 | } BWL_POST_PACKED_STRUCT wifi_nan_conn_cap_attr_t; | |
554 | ||
555 | /* NAN Element container Attribute */ | |
556 | typedef BWL_PRE_PACKED_STRUCT struct wifi_nan_container_attr_s { | |
557 | uint8 id; /* id - 0x20 */ | |
558 | uint16 len; /* Total length of following IEs */ | |
559 | uint8 map_id; /* map id */ | |
560 | uint8 data[1]; /* Data pointing to one or more IEs */ | |
561 | } BWL_POST_PACKED_STRUCT wifi_nan_container_attr_t; | |
562 | ||
563 | /* NAN 2.0 NAN avail attribute */ | |
564 | ||
565 | /* Availability Attribute */ | |
566 | typedef BWL_PRE_PACKED_STRUCT struct wifi_nan_avail_attr_s { | |
567 | uint8 id; /* id - 0x12 */ | |
568 | uint16 len; /* total length */ | |
569 | uint8 seqid; /* sequence id */ | |
570 | uint16 ctrl; /* attribute control */ | |
571 | uint8 entry[1]; /* availability entry list */ | |
572 | } BWL_POST_PACKED_STRUCT wifi_nan_avail_attr_t; | |
573 | ||
574 | /* for processing/building time bitmap info in nan_avail_entry */ | |
575 | typedef BWL_PRE_PACKED_STRUCT struct wifi_nan_time_bitmap_s { | |
576 | uint16 ctrl; /* Time bitmap control */ | |
577 | uint8 len; /* Time bitmap length */ | |
578 | uint8 bitmap[]; /* Time bitmap */ | |
579 | } BWL_POST_PACKED_STRUCT wifi_nan_time_bitmap_t; | |
580 | ||
581 | /* Availability Entry format */ | |
582 | typedef BWL_PRE_PACKED_STRUCT struct wifi_nan_avail_entry_attr_s { | |
583 | uint16 len; /* Length */ | |
584 | uint16 entry_cntrl; /* Entry Control */ | |
585 | uint8 var[]; /* Time bitmap and channel entry list */ | |
586 | } BWL_POST_PACKED_STRUCT wifi_nan_avail_entry_attr_t; | |
587 | ||
588 | /* FAC Channel Entry (section 10.7.19.1.5) */ | |
589 | typedef BWL_PRE_PACKED_STRUCT struct wifi_nan_chan_entry_s { | |
590 | uint8 oper_class; /* Operating Class */ | |
591 | uint16 chan_bitmap; /* Channel Bitmap */ | |
592 | uint8 primary_chan_bmp; /* Primary Channel Bitmap */ | |
593 | uint8 aux_chan[0]; /* Auxiliary Channel bitmap */ | |
594 | } BWL_POST_PACKED_STRUCT wifi_nan_chan_entry_t; | |
595 | ||
596 | /* Channel entry */ | |
597 | typedef BWL_PRE_PACKED_STRUCT struct wifi_nan_channel_entry_s { | |
598 | uint8 opclass; /* Operating class */ | |
599 | uint16 chan_bitmap; /* Channel bitmap */ | |
600 | uint8 prim_bitmap; /* Primary channel bitmap */ | |
601 | uint16 aux_bitmap; /* Time bitmap length */ | |
602 | } BWL_POST_PACKED_STRUCT wifi_nan_channel_entry_t; | |
603 | ||
604 | /* Type of Availability: committed */ | |
605 | #define NAN_ENTRY_CNTRL_TYPE_COMM_AVAIL_MASK 0x1 | |
606 | /* Type of Availability: potential */ | |
607 | #define NAN_ENTRY_CNTRL_TYPE_POTEN_AVAIL_MASK 0x2 | |
608 | /* Type of Availability: conditional */ | |
609 | #define NAN_ENTRY_CNTRL_TYPE_COND_AVAIL_MASK 0x4 | |
610 | ||
611 | #define NAN_AVAIL_CTRL_MAP_ID_MASK 0x000F | |
612 | #define NAN_AVAIL_CTRL_MAP_ID(_ctrl) ((_ctrl) & NAN_AVAIL_CTRL_MAP_ID_MASK) | |
613 | #define NAN_AVAIL_CTRL_COMM_CHANGED_MASK 0x0010 | |
614 | #define NAN_AVAIL_CTRL_COMM_CHANGED(_ctrl) ((_ctrl) & NAN_AVAIL_CTRL_COMM_CHANGED_MASK) | |
615 | #define NAN_AVAIL_CTRL_POTEN_CHANGED_MASK 0x0020 | |
616 | #define NAN_AVAIL_CTRL_POTEN_CHANGED(_ctrl) ((_ctrl) & NAN_AVAIL_CTRL_POTEN_CHANGED_MASK) | |
617 | #define NAN_AVAIL_CTRL_PUBLIC_CHANGED_MASK 0x0040 | |
618 | #define NAN_AVAIL_CTRL_PUBLIC_CHANGED(_ctrl) ((_ctrl) & NAN_AVAIL_CTRL_PUBLIC_CHANGED_MASK) | |
619 | #define NAN_AVAIL_CTRL_NDC_CHANGED_MASK 0x0080 | |
620 | #define NAN_AVAIL_CTRL_NDC_CHANGED(_ctrl) ((_ctrl) & NAN_AVAIL_CTRL_NDC_CHANGED_MASK) | |
621 | #define NAN_AVAIL_CTRL_MCAST_CHANGED_MASK 0x0100 | |
622 | #define NAN_AVAIL_CTRL_MCAST_CHANGED(_ctrl) ((_ctrl) & NAN_AVAIL_CTRL_MCAST_CHANGED_MASK) | |
623 | #define NAN_AVAIL_CTRL_MCAST_CHG_CHANGED_MASK 0x0200 | |
624 | #define NAN_AVAIL_CTRL_MCAST_CHG_CHANGED(_ctrl) ((_ctrl) & NAN_AVAIL_CTRL_MCAST_CHG_CHANGED_MASK) | |
625 | #define NAN_AVAIL_CTRL_CHANGED_FLAGS_MASK 0x03f0 | |
626 | ||
627 | #define NAN_AVAIL_ENTRY_CTRL_AVAIL_TYPE_MASK 0x07 | |
628 | #define NAN_AVAIL_ENTRY_CTRL_AVAIL_TYPE(_flags) ((_flags) & NAN_AVAIL_ENTRY_CTRL_AVAIL_TYPE_MASK) | |
629 | #define NAN_AVAIL_ENTRY_CTRL_USAGE_MASK 0x18 | |
630 | #define NAN_AVAIL_ENTRY_CTRL_USAGE_SHIFT 3 | |
631 | #define NAN_AVAIL_ENTRY_CTRL_USAGE(_flags) (((_flags) & NAN_AVAIL_ENTRY_CTRL_USAGE_MASK) \ | |
632 | >> NAN_AVAIL_ENTRY_CTRL_USAGE_SHIFT) | |
633 | #define NAN_AVAIL_ENTRY_CTRL_UTIL_MASK 0xE0 | |
634 | #define NAN_AVAIL_ENTRY_CTRL_UTIL_SHIFT 5 | |
635 | #define NAN_AVAIL_ENTRY_CTRL_UTIL(_flags) (((_flags) & NAN_AVAIL_ENTRY_CTRL_UTIL_MASK) \ | |
636 | >> NAN_AVAIL_ENTRY_CTRL_UTIL_SHIFT) | |
637 | #define NAN_AVAIL_ENTRY_CTRL_RX_NSS_MASK 0xF00 | |
638 | #define NAN_AVAIL_ENTRY_CTRL_RX_NSS_SHIFT 8 | |
639 | #define NAN_AVAIL_ENTRY_CTRL_RX_NSS(_flags) (((_flags) & NAN_AVAIL_ENTRY_CTRL_RX_NSS_MASK) \ | |
640 | >> NAN_AVAIL_ENTRY_CTRL_RX_NSS_SHIFT) | |
641 | #define NAN_AVAIL_ENTRY_CTRL_BITMAP_PRESENT_MASK 0x1000 | |
642 | #define NAN_AVAIL_ENTRY_CTRL_BITMAP_PRESENT_SHIFT 12 | |
643 | #define NAN_AVAIL_ENTRY_CTRL_BITMAP_PRESENT(_flags) (((_flags) & \ | |
644 | NAN_AVAIL_ENTRY_CTRL_BITMAP_PRESENT_MASK) >> NAN_AVAIL_ENTRY_CTRL_BITMAP_PRESENT_SHIFT) | |
645 | ||
646 | #define NAN_TIME_BMAP_CTRL_BITDUR_MASK 0x07 | |
647 | #define NAN_TIME_BMAP_CTRL_BITDUR(_flags) ((_flags) & NAN_TIME_BMAP_CTRL_BITDUR_MASK) | |
648 | #define NAN_TIME_BMAP_CTRL_PERIOD_MASK 0x38 | |
649 | #define NAN_TIME_BMAP_CTRL_PERIOD_SHIFT 3 | |
650 | #define NAN_TIME_BMAP_CTRL_PERIOD(_flags) (((_flags) & NAN_TIME_BMAP_CTRL_PERIOD_MASK) \ | |
651 | >> NAN_TIME_BMAP_CTRL_PERIOD_SHIFT) | |
652 | #define NAN_TIME_BMAP_CTRL_OFFSET_MASK 0x7FC0 | |
653 | #define NAN_TIME_BMAP_CTRL_OFFSET_SHIFT 6 | |
654 | #define NAN_TIME_BMAP_CTRL_OFFSET(_flags) (((_flags) & NAN_TIME_BMAP_CTRL_OFFSET_MASK) \ | |
655 | >> NAN_TIME_BMAP_CTRL_OFFSET_SHIFT) | |
656 | #define NAN_TIME_BMAP_LEN(avail_entry) \ | |
657 | (*(uint8 *)(((wifi_nan_avail_entry_attr_t *)avail_entry)->var + 2)) | |
658 | ||
659 | #define NAN_AVAIL_CHAN_LIST_HDR_LEN 1 | |
660 | #define NAN_AVAIL_CHAN_LIST_TYPE_BAND 0x00 | |
661 | #define NAN_AVAIL_CHAN_LIST_TYPE_CHANNEL 0x01 | |
662 | #define NAN_AVAIL_CHAN_LIST_NON_CONTIG_BW 0x02 | |
663 | #define NAN_AVAIL_CHAN_LIST_NUM_ENTRIES_MASK 0xF0 | |
664 | #define NAN_AVAIL_CHAN_LIST_NUM_ENTRIES_SHIFT 4 | |
665 | #define NAN_AVAIL_CHAN_LIST_NUM_ENTRIES(_ctrl) (((_ctrl) & NAN_AVAIL_CHAN_LIST_NUM_ENTRIES_MASK) \ | |
666 | >> NAN_AVAIL_CHAN_LIST_NUM_ENTRIES_SHIFT) | |
667 | ||
668 | typedef BWL_PRE_PACKED_STRUCT struct wifi_nan_channel_entry_list_s { | |
669 | uint8 chan_info; | |
670 | uint8 var[0]; | |
671 | } BWL_POST_PACKED_STRUCT wifi_nan_channel_entry_list_t; | |
672 | ||
673 | /* define for chan_info */ | |
674 | #define NAN_CHAN_OP_CLASS_MASK 0x01 | |
675 | #define NAN_CHAN_NON_CONT_BW_MASK 0x02 | |
676 | #define NAN_CHAN_RSVD_MASK 0x03 | |
677 | #define NAN_CHAN_NUM_ENTRIES_MASK 0xF0 | |
678 | ||
679 | typedef BWL_PRE_PACKED_STRUCT struct wifi_nan_band_entry_s { | |
680 | uint8 band[1]; | |
681 | } BWL_POST_PACKED_STRUCT wifi_nan_band_entry_t; | |
682 | ||
683 | /* Type of Availability: committed */ | |
684 | #define NAN_ENTRY_CNTRL_TYPE_COMM_AVAIL 0x1 | |
685 | /* Type of Availability: potential */ | |
686 | #define NAN_ENTRY_CNTRL_TYPE_POTEN_AVAIL 0x2 | |
687 | /* Type of Availability: conditional */ | |
688 | #define NAN_ENTRY_CNTRL_TYPE_COND_AVAIL 0x4 | |
689 | /* Committed + Potential */ | |
690 | #define NAN_ENTRY_CNTRL_TYPE_COMM_POTEN \ | |
691 | (NAN_ENTRY_CNTRL_TYPE_COMM_AVAIL | NAN_ENTRY_CNTRL_TYPE_POTEN_AVAIL) | |
692 | /* Conditional + Potential */ | |
693 | #define NAN_ENTRY_CNTRL_TYPE_COND_POTEN \ | |
694 | (NAN_ENTRY_CNTRL_TYPE_COND_AVAIL | NAN_ENTRY_CNTRL_TYPE_POTEN_AVAIL) | |
695 | ||
696 | /* Type of Availability */ | |
697 | #define NAN_ENTRY_CNTRL_TYPE_OF_AVAIL_MASK 0x07 | |
698 | #define NAN_ENTRY_CNTRL_TYPE_OF_AVAIL_SHIFT 0 | |
699 | /* Usage Preference */ | |
700 | #define NAN_ENTRY_CNTRL_USAGE_PREF_MASK 0x18 | |
701 | #define NAN_ENTRY_CNTRL_USAGE_PREF_SHIFT 3 | |
702 | /* Utilization */ | |
703 | #define NAN_ENTRY_CNTRL_UTIL_MASK 0x1E0 | |
704 | #define NAN_ENTRY_CNTRL_UTIL_SHIFT 5 | |
705 | ||
706 | /* Time Bitmap Control field (section 5.7.18.2.3) */ | |
707 | ||
708 | /* Reserved */ | |
709 | #define NAN_TIME_BMP_CNTRL_RSVD_MASK 0x01 | |
710 | #define NAN_TIME_BMP_CNTRL_RSVD_SHIFT 0 | |
711 | /* Bitmap Len */ | |
712 | #define NAN_TIME_BMP_CNTRL_BMP_LEN_MASK 0x7E | |
713 | #define NAN_TIME_BMP_CNTRL_BMP_LEN_SHIFT 1 | |
714 | /* Bit Duration */ | |
715 | #define NAN_TIME_BMP_CNTRL_BIT_DUR_MASK 0x380 | |
716 | #define NAN_TIME_BMP_CNTRL_BIT_DUR_SHIFT 7 | |
717 | /* Bitmap Len */ | |
718 | #define NAN_TIME_BMP_CNTRL_PERIOD_MASK 0x1C00 | |
719 | #define NAN_TIME_BMP_CNTRL_PERIOD_SHIFT 10 | |
720 | /* Start Offset */ | |
721 | #define NAN_TIME_BMP_CNTRL_START_OFFSET_MASK 0x3FE000 | |
722 | #define NAN_TIME_BMP_CNTRL_START_OFFSET_SHIFT 13 | |
723 | /* Reserved */ | |
724 | #define NAN_TIME_BMP_CNTRL_RESERVED_MASK 0xC00000 | |
725 | #define NAN_TIME_BMP_CNTRL_RESERVED_SHIFT 22 | |
726 | ||
727 | /* Time Bitmap Control field: Period */ | |
728 | typedef enum | |
729 | { | |
730 | NAN_TIME_BMP_CTRL_PERIOD_128TU = 1, | |
731 | NAN_TIME_BMP_CTRL_PERIOD_256TU = 2, | |
732 | NAN_TIME_BMP_CTRL_PERIOD_512TU = 3, | |
733 | NAN_TIME_BMP_CTRL_PERIOD_1024TU = 4, | |
734 | NAN_TIME_BMP_CTRL_PERIOD_2048U = 5, | |
735 | NAN_TIME_BMP_CTRL_PERIOD_4096U = 6, | |
736 | NAN_TIME_BMP_CTRL_PERIOD_8192U = 7 | |
737 | } nan_time_bmp_ctrl_repeat_interval_t; | |
738 | ||
739 | enum | |
740 | { | |
741 | NAN_TIME_BMP_BIT_DUR_16TU_IDX = 0, | |
742 | NAN_TIME_BMP_BIT_DUR_32TU_IDX = 1, | |
743 | NAN_TIME_BMP_BIT_DUR_64TU_IDX = 2, | |
744 | NAN_TIME_BMP_BIT_DUR_128TU_IDX = 3 | |
745 | }; | |
746 | ||
747 | enum | |
748 | { | |
749 | NAN_TIME_BMP_BIT_DUR_IDX_0 = 16, | |
750 | NAN_TIME_BMP_BIT_DUR_IDX_1 = 32, | |
751 | NAN_TIME_BMP_BIT_DUR_IDX_2 = 64, | |
752 | NAN_TIME_BMP_BIT_DUR_IDX_3 = 128 | |
753 | }; | |
754 | ||
755 | enum | |
756 | { | |
757 | NAN_TIME_BMP_CTRL_PERIOD_IDX_1 = 128, | |
758 | NAN_TIME_BMP_CTRL_PERIOD_IDX_2 = 256, | |
759 | NAN_TIME_BMP_CTRL_PERIOD_IDX_3 = 512, | |
760 | NAN_TIME_BMP_CTRL_PERIOD_IDX_4 = 1024, | |
761 | NAN_TIME_BMP_CTRL_PERIOD_IDX_5 = 2048, | |
762 | NAN_TIME_BMP_CTRL_PERIOD_IDX_6 = 4096, | |
763 | NAN_TIME_BMP_CTRL_PERIOD_IDX_7 = 8192 | |
764 | }; | |
765 | ||
766 | /* Channel Entries List field */ | |
767 | ||
768 | /* Type */ | |
769 | #define NAN_CHAN_ENTRY_TYPE_MASK 0x01 | |
770 | #define NAN_CHAN_ENTRY_TYPE_SHIFT 0 | |
771 | /* Channel Entry Length Indication */ | |
772 | #define NAN_CHAN_ENTRY_LEN_IND_MASK 0x02 | |
773 | #define NAN_CHAN_ENTRY_LEN_IND_SHIFT 1 | |
774 | /* Reserved */ | |
775 | #define NAN_CHAN_ENTRY_RESERVED_MASK 0x0C | |
776 | #define NAN_CHAN_ENTRY_RESERVED_SHIFT 2 | |
777 | /* Number of FAC Band or Channel Entries */ | |
778 | #define NAN_CHAN_ENTRY_NO_OF_CHAN_ENTRY_MASK 0xF0 | |
779 | #define NAN_CHAN_ENTRY_NO_OF_CHAN_ENTRY_SHIFT 4 | |
780 | ||
781 | #define NAN_CHAN_ENTRY_TYPE_BANDS 0 | |
782 | #define NAN_CHAN_ENTRY_TYPE_OPCLASS_CHANS 1 | |
783 | ||
784 | #define NAN_CHAN_ENTRY_BW_LT_80MHZ 0 | |
785 | #define NAN_CHAN_ENTRY_BW_EQ_160MHZ 1 | |
786 | ||
787 | /* | |
788 | * NDL Attribute WFA Tech. Spec ver 1.0.r12 (section 10.7.19.2) | |
789 | */ | |
790 | #define NDL_ATTR_IM_MAP_ID_LEN 1 | |
791 | #define NDL_ATTR_IM_TIME_BMP_CTRL_LEN 2 | |
792 | #define NDL_ATTR_IM_TIME_BMP_LEN_LEN 1 | |
793 | ||
794 | /* | |
795 | * NDL Control field - Table xx | |
796 | */ | |
797 | #define NDL_ATTR_CTRL_PEER_ID_PRESENT_MASK 0x01 | |
798 | #define NDL_ATTR_CTRL_PEER_ID_PRESENT_SHIFT 0 | |
799 | #define NDL_ATTR_CTRL_IM_SCHED_PRESENT_MASK 0x02 | |
800 | #define NDL_ATTR_CTRL_IM_SCHED_PRESENT_SHIFT 1 | |
801 | #define NDL_ATTR_CTRL_NDC_ATTR_PRESENT_MASK 0x04 | |
802 | #define NDL_ATTR_CTRL_NDC_ATTR_PRESENT_SHIFT 2 | |
803 | #define NDL_ATTR_CTRL_QOS_ATTR_PRESENT_MASK 0x08 | |
804 | #define NDL_ATTR_CTRL_QOS_ATTR_PRESENT_SHIFT 3 | |
805 | #define NDL_ATTR_CTRL_MAX_IDLE_PER_PRESENT_MASK 0x10 /* max idle period */ | |
806 | #define NDL_ATTR_CTRL_MAX_IDLE_PER_PRESENT_SHIFT 4 | |
807 | #define NDL_ATTR_CTRL_NDL_TYPE_MASK 0x20 /* NDL type */ | |
808 | #define NDL_ATTR_CTRL_NDL_TYPE_SHIFT 5 | |
809 | #define NDL_ATTR_CTRL_NDL_SETUP_REASON_MASK 0xC0 /* NDL Setup Reason */ | |
810 | #define NDL_ATTR_CTRL_NDL_SETUP_REASON_SHIFT 6 | |
811 | ||
812 | /* NDL setup Reason */ | |
813 | #define NDL_ATTR_CTRL_NDL_TYPE_S_NDL 0x0 /* S-NDL */ | |
814 | #define NDL_ATTR_CTRL_NDL_TYPE_P_NDL 0x1 /* P-NDL */ | |
815 | ||
816 | /* NDL setup Reason */ | |
817 | #define NDL_ATTR_CTRL_NDL_SETUP_REASON_NDP_RANG 0x0 /* NDP or Ranging */ | |
818 | #define NDL_ATTR_CTRL_NDL_SETUP_REASON_FSD_GAS 0x1 /* FSD using GAS */ | |
819 | ||
820 | #define NAN_NDL_TYPE_MASK 0x0F | |
821 | #define NDL_ATTR_TYPE_STATUS_REQUEST 0x00 | |
822 | #define NDL_ATTR_TYPE_STATUS_RESPONSE 0x01 | |
823 | #define NDL_ATTR_TYPE_STATUS_CONFIRM 0x02 | |
824 | #define NDL_ATTR_TYPE_STATUS_CONTINUED 0x00 | |
825 | #define NDL_ATTR_TYPE_STATUS_ACCEPTED 0x10 | |
826 | #define NDL_ATTR_TYPE_STATUS_REJECTED 0x20 | |
827 | ||
828 | #define NAN_NDL_TYPE_CHECK(_ndl, x) (((_ndl)->type_status & NAN_NDL_TYPE_MASK) == (x)) | |
829 | #define NAN_NDL_REQUEST(_ndl) (((_ndl)->type_status & NAN_NDL_TYPE_MASK) == \ | |
830 | NDL_ATTR_TYPE_STATUS_REQUEST) | |
831 | #define NAN_NDL_RESPONSE(_ndl) (((_ndl)->type_status & NAN_NDL_TYPE_MASK) == \ | |
832 | NDL_ATTR_TYPE_STATUS_RESPONSE) | |
833 | #define NAN_NDL_CONFIRM(_ndl) (((_ndl)->type_status & NAN_NDL_TYPE_MASK) == \ | |
834 | NDL_ATTR_TYPE_STATUS_CONFIRM) | |
835 | ||
836 | #define NAN_NDL_STATUS_SHIFT 4 | |
837 | #define NAN_NDL_STATUS_MASK 0xF0 | |
838 | #define NAN_NDL_CONT(_ndl) (((_ndl)->type_status & NAN_NDL_STATUS_MASK) == \ | |
839 | NDL_ATTR_TYPE_STATUS_CONTINUED) | |
840 | #define NAN_NDL_ACCEPT(_ndl) (((_ndl)->type_status & NAN_NDL_STATUS_MASK) == \ | |
841 | NDL_ATTR_TYPE_STATUS_ACCEPTED) | |
842 | #define NAN_NDL_REJECT(_ndl) (((_ndl)->type_status & NAN_NDL_STATUS_MASK) == \ | |
843 | NDL_ATTR_TYPE_STATUS_REJECTED) | |
844 | #define NAN_NDL_FRM_STATUS(_ndl) \ | |
845 | (((_ndl)->type_status & NAN_NDL_STATUS_MASK) >> NAN_NDL_STATUS_SHIFT) | |
846 | ||
847 | #define NDL_ATTR_CTRL_NONE 0 | |
848 | #define NDL_ATTR_CTRL_PEER_ID_PRESENT (1 << NDL_ATTR_CTRL_PEER_ID_PRESENT_SHIFT) | |
849 | #define NDL_ATTR_CTRL_IMSCHED_PRESENT (1 << NDL_ATTR_CTRL_IM_SCHED_PRESENT_SHIFT) | |
850 | #define NDL_ATTR_CTRL_NDC_PRESENT (1 << NDL_ATTR_CTRL_NDC_ATTR_PRESENT_SHIFT) | |
851 | #define NDL_ATTR_CTRL_NDL_QOS_PRESENT (1 << NDL_ATTR_CTRL_QOS_ATTR_PRESENT_SHIFT) | |
852 | #define NDL_ATTR_CTRL_MAX_IDLE_PER_PRESENT (1 << NDL_ATTR_CTRL_MAX_IDLE_PER_PRESENT_SHIFT) | |
853 | ||
854 | #define NA_NDL_IS_IMMUT_PRESENT(ndl) (((ndl)->ndl_ctrl) & NDL_ATTR_CTRL_IMSCHED_PRESENT) | |
855 | #define NA_NDL_IS_PEER_ID_PRESENT(ndl) (((ndl)->ndl_ctrl) & NDL_ATTR_CTRL_PEER_ID_PRESENT) | |
856 | #define NA_NDL_IS_MAX_IDLE_PER_PRESENT(ndl) (((ndl)->ndl_ctrl) & NDL_ATTR_CTRL_MAX_IDLE_PER_PRESENT) | |
857 | ||
858 | #define NDL_ATTR_PEERID_LEN 1 | |
859 | #define NDL_ATTR_MAX_IDLE_PERIOD_LEN 2 | |
860 | ||
861 | typedef BWL_PRE_PACKED_STRUCT struct wifi_nan_ndl_attr_s { | |
862 | uint8 id; /* NAN_ATTR_NAN_NDL = 0x17 */ | |
863 | uint16 len; /* Length of the fields in the attribute */ | |
864 | uint8 dialog_token; /* Identify req and resp */ | |
865 | uint8 type_status; /* Bits[3-0] type subfield, Bits[7-4] status subfield */ | |
866 | uint8 reason; /* Identifies reject reason */ | |
867 | uint8 ndl_ctrl; /* NDL control field */ | |
868 | uint8 var[]; /* Optional fields follow */ | |
869 | } BWL_POST_PACKED_STRUCT wifi_nan_ndl_attr_t; | |
870 | ||
871 | /* | |
872 | * NDL QoS Attribute WFA Tech. Spec ver r26 | |
873 | */ | |
874 | typedef BWL_PRE_PACKED_STRUCT struct wifi_nan_ndl_qos_attr_s { | |
875 | uint8 id; /* NAN_ATTR_NAN_NDL_QOS = 24 */ | |
876 | uint16 len; /* Length of the attribute field following */ | |
877 | uint8 min_slots; /* Min. number of FAW slots needed per DW interval */ | |
878 | uint16 max_latency; /* Max interval between non-cont FAW */ | |
879 | } BWL_POST_PACKED_STRUCT wifi_nan_ndl_qos_attr_t; | |
880 | ||
881 | /* no preference to min time slots */ | |
882 | #define NAN_NDL_QOS_MIN_SLOT_NO_PREF 0 | |
883 | /* no preference to no. of slots between two non-contiguous slots */ | |
884 | #define NAN_NDL_QOS_MAX_LAT_NO_PREF 0xFFFF | |
885 | ||
886 | /* Device Capability Attribute */ | |
887 | ||
888 | typedef BWL_PRE_PACKED_STRUCT struct wifi_nan_dev_cap_s { | |
889 | uint8 id; /* 0x0F */ | |
890 | uint16 len; /* Length */ | |
891 | uint8 map_id; /* map id */ | |
892 | uint16 commit_dw_info; /* Committed DW Info */ | |
893 | uint8 bands_supported; /* Supported Bands */ | |
894 | uint8 op_mode; /* Operation Mode */ | |
895 | uint8 num_antennas; /* Bit 0-3 tx, 4-7 rx */ | |
896 | uint16 chan_switch_time; /* Max channel switch time in us */ | |
897 | uint8 capabilities; /* DFS Master, Extended key id etc */ | |
898 | } BWL_POST_PACKED_STRUCT wifi_nan_dev_cap_t; | |
899 | ||
900 | /* map id related */ | |
901 | ||
902 | /* all maps */ | |
903 | #define NAN_DEV_CAP_ALL_MAPS_FLAG_MASK 0x1 /* nan default map control */ | |
904 | #define NAN_DEV_CAP_ALL_MAPS_FLAG_SHIFT 0 | |
905 | /* map id */ | |
906 | #define NAN_DEV_CAP_MAPID_MASK 0x1E | |
907 | #define NAN_DEV_CAP_MAPID_SHIFT 1 | |
908 | ||
909 | /* Awake DW Info field format */ | |
910 | ||
911 | /* 2.4GHz DW */ | |
912 | #define NAN_DEV_CAP_AWAKE_DW_2G_MASK 0x07 | |
913 | /* 5GHz DW */ | |
914 | #define NAN_DEV_CAP_AWAKE_DW_5G_MASK 0x38 | |
915 | /* Reserved */ | |
916 | #define NAN_DEV_CAP_AWAKE_DW_RSVD_MASK 0xC0 | |
917 | ||
918 | /* bit shift for dev cap */ | |
919 | #define NAN_DEV_CAP_AWAKE_DW_2G_SHIFT 0 | |
920 | #define NAN_DEV_CAP_AWAKE_DW_5G_SHIFT 3 | |
921 | ||
922 | /* Device Capability Attribute Format */ | |
923 | ||
924 | /* Committed DW Info field format */ | |
925 | /* 2.4GHz DW */ | |
926 | #define NAN_DEV_CAP_COMMIT_DW_2G_MASK 0x07 | |
927 | #define NAN_DEV_CAP_COMMIT_DW_2G_OVERWRITE_MASK 0x3C0 | |
928 | /* 5GHz DW */ | |
929 | #define NAN_DEV_CAP_COMMIT_DW_5G_MASK 0x38 | |
930 | #define NAN_DEV_CAP_COMMIT_DW_5G_OVERWRITE_MASK 0x3C00 | |
931 | /* Reserved */ | |
932 | #define NAN_DEV_CAP_COMMIT_DW_RSVD_MASK 0xC000 | |
933 | /* Committed DW bit shift for dev cap */ | |
934 | #define NAN_DEV_CAP_COMMIT_DW_2G_SHIFT 0 | |
935 | #define NAN_DEV_CAP_COMMIT_DW_5G_SHIFT 3 | |
936 | #define NAN_DEV_CAP_COMMIT_DW_2G_OVERWRITE_SHIFT 6 | |
937 | #define NAN_DEV_CAP_COMMIT_DW_5G_OVERWRITE_SHIFT 10 | |
938 | /* Operation Mode */ | |
939 | #define NAN_DEV_CAP_OP_PHY_MODE_HT_ONLY 0x00 | |
940 | #define NAN_DEV_CAP_OP_PHY_MODE_VHT 0x01 | |
941 | #define NAN_DEV_CAP_OP_PHY_MODE_VHT_8080 0x02 | |
942 | #define NAN_DEV_CAP_OP_PHY_MODE_VHT_160 0x04 | |
943 | #define NAN_DEV_CAP_OP_PAGING_NDL 0x08 | |
944 | ||
945 | #define NAN_DEV_CAP_OP_MODE_VHT_MASK 0x01 | |
946 | #define NAN_DEV_CAP_OP_MODE_VHT_SHIFT 0 | |
947 | #define NAN_DEV_CAP_OP_MODE_VHT8080_MASK 0x02 | |
948 | #define NAN_DEV_CAP_OP_MODE_VHT8080_SHIFT 1 | |
949 | #define NAN_DEV_CAP_OP_MODE_VHT160_MASK 0x04 | |
950 | #define NAN_DEV_CAP_OP_MODE_VHT160_SHIFT 2 | |
951 | #define NAN_DEV_CAP_OP_MODE_PAGING_NDL_MASK 0x08 | |
952 | #define NAN_DEV_CAP_OP_MODE_PAGING_NDL_SHIFT 3 | |
953 | ||
954 | #define NAN_DEV_CAP_RX_ANT_SHIFT 4 | |
955 | #define NAN_DEV_CAP_TX_ANT_MASK 0x0F | |
956 | #define NAN_DEV_CAP_RX_ANT_MASK 0xF0 | |
957 | #define NAN_DEV_CAP_TX_ANT(_ant) ((_ant) & NAN_DEV_CAP_TX_ANT_MASK) | |
958 | #define NAN_DEV_CAP_RX_ANT(_ant) (((_ant) & NAN_DEV_CAP_RX_ANT_MASK) \ | |
959 | >> NAN_DEV_CAP_RX_ANT_SHIFT) | |
960 | ||
961 | /* Device capabilities */ | |
962 | ||
963 | /* DFS master capability */ | |
964 | #define NAN_DEV_CAP_DFS_MASTER_MASK 0x01 | |
965 | #define NAN_DEV_CAP_DFS_MASTER_SHIFT 0 | |
966 | /* extended iv cap */ | |
967 | #define NAN_DEV_CAP_EXT_KEYID_MASK 0x02 | |
968 | #define NAN_DEV_CAP_EXT_KEYID_SHIFT 1 | |
969 | /* NDPE attribute support */ | |
970 | #define NAN_DEV_CAP_NDPE_ATTR_SUPPORT_MASK 0x08 | |
971 | #define NAN_DEV_CAP_NDPE_ATTR_SUPPORT(_cap) ((_cap) & NAN_DEV_CAP_NDPE_ATTR_SUPPORT_MASK) | |
972 | ||
973 | /* Band IDs */ | |
974 | enum { | |
975 | NAN_BAND_ID_TVWS = 0, | |
976 | NAN_BAND_ID_SIG = 1, /* Sub 1 GHz */ | |
977 | NAN_BAND_ID_2G = 2, /* 2.4 GHz */ | |
978 | NAN_BAND_ID_3G = 3, /* 3.6 GHz */ | |
979 | NAN_BAND_ID_5G = 4, /* 4.9 & 5 GHz */ | |
980 | NAN_BAND_ID_60G = 5 | |
981 | }; | |
982 | typedef uint8 nan_band_id_t; | |
983 | ||
984 | /* NAN supported band in device capability */ | |
985 | #define NAN_DEV_CAP_SUPPORTED_BANDS_2G (1 << NAN_BAND_ID_2G) | |
986 | #define NAN_DEV_CAP_SUPPORTED_BANDS_5G (1 << NAN_BAND_ID_5G) | |
987 | ||
988 | /* | |
989 | * Unaligned schedule attribute section 10.7.19.6 spec. ver r15 | |
990 | */ | |
991 | #define NAN_ULW_ATTR_CTRL_SCHED_ID_MASK 0x000F | |
992 | #define NAN_ULW_ATTR_CTRL_SCHED_ID_SHIFT 0 | |
993 | #define NAN_ULW_ATTR_CTRL_SEQ_ID_MASK 0xFF00 | |
994 | #define NAN_ULW_ATTR_CTRL_SEQ_ID_SHIFT 8 | |
995 | ||
996 | #define NAN_ULW_OVWR_ALL_MASK 0x01 | |
997 | #define NAN_ULW_OVWR_ALL_SHIFT 0 | |
998 | #define NAN_ULW_OVWR_MAP_ID_MASK 0x1E | |
999 | #define NAN_ULW_OVWR_MAP_ID_SHIFT 1 | |
1000 | ||
1001 | #define NAN_ULW_CTRL_TYPE_MASK 0x03 | |
1002 | #define NAN_ULW_CTRL_TYPE_SHIFT 0 | |
1003 | #define NAN_ULW_CTRL_TYPE(ctrl) (ctrl & NAN_ULW_CTRL_TYPE_MASK) | |
1004 | #define NAN_ULW_CTRL_CHAN_AVAIL_MASK 0x04 | |
1005 | #define NAN_ULW_CTRL_CHAN_AVAIL_SHIFT 2 | |
1006 | #define NAN_ULW_CTRL_CHAN_AVAIL(ctrl) ((ctrl & NAN_ULW_CTRL_CHAN_AVAIL_MASK) \ | |
1007 | >> NAN_ULW_CTRL_CHAN_AVAIL_SHIFT) | |
1008 | #define NAN_ULW_CTRL_RX_NSS_MASK 0x78 | |
1009 | #define NAN_ULW_CTRL_RX_NSS_SHIFT 3 | |
1010 | ||
1011 | #define NAN_ULW_CTRL_TYPE_BAND 0 | |
1012 | #define NAN_ULW_CTRL_TYPE_CHAN_NOAUX 1 | |
1013 | #define NAN_ULW_CTRL_TYPE_CHAN_AUX 2 | |
1014 | ||
1015 | #define NAN_ULW_CNT_DOWN_NO_EXPIRE 0xFF /* ULWs doen't end until next sched update */ | |
1016 | #define NAN_ULW_CNT_DOWN_CANCEL 0x0 /* cancel remaining ulws */ | |
1017 | ||
1018 | typedef BWL_PRE_PACKED_STRUCT struct wifi_nan_ulw_attr_s { | |
1019 | uint8 id; | |
1020 | uint16 len; | |
1021 | uint16 ctrl; | |
1022 | uint32 start; /* low 32 bits of tsf */ | |
1023 | uint32 dur; | |
1024 | uint32 period; | |
1025 | uint8 count_down; | |
1026 | uint8 overwrite; | |
1027 | /* | |
1028 | * ulw[0] == optional field ULW control when present. | |
1029 | * band ID or channel follows | |
1030 | */ | |
1031 | uint8 ulw_entry[]; | |
1032 | } BWL_POST_PACKED_STRUCT wifi_nan_ulw_attr_t; | |
1033 | ||
1034 | /* NAN2 Management Frame (section 5.6) */ | |
1035 | ||
1036 | /* Public action frame for NAN2 */ | |
1037 | typedef BWL_PRE_PACKED_STRUCT struct nan2_pub_act_frame_s { | |
1038 | /* NAN_PUB_AF_CATEGORY 0x04 */ | |
1039 | uint8 category_id; | |
1040 | /* NAN_PUB_AF_ACTION 0x09 */ | |
1041 | uint8 action_field; | |
1042 | /* NAN_OUI 0x50-6F-9A */ | |
1043 | uint8 oui[DOT11_OUI_LEN]; | |
1044 | /* NAN_OUI_TYPE TBD */ | |
1045 | uint8 oui_type; | |
1046 | /* NAN_OUI_SUB_TYPE TBD */ | |
1047 | uint8 oui_sub_type; | |
1048 | /* One or more NAN Attributes follow */ | |
1049 | uint8 data[]; | |
1050 | } BWL_POST_PACKED_STRUCT nan2_pub_act_frame_t; | |
1051 | ||
1052 | #define NAN2_PUB_ACT_FRM_SIZE (OFFSETOF(nan2_pub_act_frame_t, data)) | |
1053 | ||
1054 | /* NAN Action Frame Subtypes */ | |
1055 | /* Subtype-0 is Reserved */ | |
1056 | #define NAN_MGMT_FRM_SUBTYPE_RESERVED 0 | |
1057 | #define NAN_MGMT_FRM_SUBTYPE_INVALID 0 | |
1058 | /* NAN Ranging Request */ | |
1059 | #define NAN_MGMT_FRM_SUBTYPE_RANGING_REQ 1 | |
1060 | /* NAN Ranging Response */ | |
1061 | #define NAN_MGMT_FRM_SUBTYPE_RANGING_RESP 2 | |
1062 | /* NAN Ranging Termination */ | |
1063 | #define NAN_MGMT_FRM_SUBTYPE_RANGING_TERM 3 | |
1064 | /* NAN Ranging Report */ | |
1065 | #define NAN_MGMT_FRM_SUBTYPE_RANGING_RPT 4 | |
1066 | /* NDP Request */ | |
1067 | #define NAN_MGMT_FRM_SUBTYPE_NDP_REQ 5 | |
1068 | /* NDP Response */ | |
1069 | #define NAN_MGMT_FRM_SUBTYPE_NDP_RESP 6 | |
1070 | /* NDP Confirm */ | |
1071 | #define NAN_MGMT_FRM_SUBTYPE_NDP_CONFIRM 7 | |
1072 | /* NDP Key Installment */ | |
1073 | #define NAN_MGMT_FRM_SUBTYPE_NDP_KEY_INST 8 | |
1074 | /* NDP Termination */ | |
1075 | #define NAN_MGMT_FRM_SUBTYPE_NDP_END 9 | |
1076 | /* Schedule Request */ | |
1077 | #define NAN_MGMT_FRM_SUBTYPE_SCHED_REQ 10 | |
1078 | /* Schedule Response */ | |
1079 | #define NAN_MGMT_FRM_SUBTYPE_SCHED_RESP 11 | |
1080 | /* Schedule Confirm */ | |
1081 | #define NAN_MGMT_FRM_SUBTYPE_SCHED_CONF 12 | |
1082 | /* Schedule Update */ | |
1083 | #define NAN_MGMT_FRM_SUBTYPE_SCHED_UPD 13 | |
1084 | ||
1085 | #define NAN_SCHEDULE_AF(_naf_subtype) \ | |
1086 | ((_naf_subtype >= NAN_MGMT_FRM_SUBTYPE_SCHED_REQ) && \ | |
1087 | (_naf_subtype <= NAN_MGMT_FRM_SUBTYPE_SCHED_UPD)) | |
1088 | ||
1089 | /* Reason code defines */ | |
1090 | #define NAN_REASON_RESERVED 0x0 | |
1091 | #define NAN_REASON_UNSPECIFIED 0x1 | |
1092 | #define NAN_REASON_RESOURCE_LIMIT 0x2 | |
1093 | #define NAN_REASON_INVALID_PARAMS 0x3 | |
1094 | #define NAN_REASON_FTM_PARAM_INCAP 0x4 | |
1095 | #define NAN_REASON_NO_MOVEMENT 0x5 | |
1096 | #define NAN_REASON_INVALID_AVAIL 0x6 | |
1097 | #define NAN_REASON_IMMUT_UNACCEPT 0x7 | |
1098 | #define NAN_REASON_SEC_POLICY 0x8 | |
1099 | #define NAN_REASON_QOS_UNACCEPT 0x9 | |
1100 | #define NAN_REASON_NDP_REJECT 0xa | |
1101 | #define NAN_REASON_NDL_UNACCEPTABLE 0xb | |
1102 | ||
1103 | /* nan 2.0 qos (not attribute) */ | |
1104 | typedef BWL_PRE_PACKED_STRUCT struct wifi_nan_ndp_qos_s { | |
1105 | uint8 tid; /* traffic identifier */ | |
1106 | uint16 pkt_size; /* service data pkt size */ | |
1107 | uint8 data_rate; /* mean data rate */ | |
1108 | uint8 svc_interval; /* max service interval */ | |
1109 | } BWL_POST_PACKED_STRUCT wifi_nan_ndp_qos_t; | |
1110 | ||
1111 | /* NDP control bitmap defines */ | |
1112 | #define NAN_NDP_CTRL_CONFIRM_REQUIRED 0x01 | |
1113 | #define NAN_NDP_CTRL_SECURTIY_PRESENT 0x04 | |
1114 | #define NAN_NDP_CTRL_PUB_ID_PRESENT 0x08 | |
1115 | #define NAN_NDP_CTRL_RESP_NDI_PRESENT 0x10 | |
1116 | #define NAN_NDP_CTRL_SPEC_INFO_PRESENT 0x20 | |
1117 | #define NAN_NDP_CTRL_RESERVED 0xA0 | |
1118 | ||
1119 | /* Used for both NDP Attribute and NDPE Attribute, since the structures are identical */ | |
1120 | typedef BWL_PRE_PACKED_STRUCT struct wifi_nan_ndp_attr_s { | |
1121 | uint8 id; /* NDP: 0x10, NDPE: 0x29 */ | |
1122 | uint16 len; /* length */ | |
1123 | uint8 dialog_token; /* dialog token */ | |
1124 | uint8 type_status; /* bits 0-3 type, 4-7 status */ | |
1125 | uint8 reason; /* reason code */ | |
1126 | struct ether_addr init_ndi; /* ndp initiator's data interface address */ | |
1127 | uint8 ndp_id; /* ndp identifier (created by initiator */ | |
1128 | uint8 control; /* ndp control field */ | |
1129 | uint8 var[]; /* Optional fields follow */ | |
1130 | } BWL_POST_PACKED_STRUCT wifi_nan_ndp_attr_t; | |
1131 | /* NDP attribute type and status macros */ | |
1132 | #define NAN_NDP_TYPE_MASK 0x0F | |
1133 | #define NAN_NDP_TYPE_REQUEST 0x0 | |
1134 | #define NAN_NDP_TYPE_RESPONSE 0x1 | |
1135 | #define NAN_NDP_TYPE_CONFIRM 0x2 | |
1136 | #define NAN_NDP_TYPE_SECURITY 0x3 | |
1137 | #define NAN_NDP_TYPE_TERMINATE 0x4 | |
1138 | #define NAN_NDP_REQUEST(_ndp) (((_ndp)->type_status & NAN_NDP_TYPE_MASK) == NAN_NDP_TYPE_REQUEST) | |
1139 | #define NAN_NDP_RESPONSE(_ndp) (((_ndp)->type_status & NAN_NDP_TYPE_MASK) == NAN_NDP_TYPE_RESPONSE) | |
1140 | #define NAN_NDP_CONFIRM(_ndp) (((_ndp)->type_status & NAN_NDP_TYPE_MASK) == NAN_NDP_TYPE_CONFIRM) | |
1141 | #define NAN_NDP_SECURITY_INST(_ndp) (((_ndp)->type_status & NAN_NDP_TYPE_MASK) == \ | |
1142 | NAN_NDP_TYPE_SECURITY) | |
1143 | #define NAN_NDP_TERMINATE(_ndp) (((_ndp)->type_status & NAN_NDP_TYPE_MASK) == \ | |
1144 | NAN_NDP_TYPE_TERMINATE) | |
1145 | #define NAN_NDP_STATUS_SHIFT 4 | |
1146 | #define NAN_NDP_STATUS_MASK 0xF0 | |
1147 | #define NAN_NDP_STATUS_CONT (0 << NAN_NDP_STATUS_SHIFT) | |
1148 | #define NAN_NDP_STATUS_ACCEPT (1 << NAN_NDP_STATUS_SHIFT) | |
1149 | #define NAN_NDP_STATUS_REJECT (2 << NAN_NDP_STATUS_SHIFT) | |
1150 | #define NAN_NDP_CONT(_ndp) (((_ndp)->type_status & NAN_NDP_STATUS_MASK) == NAN_NDP_STATUS_CONT) | |
1151 | #define NAN_NDP_ACCEPT(_ndp) (((_ndp)->type_status & NAN_NDP_STATUS_MASK) == \ | |
1152 | NAN_NDP_STATUS_ACCEPT) | |
1153 | #define NAN_NDP_REJECT(_ndp) (((_ndp)->type_status & NAN_NDP_STATUS_MASK) == \ | |
1154 | NAN_NDP_STATUS_REJECT) | |
1155 | ||
1156 | #define NAN_NDP_FRM_STATUS(_ndp) \ | |
1157 | (((_ndp)->type_status & NAN_NDP_STATUS_MASK) >> NAN_NDP_STATUS_SHIFT) | |
1158 | ||
1159 | /* NDP Setup Status */ | |
1160 | #define NAN_NDP_SETUP_STATUS_OK 1 | |
1161 | #define NAN_NDP_SETUP_STATUS_FAIL 0 | |
1162 | #define NAN_NDP_SETUP_STATUS_REJECT 2 | |
1163 | ||
1164 | /* NDPE TLV list */ | |
1165 | #define NDPE_TLV_TYPE_IPV6 0x00 | |
1166 | #define NDPE_TLV_TYPE_SVC_INFO 0x01 | |
1167 | typedef BWL_PRE_PACKED_STRUCT struct wifi_nan_ndpe_tlv_s { | |
1168 | uint8 type; /* Operating Class */ | |
1169 | uint16 length; /* Channel Bitmap */ | |
1170 | uint8 data[]; | |
1171 | } BWL_POST_PACKED_STRUCT wifi_nan_ndpe_tlv_t; | |
1172 | ||
1173 | /* Rng setup attribute type and status macros */ | |
1174 | #define NAN_RNG_TYPE_MASK 0x0F | |
1175 | #define NAN_RNG_TYPE_REQUEST 0x0 | |
1176 | #define NAN_RNG_TYPE_RESPONSE 0x1 | |
1177 | #define NAN_RNG_TYPE_TERMINATE 0x2 | |
1178 | ||
1179 | #define NAN_RNG_STATUS_SHIFT 4 | |
1180 | #define NAN_RNG_STATUS_MASK 0xF0 | |
1181 | #define NAN_RNG_STATUS_ACCEPT (0 << NAN_RNG_STATUS_SHIFT) | |
1182 | #define NAN_RNG_STATUS_REJECT (1 << NAN_RNG_STATUS_SHIFT) | |
1183 | ||
1184 | #define NAN_RNG_ACCEPT(_rsua) (((_rsua)->type_status & NAN_RNG_STATUS_MASK) == \ | |
1185 | NAN_RNG_STATUS_ACCEPT) | |
1186 | #define NAN_RNG_REJECT(_rsua) (((_rsua)->type_status & NAN_RNG_STATUS_MASK) == \ | |
1187 | NAN_RNG_STATUS_REJECT) | |
1188 | ||
1189 | /* schedule entry */ | |
1190 | typedef BWL_PRE_PACKED_STRUCT struct wifi_nan_sched_entry_s { | |
1191 | uint8 map_id; /* map id */ | |
1192 | uint16 tbmp_ctrl; /* time bitmap control */ | |
1193 | uint8 tbmp_len; /* time bitmap len */ | |
1194 | uint8 tbmp[]; /* time bitmap - Optional */ | |
1195 | } BWL_POST_PACKED_STRUCT wifi_nan_sched_entry_t; | |
1196 | ||
1197 | #define NAN_SCHED_ENTRY_MAPID_MASK 0x0F | |
1198 | #define NAN_SCHED_ENTRY_MIN_SIZE OFFSETOF(wifi_nan_sched_entry_t, tbmp) | |
1199 | #define NAN_SCHED_ENTRY_SIZE(_entry) (NAN_SCHED_ENTRY_MIN_SIZE + (_entry)->tbmp_len) | |
1200 | ||
1201 | /* for dev cap, element container etc. */ | |
1202 | #define NAN_DEV_ELE_MAPID_CTRL_MASK 0x1 | |
1203 | #define NAN_DEV_ELE_MAPID_CTRL_SHIFT 0 | |
1204 | #define NAN_DEV_ELE_MAPID_MASK 0x1E | |
1205 | #define NAN_DEV_ELE_MAPID_SHIFT 1 | |
1206 | ||
1207 | #define NAN_DEV_ELE_MAPID_CTRL_SET(_mapid_field, value) \ | |
1208 | do {(_mapid_field) &= ~NAN_DEV_ELE_MAPID_CTRL_MASK; \ | |
1209 | (_mapid_field) |= ((value << NAN_DEV_ELE_MAPID_CTRL_SHIFT) & \ | |
1210 | NAN_DEV_ELE_MAPID_CTRL_MASK); \ | |
1211 | } while (0); | |
1212 | ||
1213 | #define NAN_DEV_ELE_MAPID_CTRL_GET(_mapid_field) \ | |
1214 | (((_mapid_field) & NAN_DEV_ELE_MAPID_CTRL_MASK) >> \ | |
1215 | NAN_DEV_ELE_MAPID_CTRL_SHIFT) | |
1216 | ||
1217 | #define NAN_DEV_ELE_MAPID_SET(_mapid_field, value) \ | |
1218 | do {(_mapid_field) &= ~NAN_DEV_ELE_MAPID_MASK; \ | |
1219 | (_mapid_field) |= ((value << NAN_DEV_ELE_MAPID_SHIFT) & \ | |
1220 | NAN_DEV_ELE_MAPID_MASK); \ | |
1221 | } while (0); | |
1222 | ||
1223 | #define NAN_DEV_ELE_MAPID_GET(_mapid_field) \ | |
1224 | (((_mapid_field) & NAN_DEV_ELE_MAPID_MASK) >> \ | |
1225 | NAN_DEV_ELE_MAPID_SHIFT) | |
1226 | ||
1227 | /* schedule entry map id handling */ | |
1228 | #define NAN_SCHED_ENTRY_MAPID_MASK 0x0F | |
1229 | #define NAN_SCHED_ENTRY_MAPID_SHIFT 0 | |
1230 | ||
1231 | #define NAN_SCHED_ENTRY_MAPID_SET(_mapid_field, value) \ | |
1232 | do {(_mapid_field) &= ~NAN_SCHED_ENTRY_MAPID_MASK; \ | |
1233 | (_mapid_field) |= ((value << NAN_SCHED_ENTRY_MAPID_SHIFT) & \ | |
1234 | NAN_SCHED_ENTRY_MAPID_MASK); \ | |
1235 | } while (0); | |
1236 | ||
1237 | #define NAN_SCHED_ENTRY_MAPID_GET(_mapid_field) \ | |
1238 | (((_mapid_field) & NAN_SCHED_ENTRY_MAPID_MASK) >> \ | |
1239 | NAN_SCHED_ENTRY_MAPID_SHIFT) | |
1240 | ||
1241 | /* NDC attribute */ | |
1242 | typedef BWL_PRE_PACKED_STRUCT struct wifi_nan_ndc_attr_s { | |
1243 | uint8 id; | |
1244 | uint16 len; | |
1245 | uint8 ndc_id[NAN_DATA_NDC_ID_SIZE]; | |
1246 | uint8 attr_cntrl; | |
1247 | uint8 var[]; | |
1248 | } BWL_POST_PACKED_STRUCT wifi_nan_ndc_attr_t; | |
1249 | ||
1250 | /* Attribute control subfield of NDC attr */ | |
1251 | /* Proposed NDC */ | |
1252 | #define NAN_NDC_ATTR_PROPOSED_NDC_MASK 0x1 | |
1253 | #define NAN_NDC_ATTR_PROPOSED_NDC_SHIFT 0 | |
1254 | ||
1255 | /* get & set */ | |
1256 | #define NAN_NDC_GET_PROPOSED_FLAG(_attr) \ | |
1257 | (((_attr)->attr_cntrl & NAN_NDC_ATTR_PROPOSED_NDC_MASK) >> \ | |
1258 | NAN_NDC_ATTR_PROPOSED_NDC_SHIFT) | |
1259 | #define NAN_NDC_SET_PROPOSED_FLAG(_attr, value) \ | |
1260 | do {((_attr)->attr_cntrl &= ~NAN_NDC_ATTR_PROPOSED_NDC_MASK); \ | |
1261 | ((_attr)->attr_cntrl |= \ | |
1262 | (((value) << NAN_NDC_ATTR_PROPOSED_NDC_SHIFT) & NAN_NDC_ATTR_PROPOSED_NDC_MASK)); \ | |
1263 | } while (0) | |
1264 | ||
1265 | /* Service descriptor extension attribute */ | |
1266 | typedef BWL_PRE_PACKED_STRUCT struct wifi_nan_svc_desc_ext_attr_s { | |
1267 | /* Attribute ID - 0x11 */ | |
1268 | uint8 id; | |
1269 | /* Length of the following fields in the attribute */ | |
1270 | uint16 len; | |
1271 | /* Instance id of associated service descriptor attribute */ | |
1272 | uint8 instance_id; | |
1273 | /* SDE control field */ | |
1274 | uint16 control; | |
1275 | /* range limit, svc upd indicator etc. */ | |
1276 | uint8 var[]; | |
1277 | } BWL_POST_PACKED_STRUCT wifi_nan_svc_desc_ext_attr_t; | |
1278 | ||
1279 | #define NAN_SDE_ATTR_MIN_LEN OFFSETOF(wifi_nan_svc_desc_ext_attr_t, var) | |
1280 | #define NAN_SDE_ATTR_RANGE_LEN 4 | |
1281 | #define NAN_SDE_ATTR_SUI_LEN 1 | |
1282 | #define NAN_SDE_ATTR_INFO_LEN_PARAM_LEN 2 | |
1283 | #define NAN_SDE_ATTR_RANGE_INGRESS_LEN 2 | |
1284 | #define NAN_SDE_ATTR_RANGE_EGRESS_LEN 2 | |
1285 | #define NAN_SDE_ATTR_CTRL_LEN 2 | |
1286 | /* max length of variable length field (matching filter, service response filter, | |
1287 | * or service info) in service descriptor attribute | |
1288 | */ | |
1289 | #define NAN_DISC_SDA_FIELD_MAX_LEN 255 | |
1290 | ||
1291 | /* SDEA control field bit definitions and access macros */ | |
1292 | #define NAN_SDE_CF_FSD_REQUIRED (1 << 0) | |
1293 | #define NAN_SDE_CF_FSD_GAS (1 << 1) | |
1294 | #define NAN_SDE_CF_DP_REQUIRED (1 << 2) | |
1295 | #define NAN_SDE_CF_DP_TYPE (1 << 3) | |
1296 | #define NAN_SDE_CF_MULTICAST_TYPE (1 << 4) | |
1297 | #define NAN_SDE_CF_QOS_REQUIRED (1 << 5) | |
1298 | #define NAN_SDE_CF_SECURITY_REQUIRED (1 << 6) | |
1299 | #define NAN_SDE_CF_RANGING_REQUIRED (1 << 7) | |
1300 | #define NAN_SDE_CF_RANGE_PRESENT (1 << 8) | |
1301 | #define NAN_SDE_CF_SVC_UPD_IND_PRESENT (1 << 9) | |
1302 | /* Using Reserved Bits as per Spec */ | |
1303 | #define NAN_SDE_CF_LIFE_CNT_PUB_RX (1 << 15) | |
1304 | #define NAN_SDE_FSD_REQUIRED(_sde) ((_sde)->control & NAN_SDE_CF_FSD_REQUIRED) | |
1305 | #define NAN_SDE_FSD_GAS(_sde) ((_sde)->control & NAN_SDE_CF_FSD_GAS) | |
1306 | #define NAN_SDE_DP_REQUIRED(_sde) ((_sde)->control & NAN_SDE_CF_DP_REQUIRED) | |
1307 | #define NAN_SDE_DP_MULTICAST(_sde) ((_sde)->control & NAN_SDE_CF_DP_TYPE) | |
1308 | #define NAN_SDE_MULTICAST_M_TO_M(_sde) ((_sde)->control & NAN_SDE_CF_MULTICAST_TYPE) | |
1309 | #define NAN_SDE_QOS_REQUIRED(_sde) ((_sde)->control & NAN_SDE_CF_QOS_REQUIRED) | |
1310 | #define NAN_SDE_SECURITY_REQUIRED(_sde) ((_sde)->control & NAN_SDE_CF_SECURITY_REQUIRED) | |
1311 | #define NAN_SDE_RANGING_REQUIRED(_sde) ((_sde)->control & NAN_SDE_CF_RANGING_REQUIRED) | |
1312 | #define NAN_SDE_RANGE_PRESENT(_sde) ((_sde)->control & NAN_SDE_CF_RANGE_PRESENT) | |
1313 | #define NAN_SDE_SVC_UPD_IND_PRESENT(_sde) ((_sde)->control & NAN_SDE_CF_SVC_UPD_IND_PRESENT) | |
1314 | #define NAN_SDE_LIFE_COUNT_FOR_PUB_RX(_sde) (_sde & NAN_SDE_CF_LIFE_CNT_PUB_RX) | |
1315 | ||
1316 | /* nan2 security */ | |
1317 | ||
1318 | /* | |
1319 | * Cipher suite information Attribute. | |
1320 | * WFA Tech. Spec ver 1.0.r21 (section 10.7.24.2) | |
1321 | */ | |
1322 | #define NAN_SEC_CIPHER_SUITE_CAP_REPLAY_4 0 | |
1323 | #define NAN_SEC_CIPHER_SUITE_CAP_REPLAY_16 (1 << 0) | |
1324 | ||
1325 | /* enum security algo. | |
1326 | */ | |
1327 | enum nan_sec_csid { | |
1328 | NAN_SEC_ALGO_NONE = 0, | |
1329 | NAN_SEC_ALGO_NCS_SK_CCM_128 = 1, /* CCMP 128 */ | |
1330 | NAN_SEC_ALGO_NCS_SK_GCM_256 = 2, /* GCMP 256 */ | |
1331 | NAN_SEC_ALGO_LAST = 3 | |
1332 | }; | |
1333 | typedef int8 nan_sec_csid_e; | |
1334 | ||
1335 | /* nan2 cipher suite attribute field */ | |
1336 | typedef BWL_PRE_PACKED_STRUCT struct wifi_nan_sec_cipher_suite_field_s { | |
1337 | uint8 cipher_suite_id; | |
1338 | uint8 inst_id; /* Instance Id */ | |
1339 | } BWL_POST_PACKED_STRUCT wifi_nan_sec_cipher_suite_field_t; | |
1340 | ||
1341 | /* nan2 cipher suite information attribute field */ | |
1342 | typedef BWL_PRE_PACKED_STRUCT struct wifi_nan_sec_cipher_suite_info_attr_s { | |
1343 | uint8 attr_id; /* 0x22 - NAN_ATTR_CIPHER_SUITE_INFO */ | |
1344 | uint16 len; | |
1345 | uint8 capabilities; | |
1346 | uint8 var[]; /* cipher suite list */ | |
1347 | } BWL_POST_PACKED_STRUCT wifi_nan_sec_cipher_suite_info_attr_t; | |
1348 | ||
1349 | /* | |
1350 | * Security context identifier attribute | |
1351 | * WFA Tech. Spec ver 1.0.r21 (section 10.7.24.4) | |
1352 | */ | |
1353 | ||
1354 | #define NAN_SEC_CTX_ID_TYPE_PMKID (1 << 0) | |
1355 | ||
1356 | /* nan2 security context identifier attribute field */ | |
1357 | typedef BWL_PRE_PACKED_STRUCT struct wifi_nan_sec_ctx_id_field_s { | |
1358 | uint16 sec_ctx_id_type_len; /* length of security ctx identifier */ | |
1359 | uint8 sec_ctx_id_type; | |
1360 | uint8 inst_id; /* Instance Id */ | |
1361 | uint8 var[]; /* security ctx identifier */ | |
1362 | } BWL_POST_PACKED_STRUCT wifi_nan_sec_ctx_id_field_t; | |
1363 | ||
1364 | /* nan2 security context identifier info attribute field */ | |
1365 | typedef BWL_PRE_PACKED_STRUCT struct wifi_nan_sec_ctx_id_info_attr_s { | |
1366 | uint8 attr_id; /* 0x23 - NAN_ATTR_SEC_CTX_ID_INFO */ | |
1367 | uint16 len; | |
1368 | uint8 var[]; /* security context identifier list */ | |
1369 | } BWL_POST_PACKED_STRUCT wifi_nan_sec_ctx_id_info_attr_t; | |
1370 | ||
1371 | /* | |
1372 | * Nan shared key descriptor attribute | |
1373 | * WFA Tech. Spec ver 23 | |
1374 | */ | |
1375 | ||
1376 | #define NAN_SEC_NCSSK_DESC_REPLAY_CNT_LEN 8 | |
1377 | #define NAN_SEC_NCSSK_DESC_KEY_NONCE_LEN 32 | |
1378 | ||
1379 | /* nan shared key descriptor attr field */ | |
1380 | typedef BWL_PRE_PACKED_STRUCT struct wifi_nan_sec_ncssk_key_desc_attr_s { | |
1381 | uint8 attr_id; /* 0x24 - NAN_ATTR_SHARED_KEY_DESC */ | |
1382 | uint16 len; | |
1383 | uint8 inst_id; /* Publish service instance ID */ | |
1384 | uint8 desc_type; | |
1385 | uint16 key_info; | |
1386 | uint16 key_len; | |
1387 | uint8 key_replay_cntr[NAN_SEC_NCSSK_DESC_REPLAY_CNT_LEN]; | |
1388 | uint8 key_nonce[NAN_SEC_NCSSK_DESC_KEY_NONCE_LEN]; | |
1389 | uint8 reserved[32]; /* EAPOL IV + Key RSC + Rsvd fields in EAPOL Key */ | |
1390 | uint8 mic[]; /* mic + key data len + key data */ | |
1391 | } BWL_POST_PACKED_STRUCT wifi_nan_sec_ncssk_key_desc_attr_t; | |
1392 | ||
1393 | /* Key Info fields */ | |
1394 | #define NAN_SEC_NCSSK_DESC_MASK 0x7 | |
1395 | #define NAN_SEC_NCSSK_DESC_SHIFT 0 | |
1396 | #define NAN_SEC_NCSSK_DESC_KEY_TYPE_MASK 0x8 | |
1397 | #define NAN_SEC_NCSSK_DESC_KEY_TYPE_SHIFT 3 | |
1398 | #define NAN_SEC_NCSSK_DESC_KEY_INSTALL_MASK 0x40 | |
1399 | #define NAN_SEC_NCSSK_DESC_KEY_INSTALL_SHIFT 6 | |
1400 | #define NAN_SEC_NCSSK_DESC_KEY_ACK_MASK 0x80 | |
1401 | #define NAN_SEC_NCSSK_DESC_KEY_ACK_SHIFT 7 | |
1402 | #define NAN_SEC_NCSSK_DESC_KEY_MIC_MASK 0x100 | |
1403 | #define NAN_SEC_NCSSK_DESC_KEY_MIC_SHIFT 8 | |
1404 | #define NAN_SEC_NCSSK_DESC_KEY_SEC_MASK 0x200 | |
1405 | #define NAN_SEC_NCSSK_DESC_KEY_SEC_SHIFT 9 | |
1406 | #define NAN_SEC_NCSSK_DESC_KEY_ERR_MASK 0x400 | |
1407 | #define NAN_SEC_NCSSK_DESC_KEY_ERR_SHIFT 10 | |
1408 | #define NAN_SEC_NCSSK_DESC_KEY_REQ_MASK 0x800 | |
1409 | #define NAN_SEC_NCSSK_DESC_KEY_REQ_SHIFT 11 | |
1410 | #define NAN_SEC_NCSSK_DESC_KEY_ENC_KEY_MASK 0x1000 | |
1411 | #define NAN_SEC_NCSSK_DESC_KEY_ENC_KEY_SHIFT 12 | |
1412 | #define NAN_SEC_NCSSK_DESC_KEY_SMK_MSG_MASK 0x2000 | |
1413 | #define NAN_SEC_NCSSK_DESC_KEY_SMK_MSG_SHIFT 13 | |
1414 | ||
1415 | /* Key Info get & set macros */ | |
1416 | #define NAN_SEC_NCSSK_KEY_DESC_VER_GET(_key_info) \ | |
1417 | (((_key_info) & NAN_SEC_NCSSK_DESC_MASK) >> NAN_SEC_NCSSK_DESC_SHIFT) | |
1418 | #define NAN_SEC_NCSSK_KEY_DESC_VER_SET(_val, _key_info) \ | |
1419 | do {(_key_info) &= ~NAN_SEC_NCSSK_DESC_MASK; \ | |
1420 | (_key_info) |= (((_val) << NAN_SEC_NCSSK_DESC_SHIFT) & \ | |
1421 | NAN_SEC_NCSSK_DESC_MASK);} while (0) | |
1422 | #define NAN_SEC_NCSSK_DESC_KEY_TYPE_GET(_key_info) \ | |
1423 | (((_key_info) & NAN_SEC_NCSSK_DESC_KEY_TYPE_MASK) >> NAN_SEC_NCSSK_DESC_KEY_TYPE_SHIFT) | |
1424 | #define NAN_SEC_NCSSK_DESC_KEY_TYPE_SET(_val, _key_info) \ | |
1425 | do {(_key_info) &= ~NAN_SEC_NCSSK_DESC_KEY_TYPE_MASK; \ | |
1426 | (_key_info) |= (((_val) << NAN_SEC_NCSSK_DESC_KEY_TYPE_SHIFT) & \ | |
1427 | NAN_SEC_NCSSK_DESC_KEY_TYPE_MASK);} while (0) | |
1428 | #define NAN_SEC_NCSSK_DESC_KEY_INSTALL_GET(_key_info) \ | |
1429 | (((_key_info) & NAN_SEC_NCSSK_DESC_KEY_INSTALL_MASK) >> \ | |
1430 | NAN_SEC_NCSSK_DESC_KEY_INSTALL_SHIFT) | |
1431 | #define NAN_SEC_NCSSK_DESC_KEY_INSTALL_SET(_val, _key_info) \ | |
1432 | do {(_key_info) &= ~NAN_SEC_NCSSK_DESC_KEY_INSTALL_MASK; \ | |
1433 | (_key_info) |= (((_val) << NAN_SEC_NCSSK_DESC_KEY_INSTALL_SHIFT) & \ | |
1434 | NAN_SEC_NCSSK_DESC_KEY_INSTALL_MASK);} while (0) | |
1435 | #define NAN_SEC_NCSSK_DESC_KEY_ACK_GET(_key_info) \ | |
1436 | (((_key_info) & NAN_SEC_NCSSK_DESC_KEY_ACK_MASK) >> NAN_SEC_NCSSK_DESC_KEY_ACK_SHIFT) | |
1437 | #define NAN_SEC_NCSSK_DESC_KEY_ACK_SET(_val, _key_info) \ | |
1438 | do {(_key_info) &= ~NAN_SEC_NCSSK_DESC_KEY_ACK_MASK; \ | |
1439 | (_key_info) |= (((_val) << NAN_SEC_NCSSK_DESC_KEY_ACK_SHIFT) & \ | |
1440 | NAN_SEC_NCSSK_DESC_KEY_ACK_MASK);} while (0) | |
1441 | #define NAN_SEC_NCSSK_DESC_KEY_MIC_GET(_key_info) \ | |
1442 | (((_key_info) & NAN_SEC_NCSSK_DESC_KEY_MIC_MASK) >> NAN_SEC_NCSSK_DESC_KEY_MIC_SHIFT) | |
1443 | #define NAN_SEC_NCSSK_DESC_KEY_MIC_SET(_val, _key_info) \ | |
1444 | do {(_key_info) &= ~NAN_SEC_NCSSK_DESC_KEY_MIC_MASK; \ | |
1445 | (_key_info) |= (((_val) << NAN_SEC_NCSSK_DESC_KEY_MIC_SHIFT) & \ | |
1446 | NAN_SEC_NCSSK_DESC_KEY_MIC_MASK);} while (0) | |
1447 | #define NAN_SEC_NCSSK_DESC_KEY_SEC_GET(_key_info) \ | |
1448 | (((_key_info) & NAN_SEC_NCSSK_DESC_KEY_SEC_MASK) >> NAN_SEC_NCSSK_DESC_KEY_SEC_SHIFT) | |
1449 | #define NAN_SEC_NCSSK_DESC_KEY_SEC_SET(_val, _key_info) \ | |
1450 | do {(_key_info) &= ~NAN_SEC_NCSSK_DESC_KEY_SEC_MASK; \ | |
1451 | (_key_info) |= (((_val) << NAN_SEC_NCSSK_DESC_KEY_SEC_SHIFT) & \ | |
1452 | NAN_SEC_NCSSK_DESC_KEY_SEC_MASK);} while (0) | |
1453 | #define NAN_SEC_NCSSK_DESC_KEY_ERR_GET(_key_info) \ | |
1454 | (((_key_info) & NAN_SEC_NCSSK_DESC_KEY_ERR_MASK) >> NAN_SEC_NCSSK_DESC_KEY_ERR_SHIFT) | |
1455 | #define NAN_SEC_NCSSK_DESC_KEY_ERR_SET(_val, _key_info) \ | |
1456 | do {(_key_info) &= ~NAN_SEC_NCSSK_DESC_KEY_ERR_MASK; \ | |
1457 | (_key_info) |= (((_val) << NAN_SEC_NCSSK_DESC_KEY_ERR_SHIFT) & \ | |
1458 | NAN_SEC_NCSSK_DESC_KEY_ERR_MASK);} while (0) | |
1459 | #define NAN_SEC_NCSSK_DESC_KEY_REQ_GET(_key_info) \ | |
1460 | (((_key_info) & NAN_SEC_NCSSK_DESC_KEY_REQ_MASK) >> NAN_SEC_NCSSK_DESC_KEY_REQ_SHIFT) | |
1461 | #define NAN_SEC_NCSSK_DESC_KEY_REQ_SET(_val, _key_info) \ | |
1462 | do {(_key_info) &= ~NAN_SEC_NCSSK_DESC_KEY_REQ_MASK; \ | |
1463 | (_key_info) |= (((_val) << NAN_SEC_NCSSK_DESC_KEY_REQ_SHIFT) & \ | |
1464 | NAN_SEC_NCSSK_DESC_KEY_REQ_MASK);} while (0) | |
1465 | #define NAN_SEC_NCSSK_DESC_KEY_ENC_KEY_GET(_key_info) \ | |
1466 | (((_key_info) & NAN_SEC_NCSSK_DESC_KEY_ENC_KEY_MASK) >> \ | |
1467 | NAN_SEC_NCSSK_DESC_KEY_ENC_KEY_SHIFT) | |
1468 | #define NAN_SEC_NCSSK_DESC_KEY_ENC_KEY_SET(_val, _key_info) \ | |
1469 | do {(_key_info) &= ~NAN_SEC_NCSSK_DESC_KEY_ENC_KEY_MASK; \ | |
1470 | (_key_info) |= (((_val) << NAN_SEC_NCSSK_DESC_KEY_ENC_KEY_SHIFT) & \ | |
1471 | NAN_SEC_NCSSK_DESC_KEY_ENC_KEY_MASK);} while (0) | |
1472 | #define NAN_SEC_NCSSK_DESC_KEY_SMK_MSG_GET(_key_info) \ | |
1473 | (((_key_info) & NAN_SEC_NCSSK_DESC_KEY_SMK_MSG_MASK) >> \ | |
1474 | NAN_SEC_NCSSK_DESC_KEY_SMK_MSG_SHIFT) | |
1475 | #define NAN_SEC_NCSSK_DESC_KEY_SMK_MSG_SET(_val, _key_info) \ | |
1476 | do {(_key_info) &= ~NAN_SEC_NCSSK_DESC_KEY_SMK_MSG_MASK; \ | |
1477 | (_key_info) |= (((_val) << NAN_SEC_NCSSK_DESC_KEY_SMK_MSG_SHIFT) & \ | |
1478 | NAN_SEC_NCSSK_DESC_KEY_SMK_MSG_MASK);} while (0) | |
1479 | ||
1480 | #define NAN_SEC_NCSSK_IEEE80211_KDESC_TYPE 2 /* IEEE 802.11 Key Descriptor Type */ | |
1481 | #define NAN_SEC_NCSSK_KEY_DESC_VER 0 /* NCSSK-128/256 */ | |
1482 | #define NAN_SEC_NCSSK_KEY_TYPE_PAIRWISE 1 /* Pairwise */ | |
1483 | #define NAN_SEC_NCSSK_LIFETIME_KDE 7 /* Lifetime KDE type */ | |
1484 | ||
1485 | /* TODO include MTK related attributes */ | |
1486 | ||
1487 | /* NAN Multicast service group(NMSG) definitions */ | |
1488 | /* Length of NMSG_ID -- (NDI * 2^16 + pub_id * 2^8 + Random_factor) */ | |
1489 | #define NAN_NMSG_ID_LEN 8 | |
1490 | ||
1491 | #define NAN_NMSG_TYPE_MASK 0x0F | |
1492 | #define NMSG_ATTR_TYPE_STATUS_REQUEST 0x00 | |
1493 | #define NMSG_ATTR_TYPE_STATUS_RESPONSE 0x01 | |
1494 | #define NMSG_ATTR_TYPE_STATUS_CONFIRM 0x02 | |
1495 | #define NMSG_ATTR_TYPE_STATUS_SEC_INSTALL 0x03 | |
1496 | #define NMSG_ATTR_TYPE_STATUS_TERMINATE 0x04 | |
1497 | #define NMSG_ATTR_TYPE_STATUS_IMPLICIT_ENROL 0x05 | |
1498 | ||
1499 | #define NMSG_ATTR_TYPE_STATUS_CONTINUED 0x00 | |
1500 | #define NMSG_ATTR_TYPE_STATUS_ACCEPTED 0x10 | |
1501 | #define NMSG_ATTR_TYPE_STATUS_REJECTED 0x20 | |
1502 | ||
1503 | #define NMSG_CTRL_PUB_ID_PRESENT 0x0001 | |
1504 | #define NMSG_CTRL_NMSG_ID_PRESENT 0x0002 | |
1505 | #define NMSG_CTRL_SECURITY_PRESENT 0x0004 | |
1506 | #define NMSG_CTRL_MANY_TO_MANY_PRESENT 0x0008 | |
1507 | #define NMSG_CTRL_SVC_INFO_PRESENT 0x0010 | |
1508 | ||
1509 | /* NMSG attribute */ | |
1510 | typedef BWL_PRE_PACKED_STRUCT struct wifi_nan_nmsg_attr_s { | |
1511 | uint8 id; /* Attribute ID - 0x11 */ | |
1512 | uint16 len; /* Length including pubid, NMSGID and svc info */ | |
1513 | uint8 dialog_token; | |
1514 | uint8 type_status; /* Type and Status field byte */ | |
1515 | uint8 reason_code; | |
1516 | uint8 mc_id; /* Multicast id similar to NDPID */ | |
1517 | uint8 nmsg_ctrl; /* NMSG control field */ | |
1518 | /* Optional publish id, NMSGID and svc info are included in var[] */ | |
1519 | uint8 var[0]; | |
1520 | } BWL_POST_PACKED_STRUCT wifi_nan_nmsg_attr_t; | |
1521 | ||
1522 | #define NMSG_ATTR_MCAST_SCHED_MAP_ID_MASK 0x1E | |
1523 | #define NMSG_ATTR_MCAST_SCHED_MAP_ID_SHIFT 1 | |
1524 | #define NMSG_ATTR_MCAST_SCHED_TIME_MAP_MASK 0x20 | |
1525 | #define NMSG_ATTR_MCAST_SCHED_TIME_MAP_SHIFT 5 | |
1526 | ||
1527 | /* NAN Multicast Schedule atribute structure */ | |
1528 | typedef BWL_PRE_PACKED_STRUCT struct wifi_nan_mcast_sched_attr_s { | |
1529 | uint8 id; /* 0x16 */ | |
1530 | uint16 len; | |
1531 | uint8 nmsg_id[NAN_NMSG_ID_LEN]; | |
1532 | uint8 attr_cntrl; | |
1533 | uint8 sched_own[ETHER_ADDR_LEN]; | |
1534 | uint8 var[]; /* multicast sched entry list (schedule_entry_list) */ | |
1535 | } BWL_POST_PACKED_STRUCT wifi_nan_mcast_sched_attr_t; | |
1536 | ||
1537 | /* FAC Channel Entry (section 10.7.19.1.5) */ | |
1538 | typedef BWL_PRE_PACKED_STRUCT struct wifi_nan_fac_chan_entry_s { | |
1539 | uint8 oper_class; /* Operating Class */ | |
1540 | uint16 chan_bitmap; /* Channel Bitmap */ | |
1541 | uint8 primary_chan_bmp; /* Primary Channel Bitmap */ | |
1542 | uint16 aux_chan; /* Auxiliary Channel bitmap */ | |
1543 | } BWL_POST_PACKED_STRUCT wifi_nan_fac_chan_entry_t; | |
1544 | ||
1545 | /* TODO move this from nan.h */ | |
1546 | #define NAN_ALL_NAN_MGMT_FRAMES (NAN_FRM_SCHED_AF | \ | |
1547 | NAN_FRM_NDP_AF | NAN_FRM_NDL_AF | \ | |
1548 | NAN_FRM_DISC_BCN | NAN_FRM_SYNC_BCN | \ | |
1549 | NAN_FRM_SVC_DISC | NAN_FRM_RNG_REQ_AF | \ | |
1550 | NAN_FRM_RNG_RESP_AF | NAN_FRM_RNG_REPORT_AF | \ | |
1551 | NAN_FRM_RNG_TERM_AF) | |
1552 | ||
1553 | /* This marks the end of a packed structure section. */ | |
1554 | #include <packed_section_end.h> | |
1555 | ||
1556 | #endif /* _NAN_H_ */ |