OSDN Git Service

Merge "bring nan header file, from original KitKat partner version" into m-wireless...
[android-x86/hardware-libhardware_legacy.git] / include / hardware_legacy / wifi_nan.h
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_H__
18 #define __NAN_H__
19
20 #include "wifi_hal.h"
21
22 #ifdef __cplusplus
23 extern "C"
24 {
25 #endif /* __cplusplus */
26
27 /*****************************************************************************
28  * NAN Discovery Service Structures and Functions
29  *****************************************************************************/
30
31 /*
32   Definitions
33   All multi-byte fields within all NAN protocol stack messages are assumed to be in Little Endian order.
34 */
35
36 typedef int NanVersion;
37
38 #define NAN_MAC_ADDR_LEN                6
39 #define NAN_COUNTRY_STRING_LEN          3
40 #define NAN_MAJOR_VERSION               1
41 #define NAN_MINOR_VERSION               0
42 #define NAN_MICRO_VERSION               0
43
44 /* NAN Maximum Lengths */
45 #define NAN_MAX_SERVICE_NAME_LEN                255
46 #define NAN_MAX_MATCH_FILTER_LEN                255
47 #define NAN_MAX_SERVICE_SPECIFIC_INFO_LEN       1024
48
49 /*
50   Definition of various NanRequestType
51 */
52 typedef enum {
53     NAN_REQUEST_ENABLE                  =0,
54     NAN_REQUEST_DISABLE                 =1,
55     NAN_REQUEST_PUBLISH                 =2,
56     NAN_REQUEST_PUBLISH_CANCEL          =3,
57     NAN_REQUEST_TRANSMIT_FOLLOWUP       =4,
58     NAN_REQUEST_SUBSCRIBE               =5,
59     NAN_REQUEST_SUBSCRIBE_CANCEL        =6,
60     NAN_REQUEST_STATS                   =7,
61     NAN_REQUEST_CONFIG                  =8,
62     NAN_REQUEST_TCA                     =9,
63     NAN_REQUEST_LAST                    =0xFFFF
64 } NanRequestType;
65
66 /*
67   Definition of various NanResponseType
68 */
69 typedef enum {
70     NAN_RESPONSE_ENABLED                =0,
71     NAN_RESPONSE_DISABLED               =1,
72     NAN_RESPONSE_PUBLISH                =2,
73     NAN_RESPONSE_PUBLISH_CANCEL         =3,
74     NAN_RESPONSE_TRANSMIT_FOLLOWUP      =4,
75     NAN_RESPONSE_SUBSCRIBE              =5,
76     NAN_RESPONSE_SUBSCRIBE_CANCEL       =6,
77     NAN_RESPONSE_STATS                  =7,
78     NAN_RESPONSE_CONFIG                 =8,
79     NAN_RESPONSE_TCA                    =9,
80     NAN_RESPONSE_ERROR                  =10,
81     NAN_RESPONSE_UNKNOWN                =0xFFFF
82 } NanResponseType;
83
84 /*
85   Definition of various NanIndication(events)
86 */
87 typedef enum {
88     NAN_INDICATION_PUBLISH_REPLIED         =0,
89     NAN_INDICATION_PUBLISH_TERMINATED      =1,
90     NAN_INDICATION_SUBSCRIBE_MATCH         =2,
91     NAN_INDICATION_SUBSCRIBE_UNMATCH       =3,
92     NAN_INDICATION_SUBSCRIBE_TERMINATED    =4,
93     NAN_INDICATION_DE_EVENT                =5,
94     NAN_INDICATION_FOLLOWUP                =6,
95     NAN_INDICATION_DISABLED                =7,
96     NAN_INDICATION_TCA                     =8,
97     NAN_INDICATION_UNKNOWN                 =0xFFFF
98 } NanIndicationType;
99
100
101 /* NAN Publish Types */
102 typedef enum {
103     NAN_PUBLISH_TYPE_UNSOLICITED = 0,
104     NAN_PUBLISH_TYPE_SOLICITED,
105     NAN_PUBLISH_TYPE_UNSOLICITED_SOLICITED,
106     NAN_PUBLISH_TYPE_LAST,
107 } NanPublishType;
108
109 /* NAN Transmit Priorities */
110 typedef enum {
111     NAN_TX_PRIORITY_LOW = 0,
112     NAN_TX_PRIORITY_NORMAL,
113     NAN_TX_PRIORITY_HIGH,
114     NAN_TX_PRIORITY_LAST
115 } NanTxPriority;
116
117 /* NAN Statistics Request ID Codes */
118 typedef enum
119 {
120     NAN_STATS_ID_FIRST = 0,
121     NAN_STATS_ID_DE_PUBLISH = NAN_STATS_ID_FIRST,
122     NAN_STATS_ID_DE_SUBSCRIBE,
123     NAN_STATS_ID_DE_MAC,
124     NAN_STATS_ID_DE_TIMING_SYNC,
125     NAN_STATS_ID_DE_DW,
126     NAN_STATS_ID_DE,
127     NAN_STATS_ID_LAST
128 } NanStatsId;
129
130 /* NAN Protocol Event ID Codes */
131 typedef enum
132 {
133     NAN_EVENT_ID_FIRST = 0,
134     NAN_EVENT_ID_SELF_STA_MAC_ADDR = NAN_EVENT_ID_FIRST,
135     NAN_EVENT_ID_STARTED_CLUSTER,
136     NAN_EVENT_ID_JOINED_CLUSTER,
137     NAN_EVENT_ID_LAST
138 } NanEventId;
139
140 /* TCA IDs */
141 typedef enum
142 {
143     NAN_TCA_ID_FIRST = 0,
144     NAN_TCA_ID_CLUSTER_SIZE = NAN_TCA_ID_FIRST,
145     NAN_TCA_ID_LAST
146 } NanTcaId;
147
148 /*
149   Various NAN Protocol Response code
150 */
151 typedef enum
152 {
153     /* NAN Protocol Response Codes */
154     NAN_STATUS_SUCCESS = 0,
155     NAN_STATUS_TIMEOUT,
156     NAN_STATUS_DE_FAILURE,
157     NAN_STATUS_INVALID_MSG_VERSION,
158     NAN_STATUS_INVALID_MSG_LEN,
159     NAN_STATUS_INVALID_MSG_ID,
160     NAN_STATUS_INVALID_HANDLE,
161     NAN_STATUS_NO_SPACE_AVAILABLE,
162     NAN_STATUS_INVALID_PUBLISH_TYPE,
163     NAN_STATUS_INVALID_TX_TYPE,
164     NAN_STATUS_INVALID_MATCH_ALGORITHM,
165     NAN_STATUS_DISABLE_IN_PROGRESS,
166     NAN_STATUS_INVALID_TLV_LEN,
167     NAN_STATUS_INVALID_TLV_TYPE,
168     NAN_STATUS_MISSING_TLV_TYPE,
169     NAN_STATUS_INVALID_TOTAL_TLVS_LEN,
170     NAN_STATUS_INVALID_MATCH_HANDLE,
171     NAN_STATUS_INVALID_TLV_VALUE,
172     NAN_STATUS_INVALID_TX_PRIORITY,
173     NAN_STATUS_INVALID_TCA_ID,
174     NAN_STATUS_INVALID_STATS_ID,
175
176     /* NAN Configuration Response codes */
177     NAN_STATUS_INVALID_RSSI_CLOSE_VALUE = 128,
178     NAN_STATUS_INVALID_RSSI_MEDIUM_VALUE,
179     NAN_STATUS_INVALID_HOP_COUNT_LIMIT,
180     NAN_STATUS_INVALID_CLUSTER_JOIN_COUNT,
181     NAN_STATUS_INVALID_MIN_WAKE_DW_DURATION_VALUE,
182     NAN_STATUS_INVALID_OFDM_DATA_RATE_VALUE,
183     NAN_STATUS_INVALID_RANDOM_FACTOR_UPDATE_TIME_VALUE,
184     NAN_STATUS_INVALID_MASTER_PREFERENCE_VALUE,
185     NAN_STATUS_INVALID_EARLY_DW_WAKE_INTERVAL_VALUE,
186     NAN_STATUS_INVALID_LOW_CLUSTER_ID_VALUE,
187     NAN_STATUS_INVALID_HIGH_CLUSTER_ID_VALUE,
188     NAN_STATUS_INVALID_INITIAL_SCAN_PERIOD,
189     NAN_STATUS_INVALID_ONGOING_SCAN_PERIOD,
190     NAN_STATUS_INVALID_RSSI_PROXIMITY_VALUE
191 } NanStatusType;
192
193 /*
194   Various NAN Terminated Indication Code
195 */
196 typedef enum
197 {
198     NAN_TERMINATED_REASON_INVALID = 0,
199     NAN_TERMINATED_REASON_TIMEOUT,
200     NAN_TERMINATED_REASON_USER_REQUEST,
201     NAN_TERMINATED_REASON_FAILURE,
202     NAN_TERMINATED_REASON_COUNT_REACHED,
203     NAN_TERMINATED_REASON_DE_SHUTDOWN,
204     NAN_TERMINATED_REASON_DISABLE_IN_PROGRESS
205 } NanTerminatedStatus;
206
207 /* NAN Transmit Types */
208 typedef enum
209 {
210     NAN_TX_TYPE_BROADCAST = 0,
211     NAN_TX_TYPE_UNICAST,
212     NAN_TX_TYPE_LAST
213 } NanTxType;
214
215 /* NAN Subscribe Type Bit */
216 #define NAN_SUBSCRIBE_TYPE_PASSIVE  0
217 #define NAN_SUBSCRIBE_TYPE_ACTIVE   1
218
219 /* NAN Service Response Filter Attribute Bit */
220 #define NAN_SRF_ATTR_BLOOM_FILTER       0
221 #define NAN_SRF_ATTR_PARTIAL_MAC_ADDR   1
222
223 /* NAN Service Response Filter Include Bit */
224 #define NAN_SRF_INCLUDE_DO_NOT_RESPOND  0
225 #define NAN_SRF_INCLUDE_RESPOND         1
226
227 /* NAN Match Algorithms */
228 typedef enum
229 {
230     NAN_MATCH_ALG_FIRST = 0,
231     NAN_MATCH_ALG_MATCH_ONCE = NAN_MATCH_ALG_FIRST,
232     NAN_MATCH_ALG_MATCH_CONTINUOUS,
233     NAN_MATCH_ALG_LAST
234 } NanMatchAlg;
235
236 /* NAN Header */
237 typedef struct {
238     /*
239     16-bit quantity which is allocated by the FW.
240     Pass the Handle as 0xFFFF if the Host would like to set up a new
241     Publish/Subscribe and the FW will pass back a valid handle in response msg.
242     To update an already opened Publish/Subscribe Host can pass a Handle
243     which has already been allocated by the FW.
244     */
245     u16 handle;
246
247     /*
248     16-bit quantity which is allocated in 2 contexts.  For all Request
249     messages the TransactionId is allocated by the Service Layer and
250     passed down to the DE.  In all Indication messages the TransactionId
251     field is allocated by the DE.  There is no correlation between the
252     TransactionIds allocated by the Service Layer and those allocated by the DE
253     */
254     u16 transaction_id;
255 } NanHeader;
256
257 /*
258   Enable Request Message Structure
259   The NanEnableReq message instructs the Discovery Engine to enter an operational state
260 */
261 typedef struct {
262     NanHeader header;
263     u8 support_5g; /* default = 0 */
264     u16 cluster_low; /* default = 0 */
265     u16 cluster_high; /* default = 0 */
266     u8 sid_beacon; /* default = 0x80 */
267     u8 sync_disc_5g; /* default  = 1 i.e 5G Discovery frames only*/
268     u8 rssi_close; /* default = 60 (-60 dBm) */
269     u8 rssi_middle; /* default = 70 (-70 dBm) */
270     u8 rssi_proximity; /* default = 70 (-70 dBm) */
271     u8 hop_count_limit; /* default = 2 */
272     u8 random_time; /* default  = 120 (DWs) */
273     u8 master_pref; /* default = 0 */
274     u8 periodic_scan_interval; /* default = 20 seconds */
275     /* TBD: Google specific IE */
276 }NanEnableRequest;
277
278 /*
279   Disable Request Message Structure
280   The NanDisableReq message instructs the Discovery Engine to exit an operational state.
281 */
282 typedef struct {
283     NanHeader header;
284 }NanDisableRequest;
285
286 /*
287   Publish Msg Structure
288   Message is used to request the DE to publish the Service Name
289   using the parameters passed into the Discovery Window
290 */
291 typedef struct {
292     NanHeader header;
293     u16 ttl; /* how many seconds to run for. 0 means forever until canceled */
294     u16 period; /* periodicity of OTA unsolicited publish. Specified in increments of 500 ms */
295     u8 replied_event_flag; /* 1= RepliedEventInd needed, 0 = Not needed */
296     NanPublishType publish_type;/* 0= unsolicited, solicited = 1, 2= both */
297     NanTxType tx_type; /* 0 = broadcast, 1= unicast  if solicited publish */
298     u8 publish_count; /* number of OTA Publish, 0 means forever until canceled */
299     u16 service_name_len; /* length of service name */
300     u8 service_name[NAN_MAX_SERVICE_NAME_LEN];/* UTF-8 encoded string identifying the service */
301
302     /* Sequence of values which should be conveyed to the Discovery Engine of a
303     NAN Device that has invoked a Subscribe method corresponding to this Publish method
304     */
305     u16 service_specific_info_len;
306     u8 service_specific_info[NAN_MAX_SERVICE_SPECIFIC_INFO_LEN];
307
308     /* Ordered sequence of <length, value> pairs which specify further response conditions
309     beyond the service name used to filter subscribe messages to respond to.
310     This is only needed when the PT is set to NAN_SOLICITED or NAN_SOLICITED_UNSOLICITED.
311     */
312     u16 rx_match_filter_len;
313     u8 rx_match_filter[NAN_MAX_MATCH_FILTER_LEN];
314
315     /* Ordered sequence of <length, value> pairs to be included in the Discovery Frame.
316     If present it is always sent in a Discovery Frame
317     */
318     u16 tx_match_filter_len;
319     u8 tx_match_filter[NAN_MAX_MATCH_FILTER_LEN];
320 }NanPublishRequest;
321
322 /*
323   Publish Cancel Msg Structure
324   The PublishServiceCancelReq Message is used to request the DE to stop publishing
325   the Service Name identified by the handle in the message.
326 */
327 typedef struct {
328     NanHeader header;
329 }NanPublishCancelRequest;
330
331 /*
332   NAN Subscribe Structure
333   The SubscribeServiceReq message is sent to the Discovery Engine
334   whenever the Upper layers would like to listen for a Service Name
335 */
336 typedef struct {
337     NanHeader header;
338     u16 ttl; /* how many seconds to run for. 0 means forever until canceled */
339     u16 period;/* periodicity of OTA Active Subscribe. Units in increments of 500 ms , 0 = attempt every DW*/
340
341     /* Flag which specifies how the Subscribe request shall be processed. */
342     u8 subscribe_type; /* 0 - PASSIVE , 1- ACTIVE */
343
344     /* Flag which specifies on Active Subscribes how the Service Response Filter attribute is populated.*/
345     u8 serviceResponseFilter; /* 0 - Bloom Filter, 1 - MAC Addr */
346
347     /* Flag which specifies how the Service Response Filter Include bit is populated.*/
348     u8 serviceResponseInclude; /* 0=Do not respond if in the Address Set, 1= Respond */
349
350     /* Flag which specifies if the Service Response Filter should be used when creating Subscribes.*/
351     u8 useServiceResponseFilter; /* 0=Do not send the Service Response Filter,1= send */
352
353     /* Flag which specifies if the Service Specific Info is needed in the Publish message before creating the MatchIndication*/
354     u8 ssiRequiredForMatchIndication; /* 0=Not needed, 1= Required */
355
356     /* Field which allows the matching behavior to be controlled.  */
357     NanMatchAlg subscribe_match; /* 0 - Match Once, 1 - Match continuous */
358
359     /* The number of Subscribe Matches which should occur before the Subscribe request is automatically terminated.*/
360     u8 subscribe_count; /* If this value is 0 this field is not used by the DE.*/
361
362     u16 service_name_len;/* length of service name */
363     u8 service_name[NAN_MAX_SERVICE_NAME_LEN]; /* UTF-8 encoded string identifying the service */
364
365     /* Sequence of values which further specify the published service beyond the service name*/
366     u16 service_specific_info_len;
367     u8 service_specific_info[NAN_MAX_SERVICE_SPECIFIC_INFO_LEN];
368
369     /* Ordered sequence of <length, value> pairs used to filter out received publish discovery messages.
370     This can be sent both for a Passive or an Active Subscribe
371     */
372     u16 rx_match_filter_len;
373     u8 rx_match_filter[NAN_MAX_MATCH_FILTER_LEN];
374
375     /* Ordered sequence of <length, value> pairs  included in the Discovery Frame when an Active Subscribe is used.*/
376     u16 tx_match_filter_len;
377     u8 tx_match_filter[NAN_MAX_MATCH_FILTER_LEN];
378 }NanSubscribeRequest;
379
380
381 /*
382   NAN Subscribe Cancel Structure
383   The SubscribeCancelReq Message is used to request the DE to stop looking for the Service Name.
384 */
385 typedef struct {
386     NanHeader header;
387 }NanSubscribeCancelRequest;
388
389
390 /*
391   Transmit follow up Structure
392   The TransmitFollowupReq message is sent to the DE to allow the sending of the Service_Specific_Info
393   to a particular MAC address.
394 */
395 typedef struct {
396     NanHeader header;
397     u8 addr[NAN_MAC_ADDR_LEN]; /* Can be a broadcast/multicast or unicast address */
398     NanTxPriority priority; /* priority of the request 0 = low, 1=normal, 2=high */
399     u8 dw_or_faw; /* 0= send in a DW, 1=send in FAW */
400
401     /* Sequence of values which further specify the published service beyond the service name
402     Treated as service specific info in case dw_or_faw is set to 0
403     Treated as extended service specific info in case dw_or_faw is set to non-zero*/
404     u16 service_specific_info_len;
405     u8 service_specific_info[NAN_MAX_SERVICE_SPECIFIC_INFO_LEN];
406 }NanTransmitFollowupRequest;
407
408 /*
409   Stats Request structure
410   The Discovery Engine can be queried at runtime by the Host processor for statistics
411   concerning various parts of the Discovery Engine.
412 */
413 typedef struct {
414     NanHeader header;
415     NanStatsId stats_id; /* NAN Statistics Request ID Codes */
416     u8 clear; /* 0= Do not clear the stats and return the current contents , 1= Clear the associated stats  */
417 }NanStatsRequest;
418
419 /*
420   Config Structure
421   The NanConfigurationReq message is sent by the Host to the
422   Discovery Engine in order to configure the Discovery Engine during runtime.
423 */
424 typedef struct {
425     NanHeader header;
426     u8 sid_beacon; /* default = 0x80 */
427     u8 sync_disc_5g; /* default  = 1 i.e 5G Discovery frames only*/
428     u8 rssi_proximity; /* default = 70 (-70 dBm) */
429     u8 random_time; /* default  = 120 (DWs) */
430     u8 master_pref; /* default = 0 */
431     u8 periodic_scan_interval; /* default = 20 seconds */
432     /* The number of Additional Discovery Window slots in
433        increments of 16 ms.  Since each DW is 512 TUs apart
434        and the DW takes up 1 slot, the maximum number of additional
435        slots which can be specified is 31.  This is a hint to the
436        scheduler and there is no guarantee that all 31 slots will
437        be available because of MCC and BT Coexistence channel usage
438     */
439     u8 additional_disc_window_slots; /* default = 0.*/
440 }NanConfigRequest;
441
442 /*
443   TCA Structure
444   The Discovery Engine can be configured to send up Events whenever a configured
445   Threshold Crossing Alert (TCA) Id crosses an integral threshold in a particular direction.
446 */
447 typedef struct {
448     NanHeader header;
449     NanTcaId tca_id; /* Nan Protocol Threshold Crossing Alert (TCA) Codes */
450
451     /* flag which control whether or not an event is generated for the Rising direction */
452     u8 rising_direction_evt_flag; /* 0 - no event, 1 - event */
453
454     /* flag which control whether or not an event is generated for the Falling direction */
455     u8 falling_direction_evt_flag;/* 0 - no event, 1 - event */
456
457     /* flag which requests a previous TCA request to be cleared from the DE */
458     u8 clear;/*0= Do not clear the TCA, 1=Clear the TCA */
459
460     /* 32 bit value which represents the threshold to be used.*/
461     u32 threshold;
462 }NanTCARequest;
463
464 /* Publish statistics. */
465 typedef struct
466 {
467     u32 validPublishServiceReqMsgs;
468     u32 validPublishServiceRspMsgs;
469     u32 validPublishServiceCancelReqMsgs;
470     u32 validPublishServiceCancelRspMsgs;
471     u32 validPublishRepliedIndMsgs;
472     u32 validPublishTerminatedIndMsgs;
473     u32 validActiveSubscribes;
474     u32 validMatches;
475     u32 validFollowups;
476     u32 invalidPublishServiceReqMsgs;
477     u32 invalidPublishServiceCancelReqMsgs;
478     u32 invalidActiveSubscribes;
479     u32 invalidMatches;
480     u32 invalidFollowups;
481     u32 publishCount;
482 } NanPublishStats;
483
484 /* Subscribe statistics. */
485 typedef struct
486 {
487     u32 validSubscribeServiceReqMsgs;
488     u32 validSubscribeServiceRspMsgs;
489     u32 validSubscribeServiceCancelReqMsgs;
490     u32 validSubscribeServiceCancelRspMsgs;
491     u32 validSubscribeTerminatedIndMsgs;
492     u32 validSubscribeMatchIndMsgs;
493     u32 validSubscribeUnmatchIndMsgs;
494     u32 validSolicitedPublishes;
495     u32 validMatches;
496     u32 validFollowups;
497     u32 invalidSubscribeServiceReqMsgs;
498     u32 invalidSubscribeServiceCancelReqMsgs;
499     u32 invalidSubscribeFollowupReqMsgs;
500     u32 invalidSolicitedPublishes;
501     u32 invalidMatches;
502     u32 invalidFollowups;
503     u32 subscribeCount;
504     u32 bloomFilterIndex;
505 } NanSubscribeStats;
506
507 /* NAN MAC Statistics. Used for MAC and DW statistics. */
508 typedef struct
509 {
510     /* RX stats */
511     u32 validFrames;
512     u32 validActionFrames;
513     u32 validBeaconFrames;
514     u32 ignoredActionFrames;
515     u32 ignoredBeaconFrames;
516     u32 invalidFrames;
517     u32 invalidActionFrames;
518     u32 invalidBeaconFrames;
519     u32 invalidMacHeaders;
520     u32 invalidPafHeaders;
521     u32 nonNanBeaconFrames;
522
523     u32 earlyActionFrames;
524     u32 inDwActionFrames;
525     u32 lateActionFrames;
526
527     /* TX stats */
528     u32 framesQueued;
529     u32 totalTRSpUpdates;
530     u32 completeByTRSp;
531     u32 completeByTp75DW;
532     u32 completeByTendDW;
533     u32 lateActionFramesTx;
534
535     /* Misc stats - ignored for DW. */
536     u32 twIncreases;
537     u32 twDecreases;
538     u32 twChanges;
539     u32 twHighwater;
540     u32 bloomFilterIndex;
541 } NanMacStats;
542
543 /* NAN Sync Statistics*/
544 typedef struct
545 {
546     u64 currTsf;
547     u64 myRank;
548     u64 currAmRank;
549     u64 lastAmRank;
550     u32 currAmBTT;
551     u32 lastAmBTT;
552     u8  currAmHopCount;
553     u8  currRole;
554     u16 currClusterId;
555
556     u64 timeSpentInCurrRole;
557     u64 totalTimeSpentAsMaster;
558     u64 totalTimeSpentAsNonMasterSync;
559     u64 totalTimeSpentAsNonMasterNonSync;
560     u32 transitionsToAnchorMaster;
561     u32 transitionsToMaster;
562     u32 transitionsToNonMasterSync;
563     u32 transitionsToNonMasterNonSync;
564     u32 amrUpdateCount;
565     u32 amrUpdateRankChangedCount;
566     u32 amrUpdateBTTChangedCount;
567     u32 amrUpdateHcChangedCount;
568     u32 amrUpdateNewDeviceCount;
569     u32 amrExpireCount;
570     u32 mergeCount;
571     u32 beaconsAboveHcLimit;
572     u32 beaconsBelowRssiThresh;
573     u32 beaconsIgnoredNoSpace;
574     u32 beaconsForOurCluster;
575     u32 beaconsForOtherCluster;
576     u32 beaconCancelRequests;
577     u32 beaconCancelFailures;
578     u32 beaconUpdateRequests;
579     u32 beaconUpdateFailures;
580     u32 syncBeaconTxAttempts;
581     u32 discBeaconTxAttempts;
582 } NanSyncStats;
583
584 /* NAN Misc DE Statistics */
585 typedef struct
586 {
587     u32 validErrorRspMsgs;
588     u32 validTransmitFollowupReqMsgs;
589     u32 validTransmitFollowupRspMsgs;
590     u32 validFollowupIndMsgs;
591     u32 validConfigurationReqMsgs;
592     u32 validConfigurationRspMsgs;
593     u32 validStatsReqMsgs;
594     u32 validStatsRspMsgs;
595     u32 validEnableReqMsgs;
596     u32 validEnableRspMsgs;
597     u32 validDisableReqMsgs;
598     u32 validDisableRspMsgs;
599     u32 validDisableIndMsgs;
600     u32 validEventIndMsgs;
601     u32 validTcaReqMsgs;
602     u32 validTcaRspMsgs;
603     u32 validTcaIndMsgs;
604     u32 invalidTransmitFollowupReqMsgs;
605     u32 invalidConfigurationReqMsgs;
606     u32 invalidStatsReqMsgs;
607     u32 invalidEnableReqMsgs;
608     u32 invalidDisableReqMsgs;
609     u32 invalidTcaReqMsgs;
610 } NanDeStats;
611
612 /*
613   Stats Response Message structure
614   The Discovery Engine response to a request by the Host for statistics.
615 */
616 typedef struct {
617     NanStatsId stats_id;
618     union {
619         NanPublishStats publish_stats;
620         NanSubscribeStats subscribe_stats;
621         NanMacStats mac_stats;
622         NanSyncStats sync_stats;
623         NanDeStats de_stats;
624     }data;
625 }NanStatsResponse;
626
627 /*
628   NAN Response messages
629 */
630 typedef struct {
631     NanHeader header;
632     u16 status; /* contains the result code */
633     u16 value; /* For error returns the value is returned which was in error */
634     NanResponseType response_type; /* NanResponseType Definitions */
635     union {
636         NanStatsResponse stats_response;
637     }body;
638 }NanResponseMsg;
639
640
641 /*
642   Publish Replied Indication
643   The PublishRepliedInd Message is sent by the DE when an Active Subscribe is
644   received over the air and it matches a Solicited PublishServiceReq which had
645   been created with the replied_event_flag set.
646 */
647 typedef struct {
648     NanHeader header;
649     u8 addr[NAN_MAC_ADDR_LEN];
650 }NanPublishRepliedInd;
651
652 /*
653   Publish Terminated
654   The PublishTerminatedInd message is sent by the DE whenever a Publish
655   terminates from a user-specified timeout or a unrecoverable error in the DE.
656 */
657 typedef struct {
658     NanHeader header;
659     NanTerminatedStatus reason;
660 }NanPublishTerminatedInd;
661
662 /*
663   Subscribe Match Indication
664   The SubscribeMatchInd message is sent once per responding MAC address whenever
665   the Discovery Engine detects a match for a previous SubscribeServiceReq.
666 */
667 typedef struct {
668     NanHeader header;
669
670     /* a 16 bit Handle which is sent to the Application.  This handle will be sent in any subsequent
671     UnmatchInd messages rather than resending the Match_Filter/Service_Specific_Info TLVs
672     The Match_Handle is a DE resource and it is of limited quantity.  In the event that the DE
673     runs out of Match_Handles the DE will still send the SubscribeMatchInd message but will
674     set the Match_Handle to MATCH_HANDLE_MATCH_POOL_EXHAUSTED=0xFFFF
675     */
676     u16 match_handle;
677     u8 addr[NAN_MAC_ADDR_LEN];
678
679     /* Sequence of octets which were received in a Discovery Frame matching this
680     Subscribe Request.*/
681     u16 service_specific_info_len;
682     u8 service_specific_info[NAN_MAX_SERVICE_NAME_LEN];
683
684     /* Ordered sequence of <length, value> pairs received in the Discovery Frame
685     matching this Subscribe Request.*/
686     u16 sdf_match_filter_len;
687     u8 sdf_match_filter[NAN_MAX_MATCH_FILTER_LEN];
688 }NanSubscribeMatchInd;
689
690 /*
691   Subscribe UnMatch
692   The SubscribeUnmatchInd message is sent whenever the Discovery Engine detects that
693   a previously Matched Subscribed Service Name has been gone for too long.
694   If the previous SubscribeMatchInd message contained a Match_Handle equal to
695   MATCH_HANDLE_MATCH_POOL_EXHAUSTED then this message will not be sent to the Host.
696 */
697 typedef struct {
698     NanHeader header;
699     /* 16 bit value sent by the DE in a previous SubscribeMatchInd to the application. */
700     u16 match_handle;
701 }NanSubscribeUnmatchInd;
702
703 /*
704   Subscribe Terminated
705   The SubscribeTerminatedInd message is sent by the DE whenever a
706   Subscribe terminates from a user-specified timeout or a unrecoverable error in the DE.
707 */
708 typedef struct {
709     NanHeader header;
710     NanTerminatedStatus reason;
711 }NanSubscribeTerminatedInd;
712
713 /*
714   Followup Indication Message
715   The FollowupInd message is sent by the DE to the Host whenever it receives a
716   Followup message from another peer.
717 */
718 typedef struct {
719     NanHeader header;
720     u8 addr[NAN_MAC_ADDR_LEN];
721
722     /* Flag which the DE uses to decide if received in a DW or a FAW*/
723     u8 dw_or_faw; /* 0=Received  in a DW, 1 = Received in a FAW*/
724
725     /* Sequence of values which further specify the published service beyond the service name
726     Service specific info in case dw_or_faw is set to 0
727     Extended service specific info in case dw_or_faw is set to non-zero*/
728     u16 service_specific_info_len;
729     u8 service_specific_info[NAN_MAX_SERVICE_SPECIFIC_INFO_LEN];
730 }NanFollowupInd;
731
732 /* Selfstaevent data*/
733 typedef struct {
734     u8 addr[NAN_MAC_ADDR_LEN];
735 }NanSelfStaEvent;
736
737 /* joined or Started cluster data*/
738 typedef struct {
739     u8 addr[NAN_MAC_ADDR_LEN];
740 }NanClusterEventData;
741
742 /*
743   Discovery Engine Event Indication
744   The Discovery Engine can inform the Host when significant events occur
745   The data following the EventId is dependent upon the EventId type.
746   In other words, each new event defined will carry a different
747   structure of information back to the host.
748 */
749 typedef struct {
750     NanHeader header;
751     NanEventId event_id; /* NAN Protocol Event Codes */
752     union {
753         /* SelfStaEvent which will have 6 byte mac address
754            of the Discovery engine.*/
755         NanSelfStaEvent self_sta;
756         /* Cluster Event Data which will be obtained when the
757            device starts a new cluster or joins a cluster.
758            The event data will have 6 byte octet string of the
759            cluster started or joined.*/
760         NanClusterEventData cluster;
761     }data;
762 }NanDiscEngEventInd;
763
764 /* Cluster size TCA data*/
765 typedef struct {
766     u16 cluster_size;
767 }NanTcaClusterData;
768
769 /*
770   NAN TCA Indication
771   The Discovery Engine can inform the Host when significant events occur.
772   The data following the TcaId is dependent upon the TcaId type.
773   In other words, each new event defined will carry a different structure
774   of information back to the host.
775 */
776 typedef struct {
777     NanHeader header;
778     NanTcaId tca_id;
779     union {
780         /* This event in obtained when the cluser size threshold
781            is crossed. Event will have the cluster size */
782         NanTcaClusterData cluster;
783     }data;
784 }NanTCAInd;
785
786 /*
787   NAN Disabled Indication
788   The NanDisableInd message indicates to the upper layers that the Discovery
789   Engine has flushed all state and has been shutdown.  When this message is received
790   the DE is guaranteed to have left the NAN cluster it was part of and will have terminated
791   any in progress Publishes or Subscribes.
792 */
793 typedef struct {
794     NanHeader header;
795     NanStatusType reason;
796 }NanDisabledInd;
797
798 /* Response and Event Callbacks */
799 typedef struct {
800     /* NotifyResponse invoked to notify the status of the Request */
801     void (*NotifyResponse)(NanResponseMsg* rsp_data);
802     /* Various Events Callback */
803     void (*EventPublishReplied)(NanPublishRepliedInd* event);
804     void (*EventPublishTerminated)(NanPublishTerminatedInd* event);
805     void (*EventSubscribeMatch) (NanSubscribeMatchInd* event);
806     void (*EventSubscribeUnMatch) (NanSubscribeUnmatchInd* event);
807     void (*EventSubscribeTerminated) (NanSubscribeTerminatedInd* event);
808     void (*EventFollowup) (NanFollowupInd* event);
809     void (*EventDiscEngEvent) (NanDiscEngEventInd* event);
810     void (*EventDisabled) (NanDisabledInd* event);
811     void (*EventTca) (NanTCAInd* event);
812 } NanCallbackHandler;
813
814
815 /*  Function to send NAN request to the wifi driver.*/
816 wifi_error nan_enable_request(wifi_request_id id,
817                               wifi_handle handle,
818                               NanEnableRequest* msg);
819
820 /*  Function to send NAN request to the wifi driver.*/
821 wifi_error nan_disable_request(wifi_request_id id,
822                                wifi_handle handle,
823                                NanDisableRequest* msg);
824
825 /*  Function to send NAN request to the wifi driver.*/
826 wifi_error nan_publish_request(wifi_request_id id,
827                                wifi_handle handle,
828                                NanPublishRequest* msg);
829
830 /*  Function to send NAN request to the wifi driver.*/
831 wifi_error nan_publish_cancel_request(wifi_request_id id,
832                                       wifi_handle handle,
833                                       NanPublishCancelRequest* msg);
834
835 /*  Function to send NAN request to the wifi driver.*/
836 wifi_error nan_subscribe_request(wifi_request_id id,
837                                  wifi_handle handle,
838                                  NanSubscribeRequest* msg);
839
840 /*  Function to send NAN request to the wifi driver.*/
841 wifi_error nan_subscribe_cancel_request(wifi_request_id id,
842                                         wifi_handle handle,
843                                         NanSubscribeCancelRequest* msg);
844
845 /*  Function to send NAN request to the wifi driver.*/
846 wifi_error nan_transmit_followup_request(wifi_request_id id,
847                                          wifi_handle handle,
848                                          NanTransmitFollowupRequest* msg);
849
850 /*  Function to send NAN statistics request to the wifi driver.*/
851 wifi_error nan_stats_request(wifi_request_id id,
852                              wifi_handle handle,
853                              NanStatsRequest* msg);
854
855 /*  Function to send NAN configuration request to the wifi driver.*/
856 wifi_error nan_config_request(wifi_request_id id,
857                               wifi_handle handle,
858                               NanConfigRequest* msg);
859
860 /*  Function to send NAN request to the wifi driver.*/
861 wifi_error nan_tca_request(wifi_request_id id,
862                            wifi_handle handle,
863                            NanTCARequest* msg);
864
865 /*  Function to register NAN callback */
866 wifi_error nan_register_handler(wifi_handle handle,
867                                 NanCallbackHandler handlers);
868
869 /*  Function to get version of the NAN HAL */
870 wifi_error nan_get_version(wifi_handle handle,
871                            NanVersion* version);
872
873 #ifdef __cplusplus
874 }
875 #endif /* __cplusplus */
876
877 #endif /* __NAN_H__ */