Merge Android 12

Bug: 202323961
Merged-In: I63befde52711ce60502d5ddfcb47e6f1faddbad0
Change-Id: I58d44f7c910fa23a1d3fdc279252eca063aa32cf
This commit is contained in:
Xin Li 2021-10-06 22:53:41 +00:00
commit 0a1470ac3c
6 changed files with 558 additions and 39 deletions

View file

@ -34,6 +34,7 @@ typedef enum {
WIFI_INTERFACE_P2P_GO = 4,
WIFI_INTERFACE_NAN = 5,
WIFI_INTERFACE_MESH = 6,
WIFI_INTERFACE_TDLS = 7,
WIFI_INTERFACE_UNKNOWN = -1
} wifi_interface_mode;
@ -54,6 +55,8 @@ typedef struct {
u8 bssid[6]; // bssid
u8 ap_country_str[3]; // country string advertised by AP
u8 country_str[3]; // country string for this association
u8 time_slicing_duty_cycle_percent;// if this iface is being served using time slicing on a radio with one or more ifaces (i.e MCC), then the duty cycle assigned to this iface in %.
// If not using time slicing (i.e SCC or DBS), set to 100.
} wifi_interface_link_layer_info;
/* channel information */
@ -158,10 +161,17 @@ typedef enum
} wifi_peer_type;
/* per peer statistics */
typedef struct bssload_info {
u16 sta_count; // station count
u16 chan_util; // channel utilization
u8 PAD[4];
} bssload_info_t;
typedef struct {
wifi_peer_type type; // peer type (AP, TDLS, GO etc.)
u8 peer_mac_address[6]; // mac address
u32 capabilities; // peer WIFI_CAPABILITY_XXX
bssload_info_t bssload; // STA count and CU
u32 num_rate; // number of rates
wifi_rate_stat rate_stats[]; // per rate statistics, number of entries = num_rate
} wifi_peer_info;

View file

@ -12,8 +12,6 @@ extern "C"
#define CONFIG_MINOR_VERSION 0
#define CONFIG_MICRO_VERSION 0
typedef int wifi_radio;
// whether the wifi chipset wakes at every dtim beacon or a multiple of the dtim period
// if extended_dtim is set to 3, the STA shall wake up every 3 DTIM beacons
wifi_error wifi_extended_dtim_config_set(wifi_request_id id,

View file

@ -25,6 +25,31 @@ extern "C"
#define IFNAMSIZ 16
/* typedefs */
typedef unsigned char byte;
typedef unsigned char u8;
typedef signed char s8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef int32_t s32;
typedef uint64_t u64;
typedef int64_t s64;
typedef int wifi_request_id;
typedef int wifi_channel; // indicates channel frequency in MHz
typedef int wifi_rssi;
typedef int wifi_radio;
typedef byte mac_addr[6];
typedef byte oui[3];
typedef int64_t wifi_timestamp; // In microseconds (us)
typedef int64_t wifi_timespan; // In picoseconds (ps)
typedef uint64_t feature_set;
/* forward declarations */
struct wifi_info;
struct wifi_interface_info;
typedef struct wifi_info *wifi_handle;
typedef struct wifi_interface_info *wifi_interface_handle;
/* WiFi Common definitions */
/* channel operating width */
typedef enum {
@ -48,6 +73,13 @@ typedef enum {
WIFI_POWER_SCENARIO_ON_BODY_CELL_OFF = 3,
WIFI_POWER_SCENARIO_ON_BODY_CELL_ON = 4,
WIFI_POWER_SCENARIO_ON_BODY_BT = 5,
WIFI_POWER_SCENARIO_ON_HEAD_HOTSPOT = 6,
WIFI_POWER_SCENARIO_ON_HEAD_HOTSPOT_MMW = 7,
WIFI_POWER_SCENARIO_ON_BODY_CELL_ON_BT = 8,
WIFI_POWER_SCENARIO_ON_BODY_HOTSPOT = 9,
WIFI_POWER_SCENARIO_ON_BODY_HOTSPOT_BT = 10,
WIFI_POWER_SCENARIO_ON_BODY_HOTSPOT_MMW = 11,
WIFI_POWER_SCENARIO_ON_BODY_HOTSPOT_BT_MMW = 12,
} wifi_power_scenario;
typedef enum {
@ -65,6 +97,15 @@ typedef enum {
WIFI_MITIGATION_EMERGENCY = 5,
} wifi_thermal_mode;
/*
* Wifi voice over IP mode
* may add new modes later, for example, voice + video over IP mode.
*/
typedef enum {
WIFI_VOIP_MODE_OFF = 0,
WIFI_VOIP_MODE_ON = 1,
} wifi_voip_mode;
/* List of interface types supported */
typedef enum {
WIFI_INTERFACE_TYPE_STA = 0,
@ -82,12 +123,11 @@ typedef enum {
/* WLAN MAC Operates in 5 GHz Band */
WLAN_MAC_5_0_BAND = 1 << 1,
/* WLAN MAC Operates in 6 GHz Band */
WLAN_MAC_6_0_BAND = 1 << 2
WLAN_MAC_6_0_BAND = 1 << 2,
/* WLAN MAC Operates in 60 GHz Band */
WLAN_MAC_60_0_BAND = 1 << 3,
} wlan_mac_band;
typedef int wifi_radio;
typedef int wifi_channel;
typedef struct {
wifi_channel_width width;
int center_frequency0;
@ -95,6 +135,53 @@ typedef struct {
int primary_frequency;
} wifi_channel_spec;
/*
* wifi_usable_channel specifies a channel frequency, bandwidth, and bitmask
* of modes allowed on the channel.
*/
typedef struct {
/* Channel frequency in MHz */
wifi_channel freq;
/* Channel operating width (20, 40, 80, 160 etc.) */
wifi_channel_width width;
/* BIT MASK of BIT(WIFI_INTERFACE_*) represented by |wifi_interface_mode|
* Bitmask does not represent concurrency.
* Examples:
* - If a channel is usable only for STA, then only the WIFI_INTERFACE_STA
* bit would be set for that channel.
* - If 5GHz SAP is not allowed, then none of the 5GHz channels will have
* WIFI_INTERFACE_SOFTAP bit set.
* Note: TDLS bit is set only if there is a STA connection. TDLS bit is set
* on non-STA channels only if TDLS off channel is supported.
*/
u32 iface_mode_mask;
} wifi_usable_channel;
/*
* wifi_usable_channel_filter
*/
typedef enum {
/* Filter Wifi channels that should be avoided due to cellular coex
* restrictions. Some Wifi channels can have extreme interference
* from/to cellular due to short frequency separation with neighboring
* cellular channels or when there is harmonic and intermodulation
* interference. Channels which only have some performance degradation
* (e.g. power back off is sufficient to deal with coexistence issue)
* can be included and should not be filtered out.
*/
WIFI_USABLE_CHANNEL_FILTER_CELLULAR_COEXISTENCE = 1 << 0,
/* Filter channels due to concurrency state.
* Examples:
* - 5GHz SAP operation may be supported in standalone mode, but if
* there is STA connection on 5GHz DFS channel, none of the 5GHz
* channels are usable for SAP if device does not support DFS SAP mode.
* - P2P GO may not be supported on indoor channels in EU during
* standalone mode but if there is a STA connection on indoor channel,
* P2P GO may be supported by some vendors on the same STA channel.
*/
WIFI_USABLE_CHANNEL_FILTER_CONCURRENCY = 1 << 1,
} wifi_usable_channel_filter;
typedef enum {
WIFI_SUCCESS = 0,
WIFI_ERROR_NONE = 0,
@ -117,26 +204,6 @@ typedef enum {
WIFI_ACCESS_CATEGORY_VOICE = 3
} wifi_access_category;
typedef unsigned char byte;
typedef unsigned char u8;
typedef signed char s8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef int32_t s32;
typedef uint64_t u64;
typedef int64_t s64;
typedef int wifi_request_id;
typedef int wifi_channel; // indicates channel frequency in MHz
typedef int wifi_rssi;
typedef byte mac_addr[6];
typedef byte oui[3];
typedef int64_t wifi_timestamp; // In microseconds (us)
typedef int64_t wifi_timespan; // In picoseconds (ps)
struct wifi_info;
struct wifi_interface_info;
typedef struct wifi_info *wifi_handle;
typedef struct wifi_interface_info *wifi_interface_handle;
/* Initialize/Cleanup */
@ -190,11 +257,9 @@ void wifi_get_error_info(wifi_error err, const char **msg); // return a pointer
#define WIFI_FEATURE_USE_BODY_HEAD_SAR (uint64_t)0x8000000 // Support Using Body/Head Proximity for SAR
#define WIFI_FEATURE_SET_LATENCY_MODE (uint64_t)0x40000000 // Support Latency mode setting
#define WIFI_FEATURE_P2P_RAND_MAC (uint64_t)0x80000000 // Support P2P MAC randomization
#define WIFI_FEATURE_INFRA_60G (uint64_t)0x100000000 // Support for 60GHz Band
// Add more features here
typedef uint64_t feature_set;
#define IS_MASK_SET(mask, flags) (((flags) & (mask)) == (mask))
#define IS_SUPPORTED_FEATURE(feature, featureSet) IS_MASK_SET(feature, featureSet)
@ -215,6 +280,70 @@ wifi_error wifi_get_ifaces(wifi_handle handle, int *num_ifaces, wifi_interface_h
wifi_error wifi_get_iface_name(wifi_interface_handle iface, char *name, size_t size);
wifi_interface_handle wifi_get_iface_handle(wifi_handle handle, char *name);
/* STA + STA support - Supported if WIFI_FEATURE_ADDITIONAL_STA is set */
/**
* Invoked to indicate that the provided iface is the primary STA iface when there are more
* than 1 STA iface concurrently active.
*
* Note: If the wifi firmware/chip cannot support multiple instances of any offload
* (like roaming, APF, rssi threshold, etc), the firmware should ensure that these
* offloads are at least enabled for the primary interface. If the new primary interface is
* already connected to a network, the firmware must switch all the offloads on
* this new interface without disconnecting.
*/
wifi_error wifi_multi_sta_set_primary_connection(wifi_handle handle, wifi_interface_handle iface);
/**
* When there are 2 or more simultaneous STA connections, this use case hint indicates what
* use-case is being enabled by the framework. This use case hint can be used by the firmware
* to modify various firmware configurations like:
* - Allowed BSSIDs the firmware can choose for the initial connection/roaming attempts.
* - Duty cycle to choose for the 2 STA connections if the radio is in MCC mode.
* - Whether roaming, APF and other offloads needs to be enabled or not.
*
* Note:
* - This will be invoked before an active wifi connection is established on the second interface.
* - This use-case hint is implicitly void when the second STA interface is brought down.
*/
typedef enum {
/**
* Usage:
* - This will be sent down for make before break use-case.
* - Platform is trying to speculatively connect to a second network and evaluate it without
* disrupting the primary connection.
*
* Requirements for Firmware:
* - Do not reduce the number of tx/rx chains of primary connection.
* - If using MCC, should set the MCC duty cycle of the primary connection to be higher than
* the secondary connection (maybe 70/30 split).
* - Should pick the best BSSID for the secondary STA (disregard the chip mode) independent of
* the primary STA:
* - Dont optimize for DBS vs MCC/SCC
* - Should not impact the primary connections bssid selection:
* - Dont downgrade chains of the existing primary connection.
* - Dont optimize for DBS vs MCC/SCC.
*/
WIFI_DUAL_STA_TRANSIENT_PREFER_PRIMARY = 0,
/**
* Usage:
* - This will be sent down for any app requested peer to peer connections.
* - In this case, both the connections needs to be allocated equal resources.
* - For the peer to peer use case, BSSID for the secondary connection will be chosen by the
* framework.
*
* Requirements for Firmware:
* - Can choose MCC or DBS mode depending on the MCC efficiency and HW capability.
* - If using MCC, set the MCC duty cycle of the primary connection to be equal to the secondary
* connection.
* - Prefer BSSID candidates which will help provide the best "overall" performance for both the
* connections.
*/
WIFI_DUAL_STA_NON_TRANSIENT_UNBIASED = 1
} wifi_multi_sta_use_case;
wifi_error wifi_multi_sta_set_use_case(wifi_handle handle, wifi_multi_sta_use_case use_case);
/* Configuration events */
typedef struct {
@ -246,6 +375,10 @@ typedef struct {
void (*on_rssi_threshold_breached)(wifi_request_id id, u8 *cur_bssid, s8 cur_rssi);
} wifi_rssi_event_handler;
typedef struct {
void (*on_subsystem_restart)(const char* error);
} wifi_subsystem_restart_handler;
wifi_error wifi_set_iface_event_handler(wifi_request_id id, wifi_interface_handle iface, wifi_event_handler eh);
wifi_error wifi_reset_iface_event_handler(wifi_request_id id, wifi_interface_handle iface);
@ -258,6 +391,9 @@ wifi_error wifi_map_dscp_access_category(wifi_handle handle,
uint32_t access_category);
wifi_error wifi_reset_dscp_mapping(wifi_handle handle);
wifi_error wifi_set_subsystem_restart_handler(wifi_handle handle,
wifi_subsystem_restart_handler handler);
/**
* Wifi HAL Thermal Mitigation API
*
@ -337,6 +473,30 @@ typedef struct wlan_driver_wake_reason_cnt_t {
RX_MULTICAST_WAKE_DATA_CNT rx_multicast_wake_pkt_info;
} WLAN_DRIVER_WAKE_REASON_CNT;
/* Wi-Fi coex channel avoidance support */
#define WIFI_COEX_NO_POWER_CAP (int32_t)0x7FFFFFF
typedef enum {
WIFI_AWARE = 1 << 0,
SOFTAP = 1 << 1,
WIFI_DIRECT = 1 << 2
} wifi_coex_restriction;
/**
* Representation of a Wi-Fi channel to be avoided for Wi-Fi coex channel avoidance.
*
* band is represented as an WLAN_MAC* enum value defined in wlan_mac_band.
* If power_cap_dbm is WIFI_COEX_NO_POWER_CAP, then no power cap should be applied if the specified
* channel is used.
*/
typedef struct {
wlan_mac_band band;
u32 channel;
s32 power_cap_dbm;
} wifi_coex_unsafe_channel;
/* include various feature headers */
#include "gscan.h"
@ -348,6 +508,7 @@ typedef struct wlan_driver_wake_reason_cnt_t {
#include "wifi_nan.h"
#include "wifi_offload.h"
#include "roam.h"
#include "wifi_twt.h"
//wifi HAL function pointer table
typedef struct {
@ -553,8 +714,188 @@ typedef struct {
wifi_interface_type iface_type);
wifi_error (*wifi_virtual_interface_delete)(wifi_handle handle, const char* ifname);
wifi_error (*wifi_set_subsystem_restart_handler)(wifi_handle handle,
wifi_subsystem_restart_handler handler);
/**
* Allow vendor HAL to choose interface name when creating
* an interface. This can be implemented by chips with their
* own interface naming policy.
* If not implemented, the default naming will be used.
*/
wifi_error (*wifi_get_supported_iface_name)(wifi_handle handle, u32 iface_type,
char *name, size_t len);
/**
* Perform early initialization steps that are needed when WIFI
* is disabled.
* If the function returns failure, it means the vendor HAL is unusable
* (for example, if chip hardware is not installed) and no further
* functions should be called.
*/
wifi_error (*wifi_early_initialize)(void);
/**
* Get supported feature set which are chip-global, that is
* not dependent on any created interface.
*/
wifi_error (*wifi_get_chip_feature_set)(wifi_handle handle, feature_set *set);
/**
* Invoked to indicate that the provided iface is the primary STA iface when there are more
* than 1 STA iface concurrently active.
*/
wifi_error (*wifi_multi_sta_set_primary_connection)(wifi_handle handle,
wifi_interface_handle iface);
/**
* When there are 2 simultaneous STA connections, this use case hint
* indicates what STA + STA use-case is being enabled by the framework.
*/
wifi_error (*wifi_multi_sta_set_use_case)(wifi_handle handle,
wifi_multi_sta_use_case use_case);
/**
* Invoked to indicate that the following list of wifi_coex_unsafe_channel should be avoided
* with the specified restrictions.
* @param unsafeChannels list of current |wifi_coex_unsafe_channel| to avoid.
* @param restrictions bitmask of |wifi_coex_restriction| indicating wifi interfaces to
* restrict from the current unsafe channels.
*/
wifi_error (*wifi_set_coex_unsafe_channels)(wifi_handle handle, u32 num_channels,
wifi_coex_unsafe_channel *unsafeChannels,
u32 restrictions);
/**
* Invoked to set voip optimization mode for the provided STA iface
*/
wifi_error (*wifi_set_voip_mode)(wifi_interface_handle iface, wifi_voip_mode mode);
/**@brief twt_register_handler
* Request to register TWT callback before sending any TWT request
* @param wifi_interface_handle:
* @param TwtCallbackHandler: callback function pointers
* @return Synchronous wifi_error
*/
wifi_error (*wifi_twt_register_handler)(wifi_interface_handle iface,
TwtCallbackHandler handler);
/**@brief twt_get_capability
* Request TWT capability
* @param wifi_interface_handle:
* @return Synchronous wifi_error and TwtCapabilitySet
*/
wifi_error (*wifi_twt_get_capability)(wifi_interface_handle iface,
TwtCapabilitySet* twt_cap_set);
/**@brief twt_setup_request
* Request to send TWT setup frame
* @param wifi_interface_handle:
* @param TwtSetupRequest: detailed parameters of setup request
* @return Synchronous wifi_error
* @return Asynchronous EventTwtSetupResponse CB return TwtSetupResponse
*/
wifi_error (*wifi_twt_setup_request)(wifi_interface_handle iface,
TwtSetupRequest* msg);
/**@brief twt_teardown_request
* Request to send TWT teardown frame
* @param wifi_interface_handle:
* @param TwtTeardownRequest: detailed parameters of teardown request
* @return Synchronous wifi_error
* @return Asynchronous EventTwtTeardownCompletion CB return TwtTeardownCompletion
* TwtTeardownCompletion may also be received due to other events
* like CSA, BTCX, TWT scheduler, MultiConnection, peer-initiated teardown, etc.
*/
wifi_error (*wifi_twt_teardown_request)(wifi_interface_handle iface,
TwtTeardownRequest* msg);
/**@brief twt_info_frame_request
* Request to send TWT info frame
* @param wifi_interface_handle:
* @param TwtInfoFrameRequest: detailed parameters in info frame
* @return Synchronous wifi_error
* @return Asynchronous EventTwtInfoFrameReceived CB return TwtInfoFrameReceived
* Driver may also receive Peer-initiated TwtInfoFrame
*/
wifi_error (*wifi_twt_info_frame_request)(wifi_interface_handle iface,
TwtInfoFrameRequest* msg);
/**@brief twt_get_stats
* Request to get TWT stats
* @param wifi_interface_handle:
* @param config_id: configuration ID of TWT request
* @return Synchronous wifi_error and TwtStats
*/
wifi_error (*wifi_twt_get_stats)(wifi_interface_handle iface, u8 config_id,
TwtStats* stats);
/**@brief twt_clear_stats
* Request to clear TWT stats
* @param wifi_interface_handle:
* @param config_id: configuration ID of TWT request
* @return Synchronous wifi_error
*/
wifi_error (*wifi_twt_clear_stats)(wifi_interface_handle iface, u8 config_id);
/**
* Invoked to set DTIM configuration when the host is in the suspend mode
* @param wifi_interface_handle:
* @param multiplier: when STA in the power saving mode, the wake up interval will be set to
* 1) multiplier * DTIM period if multiplier > 0.
* 2) the device default value if multiplier <=0
* Some implementations may apply an additional cap to wake up interval in the case of 1).
*/
wifi_error (*wifi_set_dtim_config)(wifi_interface_handle handle, u32 multiplier);
/**@brief wifi_get_usable_channels
* Request list of usable channels for the requested bands and modes. Usable
* implies channel is allowed as per regulatory for the current country code
* and not restricted due to other hard limitations (e.g. DFS, Coex) In
* certain modes (e.g. STA+SAP) there could be other hard restrictions
* since MCC operation many not be supported by SAP. This API also allows
* driver to return list of usable channels for each mode uniquely to
* distinguish cases where only a limited set of modes are allowed on
* a given channel e.g. srd channels may be supported for P2P but not
* for SAP or P2P-Client may be allowed on an indoor channel but P2P-GO
* may not be allowed. This API is not interface specific and will be
* used to query capabilities of driver in terms of what modes (STA, SAP,
* P2P_CLI, P2P_GO, NAN, TDLS) can be supported on each of the channels.
* @param handle global wifi_handle
* @param band_mask BIT MASK of WLAN_MAC* as represented by |wlan_mac_band|
* @param iface_mode_mask BIT MASK of BIT(WIFI_INTERFACE_*) represented by
* |wifi_interface_mode|. Bitmask respresents all the modes that the
* caller is interested in (e.g. STA, SAP, WFD-CLI, WFD-GO, TDLS, NAN).
* Note: Bitmask does not represent concurrency matrix. If the caller
* is interested in CLI, GO modes, the iface_mode_mask would be set
* to WIFI_INTERFACE_P2P_CLIENT|WIFI_INTERFACE_P2P_GO.
* @param filter_mask BIT MASK of WIFI_USABLE_CHANNEL_FILTER_* represented by
* |wifi_usable_channel_filter|. Indicates if the channel list should
* be filtered based on additional criteria. If filter_mask is not
* specified, driver should return list of usable channels purely
* based on regulatory constraints.
* @param max_size maximum number of |wifi_usable_channel|
* @param size actual number of |wifi_usable_channel| entries returned by driver
* @param channels list of usable channels represented by |wifi_usable_channel|
*/
wifi_error (*wifi_get_usable_channels)(wifi_handle handle, u32 band_mask, u32 iface_mode_mask,
u32 filter_mask, u32 max_size, u32* size,
wifi_usable_channel* channels);
/**
* Trigger wifi subsystem restart to reload firmware
*/
wifi_error (*wifi_trigger_subsystem_restart)(wifi_handle handle);
/*
* when adding new functions make sure to add stubs in
* hal_tool.cpp::init_wifi_stub_hal_func_table
*/
} wifi_hal_fn;
wifi_error init_wifi_vendor_hal_func_table(wifi_hal_fn *fn);
typedef wifi_error (*init_wifi_vendor_hal_func_table_t)(wifi_hal_fn *fn);
#ifdef __cplusplus
}
#endif

View file

@ -35,7 +35,6 @@ extern "C"
*/
typedef int wifi_radio;
typedef int wifi_ring_buffer_id;
#define PER_PACKET_ENTRY_FLAGS_DIRECTION_TX 1 // 0: TX, 1: RX

View file

@ -389,6 +389,7 @@ typedef struct {
u32 max_sdea_service_specific_info_len;
u32 max_subscribe_address;
u32 ndpe_attr_supported;
bool is_instant_mode_supported;
} NanCapabilities;
/*
@ -1033,6 +1034,13 @@ typedef struct {
*/
u8 config_ndpe_attr;
u32 use_ndpe_attr;
/*
Enable NAN v3.1 instant communication mode.
0 - Disable
1 - Enable
*/
u8 config_enable_instant_mode;
u32 enable_instant_mode;
} NanEnableRequest;
/*
@ -1518,6 +1526,13 @@ typedef struct {
*/
u8 config_ndpe_attr;
u32 use_ndpe_attr;
/*
Enable NAN v3.1 instant communication mode.
0 - Disable
1 - Enable
*/
u8 config_enable_instant_mode;
u32 enable_instant_mode;
} NanConfigRequest;
/*

View file

@ -0,0 +1,156 @@
/*
* Copyright (C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __WIFI_HAL_TWT_H__
#define __WIFI_HAL_TWT_H__
#include "wifi_hal.h"
typedef struct {
u8 requester_supported; // 0 for not supporting requester
u8 responder_supported; // 0 for not supporting responder
u8 broadcast_twt_supported; // 0 for not supporting broadcast TWT
u8 flexibile_twt_supported; // 0 for not supporting flexible TWT
} TwtCapability;
typedef struct {
TwtCapability device_capability;
TwtCapability peer_capability;
} TwtCapabilitySet;
// For all optional fields below, if no value specify -1
typedef struct {
u8 config_id; // An unique ID for an individual TWT request
u8 negotiation_type; // 0 for individual TWT, 1 for broadcast TWT
u8 trigger_type; // 0 for non-triggered TWT, 1 for triggered TWT
s32 wake_dur_us; // Proposed wake duration in us
s32 wake_int_us; // Average wake interval in us
s32 wake_int_min_us; // Min wake interval in us. Optional.
s32 wake_int_max_us; // Max wake interval in us. Optional.
s32 wake_dur_min_us; // Min wake duration in us. Optional.
s32 wake_dur_max_us; // Max wake duration in us. Optional.
s32 avg_pkt_size; // Average bytes of each packet to send in each wake
// duration. Optional.
s32 avg_pkt_num; // Average number of packets to send in each wake
// duration. Optional.
s32 wake_time_off_us; // First wake duration time offset in us. Optional.
} TwtSetupRequest;
typedef enum {
TWT_SETUP_SUCCESS = 0, // TWT setup is accepted.
TWT_SETUP_REJECT = 1, // TWT setup is rejected by AP.
TWT_SETUP_TIMEOUT = 2, // TWT setup response from AP times out.
TWT_SETUP_IE = 3, // AP sent TWT Setup IE parsing failure.
TWT_SETUP_PARAMS = 4, // AP sent TWT Setup IE Parameters invalid.
TWT_SETUP_ERROR = 255, // Generic error
} TwtSetupReasonCode;
typedef struct {
u8 config_id; // An unique ID for an individual TWT request
u8 status; // 0 for success, non-zero for failure
TwtSetupReasonCode reason_code;
u8 negotiation_type; // 0 for individual TWT, 1 for broadcast TWT
u8 trigger_type; // 0 for non-triggered TWT, 1 for triggered TWT
s32 wake_dur_us; // Proposed wake duration in us
s32 wake_int_us; // Average wake interval in us
s32 wake_time_off_us; // First wake duration time offset in us.
} TwtSetupResponse;
typedef struct {
u8 config_id; // An unique ID for an individual TWT request
u8 all_twt; // 0 for individual setp request, 1 for all TWT
u8 negotiation_type; // 0 for individual TWT, 1 for broadcast TWT
} TwtTeardownRequest;
typedef enum {
TWT_TD_RC_HOST = 0, // Teardown triggered by Host
TWT_TD_RC_PEER = 1, // Peer initiated teardown
TWT_TD_RC_MCHAN = 2, // Teardown due to MCHAN Active
TWT_TD_RC_MCNX = 3, // Teardown due to MultiConnection
TWT_TD_RC_CSA = 4, // Teardown due to CSA
TWT_TD_RC_BTCX = 5, // Teardown due to BT Coex
TWT_TD_RC_SETUP_FAIL = 6, // Setup fails midway. Teardown all connections
TWT_TD_RC_SCHED = 7, // Teardown by TWT Scheduler
TWT_TD_RC_ERROR = 255, // Generic error cases
} TwtTeardownReason;
typedef struct {
u8 config_id; // An unique ID for an individual TWT request
u8 all_twt; // 0 for individual setp request, 1 for all TWT
u8 status; // 0 for success, non-zero for failure
TwtTeardownReason reason;
} TwtTeardownCompletion;
typedef struct {
u8 config_id; // An unique ID for an individual TWT request
u8 all_twt; // 0 for individual setup request, 1 for all TWT
s32 resume_time_us; // If -1, TWT is suspended for indefinite time.
// Otherwise, TWT is suspended for resume_time_us
} TwtInfoFrameRequest;
typedef enum {
TWT_INFO_RC_HOST = 0, // Host initiated TWT Info frame */
TWT_INFO_RC_PEER = 1, // Peer initiated TWT Info frame
TWT_INFO_RC_ERROR = 2, // Generic error conditions */
} TwtInfoFrameReason;
// TWT Info frame triggered externally.
// Device should not send TwtInfoFrameReceived to Host for internally
// triggered TWT Info frame during SCAN, MCHAN operations.
typedef struct {
u8 config_id; // An unique ID for an individual TWT request
u8 all_twt; // 0 for individual setup request, 1 for all TWT
u8 status; // 0 for success, non-zero for failure
TwtInfoFrameReason reason;
u8 twt_resumed; // 1 - TWT resumed, 0 - TWT suspended
} TwtInfoFrameReceived;
typedef struct {
u8 config_id;
u32 avg_pkt_num_tx; // Average number of Tx packets in each wake duration.
u32 avg_pkt_num_rx; // Average number of Rx packets in each wake duration.
u32 avg_tx_pkt_size; // Average bytes per Rx packet in each wake duration.
u32 avg_rx_pkt_size; // Average bytes per Rx packet in each wake duration.
u32 avg_eosp_dur_us; // Average duration of early terminated SP
u32 eosp_count; // Count of early terminations
u32 num_sp; // Count of service period (SP), also known as wake duration.
} TwtStats;
// Asynchronous notification from the device.
// For example, TWT was torn down by the device and later when the device is
// ready, it can send this async notification.
// This can be expandable in future.
typedef enum {
TWT_NOTIF_ALLOW_TWT = 1, // Device ready to process TWT Setup request
} TwtNotification;
typedef struct {
TwtNotification notification;
} TwtDeviceNotify;
// Callbacks for various TWT responses and events
typedef struct {
// Callback for TWT setup response
void (*EventTwtSetupResponse)(TwtSetupResponse *event);
// Callback for TWT teardown completion
void (*EventTwtTeardownCompletion)(TwtTeardownCompletion* event);
// Callback for TWT info frame received event
void (*EventTwtInfoFrameReceived)(TwtInfoFrameReceived* event);
// Callback for TWT notification from the device
void (*EventTwtDeviceNotify)(TwtDeviceNotify* event);
} TwtCallbackHandler;
#endif /* __WIFI_HAL_TWT_H__ */