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