blob: 11efe7efef39a230425feb417932607baa61cdac [file] [log] [blame]
Roshan Piusaabe5752016-09-29 09:03:59 -07001/*
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 Piuse73a5062016-12-12 08:53:34 -080017#ifndef WIFI_LEGACY_HAL_H_
18#define WIFI_LEGACY_HAL_H_
Roshan Piusaabe5752016-09-29 09:03:59 -070019
Roshan Piusabcf78f2017-10-06 16:30:38 -070020#include <condition_variable>
Roshan Piusaabe5752016-09-29 09:03:59 -070021#include <functional>
Roshan Piusacededb2017-10-06 14:59:26 -070022#include <map>
Roshan Piusaabe5752016-09-29 09:03:59 -070023#include <thread>
Roshan Pius734fea02016-10-11 08:30:28 -070024#include <vector>
Roshan Piusaabe5752016-09-29 09:03:59 -070025
Roshan Pius97334112016-11-18 14:07:54 -080026#include <wifi_system/interface_tool.h>
27
Josh Gao339c3c22018-07-19 11:14:49 -070028// 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 Kimda830c92018-07-23 15:29:38 -070030// 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 Gao339c3c22018-07-19 11:14:49 -070033#include <sys/socket.h>
34
Roshan Piusaabe5752016-09-29 09:03:59 -070035namespace android {
36namespace hardware {
37namespace wifi {
Jimmy Chend460df32019-11-29 17:31:22 +020038namespace V1_5 {
Roshan Piusaabe5752016-09-29 09:03:59 -070039namespace implementation {
Roshan Pius955542e2016-10-28 09:42:44 -070040// This is in a separate namespace to prevent typename conflicts between
41// the legacy HAL types and the HIDL interface types.
42namespace 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 Piusaabe5752016-09-29 09:03:59 -070046
Roshan Pius0a47c182016-10-28 10:23:00 -070047// APF capabilities supported by the iface.
48struct PacketFilterCapabilities {
Roshan Piusabcf78f2017-10-06 16:30:38 -070049 uint32_t version;
50 uint32_t max_len;
Roshan Pius0a47c182016-10-28 10:23:00 -070051};
52
Roshan Pius7cece412016-10-28 10:38:21 -070053// 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 Piuse42ace22017-03-13 10:44:20 -070061struct LinkLayerRadioStats {
Roshan Piusabcf78f2017-10-06 16:30:38 -070062 wifi_radio_stat stats;
63 std::vector<uint32_t> tx_time_per_levels;
Sunil Ravib0343e72018-11-13 15:52:00 -080064 std::vector<wifi_channel_stat> channel_stats;
Roshan Piuse42ace22017-03-13 10:44:20 -070065};
66
Roshan Pius7cece412016-10-28 10:38:21 -070067struct LinkLayerStats {
Roshan Piusabcf78f2017-10-06 16:30:38 -070068 wifi_iface_stat iface;
69 std::vector<LinkLayerRadioStats> radios;
Roshan Pius7cece412016-10-28 10:38:21 -070070};
71#pragma GCC diagnostic pop
72
Roshan Pius8714a3e2016-10-28 10:43:51 -070073// 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.
78struct WakeReasonStats {
Roshan Piusabcf78f2017-10-06 16:30:38 -070079 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 Pius8714a3e2016-10-28 10:43:51 -070082};
83
Roshan Pius23012092016-10-28 11:27:40 -070084// NAN response and event callbacks struct.
85struct NanCallbackHandlers {
Roshan Piusabcf78f2017-10-06 16:30:38 -070086 // 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 Kimda830c92018-07-23 15:29:38 -0700111 std::function<void(const NanDataPathScheduleUpdateInd&)>
112 on_event_schedule_update;
Roshan Pius23012092016-10-28 11:27:40 -0700113};
114
Roshan Pius76ff3022016-10-28 10:33:34 -0700115// 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.
118using 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.
122using on_gscan_results_callback = std::function<void(
123 wifi_request_id, const std::vector<wifi_cached_scan_results>&)>;
124
Roshan Piusd4767542016-12-06 10:04:05 -0800125// Invoked when the rssi value breaches the thresholds set.
126using on_rssi_threshold_breached_callback =
127 std::function<void(wifi_request_id, std::array<uint8_t, 6>, int8_t)>;
128
Roshan Piusd8e915a2016-10-28 11:23:11 -0700129// 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.
133using on_rtt_results_callback = std::function<void(
134 wifi_request_id, const std::vector<const wifi_rtt_result*>&)>;
135
Roshan Pius8714a3e2016-10-28 10:43:51 -0700136// Callback for ring buffer data.
137using on_ring_buffer_data_callback =
Roshan Piusabcf78f2017-10-06 16:30:38 -0700138 std::function<void(const std::string&, const std::vector<uint8_t>&,
Roshan Pius8714a3e2016-10-28 10:43:51 -0700139 const wifi_ring_buffer_status&)>;
140
Roshan Pius203cb032016-12-14 17:41:20 -0800141// Callback for alerts.
142using on_error_alert_callback =
143 std::function<void(int32_t, const std::vector<uint8_t>&)>;
Roshan Pius01f08772018-01-22 17:56:06 -0800144
Ahmed ElArabawy2134bf72020-06-18 15:07:12 -0700145// Callback for subsystem restart
146using on_subsystem_restart_callback = std::function<void(const std::string&)>;
147
Roshan Pius01f08772018-01-22 17:56:06 -0800148// Struct for the mac info from the legacy HAL. This is a cleaner version
149// of the |wifi_mac_info| & |wifi_iface_info|.
150typedef struct {
151 std::string name;
152 wifi_channel channel;
153} WifiIfaceInfo;
154
155typedef 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
164using on_radio_mode_change_callback =
165 std::function<void(const std::vector<WifiMacInfo>&)>;
166
Kai Shi2ca7a112020-12-15 19:51:28 -0800167// TWT response and event callbacks struct.
168struct TwtCallbackHandlers {
169 // Callback for TWT setup response
170 std::function<void(const TwtSetupResponse&)> on_setup_response;
171 // Callback for TWT teardown completion
172 std::function<void(const TwtTeardownCompletion&)> on_teardown_completion;
173 // Callback for TWT info frame received event
174 std::function<void(const TwtInfoFrameReceived&)> on_info_frame_received;
175 // Callback for TWT notification from the device
176 std::function<void(const TwtDeviceNotify&)> on_device_notify;
177};
178
Roshan Piusaabe5752016-09-29 09:03:59 -0700179/**
180 * Class that encapsulates all legacy HAL interactions.
181 * This class manages the lifetime of the event loop thread used by legacy HAL.
Roshan Pius742bb972017-02-02 09:54:27 -0800182 *
Bernie Innocentiefbb9c32018-03-07 00:17:50 +0900183 * Note: There will only be a single instance of this class created in the Wifi
Roshan Pius742bb972017-02-02 09:54:27 -0800184 * object and will be valid for the lifetime of the process.
Roshan Piusaabe5752016-09-29 09:03:59 -0700185 */
186class WifiLegacyHal {
Roshan Piusabcf78f2017-10-06 16:30:38 -0700187 public:
Jimmy Chen2dddd792019-12-23 17:50:39 +0200188 WifiLegacyHal(const std::weak_ptr<wifi_system::InterfaceTool> iface_tool,
189 const wifi_hal_fn& fn, bool is_primary);
Roshan Pius200a17d2017-11-01 13:03:35 -0700190 virtual ~WifiLegacyHal() = default;
Roshan Piusab5c4712016-10-06 14:37:15 -0700191
Roshan Piusabcf78f2017-10-06 16:30:38 -0700192 // Initialize the legacy HAL function table.
Roshan Pius200a17d2017-11-01 13:03:35 -0700193 virtual wifi_error initialize();
Roshan Piusabcf78f2017-10-06 16:30:38 -0700194 // Start the legacy HAL and the event looper thread.
Roshan Pius200a17d2017-11-01 13:03:35 -0700195 virtual wifi_error start();
Roshan Piusabcf78f2017-10-06 16:30:38 -0700196 // Deinitialize the legacy HAL and wait for the event loop thread to exit
197 // using a predefined timeout.
Roshan Pius200a17d2017-11-01 13:03:35 -0700198 virtual wifi_error stop(std::unique_lock<std::recursive_mutex>* lock,
199 const std::function<void()>& on_complete_callback);
Ahmed ElArabawy48229382019-02-07 22:04:53 -0800200 // Checks if legacy HAL has successfully started
201 bool isStarted();
Roshan Piusabcf78f2017-10-06 16:30:38 -0700202 // Wrappers for all the functions in the legacy HAL function table.
Roshan Pius1cd82a82019-03-25 13:51:28 -0700203 virtual std::pair<wifi_error, std::string> getDriverVersion(
Roshan Piusabcf78f2017-10-06 16:30:38 -0700204 const std::string& iface_name);
Roshan Pius1cd82a82019-03-25 13:51:28 -0700205 virtual std::pair<wifi_error, std::string> getFirmwareVersion(
Roshan Piusabcf78f2017-10-06 16:30:38 -0700206 const std::string& iface_name);
207 std::pair<wifi_error, std::vector<uint8_t>> requestDriverMemoryDump(
208 const std::string& iface_name);
209 std::pair<wifi_error, std::vector<uint8_t>> requestFirmwareMemoryDump(
210 const std::string& iface_name);
Jimmy Chen1bdf1a72019-12-23 17:53:40 +0200211 std::pair<wifi_error, uint64_t> getSupportedFeatureSet(
Roshan Piusabcf78f2017-10-06 16:30:38 -0700212 const std::string& iface_name);
213 // APF functions.
214 std::pair<wifi_error, PacketFilterCapabilities> getPacketFilterCapabilities(
215 const std::string& iface_name);
216 wifi_error setPacketFilter(const std::string& iface_name,
217 const std::vector<uint8_t>& program);
Bernie Innocentiefbb9c32018-03-07 00:17:50 +0900218 std::pair<wifi_error, std::vector<uint8_t>> readApfPacketFilterData(
219 const std::string& iface_name);
Roshan Piusabcf78f2017-10-06 16:30:38 -0700220 // Gscan functions.
221 std::pair<wifi_error, wifi_gscan_capabilities> getGscanCapabilities(
222 const std::string& iface_name);
223 // These API's provides a simplified interface over the legacy Gscan API's:
224 // a) All scan events from the legacy HAL API other than the
225 // |WIFI_SCAN_FAILED| are treated as notification of results.
226 // This method then retrieves the cached scan results from the legacy
227 // HAL API and triggers the externally provided
228 // |on_results_user_callback| on success.
229 // b) |WIFI_SCAN_FAILED| scan event or failure to retrieve cached scan
230 // results
231 // triggers the externally provided |on_failure_user_callback|.
232 // c) Full scan result event triggers the externally provided
233 // |on_full_result_user_callback|.
234 wifi_error startGscan(
235 const std::string& iface_name, wifi_request_id id,
236 const wifi_scan_cmd_params& params,
237 const std::function<void(wifi_request_id)>& on_failure_callback,
238 const on_gscan_results_callback& on_results_callback,
239 const on_gscan_full_result_callback& on_full_result_callback);
240 wifi_error stopGscan(const std::string& iface_name, wifi_request_id id);
241 std::pair<wifi_error, std::vector<uint32_t>> getValidFrequenciesForBand(
242 const std::string& iface_name, wifi_band band);
Roshan Pius200a17d2017-11-01 13:03:35 -0700243 virtual wifi_error setDfsFlag(const std::string& iface_name, bool dfs_on);
Roshan Piusabcf78f2017-10-06 16:30:38 -0700244 // Link layer stats functions.
245 wifi_error enableLinkLayerStats(const std::string& iface_name, bool debug);
246 wifi_error disableLinkLayerStats(const std::string& iface_name);
247 std::pair<wifi_error, LinkLayerStats> getLinkLayerStats(
248 const std::string& iface_name);
249 // RSSI monitor functions.
250 wifi_error startRssiMonitoring(const std::string& iface_name,
251 wifi_request_id id, int8_t max_rssi,
252 int8_t min_rssi,
253 const on_rssi_threshold_breached_callback&
254 on_threshold_breached_callback);
255 wifi_error stopRssiMonitoring(const std::string& iface_name,
256 wifi_request_id id);
257 std::pair<wifi_error, wifi_roaming_capabilities> getRoamingCapabilities(
258 const std::string& iface_name);
259 wifi_error configureRoaming(const std::string& iface_name,
260 const wifi_roaming_config& config);
261 wifi_error enableFirmwareRoaming(const std::string& iface_name,
262 fw_roaming_state_t state);
263 wifi_error configureNdOffload(const std::string& iface_name, bool enable);
264 wifi_error startSendingOffloadedPacket(
Ahmed ElArabawyffbad182019-03-05 17:38:06 -0800265 const std::string& iface_name, uint32_t cmd_id, uint16_t ether_type,
Roshan Piusabcf78f2017-10-06 16:30:38 -0700266 const std::vector<uint8_t>& ip_packet_data,
267 const std::array<uint8_t, 6>& src_address,
268 const std::array<uint8_t, 6>& dst_address, uint32_t period_in_ms);
269 wifi_error stopSendingOffloadedPacket(const std::string& iface_name,
270 uint32_t cmd_id);
Roshan Pius6036c022019-03-27 10:41:58 -0700271 virtual wifi_error selectTxPowerScenario(const std::string& iface_name,
272 wifi_power_scenario scenario);
273 virtual wifi_error resetTxPowerScenario(const std::string& iface_name);
Ahmed ElArabawyeaf82402018-10-26 09:46:04 -0700274 wifi_error setLatencyMode(const std::string& iface_name,
275 wifi_latency_mode mode);
Kumar Anandf2747e02020-01-10 16:49:13 -0800276 wifi_error setThermalMitigationMode(wifi_thermal_mode mode,
Kumar Anand913d5602019-12-18 16:02:37 -0800277 uint32_t completion_window);
Ahmed ElArabawya1d13652020-01-29 09:22:28 -0800278 wifi_error setDscpToAccessCategoryMapping(uint32_t start, uint32_t end,
279 uint32_t access_category);
280 wifi_error resetDscpToAccessCategoryMapping();
Roshan Piusabcf78f2017-10-06 16:30:38 -0700281 // Logger/debug functions.
282 std::pair<wifi_error, uint32_t> getLoggerSupportedFeatureSet(
283 const std::string& iface_name);
284 wifi_error startPktFateMonitoring(const std::string& iface_name);
285 std::pair<wifi_error, std::vector<wifi_tx_report>> getTxPktFates(
286 const std::string& iface_name);
287 std::pair<wifi_error, std::vector<wifi_rx_report>> getRxPktFates(
288 const std::string& iface_name);
289 std::pair<wifi_error, WakeReasonStats> getWakeReasonStats(
290 const std::string& iface_name);
291 wifi_error registerRingBufferCallbackHandler(
292 const std::string& iface_name,
293 const on_ring_buffer_data_callback& on_data_callback);
294 wifi_error deregisterRingBufferCallbackHandler(
295 const std::string& iface_name);
Ahmed ElArabawy2134bf72020-06-18 15:07:12 -0700296 wifi_error registerSubsystemRestartCallbackHandler(
297 const on_subsystem_restart_callback& on_restart_callback);
Roshan Piusabcf78f2017-10-06 16:30:38 -0700298 std::pair<wifi_error, std::vector<wifi_ring_buffer_status>>
299 getRingBuffersStatus(const std::string& iface_name);
300 wifi_error startRingBufferLogging(const std::string& iface_name,
301 const std::string& ring_name,
302 uint32_t verbose_level,
303 uint32_t max_interval_sec,
304 uint32_t min_data_size);
305 wifi_error getRingBufferData(const std::string& iface_name,
306 const std::string& ring_name);
307 wifi_error registerErrorAlertCallbackHandler(
308 const std::string& iface_name,
309 const on_error_alert_callback& on_alert_callback);
310 wifi_error deregisterErrorAlertCallbackHandler(
311 const std::string& iface_name);
Roshan Pius01f08772018-01-22 17:56:06 -0800312 // Radio mode functions.
Roshan Piusaceecb02018-03-01 14:54:26 -0800313 virtual wifi_error registerRadioModeChangeCallbackHandler(
Roshan Pius01f08772018-01-22 17:56:06 -0800314 const std::string& iface_name,
315 const on_radio_mode_change_callback& on_user_change_callback);
Roshan Piusabcf78f2017-10-06 16:30:38 -0700316 // RTT functions.
317 wifi_error startRttRangeRequest(
318 const std::string& iface_name, wifi_request_id id,
319 const std::vector<wifi_rtt_config>& rtt_configs,
320 const on_rtt_results_callback& on_results_callback);
321 wifi_error cancelRttRangeRequest(
322 const std::string& iface_name, wifi_request_id id,
323 const std::vector<std::array<uint8_t, 6>>& mac_addrs);
324 std::pair<wifi_error, wifi_rtt_capabilities> getRttCapabilities(
325 const std::string& iface_name);
326 std::pair<wifi_error, wifi_rtt_responder> getRttResponderInfo(
327 const std::string& iface_name);
328 wifi_error enableRttResponder(const std::string& iface_name,
329 wifi_request_id id,
330 const wifi_channel_info& channel_hint,
331 uint32_t max_duration_secs,
332 const wifi_rtt_responder& info);
333 wifi_error disableRttResponder(const std::string& iface_name,
334 wifi_request_id id);
335 wifi_error setRttLci(const std::string& iface_name, wifi_request_id id,
336 const wifi_lci_information& info);
337 wifi_error setRttLcr(const std::string& iface_name, wifi_request_id id,
338 const wifi_lcr_information& info);
339 // NAN functions.
Roshan Pius200a17d2017-11-01 13:03:35 -0700340 virtual wifi_error nanRegisterCallbackHandlers(
Roshan Piusabcf78f2017-10-06 16:30:38 -0700341 const std::string& iface_name, const NanCallbackHandlers& callbacks);
342 wifi_error nanEnableRequest(const std::string& iface_name,
343 transaction_id id, const NanEnableRequest& msg);
Roshan Pius200a17d2017-11-01 13:03:35 -0700344 virtual wifi_error nanDisableRequest(const std::string& iface_name,
345 transaction_id id);
Roshan Piusabcf78f2017-10-06 16:30:38 -0700346 wifi_error nanPublishRequest(const std::string& iface_name,
347 transaction_id id,
348 const NanPublishRequest& msg);
349 wifi_error nanPublishCancelRequest(const std::string& iface_name,
350 transaction_id id,
351 const NanPublishCancelRequest& msg);
352 wifi_error nanSubscribeRequest(const std::string& iface_name,
353 transaction_id id,
354 const NanSubscribeRequest& msg);
355 wifi_error nanSubscribeCancelRequest(const std::string& iface_name,
356 transaction_id id,
357 const NanSubscribeCancelRequest& msg);
358 wifi_error nanTransmitFollowupRequest(
359 const std::string& iface_name, transaction_id id,
360 const NanTransmitFollowupRequest& msg);
361 wifi_error nanStatsRequest(const std::string& iface_name, transaction_id id,
362 const NanStatsRequest& msg);
363 wifi_error nanConfigRequest(const std::string& iface_name,
364 transaction_id id, const NanConfigRequest& msg);
365 wifi_error nanTcaRequest(const std::string& iface_name, transaction_id id,
366 const NanTCARequest& msg);
367 wifi_error nanBeaconSdfPayloadRequest(
368 const std::string& iface_name, transaction_id id,
369 const NanBeaconSdfPayloadRequest& msg);
370 std::pair<wifi_error, NanVersion> nanGetVersion();
371 wifi_error nanGetCapabilities(const std::string& iface_name,
372 transaction_id id);
373 wifi_error nanDataInterfaceCreate(const std::string& iface_name,
374 transaction_id id,
375 const std::string& data_iface_name);
Roshan Pius200a17d2017-11-01 13:03:35 -0700376 virtual wifi_error nanDataInterfaceDelete(
377 const std::string& iface_name, transaction_id id,
378 const std::string& data_iface_name);
Roshan Piusabcf78f2017-10-06 16:30:38 -0700379 wifi_error nanDataRequestInitiator(const std::string& iface_name,
380 transaction_id id,
381 const NanDataPathInitiatorRequest& msg);
382 wifi_error nanDataIndicationResponse(
383 const std::string& iface_name, transaction_id id,
384 const NanDataPathIndicationResponse& msg);
385 wifi_error nanDataEnd(const std::string& iface_name, transaction_id id,
386 uint32_t ndpInstanceId);
387 // AP functions.
388 wifi_error setCountryCode(const std::string& iface_name,
389 std::array<int8_t, 2> code);
Roshan Piusaabe5752016-09-29 09:03:59 -0700390
Sunil Raviddab4bb2020-02-03 22:45:19 -0800391 // interface functions.
Roshan Pius5ba0a902020-04-14 11:55:42 -0700392 virtual wifi_error createVirtualInterface(const std::string& ifname,
393 wifi_interface_type iftype);
394 virtual wifi_error deleteVirtualInterface(const std::string& ifname);
Jimmy Chen2dddd792019-12-23 17:50:39 +0200395 wifi_error getSupportedIfaceName(uint32_t iface_type, std::string& ifname);
Sunil Raviddab4bb2020-02-03 22:45:19 -0800396
Roshan Piuse9d1e7d2020-11-04 11:44:16 -0800397 // STA + STA functions
398 virtual wifi_error multiStaSetPrimaryConnection(const std::string& ifname);
399 virtual wifi_error multiStaSetUseCase(wifi_multi_sta_use_case use_case);
400
Quang Luong94bcce52020-11-25 17:52:19 -0800401 // Coex functions.
402 virtual wifi_error setCoexUnsafeChannels(
403 std::vector<wifi_coex_unsafe_channel> unsafe_channels,
404 uint32_t restrictions);
405
Kai Shi2ca7a112020-12-15 19:51:28 -0800406 wifi_error setVoipMode(const std::string& iface_name, wifi_voip_mode mode);
407
408 wifi_error twtRegisterHandler(const std::string& iface_name,
409 const TwtCallbackHandlers& handler);
410
411 std::pair<wifi_error, TwtCapabilitySet> twtGetCapability(
412 const std::string& iface_name);
413
414 wifi_error twtSetupRequest(const std::string& iface_name,
415 const TwtSetupRequest& msg);
416
417 wifi_error twtTearDownRequest(const std::string& iface_name,
418 const TwtTeardownRequest& msg);
419
420 wifi_error twtInfoFrameRequest(const std::string& iface_name,
421 const TwtInfoFrameRequest& msg);
422
423 std::pair<wifi_error, TwtStats> twtGetStats(const std::string& iface_name,
424 uint8_t configId);
425
426 wifi_error twtClearStats(const std::string& iface_name, uint8_t configId);
427
Roshan Piusabcf78f2017-10-06 16:30:38 -0700428 private:
429 // Retrieve interface handles for all the available interfaces.
430 wifi_error retrieveIfaceHandles();
431 wifi_interface_handle getIfaceHandle(const std::string& iface_name);
432 // Run the legacy HAL event loop thread.
433 void runEventLoop();
434 // Retrieve the cached gscan results to pass the results back to the
435 // external callbacks.
436 std::pair<wifi_error, std::vector<wifi_cached_scan_results>>
437 getGscanCachedResults(const std::string& iface_name);
438 void invalidate();
Sunil Raviddab4bb2020-02-03 22:45:19 -0800439 // Handles wifi (error) status of Virtual interface create/delete
440 wifi_error handleVirtualInterfaceCreateOrDeleteStatus(
441 const std::string& ifname, wifi_error status);
Roshan Piusaabe5752016-09-29 09:03:59 -0700442
Roshan Piusabcf78f2017-10-06 16:30:38 -0700443 // Global function table of legacy HAL.
444 wifi_hal_fn global_func_table_;
445 // Opaque handle to be used for all global operations.
446 wifi_handle global_handle_;
447 // Map of interface name to handle that is to be used for all interface
448 // specific operations.
449 std::map<std::string, wifi_interface_handle> iface_name_to_handle_;
450 // Flag to indicate if we have initiated the cleanup of legacy HAL.
451 std::atomic<bool> awaiting_event_loop_termination_;
452 std::condition_variable_any stop_wait_cv_;
453 // Flag to indicate if the legacy HAL has been started.
454 bool is_started_;
Roshan Piusc885df02019-05-21 14:49:05 -0700455 std::weak_ptr<wifi_system::InterfaceTool> iface_tool_;
Jimmy Chen2dddd792019-12-23 17:50:39 +0200456 // flag to indicate if this HAL is for the primary chip. This is used
457 // in order to avoid some hard-coded behavior used with older HALs,
458 // such as bring wlan0 interface up/down on start/stop HAL.
459 // it may be removed once vendor HALs are updated.
460 bool is_primary_;
Roshan Piusaabe5752016-09-29 09:03:59 -0700461};
462
Roshan Pius955542e2016-10-28 09:42:44 -0700463} // namespace legacy_hal
Roshan Piusaabe5752016-09-29 09:03:59 -0700464} // namespace implementation
Jimmy Chend460df32019-11-29 17:31:22 +0200465} // namespace V1_5
Roshan Piusaabe5752016-09-29 09:03:59 -0700466} // namespace wifi
467} // namespace hardware
468} // namespace android
469
Roshan Piuse73a5062016-12-12 08:53:34 -0800470#endif // WIFI_LEGACY_HAL_H_