blob: ec7304cfcba66558571cf4bf09e735500d0177fb [file] [log] [blame]
Gabriel Birenf3262f92022-07-15 23:25:39 +00001/*
2 * Copyright (C) 2022 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
17#ifndef WIFI_LEGACY_HAL_H_
18#define WIFI_LEGACY_HAL_H_
19
20#include <hardware_legacy/wifi_hal.h>
21#include <wifi_system/interface_tool.h>
22
23#include <condition_variable>
24#include <functional>
25#include <map>
26#include <mutex>
27#include <thread>
28#include <vector>
29
30namespace aidl {
31namespace android {
32namespace hardware {
33namespace wifi {
34// This is in a separate namespace to prevent typename conflicts between
35// the legacy HAL types and the AIDL interface types.
36namespace legacy_hal {
37// Import all the types defined inside the legacy HAL header files into this
38// namespace.
39using ::chre_nan_rtt_state;
40using ::frame_info;
41using ::frame_type;
42using ::FRAME_TYPE_80211_MGMT;
43using ::FRAME_TYPE_ETHERNET_II;
44using ::FRAME_TYPE_UNKNOWN;
45using ::fw_roaming_state_t;
46using ::mac_addr;
Nate Jiang38e8db52022-12-02 17:30:27 -080047using ::NAN_BOOTSTRAPPING_INITIATOR_RESPONSE;
48using ::NAN_BOOTSTRAPPING_RESPONDER_RESPONSE;
Gabriel Birenf3262f92022-07-15 23:25:39 +000049using ::NAN_CHANNEL_24G_BAND;
50using ::NAN_CHANNEL_5G_BAND_HIGH;
51using ::NAN_CHANNEL_5G_BAND_LOW;
52using ::NAN_DISABLE_RANGE_REPORT;
53using ::NAN_DO_NOT_USE_SRF;
54using ::NAN_DP_CHANNEL_NOT_REQUESTED;
55using ::NAN_DP_CONFIG_NO_SECURITY;
56using ::NAN_DP_CONFIG_SECURITY;
57using ::NAN_DP_END;
58using ::NAN_DP_FORCE_CHANNEL_SETUP;
59using ::NAN_DP_INITIATOR_RESPONSE;
60using ::NAN_DP_INTERFACE_CREATE;
61using ::NAN_DP_INTERFACE_DELETE;
62using ::NAN_DP_REQUEST_ACCEPT;
63using ::NAN_DP_REQUEST_CHANNEL_SETUP;
64using ::NAN_DP_REQUEST_REJECT;
65using ::NAN_DP_RESPONDER_RESPONSE;
66using ::NAN_GET_CAPABILITIES;
67using ::NAN_MATCH_ALG_MATCH_CONTINUOUS;
68using ::NAN_MATCH_ALG_MATCH_NEVER;
69using ::NAN_MATCH_ALG_MATCH_ONCE;
Nate Jiangbae6fdd2023-02-10 17:16:40 -080070using ::NAN_PAIRING_END;
Nate Jiang38e8db52022-12-02 17:30:27 -080071using ::NAN_PAIRING_INITIATOR_RESPONSE;
72using ::NAN_PAIRING_RESPONDER_RESPONSE;
73using ::NAN_PAIRING_SETUP;
74using ::NAN_PAIRING_VERIFICATION;
Gabriel Birenf3262f92022-07-15 23:25:39 +000075using ::NAN_PUBLISH_TYPE_SOLICITED;
76using ::NAN_PUBLISH_TYPE_UNSOLICITED;
77using ::NAN_PUBLISH_TYPE_UNSOLICITED_SOLICITED;
78using ::NAN_RANGING_AUTO_RESPONSE_DISABLE;
79using ::NAN_RANGING_AUTO_RESPONSE_ENABLE;
80using ::NAN_RANGING_DISABLE;
81using ::NAN_RANGING_ENABLE;
82using ::NAN_RESPONSE_BEACON_SDF_PAYLOAD;
83using ::NAN_RESPONSE_CONFIG;
84using ::NAN_RESPONSE_DISABLED;
85using ::NAN_RESPONSE_ENABLED;
86using ::NAN_RESPONSE_ERROR;
87using ::NAN_RESPONSE_PUBLISH;
88using ::NAN_RESPONSE_PUBLISH_CANCEL;
89using ::NAN_RESPONSE_STATS;
90using ::NAN_RESPONSE_SUBSCRIBE;
91using ::NAN_RESPONSE_SUBSCRIBE_CANCEL;
92using ::NAN_RESPONSE_TCA;
93using ::NAN_RESPONSE_TRANSMIT_FOLLOWUP;
Nate Jiangd6cc3312023-02-14 16:37:54 -080094using ::NAN_RESUME_REQUEST_RESPONSE;
Gabriel Birenf3262f92022-07-15 23:25:39 +000095using ::NAN_SECURITY_KEY_INPUT_PASSPHRASE;
96using ::NAN_SECURITY_KEY_INPUT_PMK;
97using ::NAN_SERVICE_ACCEPT_POLICY_ALL;
98using ::NAN_SERVICE_ACCEPT_POLICY_NONE;
99using ::NAN_SRF_ATTR_BLOOM_FILTER;
100using ::NAN_SRF_ATTR_PARTIAL_MAC_ADDR;
101using ::NAN_SRF_INCLUDE_DO_NOT_RESPOND;
102using ::NAN_SRF_INCLUDE_RESPOND;
103using ::NAN_SSI_NOT_REQUIRED_IN_MATCH_IND;
104using ::NAN_SSI_REQUIRED_IN_MATCH_IND;
105using ::NAN_STATUS_ALREADY_ENABLED;
106using ::NAN_STATUS_FOLLOWUP_QUEUE_FULL;
107using ::NAN_STATUS_INTERNAL_FAILURE;
Nate Jiang38e8db52022-12-02 17:30:27 -0800108using ::NAN_STATUS_INVALID_BOOTSTRAPPING_ID;
Gabriel Birenf3262f92022-07-15 23:25:39 +0000109using ::NAN_STATUS_INVALID_NDP_ID;
Nate Jiang38e8db52022-12-02 17:30:27 -0800110using ::NAN_STATUS_INVALID_PAIRING_ID;
Gabriel Birenf3262f92022-07-15 23:25:39 +0000111using ::NAN_STATUS_INVALID_PARAM;
112using ::NAN_STATUS_INVALID_PUBLISH_SUBSCRIBE_ID;
113using ::NAN_STATUS_INVALID_REQUESTOR_INSTANCE_ID;
114using ::NAN_STATUS_NAN_NOT_ALLOWED;
Nate Jiangd6cc3312023-02-14 16:37:54 -0800115using ::NAN_STATUS_NO_CONNECTION;
Gabriel Birenf3262f92022-07-15 23:25:39 +0000116using ::NAN_STATUS_NO_OTA_ACK;
117using ::NAN_STATUS_NO_RESOURCE_AVAILABLE;
Nate Jiangd6cc3312023-02-14 16:37:54 -0800118using ::NAN_STATUS_NOT_SUPPORTED;
Gabriel Birenf3262f92022-07-15 23:25:39 +0000119using ::NAN_STATUS_PROTOCOL_FAILURE;
Nate Jiangd6cc3312023-02-14 16:37:54 -0800120using ::NAN_STATUS_REDUNDANT_REQUEST;
Gabriel Birenf3262f92022-07-15 23:25:39 +0000121using ::NAN_STATUS_SUCCESS;
122using ::NAN_STATUS_UNSUPPORTED_CONCURRENCY_NAN_DISABLED;
123using ::NAN_SUBSCRIBE_TYPE_ACTIVE;
124using ::NAN_SUBSCRIBE_TYPE_PASSIVE;
Nate Jiangd6cc3312023-02-14 16:37:54 -0800125using ::NAN_SUSPEND_REQUEST_RESPONSE;
Gabriel Birenf3262f92022-07-15 23:25:39 +0000126using ::NAN_TRANSMIT_IN_DW;
127using ::NAN_TRANSMIT_IN_FAW;
128using ::NAN_TX_PRIORITY_HIGH;
129using ::NAN_TX_PRIORITY_NORMAL;
130using ::NAN_TX_TYPE_BROADCAST;
131using ::NAN_TX_TYPE_UNICAST;
132using ::NAN_USE_SRF;
Nate Jiangbae6fdd2023-02-10 17:16:40 -0800133using ::NanAkm;
Gabriel Birenf3262f92022-07-15 23:25:39 +0000134using ::NanBeaconSdfPayloadInd;
Nate Jiang38e8db52022-12-02 17:30:27 -0800135using ::NanBootstrappingConfirmInd;
136using ::NanBootstrappingIndicationResponse;
137using ::NanBootstrappingRequest;
138using ::NanBootstrappingRequestInd;
139using ::NanBootstrappingRequestResponse;
140using ::NanBootstrappingResponseCode;
Gabriel Birenf3262f92022-07-15 23:25:39 +0000141using ::NanCapabilities;
142using ::NanChannelInfo;
143using ::NanConfigRequest;
144using ::NanDataPathChannelCfg;
145using ::NanDataPathConfirmInd;
146using ::NanDataPathEndInd;
147using ::NanDataPathIndicationResponse;
148using ::NanDataPathInitiatorRequest;
149using ::NanDataPathRequestInd;
150using ::NanDataPathScheduleUpdateInd;
151using ::NanDisabledInd;
152using ::NanDiscEngEventInd;
153using ::NanEnableRequest;
154using ::NanFollowupInd;
Nate Jiang38e8db52022-12-02 17:30:27 -0800155using ::NanIdentityResolutionAttribute;
Gabriel Birenf3262f92022-07-15 23:25:39 +0000156using ::NanMatchAlg;
157using ::NanMatchExpiredInd;
158using ::NanMatchInd;
Nate Jiang38e8db52022-12-02 17:30:27 -0800159using ::NanPairingConfig;
160using ::NanPairingConfirmInd;
Nate Jiangbae6fdd2023-02-10 17:16:40 -0800161using ::NanPairingEndRequest;
Nate Jiang38e8db52022-12-02 17:30:27 -0800162using ::NanPairingIndicationResponse;
163using ::NanPairingRequest;
164using ::NanPairingRequestInd;
165using ::NanPairingRequestResponse;
166using ::NanPairingRequestType;
167using ::NanPairingResponseCode;
Gabriel Birenf3262f92022-07-15 23:25:39 +0000168using ::NanPublishCancelRequest;
169using ::NanPublishRequest;
170using ::NanPublishTerminatedInd;
171using ::NanPublishType;
172using ::NanRangeReportInd;
173using ::NanRangeRequestInd;
174using ::NanResponseMsg;
Phill Hayers02a97242022-12-15 16:05:14 +0000175using ::NanResumeRequest;
Gabriel Birenf3262f92022-07-15 23:25:39 +0000176using ::NanSRFType;
177using ::NanStatusType;
178using ::NanSubscribeCancelRequest;
179using ::NanSubscribeRequest;
180using ::NanSubscribeTerminatedInd;
181using ::NanSubscribeType;
Phill Hayers02a97242022-12-15 16:05:14 +0000182using ::NanSuspendRequest;
Nate Jiangd6cc3312023-02-14 16:37:54 -0800183using ::NanSuspensionModeChangeInd;
Gabriel Birenf3262f92022-07-15 23:25:39 +0000184using ::NanTransmitFollowupInd;
185using ::NanTransmitFollowupRequest;
186using ::NanTxType;
Nate Jiang38e8db52022-12-02 17:30:27 -0800187using ::NpkSecurityAssociation;
188using ::PASN;
Gabriel Biren67d33e92023-12-01 01:29:26 +0000189using ::ROAMING_AGGRESSIVE;
Gabriel Birenf3262f92022-07-15 23:25:39 +0000190using ::ROAMING_DISABLE;
191using ::ROAMING_ENABLE;
192using ::RTT_PEER_AP;
193using ::RTT_PEER_NAN;
194using ::RTT_PEER_P2P_CLIENT;
195using ::RTT_PEER_P2P_GO;
196using ::RTT_PEER_STA;
197using ::rtt_peer_type;
198using ::RTT_STATUS_ABORTED;
199using ::RTT_STATUS_FAIL_AP_ON_DIFF_CHANNEL;
200using ::RTT_STATUS_FAIL_BUSY_TRY_LATER;
201using ::RTT_STATUS_FAIL_FTM_PARAM_OVERRIDE;
202using ::RTT_STATUS_FAIL_INVALID_TS;
203using ::RTT_STATUS_FAIL_NO_CAPABILITY;
204using ::RTT_STATUS_FAIL_NO_RSP;
205using ::RTT_STATUS_FAIL_NOT_SCHEDULED_YET;
206using ::RTT_STATUS_FAIL_PROTOCOL;
207using ::RTT_STATUS_FAIL_REJECTED;
208using ::RTT_STATUS_FAIL_SCHEDULE;
209using ::RTT_STATUS_FAIL_TM_TIMEOUT;
210using ::RTT_STATUS_FAILURE;
211using ::RTT_STATUS_INVALID_REQ;
212using ::RTT_STATUS_NAN_RANGING_CONCURRENCY_NOT_SUPPORTED;
213using ::RTT_STATUS_NAN_RANGING_PROTOCOL_FAILURE;
214using ::RTT_STATUS_NO_WIFI;
215using ::RTT_STATUS_SUCCESS;
216using ::RTT_TYPE_1_SIDED;
217using ::RTT_TYPE_2_SIDED;
maheshkkv7d422812023-11-16 17:32:50 -0800218using ::RTT_TYPE_2_SIDED_11AZ_NTB;
maheshkkva7f0b8b2024-10-13 10:07:28 -0700219using ::RTT_TYPE_2_SIDED_11AZ_NTB_SECURE;
maheshkkv7d422812023-11-16 17:32:50 -0800220using ::RTT_TYPE_2_SIDED_11MC;
Gabriel Birenf3262f92022-07-15 23:25:39 +0000221using ::RX_PKT_FATE_DRV_DROP_FILTER;
222using ::RX_PKT_FATE_DRV_DROP_INVALID;
223using ::RX_PKT_FATE_DRV_DROP_NOBUFS;
224using ::RX_PKT_FATE_DRV_DROP_OTHER;
225using ::RX_PKT_FATE_DRV_QUEUED;
226using ::RX_PKT_FATE_FW_DROP_FILTER;
227using ::RX_PKT_FATE_FW_DROP_INVALID;
228using ::RX_PKT_FATE_FW_DROP_NOBUFS;
229using ::RX_PKT_FATE_FW_DROP_OTHER;
230using ::RX_PKT_FATE_FW_QUEUED;
231using ::RX_PKT_FATE_SUCCESS;
Nate Jiang38e8db52022-12-02 17:30:27 -0800232using ::SAE;
Gabriel Birenf3262f92022-07-15 23:25:39 +0000233using ::ssid_t;
234using ::transaction_id;
235using ::TX_PKT_FATE_ACKED;
236using ::TX_PKT_FATE_DRV_DROP_INVALID;
237using ::TX_PKT_FATE_DRV_DROP_NOBUFS;
238using ::TX_PKT_FATE_DRV_DROP_OTHER;
239using ::TX_PKT_FATE_DRV_QUEUED;
240using ::TX_PKT_FATE_FW_DROP_INVALID;
241using ::TX_PKT_FATE_FW_DROP_NOBUFS;
242using ::TX_PKT_FATE_FW_DROP_OTHER;
243using ::TX_PKT_FATE_FW_QUEUED;
244using ::TX_PKT_FATE_SENT;
245using ::WIFI_AC_BE;
246using ::WIFI_AC_BK;
247using ::WIFI_AC_VI;
248using ::WIFI_AC_VO;
249using ::WIFI_ANTENNA_1X1;
250using ::WIFI_ANTENNA_2X2;
251using ::WIFI_ANTENNA_3X3;
252using ::WIFI_ANTENNA_4X4;
253using ::WIFI_ANTENNA_UNSPECIFIED;
254using ::wifi_band;
255using ::WIFI_BAND_A;
256using ::WIFI_BAND_A_DFS;
257using ::WIFI_BAND_A_WITH_DFS;
258using ::WIFI_BAND_ABG;
259using ::WIFI_BAND_ABG_WITH_DFS;
260using ::WIFI_BAND_BG;
261using ::WIFI_BAND_UNSPECIFIED;
262using ::wifi_cached_scan_report;
Kai Shi7d0e5e92023-11-20 19:23:36 -0800263using ::wifi_cached_scan_result;
Gabriel Birenf3262f92022-07-15 23:25:39 +0000264using ::wifi_cached_scan_results;
265using ::WIFI_CHAN_WIDTH_10;
266using ::WIFI_CHAN_WIDTH_160;
267using ::WIFI_CHAN_WIDTH_20;
268using ::WIFI_CHAN_WIDTH_320;
269using ::WIFI_CHAN_WIDTH_40;
270using ::WIFI_CHAN_WIDTH_5;
271using ::WIFI_CHAN_WIDTH_80;
272using ::WIFI_CHAN_WIDTH_80P80;
273using ::WIFI_CHAN_WIDTH_INVALID;
Shuibing Daie5fbcab2022-12-19 15:37:19 -0800274using ::wifi_channel_category;
Gabriel Birenf3262f92022-07-15 23:25:39 +0000275using ::wifi_channel_info;
276using ::wifi_channel_stat;
277using ::wifi_channel_width;
Mahesh KKVc84d3772022-12-02 16:53:28 -0800278using ::wifi_chip_capabilities;
Gabriel Birenf3262f92022-07-15 23:25:39 +0000279using ::wifi_coex_restriction;
280using ::wifi_coex_unsafe_channel;
Shuibing Daie5fbcab2022-12-19 15:37:19 -0800281using ::WIFI_DFS_CHANNEL;
Gabriel Birenf3262f92022-07-15 23:25:39 +0000282using ::WIFI_DUAL_STA_NON_TRANSIENT_UNBIASED;
283using ::WIFI_DUAL_STA_TRANSIENT_PREFER_PRIMARY;
284using ::wifi_error;
285using ::WIFI_ERROR_BUSY;
286using ::WIFI_ERROR_INVALID_ARGS;
287using ::WIFI_ERROR_INVALID_REQUEST_ID;
288using ::WIFI_ERROR_NONE;
289using ::WIFI_ERROR_NOT_AVAILABLE;
290using ::WIFI_ERROR_NOT_SUPPORTED;
291using ::WIFI_ERROR_OUT_OF_MEMORY;
292using ::WIFI_ERROR_TIMED_OUT;
293using ::WIFI_ERROR_TOO_MANY_REQUESTS;
294using ::WIFI_ERROR_UNINITIALIZED;
295using ::WIFI_ERROR_UNKNOWN;
296using ::wifi_gscan_capabilities;
297using ::wifi_hal_fn;
Sunil Ravif68b9a22023-02-15 20:56:56 +0000298using ::wifi_iface_concurrency_matrix;
Shuibing Daie5fbcab2022-12-19 15:37:19 -0800299using ::WIFI_INDOOR_CHANNEL;
Gabriel Birenf3262f92022-07-15 23:25:39 +0000300using ::wifi_information_element;
301using ::WIFI_INTERFACE_IBSS;
302using ::WIFI_INTERFACE_MESH;
303using ::wifi_interface_mode;
304using ::WIFI_INTERFACE_NAN;
305using ::WIFI_INTERFACE_P2P_CLIENT;
306using ::WIFI_INTERFACE_P2P_GO;
307using ::WIFI_INTERFACE_SOFTAP;
308using ::WIFI_INTERFACE_STA;
309using ::WIFI_INTERFACE_TDLS;
310using ::wifi_interface_type;
311using ::WIFI_INTERFACE_TYPE_AP;
312using ::WIFI_INTERFACE_TYPE_NAN;
313using ::WIFI_INTERFACE_TYPE_P2P;
314using ::WIFI_INTERFACE_TYPE_STA;
315using ::WIFI_INTERFACE_UNKNOWN;
316using ::wifi_latency_mode;
317using ::WIFI_LATENCY_MODE_LOW;
318using ::WIFI_LATENCY_MODE_NORMAL;
319using ::wifi_lci_information;
320using ::wifi_lcr_information;
321using ::WIFI_LOGGER_CONNECT_EVENT_SUPPORTED;
322using ::WIFI_LOGGER_DRIVER_DUMP_SUPPORTED;
323using ::WIFI_LOGGER_MEMORY_DUMP_SUPPORTED;
324using ::WIFI_LOGGER_PACKET_FATE_SUPPORTED;
325using ::WIFI_LOGGER_POWER_EVENT_SUPPORTED;
326using ::WIFI_LOGGER_WAKE_LOCK_SUPPORTED;
maheshkkva8aba172023-02-13 12:33:26 -0800327using ::wifi_mlo_mode;
Gabriel Birenf3262f92022-07-15 23:25:39 +0000328using ::WIFI_MOTION_EXPECTED;
329using ::WIFI_MOTION_NOT_EXPECTED;
330using ::wifi_motion_pattern;
331using ::WIFI_MOTION_UNKNOWN;
332using ::wifi_multi_sta_use_case;
333using ::wifi_power_scenario;
334using ::WIFI_POWER_SCENARIO_ON_BODY_CELL_OFF;
335using ::WIFI_POWER_SCENARIO_ON_BODY_CELL_ON;
336using ::WIFI_POWER_SCENARIO_ON_HEAD_CELL_OFF;
337using ::WIFI_POWER_SCENARIO_ON_HEAD_CELL_ON;
338using ::WIFI_POWER_SCENARIO_VOICE_CALL;
339using ::wifi_radio_combination;
340using ::wifi_radio_combination_matrix;
341using ::wifi_radio_configuration;
342using ::wifi_rate;
343using ::wifi_request_id;
344using ::wifi_ring_buffer_status;
345using ::wifi_roaming_capabilities;
346using ::wifi_roaming_config;
347using ::wifi_rtt_bw;
348using ::WIFI_RTT_BW_10;
349using ::WIFI_RTT_BW_160;
350using ::WIFI_RTT_BW_20;
351using ::WIFI_RTT_BW_320;
352using ::WIFI_RTT_BW_40;
353using ::WIFI_RTT_BW_5;
354using ::WIFI_RTT_BW_80;
Sunil Ravif8fc2372022-11-10 18:37:41 +0000355using ::WIFI_RTT_BW_UNSPECIFIED;
Gabriel Birenf3262f92022-07-15 23:25:39 +0000356using ::wifi_rtt_capabilities;
maheshkkv7d422812023-11-16 17:32:50 -0800357using ::wifi_rtt_capabilities_v3;
Gabriel Birenf3262f92022-07-15 23:25:39 +0000358using ::wifi_rtt_config;
maheshkkv7d422812023-11-16 17:32:50 -0800359using ::wifi_rtt_config_v3;
Gabriel Birenf3262f92022-07-15 23:25:39 +0000360using ::wifi_rtt_preamble;
361using ::WIFI_RTT_PREAMBLE_EHT;
362using ::WIFI_RTT_PREAMBLE_HE;
363using ::WIFI_RTT_PREAMBLE_HT;
maheshkkv7d422812023-11-16 17:32:50 -0800364using ::WIFI_RTT_PREAMBLE_INVALID;
Gabriel Birenf3262f92022-07-15 23:25:39 +0000365using ::WIFI_RTT_PREAMBLE_LEGACY;
366using ::WIFI_RTT_PREAMBLE_VHT;
367using ::wifi_rtt_responder;
368using ::wifi_rtt_result;
Sunil Ravif8fc2372022-11-10 18:37:41 +0000369using ::wifi_rtt_result_v2;
maheshkkv7d422812023-11-16 17:32:50 -0800370using ::wifi_rtt_result_v3;
Gabriel Birenf3262f92022-07-15 23:25:39 +0000371using ::wifi_rtt_status;
372using ::wifi_rtt_type;
373using ::wifi_rx_packet_fate;
374using ::wifi_rx_report;
375using ::wifi_scan_bucket_spec;
376using ::wifi_scan_cmd_params;
377using ::WIFI_SCAN_FLAG_INTERRUPTED;
378using ::wifi_scan_result;
379using ::WIFI_SUCCESS;
maheshkkv39903822023-11-28 15:31:53 -0800380using ::wifi_twt_capabilities;
381using ::wifi_twt_error_code;
382using ::wifi_twt_events;
383using ::wifi_twt_request;
384using ::wifi_twt_session;
385using ::wifi_twt_session_stats;
386using ::wifi_twt_teardown_reason_code;
Gabriel Birenf3262f92022-07-15 23:25:39 +0000387using ::wifi_tx_packet_fate;
388using ::wifi_tx_report;
389using ::wifi_usable_channel;
390using ::WIFI_USABLE_CHANNEL_FILTER_CELLULAR_COEXISTENCE;
391using ::WIFI_USABLE_CHANNEL_FILTER_CONCURRENCY;
392using ::WLAN_MAC_2_4_BAND;
393using ::WLAN_MAC_5_0_BAND;
394using ::WLAN_MAC_60_0_BAND;
395using ::WLAN_MAC_6_0_BAND;
396
397// APF capabilities supported by the iface.
398struct PacketFilterCapabilities {
399 uint32_t version;
400 uint32_t max_len;
401};
402
403// WARNING: We don't care about the variable sized members of either
404// |wifi_iface_stat|, |wifi_radio_stat| structures. So, using the pragma
405// to escape the compiler warnings regarding this.
406#pragma GCC diagnostic push
407#pragma GCC diagnostic ignored "-Wgnu-variable-sized-type-not-at-end"
408// The |wifi_radio_stat.tx_time_per_levels| stats is provided as a pointer in
409// |wifi_radio_stat| structure in the legacy HAL API. Separate that out
410// into a separate return element to avoid passing pointers around.
411struct LinkLayerRadioStats {
412 wifi_radio_stat stats;
413 std::vector<uint32_t> tx_time_per_levels;
414 std::vector<wifi_channel_stat> channel_stats;
415};
416
417struct WifiPeerInfo {
418 wifi_peer_info peer_info;
419 std::vector<wifi_rate_stat> rate_stats;
420};
421
422struct LinkLayerStats {
423 wifi_iface_stat iface;
424 std::vector<LinkLayerRadioStats> radios;
425 std::vector<WifiPeerInfo> peers;
Mahesh KKV5f30d332022-10-26 14:07:44 -0700426 bool valid;
Gabriel Birenf3262f92022-07-15 23:25:39 +0000427};
Mahesh KKV5f30d332022-10-26 14:07:44 -0700428
429struct LinkStats {
430 wifi_link_stat stat;
431 std::vector<WifiPeerInfo> peers;
432};
433
434struct LinkLayerMlStats {
435 wifi_iface_ml_stat iface;
436 std::vector<LinkStats> links;
437 std::vector<LinkLayerRadioStats> radios;
438 bool valid;
439};
440
Kai Shi7d0e5e92023-11-20 19:23:36 -0800441struct WifiCachedScanReport {
442 uint64_t ts;
443 std::vector<int> scanned_freqs;
444 std::vector<wifi_cached_scan_result> results;
445};
446
Gabriel Birenf3262f92022-07-15 23:25:39 +0000447#pragma GCC diagnostic pop
448
449// The |WLAN_DRIVER_WAKE_REASON_CNT.cmd_event_wake_cnt| and
450// |WLAN_DRIVER_WAKE_REASON_CNT.driver_fw_local_wake_cnt| stats is provided
451// as a pointer in |WLAN_DRIVER_WAKE_REASON_CNT| structure in the legacy HAL
452// API. Separate that out into a separate return elements to avoid passing
453// pointers around.
454struct WakeReasonStats {
455 WLAN_DRIVER_WAKE_REASON_CNT wake_reason_cnt;
456 std::vector<uint32_t> cmd_event_wake_cnt;
457 std::vector<uint32_t> driver_fw_local_wake_cnt;
458};
459
460// NAN response and event callbacks struct.
461struct NanCallbackHandlers {
462 // NotifyResponse invoked to notify the status of the Request.
463 std::function<void(transaction_id, const NanResponseMsg&)> on_notify_response;
464 // Various event callbacks.
465 std::function<void(const NanPublishTerminatedInd&)> on_event_publish_terminated;
466 std::function<void(const NanMatchInd&)> on_event_match;
467 std::function<void(const NanMatchExpiredInd&)> on_event_match_expired;
468 std::function<void(const NanSubscribeTerminatedInd&)> on_event_subscribe_terminated;
469 std::function<void(const NanFollowupInd&)> on_event_followup;
470 std::function<void(const NanDiscEngEventInd&)> on_event_disc_eng_event;
471 std::function<void(const NanDisabledInd&)> on_event_disabled;
472 std::function<void(const NanTCAInd&)> on_event_tca;
473 std::function<void(const NanBeaconSdfPayloadInd&)> on_event_beacon_sdf_payload;
474 std::function<void(const NanDataPathRequestInd&)> on_event_data_path_request;
475 std::function<void(const NanDataPathConfirmInd&)> on_event_data_path_confirm;
476 std::function<void(const NanDataPathEndInd&)> on_event_data_path_end;
477 std::function<void(const NanTransmitFollowupInd&)> on_event_transmit_follow_up;
478 std::function<void(const NanRangeRequestInd&)> on_event_range_request;
479 std::function<void(const NanRangeReportInd&)> on_event_range_report;
480 std::function<void(const NanDataPathScheduleUpdateInd&)> on_event_schedule_update;
Nate Jiang38e8db52022-12-02 17:30:27 -0800481 std::function<void(const NanPairingRequestInd&)> on_event_pairing_request;
482 std::function<void(const NanPairingConfirmInd&)> on_event_pairing_confirm;
483 std::function<void(const NanBootstrappingRequestInd&)> on_event_bootstrapping_request;
484 std::function<void(const NanBootstrappingConfirmInd&)> on_event_bootstrapping_confirm;
Nate Jiangd6cc3312023-02-14 16:37:54 -0800485 std::function<void(const NanSuspensionModeChangeInd&)> on_event_suspension_mode_change;
Gabriel Birenf3262f92022-07-15 23:25:39 +0000486};
487
488// Full scan results contain IE info and are hence passed by reference, to
489// preserve the variable length array member |ie_data|. Callee must not retain
490// the pointer.
491using on_gscan_full_result_callback =
492 std::function<void(wifi_request_id, const wifi_scan_result*, uint32_t)>;
493// These scan results don't contain any IE info, so no need to pass by
494// reference.
495using on_gscan_results_callback =
496 std::function<void(wifi_request_id, const std::vector<wifi_cached_scan_results>&)>;
497
498// Invoked when the rssi value breaches the thresholds set.
499using on_rssi_threshold_breached_callback =
500 std::function<void(wifi_request_id, std::array<uint8_t, ETH_ALEN>, int8_t)>;
501
502// Callback for RTT range request results.
503// Rtt results contain IE info and are hence passed by reference, to
504// preserve the |LCI| and |LCR| pointers. Callee must not retain
505// the pointer.
506using on_rtt_results_callback =
507 std::function<void(wifi_request_id, const std::vector<const wifi_rtt_result*>&)>;
Sunil Ravif8fc2372022-11-10 18:37:41 +0000508using on_rtt_results_callback_v2 =
509 std::function<void(wifi_request_id, const std::vector<const wifi_rtt_result_v2*>&)>;
maheshkkv7d422812023-11-16 17:32:50 -0800510using on_rtt_results_callback_v3 =
511 std::function<void(wifi_request_id, const std::vector<const wifi_rtt_result_v3*>&)>;
Gabriel Birenf3262f92022-07-15 23:25:39 +0000512
513// Callback for ring buffer data.
514using on_ring_buffer_data_callback = std::function<void(
515 const std::string&, const std::vector<uint8_t>&, const wifi_ring_buffer_status&)>;
516
517// Callback for alerts.
518using on_error_alert_callback = std::function<void(int32_t, const std::vector<uint8_t>&)>;
519
520// Callback for subsystem restart
521using on_subsystem_restart_callback = std::function<void(const std::string&)>;
522
523// Struct for the mac info from the legacy HAL. This is a cleaner version
524// of the |wifi_mac_info| & |wifi_iface_info|.
525typedef struct {
526 std::string name;
527 wifi_channel channel;
528} WifiIfaceInfo;
529
530typedef struct {
531 uint32_t wlan_mac_id;
532 /* BIT MASK of BIT(WLAN_MAC*) as represented by wlan_mac_band */
533 uint32_t mac_band;
534 /* Represents the connected Wi-Fi interfaces associated with each MAC */
535 std::vector<WifiIfaceInfo> iface_infos;
536} WifiMacInfo;
537
538// Callback for radio mode change
539using on_radio_mode_change_callback = std::function<void(const std::vector<WifiMacInfo>&)>;
540
541// TWT response and event callbacks struct.
542struct TwtCallbackHandlers {
543 // Callback for TWT setup response
544 std::function<void(const TwtSetupResponse&)> on_setup_response;
545 // Callback for TWT teardown completion
546 std::function<void(const TwtTeardownCompletion&)> on_teardown_completion;
547 // Callback for TWT info frame received event
548 std::function<void(const TwtInfoFrameReceived&)> on_info_frame_received;
549 // Callback for TWT notification from the device
550 std::function<void(const TwtDeviceNotify&)> on_device_notify;
551};
552
553// CHRE response and event callbacks struct.
554struct ChreCallbackHandlers {
555 // Callback for CHRE NAN RTT
556 std::function<void(chre_nan_rtt_state)> on_wifi_chre_nan_rtt_state;
557};
558
Kai Shi7d0e5e92023-11-20 19:23:36 -0800559using on_cached_scan_results_callback = std::function<void(wifi_cached_scan_report*)>;
560
561struct CachedScanResultsCallbfackHandlers {
Gabriel Birenf3262f92022-07-15 23:25:39 +0000562 // Callback for Cached Scan Results
563 std::function<void(wifi_cached_scan_report*)> on_cached_scan_results;
564};
565
maheshkkv39903822023-11-28 15:31:53 -0800566using on_twt_failure = std::function<void(wifi_request_id id, wifi_twt_error_code error_code)>;
567using on_twt_session_create = std::function<void(wifi_request_id id, wifi_twt_session twt_session)>;
568using on_twt_session_update = std::function<void(wifi_request_id id, wifi_twt_session twt_session)>;
569using on_twt_session_teardown = std::function<void(wifi_request_id id, int session_id,
570 wifi_twt_teardown_reason_code reason_code)>;
571using on_twt_session_stats =
572 std::function<void(wifi_request_id id, int session_id, wifi_twt_session_stats stats)>;
573using on_twt_session_suspend = std::function<void(wifi_request_id id, int session_id)>;
574using on_twt_session_resume = std::function<void(wifi_request_id id, int session_id)>;
575
Gabriel Birenf3262f92022-07-15 23:25:39 +0000576/**
577 * Class that encapsulates all legacy HAL interactions.
578 * This class manages the lifetime of the event loop thread used by legacy HAL.
579 *
580 * Note: There will only be a single instance of this class created in the Wifi
581 * object and will be valid for the lifetime of the process.
582 */
583class WifiLegacyHal {
584 public:
585 WifiLegacyHal(const std::weak_ptr<::android::wifi_system::InterfaceTool> iface_tool,
586 const wifi_hal_fn& fn, bool is_primary);
587 virtual ~WifiLegacyHal() = default;
588
589 // Initialize the legacy HAL function table.
590 virtual wifi_error initialize();
591 // Start the legacy HAL and the event looper thread.
592 virtual wifi_error start();
593 // Deinitialize the legacy HAL and wait for the event loop thread to exit
594 // using a predefined timeout.
595 virtual wifi_error stop(std::unique_lock<std::recursive_mutex>* lock,
596 const std::function<void()>& on_complete_callback);
597 virtual wifi_error waitForDriverReady();
598 // Checks if legacy HAL has successfully started
599 bool isStarted();
600 // Wrappers for all the functions in the legacy HAL function table.
601 virtual std::pair<wifi_error, std::string> getDriverVersion(const std::string& iface_name);
602 virtual std::pair<wifi_error, std::string> getFirmwareVersion(const std::string& iface_name);
603 std::pair<wifi_error, std::vector<uint8_t>> requestDriverMemoryDump(
604 const std::string& iface_name);
605 std::pair<wifi_error, std::vector<uint8_t>> requestFirmwareMemoryDump(
606 const std::string& iface_name);
607 virtual std::pair<wifi_error, uint64_t> getSupportedFeatureSet(const std::string& iface_name);
608 // APF functions.
609 std::pair<wifi_error, PacketFilterCapabilities> getPacketFilterCapabilities(
610 const std::string& iface_name);
611 wifi_error setPacketFilter(const std::string& iface_name, const std::vector<uint8_t>& program);
612 std::pair<wifi_error, std::vector<uint8_t>> readApfPacketFilterData(
613 const std::string& iface_name);
614 // Gscan functions.
615 std::pair<wifi_error, wifi_gscan_capabilities> getGscanCapabilities(
616 const std::string& iface_name);
617 // These API's provides a simplified interface over the legacy Gscan API's:
618 // a) All scan events from the legacy HAL API other than the
619 // |WIFI_SCAN_FAILED| are treated as notification of results.
620 // This method then retrieves the cached scan results from the legacy
621 // HAL API and triggers the externally provided
622 // |on_results_user_callback| on success.
623 // b) |WIFI_SCAN_FAILED| scan event or failure to retrieve cached scan
624 // results
625 // Triggers the externally provided |on_failure_user_callback|.
626 // c) Full scan result event triggers the externally provided
627 // |on_full_result_user_callback|.
628 wifi_error startGscan(const std::string& iface_name, wifi_request_id id,
629 const wifi_scan_cmd_params& params,
630 const std::function<void(wifi_request_id)>& on_failure_callback,
631 const on_gscan_results_callback& on_results_callback,
632 const on_gscan_full_result_callback& on_full_result_callback);
633 wifi_error stopGscan(const std::string& iface_name, wifi_request_id id);
634 std::pair<wifi_error, std::vector<uint32_t>> getValidFrequenciesForBand(
635 const std::string& iface_name, wifi_band band);
636 virtual wifi_error setDfsFlag(const std::string& iface_name, bool dfs_on);
637 // Link layer stats functions.
638 wifi_error enableLinkLayerStats(const std::string& iface_name, bool debug);
639 wifi_error disableLinkLayerStats(const std::string& iface_name);
Mahesh KKV5f30d332022-10-26 14:07:44 -0700640 wifi_error getLinkLayerStats(const std::string& iface_name,
641 legacy_hal::LinkLayerStats& legacy_stats,
642 legacy_hal::LinkLayerMlStats& legacy_ml_stats);
Gabriel Birenf3262f92022-07-15 23:25:39 +0000643 // RSSI monitor functions.
644 wifi_error startRssiMonitoring(
645 const std::string& iface_name, wifi_request_id id, int8_t max_rssi, int8_t min_rssi,
646 const on_rssi_threshold_breached_callback& on_threshold_breached_callback);
647 wifi_error stopRssiMonitoring(const std::string& iface_name, wifi_request_id id);
648 std::pair<wifi_error, wifi_roaming_capabilities> getRoamingCapabilities(
649 const std::string& iface_name);
650 wifi_error configureRoaming(const std::string& iface_name, const wifi_roaming_config& config);
651 wifi_error enableFirmwareRoaming(const std::string& iface_name, fw_roaming_state_t state);
652 wifi_error configureNdOffload(const std::string& iface_name, bool enable);
653 wifi_error startSendingOffloadedPacket(const std::string& iface_name, int32_t cmd_id,
654 uint16_t ether_type,
655 const std::vector<uint8_t>& ip_packet_data,
656 const std::array<uint8_t, 6>& src_address,
657 const std::array<uint8_t, 6>& dst_address,
658 int32_t period_in_ms);
659 wifi_error stopSendingOffloadedPacket(const std::string& iface_name, uint32_t cmd_id);
660 virtual wifi_error selectTxPowerScenario(const std::string& iface_name,
661 wifi_power_scenario scenario);
662 virtual wifi_error resetTxPowerScenario(const std::string& iface_name);
663 wifi_error setLatencyMode(const std::string& iface_name, wifi_latency_mode mode);
664 wifi_error setThermalMitigationMode(wifi_thermal_mode mode, uint32_t completion_window);
665 wifi_error setDscpToAccessCategoryMapping(uint32_t start, uint32_t end,
666 uint32_t access_category);
667 wifi_error resetDscpToAccessCategoryMapping();
668 // Logger/debug functions.
669 std::pair<wifi_error, uint32_t> getLoggerSupportedFeatureSet(const std::string& iface_name);
670 wifi_error startPktFateMonitoring(const std::string& iface_name);
671 std::pair<wifi_error, std::vector<wifi_tx_report>> getTxPktFates(const std::string& iface_name);
672 std::pair<wifi_error, std::vector<wifi_rx_report>> getRxPktFates(const std::string& iface_name);
673 std::pair<wifi_error, WakeReasonStats> getWakeReasonStats(const std::string& iface_name);
674 wifi_error registerRingBufferCallbackHandler(
675 const std::string& iface_name, const on_ring_buffer_data_callback& on_data_callback);
676 wifi_error deregisterRingBufferCallbackHandler(const std::string& iface_name);
677 virtual wifi_error registerSubsystemRestartCallbackHandler(
678 const on_subsystem_restart_callback& on_restart_callback);
679 std::pair<wifi_error, std::vector<wifi_ring_buffer_status>> getRingBuffersStatus(
680 const std::string& iface_name);
681 wifi_error startRingBufferLogging(const std::string& iface_name, const std::string& ring_name,
682 uint32_t verbose_level, uint32_t max_interval_sec,
683 uint32_t min_data_size);
684 wifi_error getRingBufferData(const std::string& iface_name, const std::string& ring_name);
685 wifi_error registerErrorAlertCallbackHandler(const std::string& iface_name,
686 const on_error_alert_callback& on_alert_callback);
687 wifi_error deregisterErrorAlertCallbackHandler(const std::string& iface_name);
688 // Radio mode functions.
689 virtual wifi_error registerRadioModeChangeCallbackHandler(
690 const std::string& iface_name,
691 const on_radio_mode_change_callback& on_user_change_callback);
692 // RTT functions.
693 wifi_error startRttRangeRequest(const std::string& iface_name, wifi_request_id id,
694 const std::vector<wifi_rtt_config>& rtt_configs,
Sunil Ravif8fc2372022-11-10 18:37:41 +0000695 const on_rtt_results_callback& on_results_callback,
696 const on_rtt_results_callback_v2& on_results_callback_v2);
maheshkkv7d422812023-11-16 17:32:50 -0800697 wifi_error startRttRangeRequestV3(const std::string& iface_name, wifi_request_id id,
698 const std::vector<wifi_rtt_config_v3>& rtt_configs,
699 const on_rtt_results_callback_v3& on_results_callback);
700
Gabriel Birenf3262f92022-07-15 23:25:39 +0000701 wifi_error cancelRttRangeRequest(const std::string& iface_name, wifi_request_id id,
702 const std::vector<std::array<uint8_t, ETH_ALEN>>& mac_addrs);
703 std::pair<wifi_error, wifi_rtt_capabilities> getRttCapabilities(const std::string& iface_name);
maheshkkv7d422812023-11-16 17:32:50 -0800704 std::pair<wifi_error, wifi_rtt_capabilities_v3> getRttCapabilitiesV3(
705 const std::string& iface_name);
Gabriel Birenf3262f92022-07-15 23:25:39 +0000706 std::pair<wifi_error, wifi_rtt_responder> getRttResponderInfo(const std::string& iface_name);
707 wifi_error enableRttResponder(const std::string& iface_name, wifi_request_id id,
708 const wifi_channel_info& channel_hint, uint32_t max_duration_secs,
709 const wifi_rtt_responder& info);
710 wifi_error disableRttResponder(const std::string& iface_name, wifi_request_id id);
711 wifi_error setRttLci(const std::string& iface_name, wifi_request_id id,
712 const wifi_lci_information& info);
713 wifi_error setRttLcr(const std::string& iface_name, wifi_request_id id,
714 const wifi_lcr_information& info);
715 // NAN functions.
716 virtual wifi_error nanRegisterCallbackHandlers(const std::string& iface_name,
717 const NanCallbackHandlers& callbacks);
718 wifi_error nanEnableRequest(const std::string& iface_name, transaction_id id,
719 const NanEnableRequest& msg);
720 virtual wifi_error nanDisableRequest(const std::string& iface_name, transaction_id id);
721 wifi_error nanPublishRequest(const std::string& iface_name, transaction_id id,
722 const NanPublishRequest& msg);
723 wifi_error nanPublishCancelRequest(const std::string& iface_name, transaction_id id,
724 const NanPublishCancelRequest& msg);
725 wifi_error nanSubscribeRequest(const std::string& iface_name, transaction_id id,
726 const NanSubscribeRequest& msg);
727 wifi_error nanSubscribeCancelRequest(const std::string& iface_name, transaction_id id,
728 const NanSubscribeCancelRequest& msg);
729 wifi_error nanTransmitFollowupRequest(const std::string& iface_name, transaction_id id,
730 const NanTransmitFollowupRequest& msg);
731 wifi_error nanStatsRequest(const std::string& iface_name, transaction_id id,
732 const NanStatsRequest& msg);
733 wifi_error nanConfigRequest(const std::string& iface_name, transaction_id id,
734 const NanConfigRequest& msg);
735 wifi_error nanTcaRequest(const std::string& iface_name, transaction_id id,
736 const NanTCARequest& msg);
737 wifi_error nanBeaconSdfPayloadRequest(const std::string& iface_name, transaction_id id,
738 const NanBeaconSdfPayloadRequest& msg);
739 std::pair<wifi_error, NanVersion> nanGetVersion();
740 wifi_error nanGetCapabilities(const std::string& iface_name, transaction_id id);
741 wifi_error nanDataInterfaceCreate(const std::string& iface_name, transaction_id id,
742 const std::string& data_iface_name);
743 virtual wifi_error nanDataInterfaceDelete(const std::string& iface_name, transaction_id id,
744 const std::string& data_iface_name);
745 wifi_error nanDataRequestInitiator(const std::string& iface_name, transaction_id id,
746 const NanDataPathInitiatorRequest& msg);
747 wifi_error nanDataIndicationResponse(const std::string& iface_name, transaction_id id,
748 const NanDataPathIndicationResponse& msg);
Nate Jiang38e8db52022-12-02 17:30:27 -0800749 wifi_error nanPairingRequest(const std::string& iface_name, transaction_id id,
750 const NanPairingRequest& msg);
751 wifi_error nanPairingIndicationResponse(const std::string& iface_name, transaction_id id,
752 const NanPairingIndicationResponse& msg);
753 wifi_error nanBootstrappingRequest(const std::string& iface_name, transaction_id id,
754 const NanBootstrappingRequest& msg);
755 wifi_error nanBootstrappingIndicationResponse(const std::string& iface_name, transaction_id id,
756 const NanBootstrappingIndicationResponse& msg);
Gabriel Birenf3262f92022-07-15 23:25:39 +0000757 wifi_error nanDataEnd(const std::string& iface_name, transaction_id id, uint32_t ndpInstanceId);
Nate Jiangbae6fdd2023-02-10 17:16:40 -0800758 wifi_error nanPairingEnd(const std::string& iface_name, transaction_id id, uint32_t pairingId);
Phill Hayers02a97242022-12-15 16:05:14 +0000759 wifi_error nanSuspendRequest(const std::string& iface_name, transaction_id id,
760 const NanSuspendRequest& msg);
761 wifi_error nanResumeRequest(const std::string& iface_name, transaction_id id,
762 const NanResumeRequest& msg);
Gabriel Birenf3262f92022-07-15 23:25:39 +0000763 // AP functions.
764 wifi_error setCountryCode(const std::string& iface_name, const std::array<uint8_t, 2> code);
765
766 // Interface functions.
767 virtual wifi_error createVirtualInterface(const std::string& ifname,
768 wifi_interface_type iftype);
769 virtual wifi_error deleteVirtualInterface(const std::string& ifname);
770 virtual wifi_error getSupportedIfaceName(uint32_t iface_type, std::string& ifname);
771
772 // STA + STA functions
773 virtual wifi_error multiStaSetPrimaryConnection(const std::string& ifname);
774 virtual wifi_error multiStaSetUseCase(wifi_multi_sta_use_case use_case);
775
776 // Coex functions.
777 virtual wifi_error setCoexUnsafeChannels(std::vector<wifi_coex_unsafe_channel> unsafe_channels,
778 uint32_t restrictions);
779
780 wifi_error setVoipMode(const std::string& iface_name, wifi_voip_mode mode);
781
maheshkkv39903822023-11-28 15:31:53 -0800782 // TWT functions
783 std::pair<wifi_twt_capabilities, wifi_error> twtGetCapabilities(const std::string& ifaceName);
Mahesh KKV3375df82024-03-11 17:40:08 +0000784 wifi_error twtRegisterEvents(
785 const std::string& ifaceName, const on_twt_failure& on_twt_failure_user_callback,
786 const on_twt_session_create& on_twt_session_create_user_callback,
787 const on_twt_session_update& on_twt_session_update_user_callback,
788 const on_twt_session_teardown& on_twt_session_teardown_user_callback,
789 const on_twt_session_stats& on_twt_session_stats_user_callback,
790 const on_twt_session_suspend& on_twt_session_suspend_user_callback,
791 const on_twt_session_resume& on_twt_session_resume_user_callback);
maheshkkv39903822023-11-28 15:31:53 -0800792 wifi_error twtSessionSetup(const std::string& ifaceName, uint32_t cmdId,
Mahesh KKV3375df82024-03-11 17:40:08 +0000793 const wifi_twt_request& request);
maheshkkv39903822023-11-28 15:31:53 -0800794 wifi_error twtSessionUpdate(const std::string& ifaceName, uint32_t cmdId, uint32_t sessionId,
795 const wifi_twt_request& request);
796 wifi_error twtSessionSuspend(const std::string& ifaceName, uint32_t cmdId, uint32_t sessionId);
797 wifi_error twtSessionResume(const std::string& ifaceName, uint32_t cmdId, uint32_t sessionId);
798 wifi_error twtSessionTeardown(const std::string& ifaceName, uint32_t cmdId, uint32_t sessionId);
799 wifi_error twtSessionGetStats(const std::string& ifaceName, uint32_t cmdId, uint32_t sessionId);
800
801 // Note: Following TWT functions are deprecated
Mahesh KKV3375df82024-03-11 17:40:08 +0000802 // Deprecated by twtRegisterEvegnts
Gabriel Birenf3262f92022-07-15 23:25:39 +0000803 wifi_error twtRegisterHandler(const std::string& iface_name,
804 const TwtCallbackHandlers& handler);
maheshkkv39903822023-11-28 15:31:53 -0800805 // Deprecated by twtGetCapabilities
Gabriel Birenf3262f92022-07-15 23:25:39 +0000806 std::pair<wifi_error, TwtCapabilitySet> twtGetCapability(const std::string& iface_name);
maheshkkv39903822023-11-28 15:31:53 -0800807 // Deprecated by twtSessionSetup
Gabriel Birenf3262f92022-07-15 23:25:39 +0000808 wifi_error twtSetupRequest(const std::string& iface_name, const TwtSetupRequest& msg);
maheshkkv39903822023-11-28 15:31:53 -0800809 // Deprecated by twtSessionTeardown
Gabriel Birenf3262f92022-07-15 23:25:39 +0000810 wifi_error twtTearDownRequest(const std::string& iface_name, const TwtTeardownRequest& msg);
maheshkkv39903822023-11-28 15:31:53 -0800811 // Deprecated by twtSessionSuspend and twtSessionResume
Gabriel Birenf3262f92022-07-15 23:25:39 +0000812 wifi_error twtInfoFrameRequest(const std::string& iface_name, const TwtInfoFrameRequest& msg);
maheshkkv39903822023-11-28 15:31:53 -0800813 // Deprecated by twtSessionGetStats
Gabriel Birenf3262f92022-07-15 23:25:39 +0000814 std::pair<wifi_error, TwtStats> twtGetStats(const std::string& iface_name, uint8_t configId);
maheshkkv39903822023-11-28 15:31:53 -0800815 // Deprecated
Gabriel Birenf3262f92022-07-15 23:25:39 +0000816 wifi_error twtClearStats(const std::string& iface_name, uint8_t configId);
817
Ye Jiao50274f72023-01-17 14:53:22 +0800818 wifi_error setScanMode(const std::string& iface_name, bool enable);
819
Gabriel Birenf3262f92022-07-15 23:25:39 +0000820 wifi_error setDtimConfig(const std::string& iface_name, uint32_t multiplier);
821
822 // Retrieve the list of usable channels in the requested bands
823 // for the requested modes
824 std::pair<wifi_error, std::vector<wifi_usable_channel>> getUsableChannels(
825 uint32_t band_mask, uint32_t iface_mode_mask, uint32_t filter_mask);
826
827 wifi_error triggerSubsystemRestart();
828
829 wifi_error setIndoorState(bool isIndoor);
830
831 std::pair<wifi_error, wifi_radio_combination_matrix*> getSupportedRadioCombinationsMatrix();
832
833 // CHRE NAN RTT function
834 wifi_error chreNanRttRequest(const std::string& iface_name, bool enable);
835
836 wifi_error chreRegisterHandler(const std::string& iface_name,
837 const ChreCallbackHandlers& handler);
838
839 wifi_error enableWifiTxPowerLimits(const std::string& iface_name, bool enable);
840 wifi_error getWifiCachedScanResults(const std::string& iface_name,
Kai Shi7d0e5e92023-11-20 19:23:36 -0800841 WifiCachedScanReport& report);
Mahesh KKVc84d3772022-12-02 16:53:28 -0800842 std::pair<wifi_error, wifi_chip_capabilities> getWifiChipCapabilities();
Shuibing Daie5fbcab2022-12-19 15:37:19 -0800843 wifi_error enableStaChannelForPeerNetwork(uint32_t channelCategoryEnableFlag);
maheshkkva8aba172023-02-13 12:33:26 -0800844 wifi_error setMloMode(wifi_mlo_mode mode);
Sunil Ravif68b9a22023-02-15 20:56:56 +0000845 std::pair<wifi_error, wifi_iface_concurrency_matrix> getSupportedIfaceConcurrencyMatrix();
Gabriel Birenf3262f92022-07-15 23:25:39 +0000846
847 private:
848 // Retrieve interface handles for all the available interfaces.
849 wifi_error retrieveIfaceHandles();
850 wifi_interface_handle getIfaceHandle(const std::string& iface_name);
851 // Run the legacy HAL event loop thread.
852 void runEventLoop();
853 // Retrieve the cached gscan results to pass the results back to the
854 // external callbacks.
855 std::pair<wifi_error, std::vector<wifi_cached_scan_results>> getGscanCachedResults(
856 const std::string& iface_name);
857 void invalidate();
858 // Handles wifi (error) status of Virtual interface create/delete
859 wifi_error handleVirtualInterfaceCreateOrDeleteStatus(const std::string& ifname,
860 wifi_error status);
Ye Jiaodec38702023-02-10 11:37:58 +0800861 wifi_link_stat* copyLinkStat(wifi_link_stat* stat_ptr, std::vector<LinkStats>& stats);
862 wifi_peer_info* copyPeerInfo(wifi_peer_info* peer_ptr, std::vector<WifiPeerInfo>& peers);
Gabriel Birenf3262f92022-07-15 23:25:39 +0000863
864 // Global function table of legacy HAL.
865 wifi_hal_fn global_func_table_;
866 // Opaque handle to be used for all global operations.
867 wifi_handle global_handle_;
868 // Map of interface name to handle that is to be used for all interface
869 // specific operations.
870 std::map<std::string, wifi_interface_handle> iface_name_to_handle_;
871 // Flag to indicate if we have initiated the cleanup of legacy HAL.
872 std::atomic<bool> awaiting_event_loop_termination_;
873 std::condition_variable_any stop_wait_cv_;
874 // Flag to indicate if the legacy HAL has been started.
875 bool is_started_;
876 std::weak_ptr<::android::wifi_system::InterfaceTool> iface_tool_;
877 // Flag to indicate if this HAL is for the primary chip. This is used
878 // in order to avoid some hard-coded behavior used with older HALs,
879 // such as bring wlan0 interface up/down on start/stop HAL.
880 // it may be removed once vendor HALs are updated.
881 bool is_primary_;
882};
883
884} // namespace legacy_hal
885} // namespace wifi
886} // namespace hardware
887} // namespace android
888} // namespace aidl
889
890#endif // WIFI_LEGACY_HAL_H_