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