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