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