xref: /aosp_15_r20/hardware/interfaces/tetheroffload/control/1.0/IOffloadControl.hal (revision 4d7e907c777eeecc4c5bd7cf640a754fac206ff7)
1*4d7e907cSAndroid Build Coastguard Worker/*
2*4d7e907cSAndroid Build Coastguard Worker * Copyright (C) 2017 The Android Open Source Project
3*4d7e907cSAndroid Build Coastguard Worker *
4*4d7e907cSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License");
5*4d7e907cSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License.
6*4d7e907cSAndroid Build Coastguard Worker * You may obtain a copy of the License at
7*4d7e907cSAndroid Build Coastguard Worker *
8*4d7e907cSAndroid Build Coastguard Worker *      http://www.apache.org/licenses/LICENSE-2.0
9*4d7e907cSAndroid Build Coastguard Worker *
10*4d7e907cSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software
11*4d7e907cSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS,
12*4d7e907cSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*4d7e907cSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and
14*4d7e907cSAndroid Build Coastguard Worker * limitations under the License.
15*4d7e907cSAndroid Build Coastguard Worker */
16*4d7e907cSAndroid Build Coastguard Worker
17*4d7e907cSAndroid Build Coastguard Workerpackage [email protected];
18*4d7e907cSAndroid Build Coastguard Worker
19*4d7e907cSAndroid Build Coastguard Workerimport ITetheringOffloadCallback;
20*4d7e907cSAndroid Build Coastguard Worker
21*4d7e907cSAndroid Build Coastguard Worker
22*4d7e907cSAndroid Build Coastguard Worker/**
23*4d7e907cSAndroid Build Coastguard Worker * Interface used to control the lifecycle of tethering offload
24*4d7e907cSAndroid Build Coastguard Worker */
25*4d7e907cSAndroid Build Coastguard Workerinterface IOffloadControl {
26*4d7e907cSAndroid Build Coastguard Worker  /**
27*4d7e907cSAndroid Build Coastguard Worker   * Indicates intent to start offload for tethering in immediate future.
28*4d7e907cSAndroid Build Coastguard Worker   *
29*4d7e907cSAndroid Build Coastguard Worker   * This API must be called exactly once the first time that Tethering is requested by
30*4d7e907cSAndroid Build Coastguard Worker   * the user.
31*4d7e907cSAndroid Build Coastguard Worker   *
32*4d7e907cSAndroid Build Coastguard Worker   * If this API is called multiple times without first calling stopOffload, then the subsequent
33*4d7e907cSAndroid Build Coastguard Worker   * calls must fail without changing the state of the server.
34*4d7e907cSAndroid Build Coastguard Worker   *
35*4d7e907cSAndroid Build Coastguard Worker   * If for some reason, the hardware is currently unable to support offload, this call must fail.
36*4d7e907cSAndroid Build Coastguard Worker   *
37*4d7e907cSAndroid Build Coastguard Worker   * @param cb Assuming success, this callback must provide unsolicited updates of offload status.
38*4d7e907cSAndroid Build Coastguard Worker   *           It is assumed to be valid until stopOffload is called.
39*4d7e907cSAndroid Build Coastguard Worker   *
40*4d7e907cSAndroid Build Coastguard Worker   * @return success true if initialization is successful, false otherwise
41*4d7e907cSAndroid Build Coastguard Worker   * @return errMsg a human readable string if eror has occured.
42*4d7e907cSAndroid Build Coastguard Worker   *
43*4d7e907cSAndroid Build Coastguard Worker   * Remarks: Initializing offload does not imply that any upstreams or downstreams have yet been,
44*4d7e907cSAndroid Build Coastguard Worker   * or even will be, chosen.  This API is symmetrical with stopOffload.
45*4d7e907cSAndroid Build Coastguard Worker   */
46*4d7e907cSAndroid Build Coastguard Worker  @entry
47*4d7e907cSAndroid Build Coastguard Worker  @callflow(next={"*"})
48*4d7e907cSAndroid Build Coastguard Worker  initOffload(ITetheringOffloadCallback cb) generates (bool success, string errMsg);
49*4d7e907cSAndroid Build Coastguard Worker
50*4d7e907cSAndroid Build Coastguard Worker  /**
51*4d7e907cSAndroid Build Coastguard Worker   * Indicate desire to tear down all tethering offload.
52*4d7e907cSAndroid Build Coastguard Worker   *
53*4d7e907cSAndroid Build Coastguard Worker   * Called after tethering is no longer requested by the user. Any remaining offload must
54*4d7e907cSAndroid Build Coastguard Worker   * be subsequently torn down by the management process.  Upon success, the callback registered
55*4d7e907cSAndroid Build Coastguard Worker   * in initOffload must be released, and offload must be stopped.
56*4d7e907cSAndroid Build Coastguard Worker   *
57*4d7e907cSAndroid Build Coastguard Worker   * @return success true if offload is stopped, false otherwise
58*4d7e907cSAndroid Build Coastguard Worker   * @return errMsg a human readable string if eror has occured.
59*4d7e907cSAndroid Build Coastguard Worker   *
60*4d7e907cSAndroid Build Coastguard Worker   * Remarks: Statistics must be reset by this API.
61*4d7e907cSAndroid Build Coastguard Worker   */
62*4d7e907cSAndroid Build Coastguard Worker  @exit
63*4d7e907cSAndroid Build Coastguard Worker  stopOffload() generates (bool success, string errMsg);
64*4d7e907cSAndroid Build Coastguard Worker
65*4d7e907cSAndroid Build Coastguard Worker  /**
66*4d7e907cSAndroid Build Coastguard Worker   * Instruct management process not to forward traffic destined to or from the specified prefixes.
67*4d7e907cSAndroid Build Coastguard Worker   *
68*4d7e907cSAndroid Build Coastguard Worker   * This API may only be called after initOffload and before stopOffload.
69*4d7e907cSAndroid Build Coastguard Worker   *
70*4d7e907cSAndroid Build Coastguard Worker   * @param prefixes List containing fully specified prefixes. For e.g. 192.168.1.12/24
71*4d7e907cSAndroid Build Coastguard Worker                     or 2001:4860:0684:0:0:0:0:0:1002/64
72*4d7e907cSAndroid Build Coastguard Worker   *
73*4d7e907cSAndroid Build Coastguard Worker   * @return success true if success, false otherwise
74*4d7e907cSAndroid Build Coastguard Worker   * @return errMsg a human readable string if eror has occured.
75*4d7e907cSAndroid Build Coastguard Worker   *
76*4d7e907cSAndroid Build Coastguard Worker   * Remarks: This list overrides any previously specified list
77*4d7e907cSAndroid Build Coastguard Worker   */
78*4d7e907cSAndroid Build Coastguard Worker  setLocalPrefixes(vec<string> prefixes) generates (bool success, string errMsg);
79*4d7e907cSAndroid Build Coastguard Worker
80*4d7e907cSAndroid Build Coastguard Worker  /**
81*4d7e907cSAndroid Build Coastguard Worker   * Query offloaded traffic statistics forwarded to an upstream address.
82*4d7e907cSAndroid Build Coastguard Worker   *
83*4d7e907cSAndroid Build Coastguard Worker   * Return statistics that have transpired since the last query.  This would include
84*4d7e907cSAndroid Build Coastguard Worker   * statistics from all offloaded downstream tether interfaces that have been forwarded to this
85*4d7e907cSAndroid Build Coastguard Worker   * upstream interface.  After returning the statistics, the counters are reset to zero.
86*4d7e907cSAndroid Build Coastguard Worker   *
87*4d7e907cSAndroid Build Coastguard Worker   * Only offloaded statistics must be returned by this API, software stats must not be
88*4d7e907cSAndroid Build Coastguard Worker   * returned.
89*4d7e907cSAndroid Build Coastguard Worker   *
90*4d7e907cSAndroid Build Coastguard Worker   * @param upstream Upstream interface on which traffic exited/entered
91*4d7e907cSAndroid Build Coastguard Worker   *
92*4d7e907cSAndroid Build Coastguard Worker   * @return rxBytes values depicting the received bytes
93*4d7e907cSAndroid Build Coastguard Worker   * @return txBytes values depicting the transmitted bytes
94*4d7e907cSAndroid Build Coastguard Worker   */
95*4d7e907cSAndroid Build Coastguard Worker  getForwardedStats(string upstream) generates (uint64_t rxBytes, uint64_t txBytes);
96*4d7e907cSAndroid Build Coastguard Worker
97*4d7e907cSAndroid Build Coastguard Worker  /**
98*4d7e907cSAndroid Build Coastguard Worker   * Instruct hardware to stop forwarding traffic and send a callback after limit bytes have been
99*4d7e907cSAndroid Build Coastguard Worker   * transferred in either direction on this upstream interface.
100*4d7e907cSAndroid Build Coastguard Worker   *
101*4d7e907cSAndroid Build Coastguard Worker   * The limit must be applied to all traffic on the given upstream interface.  This
102*4d7e907cSAndroid Build Coastguard Worker   * includes hardware forwarded traffic, software forwarded traffic, and AP-originated traffic.
103*4d7e907cSAndroid Build Coastguard Worker   * IPv4 and IPv6 traffic both count towards the same limit.  IP headers are included in the
104*4d7e907cSAndroid Build Coastguard Worker   * byte count limit, but, link-layer headers are not.
105*4d7e907cSAndroid Build Coastguard Worker   *
106*4d7e907cSAndroid Build Coastguard Worker   * This API may only be called while offload is occurring on this upstream.  The hardware
107*4d7e907cSAndroid Build Coastguard Worker   * management process is not expected to cache the value and apply the quota once offload is
108*4d7e907cSAndroid Build Coastguard Worker   * started.  This cache is not expected, because the limit value would likely become stale over
109*4d7e907cSAndroid Build Coastguard Worker   * time and would not reflect any new traffic that has occurred.
110*4d7e907cSAndroid Build Coastguard Worker   *
111*4d7e907cSAndroid Build Coastguard Worker   * This limit must replace any previous limit.  It may be interpreted as "tell me when
112*4d7e907cSAndroid Build Coastguard Worker   * <limit> bytes have been transferred (in either direction) on <upstream>, starting
113*4d7e907cSAndroid Build Coastguard Worker   * now and counting from zero."
114*4d7e907cSAndroid Build Coastguard Worker   *
115*4d7e907cSAndroid Build Coastguard Worker   * Once the limit is reached, the callback registered in initOffload must be called to indicate
116*4d7e907cSAndroid Build Coastguard Worker   * this event and all offload must be stopped.  If offload is desired again, the hardware
117*4d7e907cSAndroid Build Coastguard Worker   * management process must be completely reprogrammed by calling setUpstreamParameters and
118*4d7e907cSAndroid Build Coastguard Worker   * addDownstream again.  Note that it is not necessary to call initOffload again to resume offload
119*4d7e907cSAndroid Build Coastguard Worker   * if stopOffload was not called by the client.
120*4d7e907cSAndroid Build Coastguard Worker   *
121*4d7e907cSAndroid Build Coastguard Worker   * @param upstream Upstream interface name that limit must apply to
122*4d7e907cSAndroid Build Coastguard Worker   * @param limit    Bytes limit that can occur before action must be taken
123*4d7e907cSAndroid Build Coastguard Worker   *
124*4d7e907cSAndroid Build Coastguard Worker   * @return success true if limit is applied, false otherwise
125*4d7e907cSAndroid Build Coastguard Worker   * @return errMsg a human readable string if eror has occured.
126*4d7e907cSAndroid Build Coastguard Worker   */
127*4d7e907cSAndroid Build Coastguard Worker  setDataLimit(string upstream, uint64_t limit) generates (bool success, string errMsg);
128*4d7e907cSAndroid Build Coastguard Worker
129*4d7e907cSAndroid Build Coastguard Worker  /**
130*4d7e907cSAndroid Build Coastguard Worker   * Instruct hardware to start forwarding traffic to the specified upstream.
131*4d7e907cSAndroid Build Coastguard Worker   *
132*4d7e907cSAndroid Build Coastguard Worker   * When iface, v4Addr, and v4Gw are all non-null, the management process may begin forwarding
133*4d7e907cSAndroid Build Coastguard Worker   * any currently configured or future configured IPv4 downstreams to this upstream interface.
134*4d7e907cSAndroid Build Coastguard Worker   *
135*4d7e907cSAndroid Build Coastguard Worker   * If any of the previously three mentioned parameters are null, then any current IPv4 offload
136*4d7e907cSAndroid Build Coastguard Worker   * must be stopped.
137*4d7e907cSAndroid Build Coastguard Worker   *
138*4d7e907cSAndroid Build Coastguard Worker   * When iface and v6Gws are both non-null, and in the case of v6Gws, are not empty, the
139*4d7e907cSAndroid Build Coastguard Worker   * management process may begin forwarding any currently configured or future configured IPv6
140*4d7e907cSAndroid Build Coastguard Worker   * downstreams to this upstream interface.
141*4d7e907cSAndroid Build Coastguard Worker   *
142*4d7e907cSAndroid Build Coastguard Worker   * If either of the two above parameters are null, or no V6 Gateways are provided, then IPv6
143*4d7e907cSAndroid Build Coastguard Worker   * offload must be stopped.
144*4d7e907cSAndroid Build Coastguard Worker   *
145*4d7e907cSAndroid Build Coastguard Worker   * This API may only be called after initOffload and before stopOffload.
146*4d7e907cSAndroid Build Coastguard Worker   *
147*4d7e907cSAndroid Build Coastguard Worker   * @param iface  Upstream interface name.  Note that only one is needed because IPv4 and IPv6
148*4d7e907cSAndroid Build Coastguard Worker   *               interfaces cannot be different (only known that this can occur during software
149*4d7e907cSAndroid Build Coastguard Worker   *               xlat, which cannot be offloaded through hardware anyways).  If the iface is
150*4d7e907cSAndroid Build Coastguard Worker   *               null, offload must be stopped.
151*4d7e907cSAndroid Build Coastguard Worker   * @param v4Addr The local IPv4 address assigned to the provided upstream interface, i.e. the
152*4d7e907cSAndroid Build Coastguard Worker   *               IPv4 address the packets are NATed to. For e.g. 192.168.1.12.
153*4d7e907cSAndroid Build Coastguard Worker   * @param v4Gw   The IPv4 address of the IPv4 gateway on the upstream interface.
154*4d7e907cSAndroid Build Coastguard Worker   *               For e.g. 192.168.1.1
155*4d7e907cSAndroid Build Coastguard Worker   * @param v6Gws  A list of IPv6 addresses (for e.g. 2001:4860:0684:0:0:0:0:0:1002) for possible
156*4d7e907cSAndroid Build Coastguard Worker   *               IPv6 gateways on the upstream interface.
157*4d7e907cSAndroid Build Coastguard Worker   *
158*4d7e907cSAndroid Build Coastguard Worker   * @return success true if success, false otherwise
159*4d7e907cSAndroid Build Coastguard Worker   * @return errMsg a human readable string if eror has occured.
160*4d7e907cSAndroid Build Coastguard Worker   *
161*4d7e907cSAndroid Build Coastguard Worker   * Remarks: This overrides any previously configured parameters.
162*4d7e907cSAndroid Build Coastguard Worker   */
163*4d7e907cSAndroid Build Coastguard Worker  setUpstreamParameters(string iface, string v4Addr, string v4Gw, vec<string> v6Gws)
164*4d7e907cSAndroid Build Coastguard Worker          generates (bool success, string errMsg);
165*4d7e907cSAndroid Build Coastguard Worker
166*4d7e907cSAndroid Build Coastguard Worker  /**
167*4d7e907cSAndroid Build Coastguard Worker   * Configure a downstream interface and prefix in the hardware management process that may be
168*4d7e907cSAndroid Build Coastguard Worker   * forwarded.
169*4d7e907cSAndroid Build Coastguard Worker   *
170*4d7e907cSAndroid Build Coastguard Worker   * The prefix may be an IPv4 or an IPv6 address to signify which family can be offloaded from the
171*4d7e907cSAndroid Build Coastguard Worker   * specified tether interface.  The list of IPv4 and IPv6 downstreams that are configured may
172*4d7e907cSAndroid Build Coastguard Worker   * differ.
173*4d7e907cSAndroid Build Coastguard Worker   *
174*4d7e907cSAndroid Build Coastguard Worker   * If the given protocol, as determined by the prefix, has an upstream set,
175*4d7e907cSAndroid Build Coastguard Worker   * the hardware may begin forwarding traffic between the upstream and any devices on the
176*4d7e907cSAndroid Build Coastguard Worker   * downstream interface that have IP addresses within the specified prefix. Traffic from the same
177*4d7e907cSAndroid Build Coastguard Worker   * downstream interfaces is unaffected and must be forwarded if and only if it was already
178*4d7e907cSAndroid Build Coastguard Worker   * being forwarded.
179*4d7e907cSAndroid Build Coastguard Worker   *
180*4d7e907cSAndroid Build Coastguard Worker   * If no upstream is currently configured, then these downstream interface and prefixes must be
181*4d7e907cSAndroid Build Coastguard Worker   * preserved so that offload may begin in the future when an upstream is set.
182*4d7e907cSAndroid Build Coastguard Worker   *
183*4d7e907cSAndroid Build Coastguard Worker   * This API does not replace any previously configured downstreams and must be explictly removed
184*4d7e907cSAndroid Build Coastguard Worker   * by calling removeDownstream.
185*4d7e907cSAndroid Build Coastguard Worker   *
186*4d7e907cSAndroid Build Coastguard Worker   * This API may only be called after initOffload and before stopOffload.
187*4d7e907cSAndroid Build Coastguard Worker   *
188*4d7e907cSAndroid Build Coastguard Worker   * @param iface  Tether interface
189*4d7e907cSAndroid Build Coastguard Worker   * @param prefix Downstream prefix depicting addresses that may be offloaded.
190*4d7e907cSAndroid Build Coastguard Worker   *               For e.g. 192.168.1.12/24 or 2001:4860:0684::/64)
191*4d7e907cSAndroid Build Coastguard Worker   *
192*4d7e907cSAndroid Build Coastguard Worker   * @return success true if success, false otherwise
193*4d7e907cSAndroid Build Coastguard Worker   * @return errMsg a human readable string if eror has occured.
194*4d7e907cSAndroid Build Coastguard Worker   *
195*4d7e907cSAndroid Build Coastguard Worker   * Remarks: The hardware management process may fail this call in a normal situation.  This can
196*4d7e907cSAndroid Build Coastguard Worker   *          happen because the hardware cannot support the current number of prefixes, the
197*4d7e907cSAndroid Build Coastguard Worker   *          hardware cannot support concurrent offload on multiple interfaces, the hardware
198*4d7e907cSAndroid Build Coastguard Worker   *          cannot currently support offload on the tether interface for some reason, or any
199*4d7e907cSAndroid Build Coastguard Worker   *          other dynamic configuration issues which may occur.  In this case,
200*4d7e907cSAndroid Build Coastguard Worker   *          traffic must remain unaffected and must be forwarded if and only if it was already
201*4d7e907cSAndroid Build Coastguard Worker   *          being forwarded.
202*4d7e907cSAndroid Build Coastguard Worker   */
203*4d7e907cSAndroid Build Coastguard Worker  addDownstream(string iface, string prefix) generates (bool success, string errMsg);
204*4d7e907cSAndroid Build Coastguard Worker
205*4d7e907cSAndroid Build Coastguard Worker  /**
206*4d7e907cSAndroid Build Coastguard Worker   * Remove a downstream prefix that may be forwarded from the hardware management process.
207*4d7e907cSAndroid Build Coastguard Worker   *
208*4d7e907cSAndroid Build Coastguard Worker   * The prefix may be an IPv4 or an IPv6 address. If it was not previously configured using
209*4d7e907cSAndroid Build Coastguard Worker   * addDownstream, then this must be a no-op.
210*4d7e907cSAndroid Build Coastguard Worker   *
211*4d7e907cSAndroid Build Coastguard Worker   * This API may only be called after initOffload and before stopOffload.
212*4d7e907cSAndroid Build Coastguard Worker   *
213*4d7e907cSAndroid Build Coastguard Worker   * @param iface  Tether interface
214*4d7e907cSAndroid Build Coastguard Worker   * @param prefix Downstream prefix depicting address that must no longer be offloaded
215*4d7e907cSAndroid Build Coastguard Worker   *               For e.g. 192.168.1.12/24 or 2001:4860:0684::/64)
216*4d7e907cSAndroid Build Coastguard Worker   *
217*4d7e907cSAndroid Build Coastguard Worker   * @return success true if success, false otherwise
218*4d7e907cSAndroid Build Coastguard Worker   * @return errMsg a human readable string if eror has occured.
219*4d7e907cSAndroid Build Coastguard Worker   */
220*4d7e907cSAndroid Build Coastguard Worker  removeDownstream(string iface, string prefix) generates (bool success, string errMsg);
221*4d7e907cSAndroid Build Coastguard Worker};
222