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

Commit 2dddd79e authored by Jimmy Chen's avatar Jimmy Chen
Browse files

Wifi: support multiple WIFI chips

The WIFI HAL API has support for multiple WIFI chips
(IWifiChip instances) however the implementation
is hard-coded to support only a single WIFI chip.
This change reworks the implementation so multiple
WIFI chips will be supported.
Support for multiple chips is based on the concept
that each chip is represented by its own vendor HAL
library.
The implementation will look for descriptor
files for vendor HAL libraries under
/vendor/etc/wifi/vendor_hals. It will parse
descriptors, dynamically load vendor HAL libraries
and create WifiLegacyHal and WifiChip objects for
each loaded vendor HAL library.
One of the descriptors should be marked with "primary"
flag. The implementation will create the first WifiChip
object for this library. Typically it is the one
providing the best WIFI functionality, which was
previously used as the only WIFI chip.
Additional support is added inside WifiChip and
WifiLegacyHal for getting available chip modes
and concurrency combinations from the vendor HAL
if available, and allowing the chip to override
network interface name when creating interfaces.
The mechanism for getting chip capabilities is
improved to allow getting chip-global capabilities,
which are independent of any created interfaces.
For example, if the framework needs to start
a SoftAP on the 60GHz band, it needs to find a
chip which supports this band, but before creating
any interface on the chip. The new mechanism allows
this.

Bug: 146922967
Test: atest VtsHalWifiV1_0TargetTest VtsHalWifiNanV1_0TargetTest VtsHalWifiApV1_0TargetTest \
            VtsHalWifiV1_1TargetTest \
            VtsHalWifiV1_2TargetTest VtsHalWifiNanV1_2TargetTest \
            VtsHalWifiV1_3TargetTest \
            VtsHalWifiApV1_4TargetTest VtsHalWifiNanV1_4TargetTest VtsHalWifiRttV1_4TargetTest
Change-Id: Ibdff93ea56aff186d4b5361ac77f6f448a0dfd45
parent 7a82ad8c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -112,7 +112,7 @@ sp<IWifiChip> getWifiChip(const std::string& instance_name) {
    const auto& status_and_chip_ids = HIDL_INVOKE(wifi, getChipIds);
    const auto& chip_ids = status_and_chip_ids.second;
    if (status_and_chip_ids.first.code != WifiStatusCode::SUCCESS ||
        chip_ids.size() != 1) {
        chip_ids.size() < 1) {
        return nullptr;
    }
    const auto& status_and_chip = HIDL_INVOKE(wifi, getChip, chip_ids[0]);
+5 −0
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ LOCAL_SRC_FILES := \
    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 \
@@ -67,12 +68,14 @@ LOCAL_SHARED_LIBRARIES := \
    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
LOCAL_C_INCLUDES += $(TOP)/external/libxml2/include
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
include $(BUILD_STATIC_LIBRARY)

@@ -96,6 +99,7 @@ LOCAL_SHARED_LIBRARIES := \
    libutils \
    libwifi-hal \
    libwifi-system-iface \
    libxml2 \
    android.hardware.wifi@1.0 \
    android.hardware.wifi@1.1 \
    android.hardware.wifi@1.2 \
@@ -129,6 +133,7 @@ LOCAL_SHARED_LIBRARIES := \
    libutils \
    libwifi-hal \
    libwifi-system-iface \
    libxml2 \
    android.hardware.wifi@1.0 \
    android.hardware.wifi@1.1 \
    android.hardware.wifi@1.2 \
+7 −1
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@
#include "wifi.h"
#include "wifi_feature_flags.h"
#include "wifi_legacy_hal.h"
#include "wifi_legacy_hal_factory.h"
#include "wifi_mode_controller.h"

using android::hardware::configureRpcThreadpool;
@@ -32,6 +33,8 @@ using android::hardware::wifi::V1_5::implementation::feature_flags::
    WifiFeatureFlags;
using android::hardware::wifi::V1_5::implementation::iface_util::WifiIfaceUtil;
using android::hardware::wifi::V1_5::implementation::legacy_hal::WifiLegacyHal;
using android::hardware::wifi::V1_5::implementation::legacy_hal::
    WifiLegacyHalFactory;
using android::hardware::wifi::V1_5::implementation::mode_controller::
    WifiModeController;

@@ -50,10 +53,13 @@ int main(int /*argc*/, char** argv) {

    const auto iface_tool =
        std::make_shared<android::wifi_system::InterfaceTool>();
    const auto legacy_hal_factory =
        std::make_shared<WifiLegacyHalFactory>(iface_tool);

    // Setup hwbinder service
    android::sp<android::hardware::wifi::V1_5::IWifi> service =
        new android::hardware::wifi::V1_5::implementation::Wifi(
            iface_tool, std::make_shared<WifiLegacyHal>(iface_tool),
            iface_tool, legacy_hal_factory,
            std::make_shared<WifiModeController>(),
            std::make_shared<WifiIfaceUtil>(iface_tool),
            std::make_shared<WifiFeatureFlags>());
+2 −1
Original line number Diff line number Diff line
@@ -33,7 +33,8 @@ class MockWifiFeatureFlags : public WifiFeatureFlags {
   public:
    MockWifiFeatureFlags();

    MOCK_METHOD0(getChipModes, std::vector<V1_0::IWifiChip::ChipMode>());
    MOCK_METHOD1(getChipModes,
                 std::vector<V1_0::IWifiChip::ChipMode>(bool is_primary));
    MOCK_METHOD0(isApMacRandomizationDisabled, bool());
};

+3 −2
Original line number Diff line number Diff line
@@ -29,8 +29,9 @@ namespace implementation {
namespace legacy_hal {

MockWifiLegacyHal::MockWifiLegacyHal(
    const std::weak_ptr<wifi_system::InterfaceTool> iface_tool)
    : WifiLegacyHal(iface_tool) {}
    const std::weak_ptr<wifi_system::InterfaceTool> iface_tool,
    const wifi_hal_fn& fn, bool is_primary)
    : WifiLegacyHal(iface_tool, fn, is_primary) {}
}  // namespace legacy_hal
}  // namespace implementation
}  // namespace V1_5
Loading