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 #define UNSPECIFIED -1 // wifi HAL common definition for unspecified value 28 29 /* typedefs */ 30 typedef unsigned char byte; 31 typedef unsigned char u8; 32 typedef signed char s8; 33 typedef uint16_t u16; 34 typedef uint32_t u32; 35 typedef int32_t s32; 36 typedef uint64_t u64; 37 typedef int64_t s64; 38 typedef int wifi_request_id; 39 typedef int wifi_channel; // indicates channel frequency in MHz 40 typedef int wifi_rssi; 41 typedef int wifi_radio; 42 typedef byte mac_addr[6]; 43 typedef byte oui[3]; 44 typedef int64_t wifi_timestamp; // In microseconds (us) 45 typedef int64_t wifi_timespan; // In picoseconds (ps) 46 typedef uint64_t feature_set; 47 48 /* forward declarations */ 49 struct wifi_info; 50 struct wifi_interface_info; 51 typedef struct wifi_info *wifi_handle; 52 typedef struct wifi_interface_info *wifi_interface_handle; 53 54 /* WiFi Common definitions */ 55 /* channel operating width */ 56 typedef enum { 57 WIFI_CHAN_WIDTH_20 = 0, 58 WIFI_CHAN_WIDTH_40 = 1, 59 WIFI_CHAN_WIDTH_80 = 2, 60 WIFI_CHAN_WIDTH_160 = 3, 61 WIFI_CHAN_WIDTH_80P80 = 4, 62 WIFI_CHAN_WIDTH_5 = 5, 63 WIFI_CHAN_WIDTH_10 = 6, 64 WIFI_CHAN_WIDTH_320 = 7, 65 WIFI_CHAN_WIDTH_INVALID = -1 66 } wifi_channel_width; 67 68 /* Multi-Link Operation modes */ 69 typedef enum { 70 WIFI_MLO_MODE_DEFAULT = 0, 71 WIFI_MLO_MODE_LOW_LATENCY = 1, 72 WIFI_MLO_MODE_HIGH_THROUGHPUT = 2, 73 WIFI_MLO_MODE_LOW_POWER = 3, 74 } wifi_mlo_mode; 75 76 /* Pre selected Power scenarios to be applied from BDF file */ 77 typedef enum { 78 WIFI_POWER_SCENARIO_INVALID = -2, 79 WIFI_POWER_SCENARIO_DEFAULT = -1, 80 WIFI_POWER_SCENARIO_VOICE_CALL = 0, 81 WIFI_POWER_SCENARIO_ON_HEAD_CELL_OFF = 1, 82 WIFI_POWER_SCENARIO_ON_HEAD_CELL_ON = 2, 83 WIFI_POWER_SCENARIO_ON_BODY_CELL_OFF = 3, 84 WIFI_POWER_SCENARIO_ON_BODY_CELL_ON = 4, 85 WIFI_POWER_SCENARIO_ON_BODY_BT = 5, 86 WIFI_POWER_SCENARIO_ON_HEAD_HOTSPOT = 6, 87 WIFI_POWER_SCENARIO_ON_HEAD_HOTSPOT_MMW = 7, 88 WIFI_POWER_SCENARIO_ON_BODY_CELL_ON_BT = 8, 89 WIFI_POWER_SCENARIO_ON_BODY_HOTSPOT = 9, 90 WIFI_POWER_SCENARIO_ON_BODY_HOTSPOT_BT = 10, 91 WIFI_POWER_SCENARIO_ON_BODY_HOTSPOT_MMW = 11, 92 WIFI_POWER_SCENARIO_ON_BODY_HOTSPOT_BT_MMW = 12, 93 WIFI_POWER_SCENARIO_ON_HEAD_CELL_OFF_UNFOLDED = 13, 94 WIFI_POWER_SCENARIO_ON_HEAD_CELL_ON_UNFOLDED = 14, 95 WIFI_POWER_SCENARIO_ON_HEAD_HOTSPOT_UNFOLDED = 15, 96 WIFI_POWER_SCENARIO_ON_HEAD_HOTSPOT_MMW_UNFOLDED = 16, 97 WIFI_POWER_SCENARIO_ON_BODY_CELL_OFF_UNFOLDED = 17, 98 WIFI_POWER_SCENARIO_ON_BODY_BT_UNFOLDED = 18, 99 WIFI_POWER_SCENARIO_ON_BODY_CELL_ON_UNFOLDED = 19, 100 WIFI_POWER_SCENARIO_ON_BODY_CELL_ON_BT_UNFOLDED = 20, 101 WIFI_POWER_SCENARIO_ON_BODY_HOTSPOT_UNFOLDED = 21, 102 WIFI_POWER_SCENARIO_ON_BODY_HOTSPOT_BT_UNFOLDED = 22, 103 WIFI_POWER_SCENARIO_ON_BODY_HOTSPOT_MMW_UNFOLDED = 23, 104 WIFI_POWER_SCENARIO_ON_BODY_HOTSPOT_BT_MMW_UNFOLDED = 24, 105 WIFI_POWER_SCENARIO_ON_BODY_REAR_CAMERA = 25, 106 WIFI_POWER_SCENARIO_ON_BODY_CELL_OFF_UNFOLDED_CAP = 26, 107 WIFI_POWER_SCENARIO_ON_BODY_BT_UNFOLDED_CAP = 27, 108 WIFI_POWER_SCENARIO_ON_BODY_CELL_ON_UNFOLDED_CAP = 28, 109 WIFI_POWER_SCENARIO_ON_BODY_CELL_ON_BT_UNFOLDED_CAP = 29, 110 } wifi_power_scenario; 111 112 typedef enum { 113 WIFI_LATENCY_MODE_NORMAL = 0, 114 WIFI_LATENCY_MODE_LOW = 1, 115 } wifi_latency_mode; 116 117 /* Wifi Thermal mitigation modes */ 118 typedef enum { 119 WIFI_MITIGATION_NONE = 0, 120 WIFI_MITIGATION_LIGHT = 1, 121 WIFI_MITIGATION_MODERATE = 2, 122 WIFI_MITIGATION_SEVERE = 3, 123 WIFI_MITIGATION_CRITICAL = 4, 124 WIFI_MITIGATION_EMERGENCY = 5, 125 } wifi_thermal_mode; 126 127 /* 128 * Wifi voice over IP mode 129 * may add new modes later, for example, voice + video over IP mode. 130 */ 131 typedef enum { 132 WIFI_VOIP_MODE_OFF = 0, 133 WIFI_VOIP_MODE_VOICE = 1, 134 } wifi_voip_mode; 135 136 /* List of interface types supported */ 137 typedef enum { 138 WIFI_INTERFACE_TYPE_STA = 0, 139 WIFI_INTERFACE_TYPE_AP = 1, 140 WIFI_INTERFACE_TYPE_P2P = 2, 141 WIFI_INTERFACE_TYPE_NAN = 3, 142 WIFI_INTERFACE_TYPE_AP_BRIDGED = 4, 143 } wifi_interface_type; 144 145 /* 146 * enum wlan_mac_band - Band information corresponding to the WLAN MAC. 147 */ 148 typedef enum { 149 /* WLAN MAC Operates in 2.4 GHz Band */ 150 WLAN_MAC_2_4_BAND = 1 << 0, 151 /* WLAN MAC Operates in 5 GHz Band */ 152 WLAN_MAC_5_0_BAND = 1 << 1, 153 /* WLAN MAC Operates in 6 GHz Band */ 154 WLAN_MAC_6_0_BAND = 1 << 2, 155 /* WLAN MAC Operates in 60 GHz Band */ 156 WLAN_MAC_60_0_BAND = 1 << 3, 157 } wlan_mac_band; 158 159 /* List of chre nan rtt state */ 160 typedef enum { 161 CHRE_PREEMPTED = 0, 162 CHRE_UNAVAILABLE = 1, 163 CHRE_AVAILABLE = 2, 164 } chre_nan_rtt_state; 165 166 typedef struct { 167 wifi_channel_width width; 168 int center_frequency0; 169 int center_frequency1; 170 int primary_frequency; 171 } wifi_channel_spec; 172 173 /* 174 * wifi_usable_channel specifies a channel frequency, bandwidth, and bitmask 175 * of modes allowed on the channel. 176 */ 177 typedef struct { 178 /* Channel frequency in MHz */ 179 wifi_channel freq; 180 /* Channel operating width (20, 40, 80, 160, 320 etc.) */ 181 wifi_channel_width width; 182 /* BIT MASK of BIT(WIFI_INTERFACE_*) represented by |wifi_interface_mode| 183 * Bitmask does not represent concurrency. 184 * Examples: 185 * - If a channel is usable only for STA, then only the WIFI_INTERFACE_STA 186 * bit would be set for that channel. 187 * - If 5GHz SAP is not allowed, then none of the 5GHz channels will have 188 * WIFI_INTERFACE_SOFTAP bit set. 189 * Note: TDLS bit is set only if there is a STA connection. TDLS bit is set 190 * on non-STA channels only if TDLS off channel is supported. 191 */ 192 u32 iface_mode_mask; 193 } wifi_usable_channel; 194 195 /* 196 * wifi_usable_channel_filter 197 */ 198 typedef enum { 199 /* Filter Wifi channels that should be avoided due to cellular coex 200 * restrictions. Some Wifi channels can have extreme interference 201 * from/to cellular due to short frequency separation with neighboring 202 * cellular channels or when there is harmonic and intermodulation 203 * interference. Channels which only have some performance degradation 204 * (e.g. power back off is sufficient to deal with coexistence issue) 205 * can be included and should not be filtered out. 206 */ 207 WIFI_USABLE_CHANNEL_FILTER_CELLULAR_COEXISTENCE = 1 << 0, 208 /* Filter channels due to concurrency state. 209 * Examples: 210 * - 5GHz SAP operation may be supported in standalone mode, but if 211 * there is STA connection on 5GHz DFS channel, none of the 5GHz 212 * channels are usable for SAP if device does not support DFS SAP mode. 213 * - P2P GO may not be supported on indoor channels in EU during 214 * standalone mode but if there is a STA connection on indoor channel, 215 * P2P GO may be supported by some vendors on the same STA channel. 216 */ 217 WIFI_USABLE_CHANNEL_FILTER_CONCURRENCY = 1 << 1, 218 /* This Filter queries Wifi channels and bands that are supported for 219 * NAN3.1 Instant communication mode. This filter should only be applied to NAN interface. 220 * If 5G is supported default discovery channel 149/44 is considered, 221 * If 5G is not supported then channel 6 has to be considered. 222 * Based on regulatory domain if channel 149 and 44 are restricted, channel 6 should 223 * be considered for instant communication channel 224 */ 225 WIFI_USABLE_CHANNEL_FILTER_NAN_INSTANT_MODE = 1 << 2, 226 } wifi_usable_channel_filter; 227 228 typedef enum { 229 WIFI_SUCCESS = 0, 230 WIFI_ERROR_NONE = 0, 231 WIFI_ERROR_UNKNOWN = -1, 232 WIFI_ERROR_UNINITIALIZED = -2, 233 WIFI_ERROR_NOT_SUPPORTED = -3, 234 WIFI_ERROR_NOT_AVAILABLE = -4, // Not available right now, but try later 235 WIFI_ERROR_INVALID_ARGS = -5, 236 WIFI_ERROR_INVALID_REQUEST_ID = -6, 237 WIFI_ERROR_TIMED_OUT = -7, 238 WIFI_ERROR_TOO_MANY_REQUESTS = -8, // Too many instances of this request 239 WIFI_ERROR_OUT_OF_MEMORY = -9, 240 WIFI_ERROR_BUSY = -10, 241 } wifi_error; 242 243 typedef enum { 244 WIFI_ACCESS_CATEGORY_BEST_EFFORT = 0, 245 WIFI_ACCESS_CATEGORY_BACKGROUND = 1, 246 WIFI_ACCESS_CATEGORY_VIDEO = 2, 247 WIFI_ACCESS_CATEGORY_VOICE = 3 248 } wifi_access_category; 249 250 /* Channel category mask */ 251 typedef enum { 252 WIFI_INDOOR_CHANNEL = 1 << 0, 253 WIFI_DFS_CHANNEL = 1 << 1, 254 } wifi_channel_category; 255 256 /* Antenna configuration */ 257 typedef enum { 258 WIFI_ANTENNA_UNSPECIFIED = 0, 259 WIFI_ANTENNA_1X1 = 1, 260 WIFI_ANTENNA_2X2 = 2, 261 WIFI_ANTENNA_3X3 = 3, 262 WIFI_ANTENNA_4X4 = 4, 263 } wifi_antenna_configuration; 264 265 /* Wifi Radio configuration */ 266 typedef struct { 267 /* Operating band */ 268 wlan_mac_band band; 269 /* Antenna configuration */ 270 wifi_antenna_configuration antenna_cfg; 271 } wifi_radio_configuration; 272 273 /* WiFi Radio Combination */ 274 typedef struct { 275 u32 num_radio_configurations; 276 wifi_radio_configuration radio_configurations[]; 277 } wifi_radio_combination; 278 279 /* WiFi Radio combinations matrix */ 280 /* For Example in case of a chip which has two radios, where one radio is 281 * capable of 2.4GHz 2X2 only and another radio which is capable of either 282 * 5GHz or 6GHz 2X2, number of possible radio combinations in this case 283 * are 5 and possible combinations are 284 * {{{2G 2X2}}, //Standalone 2G 285 * {{5G 2X2}}, //Standalone 5G 286 * {{6G 2X2}}, //Standalone 6G 287 * {{2G 2X2}, {5G 2X2}}, //2G+5G DBS 288 * {{2G 2X2}, {6G 2X2}}} //2G+6G DBS 289 * Note: Since this chip doesn’t support 5G+6G simultaneous operation 290 * as there is only one radio which can support both, So it can only 291 * do MCC 5G+6G. This table should not get populated with possible MCC 292 * configurations. This is only for simultaneous radio configurations 293 * (such as Standalone, multi band simultaneous or single band simultaneous). 294 */ 295 typedef struct { 296 u32 num_radio_combinations; 297 /* Each row represents possible radio combinations */ 298 wifi_radio_combination radio_combinations[]; 299 } wifi_radio_combination_matrix; 300 301 typedef struct { 302 /** 303 * Maximum number of links supported by the chip for MLO association. 304 */ 305 u32 max_mlo_association_link_count; 306 /** 307 * Maximum number of Simultaneous Transmit and Receive (STR) links used 308 * in Multi-Link Operation. The maximum number of STR links used can be 309 * different from the maximum number of radios supported by the chip. 310 * 311 * This is a static configuration of the chip. 312 */ 313 u32 max_mlo_str_link_count; 314 /** 315 * Maximum number of concurrent TDLS sessions supported by the chip. 316 * 317 */ 318 u32 max_concurrent_tdls_session_count; 319 } wifi_chip_capabilities; 320 321 #define MAX_IFACE_COMBINATIONS 16 322 #define MAX_IFACE_LIMITS 8 323 324 /* Wifi interface limit 325 * Example: 326 * 1. To allow STA+STA: 327 * wifi_iface_limit limit1 = { 328 * .max_limit = 2, 329 * .iface_mask = BIT(WIFI_INTERFACE_TYPE_STA) 330 * }; 331 * 2. To allow Single P2P/NAN: 332 * wifi_iface_limit limit2 = { 333 * .max_limit = 1, 334 * .iface_mask = BIT(WIFI_INTERFACE_TYPE_P2P) 335 * | BIT(WIFI_INTERFACE_TYPE_NAN) 336 * }; 337 */ 338 typedef struct { 339 /* Max number of interfaces of same type */ 340 u32 max_limit; 341 /* BIT mask of interfaces from wifi_interface_type */ 342 u32 iface_mask; 343 } wifi_iface_limit; 344 345 /* Wifi Interface combination 346 * Example: 347 * 1. To allow STA+SAP: 348 * wifi_iface_limit limits1[] = { 349 * {1, BIT(WIFI_INTERFACE_TYPE_STA)}, 350 * }; 351 * wifi_iface_limit limits2[] = { 352 * {1, BIT(WIFI_INTERFACE_TYPE_AP)}, 353 * }; 354 * wifi_iface_combination comb1 = { 355 * .max_ifaces = 2, 356 * .num_iface_limits = 2, 357 * .iface_limits = {limits1, limits2,}, 358 * }; 359 * 360 * 2. To allow STA+P2P/NAN: 361 * wifi_iface_limit limits3[] = { 362 * {1, BIT(WIFI_INTERFACE_TYPE_STA)}, 363 * {1, BIT(WIFI_INTERFACE_TYPE_P2P) 364 | BIT(WIFI_INTERFACE_TYPE_NAN)}, 365 * }; 366 * wifi_iface_combination comb2 = { 367 * .max_ifaces = 2, 368 * .num_iface_limits = 1, 369 * .iface_limits = {limits3,}, 370 * }; 371 * 372 * 3. To allow STA+STA/AP: 373 * wifi_iface_limit limits4[] = { 374 * {2, BIT(WIFI_INTERFACE_TYPE_STA)}, 375 * }; 376 * wifi_iface_limit limits5[] = { 377 * {1, BIT(WIFI_INTERFACE_TYPE_STA)}, 378 * {1, BIT(WIFI_INTERFACE_TYPE_AP)}, 379 * }; 380 * wifi_iface_combination comb3 = { 381 * .max_ifaces = 2, 382 * .num_iface_limits = 2, 383 * .iface_limits = {limits4, limits5,}, 384 * }; 385 * 386 * 4. To allow AP_BRIDGED (AP+AP in bridge mode): 387 * wifi_iface_limit limits6[] = { 388 * {1, BIT(WIFI_INTERFACE_TYPE_AP_BRIDGED)}, 389 * }; 390 * wifi_iface_combination comb4 = { 391 * .max_ifaces = 1, 392 * .num_iface_limits = 1, 393 * .iface_limits = {limits6,}, 394 * }; 395 */ 396 typedef struct { 397 /* Maximum number of concurrent interfaces allowed in this combination */ 398 u32 max_ifaces; 399 /* Total number of interface limits in a combination */ 400 u32 num_iface_limits; 401 /* Interface limits */ 402 wifi_iface_limit iface_limits[MAX_IFACE_LIMITS]; 403 } wifi_iface_combination; 404 405 /* Wifi Interface concurrency combination matrix 406 * Example: 407 * 1. To allow 2 port concurrency with limts defined in above comments: 408 * wifi_iface_concurrency_matrix iface_concurrency_matrix = { 409 * .num_iface_combinations = 4, 410 * .iface_combinations = {comb1, comb2, comb3, comb4, } 411 * }; 412 */ 413 typedef struct { 414 /* Total count of possible iface combinations */ 415 u32 num_iface_combinations; 416 /* Interface combinations */ 417 wifi_iface_combination iface_combinations[MAX_IFACE_COMBINATIONS]; 418 } wifi_iface_concurrency_matrix; 419 420 /* Wifi OUI data */ 421 typedef struct { 422 /* OUI : 24-bit organizationally unique identifier to identify the Vendor/OEM */ 423 u32 oui; 424 /* Length of the data buffer */ 425 u32 data_len; 426 /* Vendor-specific data */ 427 const u8 *data; 428 } oui_keyed_data; 429 430 /* Wifi Vendor data list */ 431 typedef struct { 432 /* Number of OUI Keyed Data objects */ 433 u32 num_oui_keyed_data; 434 /* List of OUI Keyed Data */ 435 oui_keyed_data *oui_data; 436 } wifi_vendor_data; 437 438 /* Initialize/Cleanup */ 439 440 wifi_error wifi_initialize(wifi_handle *handle); 441 442 /** 443 * wifi_wait_for_driver 444 * Function should block until the driver is ready to proceed. 445 * Any errors from this function is considered fatal & will fail the HAL startup sequence. 446 * 447 * on success returns WIFI_SUCCESS 448 * on failure returns WIFI_ERROR_TIMED_OUT 449 */ 450 wifi_error wifi_wait_for_driver_ready(void); 451 452 typedef void (*wifi_cleaned_up_handler) (wifi_handle handle); 453 void wifi_cleanup(wifi_handle handle, wifi_cleaned_up_handler handler); 454 void wifi_event_loop(wifi_handle handle); 455 456 /* Error handling */ 457 void wifi_get_error_info(wifi_error err, const char **msg); // return a pointer to a static string 458 459 /* Feature enums */ 460 #define WIFI_FEATURE_INFRA (uint64_t)0x1 // Basic infrastructure mode 461 #define WIFI_FEATURE_INFRA_5G (uint64_t)0x2 // Support for 5 GHz Band 462 #define WIFI_FEATURE_HOTSPOT (uint64_t)0x4 // Support for GAS/ANQP 463 #define WIFI_FEATURE_P2P (uint64_t)0x8 // Wifi-Direct 464 #define WIFI_FEATURE_SOFT_AP (uint64_t)0x10 // Soft AP 465 #define WIFI_FEATURE_GSCAN (uint64_t)0x20 // Google-Scan APIs 466 #define WIFI_FEATURE_NAN (uint64_t)0x40 // Neighbor Awareness Networking 467 #define WIFI_FEATURE_D2D_RTT (uint64_t)0x80 // Device-to-device RTT 468 #define WIFI_FEATURE_D2AP_RTT (uint64_t)0x100 // Device-to-AP RTT 469 #define WIFI_FEATURE_BATCH_SCAN (uint64_t)0x200 // Batched Scan (legacy) 470 #define WIFI_FEATURE_PNO (uint64_t)0x400 // Preferred network offload 471 #define WIFI_FEATURE_ADDITIONAL_STA (uint64_t)0x800 // Support for two STAs 472 #define WIFI_FEATURE_TDLS (uint64_t)0x1000 // Tunnel directed link setup 473 #define WIFI_FEATURE_TDLS_OFFCHANNEL (uint64_t)0x2000 // Support for TDLS off channel 474 #define WIFI_FEATURE_EPR (uint64_t)0x4000 // Enhanced power reporting 475 #define WIFI_FEATURE_AP_STA (uint64_t)0x8000 // Support for AP STA Concurrency 476 #define WIFI_FEATURE_LINK_LAYER_STATS (uint64_t)0x10000 // Link layer stats collection 477 #define WIFI_FEATURE_LOGGER (uint64_t)0x20000 // WiFi Logger 478 #define WIFI_FEATURE_HAL_EPNO (uint64_t)0x40000 // WiFi PNO enhanced 479 #define WIFI_FEATURE_RSSI_MONITOR (uint64_t)0x80000 // RSSI Monitor 480 #define WIFI_FEATURE_MKEEP_ALIVE (uint64_t)0x100000 // WiFi mkeep_alive 481 #define WIFI_FEATURE_CONFIG_NDO (uint64_t)0x200000 // ND offload configure 482 #define WIFI_FEATURE_TX_TRANSMIT_POWER (uint64_t)0x400000 // Capture Tx transmit power levels 483 #define WIFI_FEATURE_CONTROL_ROAMING (uint64_t)0x800000 // Enable/Disable firmware roaming 484 #define WIFI_FEATURE_IE_WHITELIST (uint64_t)0x1000000 // Support Probe IE white listing 485 #define WIFI_FEATURE_SCAN_RAND (uint64_t)0x2000000 // Support MAC & Probe Sequence Number randomization 486 #define WIFI_FEATURE_SET_TX_POWER_LIMIT (uint64_t)0x4000000 // Support Tx Power Limit setting 487 #define WIFI_FEATURE_USE_BODY_HEAD_SAR (uint64_t)0x8000000 // Support Using Body/Head Proximity for SAR 488 #define WIFI_FEATURE_DYNAMIC_SET_MAC (uint64_t)0x10000000 // Support changing MAC address without iface reset(down and up) 489 #define WIFI_FEATURE_SET_LATENCY_MODE (uint64_t)0x40000000 // Support Latency mode setting 490 #define WIFI_FEATURE_P2P_RAND_MAC (uint64_t)0x80000000 // Support P2P MAC randomization 491 #define WIFI_FEATURE_INFRA_60G (uint64_t)0x100000000 // Support for 60GHz Band 492 #define WIFI_FEATURE_AFC_CHANNEL (uint64_t)0x200000000 // Support for setting 6GHz AFC channel allowance 493 #define WIFI_FEATURE_T2LM_NEGO (uint64_t)0x400000000 // Support for TID-To-Link mapping negotiation 494 #define WIFI_FEATURE_ROAMING_MODE_CONTROL (uint64_t)0x800000000 // Support for configuring roaming mode 495 #define WIFI_FEATURE_SET_VOIP_MODE (uint64_t)0x1000000000 // Support Voip mode setting 496 #define WIFI_FEATURE_CACHED_SCAN_RESULTS (uint64_t)0x2000000000 // Support cached scan result report 497 // Add more features here 498 499 #define IS_MASK_SET(mask, flags) (((flags) & (mask)) == (mask)) 500 501 #define IS_SUPPORTED_FEATURE(feature, featureSet) IS_MASK_SET(feature, featureSet) 502 503 /* Feature set */ 504 wifi_error wifi_get_supported_feature_set(wifi_interface_handle handle, feature_set *set); 505 506 /* 507 * Each row represents a valid feature combination; 508 * all other combinations are invalid! 509 */ 510 wifi_error wifi_get_concurrency_matrix(wifi_interface_handle handle, int set_size_max, 511 feature_set set[], int *set_size); 512 513 /* multiple interface support */ 514 515 wifi_error wifi_get_ifaces(wifi_handle handle, int *num_ifaces, wifi_interface_handle **ifaces); 516 wifi_error wifi_get_iface_name(wifi_interface_handle iface, char *name, size_t size); 517 wifi_interface_handle wifi_get_iface_handle(wifi_handle handle, char *name); 518 519 /* STA + STA support - Supported if WIFI_FEATURE_ADDITIONAL_STA is set */ 520 521 /** 522 * Invoked to indicate that the provided iface is the primary STA iface when there are more 523 * than 1 STA iface concurrently active. 524 * 525 * Note: If the wifi firmware/chip cannot support multiple instances of any offload 526 * (like roaming, APF, rssi threshold, etc), the firmware should ensure that these 527 * offloads are at least enabled for the primary interface. If the new primary interface is 528 * already connected to a network, the firmware must switch all the offloads on 529 * this new interface without disconnecting. 530 */ 531 wifi_error wifi_multi_sta_set_primary_connection(wifi_handle handle, wifi_interface_handle iface); 532 533 /** 534 * When there are 2 or more simultaneous STA connections, this use case hint indicates what 535 * use-case is being enabled by the framework. This use case hint can be used by the firmware 536 * to modify various firmware configurations like: 537 * - Allowed BSSIDs the firmware can choose for the initial connection/roaming attempts. 538 * - Duty cycle to choose for the 2 STA connections if the radio is in MCC mode. 539 * - Whether roaming, APF and other offloads needs to be enabled or not. 540 * 541 * Note: 542 * - This will be invoked before an active wifi connection is established on the second interface. 543 * - This use-case hint is implicitly void when the second STA interface is brought down. 544 */ 545 typedef enum { 546 /** 547 * Usage: 548 * - This will be sent down for make before break use-case. 549 * - Platform is trying to speculatively connect to a second network and evaluate it without 550 * disrupting the primary connection. 551 * 552 * Requirements for Firmware: 553 * - Do not reduce the number of tx/rx chains of primary connection. 554 * - If using MCC, should set the MCC duty cycle of the primary connection to be higher than 555 * the secondary connection (maybe 70/30 split). 556 * - Should pick the best BSSID for the secondary STA (disregard the chip mode) independent of 557 * the primary STA: 558 * - Don’t optimize for DBS vs MCC/SCC 559 * - Should not impact the primary connection’s bssid selection: 560 * - Don’t downgrade chains of the existing primary connection. 561 * - Don’t optimize for DBS vs MCC/SCC. 562 */ 563 WIFI_DUAL_STA_TRANSIENT_PREFER_PRIMARY = 0, 564 /** 565 * Usage: 566 * - This will be sent down for any app requested peer to peer connections. 567 * - In this case, both the connections needs to be allocated equal resources. 568 * - For the peer to peer use case, BSSID for the secondary connection will be chosen by the 569 * framework. 570 * 571 * Requirements for Firmware: 572 * - Can choose MCC or DBS mode depending on the MCC efficiency and HW capability. 573 * - If using MCC, set the MCC duty cycle of the primary connection to be equal to the secondary 574 * connection. 575 * - Prefer BSSID candidates which will help provide the best "overall" performance for both the 576 * connections. 577 */ 578 WIFI_DUAL_STA_NON_TRANSIENT_UNBIASED = 1 579 } wifi_multi_sta_use_case; 580 581 wifi_error wifi_multi_sta_set_use_case(wifi_handle handle, wifi_multi_sta_use_case use_case); 582 583 /* Configuration events */ 584 585 typedef struct { 586 void (*on_country_code_changed)(char code[2]); // We can get this from supplicant too 587 588 // More event handlers 589 } wifi_event_handler; 590 591 typedef struct { 592 char iface_name[IFNAMSIZ + 1]; 593 wifi_channel channel; 594 } wifi_iface_info; 595 596 typedef struct { 597 u32 wlan_mac_id; 598 /* BIT MASK of BIT(WLAN_MAC*) as represented by wlan_mac_band */ 599 u32 mac_band; 600 /* Represents the connected Wi-Fi interfaces associated with each MAC */ 601 int num_iface; 602 wifi_iface_info *iface_info; 603 } wifi_mac_info; 604 605 typedef struct { 606 void (*on_radio_mode_change)(wifi_request_id id, unsigned num_mac, 607 wifi_mac_info *mac_info); 608 } wifi_radio_mode_change_handler; 609 610 typedef struct { 611 void (*on_rssi_threshold_breached)(wifi_request_id id, u8 *cur_bssid, s8 cur_rssi); 612 } wifi_rssi_event_handler; 613 614 typedef struct { 615 void (*on_subsystem_restart)(const char* error); 616 } wifi_subsystem_restart_handler; 617 618 typedef struct { 619 void (*on_chre_nan_rtt_change)(chre_nan_rtt_state state); 620 } wifi_chre_handler; 621 622 wifi_error wifi_set_iface_event_handler(wifi_request_id id, wifi_interface_handle iface, wifi_event_handler eh); 623 wifi_error wifi_reset_iface_event_handler(wifi_request_id id, wifi_interface_handle iface); 624 625 wifi_error wifi_set_nodfs_flag(wifi_interface_handle handle, u32 nodfs); 626 wifi_error wifi_select_tx_power_scenario(wifi_interface_handle handle, wifi_power_scenario scenario); 627 wifi_error wifi_reset_tx_power_scenario(wifi_interface_handle handle); 628 wifi_error wifi_set_latency_mode(wifi_interface_handle handle, wifi_latency_mode mode); 629 wifi_error wifi_map_dscp_access_category(wifi_handle handle, 630 uint32_t start, uint32_t end, 631 uint32_t access_category); 632 wifi_error wifi_reset_dscp_mapping(wifi_handle handle); 633 634 wifi_error wifi_set_subsystem_restart_handler(wifi_handle handle, 635 wifi_subsystem_restart_handler handler); 636 637 /** 638 * Wifi HAL Thermal Mitigation API 639 * 640 * wifi_handle : wifi global handle (note: this is not a interface specific 641 * command). Mitigation is expected to be applied across all active interfaces 642 * The implementation and the mitigation action mapping to each mode is chip 643 * specific. Mitigation will be active until Wifi is turned off or 644 * WIFI_MITIGATION_NONE mode is sent 645 * 646 * mode: Thermal mitigation mode 647 * WIFI_MITIGATION_NONE : Clear all Wifi thermal mitigation actions 648 * WIFI_MITIGATION_LIGHT : Light Throttling where UX is not impacted 649 * WIFI_MITIGATION_MODERATE : Moderate throttling where UX not largely impacted 650 * WIFI_MITIGATION_SEVERE : Severe throttling where UX is largely impacted 651 * WIFI_MITIGATION_CRITICAL : Platform has done everything to reduce power 652 * WIFI_MITIGATION_EMERGENCY: Key components in platform are shutting down 653 * 654 * completion_window 655 * Deadline (in milliseconds) to complete this request, value 0 implies apply 656 * immediately. Deadline is basically a relaxed limit and allows vendors to 657 * apply the mitigation within the window (if it cannot apply immediately) 658 * 659 * Return 660 * WIFI_ERROR_NOT_SUPPORTED : Chip does not support thermal mitigation 661 * WIFI_ERROR_BUSY : Mitigation is supported, but retry later 662 * WIFI_ERROR_NONE : Mitigation request has been accepted 663 */ 664 wifi_error wifi_set_thermal_mitigation_mode(wifi_handle handle, 665 wifi_thermal_mode mode, 666 u32 completion_window); 667 668 669 typedef struct rx_data_cnt_details_t { 670 int rx_unicast_cnt; /*Total rx unicast packet which woke up host */ 671 int rx_multicast_cnt; /*Total rx multicast packet which woke up host */ 672 int rx_broadcast_cnt; /*Total rx broadcast packet which woke up host */ 673 } RX_DATA_WAKE_CNT_DETAILS; 674 675 typedef struct rx_wake_pkt_type_classification_t { 676 int icmp_pkt; /*wake icmp packet count */ 677 int icmp6_pkt; /*wake icmp6 packet count */ 678 int icmp6_ra; /*wake icmp6 RA packet count */ 679 int icmp6_na; /*wake icmp6 NA packet count */ 680 int icmp6_ns; /*wake icmp6 NS packet count */ 681 //ToDo: Any more interesting classification to add? 682 } RX_WAKE_PKT_TYPE_CLASSFICATION; 683 684 typedef struct rx_multicast_cnt_t{ 685 int ipv4_rx_multicast_addr_cnt; /*Rx wake packet was ipv4 multicast */ 686 int ipv6_rx_multicast_addr_cnt; /*Rx wake packet was ipv6 multicast */ 687 int other_rx_multicast_addr_cnt;/*Rx wake packet was non-ipv4 and non-ipv6*/ 688 } RX_MULTICAST_WAKE_DATA_CNT; 689 690 /* 691 * Structure holding all the driver/firmware wake count reasons. 692 * 693 * Buffers for the array fields (cmd_event_wake_cnt/driver_fw_local_wake_cnt) 694 * are allocated and freed by the framework. The size of each allocated 695 * array is indicated by the corresponding |_cnt| field. HAL needs to fill in 696 * the corresponding |_used| field to indicate the number of elements used in 697 * the array. 698 */ 699 typedef struct wlan_driver_wake_reason_cnt_t { 700 int total_cmd_event_wake; /* Total count of cmd event wakes */ 701 int *cmd_event_wake_cnt; /* Individual wake count array, each index a reason */ 702 int cmd_event_wake_cnt_sz; /* Max number of cmd event wake reasons */ 703 int cmd_event_wake_cnt_used; /* Number of cmd event wake reasons specific to the driver */ 704 705 int total_driver_fw_local_wake; /* Total count of drive/fw wakes, for local reasons */ 706 int *driver_fw_local_wake_cnt; /* Individual wake count array, each index a reason */ 707 int driver_fw_local_wake_cnt_sz; /* Max number of local driver/fw wake reasons */ 708 int driver_fw_local_wake_cnt_used; /* Number of local driver/fw wake reasons specific to the driver */ 709 710 int total_rx_data_wake; /* total data rx packets, that woke up host */ 711 RX_DATA_WAKE_CNT_DETAILS rx_wake_details; 712 RX_WAKE_PKT_TYPE_CLASSFICATION rx_wake_pkt_classification_info; 713 RX_MULTICAST_WAKE_DATA_CNT rx_multicast_wake_pkt_info; 714 } WLAN_DRIVER_WAKE_REASON_CNT; 715 716 /* Wi-Fi coex channel avoidance support */ 717 718 #define WIFI_COEX_NO_POWER_CAP (int32_t)0x7FFFFFFF 719 720 typedef enum { 721 WIFI_AWARE = 1 << 0, 722 SOFTAP = 1 << 1, 723 WIFI_DIRECT = 1 << 2 724 } wifi_coex_restriction; 725 726 /** 727 * Representation of a Wi-Fi channel to be avoided for Wi-Fi coex channel avoidance. 728 * 729 * band is represented as an WLAN_MAC* enum value defined in wlan_mac_band. 730 * If power_cap_dbm is WIFI_COEX_NO_POWER_CAP, then no power cap should be applied if the specified 731 * channel is used. 732 */ 733 typedef struct { 734 wlan_mac_band band; 735 u32 channel; 736 s32 power_cap_dbm; 737 } wifi_coex_unsafe_channel; 738 739 740 /* include various feature headers */ 741 742 #include "gscan.h" 743 #include "link_layer_stats.h" 744 #include "wifi_cached_scan_results.h" 745 #include "rtt.h" 746 #include "tdls.h" 747 #include "wifi_logger.h" 748 #include "wifi_config.h" 749 #include "wifi_nan.h" 750 #include "wifi_offload.h" 751 #include "roam.h" 752 #include "wifi_twt.h" 753 754 //wifi HAL function pointer table 755 typedef struct { 756 wifi_error (* wifi_initialize) (wifi_handle *); 757 wifi_error (* wifi_wait_for_driver_ready) (void); 758 void (* wifi_cleanup) (wifi_handle, wifi_cleaned_up_handler); 759 void (*wifi_event_loop)(wifi_handle); 760 void (* wifi_get_error_info) (wifi_error , const char **); 761 wifi_error (* wifi_get_supported_feature_set) (wifi_interface_handle, feature_set *); 762 wifi_error (* wifi_get_concurrency_matrix) (wifi_interface_handle, int, feature_set *, int *); 763 wifi_error (* wifi_set_scanning_mac_oui) (wifi_interface_handle, unsigned char *); 764 wifi_error (* wifi_get_supported_channels)(wifi_handle, int *, wifi_channel *); 765 wifi_error (* wifi_is_epr_supported)(wifi_handle); 766 wifi_error (* wifi_get_ifaces) (wifi_handle , int *, wifi_interface_handle **); 767 wifi_error (* wifi_get_iface_name) (wifi_interface_handle, char *name, size_t); 768 wifi_error (* wifi_set_iface_event_handler) (wifi_request_id,wifi_interface_handle , 769 wifi_event_handler); 770 wifi_error (* wifi_reset_iface_event_handler) (wifi_request_id, wifi_interface_handle); 771 wifi_error (* wifi_start_gscan) (wifi_request_id, wifi_interface_handle, wifi_scan_cmd_params, 772 wifi_scan_result_handler); 773 wifi_error (* wifi_stop_gscan)(wifi_request_id, wifi_interface_handle); 774 wifi_error (* wifi_get_cached_gscan_results)(wifi_interface_handle, byte, int, 775 wifi_cached_scan_results *, int *); 776 wifi_error (* wifi_set_bssid_hotlist)(wifi_request_id, wifi_interface_handle, 777 wifi_bssid_hotlist_params, wifi_hotlist_ap_found_handler); 778 wifi_error (* wifi_reset_bssid_hotlist)(wifi_request_id, wifi_interface_handle); 779 wifi_error (* wifi_set_significant_change_handler)(wifi_request_id, wifi_interface_handle, 780 wifi_significant_change_params, wifi_significant_change_handler); 781 wifi_error (* wifi_reset_significant_change_handler)(wifi_request_id, wifi_interface_handle); 782 wifi_error (* wifi_get_gscan_capabilities)(wifi_interface_handle, wifi_gscan_capabilities *); 783 wifi_error (* wifi_set_link_stats) (wifi_interface_handle, wifi_link_layer_params); 784 wifi_error (* wifi_get_link_stats) (wifi_request_id,wifi_interface_handle, 785 wifi_stats_result_handler); 786 wifi_error (* wifi_clear_link_stats)(wifi_interface_handle,u32, u32 *, u8, u8 *); 787 wifi_error (* wifi_get_valid_channels)(wifi_interface_handle,int, int, wifi_channel *, int *); 788 wifi_error (* wifi_rtt_range_request)(wifi_request_id, wifi_interface_handle, unsigned, 789 wifi_rtt_config[], wifi_rtt_event_handler); 790 wifi_error (* wifi_rtt_range_request_v3)(wifi_request_id, wifi_interface_handle, unsigned, 791 wifi_rtt_config_v3[], wifi_rtt_event_handler_v3); 792 wifi_error (* wifi_rtt_range_cancel)(wifi_request_id, wifi_interface_handle, unsigned, 793 mac_addr[]); 794 wifi_error (* wifi_get_rtt_capabilities)(wifi_interface_handle, wifi_rtt_capabilities *); 795 wifi_error (* wifi_get_rtt_capabilities_v3)(wifi_interface_handle, wifi_rtt_capabilities_v3 *); 796 wifi_error (* wifi_rtt_get_responder_info)(wifi_interface_handle iface, 797 wifi_rtt_responder *responder_info); 798 wifi_error (* wifi_enable_responder)(wifi_request_id id, wifi_interface_handle iface, 799 wifi_channel_info channel_hint, unsigned max_duration_seconds, 800 wifi_rtt_responder *responder_info); 801 wifi_error (* wifi_disable_responder)(wifi_request_id id, wifi_interface_handle iface); 802 wifi_error (* wifi_set_nodfs_flag)(wifi_interface_handle, u32); 803 wifi_error (* wifi_start_logging)(wifi_interface_handle, u32, u32, u32, u32, char *); 804 wifi_error (* wifi_set_epno_list)(wifi_request_id, wifi_interface_handle, 805 const wifi_epno_params *, wifi_epno_handler); 806 wifi_error (* wifi_reset_epno_list)(wifi_request_id, wifi_interface_handle); 807 wifi_error (* wifi_set_country_code)(wifi_interface_handle, const char *); 808 wifi_error (* wifi_get_firmware_memory_dump)( wifi_interface_handle iface, 809 wifi_firmware_memory_dump_handler handler); 810 wifi_error (* wifi_set_log_handler)(wifi_request_id id, wifi_interface_handle iface, 811 wifi_ring_buffer_data_handler handler); 812 wifi_error (* wifi_reset_log_handler)(wifi_request_id id, wifi_interface_handle iface); 813 wifi_error (* wifi_set_alert_handler)(wifi_request_id id, wifi_interface_handle iface, 814 wifi_alert_handler handler); 815 wifi_error (* wifi_reset_alert_handler)(wifi_request_id id, wifi_interface_handle iface); 816 wifi_error (* wifi_get_firmware_version)(wifi_interface_handle iface, char *buffer, 817 int buffer_size); 818 wifi_error (* wifi_get_ring_buffers_status)(wifi_interface_handle iface, 819 u32 *num_rings, wifi_ring_buffer_status *status); 820 wifi_error (* wifi_get_logger_supported_feature_set)(wifi_interface_handle iface, 821 unsigned int *support); 822 wifi_error (* wifi_get_ring_data)(wifi_interface_handle iface, char *ring_name); 823 wifi_error (* wifi_enable_tdls)(wifi_interface_handle, mac_addr, wifi_tdls_params *, 824 wifi_tdls_handler); 825 wifi_error (* wifi_disable_tdls)(wifi_interface_handle, mac_addr); 826 wifi_error (*wifi_get_tdls_status) (wifi_interface_handle, mac_addr, wifi_tdls_status *); 827 wifi_error (*wifi_get_tdls_capabilities)(wifi_interface_handle iface, 828 wifi_tdls_capabilities *capabilities); 829 wifi_error (* wifi_get_driver_version)(wifi_interface_handle iface, char *buffer, 830 int buffer_size); 831 wifi_error (* wifi_set_passpoint_list)(wifi_request_id id, wifi_interface_handle iface, 832 int num, wifi_passpoint_network *networks, wifi_passpoint_event_handler handler); 833 wifi_error (* wifi_reset_passpoint_list)(wifi_request_id id, wifi_interface_handle iface); 834 wifi_error (*wifi_set_lci) (wifi_request_id id, wifi_interface_handle iface, 835 wifi_lci_information *lci); 836 wifi_error (*wifi_set_lcr) (wifi_request_id id, wifi_interface_handle iface, 837 wifi_lcr_information *lcr); 838 wifi_error (*wifi_start_sending_offloaded_packet)(wifi_request_id id, 839 wifi_interface_handle iface, u16 ether_type, u8 *ip_packet, 840 u16 ip_packet_len, u8 *src_mac_addr, u8 *dst_mac_addr, 841 u32 period_msec); 842 wifi_error (*wifi_stop_sending_offloaded_packet)(wifi_request_id id, 843 wifi_interface_handle iface); 844 wifi_error (*wifi_start_rssi_monitoring)(wifi_request_id id, wifi_interface_handle 845 iface, s8 max_rssi, s8 min_rssi, wifi_rssi_event_handler eh); 846 wifi_error (*wifi_stop_rssi_monitoring)(wifi_request_id id, wifi_interface_handle iface); 847 wifi_error (*wifi_get_wake_reason_stats)(wifi_interface_handle iface, 848 WLAN_DRIVER_WAKE_REASON_CNT *wifi_wake_reason_cnt); 849 wifi_error (*wifi_configure_nd_offload)(wifi_interface_handle iface, u8 enable); 850 wifi_error (*wifi_get_driver_memory_dump)(wifi_interface_handle iface, 851 wifi_driver_memory_dump_callbacks callbacks); 852 wifi_error (*wifi_start_pkt_fate_monitoring)(wifi_interface_handle iface); 853 wifi_error (*wifi_get_tx_pkt_fates)(wifi_interface_handle handle, 854 wifi_tx_report *tx_report_bufs, 855 size_t n_requested_fates, 856 size_t *n_provided_fates); 857 wifi_error (*wifi_get_rx_pkt_fates)(wifi_interface_handle handle, 858 wifi_rx_report *rx_report_bufs, 859 size_t n_requested_fates, 860 size_t *n_provided_fates); 861 862 /* NAN functions */ 863 wifi_error (*wifi_nan_enable_request)(transaction_id id, 864 wifi_interface_handle iface, 865 NanEnableRequest* msg); 866 wifi_error (*wifi_nan_disable_request)(transaction_id id, 867 wifi_interface_handle iface); 868 wifi_error (*wifi_nan_publish_request)(transaction_id id, 869 wifi_interface_handle iface, 870 NanPublishRequest* msg); 871 wifi_error (*wifi_nan_publish_cancel_request)(transaction_id id, 872 wifi_interface_handle iface, 873 NanPublishCancelRequest* msg); 874 wifi_error (*wifi_nan_subscribe_request)(transaction_id id, 875 wifi_interface_handle iface, 876 NanSubscribeRequest* msg); 877 wifi_error (*wifi_nan_subscribe_cancel_request)(transaction_id id, 878 wifi_interface_handle iface, 879 NanSubscribeCancelRequest* msg); 880 wifi_error (*wifi_nan_transmit_followup_request)(transaction_id id, 881 wifi_interface_handle iface, 882 NanTransmitFollowupRequest* msg); 883 wifi_error (*wifi_nan_stats_request)(transaction_id id, 884 wifi_interface_handle iface, 885 NanStatsRequest* msg); 886 wifi_error (*wifi_nan_config_request)(transaction_id id, 887 wifi_interface_handle iface, 888 NanConfigRequest* msg); 889 wifi_error (*wifi_nan_tca_request)(transaction_id id, 890 wifi_interface_handle iface, 891 NanTCARequest* msg); 892 wifi_error (*wifi_nan_beacon_sdf_payload_request)(transaction_id id, 893 wifi_interface_handle iface, 894 NanBeaconSdfPayloadRequest* msg); 895 wifi_error (*wifi_nan_register_handler)(wifi_interface_handle iface, 896 NanCallbackHandler handlers); 897 wifi_error (*wifi_nan_get_version)(wifi_handle handle, 898 NanVersion* version); 899 wifi_error (*wifi_nan_get_capabilities)(transaction_id id, 900 wifi_interface_handle iface); 901 wifi_error (*wifi_nan_data_interface_create)(transaction_id id, 902 wifi_interface_handle iface, 903 char *iface_name); 904 wifi_error (*wifi_nan_data_interface_delete)(transaction_id id, 905 wifi_interface_handle iface, 906 char *iface_name); 907 wifi_error (*wifi_nan_data_request_initiator)( 908 transaction_id id, wifi_interface_handle iface, 909 NanDataPathInitiatorRequest *msg); 910 wifi_error (*wifi_nan_data_indication_response)( 911 transaction_id id, wifi_interface_handle iface, 912 NanDataPathIndicationResponse *msg); 913 wifi_error (*wifi_nan_data_end)(transaction_id id, 914 wifi_interface_handle iface, 915 NanDataPathEndRequest *msg); 916 wifi_error (*wifi_select_tx_power_scenario)(wifi_interface_handle iface, 917 wifi_power_scenario scenario); 918 wifi_error (*wifi_reset_tx_power_scenario)(wifi_interface_handle iface); 919 920 /** 921 * Returns the chipset's hardware filtering capabilities: 922 * @param version pointer to version of the packet filter interpreter 923 * supported, filled in upon return. 0 indicates no support. 924 * @param max_len pointer to maximum size of the filter bytecode, filled in 925 * upon return. 926 */ 927 wifi_error (*wifi_get_packet_filter_capabilities)(wifi_interface_handle handle, 928 u32 *version, u32 *max_len); 929 /** 930 * Programs the packet filter. 931 * @param program pointer to the program byte-code. 932 * @param len length of the program byte-code. 933 */ 934 wifi_error (*wifi_set_packet_filter)(wifi_interface_handle handle, 935 const u8 *program, u32 len); 936 wifi_error (*wifi_read_packet_filter)(wifi_interface_handle handle, 937 u32 src_offset, u8 *host_dst, 938 u32 length); 939 wifi_error (*wifi_get_roaming_capabilities)(wifi_interface_handle handle, 940 wifi_roaming_capabilities *caps); 941 wifi_error (*wifi_enable_firmware_roaming)(wifi_interface_handle handle, 942 fw_roaming_state_t state); 943 wifi_error (*wifi_configure_roaming)(wifi_interface_handle handle, 944 wifi_roaming_config *roaming_config); 945 wifi_error (*wifi_set_radio_mode_change_handler)(wifi_request_id id, wifi_interface_handle 946 iface, wifi_radio_mode_change_handler eh); 947 wifi_error (*wifi_set_latency_mode)(wifi_interface_handle iface, 948 wifi_latency_mode mode); 949 wifi_error (*wifi_set_thermal_mitigation_mode)(wifi_handle handle, 950 wifi_thermal_mode mode, 951 u32 completion_window); 952 wifi_error (*wifi_map_dscp_access_category)(wifi_handle handle, 953 u32 start, u32 end, 954 u32 access_category); 955 wifi_error (*wifi_reset_dscp_mapping)(wifi_handle handle); 956 957 wifi_error (*wifi_virtual_interface_create)(wifi_handle handle, const char* ifname, 958 wifi_interface_type iface_type); 959 wifi_error (*wifi_virtual_interface_delete)(wifi_handle handle, const char* ifname); 960 961 wifi_error (*wifi_set_subsystem_restart_handler)(wifi_handle handle, 962 wifi_subsystem_restart_handler handler); 963 964 /** 965 * Allow vendor HAL to choose interface name when creating 966 * an interface. This can be implemented by chips with their 967 * own interface naming policy. 968 * If not implemented, the default naming will be used. 969 */ 970 wifi_error (*wifi_get_supported_iface_name)(wifi_handle handle, u32 iface_type, 971 char *name, size_t len); 972 973 /** 974 * Perform early initialization steps that are needed when WIFI 975 * is disabled. 976 * If the function returns failure, it means the vendor HAL is unusable 977 * (for example, if chip hardware is not installed) and no further 978 * functions should be called. 979 */ 980 wifi_error (*wifi_early_initialize)(void); 981 982 /** 983 * Get supported feature set which are chip-global, that is 984 * not dependent on any created interface. 985 */ 986 wifi_error (*wifi_get_chip_feature_set)(wifi_handle handle, feature_set *set); 987 988 /** 989 * Invoked to indicate that the provided iface is the primary STA iface when there are more 990 * than 1 STA iface concurrently active. 991 */ 992 wifi_error (*wifi_multi_sta_set_primary_connection)(wifi_handle handle, 993 wifi_interface_handle iface); 994 995 996 /** 997 * When there are 2 simultaneous STA connections, this use case hint 998 * indicates what STA + STA use-case is being enabled by the framework. 999 */ 1000 wifi_error (*wifi_multi_sta_set_use_case)(wifi_handle handle, 1001 wifi_multi_sta_use_case use_case); 1002 1003 /** 1004 * Invoked to indicate that the following list of wifi_coex_unsafe_channel should be avoided 1005 * with the specified restrictions. 1006 * @param unsafeChannels list of current |wifi_coex_unsafe_channel| to avoid. 1007 * @param restrictions bitmask of |wifi_coex_restriction| indicating wifi interfaces to 1008 * restrict from the current unsafe channels. 1009 */ 1010 wifi_error (*wifi_set_coex_unsafe_channels)(wifi_handle handle, u32 num_channels, 1011 wifi_coex_unsafe_channel *unsafeChannels, 1012 u32 restrictions); 1013 1014 /** 1015 * Invoked to set voip optimization mode for the provided STA iface 1016 */ 1017 wifi_error (*wifi_set_voip_mode)(wifi_interface_handle iface, wifi_voip_mode mode); 1018 1019 /** 1020 * Get Target Wake Time (TWT) local device capabilities for the station interface. 1021 * 1022 * @param iface Wifi interface handle 1023 * @param capabilities TWT capabilities 1024 * @return Synchronous wifi_error 1025 */ 1026 wifi_error (*wifi_twt_get_capabilities)(wifi_interface_handle iface, 1027 wifi_twt_capabilities* capabilities); 1028 1029 /** 1030 * Register TWT events before sending any TWT request 1031 * 1032 * @param wifi_interface_handle: 1033 * @param events: TWT events callbacks to register 1034 * @return Synchronous wifi_error 1035 */ 1036 wifi_error (*wifi_twt_register_events)(wifi_interface_handle iface, wifi_twt_events events); 1037 1038 /** 1039 * Setup a TWT session. 1040 * 1041 * Supported only if wifi_twt_capabilities.is_twt_requester_supported is set. Results in 1042 * asynchronous callback wifi_twt_events.on_twt_session_create on success or 1043 * wifi_twt_events.on_twt_failure with error code. 1044 * 1045 * @param id Identifier for the command. The value 0 is reserved. 1046 * @param iface Wifi interface handle 1047 * @param request TWT request parameters 1048 * @return Synchronous wifi_error 1049 */ 1050 wifi_error (*wifi_twt_session_setup)(wifi_request_id id, wifi_interface_handle iface, 1051 wifi_twt_request request); 1052 /** 1053 * Update a TWT session. 1054 * 1055 * Supported only if wifi_twt_session.is_updatable is set. Reesults in asynchronous callback 1056 * wifi_twt_events.on_twt_session_update on success or wifi_twt_events.on_twt_failure with 1057 * error code. 1058 * 1059 * @param id Identifier for the command. The value 0 is reserved. 1060 * @param iface Wifi interface handle 1061 * @param session_id TWT session identifier 1062 * @param request TWT request parameters 1063 * @return Synchronous wifi_error 1064 */ 1065 wifi_error (*wifi_twt_session_update)(wifi_request_id id, wifi_interface_handle iface, 1066 int session_id, wifi_twt_request request); 1067 /** 1068 * Suspend a TWT session. 1069 * Supported only if wifi_twt_session.is_suspendable is set. Results in asynchronous callback 1070 * wifi_twt_events.on_twt_session_suspend on success or wifi_twt_events.on_twt_failure with 1071 * error code. 1072 * 1073 * @param id Identifier for the command. The value 0 is reserved. 1074 * @param iface Wifi interface handle 1075 * @param session_id TWT session identifier 1076 * @return Synchronous wifi_error 1077 */ 1078 wifi_error (*wifi_twt_session_suspend)(wifi_request_id id, wifi_interface_handle iface, 1079 int session_id); 1080 /** 1081 * Resume a suspended TWT session. 1082 * 1083 * Supported only if wifi_twt_session.is_suspendable is set. Results in asynchronous callback 1084 * wifi_twt_events.on_twt_session_resume on success or wifi_twt_events.on_twt_failure with 1085 * error code. 1086 * 1087 * @param id Identifier for the command. The value 0 is reserved. 1088 * @param iface Wifi interface handle 1089 * @param session_id TWT session identifier 1090 * @return Synchronous wifi_error 1091 */ 1092 wifi_error (*wifi_twt_session_resume)(wifi_request_id id, wifi_interface_handle iface, 1093 int session_id); 1094 /** 1095 * Teardown a TWT session. 1096 * 1097 * Results in asynchronous callback wifi_twt_events.on_twt_session_teardown on success or 1098 * wifi_twt_events.on_twt_failure with error code. 1099 * 1100 * @param id Identifier for the command. The value 0 is reserved. 1101 * @param iface Wifi interface handle 1102 * @param session_id TWT session identifier 1103 * @return Synchronous wifi_error 1104 */ 1105 wifi_error (*wifi_twt_session_teardown)(wifi_request_id id, wifi_interface_handle iface, 1106 int session_id); 1107 1108 /** 1109 * Get stats for a TWT session. 1110 * 1111 * Results in asynchronous callback wifi_twt_events.on_twt_session_stats on success or 1112 * wifi_twt_events.on_twt_failure with error code. 1113 * 1114 * @param id Identifier for the command. The value 0 is reserved. 1115 * @param iface Wifi interface handle 1116 * @param session_id TWT session identifier 1117 * @return Synchronous wifi_error 1118 */ 1119 wifi_error (*wifi_twt_session_get_stats)(wifi_request_id id, wifi_interface_handle iface, 1120 int session_id); 1121 1122 /**@brief twt_register_handler 1123 * Request to register TWT callback before sending any TWT request 1124 * @param wifi_interface_handle: 1125 * @param TwtCallbackHandler: callback function pointers 1126 * @return Synchronous wifi_error 1127 * 1128 * Note: This function is deprecated by wifi_twt_register_events 1129 */ 1130 wifi_error (*wifi_twt_register_handler)(wifi_interface_handle iface, 1131 TwtCallbackHandler handler); 1132 1133 /**@brief twt_get_capability 1134 * Request TWT capability 1135 * @param wifi_interface_handle: 1136 * @return Synchronous wifi_error and TwtCapabilitySet 1137 * 1138 * Note: This function is deprecated by wifi_twt_get_capabilities 1139 */ 1140 wifi_error (*wifi_twt_get_capability)(wifi_interface_handle iface, 1141 TwtCapabilitySet* twt_cap_set); 1142 1143 /**@brief twt_setup_request 1144 * Request to send TWT setup frame 1145 * @param wifi_interface_handle: 1146 * @param TwtSetupRequest: detailed parameters of setup request 1147 * @return Synchronous wifi_error 1148 * @return Asynchronous EventTwtSetupResponse CB return TwtSetupResponse 1149 * 1150 * Note: This function is deprecated by wifi_twt_session_setup 1151 */ 1152 wifi_error (*wifi_twt_setup_request)(wifi_interface_handle iface, 1153 TwtSetupRequest* msg); 1154 1155 /**@brief twt_teardown_request 1156 * Request to send TWT teardown frame 1157 * @param wifi_interface_handle: 1158 * @param TwtTeardownRequest: detailed parameters of teardown request 1159 * @return Synchronous wifi_error 1160 * @return Asynchronous EventTwtTeardownCompletion CB return TwtTeardownCompletion 1161 * TwtTeardownCompletion may also be received due to other events 1162 * like CSA, BTCX, TWT scheduler, MultiConnection, peer-initiated teardown, etc. 1163 * 1164 * Note: This function is deprecated by wifi_twt_session_teardown 1165 */ 1166 wifi_error (*wifi_twt_teardown_request)(wifi_interface_handle iface, 1167 TwtTeardownRequest* msg); 1168 1169 /**@brief twt_info_frame_request 1170 * Request to send TWT info frame 1171 * @param wifi_interface_handle: 1172 * @param TwtInfoFrameRequest: detailed parameters in info frame 1173 * @return Synchronous wifi_error 1174 * @return Asynchronous EventTwtInfoFrameReceived CB return TwtInfoFrameReceived 1175 * Driver may also receive Peer-initiated TwtInfoFrame 1176 * 1177 * Note: This function is deprecated by wifi_twt_session_suspend and 1178 * wifi_twt_session_resume 1179 */ 1180 wifi_error (*wifi_twt_info_frame_request)(wifi_interface_handle iface, 1181 TwtInfoFrameRequest* msg); 1182 1183 /**@brief twt_get_stats 1184 * Request to get TWT stats 1185 * @param wifi_interface_handle: 1186 * @param config_id: configuration ID of TWT request 1187 * @return Synchronous wifi_error and TwtStats 1188 * 1189 * Note: This function is deprecated by wifi_twt_get_session_stats 1190 */ 1191 wifi_error (*wifi_twt_get_stats)(wifi_interface_handle iface, u8 config_id, 1192 TwtStats* stats); 1193 1194 /**@brief twt_clear_stats 1195 * Request to clear TWT stats 1196 * @param wifi_interface_handle: 1197 * @param config_id: configuration ID of TWT request 1198 * @return Synchronous wifi_error 1199 * 1200 * Note: This function is deprecated. 1201 */ 1202 wifi_error (*wifi_twt_clear_stats)(wifi_interface_handle iface, u8 config_id); 1203 1204 /** 1205 * Invoked to set DTIM configuration when the host is in the suspend mode 1206 * @param wifi_interface_handle: 1207 * @param multiplier: when STA in the power saving mode, the wake up interval will be set to 1208 * 1) multiplier * DTIM period if multiplier > 0. 1209 * 2) the device default value if multiplier <=0 1210 * Some implementations may apply an additional cap to wake up interval in the case of 1). 1211 */ 1212 wifi_error (*wifi_set_dtim_config)(wifi_interface_handle handle, u32 multiplier); 1213 1214 /**@brief wifi_get_usable_channels 1215 * Request list of usable channels for the requested bands and modes. Usable 1216 * implies channel is allowed as per regulatory for the current country code 1217 * and not restricted due to other hard limitations (e.g. DFS, Coex) In 1218 * certain modes (e.g. STA+SAP) there could be other hard restrictions 1219 * since MCC operation many not be supported by SAP. This API also allows 1220 * driver to return list of usable channels for each mode uniquely to 1221 * distinguish cases where only a limited set of modes are allowed on 1222 * a given channel e.g. srd channels may be supported for P2P but not 1223 * for SAP or P2P-Client may be allowed on an indoor channel but P2P-GO 1224 * may not be allowed. This API is not interface specific and will be 1225 * used to query capabilities of driver in terms of what modes (STA, SAP, 1226 * P2P_CLI, P2P_GO, NAN, TDLS) can be supported on each of the channels. 1227 * @param handle global wifi_handle 1228 * @param band_mask BIT MASK of WLAN_MAC* as represented by |wlan_mac_band| 1229 * @param iface_mode_mask BIT MASK of BIT(WIFI_INTERFACE_*) represented by 1230 * |wifi_interface_mode|. Bitmask respresents all the modes that the 1231 * caller is interested in (e.g. STA, SAP, WFD-CLI, WFD-GO, TDLS, NAN). 1232 * Note: Bitmask does not represent concurrency matrix. If the caller 1233 * is interested in CLI, GO modes, the iface_mode_mask would be set 1234 * to WIFI_INTERFACE_P2P_CLIENT|WIFI_INTERFACE_P2P_GO. 1235 * @param filter_mask BIT MASK of WIFI_USABLE_CHANNEL_FILTER_* represented by 1236 * |wifi_usable_channel_filter|. Indicates if the channel list should 1237 * be filtered based on additional criteria. If filter_mask is not 1238 * specified, driver should return list of usable channels purely 1239 * based on regulatory constraints. 1240 * @param max_size maximum number of |wifi_usable_channel| 1241 * @param size actual number of |wifi_usable_channel| entries returned by driver 1242 * @param channels list of usable channels represented by |wifi_usable_channel| 1243 */ 1244 wifi_error (*wifi_get_usable_channels)(wifi_handle handle, u32 band_mask, u32 iface_mode_mask, 1245 u32 filter_mask, u32 max_size, u32* size, 1246 wifi_usable_channel* channels); 1247 1248 /** 1249 * Trigger wifi subsystem restart to reload firmware 1250 */ 1251 wifi_error (*wifi_trigger_subsystem_restart)(wifi_handle handle); 1252 1253 /** 1254 * Invoked to set that the device is operating in an indoor environment. 1255 * @param handle global wifi_handle 1256 * @param isIndoor: true if the device is operating in an indoor 1257 * environment, false otherwise. 1258 * @return Synchronous wifi_error 1259 */ 1260 wifi_error (*wifi_set_indoor_state)(wifi_handle handle, bool isIndoor); 1261 1262 /**@brief wifi_get_supported_radio_combinations_matrix 1263 * Request all the possible radio combinations this device can offer. 1264 * @param handle global wifi_handle 1265 * @param max_size maximum size allocated for filling the wifi_radio_combination_matrix 1266 * @param wifi_radio_combination_matrix to return all the possible radio 1267 * combinations. 1268 * @param size actual size of wifi_radio_combination_matrix returned from 1269 * lower layer 1270 * 1271 */ 1272 wifi_error (*wifi_get_supported_radio_combinations_matrix)( 1273 wifi_handle handle, u32 max_size, u32 *size, 1274 wifi_radio_combination_matrix *radio_combination_matrix); 1275 1276 /**@brief wifi_nan_rtt_chre_enable_request 1277 * Request to enable CHRE NAN RTT 1278 * @param transaction_id: NAN transaction id 1279 * @param wifi_interface_handle 1280 * @param NanEnableRequest request message 1281 * @return Synchronous wifi_error 1282 */ 1283 wifi_error (*wifi_nan_rtt_chre_enable_request)(transaction_id id, 1284 wifi_interface_handle iface, 1285 NanEnableRequest* msg); 1286 1287 /**@brief wifi_nan_rtt_chre_disable_request 1288 * Request to disable CHRE NAN RTT 1289 * @param transaction_id: NAN transaction id 1290 * @param wifi_interface_handle 1291 * @return Synchronous wifi_error 1292 */ 1293 wifi_error (*wifi_nan_rtt_chre_disable_request)(transaction_id id, wifi_interface_handle iface); 1294 1295 /**@brief wifi_chre_register_handler 1296 * register a handler to get the state of CHR 1297 * @param wifi_interface_handle 1298 * @param wifi_chre_handler: callback function pointer 1299 * @return Synchronous wifi_error 1300 */ 1301 wifi_error (*wifi_chre_register_handler)(wifi_interface_handle iface, 1302 wifi_chre_handler handler); 1303 1304 /**@brief wifi_enable_tx_power_limits 1305 * Enable WiFi Tx power limis 1306 * @param wifi_interface_handle 1307 * @param isEnable : If enable TX limit or not 1308 * @return Synchronous wifi_error 1309 */ 1310 wifi_error (*wifi_enable_tx_power_limits) (wifi_interface_handle iface, 1311 bool isEnable); 1312 1313 /**@brief wifi_get_cached_scan_results 1314 * Retrieve scan results cached in wifi firmware 1315 * @param wifi_interface_handle 1316 * @param wifi_cached_scan_result_handler : callback function pointer 1317 * @return Synchronous wifi_error 1318 */ 1319 wifi_error (*wifi_get_cached_scan_results)(wifi_interface_handle iface, 1320 wifi_cached_scan_result_handler handler); 1321 /**@brief wifi_get_chip_capabilities 1322 * Retrieve capabilities supported by this chip 1323 * @param wifi_handle 1324 * @return Synchronous wifi_error and chip capabilites 1325 */ 1326 wifi_error (*wifi_get_chip_capabilities)(wifi_handle handle, 1327 wifi_chip_capabilities *chip_capabilities); 1328 1329 /**@brief wifi_get_supported_iface_concurrency_matrix 1330 * Request all the possible interface concurrency combinations this 1331 * Wifi Chip can offer. 1332 * @param handle global wifi_handle 1333 * @param wifi_iface_concurrency_matrix to return all the possible 1334 * interface concurrency combinations. 1335 * @return Synchronous wifi_error 1336 */ 1337 wifi_error (*wifi_get_supported_iface_concurrency_matrix)( 1338 wifi_handle handle, wifi_iface_concurrency_matrix *matrix); 1339 1340 /**@brief wifi_enable_sta_channel_for_peer_network 1341 * enable or disable the feature of allowing current STA-connected 1342 * channel for WFA GO, SAP and Wi-Fi Aware when the regulatory allows. 1343 * @param handle global wifi_handle 1344 * @param channelCategoryEnableFlag bitmask of |wifi_channel_category|. 1345 * @return Synchronous wifi_error 1346 */ 1347 wifi_error (*wifi_enable_sta_channel_for_peer_network)( 1348 wifi_handle handle, u32 channelCategoryEnableFlag); 1349 1350 /**@brief wifi_nan_suspend_request 1351 * Request that the specified NAN session be suspended. 1352 * @param transaction_id: NAN transaction id 1353 * @param wifi_interface_handle 1354 * @param NanSuspendRequest request message 1355 * @return Synchronous wifi_error 1356 */ 1357 wifi_error (*wifi_nan_suspend_request)(transaction_id id, wifi_interface_handle iface, 1358 NanSuspendRequest *msg); 1359 1360 /**@brief wifi_nan_resume_request 1361 * Request that the specified NAN session be resumed. 1362 * @param transaction_id: NAN transaction id 1363 * @param wifi_interface_handle 1364 * @param NanResumeRequest request message 1365 * @return Synchronous wifi_error 1366 */ 1367 wifi_error (*wifi_nan_resume_request)(transaction_id id, wifi_interface_handle iface, 1368 NanResumeRequest *msg); 1369 1370 wifi_error (*wifi_nan_pairing_request)( 1371 transaction_id id, wifi_interface_handle iface, 1372 NanPairingRequest *msg); 1373 wifi_error (*wifi_nan_pairing_indication_response)( 1374 transaction_id id, wifi_interface_handle iface, 1375 NanPairingIndicationResponse *msg); 1376 wifi_error (*wifi_nan_bootstrapping_request)( 1377 transaction_id id, wifi_interface_handle iface, 1378 NanBootstrappingRequest *msg); 1379 wifi_error (*wifi_nan_bootstrapping_indication_response)( 1380 transaction_id id, wifi_interface_handle iface, 1381 NanBootstrappingIndicationResponse *msg); 1382 1383 /**@brief wifi_set_scan_mode 1384 * Notify driver/firmware current is scan only mode to allow lower 1385 * level to optimize power consumption. 1386 * @param enable true if current is scan only mode 1387 * @return Synchronous wifi_error 1388 */ 1389 wifi_error (*wifi_set_scan_mode)(wifi_interface_handle iface, bool enable); 1390 1391 wifi_error (*wifi_nan_pairing_end)(transaction_id id, 1392 wifi_interface_handle iface, 1393 NanPairingEndRequest *msg); 1394 1395 /**@brief wifi_set_mlo_mode 1396 * Set Multi-Link Operation mode. 1397 * @param handle global wifi_handle 1398 * @param mode: MLO mode 1399 * @return Synchronous wifi_error 1400 */ 1401 wifi_error (*wifi_set_mlo_mode)(wifi_handle handle, wifi_mlo_mode mode); 1402 1403 /**@brief wifi_virtual_interface_create_with_vendor_data 1404 * Create new virtual interface using vendor data. 1405 * @param handle: global wifi_handle 1406 * @param ifname: name of interface to be created. 1407 * @param iface_type: one of interface types from wifi_interface_type. 1408 * @param vendor_data: vendor data to apply on this interface. 1409 * @return Synchronous wifi_error 1410 */ 1411 wifi_error (*wifi_virtual_interface_create_with_vendor_data) 1412 (wifi_handle handle, const char* ifname, 1413 wifi_interface_type iface_type, wifi_vendor_data* vendor_data); 1414 1415 /* 1416 * when adding new functions make sure to add stubs in 1417 * wifi_legacy_hal_stubs.cpp::initHalFuncTableWithStubs 1418 */ 1419 } wifi_hal_fn; 1420 1421 wifi_error init_wifi_vendor_hal_func_table(wifi_hal_fn *fn); 1422 typedef wifi_error (*init_wifi_vendor_hal_func_table_t)(wifi_hal_fn *fn); 1423 1424 #ifdef __cplusplus 1425 } 1426 #endif 1427 1428 #endif 1429