Ahmed ElArabawy | 687ce13 | 2022-01-11 16:42:48 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef HIDL_STRUCT_UTIL_H_ |
| 18 | #define HIDL_STRUCT_UTIL_H_ |
| 19 | |
| 20 | #include <vector> |
| 21 | |
| 22 | #include <android/hardware/wifi/1.0/IWifiChip.h> |
| 23 | #include <android/hardware/wifi/1.0/types.h> |
| 24 | #include <android/hardware/wifi/1.2/types.h> |
| 25 | #include <android/hardware/wifi/1.3/types.h> |
| 26 | #include <android/hardware/wifi/1.4/IWifiChipEventCallback.h> |
| 27 | #include <android/hardware/wifi/1.4/types.h> |
Ahmed ElArabawy | 05571e4 | 2022-01-19 11:54:11 -0800 | [diff] [blame] | 28 | #include <android/hardware/wifi/1.6/IWifiChip.h> |
| 29 | #include <android/hardware/wifi/1.6/types.h> |
Ahmed ElArabawy | 687ce13 | 2022-01-11 16:42:48 -0800 | [diff] [blame] | 30 | |
| 31 | #include "wifi_legacy_hal.h" |
| 32 | |
| 33 | /** |
| 34 | * This file contains a bunch of functions to convert structs from the legacy |
| 35 | * HAL to HIDL and vice versa. |
| 36 | * TODO(b/32093047): Add unit tests for these conversion methods in the VTS test |
| 37 | * suite. |
| 38 | */ |
| 39 | namespace android { |
| 40 | namespace hardware { |
| 41 | namespace wifi { |
| 42 | namespace V1_6 { |
| 43 | namespace implementation { |
| 44 | namespace hidl_struct_util { |
| 45 | using namespace android::hardware::wifi::V1_0; |
| 46 | |
| 47 | // Chip conversion methods. |
| 48 | bool convertLegacyFeaturesToHidlChipCapabilities(uint64_t legacy_feature_set, |
| 49 | uint32_t legacy_logger_feature_set, |
| 50 | uint32_t* hidl_caps); |
| 51 | bool convertLegacyDebugRingBufferStatusToHidl( |
| 52 | const legacy_hal::wifi_ring_buffer_status& legacy_status, |
| 53 | WifiDebugRingBufferStatus* hidl_status); |
| 54 | bool convertLegacyVectorOfDebugRingBufferStatusToHidl( |
| 55 | const std::vector<legacy_hal::wifi_ring_buffer_status>& legacy_status_vec, |
| 56 | std::vector<WifiDebugRingBufferStatus>* hidl_status_vec); |
| 57 | bool convertLegacyWakeReasonStatsToHidl(const legacy_hal::WakeReasonStats& legacy_stats, |
| 58 | WifiDebugHostWakeReasonStats* hidl_stats); |
| 59 | legacy_hal::wifi_power_scenario convertHidlTxPowerScenarioToLegacy( |
| 60 | V1_1::IWifiChip::TxPowerScenario hidl_scenario); |
| 61 | legacy_hal::wifi_latency_mode convertHidlLatencyModeToLegacy( |
| 62 | V1_3::IWifiChip::LatencyMode hidl_latency_mode); |
| 63 | legacy_hal::wifi_power_scenario convertHidlTxPowerScenarioToLegacy_1_2( |
| 64 | V1_2::IWifiChip::TxPowerScenario hidl_scenario); |
| 65 | bool convertLegacyWifiMacInfosToHidl( |
| 66 | const std::vector<legacy_hal::WifiMacInfo>& legacy_mac_infos, |
| 67 | std::vector<V1_4::IWifiChipEventCallback::RadioModeInfo>* hidl_radio_mode_infos); |
| 68 | legacy_hal::wifi_interface_type convertHidlIfaceTypeToLegacy(IfaceType hidl_interface_type); |
| 69 | legacy_hal::wifi_multi_sta_use_case convertHidlMultiStaUseCaseToLegacy( |
| 70 | V1_5::IWifiChip::MultiStaUseCase use_case); |
| 71 | bool convertHidlCoexUnsafeChannelToLegacy( |
| 72 | const V1_5::IWifiChip::CoexUnsafeChannel& hidl_unsafe_channel, |
| 73 | legacy_hal::wifi_coex_unsafe_channel* legacy_unsafe_channel); |
| 74 | bool convertHidlVectorOfCoexUnsafeChannelToLegacy( |
| 75 | const std::vector<V1_5::IWifiChip::CoexUnsafeChannel>& hidl_unsafe_channels, |
| 76 | std::vector<legacy_hal::wifi_coex_unsafe_channel>* legacy_unsafe_channels); |
Sunil Ravi | ef97d23 | 2022-01-24 10:39:56 -0800 | [diff] [blame] | 77 | bool convertLegacyRadioCombinationsMatrixToHidl( |
| 78 | legacy_hal::wifi_radio_combination_matrix* legacy_matrix, |
| 79 | V1_6::WifiRadioCombinationMatrix* hidl_matrix); |
| 80 | V1_5::WifiBand convertLegacyMacBandToHidlWifiBand(uint32_t band); |
| 81 | V1_6::WifiAntennaMode convertLegacyAntennaConfigurationToHidl(uint32_t antenna_cfg); |
Ahmed ElArabawy | 687ce13 | 2022-01-11 16:42:48 -0800 | [diff] [blame] | 82 | |
| 83 | // STA iface conversion methods. |
| 84 | bool convertLegacyFeaturesToHidlStaCapabilities(uint64_t legacy_feature_set, |
| 85 | uint32_t legacy_logger_feature_set, |
| 86 | uint32_t* hidl_caps); |
| 87 | bool convertLegacyApfCapabilitiesToHidl(const legacy_hal::PacketFilterCapabilities& legacy_caps, |
| 88 | StaApfPacketFilterCapabilities* hidl_caps); |
| 89 | bool convertLegacyGscanCapabilitiesToHidl(const legacy_hal::wifi_gscan_capabilities& legacy_caps, |
| 90 | StaBackgroundScanCapabilities* hidl_caps); |
| 91 | legacy_hal::wifi_band convertHidlWifiBandToLegacy(V1_0::WifiBand band); |
| 92 | bool convertHidlGscanParamsToLegacy(const StaBackgroundScanParameters& hidl_scan_params, |
| 93 | legacy_hal::wifi_scan_cmd_params* legacy_scan_params); |
| 94 | // |has_ie_data| indicates whether or not the wifi_scan_result includes 802.11 |
| 95 | // Information Elements (IEs) |
| 96 | bool convertLegacyGscanResultToHidl(const legacy_hal::wifi_scan_result& legacy_scan_result, |
| 97 | bool has_ie_data, StaScanResult* hidl_scan_result); |
| 98 | // |cached_results| is assumed to not include IEs. |
| 99 | bool convertLegacyVectorOfCachedGscanResultsToHidl( |
| 100 | const std::vector<legacy_hal::wifi_cached_scan_results>& legacy_cached_scan_results, |
| 101 | std::vector<StaScanData>* hidl_scan_datas); |
| 102 | bool convertLegacyLinkLayerStatsToHidl(const legacy_hal::LinkLayerStats& legacy_stats, |
Ahmed ElArabawy | 05571e4 | 2022-01-19 11:54:11 -0800 | [diff] [blame] | 103 | V1_6::StaLinkLayerStats* hidl_stats); |
Ahmed ElArabawy | 687ce13 | 2022-01-11 16:42:48 -0800 | [diff] [blame] | 104 | bool convertLegacyRoamingCapabilitiesToHidl( |
| 105 | const legacy_hal::wifi_roaming_capabilities& legacy_caps, |
| 106 | StaRoamingCapabilities* hidl_caps); |
| 107 | bool convertHidlRoamingConfigToLegacy(const StaRoamingConfig& hidl_config, |
| 108 | legacy_hal::wifi_roaming_config* legacy_config); |
| 109 | legacy_hal::fw_roaming_state_t convertHidlRoamingStateToLegacy(StaRoamingState state); |
| 110 | bool convertLegacyVectorOfDebugTxPacketFateToHidl( |
| 111 | const std::vector<legacy_hal::wifi_tx_report>& legacy_fates, |
| 112 | std::vector<WifiDebugTxPacketFateReport>* hidl_fates); |
| 113 | bool convertLegacyVectorOfDebugRxPacketFateToHidl( |
| 114 | const std::vector<legacy_hal::wifi_rx_report>& legacy_fates, |
| 115 | std::vector<WifiDebugRxPacketFateReport>* hidl_fates); |
| 116 | |
| 117 | // NAN iface conversion methods. |
| 118 | void convertToWifiNanStatus(legacy_hal::NanStatusType type, const char* str, size_t max_len, |
| 119 | WifiNanStatus* wifiNanStatus); |
| 120 | bool convertHidlNanEnableRequestToLegacy(const V1_4::NanEnableRequest& hidl_request, |
| 121 | legacy_hal::NanEnableRequest* legacy_request); |
| 122 | bool convertHidlNanConfigRequestToLegacy(const V1_4::NanConfigRequest& hidl_request, |
| 123 | legacy_hal::NanConfigRequest* legacy_request); |
Nate Jiang | 50c001d | 2022-01-12 16:06:01 -0800 | [diff] [blame] | 124 | bool convertHidlNanEnableRequest_1_6ToLegacy( |
Ahmed ElArabawy | 687ce13 | 2022-01-11 16:42:48 -0800 | [diff] [blame] | 125 | const V1_4::NanEnableRequest& hidl_request1, |
Nate Jiang | 50c001d | 2022-01-12 16:06:01 -0800 | [diff] [blame] | 126 | const V1_6::NanConfigRequestSupplemental& hidl_request2, |
Ahmed ElArabawy | 687ce13 | 2022-01-11 16:42:48 -0800 | [diff] [blame] | 127 | legacy_hal::NanEnableRequest* legacy_request); |
Nate Jiang | 50c001d | 2022-01-12 16:06:01 -0800 | [diff] [blame] | 128 | bool convertHidlNanConfigRequest_1_6ToLegacy( |
Ahmed ElArabawy | 687ce13 | 2022-01-11 16:42:48 -0800 | [diff] [blame] | 129 | const V1_4::NanConfigRequest& hidl_request1, |
Nate Jiang | 50c001d | 2022-01-12 16:06:01 -0800 | [diff] [blame] | 130 | const V1_6::NanConfigRequestSupplemental& hidl_request2, |
Ahmed ElArabawy | 687ce13 | 2022-01-11 16:42:48 -0800 | [diff] [blame] | 131 | legacy_hal::NanConfigRequest* legacy_request); |
Nate Jiang | 50c001d | 2022-01-12 16:06:01 -0800 | [diff] [blame] | 132 | bool convertHidlNanPublishRequestToLegacy(const V1_6::NanPublishRequest& hidl_request, |
Ahmed ElArabawy | 687ce13 | 2022-01-11 16:42:48 -0800 | [diff] [blame] | 133 | legacy_hal::NanPublishRequest* legacy_request); |
Nate Jiang | 50c001d | 2022-01-12 16:06:01 -0800 | [diff] [blame] | 134 | bool convertHidlNanSubscribeRequestToLegacy(const V1_0::NanSubscribeRequest& hidl_request, |
Ahmed ElArabawy | 687ce13 | 2022-01-11 16:42:48 -0800 | [diff] [blame] | 135 | legacy_hal::NanSubscribeRequest* legacy_request); |
| 136 | bool convertHidlNanTransmitFollowupRequestToLegacy( |
| 137 | const NanTransmitFollowupRequest& hidl_request, |
| 138 | legacy_hal::NanTransmitFollowupRequest* legacy_request); |
| 139 | bool convertHidlNanDataPathInitiatorRequestToLegacy( |
Nate Jiang | 50c001d | 2022-01-12 16:06:01 -0800 | [diff] [blame] | 140 | const V1_0::NanInitiateDataPathRequest& hidl_request, |
Ahmed ElArabawy | 687ce13 | 2022-01-11 16:42:48 -0800 | [diff] [blame] | 141 | legacy_hal::NanDataPathInitiatorRequest* legacy_request); |
| 142 | bool convertHidlNanDataPathIndicationResponseToLegacy( |
Nate Jiang | 50c001d | 2022-01-12 16:06:01 -0800 | [diff] [blame] | 143 | const V1_0::NanRespondToDataPathIndicationRequest& hidl_response, |
Ahmed ElArabawy | 687ce13 | 2022-01-11 16:42:48 -0800 | [diff] [blame] | 144 | legacy_hal::NanDataPathIndicationResponse* legacy_response); |
Nate Jiang | 50c001d | 2022-01-12 16:06:01 -0800 | [diff] [blame] | 145 | bool convertHidlNanDataPathInitiatorRequest_1_6ToLegacy( |
| 146 | const V1_6::NanInitiateDataPathRequest& hidl_request, |
| 147 | legacy_hal::NanDataPathInitiatorRequest* legacy_request); |
| 148 | bool convertHidlNanDataPathIndicationResponse_1_6ToLegacy( |
| 149 | const V1_6::NanRespondToDataPathIndicationRequest& hidl_response, |
| 150 | legacy_hal::NanDataPathIndicationResponse* legacy_response); |
| 151 | |
Ahmed ElArabawy | 687ce13 | 2022-01-11 16:42:48 -0800 | [diff] [blame] | 152 | bool convertLegacyNanResponseHeaderToHidl(const legacy_hal::NanResponseMsg& legacy_response, |
| 153 | WifiNanStatus* wifiNanStatus); |
| 154 | bool convertLegacyNanCapabilitiesResponseToHidl(const legacy_hal::NanCapabilities& legacy_response, |
Nate Jiang | 50c001d | 2022-01-12 16:06:01 -0800 | [diff] [blame] | 155 | V1_6::NanCapabilities* hidl_response); |
Ahmed ElArabawy | 687ce13 | 2022-01-11 16:42:48 -0800 | [diff] [blame] | 156 | bool convertLegacyNanMatchIndToHidl(const legacy_hal::NanMatchInd& legacy_ind, |
Nate Jiang | 50c001d | 2022-01-12 16:06:01 -0800 | [diff] [blame] | 157 | V1_6::NanMatchInd* hidl_ind); |
Ahmed ElArabawy | 687ce13 | 2022-01-11 16:42:48 -0800 | [diff] [blame] | 158 | bool convertLegacyNanFollowupIndToHidl(const legacy_hal::NanFollowupInd& legacy_ind, |
| 159 | NanFollowupReceivedInd* hidl_ind); |
| 160 | bool convertLegacyNanDataPathRequestIndToHidl(const legacy_hal::NanDataPathRequestInd& legacy_ind, |
| 161 | NanDataPathRequestInd* hidl_ind); |
| 162 | bool convertLegacyNanDataPathConfirmIndToHidl(const legacy_hal::NanDataPathConfirmInd& legacy_ind, |
Ahmed ElArabawy | 05571e4 | 2022-01-19 11:54:11 -0800 | [diff] [blame] | 163 | V1_6::NanDataPathConfirmInd* hidl_ind); |
Ahmed ElArabawy | 687ce13 | 2022-01-11 16:42:48 -0800 | [diff] [blame] | 164 | bool convertLegacyNanDataPathScheduleUpdateIndToHidl( |
| 165 | const legacy_hal::NanDataPathScheduleUpdateInd& legacy_ind, |
Ahmed ElArabawy | 05571e4 | 2022-01-19 11:54:11 -0800 | [diff] [blame] | 166 | V1_6::NanDataPathScheduleUpdateInd* hidl_ind); |
Ahmed ElArabawy | 687ce13 | 2022-01-11 16:42:48 -0800 | [diff] [blame] | 167 | |
| 168 | // RTT controller conversion methods. |
Ahmed ElArabawy | 05571e4 | 2022-01-19 11:54:11 -0800 | [diff] [blame] | 169 | bool convertHidlVectorOfRttConfigToLegacy(const std::vector<V1_6::RttConfig>& hidl_configs, |
Ahmed ElArabawy | 687ce13 | 2022-01-11 16:42:48 -0800 | [diff] [blame] | 170 | std::vector<legacy_hal::wifi_rtt_config>* legacy_configs); |
| 171 | bool convertHidlRttLciInformationToLegacy(const RttLciInformation& hidl_info, |
| 172 | legacy_hal::wifi_lci_information* legacy_info); |
| 173 | bool convertHidlRttLcrInformationToLegacy(const RttLcrInformation& hidl_info, |
| 174 | legacy_hal::wifi_lcr_information* legacy_info); |
Ahmed ElArabawy | 05571e4 | 2022-01-19 11:54:11 -0800 | [diff] [blame] | 175 | bool convertHidlRttResponderToLegacy(const V1_6::RttResponder& hidl_responder, |
Ahmed ElArabawy | 687ce13 | 2022-01-11 16:42:48 -0800 | [diff] [blame] | 176 | legacy_hal::wifi_rtt_responder* legacy_responder); |
Ahmed ElArabawy | 05571e4 | 2022-01-19 11:54:11 -0800 | [diff] [blame] | 177 | bool convertHidlWifiChannelInfoToLegacy(const V1_6::WifiChannelInfo& hidl_info, |
Ahmed ElArabawy | 687ce13 | 2022-01-11 16:42:48 -0800 | [diff] [blame] | 178 | legacy_hal::wifi_channel_info* legacy_info); |
| 179 | bool convertLegacyRttResponderToHidl(const legacy_hal::wifi_rtt_responder& legacy_responder, |
Ahmed ElArabawy | 05571e4 | 2022-01-19 11:54:11 -0800 | [diff] [blame] | 180 | V1_6::RttResponder* hidl_responder); |
Ahmed ElArabawy | 687ce13 | 2022-01-11 16:42:48 -0800 | [diff] [blame] | 181 | bool convertLegacyRttCapabilitiesToHidl( |
| 182 | const legacy_hal::wifi_rtt_capabilities& legacy_capabilities, |
Ahmed ElArabawy | 05571e4 | 2022-01-19 11:54:11 -0800 | [diff] [blame] | 183 | V1_6::RttCapabilities* hidl_capabilities); |
Ahmed ElArabawy | 687ce13 | 2022-01-11 16:42:48 -0800 | [diff] [blame] | 184 | bool convertLegacyVectorOfRttResultToHidl( |
| 185 | const std::vector<const legacy_hal::wifi_rtt_result*>& legacy_results, |
Ahmed ElArabawy | 05571e4 | 2022-01-19 11:54:11 -0800 | [diff] [blame] | 186 | std::vector<V1_6::RttResult>* hidl_results); |
Ahmed ElArabawy | 687ce13 | 2022-01-11 16:42:48 -0800 | [diff] [blame] | 187 | uint32_t convertHidlWifiBandToLegacyMacBand(V1_5::WifiBand band); |
| 188 | uint32_t convertHidlWifiIfaceModeToLegacy(uint32_t hidl_iface_mask); |
| 189 | uint32_t convertHidlUsableChannelFilterToLegacy(uint32_t hidl_filter_mask); |
| 190 | bool convertLegacyWifiUsableChannelsToHidl( |
| 191 | const std::vector<legacy_hal::wifi_usable_channel>& legacy_usable_channels, |
Ahmed ElArabawy | 05571e4 | 2022-01-19 11:54:11 -0800 | [diff] [blame] | 192 | std::vector<V1_6::WifiUsableChannel>* hidl_usable_channels); |
Ahmed ElArabawy | 687ce13 | 2022-01-11 16:42:48 -0800 | [diff] [blame] | 193 | bool convertLegacyPeerInfoStatsToHidl(const legacy_hal::WifiPeerInfo& legacy_peer_info_stats, |
Ahmed ElArabawy | 05571e4 | 2022-01-19 11:54:11 -0800 | [diff] [blame] | 194 | V1_6::StaPeerInfo* hidl_peer_info_stats); |
Ahmed ElArabawy | 687ce13 | 2022-01-11 16:42:48 -0800 | [diff] [blame] | 195 | bool convertLegacyWifiRateInfoToHidl(const legacy_hal::wifi_rate& legacy_rate, |
Ahmed ElArabawy | 05571e4 | 2022-01-19 11:54:11 -0800 | [diff] [blame] | 196 | V1_6::WifiRateInfo* hidl_rate); |
Ahmed ElArabawy | 687ce13 | 2022-01-11 16:42:48 -0800 | [diff] [blame] | 197 | } // namespace hidl_struct_util |
| 198 | } // namespace implementation |
| 199 | } // namespace V1_6 |
| 200 | } // namespace wifi |
| 201 | } // namespace hardware |
| 202 | } // namespace android |
| 203 | |
| 204 | #endif // HIDL_STRUCT_UTIL_H_ |