From 87805a2f0d09af45b88bb33fdbe09ef5079b1579 Mon Sep 17 00:00:00 2001 From: Ahmed ElArabawy Date: Thu, 18 Jun 2020 14:54:30 -0700 Subject: [PATCH 01/17] Wifi: Add a vendor function to set subsystem restart handler This commit adds a method to set the handler for wifi subsystem restart callback. Bug: 159367026 Test: force a firmware restart and make sure Wifi is recovered. Change-Id: Id125b85a697a0cdd5cf2677abb0006c85053fd43 --- include/hardware_legacy/wifi_hal.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/hardware_legacy/wifi_hal.h b/include/hardware_legacy/wifi_hal.h index 5dabeb6..231923b 100644 --- a/include/hardware_legacy/wifi_hal.h +++ b/include/hardware_legacy/wifi_hal.h @@ -246,6 +246,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 +262,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 * @@ -553,6 +560,9 @@ 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); + } wifi_hal_fn; wifi_error init_wifi_vendor_hal_func_table(wifi_hal_fn *fn); #ifdef __cplusplus From 28f471d3bf3d664999ddee0198fe9cdc7aa07c29 Mon Sep 17 00:00:00 2001 From: Jimmy Chen Date: Thu, 14 Nov 2019 14:25:05 +0200 Subject: [PATCH 02/17] Wifi: enhanced API to support multiple WIFI chips Enhance the API to support multiple WIFI chips. Each WIFI chip is represented by a separate and independent vendor HAL library providing its own function table (wifi_hal_fn structure). New functions added to the function table in order to better support multiple WIFI chips: 1. In the existing hardware/interfaces/wifi implementation, WIFI chip modes and concurrency combinations are hard-coded. Since each WIFI chip can have its own concurrency combinations, it is no longer possible to hard-code the modes/combinations. Add new function wifi_get_chip_modes for reporting chip modes/concurrency combinations. For backward compatibility, if the vendor HAL does not implement this function, the previous hard-coded chip modes and concurrency combinations will be used. 2. In the existing hardware/interfaces/wifi implementation, when creating a new interface, it will use a fixed name such as wlan0 or wlan1. This does not extend well to multiple WIFI chips, as different WIFI chips may want to use their own interface names, or the suggested interface name may have been pre-created by another chip. In order to better support interface creation on multiple WIFI chips, add a function wifi_get_supported_interface_name that allows the vendor HAL to specify its own interface name for upcoming interface creation. If the vendor HAL returns an interface name, it should be passed to wifi_virtual_interface_create to create the interface with the provided name. 3. In the existing hardware/interfaces/wifi implementation, wifi_initialize is only called when creating the first interface (typically when enabling WIFI). However some chips may want to perform early initialization and provide some functionality while WIFI is still disabled. One example is reporting chip-global capabilities that may affect the UI even before WIFI is enabled. In order to support this, add a new function wifi_early_initialize which will perform early initialization. The function should be called as soon as possible after loading the vendor HAL, and if it returns a failure, the vendor HAL should not be considered usable and no WIFI chip should be created based on it. 4. In some cases it is needed to query chip features before creating any interfaces. For example, for trying to start a SoftAP on the 60GHz band, it is needed to detect a chip which supports the 60GHz band, and only if such chip was detected, then an AP interface can be created on it. The wifi_get_supported_feature_set function only works on a created interface so it is not suitable for this scenario. To support such scenarios, add a new function wifi_get_chip_feature_set which returns a set of chip-global features which are independent of any created interface. Bug: 146922967 Test: atest VtsHalWifiV1_0TargetTest VtsHalWifiNanV1_0TargetTest VtsHalWifiApV1_0TargetTest \ VtsHalWifiV1_1TargetTest \ VtsHalWifiV1_2TargetTest VtsHalWifiNanV1_2TargetTest \ VtsHalWifiV1_3TargetTest \ VtsHalWifiApV1_4TargetTest VtsHalWifiNanV1_4TargetTest VtsHalWifiRttV1_4TargetTest Change-Id: If0b4934002c5687024c9fc2e65e15c466f94acd2 --- include/hardware_legacy/wifi_hal.h | 31 ++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/include/hardware_legacy/wifi_hal.h b/include/hardware_legacy/wifi_hal.h index 231923b..1017435 100644 --- a/include/hardware_legacy/wifi_hal.h +++ b/include/hardware_legacy/wifi_hal.h @@ -563,8 +563,39 @@ typedef struct { 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); + + /* + * 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 From ba1d91c5fd19bd3d047c4287aa219c86e30f7af2 Mon Sep 17 00:00:00 2001 From: Jimmy Chen Date: Thu, 4 Jun 2020 14:48:09 +0800 Subject: [PATCH 03/17] Wifi: add 60GHz feature bit Added a new feature code INFRA_60G for chips that operate on the 60GHz band. Bug: 146922967 Test: atest VtsHalWifiV1_0TargetTest VtsHalWifiNanV1_0TargetTest VtsHalWifiApV1_0TargetTest \ VtsHalWifiV1_1TargetTest \ VtsHalWifiV1_2TargetTest VtsHalWifiNanV1_2TargetTest \ VtsHalWifiV1_3TargetTest \ VtsHalWifiApV1_4TargetTest VtsHalWifiNanV1_4TargetTest VtsHalWifiRttV1_4TargetTest Change-Id: I4248c6d5e086305a7628497675fbd5b2a5b52e1b --- include/hardware_legacy/wifi_hal.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/hardware_legacy/wifi_hal.h b/include/hardware_legacy/wifi_hal.h index 1017435..27bc27f 100644 --- a/include/hardware_legacy/wifi_hal.h +++ b/include/hardware_legacy/wifi_hal.h @@ -190,6 +190,7 @@ 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 From 9e25034006f8db451ca7fa6b8272714cd24c7ea9 Mon Sep 17 00:00:00 2001 From: Nate Jiang Date: Wed, 26 Aug 2020 14:28:57 -0700 Subject: [PATCH 04/17] [Aware] Add instant mode support Bug: 160725208 Test: build Change-Id: Ia123cba1669c71317723831385d9c5b234155563 --- include/hardware_legacy/wifi_nan.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/hardware_legacy/wifi_nan.h b/include/hardware_legacy/wifi_nan.h index 334e37a..1fb7138 100644 --- a/include/hardware_legacy/wifi_nan.h +++ b/include/hardware_legacy/wifi_nan.h @@ -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; /* From afea6a410f310d89300972b68d0f94fb1adbc86e Mon Sep 17 00:00:00 2001 From: Mikhail Naganov Date: Mon, 5 Oct 2020 17:12:45 -0700 Subject: [PATCH 05/17] Convert mask types from uint32_t to enum type This applies to the following types: - audio_gain_mode_t; - audio_flags_mask_t; - audio_channel_representation_t; - audio_channel_mask_t; - audio_devices_t. Enum types are distinct thus proper overloading on the type is possible in C++. Also, assignments to enum types are less prone to errors. Bug: 169889714 Test: basic audio functionality Change-Id: I6366511b421ccab2782310ecc15a13e08d9c17af --- audio/audio_hw_hal.cpp | 14 +++++++++----- include/hardware_legacy/AudioSystemLegacy.h | 4 ++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/audio/audio_hw_hal.cpp b/audio/audio_hw_hal.cpp index d15044a..6ea05fd 100644 --- a/audio/audio_hw_hal.cpp +++ b/audio/audio_hw_hal.cpp @@ -90,10 +90,10 @@ static uint32_t audio_device_conv_table[][HAL_API_REV_NUM] = { AudioSystem::DEVICE_IN_DEFAULT, AUDIO_DEVICE_IN_DEFAULT }, }; -static uint32_t convert_audio_device(uint32_t from_device, int from_rev, int to_rev) +static audio_devices_t convert_audio_device(uint32_t from_device, int from_rev, int to_rev) { const uint32_t k_num_devices = sizeof(audio_device_conv_table)/sizeof(uint32_t)/HAL_API_REV_NUM; - uint32_t to_device = AUDIO_DEVICE_NONE; + audio_devices_t to_device = AUDIO_DEVICE_NONE; uint32_t in_bit = 0; if (from_rev != HAL_API_REV_1_0) { @@ -107,7 +107,7 @@ static uint32_t convert_audio_device(uint32_t from_device, int from_rev, int to_ for (i = 0; i < k_num_devices; i++) { if (audio_device_conv_table[i][from_rev] == cur_device) { - to_device |= audio_device_conv_table[i][to_rev]; + to_device = (audio_devices_t)(to_device | audio_device_conv_table[i][to_rev]); break; } } @@ -504,14 +504,16 @@ static int adev_open_output_stream(struct audio_hw_device *dev, devices = convert_audio_device(devices, HAL_API_REV_2_0, HAL_API_REV_1_0); + uint32_t raw_channel_mask = config->channel_mask; out->legacy_out = ladev->hwif->openOutputStreamWithFlags(devices, flags, (int *) &config->format, - &config->channel_mask, + &raw_channel_mask, &config->sample_rate, &status); if (!out->legacy_out) { ret = status; goto err_open; } + config->channel_mask = (audio_channel_mask_t)raw_channel_mask; out->stream.common.get_sample_rate = out_get_sample_rate; out->stream.common.set_sample_rate = out_set_sample_rate; @@ -571,13 +573,15 @@ static int adev_open_input_stream(struct audio_hw_device *dev, devices = convert_audio_device(devices, HAL_API_REV_2_0, HAL_API_REV_1_0); + uint32_t raw_channel_mask = config->channel_mask; in->legacy_in = ladev->hwif->openInputStream(devices, (int *) &config->format, - &config->channel_mask, &config->sample_rate, + &raw_channel_mask, &config->sample_rate, &status, (AudioSystem::audio_in_acoustics)0); if (!in->legacy_in) { ret = status; goto err_open; } + config->channel_mask = (audio_channel_mask_t)raw_channel_mask; in->stream.common.get_sample_rate = in_get_sample_rate; in->stream.common.set_sample_rate = in_set_sample_rate; diff --git a/include/hardware_legacy/AudioSystemLegacy.h b/include/hardware_legacy/AudioSystemLegacy.h index e2f12a5..0bec0f2 100644 --- a/include/hardware_legacy/AudioSystemLegacy.h +++ b/include/hardware_legacy/AudioSystemLegacy.h @@ -345,10 +345,10 @@ public: static bool isLinearPCM(uint32_t format) { return audio_is_linear_pcm((audio_format_t) format); } - static bool isOutputChannel(uint32_t channel) { + static bool isOutputChannel(audio_channel_mask_t channel) { return audio_is_output_channel(channel); } - static bool isInputChannel(uint32_t channel) { + static bool isInputChannel(audio_channel_mask_t channel) { return audio_is_input_channel(channel); } From 354fe63de77432241aedea12fd97cd892167f186 Mon Sep 17 00:00:00 2001 From: Roshan Pius Date: Wed, 14 Oct 2020 12:16:11 -0700 Subject: [PATCH 06/17] libhardware_legacy(wifi): Add STA + STA APIs Bug: 170305665 Test: Compiles Change-Id: I23633ee79b27a602a609edf84efec49b39af0ac9 --- include/hardware_legacy/link_layer_stats.h | 20 +++--- include/hardware_legacy/wifi_hal.h | 79 ++++++++++++++++++++++ 2 files changed, 90 insertions(+), 9 deletions(-) diff --git a/include/hardware_legacy/link_layer_stats.h b/include/hardware_legacy/link_layer_stats.h index 7a43230..4fde78a 100644 --- a/include/hardware_legacy/link_layer_stats.h +++ b/include/hardware_legacy/link_layer_stats.h @@ -45,15 +45,17 @@ typedef enum { #define WIFI_CAPABILITY_COUNTRY 0x00000020 // set is 802.11 Country Element is present typedef struct { - wifi_interface_mode mode; // interface mode - u8 mac_addr[6]; // interface mac address (self) - wifi_connection_state state; // connection state (valid for STA, CLI only) - wifi_roam_state roaming; // roaming state - u32 capabilities; // WIFI_CAPABILITY_XXX (self) - u8 ssid[33]; // null terminated SSID - u8 bssid[6]; // bssid - u8 ap_country_str[3]; // country string advertised by AP - u8 country_str[3]; // country string for this association + wifi_interface_mode mode; // interface mode + u8 mac_addr[6]; // interface mac address (self) + wifi_connection_state state; // connection state (valid for STA, CLI only) + wifi_roam_state roaming; // roaming state + u32 capabilities; // WIFI_CAPABILITY_XXX (self) + u8 ssid[33]; // null terminated SSID + 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 */ diff --git a/include/hardware_legacy/wifi_hal.h b/include/hardware_legacy/wifi_hal.h index 27bc27f..c25dacf 100644 --- a/include/hardware_legacy/wifi_hal.h +++ b/include/hardware_legacy/wifi_hal.h @@ -216,6 +216,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: + * - Don’t optimize for DBS vs MCC/SCC + * - Should not impact the primary connection’s bssid selection: + * - Don’t downgrade chains of the existing primary connection. + * - Don’t 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 hande, wifi_multi_sta_use_case use_case); + /* Configuration events */ typedef struct { @@ -588,6 +652,21 @@ typedef struct { */ 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 hande, + wifi_multi_sta_use_case use_case); + /* * when adding new functions make sure to add stubs in * hal_tool.cpp::init_wifi_stub_hal_func_table From 85f84d379618f9387fe7d4cbbce184987e026cef Mon Sep 17 00:00:00 2001 From: Quang Luong Date: Wed, 25 Nov 2020 17:49:00 -0800 Subject: [PATCH 07/17] libhardware_legacy(wifi): Add coex APIs Bug: 153651001 Test: build Change-Id: Id7f551fd2446a0484e229145a14ef27facaeab97 --- include/hardware_legacy/wifi_hal.h | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/include/hardware_legacy/wifi_hal.h b/include/hardware_legacy/wifi_hal.h index c25dacf..7c56ecd 100644 --- a/include/hardware_legacy/wifi_hal.h +++ b/include/hardware_legacy/wifi_hal.h @@ -278,7 +278,7 @@ typedef enum { WIFI_DUAL_STA_NON_TRANSIENT_UNBIASED = 1 } wifi_multi_sta_use_case; -wifi_error wifi_multi_sta_set_use_case(wifi_handle hande, wifi_multi_sta_use_case use_case); +wifi_error wifi_multi_sta_set_use_case(wifi_handle handle, wifi_multi_sta_use_case use_case); /* Configuration events */ @@ -409,6 +409,24 @@ 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 + +/** + * 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" @@ -664,9 +682,17 @@ typedef struct { * 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 hande, + 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. + */ + wifi_error (*wifi_set_coex_unsafe_channels)(wifi_handle handle, u32 num_channels, + wifi_coex_unsafe_channel *unsafeChannels, + u32 restrictions); + /* * when adding new functions make sure to add stubs in * hal_tool.cpp::init_wifi_stub_hal_func_table From f499981aa071299e6da674b5cbe021ae0d0b2a36 Mon Sep 17 00:00:00 2001 From: Quang Luong Date: Mon, 14 Dec 2020 13:00:03 -0800 Subject: [PATCH 08/17] libhardware_legacy(wifi): Add enum for wifi coex restrictions Add custom enum for wifi coex since IfaceType is not suitable for bitmasks. Bug: 153651001 Test: build Change-Id: I58b55c64f5358ff26fc45451b66e8818bb3c3d30 --- include/hardware_legacy/wifi_hal.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/hardware_legacy/wifi_hal.h b/include/hardware_legacy/wifi_hal.h index 7c56ecd..acf7567 100644 --- a/include/hardware_legacy/wifi_hal.h +++ b/include/hardware_legacy/wifi_hal.h @@ -413,6 +413,12 @@ typedef struct wlan_driver_wake_reason_cnt_t { #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. * @@ -688,6 +694,9 @@ typedef struct { /** * 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, From 3adc28c891263699c205755142dd2f905390f2ff Mon Sep 17 00:00:00 2001 From: Kai Shi Date: Tue, 15 Dec 2020 19:48:58 -0800 Subject: [PATCH 09/17] Add HAL API for VoIP optimization Add HAL API for VoIP optimization. This includes set_voip_mode() as well as TWT control related API. Test: compilation Bug: 166311728 Change-Id: Ib1210cf200ed692433626b8df549262ddf660359 --- include/hardware_legacy/wifi_hal.h | 82 +++++++++++++++ include/hardware_legacy/wifi_twt.h | 156 +++++++++++++++++++++++++++++ 2 files changed, 238 insertions(+) create mode 100644 include/hardware_legacy/wifi_twt.h diff --git a/include/hardware_legacy/wifi_hal.h b/include/hardware_legacy/wifi_hal.h index acf7567..5794204 100644 --- a/include/hardware_legacy/wifi_hal.h +++ b/include/hardware_legacy/wifi_hal.h @@ -65,6 +65,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, @@ -444,6 +453,7 @@ typedef struct { #include "wifi_nan.h" #include "wifi_offload.h" #include "roam.h" +#include "wifi_twt.h" //wifi HAL function pointer table typedef struct { @@ -702,6 +712,78 @@ typedef struct { 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); + /* * when adding new functions make sure to add stubs in * hal_tool.cpp::init_wifi_stub_hal_func_table diff --git a/include/hardware_legacy/wifi_twt.h b/include/hardware_legacy/wifi_twt.h new file mode 100644 index 0000000..ba71991 --- /dev/null +++ b/include/hardware_legacy/wifi_twt.h @@ -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__ */ From 359fa1d1ba2907436817728f4e9565ed6e8a9b73 Mon Sep 17 00:00:00 2001 From: Damon Kim Date: Wed, 30 Dec 2020 23:29:28 +0900 Subject: [PATCH 10/17] HAL: Fix to support CCA Level and Load info in WiFi link-layer statistics. - CCA Level and Load info (Channel Utilization and Station Count from BSS load IE in beacon) - For supporing this feature, DHD and HALUTIL also should be fixed accordingly. (>= DHD 101.10.460) Bug: 173477163 Test: Builds successfully Change-Id: Ic1bd3e26888f8005fdb6c14d8ffeee9d3d04c3d3 --- include/hardware_legacy/link_layer_stats.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/hardware_legacy/link_layer_stats.h b/include/hardware_legacy/link_layer_stats.h index 4fde78a..27413fd 100644 --- a/include/hardware_legacy/link_layer_stats.h +++ b/include/hardware_legacy/link_layer_stats.h @@ -160,10 +160,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; From 8485407bcc13c4683d4a501e25aa9ff4e4f627c7 Mon Sep 17 00:00:00 2001 From: Kai Shi Date: Mon, 11 Jan 2021 19:27:28 -0800 Subject: [PATCH 11/17] Add wifi_set_dtim_config for power optimization Add the new HAL API for WLAN power optimization in the suspend mode. Test: halutil test Bug: 170678227 Change-Id: Icff3d01585213431be539913c8d229fdc4875934 --- include/hardware_legacy/wifi_hal.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/hardware_legacy/wifi_hal.h b/include/hardware_legacy/wifi_hal.h index 5794204..940c150 100644 --- a/include/hardware_legacy/wifi_hal.h +++ b/include/hardware_legacy/wifi_hal.h @@ -784,6 +784,16 @@ typedef struct { */ 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); + /* * when adding new functions make sure to add stubs in * hal_tool.cpp::init_wifi_stub_hal_func_table From b25c2d1d71047b9aec9c35dd89ebcd1687c0adaa Mon Sep 17 00:00:00 2001 From: Kumar Anand Date: Thu, 14 Jan 2021 16:52:36 -0800 Subject: [PATCH 12/17] Wifi: New API to query the list of usable channels Introduce a new API that can be used to query what modes (SAP, STA, WFD Client, WFD Group Owner, TDLS, NAN) can be supported on each channel. With this new API driver, has flexibility to indicate to framework unambiguously what channels are usable by each mode. Until now, framework had to derive this using one of the NL80211_FREQUENCY_ATTR_X (NO_IR, DFS, INDOOR) which is not sufficent to unambiguously determine allowed channels for each interface modes. Bug: 160212907 Test: Using halutil Change-Id: I25ce9b5083bd6fb650e02c5113bc11b559e80cb5 --- include/hardware_legacy/link_layer_stats.h | 1 + include/hardware_legacy/wifi_hal.h | 96 ++++++++++++++++------ 2 files changed, 70 insertions(+), 27 deletions(-) diff --git a/include/hardware_legacy/link_layer_stats.h b/include/hardware_legacy/link_layer_stats.h index 27413fd..9b67f6d 100644 --- a/include/hardware_legacy/link_layer_stats.h +++ b/include/hardware_legacy/link_layer_stats.h @@ -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; diff --git a/include/hardware_legacy/wifi_hal.h b/include/hardware_legacy/wifi_hal.h index 940c150..c76ee72 100644 --- a/include/hardware_legacy/wifi_hal.h +++ b/include/hardware_legacy/wifi_hal.h @@ -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 { @@ -91,12 +116,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; @@ -104,6 +128,15 @@ typedef struct { int primary_frequency; } wifi_channel_spec; +/* + * wifi_usable_channel - modes supported on a channel and operating bandwidth + */ +typedef struct { + wifi_channel freq; // channel frequency in MHz + wifi_channel_width width; // channel operating width (20, 40, 80, 160 etc.) + u32 iface_mode_mask; // BIT MASK of BIT(WIFI_INTERFACE_*) represented by wifi_interface_mode */ +} wifi_usable_channel; + typedef enum { WIFI_SUCCESS = 0, WIFI_ERROR_NONE = 0, @@ -126,26 +159,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 */ @@ -202,9 +215,6 @@ void wifi_get_error_info(wifi_error err, const char **msg); // return a pointer #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) @@ -794,6 +804,38 @@ typedef struct { */ 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, CLI, GO, TDLS, NAN). + * Note: Bitmask does not represent concurrency matrix. + * @param max_size maximum number of |wifi_usable_channel| + * @param size actual number of |wifi_usable_channel| + * @param channels list of usable channels represented by |wifi_usable_channel| + * Each |wifi_usable_channel| entry specifies a channel frequency, + * bandwidth, and bitmask of modes (e.g. STA, SAP, CLI, GO, TDLS, NAN) + * allowed on the channel. + * 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. + * Note: Bitmask in |wifi_usable_channel| does not represent concurrency. + */ + wifi_error (*wifi_get_usable_channels)(wifi_handle handle, u32 band_mask, u32 iface_mode_mask, + u32 max_size, u32* size, wifi_usable_channel* channels); + /* * when adding new functions make sure to add stubs in * hal_tool.cpp::init_wifi_stub_hal_func_table From 33adbb23f6260d9d6e3868e28b77a342e5eae216 Mon Sep 17 00:00:00 2001 From: Kumar Anand Date: Wed, 10 Feb 2021 18:08:24 -0800 Subject: [PATCH 13/17] Wifi: Filter usable channels by Coex, Concurrency Add ability to filter usable channnels due to coex & concurrency limitations. Normally in standalone mode, list of usable channels is dictated by regulatory. But list of usable channels could be additionally limited due to coex and also due to concurrency limitations. Bug: 160212907 Test: Using halutil Change-Id: Iafde3b4fe9ca8986404ee078ed0a1a31062a4bbb --- include/hardware_legacy/wifi_hal.h | 68 ++++++++++++++++++++++++------ 1 file changed, 54 insertions(+), 14 deletions(-) diff --git a/include/hardware_legacy/wifi_hal.h b/include/hardware_legacy/wifi_hal.h index c76ee72..74cabb6 100644 --- a/include/hardware_legacy/wifi_hal.h +++ b/include/hardware_legacy/wifi_hal.h @@ -129,14 +129,52 @@ typedef struct { } wifi_channel_spec; /* - * wifi_usable_channel - modes supported on a channel and operating bandwidth + * wifi_usable_channel specifies a channel frequency, bandwidth, and bitmask + * of modes allowed on the channel. */ typedef struct { - wifi_channel freq; // channel frequency in MHz - wifi_channel_width width; // channel operating width (20, 40, 80, 160 etc.) - u32 iface_mode_mask; // BIT MASK of BIT(WIFI_INTERFACE_*) represented by wifi_interface_mode */ + /* 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 seperation 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, @@ -821,20 +859,22 @@ typedef struct { * @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, CLI, GO, TDLS, NAN). - * Note: Bitmask does not represent concurrency matrix. + * 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| + * @param size actual number of |wifi_usable_channel| entries returned by driver * @param channels list of usable channels represented by |wifi_usable_channel| - * Each |wifi_usable_channel| entry specifies a channel frequency, - * bandwidth, and bitmask of modes (e.g. STA, SAP, CLI, GO, TDLS, NAN) - * allowed on the channel. - * 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. - * Note: Bitmask in |wifi_usable_channel| does not represent concurrency. */ wifi_error (*wifi_get_usable_channels)(wifi_handle handle, u32 band_mask, u32 iface_mode_mask, - u32 max_size, u32* size, wifi_usable_channel* channels); + u32 filter_mask, u32 max_size, u32* size, + wifi_usable_channel* channels); /* * when adding new functions make sure to add stubs in From f2eed442a6769c3b873083d3ed78fc284b0a416e Mon Sep 17 00:00:00 2001 From: Kumar Anand Date: Mon, 15 Mar 2021 11:16:09 -0700 Subject: [PATCH 14/17] Wifi: Remove multiple definitions Remove compilation warnings due to -Wtypedef-redefinition. Bug: 160212907 Test: Build Successfully Change-Id: I8925cf33fa64fbba4a6cbb782ecc107a7741fe87 --- include/hardware_legacy/wifi_config.h | 2 -- include/hardware_legacy/wifi_hal.h | 2 +- include/hardware_legacy/wifi_logger.h | 1 - 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/include/hardware_legacy/wifi_config.h b/include/hardware_legacy/wifi_config.h index 8ad14f4..9ddf8b8 100644 --- a/include/hardware_legacy/wifi_config.h +++ b/include/hardware_legacy/wifi_config.h @@ -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, diff --git a/include/hardware_legacy/wifi_hal.h b/include/hardware_legacy/wifi_hal.h index 74cabb6..341a786 100644 --- a/include/hardware_legacy/wifi_hal.h +++ b/include/hardware_legacy/wifi_hal.h @@ -156,7 +156,7 @@ typedef struct { 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 seperation with neighboring + * 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) diff --git a/include/hardware_legacy/wifi_logger.h b/include/hardware_legacy/wifi_logger.h index 465c00b..e6f7c48 100644 --- a/include/hardware_legacy/wifi_logger.h +++ b/include/hardware_legacy/wifi_logger.h @@ -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 From 958307b14f9a3e8298ed0b97dcfcc02f0d186e65 Mon Sep 17 00:00:00 2001 From: Ahmed ElArabawy Date: Mon, 15 Mar 2021 21:41:42 -0700 Subject: [PATCH 15/17] WiFi: Add new SAR scenarios This commit adds new SAR Scenarios. Bug: 162191325 Test: Builds successfully Change-Id: I70c45a5675b9bc374422fe732f888b3782058dd2 --- include/hardware_legacy/wifi_hal.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/hardware_legacy/wifi_hal.h b/include/hardware_legacy/wifi_hal.h index 74cabb6..d22d902 100644 --- a/include/hardware_legacy/wifi_hal.h +++ b/include/hardware_legacy/wifi_hal.h @@ -73,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 { From 35390b6dff3d288945565187973491bc43664820 Mon Sep 17 00:00:00 2001 From: chenpaul Date: Wed, 10 Mar 2021 21:24:42 +0800 Subject: [PATCH 16/17] Wifi: New API to query the trigger subsystem restart This commit adds a method to forward the subsystem restart request Bug: 178126071 Test: Trigger firmware restart and make sure event was forwarded Change-Id: I5e97e645b630822865b1614f999e8b465a6d2b0b --- include/hardware_legacy/wifi_hal.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/hardware_legacy/wifi_hal.h b/include/hardware_legacy/wifi_hal.h index a783e11..0ad9c4b 100644 --- a/include/hardware_legacy/wifi_hal.h +++ b/include/hardware_legacy/wifi_hal.h @@ -394,6 +394,7 @@ 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_error wifi_trigger_subsystem_restart(void); /** * Wifi HAL Thermal Mitigation API * @@ -883,6 +884,10 @@ typedef struct { 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)(void); /* * when adding new functions make sure to add stubs in * hal_tool.cpp::init_wifi_stub_hal_func_table From 4ebb0af45c0bc941392d9ba8435e51642517dffd Mon Sep 17 00:00:00 2001 From: chenpaul Date: Tue, 30 Mar 2021 14:39:14 +0800 Subject: [PATCH 17/17] Wifi: Add argument "WifiHandle" in "wifi_set_subsystem_restart_handler" Bug: 178126071 Bug: 183483123 Test: vendor HAL can received API call Change-Id: I0d6c9ce294e1bcea1ed19e4050babd923e6b6141 --- include/hardware_legacy/wifi_hal.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/hardware_legacy/wifi_hal.h b/include/hardware_legacy/wifi_hal.h index 0ad9c4b..81948d6 100644 --- a/include/hardware_legacy/wifi_hal.h +++ b/include/hardware_legacy/wifi_hal.h @@ -394,7 +394,6 @@ 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_error wifi_trigger_subsystem_restart(void); /** * Wifi HAL Thermal Mitigation API * @@ -887,7 +886,7 @@ typedef struct { /** * Trigger wifi subsystem restart to reload firmware */ - wifi_error (*wifi_trigger_subsystem_restart)(void); + 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