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 | |
| 22 | #include <android/hardware/wifi/1.0/IWifi.h> |
| 23 | |
| 24 | #include "wifi_legacy_hal.h" |
| 25 | |
| 26 | /** |
| 27 | * This file contains a bunch of functions to convert structs from the legacy |
| 28 | * HAL to HIDL and vice versa. |
| 29 | * TODO(b/32093047): Add unit tests for these conversion methods in the VTS test |
| 30 | * suite. |
| 31 | */ |
| 32 | namespace android { |
| 33 | namespace hardware { |
| 34 | namespace wifi { |
| 35 | namespace V1_0 { |
| 36 | namespace implementation { |
| 37 | namespace hidl_struct_util { |
| 38 | |
Roshan Pius | f72df2e | 2016-12-04 10:49:38 -0800 | [diff] [blame] | 39 | // Chip conversion methods. |
| 40 | bool convertLegacyFeaturesToHidlChipCapabilities( |
| 41 | uint32_t legacy_logger_feature_set, uint32_t* hidl_caps); |
Roshan Pius | 48185b2 | 2016-12-15 19:10:30 -0800 | [diff] [blame^] | 42 | bool convertLegacyDebugRingBufferStatusToHidl( |
| 43 | const legacy_hal::wifi_ring_buffer_status& legacy_status, |
| 44 | WifiDebugRingBufferStatus* hidl_status); |
Roshan Pius | f72df2e | 2016-12-04 10:49:38 -0800 | [diff] [blame] | 45 | bool convertLegacyVectorOfDebugRingBufferStatusToHidl( |
| 46 | const std::vector<legacy_hal::wifi_ring_buffer_status>& legacy_status_vec, |
| 47 | std::vector<WifiDebugRingBufferStatus>* hidl_status_vec); |
| 48 | bool convertLegacyWakeReasonStatsToHidl( |
| 49 | const legacy_hal::WakeReasonStats& legacy_stats, |
| 50 | WifiDebugHostWakeReasonStats* hidl_stats); |
| 51 | |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 52 | // STA iface conversion methods. |
Roshan Pius | f72df2e | 2016-12-04 10:49:38 -0800 | [diff] [blame] | 53 | bool convertLegacyFeaturesToHidlStaCapabilities( |
| 54 | uint32_t legacy_feature_set, |
| 55 | uint32_t legacy_logger_feature_set, |
| 56 | uint32_t* hidl_caps); |
| 57 | bool convertLegacyApfCapabilitiesToHidl( |
| 58 | const legacy_hal::PacketFilterCapabilities& legacy_caps, |
| 59 | StaApfPacketFilterCapabilities* hidl_caps); |
Roshan Pius | 881d1f7 | 2016-12-05 15:37:00 -0800 | [diff] [blame] | 60 | bool convertLegacyGscanCapabilitiesToHidl( |
Roshan Pius | f72df2e | 2016-12-04 10:49:38 -0800 | [diff] [blame] | 61 | const legacy_hal::wifi_gscan_capabilities& legacy_caps, |
| 62 | StaBackgroundScanCapabilities* hidl_caps); |
Roshan Pius | 881d1f7 | 2016-12-05 15:37:00 -0800 | [diff] [blame] | 63 | legacy_hal::wifi_band convertHidlGscanBandToLegacy(StaBackgroundScanBand band); |
| 64 | bool convertHidlGscanParamsToLegacy( |
Roshan Pius | e65edb1 | 2016-11-22 13:02:01 -0800 | [diff] [blame] | 65 | const StaBackgroundScanParameters& hidl_scan_params, |
| 66 | legacy_hal::wifi_scan_cmd_params* legacy_scan_params); |
Roshan Pius | e65edb1 | 2016-11-22 13:02:01 -0800 | [diff] [blame] | 67 | // |has_ie_data| indicates whether or not the wifi_scan_result includes 802.11 |
| 68 | // Information Elements (IEs) |
Roshan Pius | 881d1f7 | 2016-12-05 15:37:00 -0800 | [diff] [blame] | 69 | bool convertLegacyGscanResultToHidl( |
Roshan Pius | e65edb1 | 2016-11-22 13:02:01 -0800 | [diff] [blame] | 70 | const legacy_hal::wifi_scan_result& legacy_scan_result, |
| 71 | bool has_ie_data, |
| 72 | StaScanResult* hidl_scan_result); |
| 73 | // |cached_results| is assumed to not include IEs. |
Roshan Pius | 881d1f7 | 2016-12-05 15:37:00 -0800 | [diff] [blame] | 74 | bool convertLegacyVectorOfCachedGscanResultsToHidl( |
Roshan Pius | e65edb1 | 2016-11-22 13:02:01 -0800 | [diff] [blame] | 75 | const std::vector<legacy_hal::wifi_cached_scan_results>& |
| 76 | legacy_cached_scan_results, |
| 77 | std::vector<StaScanData>* hidl_scan_datas); |
| 78 | bool convertLegacyLinkLayerStatsToHidl( |
| 79 | const legacy_hal::LinkLayerStats& legacy_stats, |
| 80 | StaLinkLayerStats* hidl_stats); |
Roshan Pius | 26801cb | 2016-12-13 14:25:45 -0800 | [diff] [blame] | 81 | bool convertLegacyRoamingCapabilitiesToHidl( |
| 82 | const legacy_hal::wifi_roaming_capabilities& legacy_caps, |
| 83 | StaRoamingCapabilities* hidl_caps); |
| 84 | bool convertHidlRoamingConfigToLegacy( |
| 85 | const StaRoamingConfig& hidl_config, |
| 86 | legacy_hal::wifi_roaming_config* legacy_config); |
| 87 | legacy_hal::fw_roaming_state_t convertHidlRoamingStateToLegacy( |
| 88 | StaRoamingState state); |
Roshan Pius | f72df2e | 2016-12-04 10:49:38 -0800 | [diff] [blame] | 89 | bool convertLegacyVectorOfDebugTxPacketFateToHidl( |
| 90 | const std::vector<legacy_hal::wifi_tx_report>& legacy_fates, |
| 91 | std::vector<WifiDebugTxPacketFateReport>* hidl_fates); |
| 92 | bool convertLegacyVectorOfDebugRxPacketFateToHidl( |
| 93 | const std::vector<legacy_hal::wifi_rx_report>& legacy_fates, |
| 94 | std::vector<WifiDebugRxPacketFateReport>* hidl_fates); |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 95 | |
| 96 | // NAN iface conversion methods. |
| 97 | bool convertHidlNanEnableRequestToLegacy( |
| 98 | const NanEnableRequest& hidl_request, |
| 99 | legacy_hal::NanEnableRequest* legacy_request); |
| 100 | bool convertHidlNanPublishRequestToLegacy( |
| 101 | const NanPublishRequest& hidl_request, |
| 102 | legacy_hal::NanPublishRequest* legacy_request); |
| 103 | bool convertHidlNanPublishCancelRequestToLegacy( |
| 104 | const NanPublishCancelRequest& hidl_request, |
| 105 | legacy_hal::NanPublishCancelRequest* legacy_request); |
| 106 | bool convertHidlNanSubscribeRequestToLegacy( |
| 107 | const NanSubscribeRequest& hidl_request, |
| 108 | legacy_hal::NanSubscribeRequest* legacy_request); |
| 109 | bool convertHidlNanSubscribeCancelRequestToLegacy( |
| 110 | const NanSubscribeCancelRequest& hidl_request, |
| 111 | legacy_hal::NanSubscribeCancelRequest* legacy_request); |
| 112 | bool convertHidlNanTransmitFollowupRequestToLegacy( |
| 113 | const NanTransmitFollowupRequest& hidl_request, |
| 114 | legacy_hal::NanTransmitFollowupRequest* legacy_request); |
| 115 | bool convertHidlNanConfigRequestToLegacy( |
| 116 | const NanConfigRequest& hidl_request, |
| 117 | legacy_hal::NanConfigRequest* legacy_request); |
| 118 | bool convertHidlNanBeaconSdfPayloadRequestToLegacy( |
| 119 | const NanBeaconSdfPayloadRequest& hidl_request, |
| 120 | legacy_hal::NanBeaconSdfPayloadRequest* legacy_request); |
| 121 | bool convertHidlNanDataPathInitiatorRequestToLegacy( |
| 122 | const NanDataPathInitiatorRequest& hidl_request, |
| 123 | legacy_hal::NanDataPathInitiatorRequest* legacy_request); |
| 124 | bool convertHidlNanDataPathIndicationResponseToLegacy( |
| 125 | const NanDataPathIndicationResponse& hidl_response, |
| 126 | legacy_hal::NanDataPathIndicationResponse* legacy_response); |
| 127 | bool convertHidlNanDataPathEndRequestToLegacy( |
| 128 | const NanDataPathEndRequest& hidl_request, |
| 129 | legacy_hal::NanDataPathEndRequest* legacy_request); |
| 130 | bool convertLegacyNanResponseHeaderToHidl( |
| 131 | const legacy_hal::NanResponseMsg& legacy_response, |
| 132 | NanResponseMsgHeader* hidl_response); |
| 133 | bool convertLegacyNanPublishResponseToHidl( |
| 134 | const legacy_hal::NanPublishResponse& legacy_response, |
| 135 | NanPublishResponse* hidl_response); |
| 136 | bool convertLegacyNanSubscribeResponseToHidl( |
| 137 | const legacy_hal::NanSubscribeResponse& legacy_response, |
| 138 | NanSubscribeResponse* hidl_response); |
| 139 | bool convertLegacyNanDataPathResponseToHidl( |
| 140 | const legacy_hal::NanDataPathRequestResponse& legacy_response, |
| 141 | NanDataPathResponse* hidl_response); |
| 142 | bool convertLegacyNanCapabilitiesResponseToHidl( |
| 143 | const legacy_hal::NanCapabilities& legacy_response, |
| 144 | NanCapabilitiesResponse* hidl_response); |
| 145 | bool convertLegacyNanPublishTerminatedIndToHidl( |
| 146 | const legacy_hal::NanPublishTerminatedInd& legacy_ind, |
| 147 | NanPublishTerminatedInd* hidl_ind); |
| 148 | bool convertLegacyNanMatchIndToHidl(const legacy_hal::NanMatchInd& legacy_ind, |
| 149 | NanMatchInd* hidl_ind); |
| 150 | bool convertLegacyNanMatchExpiredIndToHidl( |
| 151 | const legacy_hal::NanMatchExpiredInd& legacy_ind, |
| 152 | NanMatchExpiredInd* hidl_ind); |
| 153 | bool convertLegacyNanSubscribeTerminatedIndToHidl( |
| 154 | const legacy_hal::NanSubscribeTerminatedInd& legacy_ind, |
| 155 | NanSubscribeTerminatedInd* hidl_ind); |
| 156 | bool convertLegacyNanFollowupIndToHidl( |
| 157 | const legacy_hal::NanFollowupInd& legacy_ind, NanFollowupInd* hidl_ind); |
| 158 | bool convertLegacyNanDiscEngEventIndToHidl( |
| 159 | const legacy_hal::NanDiscEngEventInd& legacy_ind, |
| 160 | NanDiscEngEventInd* hidl_ind); |
| 161 | bool convertLegacyNanDisabledIndToHidl( |
| 162 | const legacy_hal::NanDisabledInd& legacy_ind, NanDisabledInd* hidl_ind); |
| 163 | bool convertLegacyNanBeaconSdfPayloadIndToHidl( |
| 164 | const legacy_hal::NanBeaconSdfPayloadInd& legacy_ind, |
| 165 | NanBeaconSdfPayloadInd* hidl_ind); |
| 166 | bool convertLegacyNanDataPathRequestIndToHidl( |
| 167 | const legacy_hal::NanDataPathRequestInd& legacy_ind, |
| 168 | NanDataPathRequestInd* hidl_ind); |
| 169 | bool convertLegacyNanDataPathConfirmIndToHidl( |
| 170 | const legacy_hal::NanDataPathConfirmInd& legacy_ind, |
| 171 | NanDataPathConfirmInd* hidl_ind); |
| 172 | bool convertLegacyNanDataPathEndIndToHidl( |
| 173 | const legacy_hal::NanDataPathEndInd& legacy_ind, |
| 174 | NanDataPathEndInd* hidl_ind); |
| 175 | bool convertLegacyNanTransmitFollowupIndToHidl( |
| 176 | const legacy_hal::NanTransmitFollowupInd& legacy_ind, |
| 177 | NanTransmitFollowupInd* hidl_ind); |
Roshan Pius | 3fae9c8 | 2016-12-02 14:49:41 -0800 | [diff] [blame] | 178 | |
| 179 | // RTT controller conversion methods. |
Roshan Pius | e3f72ff | 2016-12-05 16:18:43 -0800 | [diff] [blame] | 180 | bool convertHidlVectorOfRttConfigToLegacy( |
| 181 | const std::vector<RttConfig>& hidl_configs, |
| 182 | std::vector<legacy_hal::wifi_rtt_config>* legacy_configs); |
Roshan Pius | 3fae9c8 | 2016-12-02 14:49:41 -0800 | [diff] [blame] | 183 | bool convertHidlRttLciInformationToLegacy( |
| 184 | const RttLciInformation& hidl_info, |
| 185 | legacy_hal::wifi_lci_information* legacy_info); |
| 186 | bool convertHidlRttLcrInformationToLegacy( |
| 187 | const RttLcrInformation& hidl_info, |
| 188 | legacy_hal::wifi_lcr_information* legacy_info); |
| 189 | bool convertHidlRttResponderToLegacy( |
| 190 | const RttResponder& hidl_responder, |
| 191 | legacy_hal::wifi_rtt_responder* legacy_responder); |
Roshan Pius | e3f72ff | 2016-12-05 16:18:43 -0800 | [diff] [blame] | 192 | bool convertHidlWifiChannelInfoToLegacy( |
| 193 | const WifiChannelInfo& hidl_info, |
| 194 | legacy_hal::wifi_channel_info* legacy_info); |
Roshan Pius | 3fae9c8 | 2016-12-02 14:49:41 -0800 | [diff] [blame] | 195 | bool convertLegacyRttResponderToHidl( |
| 196 | const legacy_hal::wifi_rtt_responder& legacy_responder, |
| 197 | RttResponder* hidl_responder); |
| 198 | bool convertLegacyRttCapabilitiesToHidl( |
| 199 | const legacy_hal::wifi_rtt_capabilities& legacy_capabilities, |
| 200 | RttCapabilities* hidl_capabilities); |
Roshan Pius | e3f72ff | 2016-12-05 16:18:43 -0800 | [diff] [blame] | 201 | bool convertLegacyVectorOfRttResultToHidl( |
| 202 | const std::vector<const legacy_hal::wifi_rtt_result*>& legacy_results, |
| 203 | std::vector<RttResult>* hidl_results); |
Roshan Pius | e65edb1 | 2016-11-22 13:02:01 -0800 | [diff] [blame] | 204 | } // namespace hidl_struct_util |
| 205 | } // namespace implementation |
| 206 | } // namespace V1_0 |
| 207 | } // namespace wifi |
| 208 | } // namespace hardware |
| 209 | } // namespace android |
| 210 | |
| 211 | #endif // HIDL_STRUCT_UTIL_H_ |