diff options
Diffstat (limited to 'wifi/1.2/default/wifi_chip.h')
-rw-r--r-- | wifi/1.2/default/wifi_chip.h | 217 |
1 files changed, 217 insertions, 0 deletions
diff --git a/wifi/1.2/default/wifi_chip.h b/wifi/1.2/default/wifi_chip.h new file mode 100644 index 00000000..2b9ca64e --- /dev/null +++ b/wifi/1.2/default/wifi_chip.h | |||
@@ -0,0 +1,217 @@ | |||
1 | /* | ||
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_CHIP_H_ | ||
18 | #define WIFI_CHIP_H_ | ||
19 | |||
20 | #include <map> | ||
21 | |||
22 | #include <android-base/macros.h> | ||
23 | #include <android/hardware/wifi/1.1/IWifiChip.h> | ||
24 | |||
25 | #include "hidl_callback_util.h" | ||
26 | #include "wifi_ap_iface.h" | ||
27 | #include "wifi_legacy_hal.h" | ||
28 | #include "wifi_mode_controller.h" | ||
29 | #include "wifi_nan_iface.h" | ||
30 | #include "wifi_p2p_iface.h" | ||
31 | #include "wifi_rtt_controller.h" | ||
32 | #include "wifi_sta_iface.h" | ||
33 | |||
34 | namespace android { | ||
35 | namespace hardware { | ||
36 | namespace wifi { | ||
37 | namespace V1_2 { | ||
38 | namespace implementation { | ||
39 | using namespace android::hardware::wifi::V1_0; | ||
40 | |||
41 | /** | ||
42 | * HIDL interface object used to control a Wifi HAL chip instance. | ||
43 | * Since there is only a single chip instance used today, there is no | ||
44 | * identifying handle information stored here. | ||
45 | */ | ||
46 | class WifiChip : public V1_1::IWifiChip { | ||
47 | public: | ||
48 | WifiChip( | ||
49 | ChipId chip_id, | ||
50 | const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal, | ||
51 | const std::weak_ptr<mode_controller::WifiModeController> mode_controller); | ||
52 | // HIDL does not provide a built-in mechanism to let the server invalidate | ||
53 | // a HIDL interface object after creation. If any client process holds onto | ||
54 | // a reference to the object in their context, any method calls on that | ||
55 | // reference will continue to be directed to the server. | ||
56 | // | ||
57 | // However Wifi HAL needs to control the lifetime of these objects. So, add | ||
58 | // a public |invalidate| method to |WifiChip| and it's child objects. This | ||
59 | // will be used to mark an object invalid when either: | ||
60 | // a) Wifi HAL is stopped, or | ||
61 | // b) Wifi Chip is reconfigured. | ||
62 | // | ||
63 | // All HIDL method implementations should check if the object is still marked | ||
64 | // valid before processing them. | ||
65 | void invalidate(); | ||
66 | bool isValid(); | ||
67 | std::set<sp<IWifiChipEventCallback>> getEventCallbacks(); | ||
68 | |||
69 | // HIDL methods exposed. | ||
70 | Return<void> getId(getId_cb hidl_status_cb) override; | ||
71 | Return<void> registerEventCallback( | ||
72 | const sp<IWifiChipEventCallback>& event_callback, | ||
73 | registerEventCallback_cb hidl_status_cb) override; | ||
74 | Return<void> getCapabilities(getCapabilities_cb hidl_status_cb) override; | ||
75 | Return<void> getAvailableModes(getAvailableModes_cb hidl_status_cb) override; | ||
76 | Return<void> configureChip(ChipModeId mode_id, | ||
77 | configureChip_cb hidl_status_cb) override; | ||
78 | Return<void> getMode(getMode_cb hidl_status_cb) override; | ||
79 | Return<void> requestChipDebugInfo( | ||
80 | requestChipDebugInfo_cb hidl_status_cb) override; | ||
81 | Return<void> requestDriverDebugDump( | ||
82 | requestDriverDebugDump_cb hidl_status_cb) override; | ||
83 | Return<void> requestFirmwareDebugDump( | ||
84 | requestFirmwareDebugDump_cb hidl_status_cb) override; | ||
85 | Return<void> createApIface(createApIface_cb hidl_status_cb) override; | ||
86 | Return<void> getApIfaceNames(getApIfaceNames_cb hidl_status_cb) override; | ||
87 | Return<void> getApIface(const hidl_string& ifname, | ||
88 | getApIface_cb hidl_status_cb) override; | ||
89 | Return<void> removeApIface(const hidl_string& ifname, | ||
90 | removeApIface_cb hidl_status_cb) override; | ||
91 | Return<void> createNanIface(createNanIface_cb hidl_status_cb) override; | ||
92 | Return<void> getNanIfaceNames(getNanIfaceNames_cb hidl_status_cb) override; | ||
93 | Return<void> getNanIface(const hidl_string& ifname, | ||
94 | getNanIface_cb hidl_status_cb) override; | ||
95 | Return<void> removeNanIface(const hidl_string& ifname, | ||
96 | removeNanIface_cb hidl_status_cb) override; | ||
97 | Return<void> createP2pIface(createP2pIface_cb hidl_status_cb) override; | ||
98 | Return<void> getP2pIfaceNames(getP2pIfaceNames_cb hidl_status_cb) override; | ||
99 | Return<void> getP2pIface(const hidl_string& ifname, | ||
100 | getP2pIface_cb hidl_status_cb) override; | ||
101 | Return<void> removeP2pIface(const hidl_string& ifname, | ||
102 | removeP2pIface_cb hidl_status_cb) override; | ||
103 | Return<void> createStaIface(createStaIface_cb hidl_status_cb) override; | ||
104 | Return<void> getStaIfaceNames(getStaIfaceNames_cb hidl_status_cb) override; | ||
105 | Return<void> getStaIface(const hidl_string& ifname, | ||
106 | getStaIface_cb hidl_status_cb) override; | ||
107 | Return<void> removeStaIface(const hidl_string& ifname, | ||
108 | removeStaIface_cb hidl_status_cb) override; | ||
109 | Return<void> createRttController( | ||
110 | const sp<IWifiIface>& bound_iface, | ||
111 | createRttController_cb hidl_status_cb) override; | ||
112 | Return<void> getDebugRingBuffersStatus( | ||
113 | getDebugRingBuffersStatus_cb hidl_status_cb) override; | ||
114 | Return<void> startLoggingToDebugRingBuffer( | ||
115 | const hidl_string& ring_name, | ||
116 | WifiDebugRingBufferVerboseLevel verbose_level, | ||
117 | uint32_t max_interval_in_sec, | ||
118 | uint32_t min_data_size_in_bytes, | ||
119 | startLoggingToDebugRingBuffer_cb hidl_status_cb) override; | ||
120 | Return<void> forceDumpToDebugRingBuffer( | ||
121 | const hidl_string& ring_name, | ||
122 | forceDumpToDebugRingBuffer_cb hidl_status_cb) override; | ||
123 | Return<void> stopLoggingToDebugRingBuffer( | ||
124 | stopLoggingToDebugRingBuffer_cb hidl_status_cb) override; | ||
125 | Return<void> getDebugHostWakeReasonStats( | ||
126 | getDebugHostWakeReasonStats_cb hidl_status_cb) override; | ||
127 | Return<void> enableDebugErrorAlerts( | ||
128 | bool enable, enableDebugErrorAlerts_cb hidl_status_cb) override; | ||
129 | Return<void> selectTxPowerScenario( | ||
130 | TxPowerScenario scenario, | ||
131 | selectTxPowerScenario_cb hidl_status_cb) override; | ||
132 | Return<void> resetTxPowerScenario( | ||
133 | resetTxPowerScenario_cb hidl_status_cb) override; | ||
134 | |||
135 | private: | ||
136 | void invalidateAndRemoveAllIfaces(); | ||
137 | |||
138 | // Corresponding worker functions for the HIDL methods. | ||
139 | std::pair<WifiStatus, ChipId> getIdInternal(); | ||
140 | WifiStatus registerEventCallbackInternal( | ||
141 | const sp<IWifiChipEventCallback>& event_callback); | ||
142 | std::pair<WifiStatus, uint32_t> getCapabilitiesInternal(); | ||
143 | std::pair<WifiStatus, std::vector<ChipMode>> getAvailableModesInternal(); | ||
144 | WifiStatus configureChipInternal(ChipModeId mode_id); | ||
145 | std::pair<WifiStatus, uint32_t> getModeInternal(); | ||
146 | std::pair<WifiStatus, IWifiChip::ChipDebugInfo> | ||
147 | requestChipDebugInfoInternal(); | ||
148 | std::pair<WifiStatus, std::vector<uint8_t>> requestDriverDebugDumpInternal(); | ||
149 | std::pair<WifiStatus, std::vector<uint8_t>> | ||
150 | requestFirmwareDebugDumpInternal(); | ||
151 | std::pair<WifiStatus, sp<IWifiApIface>> createApIfaceInternal(); | ||
152 | std::pair<WifiStatus, std::vector<hidl_string>> getApIfaceNamesInternal(); | ||
153 | std::pair<WifiStatus, sp<IWifiApIface>> getApIfaceInternal( | ||
154 | const std::string& ifname); | ||
155 | WifiStatus removeApIfaceInternal(const std::string& ifname); | ||
156 | std::pair<WifiStatus, sp<IWifiNanIface>> createNanIfaceInternal(); | ||
157 | std::pair<WifiStatus, std::vector<hidl_string>> getNanIfaceNamesInternal(); | ||
158 | std::pair<WifiStatus, sp<IWifiNanIface>> getNanIfaceInternal( | ||
159 | const std::string& ifname); | ||
160 | WifiStatus removeNanIfaceInternal(const std::string& ifname); | ||
161 | std::pair<WifiStatus, sp<IWifiP2pIface>> createP2pIfaceInternal(); | ||
162 | std::pair<WifiStatus, std::vector<hidl_string>> getP2pIfaceNamesInternal(); | ||
163 | std::pair<WifiStatus, sp<IWifiP2pIface>> getP2pIfaceInternal( | ||
164 | const std::string& ifname); | ||
165 | WifiStatus removeP2pIfaceInternal(const std::string& ifname); | ||
166 | std::pair<WifiStatus, sp<IWifiStaIface>> createStaIfaceInternal(); | ||
167 | std::pair<WifiStatus, std::vector<hidl_string>> getStaIfaceNamesInternal(); | ||
168 | std::pair<WifiStatus, sp<IWifiStaIface>> getStaIfaceInternal( | ||
169 | const std::string& ifname); | ||
170 | WifiStatus removeStaIfaceInternal(const std::string& ifname); | ||
171 | std::pair<WifiStatus, sp<IWifiRttController>> createRttControllerInternal( | ||
172 | const sp<IWifiIface>& bound_iface); | ||
173 | std::pair<WifiStatus, std::vector<WifiDebugRingBufferStatus>> | ||
174 | getDebugRingBuffersStatusInternal(); | ||
175 | WifiStatus startLoggingToDebugRingBufferInternal( | ||
176 | const hidl_string& ring_name, | ||
177 | WifiDebugRingBufferVerboseLevel verbose_level, | ||
178 | uint32_t max_interval_in_sec, | ||
179 | uint32_t min_data_size_in_bytes); | ||
180 | WifiStatus forceDumpToDebugRingBufferInternal(const hidl_string& ring_name); | ||
181 | WifiStatus stopLoggingToDebugRingBufferInternal(); | ||
182 | std::pair<WifiStatus, WifiDebugHostWakeReasonStats> | ||
183 | getDebugHostWakeReasonStatsInternal(); | ||
184 | WifiStatus enableDebugErrorAlertsInternal(bool enable); | ||
185 | WifiStatus selectTxPowerScenarioInternal(TxPowerScenario scenario); | ||
186 | WifiStatus resetTxPowerScenarioInternal(); | ||
187 | |||
188 | WifiStatus handleChipConfiguration(ChipModeId mode_id); | ||
189 | WifiStatus registerDebugRingBufferCallback(); | ||
190 | |||
191 | ChipId chip_id_; | ||
192 | std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_; | ||
193 | std::weak_ptr<mode_controller::WifiModeController> mode_controller_; | ||
194 | sp<WifiApIface> ap_iface_; | ||
195 | sp<WifiNanIface> nan_iface_; | ||
196 | sp<WifiP2pIface> p2p_iface_; | ||
197 | sp<WifiStaIface> sta_iface_; | ||
198 | std::vector<sp<WifiRttController>> rtt_controllers_; | ||
199 | bool is_valid_; | ||
200 | uint32_t current_mode_id_; | ||
201 | // The legacy ring buffer callback API has only a global callback | ||
202 | // registration mechanism. Use this to check if we have already | ||
203 | // registered a callback. | ||
204 | bool debug_ring_buffer_cb_registered_; | ||
205 | hidl_callback_util::HidlCallbackHandler<IWifiChipEventCallback> | ||
206 | event_cb_handler_; | ||
207 | |||
208 | DISALLOW_COPY_AND_ASSIGN(WifiChip); | ||
209 | }; | ||
210 | |||
211 | } // namespace implementation | ||
212 | } // namespace V1_2 | ||
213 | } // namespace wifi | ||
214 | } // namespace hardware | ||
215 | } // namespace android | ||
216 | |||
217 | #endif // WIFI_CHIP_H_ | ||