1 /* 2 * Copyright (C) 2016 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 __WIFI_HAL_H__ 18 #define __WIFI_HAL_H__ 19 20 #ifdef __cplusplus 21 extern "C" 22 { 23 #endif 24 #include <stdint.h> 25 26 #define IFNAMSIZ 16 27 28 /* typedefs */ 29 typedef unsigned char byte; 30 typedef unsigned char u8; 31 typedef signed char s8; 32 typedef uint16_t u16; 33 typedef uint32_t u32; 34 typedef int32_t s32; 35 typedef uint64_t u64; 36 typedef int64_t s64; 37 typedef int wifi_request_id; 38 typedef int wifi_channel; // indicates channel frequency in MHz 39 typedef int wifi_rssi; 40 typedef int wifi_radio; 41 typedef byte mac_addr[6]; 42 typedef byte oui[3]; 43 typedef int64_t wifi_timestamp; // In microseconds (us) 44 typedef int64_t wifi_timespan; // In picoseconds (ps) 45 typedef uint64_t feature_set; 46 47 /* forward declarations */ 48 struct wifi_info; 49 struct wifi_interface_info; 50 typedef struct wifi_info *wifi_handle; 51 typedef struct wifi_interface_info *wifi_interface_handle; 52 53 /* WiFi Common definitions */ 54 /* channel operating width */ 55 typedef enum { 56 WIFI_CHAN_WIDTH_20 = 0, 57 WIFI_CHAN_WIDTH_40 = 1, 58 WIFI_CHAN_WIDTH_80 = 2, 59 WIFI_CHAN_WIDTH_160 = 3, 60 WIFI_CHAN_WIDTH_80P80 = 4, 61 WIFI_CHAN_WIDTH_5 = 5, 62 WIFI_CHAN_WIDTH_10 = 6, 63 WIFI_CHAN_WIDTH_INVALID = -1 64 } wifi_channel_width; 65 66 /* Pre selected Power scenarios to be applied from BDF file */ 67 typedef enum { 68 WIFI_POWER_SCENARIO_INVALID = -2, 69 WIFI_POWER_SCENARIO_DEFAULT = -1, 70 WIFI_POWER_SCENARIO_VOICE_CALL = 0, 71 WIFI_POWER_SCENARIO_ON_HEAD_CELL_OFF = 1, 72 WIFI_POWER_SCENARIO_ON_HEAD_CELL_ON = 2, 73 WIFI_POWER_SCENARIO_ON_BODY_CELL_OFF = 3, 74 WIFI_POWER_SCENARIO_ON_BODY_CELL_ON = 4, 75 WIFI_POWER_SCENARIO_ON_BODY_BT = 5, 76 WIFI_POWER_SCENARIO_ON_HEAD_HOTSPOT = 6, 77 WIFI_POWER_SCENARIO_ON_HEAD_HOTSPOT_MMW = 7, 78 WIFI_POWER_SCENARIO_ON_BODY_CELL_ON_BT = 8, 79 WIFI_POWER_SCENARIO_ON_BODY_HOTSPOT = 9, 80 WIFI_POWER_SCENARIO_ON_BODY_HOTSPOT_BT = 10, 81 WIFI_POWER_SCENARIO_ON_BODY_HOTSPOT_MMW = 11, 82 WIFI_POWER_SCENARIO_ON_BODY_HOTSPOT_BT_MMW = 12, 83 WIFI_POWER_SCENARIO_ON_HEAD_CELL_OFF_UNFOLDED = 13, 84 WIFI_POWER_SCENARIO_ON_HEAD_CELL_ON_UNFOLDED = 14, 85 WIFI_POWER_SCENARIO_ON_HEAD_HOTSPOT_UNFOLDED = 15, 86 WIFI_POWER_SCENARIO_ON_HEAD_HOTSPOT_MMW_UNFOLDED = 16, 87 WIFI_POWER_SCENARIO_ON_BODY_CELL_OFF_UNFOLDED = 17, 88 WIFI_POWER_SCENARIO_ON_BODY_BT_UNFOLDED = 18, 89 WIFI_POWER_SCENARIO_ON_BODY_CELL_ON_UNFOLDED = 19, 90 WIFI_POWER_SCENARIO_ON_BODY_CELL_ON_BT_UNFOLDED = 20, 91 WIFI_POWER_SCENARIO_ON_BODY_HOTSPOT_UNFOLDED = 21, 92 WIFI_POWER_SCENARIO_ON_BODY_HOTSPOT_BT_UNFOLDED = 22, 93 WIFI_POWER_SCENARIO_ON_BODY_HOTSPOT_MMW_UNFOLDED = 23, 94 WIFI_POWER_SCENARIO_ON_BODY_HOTSPOT_BT_MMW_UNFOLDED = 24, 95 } wifi_power_scenario; 96 97 typedef enum { 98 WIFI_LATENCY_MODE_NORMAL = 0, 99 WIFI_LATENCY_MODE_LOW = 1, 100 } wifi_latency_mode; 101 102 /* Wifi Thermal mitigation modes */ 103 typedef enum { 104 WIFI_MITIGATION_NONE = 0, 105 WIFI_MITIGATION_LIGHT = 1, 106 WIFI_MITIGATION_MODERATE = 2, 107 WIFI_MITIGATION_SEVERE = 3, 108 WIFI_MITIGATION_CRITICAL = 4, 109 WIFI_MITIGATION_EMERGENCY = 5, 110 } wifi_thermal_mode; 111 112 /* 113 * Wifi voice over IP mode 114 * may add new modes later, for example, voice + video over IP mode. 115 */ 116 typedef enum { 117 WIFI_VOIP_MODE_OFF = 0, 118 WIFI_VOIP_MODE_ON = 1, 119 } wifi_voip_mode; 120 121 /* List of interface types supported */ 122 typedef enum { 123 WIFI_INTERFACE_TYPE_STA = 0, 124 WIFI_INTERFACE_TYPE_AP = 1, 125 WIFI_INTERFACE_TYPE_P2P = 2, 126 WIFI_INTERFACE_TYPE_NAN = 3, 127 } wifi_interface_type; 128 129 /* 130 * enum wlan_mac_band - Band information corresponding to the WLAN MAC. 131 */ 132 typedef enum { 133 /* WLAN MAC Operates in 2.4 GHz Band */ 134 WLAN_MAC_2_4_BAND = 1 << 0, 135 /* WLAN MAC Operates in 5 GHz Band */ 136 WLAN_MAC_5_0_BAND = 1 << 1, 137 /* WLAN MAC Operates in 6 GHz Band */ 138 WLAN_MAC_6_0_BAND = 1 << 2, 139 /* WLAN MAC Operates in 60 GHz Band */ 140 WLAN_MAC_60_0_BAND = 1 << 3, 141 } wlan_mac_band; 142 143 typedef struct { 144 wifi_channel_width width; 145 int center_frequency0; 146 int center_frequency1; 147 int primary_frequency; 148 } wifi_channel_spec; 149 150 /* 151 * wifi_usable_channel specifies a channel frequency, bandwidth, and bitmask 152 * of modes allowed on the channel. 153 */ 154 typedef struct { 155 /* Channel frequency in MHz */ 156 wifi_channel freq; 157 /* Channel operating width (20, 40, 80, 160 etc.) */ 158 wifi_channel_width width; 159 /* BIT MASK of BIT(WIFI_INTERFACE_*) represented by |wifi_interface_mode| 160 * Bitmask does not represent concurrency. 161 * Examples: 162 * - If a channel is usable only for STA, then only the WIFI_INTERFACE_STA 163 * bit would be set for that channel. 164 * - If 5GHz SAP is not allowed, then none of the 5GHz channels will have 165 * WIFI_INTERFACE_SOFTAP bit set. 166 * Note: TDLS bit is set only if there is a STA connection. TDLS bit is set 167 * on non-STA channels only if TDLS off channel is supported. 168 */ 169 u32 iface_mode_mask; 170 } wifi_usable_channel; 171 172 /* 173 * wifi_usable_channel_filter 174 */ 175 typedef enum { 176 /* Filter Wifi channels that should be avoided due to cellular coex 177 * restrictions. Some Wifi channels can have extreme interference 178 * from/to cellular due to short frequency separation with neighboring 179 * cellular channels or when there is harmonic and intermodulation 180 * interference. Channels which only have some performance degradation 181 * (e.g. power back off is sufficient to deal with coexistence issue) 182 * can be included and should not be filtered out. 183 */ 184 WIFI_USABLE_CHANNEL_FILTER_CELLULAR_COEXISTENCE = 1 << 0, 185 /* Filter channels due to concurrency state. 186 * Examples: 187 * - 5GHz SAP operation may be supported in standalone mode, but if 188 * there is STA connection on 5GHz DFS channel, none of the 5GHz 189 * channels are usable for SAP if device does not support DFS SAP mode. 190 * - P2P GO may not be supported on indoor channels in EU during 191 * standalone mode but if there is a STA connection on indoor channel, 192 * P2P GO may be supported by some vendors on the same STA channel. 193 */ 194 WIFI_USABLE_CHANNEL_FILTER_CONCURRENCY = 1 << 1, 195 } wifi_usable_channel_filter; 196 197 typedef enum { 198 WIFI_SUCCESS = 0, 199 WIFI_ERROR_NONE = 0, 200 WIFI_ERROR_UNKNOWN = -1, 201 WIFI_ERROR_UNINITIALIZED = -2, 202 WIFI_ERROR_NOT_SUPPORTED = -3, 203 WIFI_ERROR_NOT_AVAILABLE = -4, // Not available right now, but try later 204 WIFI_ERROR_INVALID_ARGS = -5, 205 WIFI_ERROR_INVALID_REQUEST_ID = -6, 206 WIFI_ERROR_TIMED_OUT = -7, 207 WIFI_ERROR_TOO_MANY_REQUESTS = -8, // Too many instances of this request 208 WIFI_ERROR_OUT_OF_MEMORY = -9, 209 WIFI_ERROR_BUSY = -10, 210 } wifi_error; 211 212 typedef enum { 213 WIFI_ACCESS_CATEGORY_BEST_EFFORT = 0, 214 WIFI_ACCESS_CATEGORY_BACKGROUND = 1, 215 WIFI_ACCESS_CATEGORY_VIDEO = 2, 216 WIFI_ACCESS_CATEGORY_VOICE = 3 217 } wifi_access_category; 218 219 220 /* Initialize/Cleanup */ 221 222 wifi_error wifi_initialize(wifi_handle *handle); 223 224 /** 225 * wifi_wait_for_driver 226 * Function should block until the driver is ready to proceed. 227 * Any errors from this function is considered fatal & will fail the HAL startup sequence. 228 * 229 * on success returns WIFI_SUCCESS 230 * on failure returns WIFI_ERROR_TIMED_OUT 231 */ 232 wifi_error wifi_wait_for_driver_ready(void); 233 234 typedef void (*wifi_cleaned_up_handler) (wifi_handle handle); 235 void wifi_cleanup(wifi_handle handle, wifi_cleaned_up_handler handler); 236 void wifi_event_loop(wifi_handle handle); 237 238 /* Error handling */ 239 void wifi_get_error_info(wifi_error err, const char **msg); // return a pointer to a static string 240 241 /* Feature enums */ 242 #define WIFI_FEATURE_INFRA (uint64_t)0x1 // Basic infrastructure mode 243 #define WIFI_FEATURE_INFRA_5G (uint64_t)0x2 // Support for 5 GHz Band 244 #define WIFI_FEATURE_HOTSPOT (uint64_t)0x4 // Support for GAS/ANQP 245 #define WIFI_FEATURE_P2P (uint64_t)0x8 // Wifi-Direct 246 #define WIFI_FEATURE_SOFT_AP (uint64_t)0x10 // Soft AP 247 #define WIFI_FEATURE_GSCAN (uint64_t)0x20 // Google-Scan APIs 248 #define WIFI_FEATURE_NAN (uint64_t)0x40 // Neighbor Awareness Networking 249 #define WIFI_FEATURE_D2D_RTT (uint64_t)0x80 // Device-to-device RTT 250 #define WIFI_FEATURE_D2AP_RTT (uint64_t)0x100 // Device-to-AP RTT 251 #define WIFI_FEATURE_BATCH_SCAN (uint64_t)0x200 // Batched Scan (legacy) 252 #define WIFI_FEATURE_PNO (uint64_t)0x400 // Preferred network offload 253 #define WIFI_FEATURE_ADDITIONAL_STA (uint64_t)0x800 // Support for two STAs 254 #define WIFI_FEATURE_TDLS (uint64_t)0x1000 // Tunnel directed link setup 255 #define WIFI_FEATURE_TDLS_OFFCHANNEL (uint64_t)0x2000 // Support for TDLS off channel 256 #define WIFI_FEATURE_EPR (uint64_t)0x4000 // Enhanced power reporting 257 #define WIFI_FEATURE_AP_STA (uint64_t)0x8000 // Support for AP STA Concurrency 258 #define WIFI_FEATURE_LINK_LAYER_STATS (uint64_t)0x10000 // Link layer stats collection 259 #define WIFI_FEATURE_LOGGER (uint64_t)0x20000 // WiFi Logger 260 #define WIFI_FEATURE_HAL_EPNO (uint64_t)0x40000 // WiFi PNO enhanced 261 #define WIFI_FEATURE_RSSI_MONITOR (uint64_t)0x80000 // RSSI Monitor 262 #define WIFI_FEATURE_MKEEP_ALIVE (uint64_t)0x100000 // WiFi mkeep_alive 263 #define WIFI_FEATURE_CONFIG_NDO (uint64_t)0x200000 // ND offload configure 264 #define WIFI_FEATURE_TX_TRANSMIT_POWER (uint64_t)0x400000 // Capture Tx transmit power levels 265 #define WIFI_FEATURE_CONTROL_ROAMING (uint64_t)0x800000 // Enable/Disable firmware roaming 266 #define WIFI_FEATURE_IE_WHITELIST (uint64_t)0x1000000 // Support Probe IE white listing 267 #define WIFI_FEATURE_SCAN_RAND (uint64_t)0x2000000 // Support MAC & Probe Sequence Number randomization 268 #define WIFI_FEATURE_SET_TX_POWER_LIMIT (uint64_t)0x4000000 // Support Tx Power Limit setting 269 #define WIFI_FEATURE_USE_BODY_HEAD_SAR (uint64_t)0x8000000 // Support Using Body/Head Proximity for SAR 270 #define WIFI_FEATURE_SET_LATENCY_MODE (uint64_t)0x40000000 // Support Latency mode setting 271 #define WIFI_FEATURE_P2P_RAND_MAC (uint64_t)0x80000000 // Support P2P MAC randomization 272 #define WIFI_FEATURE_INFRA_60G (uint64_t)0x100000000 // Support for 60GHz Band 273 // Add more features here 274 275 #define IS_MASK_SET(mask, flags) (((flags) & (mask)) == (mask)) 276 277 #define IS_SUPPORTED_FEATURE(feature, featureSet) IS_MASK_SET(feature, featureSet) 278 279 /* Feature set */ 280 wifi_error wifi_get_supported_feature_set(wifi_interface_handle handle, feature_set *set); 281 282 /* 283 * Each row represents a valid feature combination; 284 * all other combinations are invalid! 285 */ 286 wifi_error wifi_get_concurrency_matrix(wifi_interface_handle handle, int set_size_max, 287 feature_set set[], int *set_size); 288 289 /* multiple interface support */ 290 291 wifi_error wifi_get_ifaces(wifi_handle handle, int *num_ifaces, wifi_interface_handle **ifaces); 292 wifi_error wifi_get_iface_name(wifi_interface_handle iface, char *name, size_t size); 293 wifi_interface_handle wifi_get_iface_handle(wifi_handle handle, char *name); 294 295 /* STA + STA support - Supported if WIFI_FEATURE_ADDITIONAL_STA is set */ 296 297 /** 298 * Invoked to indicate that the provided iface is the primary STA iface when there are more 299 * than 1 STA iface concurrently active. 300 * 301 * Note: If the wifi firmware/chip cannot support multiple instances of any offload 302 * (like roaming, APF, rssi threshold, etc), the firmware should ensure that these 303 * offloads are at least enabled for the primary interface. If the new primary interface is 304 * already connected to a network, the firmware must switch all the offloads on 305 * this new interface without disconnecting. 306 */ 307 wifi_error wifi_multi_sta_set_primary_connection(wifi_handle handle, wifi_interface_handle iface); 308 309 /** 310 * When there are 2 or more simultaneous STA connections, this use case hint indicates what 311 * use-case is being enabled by the framework. This use case hint can be used by the firmware 312 * to modify various firmware configurations like: 313 * - Allowed BSSIDs the firmware can choose for the initial connection/roaming attempts. 314 * - Duty cycle to choose for the 2 STA connections if the radio is in MCC mode. 315 * - Whether roaming, APF and other offloads needs to be enabled or not. 316 * 317 * Note: 318 * - This will be invoked before an active wifi connection is established on the second interface. 319 * - This use-case hint is implicitly void when the second STA interface is brought down. 320 */ 321 typedef enum { 322 /** 323 * Usage: 324 * - This will be sent down for make before break use-case. 325 * - Platform is trying to speculatively connect to a second network and evaluate it without 326 * disrupting the primary connection. 327 * 328 * Requirements for Firmware: 329 * - Do not reduce the number of tx/rx chains of primary connection. 330 * - If using MCC, should set the MCC duty cycle of the primary connection to be higher than 331 * the secondary connection (maybe 70/30 split). 332 * - Should pick the best BSSID for the secondary STA (disregard the chip mode) independent of 333 * the primary STA: 334 * - Don’t optimize for DBS vs MCC/SCC 335 * - Should not impact the primary connection’s bssid selection: 336 * - Don’t downgrade chains of the existing primary connection. 337 * - Don’t optimize for DBS vs MCC/SCC. 338 */ 339 WIFI_DUAL_STA_TRANSIENT_PREFER_PRIMARY = 0, 340 /** 341 * Usage: 342 * - This will be sent down for any app requested peer to peer connections. 343 * - In this case, both the connections needs to be allocated equal resources. 344 * - For the peer to peer use case, BSSID for the secondary connection will be chosen by the 345 * framework. 346 * 347 * Requirements for Firmware: 348 * - Can choose MCC or DBS mode depending on the MCC efficiency and HW capability. 349 * - If using MCC, set the MCC duty cycle of the primary connection to be equal to the secondary 350 * connection. 351 * - Prefer BSSID candidates which will help provide the best "overall" performance for both the 352 * connections. 353 */ 354 WIFI_DUAL_STA_NON_TRANSIENT_UNBIASED = 1 355 } wifi_multi_sta_use_case; 356 357 wifi_error wifi_multi_sta_set_use_case(wifi_handle handle, wifi_multi_sta_use_case use_case); 358 359 /* Configuration events */ 360 361 typedef struct { 362 void (*on_country_code_changed)(char code[2]); // We can get this from supplicant too 363 364 // More event handlers 365 } wifi_event_handler; 366 367 typedef struct { 368 char iface_name[IFNAMSIZ + 1]; 369 wifi_channel channel; 370 } wifi_iface_info; 371 372 typedef struct { 373 u32 wlan_mac_id; 374 /* BIT MASK of BIT(WLAN_MAC*) as represented by wlan_mac_band */ 375 u32 mac_band; 376 /* Represents the connected Wi-Fi interfaces associated with each MAC */ 377 int num_iface; 378 wifi_iface_info *iface_info; 379 } wifi_mac_info; 380 381 typedef struct { 382 void (*on_radio_mode_change)(wifi_request_id id, unsigned num_mac, 383 wifi_mac_info *mac_info); 384 } wifi_radio_mode_change_handler; 385 386 typedef struct { 387 void (*on_rssi_threshold_breached)(wifi_request_id id, u8 *cur_bssid, s8 cur_rssi); 388 } wifi_rssi_event_handler; 389 390 typedef struct { 391 void (*on_subsystem_restart)(const char* error); 392 } wifi_subsystem_restart_handler; 393 394 wifi_error wifi_set_iface_event_handler(wifi_request_id id, wifi_interface_handle iface, wifi_event_handler eh); 395 wifi_error wifi_reset_iface_event_handler(wifi_request_id id, wifi_interface_handle iface); 396 397 wifi_error wifi_set_nodfs_flag(wifi_interface_handle handle, u32 nodfs); 398 wifi_error wifi_select_tx_power_scenario(wifi_interface_handle handle, wifi_power_scenario scenario); 399 wifi_error wifi_reset_tx_power_scenario(wifi_interface_handle handle); 400 wifi_error wifi_set_latency_mode(wifi_interface_handle handle, wifi_latency_mode mode); 401 wifi_error wifi_map_dscp_access_category(wifi_handle handle, 402 uint32_t start, uint32_t end, 403 uint32_t access_category); 404 wifi_error wifi_reset_dscp_mapping(wifi_handle handle); 405 406 wifi_error wifi_set_subsystem_restart_handler(wifi_handle handle, 407 wifi_subsystem_restart_handler handler); 408 409 /** 410 * Wifi HAL Thermal Mitigation API 411 * 412 * wifi_handle : wifi global handle (note: this is not a interface specific 413 * command). Mitigation is expected to be applied across all active interfaces 414 * The implementation and the mitigation action mapping to each mode is chip 415 * specific. Mitigation will be active until Wifi is turned off or 416 * WIFI_MITIGATION_NONE mode is sent 417 * 418 * mode: Thermal mitigation mode 419 * WIFI_MITIGATION_NONE : Clear all Wifi thermal mitigation actions 420 * WIFI_MITIGATION_LIGHT : Light Throttling where UX is not impacted 421 * WIFI_MITIGATION_MODERATE : Moderate throttling where UX not largely impacted 422 * WIFI_MITIGATION_SEVERE : Severe throttling where UX is largely impacted 423 * WIFI_MITIGATION_CRITICAL : Platform has done everything to reduce power 424 * WIFI_MITIGATION_EMERGENCY: Key components in platform are shutting down 425 * 426 * completion_window 427 * Deadline (in milliseconds) to complete this request, value 0 implies apply 428 * immediately. Deadline is basically a relaxed limit and allows vendors to 429 * apply the mitigation within the window (if it cannot apply immediately) 430 * 431 * Return 432 * WIFI_ERROR_NOT_SUPPORTED : Chip does not support thermal mitigation 433 * WIFI_ERROR_BUSY : Mitigation is supported, but retry later 434 * WIFI_ERROR_NONE : Mitigation request has been accepted 435 */ 436 wifi_error wifi_set_thermal_mitigation_mode(wifi_handle handle, 437 wifi_thermal_mode mode, 438 u32 completion_window); 439 440 441 typedef struct rx_data_cnt_details_t { 442 int rx_unicast_cnt; /*Total rx unicast packet which woke up host */ 443 int rx_multicast_cnt; /*Total rx multicast packet which woke up host */ 444 int rx_broadcast_cnt; /*Total rx broadcast packet which woke up host */ 445 } RX_DATA_WAKE_CNT_DETAILS; 446 447 typedef struct rx_wake_pkt_type_classification_t { 448 int icmp_pkt; /*wake icmp packet count */ 449 int icmp6_pkt; /*wake icmp6 packet count */ 450 int icmp6_ra; /*wake icmp6 RA packet count */ 451 int icmp6_na; /*wake icmp6 NA packet count */ 452 int icmp6_ns; /*wake icmp6 NS packet count */ 453 //ToDo: Any more interesting classification to add? 454 } RX_WAKE_PKT_TYPE_CLASSFICATION; 455 456 typedef struct rx_multicast_cnt_t{ 457 int ipv4_rx_multicast_addr_cnt; /*Rx wake packet was ipv4 multicast */ 458 int ipv6_rx_multicast_addr_cnt; /*Rx wake packet was ipv6 multicast */ 459 int other_rx_multicast_addr_cnt;/*Rx wake packet was non-ipv4 and non-ipv6*/ 460 } RX_MULTICAST_WAKE_DATA_CNT; 461 462 /* 463 * Structure holding all the driver/firmware wake count reasons. 464 * 465 * Buffers for the array fields (cmd_event_wake_cnt/driver_fw_local_wake_cnt) 466 * are allocated and freed by the framework. The size of each allocated 467 * array is indicated by the corresponding |_cnt| field. HAL needs to fill in 468 * the corresponding |_used| field to indicate the number of elements used in 469 * the array. 470 */ 471 typedef struct wlan_driver_wake_reason_cnt_t { 472 int total_cmd_event_wake; /* Total count of cmd event wakes */ 473 int *cmd_event_wake_cnt; /* Individual wake count array, each index a reason */ 474 int cmd_event_wake_cnt_sz; /* Max number of cmd event wake reasons */ 475 int cmd_event_wake_cnt_used; /* Number of cmd event wake reasons specific to the driver */ 476 477 int total_driver_fw_local_wake; /* Total count of drive/fw wakes, for local reasons */ 478 int *driver_fw_local_wake_cnt; /* Individual wake count array, each index a reason */ 479 int driver_fw_local_wake_cnt_sz; /* Max number of local driver/fw wake reasons */ 480 int driver_fw_local_wake_cnt_used; /* Number of local driver/fw wake reasons specific to the driver */ 481 482 int total_rx_data_wake; /* total data rx packets, that woke up host */ 483 RX_DATA_WAKE_CNT_DETAILS rx_wake_details; 484 RX_WAKE_PKT_TYPE_CLASSFICATION rx_wake_pkt_classification_info; 485 RX_MULTICAST_WAKE_DATA_CNT rx_multicast_wake_pkt_info; 486 } WLAN_DRIVER_WAKE_REASON_CNT; 487 488 /* Wi-Fi coex channel avoidance support */ 489 490 #define WIFI_COEX_NO_POWER_CAP (int32_t)0x7FFFFFF 491 492 typedef enum { 493 WIFI_AWARE = 1 << 0, 494 SOFTAP = 1 << 1, 495 WIFI_DIRECT = 1 << 2 496 } wifi_coex_restriction; 497 498 /** 499 * Representation of a Wi-Fi channel to be avoided for Wi-Fi coex channel avoidance. 500 * 501 * band is represented as an WLAN_MAC* enum value defined in wlan_mac_band. 502 * If power_cap_dbm is WIFI_COEX_NO_POWER_CAP, then no power cap should be applied if the specified 503 * channel is used. 504 */ 505 typedef struct { 506 wlan_mac_band band; 507 u32 channel; 508 s32 power_cap_dbm; 509 } wifi_coex_unsafe_channel; 510 511 512 /* include various feature headers */ 513 514 #include "gscan.h" 515 #include "link_layer_stats.h" 516 #include "rtt.h" 517 #include "tdls.h" 518 #include "wifi_logger.h" 519 #include "wifi_config.h" 520 #include "wifi_nan.h" 521 #include "wifi_offload.h" 522 #include "roam.h" 523 #include "wifi_twt.h" 524 525 //wifi HAL function pointer table 526 typedef struct { 527 wifi_error (* wifi_initialize) (wifi_handle *); 528 wifi_error (* wifi_wait_for_driver_ready) (void); 529 void (* wifi_cleanup) (wifi_handle, wifi_cleaned_up_handler); 530 void (*wifi_event_loop)(wifi_handle); 531 void (* wifi_get_error_info) (wifi_error , const char **); 532 wifi_error (* wifi_get_supported_feature_set) (wifi_interface_handle, feature_set *); 533 wifi_error (* wifi_get_concurrency_matrix) (wifi_interface_handle, int, feature_set *, int *); 534 wifi_error (* wifi_set_scanning_mac_oui) (wifi_interface_handle, unsigned char *); 535 wifi_error (* wifi_get_supported_channels)(wifi_handle, int *, wifi_channel *); 536 wifi_error (* wifi_is_epr_supported)(wifi_handle); 537 wifi_error (* wifi_get_ifaces) (wifi_handle , int *, wifi_interface_handle **); 538 wifi_error (* wifi_get_iface_name) (wifi_interface_handle, char *name, size_t); 539 wifi_error (* wifi_set_iface_event_handler) (wifi_request_id,wifi_interface_handle , 540 wifi_event_handler); 541 wifi_error (* wifi_reset_iface_event_handler) (wifi_request_id, wifi_interface_handle); 542 wifi_error (* wifi_start_gscan) (wifi_request_id, wifi_interface_handle, wifi_scan_cmd_params, 543 wifi_scan_result_handler); 544 wifi_error (* wifi_stop_gscan)(wifi_request_id, wifi_interface_handle); 545 wifi_error (* wifi_get_cached_gscan_results)(wifi_interface_handle, byte, int, 546 wifi_cached_scan_results *, int *); 547 wifi_error (* wifi_set_bssid_hotlist)(wifi_request_id, wifi_interface_handle, 548 wifi_bssid_hotlist_params, wifi_hotlist_ap_found_handler); 549 wifi_error (* wifi_reset_bssid_hotlist)(wifi_request_id, wifi_interface_handle); 550 wifi_error (* wifi_set_significant_change_handler)(wifi_request_id, wifi_interface_handle, 551 wifi_significant_change_params, wifi_significant_change_handler); 552 wifi_error (* wifi_reset_significant_change_handler)(wifi_request_id, wifi_interface_handle); 553 wifi_error (* wifi_get_gscan_capabilities)(wifi_interface_handle, wifi_gscan_capabilities *); 554 wifi_error (* wifi_set_link_stats) (wifi_interface_handle, wifi_link_layer_params); 555 wifi_error (* wifi_get_link_stats) (wifi_request_id,wifi_interface_handle, 556 wifi_stats_result_handler); 557 wifi_error (* wifi_clear_link_stats)(wifi_interface_handle,u32, u32 *, u8, u8 *); 558 wifi_error (* wifi_get_valid_channels)(wifi_interface_handle,int, int, wifi_channel *, int *); 559 wifi_error (* wifi_rtt_range_request)(wifi_request_id, wifi_interface_handle, unsigned, 560 wifi_rtt_config[], wifi_rtt_event_handler); 561 wifi_error (* wifi_rtt_range_cancel)(wifi_request_id, wifi_interface_handle, unsigned, 562 mac_addr[]); 563 wifi_error (* wifi_get_rtt_capabilities)(wifi_interface_handle, wifi_rtt_capabilities *); 564 wifi_error (* wifi_rtt_get_responder_info)(wifi_interface_handle iface, 565 wifi_rtt_responder *responder_info); 566 wifi_error (* wifi_enable_responder)(wifi_request_id id, wifi_interface_handle iface, 567 wifi_channel_info channel_hint, unsigned max_duration_seconds, 568 wifi_rtt_responder *responder_info); 569 wifi_error (* wifi_disable_responder)(wifi_request_id id, wifi_interface_handle iface); 570 wifi_error (* wifi_set_nodfs_flag)(wifi_interface_handle, u32); 571 wifi_error (* wifi_start_logging)(wifi_interface_handle, u32, u32, u32, u32, char *); 572 wifi_error (* wifi_set_epno_list)(wifi_request_id, wifi_interface_handle, 573 const wifi_epno_params *, wifi_epno_handler); 574 wifi_error (* wifi_reset_epno_list)(wifi_request_id, wifi_interface_handle); 575 wifi_error (* wifi_set_country_code)(wifi_interface_handle, const char *); 576 wifi_error (* wifi_get_firmware_memory_dump)( wifi_interface_handle iface, 577 wifi_firmware_memory_dump_handler handler); 578 wifi_error (* wifi_set_log_handler)(wifi_request_id id, wifi_interface_handle iface, 579 wifi_ring_buffer_data_handler handler); 580 wifi_error (* wifi_reset_log_handler)(wifi_request_id id, wifi_interface_handle iface); 581 wifi_error (* wifi_set_alert_handler)(wifi_request_id id, wifi_interface_handle iface, 582 wifi_alert_handler handler); 583 wifi_error (* wifi_reset_alert_handler)(wifi_request_id id, wifi_interface_handle iface); 584 wifi_error (* wifi_get_firmware_version)(wifi_interface_handle iface, char *buffer, 585 int buffer_size); 586 wifi_error (* wifi_get_ring_buffers_status)(wifi_interface_handle iface, 587 u32 *num_rings, wifi_ring_buffer_status *status); 588 wifi_error (* wifi_get_logger_supported_feature_set)(wifi_interface_handle iface, 589 unsigned int *support); 590 wifi_error (* wifi_get_ring_data)(wifi_interface_handle iface, char *ring_name); 591 wifi_error (* wifi_enable_tdls)(wifi_interface_handle, mac_addr, wifi_tdls_params *, 592 wifi_tdls_handler); 593 wifi_error (* wifi_disable_tdls)(wifi_interface_handle, mac_addr); 594 wifi_error (*wifi_get_tdls_status) (wifi_interface_handle, mac_addr, wifi_tdls_status *); 595 wifi_error (*wifi_get_tdls_capabilities)(wifi_interface_handle iface, 596 wifi_tdls_capabilities *capabilities); 597 wifi_error (* wifi_get_driver_version)(wifi_interface_handle iface, char *buffer, 598 int buffer_size); 599 wifi_error (* wifi_set_passpoint_list)(wifi_request_id id, wifi_interface_handle iface, 600 int num, wifi_passpoint_network *networks, wifi_passpoint_event_handler handler); 601 wifi_error (* wifi_reset_passpoint_list)(wifi_request_id id, wifi_interface_handle iface); 602 wifi_error (*wifi_set_lci) (wifi_request_id id, wifi_interface_handle iface, 603 wifi_lci_information *lci); 604 wifi_error (*wifi_set_lcr) (wifi_request_id id, wifi_interface_handle iface, 605 wifi_lcr_information *lcr); 606 wifi_error (*wifi_start_sending_offloaded_packet)(wifi_request_id id, 607 wifi_interface_handle iface, u16 ether_type, u8 *ip_packet, 608 u16 ip_packet_len, u8 *src_mac_addr, u8 *dst_mac_addr, 609 u32 period_msec); 610 wifi_error (*wifi_stop_sending_offloaded_packet)(wifi_request_id id, 611 wifi_interface_handle iface); 612 wifi_error (*wifi_start_rssi_monitoring)(wifi_request_id id, wifi_interface_handle 613 iface, s8 max_rssi, s8 min_rssi, wifi_rssi_event_handler eh); 614 wifi_error (*wifi_stop_rssi_monitoring)(wifi_request_id id, wifi_interface_handle iface); 615 wifi_error (*wifi_get_wake_reason_stats)(wifi_interface_handle iface, 616 WLAN_DRIVER_WAKE_REASON_CNT *wifi_wake_reason_cnt); 617 wifi_error (*wifi_configure_nd_offload)(wifi_interface_handle iface, u8 enable); 618 wifi_error (*wifi_get_driver_memory_dump)(wifi_interface_handle iface, 619 wifi_driver_memory_dump_callbacks callbacks); 620 wifi_error (*wifi_start_pkt_fate_monitoring)(wifi_interface_handle iface); 621 wifi_error (*wifi_get_tx_pkt_fates)(wifi_interface_handle handle, 622 wifi_tx_report *tx_report_bufs, 623 size_t n_requested_fates, 624 size_t *n_provided_fates); 625 wifi_error (*wifi_get_rx_pkt_fates)(wifi_interface_handle handle, 626 wifi_rx_report *rx_report_bufs, 627 size_t n_requested_fates, 628 size_t *n_provided_fates); 629 630 /* NAN functions */ 631 wifi_error (*wifi_nan_enable_request)(transaction_id id, 632 wifi_interface_handle iface, 633 NanEnableRequest* msg); 634 wifi_error (*wifi_nan_disable_request)(transaction_id id, 635 wifi_interface_handle iface); 636 wifi_error (*wifi_nan_publish_request)(transaction_id id, 637 wifi_interface_handle iface, 638 NanPublishRequest* msg); 639 wifi_error (*wifi_nan_publish_cancel_request)(transaction_id id, 640 wifi_interface_handle iface, 641 NanPublishCancelRequest* msg); 642 wifi_error (*wifi_nan_subscribe_request)(transaction_id id, 643 wifi_interface_handle iface, 644 NanSubscribeRequest* msg); 645 wifi_error (*wifi_nan_subscribe_cancel_request)(transaction_id id, 646 wifi_interface_handle iface, 647 NanSubscribeCancelRequest* msg); 648 wifi_error (*wifi_nan_transmit_followup_request)(transaction_id id, 649 wifi_interface_handle iface, 650 NanTransmitFollowupRequest* msg); 651 wifi_error (*wifi_nan_stats_request)(transaction_id id, 652 wifi_interface_handle iface, 653 NanStatsRequest* msg); 654 wifi_error (*wifi_nan_config_request)(transaction_id id, 655 wifi_interface_handle iface, 656 NanConfigRequest* msg); 657 wifi_error (*wifi_nan_tca_request)(transaction_id id, 658 wifi_interface_handle iface, 659 NanTCARequest* msg); 660 wifi_error (*wifi_nan_beacon_sdf_payload_request)(transaction_id id, 661 wifi_interface_handle iface, 662 NanBeaconSdfPayloadRequest* msg); 663 wifi_error (*wifi_nan_register_handler)(wifi_interface_handle iface, 664 NanCallbackHandler handlers); 665 wifi_error (*wifi_nan_get_version)(wifi_handle handle, 666 NanVersion* version); 667 wifi_error (*wifi_nan_get_capabilities)(transaction_id id, 668 wifi_interface_handle iface); 669 wifi_error (*wifi_nan_data_interface_create)(transaction_id id, 670 wifi_interface_handle iface, 671 char *iface_name); 672 wifi_error (*wifi_nan_data_interface_delete)(transaction_id id, 673 wifi_interface_handle iface, 674 char *iface_name); 675 wifi_error (*wifi_nan_data_request_initiator)( 676 transaction_id id, wifi_interface_handle iface, 677 NanDataPathInitiatorRequest *msg); 678 wifi_error (*wifi_nan_data_indication_response)( 679 transaction_id id, wifi_interface_handle iface, 680 NanDataPathIndicationResponse *msg); 681 wifi_error (*wifi_nan_data_end)(transaction_id id, 682 wifi_interface_handle iface, 683 NanDataPathEndRequest *msg); 684 wifi_error (*wifi_select_tx_power_scenario)(wifi_interface_handle iface, 685 wifi_power_scenario scenario); 686 wifi_error (*wifi_reset_tx_power_scenario)(wifi_interface_handle iface); 687 688 /** 689 * Returns the chipset's hardware filtering capabilities: 690 * @param version pointer to version of the packet filter interpreter 691 * supported, filled in upon return. 0 indicates no support. 692 * @param max_len pointer to maximum size of the filter bytecode, filled in 693 * upon return. 694 */ 695 wifi_error (*wifi_get_packet_filter_capabilities)(wifi_interface_handle handle, 696 u32 *version, u32 *max_len); 697 /** 698 * Programs the packet filter. 699 * @param program pointer to the program byte-code. 700 * @param len length of the program byte-code. 701 */ 702 wifi_error (*wifi_set_packet_filter)(wifi_interface_handle handle, 703 const u8 *program, u32 len); 704 wifi_error (*wifi_read_packet_filter)(wifi_interface_handle handle, 705 u32 src_offset, u8 *host_dst, 706 u32 length); 707 wifi_error (*wifi_get_roaming_capabilities)(wifi_interface_handle handle, 708 wifi_roaming_capabilities *caps); 709 wifi_error (*wifi_enable_firmware_roaming)(wifi_interface_handle handle, 710 fw_roaming_state_t state); 711 wifi_error (*wifi_configure_roaming)(wifi_interface_handle handle, 712 wifi_roaming_config *roaming_config); 713 wifi_error (*wifi_set_radio_mode_change_handler)(wifi_request_id id, wifi_interface_handle 714 iface, wifi_radio_mode_change_handler eh); 715 wifi_error (*wifi_set_latency_mode)(wifi_interface_handle iface, 716 wifi_latency_mode mode); 717 wifi_error (*wifi_set_thermal_mitigation_mode)(wifi_handle handle, 718 wifi_thermal_mode mode, 719 u32 completion_window); 720 wifi_error (*wifi_map_dscp_access_category)(wifi_handle handle, 721 u32 start, u32 end, 722 u32 access_category); 723 wifi_error (*wifi_reset_dscp_mapping)(wifi_handle handle); 724 725 wifi_error (*wifi_virtual_interface_create)(wifi_handle handle, const char* ifname, 726 wifi_interface_type iface_type); 727 wifi_error (*wifi_virtual_interface_delete)(wifi_handle handle, const char* ifname); 728 729 wifi_error (*wifi_set_subsystem_restart_handler)(wifi_handle handle, 730 wifi_subsystem_restart_handler handler); 731 732 /** 733 * Allow vendor HAL to choose interface name when creating 734 * an interface. This can be implemented by chips with their 735 * own interface naming policy. 736 * If not implemented, the default naming will be used. 737 */ 738 wifi_error (*wifi_get_supported_iface_name)(wifi_handle handle, u32 iface_type, 739 char *name, size_t len); 740 741 /** 742 * Perform early initialization steps that are needed when WIFI 743 * is disabled. 744 * If the function returns failure, it means the vendor HAL is unusable 745 * (for example, if chip hardware is not installed) and no further 746 * functions should be called. 747 */ 748 wifi_error (*wifi_early_initialize)(void); 749 750 /** 751 * Get supported feature set which are chip-global, that is 752 * not dependent on any created interface. 753 */ 754 wifi_error (*wifi_get_chip_feature_set)(wifi_handle handle, feature_set *set); 755 756 /** 757 * Invoked to indicate that the provided iface is the primary STA iface when there are more 758 * than 1 STA iface concurrently active. 759 */ 760 wifi_error (*wifi_multi_sta_set_primary_connection)(wifi_handle handle, 761 wifi_interface_handle iface); 762 763 764 /** 765 * When there are 2 simultaneous STA connections, this use case hint 766 * indicates what STA + STA use-case is being enabled by the framework. 767 */ 768 wifi_error (*wifi_multi_sta_set_use_case)(wifi_handle handle, 769 wifi_multi_sta_use_case use_case); 770 771 /** 772 * Invoked to indicate that the following list of wifi_coex_unsafe_channel should be avoided 773 * with the specified restrictions. 774 * @param unsafeChannels list of current |wifi_coex_unsafe_channel| to avoid. 775 * @param restrictions bitmask of |wifi_coex_restriction| indicating wifi interfaces to 776 * restrict from the current unsafe channels. 777 */ 778 wifi_error (*wifi_set_coex_unsafe_channels)(wifi_handle handle, u32 num_channels, 779 wifi_coex_unsafe_channel *unsafeChannels, 780 u32 restrictions); 781 782 /** 783 * Invoked to set voip optimization mode for the provided STA iface 784 */ 785 wifi_error (*wifi_set_voip_mode)(wifi_interface_handle iface, wifi_voip_mode mode); 786 787 /**@brief twt_register_handler 788 * Request to register TWT callback before sending any TWT request 789 * @param wifi_interface_handle: 790 * @param TwtCallbackHandler: callback function pointers 791 * @return Synchronous wifi_error 792 */ 793 wifi_error (*wifi_twt_register_handler)(wifi_interface_handle iface, 794 TwtCallbackHandler handler); 795 796 /**@brief twt_get_capability 797 * Request TWT capability 798 * @param wifi_interface_handle: 799 * @return Synchronous wifi_error and TwtCapabilitySet 800 */ 801 wifi_error (*wifi_twt_get_capability)(wifi_interface_handle iface, 802 TwtCapabilitySet* twt_cap_set); 803 804 /**@brief twt_setup_request 805 * Request to send TWT setup frame 806 * @param wifi_interface_handle: 807 * @param TwtSetupRequest: detailed parameters of setup request 808 * @return Synchronous wifi_error 809 * @return Asynchronous EventTwtSetupResponse CB return TwtSetupResponse 810 */ 811 wifi_error (*wifi_twt_setup_request)(wifi_interface_handle iface, 812 TwtSetupRequest* msg); 813 814 /**@brief twt_teardown_request 815 * Request to send TWT teardown frame 816 * @param wifi_interface_handle: 817 * @param TwtTeardownRequest: detailed parameters of teardown request 818 * @return Synchronous wifi_error 819 * @return Asynchronous EventTwtTeardownCompletion CB return TwtTeardownCompletion 820 * TwtTeardownCompletion may also be received due to other events 821 * like CSA, BTCX, TWT scheduler, MultiConnection, peer-initiated teardown, etc. 822 */ 823 wifi_error (*wifi_twt_teardown_request)(wifi_interface_handle iface, 824 TwtTeardownRequest* msg); 825 826 /**@brief twt_info_frame_request 827 * Request to send TWT info frame 828 * @param wifi_interface_handle: 829 * @param TwtInfoFrameRequest: detailed parameters in info frame 830 * @return Synchronous wifi_error 831 * @return Asynchronous EventTwtInfoFrameReceived CB return TwtInfoFrameReceived 832 * Driver may also receive Peer-initiated TwtInfoFrame 833 */ 834 wifi_error (*wifi_twt_info_frame_request)(wifi_interface_handle iface, 835 TwtInfoFrameRequest* msg); 836 837 /**@brief twt_get_stats 838 * Request to get TWT stats 839 * @param wifi_interface_handle: 840 * @param config_id: configuration ID of TWT request 841 * @return Synchronous wifi_error and TwtStats 842 */ 843 wifi_error (*wifi_twt_get_stats)(wifi_interface_handle iface, u8 config_id, 844 TwtStats* stats); 845 846 /**@brief twt_clear_stats 847 * Request to clear TWT stats 848 * @param wifi_interface_handle: 849 * @param config_id: configuration ID of TWT request 850 * @return Synchronous wifi_error 851 */ 852 wifi_error (*wifi_twt_clear_stats)(wifi_interface_handle iface, u8 config_id); 853 854 /** 855 * Invoked to set DTIM configuration when the host is in the suspend mode 856 * @param wifi_interface_handle: 857 * @param multiplier: when STA in the power saving mode, the wake up interval will be set to 858 * 1) multiplier * DTIM period if multiplier > 0. 859 * 2) the device default value if multiplier <=0 860 * Some implementations may apply an additional cap to wake up interval in the case of 1). 861 */ 862 wifi_error (*wifi_set_dtim_config)(wifi_interface_handle handle, u32 multiplier); 863 864 /**@brief wifi_get_usable_channels 865 * Request list of usable channels for the requested bands and modes. Usable 866 * implies channel is allowed as per regulatory for the current country code 867 * and not restricted due to other hard limitations (e.g. DFS, Coex) In 868 * certain modes (e.g. STA+SAP) there could be other hard restrictions 869 * since MCC operation many not be supported by SAP. This API also allows 870 * driver to return list of usable channels for each mode uniquely to 871 * distinguish cases where only a limited set of modes are allowed on 872 * a given channel e.g. srd channels may be supported for P2P but not 873 * for SAP or P2P-Client may be allowed on an indoor channel but P2P-GO 874 * may not be allowed. This API is not interface specific and will be 875 * used to query capabilities of driver in terms of what modes (STA, SAP, 876 * P2P_CLI, P2P_GO, NAN, TDLS) can be supported on each of the channels. 877 * @param handle global wifi_handle 878 * @param band_mask BIT MASK of WLAN_MAC* as represented by |wlan_mac_band| 879 * @param iface_mode_mask BIT MASK of BIT(WIFI_INTERFACE_*) represented by 880 * |wifi_interface_mode|. Bitmask respresents all the modes that the 881 * caller is interested in (e.g. STA, SAP, WFD-CLI, WFD-GO, TDLS, NAN). 882 * Note: Bitmask does not represent concurrency matrix. If the caller 883 * is interested in CLI, GO modes, the iface_mode_mask would be set 884 * to WIFI_INTERFACE_P2P_CLIENT|WIFI_INTERFACE_P2P_GO. 885 * @param filter_mask BIT MASK of WIFI_USABLE_CHANNEL_FILTER_* represented by 886 * |wifi_usable_channel_filter|. Indicates if the channel list should 887 * be filtered based on additional criteria. If filter_mask is not 888 * specified, driver should return list of usable channels purely 889 * based on regulatory constraints. 890 * @param max_size maximum number of |wifi_usable_channel| 891 * @param size actual number of |wifi_usable_channel| entries returned by driver 892 * @param channels list of usable channels represented by |wifi_usable_channel| 893 */ 894 wifi_error (*wifi_get_usable_channels)(wifi_handle handle, u32 band_mask, u32 iface_mode_mask, 895 u32 filter_mask, u32 max_size, u32* size, 896 wifi_usable_channel* channels); 897 898 /** 899 * Trigger wifi subsystem restart to reload firmware 900 */ 901 wifi_error (*wifi_trigger_subsystem_restart)(wifi_handle handle); 902 /* 903 * when adding new functions make sure to add stubs in 904 * hal_tool.cpp::init_wifi_stub_hal_func_table 905 */ 906 } wifi_hal_fn; 907 908 wifi_error init_wifi_vendor_hal_func_table(wifi_hal_fn *fn); 909 typedef wifi_error (*init_wifi_vendor_hal_func_table_t)(wifi_hal_fn *fn); 910 911 #ifdef __cplusplus 912 } 913 #endif 914 915 #endif 916