OSDN Git Service

wifi: Few minor interface changes am: 8c0c8e9aa0 am: 90cc1c0869
[android-x86/hardware-interfaces.git] / wifi / 1.0 / types.hal
1 /*
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
17 package android.hardware.wifi@1.0;
18
19 /**
20  * Enum values indicating the status of operation.
21  */
22 enum WifiStatusCode : uint32_t {
23   /** No errors. */
24   SUCCESS,
25   /** Method invoked on an invalid |IWifiChip| object. */
26   ERROR_WIFI_CHIP_INVALID,
27   /** Method invoked on an invalid |IWifiIface| object. */
28   ERROR_WIFI_IFACE_INVALID,
29   /** Method invoked on an invalid |IWifiRttController| object. */
30   ERROR_WIFI_RTT_CONTROLLER_INVALID,
31   ERROR_NOT_SUPPORTED,
32   ERROR_NOT_AVAILABLE,
33   ERROR_NOT_STARTED,
34   ERROR_INVALID_ARGS,
35   ERROR_BUSY,
36   ERROR_UNKNOWN
37 };
38
39 /**
40  * Generic structure to return the status of an operation.
41  */
42 struct WifiStatus {
43   WifiStatusCode code;
44   /**
45    * A vendor specific error message from the vendor to provide more
46    * information beyond the reason code.
47    */
48   string description;
49 };
50
51 /**
52  * List of Iface types supported.
53  */
54 enum IfaceType : uint32_t {
55   STA,
56   AP,
57   P2P,
58   /**
59    * NAN control interface. Datapath support must be queried and created
60    * through this interface.
61    */
62   NAN,
63 };
64
65 /**
66  * An identifier assigned to every chip on the device.
67  */
68 typedef uint32_t ChipId;
69
70 /**
71  * An identifier for a mode that the chip can be put in.
72  */
73 typedef uint32_t ChipModeId;
74
75 /**
76  * A unique handle provided by the client to identify individual invocations of
77  * certain API's like |IWifiStaIface.startBackgroundScan|,
78  * |IWifiStaIface.installApfPacketFilter|, etc.
79  */
80 typedef uint32_t CommandId;
81
82 /**
83  * Channel frequency in Mhz.
84  */
85 typedef uint32_t WifiChannelInMhz;
86
87 /**
88  * Channel operating width in Mhz.
89  */
90 enum WifiChannelWidthInMhz : uint32_t {
91   WIDTH_20    = 0,
92   WIDTH_40    = 1,
93   WIDTH_80    = 2,
94   WIDTH_160   = 3,
95   WIDTH_80P80 = 4,
96   WIDTH_5     = 5,
97   WIDTH_10    = 6,
98   WIDTH_INVALID = -1
99 };
100
101 /**
102  * Channel information.
103  */
104 struct WifiChannelInfo {
105   /**
106    * Channel width (20, 40, 80, 80+80, 160).
107    */
108   WifiChannelWidthInMhz width;
109   /**
110    * Primary 20 MHz channel.
111    */
112   WifiChannelInMhz centerFreq;
113   /**
114    * Center frequency (MHz) first segment.
115    */
116   WifiChannelInMhz centerFreq0;
117   /**
118    * Center frequency (MHz) second segment.
119    */
120   WifiChannelInMhz centerFreq1;
121 };
122
123 /**
124  * RSSI information.
125  */
126 typedef int32_t Rssi;
127
128 /**
129  * Mac Address type. 6 octets representing physical address of a device.
130  */
131 typedef uint8_t[6] MacAddress;
132
133 /**
134  * SSID type. 32 octets representing the network.
135  */
136 typedef uint8_t[32] Ssid;
137
138 /**
139  * BSSID type. 6 octets representing the physical address of an AP.
140  */
141 typedef MacAddress Bssid;
142
143 /**
144  * TimeStamp in milliseconds (ms).
145  */
146 typedef uint32_t TimeStampInMs;
147
148 /**
149  * TimeStamp in microseconds (us).
150  */
151 typedef uint64_t TimeStampInUs;
152
153 /**
154  * TimeStamp in picoseconds (ps).
155  */
156 typedef uint64_t TimeSpanInPs;
157
158 /**
159  * Information elements contained within the |ScanResult| structure.
160  * These elements correspond to the IEEE_802.11 standard.
161  */
162 struct WifiInformationElement {
163   uint8_t id;
164   vec<uint8_t> data;
165 };
166
167 enum WifiRatePreamble : uint32_t {
168   OFDM = 0,
169   CCK = 1,
170   HT = 2,
171   VHT = 3,
172   RESERVED = 4
173 };
174
175 /**
176  * Number of spatial streams in VHT/HT.
177  */
178 enum WifiRateNss : uint32_t {
179   NSS_1x1 = 0,
180   NSS_2x2 = 1,
181   NSS_3x3 = 2,
182   NSS_4x4 = 3
183 };
184
185 /**
186  * Wifi rate info.
187  */
188 struct WifiRateInfo {
189   /**
190    * Preamble used for RTT measurements.
191    */
192   WifiRatePreamble preamble;
193   /**
194    * Number of spatial streams.
195    */
196   WifiRateNss nss;
197   /**
198    * Bandwidth of channel.
199    */
200   WifiChannelWidthInMhz bw;
201   /**
202    * OFDM/CCK rate code would be as per ieee std in the units of 0.5mbps.
203    * HT/VHT it would be mcs index.
204    */
205   uint8_t rateMcsIdx;
206   /**
207    * Bitrate in units of 100 Kbps.
208    */
209   uint32_t bitRateInKbps;
210 };
211
212 /**
213  * Wifi bands defined in 80211 spec.
214  */
215 enum WifiBand : uint32_t {
216   BAND_UNSPECIFIED = 0,
217   /**
218    * 2.4 GHz.
219    */
220   BAND_24GHZ = 1,
221   /**
222    * 5 GHz without DFS.
223    */
224   BAND_5GHZ = 2,
225   /**
226    * 5 GHz DFS only.
227    */
228   BAND_5GHZ_DFS = 4,
229   /**
230    * 5 GHz with DFS.
231    */
232   BAND_5GHZ_WITH_DFS = 6,
233   /**
234    * 2.4 GHz + 5 GHz; no DFS.
235    */
236   BAND_24GHZ_5GHZ = 3,
237   /**
238    * 2.4 GHz + 5 GHz with DFS
239    */
240   BAND_24GHZ_5GHZ_WITH_DFS = 7
241 };
242
243 /**
244  * STA specific types.
245  * TODO(b/32159498): Move to a separate sta_types.hal.
246  */
247 /**
248  * Parameters to specify the APF capabilities of this iface.
249  */
250 struct StaApfPacketFilterCapabilities {
251   /**
252    * Version of the packet filter interpreter supported
253    */
254   uint32_t version;
255   /**
256    * Maximum size of the filter bytecodes in byte for an iface.
257    */
258   uint32_t maxLength;
259 };
260
261 /**
262  * Parameters to specify the Background Scan capabilities of this iface.
263  */
264 struct StaBackgroundScanCapabilities {
265   /**
266    * Maximum number of byte available for cached scan results
267    */
268   uint32_t maxCacheSize;
269   /**
270    * Maximum number of buckets that can be supplied for a scan
271    */
272   uint32_t maxBuckets;
273   /**
274    * Maximum number of APs that must be stored for each scan.
275    */
276   uint32_t maxApCachePerScan;
277   /**
278    * Max reporting number of scans threshold that can be specified in the scan
279    * parameters.
280    */
281   int32_t maxReportingThreshold;
282 };
283
284 /**
285  * Mask of event reporting schemes that can be specified in background scan
286  * requests.
287  */
288 enum StaBackgroundScanBucketEventReportSchemeMask : uint32_t {
289   /**
290    * Report a scan completion event after scan. If this is not set then scan
291    * completion events must be reported if report_threshold_percent or
292    * report_threshold_num_scans is reached.
293    */
294   EACH_SCAN = 1 << 0,
295   /**
296    * Forward scan results (beacons/probe responses + IEs) in real time to HAL,
297    * in addition to completion events.
298    * Note: To keep backward compatibility, fire completion events regardless
299    * of REPORT_EVENTS_EACH_SCAN.
300    */
301   FULL_RESULTS = 1 << 1,
302   /**
303    * Controls if scans for this bucket must be placed in the results buffer.
304    */
305   NO_BATCH = 1 << 2,
306 };
307
308 /**
309  * Max limits for background scan.
310  */
311 enum StaScanLimits : uint32_t {
312   MAX_CHANNELS = 16,
313   MAX_BUCKETS = 16,
314   MAX_AP_CACHE_PER_SCAN = 32
315 };
316
317 /**
318  * Background Scan parameters per bucket that can be specified in background
319  * scan requests.
320  */
321 struct StaBackgroundScanBucketParameters {
322   /**
323    * Bands to scan or |BAND_UNSPECIFIED| if frequencies list must be used
324    * instead.
325    */
326   WifiBand band;
327   /**
328    * Channel frequencies (in Mhz) to scan if |band| is set to
329    * |BAND_UNSPECIFIED|.
330    * Max length: |StaScanLimits.MAX_CHANNELS|.
331    */
332   vec<WifiChannelInMhz> frequencies;
333   /**
334    * Period at which this bucket must be scanned (in milliseconds). Must be an integer
335    * multiple of the |basePeriodInMs| specified in the BackgroundScanParameters.
336    */
337   uint32_t periodInMs;
338   /**
339    * Bitset of |StaBackgroundScanBucketEventReportSchemeMask| values controlling
340    * when events for this bucket must be reported.
341    */
342   bitfield<StaBackgroundScanBucketEventReportSchemeMask> eventReportScheme;
343   /**
344    * For exponential back off. If |exponentialMaxPeriodInMs| is non zero or
345    * different than period, then this bucket is an exponential backoff bucket
346    * and the scan period must grow exponentially as per formula:
347    *   actual_period(N) = period * (base ^ (N/step_count))
348    * to this maximum period (in milliseconds).
349    */
350   uint32_t exponentialMaxPeriodInMs;
351   /**
352    * For exponential back off. multiplier: new_period=old_period * base
353    */
354   uint32_t exponentialBase;
355   /**
356    * For exponential back off. Number of scans to perform for a given
357    * period.
358    */
359   uint32_t exponentialStepCount;
360 };
361
362 /**
363  * Background Scan parameters that can be specified in background scan
364  * requests.
365  */
366 struct StaBackgroundScanParameters {
367   /**
368    * GCD of all bucket periods (in milliseconds).
369    */
370   uint32_t basePeriodInMs;
371   /**
372    * Maximum number of APs that must be stored for each scan. If the maximum
373    * is reached the highest RSSI results must be returned.
374    * Max length: |StaScanLimits.MAX_AP_CACHE_PER_SCAN|.
375    */
376   uint32_t maxApPerScan;
377   /**
378    * % cache buffer filled threshold at which the host must be notified of
379    * batched scan results.
380    */
381   uint32_t reportThresholdPercent;
382   /**
383    * Threshold at which the AP must be woken up, in number of scans.
384    */
385   uint32_t reportThresholdNumScans;
386   /**
387    * List of buckets to be scheduled.
388    * Max length: |StaScanLimits.MAX_BUCKETS|.
389    */
390   vec<StaBackgroundScanBucketParameters> buckets;
391 };
392
393 /**
394  * Packet stats for different traffic categories.
395  */
396 struct StaLinkLayerIfacePacketStats {
397   /**
398    * Number of received unicast data packets.
399    */
400   uint64_t rxMpdu;
401   /**
402    * Number of successfully transmitted unicast data pkts (ACK rcvd).
403    */
404   uint64_t txMpdu;
405   /**
406    * Number of transmitted unicast data pkt losses (no ACK).
407    */
408   uint64_t lostMpdu;
409   /**
410    * Number of transmitted unicast data retry pkts.
411    */
412   uint64_t retries;
413 };
414
415 /**
416  * Iface statistics for the current connection.
417  */
418 struct StaLinkLayerIfaceStats {
419   /**
420    * Number beacons received from the connected AP.
421    */
422   uint32_t beaconRx;
423   /**
424    * Access Point Beacon and Management frames RSSI (averaged).
425    */
426   int32_t avgRssiMgmt;
427   /**
428    * WME Best Effort Access Category packet counters.
429    */
430   StaLinkLayerIfacePacketStats wmeBePktStats;
431   /**
432    * WME Background Access Category packet counters.
433    */
434   StaLinkLayerIfacePacketStats wmeBkPktStats;
435   /**
436    * WME Video Access Category packet counters.
437    */
438   StaLinkLayerIfacePacketStats wmeViPktStats;
439   /**
440    * WME Voice Access Category packet counters.
441    */
442   StaLinkLayerIfacePacketStats wmeVoPktStats;
443 };
444
445 /**
446  * Cumulative radio statistics since collection was enabled.
447  */
448 struct StaLinkLayerRadioStats {
449   /**
450    * Time for which the radio is awake.
451    */
452   uint32_t onTimeInMs;
453   /**
454    * Total time for which the radio is in active transmission.
455    */
456   uint32_t txTimeInMs;
457   /**
458    * Time for which the radio is in active tranmission per tx level.
459    */
460   vec<uint32_t> txTimeInMsPerLevel;
461   /**
462    * Time for which the radio is in active receive.
463    */
464   uint32_t rxTimeInMs;
465   /**
466    *  Total time for which the radio is awake due to scan.
467    */
468   uint32_t onTimeInMsForScan;
469 };
470
471 /**
472  * Link layer stats retrieved via |getLinkLayerStats|.
473  */
474 struct StaLinkLayerStats {
475   StaLinkLayerIfaceStats iface;
476   StaLinkLayerRadioStats radio;
477   /**
478    * TimeStamp for each stats sample.
479    * This is the absolute milliseconds from boot when these stats were
480    * sampled.
481    */
482   TimeStampInMs timeStampInMs;
483 };
484
485 /**
486  * Structure describing all the information about a single access point seen
487  * during the scan.
488  */
489 struct StaScanResult {
490   TimeStampInUs timeStampInUs;
491   vec<uint8_t> ssid;
492   Bssid bssid;
493   Rssi rssi;
494   WifiChannelInMhz frequency;
495   uint16_t beaconPeriodInMs;
496   uint16_t capability;
497   vec<WifiInformationElement> informationElements;
498 };
499
500 /**
501  * Mask of flags set in the |ScanData| instance.
502  */
503 enum StaScanDataFlagMask : int32_t {
504   /**
505    * Indicates that a scan was interrupted/did not occur so results may be
506    * incomplete.
507    */
508   INTERRUPTED = 1 << 0,
509 };
510
511 /**
512  * Structure describing all the information about all the access points seen during
513  * the scan.
514  */
515 struct StaScanData {
516   /**
517    * Bitset containing |ScanDataFlagMask| values.
518    */
519   bitfield<StaScanDataFlagMask> flags;
520   /**
521    * Bitset where each bit indicates if the bucket with that index (starting at
522    * 0) was scanned.
523    */
524   uint32_t bucketsScanned;
525   /**
526    * List of scan results.
527    */
528   vec<StaScanResult> results;
529 };
530
531 /**
532  * Structure describing the roaming control capabilities supported.
533  */
534 struct StaRoamingCapabilities {
535   /**
536    * Maximum number of BSSID's that may be blacklisted.
537    */
538   uint32_t maxBlacklistSize;
539   /**
540    * Maximum number of SSID's that may be whitelisted.
541    */
542   uint32_t maxWhitelistSize;
543 };
544
545 /**
546  * Structure describing the roaming control configuration.
547  */
548 struct StaRoamingConfig {
549   /**
550    * List of BSSID's that are blacklisted for roaming.
551    */
552   vec<Bssid> bssidBlacklist;
553   /**
554    * List of SSID's that are whitelisted for roaming.
555    */
556   vec<Ssid> ssidWhitelist;
557 };
558
559 /**
560  * Enum describing the various states to set the roaming
561  * control to.
562  */
563 enum StaRoamingState : uint8_t {
564   /**
565    * Driver/Firmware must not perform any roaming.
566    */
567   DISABLED = 0,
568   /**
569    * Driver/Firmware is allowed to perform roaming respecting
570    * the |StaRoamingConfig| parameters set using |configureRoaming|.
571    */
572   ENABLED = 1
573 };
574
575 /**
576  * NAN specific types.
577  * TODO(b/32159498): Move to a separate nan_types.hal.
578  *
579  * References to "NAN Spec" are to the Wi-Fi Alliance "Wi-Fi Neighbor Awareness
580  * Networking (NAN) Technical Specification".
581  */
582
583 /**
584  * A unique short handle provided by the client to identify individual invocations of
585  * certain API's like |IWifiNanIface.*|.
586  */
587 typedef uint16_t CommandIdShort;
588
589 /**
590  * NAN API response codes used in request notifications and events.
591  */
592 enum NanStatusType : uint32_t {
593   SUCCESS = 0,
594   /* NAN Discovery Engine/Host driver failures */
595   INTERNAL_FAILURE = 1,
596   /* NAN OTA failures */
597   PROTOCOL_FAILURE = 2,
598   /* The publish/subscribe discovery session id is invalid */
599   INVALID_SESSION_ID = 3,
600   /* Out of resources to fufill request */
601   NO_RESOURCES_AVAILABLE = 4,
602   /* Invalid arguments passed */
603   INVALID_ARGS = 5,
604   /* Invalid peer id */
605   INVALID_PEER_ID = 6,
606   /* Invalid NAN data-path (ndp) id */
607   INVALID_NDP_ID = 7,
608   /* Attempting to enable NAN when not available, e.g. wifi is disabled */
609   NAN_NOT_ALLOWED = 8,
610   /* Over the air ACK not received */
611   NO_OTA_ACK = 9,
612   /* Attempting to enable NAN when already enabled */
613   ALREADY_ENABLED = 10,
614   /* Can't queue tx followup message foor transmission */
615   FOLLOWUP_TX_QUEUE_FULL = 11,
616   /* Unsupported concurrency of NAN and another feature - NAN disabled */
617   UNSUPPORTED_CONCURRENCY_NAN_DISABLED = 12
618 };
619
620 /**
621  * The discovery bands supported by NAN.
622  */
623 enum NanBandIndex : uint32_t {
624   NAN_BAND_24GHZ = 0,
625   NAN_BAND_5GHZ
626 };
627
628 /**
629  * The status information returned in NAN notifications.
630  */
631 struct WifiNanStatus {
632   /**
633    * Status of the command request.
634    */
635   NanStatusType status;
636   /**
637    * Further description of the issue causing a failure.
638    */
639   string description;
640 };
641
642 /**
643  * NAN Match indication type: control how often to trigger |IWifiNanIfaceEventCallback.eventMatch|
644  * for a single discovery session - i.e. continuously discovering the same publisher with no new
645  * data.
646  */
647 enum NanMatchAlg : uint32_t {
648   MATCH_ONCE = 0,   // Only trigger |IWifiNanIfaceEventCallback.eventMatch| once
649   MATCH_CONTINUOUS, // Trigger |IWifiNanIfaceEventCallback.eventMatch| every time
650   MATCH_NEVER,      // Never trigger |IWifiNanIfaceEventCallback.eventMatch|
651 };
652
653 /**
654  * NAN publish discovery session types.
655  */
656 enum NanPublishType : uint32_t {
657   UNSOLICITED = 0,       // Publish session broadcasts discovery packets
658   SOLICITED,             // Publish session silent, responds to active subscribes queries
659   UNSOLICITED_SOLICITED, // Both
660 };
661
662 /**
663  * NAN transmit type used in |NanPublishType.SOLICITED| or |NanPublishType.UNSOLICITED_SOLICITED|
664  * publish discovery sessions. Describes the addressing of the packet responding to an ACTIVE
665  * subscribe query.
666  */
667 enum NanTxType : uint32_t {
668   BROADCAST = 0, // Respond with a broadcast packet
669   UNICAST,       // Respond with a unicast packet
670 };
671
672 /**
673  * NAN subscribe discovery session types.
674  */
675 enum NanSubscribeType : uint32_t {
676   PASSIVE = 0, // Subscribe session scans for |NanPublishType.UNSOLICITED| publish sessions.
677   ACTIVE,      // Subscribe session probes for |NanPublishType.SOLICITED| publish sessions.
678 };
679
680 /**
681  * NAN Service Response Filter Attribute Bit.
682  */
683 enum NanSrfType : uint32_t {
684   BLOOM_FILTER = 0, // Use a Bloom filter.
685   PARTIAL_MAC_ADDR, // Use a list of MAC addresses.
686 };
687
688 /**
689  * NAN DP (data-path) channel config options.
690  */
691 enum NanDataPathChannelCfg : uint32_t {
692   CHANNEL_NOT_REQUESTED = 0, // No channel request is specified.
693   REQUEST_CHANNEL_SETUP,     // Channel request is specified - but may be overridden by firmware.
694   FORCE_CHANNEL_SETUP,       // Channel request is specified and must be respected. If the firmware
695                              // cannot honor the request then the data-path request is rejected.
696 };
697
698 /**
699  * NAN band-specific configuration.
700  */
701 struct NanBandSpecificConfig {
702   /**
703    * RSSI values controlling clustering behavior per spec. RSSI values are specified without a sign,
704    * e.g. a value of -65dBm would be specified as 65.
705    */
706   uint8_t rssiClose;  // NAN Spec: RSSI_close
707   uint8_t rssiMiddle; // NAN Spec: RSSI_middle
708   /**
709    * RSSI value determining whether discovery is near (used if enabled in discovery by
710    * |NanDiscoveryCommonConfig.useRssiThreshold|).
711    * RSSI values are specified without a sign, e.g. a value of -65dBm would be specified as 65.
712    * NAN Spec: RSSI_close_proximity
713    */
714   uint8_t rssiCloseProximity;
715   /**
716    * Dwell time of each discovery channel in milliseconds. If set to 0 then the firmware determines
717    * the dwell time to use.
718    */
719   uint8_t dwellTimeMs;
720   /**
721    * Scan period of each discovery channel in seconds. If set to 0 then the firmware determines
722    * the scan period to use.
723    */
724   uint16_t scanPeriodSec;
725    /**
726     * Specifies the discovery window interval for Sync beacons and SDF's.
727     * Valid values of DW Interval are: 1, 2, 3, 4 and 5 corresponding to 1, 2, 4, 8, and 16 DWs.
728     * Value of 0:
729     *  - reserved in 2.4GHz band
730     *  - no wakeup at all in 5GHz band
731     * The publish/subscribe period values don't override this device level configurations if
732     * it is specified.
733     * Configuration is only used only if |validDiscoveryWindowIntervalVal| is set to true.
734     * NAN Spec: Device Capability Attribute / 2.4 GHz DW, Device Capability Attribute / 5 GHz DW
735     */
736   bool validDiscoveryWindowIntervalVal;
737   uint8_t discoveryWindowIntervalVal;
738 };
739
740 /**
741  * Debug configuration parameters. Many of these allow non-standard-compliant operation and are
742  * not intended for normal operational mode.
743  */
744 struct NanDebugConfig {
745   /**
746    * Specification of the lower 2 bytes of the cluster ID. The cluster ID is 50-60-9a-01-00-00 to
747    * 50-60-9a-01-FF-FF. Configuration of the bottom and top values of the range (which defaults to
748    * 0x0000 and 0xFFFF respectively).
749    * Configuration is only used if |validClusterIdVals| is set to true.
750    */
751   bool validClusterIdVals;
752   uint16_t clusterIdBottomRangeVal;
753   uint16_t clusterIdTopRangeVal;
754   /**
755    * NAN management interface address, if specified (|validIntfAddrVal| is true) then overrides any
756    * other configuration (specifically the default randomization configured by
757    * |NanConfigRequest.macAddressRandomizationIntervalSec|).
758    */
759   bool validIntfAddrVal;
760   MacAddress intfAddrVal;
761   /**
762    * Combination of the 24 bit Organizationally Unique ID (OUI) and the 8 bit OUI Type.
763    * Used if |validOuiVal| is set to true.
764    */
765   bool validOuiVal;
766   uint32_t ouiVal;
767   /**
768    * Force the Random Factor to the specified value for all transmitted Sync/Discovery beacons.
769    * Used if |validRandomFactorForceVal| is set to true.
770    * NAN Spec: Master Indication Attribute / Random Factor
771    */
772   bool validRandomFactorForceVal;
773   uint8_t randomFactorForceVal;
774   /**
775    * Forces the hop-count for all transmitted Sync and Discovery Beacons NO matter the real
776    * hop-count being received over the air. Used if the |validHopCountForceVal}| flag is set to
777    * true.
778    * NAN Spec: Cluster Attribute / Anchor Master Information / Hop Count to Anchor Master
779    */
780   bool validHopCountForceVal;
781   uint8_t hopCountForceVal;
782   /**
783    * Frequency in MHz to of the discovery channel in the specified band. Indexed by |NanBandIndex|.
784    * Used if the |validDiscoveryChannelVal| is set to true.
785    */
786   bool validDiscoveryChannelVal;
787   WifiChannelInMhz[2] discoveryChannelMhzVal;
788   /**
789    * Specifies whether sync/discovery beacons are transmitted in the specified band. Indexed by
790    * |NanBandIndex|. Used if the |validUseBeaconsInBandVal| is set to true.
791    */
792   bool validUseBeaconsInBandVal;
793   bool[2] useBeaconsInBandVal;
794   /**
795    * Specifies whether SDF (service discovery frames) are transmitted in the specified band. Indexed
796    * by |NanBandIndex|. Used if the |validUseSdfInBandVal| is set to true.
797    */
798   bool validUseSdfInBandVal;
799   bool[2] useSdfInBandVal;
800 };
801
802 /**
803  * Configuration parameters of NAN: used when enabling and re-configuring a NAN cluster.
804  */
805 struct NanConfigRequest {
806   /**
807    * Master preference of this device.
808    * NAN Spec: Master Indication Attribute / Master Preference
809    */
810   uint8_t masterPref;
811   /**
812    * Controls whether or not the |IWifiNanIfaceEventCallback.eventClusterEvent| will be delivered
813    * for |NanClusterEventType.DISCOVERY_MAC_ADDRESS_CHANGED|.
814    */
815   bool disableDiscoveryAddressChangeIndication;
816   /**
817    * Controls whether or not the |IWifiNanIfaceEventCallback.eventClusterEvent| will be delivered
818    * for |NanClusterEventType.STARTED_CLUSTER|.
819    */
820   bool disableStartedClusterIndication;
821   /**
822    * Controls whether or not the |IWifiNanIfaceEventCallback.eventClusterEvent| will be delivered
823    * for |NanClusterEventType.JOINED_CLUSTER|.
824    */
825   bool disableJoinedClusterIndication;
826   /**
827    * Control whether publish service IDs are included in Sync/Discovery beacons.
828    * NAN Spec: Service ID List Attribute
829    */
830   bool includePublishServiceIdsInBeacon;
831   /**
832    * If |includePublishServiceIdsInBeacon| is true then specifies the number of publish service IDs
833    * to include in the Sync/Discovery beacons:
834    *  Value = 0: include as many service IDs as will fit into the maximum allowed beacon frame size.
835    *  Value must fit within 7 bits - i.e. <= 127.
836    */
837   uint8_t numberOfPublishServiceIdsInBeacon;
838   /**
839    * Control whether subscribe service IDs are included in Sync/Discovery beacons.
840    * Spec: Subscribe Service ID List Attribute
841    */
842   bool includeSubscribeServiceIdsInBeacon;
843   /**
844    * If |includeSubscribeServiceIdsInBeacon| is true then specifies the number of subscribe service
845    * IDs to include in the Sync/Discovery beacons:
846    *  Value = 0: include as many service IDs as will fit into the maximum allowed beacon frame size.
847    *  Value must fit within 7 bits - i.e. <= 127.
848    */
849   uint8_t numberOfSubscribeServiceIdsInBeacon;
850   /**
851    * Number of samples used to calculate RSSI.
852    */
853   uint16_t rssiWindowSize;
854   /**
855    * Specifies the interval in seconds that the NAN management interface MAC address is randomized.
856    * A value of 0 is used to disable the MAC address randomization
857    */
858   uint32_t macAddressRandomizationIntervalSec;
859   /**
860    * Additional configuration provided per band: indexed by |NanBandIndex|.
861    */
862   NanBandSpecificConfig[2] bandSpecificConfig;
863 };
864
865 /**
866  * Enable requests for NAN: start-up configuration |IWifiNanIface.enableRequest|.
867  */
868 struct NanEnableRequest {
869   /**
870    * Enable operation in a specific band: indexed by |NanBandIndex|.
871    */
872   bool[2] operateInBand;
873   /**
874    * Specify extent of cluster by specifying the max hop count.
875    */
876   uint8_t hopCountMax;
877   /**
878    * Configurations of NAN cluster operation. Can also be modified at run-time using
879    * |IWifiNanIface.configRequest|.
880    */
881   NanConfigRequest configParams;
882   /**
883    * Non-standard configurations of NAN cluster operation - useful for debugging operations.
884    */
885   NanDebugConfig debugConfigs;
886 };
887
888 /**
889  * Cipher suite flags.
890  */
891 enum NanCipherSuiteType : uint32_t {
892   NONE = 0, // No (open) security
893   SHARED_KEY_128_MASK = 1 << 0, // NCS-SK-128
894   SHARED_KEY_256_MASK = 1 << 1  // NCS-SK-256
895 };
896
897 /**
898  * Ranging in the context of discovery sessions indication controls. Controls the frequency of
899  * ranging-driven |IWifiNanIfaceEventCallback.eventMatch|.
900  */
901 enum NanRangingIndication : uint32_t {
902   CONTINUOUS_INDICATION_MASK = 1 << 0, // trigger event on every RTT measurement
903   INGRESS_MET_MASK = 1 << 1,           // trigger event only when ingress conditions met
904   EGRESS_MET_MASK = 1 << 2             // trigger event only when egress conditions met
905 };
906
907 /**
908  * Configurations of NAN discovery sessions: common to publish and subscribe discovery.
909  */
910 struct NanDiscoveryCommonConfig {
911   /**
912    * The ID of the discovery session being configured. A value of 0 specifies a request to create
913    * a new discovery session. The new discovery session ID is returned with
914    * |IWifiNanIfaceEventCallback.notifyStartPublishResponse| or
915    * |IWifiNanIfaceEventCallback.notifyStartSubscribeResponse|.
916    * NAN Spec: Service Descriptor Attribute (SDA) / Instance ID
917    */
918   uint8_t sessionId;
919   /**
920    * The lifetime of the discovery session in seconds. A value of 0 means run forever or until
921    * canceled using |IWifiIface.stopPublishRequest| or |IWifiIface.stopSubscribeRequest|.
922    */
923   uint16_t ttlSec;
924   /**
925    * Indicates the interval between two Discovery Windows in which the device supporting the
926    * service is awake to transmit or receive the Service Discovery frames. Valid values of Awake
927    * DW Interval are: 1, 2, 4, 8 and 16. A value of 0 will default to 1. Does not override
928    * |NanBandSpecificConfig.discoveryWindowIntervalVal| configurations if those are specified.
929    */
930   uint16_t discoveryWindowPeriod;
931   /**
932    * The lifetime of the discovery session in number of transmitted SDF discovery packets. A value
933    * of 0 means forever or until canceled using |IWifiIface.stopPublishRequest| or
934    * |IWifiIface.stopSubscribeRequest|.
935    */
936   uint8_t discoveryCount;
937   /**
938    * UTF-8 encoded string identifying the service.
939    * Max length: |NanCapabilities.maxServiceNameLen|.
940    * NAN Spec: The only acceptable single-byte UTF-8 symbols for a Service Name are alphanumeric
941    * values (A-Z, a-z, 0-9), the hyphen ('-'), and the period ('.'). All valid multi-byte UTF-8
942    * characters are acceptable in a Service Name.
943    */
944   vec<uint8_t> serviceName;
945   /**
946    * Specifies how often to trigger |IWifiNanIfaceEventCallback.eventMatch| when continuously
947    * discovering the same discovery session (with no changes).
948    */
949   NanMatchAlg discoveryMatchIndicator;
950   /**
951    * Arbitrary information communicated in discovery packets - there is no semantic meaning to these
952    * bytes. They are passed-through from publisher to subscriber as-is with no parsing.
953    * Max length: |NanCapabilities.maxServiceSpecificInfoLen|.
954    * NAN Spec: Service Descriptor Attribute (SDA) / Service Info
955    */
956   vec<uint8_t> serviceSpecificInfo;
957   /**
958    * Arbitrary information communicated in discovery packets - there is no semantic meaning to these
959    * bytes. They are passed-through from publisher to subscriber as-is with no parsing.
960    * Max length: |NanCapabilities.maxExtendedServiceSpecificInfoLen|.
961    * Spec: Service Descriptor Extension Attribute (SDEA) / Service Info
962    */
963   vec<uint8_t> extendedServiceSpecificInfo;
964   /**
965    * Ordered sequence of <length, value> pairs (|length| uses 1 byte and contains the number of
966    * bytes in the |value| field) which specify further match criteria (beyond the service name).
967    * The match behavior is specified in details in the NAN spec.
968    * Publisher: used in SOLICITED or SOLICITED_UNSOLICITED sessions.
969    * Subscriber: used in ACTIVE or PASSIVE sessions.
970    * Max length: |NanCapabilities.maxMatchFilterLen|.
971    * NAN Spec: matching_filter_rx
972    */
973   vec<uint8_t> rxMatchFilter;
974   /**
975    * Ordered sequence of <length, value> pairs (|length| uses 1 byte and contains the number of
976    * bytes in the |value| field) which specify further match criteria (beyond the service name).
977    * The match behavior is specified in details in the NAN spec.
978    * Publisher: used if provided.
979    * Subscriber: used (if provided) only in ACTIVE sessions.
980    * Max length: |NanCapabilities.maxMatchFilterLen|.
981    * NAN Spec: matching_filter_tx and Service Descriptor Attribute (SDA) / Matching Filter
982    */
983   vec<uint8_t> txMatchFilter;
984   /**
985    * Specifies whether or not the discovery session uses the
986    * |NanBandSpecificConfig.rssiCloseProximity| value (configured in enable/configure requests) to
987    * filter out matched discovered peers.
988    * NAN Spec: Service Descriptor Attribute / Service Control / Discovery Range Limited.
989    */
990   bool useRssiThreshold;
991   /**
992    * Controls whether or not the |IWifiNanIfaceEventCallback.eventPublishTerminated| (for publish
993    * discovery sessions) or |IWifiNanIfaceEventCallback.eventSubscribeTerminated| (for subscribe
994    * discovery sessions) will be delivered.
995    */
996   bool disableDiscoveryTerminationIndication;
997   /**
998    * Controls whether or not the |IWifiNanIfaceEventCallback.eventMatchExpired| will be delivered.
999    */
1000   bool disableMatchExpirationIndication;
1001   /**
1002    * Controls whether or not the |IWifiNanIfaceEventCallback.eventFollowupReceived| will be
1003    * delivered.
1004    */
1005   bool disableFollowupReceivedIndication;
1006   /**
1007    * Cipher type for data-paths constructed in the context of this discovery session. Must be
1008    * specified as |NanCipherSuiteType.NONE| if no |pmk| is provided.
1009    */
1010   NanCipherSuiteType cipherType;
1011   /**
1012    * Optional Pairwise Master Key (PMK) for data-paths constructed in the context of this discovery
1013    * session. A PMK can also be provided during the actual construction of the data-path (which
1014    * allows for unique PMKs for each data-path). The |cipherType| must be specified if a PMK is
1015    * provided.
1016    * Max length: 32
1017    * Ref: IEEE 802.11i
1018    */
1019   vec<uint8_t> pmk;
1020   /**
1021    * Specifies whether or not security is enabled in any data-path (NDP) constructed in the context
1022    * of this discovery session.
1023    * NAN Spec: Service Discovery Extension Attribute (SDEA) / Control / Security Required
1024    */
1025   bool securityEnabledInNdp;
1026   /**
1027    * Specifies whether or not there is a ranging requirement in this discovery session.
1028    * Ranging is only performed if all other match criteria with the peer are met. Ranging must
1029    * be performed if both peers in the discovery session (publisher and subscriber) set this
1030    * flag to true. Otherwise, if either peer sets this flag to false, ranging must not be performed
1031    * and must not impact discovery decisions.
1032    * Note: specifying that ranging is required also implies that this device must automatically
1033    * accept ranging requests from peers.
1034    * NAN Spec: Service Discovery Extension Attribute (SDEA) / Control / Ranging Require.
1035    */
1036   bool rangingRequired;
1037    /**
1038     * Interval in msec between two ranging measurements. Only relevant if |rangingRequired| is true.
1039     * If the Awake DW interval specified either in |discoveryWindowPeriod| or in
1040     * |NanBandSpecificConfig.discoveryWindowIntervalVal| is larger than the ranging interval then
1041     * priority is given to Awake DW interval.
1042     */
1043   uint32_t rangingIntervalMsec;
1044   /**
1045    * The type of ranging feedback to be provided by discovery session matches
1046    * |IWifiNanIfaceEventCallback.eventMatch|. Only relevant if |rangingRequired| is true.
1047    */
1048    bitfield<NanRangingIndication> configRangingIndications;
1049    /**
1050     * The ingress and egress distance in cm. If ranging is enabled (|rangingEnabled| is true) then
1051     * |configRangingIndications| is used to determine whether ingress and/or egress (or neither)
1052     * are used to determine whether a match has occurred.
1053     * NAN Spec: Service Discovery Extension Attribute (SDEA) / Ingress & Egress Range Limit
1054     */
1055    uint16_t distanceIngressCm;
1056    uint16_t distanceEgressCm;
1057 };
1058
1059 /**
1060  * Publish request: specifies a publish discovery operation.
1061  */
1062 struct NanPublishRequest {
1063   /**
1064    * Common configuration of discovery sessions.
1065    */
1066   NanDiscoveryCommonConfig baseConfigs;
1067   /**
1068    * The type of the publish discovery session.
1069    */
1070   NanPublishType publishType;
1071   /**
1072    * For publishType of |NanPublishType.SOLICITED| or |NanPublishType.UNSOLICITED_SOLICITED|
1073    * specifies the type of transmission used for responding to the probing subscribe discovery
1074    * peer.
1075    */
1076   NanTxType txType;
1077   /**
1078    * Specifies whether data-path requests |IWifiNanIfaceEventCallback.eventDataPathRequest| (in
1079    * the context of this discovery session) are automatically accepted (if true) - in which case
1080    * the Responder must not call the |IWifiNanIface.respondToDataPathIndicationRequest| method and
1081    * the device must automatically accept the data-path request and complete the negotiation.
1082    */
1083   bool autoAcceptDataPathRequests;
1084 };
1085
1086 /**
1087  * Subscribe request: specifies a subscribe discovery operation.
1088  */
1089 struct NanSubscribeRequest {
1090   /**
1091    * Common configuration of discovery sessions.
1092    */
1093   NanDiscoveryCommonConfig baseConfigs;
1094   /**
1095    * The type of the subscribe discovery session.
1096    */
1097   NanSubscribeType subscribeType;
1098   /**
1099    * For |NanSubscribeType.ACTIVE| subscribe discovery sessions specify how the Service Response
1100    * Filter (SRF) attribute is populated. Relevant only if |shouldUseSrf| is set to true.
1101    * NAN Spec: Service Descriptor Attribute (SDA) / Service Response Filter / SRF Control / SRF Type
1102    */
1103   NanSrfType srfType;
1104   /**
1105    * Configure whether inclusion of an address in |intfAddr| indicates that those devices should
1106    * respond or the reverse. Relevant only if |shouldUseSrf| is set to true and |srfType| is set to
1107    * |NanSrfType.PARTIAL_MAC_ADDR|.
1108    * NAN Spec: Service Descriptor Attribute (SDA) / Service Response Filter / SRF Control / Include
1109    */
1110   bool srfRespondIfInAddressSet;
1111   /**
1112    * Control whether the Service Response Filter (SRF) is used.
1113    * NAN Spec: Service Descriptor Attribute (SDA) / Service Control /
1114    *           Service Response Filter Present
1115    */
1116   bool shouldUseSrf;
1117   /**
1118    * Control whether the presence of |NanDiscoveryCommonConfig.serviceSpecificInfo| data is needed
1119    * in the publisher in order to trigger service discovery, i.e. a
1120    * |IWifiNanIfaceEventCallback.eventMatch|. The test is for presence of data - not for the
1121    * specific contents of the data.
1122    */
1123   bool isSsiRequiredForMatch;
1124   /**
1125    * NAN Interface Addresses constituting the Service Response Filter (SRF).
1126    * Max length (number of addresses): |NanCapabilities.maxSubscribeInterfaceAddresses|.
1127    * NAN Spec: Service Descriptor Attribute (SDA) / Service Response Filter / Address Set
1128    */
1129   vec<MacAddress> intfAddr;
1130 };
1131
1132 /**
1133  * Transmit follow up message request.
1134  */
1135 struct NanTransmitFollowupRequest {
1136   /**
1137    * ID of an active publish or subscribe discovery session. Follow-up message is transmitted in the
1138    * context of the discovery session.
1139    * NAN Spec: Service Descriptor Attribute (SDA) / Instance ID
1140    */
1141   uint8_t discoverySessionId;
1142   /**
1143    * ID of the peer. Obtained as part of an earlier |IWifiNanIfaceEventCallback.eventMatch| or
1144    * |IWifiNanIfaceEventCallback.eventFollowupReceived|.
1145    */
1146   uint32_t peerId;
1147   /**
1148    * MAC address of the peer. Obtained as part of an earlier |IWifiNanIfaceEventCallback.eventMatch|
1149    * or |IWifiNanIfaceEventCallback.eventFollowupReceived|.
1150    */
1151   MacAddress addr;
1152   /**
1153    * Should the follow-up message be transmitted with a high priority.
1154    */
1155   bool isHighPriority;
1156   /**
1157    * Should the follow-up message be transmitted in a discovery window (true) or a further
1158    * availability window (false).
1159    */
1160   bool shouldUseDiscoveryWindow;
1161   /**
1162    * Arbitrary information communicated to the peer - there is no semantic meaning to these
1163    * bytes. They are passed-through from sender to receiver as-is with no parsing.
1164    * Max length: |NanCapabilities.maxServiceSpecificInfoLen|.
1165    * NAN Spec: Service Descriptor Attribute (SDA) / Service Info
1166    */
1167   vec<uint8_t> serviceSpecificInfo;
1168   /**
1169    * Arbitrary information communicated in discovery packets - there is no semantic meaning to these
1170    * bytes. They are passed-through from publisher to subscriber as-is with no parsing.
1171    * Max length: |NanCapabilities.maxExtendedServiceSpecificInfoLen|.
1172    * Spec: Service Descriptor Extension Attribute (SDEA) / Service Info
1173    */
1174   vec<uint8_t> extendedServiceSpecificInfo;
1175   /**
1176    * Disable |IWifiNanIfaceEventCallback.eventTransmitFollowup| - i.e. do not get indication on
1177    * whether the follow-up was transmitted and received successfully.
1178    */
1179   bool disableFollowupResultIndication;
1180 };
1181
1182 /**
1183  *  Data Path Initiator requesting a data-path.
1184  */
1185 struct NanInitiateDataPathRequest {
1186   /**
1187    * ID of the peer. Obtained as part of an earlier |IWifiNanIfaceEventCallback.eventMatch| or
1188    * |IWifiNanIfaceEventCallback.eventFollowupReceived|.
1189    */
1190   uint32_t peerId;
1191   /**
1192    * NAN management interface MAC address of the peer. Obtained as part of an earlier
1193    * |IWifiNanIfaceEventCallback.eventMatch| or |IWifiNanIfaceEventCallback.eventFollowupReceived|.
1194    */
1195   MacAddress peerDiscMacAddr;
1196   /**
1197    * Config flag for channel request.
1198    */
1199   NanDataPathChannelCfg channelRequestType;
1200   /**
1201    * Channel frequency in MHz to start data-path. Not relevant if |channelRequestType| is
1202    * |NanDataPathChannelCfg.CHANNEL_NOT_REQUESTED|.
1203    */
1204   WifiChannelInMhz channel;
1205   /**
1206    * NAN data interface name on which this data-path session is to be initiated.
1207    * This must be an interface created using |IWifiNanIface.createDataInterfaceRequest|.
1208    */
1209   string ifaceName;
1210   /**
1211    * Specifies whether or not security is required for the data-path being created.
1212    * NAN Spec: Data Path Attributes / NDP Attribute / NDP Control / Security Present
1213    */
1214   bool securityRequired;
1215   /**
1216    * Arbitrary information communicated to the peer as part of the data-path setup process - there
1217    * is no semantic meaning to these bytes. They are passed-through from sender to receiver as-is
1218    * with no parsing.
1219    * Max length: |NanCapabilities.maxAppInfoLen|.
1220    * NAN Spec: Data Path Attributes / NDP Attribute / NDP Specific Info
1221    */
1222   vec<uint8_t> appInfo;
1223   /**
1224    * Cipher type for the data-path being requested. Must be specified as |NanCipherSuiteType.NONE|
1225    * if no |pmk| is provided.
1226    */
1227   NanCipherSuiteType cipherType;
1228   /**
1229    * Pairwise Master Key (PMK) for the data-path being requested (if |securityRequired| is true).
1230    * The |cipherType| must be specified if a PMK is provided.
1231    * Max length: 32
1232    * Ref: IEEE 802.11i
1233    */
1234   vec<uint8_t> pmk;
1235 };
1236
1237 /**
1238  * Response to a data-path request from a peer.
1239  */
1240 struct NanRespondToDataPathIndicationRequest {
1241   /**
1242    * Accept (true) or reject (false) the request.
1243    * NAN Spec: Data Path Attributes / NDP Attribute / Type and Status
1244    */
1245   bool acceptRequest;
1246   /**
1247    * ID of the data-path (NDP) for which we're responding - obtained as part of the request in
1248    * |IWifiNanIfaceEventCallback.eventDataPathRequest|.
1249    */
1250   uint32_t ndpInstanceId;
1251   /**
1252    * NAN data interface name on which this data-path session is to be started.
1253    * This must be an interface created using |IWifiNanIface.createDataInterfaceRequest|.
1254    */
1255   string ifaceName;
1256   /**
1257    * Specifies whether or not security is required for the data-path being created.
1258    * NAN Spec: Data Path Attributes / NDP Attribute / NDP Control / Security Present
1259    */
1260   bool securityRequired;
1261   /**
1262    * Arbitrary information communicated to the peer as part of the data-path setup process - there
1263    * is no semantic meaning to these bytes. They are passed-through from sender to receiver as-is
1264    * with no parsing.
1265    * Max length: |NanCapabilities.maxAppInfoLen|.
1266    * NAN Spec: Data Path Attributes / NDP Attribute / NDP Specific Info
1267    */
1268   vec<uint8_t> appInfo;
1269   /**
1270    * Cipher type for the data-path being negotiated. Must be specified as |NanCipherSuiteType.NONE|
1271    * if no |pmk| is provided.
1272    */
1273   NanCipherSuiteType cipherType;
1274   /**
1275    * Pairwise Master Key (PMK) for the data-path being negotiated (if |securityRequired| is true).
1276    * The |cipherType| must be specified if a PMK is provided.
1277    * Max length: 32
1278    */
1279   vec<uint8_t> pmk;
1280 };
1281
1282 /**
1283  * NDP Capabilities response.
1284  */
1285 struct NanCapabilities {
1286   /**
1287    * Maximum number of clusters which the device can join concurrently.
1288    */
1289   uint32_t maxConcurrentClusters;
1290   /**
1291    * Maximum number of concurrent publish discovery sessions.
1292    */
1293   uint32_t maxPublishes;
1294   /**
1295    * Maximum number of concurrent subscribe discovery sessions.
1296    */
1297   uint32_t maxSubscribes;
1298   /**
1299    * Maximum length (in bytes) of service name.
1300    */
1301   uint32_t maxServiceNameLen;
1302   /**
1303    * Maximum length (in bytes) of individual match filters.
1304    */
1305   uint32_t maxMatchFilterLen;
1306   /**
1307    * Maximum length (in bytes) of aggregate match filters across all active sessions.
1308    */
1309   uint32_t maxTotalMatchFilterLen;
1310   /**
1311    * Maximum length (in bytes) of the service specific info field.
1312    */
1313   uint32_t maxServiceSpecificInfoLen;
1314   /**
1315    * Maximum length (in bytes) of the extended service specific info field.
1316    */
1317   uint32_t maxExtendedServiceSpecificInfoLen;
1318   /**
1319    * Maximum number of data interfaces (NDI) which can be created concurrently on the device.
1320    */
1321   uint32_t maxNdiInterfaces;
1322   /**
1323    * Maximum number of data paths (NDP) which can be created concurrently on each individual
1324    * data interface (NDI).
1325    */
1326   uint32_t maxNdpSessions;
1327   /**
1328    * Maximum length (in bytes) of application info field (used in data-path negotiations).
1329    */
1330   uint32_t maxAppInfoLen;
1331   /**
1332    * Maximum number of transmitted followup messages which can be queued by the firmware.
1333    */
1334   uint32_t maxQueuedTransmitFollowupMsgs;
1335   /**
1336    * Maximum number MAC interface addresses which can be specified to a subscribe discovery session.
1337    */
1338   uint32_t maxSubscribeInterfaceAddresses;
1339   /**
1340    * The set of supported Cipher suites. The |NanCipherSuiteType| bit fields are used.
1341    */
1342   bitfield<NanCipherSuiteType> supportedCipherSuites;
1343 };
1344
1345 /**
1346  * Match indication structure
1347  */
1348 struct NanMatchInd {
1349   /**
1350    * Publish or subscribe discovery session ID of an existing discovery session.
1351    * NAN Spec: Service Descriptor Attribute (SDA) / Instance ID
1352    */
1353   uint8_t discoverySessionId;
1354   /**
1355    * A unique ID of the peer. Can be subsequently used in |IWifiNanIface.transmitFollowupRequest| or
1356    * to set up a data-path.
1357    */
1358   uint32_t peerId;
1359   /**
1360    * The NAN Discovery (management) MAC address of the peer.
1361    */
1362   MacAddress addr;
1363   /**
1364    * The arbitrary information contained in the |NanDiscoveryCommonConfig.serviceSpecificInfo| of
1365    * the peer's discovery session configuration.
1366    * Max length: |NanCapabilities.maxServiceSpecificInfoLen|.
1367    * NAN Spec: Service Descriptor Attribute (SDA) / Service Info
1368    */
1369   vec<uint8_t> serviceSpecificInfo;
1370   /**
1371    * Arbitrary information communicated in discovery packets - there is no semantic meaning to these
1372    * bytes. They are passed-through from publisher to subscriber as-is with no parsing.
1373    * Max length: |NanCapabilities.maxExtendedServiceSpecificInfoLen|.
1374    * Spec: Service Descriptor Extension Attribute (SDEA) / Service Info
1375    */
1376   vec<uint8_t> extendedServiceSpecificInfo;
1377   /**
1378    * The match filter from the discovery packet (publish or subscribe) which caused service
1379    * discovery. Matches the peer's |NanDiscoveryCommonConfig.txMatchFilter|.
1380    * Max length: |NanCapabilities.maxMatchFilterLen|.
1381    * NAN Spec: Service Descriptor Attribute (SDA) / Matching Filter
1382    */
1383   vec<uint8_t> matchFilter;
1384   /**
1385    * Indicates the type of discovery: true if match occurred on a Beacon frame, false if the match
1386    * occurred on a Service Discovery Frames (SDF).
1387    */
1388   bool matchOccuredInBeaconFlag;
1389   /**
1390    * Flag to indicate firmware is out of resource and that it can no longer track this Service Name.
1391    * Indicates that while |IWifiNanIfaceEventCallback.eventMatch| will be received, the
1392    * |NanDiscoveryCommonConfig.discoveryMatchIndicator| configuration will not be honored.
1393    */
1394   bool outOfResourceFlag;
1395   /**
1396    * If RSSI filtering was enabled using |NanDiscoveryCommonConfig.useRssiThreshold| in discovery
1397    * session setup then this field contains the received RSSI value. It will contain 0 if RSSI
1398    * filtering was not enabled.
1399    * RSSI values are returned without sign, e.g. -70dBm will be returned as 70.
1400    */
1401   uint8_t rssiValue;
1402   /**
1403    * Cipher type for data-paths constructed in the context of this discovery session. Valid if
1404    * |peerRequiresSecurityEnabledInNdp| is true.
1405    */
1406   NanCipherSuiteType peerCipherType;
1407   /**
1408    * Indicates whether or not the peer requires security enabled in any data-path (NDP) constructed
1409    * in the context of this discovery session. The |cipherType| specifies the cipher type for such
1410    * data-paths.
1411    * NAN Spec: Service Discovery Extension Attribute (SDEA) / Control / Security Required
1412    */
1413   bool peerRequiresSecurityEnabledInNdp;
1414   /**
1415    * Indicates whether or not the peer requires (and hence allows) ranging in the context of this
1416    * discovery session.
1417    * Note that ranging is only performed if all other match criteria with the peer are met.
1418    * NAN Spec: Service Discovery Extension Attribute (SDEA) / Control / Ranging Require.
1419    */
1420   bool peerRequiresRanging;
1421   /**
1422    * Ranging indication supersedes the NanMatchAlg specification.
1423    * Ex: If NanMatchAlg is MATCH_ONCE, but ranging indications is continuous then continuous
1424    * match notifications will be received (with ranging information).
1425    * Ranging indication data is provided if Ranging required is enabled in the discovery
1426    * specification and:
1427    *   1) continuous ranging specified.
1428    *   2) ingress/egress specified and:
1429    *       - notify once for ingress >= ingress_distance and egress <= egress_distance,
1430    *       - same for ingress_egress_both
1431    * If the Awake DW intervals are larger than the ranging intervals then priority is given to the
1432    * device DW intervals.
1433    *
1434    * If ranging was required and executed contains the distance to the peer in CM. The
1435    * |rangingIndicationType| field specifies the event which triggered ranging.
1436    */
1437   uint32_t rangingMeasurementInCm;
1438   /**
1439    * The ranging event(s) which triggered the ranging. E.g. can indicate that continuous ranging was
1440    * requested, or else that an ingress event occurred.
1441    */
1442    bitfield<NanRangingIndication> rangingIndicationType;
1443 };
1444
1445 /**
1446  * Followup message received from peer indication structure.
1447  */
1448 struct NanFollowupReceivedInd {
1449   /**
1450    * Discovery session (publish or subscribe) ID of a previously created discovery session. The
1451    * message is received in the context of this discovery session.
1452    * NAN Spec: Service Descriptor Attribute (SDA) / Instance ID
1453    */
1454   uint8_t discoverySessionId;
1455   /**
1456    * A unique ID of the peer. Can be subsequently used in |IWifiNanIface.transmitFollowupRequest| or
1457    * to set up a data-path.
1458    */
1459   uint32_t peerId;
1460   /**
1461    * The NAN Discovery (management) MAC address of the peer.
1462    */
1463   MacAddress addr;
1464   /**
1465    * Indicates whether received in a further availability window (FAW) if true, or in a discovery
1466    * window (DW) if false.
1467    */
1468   bool receivedInFaw;
1469   /**
1470    * Received message from the peer - there is no semantic meaning to these bytes. They are
1471    * passed-through from sender to receiver as-is with no parsing.
1472    * Max length: |NanCapabilities.maxServiceSpecificInfoLen|.
1473    * NAN Spec: Service Descriptor Attribute (SDA) / Service Info
1474    */
1475   vec<uint8_t> serviceSpecificInfo;
1476   /**
1477    * Arbitrary information communicated in discovery packets - there is no semantic meaning to these
1478    * bytes. They are passed-through from publisher to subscriber as-is with no parsing.
1479    * Max length: |NanCapabilities.maxExtendedServiceSpecificInfoLen|.
1480    * Spec: Service Descriptor Extension Attribute (SDEA) / Service Info
1481    */
1482   vec<uint8_t> extendedServiceSpecificInfo;
1483 };
1484
1485 /**
1486  * Event types for a cluster event indication.
1487  */
1488 enum NanClusterEventType : uint32_t {
1489   /**
1490    * Management/discovery interface MAC address has changed (e.g. due to randomization or at
1491    * startup).
1492    */
1493   DISCOVERY_MAC_ADDRESS_CHANGED = 0,
1494   /**
1495    * A new cluster has been formed by this device.
1496    */
1497   STARTED_CLUSTER,
1498   /**
1499    * This device has joined an existing cluster.
1500    */
1501   JOINED_CLUSTER,
1502 };
1503
1504 /**
1505  * Cluster event indication structure: triggered on events impacting how this device is
1506  * visible to peers - cluster forming, joining a new cluster, or changing of the MAC address.
1507  */
1508 struct NanClusterEventInd {
1509   /**
1510    * Event type causing the cluster event indication to be triggered.
1511    */
1512   NanClusterEventType eventType;
1513   /**
1514    * MAC Address associated with the corresponding event.
1515    */
1516   MacAddress addr;
1517 };
1518
1519 /**
1520  * NAN Data path request Indication Message structure.
1521  * Event indication received by an intended Responder when a Nan Data request initiated by an
1522  * Initiator.
1523  */
1524 struct NanDataPathRequestInd {
1525   /**
1526    * ID of an active publish or subscribe discovery session - the data-path request is in the
1527    * context of this discovery session.
1528    * NAN Spec: Data Path Attributes / NDP Attribute / Publish ID
1529    */
1530   uint8_t discoverySessionId;
1531   /**
1532    * MAC address of the Initiator peer. This is the MAC address of the peer's management/discovery
1533    * NAN interface.
1534    */
1535   MacAddress peerDiscMacAddr;
1536   /**
1537    * ID of the data-path - used to identify the data-path in further negotiation/APIs.
1538    */
1539   uint32_t ndpInstanceId;
1540   /**
1541    * Specifies whether or not security is required by the peer for the data-path being created.
1542    * NAN Spec: Data Path Attributes / NDP Attribute / NDP Control / Security Present
1543    */
1544   bool securityRequired;
1545   /**
1546    * Arbitrary information communicated from the peer as part of the data-path setup process - there
1547    * is no semantic meaning to these bytes. They are passed-through from sender to receiver as-is
1548    * with no parsing.
1549    * Max length: |NanCapabilities.maxAppInfoLen|.
1550    * NAN Spec: Data Path Attributes / NDP Attribute / NDP Specific Info
1551    */
1552   vec<uint8_t> appInfo;
1553 };
1554
1555 /**
1556  * NAN Data path confirmation Indication structure.
1557  * Event indication is received on both initiator and responder side when negotiation for a
1558  * data-path finish: on success or failure.
1559  */
1560 struct NanDataPathConfirmInd {
1561   /**
1562    * ID of the data-path.
1563    */
1564   uint32_t ndpInstanceId;
1565   /**
1566    * Indicates whether the data-path setup succeeded (true) or failed (false).
1567    */
1568   bool dataPathSetupSuccess;
1569   /**
1570    * MAC address of the peer's data-interface (not it's management/discovery interface).
1571    */
1572   MacAddress peerNdiMacAddr;
1573   /**
1574    * Arbitrary information communicated from the peer as part of the data-path setup process - there
1575    * is no semantic meaning to these bytes. They are passed-through from sender to receiver as-is
1576    * with no parsing.
1577    * Max length: |NanCapabilities.maxAppInfoLen|.
1578    * NAN Spec: Data Path Attributes / NDP Attribute / NDP Specific Info
1579    */
1580   vec<uint8_t> appInfo;
1581   /**
1582    * Failure reason if |dataPathSetupSuccess| is false.
1583    */
1584   WifiNanStatus status;
1585 };
1586
1587 /**
1588  * RTT specific types.
1589  * TODO(b/32159498): Move to a separate rtt_types.hal.
1590  */
1591 /**
1592  * Ranging status.
1593  */
1594 enum RttStatus : uint32_t {
1595   SUCCESS = 0,
1596   /** General failure status */
1597   FAILURE = 1,
1598   /** Target STA does not respond to request */
1599   FAIL_NO_RSP = 2,
1600   /** Request rejected. Applies to 2-sided RTT only */
1601   FAIL_REJECTED = 3,
1602   FAIL_NOT_SCHEDULED_YET = 4,
1603   /** Timing measurement times out */
1604   FAIL_TM_TIMEOUT = 5,
1605   /** Target on different channel, cannot range */
1606   FAIL_AP_ON_DIFF_CHANNEL = 6,
1607   /** Ranging not supported */
1608   FAIL_NO_CAPABILITY = 7,
1609   /** Request aborted for unknown reason */
1610   ABORTED = 8,
1611   /** Invalid T1-T4 timestamp */
1612   FAIL_INVALID_TS = 9,
1613   /** 11mc protocol failed */
1614   FAIL_PROTOCOL = 10,
1615   /** Request could not be scheduled */
1616   FAIL_SCHEDULE = 11,
1617   /** Responder cannot collaborate at time of request */
1618   FAIL_BUSY_TRY_LATER = 12,
1619   /** Bad request args */
1620   INVALID_REQ = 13,
1621   /** WiFi not enabled. */
1622   NO_WIFI = 14,
1623   /** Responder overrides param info, cannot range with new params */
1624   FAIL_FTM_PARAM_OVERRIDE = 15,
1625 };
1626
1627 /**
1628  * RTT peer types.
1629  */
1630 enum RttPeerType : uint32_t {
1631   AP = 0x1,
1632   STA = 0x2,
1633   P2P_GO = 0x3,
1634   P2P_CLIENT = 0x4,
1635   NAN = 0x5,
1636 };
1637
1638 /**
1639  * RTT Measurement Bandwidth.
1640  */
1641 enum RttBw : uint32_t {
1642   BW_5MHZ = 0x01,
1643   BW_10MHZ = 0x02,
1644   BW_20MHZ = 0x04,
1645   BW_40MHZ = 0x08,
1646   BW_80MHZ = 0x10,
1647   BW_160MHZ = 0x20,
1648 };
1649
1650 /**
1651  * RTT Measurement Preamble.
1652  */
1653 enum RttPreamble : uint32_t {
1654   LEGACY = 0x1,
1655   HT = 0x2,
1656   VHT = 0x4,
1657 };
1658
1659 /**
1660  * RTT Types.
1661  */
1662 enum RttType : uint32_t {
1663   ONE_SIDED = 0x1,
1664   TWO_SIDED = 0x2,
1665 };
1666
1667 /**
1668  * RTT configuration.
1669  */
1670 struct RttConfig {
1671   /**
1672    * Peer device mac address.
1673    */
1674   MacAddress addr;
1675   /**
1676    * 1-sided or 2-sided RTT.
1677    */
1678   RttType type;
1679   /**
1680    * Optional - peer device hint (STA, P2P, AP).
1681    */
1682   RttPeerType peer;
1683   /**
1684    * Required for STA-AP mode, optional for P2P, NBD etc.
1685    */
1686   WifiChannelInfo channel;
1687   /**
1688    * Time interval between bursts (units: 100 ms).
1689    * Applies to 1-sided and 2-sided RTT multi-burst requests.
1690    * Range: 0-31, 0: no preference by initiator (2-sided RTT).
1691    */
1692   uint32_t burstPeriod;
1693   /**
1694    * Total number of RTT bursts to be executed. It will be
1695    * specified in the same way as the parameter "Number of
1696    * Burst Exponent" found in the FTM frame format. It
1697    * applies to both: 1-sided RTT and 2-sided RTT. Valid
1698    * values are 0 to 15 as defined in 802.11mc std.
1699    * 0 means single shot
1700    * The implication of this parameter on the maximum
1701    * number of RTT results is the following:
1702    * for 1-sided RTT: max num of RTT results = (2^num_burst)*(num_frames_per_burst)
1703    * for 2-sided RTT: max num of RTT results = (2^num_burst)*(num_frames_per_burst - 1)
1704    */
1705   uint32_t numBurst;
1706   /**
1707    * Num of frames per burst.
1708    * Minimum value = 1, Maximum value = 31
1709    * For 2-sided this equals the number of FTM frames
1710    * to be attempted in a single burst. This also
1711    * equals the number of FTM frames that the
1712    * initiator will request that the responder send
1713    * in a single frame.
1714    */
1715   uint32_t numFramesPerBurst;
1716   /**
1717    * Number of retries for a failed RTT frame.
1718    * Applies to 1-sided RTT only. Minimum value = 0, Maximum value = 3
1719    */
1720   uint32_t numRetriesPerRttFrame;
1721   /** Following fields are only valid for 2-side RTT. */
1722   /**
1723    * Maximum number of retries that the initiator can
1724    * retry an FTMR frame.
1725    * Minimum value = 0, Maximum value = 3
1726    */
1727   uint32_t numRetriesPerFtmr;
1728   /**
1729    * Whether to request location civic info or not.
1730    */
1731   bool mustRequestLci;
1732   /**
1733    * Whether to request location civic records or not.
1734    */
1735   bool mustRequestLcr;
1736   /**
1737    * Applies to 1-sided and 2-sided RTT. Valid values will
1738    * be 2-11 and 15 as specified by the 802.11mc std for
1739    * the FTM parameter burst duration. In a multi-burst
1740    * request, if responder overrides with larger value,
1741    * the initiator will return failure. In a single-burst
1742    * request if responder overrides with larger value,
1743    * the initiator will sent TMR_STOP to terminate RTT
1744    * at the end of the burst_duration it requested.
1745    */
1746   uint32_t burstDuration;
1747   /**
1748    * RTT preamble to be used in the RTT frames.
1749    */
1750   RttPreamble preamble;
1751   /**
1752    * RTT BW to be used in the RTT frames.
1753    */
1754   RttBw bw;
1755 };
1756
1757 /**
1758  * RTT results.
1759  */
1760 struct RttResult {
1761   /**
1762    * Peer device mac address.
1763    */
1764   MacAddress addr;
1765   /**
1766    * Burst number in a multi-burst request.
1767    */
1768   uint32_t burstNum;
1769   /**
1770    * Total RTT measurement frames attempted.
1771    */
1772   uint32_t measurementNumber;
1773   /**
1774    * Total successful RTT measurement frames.
1775    */
1776   uint32_t successNumber;
1777   /**
1778    * Maximum number of "FTM frames per burst" supported by
1779    * the responder STA. Applies to 2-sided RTT only.
1780    * If reponder overrides with larger value:
1781    * - for single-burst request initiator will truncate the
1782    * larger value and send a TMR_STOP after receiving as
1783    * many frames as originally requested.
1784    * - for multi-burst request, initiator will return
1785    * failure right away.
1786    */
1787   uint8_t numberPerBurstPeer;
1788   /**
1789    * Ranging status.
1790    */
1791   RttStatus status;
1792   /**
1793    * When status == RTT_STATUS_FAIL_BUSY_TRY_LATER,
1794    * this will be the time provided by the responder as to
1795    * when the request can be tried again. Applies to 2-sided
1796    * RTT only. In sec, 1-31sec.
1797    */
1798   uint8_t retryAfterDuration;
1799   /**
1800    * RTT type.
1801    */
1802   RttType type;
1803   /**
1804    * Average rssi in 0.5 dB steps e.g. 143 implies -71.5 dB.
1805    */
1806   Rssi rssi;
1807   /**
1808    * Rssi spread in 0.5 dB steps e.g. 5 implies 2.5 dB spread (optional).
1809    */
1810   Rssi rssiSpread;
1811   /**
1812    * 1-sided RTT: TX rate of RTT frame.
1813    * 2-sided RTT: TX rate of initiator's Ack in response to FTM frame.
1814    */
1815   WifiRateInfo txRate;
1816   /**
1817    * 1-sided RTT: TX rate of Ack from other side.
1818    * 2-sided RTT: TX rate of FTM frame coming from responder.
1819    */
1820   WifiRateInfo rxRate;
1821   /**
1822    * Round trip time in picoseconds
1823    */
1824   TimeSpanInPs rtt;
1825   /**
1826    * Rtt standard deviation in picoseconds.
1827    */
1828   TimeSpanInPs rttSd;
1829   /**
1830    * Difference between max and min rtt times recorded in picoseconds.
1831    */
1832   TimeSpanInPs rttSpread;
1833   /**
1834    * Distance in mm (optional).
1835    */
1836   int32_t distanceInMm;
1837   /**
1838    * Standard deviation in mm (optional).
1839    */
1840   int32_t distanceSdInMm;
1841   /**
1842    * Difference between max and min distance recorded in mm (optional).
1843    */
1844   int32_t distanceSpreadInMm;
1845   /**
1846    * Time of the measurement (in microseconds since boot).
1847    */
1848   TimeStampInUs timeStampInUs;
1849   /**
1850    * in ms, actual time taken by the FW to finish one burst
1851    * measurement. Applies to 1-sided and 2-sided RTT.
1852    */
1853   uint32_t burstDurationInMs;
1854   /**
1855    * Number of bursts allowed by the responder. Applies
1856    * to 2-sided RTT only.
1857    */
1858   uint32_t negotiatedBurstNum;
1859   /**
1860    * for 11mc only.
1861    */
1862   WifiInformationElement lci;
1863   /**
1864    * for 11mc only.
1865    */
1866   WifiInformationElement lcr;
1867 };
1868
1869 /**
1870  * RTT Capabilities.
1871  */
1872 struct RttCapabilities {
1873   /**
1874    * if 1-sided rtt data collection is supported.
1875    */
1876   bool rttOneSidedSupported;
1877   /**
1878    * if ftm rtt data collection is supported.
1879    */
1880   bool rttFtmSupported;
1881   /**
1882    * if initiator supports LCI request. Applies to 2-sided RTT.
1883    */
1884   bool lciSupported;
1885   /**
1886    * if initiator supports LCR request. Applies to 2-sided RTT.
1887    */
1888   bool lcrSupported;
1889   /**
1890    * if 11mc responder mode is supported.
1891    */
1892   bool responderSupported;
1893   /**
1894    * Bit mask indicates what preamble is supported by initiator.
1895    * Combination of |RttPreamble| values.
1896    */
1897   bitfield<RttPreamble> preambleSupport;
1898   /**
1899    * Bit mask indicates what BW is supported by initiator.
1900    * Combination of |RttBw| values.
1901    */
1902   bitfield<RttBw> bwSupport;
1903   /**
1904    * Draft 11mc spec version supported by chip.
1905    * For instance, version 4.0 must be 40 and version 4.3 must be 43 etc.
1906    */
1907   uint8_t mcVersion;
1908 };
1909
1910 /**
1911  * Structs for setting LCI/LCR information to be provided to a requestor.
1912  */
1913 enum RttMotionPattern : uint32_t {
1914   /**
1915    * Not expected to change location.
1916    */
1917   NOT_EXPECTED = 0,
1918   /**
1919    * Expected to change location.
1920    */
1921   EXPECTED = 1,
1922   /**
1923    * Movement pattern unknown.
1924    */
1925   UNKNOWN = 2,
1926 };
1927
1928 /**
1929  * Movement pattern unknown.
1930  */
1931 struct RttLciInformation {
1932   /**
1933    * latitude in degrees * 2^25 , 2's complement.
1934    */
1935   int64_t latitude;
1936   /**
1937    * longitude in degrees * 2^25 , 2's complement.
1938    */
1939   int64_t longitude;
1940   /**
1941    * Altitude in units of 1/256 m.
1942    */
1943   int32_t altitude;
1944   /**
1945    * As defined in Section 2.3.2 of IETF RFC 6225.
1946    */
1947   uint8_t latitudeUnc;
1948   /**
1949    * As defined in Section 2.3.2 of IETF RFC 6225.
1950    */
1951   uint8_t longitudeUnc;
1952   /**
1953    * As defined in Section 2.4.5 from IETF RFC 6225.
1954    */
1955   uint8_t altitudeUnc;
1956   /** Following element for configuring the Z subelement. */
1957   /**
1958    * Motion pattern type.
1959    */
1960   RttMotionPattern motionPattern;
1961   /**
1962    * Floor in units of 1/16th of floor. 0x80000000 if unknown.
1963    */
1964   int32_t floor;
1965   /**
1966    * in units of 1/64 m.
1967    */
1968   int32_t heightAboveFloor;
1969   /**
1970    * in units of 1/64 m. 0 if unknown
1971    */
1972   int32_t heightUnc;
1973 };
1974
1975 struct RttLcrInformation {
1976   /**
1977    * Country code symbol.
1978    */
1979   int8_t[2] countryCode;
1980   /**
1981    * Civic info to be copied in FTM frame.
1982    */
1983   string civicInfo;
1984 };
1985
1986 /***
1987  * RTT Responder information
1988  */
1989 struct RttResponder {
1990   WifiChannelInfo channel;
1991   RttPreamble preamble;
1992 };
1993
1994 /**
1995  * Debug data specific types.
1996  * TODO(b/32159498): Move to a separate debug_types.hal.
1997  */
1998 typedef uint32_t WifiRingBufferId;
1999
2000 /**
2001  * Flags describing each debug ring buffer.
2002  */
2003 enum WifiDebugRingBufferFlags : uint32_t {
2004   HAS_BINARY_ENTRIES = 1 << 0,
2005   HAS_ASCII_ENTRIES = 1 << 1,
2006   HAS_PER_PACKET_ENTRIES = 1 << 2,
2007 };
2008
2009 /**
2010  * Struct describing each debug ring buffer supported by
2011  * the device.
2012  */
2013 struct WifiDebugRingBufferStatus {
2014   /**
2015    * Name of this debug ring buffer.
2016    */
2017   string ringName;
2018   /**
2019    * Combination of |WifiDebugRingBufferFlags| values.
2020    */
2021   uint32_t flags;
2022   /**
2023    * Unique integer representing the ring.
2024    */
2025   WifiRingBufferId ringId;
2026   /**
2027    * Total memory size allocated for the buffer.
2028    */
2029   uint32_t sizeInBytes;
2030   /**
2031    * Amount of free space in the buffer.
2032    */
2033   uint32_t freeSizeInBytes;
2034   /**
2035    * Verbose level for ring buffer.
2036    */
2037   uint32_t verboseLevel;
2038 };
2039
2040 /**
2041  * Verbose logging level to set for each debug ring buffer supported
2042  * by the device.
2043  */
2044 enum WifiDebugRingBufferVerboseLevel : uint32_t {
2045   /**
2046    * Level 0 corresponds to no collection, and it makes log handler
2047    * stop by no more events from driver.
2048    */
2049   NONE = 0,
2050   /**
2051    * Level 1 correspond to normal log level, with minimal user impact.
2052    * This is the default value.
2053    */
2054   DEFAULT = 1,
2055   /**
2056    * Level 2 is enabled when user is lazily trying to reproduce a problem,
2057    * wifi performances and power can be impacted but device should not
2058    * otherwise be significantly impacted.
2059    */
2060   VERBOSE = 2,
2061   /**
2062    * Level 3 is used when trying to actively debug a problem.
2063    * This will cause sever performance degradation.
2064    */
2065   EXCESSIVE = 3
2066 };
2067
2068 /**
2069  * Enum describing the fate of the TX packets.
2070  */
2071 enum WifiDebugTxPacketFate : uint32_t {
2072   /**
2073    * Sent over air and ACKed.
2074    */
2075   ACKED,
2076   /**
2077    * Sent over air but not ACKed. (Normal for broadcast/multicast.)
2078    */
2079   SENT,
2080   /**
2081    * Queued within firmware, but not yet sent over air.
2082    */
2083   FW_QUEUED,
2084   /**
2085    * Dropped by firmware as invalid. E.g. bad source address, bad checksum,
2086    * or invalid for current state.
2087    */
2088   FW_DROP_INVALID,
2089   /**
2090    * Dropped by firmware due to lack of buffer space.
2091    */
2092   FW_DROP_NOBUFS,
2093   /**
2094    * Dropped by firmware for any other reason. Includes frames that  were sent
2095    * by driver to firmware, but unaccounted for by  firmware.
2096    */
2097   FW_DROP_OTHER,
2098   /**
2099    * Queued within driver, not yet sent to firmware.
2100    */
2101   DRV_QUEUED,
2102   /**
2103    * Dropped by driver as invalid. E.g. bad source address, or invalid for
2104    * current state.
2105    */
2106   DRV_DROP_INVALID,
2107   /**
2108    * Dropped by driver due to lack of buffer space.
2109    */
2110   DRV_DROP_NOBUFS,
2111   /**
2112    * Dropped by driver for any other reason.
2113    */
2114   DRV_DROP_OTHER,
2115 };
2116
2117 /**
2118  * Enum describing the fate of the TX packets.
2119  */
2120 enum WifiDebugRxPacketFate : uint32_t {
2121   /**
2122    * Valid and delivered to network stack (e.g., netif_rx()).
2123    */
2124   SUCCESS,
2125   /**
2126    * Queued within firmware, but not yet sent to driver.
2127    */
2128   FW_QUEUED,
2129   /**
2130    * Dropped by firmware due to host-programmable filters.
2131    */
2132   FW_DROP_FILTER,
2133   /**
2134    * Dropped by firmware as invalid. E.g. bad checksum, decrypt failed,
2135    * or invalid for current state.
2136    */
2137   FW_DROP_INVALID,
2138   /**
2139    * Dropped by firmware due to lack of buffer space.
2140    */
2141   FW_DROP_NOBUFS,
2142   /**
2143    * Dropped by firmware for any other reason.
2144    */
2145   FW_DROP_OTHER,
2146   /**
2147    * Queued within driver, not yet delivered to network stack.
2148    */
2149   DRV_QUEUED,
2150   /**
2151    * Dropped by driver due to filter rules.
2152    */
2153   DRV_DROP_FILTER,
2154   /**
2155    * Dropped by driver as invalid. E.g. not permitted in current state.
2156    */
2157   DRV_DROP_INVALID,
2158   /**
2159    * Dropped by driver due to lack of buffer space.
2160    */
2161   DRV_DROP_NOBUFS,
2162   /**
2163    * Dropped by driver for any other reason.
2164    */
2165   DRV_DROP_OTHER,
2166 };
2167
2168 /**
2169  * Type of frame transmitted/received.
2170  */
2171 enum WifiDebugPacketFateFrameType : uint32_t {
2172   UNKNOWN,
2173   ETHERNET_II,
2174   MGMT_80211,
2175 };
2176
2177 /**
2178  * Information regarding the frame transmitted/received.
2179  */
2180 struct WifiDebugPacketFateFrameInfo {
2181   /**
2182    * The type of MAC-layer frame that this frame_info holds.
2183    * - For data frames, use FRAME_TYPE_ETHERNET_II.
2184    * - For management frames, use FRAME_TYPE_80211_MGMT.
2185    * - If the type of the frame is unknown, use FRAME_TYPE_UNKNOWN.
2186    */
2187   WifiDebugPacketFateFrameType frameType;
2188   /**
2189    * The number of bytes included in |frameContent|.
2190    * If the frame  contents are missing (e.g. RX frame dropped in firmware),
2191    * |frameLen| must be set to 0.
2192    */
2193   uint64_t frameLen;
2194   /**
2195    * Host clock when this frame was received by the driver (either  outbound
2196    * from the host network stack, or inbound from the firmware).
2197    * - The timestamp must be taken from a clock which includes time the host
2198    *   spent suspended (e.g. ktime_get_boottime()).
2199    * - If no host timestamp is available (e.g. RX frame was dropped in firmware),
2200    *   this field must be set to 0.
2201    */
2202   TimeStampInUs driverTimestampUsec;
2203   /**
2204    * Firmware clock when this frame was received by the firmware
2205    * (either outbound from the host, or inbound from a remote  station).
2206    * - The timestamp must be taken from a clock which includes time firmware
2207    *   spent suspended (if applicable).
2208    * - If no firmware timestamp is available (e.g. TX frame was dropped by
2209    *   driver), this field must be set to 0.
2210    * - Consumers of |frameInfo| must not assume any synchronization between
2211    *   driver and firmware clocks.
2212    */
2213   TimeStampInUs firmwareTimestampUsec;
2214   /**
2215    * Actual frame content. This is the raw bytes of the corresponding packet.
2216    * - Should be provided for TX frames originated by the host.
2217    * - Should be provided for RX frames received by the driver.
2218    * - Optionally provided for TX frames originated by firmware.
2219    *   (At discretion of HAL implementation.)
2220    * - Optionally provided for RX frames dropped in firmware.
2221    *   (At discretion of HAL implementation.)
2222    * - If frame content is not provided, |frameLen| must be set to 0.
2223    */
2224   vec<uint8_t> frameContent;
2225 };
2226
2227 /**
2228  * Struct describing packet fate report for each Tx frame.
2229  */
2230 struct WifiDebugTxPacketFateReport {
2231   WifiDebugTxPacketFate fate;
2232   WifiDebugPacketFateFrameInfo frameInfo;
2233 };
2234
2235 /**
2236  * Struct describing packet fate report for each Rx frame.
2237  */
2238 struct WifiDebugRxPacketFateReport {
2239   WifiDebugRxPacketFate fate;
2240   WifiDebugPacketFateFrameInfo frameInfo;
2241 };
2242
2243 /**
2244  * Struct capturing the count of all rx packets that caused
2245  * host wakeup.
2246  */
2247 struct WifiDebugHostWakeReasonRxPacketDetails {
2248   /**
2249    * Total rx unicast packet which woke up host.
2250    */
2251   uint32_t rxUnicastCnt;
2252   /**
2253    * Total rx multicast packet which woke up host.
2254    */
2255   uint32_t rxMulticastCnt;
2256   /**
2257    * Total rx broadcast packet which woke up host.
2258    */
2259   uint32_t rxBroadcastCnt;
2260 };
2261
2262 /**
2263  * Struct capturing the count of all rx multicast packets that caused
2264  * host wakeup.
2265  */
2266 struct WifiDebugHostWakeReasonRxMulticastPacketDetails {
2267   /**
2268    * Rx wake packet was ipv4 multicast.
2269    */
2270   uint32_t ipv4RxMulticastAddrCnt;
2271   /**
2272    * Rx wake packet was ipv6 multicast.
2273    */
2274   uint32_t ipv6RxMulticastAddrCnt;
2275   /**
2276    * Rx wake packet was non-ipv4 and non-ipv6.
2277    */
2278   uint32_t otherRxMulticastAddrCnt;
2279 };
2280
2281 /**
2282  * Struct capturing the count of all rx ICMP packets that caused
2283  * host wakeup.
2284  */
2285 struct WifiDebugHostWakeReasonRxIcmpPacketDetails {
2286   /**
2287    * Wake icmp packet count.
2288    */
2289   uint32_t icmpPkt;
2290   /**
2291    * Wake icmp6 packet count.
2292    */
2293   uint32_t icmp6Pkt;
2294   /**
2295    * Wake icmp6 RA packet count.
2296    */
2297   uint32_t icmp6Ra;
2298   /**
2299    * Wake icmp6 NA packet count.
2300    */
2301   uint32_t icmp6Na;
2302   /**
2303    * Wake icmp6 NS packet count.
2304    */
2305   uint32_t icmp6Ns;
2306 };
2307
2308 /**
2309  * Structure capturing the count of all the wireless related host wakeup.
2310  * This is used to capture all the reasons why the host processor
2311  * (WLAN driver) was woken up by the WLAN firmware.
2312  * These stats may be used to debug any power issues caused due to frequent
2313  * wakeup of the host processor by the WLAN firmware.
2314  */
2315 struct WifiDebugHostWakeReasonStats {
2316   /**
2317    * Total count of cmd/event wakes.
2318    * These must account for all wakeups due to WLAN management
2319    * commands/events received over the air.
2320    */
2321   uint32_t totalCmdEventWakeCnt;
2322   /**
2323    * Vector of wake counts per cmd/event type.
2324    * The number of command types and their meaning is only understood by the
2325    * vendor.
2326    */
2327   vec<uint32_t> cmdEventWakeCntPerType;
2328   /**
2329    * Total count of drive/fw wakes.
2330    * These must account for all wakeups due to local driver/firmware
2331    * interactions. These include all vendor implementation specific
2332    * interactions like any heart-beat monitoring, Bus management, etc.
2333    */
2334   uint32_t totalDriverFwLocalWakeCnt;
2335   /**
2336    * Vector of wake counts per driver/firmware interaction type.
2337    * The number of command types and their meaning is only understood by the
2338    * vendor.
2339    */
2340   vec<uint32_t> driverFwLocalWakeCntPerType;
2341   /**
2342    * Total data rx packets, that woke up host.
2343    */
2344   uint32_t totalRxPacketWakeCnt;
2345   WifiDebugHostWakeReasonRxPacketDetails rxPktWakeDetails;
2346   WifiDebugHostWakeReasonRxMulticastPacketDetails rxMulticastPkWakeDetails;
2347   WifiDebugHostWakeReasonRxIcmpPacketDetails rxIcmpPkWakeDetails;
2348 };