1 /* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Portions copyright (C) 2017 Broadcom Limited 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 #include <hardware_legacy/wifi_hal.h> 20 21 #ifndef __WIFI_HAL_COMMON_H__ 22 #define __WIFI_HAL_COMMON_H__ 23 24 #define LOG_TAG "WifiHAL" 25 26 #include <log/log.h> 27 #include "nl80211_copy.h" 28 #include "sync.h" 29 30 #define SOCKET_BUFFER_SIZE (32768U) 31 #define RECV_BUF_SIZE (4096) 32 #define DEFAULT_EVENT_CB_SIZE (64) 33 #define DEFAULT_CMD_SIZE (64) 34 #define DOT11_OUI_LEN 3 35 #define DOT11_MAX_SSID_LEN 32 36 37 #define ETHERTYPE_IP 0x0800 /* IP */ 38 #define ETHERTYPE_IPV6 0x86dd /* IP protocol version 6 */ 39 #define MAX_PROBE_RESP_IE_LEN 2048 40 /* 41 Vendor OUI - This is a unique identifier that identifies organization. Lets 42 code Android specific functions with Google OUI; although vendors can do more 43 with their own OUI's as well. 44 */ 45 46 const uint32_t GOOGLE_OUI = 0x001A11; 47 const uint32_t BRCM_OUI = 0x001018; 48 /* TODO: define vendor OUI here */ 49 50 51 #define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5] 52 #define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x" 53 54 #define NMR2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5], (a)[6], (a)[7] 55 #define NMRSTR "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x" 56 #define NAN_MASTER_RANK_LEN 8 57 #define NAN_SCID_INFO_LEN 16 58 59 #define SAR_CONFIG_SCENARIO_COUNT 100 60 #define MAX_NUM_RADIOS 3 61 #define MAX_CMD_RESP_BUF_LEN 8192 62 63 /* 64 This enum defines ranges for various commands; commands themselves 65 can be defined in respective feature headers; i.e. find gscan command 66 definitions in gscan.cpp 67 */ 68 69 typedef int (*nl_recvmsg_msg_cb_t)(struct nl_msg *msg, void *arg); 70 typedef enum { 71 /* don't use 0 as a valid subcommand */ 72 VENDOR_NL80211_SUBCMD_UNSPECIFIED, 73 74 /* define all vendor startup commands between 0x0 and 0x0FFF */ 75 VENDOR_NL80211_SUBCMD_RANGE_START = 0x0001, 76 VENDOR_NL80211_SUBCMD_RANGE_END = 0x0FFF, 77 78 /* define all GScan related commands between 0x1000 and 0x10FF */ 79 ANDROID_NL80211_SUBCMD_GSCAN_RANGE_START = 0x1000, 80 ANDROID_NL80211_SUBCMD_GSCAN_RANGE_END = 0x10FF, 81 82 /* define all NearbyDiscovery related commands between 0x1100 and 0x11FF */ 83 ANDROID_NL80211_SUBCMD_NBD_RANGE_START = 0x1100, 84 ANDROID_NL80211_SUBCMD_NBD_RANGE_END = 0x11FF, 85 86 /* define all RTT related commands between 0x1100 and 0x11FF */ 87 ANDROID_NL80211_SUBCMD_RTT_RANGE_START = 0x1100, 88 ANDROID_NL80211_SUBCMD_RTT_RANGE_END = 0x11FF, 89 90 ANDROID_NL80211_SUBCMD_LSTATS_RANGE_START = 0x1200, 91 ANDROID_NL80211_SUBCMD_LSTATS_RANGE_END = 0x12FF, 92 93 /* define all Logger related commands between 0x1400 and 0x14FF */ 94 ANDROID_NL80211_SUBCMD_DEBUG_RANGE_START = 0x1400, 95 ANDROID_NL80211_SUBCMD_DEBUG_RANGE_END = 0x14FF, 96 97 /* define all wifi offload related commands between 0x1600 and 0x16FF */ 98 ANDROID_NL80211_SUBCMD_WIFI_OFFLOAD_RANGE_START = 0x1600, 99 ANDROID_NL80211_SUBCMD_WIFI_OFFLOAD_RANGE_END = 0x16FF, 100 101 /* define all NAN related commands between 0x1700 and 0x17FF */ 102 ANDROID_NL80211_SUBCMD_NAN_RANGE_START = 0x1700, 103 ANDROID_NL80211_SUBCMD_NAN_RANGE_END = 0x17FF, 104 105 /* define all Android Packet Filter related commands between 0x1800 and 0x18FF */ 106 ANDROID_NL80211_SUBCMD_PKT_FILTER_RANGE_START = 0x1800, 107 ANDROID_NL80211_SUBCMD_PKT_FILTER_RANGE_END = 0x18FF, 108 109 /* define all tx power related commands between 0x1900 and 0x1910 */ 110 ANDROID_NL80211_SUBCMD_TX_POWER_RANGE_START = 0x1900, 111 ANDROID_NL80211_SUBCMD_TX_POWER_RANGE_END = 0x1910, 112 113 /* define all thermal mode related commands between 0x1920 and 0x192F */ 114 ANDROID_NL80211_SUBCMD_MITIGATION_RANGE_START = 0x1920, 115 ANDROID_NL80211_SUBCMD_MITIGATION_RANGE_END = 0x192F, 116 117 /* define all DSCP related commands between 0x2000 and 0x20FF */ 118 ANDROID_NL80211_SUBCMD_DSCP_RANGE_START = 0x2000, 119 ANDROID_NL80211_SUBCMD_DSCP_RANGE_END = 0x20FF, 120 121 /* define all Channel Avoidance related commands between 0x2100 and 0x211F */ 122 ANDROID_NL80211_SUBCMD_CHAVOID_RANGE_START = 0x2100, 123 ANDROID_NL80211_SUBCMD_CHAVOID_RANGE_END = 0x211F, 124 125 /* define all OTA Download related commands between 0x2120 and 0x212F */ 126 ANDROID_NL80211_SUBCMD_OTA_DOWNLOAD_START = 0x2120, 127 ANDROID_NL80211_SUBCMD_OTA_DOWNLOAD_END = 0x212F, 128 129 /* define all VOIP mode config related commands between 0x2130 and 0x213F */ 130 ANDROID_NL80211_SUBCMD_VIOP_MODE_START = 0x2130, 131 ANDROID_NL80211_SUBCMD_VIOP_MODE_END = 0x213F, 132 133 /* define all TWT related commands between 0x2140 and 0x214F */ 134 ANDROID_NL80211_SUBCMD_TWT_START = 0x2140, 135 ANDROID_NL80211_SUBCMD_TWT_END = 0x214F, 136 137 /* define all Usable Channel related commands between 0x2150 and 0x215F */ 138 ANDROID_NL80211_SUBCMD_USABLE_CHANNEL_START = 0x2150, 139 ANDROID_NL80211_SUBCMD_USABLE_CHANNEL_END = 0x215F, 140 141 /* define all init/deinit related commands between 0x2160 and 0x216F */ 142 ANDROID_NL80211_SUBCMD_INIT_DEINIT_RANGE_START = 0x2160, 143 ANDROID_NL80211_SUBCMD_INIT_DEINIT_RANGE_END = 0x216F, 144 145 /* This is reserved for future usage */ 146 147 } ANDROID_VENDOR_SUB_COMMAND; 148 149 typedef enum { 150 151 GSCAN_SUBCMD_GET_CAPABILITIES = ANDROID_NL80211_SUBCMD_GSCAN_RANGE_START, 152 153 GSCAN_SUBCMD_SET_CONFIG, /* 0x1001 */ 154 155 GSCAN_SUBCMD_SET_SCAN_CONFIG, /* 0x1002 */ 156 GSCAN_SUBCMD_ENABLE_GSCAN, /* 0x1003 */ 157 GSCAN_SUBCMD_GET_SCAN_RESULTS, /* 0x1004 */ 158 GSCAN_SUBCMD_SCAN_RESULTS, /* 0x1005 */ 159 160 GSCAN_SUBCMD_SET_HOTLIST, /* 0x1006 */ 161 162 GSCAN_SUBCMD_SET_SIGNIFICANT_CHANGE_CONFIG, /* 0x1007 */ 163 GSCAN_SUBCMD_ENABLE_FULL_SCAN_RESULTS, /* 0x1008 */ 164 GSCAN_SUBCMD_GET_CHANNEL_LIST, /* 0x1009 */ 165 166 WIFI_SUBCMD_GET_FEATURE_SET, /* 0x100A */ 167 WIFI_SUBCMD_GET_FEATURE_SET_MATRIX, /* 0x100B */ 168 WIFI_SUBCMD_SET_PNO_RANDOM_MAC_OUI, /* 0x100C */ 169 WIFI_SUBCMD_NODFS_SET, /* 0x100D */ 170 WIFI_SUBCMD_SET_COUNTRY_CODE, /* 0x100E */ 171 /* Add more sub commands here */ 172 GSCAN_SUBCMD_SET_EPNO_SSID, /* 0x100F */ 173 174 WIFI_SUBCMD_SET_SSID_WHITE_LIST, /* 0x1010 */ 175 WIFI_SUBCMD_SET_ROAM_PARAMS, /* 0x1011 */ 176 WIFI_SUBCMD_ENABLE_LAZY_ROAM, /* 0x1012 */ 177 WIFI_SUBCMD_SET_BSSID_PREF, /* 0x1013 */ 178 WIFI_SUBCMD_SET_BSSID_BLACKLIST, /* 0x1014 */ 179 180 GSCAN_SUBCMD_ANQPO_CONFIG, /* 0x1015 */ 181 WIFI_SUBCMD_SET_RSSI_MONITOR, /* 0x1016 */ 182 WIFI_SUBCMD_CONFIG_ND_OFFLOAD, /* 0x1017 */ 183 WIFI_SUBCMD_CONFIG_TCPACK_SUP, /* 0x1018 */ 184 WIFI_SUBCMD_FW_ROAM_POLICY, /* 0x1019 */ 185 WIFI_SUBCMD_ROAM_CAPABILITY, /* 0x101a */ 186 WIFI_SUBCMD_SET_LATENCY_MODE, /* 0x101b */ 187 WIFI_SUBCMD_SET_MULTISTA_PRIMARY_CONNECTION, /* 0x101c */ 188 WIFI_SUBCMD_SET_MULTISTA_USE_CASE, /* 0x101d */ 189 WIFI_SUBCMD_SET_DTIM_CONFIG, /* 0x101e */ 190 WIFI_SUBCMD_CONFIG_INDOOR_STATE, 191 192 GSCAN_SUBCMD_MAX, 193 194 /* NAN related */ 195 NAN_SUBCMD_ENABLE = ANDROID_NL80211_SUBCMD_NAN_RANGE_START, 196 NAN_SUBCMD_DISABLE, /* 0x1701 */ 197 NAN_SUBCMD_PUBLISH, /* 0x1702 */ 198 NAN_SUBCMD_SUBSCRIBE, /* 0x1703 */ 199 NAN_SUBCMD_PUBLISH_CANCEL, /* 0x1704 */ 200 NAN_SUBCMD_SUBSCRIBE_CANCEL, /* 0x1705 */ 201 NAN_SUBCMD_TRANSMIT_FOLLOWUP, /* 0x1706 */ 202 NAN_SUBCMD_CONFIG, /* 0x1707 */ 203 NAN_SUBCMD_TCA, /* 0x1708 */ 204 NAN_SUBCMD_STATS, /* 0x1709 */ 205 NAN_SUBCMD_GET_CAPABILITIES, /* 0x170A */ 206 NAN_SUBCMD_DATA_PATH_IFACE_CREATE, /* 0x170B */ 207 NAN_SUBCMD_DATA_PATH_IFACE_DELETE, /* 0x170C */ 208 NAN_SUBCMD_DATA_PATH_REQUEST, /* 0x170D */ 209 NAN_SUBCMD_DATA_PATH_RESPONSE, /* 0x170E */ 210 NAN_SUBCMD_DATA_PATH_END, /* 0x170F */ 211 NAN_SUBCMD_DATA_PATH_SEC_INFO, /* 0x1710 */ 212 NAN_SUBCMD_VERSION_INFO, /* 0x1711 */ 213 NAN_SUBCMD_ENABLE_MERGE, /* 0x1712 */ 214 APF_SUBCMD_GET_CAPABILITIES = ANDROID_NL80211_SUBCMD_PKT_FILTER_RANGE_START, 215 APF_SUBCMD_SET_FILTER, 216 APF_SUBCMD_READ_FILTER, 217 WIFI_SUBCMD_TX_POWER_SCENARIO = ANDROID_NL80211_SUBCMD_TX_POWER_RANGE_START, 218 WIFI_SUBCMD_THERMAL_MITIGATION = ANDROID_NL80211_SUBCMD_MITIGATION_RANGE_START, 219 DSCP_SUBCMD_SET_TABLE = ANDROID_NL80211_SUBCMD_DSCP_RANGE_START, 220 DSCP_SUBCMD_RESET_TABLE, /* 0x2001 */ 221 CHAVOID_SUBCMD_SET_CONFIG = ANDROID_NL80211_SUBCMD_CHAVOID_RANGE_START, 222 223 TWT_SUBCMD_GETCAPABILITY = ANDROID_NL80211_SUBCMD_TWT_START, 224 TWT_SUBCMD_SETUP_REQUEST, 225 TWT_SUBCMD_TEAR_DOWN_REQUEST, 226 TWT_SUBCMD_INFO_FRAME_REQUEST, 227 TWT_SUBCMD_GETSTATS, 228 TWT_SUBCMD_CLR_STATS, 229 230 WIFI_SUBCMD_CONFIG_VOIP_MODE = ANDROID_NL80211_SUBCMD_VIOP_MODE_START, 231 232 WIFI_SUBCMD_GET_OTA_CURRUNT_INFO = ANDROID_NL80211_SUBCMD_OTA_DOWNLOAD_START, 233 WIFI_SUBCMD_OTA_UPDATE, 234 WIFI_SUBCMD_USABLE_CHANNEL = ANDROID_NL80211_SUBCMD_USABLE_CHANNEL_START, 235 WIFI_SUBCMD_TRIGGER_SSR = ANDROID_NL80211_SUBCMD_INIT_DEINIT_RANGE_START, 236 WIFI_SUBCMD_GET_RADIO_COMBO_MATRIX, 237 } WIFI_SUB_COMMAND; 238 239 typedef enum { 240 BRCM_RESERVED1 = 0, 241 BRCM_RESERVED2 = 1, 242 GSCAN_EVENT_SIGNIFICANT_CHANGE_RESULTS = 2, 243 GSCAN_EVENT_HOTLIST_RESULTS_FOUND = 3, 244 GSCAN_EVENT_SCAN_RESULTS_AVAILABLE = 4, 245 GSCAN_EVENT_FULL_SCAN_RESULTS = 5, 246 RTT_EVENT_COMPLETE = 6, 247 GSCAN_EVENT_COMPLETE_SCAN = 7, 248 GSCAN_EVENT_HOTLIST_RESULTS_LOST = 8, 249 GSCAN_EVENT_EPNO_EVENT = 9, 250 GOOGLE_DEBUG_RING_EVENT = 10, 251 GOOGLE_DEBUG_MEM_DUMP_EVENT = 11, 252 GSCAN_EVENT_ANQPO_HOTSPOT_MATCH = 12, 253 GOOGLE_RSSI_MONITOR_EVENT = 13, 254 GOOGLE_MKEEP_ALIVE = 14, 255 256 /* 257 * BRCM specific events should be placed after the Generic events 258 * in order to match between the DHD and HAL 259 */ 260 NAN_EVENT_ENABLED = 15, 261 NAN_EVENT_DISABLED = 16, 262 NAN_EVENT_SUBSCRIBE_MATCH = 17, 263 NAN_EVENT_PUBLISH_REPLIED_IND = 18, 264 NAN_EVENT_PUBLISH_TERMINATED = 19, 265 NAN_EVENT_SUBSCRIBE_TERMINATED = 20, 266 NAN_EVENT_DE_EVENT = 21, 267 NAN_EVENT_FOLLOWUP = 22, 268 NAN_EVENT_TRANSMIT_FOLLOWUP_IND = 23, 269 NAN_EVENT_DATA_REQUEST = 24, 270 NAN_EVENT_DATA_CONFIRMATION = 25, 271 NAN_EVENT_DATA_END = 26, 272 NAN_EVENT_BEACON = 27, 273 NAN_EVENT_SDF = 28, 274 NAN_EVENT_TCA = 29, 275 NAN_EVENT_SUBSCRIBE_UNMATCH = 30, 276 NAN_EVENT_UNKNOWN = 31, 277 BRCM_VENDOR_EVENT_HANGED = 33, 278 ROAM_EVENT_START, 279 GOOGLE_FILE_DUMP_EVENT = 37, 280 NAN_ASYNC_RESPONSE_DISABLED = 40, 281 BRCM_VENDOR_EVENT_TWT = 43, 282 BRCM_TPUT_DUMP_EVENT = 44, 283 NAN_EVENT_MATCH_EXPIRY = 45 284 } WIFI_EVENT; 285 286 typedef void (*wifi_internal_event_handler) (wifi_handle handle, int events); 287 288 class WifiCommand; 289 290 typedef struct { 291 int nl_cmd; 292 uint32_t vendor_id; 293 int vendor_subcmd; 294 nl_recvmsg_msg_cb_t cb_func; 295 void *cb_arg; 296 } cb_info; 297 298 typedef struct { 299 wifi_request_id id; 300 WifiCommand *cmd; 301 } cmd_info; 302 303 typedef struct { 304 wifi_handle handle; // handle to wifi data 305 char name[IFNAMSIZ+1]; // interface name + trailing null 306 int id; // id to use when talking to driver 307 bool is_virtual; // mark each iface as virtual or static 308 } interface_info; 309 310 typedef struct { 311 312 struct nl_sock *cmd_sock; // command socket object 313 struct nl_sock *event_sock; // event socket object 314 int nl80211_family_id; // family id for 80211 driver 315 int cleanup_socks[2]; // sockets used to implement wifi_cleanup 316 317 bool in_event_loop; // Indicates that event loop is active 318 bool clean_up; // Indication to exit since cleanup has started 319 320 wifi_internal_event_handler event_handler; // default event handler 321 wifi_cleaned_up_handler cleaned_up_handler; // socket cleaned up handler 322 323 cb_info *event_cb; // event callbacks 324 int num_event_cb; // number of event callbacks 325 int alloc_event_cb; // number of allocated callback objects 326 pthread_mutex_t cb_lock; // mutex for the event_cb access 327 328 cmd_info *cmd; // Outstanding commands 329 int num_cmd; // number of commands 330 int alloc_cmd; // number of commands allocated 331 332 interface_info **interfaces; // array of interfaces 333 int num_interfaces; // number of interfaces 334 int max_num_interfaces; // max number of interfaces 335 wifi_subsystem_restart_handler restart_handler; // trigger sub system handler 336 337 338 // add other details 339 } hal_info; 340 341 #define PNO_SSID_FOUND 0x1 342 #define PNO_SSID_LOST 0x2 343 344 typedef struct wifi_pno_result { 345 unsigned char ssid[DOT11_MAX_SSID_LEN]; 346 unsigned char ssid_len; 347 signed char rssi; 348 u16 channel; 349 u16 flags; 350 mac_addr bssid; 351 } wifi_pno_result_t; 352 353 typedef struct wifi_gscan_result { 354 u64 ts; // Time of discovery 355 u8 ssid[DOT11_MAX_SSID_LEN+1]; // null terminated 356 mac_addr bssid; // BSSID 357 u32 channel; // channel frequency in MHz 358 s32 rssi; // in db 359 u64 rtt; // in nanoseconds 360 u64 rtt_sd; // standard deviation in rtt 361 u16 beacon_period; // units are Kusec 362 u16 capability; // Capability information 363 u32 pad; 364 } wifi_gscan_result_t; 365 366 typedef struct wifi_gscan_full_result { 367 wifi_gscan_result_t fixed; 368 u32 scan_ch_bucket; // scan chbucket bitmask 369 u32 ie_length; // byte length of Information Elements 370 u8 ie_data[1]; // IE data to follow 371 } wifi_gscan_full_result_t; 372 373 void twt_deinit_handler(); 374 375 typedef enum { 376 TWT_EVENT_INVALID = 0, 377 TWT_SETUP_RESPONSE = 1, 378 TWT_TEARDOWN_COMPLETION = 2, 379 TWT_INFORM_FRAME = 3, 380 TWT_NOTIFY = 4, 381 TWT_EVENT_LAST 382 } TwtEventType; 383 384 typedef enum { 385 TWT_INVALID = 0, 386 TWT_SETUP_REQUEST = 1, 387 TWT_INFO_FRAME_REQUEST = 2, 388 TWT_TEAR_DOWN_REQUEST = 3, 389 TWT_LAST 390 } TwtRequestType; 391 392 typedef enum { 393 TWT_ATTRIBUTE_INVALID = 0, 394 TWT_ATTRIBUTE_CONFIG_ID = 1, 395 TWT_ATTRIBUTE_NEG_TYPE = 2, 396 TWT_ATTRIBUTE_TRIGGER_TYPE = 3, 397 TWT_ATTRIBUTE_WAKE_DUR_US = 4, 398 TWT_ATTRIBUTE_WAKE_INT_US = 5, 399 TWT_ATTRIBUTE_WAKE_INT_MIN_US = 6, 400 TWT_ATTRIBUTE_WAKE_INT_MAX_US = 7, 401 TWT_ATTRIBUTE_WAKE_DUR_MIN_US = 8, 402 TWT_ATTRIBUTE_WAKE_DUR_MAX_US = 9, 403 TWT_ATTRIBUTE_AVG_PKT_SIZE = 10, 404 TWT_ATTRIBUTE_AVG_PKT_NUM = 11, 405 TWT_ATTRIBUTE_WAKE_TIME_OFF_US = 12, 406 TWT_ATTRIBUTE_ALL_TWT = 13, 407 TWT_ATTRIBUTE_RESUME_TIME_US = 14, 408 TWT_ATTRIBUTE_AVG_EOSP_DUR = 15, 409 TWT_ATTRIBUTE_EOSP_COUNT = 16, 410 TWT_ATTRIBUTE_NUM_SP = 17, 411 TWT_ATTRIBUTE_DEVICE_CAP = 18, 412 TWT_ATTRIBUTE_PEER_CAP = 19, 413 TWT_ATTRIBUTE_STATUS = 20, 414 TWT_ATTRIBUTE_REASON_CODE = 21, 415 TWT_ATTRIBUTE_RESUMED = 22, 416 TWT_ATTRIBUTE_NOTIFICATION = 23, 417 TWT_ATTRIBUTE_SUB_EVENT = 24, 418 TWT_ATTRIBUTE_NUM_PEER_STATS = 25, 419 TWT_ATTRIBUTE_AVG_PKT_NUM_TX = 26, 420 TWT_ATTRIBUTE_AVG_PKT_SIZE_TX = 27, 421 TWT_ATTRIBUTE_AVG_PKT_NUM_RX = 28, 422 TWT_ATTRIBUTE_AVG_PKT_SIZE_RX = 29, 423 TWT_ATTRIBUTE_MAX 424 } TWT_ATTRIBUTE; 425 426 wifi_error wifi_register_handler(wifi_handle handle, int cmd, nl_recvmsg_msg_cb_t func, void *arg); 427 wifi_error wifi_register_vendor_handler(wifi_handle handle, 428 uint32_t id, int subcmd, nl_recvmsg_msg_cb_t func, void *arg); 429 430 void wifi_unregister_handler(wifi_handle handle, int cmd); 431 void wifi_unregister_vendor_handler_without_lock(wifi_handle handle, uint32_t id, int subcmd); 432 void wifi_unregister_vendor_handler(wifi_handle handle, uint32_t id, int subcmd); 433 434 wifi_error wifi_register_cmd(wifi_handle handle, int id, WifiCommand *cmd); 435 WifiCommand *wifi_unregister_cmd(wifi_handle handle, int id); 436 WifiCommand *wifi_get_cmd(wifi_handle handle, int id); 437 void wifi_unregister_cmd(wifi_handle handle, WifiCommand *cmd); 438 439 interface_info *getIfaceInfo(wifi_interface_handle); 440 wifi_handle getWifiHandle(wifi_interface_handle handle); 441 hal_info *getHalInfo(wifi_handle handle); 442 hal_info *getHalInfo(wifi_interface_handle handle); 443 wifi_handle getWifiHandle(hal_info *info); 444 wifi_interface_handle getIfaceHandle(interface_info *info); 445 wifi_error wifi_cancel_cmd(wifi_request_id id, wifi_interface_handle iface); 446 wifi_error wifi_get_cancel_cmd(wifi_request_id id, wifi_interface_handle iface); 447 wifi_error nan_deinit_handler(); 448 wifi_error wifi_start_hal(wifi_interface_handle iface); 449 wifi_error wifi_stop_hal(wifi_interface_handle iface); 450 wifi_interface_handle wifi_get_wlan_interface(wifi_handle info, 451 wifi_interface_handle *ifaceHandles, int numIfaceHandles); 452 #ifdef RING_DUMP 453 wifi_error wifi_start_ring_dump(wifi_interface_handle iface, 454 wifi_ring_buffer_data_handler ring_handle); 455 wifi_error wifi_stop_ring_dump(wifi_interface_handle iface); 456 #endif /* RING_DUMP */ 457 wifi_error wifi_hal_ota_update(wifi_interface_handle iface, uint32_t ota_version); 458 wifi_error wifi_hal_preInit(wifi_interface_handle iface); 459 /* API to get wake reason statistics */ 460 wifi_error wifi_get_wake_reason_stats(wifi_interface_handle handle, 461 WLAN_DRIVER_WAKE_REASON_CNT *wifi_wake_reason_cnt); 462 wifi_error wifi_virtual_interface_create(wifi_handle handle, const char* ifname, 463 wifi_interface_type iface_type); 464 wifi_error wifi_virtual_interface_delete(wifi_handle handle, const char* ifname); 465 wifi_error wifi_set_coex_unsafe_channels(wifi_handle handle, u32 num_channels, 466 wifi_coex_unsafe_channel channels[], u32 restrictions); 467 wifi_error wifi_set_voip_mode(wifi_interface_handle handle, wifi_voip_mode mode); 468 wifi_error wifi_set_dtim_config(wifi_interface_handle handle, u32 multiplier); 469 void set_hautil_mode(bool halutil_mode); 470 bool get_halutil_mode(); 471 472 /* API's to support TWT */ 473 474 /**@brief twt_get_capability 475 * Request TWT capability 476 * @param wifi_interface_handle: 477 * @return Synchronous wifi_error and TwtCapabilitySet 478 */ 479 wifi_error twt_get_capability(wifi_interface_handle iface, TwtCapabilitySet* twt_cap_set); 480 481 /**@brief twt_register_handler 482 * Request to register TWT callback 483 * @param wifi_interface_handle: 484 * @param TwtCallbackHandler: 485 * @return Synchronous wifi_error 486 */ 487 wifi_error twt_register_handler(wifi_interface_handle iface, TwtCallbackHandler handler); 488 489 /**@brief twt_setup_request 490 * Request to send TWT setup frame 491 * @param wifi_interface_handle: 492 * @param TwtSetupRequest: 493 * @return Synchronous wifi_error 494 * @return Asynchronous EventTwtSetupResponse CB return TwtSetupResponse 495 */ 496 wifi_error twt_setup_request(wifi_interface_handle iface, TwtSetupRequest* msg); 497 498 /**@brief twt_teardown_request 499 * Request to send TWT teardown frame 500 * @param wifi_interface_handle: 501 * @param TwtTeardownRequest: 502 * @return Synchronous wifi_error 503 * @return Asynchronous EventTwtTeardownCompletion CB return TwtTeardownCompletion 504 * TwtTeardownCompletion may also be received due to other events 505 * like CSA, BTCX, TWT scheduler, MultiConnection, peer-initiated teardown, etc. 506 */ 507 wifi_error twt_teardown_request(wifi_interface_handle iface, TwtTeardownRequest* msg); 508 509 /**@brief twt_info_frame_request 510 * Request to send TWT info frame 511 * @param wifi_interface_handle: 512 * @param TwtInfoFrameRequest: 513 * @return Synchronous wifi_error 514 * @return Asynchronous EventTwtInfoFrameReceived CB return TwtInfoFrameReceived 515 * Driver may also receive Peer-initiated TwtInfoFrame 516 */ 517 wifi_error twt_info_frame_request(wifi_interface_handle iface, TwtInfoFrameRequest* msg); 518 519 /**@brief twt_get_stats 520 * Request to get TWT stats 521 * @param wifi_interface_handle: 522 * @param config_id: 523 * @return Synchronous wifi_error and TwtStats 524 */ 525 wifi_error twt_get_stats(wifi_interface_handle iface, u8 config_id, TwtStats* stats); 526 527 /**@brief twt_clear_stats 528 * Request to clear TWT stats 529 * @param wifi_interface_handle: 530 * @param config_id: 531 * @return Synchronous wifi_error 532 */ 533 wifi_error twt_clear_stats(wifi_interface_handle iface, u8 config_id); 534 535 wifi_error wifi_trigger_subsystem_restart(wifi_handle handle); 536 // some common macros 537 538 #define min(x, y) ((x) < (y) ? (x) : (y)) 539 #define max(x, y) ((x) > (y) ? (x) : (y)) 540 541 #define NULL_CHECK_RETURN(ptr, str, ret) \ 542 do { \ 543 if (!(ptr)) { \ 544 ALOGE("%s(): null pointer - #ptr (%s)\n", __FUNCTION__, str); \ 545 return ret; \ 546 } \ 547 } while (0) 548 549 #endif 550 551