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