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