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