blob: eb5b8a13838c70128e52e3282a15cc2e20c5ca76 [file] [log] [blame]
junyulai4011f472020-01-20 17:39:59 +08001/*
2 * Copyright (C) 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.tetheroffload.control@1.1;
18
19import @1.0::IOffloadControl;
20
21/**
22 * Interface used to control the lifecycle of tethering offload. Note that callbacks of 1.1 HAL
23 * can be registered with the existing callback registration methods from 1.0 HAL.
24 */
25interface IOffloadControl extends @1.0::IOffloadControl {
26 /**
27 * Instruct hardware to send callbacks after certain number of bytes have been transferred in
28 * either direction on this upstream interface.
29 *
30 * The specified quota bytes must be applied to all traffic on the given upstream interface.
31 * This includes hardware forwarded traffic, software forwarded traffic, and AP-originated
32 * traffic. IPv4 and IPv6 traffic both count towards the same quota. IP headers are included
33 * in the byte count quota, but, link-layer headers are not.
34 *
35 * This API may only be called while offload is occurring on this upstream. The hardware
36 * management process MUST NOT store the values when offload is not started and applies once
37 * offload is started. This is because the quota values would likely become stale over
38 * time and would not reflect any new traffic that has occurred.
39 *
40 * This API replaces {@link @1.0::IOffloadControl::setDataLimit}, the framework would always
41 * calls this API if 1.1 HAL is supported. Otherwise, calls the other one. Thus, no
42 * interaction between the two APIs need to be addressed. However, the hardware implementation
43 * still needs to keep functionality of both in case of shipping with older framework that
44 * doesn't support 1.1 HAL.
45 *
46 * The specified quota bytes MUST replace any previous quotas set by
47 * {@code setDataWarningAndLimit} specified on the same interface. It may be interpreted as
48 * "tell me when either <warningBytes> or <limitBytes> bytes have been transferred
49 * (in either direction), and stop offload when <limitBytes> bytes have been transferred,
50 * starting now and counting from zero on <upstream>."
51 *
52 * Once the {@code warningBytes} is reached, the callback registered in initOffload must be
53 * called with {@code OFFLOAD_WARNING_REACHED} to indicate this event. Once the event fires
54 * for this upstream, no further {@code OFFLOAD_WARNING_REACHED} event will be fired for this
55 * upstream unless this method is called again with the same interface. Note that there is
56 * no need to call initOffload again to resume offload if stopOffload was not called by the
57 * client.
58 *
59 * Similarly, Once the {@code limitBytes} is reached, the callback registered in initOffload
60 * must be called with {@code OFFLOAD_STOPPED_LIMIT_REACHED} to indicate this event. Once
61 * the event fires for this upstream, no further {@code OFFLOAD_STOPPED_LIMIT_REACHED}
62 * event will be fired for this upstream unless this method is called again with the same
63 * interface. However, unlike {@code warningBytes}, when {@code limitBytes} is reached,
64 * all offload must be stopped. If offload is desired again, the hardware management
65 * process must be completely reprogrammed by calling setUpstreamParameters and
66 * addDownstream again.
67 *
68 * Note that when one of the quota bytes is reached, the other one is still considered valid
69 * unless this method is called again with the same interface.
70 *
71 * @param upstream Upstream interface name that quota must apply to.
72 * @param warningBytes The quota of warning, defined as the number of bytes, starting from
73 * zero and counting from now.
74 * @param limitBytes The quota of limit, defined as the number of bytes, starting from zero
75 * and counting from now.
76 *
77 * @return success true if quota is applied, false otherwise
78 * @return errMsg a human readable string if error has occurred.
79 */
80 setDataWarningAndLimit(string upstream, uint64_t warningBytes, uint64_t limitBytes)
81 generates (bool success, string errMsg);
82};