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); |
| 77 | |
| 78 | // STA iface conversion methods. |
| 79 | bool convertLegacyFeaturesToHidlStaCapabilities(uint64_t legacy_feature_set, |
| 80 | uint32_t legacy_logger_feature_set, |
| 81 | uint32_t* hidl_caps); |
| 82 | bool convertLegacyApfCapabilitiesToHidl(const legacy_hal::PacketFilterCapabilities& legacy_caps, |
| 83 | StaApfPacketFilterCapabilities* hidl_caps); |
| 84 | bool convertLegacyGscanCapabilitiesToHidl(const legacy_hal::wifi_gscan_capabilities& legacy_caps, |
| 85 | StaBackgroundScanCapabilities* hidl_caps); |
| 86 | legacy_hal::wifi_band convertHidlWifiBandToLegacy(V1_0::WifiBand band); |
| 87 | bool convertHidlGscanParamsToLegacy(const StaBackgroundScanParameters& hidl_scan_params, |
| 88 | legacy_hal::wifi_scan_cmd_params* legacy_scan_params); |
| 89 | // |has_ie_data| indicates whether or not the wifi_scan_result includes 802.11 |
| 90 | // Information Elements (IEs) |
| 91 | bool convertLegacyGscanResultToHidl(const legacy_hal::wifi_scan_result& legacy_scan_result, |
| 92 | bool has_ie_data, StaScanResult* hidl_scan_result); |
| 93 | // |cached_results| is assumed to not include IEs. |
| 94 | bool convertLegacyVectorOfCachedGscanResultsToHidl( |
| 95 | const std::vector<legacy_hal::wifi_cached_scan_results>& legacy_cached_scan_results, |
| 96 | std::vector<StaScanData>* hidl_scan_datas); |
| 97 | bool convertLegacyLinkLayerStatsToHidl(const legacy_hal::LinkLayerStats& legacy_stats, |
Ahmed ElArabawy | 05571e4 | 2022-01-19 11:54:11 -0800 | [diff] [blame] | 98 | V1_6::StaLinkLayerStats* hidl_stats); |
Ahmed ElArabawy | 687ce13 | 2022-01-11 16:42:48 -0800 | [diff] [blame] | 99 | bool convertLegacyRoamingCapabilitiesToHidl( |
| 100 | const legacy_hal::wifi_roaming_capabilities& legacy_caps, |
| 101 | StaRoamingCapabilities* hidl_caps); |
| 102 | bool convertHidlRoamingConfigToLegacy(const StaRoamingConfig& hidl_config, |
| 103 | legacy_hal::wifi_roaming_config* legacy_config); |
| 104 | legacy_hal::fw_roaming_state_t convertHidlRoamingStateToLegacy(StaRoamingState state); |
| 105 | bool convertLegacyVectorOfDebugTxPacketFateToHidl( |
| 106 | const std::vector<legacy_hal::wifi_tx_report>& legacy_fates, |
| 107 | std::vector<WifiDebugTxPacketFateReport>* hidl_fates); |
| 108 | bool convertLegacyVectorOfDebugRxPacketFateToHidl( |
| 109 | const std::vector<legacy_hal::wifi_rx_report>& legacy_fates, |
| 110 | std::vector<WifiDebugRxPacketFateReport>* hidl_fates); |
| 111 | |
| 112 | // NAN iface conversion methods. |
| 113 | void convertToWifiNanStatus(legacy_hal::NanStatusType type, const char* str, size_t max_len, |
| 114 | WifiNanStatus* wifiNanStatus); |
| 115 | bool convertHidlNanEnableRequestToLegacy(const V1_4::NanEnableRequest& hidl_request, |
| 116 | legacy_hal::NanEnableRequest* legacy_request); |
| 117 | bool convertHidlNanConfigRequestToLegacy(const V1_4::NanConfigRequest& hidl_request, |
| 118 | legacy_hal::NanConfigRequest* legacy_request); |
Nate Jiang | 50c001d | 2022-01-12 16:06:01 -0800 | [diff] [blame] | 119 | bool convertHidlNanEnableRequest_1_6ToLegacy( |
Ahmed ElArabawy | 687ce13 | 2022-01-11 16:42:48 -0800 | [diff] [blame] | 120 | const V1_4::NanEnableRequest& hidl_request1, |
Nate Jiang | 50c001d | 2022-01-12 16:06:01 -0800 | [diff] [blame] | 121 | const V1_6::NanConfigRequestSupplemental& hidl_request2, |
Ahmed ElArabawy | 687ce13 | 2022-01-11 16:42:48 -0800 | [diff] [blame] | 122 | legacy_hal::NanEnableRequest* legacy_request); |
Nate Jiang | 50c001d | 2022-01-12 16:06:01 -0800 | [diff] [blame] | 123 | bool convertHidlNanConfigRequest_1_6ToLegacy( |
Ahmed ElArabawy | 687ce13 | 2022-01-11 16:42:48 -0800 | [diff] [blame] | 124 | const V1_4::NanConfigRequest& hidl_request1, |
Nate Jiang | 50c001d | 2022-01-12 16:06:01 -0800 | [diff] [blame] | 125 | const V1_6::NanConfigRequestSupplemental& hidl_request2, |
Ahmed ElArabawy | 687ce13 | 2022-01-11 16:42:48 -0800 | [diff] [blame] | 126 | legacy_hal::NanConfigRequest* legacy_request); |
Nate Jiang | 50c001d | 2022-01-12 16:06:01 -0800 | [diff] [blame] | 127 | bool convertHidlNanPublishRequestToLegacy(const V1_6::NanPublishRequest& hidl_request, |
Ahmed ElArabawy | 687ce13 | 2022-01-11 16:42:48 -0800 | [diff] [blame] | 128 | legacy_hal::NanPublishRequest* legacy_request); |
Nate Jiang | 50c001d | 2022-01-12 16:06:01 -0800 | [diff] [blame] | 129 | bool convertHidlNanSubscribeRequestToLegacy(const V1_0::NanSubscribeRequest& hidl_request, |
Ahmed ElArabawy | 687ce13 | 2022-01-11 16:42:48 -0800 | [diff] [blame] | 130 | legacy_hal::NanSubscribeRequest* legacy_request); |
| 131 | bool convertHidlNanTransmitFollowupRequestToLegacy( |
| 132 | const NanTransmitFollowupRequest& hidl_request, |
| 133 | legacy_hal::NanTransmitFollowupRequest* legacy_request); |
| 134 | bool convertHidlNanDataPathInitiatorRequestToLegacy( |
Nate Jiang | 50c001d | 2022-01-12 16:06:01 -0800 | [diff] [blame] | 135 | const V1_0::NanInitiateDataPathRequest& hidl_request, |
Ahmed ElArabawy | 687ce13 | 2022-01-11 16:42:48 -0800 | [diff] [blame] | 136 | legacy_hal::NanDataPathInitiatorRequest* legacy_request); |
| 137 | bool convertHidlNanDataPathIndicationResponseToLegacy( |
Nate Jiang | 50c001d | 2022-01-12 16:06:01 -0800 | [diff] [blame] | 138 | const V1_0::NanRespondToDataPathIndicationRequest& hidl_response, |
Ahmed ElArabawy | 687ce13 | 2022-01-11 16:42:48 -0800 | [diff] [blame] | 139 | legacy_hal::NanDataPathIndicationResponse* legacy_response); |
Nate Jiang | 50c001d | 2022-01-12 16:06:01 -0800 | [diff] [blame] | 140 | bool convertHidlNanDataPathInitiatorRequest_1_6ToLegacy( |
| 141 | const V1_6::NanInitiateDataPathRequest& hidl_request, |
| 142 | legacy_hal::NanDataPathInitiatorRequest* legacy_request); |
| 143 | bool convertHidlNanDataPathIndicationResponse_1_6ToLegacy( |
| 144 | const V1_6::NanRespondToDataPathIndicationRequest& hidl_response, |
| 145 | legacy_hal::NanDataPathIndicationResponse* legacy_response); |
| 146 | |
Ahmed ElArabawy | 687ce13 | 2022-01-11 16:42:48 -0800 | [diff] [blame] | 147 | bool convertLegacyNanResponseHeaderToHidl(const legacy_hal::NanResponseMsg& legacy_response, |
| 148 | WifiNanStatus* wifiNanStatus); |
| 149 | bool convertLegacyNanCapabilitiesResponseToHidl(const legacy_hal::NanCapabilities& legacy_response, |
Nate Jiang | 50c001d | 2022-01-12 16:06:01 -0800 | [diff] [blame] | 150 | V1_6::NanCapabilities* hidl_response); |
Ahmed ElArabawy | 687ce13 | 2022-01-11 16:42:48 -0800 | [diff] [blame] | 151 | bool convertLegacyNanMatchIndToHidl(const legacy_hal::NanMatchInd& legacy_ind, |
Nate Jiang | 50c001d | 2022-01-12 16:06:01 -0800 | [diff] [blame] | 152 | V1_6::NanMatchInd* hidl_ind); |
Ahmed ElArabawy | 687ce13 | 2022-01-11 16:42:48 -0800 | [diff] [blame] | 153 | bool convertLegacyNanFollowupIndToHidl(const legacy_hal::NanFollowupInd& legacy_ind, |
| 154 | NanFollowupReceivedInd* hidl_ind); |
| 155 | bool convertLegacyNanDataPathRequestIndToHidl(const legacy_hal::NanDataPathRequestInd& legacy_ind, |
| 156 | NanDataPathRequestInd* hidl_ind); |
| 157 | bool convertLegacyNanDataPathConfirmIndToHidl(const legacy_hal::NanDataPathConfirmInd& legacy_ind, |
Ahmed ElArabawy | 05571e4 | 2022-01-19 11:54:11 -0800 | [diff] [blame] | 158 | V1_6::NanDataPathConfirmInd* hidl_ind); |
Ahmed ElArabawy | 687ce13 | 2022-01-11 16:42:48 -0800 | [diff] [blame] | 159 | bool convertLegacyNanDataPathScheduleUpdateIndToHidl( |
| 160 | const legacy_hal::NanDataPathScheduleUpdateInd& legacy_ind, |
Ahmed ElArabawy | 05571e4 | 2022-01-19 11:54:11 -0800 | [diff] [blame] | 161 | V1_6::NanDataPathScheduleUpdateInd* hidl_ind); |
Ahmed ElArabawy | 687ce13 | 2022-01-11 16:42:48 -0800 | [diff] [blame] | 162 | |
| 163 | // RTT controller conversion methods. |
Ahmed ElArabawy | 05571e4 | 2022-01-19 11:54:11 -0800 | [diff] [blame] | 164 | bool convertHidlVectorOfRttConfigToLegacy(const std::vector<V1_6::RttConfig>& hidl_configs, |
Ahmed ElArabawy | 687ce13 | 2022-01-11 16:42:48 -0800 | [diff] [blame] | 165 | std::vector<legacy_hal::wifi_rtt_config>* legacy_configs); |
| 166 | bool convertHidlRttLciInformationToLegacy(const RttLciInformation& hidl_info, |
| 167 | legacy_hal::wifi_lci_information* legacy_info); |
| 168 | bool convertHidlRttLcrInformationToLegacy(const RttLcrInformation& hidl_info, |
| 169 | legacy_hal::wifi_lcr_information* legacy_info); |
Ahmed ElArabawy | 05571e4 | 2022-01-19 11:54:11 -0800 | [diff] [blame] | 170 | bool convertHidlRttResponderToLegacy(const V1_6::RttResponder& hidl_responder, |
Ahmed ElArabawy | 687ce13 | 2022-01-11 16:42:48 -0800 | [diff] [blame] | 171 | legacy_hal::wifi_rtt_responder* legacy_responder); |
Ahmed ElArabawy | 05571e4 | 2022-01-19 11:54:11 -0800 | [diff] [blame] | 172 | bool convertHidlWifiChannelInfoToLegacy(const V1_6::WifiChannelInfo& hidl_info, |
Ahmed ElArabawy | 687ce13 | 2022-01-11 16:42:48 -0800 | [diff] [blame] | 173 | legacy_hal::wifi_channel_info* legacy_info); |
| 174 | bool convertLegacyRttResponderToHidl(const legacy_hal::wifi_rtt_responder& legacy_responder, |
Ahmed ElArabawy | 05571e4 | 2022-01-19 11:54:11 -0800 | [diff] [blame] | 175 | V1_6::RttResponder* hidl_responder); |
Ahmed ElArabawy | 687ce13 | 2022-01-11 16:42:48 -0800 | [diff] [blame] | 176 | bool convertLegacyRttCapabilitiesToHidl( |
| 177 | const legacy_hal::wifi_rtt_capabilities& legacy_capabilities, |
Ahmed ElArabawy | 05571e4 | 2022-01-19 11:54:11 -0800 | [diff] [blame] | 178 | V1_6::RttCapabilities* hidl_capabilities); |
Ahmed ElArabawy | 687ce13 | 2022-01-11 16:42:48 -0800 | [diff] [blame] | 179 | bool convertLegacyVectorOfRttResultToHidl( |
| 180 | const std::vector<const legacy_hal::wifi_rtt_result*>& legacy_results, |
Ahmed ElArabawy | 05571e4 | 2022-01-19 11:54:11 -0800 | [diff] [blame] | 181 | std::vector<V1_6::RttResult>* hidl_results); |
Ahmed ElArabawy | 687ce13 | 2022-01-11 16:42:48 -0800 | [diff] [blame] | 182 | uint32_t convertHidlWifiBandToLegacyMacBand(V1_5::WifiBand band); |
| 183 | uint32_t convertHidlWifiIfaceModeToLegacy(uint32_t hidl_iface_mask); |
| 184 | uint32_t convertHidlUsableChannelFilterToLegacy(uint32_t hidl_filter_mask); |
| 185 | bool convertLegacyWifiUsableChannelsToHidl( |
| 186 | const std::vector<legacy_hal::wifi_usable_channel>& legacy_usable_channels, |
Ahmed ElArabawy | 05571e4 | 2022-01-19 11:54:11 -0800 | [diff] [blame] | 187 | std::vector<V1_6::WifiUsableChannel>* hidl_usable_channels); |
Ahmed ElArabawy | 687ce13 | 2022-01-11 16:42:48 -0800 | [diff] [blame] | 188 | bool convertLegacyPeerInfoStatsToHidl(const legacy_hal::WifiPeerInfo& legacy_peer_info_stats, |
Ahmed ElArabawy | 05571e4 | 2022-01-19 11:54:11 -0800 | [diff] [blame] | 189 | V1_6::StaPeerInfo* hidl_peer_info_stats); |
Ahmed ElArabawy | 687ce13 | 2022-01-11 16:42:48 -0800 | [diff] [blame] | 190 | bool convertLegacyWifiRateInfoToHidl(const legacy_hal::wifi_rate& legacy_rate, |
Ahmed ElArabawy | 05571e4 | 2022-01-19 11:54:11 -0800 | [diff] [blame] | 191 | V1_6::WifiRateInfo* hidl_rate); |
Ahmed ElArabawy | 687ce13 | 2022-01-11 16:42:48 -0800 | [diff] [blame] | 192 | } // namespace hidl_struct_util |
| 193 | } // namespace implementation |
| 194 | } // namespace V1_6 |
| 195 | } // namespace wifi |
| 196 | } // namespace hardware |
| 197 | } // namespace android |
| 198 | |
| 199 | #endif // HIDL_STRUCT_UTIL_H_ |