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