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); |
| 42 | bool convertLegacyVectorOfDebugRingBufferStatusToHidl( |
| 43 | const std::vector<legacy_hal::wifi_ring_buffer_status>& legacy_status_vec, |
| 44 | std::vector<WifiDebugRingBufferStatus>* hidl_status_vec); |
| 45 | bool convertLegacyWakeReasonStatsToHidl( |
| 46 | const legacy_hal::WakeReasonStats& legacy_stats, |
| 47 | WifiDebugHostWakeReasonStats* hidl_stats); |
| 48 | |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 49 | // STA iface conversion methods. |
Roshan Pius | f72df2e | 2016-12-04 10:49:38 -0800 | [diff] [blame] | 50 | bool convertLegacyFeaturesToHidlStaCapabilities( |
| 51 | uint32_t legacy_feature_set, |
| 52 | uint32_t legacy_logger_feature_set, |
| 53 | uint32_t* hidl_caps); |
| 54 | bool convertLegacyApfCapabilitiesToHidl( |
| 55 | const legacy_hal::PacketFilterCapabilities& legacy_caps, |
| 56 | StaApfPacketFilterCapabilities* hidl_caps); |
Roshan Pius | 881d1f7 | 2016-12-05 15:37:00 -0800 | [diff] [blame^] | 57 | bool convertLegacyGscanCapabilitiesToHidl( |
Roshan Pius | f72df2e | 2016-12-04 10:49:38 -0800 | [diff] [blame] | 58 | const legacy_hal::wifi_gscan_capabilities& legacy_caps, |
| 59 | StaBackgroundScanCapabilities* hidl_caps); |
Roshan Pius | 881d1f7 | 2016-12-05 15:37:00 -0800 | [diff] [blame^] | 60 | legacy_hal::wifi_band convertHidlGscanBandToLegacy(StaBackgroundScanBand band); |
| 61 | bool convertHidlGscanParamsToLegacy( |
Roshan Pius | e65edb1 | 2016-11-22 13:02:01 -0800 | [diff] [blame] | 62 | const StaBackgroundScanParameters& hidl_scan_params, |
| 63 | legacy_hal::wifi_scan_cmd_params* legacy_scan_params); |
Roshan Pius | e65edb1 | 2016-11-22 13:02:01 -0800 | [diff] [blame] | 64 | // |has_ie_data| indicates whether or not the wifi_scan_result includes 802.11 |
| 65 | // Information Elements (IEs) |
Roshan Pius | 881d1f7 | 2016-12-05 15:37:00 -0800 | [diff] [blame^] | 66 | bool convertLegacyGscanResultToHidl( |
Roshan Pius | e65edb1 | 2016-11-22 13:02:01 -0800 | [diff] [blame] | 67 | const legacy_hal::wifi_scan_result& legacy_scan_result, |
| 68 | bool has_ie_data, |
| 69 | StaScanResult* hidl_scan_result); |
| 70 | // |cached_results| is assumed to not include IEs. |
Roshan Pius | 881d1f7 | 2016-12-05 15:37:00 -0800 | [diff] [blame^] | 71 | bool convertLegacyVectorOfCachedGscanResultsToHidl( |
Roshan Pius | e65edb1 | 2016-11-22 13:02:01 -0800 | [diff] [blame] | 72 | const std::vector<legacy_hal::wifi_cached_scan_results>& |
| 73 | legacy_cached_scan_results, |
| 74 | std::vector<StaScanData>* hidl_scan_datas); |
| 75 | bool convertLegacyLinkLayerStatsToHidl( |
| 76 | const legacy_hal::LinkLayerStats& legacy_stats, |
| 77 | StaLinkLayerStats* hidl_stats); |
Roshan Pius | f72df2e | 2016-12-04 10:49:38 -0800 | [diff] [blame] | 78 | bool convertLegacyVectorOfDebugTxPacketFateToHidl( |
| 79 | const std::vector<legacy_hal::wifi_tx_report>& legacy_fates, |
| 80 | std::vector<WifiDebugTxPacketFateReport>* hidl_fates); |
| 81 | bool convertLegacyVectorOfDebugRxPacketFateToHidl( |
| 82 | const std::vector<legacy_hal::wifi_rx_report>& legacy_fates, |
| 83 | std::vector<WifiDebugRxPacketFateReport>* hidl_fates); |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 84 | |
| 85 | // NAN iface conversion methods. |
| 86 | bool convertHidlNanEnableRequestToLegacy( |
| 87 | const NanEnableRequest& hidl_request, |
| 88 | legacy_hal::NanEnableRequest* legacy_request); |
| 89 | bool convertHidlNanPublishRequestToLegacy( |
| 90 | const NanPublishRequest& hidl_request, |
| 91 | legacy_hal::NanPublishRequest* legacy_request); |
| 92 | bool convertHidlNanPublishCancelRequestToLegacy( |
| 93 | const NanPublishCancelRequest& hidl_request, |
| 94 | legacy_hal::NanPublishCancelRequest* legacy_request); |
| 95 | bool convertHidlNanSubscribeRequestToLegacy( |
| 96 | const NanSubscribeRequest& hidl_request, |
| 97 | legacy_hal::NanSubscribeRequest* legacy_request); |
| 98 | bool convertHidlNanSubscribeCancelRequestToLegacy( |
| 99 | const NanSubscribeCancelRequest& hidl_request, |
| 100 | legacy_hal::NanSubscribeCancelRequest* legacy_request); |
| 101 | bool convertHidlNanTransmitFollowupRequestToLegacy( |
| 102 | const NanTransmitFollowupRequest& hidl_request, |
| 103 | legacy_hal::NanTransmitFollowupRequest* legacy_request); |
| 104 | bool convertHidlNanConfigRequestToLegacy( |
| 105 | const NanConfigRequest& hidl_request, |
| 106 | legacy_hal::NanConfigRequest* legacy_request); |
| 107 | bool convertHidlNanBeaconSdfPayloadRequestToLegacy( |
| 108 | const NanBeaconSdfPayloadRequest& hidl_request, |
| 109 | legacy_hal::NanBeaconSdfPayloadRequest* legacy_request); |
| 110 | bool convertHidlNanDataPathInitiatorRequestToLegacy( |
| 111 | const NanDataPathInitiatorRequest& hidl_request, |
| 112 | legacy_hal::NanDataPathInitiatorRequest* legacy_request); |
| 113 | bool convertHidlNanDataPathIndicationResponseToLegacy( |
| 114 | const NanDataPathIndicationResponse& hidl_response, |
| 115 | legacy_hal::NanDataPathIndicationResponse* legacy_response); |
| 116 | bool convertHidlNanDataPathEndRequestToLegacy( |
| 117 | const NanDataPathEndRequest& hidl_request, |
| 118 | legacy_hal::NanDataPathEndRequest* legacy_request); |
| 119 | bool convertLegacyNanResponseHeaderToHidl( |
| 120 | const legacy_hal::NanResponseMsg& legacy_response, |
| 121 | NanResponseMsgHeader* hidl_response); |
| 122 | bool convertLegacyNanPublishResponseToHidl( |
| 123 | const legacy_hal::NanPublishResponse& legacy_response, |
| 124 | NanPublishResponse* hidl_response); |
| 125 | bool convertLegacyNanSubscribeResponseToHidl( |
| 126 | const legacy_hal::NanSubscribeResponse& legacy_response, |
| 127 | NanSubscribeResponse* hidl_response); |
| 128 | bool convertLegacyNanDataPathResponseToHidl( |
| 129 | const legacy_hal::NanDataPathRequestResponse& legacy_response, |
| 130 | NanDataPathResponse* hidl_response); |
| 131 | bool convertLegacyNanCapabilitiesResponseToHidl( |
| 132 | const legacy_hal::NanCapabilities& legacy_response, |
| 133 | NanCapabilitiesResponse* hidl_response); |
| 134 | bool convertLegacyNanPublishTerminatedIndToHidl( |
| 135 | const legacy_hal::NanPublishTerminatedInd& legacy_ind, |
| 136 | NanPublishTerminatedInd* hidl_ind); |
| 137 | bool convertLegacyNanMatchIndToHidl(const legacy_hal::NanMatchInd& legacy_ind, |
| 138 | NanMatchInd* hidl_ind); |
| 139 | bool convertLegacyNanMatchExpiredIndToHidl( |
| 140 | const legacy_hal::NanMatchExpiredInd& legacy_ind, |
| 141 | NanMatchExpiredInd* hidl_ind); |
| 142 | bool convertLegacyNanSubscribeTerminatedIndToHidl( |
| 143 | const legacy_hal::NanSubscribeTerminatedInd& legacy_ind, |
| 144 | NanSubscribeTerminatedInd* hidl_ind); |
| 145 | bool convertLegacyNanFollowupIndToHidl( |
| 146 | const legacy_hal::NanFollowupInd& legacy_ind, NanFollowupInd* hidl_ind); |
| 147 | bool convertLegacyNanDiscEngEventIndToHidl( |
| 148 | const legacy_hal::NanDiscEngEventInd& legacy_ind, |
| 149 | NanDiscEngEventInd* hidl_ind); |
| 150 | bool convertLegacyNanDisabledIndToHidl( |
| 151 | const legacy_hal::NanDisabledInd& legacy_ind, NanDisabledInd* hidl_ind); |
| 152 | bool convertLegacyNanBeaconSdfPayloadIndToHidl( |
| 153 | const legacy_hal::NanBeaconSdfPayloadInd& legacy_ind, |
| 154 | NanBeaconSdfPayloadInd* hidl_ind); |
| 155 | bool convertLegacyNanDataPathRequestIndToHidl( |
| 156 | const legacy_hal::NanDataPathRequestInd& legacy_ind, |
| 157 | NanDataPathRequestInd* hidl_ind); |
| 158 | bool convertLegacyNanDataPathConfirmIndToHidl( |
| 159 | const legacy_hal::NanDataPathConfirmInd& legacy_ind, |
| 160 | NanDataPathConfirmInd* hidl_ind); |
| 161 | bool convertLegacyNanDataPathEndIndToHidl( |
| 162 | const legacy_hal::NanDataPathEndInd& legacy_ind, |
| 163 | NanDataPathEndInd* hidl_ind); |
| 164 | bool convertLegacyNanTransmitFollowupIndToHidl( |
| 165 | const legacy_hal::NanTransmitFollowupInd& legacy_ind, |
| 166 | NanTransmitFollowupInd* hidl_ind); |
Roshan Pius | 3fae9c8 | 2016-12-02 14:49:41 -0800 | [diff] [blame] | 167 | |
| 168 | // RTT controller conversion methods. |
| 169 | bool convertHidlRttConfigToLegacy(const RttConfig& hidl_config, |
| 170 | legacy_hal::wifi_rtt_config* legacy_config); |
Roshan Pius | 3fae9c8 | 2016-12-02 14:49:41 -0800 | [diff] [blame] | 171 | bool convertHidlRttLciInformationToLegacy( |
| 172 | const RttLciInformation& hidl_info, |
| 173 | legacy_hal::wifi_lci_information* legacy_info); |
| 174 | bool convertHidlRttLcrInformationToLegacy( |
| 175 | const RttLcrInformation& hidl_info, |
| 176 | legacy_hal::wifi_lcr_information* legacy_info); |
| 177 | bool convertHidlRttResponderToLegacy( |
| 178 | const RttResponder& hidl_responder, |
| 179 | legacy_hal::wifi_rtt_responder* legacy_responder); |
| 180 | bool convertLegacyRttResponderToHidl( |
| 181 | const legacy_hal::wifi_rtt_responder& legacy_responder, |
| 182 | RttResponder* hidl_responder); |
| 183 | bool convertLegacyRttCapabilitiesToHidl( |
| 184 | const legacy_hal::wifi_rtt_capabilities& legacy_capabilities, |
| 185 | RttCapabilities* hidl_capabilities); |
| 186 | bool convertLegacyRttResultToHidl( |
| 187 | const legacy_hal::wifi_rtt_result& legacy_result, RttResult* hidl_result); |
Roshan Pius | e65edb1 | 2016-11-22 13:02:01 -0800 | [diff] [blame] | 188 | } // namespace hidl_struct_util |
| 189 | } // namespace implementation |
| 190 | } // namespace V1_0 |
| 191 | } // namespace wifi |
| 192 | } // namespace hardware |
| 193 | } // namespace android |
| 194 | |
| 195 | #endif // HIDL_STRUCT_UTIL_H_ |