• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2014 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef __NAN_I_H__
18 #define __NAN_I_H__
19 
20 #include "common.h"
21 #include "cpp_bindings.h"
22 #include "wifi_hal.h"
23 
24 #ifdef __cplusplus
25 extern "C"
26 {
27 #endif /* __cplusplus */
28 
29 #ifndef PACKED
30 #define PACKED  __attribute__((packed))
31 #endif
32 #define BIT_NONE            0x00
33 #define BIT_0               0x01
34 #define BIT_1               0x02
35 #define BIT_2               0x04
36 #define BIT_3               0x08
37 #define BIT_4               0x10
38 #define BIT_5               0x20
39 #define BIT_6               0x40
40 #define BIT_7               0x80
41 #define BIT_8               0x0100
42 #define BIT_9               0x0200
43 #define BIT_10              0x0400
44 #define BIT_11              0x0800
45 #define BIT_12              0x1000
46 #define BIT_13              0x2000
47 #define BIT_14              0x4000
48 #define BIT_15              0x8000
49 #define BIT_16              0x010000
50 #define BIT_17              0x020000
51 #define BIT_18              0x040000
52 #define BIT_19              0x080000
53 #define BIT_20              0x100000
54 #define BIT_21              0x200000
55 #define BIT_22              0x400000
56 #define BIT_23              0x800000
57 #define BIT_24              0x01000000
58 #define BIT_25              0x02000000
59 #define BIT_26              0x04000000
60 #define BIT_27              0x08000000
61 #define BIT_28              0x10000000
62 #define BIT_29              0x20000000
63 #define BIT_30              0x40000000
64 #define BIT_31              0x80000000
65 
66 /** macro to convert FW MAC address from WMI word format to User Space MAC char array */
67 #define FW_MAC_ADDR_TO_CHAR_ARRAY(fw_mac_addr, mac_addr) do { \
68      (mac_addr)[0] =    ((fw_mac_addr).mac_addr31to0) & 0xff; \
69      (mac_addr)[1] =  (((fw_mac_addr).mac_addr31to0) >> 8) & 0xff; \
70      (mac_addr)[2] =  (((fw_mac_addr).mac_addr31to0) >> 16) & 0xff; \
71      (mac_addr)[3] =  (((fw_mac_addr).mac_addr31to0) >> 24) & 0xff; \
72      (mac_addr)[4] =    ((fw_mac_addr).mac_addr47to32) & 0xff; \
73      (mac_addr)[5] =  (((fw_mac_addr).mac_addr47to32) >> 8) & 0xff; \
74 } while (0)
75 
76 /** macro to convert User space MAC address from char array to FW WMI word format */
77 #define CHAR_ARRAY_TO_MAC_ADDR(mac_addr, fw_mac_addr)  do { \
78     (fw_mac_addr).mac_addr31to0  =                   \
79          ((mac_addr)[0] | ((mac_addr)[1] << 8)            \
80            | ((mac_addr)[2] << 16) | ((mac_addr)[3] << 24));          \
81     (fw_mac_addr).mac_addr47to32  =                  \
82          ((mac_addr)[4] | ((mac_addr)[5] << 8));          \
83 } while (0)
84 
85 /*---------------------------------------------------------------------------
86 * WLAN NAN CONSTANTS
87 *--------------------------------------------------------------------------*/
88 
89 typedef enum
90 {
91     NAN_MSG_ID_ERROR_RSP                    = 0,
92     NAN_MSG_ID_CONFIGURATION_REQ            = 1,
93     NAN_MSG_ID_CONFIGURATION_RSP            = 2,
94     NAN_MSG_ID_PUBLISH_SERVICE_REQ          = 3,
95     NAN_MSG_ID_PUBLISH_SERVICE_RSP          = 4,
96     NAN_MSG_ID_PUBLISH_SERVICE_CANCEL_REQ   = 5,
97     NAN_MSG_ID_PUBLISH_SERVICE_CANCEL_RSP   = 6,
98     NAN_MSG_ID_PUBLISH_REPLIED_IND          = 7,
99     NAN_MSG_ID_PUBLISH_TERMINATED_IND       = 8,
100     NAN_MSG_ID_SUBSCRIBE_SERVICE_REQ        = 9,
101     NAN_MSG_ID_SUBSCRIBE_SERVICE_RSP        = 10,
102     NAN_MSG_ID_SUBSCRIBE_SERVICE_CANCEL_REQ = 11,
103     NAN_MSG_ID_SUBSCRIBE_SERVICE_CANCEL_RSP = 12,
104     NAN_MSG_ID_MATCH_IND                    = 13,
105     NAN_MSG_ID_MATCH_EXPIRED_IND            = 14,
106     NAN_MSG_ID_SUBSCRIBE_TERMINATED_IND     = 15,
107     NAN_MSG_ID_DE_EVENT_IND                 = 16,
108     NAN_MSG_ID_TRANSMIT_FOLLOWUP_REQ        = 17,
109     NAN_MSG_ID_TRANSMIT_FOLLOWUP_RSP        = 18,
110     NAN_MSG_ID_FOLLOWUP_IND                 = 19,
111     NAN_MSG_ID_STATS_REQ                    = 20,
112     NAN_MSG_ID_STATS_RSP                    = 21,
113     NAN_MSG_ID_ENABLE_REQ                   = 22,
114     NAN_MSG_ID_ENABLE_RSP                   = 23,
115     NAN_MSG_ID_DISABLE_REQ                  = 24,
116     NAN_MSG_ID_DISABLE_RSP                  = 25,
117     NAN_MSG_ID_DISABLE_IND                  = 26,
118     NAN_MSG_ID_TCA_REQ                      = 27,
119     NAN_MSG_ID_TCA_RSP                      = 28,
120     NAN_MSG_ID_TCA_IND                      = 29,
121     NAN_MSG_ID_BEACON_SDF_REQ               = 30,
122     NAN_MSG_ID_BEACON_SDF_RSP               = 31,
123     NAN_MSG_ID_BEACON_SDF_IND               = 32,
124     NAN_MSG_ID_CAPABILITIES_REQ             = 33,
125     NAN_MSG_ID_CAPABILITIES_RSP             = 34,
126     NAN_MSG_ID_SELF_TRANSMIT_FOLLOWUP_IND   = 35,
127     NAN_MSG_ID_RANGING_REQUEST_RECEVD_IND   = 36,
128     NAN_MSG_ID_RANGING_RESULT_IND           = 37,
129     NAN_MSG_ID_TESTMODE_REQ                 = 1025,
130     NAN_MSG_ID_TESTMODE_RSP                 = 1026
131 } NanMsgId;
132 
133 /*
134   Various TLV Type ID sent as part of NAN Stats Response
135   or NAN TCA Indication
136 */
137 typedef enum
138 {
139     NAN_TLV_TYPE_FIRST = 0,
140 
141     /* Service Discovery Frame types */
142     NAN_TLV_TYPE_SDF_FIRST = NAN_TLV_TYPE_FIRST,
143     NAN_TLV_TYPE_SERVICE_NAME = NAN_TLV_TYPE_SDF_FIRST,
144     NAN_TLV_TYPE_SDF_MATCH_FILTER,
145     NAN_TLV_TYPE_TX_MATCH_FILTER,
146     NAN_TLV_TYPE_RX_MATCH_FILTER,
147     NAN_TLV_TYPE_SERVICE_SPECIFIC_INFO,
148     NAN_TLV_TYPE_EXT_SERVICE_SPECIFIC_INFO =5,
149     NAN_TLV_TYPE_VENDOR_SPECIFIC_ATTRIBUTE_TRANSMIT = 6,
150     NAN_TLV_TYPE_VENDOR_SPECIFIC_ATTRIBUTE_RECEIVE = 7,
151     NAN_TLV_TYPE_POST_NAN_CONNECTIVITY_CAPABILITIES_RECEIVE = 8,
152     NAN_TLV_TYPE_POST_NAN_DISCOVERY_ATTRIBUTE_RECEIVE = 9,
153     NAN_TLV_TYPE_BEACON_SDF_PAYLOAD_RECEIVE = 10,
154     NAN_TLV_TYPE_NAN_DATA_PATH_PARAMS = 11,
155     NAN_TLV_TYPE_NAN_DATA_SUPPORTED_BAND = 12,
156     NAN_TLV_TYPE_2G_COMMITTED_DW = 13,
157     NAN_TLV_TYPE_5G_COMMITTED_DW = 14,
158     NAN_TLV_TYPE_NAN_DATA_RESPONDER_MODE = 15,
159     NAN_TLV_TYPE_NAN_DATA_ENABLED_IN_MATCH = 16,
160     NAN_TLV_TYPE_NAN_SERVICE_ACCEPT_POLICY = 17,
161     NAN_TLV_TYPE_NAN_CSID = 18,
162     NAN_TLV_TYPE_NAN_SCID = 19,
163     NAN_TLV_TYPE_NAN_PMK = 20,
164     NAN_TLV_TYPE_SDEA_CTRL_PARAMS = 21,
165     NAN_TLV_TYPE_NAN_RANGING_CFG = 22,
166     NAN_TLV_TYPE_CONFIG_DISCOVERY_INDICATIONS = 23,
167     NAN_TLV_TYPE_NAN20_RANGING_REQUEST = 24,
168     NAN_TLV_TYPE_NAN20_RANGING_RESULT = 25,
169     NAN_TLV_TYPE_NAN20_RANGING_REQUEST_RECEIVED = 26,
170     NAN_TLV_TYPE_NAN_PASSPHRASE = 27,
171     NAN_TLV_TYPE_SDEA_SERVICE_SPECIFIC_INFO = 28,
172     NAN_TLV_TYPE_DEV_CAP_ATTR_CAPABILITY = 29,
173     NAN_TLV_TYPE_SDF_LAST = 4095,
174 
175     /* Configuration types */
176     NAN_TLV_TYPE_CONFIG_FIRST = 4096,
177     NAN_TLV_TYPE_24G_SUPPORT = NAN_TLV_TYPE_CONFIG_FIRST,
178     NAN_TLV_TYPE_24G_BEACON,
179     NAN_TLV_TYPE_24G_SDF,
180     NAN_TLV_TYPE_24G_RSSI_CLOSE,
181     NAN_TLV_TYPE_24G_RSSI_MIDDLE = 4100,
182     NAN_TLV_TYPE_24G_RSSI_CLOSE_PROXIMITY,
183     NAN_TLV_TYPE_5G_SUPPORT,
184     NAN_TLV_TYPE_5G_BEACON,
185     NAN_TLV_TYPE_5G_SDF,
186     NAN_TLV_TYPE_5G_RSSI_CLOSE,
187     NAN_TLV_TYPE_5G_RSSI_MIDDLE,
188     NAN_TLV_TYPE_5G_RSSI_CLOSE_PROXIMITY,
189     NAN_TLV_TYPE_SID_BEACON,
190     NAN_TLV_TYPE_HOP_COUNT_LIMIT,
191     NAN_TLV_TYPE_MASTER_PREFERENCE = 4110,
192     NAN_TLV_TYPE_CLUSTER_ID_LOW,
193     NAN_TLV_TYPE_CLUSTER_ID_HIGH,
194     NAN_TLV_TYPE_RSSI_AVERAGING_WINDOW_SIZE,
195     NAN_TLV_TYPE_CLUSTER_OUI_NETWORK_ID,
196     NAN_TLV_TYPE_SOURCE_MAC_ADDRESS,
197     NAN_TLV_TYPE_CLUSTER_ATTRIBUTE_IN_SDF,
198     NAN_TLV_TYPE_SOCIAL_CHANNEL_SCAN_PARAMS,
199     NAN_TLV_TYPE_DEBUGGING_FLAGS,
200     NAN_TLV_TYPE_POST_NAN_CONNECTIVITY_CAPABILITIES_TRANSMIT,
201     NAN_TLV_TYPE_POST_NAN_DISCOVERY_ATTRIBUTE_TRANSMIT = 4120,
202     NAN_TLV_TYPE_FURTHER_AVAILABILITY_MAP,
203     NAN_TLV_TYPE_HOP_COUNT_FORCE,
204     NAN_TLV_TYPE_RANDOM_FACTOR_FORCE,
205     NAN_TLV_TYPE_RANDOM_UPDATE_TIME = 4124,
206     NAN_TLV_TYPE_EARLY_WAKEUP,
207     NAN_TLV_TYPE_PERIODIC_SCAN_INTERVAL,
208     NAN_TLV_TYPE_DW_INTERVAL = 4128,
209     NAN_TLV_TYPE_DB_INTERVAL,
210     NAN_TLV_TYPE_FURTHER_AVAILABILITY,
211     NAN_TLV_TYPE_24G_CHANNEL,
212     NAN_TLV_TYPE_5G_CHANNEL,
213     NAN_TLV_TYPE_DISC_MAC_ADDR_RANDOM_INTERVAL,
214     NAN_TLV_TYPE_RANGING_AUTO_RESPONSE_CFG = 4134,
215     NAN_TLV_TYPE_SUBSCRIBE_SID_BEACON = 4135,
216     NAN_TLV_TYPE_DW_EARLY_TERMINATION = 4136,
217     NAN_TLV_TYPE_TX_RX_CHAINS = 4137,
218     NAN_TLV_TYPE_ENABLE_DEVICE_RANGING = 4138,
219     NAN_TLV_TYPE_CONFIG_LAST = 8191,
220 
221     /* Attributes types */
222     NAN_TLV_TYPE_ATTRS_FIRST = 8192,
223     NAN_TLV_TYPE_AVAILABILITY_INTERVALS_MAP = NAN_TLV_TYPE_ATTRS_FIRST,
224     NAN_TLV_TYPE_WLAN_MESH_ID,
225     NAN_TLV_TYPE_MAC_ADDRESS,
226     NAN_TLV_TYPE_RECEIVED_RSSI_VALUE,
227     NAN_TLV_TYPE_CLUSTER_ATTRIBUTE,
228     NAN_TLV_TYPE_WLAN_INFRA_SSID,
229     NAN_TLV_TYPE_ATTRS_LAST = 12287,
230 
231     /* Events Type */
232     NAN_TLV_TYPE_EVENTS_FIRST = 12288,
233     NAN_TLV_TYPE_EVENT_SELF_STATION_MAC_ADDRESS = NAN_TLV_TYPE_EVENTS_FIRST,
234     NAN_TLV_TYPE_EVENT_STARTED_CLUSTER,
235     NAN_TLV_TYPE_EVENT_JOINED_CLUSTER,
236     NAN_TLV_TYPE_EVENT_CLUSTER_SCAN_RESULTS,
237     NAN_TLV_TYPE_FAW_MEM_AVAIL,
238     NAN_TLV_TYPE_EVENTS_LAST = 16383,
239 
240     /* TCA types */
241     NAN_TLV_TYPE_TCA_FIRST = 16384,
242     NAN_TLV_TYPE_CLUSTER_SIZE_REQ = NAN_TLV_TYPE_TCA_FIRST,
243     NAN_TLV_TYPE_CLUSTER_SIZE_RSP,
244     NAN_TLV_TYPE_TCA_LAST = 32767,
245 
246     /* Statistics types */
247     NAN_TLV_TYPE_STATS_FIRST = 32768,
248     NAN_TLV_TYPE_DE_PUBLISH_STATS = NAN_TLV_TYPE_STATS_FIRST,
249     NAN_TLV_TYPE_DE_SUBSCRIBE_STATS,
250     NAN_TLV_TYPE_DE_MAC_STATS,
251     NAN_TLV_TYPE_DE_TIMING_SYNC_STATS,
252     NAN_TLV_TYPE_DE_DW_STATS,
253     NAN_TLV_TYPE_DE_STATS,
254     NAN_TLV_TYPE_STATS_LAST = 36863,
255 
256     /* Testmode types */
257     NAN_TLV_TYPE_TESTMODE_FIRST = 36864,
258     NAN_TLV_TYPE_TESTMODE_GENERIC_CMD = NAN_TLV_TYPE_TESTMODE_FIRST,
259     NAN_TLV_TYPE_TESTMODE_LAST = 37000,
260 
261     NAN_TLV_TYPE_LAST = 65535
262 } NanTlvType;
263 
264 /* 8-byte control message header used by NAN*/
265 typedef struct PACKED
266 {
267    u16 msgVersion:4;
268    u16 msgId:12;
269    u16 msgLen;
270    u16 handle;
271    u16 transactionId;
272 } NanMsgHeader, *pNanMsgHeader;
273 
274 /* Enumeration for Version */
275 typedef enum
276 {
277    NAN_MSG_VERSION1 = 1,
278 }NanMsgVersion;
279 
280 typedef struct PACKED
281 {
282     u16 type;
283     u16 length;
284     u8* value;
285 } NanTlv, *pNanTlv;
286 
287 #define SIZEOF_TLV_HDR (sizeof(NanTlv::type) + sizeof(NanTlv::length))
288 /* NAN TLV Groups and Types */
289 typedef enum
290 {
291     NAN_TLV_GROUP_FIRST = 0,
292     NAN_TLV_GROUP_SDF = NAN_TLV_GROUP_FIRST,
293     NAN_TLV_GROUP_CONFIG,
294     NAN_TLV_GROUP_STATS,
295     NAN_TLV_GROUP_ATTRS,
296     NAN_TLV_NUM_GROUPS,
297     NAN_TLV_GROUP_LAST = NAN_TLV_NUM_GROUPS
298 } NanTlvGroup;
299 
300 /* NAN Miscellaneous Constants */
301 #define NAN_TTL_INFINITE            0
302 #define NAN_REPLY_COUNT_INFINITE    0
303 
304 /* NAN Confguration 5G Channel Access Bit */
305 #define NAN_5G_CHANNEL_ACCESS_UNSUPPORTED   0
306 #define NAN_5G_CHANNEL_ACCESS_SUPPORTED     1
307 
308 /* NAN Configuration Service IDs Enclosure Bit */
309 #define NAN_SIDS_NOT_ENCLOSED_IN_BEACONS    0
310 #define NAN_SIBS_ENCLOSED_IN_BEACONS        1
311 
312 /* NAN Configuration Priority */
313 #define NAN_CFG_PRIORITY_SERVICE_DISCOVERY  0
314 #define NAN_CFG_PRIORITY_DATA_CONNECTION    1
315 
316 /* NAN Configuration 5G Channel Usage */
317 #define NAN_5G_CHANNEL_USAGE_SYNC_AND_DISCOVERY 0
318 #define NAN_5G_CHANNEL_USAGE_DISCOVERY_ONLY     1
319 
320 /* NAN Configuration TX_Beacon Content */
321 #define NAN_TX_BEACON_CONTENT_OLD_AM_INFO       0
322 #define NAN_TX_BEACON_CONTENT_UPDATED_AM_INFO   1
323 
324 /* NAN Configuration Miscellaneous Constants */
325 #define NAN_MAC_INTERFACE_PERIODICITY_MIN   30
326 #define NAN_MAC_INTERFACE_PERIODICITY_MAX   255
327 
328 #define NAN_DW_RANDOM_TIME_MIN  120
329 #define NAN_DW_RANDOM_TIME_MAX  240
330 
331 #define NAN_INITIAL_SCAN_MIN_IDEAL_PERIOD   200
332 #define NAN_INITIAL_SCAN_MAX_IDEAL_PERIOD   300
333 
334 #define NAN_ONGOING_SCAN_MIN_PERIOD 10
335 #define NAN_ONGOING_SCAN_MAX_PERIOD 30
336 
337 #define NAN_HOP_COUNT_LIMIT 5
338 
339 #define NAN_WINDOW_DW   0
340 #define NAN_WINDOW_FAW  1
341 
342 /* NAN Error Rsp */
343 typedef struct PACKED
344 {
345     NanMsgHeader fwHeader;
346     u16 status;
347     u16 value;
348 } NanErrorRspMsg, *pNanErrorRspMsg;
349 
350 //* NAN Publish Service Req */
351 typedef struct PACKED
352 {
353     u16 ttl;
354     u16 period;
355     u32 replyIndFlag:1;
356     u32 publishType:2;
357     u32 txType:1;
358     u32 rssiThresholdFlag:1;
359     u32 ota_flag:1;
360     u32 matchAlg:2;
361     u32 count:8;
362     u32 connmap:8;
363     u32 pubTerminatedIndDisableFlag:1;
364     u32 pubMatchExpiredIndDisableFlag:1;
365     u32 followupRxIndDisableFlag:1;
366     u32 reserved2:5;
367     /*
368      * Excludes TLVs
369      *
370      * Required: Service Name,
371      * Optional: Tx Match Filter, Rx Match Filter, Service Specific Info,
372      */
373 } NanPublishServiceReqParams, *pNanPublishServiceReqParams;
374 
375 typedef struct PACKED
376 {
377     NanMsgHeader fwHeader;
378     NanPublishServiceReqParams publishServiceReqParams;
379     u8 ptlv[];
380 } NanPublishServiceReqMsg, *pNanPublishServiceReqMsg;
381 
382 /* NAN Publish Service Rsp */
383 typedef struct PACKED
384 {
385     NanMsgHeader fwHeader;
386     /* status of the request */
387     u16 status;
388     u16 value;
389 } NanPublishServiceRspMsg, *pNanPublishServiceRspMsg;
390 
391 /* NAN Publish Service Cancel Req */
392 typedef struct PACKED
393 {
394     NanMsgHeader fwHeader;
395 } NanPublishServiceCancelReqMsg, *pNanPublishServiceCancelReqMsg;
396 
397 /* NAN Publish Service Cancel Rsp */
398 typedef struct PACKED
399 {
400     NanMsgHeader fwHeader;
401     /* status of the request */
402     u16 status;
403     u16 value;
404 } NanPublishServiceCancelRspMsg, *pNanPublishServiceCancelRspMsg;
405 
406 /* NAN Publish Terminated Ind */
407 typedef struct PACKED
408 {
409     NanMsgHeader fwHeader;
410     /* reason for the termination */
411     u16 reason;
412     u16 reserved;
413 } NanPublishTerminatedIndMsg, *pNanPublishTerminatedIndMsg;
414 
415 /* Params for NAN Publish Replied Ind */
416 typedef struct PACKED
417 {
418   u32  matchHandle;
419 } NanPublishRepliedIndParams;
420 
421 /* NAN Publish Replied Ind */
422 typedef struct PACKED
423 {
424     NanMsgHeader fwHeader;
425     NanPublishRepliedIndParams publishRepliedIndParams;
426     /*
427      * Excludes TLVs
428      *
429      * Required: MAC Address
430      * Optional: Received RSSI Value
431      *
432      */
433     u8 ptlv[];
434 } NanPublishRepliedIndMsg, *pNanPublishRepliedIndMsg;
435 
436 /* NAN Device Capability Attribute */
437 typedef struct PACKED
438 {
439     u32 dfs_master:1;
440     u32 ext_key_id:1;
441     u32 simu_ndp_data_recept:1;
442     u32 ndpe_attr_supp:1;
443     u32 reserved:28;
444 } NanDevCapAttrCap, *pNanDevCapAttrCap;
445 
446 /* NAN Subscribe Service Req */
447 typedef struct PACKED
448 {
449     u16 ttl;
450     u16 period;
451     u32 subscribeType:1;
452     u32 srfAttr:1;
453     u32 srfInclude:1;
454     u32 srfSend:1;
455     u32 ssiRequired:1;
456     u32 matchAlg:2;
457     u32 xbit:1;
458     u32 count:8;
459     u32 rssiThresholdFlag:1;
460     u32 ota_flag:1;
461     u32 subTerminatedIndDisableFlag:1;
462     u32 subMatchExpiredIndDisableFlag:1;
463     u32 followupRxIndDisableFlag:1;
464     u32 reserved:3;
465     u32 connmap:8;
466     /*
467      * Excludes TLVs
468      *
469      * Required: Service Name
470      * Optional: Rx Match Filter, Tx Match Filter, Service Specific Info,
471      */
472 } NanSubscribeServiceReqParams, *pNanSubscribeServiceReqParams;
473 
474 typedef struct PACKED
475 {
476     NanMsgHeader fwHeader;
477     NanSubscribeServiceReqParams subscribeServiceReqParams;
478     u8 ptlv[];
479 } NanSubscribeServiceReqMsg, *pNanSubscribeServiceReqMsg;
480 
481 /* NAN Subscribe Service Rsp */
482 typedef struct PACKED
483 {
484     NanMsgHeader fwHeader;
485     /* status of the request */
486     u16 status;
487     u16 value;
488 } NanSubscribeServiceRspMsg, *pNanSubscribeServiceRspMsg;
489 
490 /* NAN Subscribe Service Cancel Req */
491 typedef struct PACKED
492 {
493     NanMsgHeader fwHeader;
494 } NanSubscribeServiceCancelReqMsg, *pNanSubscribeServiceCancelReqMsg;
495 
496 /* NAN Subscribe Service Cancel Rsp */
497 typedef struct PACKED
498 {
499     NanMsgHeader fwHeader;
500     /* status of the request */
501     u16 status;
502     u16 value;
503 } NanSubscribeServiceCancelRspMsg, *pNanSubscribeServiceCancelRspMsg;
504 
505 /* NAN Subscribe Match Ind */
506 typedef struct PACKED
507 {
508     u32 matchHandle;
509     u32 matchOccuredFlag:1;
510     u32 outOfResourceFlag:1;
511     u32 reserved:30;
512 } NanMatchIndParams;
513 
514 typedef struct PACKED
515 {
516     NanMsgHeader fwHeader;
517     NanMatchIndParams matchIndParams;
518     u8 ptlv[];
519 } NanMatchIndMsg, *pNanMatchIndMsg;
520 
521 /* NAN Subscribe Unmatch Ind */
522 typedef struct PACKED
523 {
524     u32 matchHandle;
525 } NanmatchExpiredIndParams;
526 
527 typedef struct PACKED
528 {
529     NanMsgHeader fwHeader;
530     NanmatchExpiredIndParams matchExpiredIndParams;
531 } NanMatchExpiredIndMsg, *pNanMatchExpiredIndMsg;
532 
533 /* NAN Subscribe Terminated Ind */
534 typedef struct PACKED
535 {
536     NanMsgHeader fwHeader;
537     /* reason for the termination */
538     u16 reason;
539     u16 reserved;
540 } NanSubscribeTerminatedIndMsg, *pNanSubscribeTerminatedIndMsg;
541 
542 /* Event Ind */
543 typedef struct PACKED
544 {
545     u32 eventId:8;
546     u32 reserved:24;
547 } NanEventIndParams;
548 
549 typedef struct PACKED
550 {
551     NanMsgHeader fwHeader;
552     u8 ptlv[];
553 } NanEventIndMsg, *pNanEventIndMsg;
554 
555 /* NAN Transmit Followup Req */
556 typedef struct PACKED
557 {
558     u32 matchHandle;
559     u32 priority:4;
560     u32 window:1;
561     u32 followupTxRspDisableFlag:1;
562     u32 reserved:26;
563     /*
564      * Excludes TLVs
565      *
566      * Required: Service Specific Info or Extended Service Specific Info
567      */
568 } NanTransmitFollowupReqParams;
569 
570 typedef struct PACKED
571 {
572     NanMsgHeader fwHeader;
573     NanTransmitFollowupReqParams transmitFollowupReqParams;
574     u8 ptlv[];
575 } NanTransmitFollowupReqMsg, *pNanTransmitFollowupReqMsg;
576 
577 /* NAN Transmit Followup Rsp */
578 typedef struct PACKED
579 {
580     NanMsgHeader fwHeader;
581     /* status of the request */
582     u16 status;
583     u16 value;
584 } NanTransmitFollowupRspMsg, *pNanTransmitFollowupRspMsg;
585 
586 /* NAN Publish Followup Ind */
587 typedef struct PACKED
588 {
589     u32 matchHandle;
590     u32 window:1;
591     u32 reserved:31;
592     /*
593      * Excludes TLVs
594      *
595      * Required: Service Specific Info or Extended Service Specific Info
596      */
597 } NanFollowupIndParams;
598 
599 typedef struct PACKED
600 {
601     NanMsgHeader fwHeader;
602     NanFollowupIndParams followupIndParams;
603     u8 ptlv[];
604 } NanFollowupIndMsg, *pNanFollowupIndMsg;
605 
606 /* NAN Statistics Req */
607 typedef struct PACKED
608 {
609     u32 statsType:8;
610     u32 clear:1;
611     u32 reserved:23;
612 } NanStatsReqParams, *pNanStatsReqParams;
613 
614 typedef struct PACKED
615 {
616     NanMsgHeader fwHeader;
617     NanStatsReqParams statsReqParams;
618 } NanStatsReqMsg, *pNanStatsReqMsg;
619 
620 /* NAN Statistics Rsp */
621 typedef struct PACKED
622 {
623     /* status of the request */
624     u16 status;
625     u16 value;
626     u8 statsType;
627     u8 reserved;
628 } NanStatsRspParams, *pNanStatsRspParams;
629 
630 typedef struct PACKED
631 {
632     NanMsgHeader fwHeader;
633     NanStatsRspParams statsRspParams;
634     u8 ptlv[];
635 } NanStatsRspMsg, *pNanStatsRspMsg;
636 
637 typedef struct PACKED
638 {
639     u8 count:7;
640     u8 s:1;
641 } NanSidAttr, *pSidAttr;
642 
643 
644 /* NAN Configuration Req */
645 typedef struct PACKED
646 {
647     NanMsgHeader fwHeader;
648     /*
649      * TLVs:
650      *
651      * Required: None.
652      * Optional: SID, Random Time, Master Preference, WLAN Intra Attr,
653      *           P2P Operation Attr, WLAN IBSS Attr, WLAN Mesh Attr
654      */
655     u8 ptlv[];
656 } NanConfigurationReqMsg, *pNanConfigurationReqMsg;
657 
658 /*
659  * Because the Configuration Req message has TLVs in it use the macro below
660  * for the size argument to buffer allocation functions (vs. sizeof(msg)).
661  */
662 #define NAN_MAX_CONFIGURATION_REQ_SIZE                       \
663     (                                                        \
664         sizeof(NanMsgHeader)                             +   \
665         SIZEOF_TLV_HDR + sizeof(u8)  /* SID Beacon    */ +   \
666         SIZEOF_TLV_HDR + sizeof(u8)  /* Random Time   */ +   \
667         SIZEOF_TLV_HDR + sizeof(u8)  /* Master Pref   */     \
668     )
669 
670 /* NAN Configuration Rsp */
671 typedef struct PACKED
672 {
673     NanMsgHeader fwHeader;
674     /* status of the request */
675     u16 status;
676     u16 value;
677 } NanConfigurationRspMsg, *pNanConfigurationRspMsg;
678 
679 /*
680  * Because the Enable Req message has TLVs in it use the macro below for
681  * the size argument to buffer allocation functions (vs. sizeof(msg)).
682  */
683 #define NAN_MAX_ENABLE_REQ_SIZE                                 \
684     (                                                           \
685         sizeof(NanMsgHeader)                                +   \
686         SIZEOF_TLV_HDR + sizeof(u16) /* Cluster Low   */    +   \
687         SIZEOF_TLV_HDR + sizeof(u16) /* Cluster High  */    +   \
688         SIZEOF_TLV_HDR + sizeof(u8)  /* Master Pref   */        \
689     )
690 
691 /* Config Discovery Indication */
692  typedef struct PACKED
693  {
694     u32 disableDiscoveryMacAddressEvent:1;
695     u32 disableDiscoveryStartedClusterEvent:1;
696     u32 disableDiscoveryJoinedClusterEvent:1;
697     u32 reserved:29;
698  } NanConfigDiscoveryIndications;
699 
700 /* NAN Enable Req */
701 typedef struct PACKED
702 {
703     NanMsgHeader fwHeader;
704     /*
705      * TLVs:
706      *
707      * Required: Cluster Low, Cluster High, Master Preference,
708      * Optional: 5G Support, SID, 5G Sync Disc, RSSI Close, RSSI Medium,
709      *           Hop Count Limit, Random Time, Master Preference,
710      *           WLAN Intra Attr, P2P Operation Attr, WLAN IBSS Attr,
711      *           WLAN Mesh Attr
712      */
713     u8 ptlv[];
714 } NanEnableReqMsg, *pNanEnableReqMsg;
715 
716 /* NAN Enable Rsp */
717 typedef struct PACKED
718 {
719     NanMsgHeader fwHeader;
720     /* status of the request */
721     u16 status;
722     u16 value;
723 } NanEnableRspMsg, *pNanEnableRspMsg;
724 
725 /* NAN Disable Req */
726 typedef struct PACKED
727 {
728     NanMsgHeader fwHeader;
729 } NanDisableReqMsg, *pNanDisableReqMsg;
730 
731 /* NAN Disable Rsp */
732 typedef struct PACKED
733 {
734     NanMsgHeader fwHeader;
735     /* status of the request */
736     u16 status;
737     u16 reserved;
738 } NanDisableRspMsg, *pNanDisableRspMsg;
739 
740 /* NAN Disable Ind */
741 typedef struct PACKED
742 {
743     NanMsgHeader fwHeader;
744     /* reason for the termination */
745     u16 reason;
746     u16 reserved;
747 } NanDisableIndMsg, *pNanDisableIndMsg;
748 
749 typedef struct PACKED
750 {
751     NanMsgHeader fwHeader;
752     u8 ptlv[];
753 } NanTcaReqMsg, *pNanTcaReqMsg;
754 
755 /* NAN TCA Rsp */
756 typedef struct PACKED
757 {
758     NanMsgHeader   fwHeader;
759     /* status of the request */
760     u16 status;
761     u16 value;
762 } NanTcaRspMsg, *pNanTcaRspMsg;
763 
764 typedef struct PACKED
765 {
766     NanMsgHeader fwHeader;
767     /*
768      * TLVs:
769      *
770      * Optional: Cluster size.
771      */
772     u8 ptlv[];
773 } NanTcaIndMsg, *pNanTcaIndMsg;
774 
775 /*
776  * Because the TCA Ind message has TLVs in it use the macro below for the
777  * size argument to buffer allocation functions (vs. sizeof(msg)).
778  */
779 #define NAN_MAX_TCA_IND_SIZE                                 \
780     (                                                        \
781         sizeof(NanMsgHeader)                             +   \
782         sizeof(NanTcaIndParams)                          +   \
783         SIZEOF_TLV_HDR + sizeof(u16) /* Cluster Size */      \
784     )
785 
786 /* Function Declarations */
787 u8* addTlv(u16 type, u16 length, const u8* value, u8* pOutTlv);
788 u16 NANTLV_ReadTlv(u8 *pInTlv, pNanTlv pOutTlv);
789 u16 NANTLV_WriteTlv(pNanTlv pInTlv, u8 *pOutTlv);
790 
791 /* NAN Beacon Sdf Payload Req */
792 typedef struct PACKED
793 {
794     NanMsgHeader fwHeader;
795     /*
796      * TLVs:
797      *
798      * Optional: Vendor specific attribute
799      */
800     u8 ptlv[];
801 } NanBeaconSdfPayloadReqMsg, *pNanBeaconSdfPayloadReqMsg;
802 
803 /* NAN Beacon Sdf Payload Rsp */
804 typedef struct PACKED
805 {
806     NanMsgHeader   fwHeader;
807     /* status of the request */
808     u16 status;
809     u16 reserved;
810 } NanBeaconSdfPayloadRspMsg, *pNanBeaconSdfPayloadRspMsg;
811 
812 /* NAN Beacon Sdf Payload Ind */
813 typedef struct PACKED
814 {
815     NanMsgHeader fwHeader;
816     /*
817      * TLVs:
818      *
819      * Required: Mac address
820      * Optional: Vendor specific attribute, sdf payload
821      * receive
822      */
823     u8 ptlv[];
824 } NanBeaconSdfPayloadIndMsg, *pNanBeaconSdfPayloadIndMsg;
825 
826 typedef struct PACKED
827 {
828     u8 availIntDuration:2;
829     u8 mapId:4;
830     u8 reserved:2;
831 } NanApiEntryCtrl;
832 
833 /*
834  * Valid Operating Classes were derived from IEEE Std. 802.11-2012 Annex E
835  * Table E-4 Global Operating Classe and, filtered by channel, are: 81, 83,
836  * 84, 103, 114, 115, 116, 124, 125.
837  */
838 typedef struct PACKED
839 {
840     NanApiEntryCtrl entryCtrl;
841     u8 opClass;
842     u8 channel;
843     u8 availIntBitmap[4];
844 } NanFurtherAvailabilityChan, *pNanFurtherAvailabilityChan;
845 
846 typedef struct PACKED
847 {
848     u8 numChan;
849     u8 pFaChan[];
850 } NanFurtherAvailabilityMapAttrTlv, *pNanFurtherAvailabilityMapAttrTlv;
851 
852 /* Publish statistics. */
853 typedef struct PACKED
854 {
855     u32 validPublishServiceReqMsgs;
856     u32 validPublishServiceRspMsgs;
857     u32 validPublishServiceCancelReqMsgs;
858     u32 validPublishServiceCancelRspMsgs;
859     u32 validPublishRepliedIndMsgs;
860     u32 validPublishTerminatedIndMsgs;
861     u32 validActiveSubscribes;
862     u32 validMatches;
863     u32 validFollowups;
864     u32 invalidPublishServiceReqMsgs;
865     u32 invalidPublishServiceCancelReqMsgs;
866     u32 invalidActiveSubscribes;
867     u32 invalidMatches;
868     u32 invalidFollowups;
869     u32 publishCount;
870     u32 publishNewMatchCount;
871     u32 pubsubGlobalNewMatchCount;
872 } FwNanPublishStats, *pFwNanPublishStats;
873 
874 /* Subscribe statistics. */
875 typedef struct PACKED
876 {
877     u32 validSubscribeServiceReqMsgs;
878     u32 validSubscribeServiceRspMsgs;
879     u32 validSubscribeServiceCancelReqMsgs;
880     u32 validSubscribeServiceCancelRspMsgs;
881     u32 validSubscribeTerminatedIndMsgs;
882     u32 validSubscribeMatchIndMsgs;
883     u32 validSubscribeUnmatchIndMsgs;
884     u32 validSolicitedPublishes;
885     u32 validMatches;
886     u32 validFollowups;
887     u32 invalidSubscribeServiceReqMsgs;
888     u32 invalidSubscribeServiceCancelReqMsgs;
889     u32 invalidSubscribeFollowupReqMsgs;
890     u32 invalidSolicitedPublishes;
891     u32 invalidMatches;
892     u32 invalidFollowups;
893     u32 subscribeCount;
894     u32 bloomFilterIndex;
895     u32 subscribeNewMatchCount;
896     u32 pubsubGlobalNewMatchCount;
897 } FwNanSubscribeStats, *pFwNanSubscribeStats;
898 
899 /* NAN MAC Statistics. Used for MAC and DW statistics. */
900 typedef struct PACKED
901 {
902     /* RX stats */
903     u32 validFrames;
904     u32 validActionFrames;
905     u32 validBeaconFrames;
906     u32 ignoredActionFrames;
907     u32 ignoredBeaconFrames;
908     u32 invalidFrames;
909     u32 invalidActionFrames;
910     u32 invalidBeaconFrames;
911     u32 invalidMacHeaders;
912     u32 invalidPafHeaders;
913     u32 nonNanBeaconFrames;
914 
915     u32 earlyActionFrames;
916     u32 inDwActionFrames;
917     u32 lateActionFrames;
918 
919     /* TX stats */
920     u32 framesQueued;
921     u32 totalTRSpUpdates;
922     u32 completeByTRSp;
923     u32 completeByTp75DW;
924     u32 completeByTendDW;
925     u32 lateActionFramesTx;
926 
927     /* Misc stats - ignored for DW. */
928     u32 twIncreases;
929     u32 twDecreases;
930     u32 twChanges;
931     u32 twHighwater;
932     u32 bloomFilterIndex;
933 } FwNanMacStats, *pFwNanMacStats;
934 
935 /* NAN Sync and DW Statistics*/
936 typedef struct PACKED
937 {
938     u64 currTsf;
939     u64 myRank;
940     u64 currAmRank;
941     u64 lastAmRank;
942     u32 currAmBTT;
943     u32 lastAmBTT;
944     u8  currAmHopCount;
945     u8  currRole;
946     u16 currClusterId;
947     u32 reserved1;
948 
949     u64 timeSpentInCurrRole;
950     u64 totalTimeSpentAsMaster;
951     u64 totalTimeSpentAsNonMasterSync;
952     u64 totalTimeSpentAsNonMasterNonSync;
953     u32 transitionsToAnchorMaster;
954     u32 transitionsToMaster;
955     u32 transitionsToNonMasterSync;
956     u32 transitionsToNonMasterNonSync;
957     u32 amrUpdateCount;
958     u32 amrUpdateRankChangedCount;
959     u32 amrUpdateBTTChangedCount;
960     u32 amrUpdateHcChangedCount;
961     u32 amrUpdateNewDeviceCount;
962     u32 amrExpireCount;
963     u32 mergeCount;
964     u32 beaconsAboveHcLimit;
965     u32 beaconsBelowRssiThresh;
966     u32 beaconsIgnoredNoSpace;
967     u32 beaconsForOurCluster;
968     u32 beaconsForOtherCluster;
969     u32 beaconCancelRequests;
970     u32 beaconCancelFailures;
971     u32 beaconUpdateRequests;
972     u32 beaconUpdateFailures;
973     u32 syncBeaconTxAttempts;
974     u32 syncBeaconTxFailures;
975     u32 discBeaconTxAttempts;
976     u32 discBeaconTxFailures;
977     u32 amHopCountExpireCount;
978     u32 ndpChannelFreq;
979     u32 ndpChannelFreq2;
980     u32 schedUpdateChannelFreq;
981 } FwNanSyncStats, *pFwNanSyncStats;
982 
983 /* NAN Misc DE Statistics */
984 typedef struct PACKED
985 {
986     u32 validErrorRspMsgs;
987     u32 validTransmitFollowupReqMsgs;
988     u32 validTransmitFollowupRspMsgs;
989     u32 validFollowupIndMsgs;
990     u32 validConfigurationReqMsgs;
991     u32 validConfigurationRspMsgs;
992     u32 validStatsReqMsgs;
993     u32 validStatsRspMsgs;
994     u32 validEnableReqMsgs;
995     u32 validEnableRspMsgs;
996     u32 validDisableReqMsgs;
997     u32 validDisableRspMsgs;
998     u32 validDisableIndMsgs;
999     u32 validEventIndMsgs;
1000     u32 validTcaReqMsgs;
1001     u32 validTcaRspMsgs;
1002     u32 validTcaIndMsgs;
1003     u32 invalidTransmitFollowupReqMsgs;
1004     u32 invalidConfigurationReqMsgs;
1005     u32 invalidStatsReqMsgs;
1006     u32 invalidEnableReqMsgs;
1007     u32 invalidDisableReqMsgs;
1008     u32 invalidTcaReqMsgs;
1009 } FwNanDeStats, *pFwNanDeStats;
1010 
1011 /*
1012   Definition of various NanIndication(events)
1013 */
1014 typedef enum {
1015     NAN_INDICATION_PUBLISH_REPLIED         =0,
1016     NAN_INDICATION_PUBLISH_TERMINATED      =1,
1017     NAN_INDICATION_MATCH                   =2,
1018     NAN_INDICATION_MATCH_EXPIRED           =3,
1019     NAN_INDICATION_SUBSCRIBE_TERMINATED    =4,
1020     NAN_INDICATION_DE_EVENT                =5,
1021     NAN_INDICATION_FOLLOWUP                =6,
1022     NAN_INDICATION_DISABLED                =7,
1023     NAN_INDICATION_TCA                     =8,
1024     NAN_INDICATION_BEACON_SDF_PAYLOAD      =9,
1025     NAN_INDICATION_SELF_TRANSMIT_FOLLOWUP  =10,
1026     NAN_INDICATION_RANGING_REQUEST_RECEIVED =11,
1027     NAN_INDICATION_RANGING_RESULT           =12,
1028     NAN_INDICATION_UNKNOWN                 =0xFFFF
1029 } NanIndicationType;
1030 
1031 /* NAN Capabilities Req */
1032 typedef struct PACKED
1033 {
1034     NanMsgHeader fwHeader;
1035 } NanCapabilitiesReqMsg, *pNanCapabilitiesReqMsg;
1036 
1037 /* NAN Capabilities Rsp */
1038 typedef struct PACKED
1039 {
1040     NanMsgHeader fwHeader;
1041     /* status of the request */
1042     u32 status;
1043     u32 value;
1044     u32 max_concurrent_nan_clusters;
1045     u32 max_publishes;
1046     u32 max_subscribes;
1047     u32 max_service_name_len;
1048     u32 max_match_filter_len;
1049     u32 max_total_match_filter_len;
1050     u32 max_service_specific_info_len;
1051     u32 max_vsa_data_len;
1052     u32 max_mesh_data_len;
1053     u32 max_ndi_interfaces;
1054     u32 max_ndp_sessions;
1055     u32 max_app_info_len;
1056     u32 max_queued_transmit_followup_msgs;
1057     u32 ndp_supported_bands;
1058     u32 cipher_suites_supported;
1059     u32 max_scid_len;
1060     u32 is_ndp_security_supported:1;
1061     u32 max_sdea_service_specific_info_len:16;
1062     u32 reserved1:5;
1063     u32 reserved2:5;
1064     u32 ndpe_attr_supported:1;
1065     u32 reserved:4;
1066     u32 max_subscribe_address;
1067 } NanCapabilitiesRspMsg, *pNanCapabilitiesRspMsg;
1068 
1069 /* NAN Self Transmit Followup */
1070 typedef struct PACKED
1071 {
1072     NanMsgHeader fwHeader;
1073     u32 reason;
1074 } NanSelfTransmitFollowupIndMsg, *pNanSelfTransmitFollowupIndMsg;
1075 
1076 /* NAN Cipher Suite Shared Key */
1077 typedef struct PACKED
1078 {
1079     u32 csid_type;
1080 } NanCsidType;
1081 
1082 /* Service Discovery Extended Attribute params */
1083 typedef struct PACKED
1084 {
1085     u32 fsd_required:1;
1086     u32 fsd_with_gas:1;
1087     u32 data_path_required:1;
1088     u32 data_path_type:1;
1089     u32 multicast_type:1;
1090     u32 qos_required:1;
1091     u32 security_required:1;
1092     u32 ranging_required:1;
1093     u32 range_limit_present:1;
1094     u32 service_update_ind_present:1;
1095     u32 reserved1:6;
1096     u32 range_report:1;
1097     u32 reserved2:15;
1098 } NanFWSdeaCtrlParams;
1099 
1100 /* NAN Ranging Configuration params */
1101 typedef struct PACKED
1102 {
1103     u32  inner_threshold;
1104     u32  outer_threshold;
1105 } NanFWGeoFenceDescriptor;
1106 
1107 typedef struct PACKED
1108 {
1109     u32 range_resolution;
1110     u32 range_interval;
1111     u32 ranging_indication_event;
1112     NanFWGeoFenceDescriptor geo_fence_threshold;
1113 } NanFWRangeConfigParams;
1114 
1115 typedef struct PACKED
1116 {
1117     NanMsgHeader fwHeader;
1118     /*
1119       Excludes TLVs
1120       Optional: Nan Availability
1121     */
1122     u8 ptlv[];
1123 } NanTestModeReqMsg, *pNanTestModeReqMsg;
1124 
1125 /*
1126   NAN Status codes exchanged between firmware
1127   and WifiHal.
1128 */
1129 typedef enum {
1130     /* NAN Protocol Response Codes */
1131     NAN_I_STATUS_SUCCESS = 0,
1132     NAN_I_STATUS_TIMEOUT = 1,
1133     NAN_I_STATUS_DE_FAILURE = 2,
1134     NAN_I_STATUS_INVALID_MSG_VERSION = 3,
1135     NAN_I_STATUS_INVALID_MSG_LEN = 4,
1136     NAN_I_STATUS_INVALID_MSG_ID = 5,
1137     NAN_I_STATUS_INVALID_HANDLE = 6,
1138     NAN_I_STATUS_NO_SPACE_AVAILABLE = 7,
1139     NAN_I_STATUS_INVALID_PUBLISH_TYPE = 8,
1140     NAN_I_STATUS_INVALID_TX_TYPE = 9,
1141     NAN_I_STATUS_INVALID_MATCH_ALGORITHM = 10,
1142     NAN_I_STATUS_DISABLE_IN_PROGRESS = 11,
1143     NAN_I_STATUS_INVALID_TLV_LEN = 12,
1144     NAN_I_STATUS_INVALID_TLV_TYPE = 13,
1145     NAN_I_STATUS_MISSING_TLV_TYPE = 14,
1146     NAN_I_STATUS_INVALID_TOTAL_TLVS_LEN = 15,
1147     NAN_I_STATUS_INVALID_REQUESTER_INSTANCE_ID= 16,
1148     NAN_I_STATUS_INVALID_TLV_VALUE = 17,
1149     NAN_I_STATUS_INVALID_TX_PRIORITY = 18,
1150     NAN_I_STATUS_INVALID_CONNECTION_MAP = 19,
1151     NAN_I_STATUS_INVALID_THRESHOLD_CROSSING_ALERT_ID = 20,
1152     NAN_I_STATUS_INVALID_STATS_ID = 21,
1153     NAN_I_STATUS_NAN_NOT_ALLOWED = 22,
1154     NAN_I_STATUS_NO_OTA_ACK = 23,
1155     NAN_I_STATUS_TX_FAIL = 24,
1156     NAN_I_STATUS_NAN_ALREADY_ENABLED = 25,
1157     NAN_I_STATUS_FOLLOWUP_QUEUE_FULL = 26,
1158     /* 27-4095 Reserved */
1159     /* NAN Configuration Response codes */
1160     NAN_I_STATUS_INVALID_RSSI_CLOSE_VALUE = 4096,
1161     NAN_I_STATUS_INVALID_RSSI_MIDDLE_VALUE = 4097,
1162     NAN_I_STATUS_INVALID_HOP_COUNT_LIMIT = 4098,
1163     NAN_I_STATUS_INVALID_MASTER_PREFERENCE_VALUE = 4099,
1164     NAN_I_STATUS_INVALID_LOW_CLUSTER_ID_VALUE = 4100,
1165     NAN_I_STATUS_INVALID_HIGH_CLUSTER_ID_VALUE = 4101,
1166     NAN_I_STATUS_INVALID_BACKGROUND_SCAN_PERIOD = 4102,
1167     NAN_I_STATUS_INVALID_RSSI_PROXIMITY_VALUE = 4103,
1168     NAN_I_STATUS_INVALID_SCAN_CHANNEL = 4104,
1169     NAN_I_STATUS_INVALID_POST_NAN_CONNECTIVITY_CAPABILITIES_BITMAP = 4105,
1170     NAN_I_STATUS_INVALID_FURTHER_AVAILABILITY_MAP_NUMCHAN_VALUE = 4106,
1171     NAN_I_STATUS_INVALID_FURTHER_AVAILABILITY_MAP_DURATION_VALUE = 4107,
1172     NAN_I_STATUS_INVALID_FURTHER_AVAILABILITY_MAP_CLASS_VALUE = 4108,
1173     NAN_I_STATUS_INVALID_FURTHER_AVAILABILITY_MAP_CHANNEL_VALUE = 4109,
1174     NAN_I_STATUS_INVALID_FURTHER_AVAILABILITY_MAP_AVAILABILITY_INTERVAL_BITMAP_VALUE = 4110,
1175     NAN_I_STATUS_INVALID_FURTHER_AVAILABILITY_MAP_MAP_ID = 4111,
1176     NAN_I_STATUS_INVALID_POST_NAN_DISCOVERY_CONN_TYPE_VALUE = 4112,
1177     NAN_I_STATUS_INVALID_POST_NAN_DISCOVERY_DEVICE_ROLE_VALUE = 4113,
1178     NAN_I_STATUS_INVALID_POST_NAN_DISCOVERY_DURATION_VALUE = 4114,
1179     NAN_I_STATUS_INVALID_POST_NAN_DISCOVERY_BITMAP_VALUE = 4115,
1180     NAN_I_STATUS_MISSING_FUTHER_AVAILABILITY_MAP = 4116,
1181     NAN_I_STATUS_INVALID_BAND_CONFIG_FLAGS = 4117,
1182     NAN_I_STATUS_INVALID_RANDOM_FACTOR_UPDATE_TIME_VALUE = 4118,
1183     NAN_I_STATUS_INVALID_ONGOING_SCAN_PERIOD = 4119,
1184     NAN_I_STATUS_INVALID_DW_INTERVAL_VALUE = 4120,
1185     NAN_I_STATUS_INVALID_DB_INTERVAL_VALUE = 4121,
1186     /* 4122-8191 RESERVED */
1187     NAN_I_PUBLISH_SUBSCRIBE_TERMINATED_REASON_INVALID = 8192,
1188     NAN_I_PUBLISH_SUBSCRIBE_TERMINATED_REASON_TIMEOUT = 8193,
1189     NAN_I_PUBLISH_SUBSCRIBE_TERMINATED_REASON_USER_REQUEST = 8194,
1190     NAN_I_PUBLISH_SUBSCRIBE_TERMINATED_REASON_FAILURE = 8195,
1191     NAN_I_PUBLISH_SUBSCRIBE_TERMINATED_REASON_COUNT_REACHED = 8196,
1192     NAN_I_PUBLISH_SUBSCRIBE_TERMINATED_REASON_DE_SHUTDOWN = 8197,
1193     NAN_I_PUBLISH_SUBSCRIBE_TERMINATED_REASON_DISABLE_IN_PROGRESS = 8198,
1194     NAN_I_PUBLISH_SUBSCRIBE_TERMINATED_REASON_POST_DISC_ATTR_EXPIRED = 8199,
1195     NAN_I_PUBLISH_SUBSCRIBE_TERMINATED_REASON_POST_DISC_LEN_EXCEEDED = 8200,
1196     NAN_I_PUBLISH_SUBSCRIBE_TERMINATED_REASON_FURTHER_AVAIL_MAP_EMPTY = 8201,
1197     /* 9000-9500 NDP Status type */
1198     NDP_I_UNSUPPORTED_CONCURRENCY = 9000,
1199     NDP_I_NAN_DATA_IFACE_CREATE_FAILED = 9001,
1200     NDP_I_NAN_DATA_IFACE_DELETE_FAILED = 9002,
1201     NDP_I_DATA_INITIATOR_REQUEST_FAILED = 9003,
1202     NDP_I_DATA_RESPONDER_REQUEST_FAILED = 9004,
1203     NDP_I_INVALID_SERVICE_INSTANCE_ID = 9005,
1204     NDP_I_INVALID_NDP_INSTANCE_ID = 9006,
1205     NDP_I_INVALID_RESPONSE_CODE = 9007,
1206     NDP_I_INVALID_APP_INFO_LEN = 9008,
1207     /* OTA failures and timeouts during negotiation */
1208     NDP_I_MGMT_FRAME_REQUEST_FAILED = 9009,
1209     NDP_I_MGMT_FRAME_RESPONSE_FAILED = 9010,
1210     NDP_I_MGMT_FRAME_CONFIRM_FAILED = 9011,
1211     NDP_I_END_FAILED = 9012,
1212     NDP_I_MGMT_FRAME_END_REQUEST_FAILED = 9013,
1213     NDP_I_MGMT_FRAME_SECURITY_INSTALL_FAILED = 9014,
1214 
1215     /* 9500 onwards vendor specific error codes */
1216     NDP_I_VENDOR_SPECIFIC_ERROR = 9500
1217 } NanInternalStatusType;
1218 
1219 /* This is the TLV used for range report */
1220 typedef struct PACKED
1221 {
1222     u32 publish_id;
1223     u32 event_type;
1224     u32 range_measurement;
1225 } NanFWRangeReportParams;
1226 
1227 typedef struct PACKED
1228 {
1229     NanMsgHeader fwHeader;
1230     /*TLV Required:
1231         MANDATORY
1232             1. MAC_ADDRESS
1233             2. NanFWRangeReportParams
1234         OPTIONAL:
1235             1. A_UINT32 event type
1236     */
1237     u8 ptlv[1];
1238 } NanFWRangeReportInd, *pNanFWRangeReportInd;
1239 
1240 /** 2 word representation of MAC addr */
1241 typedef struct {
1242     /** upper 4 bytes of  MAC address */
1243     u32 mac_addr31to0;
1244     /** lower 2 bytes of  MAC address */
1245     u32 mac_addr47to32;
1246 } fw_mac_addr;
1247 
1248 /* This is the TLV used to trigger ranging requests*/
1249 typedef struct PACKED
1250 {
1251     fw_mac_addr  range_mac_addr;
1252     u32 range_id; //Match handle in match_ind, publish_id in result ind
1253     u32 ranging_accept:1;
1254     u32 ranging_reject:1;
1255     u32 ranging_cancel:1;
1256     u32 reserved:29;
1257 } NanFWRangeReqMsg, *pNanFWRangeReqMsg;
1258 
1259 typedef struct PACKED
1260 {
1261     fw_mac_addr  range_mac_addr;
1262     u32 range_id;//This will publish_id in case of receiving publish.
1263 } NanFWRangeReqRecvdMsg, *pNanFWRangeReqRecvdMsg;
1264 
1265 typedef struct PACKED
1266 {
1267     NanMsgHeader fwHeader;
1268     /*TLV Required
1269        1. t_nan_range_req_recvd_msg
1270     */
1271     u8 ptlv[1];
1272 } NanFWRangeReqRecvdInd, *pNanFWRangeReqRecvdInd;
1273 
1274 /* Function for NAN error translation
1275    For NanResponse, NanPublishTerminatedInd, NanSubscribeTerminatedInd,
1276    NanDisabledInd, NanTransmitFollowupInd:
1277    function to translate firmware specific errors
1278    to generic freamework error along with the error string
1279 */
1280 void NanErrorTranslation(NanInternalStatusType firmwareErrorRecvd,
1281                          u32 valueRcvd,
1282                          void *pRsp,
1283                          bool is_ndp_rsp);
1284 
1285 #ifdef __cplusplus
1286 }
1287 #endif /* __cplusplus */
1288 
1289 #endif /* __NAN_I_H__ */
1290 
1291