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