diff options
author | Niranjan Pendharkar <npendhar@codeaurora.org> | 2017-01-26 10:31:20 -0800 |
---|---|---|
committer | Niranjan Pendharkar <npendhar@codeaurora.org> | 2017-04-27 13:43:41 -0700 |
commit | 257430b7839535341e76fecad62bf96c1b0026be (patch) | |
tree | f4a46952c235443abbcd8397d2f52f1e0becfcc3 /tetheroffload | |
parent | 9af336425e2172a9639480a5399ad0e55e3f43c1 (diff) | |
download | platform_hardware_interfaces-257430b7839535341e76fecad62bf96c1b0026be.tar.gz platform_hardware_interfaces-257430b7839535341e76fecad62bf96c1b0026be.tar.bz2 platform_hardware_interfaces-257430b7839535341e76fecad62bf96c1b0026be.zip |
Tether Offload HAL
Adds new interfaces to perform hardware optimized tethering offload.
Test: as follows
- built (bullhead)
- flashed
- booted
- "runtest frameworks-net" passes
Bug:34361337
Change-Id: I1ed756306e1efe98bd2703df9c9846a50a87ffcd
Diffstat (limited to 'tetheroffload')
-rw-r--r-- | tetheroffload/Android.bp | 5 | ||||
-rw-r--r-- | tetheroffload/config/1.0/Android.bp | 60 | ||||
-rw-r--r-- | tetheroffload/config/1.0/IOffloadConfig.hal | 36 | ||||
-rw-r--r-- | tetheroffload/control/1.0/Android.bp | 71 | ||||
-rw-r--r-- | tetheroffload/control/1.0/Android.mk | 274 | ||||
-rw-r--r-- | tetheroffload/control/1.0/IOffloadControl.hal | 221 | ||||
-rw-r--r-- | tetheroffload/control/1.0/ITetheringOffloadCallback.hal | 38 | ||||
-rw-r--r-- | tetheroffload/control/1.0/types.hal | 72 |
8 files changed, 777 insertions, 0 deletions
diff --git a/tetheroffload/Android.bp b/tetheroffload/Android.bp new file mode 100644 index 0000000000..4b50f111ac --- /dev/null +++ b/tetheroffload/Android.bp @@ -0,0 +1,5 @@ +// This is an autogenerated file, do not edit. +subdirs = [ + "config/1.0", + "control/1.0", +] diff --git a/tetheroffload/config/1.0/Android.bp b/tetheroffload/config/1.0/Android.bp new file mode 100644 index 0000000000..7eac6b006c --- /dev/null +++ b/tetheroffload/config/1.0/Android.bp @@ -0,0 +1,60 @@ +// This file is autogenerated by hidl-gen. Do not edit manually. + +filegroup { + name: "android.hardware.tetheroffload.config@1.0_hal", + srcs: [ + "IOffloadConfig.hal", + ], +} + +genrule { + name: "android.hardware.tetheroffload.config@1.0_genc++", + tools: ["hidl-gen"], + cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.tetheroffload.config@1.0", + srcs: [ + ":android.hardware.tetheroffload.config@1.0_hal", + ], + out: [ + "android/hardware/tetheroffload/config/1.0/OffloadConfigAll.cpp", + ], +} + +genrule { + name: "android.hardware.tetheroffload.config@1.0_genc++_headers", + tools: ["hidl-gen"], + cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.tetheroffload.config@1.0", + srcs: [ + ":android.hardware.tetheroffload.config@1.0_hal", + ], + out: [ + "android/hardware/tetheroffload/config/1.0/IOffloadConfig.h", + "android/hardware/tetheroffload/config/1.0/IHwOffloadConfig.h", + "android/hardware/tetheroffload/config/1.0/BnHwOffloadConfig.h", + "android/hardware/tetheroffload/config/1.0/BpHwOffloadConfig.h", + "android/hardware/tetheroffload/config/1.0/BsOffloadConfig.h", + ], +} + +cc_library_shared { + name: "android.hardware.tetheroffload.config@1.0", + generated_sources: ["android.hardware.tetheroffload.config@1.0_genc++"], + generated_headers: ["android.hardware.tetheroffload.config@1.0_genc++_headers"], + export_generated_headers: ["android.hardware.tetheroffload.config@1.0_genc++_headers"], + vendor_available: true, + shared_libs: [ + "libhidlbase", + "libhidltransport", + "libhwbinder", + "liblog", + "libutils", + "libcutils", + "android.hidl.base@1.0", + ], + export_shared_lib_headers: [ + "libhidlbase", + "libhidltransport", + "libhwbinder", + "libutils", + "android.hidl.base@1.0", + ], +} diff --git a/tetheroffload/config/1.0/IOffloadConfig.hal b/tetheroffload/config/1.0/IOffloadConfig.hal new file mode 100644 index 0000000000..4d285da7c5 --- /dev/null +++ b/tetheroffload/config/1.0/IOffloadConfig.hal @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.hardware.tetheroffload.config@1.0; + + +/** + * Interface used for configuring the hardware management process + */ +interface IOffloadConfig { + /** + * Provides bound netlink file descriptors for use in the management process + * + * @param fd1 A file descriptor bound to the following netlink groups + * (NF_NETLINK_CONNTRACK_NEW | NF_NETLINK_CONNTRACK_DESTROY). + * @param fd2 A file descriptor bound to the following netlink groups + * (NF_NETLINK_CONNTRACK_UPDATE | NF_NETLINK_CONNTRACK_DESTROY). + * + * @return success true if successful, false otherwise + * @return errMsg a human readable string if eror has occured. + */ + setHandles(handle fd1, handle fd2) generates (bool success, string errMsg); +}; diff --git a/tetheroffload/control/1.0/Android.bp b/tetheroffload/control/1.0/Android.bp new file mode 100644 index 0000000000..1d94ec8bca --- /dev/null +++ b/tetheroffload/control/1.0/Android.bp @@ -0,0 +1,71 @@ +// This file is autogenerated by hidl-gen. Do not edit manually. + +filegroup { + name: "android.hardware.tetheroffload.control@1.0_hal", + srcs: [ + "types.hal", + "IOffloadControl.hal", + "ITetheringOffloadCallback.hal", + ], +} + +genrule { + name: "android.hardware.tetheroffload.control@1.0_genc++", + tools: ["hidl-gen"], + cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.tetheroffload.control@1.0", + srcs: [ + ":android.hardware.tetheroffload.control@1.0_hal", + ], + out: [ + "android/hardware/tetheroffload/control/1.0/types.cpp", + "android/hardware/tetheroffload/control/1.0/OffloadControlAll.cpp", + "android/hardware/tetheroffload/control/1.0/TetheringOffloadCallbackAll.cpp", + ], +} + +genrule { + name: "android.hardware.tetheroffload.control@1.0_genc++_headers", + tools: ["hidl-gen"], + cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.tetheroffload.control@1.0", + srcs: [ + ":android.hardware.tetheroffload.control@1.0_hal", + ], + out: [ + "android/hardware/tetheroffload/control/1.0/types.h", + "android/hardware/tetheroffload/control/1.0/hwtypes.h", + "android/hardware/tetheroffload/control/1.0/IOffloadControl.h", + "android/hardware/tetheroffload/control/1.0/IHwOffloadControl.h", + "android/hardware/tetheroffload/control/1.0/BnHwOffloadControl.h", + "android/hardware/tetheroffload/control/1.0/BpHwOffloadControl.h", + "android/hardware/tetheroffload/control/1.0/BsOffloadControl.h", + "android/hardware/tetheroffload/control/1.0/ITetheringOffloadCallback.h", + "android/hardware/tetheroffload/control/1.0/IHwTetheringOffloadCallback.h", + "android/hardware/tetheroffload/control/1.0/BnHwTetheringOffloadCallback.h", + "android/hardware/tetheroffload/control/1.0/BpHwTetheringOffloadCallback.h", + "android/hardware/tetheroffload/control/1.0/BsTetheringOffloadCallback.h", + ], +} + +cc_library_shared { + name: "android.hardware.tetheroffload.control@1.0", + generated_sources: ["android.hardware.tetheroffload.control@1.0_genc++"], + generated_headers: ["android.hardware.tetheroffload.control@1.0_genc++_headers"], + export_generated_headers: ["android.hardware.tetheroffload.control@1.0_genc++_headers"], + vendor_available: true, + shared_libs: [ + "libhidlbase", + "libhidltransport", + "libhwbinder", + "liblog", + "libutils", + "libcutils", + "android.hidl.base@1.0", + ], + export_shared_lib_headers: [ + "libhidlbase", + "libhidltransport", + "libhwbinder", + "libutils", + "android.hidl.base@1.0", + ], +} diff --git a/tetheroffload/control/1.0/Android.mk b/tetheroffload/control/1.0/Android.mk new file mode 100644 index 0000000000..6e52c87edd --- /dev/null +++ b/tetheroffload/control/1.0/Android.mk @@ -0,0 +1,274 @@ +# This file is autogenerated by hidl-gen. Do not edit manually. + +LOCAL_PATH := $(call my-dir) + +################################################################################ + +include $(CLEAR_VARS) +LOCAL_MODULE := android.hardware.tetheroffload.control-V1.0-java +LOCAL_MODULE_CLASS := JAVA_LIBRARIES + +intermediates := $(call local-generated-sources-dir, COMMON) + +HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX) + +LOCAL_JAVA_LIBRARIES := \ + android.hidl.base-V1.0-java \ + + +# +# Build types.hal (IPv4AddrPortPair) +# +GEN := $(intermediates)/android/hardware/tetheroffload/control/V1_0/IPv4AddrPortPair.java +$(GEN): $(HIDL) +$(GEN): PRIVATE_HIDL := $(HIDL) +$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal +$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates) +$(GEN): PRIVATE_CUSTOM_TOOL = \ + $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \ + -Ljava \ + -randroid.hardware:hardware/interfaces \ + -randroid.hidl:system/libhidl/transport \ + android.hardware.tetheroffload.control@1.0::types.IPv4AddrPortPair + +$(GEN): $(LOCAL_PATH)/types.hal + $(transform-generated-source) +LOCAL_GENERATED_SOURCES += $(GEN) + +# +# Build types.hal (NatTimeoutUpdate) +# +GEN := $(intermediates)/android/hardware/tetheroffload/control/V1_0/NatTimeoutUpdate.java +$(GEN): $(HIDL) +$(GEN): PRIVATE_HIDL := $(HIDL) +$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal +$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates) +$(GEN): PRIVATE_CUSTOM_TOOL = \ + $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \ + -Ljava \ + -randroid.hardware:hardware/interfaces \ + -randroid.hidl:system/libhidl/transport \ + android.hardware.tetheroffload.control@1.0::types.NatTimeoutUpdate + +$(GEN): $(LOCAL_PATH)/types.hal + $(transform-generated-source) +LOCAL_GENERATED_SOURCES += $(GEN) + +# +# Build types.hal (NetworkProtocol) +# +GEN := $(intermediates)/android/hardware/tetheroffload/control/V1_0/NetworkProtocol.java +$(GEN): $(HIDL) +$(GEN): PRIVATE_HIDL := $(HIDL) +$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal +$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates) +$(GEN): PRIVATE_CUSTOM_TOOL = \ + $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \ + -Ljava \ + -randroid.hardware:hardware/interfaces \ + -randroid.hidl:system/libhidl/transport \ + android.hardware.tetheroffload.control@1.0::types.NetworkProtocol + +$(GEN): $(LOCAL_PATH)/types.hal + $(transform-generated-source) +LOCAL_GENERATED_SOURCES += $(GEN) + +# +# Build types.hal (OffloadCallbackEvent) +# +GEN := $(intermediates)/android/hardware/tetheroffload/control/V1_0/OffloadCallbackEvent.java +$(GEN): $(HIDL) +$(GEN): PRIVATE_HIDL := $(HIDL) +$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal +$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates) +$(GEN): PRIVATE_CUSTOM_TOOL = \ + $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \ + -Ljava \ + -randroid.hardware:hardware/interfaces \ + -randroid.hidl:system/libhidl/transport \ + android.hardware.tetheroffload.control@1.0::types.OffloadCallbackEvent + +$(GEN): $(LOCAL_PATH)/types.hal + $(transform-generated-source) +LOCAL_GENERATED_SOURCES += $(GEN) + +# +# Build IOffloadControl.hal +# +GEN := $(intermediates)/android/hardware/tetheroffload/control/V1_0/IOffloadControl.java +$(GEN): $(HIDL) +$(GEN): PRIVATE_HIDL := $(HIDL) +$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IOffloadControl.hal +$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/ITetheringOffloadCallback.hal +$(GEN): $(LOCAL_PATH)/ITetheringOffloadCallback.hal +$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates) +$(GEN): PRIVATE_CUSTOM_TOOL = \ + $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \ + -Ljava \ + -randroid.hardware:hardware/interfaces \ + -randroid.hidl:system/libhidl/transport \ + android.hardware.tetheroffload.control@1.0::IOffloadControl + +$(GEN): $(LOCAL_PATH)/IOffloadControl.hal + $(transform-generated-source) +LOCAL_GENERATED_SOURCES += $(GEN) + +# +# Build ITetheringOffloadCallback.hal +# +GEN := $(intermediates)/android/hardware/tetheroffload/control/V1_0/ITetheringOffloadCallback.java +$(GEN): $(HIDL) +$(GEN): PRIVATE_HIDL := $(HIDL) +$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/ITetheringOffloadCallback.hal +$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/types.hal +$(GEN): $(LOCAL_PATH)/types.hal +$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates) +$(GEN): PRIVATE_CUSTOM_TOOL = \ + $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \ + -Ljava \ + -randroid.hardware:hardware/interfaces \ + -randroid.hidl:system/libhidl/transport \ + android.hardware.tetheroffload.control@1.0::ITetheringOffloadCallback + +$(GEN): $(LOCAL_PATH)/ITetheringOffloadCallback.hal + $(transform-generated-source) +LOCAL_GENERATED_SOURCES += $(GEN) +include $(BUILD_JAVA_LIBRARY) + + +################################################################################ + +include $(CLEAR_VARS) +LOCAL_MODULE := android.hardware.tetheroffload.control-V1.0-java-static +LOCAL_MODULE_CLASS := JAVA_LIBRARIES + +intermediates := $(call local-generated-sources-dir, COMMON) + +HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX) + +LOCAL_STATIC_JAVA_LIBRARIES := \ + android.hidl.base-V1.0-java-static \ + + +# +# Build types.hal (IPv4AddrPortPair) +# +GEN := $(intermediates)/android/hardware/tetheroffload/control/V1_0/IPv4AddrPortPair.java +$(GEN): $(HIDL) +$(GEN): PRIVATE_HIDL := $(HIDL) +$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal +$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates) +$(GEN): PRIVATE_CUSTOM_TOOL = \ + $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \ + -Ljava \ + -randroid.hardware:hardware/interfaces \ + -randroid.hidl:system/libhidl/transport \ + android.hardware.tetheroffload.control@1.0::types.IPv4AddrPortPair + +$(GEN): $(LOCAL_PATH)/types.hal + $(transform-generated-source) +LOCAL_GENERATED_SOURCES += $(GEN) + +# +# Build types.hal (NatTimeoutUpdate) +# +GEN := $(intermediates)/android/hardware/tetheroffload/control/V1_0/NatTimeoutUpdate.java +$(GEN): $(HIDL) +$(GEN): PRIVATE_HIDL := $(HIDL) +$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal +$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates) +$(GEN): PRIVATE_CUSTOM_TOOL = \ + $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \ + -Ljava \ + -randroid.hardware:hardware/interfaces \ + -randroid.hidl:system/libhidl/transport \ + android.hardware.tetheroffload.control@1.0::types.NatTimeoutUpdate + +$(GEN): $(LOCAL_PATH)/types.hal + $(transform-generated-source) +LOCAL_GENERATED_SOURCES += $(GEN) + +# +# Build types.hal (NetworkProtocol) +# +GEN := $(intermediates)/android/hardware/tetheroffload/control/V1_0/NetworkProtocol.java +$(GEN): $(HIDL) +$(GEN): PRIVATE_HIDL := $(HIDL) +$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal +$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates) +$(GEN): PRIVATE_CUSTOM_TOOL = \ + $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \ + -Ljava \ + -randroid.hardware:hardware/interfaces \ + -randroid.hidl:system/libhidl/transport \ + android.hardware.tetheroffload.control@1.0::types.NetworkProtocol + +$(GEN): $(LOCAL_PATH)/types.hal + $(transform-generated-source) +LOCAL_GENERATED_SOURCES += $(GEN) + +# +# Build types.hal (OffloadCallbackEvent) +# +GEN := $(intermediates)/android/hardware/tetheroffload/control/V1_0/OffloadCallbackEvent.java +$(GEN): $(HIDL) +$(GEN): PRIVATE_HIDL := $(HIDL) +$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal +$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates) +$(GEN): PRIVATE_CUSTOM_TOOL = \ + $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \ + -Ljava \ + -randroid.hardware:hardware/interfaces \ + -randroid.hidl:system/libhidl/transport \ + android.hardware.tetheroffload.control@1.0::types.OffloadCallbackEvent + +$(GEN): $(LOCAL_PATH)/types.hal + $(transform-generated-source) +LOCAL_GENERATED_SOURCES += $(GEN) + +# +# Build IOffloadControl.hal +# +GEN := $(intermediates)/android/hardware/tetheroffload/control/V1_0/IOffloadControl.java +$(GEN): $(HIDL) +$(GEN): PRIVATE_HIDL := $(HIDL) +$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IOffloadControl.hal +$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/ITetheringOffloadCallback.hal +$(GEN): $(LOCAL_PATH)/ITetheringOffloadCallback.hal +$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates) +$(GEN): PRIVATE_CUSTOM_TOOL = \ + $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \ + -Ljava \ + -randroid.hardware:hardware/interfaces \ + -randroid.hidl:system/libhidl/transport \ + android.hardware.tetheroffload.control@1.0::IOffloadControl + +$(GEN): $(LOCAL_PATH)/IOffloadControl.hal + $(transform-generated-source) +LOCAL_GENERATED_SOURCES += $(GEN) + +# +# Build ITetheringOffloadCallback.hal +# +GEN := $(intermediates)/android/hardware/tetheroffload/control/V1_0/ITetheringOffloadCallback.java +$(GEN): $(HIDL) +$(GEN): PRIVATE_HIDL := $(HIDL) +$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/ITetheringOffloadCallback.hal +$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/types.hal +$(GEN): $(LOCAL_PATH)/types.hal +$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates) +$(GEN): PRIVATE_CUSTOM_TOOL = \ + $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \ + -Ljava \ + -randroid.hardware:hardware/interfaces \ + -randroid.hidl:system/libhidl/transport \ + android.hardware.tetheroffload.control@1.0::ITetheringOffloadCallback + +$(GEN): $(LOCAL_PATH)/ITetheringOffloadCallback.hal + $(transform-generated-source) +LOCAL_GENERATED_SOURCES += $(GEN) +include $(BUILD_STATIC_JAVA_LIBRARY) + + + +include $(call all-makefiles-under,$(LOCAL_PATH)) diff --git a/tetheroffload/control/1.0/IOffloadControl.hal b/tetheroffload/control/1.0/IOffloadControl.hal new file mode 100644 index 0000000000..334f4ca7ae --- /dev/null +++ b/tetheroffload/control/1.0/IOffloadControl.hal @@ -0,0 +1,221 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.hardware.tetheroffload.control@1.0; + +import ITetheringOffloadCallback; + + +/** + * Interface used to control the lifecycle of tethering offload + */ +interface IOffloadControl { + /** + * Indicates intent to start offload for tethering in immediate future. + * + * This API must be called exactly once the first time that Tethering is requested by + * the user. + * + * If this API is called multiple times without first calling stopOffload, then the subsequent + * calls must fail without changing the state of the server. + * + * If for some reason, the hardware is currently unable to support offload, this call must fail. + * + * @param cb Assuming success, this callback must provide unsolicited updates of offload status. + * It is assumed to be valid until stopOffload is called. + * + * @return success true if initialization is successful, false otherwise + * @return errMsg a human readable string if eror has occured. + * + * Remarks: Initializing offload does not imply that any upstreams or downstreams have yet been, + * or even will be, chosen. This API is symmetrical with stopOffload. + */ + @entry + @callflow(next={"*"}) + initOffload(ITetheringOffloadCallback cb) generates (bool success, string errMsg); + + /** + * Indicate desire to tear down all tethering offload. + * + * Called after tethering is no longer requested by the user. Any remaining offload must + * be subsequently torn down by the management process. Upon success, the callback registered + * in initOffload must be released, and offload must be stopped. + * + * @return success true if offload is stopped, false otherwise + * @return errMsg a human readable string if eror has occured. + * + * Remarks: Statistics must be reset by this API. + */ + @exit + stopOffload() generates (bool success, string errMsg); + + /** + * Instruct management process not to forward traffic destined to or from the specified prefixes. + * + * This API may only be called after initOffload and before stopOffload. + * + * @param prefixes List containing fully specified prefixes. For e.g. 192.168.1.12/24 + or 2001:4860:0684:0:0:0:0:0:1002/64 + * + * @return success true if success, false otherwise + * @return errMsg a human readable string if eror has occured. + * + * Remarks: This list overrides any previously specified list + */ + setLocalPrefixes(vec<string> prefixes) generates (bool success, string errMsg); + + /** + * Query offloaded traffic statistics forwarded to an upstream address. + * + * Return statistics that have transpired since the last query. This would include + * statistics from all offloaded downstream tether interfaces that have been forwarded to this + * upstream interface. After returning the statistics, the counters are reset to zero. + * + * Only offloaded statistics must be returned by this API, software stats must not be + * returned. + * + * @param upstream Upstream interface on which traffic exited/entered + * + * @return rxBytes values depicting the received bytes + * @return txBytes values depicting the transmitted bytes + */ + getForwardedStats(string upstream) generates (uint64_t rxBytes, uint64_t txBytes); + + /** + * Instruct hardware to stop forwarding traffic and send a callback after limit bytes have been + * transferred in either direction on this upstream interface. + * + * The limit must be applied to all traffic on the given upstream interface. This + * includes hardware forwarded traffic, software forwarded traffic, and AP-originated traffic. + * IPv4 and IPv6 traffic both count towards the same limit. IP headers are included in the + * byte count limit, but, link-layer headers are not. + * + * This API may only be called while offload is occurring on this upstream. The hardware + * management process is not expected to cache the value and apply the quota once offload is + * started. This cache is not expected, because the limit value would likely become stale over + * time and would not reflect any new traffic that has occurred. + * + * This limit must replace any previous limit. It may be interpreted as "tell me when + * <limit> bytes have been transferred (in either direction) on <upstream>, starting + * now and counting from zero." + * + * Once the limit is reached, the callback registered in initOffload must be called to indicate + * this event and all offload must be stopped. If offload is desired again, the hardware + * management process must be completely reprogrammed by calling setUpstreamParameters and + * addDownstream again. Note that it is not necessary to call initOffload again to resume offload + * if stopOffload was not called by the client. + * + * @param upstream Upstream interface name that limit must apply to + * @param limit Bytes limit that can occur before action must be taken + * + * @return success true if limit is applied, false otherwise + * @return errMsg a human readable string if eror has occured. + */ + setDataLimit(string upstream, uint64_t limit) generates (bool success, string errMsg); + + /** + * Instruct hardware to start forwarding traffic to the specified upstream. + * + * When iface, v4Addr, and v4Gw are all non-null, the management process may begin forwarding + * any currently configured or future configured IPv4 downstreams to this upstream interface. + * + * If any of the previously three mentioned parameters are null, then any current IPv4 offload + * must be stopped. + * + * When iface and v6Gws are both non-null, and in the case of v6Gws, are not empty, the + * management process may begin forwarding any currently configured or future configured IPv6 + * downstreams to this upstream interface. + * + * If either of the two above parameters are null, or no V6 Gateways are provided, then IPv6 + * offload must be stopped. + * + * This API may only be called after initOffload and before stopOffload. + * + * @param iface Upstream interface name. Note that only one is needed because IPv4 and IPv6 + * interfaces cannot be different (only known that this can occur during software + * xlat, which cannot be offloaded through hardware anyways). If the iface is + * null, offload must be stopped. + * @param v4Addr The local IPv4 address assigned to the provided upstream interface, i.e. the + * IPv4 address the packets are NATed to. For e.g. 192.168.1.12. + * @param v4Gw The IPv4 address of the IPv4 gateway on the upstream interface. + * For e.g. 192.168.1.1 + * @param v6Gws A list of IPv6 addresses (for e.g. 2001:4860:0684:0:0:0:0:0:1002) for possible + * IPv6 gateways on the upstream interface. + * + * @return success true if success, false otherwise + * @return errMsg a human readable string if eror has occured. + * + * Remarks: This overrides any previously configured parameters. + */ + setUpstreamParameters(string iface, string v4Addr, string v4Gw, vec<string> v6Gws) + generates (bool success, string errMsg); + + /** + * Configure a downstream interface and prefix in the hardware management process that may be + * forwarded. + * + * The prefix may be an IPv4 or an IPv6 address to signify which family can be offloaded from the + * specified tether interface. The list of IPv4 and IPv6 downstreams that are configured may + * differ. + * + * If the given protocol, as determined by the prefix, has an upstream set, + * the hardware may begin forwarding traffic between the upstream and any devices on the + * downstream interface that have IP addresses within the specified prefix. Traffic from the same + * downstream interfaces is unaffected and must be forwarded if and only if it was already + * being forwarded. + * + * If no upstream is currently configured, then these downstream interface and prefixes must be + * preserved so that offload may begin in the future when an upstream is set. + * + * This API does not replace any previously configured downstreams and must be explictly removed + * by calling removeDownstream. + * + * This API may only be called after initOffload and before stopOffload. + * + * @param iface Tether interface + * @param prefix Downstream prefix depicting addresses that may be offloaded. + * For e.g. 192.168.1.12/24 or 2001:4860:0684::/64) + * + * @return success true if success, false otherwise + * @return errMsg a human readable string if eror has occured. + * + * Remarks: The hardware management process may fail this call in a normal situation. This can + * happen because the hardware cannot support the current number of prefixes, the + * hardware cannot support concurrent offload on multiple interfaces, the hardware + * cannot currently support offload on the tether interface for some reason, or any + * other dynamic configuration issues which may occur. In this case, + * traffic must remain unaffected and must be forwarded if and only if it was already + * being forwarded. + */ + addDownstream(string iface, string prefix) generates (bool success, string errMsg); + + /** + * Remove a downstream prefix that may be forwarded from the hardware management process. + * + * The prefix may be an IPv4 or an IPv6 address. If it was not previously configured using + * addDownstream, then this must be a no-op. + * + * This API may only be called after initOffload and before stopOffload. + * + * @param iface Tether interface + * @param prefix Downstream prefix depicting address that must no longer be offloaded + * For e.g. 192.168.1.12/24 or 2001:4860:0684::/64) + * + * @return success true if success, false otherwise + * @return errMsg a human readable string if eror has occured. + */ + removeDownstream(string iface, string prefix) generates (bool success, string errMsg); +}; diff --git a/tetheroffload/control/1.0/ITetheringOffloadCallback.hal b/tetheroffload/control/1.0/ITetheringOffloadCallback.hal new file mode 100644 index 0000000000..397667f3fd --- /dev/null +++ b/tetheroffload/control/1.0/ITetheringOffloadCallback.hal @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.hardware.tetheroffload.control@1.0; + +/** + * Callback providing information about status of hardware management process + * as well as providing a way to keep offloaded connections from timing out. + */ +interface ITetheringOffloadCallback { + /** + * Called when an asynchronous event is generated by the hardware management + * process. + */ + oneway onEvent(OffloadCallbackEvent event); + + /** + * Provide a way for the management process to request that a connections + * timeout be updated in kernel. + * + * This is necessary to ensure that offloaded traffic is not cleaned up + * by the kernel connection tracking module for IPv4. + */ + oneway updateTimeout(NatTimeoutUpdate params); +}; diff --git a/tetheroffload/control/1.0/types.hal b/tetheroffload/control/1.0/types.hal new file mode 100644 index 0000000000..e2576accf5 --- /dev/null +++ b/tetheroffload/control/1.0/types.hal @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.hardware.tetheroffload.control@1.0; + +enum OffloadCallbackEvent : uint32_t { + /** + * Indicate that a working configuration has been programmed and the + * hardware management process has begun forwarding traffic. + */ + OFFLOAD_STARTED = 1, + /** + * Indicate that an error has occurred which has disrupted hardware + * acceleration. Software routing may still be attempted; however, + * statistics may be temporarily unavailable. Statistics may be recovered + * after OFFLOAD_SUPPORT_AVAILABLE event is fired. + */ + OFFLOAD_STOPPED_ERROR = 2, + /** + * Indicate that the device has moved to a RAT on which hardware + * acceleration is not supported. Subsequent calls to setUpstreamParameters + * and add/removeDownstream will likely fail and cannot be presumed to be + * saved inside of the hardware management process. Upon receiving + * OFFLOAD_SUPPORT_AVAIALBLE, the client may reprogram the hardware + * management process to begin offload again. + */ + OFFLOAD_STOPPED_UNSUPPORTED = 3, + /** + * Indicate that the hardware management process is willing and able to + * provide support for hardware acceleration at this time. If applicable, + * the client may query for statistics. If offload is desired, the client + * must reprogram the hardware management process. + */ + OFFLOAD_SUPPORT_AVAILABLE = 4, + /** + * Hardware acceleration is no longer in effect and must be reprogrammed + * in order to resume. This event is fired when the limit, applied in + * setDataLimit, has expired. It is recommended that the client query for + * statistics immediately after receiving this event. + */ + OFFLOAD_STOPPED_LIMIT_REACHED = 5 +}; + +enum NetworkProtocol : uint32_t { + TCP = 6, + UDP = 17 +}; + +struct IPv4AddrPortPair { + /** IPv4 Address and Port */ + string addr; // for e.g. 192.168.1.12 + uint16_t port; // for e.g. 8080 +}; + +struct NatTimeoutUpdate { + IPv4AddrPortPair src; + IPv4AddrPortPair dst; + NetworkProtocol proto; +}; |