blob: b6bd5ea6ba1624570c469af9ab431e8a2687833e [file] [log] [blame]
Roshan Piusaabe5752016-09-29 09:03:59 -07001/*
Gabriel Biren631a8112022-12-01 22:29:32 +00002 * Copyright (C) 2016 The Android Open Source Project
Roshan Piusaabe5752016-09-29 09:03:59 -07003 *
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
Gabriel Birene58e2632022-07-15 23:25:39 +000020#include <condition_variable>
21#include <functional>
22#include <map>
Gabriel Birene58e2632022-07-15 23:25:39 +000023#include <thread>
24#include <vector>
25
Nate Jiang7a7fd842022-12-06 17:11:13 -080026#include <hal_legacy/wifi_hal.h>
Gabriel Biren631a8112022-12-01 22:29:32 +000027#include <wifi_system/interface_tool.h>
28
Roshan Piusaabe5752016-09-29 09:03:59 -070029namespace android {
30namespace hardware {
31namespace wifi {
Gabriel Biren631a8112022-12-01 22:29:32 +000032namespace V1_6 {
33namespace implementation {
Roshan Pius955542e2016-10-28 09:42:44 -070034// This is in a separate namespace to prevent typename conflicts between
Gabriel Biren631a8112022-12-01 22:29:32 +000035// the legacy HAL types and the HIDL interface types.
Roshan Pius955542e2016-10-28 09:42:44 -070036namespace legacy_hal {
Peter Collingbourne78471d92020-12-30 17:12:41 -080037// Import all the types defined inside the legacy HAL header files into this
Roshan Pius955542e2016-10-28 09:42:44 -070038// namespace.
Isaac Chiou9cf44592022-01-17 13:37:35 +080039using ::chre_nan_rtt_state;
Kumar Anand2a630a32021-01-21 14:09:14 -080040using ::frame_info;
41using ::frame_type;
Peter Collingbourne78471d92020-12-30 17:12:41 -080042using ::FRAME_TYPE_80211_MGMT;
43using ::FRAME_TYPE_ETHERNET_II;
44using ::FRAME_TYPE_UNKNOWN;
Kumar Anand2a630a32021-01-21 14:09:14 -080045using ::fw_roaming_state_t;
46using ::mac_addr;
Peter Collingbourne78471d92020-12-30 17:12:41 -080047using ::NAN_CHANNEL_24G_BAND;
48using ::NAN_CHANNEL_5G_BAND_HIGH;
49using ::NAN_CHANNEL_5G_BAND_LOW;
50using ::NAN_DISABLE_RANGE_REPORT;
51using ::NAN_DO_NOT_USE_SRF;
52using ::NAN_DP_CHANNEL_NOT_REQUESTED;
53using ::NAN_DP_CONFIG_NO_SECURITY;
54using ::NAN_DP_CONFIG_SECURITY;
55using ::NAN_DP_END;
56using ::NAN_DP_FORCE_CHANNEL_SETUP;
57using ::NAN_DP_INITIATOR_RESPONSE;
58using ::NAN_DP_INTERFACE_CREATE;
59using ::NAN_DP_INTERFACE_DELETE;
60using ::NAN_DP_REQUEST_ACCEPT;
61using ::NAN_DP_REQUEST_CHANNEL_SETUP;
62using ::NAN_DP_REQUEST_REJECT;
63using ::NAN_DP_RESPONDER_RESPONSE;
64using ::NAN_GET_CAPABILITIES;
65using ::NAN_MATCH_ALG_MATCH_CONTINUOUS;
66using ::NAN_MATCH_ALG_MATCH_NEVER;
67using ::NAN_MATCH_ALG_MATCH_ONCE;
68using ::NAN_PUBLISH_TYPE_SOLICITED;
69using ::NAN_PUBLISH_TYPE_UNSOLICITED;
70using ::NAN_PUBLISH_TYPE_UNSOLICITED_SOLICITED;
71using ::NAN_RANGING_AUTO_RESPONSE_DISABLE;
72using ::NAN_RANGING_AUTO_RESPONSE_ENABLE;
73using ::NAN_RANGING_DISABLE;
74using ::NAN_RANGING_ENABLE;
75using ::NAN_RESPONSE_BEACON_SDF_PAYLOAD;
76using ::NAN_RESPONSE_CONFIG;
77using ::NAN_RESPONSE_DISABLED;
78using ::NAN_RESPONSE_ENABLED;
79using ::NAN_RESPONSE_ERROR;
80using ::NAN_RESPONSE_PUBLISH;
81using ::NAN_RESPONSE_PUBLISH_CANCEL;
82using ::NAN_RESPONSE_STATS;
83using ::NAN_RESPONSE_SUBSCRIBE;
84using ::NAN_RESPONSE_SUBSCRIBE_CANCEL;
85using ::NAN_RESPONSE_TCA;
86using ::NAN_RESPONSE_TRANSMIT_FOLLOWUP;
87using ::NAN_SECURITY_KEY_INPUT_PASSPHRASE;
Peter Collingbourne78471d92020-12-30 17:12:41 -080088using ::NAN_SECURITY_KEY_INPUT_PMK;
89using ::NAN_SERVICE_ACCEPT_POLICY_ALL;
90using ::NAN_SERVICE_ACCEPT_POLICY_NONE;
91using ::NAN_SRF_ATTR_BLOOM_FILTER;
92using ::NAN_SRF_ATTR_PARTIAL_MAC_ADDR;
93using ::NAN_SRF_INCLUDE_DO_NOT_RESPOND;
94using ::NAN_SRF_INCLUDE_RESPOND;
95using ::NAN_SSI_NOT_REQUIRED_IN_MATCH_IND;
96using ::NAN_SSI_REQUIRED_IN_MATCH_IND;
97using ::NAN_STATUS_ALREADY_ENABLED;
98using ::NAN_STATUS_FOLLOWUP_QUEUE_FULL;
99using ::NAN_STATUS_INTERNAL_FAILURE;
100using ::NAN_STATUS_INVALID_NDP_ID;
101using ::NAN_STATUS_INVALID_PARAM;
102using ::NAN_STATUS_INVALID_PUBLISH_SUBSCRIBE_ID;
103using ::NAN_STATUS_INVALID_REQUESTOR_INSTANCE_ID;
104using ::NAN_STATUS_NAN_NOT_ALLOWED;
105using ::NAN_STATUS_NO_OTA_ACK;
106using ::NAN_STATUS_NO_RESOURCE_AVAILABLE;
107using ::NAN_STATUS_PROTOCOL_FAILURE;
108using ::NAN_STATUS_SUCCESS;
109using ::NAN_STATUS_UNSUPPORTED_CONCURRENCY_NAN_DISABLED;
110using ::NAN_SUBSCRIBE_TYPE_ACTIVE;
111using ::NAN_SUBSCRIBE_TYPE_PASSIVE;
112using ::NAN_TRANSMIT_IN_DW;
113using ::NAN_TRANSMIT_IN_FAW;
114using ::NAN_TX_PRIORITY_HIGH;
115using ::NAN_TX_PRIORITY_NORMAL;
116using ::NAN_TX_TYPE_BROADCAST;
117using ::NAN_TX_TYPE_UNICAST;
118using ::NAN_USE_SRF;
119using ::NanBeaconSdfPayloadInd;
120using ::NanCapabilities;
121using ::NanChannelInfo;
122using ::NanConfigRequest;
123using ::NanDataPathChannelCfg;
124using ::NanDataPathConfirmInd;
125using ::NanDataPathEndInd;
126using ::NanDataPathIndicationResponse;
127using ::NanDataPathInitiatorRequest;
128using ::NanDataPathRequestInd;
129using ::NanDataPathScheduleUpdateInd;
130using ::NanDisabledInd;
131using ::NanDiscEngEventInd;
132using ::NanEnableRequest;
133using ::NanFollowupInd;
134using ::NanMatchAlg;
135using ::NanMatchExpiredInd;
136using ::NanMatchInd;
137using ::NanPublishCancelRequest;
138using ::NanPublishRequest;
139using ::NanPublishTerminatedInd;
140using ::NanPublishType;
141using ::NanRangeReportInd;
142using ::NanRangeRequestInd;
143using ::NanResponseMsg;
144using ::NanSRFType;
145using ::NanStatusType;
146using ::NanSubscribeCancelRequest;
147using ::NanSubscribeRequest;
148using ::NanSubscribeTerminatedInd;
149using ::NanSubscribeType;
150using ::NanTransmitFollowupInd;
151using ::NanTransmitFollowupRequest;
152using ::NanTxType;
153using ::ROAMING_DISABLE;
154using ::ROAMING_ENABLE;
155using ::RTT_PEER_AP;
156using ::RTT_PEER_NAN;
157using ::RTT_PEER_P2P_CLIENT;
158using ::RTT_PEER_P2P_GO;
159using ::RTT_PEER_STA;
Kumar Anand2a630a32021-01-21 14:09:14 -0800160using ::rtt_peer_type;
Peter Collingbourne78471d92020-12-30 17:12:41 -0800161using ::RTT_STATUS_ABORTED;
Peter Collingbourne78471d92020-12-30 17:12:41 -0800162using ::RTT_STATUS_FAIL_AP_ON_DIFF_CHANNEL;
163using ::RTT_STATUS_FAIL_BUSY_TRY_LATER;
164using ::RTT_STATUS_FAIL_FTM_PARAM_OVERRIDE;
165using ::RTT_STATUS_FAIL_INVALID_TS;
Peter Collingbourne78471d92020-12-30 17:12:41 -0800166using ::RTT_STATUS_FAIL_NO_CAPABILITY;
167using ::RTT_STATUS_FAIL_NO_RSP;
Kumar Anand2a630a32021-01-21 14:09:14 -0800168using ::RTT_STATUS_FAIL_NOT_SCHEDULED_YET;
Peter Collingbourne78471d92020-12-30 17:12:41 -0800169using ::RTT_STATUS_FAIL_PROTOCOL;
170using ::RTT_STATUS_FAIL_REJECTED;
171using ::RTT_STATUS_FAIL_SCHEDULE;
172using ::RTT_STATUS_FAIL_TM_TIMEOUT;
Kumar Anand2a630a32021-01-21 14:09:14 -0800173using ::RTT_STATUS_FAILURE;
Peter Collingbourne78471d92020-12-30 17:12:41 -0800174using ::RTT_STATUS_INVALID_REQ;
175using ::RTT_STATUS_NAN_RANGING_CONCURRENCY_NOT_SUPPORTED;
176using ::RTT_STATUS_NAN_RANGING_PROTOCOL_FAILURE;
177using ::RTT_STATUS_NO_WIFI;
178using ::RTT_STATUS_SUCCESS;
179using ::RTT_TYPE_1_SIDED;
180using ::RTT_TYPE_2_SIDED;
181using ::RX_PKT_FATE_DRV_DROP_FILTER;
182using ::RX_PKT_FATE_DRV_DROP_INVALID;
183using ::RX_PKT_FATE_DRV_DROP_NOBUFS;
184using ::RX_PKT_FATE_DRV_DROP_OTHER;
185using ::RX_PKT_FATE_DRV_QUEUED;
186using ::RX_PKT_FATE_FW_DROP_FILTER;
187using ::RX_PKT_FATE_FW_DROP_INVALID;
188using ::RX_PKT_FATE_FW_DROP_NOBUFS;
189using ::RX_PKT_FATE_FW_DROP_OTHER;
190using ::RX_PKT_FATE_FW_QUEUED;
191using ::RX_PKT_FATE_SUCCESS;
Kumar Anand2a630a32021-01-21 14:09:14 -0800192using ::ssid_t;
193using ::transaction_id;
Peter Collingbourne78471d92020-12-30 17:12:41 -0800194using ::TX_PKT_FATE_ACKED;
195using ::TX_PKT_FATE_DRV_DROP_INVALID;
196using ::TX_PKT_FATE_DRV_DROP_NOBUFS;
197using ::TX_PKT_FATE_DRV_DROP_OTHER;
198using ::TX_PKT_FATE_DRV_QUEUED;
199using ::TX_PKT_FATE_FW_DROP_INVALID;
200using ::TX_PKT_FATE_FW_DROP_NOBUFS;
201using ::TX_PKT_FATE_FW_DROP_OTHER;
202using ::TX_PKT_FATE_FW_QUEUED;
203using ::TX_PKT_FATE_SENT;
204using ::WIFI_AC_BE;
205using ::WIFI_AC_BK;
206using ::WIFI_AC_VI;
207using ::WIFI_AC_VO;
Sunil Ravief97d232022-01-24 10:39:56 -0800208using ::WIFI_ANTENNA_1X1;
209using ::WIFI_ANTENNA_2X2;
210using ::WIFI_ANTENNA_3X3;
211using ::WIFI_ANTENNA_4X4;
212using ::WIFI_ANTENNA_UNSPECIFIED;
Kumar Anand2a630a32021-01-21 14:09:14 -0800213using ::wifi_band;
Peter Collingbourne78471d92020-12-30 17:12:41 -0800214using ::WIFI_BAND_A;
Peter Collingbourne78471d92020-12-30 17:12:41 -0800215using ::WIFI_BAND_A_DFS;
216using ::WIFI_BAND_A_WITH_DFS;
Kumar Anand2a630a32021-01-21 14:09:14 -0800217using ::WIFI_BAND_ABG;
218using ::WIFI_BAND_ABG_WITH_DFS;
Peter Collingbourne78471d92020-12-30 17:12:41 -0800219using ::WIFI_BAND_BG;
220using ::WIFI_BAND_UNSPECIFIED;
kensuna7e0a832022-10-31 13:46:17 +0000221using ::wifi_cached_scan_report;
Kumar Anand2a630a32021-01-21 14:09:14 -0800222using ::wifi_cached_scan_results;
Peter Collingbourne78471d92020-12-30 17:12:41 -0800223using ::WIFI_CHAN_WIDTH_10;
224using ::WIFI_CHAN_WIDTH_160;
225using ::WIFI_CHAN_WIDTH_20;
Ahmed ElArabawy05571e42022-01-19 11:54:11 -0800226using ::WIFI_CHAN_WIDTH_320;
Peter Collingbourne78471d92020-12-30 17:12:41 -0800227using ::WIFI_CHAN_WIDTH_40;
228using ::WIFI_CHAN_WIDTH_5;
Peter Collingbourne78471d92020-12-30 17:12:41 -0800229using ::WIFI_CHAN_WIDTH_80;
230using ::WIFI_CHAN_WIDTH_80P80;
231using ::WIFI_CHAN_WIDTH_INVALID;
Kumar Anand2a630a32021-01-21 14:09:14 -0800232using ::wifi_channel_info;
233using ::wifi_channel_stat;
234using ::wifi_channel_width;
235using ::wifi_coex_restriction;
236using ::wifi_coex_unsafe_channel;
Peter Collingbourne78471d92020-12-30 17:12:41 -0800237using ::WIFI_DUAL_STA_NON_TRANSIENT_UNBIASED;
238using ::WIFI_DUAL_STA_TRANSIENT_PREFER_PRIMARY;
Kumar Anand2a630a32021-01-21 14:09:14 -0800239using ::wifi_error;
Peter Collingbourne78471d92020-12-30 17:12:41 -0800240using ::WIFI_ERROR_BUSY;
241using ::WIFI_ERROR_INVALID_ARGS;
242using ::WIFI_ERROR_INVALID_REQUEST_ID;
243using ::WIFI_ERROR_NONE;
244using ::WIFI_ERROR_NOT_AVAILABLE;
245using ::WIFI_ERROR_NOT_SUPPORTED;
246using ::WIFI_ERROR_OUT_OF_MEMORY;
247using ::WIFI_ERROR_TIMED_OUT;
248using ::WIFI_ERROR_TOO_MANY_REQUESTS;
249using ::WIFI_ERROR_UNINITIALIZED;
250using ::WIFI_ERROR_UNKNOWN;
Kumar Anand2a630a32021-01-21 14:09:14 -0800251using ::wifi_gscan_capabilities;
252using ::wifi_hal_fn;
253using ::wifi_information_element;
254using ::WIFI_INTERFACE_IBSS;
255using ::WIFI_INTERFACE_MESH;
256using ::wifi_interface_mode;
257using ::WIFI_INTERFACE_NAN;
258using ::WIFI_INTERFACE_P2P_CLIENT;
259using ::WIFI_INTERFACE_P2P_GO;
260using ::WIFI_INTERFACE_SOFTAP;
261using ::WIFI_INTERFACE_STA;
262using ::WIFI_INTERFACE_TDLS;
263using ::wifi_interface_type;
Peter Collingbourne78471d92020-12-30 17:12:41 -0800264using ::WIFI_INTERFACE_TYPE_AP;
265using ::WIFI_INTERFACE_TYPE_NAN;
266using ::WIFI_INTERFACE_TYPE_P2P;
267using ::WIFI_INTERFACE_TYPE_STA;
Kumar Anand2a630a32021-01-21 14:09:14 -0800268using ::WIFI_INTERFACE_UNKNOWN;
269using ::wifi_latency_mode;
Peter Collingbourne78471d92020-12-30 17:12:41 -0800270using ::WIFI_LATENCY_MODE_LOW;
271using ::WIFI_LATENCY_MODE_NORMAL;
Kumar Anand2a630a32021-01-21 14:09:14 -0800272using ::wifi_lci_information;
273using ::wifi_lcr_information;
Peter Collingbourne78471d92020-12-30 17:12:41 -0800274using ::WIFI_LOGGER_CONNECT_EVENT_SUPPORTED;
275using ::WIFI_LOGGER_DRIVER_DUMP_SUPPORTED;
276using ::WIFI_LOGGER_MEMORY_DUMP_SUPPORTED;
277using ::WIFI_LOGGER_PACKET_FATE_SUPPORTED;
278using ::WIFI_LOGGER_POWER_EVENT_SUPPORTED;
279using ::WIFI_LOGGER_WAKE_LOCK_SUPPORTED;
280using ::WIFI_MOTION_EXPECTED;
281using ::WIFI_MOTION_NOT_EXPECTED;
Kumar Anand2a630a32021-01-21 14:09:14 -0800282using ::wifi_motion_pattern;
Peter Collingbourne78471d92020-12-30 17:12:41 -0800283using ::WIFI_MOTION_UNKNOWN;
Kumar Anand2a630a32021-01-21 14:09:14 -0800284using ::wifi_multi_sta_use_case;
285using ::wifi_power_scenario;
Peter Collingbourne78471d92020-12-30 17:12:41 -0800286using ::WIFI_POWER_SCENARIO_ON_BODY_CELL_OFF;
287using ::WIFI_POWER_SCENARIO_ON_BODY_CELL_ON;
288using ::WIFI_POWER_SCENARIO_ON_HEAD_CELL_OFF;
289using ::WIFI_POWER_SCENARIO_ON_HEAD_CELL_ON;
290using ::WIFI_POWER_SCENARIO_VOICE_CALL;
Sunil Ravief97d232022-01-24 10:39:56 -0800291using ::wifi_radio_combination;
292using ::wifi_radio_combination_matrix;
293using ::wifi_radio_configuration;
Peter Collingbourne78471d92020-12-30 17:12:41 -0800294using ::wifi_rate;
295using ::wifi_request_id;
296using ::wifi_ring_buffer_status;
297using ::wifi_roaming_capabilities;
298using ::wifi_roaming_config;
299using ::wifi_rtt_bw;
Kumar Anand2a630a32021-01-21 14:09:14 -0800300using ::WIFI_RTT_BW_10;
301using ::WIFI_RTT_BW_160;
302using ::WIFI_RTT_BW_20;
Ahmed ElArabawy05571e42022-01-19 11:54:11 -0800303using ::WIFI_RTT_BW_320;
Kumar Anand2a630a32021-01-21 14:09:14 -0800304using ::WIFI_RTT_BW_40;
305using ::WIFI_RTT_BW_5;
306using ::WIFI_RTT_BW_80;
Peter Collingbourne78471d92020-12-30 17:12:41 -0800307using ::wifi_rtt_capabilities;
308using ::wifi_rtt_config;
309using ::wifi_rtt_preamble;
Ahmed ElArabawy05571e42022-01-19 11:54:11 -0800310using ::WIFI_RTT_PREAMBLE_EHT;
Kumar Anand2a630a32021-01-21 14:09:14 -0800311using ::WIFI_RTT_PREAMBLE_HE;
312using ::WIFI_RTT_PREAMBLE_HT;
313using ::WIFI_RTT_PREAMBLE_LEGACY;
314using ::WIFI_RTT_PREAMBLE_VHT;
Peter Collingbourne78471d92020-12-30 17:12:41 -0800315using ::wifi_rtt_responder;
316using ::wifi_rtt_result;
317using ::wifi_rtt_status;
318using ::wifi_rtt_type;
319using ::wifi_rx_packet_fate;
320using ::wifi_rx_report;
321using ::wifi_scan_bucket_spec;
322using ::wifi_scan_cmd_params;
Kumar Anand2a630a32021-01-21 14:09:14 -0800323using ::WIFI_SCAN_FLAG_INTERRUPTED;
Peter Collingbourne78471d92020-12-30 17:12:41 -0800324using ::wifi_scan_result;
Kumar Anand2a630a32021-01-21 14:09:14 -0800325using ::WIFI_SUCCESS;
Peter Collingbourne78471d92020-12-30 17:12:41 -0800326using ::wifi_tx_packet_fate;
327using ::wifi_tx_report;
Kumar Anand2a630a32021-01-21 14:09:14 -0800328using ::wifi_usable_channel;
Kumar Anandaea86e02021-02-10 16:22:31 -0800329using ::WIFI_USABLE_CHANNEL_FILTER_CELLULAR_COEXISTENCE;
330using ::WIFI_USABLE_CHANNEL_FILTER_CONCURRENCY;
Kumar Anand2a630a32021-01-21 14:09:14 -0800331using ::WLAN_MAC_2_4_BAND;
332using ::WLAN_MAC_5_0_BAND;
333using ::WLAN_MAC_60_0_BAND;
334using ::WLAN_MAC_6_0_BAND;
Roshan Piusaabe5752016-09-29 09:03:59 -0700335
Roshan Pius0a47c182016-10-28 10:23:00 -0700336// APF capabilities supported by the iface.
337struct PacketFilterCapabilities {
Roshan Piusabcf78f2017-10-06 16:30:38 -0700338 uint32_t version;
339 uint32_t max_len;
Roshan Pius0a47c182016-10-28 10:23:00 -0700340};
341
Roshan Pius7cece412016-10-28 10:38:21 -0700342// WARNING: We don't care about the variable sized members of either
343// |wifi_iface_stat|, |wifi_radio_stat| structures. So, using the pragma
344// to escape the compiler warnings regarding this.
345#pragma GCC diagnostic push
346#pragma GCC diagnostic ignored "-Wgnu-variable-sized-type-not-at-end"
347// The |wifi_radio_stat.tx_time_per_levels| stats is provided as a pointer in
348// |wifi_radio_stat| structure in the legacy HAL API. Separate that out
349// into a separate return element to avoid passing pointers around.
Roshan Piuse42ace22017-03-13 10:44:20 -0700350struct LinkLayerRadioStats {
Roshan Piusabcf78f2017-10-06 16:30:38 -0700351 wifi_radio_stat stats;
352 std::vector<uint32_t> tx_time_per_levels;
Sunil Ravib0343e72018-11-13 15:52:00 -0800353 std::vector<wifi_channel_stat> channel_stats;
Roshan Piuse42ace22017-03-13 10:44:20 -0700354};
355
Mingguang Xu41242be2021-02-19 18:16:01 -0800356struct WifiPeerInfo {
357 wifi_peer_info peer_info;
358 std::vector<wifi_rate_stat> rate_stats;
359};
360
Roshan Pius7cece412016-10-28 10:38:21 -0700361struct LinkLayerStats {
Roshan Piusabcf78f2017-10-06 16:30:38 -0700362 wifi_iface_stat iface;
363 std::vector<LinkLayerRadioStats> radios;
Mingguang Xu41242be2021-02-19 18:16:01 -0800364 std::vector<WifiPeerInfo> peers;
Roshan Pius7cece412016-10-28 10:38:21 -0700365};
366#pragma GCC diagnostic pop
367
Roshan Pius8714a3e2016-10-28 10:43:51 -0700368// The |WLAN_DRIVER_WAKE_REASON_CNT.cmd_event_wake_cnt| and
369// |WLAN_DRIVER_WAKE_REASON_CNT.driver_fw_local_wake_cnt| stats is provided
370// as a pointer in |WLAN_DRIVER_WAKE_REASON_CNT| structure in the legacy HAL
371// API. Separate that out into a separate return elements to avoid passing
372// pointers around.
373struct WakeReasonStats {
Roshan Piusabcf78f2017-10-06 16:30:38 -0700374 WLAN_DRIVER_WAKE_REASON_CNT wake_reason_cnt;
375 std::vector<uint32_t> cmd_event_wake_cnt;
376 std::vector<uint32_t> driver_fw_local_wake_cnt;
Roshan Pius8714a3e2016-10-28 10:43:51 -0700377};
378
Roshan Pius23012092016-10-28 11:27:40 -0700379// NAN response and event callbacks struct.
380struct NanCallbackHandlers {
Roshan Piusabcf78f2017-10-06 16:30:38 -0700381 // NotifyResponse invoked to notify the status of the Request.
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800382 std::function<void(transaction_id, const NanResponseMsg&)> on_notify_response;
Roshan Piusabcf78f2017-10-06 16:30:38 -0700383 // Various event callbacks.
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800384 std::function<void(const NanPublishTerminatedInd&)> on_event_publish_terminated;
Roshan Piusabcf78f2017-10-06 16:30:38 -0700385 std::function<void(const NanMatchInd&)> on_event_match;
386 std::function<void(const NanMatchExpiredInd&)> on_event_match_expired;
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800387 std::function<void(const NanSubscribeTerminatedInd&)> on_event_subscribe_terminated;
Roshan Piusabcf78f2017-10-06 16:30:38 -0700388 std::function<void(const NanFollowupInd&)> on_event_followup;
389 std::function<void(const NanDiscEngEventInd&)> on_event_disc_eng_event;
390 std::function<void(const NanDisabledInd&)> on_event_disabled;
391 std::function<void(const NanTCAInd&)> on_event_tca;
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800392 std::function<void(const NanBeaconSdfPayloadInd&)> on_event_beacon_sdf_payload;
393 std::function<void(const NanDataPathRequestInd&)> on_event_data_path_request;
394 std::function<void(const NanDataPathConfirmInd&)> on_event_data_path_confirm;
Roshan Piusabcf78f2017-10-06 16:30:38 -0700395 std::function<void(const NanDataPathEndInd&)> on_event_data_path_end;
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800396 std::function<void(const NanTransmitFollowupInd&)> on_event_transmit_follow_up;
Roshan Piusabcf78f2017-10-06 16:30:38 -0700397 std::function<void(const NanRangeRequestInd&)> on_event_range_request;
398 std::function<void(const NanRangeReportInd&)> on_event_range_report;
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800399 std::function<void(const NanDataPathScheduleUpdateInd&)> on_event_schedule_update;
Roshan Pius23012092016-10-28 11:27:40 -0700400};
401
Roshan Pius76ff3022016-10-28 10:33:34 -0700402// Full scan results contain IE info and are hence passed by reference, to
403// preserve the variable length array member |ie_data|. Callee must not retain
404// the pointer.
405using on_gscan_full_result_callback =
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800406 std::function<void(wifi_request_id, const wifi_scan_result*, uint32_t)>;
Roshan Pius76ff3022016-10-28 10:33:34 -0700407// These scan results don't contain any IE info, so no need to pass by
408// reference.
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800409using on_gscan_results_callback =
410 std::function<void(wifi_request_id, const std::vector<wifi_cached_scan_results>&)>;
Roshan Pius76ff3022016-10-28 10:33:34 -0700411
Roshan Piusd4767542016-12-06 10:04:05 -0800412// Invoked when the rssi value breaches the thresholds set.
413using on_rssi_threshold_breached_callback =
Gabriel Biren631a8112022-12-01 22:29:32 +0000414 std::function<void(wifi_request_id, std::array<uint8_t, 6>, int8_t)>;
Roshan Piusd4767542016-12-06 10:04:05 -0800415
Roshan Piusd8e915a2016-10-28 11:23:11 -0700416// Callback for RTT range request results.
417// Rtt results contain IE info and are hence passed by reference, to
418// preserve the |LCI| and |LCR| pointers. Callee must not retain
419// the pointer.
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800420using on_rtt_results_callback =
421 std::function<void(wifi_request_id, const std::vector<const wifi_rtt_result*>&)>;
Roshan Piusd8e915a2016-10-28 11:23:11 -0700422
Roshan Pius8714a3e2016-10-28 10:43:51 -0700423// Callback for ring buffer data.
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800424using on_ring_buffer_data_callback = std::function<void(
425 const std::string&, const std::vector<uint8_t>&, const wifi_ring_buffer_status&)>;
Roshan Pius8714a3e2016-10-28 10:43:51 -0700426
Roshan Pius203cb032016-12-14 17:41:20 -0800427// Callback for alerts.
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800428using on_error_alert_callback = std::function<void(int32_t, const std::vector<uint8_t>&)>;
Roshan Pius01f08772018-01-22 17:56:06 -0800429
Ahmed ElArabawy2134bf72020-06-18 15:07:12 -0700430// Callback for subsystem restart
431using on_subsystem_restart_callback = std::function<void(const std::string&)>;
432
Roshan Pius01f08772018-01-22 17:56:06 -0800433// Struct for the mac info from the legacy HAL. This is a cleaner version
434// of the |wifi_mac_info| & |wifi_iface_info|.
435typedef struct {
436 std::string name;
437 wifi_channel channel;
438} WifiIfaceInfo;
439
440typedef struct {
441 uint32_t wlan_mac_id;
442 /* BIT MASK of BIT(WLAN_MAC*) as represented by wlan_mac_band */
443 uint32_t mac_band;
444 /* Represents the connected Wi-Fi interfaces associated with each MAC */
445 std::vector<WifiIfaceInfo> iface_infos;
446} WifiMacInfo;
447
448// Callback for radio mode change
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800449using on_radio_mode_change_callback = std::function<void(const std::vector<WifiMacInfo>&)>;
Roshan Pius01f08772018-01-22 17:56:06 -0800450
Kai Shi2ca7a112020-12-15 19:51:28 -0800451// TWT response and event callbacks struct.
452struct TwtCallbackHandlers {
453 // Callback for TWT setup response
454 std::function<void(const TwtSetupResponse&)> on_setup_response;
455 // Callback for TWT teardown completion
456 std::function<void(const TwtTeardownCompletion&)> on_teardown_completion;
457 // Callback for TWT info frame received event
458 std::function<void(const TwtInfoFrameReceived&)> on_info_frame_received;
459 // Callback for TWT notification from the device
460 std::function<void(const TwtDeviceNotify&)> on_device_notify;
461};
462
Isaac Chiou9cf44592022-01-17 13:37:35 +0800463// CHRE response and event callbacks struct.
464struct ChreCallbackHandlers {
465 // Callback for CHRE NAN RTT
466 std::function<void(chre_nan_rtt_state)> on_wifi_chre_nan_rtt_state;
467};
468
kensuna7e0a832022-10-31 13:46:17 +0000469// Cached Scan Results response and event callbacks struct.
470struct CachedScanResultsCallbackHandlers {
471 // Callback for Cached Scan Results
472 std::function<void(wifi_cached_scan_report*)> on_cached_scan_results;
473};
474
Roshan Piusaabe5752016-09-29 09:03:59 -0700475/**
476 * Class that encapsulates all legacy HAL interactions.
477 * This class manages the lifetime of the event loop thread used by legacy HAL.
Roshan Pius742bb972017-02-02 09:54:27 -0800478 *
Bernie Innocentiefbb9c32018-03-07 00:17:50 +0900479 * Note: There will only be a single instance of this class created in the Wifi
Roshan Pius742bb972017-02-02 09:54:27 -0800480 * object and will be valid for the lifetime of the process.
Roshan Piusaabe5752016-09-29 09:03:59 -0700481 */
482class WifiLegacyHal {
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800483 public:
Gabriel Biren631a8112022-12-01 22:29:32 +0000484 WifiLegacyHal(const std::weak_ptr<wifi_system::InterfaceTool> iface_tool, const wifi_hal_fn& fn,
485 bool is_primary);
Roshan Pius200a17d2017-11-01 13:03:35 -0700486 virtual ~WifiLegacyHal() = default;
Roshan Piusab5c4712016-10-06 14:37:15 -0700487
Roshan Piusabcf78f2017-10-06 16:30:38 -0700488 // Initialize the legacy HAL function table.
Roshan Pius200a17d2017-11-01 13:03:35 -0700489 virtual wifi_error initialize();
Roshan Piusabcf78f2017-10-06 16:30:38 -0700490 // Start the legacy HAL and the event looper thread.
Roshan Pius200a17d2017-11-01 13:03:35 -0700491 virtual wifi_error start();
Roshan Piusabcf78f2017-10-06 16:30:38 -0700492 // Deinitialize the legacy HAL and wait for the event loop thread to exit
493 // using a predefined timeout.
Roshan Pius200a17d2017-11-01 13:03:35 -0700494 virtual wifi_error stop(std::unique_lock<std::recursive_mutex>* lock,
495 const std::function<void()>& on_complete_callback);
Roshan Pius8c1a67b2021-03-02 10:00:23 -0800496 virtual wifi_error waitForDriverReady();
Ahmed ElArabawy48229382019-02-07 22:04:53 -0800497 // Checks if legacy HAL has successfully started
498 bool isStarted();
Roshan Piusabcf78f2017-10-06 16:30:38 -0700499 // Wrappers for all the functions in the legacy HAL function table.
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800500 virtual std::pair<wifi_error, std::string> getDriverVersion(const std::string& iface_name);
501 virtual std::pair<wifi_error, std::string> getFirmwareVersion(const std::string& iface_name);
Roshan Piusabcf78f2017-10-06 16:30:38 -0700502 std::pair<wifi_error, std::vector<uint8_t>> requestDriverMemoryDump(
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800503 const std::string& iface_name);
Roshan Piusabcf78f2017-10-06 16:30:38 -0700504 std::pair<wifi_error, std::vector<uint8_t>> requestFirmwareMemoryDump(
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800505 const std::string& iface_name);
Jimmy Chen1cfe0812022-02-16 18:31:37 +0800506 virtual std::pair<wifi_error, uint64_t> getSupportedFeatureSet(const std::string& iface_name);
Roshan Piusabcf78f2017-10-06 16:30:38 -0700507 // APF functions.
508 std::pair<wifi_error, PacketFilterCapabilities> getPacketFilterCapabilities(
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800509 const std::string& iface_name);
510 wifi_error setPacketFilter(const std::string& iface_name, const std::vector<uint8_t>& program);
Bernie Innocentiefbb9c32018-03-07 00:17:50 +0900511 std::pair<wifi_error, std::vector<uint8_t>> readApfPacketFilterData(
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800512 const std::string& iface_name);
Roshan Piusabcf78f2017-10-06 16:30:38 -0700513 // Gscan functions.
514 std::pair<wifi_error, wifi_gscan_capabilities> getGscanCapabilities(
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800515 const std::string& iface_name);
Roshan Piusabcf78f2017-10-06 16:30:38 -0700516 // These API's provides a simplified interface over the legacy Gscan API's:
517 // a) All scan events from the legacy HAL API other than the
518 // |WIFI_SCAN_FAILED| are treated as notification of results.
519 // This method then retrieves the cached scan results from the legacy
520 // HAL API and triggers the externally provided
521 // |on_results_user_callback| on success.
522 // b) |WIFI_SCAN_FAILED| scan event or failure to retrieve cached scan
523 // results
Gabriel Biren631a8112022-12-01 22:29:32 +0000524 // triggers the externally provided |on_failure_user_callback|.
Roshan Piusabcf78f2017-10-06 16:30:38 -0700525 // c) Full scan result event triggers the externally provided
526 // |on_full_result_user_callback|.
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800527 wifi_error startGscan(const std::string& iface_name, wifi_request_id id,
528 const wifi_scan_cmd_params& params,
529 const std::function<void(wifi_request_id)>& on_failure_callback,
530 const on_gscan_results_callback& on_results_callback,
531 const on_gscan_full_result_callback& on_full_result_callback);
Roshan Piusabcf78f2017-10-06 16:30:38 -0700532 wifi_error stopGscan(const std::string& iface_name, wifi_request_id id);
533 std::pair<wifi_error, std::vector<uint32_t>> getValidFrequenciesForBand(
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800534 const std::string& iface_name, wifi_band band);
Roshan Pius200a17d2017-11-01 13:03:35 -0700535 virtual wifi_error setDfsFlag(const std::string& iface_name, bool dfs_on);
Roshan Piusabcf78f2017-10-06 16:30:38 -0700536 // Link layer stats functions.
537 wifi_error enableLinkLayerStats(const std::string& iface_name, bool debug);
538 wifi_error disableLinkLayerStats(const std::string& iface_name);
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800539 std::pair<wifi_error, LinkLayerStats> getLinkLayerStats(const std::string& iface_name);
Roshan Piusabcf78f2017-10-06 16:30:38 -0700540 // RSSI monitor functions.
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800541 wifi_error startRssiMonitoring(
542 const std::string& iface_name, wifi_request_id id, int8_t max_rssi, int8_t min_rssi,
543 const on_rssi_threshold_breached_callback& on_threshold_breached_callback);
544 wifi_error stopRssiMonitoring(const std::string& iface_name, wifi_request_id id);
Roshan Piusabcf78f2017-10-06 16:30:38 -0700545 std::pair<wifi_error, wifi_roaming_capabilities> getRoamingCapabilities(
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800546 const std::string& iface_name);
547 wifi_error configureRoaming(const std::string& iface_name, const wifi_roaming_config& config);
548 wifi_error enableFirmwareRoaming(const std::string& iface_name, fw_roaming_state_t state);
Roshan Piusabcf78f2017-10-06 16:30:38 -0700549 wifi_error configureNdOffload(const std::string& iface_name, bool enable);
Gabriel Biren631a8112022-12-01 22:29:32 +0000550 wifi_error startSendingOffloadedPacket(const std::string& iface_name, uint32_t cmd_id,
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800551 uint16_t ether_type,
552 const std::vector<uint8_t>& ip_packet_data,
553 const std::array<uint8_t, 6>& src_address,
554 const std::array<uint8_t, 6>& dst_address,
Gabriel Biren631a8112022-12-01 22:29:32 +0000555 uint32_t period_in_ms);
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800556 wifi_error stopSendingOffloadedPacket(const std::string& iface_name, uint32_t cmd_id);
Roshan Pius6036c022019-03-27 10:41:58 -0700557 virtual wifi_error selectTxPowerScenario(const std::string& iface_name,
558 wifi_power_scenario scenario);
559 virtual wifi_error resetTxPowerScenario(const std::string& iface_name);
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800560 wifi_error setLatencyMode(const std::string& iface_name, wifi_latency_mode mode);
561 wifi_error setThermalMitigationMode(wifi_thermal_mode mode, uint32_t completion_window);
Ahmed ElArabawya1d13652020-01-29 09:22:28 -0800562 wifi_error setDscpToAccessCategoryMapping(uint32_t start, uint32_t end,
563 uint32_t access_category);
564 wifi_error resetDscpToAccessCategoryMapping();
Roshan Piusabcf78f2017-10-06 16:30:38 -0700565 // Logger/debug functions.
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800566 std::pair<wifi_error, uint32_t> getLoggerSupportedFeatureSet(const std::string& iface_name);
Roshan Piusabcf78f2017-10-06 16:30:38 -0700567 wifi_error startPktFateMonitoring(const std::string& iface_name);
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800568 std::pair<wifi_error, std::vector<wifi_tx_report>> getTxPktFates(const std::string& iface_name);
569 std::pair<wifi_error, std::vector<wifi_rx_report>> getRxPktFates(const std::string& iface_name);
570 std::pair<wifi_error, WakeReasonStats> getWakeReasonStats(const std::string& iface_name);
Roshan Piusabcf78f2017-10-06 16:30:38 -0700571 wifi_error registerRingBufferCallbackHandler(
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800572 const std::string& iface_name, const on_ring_buffer_data_callback& on_data_callback);
573 wifi_error deregisterRingBufferCallbackHandler(const std::string& iface_name);
Jimmy Chen1cfe0812022-02-16 18:31:37 +0800574 virtual wifi_error registerSubsystemRestartCallbackHandler(
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800575 const on_subsystem_restart_callback& on_restart_callback);
576 std::pair<wifi_error, std::vector<wifi_ring_buffer_status>> getRingBuffersStatus(
577 const std::string& iface_name);
578 wifi_error startRingBufferLogging(const std::string& iface_name, const std::string& ring_name,
579 uint32_t verbose_level, uint32_t max_interval_sec,
Roshan Piusabcf78f2017-10-06 16:30:38 -0700580 uint32_t min_data_size);
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800581 wifi_error getRingBufferData(const std::string& iface_name, const std::string& ring_name);
582 wifi_error registerErrorAlertCallbackHandler(const std::string& iface_name,
583 const on_error_alert_callback& on_alert_callback);
584 wifi_error deregisterErrorAlertCallbackHandler(const std::string& iface_name);
Roshan Pius01f08772018-01-22 17:56:06 -0800585 // Radio mode functions.
Roshan Piusaceecb02018-03-01 14:54:26 -0800586 virtual wifi_error registerRadioModeChangeCallbackHandler(
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800587 const std::string& iface_name,
588 const on_radio_mode_change_callback& on_user_change_callback);
Roshan Piusabcf78f2017-10-06 16:30:38 -0700589 // RTT functions.
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800590 wifi_error startRttRangeRequest(const std::string& iface_name, wifi_request_id id,
591 const std::vector<wifi_rtt_config>& rtt_configs,
592 const on_rtt_results_callback& on_results_callback);
593 wifi_error cancelRttRangeRequest(const std::string& iface_name, wifi_request_id id,
Gabriel Biren631a8112022-12-01 22:29:32 +0000594 const std::vector<std::array<uint8_t, 6>>& mac_addrs);
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800595 std::pair<wifi_error, wifi_rtt_capabilities> getRttCapabilities(const std::string& iface_name);
596 std::pair<wifi_error, wifi_rtt_responder> getRttResponderInfo(const std::string& iface_name);
597 wifi_error enableRttResponder(const std::string& iface_name, wifi_request_id id,
598 const wifi_channel_info& channel_hint, uint32_t max_duration_secs,
Roshan Piusabcf78f2017-10-06 16:30:38 -0700599 const wifi_rtt_responder& info);
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800600 wifi_error disableRttResponder(const std::string& iface_name, wifi_request_id id);
Roshan Piusabcf78f2017-10-06 16:30:38 -0700601 wifi_error setRttLci(const std::string& iface_name, wifi_request_id id,
602 const wifi_lci_information& info);
603 wifi_error setRttLcr(const std::string& iface_name, wifi_request_id id,
604 const wifi_lcr_information& info);
605 // NAN functions.
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800606 virtual wifi_error nanRegisterCallbackHandlers(const std::string& iface_name,
607 const NanCallbackHandlers& callbacks);
608 wifi_error nanEnableRequest(const std::string& iface_name, transaction_id id,
609 const NanEnableRequest& msg);
610 virtual wifi_error nanDisableRequest(const std::string& iface_name, transaction_id id);
611 wifi_error nanPublishRequest(const std::string& iface_name, transaction_id id,
Roshan Piusabcf78f2017-10-06 16:30:38 -0700612 const NanPublishRequest& msg);
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800613 wifi_error nanPublishCancelRequest(const std::string& iface_name, transaction_id id,
Roshan Piusabcf78f2017-10-06 16:30:38 -0700614 const NanPublishCancelRequest& msg);
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800615 wifi_error nanSubscribeRequest(const std::string& iface_name, transaction_id id,
Roshan Piusabcf78f2017-10-06 16:30:38 -0700616 const NanSubscribeRequest& msg);
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800617 wifi_error nanSubscribeCancelRequest(const std::string& iface_name, transaction_id id,
Roshan Piusabcf78f2017-10-06 16:30:38 -0700618 const NanSubscribeCancelRequest& msg);
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800619 wifi_error nanTransmitFollowupRequest(const std::string& iface_name, transaction_id id,
620 const NanTransmitFollowupRequest& msg);
Roshan Piusabcf78f2017-10-06 16:30:38 -0700621 wifi_error nanStatsRequest(const std::string& iface_name, transaction_id id,
622 const NanStatsRequest& msg);
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800623 wifi_error nanConfigRequest(const std::string& iface_name, transaction_id id,
624 const NanConfigRequest& msg);
Roshan Piusabcf78f2017-10-06 16:30:38 -0700625 wifi_error nanTcaRequest(const std::string& iface_name, transaction_id id,
626 const NanTCARequest& msg);
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800627 wifi_error nanBeaconSdfPayloadRequest(const std::string& iface_name, transaction_id id,
628 const NanBeaconSdfPayloadRequest& msg);
Roshan Piusabcf78f2017-10-06 16:30:38 -0700629 std::pair<wifi_error, NanVersion> nanGetVersion();
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800630 wifi_error nanGetCapabilities(const std::string& iface_name, transaction_id id);
631 wifi_error nanDataInterfaceCreate(const std::string& iface_name, transaction_id id,
Roshan Piusabcf78f2017-10-06 16:30:38 -0700632 const std::string& data_iface_name);
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800633 virtual wifi_error nanDataInterfaceDelete(const std::string& iface_name, transaction_id id,
634 const std::string& data_iface_name);
635 wifi_error nanDataRequestInitiator(const std::string& iface_name, transaction_id id,
Roshan Piusabcf78f2017-10-06 16:30:38 -0700636 const NanDataPathInitiatorRequest& msg);
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800637 wifi_error nanDataIndicationResponse(const std::string& iface_name, transaction_id id,
638 const NanDataPathIndicationResponse& msg);
639 wifi_error nanDataEnd(const std::string& iface_name, transaction_id id, uint32_t ndpInstanceId);
Roshan Piusabcf78f2017-10-06 16:30:38 -0700640 // AP functions.
Gabriel Biren631a8112022-12-01 22:29:32 +0000641 wifi_error setCountryCode(const std::string& iface_name, std::array<int8_t, 2> code);
Roshan Piusaabe5752016-09-29 09:03:59 -0700642
Gabriel Biren631a8112022-12-01 22:29:32 +0000643 // interface functions.
Roshan Pius5ba0a902020-04-14 11:55:42 -0700644 virtual wifi_error createVirtualInterface(const std::string& ifname,
645 wifi_interface_type iftype);
646 virtual wifi_error deleteVirtualInterface(const std::string& ifname);
Jimmy Chen1cfe0812022-02-16 18:31:37 +0800647 virtual wifi_error getSupportedIfaceName(uint32_t iface_type, std::string& ifname);
Sunil Raviddab4bb2020-02-03 22:45:19 -0800648
Roshan Piuse9d1e7d2020-11-04 11:44:16 -0800649 // STA + STA functions
650 virtual wifi_error multiStaSetPrimaryConnection(const std::string& ifname);
651 virtual wifi_error multiStaSetUseCase(wifi_multi_sta_use_case use_case);
652
Quang Luong94bcce52020-11-25 17:52:19 -0800653 // Coex functions.
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800654 virtual wifi_error setCoexUnsafeChannels(std::vector<wifi_coex_unsafe_channel> unsafe_channels,
655 uint32_t restrictions);
Quang Luong94bcce52020-11-25 17:52:19 -0800656
Kai Shi2ca7a112020-12-15 19:51:28 -0800657 wifi_error setVoipMode(const std::string& iface_name, wifi_voip_mode mode);
658
659 wifi_error twtRegisterHandler(const std::string& iface_name,
660 const TwtCallbackHandlers& handler);
661
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800662 std::pair<wifi_error, TwtCapabilitySet> twtGetCapability(const std::string& iface_name);
Kai Shi2ca7a112020-12-15 19:51:28 -0800663
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800664 wifi_error twtSetupRequest(const std::string& iface_name, const TwtSetupRequest& msg);
Kai Shi2ca7a112020-12-15 19:51:28 -0800665
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800666 wifi_error twtTearDownRequest(const std::string& iface_name, const TwtTeardownRequest& msg);
Kai Shi2ca7a112020-12-15 19:51:28 -0800667
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800668 wifi_error twtInfoFrameRequest(const std::string& iface_name, const TwtInfoFrameRequest& msg);
Kai Shi2ca7a112020-12-15 19:51:28 -0800669
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800670 std::pair<wifi_error, TwtStats> twtGetStats(const std::string& iface_name, uint8_t configId);
Kai Shi2ca7a112020-12-15 19:51:28 -0800671
672 wifi_error twtClearStats(const std::string& iface_name, uint8_t configId);
673
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800674 wifi_error setDtimConfig(const std::string& iface_name, uint32_t multiplier);
Kai Shi0b6341c2021-01-11 20:22:59 -0800675
Kumar Anand2a630a32021-01-21 14:09:14 -0800676 // Retrieve the list of usable channels in the requested bands
677 // for the requested modes
678 std::pair<wifi_error, std::vector<wifi_usable_channel>> getUsableChannels(
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800679 uint32_t band_mask, uint32_t iface_mode_mask, uint32_t filter_mask);
Kumar Anand2a630a32021-01-21 14:09:14 -0800680
chenpaulc6f57032021-03-05 17:06:50 +0800681 wifi_error triggerSubsystemRestart();
682
Sunil Ravi59559852022-01-24 17:33:24 -0800683 wifi_error setIndoorState(bool isIndoor);
684
Sunil Ravief97d232022-01-24 10:39:56 -0800685 std::pair<wifi_error, wifi_radio_combination_matrix*> getSupportedRadioCombinationsMatrix();
686
Isaac Chiou9cf44592022-01-17 13:37:35 +0800687 // CHRE NAN RTT function
688 wifi_error chreNanRttRequest(const std::string& iface_name, bool enable);
689
690 wifi_error chreRegisterHandler(const std::string& iface_name,
691 const ChreCallbackHandlers& handler);
692
Isaac Chiou52afeb62022-03-16 18:47:01 +0800693 wifi_error enableWifiTxPowerLimits(const std::string& iface_name, bool enable);
kensuna7e0a832022-10-31 13:46:17 +0000694 wifi_error getWifiCachedScanResults(const std::string& iface_name,
695 const CachedScanResultsCallbackHandlers& handler);
Isaac Chiou52afeb62022-03-16 18:47:01 +0800696
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800697 private:
Roshan Piusabcf78f2017-10-06 16:30:38 -0700698 // Retrieve interface handles for all the available interfaces.
699 wifi_error retrieveIfaceHandles();
700 wifi_interface_handle getIfaceHandle(const std::string& iface_name);
701 // Run the legacy HAL event loop thread.
702 void runEventLoop();
703 // Retrieve the cached gscan results to pass the results back to the
704 // external callbacks.
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800705 std::pair<wifi_error, std::vector<wifi_cached_scan_results>> getGscanCachedResults(
706 const std::string& iface_name);
Roshan Piusabcf78f2017-10-06 16:30:38 -0700707 void invalidate();
Sunil Raviddab4bb2020-02-03 22:45:19 -0800708 // Handles wifi (error) status of Virtual interface create/delete
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800709 wifi_error handleVirtualInterfaceCreateOrDeleteStatus(const std::string& ifname,
710 wifi_error status);
Roshan Piusaabe5752016-09-29 09:03:59 -0700711
Roshan Piusabcf78f2017-10-06 16:30:38 -0700712 // Global function table of legacy HAL.
713 wifi_hal_fn global_func_table_;
714 // Opaque handle to be used for all global operations.
715 wifi_handle global_handle_;
716 // Map of interface name to handle that is to be used for all interface
717 // specific operations.
718 std::map<std::string, wifi_interface_handle> iface_name_to_handle_;
719 // Flag to indicate if we have initiated the cleanup of legacy HAL.
720 std::atomic<bool> awaiting_event_loop_termination_;
721 std::condition_variable_any stop_wait_cv_;
722 // Flag to indicate if the legacy HAL has been started.
723 bool is_started_;
Gabriel Biren631a8112022-12-01 22:29:32 +0000724 std::weak_ptr<wifi_system::InterfaceTool> iface_tool_;
725 // flag to indicate if this HAL is for the primary chip. This is used
Jimmy Chen2dddd792019-12-23 17:50:39 +0200726 // in order to avoid some hard-coded behavior used with older HALs,
727 // such as bring wlan0 interface up/down on start/stop HAL.
728 // it may be removed once vendor HALs are updated.
729 bool is_primary_;
Roshan Piusaabe5752016-09-29 09:03:59 -0700730};
731
Roshan Pius955542e2016-10-28 09:42:44 -0700732} // namespace legacy_hal
Gabriel Biren631a8112022-12-01 22:29:32 +0000733} // namespace implementation
734} // namespace V1_6
Roshan Piusaabe5752016-09-29 09:03:59 -0700735} // namespace wifi
736} // namespace hardware
737} // namespace android
738
Roshan Piuse73a5062016-12-12 08:53:34 -0800739#endif // WIFI_LEGACY_HAL_H_