blob: 796098db2ad2e1b13a1c53267458b5c4c8efeffc [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#include "wifi_legacy_hal.h"
18
19#include <android-base/logging.h>
20#include <cutils/properties.h>
21#include <net/if.h>
22
23#include <array>
24#include <chrono>
25
26#include "aidl_sync_util.h"
27#include "wifi_legacy_hal_stubs.h"
28
29namespace {
30// Constants ported over from the legacy HAL calling code
31// (com_android_server_wifi_WifiNative.cpp). This will all be thrown
32// away when this shim layer is replaced by the real vendor
33// implementation.
34static constexpr uint32_t kMaxVersionStringLength = 256;
35static constexpr uint32_t kMaxCachedGscanResults = 64;
36static constexpr uint32_t kMaxGscanFrequenciesForBand = 64;
37static constexpr uint32_t kLinkLayerStatsDataMpduSizeThreshold = 128;
38static constexpr uint32_t kMaxWakeReasonStatsArraySize = 32;
39static constexpr uint32_t kMaxRingBuffers = 10;
40static constexpr uint32_t kMaxWifiUsableChannels = 256;
41static constexpr uint32_t kMaxSupportedRadioCombinationsMatrixLength = 256;
42// Need a long timeout (1000ms) for chips that unload their driver.
43static constexpr uint32_t kMaxStopCompleteWaitMs = 1000;
44static constexpr char kDriverPropName[] = "wlan.driver.status";
45
46// Helper function to create a non-const char* for legacy Hal API's.
47std::vector<char> makeCharVec(const std::string& str) {
48 std::vector<char> vec(str.size() + 1);
49 vec.assign(str.begin(), str.end());
50 vec.push_back('\0');
51 return vec;
52}
53} // namespace
54
55namespace aidl {
56namespace android {
57namespace hardware {
58namespace wifi {
59namespace legacy_hal {
60
61// Legacy HAL functions accept "C" style function pointers, so use global
62// functions to pass to the legacy HAL function and store the corresponding
63// std::function methods to be invoked.
64//
65// Callback to be invoked once |stop| is complete
66std::function<void(wifi_handle handle)> on_stop_complete_internal_callback;
67void onAsyncStopComplete(wifi_handle handle) {
68 const auto lock = aidl_sync_util::acquireGlobalLock();
69 if (on_stop_complete_internal_callback) {
70 on_stop_complete_internal_callback(handle);
71 // Invalidate this callback since we don't want this firing again.
72 on_stop_complete_internal_callback = nullptr;
73 }
74}
75
76// Callback to be invoked for driver dump.
77std::function<void(char*, int)> on_driver_memory_dump_internal_callback;
78void onSyncDriverMemoryDump(char* buffer, int buffer_size) {
79 if (on_driver_memory_dump_internal_callback) {
80 on_driver_memory_dump_internal_callback(buffer, buffer_size);
81 }
82}
83
84// Callback to be invoked for firmware dump.
85std::function<void(char*, int)> on_firmware_memory_dump_internal_callback;
86void onSyncFirmwareMemoryDump(char* buffer, int buffer_size) {
87 if (on_firmware_memory_dump_internal_callback) {
88 on_firmware_memory_dump_internal_callback(buffer, buffer_size);
89 }
90}
91
92// Callback to be invoked for Gscan events.
93std::function<void(wifi_request_id, wifi_scan_event)> on_gscan_event_internal_callback;
94void onAsyncGscanEvent(wifi_request_id id, wifi_scan_event event) {
95 const auto lock = aidl_sync_util::acquireGlobalLock();
96 if (on_gscan_event_internal_callback) {
97 on_gscan_event_internal_callback(id, event);
98 }
99}
100
101// Callback to be invoked for Gscan full results.
102std::function<void(wifi_request_id, wifi_scan_result*, uint32_t)>
103 on_gscan_full_result_internal_callback;
104void onAsyncGscanFullResult(wifi_request_id id, wifi_scan_result* result,
105 uint32_t buckets_scanned) {
106 const auto lock = aidl_sync_util::acquireGlobalLock();
107 if (on_gscan_full_result_internal_callback) {
108 on_gscan_full_result_internal_callback(id, result, buckets_scanned);
109 }
110}
111
112// Callback to be invoked for link layer stats results.
113std::function<void((wifi_request_id, wifi_iface_stat*, int, wifi_radio_stat*))>
114 on_link_layer_stats_result_internal_callback;
115void onSyncLinkLayerStatsResult(wifi_request_id id, wifi_iface_stat* iface_stat, int num_radios,
116 wifi_radio_stat* radio_stat) {
117 if (on_link_layer_stats_result_internal_callback) {
118 on_link_layer_stats_result_internal_callback(id, iface_stat, num_radios, radio_stat);
119 }
120}
121
Mahesh KKV5f30d332022-10-26 14:07:44 -0700122// Callback to be invoked for Multi link layer stats results.
123std::function<void((wifi_request_id, wifi_iface_ml_stat*, int, wifi_radio_stat*))>
124 on_link_layer_ml_stats_result_internal_callback;
125void onSyncLinkLayerMlStatsResult(wifi_request_id id, wifi_iface_ml_stat* iface_ml_stat,
126 int num_radios, wifi_radio_stat* radio_stat) {
127 if (on_link_layer_ml_stats_result_internal_callback) {
128 on_link_layer_ml_stats_result_internal_callback(id, iface_ml_stat, num_radios, radio_stat);
129 }
130}
131
Gabriel Birenf3262f92022-07-15 23:25:39 +0000132// Callback to be invoked for rssi threshold breach.
133std::function<void((wifi_request_id, uint8_t*, int8_t))>
134 on_rssi_threshold_breached_internal_callback;
135void onAsyncRssiThresholdBreached(wifi_request_id id, uint8_t* bssid, int8_t rssi) {
136 const auto lock = aidl_sync_util::acquireGlobalLock();
137 if (on_rssi_threshold_breached_internal_callback) {
138 on_rssi_threshold_breached_internal_callback(id, bssid, rssi);
139 }
140}
141
142// Callback to be invoked for ring buffer data indication.
143std::function<void(char*, char*, int, wifi_ring_buffer_status*)>
144 on_ring_buffer_data_internal_callback;
145void onAsyncRingBufferData(char* ring_name, char* buffer, int buffer_size,
146 wifi_ring_buffer_status* status) {
147 const auto lock = aidl_sync_util::acquireGlobalLock();
148 if (on_ring_buffer_data_internal_callback) {
149 on_ring_buffer_data_internal_callback(ring_name, buffer, buffer_size, status);
150 }
151}
152
153// Callback to be invoked for error alert indication.
154std::function<void(wifi_request_id, char*, int, int)> on_error_alert_internal_callback;
155void onAsyncErrorAlert(wifi_request_id id, char* buffer, int buffer_size, int err_code) {
156 const auto lock = aidl_sync_util::acquireGlobalLock();
157 if (on_error_alert_internal_callback) {
158 on_error_alert_internal_callback(id, buffer, buffer_size, err_code);
159 }
160}
161
162// Callback to be invoked for radio mode change indication.
163std::function<void(wifi_request_id, uint32_t, wifi_mac_info*)>
164 on_radio_mode_change_internal_callback;
165void onAsyncRadioModeChange(wifi_request_id id, uint32_t num_macs, wifi_mac_info* mac_infos) {
166 const auto lock = aidl_sync_util::acquireGlobalLock();
167 if (on_radio_mode_change_internal_callback) {
168 on_radio_mode_change_internal_callback(id, num_macs, mac_infos);
169 }
170}
171
172// Callback to be invoked to report subsystem restart
173std::function<void(const char*)> on_subsystem_restart_internal_callback;
174void onAsyncSubsystemRestart(const char* error) {
175 const auto lock = aidl_sync_util::acquireGlobalLock();
176 if (on_subsystem_restart_internal_callback) {
177 on_subsystem_restart_internal_callback(error);
178 }
179}
180
181// Callback to be invoked for rtt results results.
182std::function<void(wifi_request_id, unsigned num_results, wifi_rtt_result* rtt_results[])>
183 on_rtt_results_internal_callback;
Sunil Ravif8fc2372022-11-10 18:37:41 +0000184std::function<void(wifi_request_id, unsigned num_results, wifi_rtt_result_v2* rtt_results_v2[])>
185 on_rtt_results_internal_callback_v2;
186
187void invalidateRttResultsCallbacks() {
188 on_rtt_results_internal_callback = nullptr;
189 on_rtt_results_internal_callback_v2 = nullptr;
190};
191
Gabriel Birenf3262f92022-07-15 23:25:39 +0000192void onAsyncRttResults(wifi_request_id id, unsigned num_results, wifi_rtt_result* rtt_results[]) {
193 const auto lock = aidl_sync_util::acquireGlobalLock();
194 if (on_rtt_results_internal_callback) {
195 on_rtt_results_internal_callback(id, num_results, rtt_results);
Sunil Ravif8fc2372022-11-10 18:37:41 +0000196 invalidateRttResultsCallbacks();
197 }
198}
199
200void onAsyncRttResultsV2(wifi_request_id id, unsigned num_results,
201 wifi_rtt_result_v2* rtt_results_v2[]) {
202 const auto lock = aidl_sync_util::acquireGlobalLock();
203 if (on_rtt_results_internal_callback_v2) {
204 on_rtt_results_internal_callback_v2(id, num_results, rtt_results_v2);
205 invalidateRttResultsCallbacks();
Gabriel Birenf3262f92022-07-15 23:25:39 +0000206 }
207}
208
209// Callbacks for the various NAN operations.
210// NOTE: These have very little conversions to perform before invoking the user
211// callbacks.
212// So, handle all of them here directly to avoid adding an unnecessary layer.
213std::function<void(transaction_id, const NanResponseMsg&)> on_nan_notify_response_user_callback;
214void onAsyncNanNotifyResponse(transaction_id id, NanResponseMsg* msg) {
215 const auto lock = aidl_sync_util::acquireGlobalLock();
216 if (on_nan_notify_response_user_callback && msg) {
217 on_nan_notify_response_user_callback(id, *msg);
218 }
219}
220
221std::function<void(const NanPublishRepliedInd&)> on_nan_event_publish_replied_user_callback;
222void onAsyncNanEventPublishReplied(NanPublishRepliedInd* /* event */) {
223 LOG(ERROR) << "onAsyncNanEventPublishReplied triggered";
224}
225
226std::function<void(const NanPublishTerminatedInd&)> on_nan_event_publish_terminated_user_callback;
227void onAsyncNanEventPublishTerminated(NanPublishTerminatedInd* event) {
228 const auto lock = aidl_sync_util::acquireGlobalLock();
229 if (on_nan_event_publish_terminated_user_callback && event) {
230 on_nan_event_publish_terminated_user_callback(*event);
231 }
232}
233
234std::function<void(const NanMatchInd&)> on_nan_event_match_user_callback;
235void onAsyncNanEventMatch(NanMatchInd* event) {
236 const auto lock = aidl_sync_util::acquireGlobalLock();
237 if (on_nan_event_match_user_callback && event) {
238 on_nan_event_match_user_callback(*event);
239 }
240}
241
242std::function<void(const NanMatchExpiredInd&)> on_nan_event_match_expired_user_callback;
243void onAsyncNanEventMatchExpired(NanMatchExpiredInd* event) {
244 const auto lock = aidl_sync_util::acquireGlobalLock();
245 if (on_nan_event_match_expired_user_callback && event) {
246 on_nan_event_match_expired_user_callback(*event);
247 }
248}
249
250std::function<void(const NanSubscribeTerminatedInd&)>
251 on_nan_event_subscribe_terminated_user_callback;
252void onAsyncNanEventSubscribeTerminated(NanSubscribeTerminatedInd* event) {
253 const auto lock = aidl_sync_util::acquireGlobalLock();
254 if (on_nan_event_subscribe_terminated_user_callback && event) {
255 on_nan_event_subscribe_terminated_user_callback(*event);
256 }
257}
258
259std::function<void(const NanFollowupInd&)> on_nan_event_followup_user_callback;
260void onAsyncNanEventFollowup(NanFollowupInd* event) {
261 const auto lock = aidl_sync_util::acquireGlobalLock();
262 if (on_nan_event_followup_user_callback && event) {
263 on_nan_event_followup_user_callback(*event);
264 }
265}
266
267std::function<void(const NanDiscEngEventInd&)> on_nan_event_disc_eng_event_user_callback;
268void onAsyncNanEventDiscEngEvent(NanDiscEngEventInd* event) {
269 const auto lock = aidl_sync_util::acquireGlobalLock();
270 if (on_nan_event_disc_eng_event_user_callback && event) {
271 on_nan_event_disc_eng_event_user_callback(*event);
272 }
273}
274
275std::function<void(const NanDisabledInd&)> on_nan_event_disabled_user_callback;
276void onAsyncNanEventDisabled(NanDisabledInd* event) {
277 const auto lock = aidl_sync_util::acquireGlobalLock();
278 if (on_nan_event_disabled_user_callback && event) {
279 on_nan_event_disabled_user_callback(*event);
280 }
281}
282
283std::function<void(const NanTCAInd&)> on_nan_event_tca_user_callback;
284void onAsyncNanEventTca(NanTCAInd* event) {
285 const auto lock = aidl_sync_util::acquireGlobalLock();
286 if (on_nan_event_tca_user_callback && event) {
287 on_nan_event_tca_user_callback(*event);
288 }
289}
290
291std::function<void(const NanBeaconSdfPayloadInd&)> on_nan_event_beacon_sdf_payload_user_callback;
292void onAsyncNanEventBeaconSdfPayload(NanBeaconSdfPayloadInd* event) {
293 const auto lock = aidl_sync_util::acquireGlobalLock();
294 if (on_nan_event_beacon_sdf_payload_user_callback && event) {
295 on_nan_event_beacon_sdf_payload_user_callback(*event);
296 }
297}
298
299std::function<void(const NanDataPathRequestInd&)> on_nan_event_data_path_request_user_callback;
300void onAsyncNanEventDataPathRequest(NanDataPathRequestInd* event) {
301 const auto lock = aidl_sync_util::acquireGlobalLock();
302 if (on_nan_event_data_path_request_user_callback && event) {
303 on_nan_event_data_path_request_user_callback(*event);
304 }
305}
306std::function<void(const NanDataPathConfirmInd&)> on_nan_event_data_path_confirm_user_callback;
307void onAsyncNanEventDataPathConfirm(NanDataPathConfirmInd* event) {
308 const auto lock = aidl_sync_util::acquireGlobalLock();
309 if (on_nan_event_data_path_confirm_user_callback && event) {
310 on_nan_event_data_path_confirm_user_callback(*event);
311 }
312}
313
314std::function<void(const NanDataPathEndInd&)> on_nan_event_data_path_end_user_callback;
315void onAsyncNanEventDataPathEnd(NanDataPathEndInd* event) {
316 const auto lock = aidl_sync_util::acquireGlobalLock();
317 if (on_nan_event_data_path_end_user_callback && event) {
318 on_nan_event_data_path_end_user_callback(*event);
319 }
320}
321
322std::function<void(const NanTransmitFollowupInd&)> on_nan_event_transmit_follow_up_user_callback;
323void onAsyncNanEventTransmitFollowUp(NanTransmitFollowupInd* event) {
324 const auto lock = aidl_sync_util::acquireGlobalLock();
325 if (on_nan_event_transmit_follow_up_user_callback && event) {
326 on_nan_event_transmit_follow_up_user_callback(*event);
327 }
328}
329
330std::function<void(const NanRangeRequestInd&)> on_nan_event_range_request_user_callback;
331void onAsyncNanEventRangeRequest(NanRangeRequestInd* event) {
332 const auto lock = aidl_sync_util::acquireGlobalLock();
333 if (on_nan_event_range_request_user_callback && event) {
334 on_nan_event_range_request_user_callback(*event);
335 }
336}
337
338std::function<void(const NanRangeReportInd&)> on_nan_event_range_report_user_callback;
339void onAsyncNanEventRangeReport(NanRangeReportInd* event) {
340 const auto lock = aidl_sync_util::acquireGlobalLock();
341 if (on_nan_event_range_report_user_callback && event) {
342 on_nan_event_range_report_user_callback(*event);
343 }
344}
345
346std::function<void(const NanDataPathScheduleUpdateInd&)> on_nan_event_schedule_update_user_callback;
347void onAsyncNanEventScheduleUpdate(NanDataPathScheduleUpdateInd* event) {
348 const auto lock = aidl_sync_util::acquireGlobalLock();
349 if (on_nan_event_schedule_update_user_callback && event) {
350 on_nan_event_schedule_update_user_callback(*event);
351 }
352}
353
Nate Jiangd6cc3312023-02-14 16:37:54 -0800354std::function<void(const NanSuspensionModeChangeInd&)>
355 on_nan_event_suspension_mode_change_user_callback;
356void onAsyncNanEventSuspensionModeChange(NanSuspensionModeChangeInd* event) {
357 const auto lock = aidl_sync_util::acquireGlobalLock();
358 if (on_nan_event_suspension_mode_change_user_callback && event) {
359 on_nan_event_suspension_mode_change_user_callback(*event);
360 }
361}
362
Nate Jiang38e8db52022-12-02 17:30:27 -0800363std::function<void(const NanPairingRequestInd&)> on_nan_event_pairing_request_user_callback;
364void onAsyncNanEventPairingRequest(NanPairingRequestInd* event) {
365 const auto lock = aidl_sync_util::acquireGlobalLock();
366 if (on_nan_event_pairing_request_user_callback && event) {
367 on_nan_event_pairing_request_user_callback(*event);
368 }
369}
370
371std::function<void(const NanPairingConfirmInd&)> on_nan_event_pairing_confirm_user_callback;
372void onAsyncNanEventPairingConfirm(NanPairingConfirmInd* event) {
373 const auto lock = aidl_sync_util::acquireGlobalLock();
374 if (on_nan_event_pairing_confirm_user_callback && event) {
375 on_nan_event_pairing_confirm_user_callback(*event);
376 }
377}
378
379std::function<void(const NanBootstrappingRequestInd&)>
380 on_nan_event_bootstrapping_request_user_callback;
381void onAsyncNanEventBootstrappingRequest(NanBootstrappingRequestInd* event) {
382 const auto lock = aidl_sync_util::acquireGlobalLock();
383 if (on_nan_event_bootstrapping_request_user_callback && event) {
384 on_nan_event_bootstrapping_request_user_callback(*event);
385 }
386}
387
388std::function<void(const NanBootstrappingConfirmInd&)>
389 on_nan_event_bootstrapping_confirm_user_callback;
390void onAsyncNanEventBootstrappingConfirm(NanBootstrappingConfirmInd* event) {
391 const auto lock = aidl_sync_util::acquireGlobalLock();
392 if (on_nan_event_bootstrapping_confirm_user_callback && event) {
393 on_nan_event_bootstrapping_confirm_user_callback(*event);
394 }
395}
396
Gabriel Birenf3262f92022-07-15 23:25:39 +0000397// Callbacks for the various TWT operations.
398std::function<void(const TwtSetupResponse&)> on_twt_event_setup_response_callback;
399void onAsyncTwtEventSetupResponse(TwtSetupResponse* event) {
400 const auto lock = aidl_sync_util::acquireGlobalLock();
401 if (on_twt_event_setup_response_callback && event) {
402 on_twt_event_setup_response_callback(*event);
403 }
404}
405
406std::function<void(const TwtTeardownCompletion&)> on_twt_event_teardown_completion_callback;
407void onAsyncTwtEventTeardownCompletion(TwtTeardownCompletion* event) {
408 const auto lock = aidl_sync_util::acquireGlobalLock();
409 if (on_twt_event_teardown_completion_callback && event) {
410 on_twt_event_teardown_completion_callback(*event);
411 }
412}
413
414std::function<void(const TwtInfoFrameReceived&)> on_twt_event_info_frame_received_callback;
415void onAsyncTwtEventInfoFrameReceived(TwtInfoFrameReceived* event) {
416 const auto lock = aidl_sync_util::acquireGlobalLock();
417 if (on_twt_event_info_frame_received_callback && event) {
418 on_twt_event_info_frame_received_callback(*event);
419 }
420}
421
422std::function<void(const TwtDeviceNotify&)> on_twt_event_device_notify_callback;
423void onAsyncTwtEventDeviceNotify(TwtDeviceNotify* event) {
424 const auto lock = aidl_sync_util::acquireGlobalLock();
425 if (on_twt_event_device_notify_callback && event) {
426 on_twt_event_device_notify_callback(*event);
427 }
428}
429
430// Callback to report current CHRE NAN state
431std::function<void(chre_nan_rtt_state)> on_chre_nan_rtt_internal_callback;
432void onAsyncChreNanRttState(chre_nan_rtt_state state) {
433 const auto lock = aidl_sync_util::acquireGlobalLock();
434 if (on_chre_nan_rtt_internal_callback) {
435 on_chre_nan_rtt_internal_callback(state);
436 }
437}
438
439// Callback to report cached scan results
440std::function<void(wifi_cached_scan_report*)> on_cached_scan_results_internal_callback;
441void onSyncCachedScanResults(wifi_cached_scan_report* cache_report) {
442 if (on_cached_scan_results_internal_callback) {
443 on_cached_scan_results_internal_callback(cache_report);
444 }
445}
446
447// End of the free-standing "C" style callbacks.
448
449WifiLegacyHal::WifiLegacyHal(const std::weak_ptr<::android::wifi_system::InterfaceTool> iface_tool,
450 const wifi_hal_fn& fn, bool is_primary)
451 : global_func_table_(fn),
452 global_handle_(nullptr),
453 awaiting_event_loop_termination_(false),
454 is_started_(false),
455 iface_tool_(iface_tool),
456 is_primary_(is_primary) {}
457
458wifi_error WifiLegacyHal::initialize() {
459 LOG(DEBUG) << "Initialize legacy HAL";
460 // this now does nothing, since HAL function table is provided
461 // to the constructor
462 return WIFI_SUCCESS;
463}
464
465wifi_error WifiLegacyHal::start() {
466 // Ensure that we're starting in a good state.
467 CHECK(global_func_table_.wifi_initialize && !global_handle_ && iface_name_to_handle_.empty() &&
468 !awaiting_event_loop_termination_);
469 if (is_started_) {
470 LOG(DEBUG) << "Legacy HAL already started";
471 return WIFI_SUCCESS;
472 }
473 LOG(DEBUG) << "Waiting for the driver ready";
474 wifi_error status = global_func_table_.wifi_wait_for_driver_ready();
475 if (status == WIFI_ERROR_TIMED_OUT || status == WIFI_ERROR_UNKNOWN) {
476 LOG(ERROR) << "Failed or timed out awaiting driver ready";
477 return status;
478 }
479
480 if (is_primary_) {
481 property_set(kDriverPropName, "ok");
482
483 if (!iface_tool_.lock()->SetWifiUpState(true)) {
484 LOG(ERROR) << "Failed to set WiFi interface up";
485 return WIFI_ERROR_UNKNOWN;
486 }
487 }
488
489 LOG(DEBUG) << "Starting legacy HAL";
490 status = global_func_table_.wifi_initialize(&global_handle_);
491 if (status != WIFI_SUCCESS || !global_handle_) {
492 LOG(ERROR) << "Failed to retrieve global handle";
493 return status;
494 }
495 std::thread(&WifiLegacyHal::runEventLoop, this).detach();
496 status = retrieveIfaceHandles();
497 if (status != WIFI_SUCCESS || iface_name_to_handle_.empty()) {
498 LOG(ERROR) << "Failed to retrieve wlan interface handle";
499 return status;
500 }
501 LOG(DEBUG) << "Legacy HAL start complete";
502 is_started_ = true;
503 return WIFI_SUCCESS;
504}
505
506wifi_error WifiLegacyHal::stop(
507 /* NONNULL */ std::unique_lock<std::recursive_mutex>* lock,
508 const std::function<void()>& on_stop_complete_user_callback) {
509 if (!is_started_) {
510 LOG(DEBUG) << "Legacy HAL already stopped";
511 on_stop_complete_user_callback();
512 return WIFI_SUCCESS;
513 }
514 LOG(DEBUG) << "Stopping legacy HAL";
515 on_stop_complete_internal_callback = [on_stop_complete_user_callback,
516 this](wifi_handle handle) {
517 CHECK_EQ(global_handle_, handle) << "Handle mismatch";
518 LOG(INFO) << "Legacy HAL stop complete callback received";
519 // Invalidate all the internal pointers now that the HAL is
520 // stopped.
521 invalidate();
522 if (is_primary_) iface_tool_.lock()->SetWifiUpState(false);
523 on_stop_complete_user_callback();
524 is_started_ = false;
525 };
526 awaiting_event_loop_termination_ = true;
527 global_func_table_.wifi_cleanup(global_handle_, onAsyncStopComplete);
528 const auto status =
529 stop_wait_cv_.wait_for(*lock, std::chrono::milliseconds(kMaxStopCompleteWaitMs),
530 [this] { return !awaiting_event_loop_termination_; });
531 if (!status) {
532 LOG(ERROR) << "Legacy HAL stop failed or timed out";
533 return WIFI_ERROR_UNKNOWN;
534 }
535 LOG(DEBUG) << "Legacy HAL stop complete";
536 return WIFI_SUCCESS;
537}
538
539bool WifiLegacyHal::isStarted() {
540 return is_started_;
541}
542
543wifi_error WifiLegacyHal::waitForDriverReady() {
544 return global_func_table_.wifi_wait_for_driver_ready();
545}
546
547std::pair<wifi_error, std::string> WifiLegacyHal::getDriverVersion(const std::string& iface_name) {
548 std::array<char, kMaxVersionStringLength> buffer;
549 buffer.fill(0);
550 wifi_error status = global_func_table_.wifi_get_driver_version(getIfaceHandle(iface_name),
551 buffer.data(), buffer.size());
552 return {status, buffer.data()};
553}
554
555std::pair<wifi_error, std::string> WifiLegacyHal::getFirmwareVersion(
556 const std::string& iface_name) {
557 std::array<char, kMaxVersionStringLength> buffer;
558 buffer.fill(0);
559 wifi_error status = global_func_table_.wifi_get_firmware_version(getIfaceHandle(iface_name),
560 buffer.data(), buffer.size());
561 return {status, buffer.data()};
562}
563
564std::pair<wifi_error, std::vector<uint8_t>> WifiLegacyHal::requestDriverMemoryDump(
565 const std::string& iface_name) {
566 std::vector<uint8_t> driver_dump;
567 on_driver_memory_dump_internal_callback = [&driver_dump](char* buffer, int buffer_size) {
568 driver_dump.insert(driver_dump.end(), reinterpret_cast<uint8_t*>(buffer),
569 reinterpret_cast<uint8_t*>(buffer) + buffer_size);
570 };
571 wifi_error status = global_func_table_.wifi_get_driver_memory_dump(getIfaceHandle(iface_name),
572 {onSyncDriverMemoryDump});
573 on_driver_memory_dump_internal_callback = nullptr;
574 return {status, std::move(driver_dump)};
575}
576
577std::pair<wifi_error, std::vector<uint8_t>> WifiLegacyHal::requestFirmwareMemoryDump(
578 const std::string& iface_name) {
579 std::vector<uint8_t> firmware_dump;
580 on_firmware_memory_dump_internal_callback = [&firmware_dump](char* buffer, int buffer_size) {
581 firmware_dump.insert(firmware_dump.end(), reinterpret_cast<uint8_t*>(buffer),
582 reinterpret_cast<uint8_t*>(buffer) + buffer_size);
583 };
584 wifi_error status = global_func_table_.wifi_get_firmware_memory_dump(
585 getIfaceHandle(iface_name), {onSyncFirmwareMemoryDump});
586 on_firmware_memory_dump_internal_callback = nullptr;
587 return {status, std::move(firmware_dump)};
588}
589
590std::pair<wifi_error, uint64_t> WifiLegacyHal::getSupportedFeatureSet(
591 const std::string& iface_name) {
592 feature_set set = 0, chip_set = 0;
593 wifi_error status = WIFI_SUCCESS;
594
595 static_assert(sizeof(set) == sizeof(uint64_t),
596 "Some feature_flags can not be represented in output");
597 wifi_interface_handle iface_handle = getIfaceHandle(iface_name);
598
599 global_func_table_.wifi_get_chip_feature_set(
600 global_handle_, &chip_set); /* ignore error, chip_set will stay 0 */
601
602 if (iface_handle) {
603 status = global_func_table_.wifi_get_supported_feature_set(iface_handle, &set);
604 }
605 return {status, static_cast<uint64_t>(set | chip_set)};
606}
607
608std::pair<wifi_error, PacketFilterCapabilities> WifiLegacyHal::getPacketFilterCapabilities(
609 const std::string& iface_name) {
610 PacketFilterCapabilities caps;
611 wifi_error status = global_func_table_.wifi_get_packet_filter_capabilities(
612 getIfaceHandle(iface_name), &caps.version, &caps.max_len);
613 return {status, caps};
614}
615
616wifi_error WifiLegacyHal::setPacketFilter(const std::string& iface_name,
617 const std::vector<uint8_t>& program) {
618 return global_func_table_.wifi_set_packet_filter(getIfaceHandle(iface_name), program.data(),
619 program.size());
620}
621
622std::pair<wifi_error, std::vector<uint8_t>> WifiLegacyHal::readApfPacketFilterData(
623 const std::string& iface_name) {
624 PacketFilterCapabilities caps;
625 wifi_error status = global_func_table_.wifi_get_packet_filter_capabilities(
626 getIfaceHandle(iface_name), &caps.version, &caps.max_len);
627 if (status != WIFI_SUCCESS) {
628 return {status, {}};
629 }
630
631 // Size the buffer to read the entire program & work memory.
632 std::vector<uint8_t> buffer(caps.max_len);
633
634 status = global_func_table_.wifi_read_packet_filter(
635 getIfaceHandle(iface_name), /*src_offset=*/0, buffer.data(), buffer.size());
636 return {status, std::move(buffer)};
637}
638
639std::pair<wifi_error, wifi_gscan_capabilities> WifiLegacyHal::getGscanCapabilities(
640 const std::string& iface_name) {
641 wifi_gscan_capabilities caps;
642 wifi_error status =
643 global_func_table_.wifi_get_gscan_capabilities(getIfaceHandle(iface_name), &caps);
644 return {status, caps};
645}
646
647wifi_error WifiLegacyHal::startGscan(
648 const std::string& iface_name, wifi_request_id id, const wifi_scan_cmd_params& params,
649 const std::function<void(wifi_request_id)>& on_failure_user_callback,
650 const on_gscan_results_callback& on_results_user_callback,
651 const on_gscan_full_result_callback& on_full_result_user_callback) {
652 // If there is already an ongoing background scan, reject new scan requests.
653 if (on_gscan_event_internal_callback || on_gscan_full_result_internal_callback) {
654 return WIFI_ERROR_NOT_AVAILABLE;
655 }
656
657 // This callback will be used to either trigger |on_results_user_callback|
658 // or |on_failure_user_callback|.
659 on_gscan_event_internal_callback = [iface_name, on_failure_user_callback,
660 on_results_user_callback,
661 this](wifi_request_id id, wifi_scan_event event) {
662 switch (event) {
663 case WIFI_SCAN_RESULTS_AVAILABLE:
664 case WIFI_SCAN_THRESHOLD_NUM_SCANS:
665 case WIFI_SCAN_THRESHOLD_PERCENT: {
666 wifi_error status;
667 std::vector<wifi_cached_scan_results> cached_scan_results;
668 std::tie(status, cached_scan_results) = getGscanCachedResults(iface_name);
669 if (status == WIFI_SUCCESS) {
670 on_results_user_callback(id, cached_scan_results);
671 return;
672 }
673 FALLTHROUGH_INTENDED;
674 }
675 // Fall through if failed. Failure to retrieve cached scan
676 // results should trigger a background scan failure.
677 case WIFI_SCAN_FAILED:
678 on_failure_user_callback(id);
679 on_gscan_event_internal_callback = nullptr;
680 on_gscan_full_result_internal_callback = nullptr;
681 return;
682 }
683 LOG(FATAL) << "Unexpected gscan event received: " << event;
684 };
685
686 on_gscan_full_result_internal_callback = [on_full_result_user_callback](
687 wifi_request_id id, wifi_scan_result* result,
688 uint32_t buckets_scanned) {
689 if (result) {
690 on_full_result_user_callback(id, result, buckets_scanned);
691 }
692 };
693
694 wifi_scan_result_handler handler = {onAsyncGscanFullResult, onAsyncGscanEvent};
695 wifi_error status =
696 global_func_table_.wifi_start_gscan(id, getIfaceHandle(iface_name), params, handler);
697 if (status != WIFI_SUCCESS) {
698 on_gscan_event_internal_callback = nullptr;
699 on_gscan_full_result_internal_callback = nullptr;
700 }
701 return status;
702}
703
704wifi_error WifiLegacyHal::stopGscan(const std::string& iface_name, wifi_request_id id) {
705 // If there is no an ongoing background scan, reject stop requests.
706 // TODO(b/32337212): This needs to be handled by the HIDL object because we
707 // need to return the NOT_STARTED error code.
708 if (!on_gscan_event_internal_callback && !on_gscan_full_result_internal_callback) {
709 return WIFI_ERROR_NOT_AVAILABLE;
710 }
711 wifi_error status = global_func_table_.wifi_stop_gscan(id, getIfaceHandle(iface_name));
712 // If the request Id is wrong, don't stop the ongoing background scan. Any
713 // other error should be treated as the end of background scan.
714 if (status != WIFI_ERROR_INVALID_REQUEST_ID) {
715 on_gscan_event_internal_callback = nullptr;
716 on_gscan_full_result_internal_callback = nullptr;
717 }
718 return status;
719}
720
721std::pair<wifi_error, std::vector<uint32_t>> WifiLegacyHal::getValidFrequenciesForBand(
722 const std::string& iface_name, wifi_band band) {
723 static_assert(sizeof(uint32_t) >= sizeof(wifi_channel),
724 "Wifi Channel cannot be represented in output");
725 std::vector<uint32_t> freqs;
726 freqs.resize(kMaxGscanFrequenciesForBand);
727 int32_t num_freqs = 0;
728 wifi_error status = global_func_table_.wifi_get_valid_channels(
729 getIfaceHandle(iface_name), band, freqs.size(),
730 reinterpret_cast<wifi_channel*>(freqs.data()), &num_freqs);
731 CHECK(num_freqs >= 0 && static_cast<uint32_t>(num_freqs) <= kMaxGscanFrequenciesForBand);
732 freqs.resize(num_freqs);
733 return {status, std::move(freqs)};
734}
735
736wifi_error WifiLegacyHal::setDfsFlag(const std::string& iface_name, bool dfs_on) {
737 return global_func_table_.wifi_set_nodfs_flag(getIfaceHandle(iface_name), dfs_on ? 0 : 1);
738}
739
740wifi_error WifiLegacyHal::enableLinkLayerStats(const std::string& iface_name, bool debug) {
741 wifi_link_layer_params params;
742 params.mpdu_size_threshold = kLinkLayerStatsDataMpduSizeThreshold;
743 params.aggressive_statistics_gathering = debug;
744 return global_func_table_.wifi_set_link_stats(getIfaceHandle(iface_name), params);
745}
746
747wifi_error WifiLegacyHal::disableLinkLayerStats(const std::string& iface_name) {
748 // TODO: Do we care about these responses?
749 uint32_t clear_mask_rsp;
750 uint8_t stop_rsp;
751 return global_func_table_.wifi_clear_link_stats(getIfaceHandle(iface_name), 0xFFFFFFFF,
752 &clear_mask_rsp, 1, &stop_rsp);
753}
754
Mahesh KKV5f30d332022-10-26 14:07:44 -0700755// Copies wifi_peer_info* to vector<WifiPeerInfo> and returns poiner to next element.
756wifi_peer_info* WifiLegacyHal::copyPeerInfo(wifi_peer_info* peer_ptr,
757 std::vector<WifiPeerInfo> peers) {
758 WifiPeerInfo peer;
759 peer.peer_info = *peer_ptr;
760 if (peer_ptr->num_rate > 0) {
761 // Copy the rate stats.
762 peer.rate_stats.assign(peer_ptr->rate_stats, peer_ptr->rate_stats + peer_ptr->num_rate);
763 }
764 peer.peer_info.num_rate = 0;
765 // Push peer info.
766 peers.push_back(peer);
767 // Return the address of next peer info.
768 return (wifi_peer_info*)((u8*)peer_ptr + sizeof(wifi_peer_info) +
769 (sizeof(wifi_rate_stat) * peer_ptr->num_rate));
770}
771// Copies wifi_link_stat* to vector<LinkStats> and returns poiner to next element.
772wifi_link_stat* WifiLegacyHal::copyLinkStat(wifi_link_stat* stat_ptr,
773 std::vector<LinkStats> stats) {
774 LinkStats linkStat;
775 linkStat.stat = *stat_ptr;
776 wifi_peer_info* l_peer_info_stats_ptr = stat_ptr->peer_info;
777 for (uint32_t i = 0; i < linkStat.stat.num_peers; i++) {
778 l_peer_info_stats_ptr = copyPeerInfo(l_peer_info_stats_ptr, linkStat.peers);
779 }
780 // Copied all peers to linkStat.peers.
781 linkStat.stat.num_peers = 0;
782 // Push link stat.
783 stats.push_back(linkStat);
784 // Read all peers, return the address of next wifi_link_stat.
785 return (wifi_link_stat*)l_peer_info_stats_ptr;
786}
787
788wifi_error WifiLegacyHal::getLinkLayerStats(const std::string& iface_name,
789 LinkLayerStats& link_stats,
790 LinkLayerMlStats& link_ml_stats) {
Gabriel Birenf3262f92022-07-15 23:25:39 +0000791 LinkLayerStats* link_stats_ptr = &link_stats;
Mahesh KKV5f30d332022-10-26 14:07:44 -0700792 link_stats_ptr->valid = false;
Gabriel Birenf3262f92022-07-15 23:25:39 +0000793
794 on_link_layer_stats_result_internal_callback = [&link_stats_ptr](
795 wifi_request_id /* id */,
796 wifi_iface_stat* iface_stats_ptr,
797 int num_radios,
798 wifi_radio_stat* radio_stats_ptr) {
799 wifi_radio_stat* l_radio_stats_ptr;
800 wifi_peer_info* l_peer_info_stats_ptr;
Mahesh KKV5f30d332022-10-26 14:07:44 -0700801 link_stats_ptr->valid = true;
Gabriel Birenf3262f92022-07-15 23:25:39 +0000802
803 if (iface_stats_ptr != nullptr) {
804 link_stats_ptr->iface = *iface_stats_ptr;
805 l_peer_info_stats_ptr = iface_stats_ptr->peer_info;
806 for (uint32_t i = 0; i < iface_stats_ptr->num_peers; i++) {
807 WifiPeerInfo peer;
808 peer.peer_info = *l_peer_info_stats_ptr;
809 if (l_peer_info_stats_ptr->num_rate > 0) {
810 /* Copy the rate stats */
811 peer.rate_stats.assign(
812 l_peer_info_stats_ptr->rate_stats,
813 l_peer_info_stats_ptr->rate_stats + l_peer_info_stats_ptr->num_rate);
814 }
815 peer.peer_info.num_rate = 0;
816 link_stats_ptr->peers.push_back(peer);
817 l_peer_info_stats_ptr =
818 (wifi_peer_info*)((u8*)l_peer_info_stats_ptr + sizeof(wifi_peer_info) +
819 (sizeof(wifi_rate_stat) *
820 l_peer_info_stats_ptr->num_rate));
821 }
822 link_stats_ptr->iface.num_peers = 0;
823 } else {
824 LOG(ERROR) << "Invalid iface stats in link layer stats";
825 }
826 if (num_radios <= 0 || radio_stats_ptr == nullptr) {
827 LOG(ERROR) << "Invalid radio stats in link layer stats";
828 return;
829 }
830 l_radio_stats_ptr = radio_stats_ptr;
831 for (int i = 0; i < num_radios; i++) {
832 LinkLayerRadioStats radio;
833
834 radio.stats = *l_radio_stats_ptr;
835 // Copy over the tx level array to the separate vector.
836 if (l_radio_stats_ptr->num_tx_levels > 0 &&
837 l_radio_stats_ptr->tx_time_per_levels != nullptr) {
838 radio.tx_time_per_levels.assign(
839 l_radio_stats_ptr->tx_time_per_levels,
840 l_radio_stats_ptr->tx_time_per_levels + l_radio_stats_ptr->num_tx_levels);
841 }
842 radio.stats.num_tx_levels = 0;
843 radio.stats.tx_time_per_levels = nullptr;
844 /* Copy over the channel stat to separate vector */
845 if (l_radio_stats_ptr->num_channels > 0) {
846 /* Copy the channel stats */
847 radio.channel_stats.assign(
848 l_radio_stats_ptr->channels,
849 l_radio_stats_ptr->channels + l_radio_stats_ptr->num_channels);
850 }
851 link_stats_ptr->radios.push_back(radio);
852 l_radio_stats_ptr =
853 (wifi_radio_stat*)((u8*)l_radio_stats_ptr + sizeof(wifi_radio_stat) +
854 (sizeof(wifi_channel_stat) *
855 l_radio_stats_ptr->num_channels));
856 }
857 };
858
Mahesh KKV5f30d332022-10-26 14:07:44 -0700859 LinkLayerMlStats* link_ml_stats_ptr = &link_ml_stats;
860 link_ml_stats_ptr->valid = false;
861
862 on_link_layer_ml_stats_result_internal_callback =
863 [this, &link_ml_stats_ptr](wifi_request_id /* id */,
864 wifi_iface_ml_stat* iface_ml_stats_ptr, int num_radios,
865 wifi_radio_stat* radio_stats_ptr) {
866 wifi_radio_stat* l_radio_stats_ptr;
867 wifi_link_stat* l_link_stat_ptr;
868 link_ml_stats_ptr->valid = true;
869
870 if (iface_ml_stats_ptr != nullptr && iface_ml_stats_ptr->num_links > 0) {
871 // Copy stats from wifi_iface_ml_stat to LinkLayerMlStats,
872 // - num_links * links[] to vector of links.
873 // - num_peers * peer_info[] to vector of links[i].peers.
874 link_ml_stats_ptr->iface = *iface_ml_stats_ptr;
875 l_link_stat_ptr = iface_ml_stats_ptr->links;
876 for (int l = 0; l < iface_ml_stats_ptr->num_links; ++l) {
877 l_link_stat_ptr = copyLinkStat(l_link_stat_ptr, link_ml_stats_ptr->links);
878 }
879 } else {
880 LOG(ERROR) << "Invalid iface stats in link layer stats";
881 }
882 if (num_radios <= 0 || radio_stats_ptr == nullptr) {
883 LOG(ERROR) << "Invalid radio stats in link layer stats";
884 return;
885 }
886 l_radio_stats_ptr = radio_stats_ptr;
887 for (int i = 0; i < num_radios; i++) {
888 LinkLayerRadioStats radio;
889
890 radio.stats = *l_radio_stats_ptr;
891 // Copy over the tx level array to the separate vector.
892 if (l_radio_stats_ptr->num_tx_levels > 0 &&
893 l_radio_stats_ptr->tx_time_per_levels != nullptr) {
894 radio.tx_time_per_levels.assign(l_radio_stats_ptr->tx_time_per_levels,
895 l_radio_stats_ptr->tx_time_per_levels +
896 l_radio_stats_ptr->num_tx_levels);
897 }
898 radio.stats.num_tx_levels = 0;
899 radio.stats.tx_time_per_levels = nullptr;
900 /* Copy over the channel stat to separate vector */
901 if (l_radio_stats_ptr->num_channels > 0) {
902 /* Copy the channel stats */
903 radio.channel_stats.assign(
904 l_radio_stats_ptr->channels,
905 l_radio_stats_ptr->channels + l_radio_stats_ptr->num_channels);
906 }
907 link_ml_stats_ptr->radios.push_back(radio);
908 l_radio_stats_ptr =
909 (wifi_radio_stat*)((u8*)l_radio_stats_ptr + sizeof(wifi_radio_stat) +
910 (sizeof(wifi_channel_stat) *
911 l_radio_stats_ptr->num_channels));
912 }
913 };
914
915 wifi_error status = global_func_table_.wifi_get_link_stats(
916 0, getIfaceHandle(iface_name),
917 {onSyncLinkLayerStatsResult, onSyncLinkLayerMlStatsResult});
Gabriel Birenf3262f92022-07-15 23:25:39 +0000918 on_link_layer_stats_result_internal_callback = nullptr;
Mahesh KKV5f30d332022-10-26 14:07:44 -0700919 on_link_layer_ml_stats_result_internal_callback = nullptr;
920
921 return status;
Gabriel Birenf3262f92022-07-15 23:25:39 +0000922}
923
924wifi_error WifiLegacyHal::startRssiMonitoring(
925 const std::string& iface_name, wifi_request_id id, int8_t max_rssi, int8_t min_rssi,
926 const on_rssi_threshold_breached_callback& on_threshold_breached_user_callback) {
927 if (on_rssi_threshold_breached_internal_callback) {
928 return WIFI_ERROR_NOT_AVAILABLE;
929 }
930 on_rssi_threshold_breached_internal_callback = [on_threshold_breached_user_callback](
931 wifi_request_id id, uint8_t* bssid_ptr,
932 int8_t rssi) {
933 if (!bssid_ptr) {
934 return;
935 }
936 std::array<uint8_t, ETH_ALEN> bssid_arr;
937 // |bssid_ptr| pointer is assumed to have 6 bytes for the mac
938 // address.
939 std::copy(bssid_ptr, bssid_ptr + 6, std::begin(bssid_arr));
940 on_threshold_breached_user_callback(id, bssid_arr, rssi);
941 };
942 wifi_error status = global_func_table_.wifi_start_rssi_monitoring(
943 id, getIfaceHandle(iface_name), max_rssi, min_rssi, {onAsyncRssiThresholdBreached});
944 if (status != WIFI_SUCCESS) {
945 on_rssi_threshold_breached_internal_callback = nullptr;
946 }
947 return status;
948}
949
950wifi_error WifiLegacyHal::stopRssiMonitoring(const std::string& iface_name, wifi_request_id id) {
951 if (!on_rssi_threshold_breached_internal_callback) {
952 return WIFI_ERROR_NOT_AVAILABLE;
953 }
954 wifi_error status =
955 global_func_table_.wifi_stop_rssi_monitoring(id, getIfaceHandle(iface_name));
956 // If the request Id is wrong, don't stop the ongoing rssi monitoring. Any
957 // other error should be treated as the end of background scan.
958 if (status != WIFI_ERROR_INVALID_REQUEST_ID) {
959 on_rssi_threshold_breached_internal_callback = nullptr;
960 }
961 return status;
962}
963
964std::pair<wifi_error, wifi_roaming_capabilities> WifiLegacyHal::getRoamingCapabilities(
965 const std::string& iface_name) {
966 wifi_roaming_capabilities caps;
967 wifi_error status =
968 global_func_table_.wifi_get_roaming_capabilities(getIfaceHandle(iface_name), &caps);
969 return {status, caps};
970}
971
972wifi_error WifiLegacyHal::configureRoaming(const std::string& iface_name,
973 const wifi_roaming_config& config) {
974 wifi_roaming_config config_internal = config;
975 return global_func_table_.wifi_configure_roaming(getIfaceHandle(iface_name), &config_internal);
976}
977
978wifi_error WifiLegacyHal::enableFirmwareRoaming(const std::string& iface_name,
979 fw_roaming_state_t state) {
980 return global_func_table_.wifi_enable_firmware_roaming(getIfaceHandle(iface_name), state);
981}
982
983wifi_error WifiLegacyHal::configureNdOffload(const std::string& iface_name, bool enable) {
984 return global_func_table_.wifi_configure_nd_offload(getIfaceHandle(iface_name), enable);
985}
986
987wifi_error WifiLegacyHal::startSendingOffloadedPacket(const std::string& iface_name, int32_t cmd_id,
988 uint16_t ether_type,
989 const std::vector<uint8_t>& ip_packet_data,
990 const std::array<uint8_t, 6>& src_address,
991 const std::array<uint8_t, 6>& dst_address,
992 int32_t period_in_ms) {
993 std::vector<uint8_t> ip_packet_data_internal(ip_packet_data);
994 std::vector<uint8_t> src_address_internal(src_address.data(),
995 src_address.data() + src_address.size());
996 std::vector<uint8_t> dst_address_internal(dst_address.data(),
997 dst_address.data() + dst_address.size());
998 return global_func_table_.wifi_start_sending_offloaded_packet(
999 cmd_id, getIfaceHandle(iface_name), ether_type, ip_packet_data_internal.data(),
1000 ip_packet_data_internal.size(), src_address_internal.data(),
1001 dst_address_internal.data(), period_in_ms);
1002}
1003
1004wifi_error WifiLegacyHal::stopSendingOffloadedPacket(const std::string& iface_name,
1005 uint32_t cmd_id) {
1006 return global_func_table_.wifi_stop_sending_offloaded_packet(cmd_id,
1007 getIfaceHandle(iface_name));
1008}
1009
1010wifi_error WifiLegacyHal::selectTxPowerScenario(const std::string& iface_name,
1011 wifi_power_scenario scenario) {
1012 return global_func_table_.wifi_select_tx_power_scenario(getIfaceHandle(iface_name), scenario);
1013}
1014
1015wifi_error WifiLegacyHal::resetTxPowerScenario(const std::string& iface_name) {
1016 return global_func_table_.wifi_reset_tx_power_scenario(getIfaceHandle(iface_name));
1017}
1018
1019wifi_error WifiLegacyHal::setLatencyMode(const std::string& iface_name, wifi_latency_mode mode) {
1020 return global_func_table_.wifi_set_latency_mode(getIfaceHandle(iface_name), mode);
1021}
1022
1023wifi_error WifiLegacyHal::setThermalMitigationMode(wifi_thermal_mode mode,
1024 uint32_t completion_window) {
1025 return global_func_table_.wifi_set_thermal_mitigation_mode(global_handle_, mode,
1026 completion_window);
1027}
1028
1029wifi_error WifiLegacyHal::setDscpToAccessCategoryMapping(uint32_t start, uint32_t end,
1030 uint32_t access_category) {
1031 return global_func_table_.wifi_map_dscp_access_category(global_handle_, start, end,
1032 access_category);
1033}
1034
1035wifi_error WifiLegacyHal::resetDscpToAccessCategoryMapping() {
1036 return global_func_table_.wifi_reset_dscp_mapping(global_handle_);
1037}
1038
1039std::pair<wifi_error, uint32_t> WifiLegacyHal::getLoggerSupportedFeatureSet(
1040 const std::string& iface_name) {
1041 uint32_t supported_feature_flags = 0;
1042 wifi_error status = WIFI_SUCCESS;
1043
1044 wifi_interface_handle iface_handle = getIfaceHandle(iface_name);
1045
1046 if (iface_handle) {
1047 status = global_func_table_.wifi_get_logger_supported_feature_set(iface_handle,
1048 &supported_feature_flags);
1049 }
1050 return {status, supported_feature_flags};
1051}
1052
1053wifi_error WifiLegacyHal::startPktFateMonitoring(const std::string& iface_name) {
1054 return global_func_table_.wifi_start_pkt_fate_monitoring(getIfaceHandle(iface_name));
1055}
1056
1057std::pair<wifi_error, std::vector<wifi_tx_report>> WifiLegacyHal::getTxPktFates(
1058 const std::string& iface_name) {
1059 std::vector<wifi_tx_report> tx_pkt_fates;
1060 tx_pkt_fates.resize(MAX_FATE_LOG_LEN);
1061 size_t num_fates = 0;
1062 wifi_error status = global_func_table_.wifi_get_tx_pkt_fates(
1063 getIfaceHandle(iface_name), tx_pkt_fates.data(), tx_pkt_fates.size(), &num_fates);
1064 CHECK(num_fates <= MAX_FATE_LOG_LEN);
1065 tx_pkt_fates.resize(num_fates);
1066 return {status, std::move(tx_pkt_fates)};
1067}
1068
1069std::pair<wifi_error, std::vector<wifi_rx_report>> WifiLegacyHal::getRxPktFates(
1070 const std::string& iface_name) {
1071 std::vector<wifi_rx_report> rx_pkt_fates;
1072 rx_pkt_fates.resize(MAX_FATE_LOG_LEN);
1073 size_t num_fates = 0;
1074 wifi_error status = global_func_table_.wifi_get_rx_pkt_fates(
1075 getIfaceHandle(iface_name), rx_pkt_fates.data(), rx_pkt_fates.size(), &num_fates);
1076 CHECK(num_fates <= MAX_FATE_LOG_LEN);
1077 rx_pkt_fates.resize(num_fates);
1078 return {status, std::move(rx_pkt_fates)};
1079}
1080
1081std::pair<wifi_error, WakeReasonStats> WifiLegacyHal::getWakeReasonStats(
1082 const std::string& iface_name) {
1083 WakeReasonStats stats;
1084 stats.cmd_event_wake_cnt.resize(kMaxWakeReasonStatsArraySize);
1085 stats.driver_fw_local_wake_cnt.resize(kMaxWakeReasonStatsArraySize);
1086
1087 // This legacy struct needs separate memory to store the variable sized wake
1088 // reason types.
1089 stats.wake_reason_cnt.cmd_event_wake_cnt =
1090 reinterpret_cast<int32_t*>(stats.cmd_event_wake_cnt.data());
1091 stats.wake_reason_cnt.cmd_event_wake_cnt_sz = stats.cmd_event_wake_cnt.size();
1092 stats.wake_reason_cnt.cmd_event_wake_cnt_used = 0;
1093 stats.wake_reason_cnt.driver_fw_local_wake_cnt =
1094 reinterpret_cast<int32_t*>(stats.driver_fw_local_wake_cnt.data());
1095 stats.wake_reason_cnt.driver_fw_local_wake_cnt_sz = stats.driver_fw_local_wake_cnt.size();
1096 stats.wake_reason_cnt.driver_fw_local_wake_cnt_used = 0;
1097
1098 wifi_error status = global_func_table_.wifi_get_wake_reason_stats(getIfaceHandle(iface_name),
1099 &stats.wake_reason_cnt);
1100
1101 CHECK(stats.wake_reason_cnt.cmd_event_wake_cnt_used >= 0 &&
1102 static_cast<uint32_t>(stats.wake_reason_cnt.cmd_event_wake_cnt_used) <=
1103 kMaxWakeReasonStatsArraySize);
1104 stats.cmd_event_wake_cnt.resize(stats.wake_reason_cnt.cmd_event_wake_cnt_used);
1105 stats.wake_reason_cnt.cmd_event_wake_cnt = nullptr;
1106
1107 CHECK(stats.wake_reason_cnt.driver_fw_local_wake_cnt_used >= 0 &&
1108 static_cast<uint32_t>(stats.wake_reason_cnt.driver_fw_local_wake_cnt_used) <=
1109 kMaxWakeReasonStatsArraySize);
1110 stats.driver_fw_local_wake_cnt.resize(stats.wake_reason_cnt.driver_fw_local_wake_cnt_used);
1111 stats.wake_reason_cnt.driver_fw_local_wake_cnt = nullptr;
1112
1113 return {status, stats};
1114}
1115
1116wifi_error WifiLegacyHal::registerRingBufferCallbackHandler(
1117 const std::string& iface_name, const on_ring_buffer_data_callback& on_user_data_callback) {
1118 if (on_ring_buffer_data_internal_callback) {
1119 return WIFI_ERROR_NOT_AVAILABLE;
1120 }
1121 on_ring_buffer_data_internal_callback = [on_user_data_callback](
1122 char* ring_name, char* buffer, int buffer_size,
1123 wifi_ring_buffer_status* status) {
1124 if (status && buffer) {
1125 std::vector<uint8_t> buffer_vector(reinterpret_cast<uint8_t*>(buffer),
1126 reinterpret_cast<uint8_t*>(buffer) + buffer_size);
1127 on_user_data_callback(ring_name, buffer_vector, *status);
1128 }
1129 };
1130 wifi_error status = global_func_table_.wifi_set_log_handler(0, getIfaceHandle(iface_name),
1131 {onAsyncRingBufferData});
1132 if (status != WIFI_SUCCESS) {
1133 on_ring_buffer_data_internal_callback = nullptr;
1134 }
1135 return status;
1136}
1137
1138wifi_error WifiLegacyHal::deregisterRingBufferCallbackHandler(const std::string& iface_name) {
1139 if (!on_ring_buffer_data_internal_callback) {
1140 return WIFI_ERROR_NOT_AVAILABLE;
1141 }
1142 on_ring_buffer_data_internal_callback = nullptr;
1143 return global_func_table_.wifi_reset_log_handler(0, getIfaceHandle(iface_name));
1144}
1145
1146std::pair<wifi_error, std::vector<wifi_ring_buffer_status>> WifiLegacyHal::getRingBuffersStatus(
1147 const std::string& iface_name) {
1148 std::vector<wifi_ring_buffer_status> ring_buffers_status;
1149 ring_buffers_status.resize(kMaxRingBuffers);
1150 uint32_t num_rings = kMaxRingBuffers;
1151 wifi_error status = global_func_table_.wifi_get_ring_buffers_status(
1152 getIfaceHandle(iface_name), &num_rings, ring_buffers_status.data());
1153 CHECK(num_rings <= kMaxRingBuffers);
1154 ring_buffers_status.resize(num_rings);
1155 return {status, std::move(ring_buffers_status)};
1156}
1157
1158wifi_error WifiLegacyHal::startRingBufferLogging(const std::string& iface_name,
1159 const std::string& ring_name,
1160 uint32_t verbose_level, uint32_t max_interval_sec,
1161 uint32_t min_data_size) {
1162 return global_func_table_.wifi_start_logging(getIfaceHandle(iface_name), verbose_level, 0,
1163 max_interval_sec, min_data_size,
1164 makeCharVec(ring_name).data());
1165}
1166
1167wifi_error WifiLegacyHal::getRingBufferData(const std::string& iface_name,
1168 const std::string& ring_name) {
1169 return global_func_table_.wifi_get_ring_data(getIfaceHandle(iface_name),
1170 makeCharVec(ring_name).data());
1171}
1172
1173wifi_error WifiLegacyHal::registerErrorAlertCallbackHandler(
1174 const std::string& iface_name, const on_error_alert_callback& on_user_alert_callback) {
1175 if (on_error_alert_internal_callback) {
1176 return WIFI_ERROR_NOT_AVAILABLE;
1177 }
1178 on_error_alert_internal_callback = [on_user_alert_callback](wifi_request_id id, char* buffer,
1179 int buffer_size, int err_code) {
1180 if (buffer) {
1181 CHECK(id == 0);
1182 on_user_alert_callback(
1183 err_code,
1184 std::vector<uint8_t>(reinterpret_cast<uint8_t*>(buffer),
1185 reinterpret_cast<uint8_t*>(buffer) + buffer_size));
1186 }
1187 };
1188 wifi_error status = global_func_table_.wifi_set_alert_handler(0, getIfaceHandle(iface_name),
1189 {onAsyncErrorAlert});
1190 if (status != WIFI_SUCCESS) {
1191 on_error_alert_internal_callback = nullptr;
1192 }
1193 return status;
1194}
1195
1196wifi_error WifiLegacyHal::deregisterErrorAlertCallbackHandler(const std::string& iface_name) {
1197 if (!on_error_alert_internal_callback) {
1198 return WIFI_ERROR_NOT_AVAILABLE;
1199 }
1200 on_error_alert_internal_callback = nullptr;
1201 return global_func_table_.wifi_reset_alert_handler(0, getIfaceHandle(iface_name));
1202}
1203
1204wifi_error WifiLegacyHal::registerRadioModeChangeCallbackHandler(
1205 const std::string& iface_name,
1206 const on_radio_mode_change_callback& on_user_change_callback) {
1207 if (on_radio_mode_change_internal_callback) {
1208 return WIFI_ERROR_NOT_AVAILABLE;
1209 }
1210 on_radio_mode_change_internal_callback = [on_user_change_callback](
1211 wifi_request_id /* id */, uint32_t num_macs,
1212 wifi_mac_info* mac_infos_arr) {
1213 if (num_macs > 0 && mac_infos_arr) {
1214 std::vector<WifiMacInfo> mac_infos_vec;
1215 for (uint32_t i = 0; i < num_macs; i++) {
1216 WifiMacInfo mac_info;
1217 mac_info.wlan_mac_id = mac_infos_arr[i].wlan_mac_id;
1218 mac_info.mac_band = mac_infos_arr[i].mac_band;
1219 for (int32_t j = 0; j < mac_infos_arr[i].num_iface; j++) {
1220 WifiIfaceInfo iface_info;
1221 iface_info.name = mac_infos_arr[i].iface_info[j].iface_name;
1222 iface_info.channel = mac_infos_arr[i].iface_info[j].channel;
1223 mac_info.iface_infos.push_back(iface_info);
1224 }
1225 mac_infos_vec.push_back(mac_info);
1226 }
1227 on_user_change_callback(mac_infos_vec);
1228 }
1229 };
1230 wifi_error status = global_func_table_.wifi_set_radio_mode_change_handler(
1231 0, getIfaceHandle(iface_name), {onAsyncRadioModeChange});
1232 if (status != WIFI_SUCCESS) {
1233 on_radio_mode_change_internal_callback = nullptr;
1234 }
1235 return status;
1236}
1237
1238wifi_error WifiLegacyHal::registerSubsystemRestartCallbackHandler(
1239 const on_subsystem_restart_callback& on_restart_callback) {
1240 if (on_subsystem_restart_internal_callback) {
1241 return WIFI_ERROR_NOT_AVAILABLE;
1242 }
1243 on_subsystem_restart_internal_callback = [on_restart_callback](const char* error) {
1244 on_restart_callback(error);
1245 };
1246 wifi_error status = global_func_table_.wifi_set_subsystem_restart_handler(
1247 global_handle_, {onAsyncSubsystemRestart});
1248 if (status != WIFI_SUCCESS) {
1249 on_subsystem_restart_internal_callback = nullptr;
1250 }
1251 return status;
1252}
1253
1254wifi_error WifiLegacyHal::startRttRangeRequest(
1255 const std::string& iface_name, wifi_request_id id,
1256 const std::vector<wifi_rtt_config>& rtt_configs,
Sunil Ravif8fc2372022-11-10 18:37:41 +00001257 const on_rtt_results_callback& on_results_user_callback,
1258 const on_rtt_results_callback_v2& on_results_user_callback_v2) {
1259 if (on_rtt_results_internal_callback || on_rtt_results_internal_callback_v2) {
Gabriel Birenf3262f92022-07-15 23:25:39 +00001260 return WIFI_ERROR_NOT_AVAILABLE;
1261 }
1262
1263 on_rtt_results_internal_callback = [on_results_user_callback](wifi_request_id id,
1264 unsigned num_results,
1265 wifi_rtt_result* rtt_results[]) {
1266 if (num_results > 0 && !rtt_results) {
1267 LOG(ERROR) << "Unexpected nullptr in RTT results";
1268 return;
1269 }
1270 std::vector<const wifi_rtt_result*> rtt_results_vec;
1271 std::copy_if(rtt_results, rtt_results + num_results, back_inserter(rtt_results_vec),
1272 [](wifi_rtt_result* rtt_result) { return rtt_result != nullptr; });
1273 on_results_user_callback(id, rtt_results_vec);
1274 };
1275
Sunil Ravif8fc2372022-11-10 18:37:41 +00001276 on_rtt_results_internal_callback_v2 = [on_results_user_callback_v2](
1277 wifi_request_id id, unsigned num_results,
1278 wifi_rtt_result_v2* rtt_results_v2[]) {
1279 if (num_results > 0 && !rtt_results_v2) {
1280 LOG(ERROR) << "Unexpected nullptr in RTT results";
1281 return;
1282 }
1283 std::vector<const wifi_rtt_result_v2*> rtt_results_vec_v2;
1284 std::copy_if(rtt_results_v2, rtt_results_v2 + num_results,
1285 back_inserter(rtt_results_vec_v2),
1286 [](wifi_rtt_result_v2* rtt_result_v2) { return rtt_result_v2 != nullptr; });
1287 on_results_user_callback_v2(id, rtt_results_vec_v2);
1288 };
1289
Gabriel Birenf3262f92022-07-15 23:25:39 +00001290 std::vector<wifi_rtt_config> rtt_configs_internal(rtt_configs);
1291 wifi_error status = global_func_table_.wifi_rtt_range_request(
1292 id, getIfaceHandle(iface_name), rtt_configs.size(), rtt_configs_internal.data(),
Sunil Ravif8fc2372022-11-10 18:37:41 +00001293 {onAsyncRttResults, onAsyncRttResultsV2});
Gabriel Birenf3262f92022-07-15 23:25:39 +00001294 if (status != WIFI_SUCCESS) {
Sunil Ravif8fc2372022-11-10 18:37:41 +00001295 invalidateRttResultsCallbacks();
Gabriel Birenf3262f92022-07-15 23:25:39 +00001296 }
1297 return status;
1298}
1299
1300wifi_error WifiLegacyHal::cancelRttRangeRequest(
1301 const std::string& iface_name, wifi_request_id id,
1302 const std::vector<std::array<uint8_t, ETH_ALEN>>& mac_addrs) {
Sunil Ravif8fc2372022-11-10 18:37:41 +00001303 if (!on_rtt_results_internal_callback && !on_rtt_results_internal_callback_v2) {
Gabriel Birenf3262f92022-07-15 23:25:39 +00001304 return WIFI_ERROR_NOT_AVAILABLE;
1305 }
1306 static_assert(sizeof(mac_addr) == sizeof(std::array<uint8_t, ETH_ALEN>),
1307 "MAC address size mismatch");
1308 // TODO: How do we handle partial cancels (i.e only a subset of enabled mac
1309 // addressed are cancelled).
1310 std::vector<std::array<uint8_t, ETH_ALEN>> mac_addrs_internal(mac_addrs);
1311 wifi_error status = global_func_table_.wifi_rtt_range_cancel(
1312 id, getIfaceHandle(iface_name), mac_addrs.size(),
1313 reinterpret_cast<mac_addr*>(mac_addrs_internal.data()));
1314 // If the request Id is wrong, don't stop the ongoing range request. Any
1315 // other error should be treated as the end of rtt ranging.
1316 if (status != WIFI_ERROR_INVALID_REQUEST_ID) {
Sunil Ravif8fc2372022-11-10 18:37:41 +00001317 invalidateRttResultsCallbacks();
Gabriel Birenf3262f92022-07-15 23:25:39 +00001318 }
1319 return status;
1320}
1321
1322std::pair<wifi_error, wifi_rtt_capabilities> WifiLegacyHal::getRttCapabilities(
1323 const std::string& iface_name) {
1324 wifi_rtt_capabilities rtt_caps;
1325 wifi_error status =
1326 global_func_table_.wifi_get_rtt_capabilities(getIfaceHandle(iface_name), &rtt_caps);
1327 return {status, rtt_caps};
1328}
1329
1330std::pair<wifi_error, wifi_rtt_responder> WifiLegacyHal::getRttResponderInfo(
1331 const std::string& iface_name) {
1332 wifi_rtt_responder rtt_responder;
1333 wifi_error status = global_func_table_.wifi_rtt_get_responder_info(getIfaceHandle(iface_name),
1334 &rtt_responder);
1335 return {status, rtt_responder};
1336}
1337
1338wifi_error WifiLegacyHal::enableRttResponder(const std::string& iface_name, wifi_request_id id,
1339 const wifi_channel_info& channel_hint,
1340 uint32_t max_duration_secs,
1341 const wifi_rtt_responder& info) {
1342 wifi_rtt_responder info_internal(info);
1343 return global_func_table_.wifi_enable_responder(id, getIfaceHandle(iface_name), channel_hint,
1344 max_duration_secs, &info_internal);
1345}
1346
1347wifi_error WifiLegacyHal::disableRttResponder(const std::string& iface_name, wifi_request_id id) {
1348 return global_func_table_.wifi_disable_responder(id, getIfaceHandle(iface_name));
1349}
1350
1351wifi_error WifiLegacyHal::setRttLci(const std::string& iface_name, wifi_request_id id,
1352 const wifi_lci_information& info) {
1353 wifi_lci_information info_internal(info);
1354 return global_func_table_.wifi_set_lci(id, getIfaceHandle(iface_name), &info_internal);
1355}
1356
1357wifi_error WifiLegacyHal::setRttLcr(const std::string& iface_name, wifi_request_id id,
1358 const wifi_lcr_information& info) {
1359 wifi_lcr_information info_internal(info);
1360 return global_func_table_.wifi_set_lcr(id, getIfaceHandle(iface_name), &info_internal);
1361}
1362
1363wifi_error WifiLegacyHal::nanRegisterCallbackHandlers(const std::string& iface_name,
1364 const NanCallbackHandlers& user_callbacks) {
1365 on_nan_notify_response_user_callback = user_callbacks.on_notify_response;
1366 on_nan_event_publish_terminated_user_callback = user_callbacks.on_event_publish_terminated;
1367 on_nan_event_match_user_callback = user_callbacks.on_event_match;
1368 on_nan_event_match_expired_user_callback = user_callbacks.on_event_match_expired;
1369 on_nan_event_subscribe_terminated_user_callback = user_callbacks.on_event_subscribe_terminated;
1370 on_nan_event_followup_user_callback = user_callbacks.on_event_followup;
1371 on_nan_event_disc_eng_event_user_callback = user_callbacks.on_event_disc_eng_event;
1372 on_nan_event_disabled_user_callback = user_callbacks.on_event_disabled;
1373 on_nan_event_tca_user_callback = user_callbacks.on_event_tca;
1374 on_nan_event_beacon_sdf_payload_user_callback = user_callbacks.on_event_beacon_sdf_payload;
1375 on_nan_event_data_path_request_user_callback = user_callbacks.on_event_data_path_request;
Nate Jiang38e8db52022-12-02 17:30:27 -08001376 on_nan_event_pairing_request_user_callback = user_callbacks.on_event_pairing_request;
1377 on_nan_event_pairing_confirm_user_callback = user_callbacks.on_event_pairing_confirm;
1378 on_nan_event_bootstrapping_request_user_callback =
1379 user_callbacks.on_event_bootstrapping_request;
1380 on_nan_event_bootstrapping_confirm_user_callback =
1381 user_callbacks.on_event_bootstrapping_confirm;
Gabriel Birenf3262f92022-07-15 23:25:39 +00001382 on_nan_event_data_path_confirm_user_callback = user_callbacks.on_event_data_path_confirm;
1383 on_nan_event_data_path_end_user_callback = user_callbacks.on_event_data_path_end;
1384 on_nan_event_transmit_follow_up_user_callback = user_callbacks.on_event_transmit_follow_up;
1385 on_nan_event_range_request_user_callback = user_callbacks.on_event_range_request;
1386 on_nan_event_range_report_user_callback = user_callbacks.on_event_range_report;
1387 on_nan_event_schedule_update_user_callback = user_callbacks.on_event_schedule_update;
Nate Jiangd6cc3312023-02-14 16:37:54 -08001388 on_nan_event_suspension_mode_change_user_callback =
1389 user_callbacks.on_event_suspension_mode_change;
Gabriel Birenf3262f92022-07-15 23:25:39 +00001390
Nate Jiang38e8db52022-12-02 17:30:27 -08001391 return global_func_table_.wifi_nan_register_handler(getIfaceHandle(iface_name),
1392 {onAsyncNanNotifyResponse,
1393 onAsyncNanEventPublishReplied,
1394 onAsyncNanEventPublishTerminated,
1395 onAsyncNanEventMatch,
1396 onAsyncNanEventMatchExpired,
1397 onAsyncNanEventSubscribeTerminated,
1398 onAsyncNanEventFollowup,
1399 onAsyncNanEventDiscEngEvent,
1400 onAsyncNanEventDisabled,
1401 onAsyncNanEventTca,
1402 onAsyncNanEventBeaconSdfPayload,
1403 onAsyncNanEventDataPathRequest,
1404 onAsyncNanEventDataPathConfirm,
1405 onAsyncNanEventDataPathEnd,
1406 onAsyncNanEventTransmitFollowUp,
1407 onAsyncNanEventRangeRequest,
1408 onAsyncNanEventRangeReport,
1409 onAsyncNanEventScheduleUpdate,
1410 onAsyncNanEventPairingRequest,
1411 onAsyncNanEventPairingConfirm,
1412 onAsyncNanEventBootstrappingRequest,
Nate Jiangd6cc3312023-02-14 16:37:54 -08001413 onAsyncNanEventBootstrappingConfirm,
1414 onAsyncNanEventSuspensionModeChange});
Gabriel Birenf3262f92022-07-15 23:25:39 +00001415}
1416
1417wifi_error WifiLegacyHal::nanEnableRequest(const std::string& iface_name, transaction_id id,
1418 const NanEnableRequest& msg) {
1419 NanEnableRequest msg_internal(msg);
1420 return global_func_table_.wifi_nan_enable_request(id, getIfaceHandle(iface_name),
1421 &msg_internal);
1422}
1423
1424wifi_error WifiLegacyHal::nanDisableRequest(const std::string& iface_name, transaction_id id) {
1425 return global_func_table_.wifi_nan_disable_request(id, getIfaceHandle(iface_name));
1426}
1427
1428wifi_error WifiLegacyHal::nanPublishRequest(const std::string& iface_name, transaction_id id,
1429 const NanPublishRequest& msg) {
1430 NanPublishRequest msg_internal(msg);
1431 return global_func_table_.wifi_nan_publish_request(id, getIfaceHandle(iface_name),
1432 &msg_internal);
1433}
1434
1435wifi_error WifiLegacyHal::nanPublishCancelRequest(const std::string& iface_name, transaction_id id,
1436 const NanPublishCancelRequest& msg) {
1437 NanPublishCancelRequest msg_internal(msg);
1438 return global_func_table_.wifi_nan_publish_cancel_request(id, getIfaceHandle(iface_name),
1439 &msg_internal);
1440}
1441
1442wifi_error WifiLegacyHal::nanSubscribeRequest(const std::string& iface_name, transaction_id id,
1443 const NanSubscribeRequest& msg) {
1444 NanSubscribeRequest msg_internal(msg);
1445 return global_func_table_.wifi_nan_subscribe_request(id, getIfaceHandle(iface_name),
1446 &msg_internal);
1447}
1448
1449wifi_error WifiLegacyHal::nanSubscribeCancelRequest(const std::string& iface_name,
1450 transaction_id id,
1451 const NanSubscribeCancelRequest& msg) {
1452 NanSubscribeCancelRequest msg_internal(msg);
1453 return global_func_table_.wifi_nan_subscribe_cancel_request(id, getIfaceHandle(iface_name),
1454 &msg_internal);
1455}
1456
1457wifi_error WifiLegacyHal::nanTransmitFollowupRequest(const std::string& iface_name,
1458 transaction_id id,
1459 const NanTransmitFollowupRequest& msg) {
1460 NanTransmitFollowupRequest msg_internal(msg);
1461 return global_func_table_.wifi_nan_transmit_followup_request(id, getIfaceHandle(iface_name),
1462 &msg_internal);
1463}
1464
1465wifi_error WifiLegacyHal::nanStatsRequest(const std::string& iface_name, transaction_id id,
1466 const NanStatsRequest& msg) {
1467 NanStatsRequest msg_internal(msg);
1468 return global_func_table_.wifi_nan_stats_request(id, getIfaceHandle(iface_name), &msg_internal);
1469}
1470
1471wifi_error WifiLegacyHal::nanConfigRequest(const std::string& iface_name, transaction_id id,
1472 const NanConfigRequest& msg) {
1473 NanConfigRequest msg_internal(msg);
1474 return global_func_table_.wifi_nan_config_request(id, getIfaceHandle(iface_name),
1475 &msg_internal);
1476}
1477
1478wifi_error WifiLegacyHal::nanTcaRequest(const std::string& iface_name, transaction_id id,
1479 const NanTCARequest& msg) {
1480 NanTCARequest msg_internal(msg);
1481 return global_func_table_.wifi_nan_tca_request(id, getIfaceHandle(iface_name), &msg_internal);
1482}
1483
1484wifi_error WifiLegacyHal::nanBeaconSdfPayloadRequest(const std::string& iface_name,
1485 transaction_id id,
1486 const NanBeaconSdfPayloadRequest& msg) {
1487 NanBeaconSdfPayloadRequest msg_internal(msg);
1488 return global_func_table_.wifi_nan_beacon_sdf_payload_request(id, getIfaceHandle(iface_name),
1489 &msg_internal);
1490}
1491
1492std::pair<wifi_error, NanVersion> WifiLegacyHal::nanGetVersion() {
1493 NanVersion version;
1494 wifi_error status = global_func_table_.wifi_nan_get_version(global_handle_, &version);
1495 return {status, version};
1496}
1497
1498wifi_error WifiLegacyHal::nanGetCapabilities(const std::string& iface_name, transaction_id id) {
1499 return global_func_table_.wifi_nan_get_capabilities(id, getIfaceHandle(iface_name));
1500}
1501
1502wifi_error WifiLegacyHal::nanDataInterfaceCreate(const std::string& iface_name, transaction_id id,
1503 const std::string& data_iface_name) {
1504 return global_func_table_.wifi_nan_data_interface_create(id, getIfaceHandle(iface_name),
1505 makeCharVec(data_iface_name).data());
1506}
1507
1508wifi_error WifiLegacyHal::nanDataInterfaceDelete(const std::string& iface_name, transaction_id id,
1509 const std::string& data_iface_name) {
1510 return global_func_table_.wifi_nan_data_interface_delete(id, getIfaceHandle(iface_name),
1511 makeCharVec(data_iface_name).data());
1512}
1513
1514wifi_error WifiLegacyHal::nanDataRequestInitiator(const std::string& iface_name, transaction_id id,
1515 const NanDataPathInitiatorRequest& msg) {
1516 NanDataPathInitiatorRequest msg_internal(msg);
1517 return global_func_table_.wifi_nan_data_request_initiator(id, getIfaceHandle(iface_name),
1518 &msg_internal);
1519}
1520
1521wifi_error WifiLegacyHal::nanDataIndicationResponse(const std::string& iface_name,
1522 transaction_id id,
1523 const NanDataPathIndicationResponse& msg) {
1524 NanDataPathIndicationResponse msg_internal(msg);
1525 return global_func_table_.wifi_nan_data_indication_response(id, getIfaceHandle(iface_name),
1526 &msg_internal);
1527}
1528
Nate Jiang38e8db52022-12-02 17:30:27 -08001529wifi_error WifiLegacyHal::nanPairingRequest(const std::string& iface_name, transaction_id id,
1530 const NanPairingRequest& msg) {
1531 NanPairingRequest msg_internal(msg);
1532 return global_func_table_.wifi_nan_pairing_request(id, getIfaceHandle(iface_name),
1533 &msg_internal);
1534}
1535
1536wifi_error WifiLegacyHal::nanPairingIndicationResponse(const std::string& iface_name,
1537 transaction_id id,
1538 const NanPairingIndicationResponse& msg) {
1539 NanPairingIndicationResponse msg_internal(msg);
1540 return global_func_table_.wifi_nan_pairing_indication_response(id, getIfaceHandle(iface_name),
1541 &msg_internal);
1542}
1543
1544wifi_error WifiLegacyHal::nanBootstrappingRequest(const std::string& iface_name, transaction_id id,
1545 const NanBootstrappingRequest& msg) {
1546 NanBootstrappingRequest msg_internal(msg);
1547 return global_func_table_.wifi_nan_bootstrapping_request(id, getIfaceHandle(iface_name),
1548 &msg_internal);
1549}
1550
1551wifi_error WifiLegacyHal::nanBootstrappingIndicationResponse(
1552 const std::string& iface_name, transaction_id id,
1553 const NanBootstrappingIndicationResponse& msg) {
1554 NanBootstrappingIndicationResponse msg_internal(msg);
1555 return global_func_table_.wifi_nan_bootstrapping_indication_response(
1556 id, getIfaceHandle(iface_name), &msg_internal);
1557}
1558
Gabriel Birenf3262f92022-07-15 23:25:39 +00001559typedef struct {
1560 u8 num_ndp_instances;
1561 NanDataPathId ndp_instance_id;
1562} NanDataPathEndSingleNdpIdRequest;
1563
1564wifi_error WifiLegacyHal::nanDataEnd(const std::string& iface_name, transaction_id id,
1565 uint32_t ndpInstanceId) {
1566 NanDataPathEndSingleNdpIdRequest msg;
1567 msg.num_ndp_instances = 1;
1568 msg.ndp_instance_id = ndpInstanceId;
1569 wifi_error status = global_func_table_.wifi_nan_data_end(id, getIfaceHandle(iface_name),
1570 (NanDataPathEndRequest*)&msg);
1571 return status;
1572}
1573
Nate Jiangbae6fdd2023-02-10 17:16:40 -08001574wifi_error WifiLegacyHal::nanPairingEnd(const std::string& iface_name, transaction_id id,
1575 uint32_t pairingId) {
1576 NanPairingEndRequest msg;
1577 msg.pairing_instance_id = pairingId;
1578 wifi_error status =
1579 global_func_table_.wifi_nan_pairing_end(id, getIfaceHandle(iface_name), &msg);
1580 return status;
1581}
1582
Phill Hayers02a97242022-12-15 16:05:14 +00001583wifi_error WifiLegacyHal::nanSuspendRequest(const std::string& iface_name, transaction_id id,
1584 const NanSuspendRequest& msg) {
1585 NanSuspendRequest msg_internal(msg);
1586 wifi_error status = global_func_table_.wifi_nan_suspend_request(id, getIfaceHandle(iface_name),
1587 &msg_internal);
1588 return status;
1589}
1590
1591wifi_error WifiLegacyHal::nanResumeRequest(const std::string& iface_name, transaction_id id,
1592 const NanResumeRequest& msg) {
1593 NanResumeRequest msg_internal(msg);
1594 wifi_error status = global_func_table_.wifi_nan_resume_request(id, getIfaceHandle(iface_name),
1595 &msg_internal);
1596 return status;
1597}
1598
Gabriel Birenf3262f92022-07-15 23:25:39 +00001599wifi_error WifiLegacyHal::setCountryCode(const std::string& iface_name,
1600 const std::array<uint8_t, 2> code) {
1601 std::string code_str(code.data(), code.data() + code.size());
1602 return global_func_table_.wifi_set_country_code(getIfaceHandle(iface_name), code_str.c_str());
1603}
1604
1605wifi_error WifiLegacyHal::retrieveIfaceHandles() {
1606 wifi_interface_handle* iface_handles = nullptr;
1607 int num_iface_handles = 0;
1608 wifi_error status =
1609 global_func_table_.wifi_get_ifaces(global_handle_, &num_iface_handles, &iface_handles);
1610 if (status != WIFI_SUCCESS) {
1611 LOG(ERROR) << "Failed to enumerate interface handles";
1612 return status;
1613 }
1614 iface_name_to_handle_.clear();
1615 for (int i = 0; i < num_iface_handles; ++i) {
1616 std::array<char, IFNAMSIZ> iface_name_arr = {};
1617 status = global_func_table_.wifi_get_iface_name(iface_handles[i], iface_name_arr.data(),
1618 iface_name_arr.size());
1619 if (status != WIFI_SUCCESS) {
1620 LOG(WARNING) << "Failed to get interface handle name";
1621 continue;
1622 }
1623 // Assuming the interface name is null terminated since the legacy HAL
1624 // API does not return a size.
1625 std::string iface_name(iface_name_arr.data());
1626 LOG(INFO) << "Adding interface handle for " << iface_name;
1627 iface_name_to_handle_[iface_name] = iface_handles[i];
1628 }
1629 return WIFI_SUCCESS;
1630}
1631
1632wifi_interface_handle WifiLegacyHal::getIfaceHandle(const std::string& iface_name) {
1633 const auto iface_handle_iter = iface_name_to_handle_.find(iface_name);
1634 if (iface_handle_iter == iface_name_to_handle_.end()) {
1635 LOG(ERROR) << "Unknown iface name: " << iface_name;
1636 return nullptr;
1637 }
1638 return iface_handle_iter->second;
1639}
1640
1641void WifiLegacyHal::runEventLoop() {
1642 LOG(DEBUG) << "Starting legacy HAL event loop";
1643 global_func_table_.wifi_event_loop(global_handle_);
1644 const auto lock = aidl_sync_util::acquireGlobalLock();
1645 if (!awaiting_event_loop_termination_) {
1646 LOG(FATAL) << "Legacy HAL event loop terminated, but HAL was not stopping";
1647 }
1648 LOG(DEBUG) << "Legacy HAL event loop terminated";
1649 awaiting_event_loop_termination_ = false;
1650 stop_wait_cv_.notify_one();
1651}
1652
1653std::pair<wifi_error, std::vector<wifi_cached_scan_results>> WifiLegacyHal::getGscanCachedResults(
1654 const std::string& iface_name) {
1655 std::vector<wifi_cached_scan_results> cached_scan_results;
1656 cached_scan_results.resize(kMaxCachedGscanResults);
1657 int32_t num_results = 0;
1658 wifi_error status = global_func_table_.wifi_get_cached_gscan_results(
1659 getIfaceHandle(iface_name), true /* always flush */, cached_scan_results.size(),
1660 cached_scan_results.data(), &num_results);
1661 CHECK(num_results >= 0 && static_cast<uint32_t>(num_results) <= kMaxCachedGscanResults);
1662 cached_scan_results.resize(num_results);
1663 // Check for invalid IE lengths in these cached scan results and correct it.
1664 for (auto& cached_scan_result : cached_scan_results) {
1665 int num_scan_results = cached_scan_result.num_results;
1666 for (int i = 0; i < num_scan_results; i++) {
1667 auto& scan_result = cached_scan_result.results[i];
1668 if (scan_result.ie_length > 0) {
1669 LOG(DEBUG) << "Cached scan result has non-zero IE length " << scan_result.ie_length;
1670 scan_result.ie_length = 0;
1671 }
1672 }
1673 }
1674 return {status, std::move(cached_scan_results)};
1675}
1676
1677wifi_error WifiLegacyHal::createVirtualInterface(const std::string& ifname,
1678 wifi_interface_type iftype) {
1679 // Create the interface if it doesn't exist. If interface already exist,
1680 // Vendor Hal should return WIFI_SUCCESS.
1681 wifi_error status = global_func_table_.wifi_virtual_interface_create(global_handle_,
1682 ifname.c_str(), iftype);
1683 return handleVirtualInterfaceCreateOrDeleteStatus(ifname, status);
1684}
1685
1686wifi_error WifiLegacyHal::deleteVirtualInterface(const std::string& ifname) {
1687 // Delete the interface if it was created dynamically.
1688 wifi_error status =
1689 global_func_table_.wifi_virtual_interface_delete(global_handle_, ifname.c_str());
1690 return handleVirtualInterfaceCreateOrDeleteStatus(ifname, status);
1691}
1692
1693wifi_error WifiLegacyHal::handleVirtualInterfaceCreateOrDeleteStatus(const std::string& ifname,
1694 wifi_error status) {
1695 if (status == WIFI_SUCCESS) {
1696 // refresh list of handlers now.
1697 status = retrieveIfaceHandles();
1698 } else if (status == WIFI_ERROR_NOT_SUPPORTED) {
1699 // Vendor hal does not implement this API. Such vendor implementations
1700 // are expected to create / delete interface by other means.
1701
1702 // check if interface exists.
1703 if (if_nametoindex(ifname.c_str())) {
1704 status = retrieveIfaceHandles();
1705 }
1706 }
1707 return status;
1708}
1709
1710wifi_error WifiLegacyHal::getSupportedIfaceName(uint32_t iface_type, std::string& ifname) {
1711 std::array<char, IFNAMSIZ> buffer;
1712
1713 wifi_error res = global_func_table_.wifi_get_supported_iface_name(
1714 global_handle_, (uint32_t)iface_type, buffer.data(), buffer.size());
1715 if (res == WIFI_SUCCESS) ifname = buffer.data();
1716
1717 return res;
1718}
1719
1720wifi_error WifiLegacyHal::multiStaSetPrimaryConnection(const std::string& ifname) {
1721 return global_func_table_.wifi_multi_sta_set_primary_connection(global_handle_,
1722 getIfaceHandle(ifname));
1723}
1724
1725wifi_error WifiLegacyHal::multiStaSetUseCase(wifi_multi_sta_use_case use_case) {
1726 return global_func_table_.wifi_multi_sta_set_use_case(global_handle_, use_case);
1727}
1728
1729wifi_error WifiLegacyHal::setCoexUnsafeChannels(
1730 std::vector<wifi_coex_unsafe_channel> unsafe_channels, uint32_t restrictions) {
1731 return global_func_table_.wifi_set_coex_unsafe_channels(global_handle_, unsafe_channels.size(),
1732 unsafe_channels.data(), restrictions);
1733}
1734
1735wifi_error WifiLegacyHal::setVoipMode(const std::string& iface_name, wifi_voip_mode mode) {
1736 return global_func_table_.wifi_set_voip_mode(getIfaceHandle(iface_name), mode);
1737}
1738
1739wifi_error WifiLegacyHal::twtRegisterHandler(const std::string& iface_name,
1740 const TwtCallbackHandlers& user_callbacks) {
1741 on_twt_event_setup_response_callback = user_callbacks.on_setup_response;
1742 on_twt_event_teardown_completion_callback = user_callbacks.on_teardown_completion;
1743 on_twt_event_info_frame_received_callback = user_callbacks.on_info_frame_received;
1744 on_twt_event_device_notify_callback = user_callbacks.on_device_notify;
1745
1746 return global_func_table_.wifi_twt_register_handler(
1747 getIfaceHandle(iface_name),
1748 {onAsyncTwtEventSetupResponse, onAsyncTwtEventTeardownCompletion,
1749 onAsyncTwtEventInfoFrameReceived, onAsyncTwtEventDeviceNotify});
1750}
1751
1752std::pair<wifi_error, TwtCapabilitySet> WifiLegacyHal::twtGetCapability(
1753 const std::string& iface_name) {
1754 TwtCapabilitySet capSet;
1755 wifi_error status =
1756 global_func_table_.wifi_twt_get_capability(getIfaceHandle(iface_name), &capSet);
1757 return {status, capSet};
1758}
1759
1760wifi_error WifiLegacyHal::twtSetupRequest(const std::string& iface_name,
1761 const TwtSetupRequest& msg) {
1762 TwtSetupRequest msgInternal(msg);
1763 return global_func_table_.wifi_twt_setup_request(getIfaceHandle(iface_name), &msgInternal);
1764}
1765
1766wifi_error WifiLegacyHal::twtTearDownRequest(const std::string& iface_name,
1767 const TwtTeardownRequest& msg) {
1768 TwtTeardownRequest msgInternal(msg);
1769 return global_func_table_.wifi_twt_teardown_request(getIfaceHandle(iface_name), &msgInternal);
1770}
1771
1772wifi_error WifiLegacyHal::twtInfoFrameRequest(const std::string& iface_name,
1773 const TwtInfoFrameRequest& msg) {
1774 TwtInfoFrameRequest msgInternal(msg);
1775 return global_func_table_.wifi_twt_info_frame_request(getIfaceHandle(iface_name), &msgInternal);
1776}
1777
1778std::pair<wifi_error, TwtStats> WifiLegacyHal::twtGetStats(const std::string& iface_name,
1779 uint8_t configId) {
1780 TwtStats stats;
1781 wifi_error status =
1782 global_func_table_.wifi_twt_get_stats(getIfaceHandle(iface_name), configId, &stats);
1783 return {status, stats};
1784}
1785
1786wifi_error WifiLegacyHal::twtClearStats(const std::string& iface_name, uint8_t configId) {
1787 return global_func_table_.wifi_twt_clear_stats(getIfaceHandle(iface_name), configId);
1788}
1789
Ye Jiao50274f72023-01-17 14:53:22 +08001790wifi_error WifiLegacyHal::setScanMode(const std::string& iface_name, bool enable) {
1791 return global_func_table_.wifi_set_scan_mode(iface_name.c_str(), enable);
1792}
1793
Gabriel Birenf3262f92022-07-15 23:25:39 +00001794wifi_error WifiLegacyHal::setDtimConfig(const std::string& iface_name, uint32_t multiplier) {
1795 return global_func_table_.wifi_set_dtim_config(getIfaceHandle(iface_name), multiplier);
1796}
1797
1798std::pair<wifi_error, std::vector<wifi_usable_channel>> WifiLegacyHal::getUsableChannels(
1799 uint32_t band_mask, uint32_t iface_mode_mask, uint32_t filter_mask) {
1800 std::vector<wifi_usable_channel> channels;
1801 channels.resize(kMaxWifiUsableChannels);
1802 uint32_t size = 0;
1803 wifi_error status = global_func_table_.wifi_get_usable_channels(
1804 global_handle_, band_mask, iface_mode_mask, filter_mask, channels.size(), &size,
1805 reinterpret_cast<wifi_usable_channel*>(channels.data()));
1806 CHECK(size >= 0 && size <= kMaxWifiUsableChannels);
1807 channels.resize(size);
1808 return {status, std::move(channels)};
1809}
1810
1811wifi_error WifiLegacyHal::triggerSubsystemRestart() {
1812 return global_func_table_.wifi_trigger_subsystem_restart(global_handle_);
1813}
1814
1815wifi_error WifiLegacyHal::setIndoorState(bool isIndoor) {
1816 return global_func_table_.wifi_set_indoor_state(global_handle_, isIndoor);
1817}
1818
1819std::pair<wifi_error, wifi_radio_combination_matrix*>
1820WifiLegacyHal::getSupportedRadioCombinationsMatrix() {
1821 char* buffer = new char[kMaxSupportedRadioCombinationsMatrixLength];
1822 std::fill(buffer, buffer + kMaxSupportedRadioCombinationsMatrixLength, 0);
1823 uint32_t size = 0;
1824 wifi_radio_combination_matrix* radio_combination_matrix_ptr =
1825 reinterpret_cast<wifi_radio_combination_matrix*>(buffer);
1826 wifi_error status = global_func_table_.wifi_get_supported_radio_combinations_matrix(
1827 global_handle_, kMaxSupportedRadioCombinationsMatrixLength, &size,
1828 radio_combination_matrix_ptr);
1829 CHECK(size >= 0 && size <= kMaxSupportedRadioCombinationsMatrixLength);
1830 return {status, radio_combination_matrix_ptr};
1831}
1832
1833wifi_error WifiLegacyHal::chreNanRttRequest(const std::string& iface_name, bool enable) {
1834 if (enable)
1835 return global_func_table_.wifi_nan_rtt_chre_enable_request(0, getIfaceHandle(iface_name),
1836 NULL);
1837 else
1838 return global_func_table_.wifi_nan_rtt_chre_disable_request(0, getIfaceHandle(iface_name));
1839}
1840
1841wifi_error WifiLegacyHal::chreRegisterHandler(const std::string& iface_name,
1842 const ChreCallbackHandlers& handler) {
1843 if (on_chre_nan_rtt_internal_callback) {
1844 return WIFI_ERROR_NOT_AVAILABLE;
1845 }
1846
1847 on_chre_nan_rtt_internal_callback = handler.on_wifi_chre_nan_rtt_state;
1848
1849 wifi_error status = global_func_table_.wifi_chre_register_handler(getIfaceHandle(iface_name),
1850 {onAsyncChreNanRttState});
1851 if (status != WIFI_SUCCESS) {
1852 on_chre_nan_rtt_internal_callback = nullptr;
1853 }
1854 return status;
1855}
1856
1857wifi_error WifiLegacyHal::enableWifiTxPowerLimits(const std::string& iface_name, bool enable) {
1858 return global_func_table_.wifi_enable_tx_power_limits(getIfaceHandle(iface_name), enable);
1859}
1860
1861wifi_error WifiLegacyHal::getWifiCachedScanResults(
1862 const std::string& iface_name, const CachedScanResultsCallbackHandlers& handler) {
1863 on_cached_scan_results_internal_callback = handler.on_cached_scan_results;
1864
1865 wifi_error status = global_func_table_.wifi_get_cached_scan_results(getIfaceHandle(iface_name),
1866 {onSyncCachedScanResults});
1867
1868 on_cached_scan_results_internal_callback = nullptr;
1869 return status;
1870}
1871
Mahesh KKVc84d3772022-12-02 16:53:28 -08001872std::pair<wifi_error, wifi_chip_capabilities> WifiLegacyHal::getWifiChipCapabilities() {
1873 wifi_chip_capabilities chip_capabilities;
1874 wifi_error status =
1875 global_func_table_.wifi_get_chip_capabilities(global_handle_, &chip_capabilities);
1876 return {status, chip_capabilities};
1877}
1878
Shuibing Daie5fbcab2022-12-19 15:37:19 -08001879wifi_error WifiLegacyHal::enableStaChannelForPeerNetwork(uint32_t channelCategoryEnableFlag) {
1880 return global_func_table_.wifi_enable_sta_channel_for_peer_network(global_handle_,
1881 channelCategoryEnableFlag);
1882}
1883
Gabriel Birenf3262f92022-07-15 23:25:39 +00001884void WifiLegacyHal::invalidate() {
1885 global_handle_ = nullptr;
1886 iface_name_to_handle_.clear();
1887 on_driver_memory_dump_internal_callback = nullptr;
1888 on_firmware_memory_dump_internal_callback = nullptr;
1889 on_gscan_event_internal_callback = nullptr;
1890 on_gscan_full_result_internal_callback = nullptr;
1891 on_link_layer_stats_result_internal_callback = nullptr;
Mahesh KKV5f30d332022-10-26 14:07:44 -07001892 on_link_layer_ml_stats_result_internal_callback = nullptr;
Gabriel Birenf3262f92022-07-15 23:25:39 +00001893 on_rssi_threshold_breached_internal_callback = nullptr;
1894 on_ring_buffer_data_internal_callback = nullptr;
1895 on_error_alert_internal_callback = nullptr;
1896 on_radio_mode_change_internal_callback = nullptr;
1897 on_subsystem_restart_internal_callback = nullptr;
Sunil Ravif8fc2372022-11-10 18:37:41 +00001898 invalidateRttResultsCallbacks();
Gabriel Birenf3262f92022-07-15 23:25:39 +00001899 on_nan_notify_response_user_callback = nullptr;
1900 on_nan_event_publish_terminated_user_callback = nullptr;
1901 on_nan_event_match_user_callback = nullptr;
1902 on_nan_event_match_expired_user_callback = nullptr;
1903 on_nan_event_subscribe_terminated_user_callback = nullptr;
1904 on_nan_event_followup_user_callback = nullptr;
1905 on_nan_event_disc_eng_event_user_callback = nullptr;
1906 on_nan_event_disabled_user_callback = nullptr;
1907 on_nan_event_tca_user_callback = nullptr;
1908 on_nan_event_beacon_sdf_payload_user_callback = nullptr;
1909 on_nan_event_data_path_request_user_callback = nullptr;
Nate Jiang38e8db52022-12-02 17:30:27 -08001910 on_nan_event_pairing_request_user_callback = nullptr;
1911 on_nan_event_pairing_confirm_user_callback = nullptr;
1912 on_nan_event_bootstrapping_request_user_callback = nullptr;
1913 on_nan_event_bootstrapping_confirm_user_callback = nullptr;
Gabriel Birenf3262f92022-07-15 23:25:39 +00001914 on_nan_event_data_path_confirm_user_callback = nullptr;
1915 on_nan_event_data_path_end_user_callback = nullptr;
1916 on_nan_event_transmit_follow_up_user_callback = nullptr;
1917 on_nan_event_range_request_user_callback = nullptr;
1918 on_nan_event_range_report_user_callback = nullptr;
1919 on_nan_event_schedule_update_user_callback = nullptr;
1920 on_twt_event_setup_response_callback = nullptr;
1921 on_twt_event_teardown_completion_callback = nullptr;
1922 on_twt_event_info_frame_received_callback = nullptr;
1923 on_twt_event_device_notify_callback = nullptr;
1924 on_chre_nan_rtt_internal_callback = nullptr;
1925}
1926
1927} // namespace legacy_hal
1928} // namespace wifi
1929} // namespace hardware
1930} // namespace android
1931} // namespace aidl