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