blob: 8f45777fd17d44d91f7dd728c45f7216c12e62f9 [file] [log] [blame]
Roshan Piusadcfba42016-10-05 10:19:06 -07001/*
2 * Copyright 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
17package android.hardware.wifi@1.0;
18
19import IWifiIface;
Roshan Pius7b777472016-10-07 13:15:59 -070020import IWifiStaIfaceEventCallback;
Roshan Piusadcfba42016-10-05 10:19:06 -070021
22/**
23 * Interface used to represent a single STA iface.
24 */
25interface IWifiStaIface extends IWifiIface {
Roshan Pius7b777472016-10-07 13:15:59 -070026 /**
27 * Mask of capabilities suported by this Iface.
28 */
29 enum StaIfaceCapabilityMask : uint32_t {
30 /**
31 * If set indicates that the APF APIs are supported.
32 * APF (Android Packet Filter) is a BPF like packet filtering
33 * bytecode executed by the firmware.
34 */
35 APF = 1 << 0,
36 /**
37 * If set indicates that the Background Scan APIs are supported.
38 * Background scan allow the host to send a number of buckets down to the
39 * firmware. Each bucket contains a set of channels, a period, and some
40 * parameters about how and when to report results.
41 */
42 BACKGROUND_SCAN = 1 << 1,
Roshan Pius18680b72016-10-12 08:25:48 -070043 /**
44 * If set indicates that the link layer stats APIs are supported.
45 */
46 LINK_LAYER_STATS = 1 << 2
Roshan Pius7b777472016-10-07 13:15:59 -070047 };
48
49 /**
50 * Parameters to specify the APF capability of this iface.
51 */
52 struct ApfPacketFilterCapabilities {
53 /**
54 * Version of the packet filter interpreter supported
55 */
56 uint32_t version;
57 /**
58 * Maximum size of the filter bytecodes in bytes for an iface.
59 */
60 uint32_t maxLength;
61 };
62
63 /**
64 * Parameters to specify the Background Scan capability of this iface.
65 */
66 struct BackgroundScanCapabilities {
67 /**
68 * Maximum number of bytes available for cached scan results
69 */
70 uint32_t maxCacheSize;
71 /**
72 * Maximum number of buckets that can be supplied for a scan
73 */
74 uint32_t maxBuckets;
75 /**
76 * Maximum number of APs that must be stored for each scan.
77 */
78 uint32_t maxApCachePerScan;
79 /**
80 * Max reporting number of scans threshold that can be specified in the scan
81 * parameters.
82 */
83 int32_t maxReportingThreshold;
84 };
85
86 /**
87 * Bands that can be specified in Background scan requests.
88 */
89 enum BackgroundScanBand : uint32_t {
90 BAND_UNSPECIFIED,
91 /**
92 * 2.4 GHz.
93 */
94 BAND_24GHZ = 1,
95 /**
96 * 5 GHz without DFS.
97 */
98 BAND_5GHZ = 2,
99 /**
100 * 5 GHz DFS only.
101 */
102 BAND_5GHZ_DFS = 4,
103 /**
104 * 5 GHz with DFS.
105 */
106 BAND_5GHZ_WITH_DFS = 6,
107 /**
108 * 2.4 GHz + 5 GHz; no DFS.
109 */
110 BAND_24GHZ_5GHZ = 3,
111 /**
112 * 2.4 GHz + 5 GHz with DFS
113 */
114 BAND_24GHZ_5GHZ_WITH_DFS = 7
115 };
116
117 /**
118 * Mask of event reporting schemes that can be specified in background scan
119 * requests.
120 */
121 enum BackgroundScanBucketEventReportSchemeMask : uint32_t {
122 /**
123 * Report a scan completion event after scan. If this is not set then scan
124 * completion events must be reported if report_threshold_percent or
125 * report_threshold_num_scans is reached.
126 */
127 EACH_SCAN = 1 << 0,
128 /**
129 * Forward scan results (beacons/probe responses + IEs) in real time to HAL,
130 * in addition to completion events.
131 * Note: To keep backward compatibility, fire completion events regardless
132 * of REPORT_EVENTS_EACH_SCAN.
133 */
134 FULL_RESULTS = 1 << 1,
135 /**
136 * Controls if scans for this bucket must be placed in the results buffer.
137 */
138 NO_BATCH = 1 << 2,
139 };
140
141 /**
142 * Background Scan parameters per bucket that can be specified in background
143 * scan requests.
144 */
145 struct BackgroundScanBucketParameters {
146 /**
147 * Bands to scan or 0 if frequencies list must be used instead.
148 */
149 BackgroundScanBand band;
150 /**
151 * Channel frequencies (in Mhz) to scan if |band| is set to
152 * |UNSPECIFIED|.
153 */
Roshan Pius120f94c2016-10-13 11:48:42 -0700154 vec<WifiChannelInMhz> frequencies;
Roshan Pius7b777472016-10-07 13:15:59 -0700155 /**
156 * Period at which this bucket must be scanned (in milliseconds). Must be an integer
157 * multiple of the |basePeriodInMs| specified in the BackgroundScanParameters.
158 */
159 uint32_t periodInMs;
160 /**
161 * Bitset of |BackgroundScanBucketEventReportSchemeMask| values controlling
162 * when events for this bucket must be reported.
163 */
164 uint32_t eventReportScheme;
165 /**
166 * For exponential back off. If |exponentialMaxPeriodInMs| is non zero or
167 * different than period, then this bucket is an exponential backoff bucket
168 * and the scan period must grow exponentially as per formula:
169 * actual_period(N) = period * (base ^ (N/step_count))
170 * to this maximum period (in milliseconds).
171 */
172 uint32_t exponentialMaxPeriodInMs;
173 /**
174 * For exponential back off. multiplier: new_period=old_period * base
175 */
176 uint32_t exponentialBase;
177 /**
178 * For exponential back off. Number of scans to perform for a given
179 * period.
180 */
181 uint32_t exponentialStepCount;
182 };
183
184 /**
185 * Background Scan parameters that can be specified in background scan
186 * requests.
187 */
188 struct BackgroundScanParameters {
189 /**
190 * GCD of all bucket periods (in milliseconds).
191 */
192 uint32_t basePeriodInMs;
193 /**
194 * Maximum number of APs that must be stored for each scan. If the maximum
195 * is reached the highest RSSI results must be returned.
196 */
197 uint32_t maxApPerScan;
198 /**
199 * % cache buffer filled threshold at which the host must be notified of
200 * batched scan results.
201 */
202 uint32_t reportThresholdPercent;
203 /**
204 * Threshold at which the AP must be woken up, in number of scans.
205 */
206 uint32_t reportThresholdNumScans;
207 /**
208 * List of buckets to be scheduled.
209 */
210 vec<BackgroundScanBucketParameters> buckets;
211 };
212
213 /**
Roshan Pius18680b72016-10-12 08:25:48 -0700214 * Packet stats for different traffic categories.
215 */
216 struct LinkLayerIfacePacketStats {
217 /**
218 * Number of received unicast data packets.
219 */
220 uint64_t rxMpdu;
221 /**
222 * Number of successfully transmitted unicast data pkts (ACK rcvd).
223 */
224 uint64_t txMpdu;
225 /**
226 * Number of transmitted unicast data pkt losses (no ACK).
227 */
228 uint64_t lostMpdu;
229 /**
230 * Number of transmitted unicast data retry pkts.
231 */
232 uint64_t retries;
233 };
234
235 /**
236 * Iface statistics for the current connection.
237 */
238 struct LinkLayerIfaceStats {
239 /**
240 * Number beacons received from the connected AP.
241 */
242 uint32_t beaconRx;
243 /**
244 * Access Point Beacon and Management frames RSSI (averaged).
245 */
246 int32_t avgRssiMgmt;
247 /**
248 * WME Best Effort Access Category packet counters.
249 */
250 LinkLayerIfacePacketStats wmeBePktStats;
251 /**
252 * WME Background Access Category packet counters.
253 */
254 LinkLayerIfacePacketStats wmeBkPktStats;
255 /**
256 * WME Video Access Category packet counters.
257 */
258 LinkLayerIfacePacketStats wmeViPktStats;
259 /**
260 * WME Voice Access Category packet counters.
261 */
262 LinkLayerIfacePacketStats wmeVoPktStats;
263 };
264
265 /**
266 * Cumulative radio statistics since collection was enabled.
267 */
268 struct LinkLayerRadioStats {
269 /**
270 * Time for which the radio is awake.
271 */
272 uint32_t onTimeInMs;
273 /**
274 * Total time for which the radio is in active transmission.
275 */
276 uint32_t txTimeInMs;
277 /**
278 * Time for which the radio is in active tranmission per tx level.
279 */
280 vec<uint32_t> txTimeInMsPerLevel;
281 /**
282 * Time for which the radio is in active receive.
283 */
284 uint32_t rxTimeInMs;
285 /**
286 * Total time for which the radio is awake due to scan.
287 */
288 uint32_t onTimeInMsForScan;
289 };
290
291 /**
292 * Link layer stats retrieved via |getLinkLayerStats|.
293 */
294 struct LinkLayerStats {
295 LinkLayerIfaceStats iface;
296 LinkLayerRadioStats radio;
297 /**
298 * Timestamp for each stats sample.
299 * This is the absolute milliseconds from boot when these stats were
300 * sampled.
301 */
302 uint32_t timeStampInMs;
303 };
304
305 /**
Roshan Pius7b777472016-10-07 13:15:59 -0700306 * Requests notifications of significant events on this iface. Multiple calls
307 * to this must register multiple callbacks each of which must receive all
308 * events.
309 *
310 * @param callback An instance of the |IWifiStaIfaceEventCallback| HIDL interface
311 * object.
Roshan Piusa52dc732016-10-10 11:53:07 -0700312 * @return status WifiStatus of the operation.
Roshan Pius1f9073c2016-10-10 10:32:22 -0700313 * Possible status codes:
Roshan Piusa52dc732016-10-10 11:53:07 -0700314 * |WifiStatusCode.SUCCESS|,
315 * |WifiStatusCode.ERROR_WIFI_IFACE_INVALID|
Roshan Pius7b777472016-10-07 13:15:59 -0700316 */
Roshan Pius1f9073c2016-10-10 10:32:22 -0700317 registerEventCallback(IWifiStaIfaceEventCallback callback)
Roshan Piusa52dc732016-10-10 11:53:07 -0700318 generates (WifiStatus status);
Roshan Pius7b777472016-10-07 13:15:59 -0700319
320 /**
321 * Get the capabilities supported by this STA iface.
322 *
Roshan Piusa52dc732016-10-10 11:53:07 -0700323 * @return status WifiStatus of the operation.
Roshan Pius1f9073c2016-10-10 10:32:22 -0700324 * Possible status codes:
Roshan Piusa52dc732016-10-10 11:53:07 -0700325 * |WifiStatusCode.SUCCESS|,
326 * |WifiStatusCode.ERROR_WIFI_IFACE_INVALID|,
327 * |WifiStatusCode.ERROR_NOT_AVAILABLE|,
328 * |WifiStatusCode.ERROR_UNKNOWN|
Roshan Pius7b777472016-10-07 13:15:59 -0700329 * @return capabilities Bitset of |StaIfaceCapabilityMask| values.
330 */
Roshan Piusa52dc732016-10-10 11:53:07 -0700331 getCapabilities() generates (WifiStatus status, uint64_t capabilities);
Roshan Pius7b777472016-10-07 13:15:59 -0700332
333 /**
334 * Used to query additional information about the chip's APF capabilities.
Roshan Pius18680b72016-10-12 08:25:48 -0700335 * Must fail if |StaIfaceCapabilityMask.APF| is not set.
Roshan Pius7b777472016-10-07 13:15:59 -0700336 *
Roshan Piusa52dc732016-10-10 11:53:07 -0700337 * @return status WifiStatus of the operation.
Roshan Pius1f9073c2016-10-10 10:32:22 -0700338 * Possible status codes:
Roshan Piusa52dc732016-10-10 11:53:07 -0700339 * |WifiStatusCode.SUCCESS|,
340 * |WifiStatusCode.ERROR_WIFI_IFACE_INVALID|,
341 * |WifiStatusCode.ERROR_NOT_SUPPORTED|,
342 * |WifiStatusCode.ERROR_NOT_AVAILABLE|,
343 * |WifiStatusCode.ERROR_UNKNOWN|
Roshan Pius7b777472016-10-07 13:15:59 -0700344 * @return capabilities Instance of |ApfPacketFilterCapabilities|.
345 */
346 getApfPacketFilterCapabilities()
Roshan Piusa52dc732016-10-10 11:53:07 -0700347 generates (WifiStatus status, ApfPacketFilterCapabilities capabilities);
Roshan Pius7b777472016-10-07 13:15:59 -0700348
349 /**
350 * Installs an APF program on this iface, replacing an existing
351 * program if present.
Roshan Pius18680b72016-10-12 08:25:48 -0700352 * Must fail if |StaIfaceCapabilityMask.APF| is not set.
Roshan Pius7b777472016-10-07 13:15:59 -0700353 *
354 * @param cmdId command Id to use for this invocation.
Roshan Pius1f9073c2016-10-10 10:32:22 -0700355 * @param APF Program to be set.
Roshan Piusa52dc732016-10-10 11:53:07 -0700356 * @return status WifiStatus of the operation.
Roshan Pius1f9073c2016-10-10 10:32:22 -0700357 * Possible status codes:
Roshan Piusa52dc732016-10-10 11:53:07 -0700358 * |WifiStatusCode.SUCCESS|,
359 * |WifiStatusCode.ERROR_WIFI_IFACE_INVALID|,
360 * |WifiStatusCode.ERROR_INVALID_ARGS|,
361 * |WifiStatusCode.ERROR_NOT_SUPPORTED|,
362 * |WifiStatusCode.ERROR_NOT_AVAILABLE|,
363 * |WifiStatusCode.ERROR_UNKNOWN|
Roshan Pius7b777472016-10-07 13:15:59 -0700364 */
Roshan Pius1f9073c2016-10-10 10:32:22 -0700365 installApfPacketFilter(CommandId cmdId, vec<uint8_t> program)
Roshan Piusa52dc732016-10-10 11:53:07 -0700366 generates (WifiStatus status);
Roshan Pius7b777472016-10-07 13:15:59 -0700367
368 /**
Roshan Pius18680b72016-10-12 08:25:48 -0700369 * Used to query additional information about the chip's Background Scan capabilities.
370 * Must fail if |StaIfaceCapabilityMask.BACKGROUND_SCAN| is not set.
Roshan Pius7b777472016-10-07 13:15:59 -0700371 *
Roshan Piusa52dc732016-10-10 11:53:07 -0700372 * @return status WifiStatus of the operation.
Roshan Pius1f9073c2016-10-10 10:32:22 -0700373 * Possible status codes:
Roshan Piusa52dc732016-10-10 11:53:07 -0700374 * |WifiStatusCode.SUCCESS|,
375 * |WifiStatusCode.ERROR_WIFI_IFACE_INVALID|,
376 * |WifiStatusCode.ERROR_NOT_SUPPORTED|,
377 * |WifiStatusCode.ERROR_NOT_AVAILABLE|,
378 * |WifiStatusCode.ERROR_UNKNOWN|
Roshan Pius7b777472016-10-07 13:15:59 -0700379 * @return capabilities Instance of |BackgroundScanCapabilities|.
380 */
381 getBackgroundScanCapabilities()
Roshan Piusa52dc732016-10-10 11:53:07 -0700382 generates (WifiStatus status, BackgroundScanCapabilities capabilities);
Roshan Pius7b777472016-10-07 13:15:59 -0700383
384 /**
Roshan Pius18680b72016-10-12 08:25:48 -0700385 * Used to query the list of valid frequencies (depending on country code set)
386 * for the provided band. These channels may be specifed in the
387 * |BackgroundScanBucketParameters.frequenciesInMhz| for a background scan
388 * request.
389 * Must fail if |StaIfaceCapabilityMask.BACKGROUND_SCAN| is not set.
390 *
391 * @return status WifiStatus of the operation.
392 * Possible status codes:
393 * |WifiStatusCode.SUCCESS|,
394 * |WifiStatusCode.ERROR_WIFI_IFACE_INVALID|,
395 * |WifiStatusCode.ERROR_NOT_SUPPORTED|,
396 * |WifiStatusCode.ERROR_NOT_AVAILABLE|,
397 * |WifiStatusCode.ERROR_UNKNOWN|
Roshan Pius120f94c2016-10-13 11:48:42 -0700398 * @return frequencies vector of valid frequencies for the provided band.
Roshan Pius18680b72016-10-12 08:25:48 -0700399 */
400 getValidFrequenciesForBackgroundScan(BackgroundScanBand band)
Roshan Pius120f94c2016-10-13 11:48:42 -0700401 generates (WifiStatus status, vec<WifiChannelInMhz> frequencies);
Roshan Pius18680b72016-10-12 08:25:48 -0700402
403 /**
Roshan Pius7b777472016-10-07 13:15:59 -0700404 * Start a background scan using the given cmdId as an identifier. Only one
405 * active background scan need be supported.
Roshan Pius18680b72016-10-12 08:25:48 -0700406 * Must fail if |StaIfaceCapabilityMask.BACKGROUND_SCAN| is not set.
Roshan Pius7b777472016-10-07 13:15:59 -0700407 *
408 * When this is called all requested buckets must be scanned, starting the
409 * beginning of the cycle.
410 *
411 * For example:
412 * If there are two buckets specified
413 * - Bucket 1: period=10s
414 * - Bucket 2: period=20s
415 * - Bucket 3: period=30s
416 * Then the following scans must occur
417 * - t=0 buckets 1, 2, and 3 are scanned
418 * - t=10 bucket 1 is scanned
419 * - t=20 bucket 1 and 2 are scanned
420 * - t=30 bucket 1 and 3 are scanned
421 * - t=40 bucket 1 and 2 are scanned
422 * - t=50 bucket 1 is scanned
423 * - t=60 buckets 1, 2, and 3 are scanned
424 * - and the patter repeats
425 *
426 * If any scan does not occur or is incomplete (error, interrupted, etc) then
427 * a cached scan result must still be recorded with the
428 * WIFI_SCAN_FLAG_INTERRUPTED flag set.
429 *
430 * @param cmdId command Id to use for this invocation.
Roshan Pius1f9073c2016-10-10 10:32:22 -0700431 * @params Background scan parameters.
Roshan Piusa52dc732016-10-10 11:53:07 -0700432 * @return status WifiStatus of the operation.
Roshan Pius1f9073c2016-10-10 10:32:22 -0700433 * Possible status codes:
Roshan Piusa52dc732016-10-10 11:53:07 -0700434 * |WifiStatusCode.ERROR_WIFI_IFACE_INVALID|,
435 * |WifiStatusCode.ERROR_INVALID_ARGS|,
436 * |WifiStatusCode.ERROR_NOT_SUPPORTED|,
437 * |WifiStatusCode.ERROR_NOT_AVAILABLE|,
438 * |WifiStatusCode.ERROR_UNKNOWN|
Roshan Pius7b777472016-10-07 13:15:59 -0700439 */
Roshan Pius1f9073c2016-10-10 10:32:22 -0700440 startBackgroundScan(CommandId cmdId, BackgroundScanParameters params)
Roshan Piusa52dc732016-10-10 11:53:07 -0700441 generates (WifiStatus status);
Roshan Pius7b777472016-10-07 13:15:59 -0700442
443 /**
444 * Stop the background scan started.
Roshan Pius18680b72016-10-12 08:25:48 -0700445 * Must fail if |StaIfaceCapabilityMask.BACKGROUND_SCAN| is not set.
Roshan Pius7b777472016-10-07 13:15:59 -0700446 *
447 * @param cmdId command Id corresponding to the request.
Roshan Piusa52dc732016-10-10 11:53:07 -0700448 * @return status WifiStatus of the operation.
Roshan Pius1f9073c2016-10-10 10:32:22 -0700449 * Possible status codes:
Roshan Piusa52dc732016-10-10 11:53:07 -0700450 * |WifiStatusCode.SUCCESS|,
451 * |WifiStatusCode.ERROR_WIFI_IFACE_INVALID|,
452 * |WifiStatusCode.ERROR_NOT_SUPPORTED|,
453 * |WifiStatusCode.ERROR_NOT_AVAILABLE|,
454 * |WifiStatusCode.ERROR_UNKNOWN|
Roshan Pius7b777472016-10-07 13:15:59 -0700455 */
Roshan Piusa52dc732016-10-10 11:53:07 -0700456 stopBackgroundScan(CommandId cmdId) generates (WifiStatus status);
Roshan Pius18680b72016-10-12 08:25:48 -0700457
458 /**
459 * Enable link layer stats collection.
460 * Must fail if |StaIfaceCapabilityMask.LINK_LAYER_STATS| is not set.
461 *
462 * Radio statistics (once started) must not stop until disabled.
463 * Iface statistics (once started) reset and start afresh after each
464 * connection until disabled.
465 *
466 * @param debug Set for field debug mode. Driver must collect all
467 * statistics regardless of performance impact.
468 * @return status WifiStatus of the operation.
469 * Possible status codes:
470 * |WifiStatusCode.SUCCESS|,
471 * |WifiStatusCode.ERROR_WIFI_IFACE_INVALID|,
472 * |WifiStatusCode.ERROR_NOT_SUPPORTED|,
473 * |WifiStatusCode.ERROR_NOT_AVAILABLE|,
474 * |WifiStatusCode.ERROR_UNKNOWN|
475 */
476 enableLinkLayerStatsCollection(bool debug)
477 generates (WifiStatus status);
478
479 /**
480 * Disable link layer stats collection.
481 * Must fail if |StaIfaceCapabilityMask.LINK_LAYER_STATS| is not set.
482 *
483 * @return status WifiStatus of the operation.
484 * Possible status codes:
485 * |WifiStatusCode.SUCCESS|,
486 * |WifiStatusCode.ERROR_WIFI_IFACE_INVALID|,
487 * |WifiStatusCode.ERROR_NOT_SUPPORTED|,
488 * |WifiStatusCode.ERROR_NOT_AVAILABLE|,
489 * |WifiStatusCode.ERROR_UNKNOWN|
490 */
491 disableLinkLayerStatsCollection() generates (WifiStatus status);
492
493 /**
494 * Retrieve the latest link layer stats.
495 * Must fail if |StaIfaceCapabilityMask.LINK_LAYER_STATS| is not set or if
496 * link layer stats collection hasn't been explicitly enabled.
497 *
498 * @return status WifiStatus of the operation.
499 * Possible status codes:
500 * |WifiStatusCode.SUCCESS|,
501 * |WifiStatusCode.ERROR_WIFI_IFACE_INVALID|,
502 * |WifiStatusCode.ERROR_NOT_SUPPORTED|,
503 * |WifiStatusCode.ERROR_NOT_AVAILABLE|,
504 * |WifiStatusCode.ERROR_UNKNOWN|
505 * @return stats Instance of |LinkLayerStats|.
506 */
507 getLinkLayerStats() generates (WifiStatus status, LinkLayerStats stats);
Roshan Piusadcfba42016-10-05 10:19:06 -0700508};