blob: 2d4a5f13f4a8eb3f49196b1a5c17fd5cca6cb58e [file] [log] [blame]
Ahmed ElArabawy687ce132022-01-11 16:42:48 -08001/*
2 * Copyright (C) 2016 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 HIDL_STRUCT_UTIL_H_
18#define HIDL_STRUCT_UTIL_H_
19
20#include <vector>
21
22#include <android/hardware/wifi/1.0/IWifiChip.h>
23#include <android/hardware/wifi/1.0/types.h>
24#include <android/hardware/wifi/1.2/types.h>
25#include <android/hardware/wifi/1.3/types.h>
26#include <android/hardware/wifi/1.4/IWifiChipEventCallback.h>
27#include <android/hardware/wifi/1.4/types.h>
Ahmed ElArabawy05571e42022-01-19 11:54:11 -080028#include <android/hardware/wifi/1.6/IWifiChip.h>
29#include <android/hardware/wifi/1.6/types.h>
Ahmed ElArabawy687ce132022-01-11 16:42:48 -080030
31#include "wifi_legacy_hal.h"
32
33/**
34 * This file contains a bunch of functions to convert structs from the legacy
35 * HAL to HIDL and vice versa.
36 * TODO(b/32093047): Add unit tests for these conversion methods in the VTS test
37 * suite.
38 */
39namespace android {
40namespace hardware {
41namespace wifi {
42namespace V1_6 {
43namespace implementation {
44namespace hidl_struct_util {
45using namespace android::hardware::wifi::V1_0;
46
47// Chip conversion methods.
48bool convertLegacyFeaturesToHidlChipCapabilities(uint64_t legacy_feature_set,
49 uint32_t legacy_logger_feature_set,
50 uint32_t* hidl_caps);
51bool convertLegacyDebugRingBufferStatusToHidl(
52 const legacy_hal::wifi_ring_buffer_status& legacy_status,
53 WifiDebugRingBufferStatus* hidl_status);
54bool convertLegacyVectorOfDebugRingBufferStatusToHidl(
55 const std::vector<legacy_hal::wifi_ring_buffer_status>& legacy_status_vec,
56 std::vector<WifiDebugRingBufferStatus>* hidl_status_vec);
57bool convertLegacyWakeReasonStatsToHidl(const legacy_hal::WakeReasonStats& legacy_stats,
58 WifiDebugHostWakeReasonStats* hidl_stats);
59legacy_hal::wifi_power_scenario convertHidlTxPowerScenarioToLegacy(
60 V1_1::IWifiChip::TxPowerScenario hidl_scenario);
61legacy_hal::wifi_latency_mode convertHidlLatencyModeToLegacy(
62 V1_3::IWifiChip::LatencyMode hidl_latency_mode);
63legacy_hal::wifi_power_scenario convertHidlTxPowerScenarioToLegacy_1_2(
64 V1_2::IWifiChip::TxPowerScenario hidl_scenario);
65bool convertLegacyWifiMacInfosToHidl(
66 const std::vector<legacy_hal::WifiMacInfo>& legacy_mac_infos,
67 std::vector<V1_4::IWifiChipEventCallback::RadioModeInfo>* hidl_radio_mode_infos);
68legacy_hal::wifi_interface_type convertHidlIfaceTypeToLegacy(IfaceType hidl_interface_type);
69legacy_hal::wifi_multi_sta_use_case convertHidlMultiStaUseCaseToLegacy(
70 V1_5::IWifiChip::MultiStaUseCase use_case);
71bool convertHidlCoexUnsafeChannelToLegacy(
72 const V1_5::IWifiChip::CoexUnsafeChannel& hidl_unsafe_channel,
73 legacy_hal::wifi_coex_unsafe_channel* legacy_unsafe_channel);
74bool convertHidlVectorOfCoexUnsafeChannelToLegacy(
75 const std::vector<V1_5::IWifiChip::CoexUnsafeChannel>& hidl_unsafe_channels,
76 std::vector<legacy_hal::wifi_coex_unsafe_channel>* legacy_unsafe_channels);
Sunil Ravief97d232022-01-24 10:39:56 -080077bool convertLegacyRadioCombinationsMatrixToHidl(
78 legacy_hal::wifi_radio_combination_matrix* legacy_matrix,
79 V1_6::WifiRadioCombinationMatrix* hidl_matrix);
80V1_5::WifiBand convertLegacyMacBandToHidlWifiBand(uint32_t band);
81V1_6::WifiAntennaMode convertLegacyAntennaConfigurationToHidl(uint32_t antenna_cfg);
Ahmed ElArabawy687ce132022-01-11 16:42:48 -080082
83// STA iface conversion methods.
84bool convertLegacyFeaturesToHidlStaCapabilities(uint64_t legacy_feature_set,
85 uint32_t legacy_logger_feature_set,
86 uint32_t* hidl_caps);
87bool convertLegacyApfCapabilitiesToHidl(const legacy_hal::PacketFilterCapabilities& legacy_caps,
88 StaApfPacketFilterCapabilities* hidl_caps);
89bool convertLegacyGscanCapabilitiesToHidl(const legacy_hal::wifi_gscan_capabilities& legacy_caps,
90 StaBackgroundScanCapabilities* hidl_caps);
91legacy_hal::wifi_band convertHidlWifiBandToLegacy(V1_0::WifiBand band);
92bool convertHidlGscanParamsToLegacy(const StaBackgroundScanParameters& hidl_scan_params,
93 legacy_hal::wifi_scan_cmd_params* legacy_scan_params);
94// |has_ie_data| indicates whether or not the wifi_scan_result includes 802.11
95// Information Elements (IEs)
96bool convertLegacyGscanResultToHidl(const legacy_hal::wifi_scan_result& legacy_scan_result,
97 bool has_ie_data, StaScanResult* hidl_scan_result);
98// |cached_results| is assumed to not include IEs.
99bool convertLegacyVectorOfCachedGscanResultsToHidl(
100 const std::vector<legacy_hal::wifi_cached_scan_results>& legacy_cached_scan_results,
101 std::vector<StaScanData>* hidl_scan_datas);
102bool convertLegacyLinkLayerStatsToHidl(const legacy_hal::LinkLayerStats& legacy_stats,
Ahmed ElArabawy05571e42022-01-19 11:54:11 -0800103 V1_6::StaLinkLayerStats* hidl_stats);
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800104bool convertLegacyRoamingCapabilitiesToHidl(
105 const legacy_hal::wifi_roaming_capabilities& legacy_caps,
106 StaRoamingCapabilities* hidl_caps);
107bool convertHidlRoamingConfigToLegacy(const StaRoamingConfig& hidl_config,
108 legacy_hal::wifi_roaming_config* legacy_config);
109legacy_hal::fw_roaming_state_t convertHidlRoamingStateToLegacy(StaRoamingState state);
110bool convertLegacyVectorOfDebugTxPacketFateToHidl(
111 const std::vector<legacy_hal::wifi_tx_report>& legacy_fates,
112 std::vector<WifiDebugTxPacketFateReport>* hidl_fates);
113bool convertLegacyVectorOfDebugRxPacketFateToHidl(
114 const std::vector<legacy_hal::wifi_rx_report>& legacy_fates,
115 std::vector<WifiDebugRxPacketFateReport>* hidl_fates);
116
117// NAN iface conversion methods.
118void convertToWifiNanStatus(legacy_hal::NanStatusType type, const char* str, size_t max_len,
119 WifiNanStatus* wifiNanStatus);
120bool convertHidlNanEnableRequestToLegacy(const V1_4::NanEnableRequest& hidl_request,
121 legacy_hal::NanEnableRequest* legacy_request);
122bool convertHidlNanConfigRequestToLegacy(const V1_4::NanConfigRequest& hidl_request,
123 legacy_hal::NanConfigRequest* legacy_request);
Nate Jiang50c001d2022-01-12 16:06:01 -0800124bool convertHidlNanEnableRequest_1_6ToLegacy(
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800125 const V1_4::NanEnableRequest& hidl_request1,
Nate Jiang50c001d2022-01-12 16:06:01 -0800126 const V1_6::NanConfigRequestSupplemental& hidl_request2,
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800127 legacy_hal::NanEnableRequest* legacy_request);
Nate Jiang50c001d2022-01-12 16:06:01 -0800128bool convertHidlNanConfigRequest_1_6ToLegacy(
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800129 const V1_4::NanConfigRequest& hidl_request1,
Nate Jiang50c001d2022-01-12 16:06:01 -0800130 const V1_6::NanConfigRequestSupplemental& hidl_request2,
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800131 legacy_hal::NanConfigRequest* legacy_request);
Nate Jiang50c001d2022-01-12 16:06:01 -0800132bool convertHidlNanPublishRequestToLegacy(const V1_6::NanPublishRequest& hidl_request,
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800133 legacy_hal::NanPublishRequest* legacy_request);
Nate Jiang50c001d2022-01-12 16:06:01 -0800134bool convertHidlNanSubscribeRequestToLegacy(const V1_0::NanSubscribeRequest& hidl_request,
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800135 legacy_hal::NanSubscribeRequest* legacy_request);
136bool convertHidlNanTransmitFollowupRequestToLegacy(
137 const NanTransmitFollowupRequest& hidl_request,
138 legacy_hal::NanTransmitFollowupRequest* legacy_request);
139bool convertHidlNanDataPathInitiatorRequestToLegacy(
Nate Jiang50c001d2022-01-12 16:06:01 -0800140 const V1_0::NanInitiateDataPathRequest& hidl_request,
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800141 legacy_hal::NanDataPathInitiatorRequest* legacy_request);
142bool convertHidlNanDataPathIndicationResponseToLegacy(
Nate Jiang50c001d2022-01-12 16:06:01 -0800143 const V1_0::NanRespondToDataPathIndicationRequest& hidl_response,
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800144 legacy_hal::NanDataPathIndicationResponse* legacy_response);
Nate Jiang50c001d2022-01-12 16:06:01 -0800145bool convertHidlNanDataPathInitiatorRequest_1_6ToLegacy(
146 const V1_6::NanInitiateDataPathRequest& hidl_request,
147 legacy_hal::NanDataPathInitiatorRequest* legacy_request);
148bool convertHidlNanDataPathIndicationResponse_1_6ToLegacy(
149 const V1_6::NanRespondToDataPathIndicationRequest& hidl_response,
150 legacy_hal::NanDataPathIndicationResponse* legacy_response);
151
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800152bool convertLegacyNanResponseHeaderToHidl(const legacy_hal::NanResponseMsg& legacy_response,
153 WifiNanStatus* wifiNanStatus);
154bool convertLegacyNanCapabilitiesResponseToHidl(const legacy_hal::NanCapabilities& legacy_response,
Nate Jiang50c001d2022-01-12 16:06:01 -0800155 V1_6::NanCapabilities* hidl_response);
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800156bool convertLegacyNanMatchIndToHidl(const legacy_hal::NanMatchInd& legacy_ind,
Nate Jiang50c001d2022-01-12 16:06:01 -0800157 V1_6::NanMatchInd* hidl_ind);
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800158bool convertLegacyNanFollowupIndToHidl(const legacy_hal::NanFollowupInd& legacy_ind,
159 NanFollowupReceivedInd* hidl_ind);
160bool convertLegacyNanDataPathRequestIndToHidl(const legacy_hal::NanDataPathRequestInd& legacy_ind,
161 NanDataPathRequestInd* hidl_ind);
162bool convertLegacyNanDataPathConfirmIndToHidl(const legacy_hal::NanDataPathConfirmInd& legacy_ind,
Ahmed ElArabawy05571e42022-01-19 11:54:11 -0800163 V1_6::NanDataPathConfirmInd* hidl_ind);
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800164bool convertLegacyNanDataPathScheduleUpdateIndToHidl(
165 const legacy_hal::NanDataPathScheduleUpdateInd& legacy_ind,
Ahmed ElArabawy05571e42022-01-19 11:54:11 -0800166 V1_6::NanDataPathScheduleUpdateInd* hidl_ind);
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800167
168// RTT controller conversion methods.
Ahmed ElArabawy05571e42022-01-19 11:54:11 -0800169bool convertHidlVectorOfRttConfigToLegacy(const std::vector<V1_6::RttConfig>& hidl_configs,
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800170 std::vector<legacy_hal::wifi_rtt_config>* legacy_configs);
171bool convertHidlRttLciInformationToLegacy(const RttLciInformation& hidl_info,
172 legacy_hal::wifi_lci_information* legacy_info);
173bool convertHidlRttLcrInformationToLegacy(const RttLcrInformation& hidl_info,
174 legacy_hal::wifi_lcr_information* legacy_info);
Ahmed ElArabawy05571e42022-01-19 11:54:11 -0800175bool convertHidlRttResponderToLegacy(const V1_6::RttResponder& hidl_responder,
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800176 legacy_hal::wifi_rtt_responder* legacy_responder);
Ahmed ElArabawy05571e42022-01-19 11:54:11 -0800177bool convertHidlWifiChannelInfoToLegacy(const V1_6::WifiChannelInfo& hidl_info,
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800178 legacy_hal::wifi_channel_info* legacy_info);
179bool convertLegacyRttResponderToHidl(const legacy_hal::wifi_rtt_responder& legacy_responder,
Ahmed ElArabawy05571e42022-01-19 11:54:11 -0800180 V1_6::RttResponder* hidl_responder);
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800181bool convertLegacyRttCapabilitiesToHidl(
182 const legacy_hal::wifi_rtt_capabilities& legacy_capabilities,
Ahmed ElArabawy05571e42022-01-19 11:54:11 -0800183 V1_6::RttCapabilities* hidl_capabilities);
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800184bool convertLegacyVectorOfRttResultToHidl(
185 const std::vector<const legacy_hal::wifi_rtt_result*>& legacy_results,
Ahmed ElArabawy05571e42022-01-19 11:54:11 -0800186 std::vector<V1_6::RttResult>* hidl_results);
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800187uint32_t convertHidlWifiBandToLegacyMacBand(V1_5::WifiBand band);
188uint32_t convertHidlWifiIfaceModeToLegacy(uint32_t hidl_iface_mask);
189uint32_t convertHidlUsableChannelFilterToLegacy(uint32_t hidl_filter_mask);
190bool convertLegacyWifiUsableChannelsToHidl(
191 const std::vector<legacy_hal::wifi_usable_channel>& legacy_usable_channels,
Ahmed ElArabawy05571e42022-01-19 11:54:11 -0800192 std::vector<V1_6::WifiUsableChannel>* hidl_usable_channels);
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800193bool convertLegacyPeerInfoStatsToHidl(const legacy_hal::WifiPeerInfo& legacy_peer_info_stats,
Ahmed ElArabawy05571e42022-01-19 11:54:11 -0800194 V1_6::StaPeerInfo* hidl_peer_info_stats);
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800195bool convertLegacyWifiRateInfoToHidl(const legacy_hal::wifi_rate& legacy_rate,
Ahmed ElArabawy05571e42022-01-19 11:54:11 -0800196 V1_6::WifiRateInfo* hidl_rate);
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800197} // namespace hidl_struct_util
198} // namespace implementation
199} // namespace V1_6
200} // namespace wifi
201} // namespace hardware
202} // namespace android
203
204#endif // HIDL_STRUCT_UTIL_H_