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