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