blob: 26a6ebc85e868ad8077a16b1fcab0852087036f1 [file] [log] [blame]
Ahmed ElArabawy687ce132022-01-11 16:42:48 -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/IWifiChip.h>
23#include <android/hardware/wifi/1.0/types.h>
24#include <android/hardware/wifi/1.2/types.h>
25#include <android/hardware/wifi/1.3/types.h>
26#include <android/hardware/wifi/1.4/IWifiChipEventCallback.h>
27#include <android/hardware/wifi/1.4/types.h>
Ahmed ElArabawy05571e42022-01-19 11:54:11 -080028#include <android/hardware/wifi/1.6/IWifiChip.h>
29#include <android/hardware/wifi/1.6/types.h>
Ahmed ElArabawy687ce132022-01-11 16:42:48 -080030
31#include "wifi_legacy_hal.h"
32
33/**
34 * This file contains a bunch of functions to convert structs from the legacy
35 * HAL to HIDL and vice versa.
36 * TODO(b/32093047): Add unit tests for these conversion methods in the VTS test
37 * suite.
38 */
39namespace android {
40namespace hardware {
41namespace wifi {
42namespace V1_6 {
43namespace implementation {
44namespace hidl_struct_util {
45using namespace android::hardware::wifi::V1_0;
46
47// Chip conversion methods.
48bool convertLegacyFeaturesToHidlChipCapabilities(uint64_t legacy_feature_set,
49 uint32_t legacy_logger_feature_set,
50 uint32_t* hidl_caps);
51bool convertLegacyDebugRingBufferStatusToHidl(
52 const legacy_hal::wifi_ring_buffer_status& legacy_status,
53 WifiDebugRingBufferStatus* hidl_status);
54bool convertLegacyVectorOfDebugRingBufferStatusToHidl(
55 const std::vector<legacy_hal::wifi_ring_buffer_status>& legacy_status_vec,
56 std::vector<WifiDebugRingBufferStatus>* hidl_status_vec);
57bool convertLegacyWakeReasonStatsToHidl(const legacy_hal::WakeReasonStats& legacy_stats,
58 WifiDebugHostWakeReasonStats* hidl_stats);
59legacy_hal::wifi_power_scenario convertHidlTxPowerScenarioToLegacy(
60 V1_1::IWifiChip::TxPowerScenario hidl_scenario);
61legacy_hal::wifi_latency_mode convertHidlLatencyModeToLegacy(
62 V1_3::IWifiChip::LatencyMode hidl_latency_mode);
63legacy_hal::wifi_power_scenario convertHidlTxPowerScenarioToLegacy_1_2(
64 V1_2::IWifiChip::TxPowerScenario hidl_scenario);
65bool convertLegacyWifiMacInfosToHidl(
66 const std::vector<legacy_hal::WifiMacInfo>& legacy_mac_infos,
67 std::vector<V1_4::IWifiChipEventCallback::RadioModeInfo>* hidl_radio_mode_infos);
68legacy_hal::wifi_interface_type convertHidlIfaceTypeToLegacy(IfaceType hidl_interface_type);
69legacy_hal::wifi_multi_sta_use_case convertHidlMultiStaUseCaseToLegacy(
70 V1_5::IWifiChip::MultiStaUseCase use_case);
71bool convertHidlCoexUnsafeChannelToLegacy(
72 const V1_5::IWifiChip::CoexUnsafeChannel& hidl_unsafe_channel,
73 legacy_hal::wifi_coex_unsafe_channel* legacy_unsafe_channel);
74bool convertHidlVectorOfCoexUnsafeChannelToLegacy(
75 const std::vector<V1_5::IWifiChip::CoexUnsafeChannel>& hidl_unsafe_channels,
76 std::vector<legacy_hal::wifi_coex_unsafe_channel>* legacy_unsafe_channels);
77
78// STA iface conversion methods.
79bool convertLegacyFeaturesToHidlStaCapabilities(uint64_t legacy_feature_set,
80 uint32_t legacy_logger_feature_set,
81 uint32_t* hidl_caps);
82bool convertLegacyApfCapabilitiesToHidl(const legacy_hal::PacketFilterCapabilities& legacy_caps,
83 StaApfPacketFilterCapabilities* hidl_caps);
84bool convertLegacyGscanCapabilitiesToHidl(const legacy_hal::wifi_gscan_capabilities& legacy_caps,
85 StaBackgroundScanCapabilities* hidl_caps);
86legacy_hal::wifi_band convertHidlWifiBandToLegacy(V1_0::WifiBand band);
87bool convertHidlGscanParamsToLegacy(const StaBackgroundScanParameters& hidl_scan_params,
88 legacy_hal::wifi_scan_cmd_params* legacy_scan_params);
89// |has_ie_data| indicates whether or not the wifi_scan_result includes 802.11
90// Information Elements (IEs)
91bool convertLegacyGscanResultToHidl(const legacy_hal::wifi_scan_result& legacy_scan_result,
92 bool has_ie_data, StaScanResult* hidl_scan_result);
93// |cached_results| is assumed to not include IEs.
94bool convertLegacyVectorOfCachedGscanResultsToHidl(
95 const std::vector<legacy_hal::wifi_cached_scan_results>& legacy_cached_scan_results,
96 std::vector<StaScanData>* hidl_scan_datas);
97bool convertLegacyLinkLayerStatsToHidl(const legacy_hal::LinkLayerStats& legacy_stats,
Ahmed ElArabawy05571e42022-01-19 11:54:11 -080098 V1_6::StaLinkLayerStats* hidl_stats);
Ahmed ElArabawy687ce132022-01-11 16:42:48 -080099bool convertLegacyRoamingCapabilitiesToHidl(
100 const legacy_hal::wifi_roaming_capabilities& legacy_caps,
101 StaRoamingCapabilities* hidl_caps);
102bool convertHidlRoamingConfigToLegacy(const StaRoamingConfig& hidl_config,
103 legacy_hal::wifi_roaming_config* legacy_config);
104legacy_hal::fw_roaming_state_t convertHidlRoamingStateToLegacy(StaRoamingState state);
105bool convertLegacyVectorOfDebugTxPacketFateToHidl(
106 const std::vector<legacy_hal::wifi_tx_report>& legacy_fates,
107 std::vector<WifiDebugTxPacketFateReport>* hidl_fates);
108bool convertLegacyVectorOfDebugRxPacketFateToHidl(
109 const std::vector<legacy_hal::wifi_rx_report>& legacy_fates,
110 std::vector<WifiDebugRxPacketFateReport>* hidl_fates);
111
112// NAN iface conversion methods.
113void convertToWifiNanStatus(legacy_hal::NanStatusType type, const char* str, size_t max_len,
114 WifiNanStatus* wifiNanStatus);
115bool convertHidlNanEnableRequestToLegacy(const V1_4::NanEnableRequest& hidl_request,
116 legacy_hal::NanEnableRequest* legacy_request);
117bool convertHidlNanConfigRequestToLegacy(const V1_4::NanConfigRequest& hidl_request,
118 legacy_hal::NanConfigRequest* legacy_request);
Nate Jiang50c001d2022-01-12 16:06:01 -0800119bool convertHidlNanEnableRequest_1_6ToLegacy(
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800120 const V1_4::NanEnableRequest& hidl_request1,
Nate Jiang50c001d2022-01-12 16:06:01 -0800121 const V1_6::NanConfigRequestSupplemental& hidl_request2,
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800122 legacy_hal::NanEnableRequest* legacy_request);
Nate Jiang50c001d2022-01-12 16:06:01 -0800123bool convertHidlNanConfigRequest_1_6ToLegacy(
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800124 const V1_4::NanConfigRequest& hidl_request1,
Nate Jiang50c001d2022-01-12 16:06:01 -0800125 const V1_6::NanConfigRequestSupplemental& hidl_request2,
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800126 legacy_hal::NanConfigRequest* legacy_request);
Nate Jiang50c001d2022-01-12 16:06:01 -0800127bool convertHidlNanPublishRequestToLegacy(const V1_6::NanPublishRequest& hidl_request,
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800128 legacy_hal::NanPublishRequest* legacy_request);
Nate Jiang50c001d2022-01-12 16:06:01 -0800129bool convertHidlNanSubscribeRequestToLegacy(const V1_0::NanSubscribeRequest& hidl_request,
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800130 legacy_hal::NanSubscribeRequest* legacy_request);
131bool convertHidlNanTransmitFollowupRequestToLegacy(
132 const NanTransmitFollowupRequest& hidl_request,
133 legacy_hal::NanTransmitFollowupRequest* legacy_request);
134bool convertHidlNanDataPathInitiatorRequestToLegacy(
Nate Jiang50c001d2022-01-12 16:06:01 -0800135 const V1_0::NanInitiateDataPathRequest& hidl_request,
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800136 legacy_hal::NanDataPathInitiatorRequest* legacy_request);
137bool convertHidlNanDataPathIndicationResponseToLegacy(
Nate Jiang50c001d2022-01-12 16:06:01 -0800138 const V1_0::NanRespondToDataPathIndicationRequest& hidl_response,
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800139 legacy_hal::NanDataPathIndicationResponse* legacy_response);
Nate Jiang50c001d2022-01-12 16:06:01 -0800140bool convertHidlNanDataPathInitiatorRequest_1_6ToLegacy(
141 const V1_6::NanInitiateDataPathRequest& hidl_request,
142 legacy_hal::NanDataPathInitiatorRequest* legacy_request);
143bool convertHidlNanDataPathIndicationResponse_1_6ToLegacy(
144 const V1_6::NanRespondToDataPathIndicationRequest& hidl_response,
145 legacy_hal::NanDataPathIndicationResponse* legacy_response);
146
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800147bool convertLegacyNanResponseHeaderToHidl(const legacy_hal::NanResponseMsg& legacy_response,
148 WifiNanStatus* wifiNanStatus);
149bool convertLegacyNanCapabilitiesResponseToHidl(const legacy_hal::NanCapabilities& legacy_response,
Nate Jiang50c001d2022-01-12 16:06:01 -0800150 V1_6::NanCapabilities* hidl_response);
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800151bool convertLegacyNanMatchIndToHidl(const legacy_hal::NanMatchInd& legacy_ind,
Nate Jiang50c001d2022-01-12 16:06:01 -0800152 V1_6::NanMatchInd* hidl_ind);
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800153bool convertLegacyNanFollowupIndToHidl(const legacy_hal::NanFollowupInd& legacy_ind,
154 NanFollowupReceivedInd* hidl_ind);
155bool convertLegacyNanDataPathRequestIndToHidl(const legacy_hal::NanDataPathRequestInd& legacy_ind,
156 NanDataPathRequestInd* hidl_ind);
157bool convertLegacyNanDataPathConfirmIndToHidl(const legacy_hal::NanDataPathConfirmInd& legacy_ind,
Ahmed ElArabawy05571e42022-01-19 11:54:11 -0800158 V1_6::NanDataPathConfirmInd* hidl_ind);
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800159bool convertLegacyNanDataPathScheduleUpdateIndToHidl(
160 const legacy_hal::NanDataPathScheduleUpdateInd& legacy_ind,
Ahmed ElArabawy05571e42022-01-19 11:54:11 -0800161 V1_6::NanDataPathScheduleUpdateInd* hidl_ind);
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800162
163// RTT controller conversion methods.
Ahmed ElArabawy05571e42022-01-19 11:54:11 -0800164bool convertHidlVectorOfRttConfigToLegacy(const std::vector<V1_6::RttConfig>& hidl_configs,
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800165 std::vector<legacy_hal::wifi_rtt_config>* legacy_configs);
166bool convertHidlRttLciInformationToLegacy(const RttLciInformation& hidl_info,
167 legacy_hal::wifi_lci_information* legacy_info);
168bool convertHidlRttLcrInformationToLegacy(const RttLcrInformation& hidl_info,
169 legacy_hal::wifi_lcr_information* legacy_info);
Ahmed ElArabawy05571e42022-01-19 11:54:11 -0800170bool convertHidlRttResponderToLegacy(const V1_6::RttResponder& hidl_responder,
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800171 legacy_hal::wifi_rtt_responder* legacy_responder);
Ahmed ElArabawy05571e42022-01-19 11:54:11 -0800172bool convertHidlWifiChannelInfoToLegacy(const V1_6::WifiChannelInfo& hidl_info,
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800173 legacy_hal::wifi_channel_info* legacy_info);
174bool convertLegacyRttResponderToHidl(const legacy_hal::wifi_rtt_responder& legacy_responder,
Ahmed ElArabawy05571e42022-01-19 11:54:11 -0800175 V1_6::RttResponder* hidl_responder);
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800176bool convertLegacyRttCapabilitiesToHidl(
177 const legacy_hal::wifi_rtt_capabilities& legacy_capabilities,
Ahmed ElArabawy05571e42022-01-19 11:54:11 -0800178 V1_6::RttCapabilities* hidl_capabilities);
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800179bool convertLegacyVectorOfRttResultToHidl(
180 const std::vector<const legacy_hal::wifi_rtt_result*>& legacy_results,
Ahmed ElArabawy05571e42022-01-19 11:54:11 -0800181 std::vector<V1_6::RttResult>* hidl_results);
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800182uint32_t convertHidlWifiBandToLegacyMacBand(V1_5::WifiBand band);
183uint32_t convertHidlWifiIfaceModeToLegacy(uint32_t hidl_iface_mask);
184uint32_t convertHidlUsableChannelFilterToLegacy(uint32_t hidl_filter_mask);
185bool convertLegacyWifiUsableChannelsToHidl(
186 const std::vector<legacy_hal::wifi_usable_channel>& legacy_usable_channels,
Ahmed ElArabawy05571e42022-01-19 11:54:11 -0800187 std::vector<V1_6::WifiUsableChannel>* hidl_usable_channels);
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800188bool convertLegacyPeerInfoStatsToHidl(const legacy_hal::WifiPeerInfo& legacy_peer_info_stats,
Ahmed ElArabawy05571e42022-01-19 11:54:11 -0800189 V1_6::StaPeerInfo* hidl_peer_info_stats);
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800190bool convertLegacyWifiRateInfoToHidl(const legacy_hal::wifi_rate& legacy_rate,
Ahmed ElArabawy05571e42022-01-19 11:54:11 -0800191 V1_6::WifiRateInfo* hidl_rate);
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800192} // namespace hidl_struct_util
193} // namespace implementation
194} // namespace V1_6
195} // namespace wifi
196} // namespace hardware
197} // namespace android
198
199#endif // HIDL_STRUCT_UTIL_H_