nan.h 57 KB

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