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