1/*
2 * Copyright 2019 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.4;
18
19import @1.0::MacAddress;
20import @1.0::NanBandIndex;
21import @1.0::NanBandSpecificConfig;
22import @1.0::Rssi;
23import @1.0::RttBw;
24import @1.0::RttConfig;
25import @1.0::RttPeerType;
26import @1.0::RttPreamble;
27import @1.0::RttStatus;
28import @1.0::RttType;
29import @1.0::TimeSpanInPs;
30import @1.0::TimeStampInUs;
31import @1.0::WifiBand;
32import @1.0::WifiChannelInfo;
33import @1.0::WifiChannelInMhz;
34import @1.0::WifiChannelWidthInMhz;
35import @1.0::WifiInformationElement;
36import @1.0::WifiRateNss;
37import @1.0::WifiRatePreamble;
38
39/**
40 * Wifi bands defined in 80211 spec.
41 */
42enum WifiBand : @1.0::WifiBand {
43    /**
44     * 6 GHz.
45     */
46    BAND_6GHZ = 8,
47    /**
48     * 5 GHz no DFS + 6 GHz.
49     */
50    BAND_5GHZ_6GHZ = 10,
51    /**
52     * 2.4 GHz + 5 GHz no DFS + 6 GHz.
53     */
54    BAND_24GHZ_5GHZ_6GHZ = 11,
55    /**
56     * 2.4 GHz + 5 GHz with DFS + 6 GHz.
57     */
58    BAND_24GHZ_5GHZ_WITH_DFS_6GHZ = 15,
59};
60
61/**
62 * The discovery bands supported by NAN.
63 */
64enum NanBandIndex : @1.0::NanBandIndex {
65    /**
66     * Index for 6 GHz band.
67     */
68    NAN_BAND_6GHZ = 2,
69};
70
71/**
72 * Wifi Rate Preamble
73 */
74enum WifiRatePreamble : @1.0::WifiRatePreamble {
75    /**
76     * Preamble type for 11ax
77     */
78    HE = 5,
79};
80
81/**
82 * RTT Measurement Preamble.
83 */
84enum RttPreamble : @1.0::RttPreamble {
85    /**
86     * Preamble type for 11ax
87     */
88    HE = 0x8,
89};
90
91/**
92 * Debug configuration parameters. Many of these allow non-standard-compliant operation and are
93 * not intended for normal operational mode.
94 */
95struct NanDebugConfig {
96    /**
97     * Specification of the lower 2 bytes of the cluster ID. The cluster ID is 50-60-9a-01-00-00 to
98     * 50-60-9a-01-FF-FF. Configuration of the bottom and top values of the range (which defaults to
99     * 0x0000 and 0xFFFF respectively).
100     * Configuration is only used if |validClusterIdVals| is set to true.
101     */
102    bool validClusterIdVals;
103
104    uint16_t clusterIdBottomRangeVal;
105
106    uint16_t clusterIdTopRangeVal;
107
108    /**
109     * NAN management interface address, if specified (|validIntfAddrVal| is true) then overrides any
110     * other configuration (specifically the default randomization configured by
111     * |NanConfigRequest.macAddressRandomizationIntervalSec|).
112     */
113    bool validIntfAddrVal;
114
115    MacAddress intfAddrVal;
116
117    /**
118     * Combination of the 24 bit Organizationally Unique ID (OUI) and the 8 bit OUI Type.
119     * Used if |validOuiVal| is set to true.
120     */
121    bool validOuiVal;
122
123    uint32_t ouiVal;
124
125    /**
126     * Force the Random Factor to the specified value for all transmitted Sync/Discovery beacons.
127     * Used if |validRandomFactorForceVal| is set to true.
128     * NAN Spec: Master Indication Attribute / Random Factor
129     */
130    bool validRandomFactorForceVal;
131
132    uint8_t randomFactorForceVal;
133
134    /**
135     * Forces the hop-count for all transmitted Sync and Discovery Beacons NO matter the real
136     * hop-count being received over the air. Used if the |validHopCountForceVal}| flag is set to
137     * true.
138     * NAN Spec: Cluster Attribute / Anchor Master Information / Hop Count to Anchor Master
139     */
140    bool validHopCountForceVal;
141
142    uint8_t hopCountForceVal;
143
144    /**
145     * Frequency in MHz to of the discovery channel in the specified band. Indexed by |NanBandIndex|.
146     * Used if the |validDiscoveryChannelVal| is set to true.
147     */
148    bool validDiscoveryChannelVal;
149
150    WifiChannelInMhz[3] discoveryChannelMhzVal;
151
152    /**
153     * Specifies whether sync/discovery beacons are transmitted in the specified band. Indexed by
154     * |NanBandIndex|. Used if the |validUseBeaconsInBandVal| is set to true.
155     */
156    bool validUseBeaconsInBandVal;
157
158    bool[3] useBeaconsInBandVal;
159
160    /**
161     * Specifies whether SDF (service discovery frames) are transmitted in the specified band. Indexed
162     * by |NanBandIndex|. Used if the |validUseSdfInBandVal| is set to true.
163     */
164    bool validUseSdfInBandVal;
165
166    bool[3] useSdfInBandVal;
167};
168
169/**
170 * Configuration parameters of NAN: used when enabling and re-configuring a NAN cluster.
171 */
172struct NanConfigRequest {
173    /**
174     * Master preference of this device.
175     * NAN Spec: Master Indication Attribute / Master Preference
176     */
177    uint8_t masterPref;
178
179    /**
180     * Controls whether or not the |IWifiNanIfaceEventCallback.eventClusterEvent| will be delivered
181     * for |NanClusterEventType.DISCOVERY_MAC_ADDRESS_CHANGED|.
182     */
183    bool disableDiscoveryAddressChangeIndication;
184
185    /**
186     * Controls whether or not the |IWifiNanIfaceEventCallback.eventClusterEvent| will be delivered
187     * for |NanClusterEventType.STARTED_CLUSTER|.
188     */
189    bool disableStartedClusterIndication;
190
191    /**
192     * Controls whether or not the |IWifiNanIfaceEventCallback.eventClusterEvent| will be delivered
193     * for |NanClusterEventType.JOINED_CLUSTER|.
194     */
195    bool disableJoinedClusterIndication;
196
197    /**
198     * Control whether publish service IDs are included in Sync/Discovery beacons.
199     * NAN Spec: Service ID List Attribute
200     */
201    bool includePublishServiceIdsInBeacon;
202
203    /**
204     * If |includePublishServiceIdsInBeacon| is true then specifies the number of publish service IDs
205     * to include in the Sync/Discovery beacons:
206     *  Value = 0: include as many service IDs as will fit into the maximum allowed beacon frame size.
207     *  Value must fit within 7 bits - i.e. <= 127.
208     */
209    uint8_t numberOfPublishServiceIdsInBeacon;
210
211    /**
212     * Control whether subscribe service IDs are included in Sync/Discovery beacons.
213     * Spec: Subscribe Service ID List Attribute
214     */
215    bool includeSubscribeServiceIdsInBeacon;
216
217    /**
218     * If |includeSubscribeServiceIdsInBeacon| is true then specifies the number of subscribe service
219     * IDs to include in the Sync/Discovery beacons:
220     *  Value = 0: include as many service IDs as will fit into the maximum allowed beacon frame size.
221     *  Value must fit within 7 bits - i.e. <= 127.
222     */
223    uint8_t numberOfSubscribeServiceIdsInBeacon;
224
225    /**
226     * Number of samples used to calculate RSSI.
227     */
228    uint16_t rssiWindowSize;
229
230    /**
231     * Specifies the interval in seconds that the NAN management interface MAC address is randomized.
232     * A value of 0 is used to disable the MAC address randomization
233     */
234    uint32_t macAddressRandomizationIntervalSec;
235
236    /**
237     * Additional configuration provided per band: indexed by |NanBandIndex|.
238     */
239    NanBandSpecificConfig[3] bandSpecificConfig;
240};
241
242/**
243 * Enable requests for NAN: start-up configuration |IWifiNanIface.enableRequest|.
244 */
245struct NanEnableRequest {
246    /**
247     * Enable operation in a specific band: indexed by |NanBandIndex|.
248     */
249    bool[3] operateInBand;
250
251    /**
252     * Specify extent of cluster by specifying the max hop count.
253     */
254    uint8_t hopCountMax;
255
256    /**
257     * Configurations of NAN cluster operation. Can also be modified at run-time using
258     * |IWifiNanIface.configRequest|.
259     */
260    NanConfigRequest configParams;
261
262    /**
263     * Non-standard configurations of NAN cluster operation - useful for debugging operations.
264     */
265    NanDebugConfig debugConfigs;
266};
267
268/**
269 * RTT configuration.
270 */
271struct RttConfig {
272    /**
273     * Peer device mac address.
274     */
275    MacAddress addr;
276
277    /**
278     * 1-sided or 2-sided RTT.
279     */
280    RttType type;
281
282    /**
283     * Optional - peer device hint (STA, P2P, AP).
284     */
285    RttPeerType peer;
286
287    /**
288     * Required for STA-AP mode, optional for P2P, NBD etc.
289     */
290    WifiChannelInfo channel;
291
292    /**
293     * Time interval between bursts (units: 100 ms).
294     * Applies to 1-sided and 2-sided RTT multi-burst requests.
295     * Range: 0-31, 0: no preference by initiator (2-sided RTT).
296     */
297    uint32_t burstPeriod;
298
299    /**
300     * Total number of RTT bursts to be executed. It will be
301     * specified in the same way as the parameter "Number of
302     * Burst Exponent" found in the FTM frame format. It
303     * applies to both: 1-sided RTT and 2-sided RTT. Valid
304     * values are 0 to 15 as defined in 802.11mc std.
305     * 0 means single shot
306     * The implication of this parameter on the maximum
307     * number of RTT results is the following:
308     * for 1-sided RTT: max num of RTT results = (2^num_burst)*(num_frames_per_burst)
309     * for 2-sided RTT: max num of RTT results = (2^num_burst)*(num_frames_per_burst - 1)
310     */
311    uint32_t numBurst;
312
313    /**
314     * Num of frames per burst.
315     * Minimum value = 1, Maximum value = 31
316     * For 2-sided this equals the number of FTM frames
317     * to be attempted in a single burst. This also
318     * equals the number of FTM frames that the
319     * initiator will request that the responder send
320     * in a single frame.
321     */
322    uint32_t numFramesPerBurst;
323
324    /**
325     * Number of retries for a failed RTT frame.
326     * Applies to 1-sided RTT only. Minimum value = 0, Maximum value = 3
327     */
328    uint32_t numRetriesPerRttFrame;
329
330    /**
331     * Following fields are only valid for 2-side RTT.
332     *
333     *
334     * Maximum number of retries that the initiator can
335     * retry an FTMR frame.
336     * Minimum value = 0, Maximum value = 3
337     */
338    uint32_t numRetriesPerFtmr;
339
340    /**
341     * Whether to request location civic info or not.
342     */
343    bool mustRequestLci;
344
345    /**
346     * Whether to request location civic records or not.
347     */
348    bool mustRequestLcr;
349
350    /**
351     * Applies to 1-sided and 2-sided RTT. Valid values will
352     * be 2-11 and 15 as specified by the 802.11mc std for
353     * the FTM parameter burst duration. In a multi-burst
354     * request, if responder overrides with larger value,
355     * the initiator will return failure. In a single-burst
356     * request if responder overrides with larger value,
357     * the initiator will sent TMR_STOP to terminate RTT
358     * at the end of the burst_duration it requested.
359     */
360    uint32_t burstDuration;
361
362    /**
363     * RTT preamble to be used in the RTT frames.
364     */
365    RttPreamble preamble;
366
367    /**
368     * RTT BW to be used in the RTT frames.
369     */
370    RttBw bw;
371};
372
373/**
374 * RTT Capabilities.
375 */
376struct RttCapabilities {
377    /**
378     * if 1-sided rtt data collection is supported.
379     */
380    bool rttOneSidedSupported;
381
382    /**
383     * if ftm rtt data collection is supported.
384     */
385    bool rttFtmSupported;
386
387    /**
388     * if initiator supports LCI request. Applies to 2-sided RTT.
389     */
390    bool lciSupported;
391
392    /**
393     * if initiator supports LCR request. Applies to 2-sided RTT.
394     */
395    bool lcrSupported;
396
397    /**
398     * if 11mc responder mode is supported.
399     */
400    bool responderSupported;
401
402    /**
403     * Bit mask indicates what preamble is supported by initiator.
404     * Combination of |RttPreamble| values.
405     */
406    bitfield<RttPreamble> preambleSupport;
407
408    /**
409     * Bit mask indicates what BW is supported by initiator.
410     * Combination of |RttBw| values.
411     */
412    bitfield<RttBw> bwSupport;
413
414    /**
415     * Draft 11mc spec version supported by chip.
416     * For instance, version 4.0 must be 40 and version 4.3 must be 43 etc.
417     */
418    uint8_t mcVersion;
419};
420
421/**
422 * RTT Responder information
423 */
424struct RttResponder {
425    WifiChannelInfo channel;
426
427    RttPreamble preamble;
428};
429
430/**
431 * Wifi rate info.
432 */
433struct WifiRateInfo {
434    /**
435     * Preamble used for RTT measurements.
436     */
437    WifiRatePreamble preamble;
438
439    /**
440     * Number of spatial streams.
441     */
442    WifiRateNss nss;
443
444    /**
445     * Bandwidth of channel.
446     */
447    WifiChannelWidthInMhz bw;
448
449    /**
450     * OFDM/CCK rate code would be as per ieee std in the units of 0.5mbps.
451     * HT/VHT/HE it would be mcs index.
452     */
453    uint8_t rateMcsIdx;
454
455    /**
456     * Bitrate in units of 100 Kbps.
457     */
458    uint32_t bitRateInKbps;
459};
460
461/**
462 * RTT results.
463 */
464struct RttResult {
465    /**
466     * Peer device mac address.
467     */
468    MacAddress addr;
469
470    /**
471     * Burst number in a multi-burst request.
472     */
473    uint32_t burstNum;
474
475    /**
476     * Total RTT measurement frames attempted.
477     */
478    uint32_t measurementNumber;
479
480    /**
481     * Total successful RTT measurement frames.
482     */
483    uint32_t successNumber;
484
485    /**
486     * Maximum number of "FTM frames per burst" supported by
487     * the responder STA. Applies to 2-sided RTT only.
488     * If reponder overrides with larger value:
489     * - for single-burst request initiator will truncate the
490     * larger value and send a TMR_STOP after receiving as
491     * many frames as originally requested.
492     * - for multi-burst request, initiator will return
493     * failure right away.
494     */
495    uint8_t numberPerBurstPeer;
496
497    /**
498     * Ranging status.
499     */
500    RttStatus status;
501
502    /**
503     * When status == RTT_STATUS_FAIL_BUSY_TRY_LATER,
504     * this will be the time provided by the responder as to
505     * when the request can be tried again. Applies to 2-sided
506     * RTT only. In sec, 1-31sec.
507     */
508    uint8_t retryAfterDuration;
509
510    /**
511     * RTT type.
512     */
513    RttType type;
514
515    /**
516     * Average rssi in 0.5 dB steps e.g. 143 implies -71.5 dB.
517     */
518    Rssi rssi;
519
520    /**
521     * Rssi spread in 0.5 dB steps e.g. 5 implies 2.5 dB spread (optional).
522     */
523    Rssi rssiSpread;
524
525    /**
526     * 1-sided RTT: TX rate of RTT frame.
527     * 2-sided RTT: TX rate of initiator's Ack in response to FTM frame.
528     */
529    WifiRateInfo txRate;
530
531    /**
532     * 1-sided RTT: TX rate of Ack from other side.
533     * 2-sided RTT: TX rate of FTM frame coming from responder.
534     */
535    WifiRateInfo rxRate;
536
537    /**
538     * Round trip time in picoseconds
539     */
540    TimeSpanInPs rtt;
541
542    /**
543     * Rtt standard deviation in picoseconds.
544     */
545    TimeSpanInPs rttSd;
546
547    /**
548     * Difference between max and min rtt times recorded in picoseconds.
549     */
550    TimeSpanInPs rttSpread;
551
552    /**
553     * Distance in mm (optional).
554     */
555    int32_t distanceInMm;
556
557    /**
558     * Standard deviation in mm (optional).
559     */
560    int32_t distanceSdInMm;
561
562    /**
563     * Difference between max and min distance recorded in mm (optional).
564     */
565    int32_t distanceSpreadInMm;
566
567    /**
568     * Time of the measurement (in microseconds since boot).
569     */
570    TimeStampInUs timeStampInUs;
571
572    /**
573     * in ms, actual time taken by the FW to finish one burst
574     * measurement. Applies to 1-sided and 2-sided RTT.
575     */
576    uint32_t burstDurationInMs;
577
578    /**
579     * Number of bursts allowed by the responder. Applies
580     * to 2-sided RTT only.
581     */
582    uint32_t negotiatedBurstNum;
583
584    /**
585     * for 11mc only.
586     */
587    WifiInformationElement lci;
588
589    /**
590     * for 11mc only.
591     */
592    WifiInformationElement lcr;
593};
594