• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 package com.android.server.wifi.hal;
18 
19 import android.annotation.Nullable;
20 import android.hardware.wifi.WifiStatusCode;
21 import android.net.MacAddress;
22 import android.net.apf.ApfCapabilities;
23 import android.net.wifi.WifiManager.RoamingMode;
24 import android.net.wifi.WifiScanner;
25 import android.net.wifi.twt.TwtRequest;
26 import android.os.Bundle;
27 
28 import com.android.server.wifi.WifiLinkLayerStats;
29 import com.android.server.wifi.WifiLoggerHal;
30 import com.android.server.wifi.WifiNative;
31 
32 import java.util.BitSet;
33 import java.util.List;
34 
35 /** Abstraction of WifiStaIface */
36 public interface IWifiStaIface {
37     /**
38      * Register for event callbacks.
39      *
40      * @param callback Instance of {@link WifiStaIface.Callback}
41      * @return true if successful, false otherwise.
42      */
registerFrameworkCallback(WifiStaIface.Callback callback)43     boolean registerFrameworkCallback(WifiStaIface.Callback callback);
44 
45     /**
46      * Get the name of this interface.
47      *
48      * @return Name of this interface, or null on error.
49      */
50     @Nullable
getName()51     String getName();
52 
53     /**
54      * Configure roaming control parameters.
55      *
56      * @param bssidBlocklist List of BSSIDs that are blocklisted for roaming.
57      * @param ssidAllowlist List of SSIDs that are allowlisted for roaming.
58      * @return true if successful, false otherwise.
59      */
configureRoaming(List<MacAddress> bssidBlocklist, List<byte[]> ssidAllowlist)60     boolean configureRoaming(List<MacAddress> bssidBlocklist, List<byte[]> ssidAllowlist);
61 
62     /**
63      * Enable link layer stats collection.
64      *
65      * Radio statistics (once started) must not stop until disabled.
66      * Iface statistics (once started) reset and start afresh after each
67      * connection until disabled.
68      *
69      * @param debug true to enable field debug mode, false to disable. Driver
70      *        must collect all statistics regardless of performance impact.
71      * @return true if successful, false otherwise.
72      */
enableLinkLayerStatsCollection(boolean debug)73     boolean enableLinkLayerStatsCollection(boolean debug);
74 
75     /**
76      * Enable/disable the neighbor discovery offload functionality in the firmware.
77      *
78      * @param enable true to enable, false to disable.
79      * @return true if successful, false otherwise.
80      */
enableNdOffload(boolean enable)81     boolean enableNdOffload(boolean enable);
82 
83     /**
84      * Used to query additional information about the chip's APF capabilities.
85      *
86      * @return Instance of {@link ApfCapabilities}.
87      */
getApfPacketFilterCapabilities()88     ApfCapabilities getApfPacketFilterCapabilities();
89 
90     /**
91      * Used to query additional information about the chip's Background Scan capabilities.
92      *
93      * @return Instance of {@link WifiNative.ScanCapabilities}, or null on error.
94      */
95     @Nullable
getBackgroundScanCapabilities()96     WifiNative.ScanCapabilities getBackgroundScanCapabilities();
97 
98     /**
99      * Get the capabilities supported by this STA iface.
100      *
101      * @return BitSet of WifiManager.WIFI_FEATURE_* values.
102      */
getCapabilities()103     BitSet getCapabilities();
104 
105     /**
106      * Retrieve the fates of inbound packets.
107      * Reports the inbound frames for the most recent association (space allowing).
108      *
109      * @return List of RxFateReports up to size {@link WifiLoggerHal#MAX_FATE_LOG_LEN},
110      *        or empty list on failure.
111      */
getDebugRxPacketFates()112     List<WifiNative.RxFateReport> getDebugRxPacketFates();
113 
114     /**
115      * Retrieve fates of outbound packets.
116      * Reports the outbound frames for the most recent association (space allowing).
117      *
118      * @return List of TxFateReports up to size {@link WifiLoggerHal#MAX_FATE_LOG_LEN},
119      *         or empty list on failure.
120      */
getDebugTxPacketFates()121     List<WifiNative.TxFateReport> getDebugTxPacketFates();
122 
123     /**
124      * Get the factory MAC address of the STA interface.
125      *
126      * @return Factory MAC address of the STA interface, or null on error.
127      */
128     @Nullable
getFactoryMacAddress()129     MacAddress getFactoryMacAddress();
130 
131     /**
132      * Retrieve the cached scan data.
133      *
134      * @return Instance of {@link ScanData}, or null on error.
135      */
136     @Nullable
getCachedScanData()137     WifiScanner.ScanData getCachedScanData();
138 
139     /**
140      * Retrieve the latest link layer stats.
141      * Note: will fail if link layer stats collection has not been explicitly enabled.
142      *
143      * @return Instance of {@link WifiLinkLayerStats}, or null on error.
144      */
145     @Nullable
getLinkLayerStats()146     WifiLinkLayerStats getLinkLayerStats();
147 
148     /**
149      * Get roaming control capabilities.
150      *
151      * @return Instance of {@link WifiNative.RoamingCapabilities}, or null on error.
152      */
153     @Nullable
getRoamingCapabilities()154     WifiNative.RoamingCapabilities getRoamingCapabilities();
155 
156     /**
157      * Install an APF program on this interface, replacing any existing program.
158      *
159      * @param program APF Program to be set.
160      * @return true if successful, false otherwise.
161      */
installApfPacketFilter(byte[] program)162     boolean installApfPacketFilter(byte[] program);
163 
164     /**
165      * Read the APF program and data buffer on this interface.
166      *
167      * @return Buffer returned by the driver, or null if an error occurred.
168      */
169     @Nullable
readApfPacketFilterData()170     byte[] readApfPacketFilterData();
171 
172     /**
173      * Changes the MAC address of the interface to the given MAC address.
174      *
175      * @param mac MAC address to change to.
176      * @return true if successful, false otherwise.
177      */
setMacAddress(MacAddress mac)178     boolean setMacAddress(MacAddress mac);
179 
180     /**
181      * Enable/disable firmware roaming.
182      *
183      * @param state State of the roaming control.
184      * @return SET_FIRMWARE_ROAMING_SUCCESS, SET_FIRMWARE_ROAMING_FAILURE,
185      *         or SET_FIRMWARE_ROAMING_BUSY
186      */
setRoamingState(@ifiNative.RoamingEnableState int state)187     @WifiNative.RoamingEnableStatus int setRoamingState(@WifiNative.RoamingEnableState int state);
188 
189     /**
190      * Enable/disable scan-only mode for this interface.
191      *
192      * @param enable True to enable scan only mode, false to disable.
193      * @return true if successful, false otherwise.
194      */
setScanMode(boolean enable)195     boolean setScanMode(boolean enable);
196 
197     /**
198      * Starts a background scan.
199      * Note: any ongoing scan will be stopped first.
200      *
201      * @param cmdId Command ID to use for this invocation.
202      * @param params Background scan parameters.
203      * @return true if successful, false otherwise.
204      */
startBackgroundScan(int cmdId, WifiStaIface.StaBackgroundScanParameters params)205     boolean startBackgroundScan(int cmdId, WifiStaIface.StaBackgroundScanParameters params);
206 
207     /**
208      * Start packet fate monitoring. Once started, monitoring remains active until
209      * the HAL is unloaded.
210      *
211      * @return true if successful, false otherwise.
212      */
startDebugPacketFateMonitoring()213     boolean startDebugPacketFateMonitoring();
214 
215     /**
216      * Start RSSI monitoring on the currently connected access point.
217      *
218      * @param cmdId Command ID to use for this invocation.
219      * @param maxRssi Maximum RSSI threshold.
220      * @param minRssi Minimum RSSI threshold.
221      * @return true if successful, false otherwise.
222      */
startRssiMonitoring(int cmdId, int maxRssi, int minRssi)223     boolean startRssiMonitoring(int cmdId, int maxRssi, int minRssi);
224 
225     /**
226      * Start sending the specified keep-alive packets periodically.
227      *
228      * @param cmdId Command ID to use for this invocation.
229      * @param ipPacketData IP packet contents to be transmitted.
230      * @param etherType Ether type to be set in the ethernet frame transmitted.
231      * @param srcAddress Source MAC address of the packet.
232      * @param dstAddress Destination MAC address of the packet.
233      * @param periodInMs Interval at which this packet must be transmitted.
234      * @return true if successful, false otherwise.
235      */
startSendingKeepAlivePackets(int cmdId, byte[] ipPacketData, int etherType, MacAddress srcAddress, MacAddress dstAddress, int periodInMs)236     boolean startSendingKeepAlivePackets(int cmdId, byte[] ipPacketData, int etherType,
237             MacAddress srcAddress, MacAddress dstAddress, int periodInMs);
238 
239     /**
240      * Stop the current background scan.
241      *
242      * @param cmdId Command ID corresponding to the request.
243      * @return true if successful, false otherwise.
244      */
stopBackgroundScan(int cmdId)245     boolean stopBackgroundScan(int cmdId);
246 
247     /**
248      * Stop RSSI monitoring.
249      *
250      * @param cmdId Command ID corresponding to the request.
251      * @return true if successful, false otherwise.
252      */
stopRssiMonitoring(int cmdId)253     boolean stopRssiMonitoring(int cmdId);
254 
255     /**
256      * Stop sending the specified keep-alive packets.
257      *
258      * @param cmdId Command ID corresponding to the request.
259      * @return true if successful, false otherwise.
260      */
stopSendingKeepAlivePackets(int cmdId)261     boolean stopSendingKeepAlivePackets(int cmdId);
262 
263     /**
264      * Set maximum acceptable DTIM multiplier to hardware driver. Any multiplier larger than the
265      * maximum value must not be accepted, it will cause packet loss higher than what the system
266      * can accept, which will cause unexpected behavior for apps, and may interrupt the network
267      * connection.
268      *
269      * @param multiplier maximum DTIM multiplier value to set.
270      * @return true if successful, false otherwise.
271      */
setDtimMultiplier(int multiplier)272     boolean setDtimMultiplier(int multiplier);
273 
274     /**
275      * Set the roaming mode.
276      *
277      * @param roamingMode {@link android.net.wifi.WifiManager.RoamingMode}.
278      * @return {@link WifiStatusCode#SUCCESS} if success, otherwise error code.
279      */
setRoamingMode(@oamingMode int roamingMode)280     @WifiStatusCode int setRoamingMode(@RoamingMode int roamingMode);
281 
282     /**
283      * Get target wake time (TWT) capabilities.
284      *
285      * @return TWT capabilities as Bundle
286      */
getTwtCapabilities()287     default Bundle getTwtCapabilities() {
288         return null;
289     }
290 
291     /**
292      * Set up a TWT session
293      *
294      * @param cmdId Command ID to use for this invocation.
295      * @param twtRequest TWT request configuration to setup TWT session
296      * @return true if successful, false otherwise.
297      */
setupTwtSession(int cmdId, TwtRequest twtRequest)298     default boolean setupTwtSession(int cmdId, TwtRequest twtRequest) {
299         return false;
300     }
301 
302     /**
303      * Teardown a TWT session.
304      *
305      * @param cmdId Command ID to use for this invocation.
306      * @param sessionId TWT session identifier
307      * @return true if successful, false otherwise.
308      */
tearDownTwtSession(int cmdId, int sessionId)309     default boolean tearDownTwtSession(int cmdId, int sessionId) {
310         return false;
311     }
312 
313     /**
314      * Get stats for the TWT session.
315      *
316      * @param cmdId Command ID to use for this invocation.
317      * @param sessionId TWT session identifier
318      * @return true if successful, false otherwise.
319      */
getStatsTwtSession(int cmdId, int sessionId)320     default boolean getStatsTwtSession(int cmdId, int sessionId) {
321         return false;
322     }
323 }
324