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