Home | History | Annotate | Download | only in wifi_hal
      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 typedef u8 SirMacAddr[NAN_MAC_ADDR_LEN];
     66 /*---------------------------------------------------------------------------
     67 * WLAN NAN CONSTANTS
     68 *--------------------------------------------------------------------------*/
     69 
     70 typedef enum
     71 {
     72     NAN_MSG_ID_ERROR_RSP                    = 0,
     73     NAN_MSG_ID_CONFIGURATION_REQ            = 1,
     74     NAN_MSG_ID_CONFIGURATION_RSP            = 2,
     75     NAN_MSG_ID_PUBLISH_SERVICE_REQ          = 3,
     76     NAN_MSG_ID_PUBLISH_SERVICE_RSP          = 4,
     77     NAN_MSG_ID_PUBLISH_SERVICE_CANCEL_REQ   = 5,
     78     NAN_MSG_ID_PUBLISH_SERVICE_CANCEL_RSP   = 6,
     79     NAN_MSG_ID_PUBLISH_REPLIED_IND          = 7,
     80     NAN_MSG_ID_PUBLISH_TERMINATED_IND       = 8,
     81     NAN_MSG_ID_SUBSCRIBE_SERVICE_REQ        = 9,
     82     NAN_MSG_ID_SUBSCRIBE_SERVICE_RSP        = 10,
     83     NAN_MSG_ID_SUBSCRIBE_SERVICE_CANCEL_REQ = 11,
     84     NAN_MSG_ID_SUBSCRIBE_SERVICE_CANCEL_RSP = 12,
     85     NAN_MSG_ID_MATCH_IND                    = 13,
     86     NAN_MSG_ID_MATCH_EXPIRED_IND            = 14,
     87     NAN_MSG_ID_SUBSCRIBE_TERMINATED_IND     = 15,
     88     NAN_MSG_ID_DE_EVENT_IND                 = 16,
     89     NAN_MSG_ID_TRANSMIT_FOLLOWUP_REQ        = 17,
     90     NAN_MSG_ID_TRANSMIT_FOLLOWUP_RSP        = 18,
     91     NAN_MSG_ID_FOLLOWUP_IND                 = 19,
     92     NAN_MSG_ID_STATS_REQ                    = 20,
     93     NAN_MSG_ID_STATS_RSP                    = 21,
     94     NAN_MSG_ID_ENABLE_REQ                   = 22,
     95     NAN_MSG_ID_ENABLE_RSP                   = 23,
     96     NAN_MSG_ID_DISABLE_REQ                  = 24,
     97     NAN_MSG_ID_DISABLE_RSP                  = 25,
     98     NAN_MSG_ID_DISABLE_IND                  = 26,
     99     NAN_MSG_ID_TCA_REQ                      = 27,
    100     NAN_MSG_ID_TCA_RSP                      = 28,
    101     NAN_MSG_ID_TCA_IND                      = 29,
    102     NAN_MSG_ID_BEACON_SDF_REQ               = 30,
    103     NAN_MSG_ID_BEACON_SDF_RSP               = 31,
    104     NAN_MSG_ID_BEACON_SDF_IND               = 32,
    105     NAN_MSG_ID_CAPABILITIES_REQ             = 33,
    106     NAN_MSG_ID_CAPABILITIES_RSP             = 34
    107 } NanMsgId;
    108 
    109 /*
    110   Various TLV Type ID sent as part of NAN Stats Response
    111   or NAN TCA Indication
    112 */
    113 typedef enum
    114 {
    115     NAN_TLV_TYPE_FIRST = 0,
    116 
    117     /* Service Discovery Frame types */
    118     NAN_TLV_TYPE_SDF_FIRST = NAN_TLV_TYPE_FIRST,
    119     NAN_TLV_TYPE_SERVICE_NAME = NAN_TLV_TYPE_SDF_FIRST,
    120     NAN_TLV_TYPE_SDF_MATCH_FILTER,
    121     NAN_TLV_TYPE_TX_MATCH_FILTER,
    122     NAN_TLV_TYPE_RX_MATCH_FILTER,
    123     NAN_TLV_TYPE_SERVICE_SPECIFIC_INFO,
    124     NAN_TLV_TYPE_EXT_SERVICE_SPECIFIC_INFO =5,
    125     NAN_TLV_TYPE_VENDOR_SPECIFIC_ATTRIBUTE_TRANSMIT = 6,
    126     NAN_TLV_TYPE_VENDOR_SPECIFIC_ATTRIBUTE_RECEIVE = 7,
    127     NAN_TLV_TYPE_POST_NAN_CONNECTIVITY_CAPABILITIES_RECEIVE = 8,
    128     NAN_TLV_TYPE_POST_NAN_DISCOVERY_ATTRIBUTE_RECEIVE = 9,
    129     NAN_TLV_TYPE_BEACON_SDF_PAYLOAD_RECEIVE = 10,
    130     NAN_TLV_TYPE_SDF_LAST = 4095,
    131 
    132     /* Configuration types */
    133     NAN_TLV_TYPE_CONFIG_FIRST = 4096,
    134     NAN_TLV_TYPE_24G_SUPPORT = NAN_TLV_TYPE_CONFIG_FIRST,
    135     NAN_TLV_TYPE_24G_BEACON,
    136     NAN_TLV_TYPE_24G_SDF,
    137     NAN_TLV_TYPE_24G_RSSI_CLOSE,
    138     NAN_TLV_TYPE_24G_RSSI_MIDDLE = 4100,
    139     NAN_TLV_TYPE_24G_RSSI_CLOSE_PROXIMITY,
    140     NAN_TLV_TYPE_5G_SUPPORT,
    141     NAN_TLV_TYPE_5G_BEACON,
    142     NAN_TLV_TYPE_5G_SDF,
    143     NAN_TLV_TYPE_5G_RSSI_CLOSE,
    144     NAN_TLV_TYPE_5G_RSSI_MIDDLE,
    145     NAN_TLV_TYPE_5G_RSSI_CLOSE_PROXIMITY,
    146     NAN_TLV_TYPE_SID_BEACON,
    147     NAN_TLV_TYPE_HOP_COUNT_LIMIT,
    148     NAN_TLV_TYPE_MASTER_PREFERENCE = 4110,
    149     NAN_TLV_TYPE_CLUSTER_ID_LOW,
    150     NAN_TLV_TYPE_CLUSTER_ID_HIGH,
    151     NAN_TLV_TYPE_RSSI_AVERAGING_WINDOW_SIZE,
    152     NAN_TLV_TYPE_CLUSTER_OUI_NETWORK_ID,
    153     NAN_TLV_TYPE_SOURCE_MAC_ADDRESS,
    154     NAN_TLV_TYPE_CLUSTER_ATTRIBUTE_IN_SDF,
    155     NAN_TLV_TYPE_SOCIAL_CHANNEL_SCAN_PARAMS,
    156     NAN_TLV_TYPE_DEBUGGING_FLAGS,
    157     NAN_TLV_TYPE_POST_NAN_CONNECTIVITY_CAPABILITIES_TRANSMIT,
    158     NAN_TLV_TYPE_POST_NAN_DISCOVERY_ATTRIBUTE_TRANSMIT = 4120,
    159     NAN_TLV_TYPE_FURTHER_AVAILABILITY_MAP,
    160     NAN_TLV_TYPE_HOP_COUNT_FORCE,
    161     NAN_TLV_TYPE_RANDOM_FACTOR_FORCE,
    162     NAN_TLV_TYPE_RANDOM_UPDATE_TIME = 4124,
    163     NAN_TLV_TYPE_EARLY_WAKEUP,
    164     NAN_TLV_TYPE_PERIODIC_SCAN_INTERVAL,
    165     NAN_TLV_TYPE_DW_INTERVAL = 4128,
    166     NAN_TLV_TYPE_DB_INTERVAL,
    167     NAN_TLV_TYPE_FURTHER_AVAILABILITY,
    168     NAN_TLV_TYPE_24G_CHANNEL,
    169     NAN_TLV_TYPE_5G_CHANNEL,
    170     NAN_TLV_TYPE_CONFIG_LAST = 8191,
    171 
    172     /* Attributes types */
    173     NAN_TLV_TYPE_ATTRS_FIRST = 8192,
    174     NAN_TLV_TYPE_AVAILABILITY_INTERVALS_MAP = NAN_TLV_TYPE_ATTRS_FIRST,
    175     NAN_TLV_TYPE_WLAN_MESH_ID,
    176     NAN_TLV_TYPE_MAC_ADDRESS,
    177     NAN_TLV_TYPE_RECEIVED_RSSI_VALUE,
    178     NAN_TLV_TYPE_CLUSTER_ATTRIBUTE,
    179     NAN_TLV_TYPE_WLAN_INFRA_SSID,
    180     NAN_TLV_TYPE_ATTRS_LAST = 12287,
    181 
    182     /* Events Type */
    183     NAN_TLV_TYPE_EVENTS_FIRST = 12288,
    184     NAN_TLV_TYPE_EVENT_SELF_STATION_MAC_ADDRESS = NAN_TLV_TYPE_EVENTS_FIRST,
    185     NAN_TLV_TYPE_EVENT_STARTED_CLUSTER,
    186     NAN_TLV_TYPE_EVENT_JOINED_CLUSTER,
    187     NAN_TLV_TYPE_EVENT_CLUSTER_SCAN_RESULTS,
    188     NAN_TLV_TYPE_FAW_MEM_AVAIL,
    189     NAN_TLV_TYPE_EVENTS_LAST = 16383,
    190 
    191     /* TCA types */
    192     NAN_TLV_TYPE_TCA_FIRST = 16384,
    193     NAN_TLV_TYPE_CLUSTER_SIZE_REQ = NAN_TLV_TYPE_TCA_FIRST,
    194     NAN_TLV_TYPE_CLUSTER_SIZE_RSP,
    195     NAN_TLV_TYPE_TCA_LAST = 32767,
    196 
    197     /* Statistics types */
    198     NAN_TLV_TYPE_STATS_FIRST = 32768,
    199     NAN_TLV_TYPE_DE_PUBLISH_STATS = NAN_TLV_TYPE_STATS_FIRST,
    200     NAN_TLV_TYPE_DE_SUBSCRIBE_STATS,
    201     NAN_TLV_TYPE_DE_MAC_STATS,
    202     NAN_TLV_TYPE_DE_TIMING_SYNC_STATS,
    203     NAN_TLV_TYPE_DE_DW_STATS,
    204     NAN_TLV_TYPE_DE_STATS,
    205     NAN_TLV_TYPE_STATS_LAST = 36863,
    206 
    207     NAN_TLV_TYPE_LAST = 65535
    208 } NanTlvType;
    209 
    210 /* 8-byte control message header used by NAN*/
    211 typedef struct PACKED
    212 {
    213    u16 msgVersion:4;
    214    u16 msgId:12;
    215    u16 msgLen;
    216    u16 handle;
    217    u16 transactionId;
    218 } NanMsgHeader, *pNanMsgHeader;
    219 
    220 /* Enumeration for Version */
    221 typedef enum
    222 {
    223    NAN_MSG_VERSION1 = 1,
    224 }NanMsgVersion;
    225 
    226 typedef struct PACKED
    227 {
    228     u16 type;
    229     u16 length;
    230     u8* value;
    231 } NanTlv, *pNanTlv;
    232 
    233 #define SIZEOF_TLV_HDR (sizeof(NanTlv::type) + sizeof(NanTlv::length))
    234 /* NAN TLV Groups and Types */
    235 typedef enum
    236 {
    237     NAN_TLV_GROUP_FIRST = 0,
    238     NAN_TLV_GROUP_SDF = NAN_TLV_GROUP_FIRST,
    239     NAN_TLV_GROUP_CONFIG,
    240     NAN_TLV_GROUP_STATS,
    241     NAN_TLV_GROUP_ATTRS,
    242     NAN_TLV_NUM_GROUPS,
    243     NAN_TLV_GROUP_LAST = NAN_TLV_NUM_GROUPS
    244 } NanTlvGroup;
    245 
    246 /* NAN Miscellaneous Constants */
    247 #define NAN_TTL_INFINITE            0
    248 #define NAN_REPLY_COUNT_INFINITE    0
    249 
    250 /* NAN Confguration 5G Channel Access Bit */
    251 #define NAN_5G_CHANNEL_ACCESS_UNSUPPORTED   0
    252 #define NAN_5G_CHANNEL_ACCESS_SUPPORTED     1
    253 
    254 /* NAN Configuration Service IDs Enclosure Bit */
    255 #define NAN_SIDS_NOT_ENCLOSED_IN_BEACONS    0
    256 #define NAN_SIBS_ENCLOSED_IN_BEACONS        1
    257 
    258 /* NAN Configuration Priority */
    259 #define NAN_CFG_PRIORITY_SERVICE_DISCOVERY  0
    260 #define NAN_CFG_PRIORITY_DATA_CONNECTION    1
    261 
    262 /* NAN Configuration 5G Channel Usage */
    263 #define NAN_5G_CHANNEL_USAGE_SYNC_AND_DISCOVERY 0
    264 #define NAN_5G_CHANNEL_USAGE_DISCOVERY_ONLY     1
    265 
    266 /* NAN Configuration TX_Beacon Content */
    267 #define NAN_TX_BEACON_CONTENT_OLD_AM_INFO       0
    268 #define NAN_TX_BEACON_CONTENT_UPDATED_AM_INFO   1
    269 
    270 /* NAN Configuration Miscellaneous Constants */
    271 #define NAN_MAC_INTERFACE_PERIODICITY_MIN   30
    272 #define NAN_MAC_INTERFACE_PERIODICITY_MAX   255
    273 
    274 #define NAN_DW_RANDOM_TIME_MIN  120
    275 #define NAN_DW_RANDOM_TIME_MAX  240
    276 
    277 #define NAN_INITIAL_SCAN_MIN_IDEAL_PERIOD   200
    278 #define NAN_INITIAL_SCAN_MAX_IDEAL_PERIOD   300
    279 
    280 #define NAN_ONGOING_SCAN_MIN_PERIOD 10
    281 #define NAN_ONGOING_SCAN_MAX_PERIOD 30
    282 
    283 #define NAN_HOP_COUNT_LIMIT 5
    284 
    285 #define NAN_WINDOW_DW   0
    286 #define NAN_WINDOW_FAW  1
    287 
    288 /* NAN Error Rsp */
    289 typedef struct PACKED
    290 {
    291     NanMsgHeader fwHeader;
    292     u16 status;
    293     u16 value;
    294 } NanErrorRspMsg, *pNanErrorRspMsg;
    295 
    296 //* NAN Publish Service Req */
    297 typedef struct PACKED
    298 {
    299     u16 ttl;
    300     u16 period;
    301     u32 reserved:1;
    302     u32 publishType:2;
    303     u32 txType:1;
    304     u32 rssiThresholdFlag:1;
    305     u32 ota_flag:1;
    306     u32 matchAlg:2;
    307     u32 count:8;
    308     u32 connmap:8;
    309     u32 pubTerminatedIndDisableFlag:1;
    310     u32 pubMatchExpiredIndDisableFlag:1;
    311     u32 followupRxIndDisableFlag:1;
    312     u32 reserved2:5;
    313     /*
    314      * Excludes TLVs
    315      *
    316      * Required: Service Name,
    317      * Optional: Tx Match Filter, Rx Match Filter, Service Specific Info,
    318      */
    319 } NanPublishServiceReqParams, *pNanPublishServiceReqParams;
    320 
    321 typedef struct PACKED
    322 {
    323     NanMsgHeader fwHeader;
    324     NanPublishServiceReqParams publishServiceReqParams;
    325     u8 ptlv[];
    326 } NanPublishServiceReqMsg, *pNanPublishServiceReqMsg;
    327 
    328 /* NAN Publish Service Rsp */
    329 typedef struct PACKED
    330 {
    331     NanMsgHeader fwHeader;
    332     /* status of the request */
    333     u16 status;
    334     u16 value;
    335 } NanPublishServiceRspMsg, *pNanPublishServiceRspMsg;
    336 
    337 /* NAN Publish Service Cancel Req */
    338 typedef struct PACKED
    339 {
    340     NanMsgHeader fwHeader;
    341 } NanPublishServiceCancelReqMsg, *pNanPublishServiceCancelReqMsg;
    342 
    343 /* NAN Publish Service Cancel Rsp */
    344 typedef struct PACKED
    345 {
    346     NanMsgHeader fwHeader;
    347     /* status of the request */
    348     u16 status;
    349     u16 value;
    350 } NanPublishServiceCancelRspMsg, *pNanPublishServiceCancelRspMsg;
    351 
    352 /* NAN Publish Terminated Ind */
    353 typedef struct PACKED
    354 {
    355     NanMsgHeader fwHeader;
    356     /* reason for the termination */
    357     u16 reason;
    358     u16 reserved;
    359 } NanPublishTerminatedIndMsg, *pNanPublishTerminatedIndMsg;
    360 
    361 /* NAN Subscribe Service Req */
    362 typedef struct PACKED
    363 {
    364     u16 ttl;
    365     u16 period;
    366     u32 subscribeType:1;
    367     u32 srfAttr:1;
    368     u32 srfInclude:1;
    369     u32 srfSend:1;
    370     u32 ssiRequired:1;
    371     u32 matchAlg:2;
    372     u32 xbit:1;
    373     u32 count:8;
    374     u32 rssiThresholdFlag:1;
    375     u32 ota_flag:1;
    376     u32 subTerminatedIndDisableFlag:1;
    377     u32 subMatchExpiredIndDisableFlag:1;
    378     u32 followupRxIndDisableFlag:1;
    379     u32 reserved:3;
    380     u32 connmap:8;
    381     /*
    382      * Excludes TLVs
    383      *
    384      * Required: Service Name
    385      * Optional: Rx Match Filter, Tx Match Filter, Service Specific Info,
    386      */
    387 } NanSubscribeServiceReqParams, *pNanSubscribeServiceReqParams;
    388 
    389 typedef struct PACKED
    390 {
    391     NanMsgHeader fwHeader;
    392     NanSubscribeServiceReqParams subscribeServiceReqParams;
    393     u8 ptlv[];
    394 } NanSubscribeServiceReqMsg, *pNanSubscribeServiceReqMsg;
    395 
    396 /* NAN Subscribe Service Rsp */
    397 typedef struct PACKED
    398 {
    399     NanMsgHeader fwHeader;
    400     /* status of the request */
    401     u16 status;
    402     u16 value;
    403 } NanSubscribeServiceRspMsg, *pNanSubscribeServiceRspMsg;
    404 
    405 /* NAN Subscribe Service Cancel Req */
    406 typedef struct PACKED
    407 {
    408     NanMsgHeader fwHeader;
    409 } NanSubscribeServiceCancelReqMsg, *pNanSubscribeServiceCancelReqMsg;
    410 
    411 /* NAN Subscribe Service Cancel Rsp */
    412 typedef struct PACKED
    413 {
    414     NanMsgHeader fwHeader;
    415     /* status of the request */
    416     u16 status;
    417     u16 value;
    418 } NanSubscribeServiceCancelRspMsg, *pNanSubscribeServiceCancelRspMsg;
    419 
    420 /* NAN Subscribe Match Ind */
    421 typedef struct PACKED
    422 {
    423     u32 matchHandle;
    424     u32 matchOccuredFlag:1;
    425     u32 outOfResourceFlag:1;
    426     u32 reserved:30;
    427 } NanMatchIndParams;
    428 
    429 typedef struct PACKED
    430 {
    431     NanMsgHeader fwHeader;
    432     NanMatchIndParams matchIndParams;
    433     u8 ptlv[];
    434 } NanMatchIndMsg, *pNanMatchIndMsg;
    435 
    436 /* NAN Subscribe Unmatch Ind */
    437 typedef struct PACKED
    438 {
    439     u32 matchHandle;
    440 } NanmatchExpiredIndParams;
    441 
    442 typedef struct PACKED
    443 {
    444     NanMsgHeader fwHeader;
    445     NanmatchExpiredIndParams matchExpiredIndParams;
    446 } NanMatchExpiredIndMsg, *pNanMatchExpiredIndMsg;
    447 
    448 /* NAN Subscribe Terminated Ind */
    449 typedef struct PACKED
    450 {
    451     NanMsgHeader fwHeader;
    452     /* reason for the termination */
    453     u16 reason;
    454     u16 reserved;
    455 } NanSubscribeTerminatedIndMsg, *pNanSubscribeTerminatedIndMsg;
    456 
    457 /* Event Ind */
    458 typedef struct PACKED
    459 {
    460     u32 eventId:8;
    461     u32 reserved:24;
    462 } NanEventIndParams;
    463 
    464 typedef struct PACKED
    465 {
    466     NanMsgHeader fwHeader;
    467     u8 ptlv[];
    468 } NanEventIndMsg, *pNanEventIndMsg;
    469 
    470 /* NAN Transmit Followup Req */
    471 typedef struct PACKED
    472 {
    473     u32 matchHandle;
    474     u32 priority:4;
    475     u32 window:1;
    476     u32 followupTxRspDisableFlag:1;
    477     u32 reserved:26;
    478     /*
    479      * Excludes TLVs
    480      *
    481      * Required: Service Specific Info or Extended Service Specific Info
    482      */
    483 } NanTransmitFollowupReqParams;
    484 
    485 typedef struct PACKED
    486 {
    487     NanMsgHeader fwHeader;
    488     NanTransmitFollowupReqParams transmitFollowupReqParams;
    489     u8 ptlv[];
    490 } NanTransmitFollowupReqMsg, *pNanTransmitFollowupReqMsg;
    491 
    492 /* NAN Transmit Followup Rsp */
    493 typedef struct PACKED
    494 {
    495     NanMsgHeader fwHeader;
    496     /* status of the request */
    497     u16 status;
    498     u16 value;
    499 } NanTransmitFollowupRspMsg, *pNanTransmitFollowupRspMsg;
    500 
    501 /* NAN Publish Followup Ind */
    502 typedef struct PACKED
    503 {
    504     u32 matchHandle;
    505     u32 window:1;
    506     u32 reserved:31;
    507     /*
    508      * Excludes TLVs
    509      *
    510      * Required: Service Specific Info or Extended Service Specific Info
    511      */
    512 } NanFollowupIndParams;
    513 
    514 typedef struct PACKED
    515 {
    516     NanMsgHeader fwHeader;
    517     NanFollowupIndParams followupIndParams;
    518     u8 ptlv[];
    519 } NanFollowupIndMsg, *pNanFollowupIndMsg;
    520 
    521 /* NAN Statistics Req */
    522 typedef struct PACKED
    523 {
    524     u32 statsType:8;
    525     u32 clear:1;
    526     u32 reserved:23;
    527 } NanStatsReqParams, *pNanStatsReqParams;
    528 
    529 typedef struct PACKED
    530 {
    531     NanMsgHeader fwHeader;
    532     NanStatsReqParams statsReqParams;
    533 } NanStatsReqMsg, *pNanStatsReqMsg;
    534 
    535 /* NAN Statistics Rsp */
    536 typedef struct PACKED
    537 {
    538     /* status of the request */
    539     u16 status;
    540     u16 value;
    541     u8 statsType;
    542     u8 reserved;
    543 } NanStatsRspParams, *pNanStatsRspParams;
    544 
    545 typedef struct PACKED
    546 {
    547     NanMsgHeader fwHeader;
    548     NanStatsRspParams statsRspParams;
    549     u8 ptlv[];
    550 } NanStatsRspMsg, *pNanStatsRspMsg;
    551 
    552 typedef struct PACKED
    553 {
    554     u8 count:7;
    555     u8 s:1;
    556 } NanSidAttr, *pSidAttr;
    557 
    558 
    559 /* NAN Configuration Req */
    560 typedef struct PACKED
    561 {
    562     NanMsgHeader fwHeader;
    563     /*
    564      * TLVs:
    565      *
    566      * Required: None.
    567      * Optional: SID, Random Time, Master Preference, WLAN Intra Attr,
    568      *           P2P Operation Attr, WLAN IBSS Attr, WLAN Mesh Attr
    569      */
    570     u8 ptlv[];
    571 } NanConfigurationReqMsg, *pNanConfigurationReqMsg;
    572 
    573 /*
    574  * Because the Configuration Req message has TLVs in it use the macro below
    575  * for the size argument to buffer allocation functions (vs. sizeof(msg)).
    576  */
    577 #define NAN_MAX_CONFIGURATION_REQ_SIZE                       \
    578     (                                                        \
    579         sizeof(NanMsgHeader)                             +   \
    580         SIZEOF_TLV_HDR + sizeof(u8)  /* SID Beacon    */ +   \
    581         SIZEOF_TLV_HDR + sizeof(u8)  /* Random Time   */ +   \
    582         SIZEOF_TLV_HDR + sizeof(u8)  /* Master Pref   */     \
    583     )
    584 
    585 /* NAN Configuration Rsp */
    586 typedef struct PACKED
    587 {
    588     NanMsgHeader fwHeader;
    589     /* status of the request */
    590     u16 status;
    591     u16 value;
    592 } NanConfigurationRspMsg, *pNanConfigurationRspMsg;
    593 
    594 /*
    595  * Because the Enable Req message has TLVs in it use the macro below for
    596  * the size argument to buffer allocation functions (vs. sizeof(msg)).
    597  */
    598 #define NAN_MAX_ENABLE_REQ_SIZE                                 \
    599     (                                                           \
    600         sizeof(NanMsgHeader)                                +   \
    601         SIZEOF_TLV_HDR + sizeof(u16) /* Cluster Low   */    +   \
    602         SIZEOF_TLV_HDR + sizeof(u16) /* Cluster High  */    +   \
    603         SIZEOF_TLV_HDR + sizeof(u8)  /* Master Pref   */        \
    604     )
    605 
    606 /* NAN Enable Req */
    607 typedef struct PACKED
    608 {
    609     NanMsgHeader fwHeader;
    610     /*
    611      * TLVs:
    612      *
    613      * Required: Cluster Low, Cluster High, Master Preference,
    614      * Optional: 5G Support, SID, 5G Sync Disc, RSSI Close, RSSI Medium,
    615      *           Hop Count Limit, Random Time, Master Preference,
    616      *           WLAN Intra Attr, P2P Operation Attr, WLAN IBSS Attr,
    617      *           WLAN Mesh Attr
    618      */
    619     u8 ptlv[];
    620 } NanEnableReqMsg, *pNanEnableReqMsg;
    621 
    622 /* NAN Enable Rsp */
    623 typedef struct PACKED
    624 {
    625     NanMsgHeader fwHeader;
    626     /* status of the request */
    627     u16 status;
    628     u16 value;
    629 } NanEnableRspMsg, *pNanEnableRspMsg;
    630 
    631 /* NAN Disable Req */
    632 typedef struct PACKED
    633 {
    634     NanMsgHeader fwHeader;
    635 } NanDisableReqMsg, *pNanDisableReqMsg;
    636 
    637 /* NAN Disable Rsp */
    638 typedef struct PACKED
    639 {
    640     NanMsgHeader fwHeader;
    641     /* status of the request */
    642     u16 status;
    643     u16 reserved;
    644 } NanDisableRspMsg, *pNanDisableRspMsg;
    645 
    646 /* NAN Disable Ind */
    647 typedef struct PACKED
    648 {
    649     NanMsgHeader fwHeader;
    650     /* reason for the termination */
    651     u16 reason;
    652     u16 reserved;
    653 } NanDisableIndMsg, *pNanDisableIndMsg;
    654 
    655 typedef struct PACKED
    656 {
    657     NanMsgHeader fwHeader;
    658     u8 ptlv[];
    659 } NanTcaReqMsg, *pNanTcaReqMsg;
    660 
    661 /* NAN TCA Rsp */
    662 typedef struct PACKED
    663 {
    664     NanMsgHeader   fwHeader;
    665     /* status of the request */
    666     u16 status;
    667     u16 value;
    668 } NanTcaRspMsg, *pNanTcaRspMsg;
    669 
    670 typedef struct PACKED
    671 {
    672     NanMsgHeader fwHeader;
    673     /*
    674      * TLVs:
    675      *
    676      * Optional: Cluster size.
    677      */
    678     u8 ptlv[];
    679 } NanTcaIndMsg, *pNanTcaIndMsg;
    680 
    681 /*
    682  * Because the TCA Ind message has TLVs in it use the macro below for the
    683  * size argument to buffer allocation functions (vs. sizeof(msg)).
    684  */
    685 #define NAN_MAX_TCA_IND_SIZE                                 \
    686     (                                                        \
    687         sizeof(NanMsgHeader)                             +   \
    688         sizeof(NanTcaIndParams)                          +   \
    689         SIZEOF_TLV_HDR + sizeof(u16) /* Cluster Size */      \
    690     )
    691 
    692 /* Function Declarations */
    693 u8* addTlv(u16 type, u16 length, const u8* value, u8* pOutTlv);
    694 u16 NANTLV_ReadTlv(u8 *pInTlv, pNanTlv pOutTlv);
    695 u16 NANTLV_WriteTlv(pNanTlv pInTlv, u8 *pOutTlv);
    696 
    697 /* NAN Beacon Sdf Payload Req */
    698 typedef struct PACKED
    699 {
    700     NanMsgHeader fwHeader;
    701     /*
    702      * TLVs:
    703      *
    704      * Optional: Vendor specific attribute
    705      */
    706     u8 ptlv[];
    707 } NanBeaconSdfPayloadReqMsg, *pNanBeaconSdfPayloadReqMsg;
    708 
    709 /* NAN Beacon Sdf Payload Rsp */
    710 typedef struct PACKED
    711 {
    712     NanMsgHeader   fwHeader;
    713     /* status of the request */
    714     u16 status;
    715     u16 reserved;
    716 } NanBeaconSdfPayloadRspMsg, *pNanBeaconSdfPayloadRspMsg;
    717 
    718 /* NAN Beacon Sdf Payload Ind */
    719 typedef struct PACKED
    720 {
    721     NanMsgHeader fwHeader;
    722     /*
    723      * TLVs:
    724      *
    725      * Required: Mac address
    726      * Optional: Vendor specific attribute, sdf payload
    727      * receive
    728      */
    729     u8 ptlv[];
    730 } NanBeaconSdfPayloadIndMsg, *pNanBeaconSdfPayloadIndMsg;
    731 
    732 typedef struct PACKED
    733 {
    734     u8 availIntDuration:2;
    735     u8 mapId:4;
    736     u8 reserved:2;
    737 } NanApiEntryCtrl;
    738 
    739 /*
    740  * Valid Operating Classes were derived from IEEE Std. 802.11-2012 Annex E
    741  * Table E-4 Global Operating Classe and, filtered by channel, are: 81, 83,
    742  * 84, 103, 114, 115, 116, 124, 125.
    743  */
    744 typedef struct PACKED
    745 {
    746     NanApiEntryCtrl entryCtrl;
    747     u8 opClass;
    748     u8 channel;
    749     u8 availIntBitmap[4];
    750 } NanFurtherAvailabilityChan, *pNanFurtherAvailabilityChan;
    751 
    752 typedef struct PACKED
    753 {
    754     u8 numChan;
    755     u8 pFaChan[];
    756 } NanFurtherAvailabilityMapAttrTlv, *pNanFurtherAvailabilityMapAttrTlv;
    757 
    758 /* Publish statistics. */
    759 typedef struct PACKED
    760 {
    761     u32 validPublishServiceReqMsgs;
    762     u32 validPublishServiceRspMsgs;
    763     u32 validPublishServiceCancelReqMsgs;
    764     u32 validPublishServiceCancelRspMsgs;
    765     u32 validPublishRepliedIndMsgs;
    766     u32 validPublishTerminatedIndMsgs;
    767     u32 validActiveSubscribes;
    768     u32 validMatches;
    769     u32 validFollowups;
    770     u32 invalidPublishServiceReqMsgs;
    771     u32 invalidPublishServiceCancelReqMsgs;
    772     u32 invalidActiveSubscribes;
    773     u32 invalidMatches;
    774     u32 invalidFollowups;
    775     u32 publishCount;
    776     u32 publishNewMatchCount;
    777     u32 pubsubGlobalNewMatchCount;
    778 } FwNanPublishStats, *pFwNanPublishStats;
    779 
    780 /* Subscribe statistics. */
    781 typedef struct PACKED
    782 {
    783     u32 validSubscribeServiceReqMsgs;
    784     u32 validSubscribeServiceRspMsgs;
    785     u32 validSubscribeServiceCancelReqMsgs;
    786     u32 validSubscribeServiceCancelRspMsgs;
    787     u32 validSubscribeTerminatedIndMsgs;
    788     u32 validSubscribeMatchIndMsgs;
    789     u32 validSubscribeUnmatchIndMsgs;
    790     u32 validSolicitedPublishes;
    791     u32 validMatches;
    792     u32 validFollowups;
    793     u32 invalidSubscribeServiceReqMsgs;
    794     u32 invalidSubscribeServiceCancelReqMsgs;
    795     u32 invalidSubscribeFollowupReqMsgs;
    796     u32 invalidSolicitedPublishes;
    797     u32 invalidMatches;
    798     u32 invalidFollowups;
    799     u32 subscribeCount;
    800     u32 bloomFilterIndex;
    801     u32 subscribeNewMatchCount;
    802     u32 pubsubGlobalNewMatchCount;
    803 } FwNanSubscribeStats, *pFwNanSubscribeStats;
    804 
    805 /* NAN MAC Statistics. Used for MAC and DW statistics. */
    806 typedef struct PACKED
    807 {
    808     /* RX stats */
    809     u32 validFrames;
    810     u32 validActionFrames;
    811     u32 validBeaconFrames;
    812     u32 ignoredActionFrames;
    813     u32 ignoredBeaconFrames;
    814     u32 invalidFrames;
    815     u32 invalidActionFrames;
    816     u32 invalidBeaconFrames;
    817     u32 invalidMacHeaders;
    818     u32 invalidPafHeaders;
    819     u32 nonNanBeaconFrames;
    820 
    821     u32 earlyActionFrames;
    822     u32 inDwActionFrames;
    823     u32 lateActionFrames;
    824 
    825     /* TX stats */
    826     u32 framesQueued;
    827     u32 totalTRSpUpdates;
    828     u32 completeByTRSp;
    829     u32 completeByTp75DW;
    830     u32 completeByTendDW;
    831     u32 lateActionFramesTx;
    832 
    833     /* Misc stats - ignored for DW. */
    834     u32 twIncreases;
    835     u32 twDecreases;
    836     u32 twChanges;
    837     u32 twHighwater;
    838     u32 bloomFilterIndex;
    839 } FwNanMacStats, *pFwNanMacStats;
    840 
    841 /* NAN Sync and DW Statistics*/
    842 typedef struct PACKED
    843 {
    844     u64 currTsf;
    845     u64 myRank;
    846     u64 currAmRank;
    847     u64 lastAmRank;
    848     u32 currAmBTT;
    849     u32 lastAmBTT;
    850     u8  currAmHopCount;
    851     u8  currRole;
    852     u16 currClusterId;
    853     u32 reserved1;
    854 
    855     u64 timeSpentInCurrRole;
    856     u64 totalTimeSpentAsMaster;
    857     u64 totalTimeSpentAsNonMasterSync;
    858     u64 totalTimeSpentAsNonMasterNonSync;
    859     u32 transitionsToAnchorMaster;
    860     u32 transitionsToMaster;
    861     u32 transitionsToNonMasterSync;
    862     u32 transitionsToNonMasterNonSync;
    863     u32 amrUpdateCount;
    864     u32 amrUpdateRankChangedCount;
    865     u32 amrUpdateBTTChangedCount;
    866     u32 amrUpdateHcChangedCount;
    867     u32 amrUpdateNewDeviceCount;
    868     u32 amrExpireCount;
    869     u32 mergeCount;
    870     u32 beaconsAboveHcLimit;
    871     u32 beaconsBelowRssiThresh;
    872     u32 beaconsIgnoredNoSpace;
    873     u32 beaconsForOurCluster;
    874     u32 beaconsForOtherCluster;
    875     u32 beaconCancelRequests;
    876     u32 beaconCancelFailures;
    877     u32 beaconUpdateRequests;
    878     u32 beaconUpdateFailures;
    879     u32 syncBeaconTxAttempts;
    880     u32 syncBeaconTxFailures;
    881     u32 discBeaconTxAttempts;
    882     u32 discBeaconTxFailures;
    883     u32 amHopCountExpireCount;
    884 } FwNanSyncStats, *pFwNanSyncStats;
    885 
    886 /* NAN Misc DE Statistics */
    887 typedef struct PACKED
    888 {
    889     u32 validErrorRspMsgs;
    890     u32 validTransmitFollowupReqMsgs;
    891     u32 validTransmitFollowupRspMsgs;
    892     u32 validFollowupIndMsgs;
    893     u32 validConfigurationReqMsgs;
    894     u32 validConfigurationRspMsgs;
    895     u32 validStatsReqMsgs;
    896     u32 validStatsRspMsgs;
    897     u32 validEnableReqMsgs;
    898     u32 validEnableRspMsgs;
    899     u32 validDisableReqMsgs;
    900     u32 validDisableRspMsgs;
    901     u32 validDisableIndMsgs;
    902     u32 validEventIndMsgs;
    903     u32 validTcaReqMsgs;
    904     u32 validTcaRspMsgs;
    905     u32 validTcaIndMsgs;
    906     u32 invalidTransmitFollowupReqMsgs;
    907     u32 invalidConfigurationReqMsgs;
    908     u32 invalidStatsReqMsgs;
    909     u32 invalidEnableReqMsgs;
    910     u32 invalidDisableReqMsgs;
    911     u32 invalidTcaReqMsgs;
    912 } FwNanDeStats, *pFwNanDeStats;
    913 
    914 /*
    915   Definition of various NanIndication(events)
    916 */
    917 typedef enum {
    918     NAN_INDICATION_PUBLISH_TERMINATED      =1,
    919     NAN_INDICATION_MATCH                   =2,
    920     NAN_INDICATION_MATCH_EXPIRED           =3,
    921     NAN_INDICATION_SUBSCRIBE_TERMINATED    =4,
    922     NAN_INDICATION_DE_EVENT                =5,
    923     NAN_INDICATION_FOLLOWUP                =6,
    924     NAN_INDICATION_DISABLED                =7,
    925     NAN_INDICATION_TCA                     =8,
    926     NAN_INDICATION_BEACON_SDF_PAYLOAD      =9,
    927     NAN_INDICATION_UNKNOWN                 =0xFFFF
    928 } NanIndicationType;
    929 
    930 typedef struct {
    931   /* NAN master rank being advertised by DE */
    932   u64 master_rank;
    933   /* NAN master preference being advertised by DE */
    934   u8 master_pref;
    935   /* random value being advertised by DE */
    936   u8 random_factor;
    937   /* hop_count from anchor master */
    938   u8 hop_count;
    939   u32 beacon_transmit_time;
    940 } NanStaParameter;
    941 
    942 /* NAN Capabilities Req */
    943 typedef struct PACKED
    944 {
    945     NanMsgHeader fwHeader;
    946 } NanCapabilitiesReqMsg, *pNanCapabilitiesReqMsg;
    947 
    948 /* NAN Capabilities Rsp */
    949 typedef struct PACKED
    950 {
    951     NanMsgHeader fwHeader;
    952     /* status of the request */
    953     u32 status;
    954     u32 value;
    955     u32 max_concurrent_nan_clusters;
    956     u32 max_publishes;
    957     u32 max_subscribes;
    958     u32 max_service_name_len;
    959     u32 max_match_filter_len;
    960     u32 max_total_match_filter_len;
    961     u32 max_service_specific_info_len;
    962     u32 max_vsa_data_len;
    963     u32 max_mesh_data_len;
    964     u32 max_ndi_interfaces;
    965     u32 max_ndp_sessions;
    966     u32 max_app_info_len;
    967 } NanCapabilitiesRspMsg, *pNanCapabilitiesRspMsg;
    968 
    969 /*
    970     Function to get the sta_parameter expected by Sigma
    971     as per CAPI spec.
    972 */
    973 wifi_error nan_get_sta_parameter(wifi_request_id id,
    974                                  wifi_interface_handle iface,
    975                                  NanStaParameter* msg);
    976 
    977 #ifdef __cplusplus
    978 }
    979 #endif /* __cplusplus */
    980 
    981 #endif /* __NAN_I_H__ */
    982 
    983