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