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