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