blob: 8df484d0639de0063deefb78f35ecccc6b44f442 [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>
xshue9873252018-08-07 11:04:34 -070027#include <android/hardware/wifi/1.3/types.h>
Roshan Piuse65edb12016-11-22 13:02:01 -080028
29#include "wifi_legacy_hal.h"
30
31/**
32 * This file contains a bunch of functions to convert structs from the legacy
33 * HAL to HIDL and vice versa.
34 * TODO(b/32093047): Add unit tests for these conversion methods in the VTS test
35 * suite.
36 */
37namespace android {
38namespace hardware {
39namespace wifi {
Jong Wook Kimda830c92018-07-23 15:29:38 -070040namespace V1_3 {
Roshan Piuse65edb12016-11-22 13:02:01 -080041namespace implementation {
42namespace hidl_struct_util {
Roshan Piusdbd83ef2017-06-20 12:05:40 -070043using namespace android::hardware::wifi::V1_0;
Roshan Piuse65edb12016-11-22 13:02:01 -080044
Roshan Piusf72df2e2016-12-04 10:49:38 -080045// Chip conversion methods.
46bool convertLegacyFeaturesToHidlChipCapabilities(
Roshan Piusabcf78f2017-10-06 16:30:38 -070047 uint32_t legacy_feature_set, uint32_t legacy_logger_feature_set,
Roshan Pius8184d212017-07-11 08:59:29 -070048 uint32_t* hidl_caps);
Roshan Pius48185b22016-12-15 19:10:30 -080049bool convertLegacyDebugRingBufferStatusToHidl(
50 const legacy_hal::wifi_ring_buffer_status& legacy_status,
51 WifiDebugRingBufferStatus* hidl_status);
Roshan Piusf72df2e2016-12-04 10:49:38 -080052bool convertLegacyVectorOfDebugRingBufferStatusToHidl(
53 const std::vector<legacy_hal::wifi_ring_buffer_status>& legacy_status_vec,
54 std::vector<WifiDebugRingBufferStatus>* hidl_status_vec);
55bool convertLegacyWakeReasonStatsToHidl(
56 const legacy_hal::WakeReasonStats& legacy_stats,
57 WifiDebugHostWakeReasonStats* hidl_stats);
Roshan Pius735ff432017-07-25 08:48:08 -070058legacy_hal::wifi_power_scenario convertHidlTxPowerScenarioToLegacy(
59 V1_1::IWifiChip::TxPowerScenario hidl_scenario);
Ahmed ElArabawy6a1accf2018-01-23 10:57:29 -080060legacy_hal::wifi_power_scenario convertHidlTxPowerScenarioToLegacy_1_2(
Jong Wook Kimda830c92018-07-23 15:29:38 -070061 V1_2::IWifiChip::TxPowerScenario hidl_scenario);
Roshan Pius1a7b1db2018-01-22 17:57:20 -080062bool convertLegacyWifiMacInfosToHidl(
63 const std::vector<legacy_hal::WifiMacInfo>& legacy_mac_infos,
Jong Wook Kimda830c92018-07-23 15:29:38 -070064 std::vector<V1_2::IWifiChipEventCallback::RadioModeInfo>*
65 hidl_radio_mode_infos);
Roshan Piusf72df2e2016-12-04 10:49:38 -080066
Roshan Piusf5f51fd2016-12-01 13:54:24 -080067// STA iface conversion methods.
Roshan Piusf72df2e2016-12-04 10:49:38 -080068bool convertLegacyFeaturesToHidlStaCapabilities(
Roshan Piusabcf78f2017-10-06 16:30:38 -070069 uint32_t legacy_feature_set, uint32_t legacy_logger_feature_set,
Roshan Piusf72df2e2016-12-04 10:49:38 -080070 uint32_t* hidl_caps);
71bool convertLegacyApfCapabilitiesToHidl(
72 const legacy_hal::PacketFilterCapabilities& legacy_caps,
73 StaApfPacketFilterCapabilities* hidl_caps);
Roshan Pius881d1f72016-12-05 15:37:00 -080074bool convertLegacyGscanCapabilitiesToHidl(
Roshan Piusf72df2e2016-12-04 10:49:38 -080075 const legacy_hal::wifi_gscan_capabilities& legacy_caps,
76 StaBackgroundScanCapabilities* hidl_caps);
Roshan Pius7f4574d2017-02-22 09:48:03 -080077legacy_hal::wifi_band convertHidlWifiBandToLegacy(WifiBand band);
Roshan Pius881d1f72016-12-05 15:37:00 -080078bool convertHidlGscanParamsToLegacy(
Roshan Piuse65edb12016-11-22 13:02:01 -080079 const StaBackgroundScanParameters& hidl_scan_params,
80 legacy_hal::wifi_scan_cmd_params* legacy_scan_params);
Roshan Piuse65edb12016-11-22 13:02:01 -080081// |has_ie_data| indicates whether or not the wifi_scan_result includes 802.11
82// Information Elements (IEs)
Roshan Pius881d1f72016-12-05 15:37:00 -080083bool convertLegacyGscanResultToHidl(
Roshan Piusabcf78f2017-10-06 16:30:38 -070084 const legacy_hal::wifi_scan_result& legacy_scan_result, bool has_ie_data,
Roshan Piuse65edb12016-11-22 13:02:01 -080085 StaScanResult* hidl_scan_result);
86// |cached_results| is assumed to not include IEs.
Roshan Pius881d1f72016-12-05 15:37:00 -080087bool convertLegacyVectorOfCachedGscanResultsToHidl(
Roshan Piuse65edb12016-11-22 13:02:01 -080088 const std::vector<legacy_hal::wifi_cached_scan_results>&
89 legacy_cached_scan_results,
90 std::vector<StaScanData>* hidl_scan_datas);
91bool convertLegacyLinkLayerStatsToHidl(
92 const legacy_hal::LinkLayerStats& legacy_stats,
xshue9873252018-08-07 11:04:34 -070093 V1_3::StaLinkLayerStats* hidl_stats);
Roshan Pius26801cb2016-12-13 14:25:45 -080094bool convertLegacyRoamingCapabilitiesToHidl(
95 const legacy_hal::wifi_roaming_capabilities& legacy_caps,
96 StaRoamingCapabilities* hidl_caps);
97bool convertHidlRoamingConfigToLegacy(
98 const StaRoamingConfig& hidl_config,
99 legacy_hal::wifi_roaming_config* legacy_config);
100legacy_hal::fw_roaming_state_t convertHidlRoamingStateToLegacy(
101 StaRoamingState state);
Roshan Piusf72df2e2016-12-04 10:49:38 -0800102bool convertLegacyVectorOfDebugTxPacketFateToHidl(
103 const std::vector<legacy_hal::wifi_tx_report>& legacy_fates,
104 std::vector<WifiDebugTxPacketFateReport>* hidl_fates);
105bool convertLegacyVectorOfDebugRxPacketFateToHidl(
106 const std::vector<legacy_hal::wifi_rx_report>& legacy_fates,
107 std::vector<WifiDebugRxPacketFateReport>* hidl_fates);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800108
109// NAN iface conversion methods.
Roshan Piusabcf78f2017-10-06 16:30:38 -0700110void convertToWifiNanStatus(legacy_hal::NanStatusType type, const char* str,
111 size_t max_len, WifiNanStatus* wifiNanStatus);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800112bool convertHidlNanEnableRequestToLegacy(
113 const NanEnableRequest& hidl_request,
114 legacy_hal::NanEnableRequest* legacy_request);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800115bool convertHidlNanConfigRequestToLegacy(
116 const NanConfigRequest& hidl_request,
117 legacy_hal::NanConfigRequest* legacy_request);
Etan Cohen9e7a4052017-12-21 13:45:26 -0800118bool convertHidlNanEnableRequest_1_2ToLegacy(
119 const NanEnableRequest& hidl_request1,
Jong Wook Kimda830c92018-07-23 15:29:38 -0700120 const V1_2::NanConfigRequestSupplemental& hidl_request2,
Etan Cohen9e7a4052017-12-21 13:45:26 -0800121 legacy_hal::NanEnableRequest* legacy_request);
122bool convertHidlNanConfigRequest_1_2ToLegacy(
123 const NanConfigRequest& hidl_request1,
Jong Wook Kimda830c92018-07-23 15:29:38 -0700124 const V1_2::NanConfigRequestSupplemental& hidl_request2,
Etan Cohen9e7a4052017-12-21 13:45:26 -0800125 legacy_hal::NanConfigRequest* legacy_request);
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800126bool convertHidlNanPublishRequestToLegacy(
127 const NanPublishRequest& hidl_request,
128 legacy_hal::NanPublishRequest* legacy_request);
129bool convertHidlNanSubscribeRequestToLegacy(
130 const NanSubscribeRequest& hidl_request,
131 legacy_hal::NanSubscribeRequest* legacy_request);
132bool convertHidlNanTransmitFollowupRequestToLegacy(
133 const NanTransmitFollowupRequest& hidl_request,
134 legacy_hal::NanTransmitFollowupRequest* legacy_request);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800135bool convertHidlNanDataPathInitiatorRequestToLegacy(
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800136 const NanInitiateDataPathRequest& hidl_request,
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800137 legacy_hal::NanDataPathInitiatorRequest* legacy_request);
138bool convertHidlNanDataPathIndicationResponseToLegacy(
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800139 const NanRespondToDataPathIndicationRequest& hidl_response,
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800140 legacy_hal::NanDataPathIndicationResponse* legacy_response);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800141bool convertLegacyNanResponseHeaderToHidl(
142 const legacy_hal::NanResponseMsg& legacy_response,
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800143 WifiNanStatus* wifiNanStatus);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800144bool convertLegacyNanCapabilitiesResponseToHidl(
145 const legacy_hal::NanCapabilities& legacy_response,
Etan Cohenf01bcaa2016-12-25 09:42:21 -0800146 NanCapabilities* hidl_response);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800147bool convertLegacyNanMatchIndToHidl(const legacy_hal::NanMatchInd& legacy_ind,
148 NanMatchInd* hidl_ind);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800149bool convertLegacyNanFollowupIndToHidl(
Roshan Piusabcf78f2017-10-06 16:30:38 -0700150 const legacy_hal::NanFollowupInd& legacy_ind,
151 NanFollowupReceivedInd* hidl_ind);
Roshan Piusf5f51fd2016-12-01 13:54:24 -0800152bool convertLegacyNanDataPathRequestIndToHidl(
153 const legacy_hal::NanDataPathRequestInd& legacy_ind,
154 NanDataPathRequestInd* hidl_ind);
155bool convertLegacyNanDataPathConfirmIndToHidl(
156 const legacy_hal::NanDataPathConfirmInd& legacy_ind,
Jong Wook Kimda830c92018-07-23 15:29:38 -0700157 V1_2::NanDataPathConfirmInd* hidl_ind);
Etan Cohenc7bd0f72017-12-26 11:52:44 -0800158bool convertLegacyNanDataPathScheduleUpdateIndToHidl(
159 const legacy_hal::NanDataPathScheduleUpdateInd& legacy_ind,
Jong Wook Kimda830c92018-07-23 15:29:38 -0700160 V1_2::NanDataPathScheduleUpdateInd* hidl_ind);
Roshan Pius3fae9c82016-12-02 14:49:41 -0800161
162// RTT controller conversion methods.
Roshan Piuse3f72ff2016-12-05 16:18:43 -0800163bool convertHidlVectorOfRttConfigToLegacy(
164 const std::vector<RttConfig>& hidl_configs,
165 std::vector<legacy_hal::wifi_rtt_config>* legacy_configs);
Roshan Pius3fae9c82016-12-02 14:49:41 -0800166bool convertHidlRttLciInformationToLegacy(
167 const RttLciInformation& hidl_info,
168 legacy_hal::wifi_lci_information* legacy_info);
169bool convertHidlRttLcrInformationToLegacy(
170 const RttLcrInformation& hidl_info,
171 legacy_hal::wifi_lcr_information* legacy_info);
172bool convertHidlRttResponderToLegacy(
173 const RttResponder& hidl_responder,
174 legacy_hal::wifi_rtt_responder* legacy_responder);
Roshan Piuse3f72ff2016-12-05 16:18:43 -0800175bool convertHidlWifiChannelInfoToLegacy(
176 const WifiChannelInfo& hidl_info,
177 legacy_hal::wifi_channel_info* legacy_info);
Roshan Pius3fae9c82016-12-02 14:49:41 -0800178bool convertLegacyRttResponderToHidl(
179 const legacy_hal::wifi_rtt_responder& legacy_responder,
180 RttResponder* hidl_responder);
181bool convertLegacyRttCapabilitiesToHidl(
182 const legacy_hal::wifi_rtt_capabilities& legacy_capabilities,
183 RttCapabilities* hidl_capabilities);
Roshan Piuse3f72ff2016-12-05 16:18:43 -0800184bool convertLegacyVectorOfRttResultToHidl(
185 const std::vector<const legacy_hal::wifi_rtt_result*>& legacy_results,
186 std::vector<RttResult>* hidl_results);
Roshan Piuse65edb12016-11-22 13:02:01 -0800187} // namespace hidl_struct_util
188} // namespace implementation
Jong Wook Kimda830c92018-07-23 15:29:38 -0700189} // namespace V1_3
Roshan Piuse65edb12016-11-22 13:02:01 -0800190} // namespace wifi
191} // namespace hardware
192} // namespace android
193
194#endif // HIDL_STRUCT_UTIL_H_