blob: 49d8a1213edc0aec179a059d8210d86e96e010a8 [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>
xshue9873252018-08-07 11:04:34 -070025#include <android/hardware/wifi/1.3/types.h>
Ahmed ElArabawyfd809fc2019-11-15 18:19:15 -080026#include <android/hardware/wifi/1.4/IWifiChipEventCallback.h>
Ahmed ElArabawyeeb53382019-10-10 20:18:31 -070027#include <android/hardware/wifi/1.4/types.h>
Jimmy Chen1bdf1a72019-12-23 17:53:40 +020028#include <android/hardware/wifi/1.5/IWifiChip.h>
Nate Jiang3ec67812020-08-24 11:04:31 -070029#include <android/hardware/wifi/1.5/types.h>
Roshan Piuse65edb12016-11-22 13:02:01 -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 {
Jimmy Chend460df32019-11-29 17:31:22 +020042namespace V1_5 {
Roshan Piuse65edb12016-11-22 13:02:01 -080043namespace implementation {
44namespace hidl_struct_util {
Roshan Piusdbd83ef2017-06-20 12:05:40 -070045using namespace android::hardware::wifi::V1_0;
Roshan Piuse65edb12016-11-22 13:02:01 -080046
Roshan Piusf72df2e2016-12-04 10:49:38 -080047// Chip conversion methods.
48bool convertLegacyFeaturesToHidlChipCapabilities(
Jimmy Chen1bdf1a72019-12-23 17:53:40 +020049 uint64_t legacy_feature_set, uint32_t legacy_logger_feature_set,
Roshan Pius8184d212017-07-11 08:59:29 -070050 uint32_t* hidl_caps);
Roshan Pius48185b22016-12-15 19:10:30 -080051bool convertLegacyDebugRingBufferStatusToHidl(
52 const legacy_hal::wifi_ring_buffer_status& legacy_status,
53 WifiDebugRingBufferStatus* hidl_status);
Roshan Piusf72df2e2016-12-04 10:49:38 -080054bool convertLegacyVectorOfDebugRingBufferStatusToHidl(
55 const std::vector<legacy_hal::wifi_ring_buffer_status>& legacy_status_vec,
56 std::vector<WifiDebugRingBufferStatus>* hidl_status_vec);
57bool convertLegacyWakeReasonStatsToHidl(
58 const legacy_hal::WakeReasonStats& legacy_stats,
59 WifiDebugHostWakeReasonStats* hidl_stats);
Roshan Pius735ff432017-07-25 08:48:08 -070060legacy_hal::wifi_power_scenario convertHidlTxPowerScenarioToLegacy(
61 V1_1::IWifiChip::TxPowerScenario hidl_scenario);
Ahmed ElArabawyeaf82402018-10-26 09:46:04 -070062legacy_hal::wifi_latency_mode convertHidlLatencyModeToLegacy(
63 V1_3::IWifiChip::LatencyMode hidl_latency_mode);
Ahmed ElArabawy6a1accf2018-01-23 10:57:29 -080064legacy_hal::wifi_power_scenario convertHidlTxPowerScenarioToLegacy_1_2(
Jong Wook Kimda830c92018-07-23 15:29:38 -070065 V1_2::IWifiChip::TxPowerScenario hidl_scenario);
Roshan Pius1a7b1db2018-01-22 17:57:20 -080066bool convertLegacyWifiMacInfosToHidl(
67 const std::vector<legacy_hal::WifiMacInfo>& legacy_mac_infos,
Jimmy Chend460df32019-11-29 17:31:22 +020068 std::vector<V1_4::IWifiChipEventCallback::RadioModeInfo>*
69 hidl_radio_mode_infos);
Sunil Raviddab4bb2020-02-03 22:45:19 -080070legacy_hal::wifi_interface_type convertHidlIfaceTypeToLegacy(
71 IfaceType hidl_interface_type);
Roshan Piuse9d1e7d2020-11-04 11:44:16 -080072legacy_hal::wifi_multi_sta_use_case convertHidlMultiStaUseCaseToLegacy(
73 IWifiChip::MultiStaUseCase use_case);
Roshan Piusf72df2e2016-12-04 10:49:38 -080074
Roshan Piusf5f51fd2016-12-01 13:54:24 -080075// STA iface conversion methods.
Roshan Piusf72df2e2016-12-04 10:49:38 -080076bool convertLegacyFeaturesToHidlStaCapabilities(
Ahmed ElArabawy95e36b72019-11-15 21:24:53 +000077 uint64_t legacy_feature_set, uint32_t legacy_logger_feature_set,
Roshan Piusf72df2e2016-12-04 10:49:38 -080078 uint32_t* hidl_caps);
79bool convertLegacyApfCapabilitiesToHidl(
80 const legacy_hal::PacketFilterCapabilities& legacy_caps,
81 StaApfPacketFilterCapabilities* hidl_caps);
Roshan Pius881d1f72016-12-05 15:37:00 -080082bool convertLegacyGscanCapabilitiesToHidl(
Roshan Piusf72df2e2016-12-04 10:49:38 -080083 const legacy_hal::wifi_gscan_capabilities& legacy_caps,
84 StaBackgroundScanCapabilities* hidl_caps);
Ahmed ElArabawyfd809fc2019-11-15 18:19:15 -080085legacy_hal::wifi_band convertHidlWifiBandToLegacy(V1_0::WifiBand band);
Roshan Pius881d1f72016-12-05 15:37:00 -080086bool convertHidlGscanParamsToLegacy(
Roshan Piuse65edb12016-11-22 13:02:01 -080087 const StaBackgroundScanParameters& hidl_scan_params,
88 legacy_hal::wifi_scan_cmd_params* legacy_scan_params);
Roshan Piuse65edb12016-11-22 13:02:01 -080089// |has_ie_data| indicates whether or not the wifi_scan_result includes 802.11
90// Information Elements (IEs)
Roshan Pius881d1f72016-12-05 15:37:00 -080091bool convertLegacyGscanResultToHidl(
Roshan Piusabcf78f2017-10-06 16:30:38 -070092 const legacy_hal::wifi_scan_result& legacy_scan_result, bool has_ie_data,
Roshan Piuse65edb12016-11-22 13:02:01 -080093 StaScanResult* hidl_scan_result);
94// |cached_results| is assumed to not include IEs.
Roshan Pius881d1f72016-12-05 15:37:00 -080095bool convertLegacyVectorOfCachedGscanResultsToHidl(
Roshan Piuse65edb12016-11-22 13:02:01 -080096 const std::vector<legacy_hal::wifi_cached_scan_results>&
97 legacy_cached_scan_results,
98 std::vector<StaScanData>* hidl_scan_datas);
99bool convertLegacyLinkLayerStatsToHidl(
100 const legacy_hal::LinkLayerStats& legacy_stats,
Roshan Piuse9d1e7d2020-11-04 11:44:16 -0800101 StaLinkLayerStats* hidl_stats);
Roshan Pius26801cb2016-12-13 14:25:45 -0800102bool convertLegacyRoamingCapabilitiesToHidl(
103 const legacy_hal::wifi_roaming_capabilities& legacy_caps,
104 StaRoamingCapabilities* hidl_caps);
105bool convertHidlRoamingConfigToLegacy(
106 const StaRoamingConfig& hidl_config,
107 legacy_hal::wifi_roaming_config* legacy_config);
108legacy_hal::fw_roaming_state_t convertHidlRoamingStateToLegacy(
109 StaRoamingState state);
Roshan Piusf72df2e2016-12-04 10:49:38 -0800110bool 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);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800116
117// NAN iface conversion methods.
Roshan Piusabcf78f2017-10-06 16:30:38 -0700118void convertToWifiNanStatus(legacy_hal::NanStatusType type, const char* str,
119 size_t max_len, WifiNanStatus* wifiNanStatus);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800120bool convertHidlNanEnableRequestToLegacy(
Jimmy Chend460df32019-11-29 17:31:22 +0200121 const V1_4::NanEnableRequest& hidl_request,
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800122 legacy_hal::NanEnableRequest* legacy_request);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800123bool convertHidlNanConfigRequestToLegacy(
Jimmy Chend460df32019-11-29 17:31:22 +0200124 const V1_4::NanConfigRequest& hidl_request,
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800125 legacy_hal::NanConfigRequest* legacy_request);
Ahmed ElArabawy83baffd2019-11-15 19:20:41 -0800126bool convertHidlNanEnableRequest_1_4ToLegacy(
Jimmy Chend460df32019-11-29 17:31:22 +0200127 const V1_4::NanEnableRequest& hidl_request1,
Nate Jiang3ec67812020-08-24 11:04:31 -0700128 const NanConfigRequestSupplemental& hidl_request2,
Etan Cohen9e7a4052017-12-21 13:45:26 -0800129 legacy_hal::NanEnableRequest* legacy_request);
Ahmed ElArabawy83baffd2019-11-15 19:20:41 -0800130bool convertHidlNanConfigRequest_1_4ToLegacy(
Jimmy Chend460df32019-11-29 17:31:22 +0200131 const V1_4::NanConfigRequest& hidl_request1,
Nate Jiang3ec67812020-08-24 11:04:31 -0700132 const NanConfigRequestSupplemental& hidl_request2,
133 legacy_hal::NanConfigRequest* legacy_request);
134bool convertHidlNanEnableRequest_1_5ToLegacy(
135 const V1_4::NanEnableRequest& hidl_request1,
136 const NanConfigRequestSupplemental& hidl_request2,
137 legacy_hal::NanEnableRequest* legacy_request);
138bool convertHidlNanConfigRequest_1_5ToLegacy(
139 const V1_4::NanConfigRequest& hidl_request1,
140 const NanConfigRequestSupplemental& hidl_request2,
Etan Cohen9e7a4052017-12-21 13:45:26 -0800141 legacy_hal::NanConfigRequest* legacy_request);
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800142bool convertHidlNanPublishRequestToLegacy(
143 const NanPublishRequest& hidl_request,
144 legacy_hal::NanPublishRequest* legacy_request);
145bool convertHidlNanSubscribeRequestToLegacy(
146 const NanSubscribeRequest& hidl_request,
147 legacy_hal::NanSubscribeRequest* legacy_request);
148bool convertHidlNanTransmitFollowupRequestToLegacy(
149 const NanTransmitFollowupRequest& hidl_request,
150 legacy_hal::NanTransmitFollowupRequest* legacy_request);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800151bool convertHidlNanDataPathInitiatorRequestToLegacy(
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800152 const NanInitiateDataPathRequest& hidl_request,
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800153 legacy_hal::NanDataPathInitiatorRequest* legacy_request);
154bool convertHidlNanDataPathIndicationResponseToLegacy(
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800155 const NanRespondToDataPathIndicationRequest& hidl_response,
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800156 legacy_hal::NanDataPathIndicationResponse* legacy_response);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800157bool convertLegacyNanResponseHeaderToHidl(
158 const legacy_hal::NanResponseMsg& legacy_response,
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800159 WifiNanStatus* wifiNanStatus);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800160bool convertLegacyNanCapabilitiesResponseToHidl(
161 const legacy_hal::NanCapabilities& legacy_response,
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800162 NanCapabilities* hidl_response);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800163bool convertLegacyNanMatchIndToHidl(const legacy_hal::NanMatchInd& legacy_ind,
164 NanMatchInd* hidl_ind);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800165bool convertLegacyNanFollowupIndToHidl(
Roshan Piusabcf78f2017-10-06 16:30:38 -0700166 const legacy_hal::NanFollowupInd& legacy_ind,
167 NanFollowupReceivedInd* hidl_ind);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800168bool convertLegacyNanDataPathRequestIndToHidl(
169 const legacy_hal::NanDataPathRequestInd& legacy_ind,
170 NanDataPathRequestInd* hidl_ind);
171bool convertLegacyNanDataPathConfirmIndToHidl(
172 const legacy_hal::NanDataPathConfirmInd& legacy_ind,
Jong Wook Kimda830c92018-07-23 15:29:38 -0700173 V1_2::NanDataPathConfirmInd* hidl_ind);
Etan Cohenc7bd0f72017-12-26 11:52:44 -0800174bool convertLegacyNanDataPathScheduleUpdateIndToHidl(
175 const legacy_hal::NanDataPathScheduleUpdateInd& legacy_ind,
Jong Wook Kimda830c92018-07-23 15:29:38 -0700176 V1_2::NanDataPathScheduleUpdateInd* hidl_ind);
Roshan Pius3fae9c82016-12-02 14:49:41 -0800177
178// RTT controller conversion methods.
Roshan Piuse3f72ff2016-12-05 16:18:43 -0800179bool convertHidlVectorOfRttConfigToLegacy(
Jimmy Chend460df32019-11-29 17:31:22 +0200180 const std::vector<V1_4::RttConfig>& hidl_configs,
Roshan Piuse3f72ff2016-12-05 16:18:43 -0800181 std::vector<legacy_hal::wifi_rtt_config>* legacy_configs);
Roshan Pius3fae9c82016-12-02 14:49:41 -0800182bool convertHidlRttLciInformationToLegacy(
183 const RttLciInformation& hidl_info,
184 legacy_hal::wifi_lci_information* legacy_info);
185bool convertHidlRttLcrInformationToLegacy(
186 const RttLcrInformation& hidl_info,
187 legacy_hal::wifi_lcr_information* legacy_info);
188bool convertHidlRttResponderToLegacy(
Jimmy Chend460df32019-11-29 17:31:22 +0200189 const V1_4::RttResponder& hidl_responder,
Roshan Pius3fae9c82016-12-02 14:49:41 -0800190 legacy_hal::wifi_rtt_responder* legacy_responder);
Roshan Piuse3f72ff2016-12-05 16:18:43 -0800191bool convertHidlWifiChannelInfoToLegacy(
192 const WifiChannelInfo& hidl_info,
193 legacy_hal::wifi_channel_info* legacy_info);
Roshan Pius3fae9c82016-12-02 14:49:41 -0800194bool convertLegacyRttResponderToHidl(
195 const legacy_hal::wifi_rtt_responder& legacy_responder,
Jimmy Chend460df32019-11-29 17:31:22 +0200196 V1_4::RttResponder* hidl_responder);
Roshan Pius3fae9c82016-12-02 14:49:41 -0800197bool convertLegacyRttCapabilitiesToHidl(
198 const legacy_hal::wifi_rtt_capabilities& legacy_capabilities,
Jimmy Chend460df32019-11-29 17:31:22 +0200199 V1_4::RttCapabilities* hidl_capabilities);
Roshan Piuse3f72ff2016-12-05 16:18:43 -0800200bool convertLegacyVectorOfRttResultToHidl(
201 const std::vector<const legacy_hal::wifi_rtt_result*>& legacy_results,
Jimmy Chend460df32019-11-29 17:31:22 +0200202 std::vector<V1_4::RttResult>* hidl_results);
Roshan Piuse65edb12016-11-22 13:02:01 -0800203} // namespace hidl_struct_util
204} // namespace implementation
Jimmy Chend460df32019-11-29 17:31:22 +0200205} // namespace V1_5
Roshan Piuse65edb12016-11-22 13:02:01 -0800206} // namespace wifi
207} // namespace hardware
208} // namespace android
209
210#endif // HIDL_STRUCT_UTIL_H_