blob: 6766b0fd2bbbb6af5bf4c101154b051d3ffd602f [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>
Roshan Pius735ff432017-07-25 08:48:08 -070024#include <android/hardware/wifi/1.1/IWifiChip.h>
Roshan Piuse65edb12016-11-22 13:02:01 -080025
26#include "wifi_legacy_hal.h"
27
28/**
29 * This file contains a bunch of functions to convert structs from the legacy
30 * HAL to HIDL and vice versa.
31 * TODO(b/32093047): Add unit tests for these conversion methods in the VTS test
32 * suite.
33 */
34namespace android {
35namespace hardware {
36namespace wifi {
Etan Cohen6ce50902017-09-14 07:30:57 -070037namespace V1_2 {
Roshan Piuse65edb12016-11-22 13:02:01 -080038namespace implementation {
39namespace hidl_struct_util {
Roshan Piusdbd83ef2017-06-20 12:05:40 -070040using namespace android::hardware::wifi::V1_0;
Roshan Piuse65edb12016-11-22 13:02:01 -080041
Roshan Piusf72df2e2016-12-04 10:49:38 -080042// Chip conversion methods.
43bool convertLegacyFeaturesToHidlChipCapabilities(
Roshan Piusabcf78f2017-10-06 16:30:38 -070044 uint32_t legacy_feature_set, uint32_t legacy_logger_feature_set,
Roshan Pius8184d212017-07-11 08:59:29 -070045 uint32_t* hidl_caps);
Roshan Pius48185b22016-12-15 19:10:30 -080046bool convertLegacyDebugRingBufferStatusToHidl(
47 const legacy_hal::wifi_ring_buffer_status& legacy_status,
48 WifiDebugRingBufferStatus* hidl_status);
Roshan Piusf72df2e2016-12-04 10:49:38 -080049bool convertLegacyVectorOfDebugRingBufferStatusToHidl(
50 const std::vector<legacy_hal::wifi_ring_buffer_status>& legacy_status_vec,
51 std::vector<WifiDebugRingBufferStatus>* hidl_status_vec);
52bool convertLegacyWakeReasonStatsToHidl(
53 const legacy_hal::WakeReasonStats& legacy_stats,
54 WifiDebugHostWakeReasonStats* hidl_stats);
Roshan Pius735ff432017-07-25 08:48:08 -070055legacy_hal::wifi_power_scenario convertHidlTxPowerScenarioToLegacy(
56 V1_1::IWifiChip::TxPowerScenario hidl_scenario);
Roshan Piusf72df2e2016-12-04 10:49:38 -080057
Roshan Piusf5f51fd2016-12-01 13:54:24 -080058// STA iface conversion methods.
Roshan Piusf72df2e2016-12-04 10:49:38 -080059bool convertLegacyFeaturesToHidlStaCapabilities(
Roshan Piusabcf78f2017-10-06 16:30:38 -070060 uint32_t legacy_feature_set, uint32_t legacy_logger_feature_set,
Roshan Piusf72df2e2016-12-04 10:49:38 -080061 uint32_t* hidl_caps);
62bool convertLegacyApfCapabilitiesToHidl(
63 const legacy_hal::PacketFilterCapabilities& legacy_caps,
64 StaApfPacketFilterCapabilities* hidl_caps);
Roshan Pius881d1f72016-12-05 15:37:00 -080065bool convertLegacyGscanCapabilitiesToHidl(
Roshan Piusf72df2e2016-12-04 10:49:38 -080066 const legacy_hal::wifi_gscan_capabilities& legacy_caps,
67 StaBackgroundScanCapabilities* hidl_caps);
Roshan Pius7f4574d2017-02-22 09:48:03 -080068legacy_hal::wifi_band convertHidlWifiBandToLegacy(WifiBand band);
Roshan Pius881d1f72016-12-05 15:37:00 -080069bool convertHidlGscanParamsToLegacy(
Roshan Piuse65edb12016-11-22 13:02:01 -080070 const StaBackgroundScanParameters& hidl_scan_params,
71 legacy_hal::wifi_scan_cmd_params* legacy_scan_params);
Roshan Piuse65edb12016-11-22 13:02:01 -080072// |has_ie_data| indicates whether or not the wifi_scan_result includes 802.11
73// Information Elements (IEs)
Roshan Pius881d1f72016-12-05 15:37:00 -080074bool convertLegacyGscanResultToHidl(
Roshan Piusabcf78f2017-10-06 16:30:38 -070075 const legacy_hal::wifi_scan_result& legacy_scan_result, bool has_ie_data,
Roshan Piuse65edb12016-11-22 13:02:01 -080076 StaScanResult* hidl_scan_result);
77// |cached_results| is assumed to not include IEs.
Roshan Pius881d1f72016-12-05 15:37:00 -080078bool convertLegacyVectorOfCachedGscanResultsToHidl(
Roshan Piuse65edb12016-11-22 13:02:01 -080079 const std::vector<legacy_hal::wifi_cached_scan_results>&
80 legacy_cached_scan_results,
81 std::vector<StaScanData>* hidl_scan_datas);
82bool convertLegacyLinkLayerStatsToHidl(
83 const legacy_hal::LinkLayerStats& legacy_stats,
84 StaLinkLayerStats* hidl_stats);
Roshan Pius26801cb2016-12-13 14:25:45 -080085bool convertLegacyRoamingCapabilitiesToHidl(
86 const legacy_hal::wifi_roaming_capabilities& legacy_caps,
87 StaRoamingCapabilities* hidl_caps);
88bool convertHidlRoamingConfigToLegacy(
89 const StaRoamingConfig& hidl_config,
90 legacy_hal::wifi_roaming_config* legacy_config);
91legacy_hal::fw_roaming_state_t convertHidlRoamingStateToLegacy(
92 StaRoamingState state);
Roshan Piusf72df2e2016-12-04 10:49:38 -080093bool convertLegacyVectorOfDebugTxPacketFateToHidl(
94 const std::vector<legacy_hal::wifi_tx_report>& legacy_fates,
95 std::vector<WifiDebugTxPacketFateReport>* hidl_fates);
96bool convertLegacyVectorOfDebugRxPacketFateToHidl(
97 const std::vector<legacy_hal::wifi_rx_report>& legacy_fates,
98 std::vector<WifiDebugRxPacketFateReport>* hidl_fates);
Roshan Piusf5f51fd2016-12-01 13:54:24 -080099
100// NAN iface conversion methods.
Roshan Piusabcf78f2017-10-06 16:30:38 -0700101void convertToWifiNanStatus(legacy_hal::NanStatusType type, const char* str,
102 size_t max_len, WifiNanStatus* wifiNanStatus);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800103bool convertHidlNanEnableRequestToLegacy(
104 const NanEnableRequest& hidl_request,
105 legacy_hal::NanEnableRequest* legacy_request);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800106bool convertHidlNanConfigRequestToLegacy(
107 const NanConfigRequest& hidl_request,
108 legacy_hal::NanConfigRequest* legacy_request);
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800109bool convertHidlNanPublishRequestToLegacy(
110 const NanPublishRequest& hidl_request,
111 legacy_hal::NanPublishRequest* legacy_request);
112bool convertHidlNanSubscribeRequestToLegacy(
113 const NanSubscribeRequest& hidl_request,
114 legacy_hal::NanSubscribeRequest* legacy_request);
115bool convertHidlNanTransmitFollowupRequestToLegacy(
116 const NanTransmitFollowupRequest& hidl_request,
117 legacy_hal::NanTransmitFollowupRequest* legacy_request);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800118bool convertHidlNanDataPathInitiatorRequestToLegacy(
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800119 const NanInitiateDataPathRequest& hidl_request,
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800120 legacy_hal::NanDataPathInitiatorRequest* legacy_request);
121bool convertHidlNanDataPathIndicationResponseToLegacy(
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800122 const NanRespondToDataPathIndicationRequest& hidl_response,
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800123 legacy_hal::NanDataPathIndicationResponse* legacy_response);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800124bool convertLegacyNanResponseHeaderToHidl(
125 const legacy_hal::NanResponseMsg& legacy_response,
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800126 WifiNanStatus* wifiNanStatus);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800127bool convertLegacyNanCapabilitiesResponseToHidl(
128 const legacy_hal::NanCapabilities& legacy_response,
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800129 NanCapabilities* hidl_response);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800130bool convertLegacyNanMatchIndToHidl(const legacy_hal::NanMatchInd& legacy_ind,
131 NanMatchInd* hidl_ind);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800132bool convertLegacyNanFollowupIndToHidl(
Roshan Piusabcf78f2017-10-06 16:30:38 -0700133 const legacy_hal::NanFollowupInd& legacy_ind,
134 NanFollowupReceivedInd* hidl_ind);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800135bool convertLegacyNanDataPathRequestIndToHidl(
136 const legacy_hal::NanDataPathRequestInd& legacy_ind,
137 NanDataPathRequestInd* hidl_ind);
138bool convertLegacyNanDataPathConfirmIndToHidl(
139 const legacy_hal::NanDataPathConfirmInd& legacy_ind,
140 NanDataPathConfirmInd* hidl_ind);
Roshan Pius3fae9c82016-12-02 14:49:41 -0800141
142// RTT controller conversion methods.
Roshan Piuse3f72ff2016-12-05 16:18:43 -0800143bool convertHidlVectorOfRttConfigToLegacy(
144 const std::vector<RttConfig>& hidl_configs,
145 std::vector<legacy_hal::wifi_rtt_config>* legacy_configs);
Roshan Pius3fae9c82016-12-02 14:49:41 -0800146bool convertHidlRttLciInformationToLegacy(
147 const RttLciInformation& hidl_info,
148 legacy_hal::wifi_lci_information* legacy_info);
149bool convertHidlRttLcrInformationToLegacy(
150 const RttLcrInformation& hidl_info,
151 legacy_hal::wifi_lcr_information* legacy_info);
152bool convertHidlRttResponderToLegacy(
153 const RttResponder& hidl_responder,
154 legacy_hal::wifi_rtt_responder* legacy_responder);
Roshan Piuse3f72ff2016-12-05 16:18:43 -0800155bool convertHidlWifiChannelInfoToLegacy(
156 const WifiChannelInfo& hidl_info,
157 legacy_hal::wifi_channel_info* legacy_info);
Roshan Pius3fae9c82016-12-02 14:49:41 -0800158bool convertLegacyRttResponderToHidl(
159 const legacy_hal::wifi_rtt_responder& legacy_responder,
160 RttResponder* hidl_responder);
161bool convertLegacyRttCapabilitiesToHidl(
162 const legacy_hal::wifi_rtt_capabilities& legacy_capabilities,
163 RttCapabilities* hidl_capabilities);
Roshan Piuse3f72ff2016-12-05 16:18:43 -0800164bool convertLegacyVectorOfRttResultToHidl(
165 const std::vector<const legacy_hal::wifi_rtt_result*>& legacy_results,
166 std::vector<RttResult>* hidl_results);
Roshan Piuse65edb12016-11-22 13:02:01 -0800167} // namespace hidl_struct_util
168} // namespace implementation
Etan Cohen6ce50902017-09-14 07:30:57 -0700169} // namespace V1_2
Roshan Piuse65edb12016-11-22 13:02:01 -0800170} // namespace wifi
171} // namespace hardware
172} // namespace android
173
174#endif // HIDL_STRUCT_UTIL_H_