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