Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0c045862 authored by Gabriel Biren's avatar Gabriel Biren Committed by Android (Google) Code Review
Browse files

Merge "Remove HIDL implementation for the WiFi Vendor HAL." into udc-dev

parents 6ef7a20d 7b65166e
Loading
Loading
Loading
Loading

wifi/1.6/default/Android.bp

deleted100644 → 0
+0 −242
Original line number Original line Diff line number Diff line
// Copyright (C) 2021 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 {
    default_applicable_licenses: ["hardware_interfaces_license"],
}

soong_config_module_type {
    name: "wifi_hal_cc_defaults",
    module_type: "cc_defaults",
    config_namespace: "wifi",
    bool_variables: [
        "hidl_feature_aware", // WIFI_HIDL_FEATURE_AWARE
        "hidl_feature_dual_interface", // WIFI_HIDL_FEATURE_DUAL_INTERFACE
        "hidl_feature_disable_ap", // WIFI_HIDL_FEATURE_DISABLE_AP
        "hidl_feature_disable_ap_mac_randomization", // WIFI_HIDL_FEATURE_DISABLE_AP_MAC_RANDOMIZATION
        "avoid_iface_reset_mac_change", // WIFI_AVOID_IFACE_RESET_MAC_CHANGE
        "wifi_skip_state_toggle_off_on_for_nan", // WIFI_SKIP_STATE_TOGGLE_OFF_ON_FOR_NAN
    ],
    value_variables: [
        "hal_interface_combinations", // WIFI_HAL_INTERFACE_COMBINATIONS
    ],
    properties: [
        "cppflags",
    ],
}

wifi_hal_cc_defaults {
    name: "android.hardware.wifi@1.0-service-cppflags-defaults",
    soong_config_variables: {
        hidl_feature_aware: {
            cppflags: ["-DWIFI_HIDL_FEATURE_AWARE"],
        },
        hidl_feature_dual_interface: {
            cppflags: ["-DWIFI_HIDL_FEATURE_DUAL_INTERFACE"],
        },
        hidl_feature_disable_ap: {
            cppflags: ["-DWIFI_HIDL_FEATURE_DISABLE_AP"],
        },
        hidl_feature_disable_ap_mac_randomization: {
            cppflags: ["-DWIFI_HIDL_FEATURE_DISABLE_AP_MAC_RANDOMIZATION"],
        },
        avoid_iface_reset_mac_change: {
            cppflags: ["-DWIFI_AVOID_IFACE_RESET_MAC_CHANGE"],
        },
        wifi_skip_state_toggle_off_on_for_nan: {
            cppflags: ["-DWIFI_SKIP_STATE_TOGGLE_OFF_ON_FOR_NAN"],
        },
        hal_interface_combinations: {
            cppflags: ["-DWIFI_HAL_INTERFACE_COMBINATIONS=%s"],
        },
    },
}

cc_library_static {
    name: "android.hardware.wifi@1.0-service-lib",
    defaults: ["android.hardware.wifi@1.0-service-cppflags-defaults"],
    proprietary: true,
    compile_multilib: "first",
    cppflags: [
        "-Wall",
        "-Werror",
        "-Wextra",
    ],
    // Allow implicit fallthroughs in wifi_legacy_hal.cpp until they are fixed.
    cflags: ["-Wno-error=implicit-fallthrough"],
    srcs: [
        "hidl_struct_util.cpp",
        "hidl_sync_util.cpp",
        "ringbuffer.cpp",
        "wifi.cpp",
        "wifi_ap_iface.cpp",
        "wifi_chip.cpp",
        "wifi_feature_flags.cpp",
        "wifi_iface_util.cpp",
        "wifi_legacy_hal.cpp",
        "wifi_legacy_hal_factory.cpp",
        "wifi_legacy_hal_stubs.cpp",
        "wifi_mode_controller.cpp",
        "wifi_nan_iface.cpp",
        "wifi_p2p_iface.cpp",
        "wifi_rtt_controller.cpp",
        "wifi_sta_iface.cpp",
        "wifi_status_util.cpp",
    ],

    shared_libs: [
        "libbase",
        "libcutils",
        "libhidlbase",
        "liblog",
        "libnl",
        "libutils",
        "libwifi-hal",
        "libwifi-system-iface",
        "libxml2",
        "android.hardware.wifi@1.0",
        "android.hardware.wifi@1.1",
        "android.hardware.wifi@1.2",
        "android.hardware.wifi@1.3",
        "android.hardware.wifi@1.4",
        "android.hardware.wifi@1.5",
        "android.hardware.wifi@1.6",
    ],

    export_include_dirs: ["."],
}

cc_binary {
    name: "android.hardware.wifi@1.0-service",
    vintf_fragments: ["android.hardware.wifi@1.0-service.xml"],
    relative_install_path: "hw",
    proprietary: true,
    cppflags: [
        "-Wall",
        "-Werror",
        "-Wextra",
    ],
    srcs: ["service.cpp"],
    shared_libs: [
        "libbase",
        "libcutils",
        "libhidlbase",
        "liblog",
        "libnl",
        "libutils",
        "libwifi-hal",
        "libwifi-system-iface",
        "libxml2",
        "android.hardware.wifi@1.0",
        "android.hardware.wifi@1.1",
        "android.hardware.wifi@1.2",
        "android.hardware.wifi@1.3",
        "android.hardware.wifi@1.4",
        "android.hardware.wifi@1.5",
        "android.hardware.wifi@1.6",
    ],
    static_libs: ["android.hardware.wifi@1.0-service-lib"],
    init_rc: ["android.hardware.wifi@1.0-service.rc"],
}

cc_binary {
    name: "android.hardware.wifi@1.0-service-lazy",
    vintf_fragments: ["android.hardware.wifi@1.0-service.xml"],
    overrides: ["android.hardware.wifi@1.0-service"],
    cflags: ["-DLAZY_SERVICE"],
    relative_install_path: "hw",
    proprietary: true,
    cppflags: [
        "-Wall",
        "-Werror",
        "-Wextra",
    ],
    srcs: ["service.cpp"],
    shared_libs: [
        "libbase",
        "libcutils",
        "libhidlbase",
        "liblog",
        "libnl",
        "libutils",
        "libwifi-hal",
        "libwifi-system-iface",
        "libxml2",
        "android.hardware.wifi@1.0",
        "android.hardware.wifi@1.1",
        "android.hardware.wifi@1.2",
        "android.hardware.wifi@1.3",
        "android.hardware.wifi@1.4",
        "android.hardware.wifi@1.5",
        "android.hardware.wifi@1.6",
    ],
    static_libs: ["android.hardware.wifi@1.0-service-lib"],
    init_rc: ["android.hardware.wifi@1.0-service-lazy.rc"],
}

cc_test {
    name: "android.hardware.wifi@1.0-service-tests",
    proprietary: true,
    compile_multilib: "first",
    cppflags: [
        "-Wall",
        "-Werror",
        "-Wextra",
    ],
    srcs: [
        "tests/hidl_struct_util_unit_tests.cpp",
        "tests/main.cpp",
        "tests/mock_interface_tool.cpp",
        "tests/mock_wifi_feature_flags.cpp",
        "tests/mock_wifi_iface_util.cpp",
        "tests/mock_wifi_legacy_hal.cpp",
        "tests/mock_wifi_mode_controller.cpp",
        "tests/ringbuffer_unit_tests.cpp",
        "tests/wifi_nan_iface_unit_tests.cpp",
        "tests/wifi_chip_unit_tests.cpp",
        "tests/wifi_iface_util_unit_tests.cpp",
    ],
    static_libs: [
        "libgmock",
        "libgtest",
        "android.hardware.wifi@1.0",
        "android.hardware.wifi@1.1",
        "android.hardware.wifi@1.2",
        "android.hardware.wifi@1.3",
        "android.hardware.wifi@1.4",
        "android.hardware.wifi@1.5",
        "android.hardware.wifi@1.6",
        "android.hardware.wifi@1.0-service-lib",
    ],
    shared_libs: [
        "libbase",
        "libcutils",
        "libhidlbase",
        "liblog",
        "libnl",
        "libutils",
        "libwifi-hal",
        "libwifi-system-iface",
    ],
}

filegroup {
    name: "default-android.hardware.wifi@1.0-service.rc",
    srcs: ["android.hardware.wifi@1.0-service.rc"],
}

filegroup {
    name: "default-android.hardware.wifi@1.0-service.xml",
    srcs: ["android.hardware.wifi@1.0-service.xml"],
}

wifi/1.6/default/THREADING.README

deleted100644 → 0
+0 −35
Original line number Original line Diff line number Diff line
Vendor HAL Threading Model
==========================
The vendor HAL service has two threads:
1. HIDL thread: This is the main thread which processes all the incoming HIDL
RPC's.
2. Legacy HAL event loop thread: This is the thread forked off for processing
the legacy HAL event loop (wifi_event_loop()). This thread is used to process
any asynchronous netlink events posted by the driver. Any asynchronous
callbacks passed to the legacy HAL API's are invoked on this thread.

Synchronization Concerns
========================
wifi_legacy_hal.cpp has a bunch of global "C" style functions to handle the
legacy callbacks. Each of these "C" style function invokes a corresponding
"std::function" version of the callback which does the actual processing.
The variables holding these "std::function" callbacks are reset from the HIDL
thread when they are no longer used. For example: stopGscan() will reset the
corresponding "on_gscan_*" callback variables which were set when startGscan()
was invoked. This is not thread safe since these callback variables are
accesed from the legacy hal event loop thread as well.

Synchronization Solution
========================
Adding a global lock seems to be the most trivial solution to the problem.
a) All of the asynchronous "C" style callbacks will acquire the global lock
before invoking the corresponding "std::function" callback variables.
b) All of the HIDL methods will also acquire the global lock before processing
(in hidl_return_util::validateAndCall()).

Note: It's important that we only acquire the global lock for asynchronous
callbacks, because there is no guarantee (or documentation to clarify) that the
synchronous callbacks are invoked on the same invocation thread. If that is not
the case in some implementation, we will end up deadlocking the system since the
HIDL thread would have acquired the global lock which is needed by the
synchronous callback executed on the legacy hal event loop thread.
+0 −14
Original line number Original line Diff line number Diff line
service vendor.wifi_hal_legacy /vendor/bin/hw/android.hardware.wifi@1.0-service-lazy
    interface android.hardware.wifi@1.0::IWifi default
    interface android.hardware.wifi@1.1::IWifi default
    interface android.hardware.wifi@1.2::IWifi default
    interface android.hardware.wifi@1.3::IWifi default
    interface android.hardware.wifi@1.4::IWifi default
    interface android.hardware.wifi@1.5::IWifi default
    interface android.hardware.wifi@1.6::IWifi default
    oneshot
    disabled
    class hal
    capabilities NET_ADMIN NET_RAW SYS_MODULE
    user wifi
    group wifi gps
+0 −12
Original line number Original line Diff line number Diff line
service vendor.wifi_hal_legacy /vendor/bin/hw/android.hardware.wifi@1.0-service
    interface android.hardware.wifi@1.0::IWifi default
    interface android.hardware.wifi@1.1::IWifi default
    interface android.hardware.wifi@1.2::IWifi default
    interface android.hardware.wifi@1.3::IWifi default
    interface android.hardware.wifi@1.4::IWifi default
    interface android.hardware.wifi@1.5::IWifi default
    interface android.hardware.wifi@1.6::IWifi default
    class hal
    capabilities NET_ADMIN NET_RAW SYS_MODULE
    user wifi
    group wifi gps
+0 −11
Original line number Original line Diff line number Diff line
<manifest version="1.0" type="device">
    <hal format="hidl">
        <name>android.hardware.wifi</name>
        <transport>hwbinder</transport>
        <version>1.6</version>
        <interface>
            <name>IWifi</name>
            <instance>default</instance>
        </interface>
    </hal>
</manifest>
Loading