blob: 3c789c046f2eee116299f912a89b6c9152cd44cd [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>
Ahmed ElArabawy6a1accf2018-01-23 10:57:29 -080024#include <android/hardware/wifi/1.2/IWifiChip.h>
Roshan Pius1a7b1db2018-01-22 17:57:20 -080025#include <android/hardware/wifi/1.2/IWifiChipEventCallback.h>
Etan Cohen9e7a4052017-12-21 13:45:26 -080026#include <android/hardware/wifi/1.2/types.h>
Roshan Piuse65edb12016-11-22 13:02:01 -080027
28#include "wifi_legacy_hal.h"
29
30/**
31 * This file contains a bunch of functions to convert structs from the legacy
32 * HAL to HIDL and vice versa.
33 * TODO(b/32093047): Add unit tests for these conversion methods in the VTS test
34 * suite.
35 */
36namespace android {
37namespace hardware {
38namespace wifi {
Etan Cohen6ce50902017-09-14 07:30:57 -070039namespace V1_2 {
Roshan Piuse65edb12016-11-22 13:02:01 -080040namespace implementation {
41namespace hidl_struct_util {
Roshan Piusdbd83ef2017-06-20 12:05:40 -070042using namespace android::hardware::wifi::V1_0;
Roshan Piuse65edb12016-11-22 13:02:01 -080043
Roshan Piusf72df2e2016-12-04 10:49:38 -080044// Chip conversion methods.
45bool convertLegacyFeaturesToHidlChipCapabilities(
Roshan Piusabcf78f2017-10-06 16:30:38 -070046 uint32_t legacy_feature_set, uint32_t legacy_logger_feature_set,
Roshan Pius8184d212017-07-11 08:59:29 -070047 uint32_t* hidl_caps);
Roshan Pius48185b22016-12-15 19:10:30 -080048bool convertLegacyDebugRingBufferStatusToHidl(
49 const legacy_hal::wifi_ring_buffer_status& legacy_status,
50 WifiDebugRingBufferStatus* hidl_status);
Roshan Piusf72df2e2016-12-04 10:49:38 -080051bool convertLegacyVectorOfDebugRingBufferStatusToHidl(
52 const std::vector<legacy_hal::wifi_ring_buffer_status>& legacy_status_vec,
53 std::vector<WifiDebugRingBufferStatus>* hidl_status_vec);
54bool convertLegacyWakeReasonStatsToHidl(
55 const legacy_hal::WakeReasonStats& legacy_stats,
56 WifiDebugHostWakeReasonStats* hidl_stats);
Roshan Pius735ff432017-07-25 08:48:08 -070057legacy_hal::wifi_power_scenario convertHidlTxPowerScenarioToLegacy(
58 V1_1::IWifiChip::TxPowerScenario hidl_scenario);
Ahmed ElArabawy6a1accf2018-01-23 10:57:29 -080059legacy_hal::wifi_power_scenario convertHidlTxPowerScenarioToLegacy_1_2(
60 IWifiChip::TxPowerScenario hidl_scenario);
Roshan Pius1a7b1db2018-01-22 17:57:20 -080061bool convertLegacyWifiMacInfosToHidl(
62 const std::vector<legacy_hal::WifiMacInfo>& legacy_mac_infos,
63 std::vector<IWifiChipEventCallback::RadioModeInfo>* hidl_radio_mode_infos);
Roshan Piusf72df2e2016-12-04 10:49:38 -080064
Roshan Piusf5f51fd2016-12-01 13:54:24 -080065// STA iface conversion methods.
Roshan Piusf72df2e2016-12-04 10:49:38 -080066bool convertLegacyFeaturesToHidlStaCapabilities(
Roshan Piusabcf78f2017-10-06 16:30:38 -070067 uint32_t legacy_feature_set, uint32_t legacy_logger_feature_set,
Roshan Piusf72df2e2016-12-04 10:49:38 -080068 uint32_t* hidl_caps);
69bool convertLegacyApfCapabilitiesToHidl(
70 const legacy_hal::PacketFilterCapabilities& legacy_caps,
71 StaApfPacketFilterCapabilities* hidl_caps);
Roshan Pius881d1f72016-12-05 15:37:00 -080072bool convertLegacyGscanCapabilitiesToHidl(
Roshan Piusf72df2e2016-12-04 10:49:38 -080073 const legacy_hal::wifi_gscan_capabilities& legacy_caps,
74 StaBackgroundScanCapabilities* hidl_caps);
Roshan Pius7f4574d2017-02-22 09:48:03 -080075legacy_hal::wifi_band convertHidlWifiBandToLegacy(WifiBand band);
Roshan Pius881d1f72016-12-05 15:37:00 -080076bool convertHidlGscanParamsToLegacy(
Roshan Piuse65edb12016-11-22 13:02:01 -080077 const StaBackgroundScanParameters& hidl_scan_params,
78 legacy_hal::wifi_scan_cmd_params* legacy_scan_params);
Roshan Piuse65edb12016-11-22 13:02:01 -080079// |has_ie_data| indicates whether or not the wifi_scan_result includes 802.11
80// Information Elements (IEs)
Roshan Pius881d1f72016-12-05 15:37:00 -080081bool convertLegacyGscanResultToHidl(
Roshan Piusabcf78f2017-10-06 16:30:38 -070082 const legacy_hal::wifi_scan_result& legacy_scan_result, bool has_ie_data,
Roshan Piuse65edb12016-11-22 13:02:01 -080083 StaScanResult* hidl_scan_result);
84// |cached_results| is assumed to not include IEs.
Roshan Pius881d1f72016-12-05 15:37:00 -080085bool convertLegacyVectorOfCachedGscanResultsToHidl(
Roshan Piuse65edb12016-11-22 13:02:01 -080086 const std::vector<legacy_hal::wifi_cached_scan_results>&
87 legacy_cached_scan_results,
88 std::vector<StaScanData>* hidl_scan_datas);
89bool convertLegacyLinkLayerStatsToHidl(
90 const legacy_hal::LinkLayerStats& legacy_stats,
91 StaLinkLayerStats* hidl_stats);
Roshan Pius26801cb2016-12-13 14:25:45 -080092bool convertLegacyRoamingCapabilitiesToHidl(
93 const legacy_hal::wifi_roaming_capabilities& legacy_caps,
94 StaRoamingCapabilities* hidl_caps);
95bool convertHidlRoamingConfigToLegacy(
96 const StaRoamingConfig& hidl_config,
97 legacy_hal::wifi_roaming_config* legacy_config);
98legacy_hal::fw_roaming_state_t convertHidlRoamingStateToLegacy(
99 StaRoamingState state);
Roshan Piusf72df2e2016-12-04 10:49:38 -0800100bool convertLegacyVectorOfDebugTxPacketFateToHidl(
101 const std::vector<legacy_hal::wifi_tx_report>& legacy_fates,
102 std::vector<WifiDebugTxPacketFateReport>* hidl_fates);
103bool convertLegacyVectorOfDebugRxPacketFateToHidl(
104 const std::vector<legacy_hal::wifi_rx_report>& legacy_fates,
105 std::vector<WifiDebugRxPacketFateReport>* hidl_fates);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800106
107// NAN iface conversion methods.
Roshan Piusabcf78f2017-10-06 16:30:38 -0700108void convertToWifiNanStatus(legacy_hal::NanStatusType type, const char* str,
109 size_t max_len, WifiNanStatus* wifiNanStatus);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800110bool convertHidlNanEnableRequestToLegacy(
111 const NanEnableRequest& hidl_request,
112 legacy_hal::NanEnableRequest* legacy_request);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800113bool convertHidlNanConfigRequestToLegacy(
114 const NanConfigRequest& hidl_request,
115 legacy_hal::NanConfigRequest* legacy_request);
Etan Cohen9e7a4052017-12-21 13:45:26 -0800116bool convertHidlNanEnableRequest_1_2ToLegacy(
117 const NanEnableRequest& hidl_request1,
118 const NanConfigRequestSupplemental& hidl_request2,
119 legacy_hal::NanEnableRequest* legacy_request);
120bool convertHidlNanConfigRequest_1_2ToLegacy(
121 const NanConfigRequest& hidl_request1,
122 const NanConfigRequestSupplemental& hidl_request2,
123 legacy_hal::NanConfigRequest* legacy_request);
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800124bool convertHidlNanPublishRequestToLegacy(
125 const NanPublishRequest& hidl_request,
126 legacy_hal::NanPublishRequest* legacy_request);
127bool convertHidlNanSubscribeRequestToLegacy(
128 const NanSubscribeRequest& hidl_request,
129 legacy_hal::NanSubscribeRequest* legacy_request);
130bool convertHidlNanTransmitFollowupRequestToLegacy(
131 const NanTransmitFollowupRequest& hidl_request,
132 legacy_hal::NanTransmitFollowupRequest* legacy_request);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800133bool convertHidlNanDataPathInitiatorRequestToLegacy(
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800134 const NanInitiateDataPathRequest& hidl_request,
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800135 legacy_hal::NanDataPathInitiatorRequest* legacy_request);
136bool convertHidlNanDataPathIndicationResponseToLegacy(
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800137 const NanRespondToDataPathIndicationRequest& hidl_response,
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800138 legacy_hal::NanDataPathIndicationResponse* legacy_response);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800139bool convertLegacyNanResponseHeaderToHidl(
140 const legacy_hal::NanResponseMsg& legacy_response,
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800141 WifiNanStatus* wifiNanStatus);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800142bool convertLegacyNanCapabilitiesResponseToHidl(
143 const legacy_hal::NanCapabilities& legacy_response,
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800144 NanCapabilities* hidl_response);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800145bool convertLegacyNanMatchIndToHidl(const legacy_hal::NanMatchInd& legacy_ind,
146 NanMatchInd* hidl_ind);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800147bool convertLegacyNanFollowupIndToHidl(
Roshan Piusabcf78f2017-10-06 16:30:38 -0700148 const legacy_hal::NanFollowupInd& legacy_ind,
149 NanFollowupReceivedInd* hidl_ind);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800150bool convertLegacyNanDataPathRequestIndToHidl(
151 const legacy_hal::NanDataPathRequestInd& legacy_ind,
152 NanDataPathRequestInd* hidl_ind);
153bool convertLegacyNanDataPathConfirmIndToHidl(
154 const legacy_hal::NanDataPathConfirmInd& legacy_ind,
155 NanDataPathConfirmInd* hidl_ind);
Etan Cohenc7bd0f72017-12-26 11:52:44 -0800156bool convertLegacyNanDataPathScheduleUpdateIndToHidl(
157 const legacy_hal::NanDataPathScheduleUpdateInd& legacy_ind,
158 NanDataPathScheduleUpdateInd* hidl_ind);
Roshan Pius3fae9c82016-12-02 14:49:41 -0800159
160// RTT controller conversion methods.
Roshan Piuse3f72ff2016-12-05 16:18:43 -0800161bool convertHidlVectorOfRttConfigToLegacy(
162 const std::vector<RttConfig>& hidl_configs,
163 std::vector<legacy_hal::wifi_rtt_config>* legacy_configs);
Roshan Pius3fae9c82016-12-02 14:49:41 -0800164bool convertHidlRttLciInformationToLegacy(
165 const RttLciInformation& hidl_info,
166 legacy_hal::wifi_lci_information* legacy_info);
167bool convertHidlRttLcrInformationToLegacy(
168 const RttLcrInformation& hidl_info,
169 legacy_hal::wifi_lcr_information* legacy_info);
170bool convertHidlRttResponderToLegacy(
171 const RttResponder& hidl_responder,
172 legacy_hal::wifi_rtt_responder* legacy_responder);
Roshan Piuse3f72ff2016-12-05 16:18:43 -0800173bool convertHidlWifiChannelInfoToLegacy(
174 const WifiChannelInfo& hidl_info,
175 legacy_hal::wifi_channel_info* legacy_info);
Roshan Pius3fae9c82016-12-02 14:49:41 -0800176bool convertLegacyRttResponderToHidl(
177 const legacy_hal::wifi_rtt_responder& legacy_responder,
178 RttResponder* hidl_responder);
179bool convertLegacyRttCapabilitiesToHidl(
180 const legacy_hal::wifi_rtt_capabilities& legacy_capabilities,
181 RttCapabilities* hidl_capabilities);
Roshan Piuse3f72ff2016-12-05 16:18:43 -0800182bool convertLegacyVectorOfRttResultToHidl(
183 const std::vector<const legacy_hal::wifi_rtt_result*>& legacy_results,
184 std::vector<RttResult>* hidl_results);
Roshan Piuse65edb12016-11-22 13:02:01 -0800185} // namespace hidl_struct_util
186} // namespace implementation
Etan Cohen6ce50902017-09-14 07:30:57 -0700187} // namespace V1_2
Roshan Piuse65edb12016-11-22 13:02:01 -0800188} // namespace wifi
189} // namespace hardware
190} // namespace android
191
192#endif // HIDL_STRUCT_UTIL_H_