Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [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 | |
Roshan Pius | e73a506 | 2016-12-12 08:53:34 -0800 | [diff] [blame] | 17 | #ifndef WIFI_LEGACY_HAL_H_ |
| 18 | #define WIFI_LEGACY_HAL_H_ |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 19 | |
| 20 | #include <functional> |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame^] | 21 | #include <map> |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 22 | #include <thread> |
Roshan Pius | 734fea0 | 2016-10-11 08:30:28 -0700 | [diff] [blame] | 23 | #include <vector> |
Roshan Pius | 155344b | 2017-08-11 15:47:42 -0700 | [diff] [blame] | 24 | #include <condition_variable> |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 25 | |
Roshan Pius | 9733411 | 2016-11-18 14:07:54 -0800 | [diff] [blame] | 26 | #include <wifi_system/interface_tool.h> |
| 27 | |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 28 | namespace android { |
| 29 | namespace hardware { |
| 30 | namespace wifi { |
Etan Cohen | 6ce5090 | 2017-09-14 07:30:57 -0700 | [diff] [blame] | 31 | namespace V1_2 { |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 32 | namespace implementation { |
Roshan Pius | 955542e | 2016-10-28 09:42:44 -0700 | [diff] [blame] | 33 | // This is in a separate namespace to prevent typename conflicts between |
| 34 | // the legacy HAL types and the HIDL interface types. |
| 35 | namespace legacy_hal { |
| 36 | // Wrap all the types defined inside the legacy HAL header files inside this |
| 37 | // namespace. |
| 38 | #include <hardware_legacy/wifi_hal.h> |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 39 | |
Roshan Pius | 0a47c18 | 2016-10-28 10:23:00 -0700 | [diff] [blame] | 40 | // APF capabilities supported by the iface. |
| 41 | struct PacketFilterCapabilities { |
| 42 | uint32_t version; |
| 43 | uint32_t max_len; |
| 44 | }; |
| 45 | |
Roshan Pius | 7cece41 | 2016-10-28 10:38:21 -0700 | [diff] [blame] | 46 | // WARNING: We don't care about the variable sized members of either |
| 47 | // |wifi_iface_stat|, |wifi_radio_stat| structures. So, using the pragma |
| 48 | // to escape the compiler warnings regarding this. |
| 49 | #pragma GCC diagnostic push |
| 50 | #pragma GCC diagnostic ignored "-Wgnu-variable-sized-type-not-at-end" |
| 51 | // The |wifi_radio_stat.tx_time_per_levels| stats is provided as a pointer in |
| 52 | // |wifi_radio_stat| structure in the legacy HAL API. Separate that out |
| 53 | // into a separate return element to avoid passing pointers around. |
Roshan Pius | e42ace2 | 2017-03-13 10:44:20 -0700 | [diff] [blame] | 54 | struct LinkLayerRadioStats { |
| 55 | wifi_radio_stat stats; |
| 56 | std::vector<uint32_t> tx_time_per_levels; |
| 57 | }; |
| 58 | |
Roshan Pius | 7cece41 | 2016-10-28 10:38:21 -0700 | [diff] [blame] | 59 | struct LinkLayerStats { |
| 60 | wifi_iface_stat iface; |
Roshan Pius | e42ace2 | 2017-03-13 10:44:20 -0700 | [diff] [blame] | 61 | std::vector<LinkLayerRadioStats> radios; |
Roshan Pius | 7cece41 | 2016-10-28 10:38:21 -0700 | [diff] [blame] | 62 | }; |
| 63 | #pragma GCC diagnostic pop |
| 64 | |
Roshan Pius | 8714a3e | 2016-10-28 10:43:51 -0700 | [diff] [blame] | 65 | // The |WLAN_DRIVER_WAKE_REASON_CNT.cmd_event_wake_cnt| and |
| 66 | // |WLAN_DRIVER_WAKE_REASON_CNT.driver_fw_local_wake_cnt| stats is provided |
| 67 | // as a pointer in |WLAN_DRIVER_WAKE_REASON_CNT| structure in the legacy HAL |
| 68 | // API. Separate that out into a separate return elements to avoid passing |
| 69 | // pointers around. |
| 70 | struct WakeReasonStats { |
| 71 | WLAN_DRIVER_WAKE_REASON_CNT wake_reason_cnt; |
| 72 | std::vector<uint32_t> cmd_event_wake_cnt; |
| 73 | std::vector<uint32_t> driver_fw_local_wake_cnt; |
| 74 | }; |
| 75 | |
Roshan Pius | 2301209 | 2016-10-28 11:27:40 -0700 | [diff] [blame] | 76 | // NAN response and event callbacks struct. |
| 77 | struct NanCallbackHandlers { |
| 78 | // NotifyResponse invoked to notify the status of the Request. |
| 79 | std::function<void(transaction_id, const NanResponseMsg&)> on_notify_response; |
| 80 | // Various event callbacks. |
| 81 | std::function<void(const NanPublishTerminatedInd&)> |
| 82 | on_event_publish_terminated; |
| 83 | std::function<void(const NanMatchInd&)> on_event_match; |
| 84 | std::function<void(const NanMatchExpiredInd&)> on_event_match_expired; |
| 85 | std::function<void(const NanSubscribeTerminatedInd&)> |
| 86 | on_event_subscribe_terminated; |
| 87 | std::function<void(const NanFollowupInd&)> on_event_followup; |
| 88 | std::function<void(const NanDiscEngEventInd&)> on_event_disc_eng_event; |
| 89 | std::function<void(const NanDisabledInd&)> on_event_disabled; |
| 90 | std::function<void(const NanTCAInd&)> on_event_tca; |
| 91 | std::function<void(const NanBeaconSdfPayloadInd&)> |
| 92 | on_event_beacon_sdf_payload; |
| 93 | std::function<void(const NanDataPathRequestInd&)> on_event_data_path_request; |
| 94 | std::function<void(const NanDataPathConfirmInd&)> on_event_data_path_confirm; |
| 95 | std::function<void(const NanDataPathEndInd&)> on_event_data_path_end; |
| 96 | std::function<void(const NanTransmitFollowupInd&)> |
| 97 | on_event_transmit_follow_up; |
Etan Cohen | c190f93 | 2017-02-17 13:06:55 -0800 | [diff] [blame] | 98 | std::function<void(const NanRangeRequestInd&)> |
| 99 | on_event_range_request; |
| 100 | std::function<void(const NanRangeReportInd&)> |
| 101 | on_event_range_report; |
Roshan Pius | 2301209 | 2016-10-28 11:27:40 -0700 | [diff] [blame] | 102 | }; |
| 103 | |
Roshan Pius | 76ff302 | 2016-10-28 10:33:34 -0700 | [diff] [blame] | 104 | // Full scan results contain IE info and are hence passed by reference, to |
| 105 | // preserve the variable length array member |ie_data|. Callee must not retain |
| 106 | // the pointer. |
| 107 | using on_gscan_full_result_callback = |
| 108 | std::function<void(wifi_request_id, const wifi_scan_result*, uint32_t)>; |
| 109 | // These scan results don't contain any IE info, so no need to pass by |
| 110 | // reference. |
| 111 | using on_gscan_results_callback = std::function<void( |
| 112 | wifi_request_id, const std::vector<wifi_cached_scan_results>&)>; |
| 113 | |
Roshan Pius | d476754 | 2016-12-06 10:04:05 -0800 | [diff] [blame] | 114 | // Invoked when the rssi value breaches the thresholds set. |
| 115 | using on_rssi_threshold_breached_callback = |
| 116 | std::function<void(wifi_request_id, std::array<uint8_t, 6>, int8_t)>; |
| 117 | |
Roshan Pius | d8e915a | 2016-10-28 11:23:11 -0700 | [diff] [blame] | 118 | // Callback for RTT range request results. |
| 119 | // Rtt results contain IE info and are hence passed by reference, to |
| 120 | // preserve the |LCI| and |LCR| pointers. Callee must not retain |
| 121 | // the pointer. |
| 122 | using on_rtt_results_callback = std::function<void( |
| 123 | wifi_request_id, const std::vector<const wifi_rtt_result*>&)>; |
| 124 | |
Roshan Pius | 8714a3e | 2016-10-28 10:43:51 -0700 | [diff] [blame] | 125 | // Callback for ring buffer data. |
| 126 | using on_ring_buffer_data_callback = |
| 127 | std::function<void(const std::string&, |
| 128 | const std::vector<uint8_t>&, |
| 129 | const wifi_ring_buffer_status&)>; |
| 130 | |
Roshan Pius | 203cb03 | 2016-12-14 17:41:20 -0800 | [diff] [blame] | 131 | // Callback for alerts. |
| 132 | using on_error_alert_callback = |
| 133 | std::function<void(int32_t, const std::vector<uint8_t>&)>; |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 134 | /** |
| 135 | * Class that encapsulates all legacy HAL interactions. |
| 136 | * This class manages the lifetime of the event loop thread used by legacy HAL. |
Roshan Pius | 742bb97 | 2017-02-02 09:54:27 -0800 | [diff] [blame] | 137 | * |
| 138 | * Note: aThere will only be a single instance of this class created in the Wifi |
| 139 | * object and will be valid for the lifetime of the process. |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 140 | */ |
| 141 | class WifiLegacyHal { |
| 142 | public: |
| 143 | WifiLegacyHal(); |
Roshan Pius | ab5c471 | 2016-10-06 14:37:15 -0700 | [diff] [blame] | 144 | |
Roshan Pius | 9733411 | 2016-11-18 14:07:54 -0800 | [diff] [blame] | 145 | // Initialize the legacy HAL function table. |
| 146 | wifi_error initialize(); |
| 147 | // Start the legacy HAL and the event looper thread. |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 148 | wifi_error start(); |
Roshan Pius | 155344b | 2017-08-11 15:47:42 -0700 | [diff] [blame] | 149 | // Deinitialize the legacy HAL and wait for the event loop thread to exit |
| 150 | // using a predefined timeout. |
| 151 | wifi_error stop(std::unique_lock<std::recursive_mutex>* lock, |
| 152 | const std::function<void()>& on_complete_callback); |
Roshan Pius | 4b26c83 | 2016-10-03 12:49:58 -0700 | [diff] [blame] | 153 | // Wrappers for all the functions in the legacy HAL function table. |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame^] | 154 | std::pair<wifi_error, std::string> getDriverVersion( |
| 155 | const std::string& iface_name); |
| 156 | std::pair<wifi_error, std::string> getFirmwareVersion( |
| 157 | const std::string& iface_name); |
| 158 | std::pair<wifi_error, std::vector<uint8_t>> requestDriverMemoryDump( |
| 159 | const std::string& iface_name); |
| 160 | std::pair<wifi_error, std::vector<uint8_t>> requestFirmwareMemoryDump( |
| 161 | const std::string& iface_name); |
| 162 | std::pair<wifi_error, uint32_t> getSupportedFeatureSet( |
| 163 | const std::string& iface_name); |
Roshan Pius | 0a47c18 | 2016-10-28 10:23:00 -0700 | [diff] [blame] | 164 | // APF functions. |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame^] | 165 | std::pair<wifi_error, PacketFilterCapabilities> getPacketFilterCapabilities( |
| 166 | const std::string& iface_name); |
| 167 | wifi_error setPacketFilter( |
| 168 | const std::string& iface_name, const std::vector<uint8_t>& program); |
Roshan Pius | 76ff302 | 2016-10-28 10:33:34 -0700 | [diff] [blame] | 169 | // Gscan functions. |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame^] | 170 | std::pair<wifi_error, wifi_gscan_capabilities> getGscanCapabilities( |
| 171 | const std::string& iface_name); |
Roshan Pius | 76ff302 | 2016-10-28 10:33:34 -0700 | [diff] [blame] | 172 | // These API's provides a simplified interface over the legacy Gscan API's: |
| 173 | // a) All scan events from the legacy HAL API other than the |
| 174 | // |WIFI_SCAN_FAILED| are treated as notification of results. |
| 175 | // This method then retrieves the cached scan results from the legacy |
| 176 | // HAL API and triggers the externally provided |on_results_user_callback| |
| 177 | // on success. |
| 178 | // b) |WIFI_SCAN_FAILED| scan event or failure to retrieve cached scan results |
| 179 | // triggers the externally provided |on_failure_user_callback|. |
| 180 | // c) Full scan result event triggers the externally provided |
| 181 | // |on_full_result_user_callback|. |
| 182 | wifi_error startGscan( |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame^] | 183 | const std::string& iface_name, |
Roshan Pius | 76ff302 | 2016-10-28 10:33:34 -0700 | [diff] [blame] | 184 | wifi_request_id id, |
| 185 | const wifi_scan_cmd_params& params, |
| 186 | const std::function<void(wifi_request_id)>& on_failure_callback, |
| 187 | const on_gscan_results_callback& on_results_callback, |
| 188 | const on_gscan_full_result_callback& on_full_result_callback); |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame^] | 189 | wifi_error stopGscan(const std::string& iface_name, wifi_request_id id); |
Roshan Pius | 7f4574d | 2017-02-22 09:48:03 -0800 | [diff] [blame] | 190 | std::pair<wifi_error, std::vector<uint32_t>> getValidFrequenciesForBand( |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame^] | 191 | const std::string& iface_name, wifi_band band); |
| 192 | wifi_error setDfsFlag(const std::string& iface_name, bool dfs_on); |
Roshan Pius | 7cece41 | 2016-10-28 10:38:21 -0700 | [diff] [blame] | 193 | // Link layer stats functions. |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame^] | 194 | wifi_error enableLinkLayerStats(const std::string& iface_name, bool debug); |
| 195 | wifi_error disableLinkLayerStats(const std::string& iface_name); |
| 196 | std::pair<wifi_error, LinkLayerStats> getLinkLayerStats( |
| 197 | const std::string& iface_name); |
Roshan Pius | d476754 | 2016-12-06 10:04:05 -0800 | [diff] [blame] | 198 | // RSSI monitor functions. |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame^] | 199 | wifi_error startRssiMonitoring( |
| 200 | const std::string& iface_name, wifi_request_id id, int8_t max_rssi, |
| 201 | int8_t min_rssi, const on_rssi_threshold_breached_callback& |
| 202 | on_threshold_breached_callback); |
| 203 | wifi_error stopRssiMonitoring( |
| 204 | const std::string& iface_name, wifi_request_id id); |
| 205 | std::pair<wifi_error, wifi_roaming_capabilities> getRoamingCapabilities( |
| 206 | const std::string& iface_name); |
| 207 | wifi_error configureRoaming( |
| 208 | const std::string& iface_name, const wifi_roaming_config& config); |
| 209 | wifi_error enableFirmwareRoaming( |
| 210 | const std::string& iface_name, fw_roaming_state_t state); |
| 211 | wifi_error configureNdOffload(const std::string& iface_name, bool enable); |
Roshan Pius | 9a9869a | 2017-01-11 16:42:16 -0800 | [diff] [blame] | 212 | wifi_error startSendingOffloadedPacket( |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame^] | 213 | const std::string& iface_name, |
Roshan Pius | 9a9869a | 2017-01-11 16:42:16 -0800 | [diff] [blame] | 214 | uint32_t cmd_id, |
| 215 | const std::vector<uint8_t>& ip_packet_data, |
| 216 | const std::array<uint8_t, 6>& src_address, |
| 217 | const std::array<uint8_t, 6>& dst_address, |
| 218 | uint32_t period_in_ms); |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame^] | 219 | wifi_error stopSendingOffloadedPacket( |
| 220 | const std::string& iface_name, uint32_t cmd_id); |
| 221 | wifi_error setScanningMacOui( |
| 222 | const std::string& iface_name, const std::array<uint8_t, 3>& oui); |
| 223 | wifi_error selectTxPowerScenario( |
| 224 | const std::string& iface_name, wifi_power_scenario scenario); |
| 225 | wifi_error resetTxPowerScenario(const std::string& iface_name); |
Roshan Pius | 8714a3e | 2016-10-28 10:43:51 -0700 | [diff] [blame] | 226 | // Logger/debug functions. |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame^] | 227 | std::pair<wifi_error, uint32_t> getLoggerSupportedFeatureSet( |
| 228 | const std::string& iface_name); |
| 229 | wifi_error startPktFateMonitoring(const std::string& iface_name); |
| 230 | std::pair<wifi_error, std::vector<wifi_tx_report>> getTxPktFates( |
| 231 | const std::string& iface_name); |
| 232 | std::pair<wifi_error, std::vector<wifi_rx_report>> getRxPktFates( |
| 233 | const std::string& iface_name); |
| 234 | std::pair<wifi_error, WakeReasonStats> getWakeReasonStats( |
| 235 | const std::string& iface_name); |
Roshan Pius | 8714a3e | 2016-10-28 10:43:51 -0700 | [diff] [blame] | 236 | wifi_error registerRingBufferCallbackHandler( |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame^] | 237 | const std::string& iface_name, |
Roshan Pius | 8714a3e | 2016-10-28 10:43:51 -0700 | [diff] [blame] | 238 | const on_ring_buffer_data_callback& on_data_callback); |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame^] | 239 | wifi_error deregisterRingBufferCallbackHandler(const std::string& iface_name); |
Roshan Pius | 8714a3e | 2016-10-28 10:43:51 -0700 | [diff] [blame] | 240 | std::pair<wifi_error, std::vector<wifi_ring_buffer_status>> |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame^] | 241 | getRingBuffersStatus(const std::string& iface_name); |
| 242 | wifi_error startRingBufferLogging( |
| 243 | const std::string& iface_name, const std::string& ring_name, |
| 244 | uint32_t verbose_level, uint32_t max_interval_sec, |
| 245 | uint32_t min_data_size); |
| 246 | wifi_error getRingBufferData( |
| 247 | const std::string& iface_name, const std::string& ring_name); |
Roshan Pius | 203cb03 | 2016-12-14 17:41:20 -0800 | [diff] [blame] | 248 | wifi_error registerErrorAlertCallbackHandler( |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame^] | 249 | const std::string& iface_name, |
Roshan Pius | 203cb03 | 2016-12-14 17:41:20 -0800 | [diff] [blame] | 250 | const on_error_alert_callback& on_alert_callback); |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame^] | 251 | wifi_error deregisterErrorAlertCallbackHandler(const std::string& iface_name); |
Roshan Pius | d8e915a | 2016-10-28 11:23:11 -0700 | [diff] [blame] | 252 | // RTT functions. |
| 253 | wifi_error startRttRangeRequest( |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame^] | 254 | const std::string& iface_name, |
Roshan Pius | d8e915a | 2016-10-28 11:23:11 -0700 | [diff] [blame] | 255 | wifi_request_id id, |
| 256 | const std::vector<wifi_rtt_config>& rtt_configs, |
| 257 | const on_rtt_results_callback& on_results_callback); |
| 258 | wifi_error cancelRttRangeRequest( |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame^] | 259 | const std::string& iface_name, wifi_request_id id, |
| 260 | const std::vector<std::array<uint8_t, 6>>& mac_addrs); |
| 261 | std::pair<wifi_error, wifi_rtt_capabilities> getRttCapabilities( |
| 262 | const std::string& iface_name); |
| 263 | std::pair<wifi_error, wifi_rtt_responder> getRttResponderInfo( |
| 264 | const std::string& iface_name); |
| 265 | wifi_error enableRttResponder( |
| 266 | const std::string& iface_name, wifi_request_id id, |
| 267 | const wifi_channel_info& channel_hint, uint32_t max_duration_secs, |
| 268 | const wifi_rtt_responder& info); |
| 269 | wifi_error disableRttResponder( |
| 270 | const std::string& iface_name, wifi_request_id id); |
| 271 | wifi_error setRttLci( |
| 272 | const std::string& iface_name, wifi_request_id id, |
| 273 | const wifi_lci_information& info); |
| 274 | wifi_error setRttLcr( |
| 275 | const std::string& iface_name, wifi_request_id id, |
| 276 | const wifi_lcr_information& info); |
Roshan Pius | 2301209 | 2016-10-28 11:27:40 -0700 | [diff] [blame] | 277 | // NAN functions. |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame^] | 278 | wifi_error nanRegisterCallbackHandlers( |
| 279 | const std::string& iface_name, const NanCallbackHandlers& callbacks); |
| 280 | wifi_error nanEnableRequest( |
| 281 | const std::string& iface_name, transaction_id id, |
| 282 | const NanEnableRequest& msg); |
| 283 | wifi_error nanDisableRequest( |
| 284 | const std::string& iface_name, transaction_id id); |
| 285 | wifi_error nanPublishRequest( |
| 286 | const std::string& iface_name, transaction_id id, |
| 287 | const NanPublishRequest& msg); |
| 288 | wifi_error nanPublishCancelRequest( |
| 289 | const std::string& iface_name, transaction_id id, |
| 290 | const NanPublishCancelRequest& msg); |
| 291 | wifi_error nanSubscribeRequest( |
| 292 | const std::string& iface_name, transaction_id id, |
| 293 | const NanSubscribeRequest& msg); |
| 294 | wifi_error nanSubscribeCancelRequest( |
| 295 | const std::string& iface_name, transaction_id id, |
| 296 | const NanSubscribeCancelRequest& msg); |
| 297 | wifi_error nanTransmitFollowupRequest( |
| 298 | const std::string& iface_name, transaction_id id, |
| 299 | const NanTransmitFollowupRequest& msg); |
| 300 | wifi_error nanStatsRequest( |
| 301 | const std::string& iface_name, transaction_id id, |
| 302 | const NanStatsRequest& msg); |
| 303 | wifi_error nanConfigRequest( |
| 304 | const std::string& iface_name, transaction_id id, |
| 305 | const NanConfigRequest& msg); |
| 306 | wifi_error nanTcaRequest( |
| 307 | const std::string& iface_name, transaction_id id, |
| 308 | const NanTCARequest& msg); |
| 309 | wifi_error nanBeaconSdfPayloadRequest( |
| 310 | const std::string& iface_name, transaction_id id, |
| 311 | const NanBeaconSdfPayloadRequest& msg); |
Roshan Pius | 2301209 | 2016-10-28 11:27:40 -0700 | [diff] [blame] | 312 | std::pair<wifi_error, NanVersion> nanGetVersion(); |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame^] | 313 | wifi_error nanGetCapabilities( |
| 314 | const std::string& iface_name, transaction_id id); |
| 315 | wifi_error nanDataInterfaceCreate( |
| 316 | const std::string& iface_name, transaction_id id, |
| 317 | const std::string& data_iface_name); |
| 318 | wifi_error nanDataInterfaceDelete( |
| 319 | const std::string& iface_name, transaction_id id, |
| 320 | const std::string& data_iface_name); |
| 321 | wifi_error nanDataRequestInitiator( |
| 322 | const std::string& iface_name, transaction_id id, |
| 323 | const NanDataPathInitiatorRequest& msg); |
Roshan Pius | 2301209 | 2016-10-28 11:27:40 -0700 | [diff] [blame] | 324 | wifi_error nanDataIndicationResponse( |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame^] | 325 | const std::string& iface_name, transaction_id id, |
| 326 | const NanDataPathIndicationResponse& msg); |
| 327 | wifi_error nanDataEnd( |
| 328 | const std::string& iface_name, transaction_id id, uint32_t ndpInstanceId); |
Roshan Pius | 32fc12e | 2017-01-25 17:44:42 -0800 | [diff] [blame] | 329 | // AP functions. |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame^] | 330 | wifi_error setCountryCode( |
| 331 | const std::string& iface_name, std::array<int8_t, 2> code); |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 332 | |
| 333 | private: |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame^] | 334 | // Retrieve interface handles for all the available interfaces. |
| 335 | wifi_error retrieveIfaceHandles(); |
| 336 | wifi_interface_handle getIfaceHandle(const std::string& iface_name); |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 337 | // Run the legacy HAL event loop thread. |
| 338 | void runEventLoop(); |
Roshan Pius | 76ff302 | 2016-10-28 10:33:34 -0700 | [diff] [blame] | 339 | // Retrieve the cached gscan results to pass the results back to the external |
| 340 | // callbacks. |
| 341 | std::pair<wifi_error, std::vector<wifi_cached_scan_results>> |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame^] | 342 | getGscanCachedResults(const std::string& iface_name); |
Roshan Pius | 511cc49 | 2016-10-28 09:54:26 -0700 | [diff] [blame] | 343 | void invalidate(); |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 344 | |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 345 | // Global function table of legacy HAL. |
| 346 | wifi_hal_fn global_func_table_; |
| 347 | // Opaque handle to be used for all global operations. |
| 348 | wifi_handle global_handle_; |
Roshan Pius | acededb | 2017-10-06 14:59:26 -0700 | [diff] [blame^] | 349 | // Map of interface name to handle that is to be used for all interface specific operations. |
| 350 | std::map<std::string, wifi_interface_handle> iface_name_to_handle_; |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 351 | // Flag to indicate if we have initiated the cleanup of legacy HAL. |
Roshan Pius | d32a43f | 2017-03-14 08:30:45 -0700 | [diff] [blame] | 352 | std::atomic<bool> awaiting_event_loop_termination_; |
Roshan Pius | 155344b | 2017-08-11 15:47:42 -0700 | [diff] [blame] | 353 | std::condition_variable_any stop_wait_cv_; |
Roshan Pius | 11f9303 | 2016-12-09 10:26:17 -0800 | [diff] [blame] | 354 | // Flag to indicate if the legacy HAL has been started. |
| 355 | bool is_started_; |
Roshan Pius | 9733411 | 2016-11-18 14:07:54 -0800 | [diff] [blame] | 356 | wifi_system::InterfaceTool iface_tool_; |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 357 | }; |
| 358 | |
Roshan Pius | 955542e | 2016-10-28 09:42:44 -0700 | [diff] [blame] | 359 | } // namespace legacy_hal |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 360 | } // namespace implementation |
Etan Cohen | 6ce5090 | 2017-09-14 07:30:57 -0700 | [diff] [blame] | 361 | } // namespace V1_2 |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 362 | } // namespace wifi |
| 363 | } // namespace hardware |
| 364 | } // namespace android |
| 365 | |
Roshan Pius | e73a506 | 2016-12-12 08:53:34 -0800 | [diff] [blame] | 366 | #endif // WIFI_LEGACY_HAL_H_ |