Roshan Pius | e65edb1 | 2016-11-22 13:02:01 -0800 | [diff] [blame] | 1 | /* |
| 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 Pius | 735ff43 | 2017-07-25 08:48:08 -0700 | [diff] [blame] | 22 | #include <android/hardware/wifi/1.0/IWifiChip.h> |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 23 | #include <android/hardware/wifi/1.0/types.h> |
Roshan Pius | 1a7b1db | 2018-01-22 17:57:20 -0800 | [diff] [blame] | 24 | #include <android/hardware/wifi/1.2/IWifiChipEventCallback.h> |
Etan Cohen | 9e7a405 | 2017-12-21 13:45:26 -0800 | [diff] [blame] | 25 | #include <android/hardware/wifi/1.2/types.h> |
Ahmed ElArabawy | eaf8240 | 2018-10-26 09:46:04 -0700 | [diff] [blame] | 26 | #include <android/hardware/wifi/1.3/IWifiChip.h> |
xshu | e987325 | 2018-08-07 11:04:34 -0700 | [diff] [blame] | 27 | #include <android/hardware/wifi/1.3/types.h> |
Ahmed ElArabawy | 95e36b7 | 2019-11-15 21:24:53 +0000 | [diff] [blame] | 28 | #include <android/hardware/wifi/1.4/IWifiStaIface.h> |
Ahmed ElArabawy | eeb5338 | 2019-10-10 20:18:31 -0700 | [diff] [blame] | 29 | #include <android/hardware/wifi/1.4/types.h> |
Roshan Pius | e65edb1 | 2016-11-22 13:02:01 -0800 | [diff] [blame] | 30 | |
| 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 | */ |
| 39 | namespace android { |
| 40 | namespace hardware { |
| 41 | namespace wifi { |
Ahmed ElArabawy | f501a98 | 2019-07-23 15:02:22 -0700 | [diff] [blame] | 42 | namespace V1_4 { |
Roshan Pius | e65edb1 | 2016-11-22 13:02:01 -0800 | [diff] [blame] | 43 | namespace implementation { |
| 44 | namespace hidl_struct_util { |
Roshan Pius | dbd83ef | 2017-06-20 12:05:40 -0700 | [diff] [blame] | 45 | using namespace android::hardware::wifi::V1_0; |
Roshan Pius | e65edb1 | 2016-11-22 13:02:01 -0800 | [diff] [blame] | 46 | |
Roshan Pius | f72df2e | 2016-12-04 10:49:38 -0800 | [diff] [blame] | 47 | // Chip conversion methods. |
| 48 | bool convertLegacyFeaturesToHidlChipCapabilities( |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 49 | uint32_t legacy_feature_set, uint32_t legacy_logger_feature_set, |
Roshan Pius | 8184d21 | 2017-07-11 08:59:29 -0700 | [diff] [blame] | 50 | uint32_t* hidl_caps); |
Roshan Pius | 48185b2 | 2016-12-15 19:10:30 -0800 | [diff] [blame] | 51 | bool convertLegacyDebugRingBufferStatusToHidl( |
| 52 | const legacy_hal::wifi_ring_buffer_status& legacy_status, |
| 53 | WifiDebugRingBufferStatus* hidl_status); |
Roshan Pius | f72df2e | 2016-12-04 10:49:38 -0800 | [diff] [blame] | 54 | bool convertLegacyVectorOfDebugRingBufferStatusToHidl( |
| 55 | const std::vector<legacy_hal::wifi_ring_buffer_status>& legacy_status_vec, |
| 56 | std::vector<WifiDebugRingBufferStatus>* hidl_status_vec); |
| 57 | bool convertLegacyWakeReasonStatsToHidl( |
| 58 | const legacy_hal::WakeReasonStats& legacy_stats, |
| 59 | WifiDebugHostWakeReasonStats* hidl_stats); |
Roshan Pius | 735ff43 | 2017-07-25 08:48:08 -0700 | [diff] [blame] | 60 | legacy_hal::wifi_power_scenario convertHidlTxPowerScenarioToLegacy( |
| 61 | V1_1::IWifiChip::TxPowerScenario hidl_scenario); |
Ahmed ElArabawy | eaf8240 | 2018-10-26 09:46:04 -0700 | [diff] [blame] | 62 | legacy_hal::wifi_latency_mode convertHidlLatencyModeToLegacy( |
| 63 | V1_3::IWifiChip::LatencyMode hidl_latency_mode); |
Ahmed ElArabawy | 6a1accf | 2018-01-23 10:57:29 -0800 | [diff] [blame] | 64 | legacy_hal::wifi_power_scenario convertHidlTxPowerScenarioToLegacy_1_2( |
Jong Wook Kim | da830c9 | 2018-07-23 15:29:38 -0700 | [diff] [blame] | 65 | V1_2::IWifiChip::TxPowerScenario hidl_scenario); |
Roshan Pius | 1a7b1db | 2018-01-22 17:57:20 -0800 | [diff] [blame] | 66 | bool convertLegacyWifiMacInfosToHidl( |
| 67 | const std::vector<legacy_hal::WifiMacInfo>& legacy_mac_infos, |
Jong Wook Kim | da830c9 | 2018-07-23 15:29:38 -0700 | [diff] [blame] | 68 | std::vector<V1_2::IWifiChipEventCallback::RadioModeInfo>* |
| 69 | hidl_radio_mode_infos); |
Roshan Pius | f72df2e | 2016-12-04 10:49:38 -0800 | [diff] [blame] | 70 | |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 71 | // STA iface conversion methods. |
Roshan Pius | f72df2e | 2016-12-04 10:49:38 -0800 | [diff] [blame] | 72 | bool convertLegacyFeaturesToHidlStaCapabilities( |
Ahmed ElArabawy | 95e36b7 | 2019-11-15 21:24:53 +0000 | [diff] [blame] | 73 | uint64_t legacy_feature_set, uint32_t legacy_logger_feature_set, |
Roshan Pius | f72df2e | 2016-12-04 10:49:38 -0800 | [diff] [blame] | 74 | uint32_t* hidl_caps); |
| 75 | bool convertLegacyApfCapabilitiesToHidl( |
| 76 | const legacy_hal::PacketFilterCapabilities& legacy_caps, |
| 77 | StaApfPacketFilterCapabilities* hidl_caps); |
Roshan Pius | 881d1f7 | 2016-12-05 15:37:00 -0800 | [diff] [blame] | 78 | bool convertLegacyGscanCapabilitiesToHidl( |
Roshan Pius | f72df2e | 2016-12-04 10:49:38 -0800 | [diff] [blame] | 79 | const legacy_hal::wifi_gscan_capabilities& legacy_caps, |
| 80 | StaBackgroundScanCapabilities* hidl_caps); |
Roshan Pius | 7f4574d | 2017-02-22 09:48:03 -0800 | [diff] [blame] | 81 | legacy_hal::wifi_band convertHidlWifiBandToLegacy(WifiBand band); |
Roshan Pius | 881d1f7 | 2016-12-05 15:37:00 -0800 | [diff] [blame] | 82 | bool convertHidlGscanParamsToLegacy( |
Roshan Pius | e65edb1 | 2016-11-22 13:02:01 -0800 | [diff] [blame] | 83 | const StaBackgroundScanParameters& hidl_scan_params, |
| 84 | legacy_hal::wifi_scan_cmd_params* legacy_scan_params); |
Roshan Pius | e65edb1 | 2016-11-22 13:02:01 -0800 | [diff] [blame] | 85 | // |has_ie_data| indicates whether or not the wifi_scan_result includes 802.11 |
| 86 | // Information Elements (IEs) |
Roshan Pius | 881d1f7 | 2016-12-05 15:37:00 -0800 | [diff] [blame] | 87 | bool convertLegacyGscanResultToHidl( |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 88 | const legacy_hal::wifi_scan_result& legacy_scan_result, bool has_ie_data, |
Roshan Pius | e65edb1 | 2016-11-22 13:02:01 -0800 | [diff] [blame] | 89 | StaScanResult* hidl_scan_result); |
| 90 | // |cached_results| is assumed to not include IEs. |
Roshan Pius | 881d1f7 | 2016-12-05 15:37:00 -0800 | [diff] [blame] | 91 | bool convertLegacyVectorOfCachedGscanResultsToHidl( |
Roshan Pius | e65edb1 | 2016-11-22 13:02:01 -0800 | [diff] [blame] | 92 | const std::vector<legacy_hal::wifi_cached_scan_results>& |
| 93 | legacy_cached_scan_results, |
| 94 | std::vector<StaScanData>* hidl_scan_datas); |
| 95 | bool convertLegacyLinkLayerStatsToHidl( |
| 96 | const legacy_hal::LinkLayerStats& legacy_stats, |
xshu | e987325 | 2018-08-07 11:04:34 -0700 | [diff] [blame] | 97 | V1_3::StaLinkLayerStats* hidl_stats); |
Roshan Pius | 26801cb | 2016-12-13 14:25:45 -0800 | [diff] [blame] | 98 | bool convertLegacyRoamingCapabilitiesToHidl( |
| 99 | const legacy_hal::wifi_roaming_capabilities& legacy_caps, |
| 100 | StaRoamingCapabilities* hidl_caps); |
| 101 | bool convertHidlRoamingConfigToLegacy( |
| 102 | const StaRoamingConfig& hidl_config, |
| 103 | legacy_hal::wifi_roaming_config* legacy_config); |
| 104 | legacy_hal::fw_roaming_state_t convertHidlRoamingStateToLegacy( |
| 105 | StaRoamingState state); |
Roshan Pius | f72df2e | 2016-12-04 10:49:38 -0800 | [diff] [blame] | 106 | bool convertLegacyVectorOfDebugTxPacketFateToHidl( |
| 107 | const std::vector<legacy_hal::wifi_tx_report>& legacy_fates, |
| 108 | std::vector<WifiDebugTxPacketFateReport>* hidl_fates); |
| 109 | bool convertLegacyVectorOfDebugRxPacketFateToHidl( |
| 110 | const std::vector<legacy_hal::wifi_rx_report>& legacy_fates, |
| 111 | std::vector<WifiDebugRxPacketFateReport>* hidl_fates); |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 112 | |
| 113 | // NAN iface conversion methods. |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 114 | void convertToWifiNanStatus(legacy_hal::NanStatusType type, const char* str, |
| 115 | size_t max_len, WifiNanStatus* wifiNanStatus); |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 116 | bool convertHidlNanEnableRequestToLegacy( |
| 117 | const NanEnableRequest& hidl_request, |
| 118 | legacy_hal::NanEnableRequest* legacy_request); |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 119 | bool convertHidlNanConfigRequestToLegacy( |
| 120 | const NanConfigRequest& hidl_request, |
| 121 | legacy_hal::NanConfigRequest* legacy_request); |
Etan Cohen | 9e7a405 | 2017-12-21 13:45:26 -0800 | [diff] [blame] | 122 | bool convertHidlNanEnableRequest_1_2ToLegacy( |
| 123 | const NanEnableRequest& hidl_request1, |
Jong Wook Kim | da830c9 | 2018-07-23 15:29:38 -0700 | [diff] [blame] | 124 | const V1_2::NanConfigRequestSupplemental& hidl_request2, |
Etan Cohen | 9e7a405 | 2017-12-21 13:45:26 -0800 | [diff] [blame] | 125 | legacy_hal::NanEnableRequest* legacy_request); |
| 126 | bool convertHidlNanConfigRequest_1_2ToLegacy( |
| 127 | const NanConfigRequest& hidl_request1, |
Jong Wook Kim | da830c9 | 2018-07-23 15:29:38 -0700 | [diff] [blame] | 128 | const V1_2::NanConfigRequestSupplemental& hidl_request2, |
Etan Cohen | 9e7a405 | 2017-12-21 13:45:26 -0800 | [diff] [blame] | 129 | legacy_hal::NanConfigRequest* legacy_request); |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 130 | bool convertHidlNanPublishRequestToLegacy( |
| 131 | const NanPublishRequest& hidl_request, |
| 132 | legacy_hal::NanPublishRequest* legacy_request); |
| 133 | bool convertHidlNanSubscribeRequestToLegacy( |
| 134 | const NanSubscribeRequest& hidl_request, |
| 135 | legacy_hal::NanSubscribeRequest* legacy_request); |
| 136 | bool convertHidlNanTransmitFollowupRequestToLegacy( |
| 137 | const NanTransmitFollowupRequest& hidl_request, |
| 138 | legacy_hal::NanTransmitFollowupRequest* legacy_request); |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 139 | bool convertHidlNanDataPathInitiatorRequestToLegacy( |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 140 | const NanInitiateDataPathRequest& hidl_request, |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 141 | legacy_hal::NanDataPathInitiatorRequest* legacy_request); |
| 142 | bool convertHidlNanDataPathIndicationResponseToLegacy( |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 143 | const NanRespondToDataPathIndicationRequest& hidl_response, |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 144 | legacy_hal::NanDataPathIndicationResponse* legacy_response); |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 145 | bool convertLegacyNanResponseHeaderToHidl( |
| 146 | const legacy_hal::NanResponseMsg& legacy_response, |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 147 | WifiNanStatus* wifiNanStatus); |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 148 | bool convertLegacyNanCapabilitiesResponseToHidl( |
| 149 | const legacy_hal::NanCapabilities& legacy_response, |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 150 | NanCapabilities* hidl_response); |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 151 | bool convertLegacyNanMatchIndToHidl(const legacy_hal::NanMatchInd& legacy_ind, |
| 152 | NanMatchInd* hidl_ind); |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 153 | bool convertLegacyNanFollowupIndToHidl( |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 154 | const legacy_hal::NanFollowupInd& legacy_ind, |
| 155 | NanFollowupReceivedInd* hidl_ind); |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 156 | bool convertLegacyNanDataPathRequestIndToHidl( |
| 157 | const legacy_hal::NanDataPathRequestInd& legacy_ind, |
| 158 | NanDataPathRequestInd* hidl_ind); |
| 159 | bool convertLegacyNanDataPathConfirmIndToHidl( |
| 160 | const legacy_hal::NanDataPathConfirmInd& legacy_ind, |
Jong Wook Kim | da830c9 | 2018-07-23 15:29:38 -0700 | [diff] [blame] | 161 | V1_2::NanDataPathConfirmInd* hidl_ind); |
Etan Cohen | c7bd0f7 | 2017-12-26 11:52:44 -0800 | [diff] [blame] | 162 | bool convertLegacyNanDataPathScheduleUpdateIndToHidl( |
| 163 | const legacy_hal::NanDataPathScheduleUpdateInd& legacy_ind, |
Jong Wook Kim | da830c9 | 2018-07-23 15:29:38 -0700 | [diff] [blame] | 164 | V1_2::NanDataPathScheduleUpdateInd* hidl_ind); |
Roshan Pius | 3fae9c8 | 2016-12-02 14:49:41 -0800 | [diff] [blame] | 165 | |
| 166 | // RTT controller conversion methods. |
Roshan Pius | e3f72ff | 2016-12-05 16:18:43 -0800 | [diff] [blame] | 167 | bool convertHidlVectorOfRttConfigToLegacy( |
| 168 | const std::vector<RttConfig>& hidl_configs, |
| 169 | std::vector<legacy_hal::wifi_rtt_config>* legacy_configs); |
Roshan Pius | 3fae9c8 | 2016-12-02 14:49:41 -0800 | [diff] [blame] | 170 | bool convertHidlRttLciInformationToLegacy( |
| 171 | const RttLciInformation& hidl_info, |
| 172 | legacy_hal::wifi_lci_information* legacy_info); |
| 173 | bool convertHidlRttLcrInformationToLegacy( |
| 174 | const RttLcrInformation& hidl_info, |
| 175 | legacy_hal::wifi_lcr_information* legacy_info); |
| 176 | bool convertHidlRttResponderToLegacy( |
| 177 | const RttResponder& hidl_responder, |
| 178 | legacy_hal::wifi_rtt_responder* legacy_responder); |
Roshan Pius | e3f72ff | 2016-12-05 16:18:43 -0800 | [diff] [blame] | 179 | bool convertHidlWifiChannelInfoToLegacy( |
| 180 | const WifiChannelInfo& hidl_info, |
| 181 | legacy_hal::wifi_channel_info* legacy_info); |
Roshan Pius | 3fae9c8 | 2016-12-02 14:49:41 -0800 | [diff] [blame] | 182 | bool convertLegacyRttResponderToHidl( |
| 183 | const legacy_hal::wifi_rtt_responder& legacy_responder, |
| 184 | RttResponder* hidl_responder); |
| 185 | bool convertLegacyRttCapabilitiesToHidl( |
| 186 | const legacy_hal::wifi_rtt_capabilities& legacy_capabilities, |
| 187 | RttCapabilities* hidl_capabilities); |
Roshan Pius | e3f72ff | 2016-12-05 16:18:43 -0800 | [diff] [blame] | 188 | bool convertLegacyVectorOfRttResultToHidl( |
| 189 | const std::vector<const legacy_hal::wifi_rtt_result*>& legacy_results, |
| 190 | std::vector<RttResult>* hidl_results); |
Roshan Pius | e65edb1 | 2016-11-22 13:02:01 -0800 | [diff] [blame] | 191 | } // namespace hidl_struct_util |
| 192 | } // namespace implementation |
Ahmed ElArabawy | f501a98 | 2019-07-23 15:02:22 -0700 | [diff] [blame] | 193 | } // namespace V1_4 |
Roshan Pius | e65edb1 | 2016-11-22 13:02:01 -0800 | [diff] [blame] | 194 | } // namespace wifi |
| 195 | } // namespace hardware |
| 196 | } // namespace android |
| 197 | |
| 198 | #endif // HIDL_STRUCT_UTIL_H_ |