blob: 15a320584709bf6acc69f49bb4f26e2567770b88 [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>
28#include <android/hardware/wifi/1.5/IWifiChip.h>
29#include <android/hardware/wifi/1.5/types.h>
30
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);
77
78// STA iface conversion methods.
79bool convertLegacyFeaturesToHidlStaCapabilities(uint64_t legacy_feature_set,
80 uint32_t legacy_logger_feature_set,
81 uint32_t* hidl_caps);
82bool convertLegacyApfCapabilitiesToHidl(const legacy_hal::PacketFilterCapabilities& legacy_caps,
83 StaApfPacketFilterCapabilities* hidl_caps);
84bool convertLegacyGscanCapabilitiesToHidl(const legacy_hal::wifi_gscan_capabilities& legacy_caps,
85 StaBackgroundScanCapabilities* hidl_caps);
86legacy_hal::wifi_band convertHidlWifiBandToLegacy(V1_0::WifiBand band);
87bool convertHidlGscanParamsToLegacy(const StaBackgroundScanParameters& hidl_scan_params,
88 legacy_hal::wifi_scan_cmd_params* legacy_scan_params);
89// |has_ie_data| indicates whether or not the wifi_scan_result includes 802.11
90// Information Elements (IEs)
91bool convertLegacyGscanResultToHidl(const legacy_hal::wifi_scan_result& legacy_scan_result,
92 bool has_ie_data, StaScanResult* hidl_scan_result);
93// |cached_results| is assumed to not include IEs.
94bool convertLegacyVectorOfCachedGscanResultsToHidl(
95 const std::vector<legacy_hal::wifi_cached_scan_results>& legacy_cached_scan_results,
96 std::vector<StaScanData>* hidl_scan_datas);
97bool convertLegacyLinkLayerStatsToHidl(const legacy_hal::LinkLayerStats& legacy_stats,
98 V1_5::StaLinkLayerStats* hidl_stats);
99bool convertLegacyRoamingCapabilitiesToHidl(
100 const legacy_hal::wifi_roaming_capabilities& legacy_caps,
101 StaRoamingCapabilities* hidl_caps);
102bool convertHidlRoamingConfigToLegacy(const StaRoamingConfig& hidl_config,
103 legacy_hal::wifi_roaming_config* legacy_config);
104legacy_hal::fw_roaming_state_t convertHidlRoamingStateToLegacy(StaRoamingState state);
105bool convertLegacyVectorOfDebugTxPacketFateToHidl(
106 const std::vector<legacy_hal::wifi_tx_report>& legacy_fates,
107 std::vector<WifiDebugTxPacketFateReport>* hidl_fates);
108bool convertLegacyVectorOfDebugRxPacketFateToHidl(
109 const std::vector<legacy_hal::wifi_rx_report>& legacy_fates,
110 std::vector<WifiDebugRxPacketFateReport>* hidl_fates);
111
112// NAN iface conversion methods.
113void convertToWifiNanStatus(legacy_hal::NanStatusType type, const char* str, size_t max_len,
114 WifiNanStatus* wifiNanStatus);
115bool convertHidlNanEnableRequestToLegacy(const V1_4::NanEnableRequest& hidl_request,
116 legacy_hal::NanEnableRequest* legacy_request);
117bool convertHidlNanConfigRequestToLegacy(const V1_4::NanConfigRequest& hidl_request,
118 legacy_hal::NanConfigRequest* legacy_request);
119bool convertHidlNanEnableRequest_1_4ToLegacy(
120 const V1_4::NanEnableRequest& hidl_request1,
121 const V1_5::NanConfigRequestSupplemental& hidl_request2,
122 legacy_hal::NanEnableRequest* legacy_request);
123bool convertHidlNanConfigRequest_1_4ToLegacy(
124 const V1_4::NanConfigRequest& hidl_request1,
125 const V1_5::NanConfigRequestSupplemental& hidl_request2,
126 legacy_hal::NanConfigRequest* legacy_request);
127bool convertHidlNanEnableRequest_1_5ToLegacy(
128 const V1_4::NanEnableRequest& hidl_request1,
129 const V1_5::NanConfigRequestSupplemental& hidl_request2,
130 legacy_hal::NanEnableRequest* legacy_request);
131bool convertHidlNanConfigRequest_1_5ToLegacy(
132 const V1_4::NanConfigRequest& hidl_request1,
133 const V1_5::NanConfigRequestSupplemental& hidl_request2,
134 legacy_hal::NanConfigRequest* legacy_request);
135bool convertHidlNanPublishRequestToLegacy(const NanPublishRequest& hidl_request,
136 legacy_hal::NanPublishRequest* legacy_request);
137bool convertHidlNanSubscribeRequestToLegacy(const NanSubscribeRequest& hidl_request,
138 legacy_hal::NanSubscribeRequest* legacy_request);
139bool convertHidlNanTransmitFollowupRequestToLegacy(
140 const NanTransmitFollowupRequest& hidl_request,
141 legacy_hal::NanTransmitFollowupRequest* legacy_request);
142bool convertHidlNanDataPathInitiatorRequestToLegacy(
143 const NanInitiateDataPathRequest& hidl_request,
144 legacy_hal::NanDataPathInitiatorRequest* legacy_request);
145bool convertHidlNanDataPathIndicationResponseToLegacy(
146 const NanRespondToDataPathIndicationRequest& hidl_response,
147 legacy_hal::NanDataPathIndicationResponse* legacy_response);
148bool convertLegacyNanResponseHeaderToHidl(const legacy_hal::NanResponseMsg& legacy_response,
149 WifiNanStatus* wifiNanStatus);
150bool convertLegacyNanCapabilitiesResponseToHidl(const legacy_hal::NanCapabilities& legacy_response,
151 V1_5::NanCapabilities* hidl_response);
152bool convertLegacyNanMatchIndToHidl(const legacy_hal::NanMatchInd& legacy_ind,
153 NanMatchInd* hidl_ind);
154bool convertLegacyNanFollowupIndToHidl(const legacy_hal::NanFollowupInd& legacy_ind,
155 NanFollowupReceivedInd* hidl_ind);
156bool convertLegacyNanDataPathRequestIndToHidl(const legacy_hal::NanDataPathRequestInd& legacy_ind,
157 NanDataPathRequestInd* hidl_ind);
158bool convertLegacyNanDataPathConfirmIndToHidl(const legacy_hal::NanDataPathConfirmInd& legacy_ind,
159 V1_2::NanDataPathConfirmInd* hidl_ind);
160bool convertLegacyNanDataPathScheduleUpdateIndToHidl(
161 const legacy_hal::NanDataPathScheduleUpdateInd& legacy_ind,
162 V1_2::NanDataPathScheduleUpdateInd* hidl_ind);
163
164// RTT controller conversion methods.
165bool convertHidlVectorOfRttConfigToLegacy(const std::vector<V1_4::RttConfig>& hidl_configs,
166 std::vector<legacy_hal::wifi_rtt_config>* legacy_configs);
167bool convertHidlRttLciInformationToLegacy(const RttLciInformation& hidl_info,
168 legacy_hal::wifi_lci_information* legacy_info);
169bool convertHidlRttLcrInformationToLegacy(const RttLcrInformation& hidl_info,
170 legacy_hal::wifi_lcr_information* legacy_info);
171bool convertHidlRttResponderToLegacy(const V1_4::RttResponder& hidl_responder,
172 legacy_hal::wifi_rtt_responder* legacy_responder);
173bool convertHidlWifiChannelInfoToLegacy(const WifiChannelInfo& hidl_info,
174 legacy_hal::wifi_channel_info* legacy_info);
175bool convertLegacyRttResponderToHidl(const legacy_hal::wifi_rtt_responder& legacy_responder,
176 V1_4::RttResponder* hidl_responder);
177bool convertLegacyRttCapabilitiesToHidl(
178 const legacy_hal::wifi_rtt_capabilities& legacy_capabilities,
179 V1_4::RttCapabilities* hidl_capabilities);
180bool convertLegacyVectorOfRttResultToHidl(
181 const std::vector<const legacy_hal::wifi_rtt_result*>& legacy_results,
182 std::vector<V1_4::RttResult>* hidl_results);
183uint32_t convertHidlWifiBandToLegacyMacBand(V1_5::WifiBand band);
184uint32_t convertHidlWifiIfaceModeToLegacy(uint32_t hidl_iface_mask);
185uint32_t convertHidlUsableChannelFilterToLegacy(uint32_t hidl_filter_mask);
186bool convertLegacyWifiUsableChannelsToHidl(
187 const std::vector<legacy_hal::wifi_usable_channel>& legacy_usable_channels,
188 std::vector<V1_5::WifiUsableChannel>* hidl_usable_channels);
189bool convertLegacyPeerInfoStatsToHidl(const legacy_hal::WifiPeerInfo& legacy_peer_info_stats,
190 V1_5::StaPeerInfo* hidl_peer_info_stats);
191bool convertLegacyWifiRateInfoToHidl(const legacy_hal::wifi_rate& legacy_rate,
192 V1_4::WifiRateInfo* hidl_rate);
193} // namespace hidl_struct_util
194} // namespace implementation
195} // namespace V1_6
196} // namespace wifi
197} // namespace hardware
198} // namespace android
199
200#endif // HIDL_STRUCT_UTIL_H_