1/*
2 * Copyright 2022 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.hardware.wifi@1.6;
18
19import @1.0::ChipModeId;
20import @1.0::IWifiIface;
21import @1.0::WifiStatus;
22import @1.5::WifiBand;
23import @1.5::IWifiChip;
24import @1.5::WifiIfaceMode;
25import IWifiRttController;
26
27/**
28 * Interface that represents a chip that must be configured as a single unit.
29 */
30interface IWifiChip extends @1.5::IWifiChip {
31    /**
32     * Usable Wifi channels filter masks.
33     */
34    enum UsableChannelFilter : @1.5::IWifiChip.UsableChannelFilter {
35        /**
36         * Filter Wifi channels that are supported for NAN3.1 Instant communication mode. This
37         * filter should only be applied to NAN interface.
38         * - If 5G is supported default discovery channel 149/44 is considered,
39         * - If 5G is not supported then channel 6 has to be considered.
40         */
41        NAN_INSTANT_MODE = 1 << 2,
42    };
43
44    /**
45     * Create a RTTController instance.
46     *
47     * RTT controller can be either:
48     * a) Bound to a specific iface by passing in the corresponding |IWifiIface|
49     * object in |iface| param, OR
50     * b) Let the implementation decide the iface to use for RTT operations by
51     * passing null in |iface| param.
52     *
53     * @param boundIface HIDL interface object representing the iface if
54     *        the responder must be bound to a specific iface, null otherwise.
55     * @return status WifiStatus of the operation.
56     *         Possible status codes:
57     *         |WifiStatusCode.SUCCESS|,
58     *         |WifiStatusCode.ERROR_WIFI_CHIP_INVALID|
59     */
60    createRttController_1_6(IWifiIface boundIface)
61        generates (WifiStatus status, IWifiRttController rtt);
62
63    /**
64     * Retrieve list of usable Wifi channels for the specified band &
65     * operational modes.
66     *
67     * The list of usable Wifi channels in a given band depends on factors
68     * like current country code, operational mode (e.g. STA, SAP, WFD-CLI,
69     * WFD-GO, TDLS, NAN) and other restrictons due to DFS, cellular coexistence
70     * and conncurency state of the device.
71     *
72     * @param band |WifiBand| for which list of usable channels is requested.
73     * @param ifaceModeMask Bitmask of the modes represented by |WifiIfaceMode|
74     *        Bitmask respresents all the modes that the caller is interested
75     *        in (e.g. STA, SAP, CLI, GO, TDLS, NAN). E.g. If the caller is
76     *        interested in knowing usable channels for P2P CLI, P2P GO & NAN,
77     *        ifaceModeMask would be set to
78     *        IFACE_MODE_P2P_CLIENT|IFACE_MODE_P2P_GO|IFACE_MODE_NAN.
79     * @param filterMask Bitmask of filters represented by
80     *        |UsableChannelFilter|. Specifies whether driver should filter
81     *        channels based on additional criteria. If no filter is specified
82     *        driver should return usable channels purely based on regulatory
83     *        constraints.
84     * @return status WifiStatus of the operation.
85     *         Possible status codes:
86     *         |WifiStatusCode.SUCCESS|,
87     *         |WifiStatusCode.ERROR_NOT_SUPPORTED|,
88     *         |WifiStatusCode.ERROR_INVALID_ARGS|,
89     *         |WifiStatusCode.FAILURE_UNKNOWN|
90     * @return channels List of channels represented by |WifiUsableChannel|
91     *         Each entry represents a channel frequency, bandwidth and
92     *         bitmask of modes (e.g. STA, SAP, CLI, GO, TDLS, NAN) that are
93     *         allowed on that channel. E.g. If only STA mode can be supported
94     *         on an indoor channel, only the IFACE_MODE_STA bit would be set
95     *         for that channel. If 5GHz SAP cannot be supported, then none of
96     *         the 5GHz channels will have IFACE_MODE_SOFTAP bit set.
97     *         Note: Bits do not represent concurrency state. Each bit only
98     *         represents whether particular mode is allowed on that channel.
99     */
100    getUsableChannels_1_6(WifiBand band, bitfield<WifiIfaceMode> ifaceModeMask,
101        bitfield<UsableChannelFilter> filterMask)
102        generates (WifiStatus status, vec<WifiUsableChannel> channels);
103
104    /**
105     * Set of interface concurrency types with the maximum number of interfaces that can have
106     * one of the specified concurrency types for a given ChipConcurrencyCombination. See
107     * ChipConcurrencyCombination for examples.
108     */
109    struct ChipConcurrencyCombinationLimit {
110        // Each IfaceConcurrencyType must occur at most once.
111        vec<IfaceConcurrencyType> types;
112        uint32_t maxIfaces;
113    };
114
115    /**
116     * Set of interfaces that can operate concurrently when in a given mode. See
117     * ChipMode below.
118     *
119     * For example:
120     *   [{STA} <= 2]
121     *       At most two STA interfaces are supported
122     *       [], [STA], [STA+STA]
123     *
124     *   [{STA} <= 1, {NAN} <= 1, {AP_BRIDGED} <= 1]
125     *       Any combination of STA, NAN, AP_BRIDGED
126     *       [], [STA], [NAN], [AP_BRIDGED], [STA+NAN], [STA+AP_BRIDGED], [NAN+AP_BRIDGED],
127     *       [STA+NAN+AP_BRIDGED]
128     *
129     *   [{STA} <= 1, {NAN,P2P} <= 1]
130     *       Optionally a STA and either NAN or P2P
131     *       [], [STA], [STA+NAN], [STA+P2P], [NAN], [P2P]
132     *       Not included [NAN+P2P], [STA+NAN+P2P]
133     *
134     *   [{STA} <= 1, {STA,NAN} <= 1]
135     *       Optionally a STA and either a second STA or a NAN
136     *       [], [STA], [STA+NAN], [STA+STA], [NAN]
137     *       Not included [STA+STA+NAN]
138     */
139    struct ChipConcurrencyCombination {
140        vec<ChipConcurrencyCombinationLimit> limits;
141    };
142
143    /**
144     * A mode that the chip can be put in. A mode defines a set of constraints on
145     * the interfaces that can exist while in that mode. Modes define a unit of
146     * configuration where all interfaces must be torn down to switch to a
147     * different mode. Some HALs may only have a single mode, but an example where
148     * multiple modes would be required is if a chip has different firmwares with
149     * different capabilities.
150     *
151     * When in a mode, it must be possible to perform any combination of creating
152     * and removing interfaces as long as at least one of the
153     * ChipConcurrencyCombinations is satisfied. This means that if a chip has two
154     * available combinations, [{STA} <= 1] and [{AP_BRIDGED} <= 1] then it is expected
155     * that exactly one STA type or one AP_BRIDGED type can be created, but it
156     * is not expected that both a STA and AP_BRIDGED type  could be created. If it
157     * was then there would be a single available combination
158     * [{STA} <=1, {AP_BRIDGED} <= 1].
159     *
160     * When switching between two available combinations it is expected that
161     * interfaces only supported by the initial combination must be removed until
162     * the target combination is also satisfied. At that point new interfaces
163     * satisfying only the target combination can be added (meaning the initial
164     * combination limits will no longer satisfied). The addition of these new
165     * interfaces must not impact the existence of interfaces that satisfy both
166     * combinations.
167     *
168     * For example, a chip with available combinations:
169     *     [{STA} <= 2, {NAN} <=1] and [{STA} <=1, {NAN} <= 1, {AP_BRIDGED} <= 1}]
170     * If the chip currently has 3 interfaces STA, STA and NAN and wants to add an
171     * AP_BRIDGED interface in place of one of the STAs then first one of the STA
172     * interfaces must be removed and then the AP interface can be created after
173     * the STA had been torn down. During this process the remaining STA and NAN
174     * interfaces must not be removed/recreated.
175     *
176     * If a chip does not support this kind of reconfiguration in this mode then
177     * the combinations must be separated into two separate modes. Before
178     * switching modes all interfaces must be torn down, the mode switch must be
179     * enacted and when it completes the new interfaces must be brought up.
180     */
181    struct ChipMode {
182        /**
183         * Id that can be used to put the chip in this mode.
184         */
185        ChipModeId id;
186
187        /**
188         * A list of the possible interface concurrency type combinations that the chip can have
189         * while in this mode.
190         */
191        vec<ChipConcurrencyCombination> availableCombinations;
192    };
193
194    /**
195     * Get the set of operation modes that the chip supports.
196     *
197     * @return status WifiStatus of the operation.
198     *         Possible status codes:
199     *         |WifiStatusCode.SUCCESS|,
200     *         |WifiStatusCode.ERROR_WIFI_CHIP_INVALID|
201     * @return modes List of modes supported by the device.
202     */
203    getAvailableModes_1_6() generates (WifiStatus status, vec<ChipMode> modes);
204
205    /**
206     * Retrieve the list of all the possible radio combinations supported by this
207     * chip.
208     *
209     * @return status WifiStatus of the operation.
210     *         Possible status codes:
211     *         |WifiStatusCode.SUCCESS|,
212     *         |WifiStatusCode.ERROR_WIFI_CHIP_INVALID|,
213     *         |WifiStatusCode.ERROR_NOT_SUPPORTED|,
214     *         |WifiStatusCode.FAILURE_UNKNOWN|
215     * @return radioCombinationMatrix
216     *         A list of all the possible radio combinations represented by
217     *         |WifiRadioCombinationMatrix|.
218     *         For Example in case of a chip which has two radios, where one radio is
219     *         capable of 2.4GHz 2X2 only and another radio which is capable of either
220     *         5GHz or 6GHz 2X2, number of possible radio combinations in this case
221     *         are 5 and possible combinations are
222     *         {{{2G 2X2}}, //Standalone 2G
223     *         {{5G 2X2}}, //Standalone 5G
224     *         {{6G 2X2}}, //Standalone 6G
225     *         {{2G 2X2}, {5G 2X2}}, //2G+5G DBS
226     *         {{2G 2X2}, {6G 2X2}}} //2G+6G DBS
227     *         Note: Since this chip doesn’t support 5G+6G simultaneous operation
228     *         as there is only one radio which can support both bands, So it can only
229     *         do MCC 5G+6G. This table should not get populated with possible MCC
230     *         configurations. This is only for simultaneous radio configurations
231     *         (such as standalone, multi band simultaneous or single band simultaneous).
232     */
233    getSupportedRadioCombinationsMatrix()
234        generates (WifiStatus status, WifiRadioCombinationMatrix radioCombinationMatrix);
235};
236