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