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