blob: 929f877d96e9119dbf7ddd6b13b31e34a1733f9a [file] [log] [blame]
Roshan Piuse65edb12016-11-22 13:02:01 -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
Roshan Pius735ff432017-07-25 08:48:08 -070022#include <android/hardware/wifi/1.0/IWifiChip.h>
Roshan Piusabcf78f2017-10-06 16:30:38 -070023#include <android/hardware/wifi/1.0/types.h>
Etan Cohen9e7a4052017-12-21 13:45:26 -080024#include <android/hardware/wifi/1.2/types.h>
Ahmed ElArabawyeaf82402018-10-26 09:46:04 -070025#include <android/hardware/wifi/1.3/IWifiChip.h>
xshue9873252018-08-07 11:04:34 -070026#include <android/hardware/wifi/1.3/types.h>
Ahmed ElArabawyfd809fc2019-11-15 18:19:15 -080027#include <android/hardware/wifi/1.4/IWifiChipEventCallback.h>
Ahmed ElArabawyeeb53382019-10-10 20:18:31 -070028#include <android/hardware/wifi/1.4/types.h>
Roshan Piuse65edb12016-11-22 13:02:01 -080029
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 HIDL and vice versa.
35 * TODO(b/32093047): Add unit tests for these conversion methods in the VTS test
36 * suite.
37 */
38namespace android {
39namespace hardware {
40namespace wifi {
Ahmed ElArabawyf501a982019-07-23 15:02:22 -070041namespace V1_4 {
Roshan Piuse65edb12016-11-22 13:02:01 -080042namespace implementation {
43namespace hidl_struct_util {
Roshan Piusdbd83ef2017-06-20 12:05:40 -070044using namespace android::hardware::wifi::V1_0;
Roshan Piuse65edb12016-11-22 13:02:01 -080045
Roshan Piusf72df2e2016-12-04 10:49:38 -080046// Chip conversion methods.
47bool convertLegacyFeaturesToHidlChipCapabilities(
Roshan Piusabcf78f2017-10-06 16:30:38 -070048 uint32_t legacy_feature_set, uint32_t legacy_logger_feature_set,
Roshan Pius8184d212017-07-11 08:59:29 -070049 uint32_t* hidl_caps);
Roshan Pius48185b22016-12-15 19:10:30 -080050bool convertLegacyDebugRingBufferStatusToHidl(
51 const legacy_hal::wifi_ring_buffer_status& legacy_status,
52 WifiDebugRingBufferStatus* hidl_status);
Roshan Piusf72df2e2016-12-04 10:49:38 -080053bool convertLegacyVectorOfDebugRingBufferStatusToHidl(
54 const std::vector<legacy_hal::wifi_ring_buffer_status>& legacy_status_vec,
55 std::vector<WifiDebugRingBufferStatus>* hidl_status_vec);
56bool convertLegacyWakeReasonStatsToHidl(
57 const legacy_hal::WakeReasonStats& legacy_stats,
58 WifiDebugHostWakeReasonStats* hidl_stats);
Roshan Pius735ff432017-07-25 08:48:08 -070059legacy_hal::wifi_power_scenario convertHidlTxPowerScenarioToLegacy(
60 V1_1::IWifiChip::TxPowerScenario hidl_scenario);
Ahmed ElArabawyeaf82402018-10-26 09:46:04 -070061legacy_hal::wifi_latency_mode convertHidlLatencyModeToLegacy(
62 V1_3::IWifiChip::LatencyMode hidl_latency_mode);
Ahmed ElArabawy6a1accf2018-01-23 10:57:29 -080063legacy_hal::wifi_power_scenario convertHidlTxPowerScenarioToLegacy_1_2(
Jong Wook Kimda830c92018-07-23 15:29:38 -070064 V1_2::IWifiChip::TxPowerScenario hidl_scenario);
Roshan Pius1a7b1db2018-01-22 17:57:20 -080065bool convertLegacyWifiMacInfosToHidl(
66 const std::vector<legacy_hal::WifiMacInfo>& legacy_mac_infos,
Ahmed ElArabawyfd809fc2019-11-15 18:19:15 -080067 std::vector<IWifiChipEventCallback::RadioModeInfo>* hidl_radio_mode_infos);
Sunil Raviddab4bb2020-02-03 22:45:19 -080068legacy_hal::wifi_interface_type convertHidlIfaceTypeToLegacy(
69 IfaceType hidl_interface_type);
Roshan Piusf72df2e2016-12-04 10:49:38 -080070
Roshan Piusf5f51fd2016-12-01 13:54:24 -080071// STA iface conversion methods.
Roshan Piusf72df2e2016-12-04 10:49:38 -080072bool convertLegacyFeaturesToHidlStaCapabilities(
Ahmed ElArabawy95e36b72019-11-15 21:24:53 +000073 uint64_t legacy_feature_set, uint32_t legacy_logger_feature_set,
Roshan Piusf72df2e2016-12-04 10:49:38 -080074 uint32_t* hidl_caps);
75bool convertLegacyApfCapabilitiesToHidl(
76 const legacy_hal::PacketFilterCapabilities& legacy_caps,
77 StaApfPacketFilterCapabilities* hidl_caps);
Roshan Pius881d1f72016-12-05 15:37:00 -080078bool convertLegacyGscanCapabilitiesToHidl(
Roshan Piusf72df2e2016-12-04 10:49:38 -080079 const legacy_hal::wifi_gscan_capabilities& legacy_caps,
80 StaBackgroundScanCapabilities* hidl_caps);
Ahmed ElArabawyfd809fc2019-11-15 18:19:15 -080081legacy_hal::wifi_band convertHidlWifiBandToLegacy(V1_0::WifiBand band);
Roshan Pius881d1f72016-12-05 15:37:00 -080082bool convertHidlGscanParamsToLegacy(
Roshan Piuse65edb12016-11-22 13:02:01 -080083 const StaBackgroundScanParameters& hidl_scan_params,
84 legacy_hal::wifi_scan_cmd_params* legacy_scan_params);
Roshan Piuse65edb12016-11-22 13:02:01 -080085// |has_ie_data| indicates whether or not the wifi_scan_result includes 802.11
86// Information Elements (IEs)
Roshan Pius881d1f72016-12-05 15:37:00 -080087bool convertLegacyGscanResultToHidl(
Roshan Piusabcf78f2017-10-06 16:30:38 -070088 const legacy_hal::wifi_scan_result& legacy_scan_result, bool has_ie_data,
Roshan Piuse65edb12016-11-22 13:02:01 -080089 StaScanResult* hidl_scan_result);
90// |cached_results| is assumed to not include IEs.
Roshan Pius881d1f72016-12-05 15:37:00 -080091bool convertLegacyVectorOfCachedGscanResultsToHidl(
Roshan Piuse65edb12016-11-22 13:02:01 -080092 const std::vector<legacy_hal::wifi_cached_scan_results>&
93 legacy_cached_scan_results,
94 std::vector<StaScanData>* hidl_scan_datas);
95bool convertLegacyLinkLayerStatsToHidl(
96 const legacy_hal::LinkLayerStats& legacy_stats,
xshue9873252018-08-07 11:04:34 -070097 V1_3::StaLinkLayerStats* hidl_stats);
Roshan Pius26801cb2016-12-13 14:25:45 -080098bool convertLegacyRoamingCapabilitiesToHidl(
99 const legacy_hal::wifi_roaming_capabilities& legacy_caps,
100 StaRoamingCapabilities* hidl_caps);
101bool convertHidlRoamingConfigToLegacy(
102 const StaRoamingConfig& hidl_config,
103 legacy_hal::wifi_roaming_config* legacy_config);
104legacy_hal::fw_roaming_state_t convertHidlRoamingStateToLegacy(
105 StaRoamingState state);
Roshan Piusf72df2e2016-12-04 10:49:38 -0800106bool convertLegacyVectorOfDebugTxPacketFateToHidl(
107 const std::vector<legacy_hal::wifi_tx_report>& legacy_fates,
108 std::vector<WifiDebugTxPacketFateReport>* hidl_fates);
109bool convertLegacyVectorOfDebugRxPacketFateToHidl(
110 const std::vector<legacy_hal::wifi_rx_report>& legacy_fates,
111 std::vector<WifiDebugRxPacketFateReport>* hidl_fates);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800112
113// NAN iface conversion methods.
Roshan Piusabcf78f2017-10-06 16:30:38 -0700114void convertToWifiNanStatus(legacy_hal::NanStatusType type, const char* str,
115 size_t max_len, WifiNanStatus* wifiNanStatus);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800116bool convertHidlNanEnableRequestToLegacy(
117 const NanEnableRequest& hidl_request,
118 legacy_hal::NanEnableRequest* legacy_request);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800119bool convertHidlNanConfigRequestToLegacy(
120 const NanConfigRequest& hidl_request,
121 legacy_hal::NanConfigRequest* legacy_request);
Ahmed ElArabawy83baffd2019-11-15 19:20:41 -0800122bool convertHidlNanEnableRequest_1_4ToLegacy(
Etan Cohen9e7a4052017-12-21 13:45:26 -0800123 const NanEnableRequest& hidl_request1,
Jong Wook Kimda830c92018-07-23 15:29:38 -0700124 const V1_2::NanConfigRequestSupplemental& hidl_request2,
Etan Cohen9e7a4052017-12-21 13:45:26 -0800125 legacy_hal::NanEnableRequest* legacy_request);
Ahmed ElArabawy83baffd2019-11-15 19:20:41 -0800126bool convertHidlNanConfigRequest_1_4ToLegacy(
Etan Cohen9e7a4052017-12-21 13:45:26 -0800127 const NanConfigRequest& hidl_request1,
Jong Wook Kimda830c92018-07-23 15:29:38 -0700128 const V1_2::NanConfigRequestSupplemental& hidl_request2,
Etan Cohen9e7a4052017-12-21 13:45:26 -0800129 legacy_hal::NanConfigRequest* legacy_request);
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800130bool convertHidlNanPublishRequestToLegacy(
131 const NanPublishRequest& hidl_request,
132 legacy_hal::NanPublishRequest* legacy_request);
133bool convertHidlNanSubscribeRequestToLegacy(
134 const NanSubscribeRequest& hidl_request,
135 legacy_hal::NanSubscribeRequest* legacy_request);
136bool convertHidlNanTransmitFollowupRequestToLegacy(
137 const NanTransmitFollowupRequest& hidl_request,
138 legacy_hal::NanTransmitFollowupRequest* legacy_request);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800139bool convertHidlNanDataPathInitiatorRequestToLegacy(
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800140 const NanInitiateDataPathRequest& hidl_request,
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800141 legacy_hal::NanDataPathInitiatorRequest* legacy_request);
142bool convertHidlNanDataPathIndicationResponseToLegacy(
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800143 const NanRespondToDataPathIndicationRequest& hidl_response,
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800144 legacy_hal::NanDataPathIndicationResponse* legacy_response);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800145bool convertLegacyNanResponseHeaderToHidl(
146 const legacy_hal::NanResponseMsg& legacy_response,
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800147 WifiNanStatus* wifiNanStatus);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800148bool convertLegacyNanCapabilitiesResponseToHidl(
149 const legacy_hal::NanCapabilities& legacy_response,
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800150 NanCapabilities* hidl_response);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800151bool convertLegacyNanMatchIndToHidl(const legacy_hal::NanMatchInd& legacy_ind,
152 NanMatchInd* hidl_ind);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800153bool convertLegacyNanFollowupIndToHidl(
Roshan Piusabcf78f2017-10-06 16:30:38 -0700154 const legacy_hal::NanFollowupInd& legacy_ind,
155 NanFollowupReceivedInd* hidl_ind);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800156bool convertLegacyNanDataPathRequestIndToHidl(
157 const legacy_hal::NanDataPathRequestInd& legacy_ind,
158 NanDataPathRequestInd* hidl_ind);
159bool convertLegacyNanDataPathConfirmIndToHidl(
160 const legacy_hal::NanDataPathConfirmInd& legacy_ind,
Jong Wook Kimda830c92018-07-23 15:29:38 -0700161 V1_2::NanDataPathConfirmInd* hidl_ind);
Etan Cohenc7bd0f72017-12-26 11:52:44 -0800162bool convertLegacyNanDataPathScheduleUpdateIndToHidl(
163 const legacy_hal::NanDataPathScheduleUpdateInd& legacy_ind,
Jong Wook Kimda830c92018-07-23 15:29:38 -0700164 V1_2::NanDataPathScheduleUpdateInd* hidl_ind);
Roshan Pius3fae9c82016-12-02 14:49:41 -0800165
166// RTT controller conversion methods.
Roshan Piuse3f72ff2016-12-05 16:18:43 -0800167bool convertHidlVectorOfRttConfigToLegacy(
168 const std::vector<RttConfig>& hidl_configs,
169 std::vector<legacy_hal::wifi_rtt_config>* legacy_configs);
Roshan Pius3fae9c82016-12-02 14:49:41 -0800170bool convertHidlRttLciInformationToLegacy(
171 const RttLciInformation& hidl_info,
172 legacy_hal::wifi_lci_information* legacy_info);
173bool convertHidlRttLcrInformationToLegacy(
174 const RttLcrInformation& hidl_info,
175 legacy_hal::wifi_lcr_information* legacy_info);
176bool convertHidlRttResponderToLegacy(
177 const RttResponder& hidl_responder,
178 legacy_hal::wifi_rtt_responder* legacy_responder);
Roshan Piuse3f72ff2016-12-05 16:18:43 -0800179bool convertHidlWifiChannelInfoToLegacy(
180 const WifiChannelInfo& hidl_info,
181 legacy_hal::wifi_channel_info* legacy_info);
Roshan Pius3fae9c82016-12-02 14:49:41 -0800182bool convertLegacyRttResponderToHidl(
183 const legacy_hal::wifi_rtt_responder& legacy_responder,
184 RttResponder* hidl_responder);
185bool convertLegacyRttCapabilitiesToHidl(
186 const legacy_hal::wifi_rtt_capabilities& legacy_capabilities,
187 RttCapabilities* hidl_capabilities);
Roshan Piuse3f72ff2016-12-05 16:18:43 -0800188bool convertLegacyVectorOfRttResultToHidl(
189 const std::vector<const legacy_hal::wifi_rtt_result*>& legacy_results,
190 std::vector<RttResult>* hidl_results);
Roshan Piuse65edb12016-11-22 13:02:01 -0800191} // namespace hidl_struct_util
192} // namespace implementation
Ahmed ElArabawyf501a982019-07-23 15:02:22 -0700193} // namespace V1_4
Roshan Piuse65edb12016-11-22 13:02:01 -0800194} // namespace wifi
195} // namespace hardware
196} // namespace android
197
198#endif // HIDL_STRUCT_UTIL_H_