blob: 41e97b35904055bb6197ddeccaa7290eb153b451 [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
22#include <android/hardware/wifi/1.0/IWifi.h>
23
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 {
35namespace V1_0 {
36namespace implementation {
37namespace hidl_struct_util {
38
Roshan Piusf72df2e2016-12-04 10:49:38 -080039// Chip conversion methods.
40bool convertLegacyFeaturesToHidlChipCapabilities(
41 uint32_t legacy_logger_feature_set, uint32_t* hidl_caps);
Roshan Pius48185b22016-12-15 19:10:30 -080042bool convertLegacyDebugRingBufferStatusToHidl(
43 const legacy_hal::wifi_ring_buffer_status& legacy_status,
44 WifiDebugRingBufferStatus* hidl_status);
Roshan Piusf72df2e2016-12-04 10:49:38 -080045bool convertLegacyVectorOfDebugRingBufferStatusToHidl(
46 const std::vector<legacy_hal::wifi_ring_buffer_status>& legacy_status_vec,
47 std::vector<WifiDebugRingBufferStatus>* hidl_status_vec);
48bool convertLegacyWakeReasonStatsToHidl(
49 const legacy_hal::WakeReasonStats& legacy_stats,
50 WifiDebugHostWakeReasonStats* hidl_stats);
51
Roshan Piusf5f51fd2016-12-01 13:54:24 -080052// STA iface conversion methods.
Roshan Piusf72df2e2016-12-04 10:49:38 -080053bool convertLegacyFeaturesToHidlStaCapabilities(
54 uint32_t legacy_feature_set,
55 uint32_t legacy_logger_feature_set,
56 uint32_t* hidl_caps);
57bool convertLegacyApfCapabilitiesToHidl(
58 const legacy_hal::PacketFilterCapabilities& legacy_caps,
59 StaApfPacketFilterCapabilities* hidl_caps);
Roshan Pius881d1f72016-12-05 15:37:00 -080060bool convertLegacyGscanCapabilitiesToHidl(
Roshan Piusf72df2e2016-12-04 10:49:38 -080061 const legacy_hal::wifi_gscan_capabilities& legacy_caps,
62 StaBackgroundScanCapabilities* hidl_caps);
Roshan Pius7f4574d2017-02-22 09:48:03 -080063legacy_hal::wifi_band convertHidlWifiBandToLegacy(WifiBand band);
Roshan Pius881d1f72016-12-05 15:37:00 -080064bool convertHidlGscanParamsToLegacy(
Roshan Piuse65edb12016-11-22 13:02:01 -080065 const StaBackgroundScanParameters& hidl_scan_params,
66 legacy_hal::wifi_scan_cmd_params* legacy_scan_params);
Roshan Piuse65edb12016-11-22 13:02:01 -080067// |has_ie_data| indicates whether or not the wifi_scan_result includes 802.11
68// Information Elements (IEs)
Roshan Pius881d1f72016-12-05 15:37:00 -080069bool convertLegacyGscanResultToHidl(
Roshan Piuse65edb12016-11-22 13:02:01 -080070 const legacy_hal::wifi_scan_result& legacy_scan_result,
71 bool has_ie_data,
72 StaScanResult* hidl_scan_result);
73// |cached_results| is assumed to not include IEs.
Roshan Pius881d1f72016-12-05 15:37:00 -080074bool convertLegacyVectorOfCachedGscanResultsToHidl(
Roshan Piuse65edb12016-11-22 13:02:01 -080075 const std::vector<legacy_hal::wifi_cached_scan_results>&
76 legacy_cached_scan_results,
77 std::vector<StaScanData>* hidl_scan_datas);
78bool convertLegacyLinkLayerStatsToHidl(
79 const legacy_hal::LinkLayerStats& legacy_stats,
80 StaLinkLayerStats* hidl_stats);
Roshan Pius26801cb2016-12-13 14:25:45 -080081bool convertLegacyRoamingCapabilitiesToHidl(
82 const legacy_hal::wifi_roaming_capabilities& legacy_caps,
83 StaRoamingCapabilities* hidl_caps);
84bool convertHidlRoamingConfigToLegacy(
85 const StaRoamingConfig& hidl_config,
86 legacy_hal::wifi_roaming_config* legacy_config);
87legacy_hal::fw_roaming_state_t convertHidlRoamingStateToLegacy(
88 StaRoamingState state);
Roshan Piusf72df2e2016-12-04 10:49:38 -080089bool convertLegacyVectorOfDebugTxPacketFateToHidl(
90 const std::vector<legacy_hal::wifi_tx_report>& legacy_fates,
91 std::vector<WifiDebugTxPacketFateReport>* hidl_fates);
92bool convertLegacyVectorOfDebugRxPacketFateToHidl(
93 const std::vector<legacy_hal::wifi_rx_report>& legacy_fates,
94 std::vector<WifiDebugRxPacketFateReport>* hidl_fates);
Roshan Piusf5f51fd2016-12-01 13:54:24 -080095
96// NAN iface conversion methods.
Etan Cohenf01bcaa2016-12-25 09:42:21 -080097NanStatusType convertLegacyNanStatusTypeToHidl(legacy_hal::NanStatusType type);
Roshan Piusf5f51fd2016-12-01 13:54:24 -080098bool convertHidlNanEnableRequestToLegacy(
99 const NanEnableRequest& hidl_request,
100 legacy_hal::NanEnableRequest* legacy_request);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800101bool convertHidlNanConfigRequestToLegacy(
102 const NanConfigRequest& hidl_request,
103 legacy_hal::NanConfigRequest* legacy_request);
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800104bool convertHidlNanPublishRequestToLegacy(
105 const NanPublishRequest& hidl_request,
106 legacy_hal::NanPublishRequest* legacy_request);
107bool convertHidlNanSubscribeRequestToLegacy(
108 const NanSubscribeRequest& hidl_request,
109 legacy_hal::NanSubscribeRequest* legacy_request);
110bool convertHidlNanTransmitFollowupRequestToLegacy(
111 const NanTransmitFollowupRequest& hidl_request,
112 legacy_hal::NanTransmitFollowupRequest* legacy_request);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800113bool convertHidlNanDataPathInitiatorRequestToLegacy(
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800114 const NanInitiateDataPathRequest& hidl_request,
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800115 legacy_hal::NanDataPathInitiatorRequest* legacy_request);
116bool convertHidlNanDataPathIndicationResponseToLegacy(
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800117 const NanRespondToDataPathIndicationRequest& hidl_response,
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800118 legacy_hal::NanDataPathIndicationResponse* legacy_response);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800119bool convertLegacyNanResponseHeaderToHidl(
120 const legacy_hal::NanResponseMsg& legacy_response,
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800121 WifiNanStatus* wifiNanStatus);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800122bool convertLegacyNanCapabilitiesResponseToHidl(
123 const legacy_hal::NanCapabilities& legacy_response,
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800124 NanCapabilities* hidl_response);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800125bool convertLegacyNanMatchIndToHidl(const legacy_hal::NanMatchInd& legacy_ind,
126 NanMatchInd* hidl_ind);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800127bool convertLegacyNanFollowupIndToHidl(
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800128 const legacy_hal::NanFollowupInd& legacy_ind, NanFollowupReceivedInd* hidl_ind);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800129bool convertLegacyNanDataPathRequestIndToHidl(
130 const legacy_hal::NanDataPathRequestInd& legacy_ind,
131 NanDataPathRequestInd* hidl_ind);
132bool convertLegacyNanDataPathConfirmIndToHidl(
133 const legacy_hal::NanDataPathConfirmInd& legacy_ind,
134 NanDataPathConfirmInd* hidl_ind);
Roshan Pius3fae9c82016-12-02 14:49:41 -0800135
136// RTT controller conversion methods.
Roshan Piuse3f72ff2016-12-05 16:18:43 -0800137bool convertHidlVectorOfRttConfigToLegacy(
138 const std::vector<RttConfig>& hidl_configs,
139 std::vector<legacy_hal::wifi_rtt_config>* legacy_configs);
Roshan Pius3fae9c82016-12-02 14:49:41 -0800140bool convertHidlRttLciInformationToLegacy(
141 const RttLciInformation& hidl_info,
142 legacy_hal::wifi_lci_information* legacy_info);
143bool convertHidlRttLcrInformationToLegacy(
144 const RttLcrInformation& hidl_info,
145 legacy_hal::wifi_lcr_information* legacy_info);
146bool convertHidlRttResponderToLegacy(
147 const RttResponder& hidl_responder,
148 legacy_hal::wifi_rtt_responder* legacy_responder);
Roshan Piuse3f72ff2016-12-05 16:18:43 -0800149bool convertHidlWifiChannelInfoToLegacy(
150 const WifiChannelInfo& hidl_info,
151 legacy_hal::wifi_channel_info* legacy_info);
Roshan Pius3fae9c82016-12-02 14:49:41 -0800152bool convertLegacyRttResponderToHidl(
153 const legacy_hal::wifi_rtt_responder& legacy_responder,
154 RttResponder* hidl_responder);
155bool convertLegacyRttCapabilitiesToHidl(
156 const legacy_hal::wifi_rtt_capabilities& legacy_capabilities,
157 RttCapabilities* hidl_capabilities);
Roshan Piuse3f72ff2016-12-05 16:18:43 -0800158bool convertLegacyVectorOfRttResultToHidl(
159 const std::vector<const legacy_hal::wifi_rtt_result*>& legacy_results,
160 std::vector<RttResult>* hidl_results);
Roshan Piuse65edb12016-11-22 13:02:01 -0800161} // namespace hidl_struct_util
162} // namespace implementation
163} // namespace V1_0
164} // namespace wifi
165} // namespace hardware
166} // namespace android
167
168#endif // HIDL_STRUCT_UTIL_H_