diff options
author | Purushottam Kushwaha <pkushwah@codeaurora.org> | 2018-06-07 23:05:16 +0530 |
---|---|---|
committer | Bruno Martins <bgcngm@gmail.com> | 2020-04-17 20:40:45 +0200 |
commit | 800c778d9aa8c5fdeffd688e6ba3dd8dcb46930f (patch) | |
tree | cda3e994d8cfac387415f0e7cb02158222fcbfbe /wifi/1.3/default/wifi_chip.cpp | |
parent | 26d9c2a4ab696cbdcfe71b7a80afa1a97cc172e2 (diff) | |
download | android_hardware_interfaces-800c778d9aa8c5fdeffd688e6ba3dd8dcb46930f.tar.gz android_hardware_interfaces-800c778d9aa8c5fdeffd688e6ba3dd8dcb46930f.tar.bz2 android_hardware_interfaces-800c778d9aa8c5fdeffd688e6ba3dd8dcb46930f.zip |
wifi: Add provision to create/remove dynamic interface(s).
This commit does following:
- Add/Remove softap interface at runtime, if needed.
- Use wlan.concurrent.interface as default softap interface.
- Add build time support to enable SAP+SAP feature using
QC_WIFI_HIDL_FEATURE_DUAL_AP flag. if enabled use wlan.interface
as second SAP interface.
Change-Id: Icde3d54eda0f142e20f33cdb7ed95152eeee0bec
CRs-Fixed: 2257197
Diffstat (limited to 'wifi/1.3/default/wifi_chip.cpp')
-rw-r--r-- | wifi/1.3/default/wifi_chip.cpp | 56 |
1 files changed, 48 insertions, 8 deletions
diff --git a/wifi/1.3/default/wifi_chip.cpp b/wifi/1.3/default/wifi_chip.cpp index 0d33ae6e2..3acc487cb 100644 --- a/wifi/1.3/default/wifi_chip.cpp +++ b/wifi/1.3/default/wifi_chip.cpp @@ -21,6 +21,7 @@ #include <cutils/properties.h> #include <sys/stat.h> #include <sys/sysmacros.h> +#include <net/if.h> #include "hidl_return_util.h" #include "hidl_struct_util.h" @@ -107,12 +108,6 @@ std::string getP2pIfaceName() { return buffer.data(); } -std::string getApIfaceName() { - std::array<char, PROPERTY_VALUE_MAX> buffer; - property_get("persist.vendor.wifi.softap.interface", buffer.data(), ""); - return buffer.data(); -} - void setActiveWlanIfaceNameProperty(const std::string& ifname) { auto res = property_set(kActiveWlanIfaceNameProperty, ifname.data()); if (res != 0) { @@ -632,6 +627,7 @@ void WifiChip::invalidateAndRemoveAllIfaces() { invalidateAndClearAll(nan_ifaces_); invalidateAndClearAll(p2p_ifaces_); invalidateAndClearAll(sta_ifaces_); + invalidateAndClearAll(created_ap_ifaces_); // Since all the ifaces are invalid now, all RTT controller objects // using those ifaces also need to be invalidated. for (const auto& rtt : rtt_controllers_) { @@ -811,12 +807,29 @@ std::pair<WifiStatus, sp<IWifiApIface>> WifiChip::createApIfaceInternal() { if (!canCurrentModeSupportIfaceOfTypeWithCurrentIfaces(IfaceType::AP)) { return {createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE), {}}; } - std::string ifname = getApIfaceName(); - if (ifname.empty()) + + std::string ifname = ""; + bool iface_created = false; + if (feature_flags_.lock()->isDualInterfaceSupported()) + ifname = qcAllocateApIfaceName(); + else ifname = allocateApIfaceName(); + + if (!if_nametoindex(ifname.c_str())) { + legacy_hal::wifi_error legacy_status = + legacy_hal_.lock()->QcAddInterface(getWlan0IfaceName(), ifname, + (uint32_t)IfaceType::AP); + if (legacy_status != legacy_hal::WIFI_SUCCESS) { + LOG(ERROR) << "Failed to add interface: " << ifname << " " + << legacyErrorToString(legacy_status); + return {createWifiStatusFromLegacyError(legacy_status), {}}; + } + iface_created = true; + } sp<WifiApIface> iface = new WifiApIface(ifname, legacy_hal_, iface_util_, feature_flags_); ap_ifaces_.push_back(iface); + if (iface_created) created_ap_ifaces_.push_back(iface); for (const auto& callback : event_cb_handler_.getCallbacks()) { if (!callback->onIfaceAdded(IfaceType::AP, ifname).isOk()) { LOG(ERROR) << "Failed to invoke onIfaceAdded callback"; @@ -848,6 +861,16 @@ WifiStatus WifiChip::removeApIfaceInternal(const std::string& ifname) { if (!iface.get()) { return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS); } + + if (findUsingName(created_ap_ifaces_, ifname) != nullptr) { + legacy_hal::wifi_error legacy_status = + legacy_hal_.lock()->QcRemoveInterface(getWlan0IfaceName(), ifname); + if (legacy_status != legacy_hal::WIFI_SUCCESS) { + LOG(ERROR) << "Failed to remove interface: " << ifname << " " + << legacyErrorToString(legacy_status); + } + invalidateAndClear(created_ap_ifaces_, iface); + } // Invalidate & remove any dependent objects first. // Note: This is probably not required because we never create // nan/rtt objects over AP iface. But, there is no harm to do it @@ -1517,6 +1540,23 @@ std::string WifiChip::allocateStaIfaceName() { return allocateApOrStaIfaceName(0); } +// Return "wlan1", if "wlan1" is not already in use, else return "wlan0". +// This is based on the assumption that we'll have a max of 2 concurrent +// AP ifaces. +std::string WifiChip::qcAllocateApIfaceName() { + auto ap_iface = findUsingName(ap_ifaces_, getWlan1IfaceName()); + if (!ap_iface.get()) { + return getWlan1IfaceName(); + } + ap_iface = findUsingName(ap_ifaces_, getWlan0IfaceName()); + if (!ap_iface.get()) { + return getWlan0IfaceName(); + } + // This should never happen. We screwed up somewhere if it did. + CHECK(0) << "wlan0 and wlan1 in use already!"; + return {}; +} + bool WifiChip::writeRingbufferFilesInternal() { if (!removeOldFilesInternal()) { LOG(ERROR) << "Error occurred while deleting old tombstone files"; |