1/*
2 * Copyright 2020 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.5;
18
19import @1.0::StaLinkLayerIfaceStats;
20import @1.0::StaLinkLayerIfacePacketStats;
21import @1.0::TimeStampInMs;
22import @1.4::WifiBand;
23import @1.0::NanCipherSuiteType;
24import @1.0::NanCapabilities;
25import @1.2::NanConfigRequestSupplemental;
26import @1.3::StaLinkLayerRadioStats;
27import @1.0::WifiChannelInMhz;
28import @1.0::WifiChannelWidthInMhz;
29import @1.4::WifiRateInfo;
30
31/**
32 * Wifi bands defined in 80211 spec.
33 */
34enum WifiBand : @1.4::WifiBand {
35    /**
36     * 60 GHz.
37     */
38    BAND_60GHZ = 16,
39    /**
40     * 2.4 GHz + 5 GHz no DFS + 6 GHz + 60 GHz.
41     */
42    BAND_24GHZ_5GHZ_6GHZ_60GHZ = 27,
43    /**
44     * 2.4 GHz + 5 GHz with DFS + 6 GHz + 60 GHz.
45     */
46    BAND_24GHZ_5GHZ_WITH_DFS_6GHZ_60GHZ = 31,
47};
48
49/**
50 * Interface operating modes.
51 */
52enum WifiIfaceMode : uint32_t {
53    /**
54     * Interface operation mode is client.
55     */
56    IFACE_MODE_STA = 1 << 0,
57    /**
58     * Interface operation mode is Hotspot.
59     */
60    IFACE_MODE_SOFTAP = 1 << 1,
61    /**
62     * Interface operation mode is Ad-Hoc network.
63     */
64    IFACE_MODE_IBSS = 1 << 2,
65    /**
66     * Interface operation mode is Wifi Direct Client.
67     */
68    IFACE_MODE_P2P_CLIENT = 1 << 3,
69    /**
70     * Interface operation mode is Wifi Direct Group Owner.
71     */
72    IFACE_MODE_P2P_GO = 1 << 4,
73    /**
74     * Interface operation mode is Aware.
75     */
76    IFACE_MODE_NAN = 1 << 5,
77    /**
78     * Interface operation mode is Mesh network.
79     */
80    IFACE_MODE_MESH = 1 << 6,
81    /**
82     * Interface operation mode is Tunneled Direct Link Setup.
83     */
84    IFACE_MODE_TDLS = 1 << 7,
85};
86
87/**
88 * Wifi usable channel information.
89 */
90struct WifiUsableChannel {
91    /**
92     * Wifi channel freqeuncy in MHz.
93     */
94    WifiChannelInMhz channel;
95
96    /**
97     * Wifi channel bandwidth in MHz.
98     */
99    WifiChannelWidthInMhz channelBandwidth;
100
101    /**
102     * Iface modes feasible on this channel.
103     */
104    bitfield<WifiIfaceMode> ifaceModeMask;
105};
106
107/**
108 * NAN configuration request parameters added in the 1.2 HAL. These are supplemental to previous
109 * versions.
110 */
111struct NanConfigRequestSupplemental {
112    /**
113     * Baseline information as defined in HAL 1.2.
114     */
115    @1.2::NanConfigRequestSupplemental V1_2;
116
117    /**
118     * Controls whether NAN instant communication mode is enabled.
119     */
120    bool enableInstantCommunicationMode;
121};
122
123/**
124 * NDP Capabilities response.
125 */
126struct NanCapabilities {
127    /**
128     * Baseline information as defined in HAL 1.0.
129     */
130    @1.0::NanCapabilities V1_0;
131
132    /**
133     * Flag to indicate id instant communication mode is supported.
134     */
135    bool instantCommunicationModeSupportFlag;
136};
137
138/**
139 * Contention time statistics for different traffic categories.
140 */
141struct StaLinkLayerIfaceContentionTimeStats {
142    /**
143     * Data packet min contention time (usec).  It includes both the internal contention time
144     * among different access categories within the chipset and the contention time for the medium.
145     */
146    uint32_t contentionTimeMinInUsec;
147
148    /**
149     * Data packet max contention time (usec).  It includes both the internal contention time
150     * among different access categories within the chipset and the contention time for the medium.
151     */
152    uint32_t contentionTimeMaxInUsec;
153    /**
154     * Data packet average contention time (usec).  It includes both the internal contention time
155     * among different access categories within the chipset and the contention time for the medium.
156     */
157    uint32_t contentionTimeAvgInUsec;
158
159    /**
160     * Number of data packets used for contention statistics.
161     */
162    uint32_t contentionNumSamples;
163};
164
165/**
166 * Per rate statistics.  The rate is characterized by the combination of preamble, number of spatial
167 * streams, transmission bandwidth, and modulation and coding scheme (MCS).
168 */
169struct StaRateStat{
170    /**
171     * Wifi rate information: preamble, number of spatial streams, bandwidth, MCS, etc.
172     */
173    WifiRateInfo rateInfo;
174    /**
175     * Number of successfully transmitted data packets (ACK received)
176     */
177    uint32_t txMpdu;
178    /**
179     * Number of received data packets
180     */
181    uint32_t rxMpdu;
182    /**
183     * Number of data packet losses (no ACK)
184     */
185    uint32_t mpduLost;
186    /**
187     * Number of data packet retries
188     */
189    uint32_t retries;
190};
191
192/**
193 * Per peer statistics.  The types of peer include the Access Point (AP), the Tunneled Direct Link
194 * Setup (TDLS), the Group Owner (GO), the Neighbor Awareness Networking (NAN), etc.
195 */
196struct StaPeerInfo {
197    /**
198     * Station count: The total number of stations currently associated with the peer.
199     */
200    uint16_t staCount;
201    /**
202     * Channel utilization: The percentage of time (normalized to 255, i.e., x% corresponds to
203     * (int) x * 255 / 100) that the medium is sensed as busy measured by either physical or
204     * virtual carrier sense (CS) mechanism.
205     */
206    uint16_t chanUtil;
207    /**
208     * Per rate statistics
209     */
210    vec<StaRateStat> rateStats;
211};
212
213/**
214 * Iface statistics for the current connection.
215 */
216struct StaLinkLayerIfaceStats {
217    /**
218     * Baseline information as defined in HAL 1.0.
219     */
220    @1.0::StaLinkLayerIfaceStats V1_0;
221
222    /**
223     * Duty cycle for the iface.
224     * if this iface is being served using time slicing on a radio with one or more ifaces
225     * (i.e MCC), then the duty cycle assigned to this iface in %.
226     * If not using time slicing (i.e SCC or DBS), set to 100.
227     */
228    uint8_t timeSliceDutyCycleInPercent;
229
230    /**
231     * WME Best Effort (BE) Access Category (AC) contention time statistics.
232     */
233    StaLinkLayerIfaceContentionTimeStats wmeBeContentionTimeStats;
234
235    /**
236     * WME Background (BK) Access Category (AC) contention time statistics.
237     */
238    StaLinkLayerIfaceContentionTimeStats wmeBkContentionTimeStats;
239
240    /**
241     * WME Video (VI) Access Category (AC) contention time statistics.
242     */
243    StaLinkLayerIfaceContentionTimeStats wmeViContentionTimeStats;
244
245    /**
246     * WME Voice (VO) Access Category (AC) contention time statistics.
247     */
248    StaLinkLayerIfaceContentionTimeStats wmeVoContentionTimeStats;
249
250    /**
251     * Per peer statistics.
252     */
253    vec<StaPeerInfo> peers;
254};
255
256struct StaLinkLayerRadioStats {
257    /**
258     * Baseline information as defined in HAL 1.3.
259     */
260    @1.3::StaLinkLayerRadioStats V1_3;
261
262    /**
263     * Radio ID: An implementation specific value identifying the radio interface for which the
264     * stats are produced. Framework must not interpret this value. It must use this value for
265     * persistently identifying the statistics between calls,
266     * e.g. if the HAL provides them in different order.
267     */
268    int32_t radioId;
269};
270
271/**
272 * Link layer stats retrieved via |getLinkLayerStats|.
273 */
274struct StaLinkLayerStats {
275    StaLinkLayerIfaceStats iface;
276
277    vec<StaLinkLayerRadioStats> radios;
278
279    /**
280     * TimeStamp for each stats sample.
281     * This is the absolute milliseconds from boot when these stats were
282     * sampled.
283     */
284    TimeStampInMs timeStampInMs;
285};
286