blob: 7a840f9b53a8de10a4edcb8fba975f1a5170af88 [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 Pius8184d212017-07-11 08:59:29 -070022#include <android/hardware/wifi/1.0/types.h>
Roshan Piuse65edb12016-11-22 13:02:01 -080023
24#include "wifi_legacy_hal.h"
25
26/**
27 * This file contains a bunch of functions to convert structs from the legacy
28 * HAL to HIDL and vice versa.
29 * TODO(b/32093047): Add unit tests for these conversion methods in the VTS test
30 * suite.
31 */
32namespace android {
33namespace hardware {
34namespace wifi {
Roshan Piusdbd83ef2017-06-20 12:05:40 -070035namespace V1_1 {
Roshan Piuse65edb12016-11-22 13:02:01 -080036namespace implementation {
37namespace hidl_struct_util {
Roshan Piusdbd83ef2017-06-20 12:05:40 -070038using namespace android::hardware::wifi::V1_0;
Roshan Piuse65edb12016-11-22 13:02:01 -080039
Roshan Piusf72df2e2016-12-04 10:49:38 -080040// Chip conversion methods.
41bool convertLegacyFeaturesToHidlChipCapabilities(
Roshan Pius8184d212017-07-11 08:59:29 -070042 uint32_t legacy_feature_set,
43 uint32_t legacy_logger_feature_set,
44 uint32_t* hidl_caps);
Roshan Pius48185b22016-12-15 19:10:30 -080045bool convertLegacyDebugRingBufferStatusToHidl(
46 const legacy_hal::wifi_ring_buffer_status& legacy_status,
47 WifiDebugRingBufferStatus* hidl_status);
Roshan Piusf72df2e2016-12-04 10:49:38 -080048bool convertLegacyVectorOfDebugRingBufferStatusToHidl(
49 const std::vector<legacy_hal::wifi_ring_buffer_status>& legacy_status_vec,
50 std::vector<WifiDebugRingBufferStatus>* hidl_status_vec);
51bool convertLegacyWakeReasonStatsToHidl(
52 const legacy_hal::WakeReasonStats& legacy_stats,
53 WifiDebugHostWakeReasonStats* hidl_stats);
54
Roshan Piusf5f51fd2016-12-01 13:54:24 -080055// STA iface conversion methods.
Roshan Piusf72df2e2016-12-04 10:49:38 -080056bool convertLegacyFeaturesToHidlStaCapabilities(
57 uint32_t legacy_feature_set,
58 uint32_t legacy_logger_feature_set,
59 uint32_t* hidl_caps);
60bool convertLegacyApfCapabilitiesToHidl(
61 const legacy_hal::PacketFilterCapabilities& legacy_caps,
62 StaApfPacketFilterCapabilities* hidl_caps);
Roshan Pius881d1f72016-12-05 15:37:00 -080063bool convertLegacyGscanCapabilitiesToHidl(
Roshan Piusf72df2e2016-12-04 10:49:38 -080064 const legacy_hal::wifi_gscan_capabilities& legacy_caps,
65 StaBackgroundScanCapabilities* hidl_caps);
Roshan Pius7f4574d2017-02-22 09:48:03 -080066legacy_hal::wifi_band convertHidlWifiBandToLegacy(WifiBand band);
Roshan Pius881d1f72016-12-05 15:37:00 -080067bool convertHidlGscanParamsToLegacy(
Roshan Piuse65edb12016-11-22 13:02:01 -080068 const StaBackgroundScanParameters& hidl_scan_params,
69 legacy_hal::wifi_scan_cmd_params* legacy_scan_params);
Roshan Piuse65edb12016-11-22 13:02:01 -080070// |has_ie_data| indicates whether or not the wifi_scan_result includes 802.11
71// Information Elements (IEs)
Roshan Pius881d1f72016-12-05 15:37:00 -080072bool convertLegacyGscanResultToHidl(
Roshan Piuse65edb12016-11-22 13:02:01 -080073 const legacy_hal::wifi_scan_result& legacy_scan_result,
74 bool has_ie_data,
75 StaScanResult* hidl_scan_result);
76// |cached_results| is assumed to not include IEs.
Roshan Pius881d1f72016-12-05 15:37:00 -080077bool convertLegacyVectorOfCachedGscanResultsToHidl(
Roshan Piuse65edb12016-11-22 13:02:01 -080078 const std::vector<legacy_hal::wifi_cached_scan_results>&
79 legacy_cached_scan_results,
80 std::vector<StaScanData>* hidl_scan_datas);
81bool convertLegacyLinkLayerStatsToHidl(
82 const legacy_hal::LinkLayerStats& legacy_stats,
83 StaLinkLayerStats* hidl_stats);
Roshan Pius26801cb2016-12-13 14:25:45 -080084bool convertLegacyRoamingCapabilitiesToHidl(
85 const legacy_hal::wifi_roaming_capabilities& legacy_caps,
86 StaRoamingCapabilities* hidl_caps);
87bool convertHidlRoamingConfigToLegacy(
88 const StaRoamingConfig& hidl_config,
89 legacy_hal::wifi_roaming_config* legacy_config);
90legacy_hal::fw_roaming_state_t convertHidlRoamingStateToLegacy(
91 StaRoamingState state);
Roshan Piusf72df2e2016-12-04 10:49:38 -080092bool convertLegacyVectorOfDebugTxPacketFateToHidl(
93 const std::vector<legacy_hal::wifi_tx_report>& legacy_fates,
94 std::vector<WifiDebugTxPacketFateReport>* hidl_fates);
95bool convertLegacyVectorOfDebugRxPacketFateToHidl(
96 const std::vector<legacy_hal::wifi_rx_report>& legacy_fates,
97 std::vector<WifiDebugRxPacketFateReport>* hidl_fates);
Roshan Piusf5f51fd2016-12-01 13:54:24 -080098
99// NAN iface conversion methods.
Etan Cohenbbc0f092017-04-26 16:52:34 -0700100void convertToWifiNanStatus(legacy_hal::NanStatusType type, const char* str, size_t max_len,
101 WifiNanStatus* wifiNanStatus);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800102bool convertHidlNanEnableRequestToLegacy(
103 const NanEnableRequest& hidl_request,
104 legacy_hal::NanEnableRequest* legacy_request);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800105bool convertHidlNanConfigRequestToLegacy(
106 const NanConfigRequest& hidl_request,
107 legacy_hal::NanConfigRequest* legacy_request);
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800108bool convertHidlNanPublishRequestToLegacy(
109 const NanPublishRequest& hidl_request,
110 legacy_hal::NanPublishRequest* legacy_request);
111bool convertHidlNanSubscribeRequestToLegacy(
112 const NanSubscribeRequest& hidl_request,
113 legacy_hal::NanSubscribeRequest* legacy_request);
114bool convertHidlNanTransmitFollowupRequestToLegacy(
115 const NanTransmitFollowupRequest& hidl_request,
116 legacy_hal::NanTransmitFollowupRequest* legacy_request);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800117bool convertHidlNanDataPathInitiatorRequestToLegacy(
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800118 const NanInitiateDataPathRequest& hidl_request,
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800119 legacy_hal::NanDataPathInitiatorRequest* legacy_request);
120bool convertHidlNanDataPathIndicationResponseToLegacy(
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800121 const NanRespondToDataPathIndicationRequest& hidl_response,
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800122 legacy_hal::NanDataPathIndicationResponse* legacy_response);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800123bool convertLegacyNanResponseHeaderToHidl(
124 const legacy_hal::NanResponseMsg& legacy_response,
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800125 WifiNanStatus* wifiNanStatus);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800126bool convertLegacyNanCapabilitiesResponseToHidl(
127 const legacy_hal::NanCapabilities& legacy_response,
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800128 NanCapabilities* hidl_response);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800129bool convertLegacyNanMatchIndToHidl(const legacy_hal::NanMatchInd& legacy_ind,
130 NanMatchInd* hidl_ind);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800131bool convertLegacyNanFollowupIndToHidl(
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800132 const legacy_hal::NanFollowupInd& legacy_ind, NanFollowupReceivedInd* hidl_ind);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800133bool convertLegacyNanDataPathRequestIndToHidl(
134 const legacy_hal::NanDataPathRequestInd& legacy_ind,
135 NanDataPathRequestInd* hidl_ind);
136bool convertLegacyNanDataPathConfirmIndToHidl(
137 const legacy_hal::NanDataPathConfirmInd& legacy_ind,
138 NanDataPathConfirmInd* hidl_ind);
Roshan Pius3fae9c82016-12-02 14:49:41 -0800139
140// RTT controller conversion methods.
Roshan Piuse3f72ff2016-12-05 16:18:43 -0800141bool convertHidlVectorOfRttConfigToLegacy(
142 const std::vector<RttConfig>& hidl_configs,
143 std::vector<legacy_hal::wifi_rtt_config>* legacy_configs);
Roshan Pius3fae9c82016-12-02 14:49:41 -0800144bool convertHidlRttLciInformationToLegacy(
145 const RttLciInformation& hidl_info,
146 legacy_hal::wifi_lci_information* legacy_info);
147bool convertHidlRttLcrInformationToLegacy(
148 const RttLcrInformation& hidl_info,
149 legacy_hal::wifi_lcr_information* legacy_info);
150bool convertHidlRttResponderToLegacy(
151 const RttResponder& hidl_responder,
152 legacy_hal::wifi_rtt_responder* legacy_responder);
Roshan Piuse3f72ff2016-12-05 16:18:43 -0800153bool convertHidlWifiChannelInfoToLegacy(
154 const WifiChannelInfo& hidl_info,
155 legacy_hal::wifi_channel_info* legacy_info);
Roshan Pius3fae9c82016-12-02 14:49:41 -0800156bool convertLegacyRttResponderToHidl(
157 const legacy_hal::wifi_rtt_responder& legacy_responder,
158 RttResponder* hidl_responder);
159bool convertLegacyRttCapabilitiesToHidl(
160 const legacy_hal::wifi_rtt_capabilities& legacy_capabilities,
161 RttCapabilities* hidl_capabilities);
Roshan Piuse3f72ff2016-12-05 16:18:43 -0800162bool convertLegacyVectorOfRttResultToHidl(
163 const std::vector<const legacy_hal::wifi_rtt_result*>& legacy_results,
164 std::vector<RttResult>* hidl_results);
Roshan Piuse65edb12016-11-22 13:02:01 -0800165} // namespace hidl_struct_util
166} // namespace implementation
Roshan Piusdbd83ef2017-06-20 12:05:40 -0700167} // namespace V1_1
Roshan Piuse65edb12016-11-22 13:02:01 -0800168} // namespace wifi
169} // namespace hardware
170} // namespace android
171
172#endif // HIDL_STRUCT_UTIL_H_