Wifi: HAL API to query the list of usable channels

API can be used to query what modes (SAP, STA,
WFD Client, WFD Group Owner, TDLS, NAN) can be
supported on each channel for specified band.
Needs support from Wifi chip vendors.

Bug: 160212907
Test: VTS - VtsHalWifiV1_5TargetTest
Change-Id: Icf270b8c2ee14c794778421c9d988712c5c38380
This commit is contained in:
Kumar Anand 2021-01-21 14:09:14 -08:00
parent 24a732cd14
commit 2a630a3817
10 changed files with 343 additions and 47 deletions

View file

@ -234,4 +234,33 @@ interface IWifiChip extends @1.4::IWifiChip {
* |WifiStatusCode.FAILURE_IFACE_INVALID|
*/
setCountryCode(int8_t[2] code) generates (WifiStatus status);
/**
* Retrieve list of usable Wifi channels for the specified band &
* operational modes.
*
* The list of usable Wifi channels in a given band depends on factors
* like current country code, operational mode (e.g. STA, SAP, CLI, GO,
* TDLS, NAN) and any hard restrictons due to DFS, LTE Coex and
* MCC(multi channel-concurrency).
*
* @param band |WifiBand| for which list of usable channels is requested.
* @param ifaceModeMask Bitmask of the modes represented by |WifiIfaceMode|
* 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.
* @return status WifiStatus of the operation.
* Possible status codes:
* |WifiStatusCode.SUCCESS|,
* |WifiStatusCode.ERROR_NOT_SUPPORTED|,
* |WifiStatusCode.ERROR_INVALID_ARGS|,
* |WifiStatusCode.FAILURE_UNKNOWN|
* @return channels List of channels represented by |WifiUsableChannel|
* Each entry represents a channel frequency, bandwidth and
* bitmask of operational modes (e.g. STA, SAP, CLI, GO, TDLS, NAN)
* allowed on that channel.
* Note: Bitmask does not represent concurrency matrix.
*/
getUsableChannels(WifiBand band, bitfield<WifiIfaceMode> ifaceModeMask)
generates (WifiStatus status, vec<WifiUsableChannel> channels);
};

View file

@ -356,6 +356,129 @@ bool convertLegacyWifiMacInfoToHidl(
return true;
}
uint32_t convertHidlWifiBandToLegacyMacBand(V1_5::WifiBand hidl_band) {
switch (hidl_band) {
case V1_5::WifiBand::BAND_24GHZ:
return legacy_hal::WLAN_MAC_2_4_BAND;
case V1_5::WifiBand::BAND_5GHZ:
case V1_5::WifiBand::BAND_5GHZ_DFS:
case V1_5::WifiBand::BAND_5GHZ_WITH_DFS:
return legacy_hal::WLAN_MAC_5_0_BAND;
case V1_5::WifiBand::BAND_24GHZ_5GHZ:
case V1_5::WifiBand::BAND_24GHZ_5GHZ_WITH_DFS:
return (legacy_hal::WLAN_MAC_2_4_BAND |
legacy_hal::WLAN_MAC_5_0_BAND);
case V1_5::WifiBand::BAND_6GHZ:
return legacy_hal::WLAN_MAC_6_0_BAND;
case V1_5::WifiBand::BAND_5GHZ_6GHZ:
return (legacy_hal::WLAN_MAC_5_0_BAND |
legacy_hal::WLAN_MAC_6_0_BAND);
case V1_5::WifiBand::BAND_24GHZ_5GHZ_6GHZ:
case V1_5::WifiBand::BAND_24GHZ_5GHZ_WITH_DFS_6GHZ:
return (legacy_hal::WLAN_MAC_2_4_BAND |
legacy_hal::WLAN_MAC_5_0_BAND |
legacy_hal::WLAN_MAC_6_0_BAND);
case V1_5::WifiBand::BAND_60GHZ:
return legacy_hal::WLAN_MAC_60_0_BAND;
default:
return (
legacy_hal::WLAN_MAC_2_4_BAND | legacy_hal::WLAN_MAC_5_0_BAND |
legacy_hal::WLAN_MAC_6_0_BAND | legacy_hal::WLAN_MAC_60_0_BAND);
}
}
uint32_t convertHidlWifiIfaceModeToLegacy(uint32_t hidl_iface_mask) {
uint32_t legacy_iface_mask = 0;
if (hidl_iface_mask & V1_5::WifiIfaceMode::IFACE_MODE_STA) {
legacy_iface_mask |= (1 << legacy_hal::WIFI_INTERFACE_STA);
}
if (hidl_iface_mask & V1_5::WifiIfaceMode::IFACE_MODE_SOFTAP) {
legacy_iface_mask |= (1 << legacy_hal::WIFI_INTERFACE_SOFTAP);
}
if (hidl_iface_mask & V1_5::WifiIfaceMode::IFACE_MODE_P2P_CLIENT) {
legacy_iface_mask |= (1 << legacy_hal::WIFI_INTERFACE_P2P_CLIENT);
}
if (hidl_iface_mask & V1_5::WifiIfaceMode::IFACE_MODE_P2P_GO) {
legacy_iface_mask |= (1 << legacy_hal::WIFI_INTERFACE_P2P_GO);
}
if (hidl_iface_mask & V1_5::WifiIfaceMode::IFACE_MODE_NAN) {
legacy_iface_mask |= (1 << legacy_hal::WIFI_INTERFACE_NAN);
}
if (hidl_iface_mask & V1_5::WifiIfaceMode::IFACE_MODE_TDLS) {
legacy_iface_mask |= (1 << legacy_hal::WIFI_INTERFACE_TDLS);
}
if (hidl_iface_mask & V1_5::WifiIfaceMode::IFACE_MODE_MESH) {
legacy_iface_mask |= (1 << legacy_hal::WIFI_INTERFACE_MESH);
}
if (hidl_iface_mask & V1_5::WifiIfaceMode::IFACE_MODE_IBSS) {
legacy_iface_mask |= (1 << legacy_hal::WIFI_INTERFACE_IBSS);
}
return legacy_iface_mask;
}
uint32_t convertLegacyWifiInterfaceModeToHidl(uint32_t legacy_iface_mask) {
uint32_t hidl_iface_mask = 0;
if (legacy_iface_mask & (1 << legacy_hal::WIFI_INTERFACE_STA)) {
hidl_iface_mask |= V1_5::WifiIfaceMode::IFACE_MODE_STA;
}
if (legacy_iface_mask & (1 << legacy_hal::WIFI_INTERFACE_SOFTAP)) {
hidl_iface_mask |= V1_5::WifiIfaceMode::IFACE_MODE_SOFTAP;
}
if (legacy_iface_mask & (1 << legacy_hal::WIFI_INTERFACE_P2P_CLIENT)) {
hidl_iface_mask |= V1_5::WifiIfaceMode::IFACE_MODE_P2P_CLIENT;
}
if (legacy_iface_mask & (1 << legacy_hal::WIFI_INTERFACE_P2P_GO)) {
hidl_iface_mask |= V1_5::WifiIfaceMode::IFACE_MODE_P2P_GO;
}
if (legacy_iface_mask & (1 << legacy_hal::WIFI_INTERFACE_NAN)) {
hidl_iface_mask |= V1_5::WifiIfaceMode::IFACE_MODE_NAN;
}
if (legacy_iface_mask & (1 << legacy_hal::WIFI_INTERFACE_TDLS)) {
hidl_iface_mask |= V1_5::WifiIfaceMode::IFACE_MODE_TDLS;
}
if (legacy_iface_mask & (1 << legacy_hal::WIFI_INTERFACE_MESH)) {
hidl_iface_mask |= V1_5::WifiIfaceMode::IFACE_MODE_MESH;
}
if (legacy_iface_mask & (1 << legacy_hal::WIFI_INTERFACE_IBSS)) {
hidl_iface_mask |= V1_5::WifiIfaceMode::IFACE_MODE_IBSS;
}
return hidl_iface_mask;
}
bool convertLegacyWifiUsableChannelToHidl(
const legacy_hal::wifi_usable_channel& legacy_usable_channel,
V1_5::WifiUsableChannel* hidl_usable_channel) {
if (!hidl_usable_channel) {
return false;
}
*hidl_usable_channel = {};
hidl_usable_channel->channel = legacy_usable_channel.freq;
hidl_usable_channel->channelBandwidth =
convertLegacyWifiChannelWidthToHidl(legacy_usable_channel.width);
hidl_usable_channel->ifaceModeMask = convertLegacyWifiInterfaceModeToHidl(
legacy_usable_channel.iface_mode_mask);
return true;
}
bool convertLegacyWifiUsableChannelsToHidl(
const std::vector<legacy_hal::wifi_usable_channel>& legacy_usable_channels,
std::vector<V1_5::WifiUsableChannel>* hidl_usable_channels) {
if (!hidl_usable_channels) {
return false;
}
*hidl_usable_channels = {};
for (const auto& legacy_usable_channel : legacy_usable_channels) {
V1_5::WifiUsableChannel hidl_usable_channel;
if (!convertLegacyWifiUsableChannelToHidl(legacy_usable_channel,
&hidl_usable_channel)) {
return false;
}
hidl_usable_channels->push_back(hidl_usable_channel);
}
return true;
}
bool convertLegacyWifiMacInfosToHidl(
const std::vector<legacy_hal::WifiMacInfo>& legacy_mac_infos,
std::vector<V1_4::IWifiChipEventCallback::RadioModeInfo>*

View file

@ -206,6 +206,11 @@ bool convertLegacyRttCapabilitiesToHidl(
bool convertLegacyVectorOfRttResultToHidl(
const std::vector<const legacy_hal::wifi_rtt_result*>& legacy_results,
std::vector<V1_4::RttResult>* hidl_results);
uint32_t convertHidlWifiBandToLegacyMacBand(V1_5::WifiBand band);
uint32_t convertHidlWifiIfaceModeToLegacy(uint32_t hidl_iface_mask);
bool convertLegacyWifiUsableChannelsToHidl(
const std::vector<legacy_hal::wifi_usable_channel>& legacy_usable_channels,
std::vector<V1_5::WifiUsableChannel>* hidl_usable_channels);
} // namespace hidl_struct_util
} // namespace implementation
} // namespace V1_5

View file

@ -738,6 +738,14 @@ Return<void> WifiChip::setCountryCode(const hidl_array<int8_t, 2>& code,
code);
}
Return<void> WifiChip::getUsableChannels(
WifiBand band, hidl_bitfield<WifiIfaceMode> ifaceModeMask,
getUsableChannels_cb _hidl_cb) {
return validateAndCall(this, WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
&WifiChip::getUsableChannelsInternal, _hidl_cb, band,
ifaceModeMask);
}
void WifiChip::invalidateAndRemoveAllIfaces() {
invalidateAndClearBridgedApAll();
invalidateAndClearAll(ap_ifaces_);
@ -1490,6 +1498,25 @@ WifiStatus WifiChip::setCountryCodeInternal(const std::array<int8_t, 2>& code) {
return createWifiStatusFromLegacyError(legacy_status);
}
std::pair<WifiStatus, std::vector<WifiUsableChannel>>
WifiChip::getUsableChannelsInternal(WifiBand band, uint32_t ifaceModeMask) {
legacy_hal::wifi_error legacy_status;
std::vector<legacy_hal::wifi_usable_channel> legacy_usable_channels;
std::tie(legacy_status, legacy_usable_channels) =
legacy_hal_.lock()->getUsableChannels(
hidl_struct_util::convertHidlWifiBandToLegacyMacBand(band),
hidl_struct_util::convertHidlWifiIfaceModeToLegacy(ifaceModeMask));
if (legacy_status != legacy_hal::WIFI_SUCCESS) {
return {createWifiStatusFromLegacyError(legacy_status), {}};
}
std::vector<WifiUsableChannel> hidl_usable_channels;
if (!hidl_struct_util::convertLegacyWifiUsableChannelsToHidl(
legacy_usable_channels, &hidl_usable_channels)) {
return {createWifiStatus(WifiStatusCode::ERROR_UNKNOWN), {}};
}
return {createWifiStatus(WifiStatusCode::SUCCESS), hidl_usable_channels};
}
WifiStatus WifiChip::handleChipConfiguration(
/* NONNULL */ std::unique_lock<std::recursive_mutex>* lock,
ChipModeId mode_id) {

View file

@ -180,6 +180,9 @@ class WifiChip : public V1_5::IWifiChip {
setCoexUnsafeChannels_cb hidl_status_cb) override;
Return<void> setCountryCode(const hidl_array<int8_t, 2>& code,
setCountryCode_cb _hidl_cb) override;
Return<void> getUsableChannels(WifiBand band,
hidl_bitfield<WifiIfaceMode> ifaceModeMask,
getUsableChannels_cb _hidl_cb) override;
private:
void invalidateAndRemoveAllIfaces();
@ -261,6 +264,8 @@ class WifiChip : public V1_5::IWifiChip {
WifiStatus setCoexUnsafeChannelsInternal(
std::vector<CoexUnsafeChannel> unsafe_channels, uint32_t restrictions);
WifiStatus setCountryCodeInternal(const std::array<int8_t, 2>& code);
std::pair<WifiStatus, std::vector<WifiUsableChannel>>
getUsableChannelsInternal(WifiBand band, uint32_t ifaceModeMask);
WifiStatus handleChipConfiguration(
std::unique_lock<std::recursive_mutex>* lock, ChipModeId mode_id);
WifiStatus registerDebugRingBufferCallback();

View file

@ -36,6 +36,7 @@ static constexpr uint32_t kMaxGscanFrequenciesForBand = 64;
static constexpr uint32_t kLinkLayerStatsDataMpduSizeThreshold = 128;
static constexpr uint32_t kMaxWakeReasonStatsArraySize = 32;
static constexpr uint32_t kMaxRingBuffers = 10;
static constexpr uint32_t kMaxWifiUsableChannels = 256;
// need a long timeout (1000ms) for chips that unload their driver.
static constexpr uint32_t kMaxStopCompleteWaitMs = 1000;
static constexpr char kDriverPropName[] = "wlan.driver.status";
@ -1636,6 +1637,19 @@ wifi_error WifiLegacyHal::setDtimConfig(const std::string& iface_name,
multiplier);
}
std::pair<wifi_error, std::vector<wifi_usable_channel>>
WifiLegacyHal::getUsableChannels(uint32_t band_mask, uint32_t iface_mode_mask) {
std::vector<wifi_usable_channel> channels;
channels.resize(kMaxWifiUsableChannels);
uint32_t size = 0;
wifi_error status = global_func_table_.wifi_get_usable_channels(
global_handle_, band_mask, iface_mode_mask, channels.size(), &size,
reinterpret_cast<wifi_usable_channel*>(channels.data()));
CHECK(size >= 0 && size <= kMaxWifiUsableChannels);
channels.resize(size);
return {status, std::move(channels)};
}
void WifiLegacyHal::invalidate() {
global_handle_ = nullptr;
iface_name_to_handle_.clear();

View file

@ -36,9 +36,13 @@ namespace implementation {
namespace legacy_hal {
// Import all the types defined inside the legacy HAL header files into this
// namespace.
using ::frame_info;
using ::frame_type;
using ::FRAME_TYPE_80211_MGMT;
using ::FRAME_TYPE_ETHERNET_II;
using ::FRAME_TYPE_UNKNOWN;
using ::fw_roaming_state_t;
using ::mac_addr;
using ::NAN_CHANNEL_24G_BAND;
using ::NAN_CHANNEL_5G_BAND_HIGH;
using ::NAN_CHANNEL_5G_BAND_LOW;
@ -80,8 +84,6 @@ using ::NAN_RESPONSE_SUBSCRIBE_CANCEL;
using ::NAN_RESPONSE_TCA;
using ::NAN_RESPONSE_TRANSMIT_FOLLOWUP;
using ::NAN_SECURITY_KEY_INPUT_PASSPHRASE;
using ::NAN_SECURITY_KEY_INPUT_PASSPHRASE;
using ::NAN_SECURITY_KEY_INPUT_PMK;
using ::NAN_SECURITY_KEY_INPUT_PMK;
using ::NAN_SERVICE_ACCEPT_POLICY_ALL;
using ::NAN_SERVICE_ACCEPT_POLICY_NONE;
@ -154,19 +156,20 @@ using ::RTT_PEER_NAN;
using ::RTT_PEER_P2P_CLIENT;
using ::RTT_PEER_P2P_GO;
using ::RTT_PEER_STA;
using ::rtt_peer_type;
using ::RTT_STATUS_ABORTED;
using ::RTT_STATUS_FAILURE;
using ::RTT_STATUS_FAIL_AP_ON_DIFF_CHANNEL;
using ::RTT_STATUS_FAIL_BUSY_TRY_LATER;
using ::RTT_STATUS_FAIL_FTM_PARAM_OVERRIDE;
using ::RTT_STATUS_FAIL_INVALID_TS;
using ::RTT_STATUS_FAIL_NOT_SCHEDULED_YET;
using ::RTT_STATUS_FAIL_NO_CAPABILITY;
using ::RTT_STATUS_FAIL_NO_RSP;
using ::RTT_STATUS_FAIL_NOT_SCHEDULED_YET;
using ::RTT_STATUS_FAIL_PROTOCOL;
using ::RTT_STATUS_FAIL_REJECTED;
using ::RTT_STATUS_FAIL_SCHEDULE;
using ::RTT_STATUS_FAIL_TM_TIMEOUT;
using ::RTT_STATUS_FAILURE;
using ::RTT_STATUS_INVALID_REQ;
using ::RTT_STATUS_NAN_RANGING_CONCURRENCY_NOT_SUPPORTED;
using ::RTT_STATUS_NAN_RANGING_PROTOCOL_FAILURE;
@ -185,6 +188,8 @@ using ::RX_PKT_FATE_FW_DROP_NOBUFS;
using ::RX_PKT_FATE_FW_DROP_OTHER;
using ::RX_PKT_FATE_FW_QUEUED;
using ::RX_PKT_FATE_SUCCESS;
using ::ssid_t;
using ::transaction_id;
using ::TX_PKT_FATE_ACKED;
using ::TX_PKT_FATE_DRV_DROP_INVALID;
using ::TX_PKT_FATE_DRV_DROP_NOBUFS;
@ -199,24 +204,31 @@ using ::WIFI_AC_BE;
using ::WIFI_AC_BK;
using ::WIFI_AC_VI;
using ::WIFI_AC_VO;
using ::wifi_band;
using ::WIFI_BAND_A;
using ::WIFI_BAND_ABG;
using ::WIFI_BAND_ABG_WITH_DFS;
using ::WIFI_BAND_A_DFS;
using ::WIFI_BAND_A_WITH_DFS;
using ::WIFI_BAND_ABG;
using ::WIFI_BAND_ABG_WITH_DFS;
using ::WIFI_BAND_BG;
using ::WIFI_BAND_UNSPECIFIED;
using ::wifi_cached_scan_results;
using ::WIFI_CHAN_WIDTH_10;
using ::WIFI_CHAN_WIDTH_160;
using ::WIFI_CHAN_WIDTH_20;
using ::WIFI_CHAN_WIDTH_40;
using ::WIFI_CHAN_WIDTH_5;
using ::WIFI_CHAN_WIDTH_5;
using ::WIFI_CHAN_WIDTH_80;
using ::WIFI_CHAN_WIDTH_80P80;
using ::WIFI_CHAN_WIDTH_INVALID;
using ::wifi_channel_info;
using ::wifi_channel_stat;
using ::wifi_channel_width;
using ::wifi_coex_restriction;
using ::wifi_coex_unsafe_channel;
using ::WIFI_DUAL_STA_NON_TRANSIENT_UNBIASED;
using ::WIFI_DUAL_STA_TRANSIENT_PREFER_PRIMARY;
using ::wifi_error;
using ::WIFI_ERROR_BUSY;
using ::WIFI_ERROR_INVALID_ARGS;
using ::WIFI_ERROR_INVALID_REQUEST_ID;
@ -228,12 +240,29 @@ using ::WIFI_ERROR_TIMED_OUT;
using ::WIFI_ERROR_TOO_MANY_REQUESTS;
using ::WIFI_ERROR_UNINITIALIZED;
using ::WIFI_ERROR_UNKNOWN;
using ::wifi_gscan_capabilities;
using ::wifi_hal_fn;
using ::wifi_information_element;
using ::WIFI_INTERFACE_IBSS;
using ::WIFI_INTERFACE_MESH;
using ::wifi_interface_mode;
using ::WIFI_INTERFACE_NAN;
using ::WIFI_INTERFACE_P2P_CLIENT;
using ::WIFI_INTERFACE_P2P_GO;
using ::WIFI_INTERFACE_SOFTAP;
using ::WIFI_INTERFACE_STA;
using ::WIFI_INTERFACE_TDLS;
using ::wifi_interface_type;
using ::WIFI_INTERFACE_TYPE_AP;
using ::WIFI_INTERFACE_TYPE_NAN;
using ::WIFI_INTERFACE_TYPE_P2P;
using ::WIFI_INTERFACE_TYPE_STA;
using ::WIFI_INTERFACE_UNKNOWN;
using ::wifi_latency_mode;
using ::WIFI_LATENCY_MODE_LOW;
using ::WIFI_LATENCY_MODE_NORMAL;
using ::wifi_lci_information;
using ::wifi_lcr_information;
using ::WIFI_LOGGER_CONNECT_EVENT_SUPPORTED;
using ::WIFI_LOGGER_DRIVER_DUMP_SUPPORTED;
using ::WIFI_LOGGER_MEMORY_DUMP_SUPPORTED;
@ -242,61 +271,34 @@ using ::WIFI_LOGGER_POWER_EVENT_SUPPORTED;
using ::WIFI_LOGGER_WAKE_LOCK_SUPPORTED;
using ::WIFI_MOTION_EXPECTED;
using ::WIFI_MOTION_NOT_EXPECTED;
using ::wifi_motion_pattern;
using ::WIFI_MOTION_UNKNOWN;
using ::wifi_multi_sta_use_case;
using ::wifi_power_scenario;
using ::WIFI_POWER_SCENARIO_ON_BODY_CELL_OFF;
using ::WIFI_POWER_SCENARIO_ON_BODY_CELL_ON;
using ::WIFI_POWER_SCENARIO_ON_HEAD_CELL_OFF;
using ::WIFI_POWER_SCENARIO_ON_HEAD_CELL_ON;
using ::WIFI_POWER_SCENARIO_VOICE_CALL;
using ::WIFI_RTT_BW_10;
using ::WIFI_RTT_BW_160;
using ::WIFI_RTT_BW_20;
using ::WIFI_RTT_BW_40;
using ::WIFI_RTT_BW_5;
using ::WIFI_RTT_BW_80;
using ::WIFI_RTT_PREAMBLE_HE;
using ::WIFI_RTT_PREAMBLE_HT;
using ::WIFI_RTT_PREAMBLE_LEGACY;
using ::WIFI_RTT_PREAMBLE_VHT;
using ::WIFI_SCAN_FLAG_INTERRUPTED;
using ::WIFI_SUCCESS;
using ::WLAN_MAC_2_4_BAND;
using ::WLAN_MAC_5_0_BAND;
using ::WLAN_MAC_6_0_BAND;
using ::frame_info;
using ::frame_type;
using ::fw_roaming_state_t;
using ::mac_addr;
using ::rtt_peer_type;
using ::ssid_t;
using ::transaction_id;
using ::wifi_band;
using ::wifi_cached_scan_results;
using ::wifi_channel_info;
using ::wifi_channel_stat;
using ::wifi_channel_width;
using ::wifi_coex_restriction;
using ::wifi_coex_unsafe_channel;
using ::wifi_error;
using ::wifi_gscan_capabilities;
using ::wifi_hal_fn;
using ::wifi_information_element;
using ::wifi_interface_type;
using ::wifi_latency_mode;
using ::wifi_lci_information;
using ::wifi_lcr_information;
using ::wifi_motion_pattern;
using ::wifi_multi_sta_use_case;
using ::wifi_power_scenario;
using ::wifi_rate;
using ::wifi_request_id;
using ::wifi_ring_buffer_status;
using ::wifi_roaming_capabilities;
using ::wifi_roaming_config;
using ::wifi_rtt_bw;
using ::WIFI_RTT_BW_10;
using ::WIFI_RTT_BW_160;
using ::WIFI_RTT_BW_20;
using ::WIFI_RTT_BW_40;
using ::WIFI_RTT_BW_5;
using ::WIFI_RTT_BW_80;
using ::wifi_rtt_capabilities;
using ::wifi_rtt_config;
using ::wifi_rtt_preamble;
using ::WIFI_RTT_PREAMBLE_HE;
using ::WIFI_RTT_PREAMBLE_HT;
using ::WIFI_RTT_PREAMBLE_LEGACY;
using ::WIFI_RTT_PREAMBLE_VHT;
using ::wifi_rtt_responder;
using ::wifi_rtt_result;
using ::wifi_rtt_status;
@ -305,9 +307,16 @@ using ::wifi_rx_packet_fate;
using ::wifi_rx_report;
using ::wifi_scan_bucket_spec;
using ::wifi_scan_cmd_params;
using ::WIFI_SCAN_FLAG_INTERRUPTED;
using ::wifi_scan_result;
using ::WIFI_SUCCESS;
using ::wifi_tx_packet_fate;
using ::wifi_tx_report;
using ::wifi_usable_channel;
using ::WLAN_MAC_2_4_BAND;
using ::WLAN_MAC_5_0_BAND;
using ::WLAN_MAC_60_0_BAND;
using ::WLAN_MAC_6_0_BAND;
// APF capabilities supported by the iface.
struct PacketFilterCapabilities {
@ -693,6 +702,11 @@ class WifiLegacyHal {
wifi_error setDtimConfig(const std::string& iface_name,
uint32_t multiplier);
// Retrieve the list of usable channels in the requested bands
// for the requested modes
std::pair<wifi_error, std::vector<wifi_usable_channel>> getUsableChannels(
uint32_t band_mask, uint32_t iface_mode_mask);
private:
// Retrieve interface handles for all the available interfaces.
wifi_error retrieveIfaceHandles();

View file

@ -159,6 +159,7 @@ bool initHalFuncTableWithStubs(wifi_hal_fn* hal_fn) {
populateStubFor(&hal_fn->wifi_twt_get_stats);
populateStubFor(&hal_fn->wifi_twt_clear_stats);
populateStubFor(&hal_fn->wifi_set_dtim_config);
populateStubFor(&hal_fn->wifi_get_usable_channels);
return true;
}
} // namespace legacy_hal

View file

@ -24,6 +24,8 @@ import @1.0::NanCipherSuiteType;
import @1.0::NanCapabilities;
import @1.2::NanConfigRequestSupplemental;
import @1.3::StaLinkLayerRadioStats;
import @1.0::WifiChannelInMhz;
import @1.0::WifiChannelWidthInMhz;
/**
* Wifi bands defined in 80211 spec.
@ -43,6 +45,64 @@ enum WifiBand : @1.4::WifiBand {
BAND_24GHZ_5GHZ_WITH_DFS_6GHZ_60GHZ = 31,
};
/**
* Interface operating modes.
*/
enum WifiIfaceMode : uint32_t {
/**
* Interface operation mode is client.
*/
IFACE_MODE_STA = 1 << 0,
/**
* Interface operation mode is Hotspot.
*/
IFACE_MODE_SOFTAP = 1 << 1,
/**
* Interface operation mode is Ad-Hoc network.
*/
IFACE_MODE_IBSS = 1 << 2,
/**
* Interface operation mode is Wifi Direct Client.
*/
IFACE_MODE_P2P_CLIENT = 1 << 3,
/**
* Interface operation mode is Wifi Direct Group Owner.
*/
IFACE_MODE_P2P_GO = 1 << 4,
/**
* Interface operation mode is Aware.
*/
IFACE_MODE_NAN = 1 << 5,
/**
* Interface operation mode is Mesh network.
*/
IFACE_MODE_MESH = 1 << 6,
/**
* Interface operation mode is Tunneled Direct Link Setup.
*/
IFACE_MODE_TDLS = 1 << 7,
};
/**
* Wifi usable channel information.
*/
struct WifiUsableChannel {
/**
* Wifi channel freqeuncy in MHz.
*/
WifiChannelInMhz channel;
/**
* Wifi channel bandwidth in MHz.
*/
WifiChannelWidthInMhz channelBandwidth;
/**
* Iface modes feasible on this channel.
*/
bitfield<WifiIfaceMode> ifaceModeMask;
};
/**
* NAN configuration request parameters added in the 1.2 HAL. These are supplemental to previous
* versions.

View file

@ -45,6 +45,7 @@ using ::android::hardware::wifi::V1_0::WifiStatusCode;
using ::android::hardware::wifi::V1_4::IWifiChipEventCallback;
using ::android::hardware::wifi::V1_5::IWifiChip;
using ::android::hardware::wifi::V1_5::WifiBand;
using ::android::hardware::wifi::V1_5::WifiIfaceMode;
/**
* Fixture to use for all Wifi chip HIDL interface tests.
@ -187,6 +188,23 @@ TEST_P(WifiChipHidlTest, setCountryCode) {
HIDL_INVOKE(wifi_chip_, setCountryCode, kCountryCode).code);
}
/* getUsableChannels:
* Ensure that a call to getUsableChannels will return with a success
* status for valid inputs.
*/
TEST_P(WifiChipHidlTest, getUsableChannels) {
uint32_t ifaceModeMask =
WifiIfaceMode::IFACE_MODE_P2P_CLIENT | WifiIfaceMode::IFACE_MODE_P2P_GO;
configureChipForIfaceType(IfaceType::STA, true);
WifiBand band = WifiBand::BAND_24GHZ_5GHZ_6GHZ;
const auto& statusNonEmpty =
HIDL_INVOKE(wifi_chip_, getUsableChannels, band, ifaceModeMask);
if (statusNonEmpty.first.code != WifiStatusCode::SUCCESS) {
EXPECT_EQ(WifiStatusCode::ERROR_NOT_SUPPORTED,
statusNonEmpty.first.code);
}
}
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(WifiChipHidlTest);
INSTANTIATE_TEST_SUITE_P(
PerInstance, WifiChipHidlTest,