1 /* 2 * Copyright (C) 2022 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 AIDL_STRUCT_UTIL_H_ 18 #define AIDL_STRUCT_UTIL_H_ 19 20 #include <aidl/android/hardware/wifi/IWifiChip.h> 21 #include <aidl/android/hardware/wifi/IWifiChipEventCallback.h> 22 #include <aidl/android/hardware/wifi/NanBandIndex.h> 23 #include <aidl/android/hardware/wifi/StaBackgroundScanBucketEventReportSchemeMask.h> 24 #include <aidl/android/hardware/wifi/StaScanDataFlagMask.h> 25 #include <aidl/android/hardware/wifi/WifiDebugRingBufferFlags.h> 26 #include <aidl/android/hardware/wifi/WifiIfaceMode.h> 27 28 #include <vector> 29 30 #include "wifi_legacy_hal.h" 31 32 /** 33 * This file contains a bunch of functions to convert structs from the legacy 34 * HAL to AIDL and vice versa. 35 */ 36 namespace aidl { 37 namespace android { 38 namespace hardware { 39 namespace wifi { 40 namespace aidl_struct_util { 41 42 // Chip conversion methods. 43 bool convertLegacyChipFeaturesToAidl(uint64_t legacy_feature_set, uint32_t* aidl_feature_set); 44 bool convertLegacyDebugRingBufferStatusToAidl( 45 const legacy_hal::wifi_ring_buffer_status& legacy_status, 46 WifiDebugRingBufferStatus* aidl_status); 47 bool convertLegacyVectorOfDebugRingBufferStatusToAidl( 48 const std::vector<legacy_hal::wifi_ring_buffer_status>& legacy_status_vec, 49 std::vector<WifiDebugRingBufferStatus>* aidl_status_vec); 50 bool convertLegacyWakeReasonStatsToAidl(const legacy_hal::WakeReasonStats& legacy_stats, 51 WifiDebugHostWakeReasonStats* aidl_stats); 52 legacy_hal::wifi_power_scenario convertAidlTxPowerScenarioToLegacy( 53 IWifiChip::TxPowerScenario aidl_scenario); 54 legacy_hal::wifi_latency_mode convertAidlLatencyModeToLegacy( 55 IWifiChip::LatencyMode aidl_latency_mode); 56 bool convertLegacyWifiMacInfosToAidl( 57 const std::vector<legacy_hal::WifiMacInfo>& legacy_mac_infos, 58 std::vector<IWifiChipEventCallback::RadioModeInfo>* aidl_radio_mode_infos); 59 legacy_hal::wifi_interface_type convertAidlIfaceTypeToLegacy(IfaceType aidl_interface_type); 60 legacy_hal::wifi_multi_sta_use_case convertAidlMultiStaUseCaseToLegacy( 61 IWifiChip::MultiStaUseCase use_case); 62 bool convertAidlCoexUnsafeChannelToLegacy( 63 const IWifiChip::CoexUnsafeChannel& aidl_unsafe_channel, 64 legacy_hal::wifi_coex_unsafe_channel* legacy_unsafe_channel); 65 bool convertAidlVectorOfCoexUnsafeChannelToLegacy( 66 const std::vector<IWifiChip::CoexUnsafeChannel>& aidl_unsafe_channels, 67 std::vector<legacy_hal::wifi_coex_unsafe_channel>* legacy_unsafe_channels); 68 bool convertLegacyRadioCombinationsMatrixToAidl( 69 legacy_hal::wifi_radio_combination_matrix* legacy_matrix, 70 std::vector<WifiRadioCombination>* aidl_combinations); 71 WifiBand convertLegacyMacBandToAidlWifiBand(uint32_t band); 72 WifiAntennaMode convertLegacyAntennaConfigurationToAidl(uint32_t antenna_cfg); 73 bool convertLegacyIfaceCombinationsMatrixToChipMode( 74 legacy_hal::wifi_iface_concurrency_matrix& legacy_matrix, IWifiChip::ChipMode* chip_mode); 75 76 // STA iface conversion methods. 77 bool convertLegacyStaIfaceFeaturesToAidl(uint64_t legacy_feature_set, uint32_t* aidl_feature_set); 78 bool convertLegacyApfCapabilitiesToAidl(const legacy_hal::PacketFilterCapabilities& legacy_caps, 79 StaApfPacketFilterCapabilities* aidl_caps); 80 bool convertLegacyGscanCapabilitiesToAidl(const legacy_hal::wifi_gscan_capabilities& legacy_caps, 81 StaBackgroundScanCapabilities* aidl_caps); 82 legacy_hal::wifi_band convertAidlWifiBandToLegacy(WifiBand band); 83 bool convertAidlGscanParamsToLegacy(const StaBackgroundScanParameters& aidl_scan_params, 84 legacy_hal::wifi_scan_cmd_params* legacy_scan_params); 85 // |has_ie_data| indicates whether or not the wifi_scan_result includes 802.11 86 // Information Elements (IEs) 87 bool convertLegacyGscanResultToAidl(const legacy_hal::wifi_scan_result& legacy_scan_result, 88 bool has_ie_data, StaScanResult* aidl_scan_result); 89 // |cached_results| is assumed to not include IEs. 90 bool convertLegacyVectorOfCachedGscanResultsToAidl( 91 const std::vector<legacy_hal::wifi_cached_scan_results>& legacy_cached_scan_results, 92 std::vector<StaScanData>* aidl_scan_datas); 93 bool convertLegacyLinkLayerMlStatsToAidl(const legacy_hal::LinkLayerMlStats& legacy_ml_stats, 94 StaLinkLayerStats* aidl_stats); 95 bool convertLegacyLinkLayerStatsToAidl(const legacy_hal::LinkLayerStats& legacy_stats, 96 StaLinkLayerStats* aidl_stats); 97 bool convertLegacyRoamingCapabilitiesToAidl( 98 const legacy_hal::wifi_roaming_capabilities& legacy_caps, 99 StaRoamingCapabilities* aidl_caps); 100 bool convertAidlRoamingConfigToLegacy(const StaRoamingConfig& aidl_config, 101 legacy_hal::wifi_roaming_config* legacy_config); 102 legacy_hal::fw_roaming_state_t convertAidlRoamingStateToLegacy(StaRoamingState state); 103 bool convertLegacyVectorOfDebugTxPacketFateToAidl( 104 const std::vector<legacy_hal::wifi_tx_report>& legacy_fates, 105 std::vector<WifiDebugTxPacketFateReport>* aidl_fates); 106 bool convertLegacyVectorOfDebugRxPacketFateToAidl( 107 const std::vector<legacy_hal::wifi_rx_report>& legacy_fates, 108 std::vector<WifiDebugRxPacketFateReport>* aidl_fates); 109 110 // NAN iface conversion methods. 111 void convertToNanStatus(legacy_hal::NanStatusType type, const char* str, size_t max_len, 112 NanStatus* nanStatus); 113 bool convertAidlNanEnableRequestToLegacy(const NanEnableRequest& aidl_request1, 114 const NanConfigRequestSupplemental& aidl_request2, 115 legacy_hal::NanEnableRequest* legacy_request); 116 bool convertAidlNanConfigRequestToLegacy(const NanConfigRequest& aidl_request1, 117 const NanConfigRequestSupplemental& aidl_request2, 118 legacy_hal::NanConfigRequest* legacy_request); 119 bool convertAidlNanPublishRequestToLegacy(const NanPublishRequest& aidl_request, 120 legacy_hal::NanPublishRequest* legacy_request); 121 bool convertAidlNanSubscribeRequestToLegacy(const NanSubscribeRequest& aidl_request, 122 legacy_hal::NanSubscribeRequest* legacy_request); 123 bool convertAidlNanTransmitFollowupRequestToLegacy( 124 const NanTransmitFollowupRequest& aidl_request, 125 legacy_hal::NanTransmitFollowupRequest* legacy_request); 126 bool convertAidlNanDataPathInitiatorRequestToLegacy( 127 const NanInitiateDataPathRequest& aidl_request, 128 legacy_hal::NanDataPathInitiatorRequest* legacy_request); 129 bool convertAidlNanDataPathIndicationResponseToLegacy( 130 const NanRespondToDataPathIndicationRequest& aidl_response, 131 legacy_hal::NanDataPathIndicationResponse* legacy_response); 132 bool convertLegacyNanResponseHeaderToAidl(const legacy_hal::NanResponseMsg& legacy_response, 133 NanStatus* nanStatus); 134 bool convertLegacyNanCapabilitiesResponseToAidl(const legacy_hal::NanCapabilities& legacy_response, 135 NanCapabilities* aidl_response); 136 bool convertLegacyNanMatchIndToAidl(const legacy_hal::NanMatchInd& legacy_ind, 137 NanMatchInd* aidl_ind); 138 bool convertLegacyNanFollowupIndToAidl(const legacy_hal::NanFollowupInd& legacy_ind, 139 NanFollowupReceivedInd* aidl_ind); 140 bool convertLegacyNanDataPathRequestIndToAidl(const legacy_hal::NanDataPathRequestInd& legacy_ind, 141 NanDataPathRequestInd* aidl_ind); 142 bool convertLegacyNanDataPathConfirmIndToAidl(const legacy_hal::NanDataPathConfirmInd& legacy_ind, 143 NanDataPathConfirmInd* aidl_ind); 144 bool convertLegacyNanDataPathScheduleUpdateIndToAidl( 145 const legacy_hal::NanDataPathScheduleUpdateInd& legacy_ind, 146 NanDataPathScheduleUpdateInd* aidl_ind); 147 148 // RTT controller conversion methods. 149 bool convertAidlVectorOfRttConfigToLegacy(const std::vector<RttConfig>& aidl_configs, 150 std::vector<legacy_hal::wifi_rtt_config>* legacy_configs); 151 bool convertAidlRttLciInformationToLegacy(const RttLciInformation& aidl_info, 152 legacy_hal::wifi_lci_information* legacy_info); 153 bool convertAidlRttLcrInformationToLegacy(const RttLcrInformation& aidl_info, 154 legacy_hal::wifi_lcr_information* legacy_info); 155 bool convertAidlRttResponderToLegacy(const RttResponder& aidl_responder, 156 legacy_hal::wifi_rtt_responder* legacy_responder); 157 bool convertAidlWifiChannelInfoToLegacy(const WifiChannelInfo& aidl_info, 158 legacy_hal::wifi_channel_info* legacy_info); 159 bool convertLegacyRttResponderToAidl(const legacy_hal::wifi_rtt_responder& legacy_responder, 160 RttResponder* aidl_responder); 161 bool convertLegacyRttCapabilitiesToAidl( 162 const legacy_hal::wifi_rtt_capabilities& legacy_capabilities, 163 RttCapabilities* aidl_capabilities); 164 bool convertLegacyVectorOfRttResultToAidl( 165 const std::vector<const legacy_hal::wifi_rtt_result*>& legacy_results, 166 std::vector<RttResult>* aidl_results); 167 bool convertLegacyVectorOfRttResultV2ToAidl( 168 const std::vector<const legacy_hal::wifi_rtt_result_v2*>& legacy_results, 169 std::vector<RttResult>* aidl_results); 170 uint32_t convertAidlWifiBandToLegacyMacBand(WifiBand band); 171 uint32_t convertAidlWifiIfaceModeToLegacy(uint32_t aidl_iface_mask); 172 uint32_t convertAidlUsableChannelFilterToLegacy(uint32_t aidl_filter_mask); 173 bool convertLegacyWifiUsableChannelsToAidl( 174 const std::vector<legacy_hal::wifi_usable_channel>& legacy_usable_channels, 175 std::vector<WifiUsableChannel>* aidl_usable_channels); 176 bool convertLegacyPeerInfoStatsToAidl(const legacy_hal::WifiPeerInfo& legacy_peer_info_stats, 177 StaPeerInfo* aidl_peer_info_stats); 178 bool convertLegacyWifiRateInfoToAidl(const legacy_hal::wifi_rate& legacy_rate, 179 WifiRateInfo* aidl_rate); 180 bool convertLegacyWifiChipCapabilitiesToAidl( 181 const legacy_hal::wifi_chip_capabilities& legacy_chip_capabilities, 182 WifiChipCapabilities& aidl_chip_capabilities); 183 bool convertAidlNanPairingInitiatorRequestToLegacy(const NanPairingRequest& aidl_request, 184 legacy_hal::NanPairingRequest* legacy_request); 185 bool convertAidlNanPairingIndicationResponseToLegacy( 186 const NanRespondToPairingIndicationRequest& aidl_response, 187 legacy_hal::NanPairingIndicationResponse* legacy_response); 188 bool convertAidlNanBootstrappingInitiatorRequestToLegacy( 189 const NanBootstrappingRequest& aidl_request, 190 legacy_hal::NanBootstrappingRequest* legacy_request); 191 bool convertAidlNanBootstrappingIndicationResponseToLegacy( 192 const NanBootstrappingResponse& aidl_response, 193 legacy_hal::NanBootstrappingIndicationResponse* legacy_response); 194 bool convertLegacyNanPairingRequestIndToAidl(const legacy_hal::NanPairingRequestInd& legacy_ind, 195 NanPairingRequestInd* aidl_ind); 196 bool convertLegacyNanPairingConfirmIndToAidl(const legacy_hal::NanPairingConfirmInd& legacy_ind, 197 NanPairingConfirmInd* aidl_ind); 198 bool convertLegacyNanBootstrappingRequestIndToAidl( 199 const legacy_hal::NanBootstrappingRequestInd& legacy_ind, 200 NanBootstrappingRequestInd* aidl_ind); 201 bool convertLegacyNanBootstrappingConfirmIndToAidl( 202 const legacy_hal::NanBootstrappingConfirmInd& legacy_ind, 203 NanBootstrappingConfirmInd* aidl_ind); 204 uint32_t convertAidlChannelCategoryToLegacy(uint32_t aidl_channel_category_mask); 205 } // namespace aidl_struct_util 206 } // namespace wifi 207 } // namespace hardware 208 } // namespace android 209 } // namespace aidl 210 211 #endif // AIDL_STRUCT_UTIL_H_ 212