blob: 8bd146a1671ec24ec224e8fe255fd7af7d8aec00 [file] [log] [blame]
Roshan Piusaabe5752016-09-29 09:03:59 -07001/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef WIFI_LEGACY_WIFI_HAL_H_
18#define WIFI_LEGACY_WIFI_HAL_H_
19
20#include <functional>
21#include <thread>
Roshan Pius734fea02016-10-11 08:30:28 -070022#include <vector>
Roshan Piusaabe5752016-09-29 09:03:59 -070023
Roshan Piusaabe5752016-09-29 09:03:59 -070024namespace android {
25namespace hardware {
26namespace wifi {
27namespace V1_0 {
28namespace implementation {
Roshan Pius955542e2016-10-28 09:42:44 -070029// This is in a separate namespace to prevent typename conflicts between
30// the legacy HAL types and the HIDL interface types.
31namespace legacy_hal {
32// Wrap all the types defined inside the legacy HAL header files inside this
33// namespace.
34#include <hardware_legacy/wifi_hal.h>
Roshan Piusaabe5752016-09-29 09:03:59 -070035
Roshan Pius0a47c182016-10-28 10:23:00 -070036// APF capabilities supported by the iface.
37struct PacketFilterCapabilities {
38 uint32_t version;
39 uint32_t max_len;
40};
41
Roshan Piusaabe5752016-09-29 09:03:59 -070042/**
43 * Class that encapsulates all legacy HAL interactions.
44 * This class manages the lifetime of the event loop thread used by legacy HAL.
45 */
46class WifiLegacyHal {
47 public:
48 WifiLegacyHal();
Roshan Piusab5c4712016-10-06 14:37:15 -070049 // Names to use for the different types of iface.
50 std::string getApIfaceName();
51 std::string getNanIfaceName();
52 std::string getP2pIfaceName();
53 std::string getStaIfaceName();
54
Roshan Piusaabe5752016-09-29 09:03:59 -070055 // Initialize the legacy HAL and start the event looper thread.
56 wifi_error start();
57 // Deinitialize the legacy HAL and stop the event looper thread.
58 wifi_error stop(const std::function<void()>& on_complete_callback);
Roshan Pius4b26c832016-10-03 12:49:58 -070059 // Wrappers for all the functions in the legacy HAL function table.
Roshan Piusab5c4712016-10-06 14:37:15 -070060 std::pair<wifi_error, std::string> getDriverVersion();
61 std::pair<wifi_error, std::string> getFirmwareVersion();
Roshan Pius3c868522016-10-27 12:43:49 -070062 std::pair<wifi_error, std::vector<uint8_t>> requestDriverMemoryDump();
63 std::pair<wifi_error, std::vector<uint8_t>> requestFirmwareMemoryDump();
Roshan Pius0a47c182016-10-28 10:23:00 -070064 std::pair<wifi_error, uint32_t> getSupportedFeatureSet();
65 // APF functions.
66 std::pair<wifi_error, PacketFilterCapabilities> getPacketFilterCapabilities();
67 wifi_error setPacketFilter(const std::vector<uint8_t>& program);
Roshan Piusaabe5752016-09-29 09:03:59 -070068
69 private:
Roshan Piusaabe5752016-09-29 09:03:59 -070070 // Retrieve the interface handle to be used for the "wlan" interface.
71 wifi_error retrieveWlanInterfaceHandle();
72 // Run the legacy HAL event loop thread.
73 void runEventLoop();
Roshan Pius511cc492016-10-28 09:54:26 -070074 void invalidate();
Roshan Piusaabe5752016-09-29 09:03:59 -070075
76 // Event loop thread used by legacy HAL.
77 std::thread event_loop_thread_;
78 // Global function table of legacy HAL.
79 wifi_hal_fn global_func_table_;
80 // Opaque handle to be used for all global operations.
81 wifi_handle global_handle_;
82 // Opaque handle to be used for all wlan0 interface specific operations.
83 wifi_interface_handle wlan_interface_handle_;
84 // Flag to indicate if we have initiated the cleanup of legacy HAL.
85 bool awaiting_event_loop_termination_;
86};
87
Roshan Pius955542e2016-10-28 09:42:44 -070088} // namespace legacy_hal
Roshan Piusaabe5752016-09-29 09:03:59 -070089} // namespace implementation
90} // namespace V1_0
91} // namespace wifi
92} // namespace hardware
93} // namespace android
94
95#endif // WIFI_LEGACY_WIFI_HAL_H_