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