summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPurushottam Kushwaha <pkushwah@codeaurora.org>2018-06-07 23:05:16 +0530
committerBruno Martins <bgcngm@gmail.com>2020-04-17 20:40:45 +0200
commit800c778d9aa8c5fdeffd688e6ba3dd8dcb46930f (patch)
treecda3e994d8cfac387415f0e7cb02158222fcbfbe
parent26d9c2a4ab696cbdcfe71b7a80afa1a97cc172e2 (diff)
downloadandroid_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
-rw-r--r--wifi/1.3/default/Android.mk3
-rw-r--r--wifi/1.3/default/wifi_chip.cpp56
-rw-r--r--wifi/1.3/default/wifi_chip.h3
-rw-r--r--wifi/1.3/default/wifi_feature_flags.cpp28
-rw-r--r--wifi/1.3/default/wifi_legacy_hal.cpp29
-rw-r--r--wifi/1.3/default/wifi_legacy_hal.h7
6 files changed, 111 insertions, 15 deletions
diff --git a/wifi/1.3/default/Android.mk b/wifi/1.3/default/Android.mk
index 0a3809cce..0fb42177b 100644
--- a/wifi/1.3/default/Android.mk
+++ b/wifi/1.3/default/Android.mk
@@ -36,6 +36,9 @@ endif
ifdef WIFI_HIDL_FEATURE_DISABLE_AP_MAC_RANDOMIZATION
LOCAL_CPPFLAGS += -DWIFI_HIDL_FEATURE_DISABLE_AP_MAC_RANDOMIZATION
endif
+ifdef QC_WIFI_HIDL_FEATURE_DUAL_AP
+LOCAL_CPPFLAGS += -DQC_WIFI_HIDL_FEATURE_DUAL_AP
+endif
# Allow implicit fallthroughs in wifi_legacy_hal.cpp until they are fixed.
LOCAL_CFLAGS += -Wno-error=implicit-fallthrough
LOCAL_SRC_FILES := \
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";
diff --git a/wifi/1.3/default/wifi_chip.h b/wifi/1.3/default/wifi_chip.h
index 153ca6a62..353abda98 100644
--- a/wifi/1.3/default/wifi_chip.h
+++ b/wifi/1.3/default/wifi_chip.h
@@ -245,6 +245,7 @@ class WifiChip : public V1_3::IWifiChip {
std::string allocateApOrStaIfaceName(uint32_t start_idx);
std::string allocateApIfaceName();
std::string allocateStaIfaceName();
+ std::string qcAllocateApIfaceName();
bool writeRingbufferFilesInternal();
ChipId chip_id_;
@@ -269,6 +270,8 @@ class WifiChip : public V1_3::IWifiChip {
hidl_callback_util::HidlCallbackHandler<V1_2::IWifiChipEventCallback>
event_cb_handler_;
+ std::vector<sp<WifiApIface>> created_ap_ifaces_;
+
DISALLOW_COPY_AND_ASSIGN(WifiChip);
};
diff --git a/wifi/1.3/default/wifi_feature_flags.cpp b/wifi/1.3/default/wifi_feature_flags.cpp
index 7212cfac3..a0ffab790 100644
--- a/wifi/1.3/default/wifi_feature_flags.cpp
+++ b/wifi/1.3/default/wifi_feature_flags.cpp
@@ -79,14 +79,28 @@ constexpr ChipModeId kMainModeId = chip_mode_ids::kV3;
# define WIFI_HAL_INTERFACE_COMBINATIONS {{{STA}, 1}, {{P2P}, 1}}
# endif
# else
-# ifdef WIFI_HIDL_FEATURE_AWARE
-// (1 STA + 1 AP) or (1 STA + 1 of (P2P or NAN))
-# define WIFI_HAL_INTERFACE_COMBINATIONS {{{STA}, 1}, {{AP}, 1}},\
- {{{STA}, 1}, {{P2P, NAN}, 1}}
+# ifdef QC_WIFI_HIDL_FEATURE_DUAL_AP
+# ifdef WIFI_HIDL_FEATURE_AWARE
+// (1 STA + 1 AP) or (1 STA + 1 of (P2P or NAN)) or (2 AP)
+# define WIFI_HAL_INTERFACE_COMBINATIONS {{{STA}, 1}, {{AP}, 1}},\
+ {{{STA}, 1}, {{P2P, NAN}, 1}},\
+ {{{AP}, 2}}
+# else
+// (1 STA + 1 AP) or (1 STA + 1 P2P) or (2 AP)
+# define WIFI_HAL_INTERFACE_COMBINATIONS {{{STA}, 1}, {{AP}, 1}},\
+ {{{STA}, 1}, {{P2P}, 1}},\
+ {{{AP}, 2}}
+# endif
# else
-// (1 STA + 1 AP) or (1 STA + 1 P2P)
-# define WIFI_HAL_INTERFACE_COMBINATIONS {{{STA}, 1}, {{AP}, 1}},\
- {{{STA}, 1}, {{P2P}, 1}}
+# ifdef WIFI_HIDL_FEATURE_AWARE
+// (1 STA + 1 AP) or (1 STA + 1 of (P2P or NAN))
+# define WIFI_HAL_INTERFACE_COMBINATIONS {{{STA}, 1}, {{AP}, 1}},\
+ {{{STA}, 1}, {{P2P, NAN}, 1}}
+# else
+// (1 STA + 1 AP) or (1 STA + 1 P2P)
+# define WIFI_HAL_INTERFACE_COMBINATIONS {{{STA}, 1}, {{AP}, 1}},\
+ {{{STA}, 1}, {{P2P}, 1}}
+# endif
# endif
# endif
#else
diff --git a/wifi/1.3/default/wifi_legacy_hal.cpp b/wifi/1.3/default/wifi_legacy_hal.cpp
index 485bd1663..5240d5bfc 100644
--- a/wifi/1.3/default/wifi_legacy_hal.cpp
+++ b/wifi/1.3/default/wifi_legacy_hal.cpp
@@ -1415,6 +1415,35 @@ WifiLegacyHal::getGscanCachedResults(const std::string& iface_name) {
return {status, std::move(cached_scan_results)};
}
+wifi_error WifiLegacyHal::QcAddInterface(const std::string& iface_name,
+ const std::string& new_ifname,
+ uint32_t type) {
+ wifi_error status = global_func_table_.wifi_add_or_remove_virtual_intf(
+ getIfaceHandle(iface_name),
+ new_ifname.c_str(), type, true);
+
+ if (status == WIFI_SUCCESS) {
+ // refresh list of handlers now.
+ iface_name_to_handle_.clear();
+ status = retrieveIfaceHandles();
+ }
+ return status;
+}
+
+wifi_error WifiLegacyHal::QcRemoveInterface(const std::string& iface_name,
+ const std::string& ifname) {
+ wifi_error status = global_func_table_.wifi_add_or_remove_virtual_intf(
+ getIfaceHandle(iface_name),
+ ifname.c_str(), 0, false);
+
+ if (status == WIFI_SUCCESS) {
+ // refresh list of handlers now.
+ iface_name_to_handle_.clear();
+ status = retrieveIfaceHandles();
+ }
+ return status;
+}
+
void WifiLegacyHal::invalidate() {
global_handle_ = nullptr;
iface_name_to_handle_.clear();
diff --git a/wifi/1.3/default/wifi_legacy_hal.h b/wifi/1.3/default/wifi_legacy_hal.h
index 9cfa17240..f88728b9c 100644
--- a/wifi/1.3/default/wifi_legacy_hal.h
+++ b/wifi/1.3/default/wifi_legacy_hal.h
@@ -367,6 +367,13 @@ class WifiLegacyHal {
wifi_error setCountryCode(const std::string& iface_name,
std::array<int8_t, 2> code);
+ wifi_error QcAddInterface(const std::string& iface_name,
+ const std::string& new_ifname,
+ uint32_t type);
+ wifi_error QcRemoveInterface(const std::string& iface_name,
+ const std::string& ifname);
+
+
private:
// Retrieve interface handles for all the available interfaces.
wifi_error retrieveIfaceHandles();