blob: 2574f9546b831fd9d2249e68a74c5aaea520a3d4 [file] [log] [blame]
Gabriel Birenf3262f92022-07-15 23:25:39 +00001/*
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>
Gabriel Biren3b86a782023-02-04 00:42:53 +000023#include <aidl/android/hardware/wifi/StaBackgroundScanBucketEventReportSchemeMask.h>
24#include <aidl/android/hardware/wifi/StaScanDataFlagMask.h>
Gabriel Birenf3262f92022-07-15 23:25:39 +000025#include <aidl/android/hardware/wifi/WifiDebugRingBufferFlags.h>
Gabriel Biren3b86a782023-02-04 00:42:53 +000026#include <aidl/android/hardware/wifi/WifiIfaceMode.h>
Gabriel Birenf3262f92022-07-15 23:25:39 +000027
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 */
36namespace aidl {
37namespace android {
38namespace hardware {
39namespace wifi {
40namespace aidl_struct_util {
41
42// Chip conversion methods.
Gabriel Biren2f862492023-03-09 19:13:07 +000043bool convertLegacyChipFeaturesToAidl(uint64_t legacy_feature_set, uint32_t* aidl_feature_set);
Gabriel Birenf3262f92022-07-15 23:25:39 +000044bool convertLegacyDebugRingBufferStatusToAidl(
45 const legacy_hal::wifi_ring_buffer_status& legacy_status,
46 WifiDebugRingBufferStatus* aidl_status);
47bool convertLegacyVectorOfDebugRingBufferStatusToAidl(
48 const std::vector<legacy_hal::wifi_ring_buffer_status>& legacy_status_vec,
49 std::vector<WifiDebugRingBufferStatus>* aidl_status_vec);
50bool convertLegacyWakeReasonStatsToAidl(const legacy_hal::WakeReasonStats& legacy_stats,
51 WifiDebugHostWakeReasonStats* aidl_stats);
52legacy_hal::wifi_power_scenario convertAidlTxPowerScenarioToLegacy(
53 IWifiChip::TxPowerScenario aidl_scenario);
54legacy_hal::wifi_latency_mode convertAidlLatencyModeToLegacy(
55 IWifiChip::LatencyMode aidl_latency_mode);
56bool convertLegacyWifiMacInfosToAidl(
57 const std::vector<legacy_hal::WifiMacInfo>& legacy_mac_infos,
58 std::vector<IWifiChipEventCallback::RadioModeInfo>* aidl_radio_mode_infos);
59legacy_hal::wifi_interface_type convertAidlIfaceTypeToLegacy(IfaceType aidl_interface_type);
60legacy_hal::wifi_multi_sta_use_case convertAidlMultiStaUseCaseToLegacy(
61 IWifiChip::MultiStaUseCase use_case);
62bool convertAidlCoexUnsafeChannelToLegacy(
63 const IWifiChip::CoexUnsafeChannel& aidl_unsafe_channel,
64 legacy_hal::wifi_coex_unsafe_channel* legacy_unsafe_channel);
65bool convertAidlVectorOfCoexUnsafeChannelToLegacy(
66 const std::vector<IWifiChip::CoexUnsafeChannel>& aidl_unsafe_channels,
67 std::vector<legacy_hal::wifi_coex_unsafe_channel>* legacy_unsafe_channels);
68bool convertLegacyRadioCombinationsMatrixToAidl(
69 legacy_hal::wifi_radio_combination_matrix* legacy_matrix,
Gabriel Biren263db452023-02-24 21:07:38 +000070 std::vector<WifiRadioCombination>* aidl_combinations);
Gabriel Birenf3262f92022-07-15 23:25:39 +000071WifiBand convertLegacyMacBandToAidlWifiBand(uint32_t band);
72WifiAntennaMode convertLegacyAntennaConfigurationToAidl(uint32_t antenna_cfg);
Sunil Ravi2be1f262023-02-15 20:56:56 +000073bool convertLegacyIfaceCombinationsMatrixToChipMode(
74 legacy_hal::wifi_iface_concurrency_matrix& legacy_matrix, IWifiChip::ChipMode* chip_mode);
Gabriel Birenf3262f92022-07-15 23:25:39 +000075
76// STA iface conversion methods.
Gabriel Biren2f862492023-03-09 19:13:07 +000077bool convertLegacyStaIfaceFeaturesToAidl(uint64_t legacy_feature_set, uint32_t* aidl_feature_set);
Gabriel Birenf3262f92022-07-15 23:25:39 +000078bool convertLegacyApfCapabilitiesToAidl(const legacy_hal::PacketFilterCapabilities& legacy_caps,
79 StaApfPacketFilterCapabilities* aidl_caps);
80bool convertLegacyGscanCapabilitiesToAidl(const legacy_hal::wifi_gscan_capabilities& legacy_caps,
81 StaBackgroundScanCapabilities* aidl_caps);
82legacy_hal::wifi_band convertAidlWifiBandToLegacy(WifiBand band);
83bool 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)
87bool 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.
90bool convertLegacyVectorOfCachedGscanResultsToAidl(
91 const std::vector<legacy_hal::wifi_cached_scan_results>& legacy_cached_scan_results,
92 std::vector<StaScanData>* aidl_scan_datas);
Mahesh KKV5f30d332022-10-26 14:07:44 -070093bool convertLegacyLinkLayerMlStatsToAidl(const legacy_hal::LinkLayerMlStats& legacy_ml_stats,
94 StaLinkLayerStats* aidl_stats);
Gabriel Birenf3262f92022-07-15 23:25:39 +000095bool convertLegacyLinkLayerStatsToAidl(const legacy_hal::LinkLayerStats& legacy_stats,
96 StaLinkLayerStats* aidl_stats);
Gabriel Biren2ccf70f2024-02-14 22:52:58 +000097void logAidlLinkLayerStatsSize(StaLinkLayerStats& aidl_stats);
Gabriel Birenf3262f92022-07-15 23:25:39 +000098bool convertLegacyRoamingCapabilitiesToAidl(
99 const legacy_hal::wifi_roaming_capabilities& legacy_caps,
100 StaRoamingCapabilities* aidl_caps);
101bool convertAidlRoamingConfigToLegacy(const StaRoamingConfig& aidl_config,
102 legacy_hal::wifi_roaming_config* legacy_config);
103legacy_hal::fw_roaming_state_t convertAidlRoamingStateToLegacy(StaRoamingState state);
104bool convertLegacyVectorOfDebugTxPacketFateToAidl(
105 const std::vector<legacy_hal::wifi_tx_report>& legacy_fates,
106 std::vector<WifiDebugTxPacketFateReport>* aidl_fates);
107bool convertLegacyVectorOfDebugRxPacketFateToAidl(
108 const std::vector<legacy_hal::wifi_rx_report>& legacy_fates,
109 std::vector<WifiDebugRxPacketFateReport>* aidl_fates);
110
111// NAN iface conversion methods.
112void convertToNanStatus(legacy_hal::NanStatusType type, const char* str, size_t max_len,
113 NanStatus* nanStatus);
114bool convertAidlNanEnableRequestToLegacy(const NanEnableRequest& aidl_request1,
115 const NanConfigRequestSupplemental& aidl_request2,
116 legacy_hal::NanEnableRequest* legacy_request);
117bool convertAidlNanConfigRequestToLegacy(const NanConfigRequest& aidl_request1,
118 const NanConfigRequestSupplemental& aidl_request2,
119 legacy_hal::NanConfigRequest* legacy_request);
120bool convertAidlNanPublishRequestToLegacy(const NanPublishRequest& aidl_request,
121 legacy_hal::NanPublishRequest* legacy_request);
122bool convertAidlNanSubscribeRequestToLegacy(const NanSubscribeRequest& aidl_request,
123 legacy_hal::NanSubscribeRequest* legacy_request);
124bool convertAidlNanTransmitFollowupRequestToLegacy(
125 const NanTransmitFollowupRequest& aidl_request,
126 legacy_hal::NanTransmitFollowupRequest* legacy_request);
127bool convertAidlNanDataPathInitiatorRequestToLegacy(
128 const NanInitiateDataPathRequest& aidl_request,
129 legacy_hal::NanDataPathInitiatorRequest* legacy_request);
130bool convertAidlNanDataPathIndicationResponseToLegacy(
131 const NanRespondToDataPathIndicationRequest& aidl_response,
132 legacy_hal::NanDataPathIndicationResponse* legacy_response);
133bool convertLegacyNanResponseHeaderToAidl(const legacy_hal::NanResponseMsg& legacy_response,
134 NanStatus* nanStatus);
135bool convertLegacyNanCapabilitiesResponseToAidl(const legacy_hal::NanCapabilities& legacy_response,
136 NanCapabilities* aidl_response);
137bool convertLegacyNanMatchIndToAidl(const legacy_hal::NanMatchInd& legacy_ind,
138 NanMatchInd* aidl_ind);
139bool convertLegacyNanFollowupIndToAidl(const legacy_hal::NanFollowupInd& legacy_ind,
140 NanFollowupReceivedInd* aidl_ind);
141bool convertLegacyNanDataPathRequestIndToAidl(const legacy_hal::NanDataPathRequestInd& legacy_ind,
142 NanDataPathRequestInd* aidl_ind);
143bool convertLegacyNanDataPathConfirmIndToAidl(const legacy_hal::NanDataPathConfirmInd& legacy_ind,
144 NanDataPathConfirmInd* aidl_ind);
145bool convertLegacyNanDataPathScheduleUpdateIndToAidl(
146 const legacy_hal::NanDataPathScheduleUpdateInd& legacy_ind,
147 NanDataPathScheduleUpdateInd* aidl_ind);
148
149// RTT controller conversion methods.
150bool convertAidlVectorOfRttConfigToLegacy(const std::vector<RttConfig>& aidl_configs,
151 std::vector<legacy_hal::wifi_rtt_config>* legacy_configs);
maheshkkv7d422812023-11-16 17:32:50 -0800152bool convertAidlVectorOfRttConfigToLegacyV3(
153 const std::vector<RttConfig>& aidl_configs,
154 std::vector<legacy_hal::wifi_rtt_config_v3>* legacy_configs);
155
Gabriel Birenf3262f92022-07-15 23:25:39 +0000156bool convertAidlRttLciInformationToLegacy(const RttLciInformation& aidl_info,
157 legacy_hal::wifi_lci_information* legacy_info);
158bool convertAidlRttLcrInformationToLegacy(const RttLcrInformation& aidl_info,
159 legacy_hal::wifi_lcr_information* legacy_info);
160bool convertAidlRttResponderToLegacy(const RttResponder& aidl_responder,
161 legacy_hal::wifi_rtt_responder* legacy_responder);
162bool convertAidlWifiChannelInfoToLegacy(const WifiChannelInfo& aidl_info,
163 legacy_hal::wifi_channel_info* legacy_info);
164bool convertLegacyRttResponderToAidl(const legacy_hal::wifi_rtt_responder& legacy_responder,
165 RttResponder* aidl_responder);
166bool convertLegacyRttCapabilitiesToAidl(
167 const legacy_hal::wifi_rtt_capabilities& legacy_capabilities,
168 RttCapabilities* aidl_capabilities);
maheshkkv7d422812023-11-16 17:32:50 -0800169bool convertLegacyRttCapabilitiesV3ToAidl(
170 const legacy_hal::wifi_rtt_capabilities_v3& legacy_capabilities_v3,
171 RttCapabilities* aidl_capabilities);
172
Gabriel Birenf3262f92022-07-15 23:25:39 +0000173bool convertLegacyVectorOfRttResultToAidl(
174 const std::vector<const legacy_hal::wifi_rtt_result*>& legacy_results,
175 std::vector<RttResult>* aidl_results);
Sunil Ravif8fc2372022-11-10 18:37:41 +0000176bool convertLegacyVectorOfRttResultV2ToAidl(
177 const std::vector<const legacy_hal::wifi_rtt_result_v2*>& legacy_results,
178 std::vector<RttResult>* aidl_results);
maheshkkv7d422812023-11-16 17:32:50 -0800179bool convertLegacyVectorOfRttResultV3ToAidl(
180 const std::vector<const legacy_hal::wifi_rtt_result_v3*>& legacy_results,
181 std::vector<RttResult>* aidl_results);
Gabriel Birenf3262f92022-07-15 23:25:39 +0000182uint32_t convertAidlWifiBandToLegacyMacBand(WifiBand band);
183uint32_t convertAidlWifiIfaceModeToLegacy(uint32_t aidl_iface_mask);
184uint32_t convertAidlUsableChannelFilterToLegacy(uint32_t aidl_filter_mask);
185bool convertLegacyWifiUsableChannelsToAidl(
186 const std::vector<legacy_hal::wifi_usable_channel>& legacy_usable_channels,
187 std::vector<WifiUsableChannel>* aidl_usable_channels);
188bool convertLegacyPeerInfoStatsToAidl(const legacy_hal::WifiPeerInfo& legacy_peer_info_stats,
189 StaPeerInfo* aidl_peer_info_stats);
190bool convertLegacyWifiRateInfoToAidl(const legacy_hal::wifi_rate& legacy_rate,
191 WifiRateInfo* aidl_rate);
Mahesh KKVc84d3772022-12-02 16:53:28 -0800192bool convertLegacyWifiChipCapabilitiesToAidl(
193 const legacy_hal::wifi_chip_capabilities& legacy_chip_capabilities,
194 WifiChipCapabilities& aidl_chip_capabilities);
Nate Jiang38e8db52022-12-02 17:30:27 -0800195bool convertAidlNanPairingInitiatorRequestToLegacy(const NanPairingRequest& aidl_request,
196 legacy_hal::NanPairingRequest* legacy_request);
197bool convertAidlNanPairingIndicationResponseToLegacy(
198 const NanRespondToPairingIndicationRequest& aidl_response,
199 legacy_hal::NanPairingIndicationResponse* legacy_response);
200bool convertAidlNanBootstrappingInitiatorRequestToLegacy(
201 const NanBootstrappingRequest& aidl_request,
202 legacy_hal::NanBootstrappingRequest* legacy_request);
203bool convertAidlNanBootstrappingIndicationResponseToLegacy(
204 const NanBootstrappingResponse& aidl_response,
205 legacy_hal::NanBootstrappingIndicationResponse* legacy_response);
206bool convertLegacyNanPairingRequestIndToAidl(const legacy_hal::NanPairingRequestInd& legacy_ind,
207 NanPairingRequestInd* aidl_ind);
208bool convertLegacyNanPairingConfirmIndToAidl(const legacy_hal::NanPairingConfirmInd& legacy_ind,
209 NanPairingConfirmInd* aidl_ind);
210bool convertLegacyNanBootstrappingRequestIndToAidl(
211 const legacy_hal::NanBootstrappingRequestInd& legacy_ind,
212 NanBootstrappingRequestInd* aidl_ind);
213bool convertLegacyNanBootstrappingConfirmIndToAidl(
214 const legacy_hal::NanBootstrappingConfirmInd& legacy_ind,
215 NanBootstrappingConfirmInd* aidl_ind);
Shuibing Daie5fbcab2022-12-19 15:37:19 -0800216uint32_t convertAidlChannelCategoryToLegacy(uint32_t aidl_channel_category_mask);
Kai Shi7d0e5e92023-11-20 19:23:36 -0800217bool convertCachedScanReportToAidl(const legacy_hal::WifiCachedScanReport& report,
218 CachedScanData* aidl_scan_data);
219bool convertCachedScanResultToAidl(const legacy_hal::wifi_cached_scan_result& legacy_scan_result,
220 uint64_t ts_us, CachedScanResult* aidl_scan_result);
221WifiRatePreamble convertScanResultFlagsToPreambleType(int flags);
maheshkkv39903822023-11-28 15:31:53 -0800222bool convertTwtCapabilitiesToAidl(const legacy_hal::wifi_twt_capabilities legacy_twt_capabs,
223 TwtCapabilities* aidl_twt_capabs);
224bool convertAidlTwtRequestToLegacy(const TwtRequest aidl_twt_request,
225 legacy_hal::wifi_twt_request* legacy_twt_request);
226IWifiStaIfaceEventCallback::TwtErrorCode convertLegacyHalTwtErrorCodeToAidl(
227 legacy_hal::wifi_twt_error_code legacy_error_code);
228IWifiStaIfaceEventCallback::TwtTeardownReasonCode convertLegacyHalTwtReasonCodeToAidl(
229 legacy_hal::wifi_twt_teardown_reason_code legacy_reason_code);
230bool convertLegacyHalTwtSessionToAidl(legacy_hal::wifi_twt_session twt_session,
231 TwtSession* aidl_twt_session);
232bool convertLegacyHalTwtSessionStatsToAidl(legacy_hal::wifi_twt_session_stats twt_stats,
233 TwtSessionStats* aidl_twt_stats);
Gabriel Birenf3262f92022-07-15 23:25:39 +0000234} // namespace aidl_struct_util
235} // namespace wifi
236} // namespace hardware
237} // namespace android
238} // namespace aidl
239
240#endif // AIDL_STRUCT_UTIL_H_