2 * Fundamental types and constants relating to WFA NAN
3 * (Neighbor Awareness Networking)
5 * Copyright (C) 1999-2019, Broadcom.
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:
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.
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.
26 * <<Broadcom-WL-IPTag/Open:>>
28 * $Id: nan.h 758133 2018-04-17 19:07:15Z $
36 /* This marks the start of a packed structure section. */
37 #include <packed_section_start.h>
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
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))
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
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
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 */
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)
94 /* NAN slot duration / period */
96 #define NAN_TU_PER_DW 512
98 #define NAN_MAX_TU (NAN_MAX_DW * NAN_TU_PER_DW)
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
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 */
117 #define NAN_DATA_NDC_ID_SIZE 6
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 */
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)
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 */
138 /* NAN_PUB_AF_ACTION 0x09 */
140 /* NAN_OUI 0x50-6F-9A */
141 uint8 oui
[DOT11_OUI_LEN
];
142 /* NAN_OUI_TYPE 0x13 */
144 /* One or more NAN Attributes follow */
146 } BWL_POST_PACKED_STRUCT nan_pub_act_frame_t
;
148 /* NAN attributes as defined in the nan spec */
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,
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,
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,
193 /* change NAN_ATTR_MAX_ID to max ids + 1, excluding NAN_ATTR_VENDOR_SPECIFIC.
194 * This is used in nan_parse.c
196 NAN_ATTR_MAX_ID
= NAN_ATTR_NDPE
+ 1,
198 NAN_ATTR_VENDOR_SPECIFIC
= 221
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
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
;
216 #define NAN_IE_HDR_SIZE (OFFSETOF(wifi_nan_ie_t, attr))
218 /* master indication record */
219 typedef BWL_PRE_PACKED_STRUCT
struct wifi_nan_master_ind_attr_s
{
222 uint8 master_preference
;
224 } BWL_POST_PACKED_STRUCT wifi_nan_master_ind_attr_t
;
226 /* cluster attr record */
227 typedef BWL_PRE_PACKED_STRUCT
struct wifi_nan_cluster_attr_s
{
230 uint8 amr
[NAN_MASTER_RANK_LEN
];
232 /* Anchor Master Beacon Transmission Time */
234 } BWL_POST_PACKED_STRUCT wifi_nan_cluster_attr_t
;
236 /* container for service ID records */
237 typedef BWL_PRE_PACKED_STRUCT
struct wifi_nan_svc_id_attr_s
{
240 uint8 svcid
[0]; /* 6*len of srvc IDs */
241 } BWL_POST_PACKED_STRUCT wifi_nan_svc_id_attr_t
;
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
258 /* Service descriptor */
259 typedef BWL_PRE_PACKED_STRUCT
struct wifi_nan_svc_descriptor_attr_s
{
260 /* Attribute ID - 0x03. */
262 /* Length of the following fields in the attribute */
264 /* Hash of the Service Name */
265 uint8 svc_hash
[NAN_SVC_HASH_LEN
];
266 /* Publish or subscribe instance id */
268 /* Requestor Instance ID */
270 /* Service Control Bitmask. Also determines what data follows. */
272 /* Optional fields follow */
273 } BWL_POST_PACKED_STRUCT wifi_nan_svc_descriptor_attr_t
;
276 typedef BWL_PRE_PACKED_STRUCT
struct wifi_nan_ibss_attr_s
{
277 /* Attribute ID - 0x07. */
279 /* Length of the following fields in the attribute */
281 /* BSSID of the ibss */
282 struct ether_addr bssid
;
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?
291 /* avail. intervals bitmap, var len */
293 } BWL_POST_PACKED_STRUCT wifi_nan_ibss_attr_t
;
295 /* Further Availability MAP attr */
296 typedef BWL_PRE_PACKED_STRUCT
struct wifi_nan_favail_attr_s
{
297 /* Attribute ID - 0x0A. */
299 /* Length of the following fields in the attribute */
301 /* MAP id: val [0..15], values[16-255] reserved */
303 /* availibility entry, var len */
305 } BWL_POST_PACKED_STRUCT wifi_nan_favail_attr_t
;
307 /* Further Availability MAP attr */
308 typedef BWL_PRE_PACKED_STRUCT
struct wifi_nan_avail_entry_s
{
311 [0-1]: avail interval duration: 0:16ms; 1:32ms; 2:64ms;
315 /* operating class: freq band etc IEEE 802.11 */
319 /* avail bmp, var len */
321 } BWL_POST_PACKED_STRUCT wifi_nan_avail_entry_t
;
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
330 #define NAN_VENDOR_TYPE_RTT 0
331 #define NAN_VENDOR_TYPE_P2P 1
333 /* Vendor Specific Attribute - old definition */
335 typedef BWL_PRE_PACKED_STRUCT
struct wifi_nan_vendor_attr_s
{
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
;
343 #define NAN_VENDOR_HDR_SIZE (OFFSETOF(wifi_nan_vendor_attr_t, attr))
345 /* vendor specific attribute */
346 typedef BWL_PRE_PACKED_STRUCT
struct wifi_nan_vndr_attr_s
{
348 uint16 len
; /* length of following fields */
349 uint8 oui
[DOT11_OUI_LEN
]; /* vendor specific OUI */
351 } BWL_POST_PACKED_STRUCT wifi_nan_vndr_attr_t
;
353 /* p2p operation attribute */
354 typedef BWL_PRE_PACKED_STRUCT
struct wifi_nan_p2p_op_attr_s
{
355 /* Attribute ID - 0x06. */
357 /* Length of the following fields in the attribute */
359 /* P2P device role */
361 /* BSSID of the ibss */
362 struct ether_addr p2p_dev_addr
;
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?
371 /* avail. intervals bitmap */
373 } BWL_POST_PACKED_STRUCT wifi_nan_p2p_op_attr_t
;
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))
393 NAN_RANGING_PROTO_FTM
= 0
396 typedef BWL_PRE_PACKED_STRUCT
struct wifi_nan_ranging_attr_s
{
398 uint16 len
; /* length that follows */
399 struct ether_addr dev_addr
; /* device mac address */
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?
410 uint8 protocol
; /* FTM = 0 */
411 uint32 avail_bmp
; /* avail interval bitmap */
412 } BWL_POST_PACKED_STRUCT wifi_nan_ranging_attr_t
;
414 typedef BWL_PRE_PACKED_STRUCT
struct wifi_nan_ranging_info_attr_s
{
416 uint16 len
; /* length that follows */
418 location info availability bit map
419 0: LCI Local Coordinates
420 1: Geospatial LCI WGS84
422 3: Last Movement Indication
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
431 uint16 last_movement
;
433 } BWL_POST_PACKED_STRUCT wifi_nan_ranging_info_attr_t
;
435 typedef BWL_PRE_PACKED_STRUCT
struct wifi_nan_ranging_setup_attr_hdr_s
{
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 */
441 i. when frm type = response & status = reject
442 ii. frm type = termination
445 } BWL_POST_PACKED_STRUCT wifi_nan_ranging_setup_attr_hdr_t
;
447 typedef BWL_PRE_PACKED_STRUCT
struct wifi_nan_ranging_setup_attr_s
{
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 */
453 uint8 data
[]; /* schedule entry list */
454 } BWL_POST_PACKED_STRUCT wifi_nan_ranging_setup_attr_t
;
456 #define NAN_RANGE_SETUP_ATTR_OFFSET_TBM_INFO (OFFSETOF(wifi_nan_ranging_setup_attr_t, data))
458 typedef BWL_PRE_PACKED_STRUCT
struct wifi_nan_ranging_report_attr_s
{
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
465 uint8 data
[2]; /* includes pad */
467 dot11_ftm_range_entry_t entries[entry_count];
469 dot11_ftm_error_entry_t errors[error_count];
471 } BWL_POST_PACKED_STRUCT wifi_nan_ranging_report_attr_t
;
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
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
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
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
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
500 #define FTM_PARAMS_BURSTTMO_FACTOR 250
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;}
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 | \
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)
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
536 #define NAN_DEFAULT_MAP_ID 0 /* nan default map id */
537 #define NAN_DEFAULT_MAP_CTRL 0 /* nan default map control */
539 typedef BWL_PRE_PACKED_STRUCT
struct wifi_nan_conn_cap_attr_s
{
540 /* Attribute ID - 0x04. */
542 /* Length of the following fields in the attribute */
544 uint16 conn_cap_bmp
; /* Connection capability bitmap */
545 } BWL_POST_PACKED_STRUCT wifi_nan_conn_cap_attr_t
;
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
;
555 /* NAN 2.0 NAN avail attribute */
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
;
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
;
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
;
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
;
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
;
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
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
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)
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))
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)
660 typedef BWL_PRE_PACKED_STRUCT
struct wifi_nan_channel_entry_list_s
{
663 } BWL_POST_PACKED_STRUCT wifi_nan_channel_entry_list_t
;
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
671 typedef BWL_PRE_PACKED_STRUCT
struct wifi_nan_band_entry_s
{
673 } BWL_POST_PACKED_STRUCT wifi_nan_band_entry_t
;
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)
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
695 #define NAN_ENTRY_CNTRL_UTIL_MASK 0x1E0
696 #define NAN_ENTRY_CNTRL_UTIL_SHIFT 5
698 /* Time Bitmap Control field (section 5.7.18.2.3) */
701 #define NAN_TIME_BMP_CNTRL_RSVD_MASK 0x01
702 #define NAN_TIME_BMP_CNTRL_RSVD_SHIFT 0
704 #define NAN_TIME_BMP_CNTRL_BMP_LEN_MASK 0x7E
705 #define NAN_TIME_BMP_CNTRL_BMP_LEN_SHIFT 1
707 #define NAN_TIME_BMP_CNTRL_BIT_DUR_MASK 0x380
708 #define NAN_TIME_BMP_CNTRL_BIT_DUR_SHIFT 7
710 #define NAN_TIME_BMP_CNTRL_PERIOD_MASK 0x1C00
711 #define NAN_TIME_BMP_CNTRL_PERIOD_SHIFT 10
713 #define NAN_TIME_BMP_CNTRL_START_OFFSET_MASK 0x3FE000
714 #define NAN_TIME_BMP_CNTRL_START_OFFSET_SHIFT 13
716 #define NAN_TIME_BMP_CNTRL_RESERVED_MASK 0xC00000
717 #define NAN_TIME_BMP_CNTRL_RESERVED_SHIFT 22
719 /* Time Bitmap Control field: Period */
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
;
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
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
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
758 /* Channel Entries List field */
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
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
773 #define NAN_CHAN_ENTRY_TYPE_BANDS 0
774 #define NAN_CHAN_ENTRY_TYPE_OPCLASS_CHANS 1
776 #define NAN_CHAN_ENTRY_BW_LT_80MHZ 0
777 #define NAN_CHAN_ENTRY_BW_EQ_160MHZ 1
780 * NDL Attribute WFA Tech. Spec ver 1.0.r12 (section 10.7.19.2)
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
787 * NDL Control field - Table xx
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
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 */
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 */
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
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)
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)
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)
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)
848 #define NDL_ATTR_PEERID_LEN 1
849 #define NDL_ATTR_MAX_IDLE_PERIOD_LEN 2
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
;
862 * NDL QoS Attribute WFA Tech. Spec ver r26
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
;
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
876 /* Device Capability Attribute */
878 typedef BWL_PRE_PACKED_STRUCT
struct wifi_nan_dev_cap_s
{
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
;
893 #define NAN_DEV_CAP_ALL_MAPS_FLAG_MASK 0x1 /* nan default map control */
894 #define NAN_DEV_CAP_ALL_MAPS_FLAG_SHIFT 0
896 #define NAN_DEV_CAP_MAPID_MASK 0x1E
897 #define NAN_DEV_CAP_MAPID_SHIFT 1
899 /* Awake DW Info field format */
902 #define NAN_DEV_CAP_AWAKE_DW_2G_MASK 0x07
904 #define NAN_DEV_CAP_AWAKE_DW_5G_MASK 0x38
906 #define NAN_DEV_CAP_AWAKE_DW_RSVD_MASK 0xC0
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
912 /* Device Capability Attribute Format */
914 /* Committed DW Info field format */
916 #define NAN_DEV_CAP_COMMIT_DW_2G_MASK 0x07
917 #define NAN_DEV_CAP_COMMIT_DW_2G_OVERWRITE_MASK 0x3C0
919 #define NAN_DEV_CAP_COMMIT_DW_5G_MASK 0x38
920 #define NAN_DEV_CAP_COMMIT_DW_5G_OVERWRITE_MASK 0x3C00
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
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
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
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)
951 /* Device capabilities */
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)
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 */
972 typedef uint8 nan_band_id_t
;
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)
979 * Unaligned schedule attribute section 10.7.19.6 spec. ver r15
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
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
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
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
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 */
1008 typedef BWL_PRE_PACKED_STRUCT
struct wifi_nan_ulw_attr_s
{
1012 uint32 start
; /* low 32 bits of tsf */
1018 * ulw[0] == optional field ULW control when present.
1019 * band ID or channel follows
1022 } BWL_POST_PACKED_STRUCT wifi_nan_ulw_attr_t
;
1024 /* NAN2 Management Frame (section 5.6) */
1026 /* Public action frame for NAN2 */
1027 typedef BWL_PRE_PACKED_STRUCT
struct nan2_pub_act_frame_s
{
1028 /* NAN_PUB_AF_CATEGORY 0x04 */
1030 /* NAN_PUB_AF_ACTION 0x09 */
1032 /* NAN_OUI 0x50-6F-9A */
1033 uint8 oui
[DOT11_OUI_LEN
];
1034 /* NAN_OUI_TYPE TBD */
1036 /* NAN_OUI_SUB_TYPE TBD */
1038 /* One or more NAN Attributes follow */
1040 } BWL_POST_PACKED_STRUCT nan2_pub_act_frame_t
;
1042 #define NAN2_PUB_ACT_FRM_SIZE (OFFSETOF(nan2_pub_act_frame_t, data))
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
1057 #define NAN_MGMT_FRM_SUBTYPE_NDP_REQ 5
1059 #define NAN_MGMT_FRM_SUBTYPE_NDP_RESP 6
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
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
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
;
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
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
1146 /* Rng setup attribute type and status macros */
1147 #define NAN_RNG_TYPE_MASK 0x0F
1148 #define NAN_RNG_TYPE_REQUEST 0x0
1149 #define NAN_RNG_TYPE_RESPONSE 0x1
1150 #define NAN_RNG_TYPE_TERMINATE 0x2
1152 #define NAN_RNG_STATUS_SHIFT 4
1153 #define NAN_RNG_STATUS_MASK 0xF0
1154 #define NAN_RNG_STATUS_ACCEPT (0 << NAN_RNG_STATUS_SHIFT)
1155 #define NAN_RNG_STATUS_REJECT (1 << NAN_RNG_STATUS_SHIFT)
1157 #define NAN_RNG_ACCEPT(_rsua) (((_rsua)->type_status & NAN_RNG_STATUS_MASK) == \
1158 NAN_RNG_STATUS_ACCEPT)
1159 #define NAN_RNG_REJECT(_rsua) (((_rsua)->type_status & NAN_RNG_STATUS_MASK) == \
1160 NAN_RNG_STATUS_REJECT)
1162 /* schedule entry */
1163 typedef BWL_PRE_PACKED_STRUCT
struct wifi_nan_sched_entry_s
{
1164 uint8 map_id
; /* map id */
1165 uint16 tbmp_ctrl
; /* time bitmap control */
1166 uint8 tbmp_len
; /* time bitmap len */
1167 uint8 tbmp
[]; /* time bitmap - Optional */
1168 } BWL_POST_PACKED_STRUCT wifi_nan_sched_entry_t
;
1170 #define NAN_SCHED_ENTRY_MAPID_MASK 0x0F
1171 #define NAN_SCHED_ENTRY_MIN_SIZE OFFSETOF(wifi_nan_sched_entry_t, tbmp)
1172 #define NAN_SCHED_ENTRY_SIZE(_entry) (NAN_SCHED_ENTRY_MIN_SIZE + (_entry)->tbmp_len)
1174 /* for dev cap, element container etc. */
1175 #define NAN_DEV_ELE_MAPID_CTRL_MASK 0x1
1176 #define NAN_DEV_ELE_MAPID_CTRL_SHIFT 0
1177 #define NAN_DEV_ELE_MAPID_MASK 0x1E
1178 #define NAN_DEV_ELE_MAPID_SHIFT 1
1180 #define NAN_DEV_ELE_MAPID_CTRL_SET(_mapid_field, value) \
1181 do {(_mapid_field) &= ~NAN_DEV_ELE_MAPID_CTRL_MASK; \
1182 (_mapid_field) |= ((value << NAN_DEV_ELE_MAPID_CTRL_SHIFT) & \
1183 NAN_DEV_ELE_MAPID_CTRL_MASK); \
1186 #define NAN_DEV_ELE_MAPID_CTRL_GET(_mapid_field) \
1187 (((_mapid_field) & NAN_DEV_ELE_MAPID_CTRL_MASK) >> \
1188 NAN_DEV_ELE_MAPID_CTRL_SHIFT)
1190 #define NAN_DEV_ELE_MAPID_SET(_mapid_field, value) \
1191 do {(_mapid_field) &= ~NAN_DEV_ELE_MAPID_MASK; \
1192 (_mapid_field) |= ((value << NAN_DEV_ELE_MAPID_SHIFT) & \
1193 NAN_DEV_ELE_MAPID_MASK); \
1196 #define NAN_DEV_ELE_MAPID_GET(_mapid_field) \
1197 (((_mapid_field) & NAN_DEV_ELE_MAPID_MASK) >> \
1198 NAN_DEV_ELE_MAPID_SHIFT)
1200 /* schedule entry map id handling */
1201 #define NAN_SCHED_ENTRY_MAPID_MASK 0x0F
1202 #define NAN_SCHED_ENTRY_MAPID_SHIFT 0
1204 #define NAN_SCHED_ENTRY_MAPID_SET(_mapid_field, value) \
1205 do {(_mapid_field) &= ~NAN_SCHED_ENTRY_MAPID_MASK; \
1206 (_mapid_field) |= ((value << NAN_SCHED_ENTRY_MAPID_SHIFT) & \
1207 NAN_SCHED_ENTRY_MAPID_MASK); \
1210 #define NAN_SCHED_ENTRY_MAPID_GET(_mapid_field) \
1211 (((_mapid_field) & NAN_SCHED_ENTRY_MAPID_MASK) >> \
1212 NAN_SCHED_ENTRY_MAPID_SHIFT)
1215 typedef BWL_PRE_PACKED_STRUCT
struct wifi_nan_ndc_attr_s
{
1218 uint8 ndc_id
[NAN_DATA_NDC_ID_SIZE
];
1221 } BWL_POST_PACKED_STRUCT wifi_nan_ndc_attr_t
;
1223 /* Attribute control subfield of NDC attr */
1225 #define NAN_NDC_ATTR_PROPOSED_NDC_MASK 0x1
1226 #define NAN_NDC_ATTR_PROPOSED_NDC_SHIFT 0
1229 #define NAN_NDC_GET_PROPOSED_FLAG(_attr) \
1230 (((_attr)->attr_cntrl & NAN_NDC_ATTR_PROPOSED_NDC_MASK) >> \
1231 NAN_NDC_ATTR_PROPOSED_NDC_SHIFT)
1232 #define NAN_NDC_SET_PROPOSED_FLAG(_attr, value) \
1233 do {((_attr)->attr_cntrl &= ~NAN_NDC_ATTR_PROPOSED_NDC_MASK); \
1234 ((_attr)->attr_cntrl |= \
1235 (((value) << NAN_NDC_ATTR_PROPOSED_NDC_SHIFT) & NAN_NDC_ATTR_PROPOSED_NDC_MASK)); \
1238 /* Service descriptor extension attribute */
1239 typedef BWL_PRE_PACKED_STRUCT
struct wifi_nan_svc_desc_ext_attr_s
{
1240 /* Attribute ID - 0x11 */
1242 /* Length of the following fields in the attribute */
1244 /* Instance id of associated service descriptor attribute */
1246 /* SDE control field */
1248 /* range limit, svc upd indicator etc. */
1250 } BWL_POST_PACKED_STRUCT wifi_nan_svc_desc_ext_attr_t
;
1252 #define NAN_SDE_ATTR_MIN_LEN OFFSETOF(wifi_nan_svc_desc_ext_attr_t, var)
1253 #define NAN_SDE_ATTR_RANGE_LEN 4
1254 #define NAN_SDE_ATTR_SUI_LEN 1
1255 #define NAN_SDE_ATTR_INFO_LEN_PARAM_LEN 2
1256 #define NAN_SDE_ATTR_RANGE_INGRESS_LEN 2
1257 #define NAN_SDE_ATTR_RANGE_EGRESS_LEN 2
1258 #define NAN_SDE_ATTR_CTRL_LEN 2
1259 /* max length of variable length field (matching filter, service response filter,
1260 * or service info) in service descriptor attribute
1262 #define NAN_DISC_SDA_FIELD_MAX_LEN 255
1264 /* SDEA control field bit definitions and access macros */
1265 #define NAN_SDE_CF_FSD_REQUIRED (1 << 0)
1266 #define NAN_SDE_CF_FSD_GAS (1 << 1)
1267 #define NAN_SDE_CF_DP_REQUIRED (1 << 2)
1268 #define NAN_SDE_CF_DP_TYPE (1 << 3)
1269 #define NAN_SDE_CF_MULTICAST_TYPE (1 << 4)
1270 #define NAN_SDE_CF_QOS_REQUIRED (1 << 5)
1271 #define NAN_SDE_CF_SECURITY_REQUIRED (1 << 6)
1272 #define NAN_SDE_CF_RANGING_REQUIRED (1 << 7)
1273 #define NAN_SDE_CF_RANGE_PRESENT (1 << 8)
1274 #define NAN_SDE_CF_SVC_UPD_IND_PRESENT (1 << 9)
1275 /* Using Reserved Bits as per Spec */
1276 #define NAN_SDE_CF_LIFE_CNT_PUB_RX (1 << 15)
1277 #define NAN_SDE_FSD_REQUIRED(_sde) ((_sde)->control & NAN_SDE_CF_FSD_REQUIRED)
1278 #define NAN_SDE_FSD_GAS(_sde) ((_sde)->control & NAN_SDE_CF_FSD_GAS)
1279 #define NAN_SDE_DP_REQUIRED(_sde) ((_sde)->control & NAN_SDE_CF_DP_REQUIRED)
1280 #define NAN_SDE_DP_MULTICAST(_sde) ((_sde)->control & NAN_SDE_CF_DP_TYPE)
1281 #define NAN_SDE_MULTICAST_M_TO_M(_sde) ((_sde)->control & NAN_SDE_CF_MULTICAST_TYPE)
1282 #define NAN_SDE_QOS_REQUIRED(_sde) ((_sde)->control & NAN_SDE_CF_QOS_REQUIRED)
1283 #define NAN_SDE_SECURITY_REQUIRED(_sde) ((_sde)->control & NAN_SDE_CF_SECURITY_REQUIRED)
1284 #define NAN_SDE_RANGING_REQUIRED(_sde) ((_sde)->control & NAN_SDE_CF_RANGING_REQUIRED)
1285 #define NAN_SDE_RANGE_PRESENT(_sde) ((_sde)->control & NAN_SDE_CF_RANGE_PRESENT)
1286 #define NAN_SDE_SVC_UPD_IND_PRESENT(_sde) ((_sde)->control & NAN_SDE_CF_SVC_UPD_IND_PRESENT)
1287 #define NAN_SDE_LIFE_COUNT_FOR_PUB_RX(_sde) (_sde & NAN_SDE_CF_LIFE_CNT_PUB_RX)
1292 * Cipher suite information Attribute.
1293 * WFA Tech. Spec ver 1.0.r21 (section 10.7.24.2)
1295 #define NAN_SEC_CIPHER_SUITE_CAP_REPLAY_4 0
1296 #define NAN_SEC_CIPHER_SUITE_CAP_REPLAY_16 (1 << 0)
1298 /* enum security algo.
1301 NAN_SEC_ALGO_NONE
= 0,
1302 NAN_SEC_ALGO_NCS_SK_CCM_128
= 1, /* CCMP 128 */
1303 NAN_SEC_ALGO_NCS_SK_GCM_256
= 2, /* GCMP 256 */
1304 NAN_SEC_ALGO_LAST
= 3
1306 typedef int8 nan_sec_csid_e
;
1308 /* nan2 cipher suite attribute field */
1309 typedef BWL_PRE_PACKED_STRUCT
struct wifi_nan_sec_cipher_suite_field_s
{
1310 uint8 cipher_suite_id
;
1311 uint8 inst_id
; /* Instance Id */
1312 } BWL_POST_PACKED_STRUCT wifi_nan_sec_cipher_suite_field_t
;
1314 /* nan2 cipher suite information attribute field */
1315 typedef BWL_PRE_PACKED_STRUCT
struct wifi_nan_sec_cipher_suite_info_attr_s
{
1316 uint8 attr_id
; /* 0x22 - NAN_ATTR_CIPHER_SUITE_INFO */
1319 uint8 var
[]; /* cipher suite list */
1320 } BWL_POST_PACKED_STRUCT wifi_nan_sec_cipher_suite_info_attr_t
;
1323 * Security context identifier attribute
1324 * WFA Tech. Spec ver 1.0.r21 (section 10.7.24.4)
1327 #define NAN_SEC_CTX_ID_TYPE_PMKID (1 << 0)
1329 /* nan2 security context identifier attribute field */
1330 typedef BWL_PRE_PACKED_STRUCT
struct wifi_nan_sec_ctx_id_field_s
{
1331 uint16 sec_ctx_id_type_len
; /* length of security ctx identifier */
1332 uint8 sec_ctx_id_type
;
1333 uint8 inst_id
; /* Instance Id */
1334 uint8 var
[]; /* security ctx identifier */
1335 } BWL_POST_PACKED_STRUCT wifi_nan_sec_ctx_id_field_t
;
1337 /* nan2 security context identifier info attribute field */
1338 typedef BWL_PRE_PACKED_STRUCT
struct wifi_nan_sec_ctx_id_info_attr_s
{
1339 uint8 attr_id
; /* 0x23 - NAN_ATTR_SEC_CTX_ID_INFO */
1341 uint8 var
[]; /* security context identifier list */
1342 } BWL_POST_PACKED_STRUCT wifi_nan_sec_ctx_id_info_attr_t
;
1345 * Nan shared key descriptor attribute
1346 * WFA Tech. Spec ver 23
1349 #define NAN_SEC_NCSSK_DESC_REPLAY_CNT_LEN 8
1350 #define NAN_SEC_NCSSK_DESC_KEY_NONCE_LEN 32
1352 /* nan shared key descriptor attr field */
1353 typedef BWL_PRE_PACKED_STRUCT
struct wifi_nan_sec_ncssk_key_desc_attr_s
{
1354 uint8 attr_id
; /* 0x24 - NAN_ATTR_SHARED_KEY_DESC */
1356 uint8 inst_id
; /* Publish service instance ID */
1360 uint8 key_replay_cntr
[NAN_SEC_NCSSK_DESC_REPLAY_CNT_LEN
];
1361 uint8 key_nonce
[NAN_SEC_NCSSK_DESC_KEY_NONCE_LEN
];
1362 uint8 reserved
[32]; /* EAPOL IV + Key RSC + Rsvd fields in EAPOL Key */
1363 uint8 mic
[]; /* mic + key data len + key data */
1364 } BWL_POST_PACKED_STRUCT wifi_nan_sec_ncssk_key_desc_attr_t
;
1366 /* Key Info fields */
1367 #define NAN_SEC_NCSSK_DESC_MASK 0x7
1368 #define NAN_SEC_NCSSK_DESC_SHIFT 0
1369 #define NAN_SEC_NCSSK_DESC_KEY_TYPE_MASK 0x8
1370 #define NAN_SEC_NCSSK_DESC_KEY_TYPE_SHIFT 3
1371 #define NAN_SEC_NCSSK_DESC_KEY_INSTALL_MASK 0x40
1372 #define NAN_SEC_NCSSK_DESC_KEY_INSTALL_SHIFT 6
1373 #define NAN_SEC_NCSSK_DESC_KEY_ACK_MASK 0x80
1374 #define NAN_SEC_NCSSK_DESC_KEY_ACK_SHIFT 7
1375 #define NAN_SEC_NCSSK_DESC_KEY_MIC_MASK 0x100
1376 #define NAN_SEC_NCSSK_DESC_KEY_MIC_SHIFT 8
1377 #define NAN_SEC_NCSSK_DESC_KEY_SEC_MASK 0x200
1378 #define NAN_SEC_NCSSK_DESC_KEY_SEC_SHIFT 9
1379 #define NAN_SEC_NCSSK_DESC_KEY_ERR_MASK 0x400
1380 #define NAN_SEC_NCSSK_DESC_KEY_ERR_SHIFT 10
1381 #define NAN_SEC_NCSSK_DESC_KEY_REQ_MASK 0x800
1382 #define NAN_SEC_NCSSK_DESC_KEY_REQ_SHIFT 11
1383 #define NAN_SEC_NCSSK_DESC_KEY_ENC_KEY_MASK 0x1000
1384 #define NAN_SEC_NCSSK_DESC_KEY_ENC_KEY_SHIFT 12
1385 #define NAN_SEC_NCSSK_DESC_KEY_SMK_MSG_MASK 0x2000
1386 #define NAN_SEC_NCSSK_DESC_KEY_SMK_MSG_SHIFT 13
1388 /* Key Info get & set macros */
1389 #define NAN_SEC_NCSSK_KEY_DESC_VER_GET(_key_info) \
1390 (((_key_info) & NAN_SEC_NCSSK_DESC_MASK) >> NAN_SEC_NCSSK_DESC_SHIFT)
1391 #define NAN_SEC_NCSSK_KEY_DESC_VER_SET(_val, _key_info) \
1392 do {(_key_info) &= ~NAN_SEC_NCSSK_DESC_MASK; \
1393 (_key_info) |= (((_val) << NAN_SEC_NCSSK_DESC_SHIFT) & \
1394 NAN_SEC_NCSSK_DESC_MASK);} while (0)
1395 #define NAN_SEC_NCSSK_DESC_KEY_TYPE_GET(_key_info) \
1396 (((_key_info) & NAN_SEC_NCSSK_DESC_KEY_TYPE_MASK) >> NAN_SEC_NCSSK_DESC_KEY_TYPE_SHIFT)
1397 #define NAN_SEC_NCSSK_DESC_KEY_TYPE_SET(_val, _key_info) \
1398 do {(_key_info) &= ~NAN_SEC_NCSSK_DESC_KEY_TYPE_MASK; \
1399 (_key_info) |= (((_val) << NAN_SEC_NCSSK_DESC_KEY_TYPE_SHIFT) & \
1400 NAN_SEC_NCSSK_DESC_KEY_TYPE_MASK);} while (0)
1401 #define NAN_SEC_NCSSK_DESC_KEY_INSTALL_GET(_key_info) \
1402 (((_key_info) & NAN_SEC_NCSSK_DESC_KEY_INSTALL_MASK) >> \
1403 NAN_SEC_NCSSK_DESC_KEY_INSTALL_SHIFT)
1404 #define NAN_SEC_NCSSK_DESC_KEY_INSTALL_SET(_val, _key_info) \
1405 do {(_key_info) &= ~NAN_SEC_NCSSK_DESC_KEY_INSTALL_MASK; \
1406 (_key_info) |= (((_val) << NAN_SEC_NCSSK_DESC_KEY_INSTALL_SHIFT) & \
1407 NAN_SEC_NCSSK_DESC_KEY_INSTALL_MASK);} while (0)
1408 #define NAN_SEC_NCSSK_DESC_KEY_ACK_GET(_key_info) \
1409 (((_key_info) & NAN_SEC_NCSSK_DESC_KEY_ACK_MASK) >> NAN_SEC_NCSSK_DESC_KEY_ACK_SHIFT)
1410 #define NAN_SEC_NCSSK_DESC_KEY_ACK_SET(_val, _key_info) \
1411 do {(_key_info) &= ~NAN_SEC_NCSSK_DESC_KEY_ACK_MASK; \
1412 (_key_info) |= (((_val) << NAN_SEC_NCSSK_DESC_KEY_ACK_SHIFT) & \
1413 NAN_SEC_NCSSK_DESC_KEY_ACK_MASK);} while (0)
1414 #define NAN_SEC_NCSSK_DESC_KEY_MIC_GET(_key_info) \
1415 (((_key_info) & NAN_SEC_NCSSK_DESC_KEY_MIC_MASK) >> NAN_SEC_NCSSK_DESC_KEY_MIC_SHIFT)
1416 #define NAN_SEC_NCSSK_DESC_KEY_MIC_SET(_val, _key_info) \
1417 do {(_key_info) &= ~NAN_SEC_NCSSK_DESC_KEY_MIC_MASK; \
1418 (_key_info) |= (((_val) << NAN_SEC_NCSSK_DESC_KEY_MIC_SHIFT) & \
1419 NAN_SEC_NCSSK_DESC_KEY_MIC_MASK);} while (0)
1420 #define NAN_SEC_NCSSK_DESC_KEY_SEC_GET(_key_info) \
1421 (((_key_info) & NAN_SEC_NCSSK_DESC_KEY_SEC_MASK) >> NAN_SEC_NCSSK_DESC_KEY_SEC_SHIFT)
1422 #define NAN_SEC_NCSSK_DESC_KEY_SEC_SET(_val, _key_info) \
1423 do {(_key_info) &= ~NAN_SEC_NCSSK_DESC_KEY_SEC_MASK; \
1424 (_key_info) |= (((_val) << NAN_SEC_NCSSK_DESC_KEY_SEC_SHIFT) & \
1425 NAN_SEC_NCSSK_DESC_KEY_SEC_MASK);} while (0)
1426 #define NAN_SEC_NCSSK_DESC_KEY_ERR_GET(_key_info) \
1427 (((_key_info) & NAN_SEC_NCSSK_DESC_KEY_ERR_MASK) >> NAN_SEC_NCSSK_DESC_KEY_ERR_SHIFT)
1428 #define NAN_SEC_NCSSK_DESC_KEY_ERR_SET(_val, _key_info) \
1429 do {(_key_info) &= ~NAN_SEC_NCSSK_DESC_KEY_ERR_MASK; \
1430 (_key_info) |= (((_val) << NAN_SEC_NCSSK_DESC_KEY_ERR_SHIFT) & \
1431 NAN_SEC_NCSSK_DESC_KEY_ERR_MASK);} while (0)
1432 #define NAN_SEC_NCSSK_DESC_KEY_REQ_GET(_key_info) \
1433 (((_key_info) & NAN_SEC_NCSSK_DESC_KEY_REQ_MASK) >> NAN_SEC_NCSSK_DESC_KEY_REQ_SHIFT)
1434 #define NAN_SEC_NCSSK_DESC_KEY_REQ_SET(_val, _key_info) \
1435 do {(_key_info) &= ~NAN_SEC_NCSSK_DESC_KEY_REQ_MASK; \
1436 (_key_info) |= (((_val) << NAN_SEC_NCSSK_DESC_KEY_REQ_SHIFT) & \
1437 NAN_SEC_NCSSK_DESC_KEY_REQ_MASK);} while (0)
1438 #define NAN_SEC_NCSSK_DESC_KEY_ENC_KEY_GET(_key_info) \
1439 (((_key_info) & NAN_SEC_NCSSK_DESC_KEY_ENC_KEY_MASK) >> \
1440 NAN_SEC_NCSSK_DESC_KEY_ENC_KEY_SHIFT)
1441 #define NAN_SEC_NCSSK_DESC_KEY_ENC_KEY_SET(_val, _key_info) \
1442 do {(_key_info) &= ~NAN_SEC_NCSSK_DESC_KEY_ENC_KEY_MASK; \
1443 (_key_info) |= (((_val) << NAN_SEC_NCSSK_DESC_KEY_ENC_KEY_SHIFT) & \
1444 NAN_SEC_NCSSK_DESC_KEY_ENC_KEY_MASK);} while (0)
1445 #define NAN_SEC_NCSSK_DESC_KEY_SMK_MSG_GET(_key_info) \
1446 (((_key_info) & NAN_SEC_NCSSK_DESC_KEY_SMK_MSG_MASK) >> \
1447 NAN_SEC_NCSSK_DESC_KEY_SMK_MSG_SHIFT)
1448 #define NAN_SEC_NCSSK_DESC_KEY_SMK_MSG_SET(_val, _key_info) \
1449 do {(_key_info) &= ~NAN_SEC_NCSSK_DESC_KEY_SMK_MSG_MASK; \
1450 (_key_info) |= (((_val) << NAN_SEC_NCSSK_DESC_KEY_SMK_MSG_SHIFT) & \
1451 NAN_SEC_NCSSK_DESC_KEY_SMK_MSG_MASK);} while (0)
1453 #define NAN_SEC_NCSSK_IEEE80211_KDESC_TYPE 2 /* IEEE 802.11 Key Descriptor Type */
1454 #define NAN_SEC_NCSSK_KEY_DESC_VER 0 /* NCSSK-128/256 */
1455 #define NAN_SEC_NCSSK_KEY_TYPE_PAIRWISE 1 /* Pairwise */
1456 #define NAN_SEC_NCSSK_LIFETIME_KDE 7 /* Lifetime KDE type */
1458 /* TODO include MTK related attributes */
1460 /* NAN Multicast service group(NMSG) definitions */
1461 /* Length of NMSG_ID -- (NDI * 2^16 + pub_id * 2^8 + Random_factor) */
1462 #define NAN_NMSG_ID_LEN 8
1464 #define NAN_NMSG_TYPE_MASK 0x0F
1465 #define NMSG_ATTR_TYPE_STATUS_REQUEST 0x00
1466 #define NMSG_ATTR_TYPE_STATUS_RESPONSE 0x01
1467 #define NMSG_ATTR_TYPE_STATUS_CONFIRM 0x02
1468 #define NMSG_ATTR_TYPE_STATUS_SEC_INSTALL 0x03
1469 #define NMSG_ATTR_TYPE_STATUS_TERMINATE 0x04
1470 #define NMSG_ATTR_TYPE_STATUS_IMPLICIT_ENROL 0x05
1472 #define NMSG_ATTR_TYPE_STATUS_CONTINUED 0x00
1473 #define NMSG_ATTR_TYPE_STATUS_ACCEPTED 0x10
1474 #define NMSG_ATTR_TYPE_STATUS_REJECTED 0x20
1476 #define NMSG_CTRL_PUB_ID_PRESENT 0x0001
1477 #define NMSG_CTRL_NMSG_ID_PRESENT 0x0002
1478 #define NMSG_CTRL_SECURITY_PRESENT 0x0004
1479 #define NMSG_CTRL_MANY_TO_MANY_PRESENT 0x0008
1480 #define NMSG_CTRL_SVC_INFO_PRESENT 0x0010
1482 /* NMSG attribute */
1483 typedef BWL_PRE_PACKED_STRUCT
struct wifi_nan_nmsg_attr_s
{
1484 uint8 id
; /* Attribute ID - 0x11 */
1485 uint16 len
; /* Length including pubid, NMSGID and svc info */
1487 uint8 type_status
; /* Type and Status field byte */
1489 uint8 mc_id
; /* Multicast id similar to NDPID */
1490 uint8 nmsg_ctrl
; /* NMSG control field */
1491 /* Optional publish id, NMSGID and svc info are included in var[] */
1493 } BWL_POST_PACKED_STRUCT wifi_nan_nmsg_attr_t
;
1495 #define NMSG_ATTR_MCAST_SCHED_MAP_ID_MASK 0x1E
1496 #define NMSG_ATTR_MCAST_SCHED_MAP_ID_SHIFT 1
1497 #define NMSG_ATTR_MCAST_SCHED_TIME_MAP_MASK 0x20
1498 #define NMSG_ATTR_MCAST_SCHED_TIME_MAP_SHIFT 5
1500 /* NAN Multicast Schedule atribute structure */
1501 typedef BWL_PRE_PACKED_STRUCT
struct wifi_nan_mcast_sched_attr_s
{
1502 uint8 id
; /* 0x16 */
1504 uint8 nmsg_id
[NAN_NMSG_ID_LEN
];
1506 uint8 sched_own
[ETHER_ADDR_LEN
];
1507 uint8 var
[]; /* multicast sched entry list (schedule_entry_list) */
1508 } BWL_POST_PACKED_STRUCT wifi_nan_mcast_sched_attr_t
;
1510 /* FAC Channel Entry (section 10.7.19.1.5) */
1511 typedef BWL_PRE_PACKED_STRUCT
struct wifi_nan_fac_chan_entry_s
{
1512 uint8 oper_class
; /* Operating Class */
1513 uint16 chan_bitmap
; /* Channel Bitmap */
1514 uint8 primary_chan_bmp
; /* Primary Channel Bitmap */
1515 uint16 aux_chan
; /* Auxiliary Channel bitmap */
1516 } BWL_POST_PACKED_STRUCT wifi_nan_fac_chan_entry_t
;
1518 /* TODO move this from nan.h */
1519 #define NAN_ALL_NAN_MGMT_FRAMES (NAN_FRM_SCHED_AF | \
1520 NAN_FRM_NDP_AF | NAN_FRM_NDL_AF | \
1521 NAN_FRM_DISC_BCN | NAN_FRM_SYNC_BCN | \
1522 NAN_FRM_SVC_DISC | NAN_FRM_RNG_REQ_AF | \
1523 NAN_FRM_RNG_RESP_AF | NAN_FRM_RNG_REPORT_AF | \
1524 NAN_FRM_RNG_TERM_AF)
1526 /* This marks the end of a packed structure section. */
1527 #include <packed_section_end.h>
1529 #endif /* _NAN_H_ */