summaryrefslogtreecommitdiff
path: root/wifi/1.5/default/wifi_chip.cpp
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2021-03-02 10:00:23 -0800
committerRoshan Pius <rpius@google.com>2021-03-03 09:00:00 -0800
commit8c1a67b7af5851a01fedf087bfd998afdbcfeaaa (patch)
tree19e0675c0c7a34efe4003232078aeee00343b3df /wifi/1.5/default/wifi_chip.cpp
parent0a04fe136757c9df5f79533fe24fc6f5dd74d8ae (diff)
wifi: Wait for driver ready and bring up the interface when setMacAddress fails
setMacAddress may fail in some scenarios like SSR inprogress. In such case framework is not bringing up the iface again if it was brought down to set random MAC address. Due to this subsequent operations like scans are failing with "Network Down" error and Wi-Fi can't recover until Wi-Fi restarts. To avoid this bring up the iface irrespective of setMacAddress status. Modified the original CL to move the WifiIfaceUtil creation to inside Wifi object since that is where the legacy HAL instance is created for the corresponding chip. This helps keeping the setMacAddress logic still inside WifiIfaceUtil. Modified the iface_util lifetime - no longer a singleton, one instance created per wifi chip instance. Bug: 174183763 Test: Wifi can be enabled when back-to-back SSR and wifi on Change-Id: I926b59f5da126aba222e05d1e570c0c19de739ed
Diffstat (limited to 'wifi/1.5/default/wifi_chip.cpp')
-rw-r--r--wifi/1.5/default/wifi_chip.cpp19
1 files changed, 9 insertions, 10 deletions
diff --git a/wifi/1.5/default/wifi_chip.cpp b/wifi/1.5/default/wifi_chip.cpp
index 0450a7bfe1..0499f456c1 100644
--- a/wifi/1.5/default/wifi_chip.cpp
+++ b/wifi/1.5/default/wifi_chip.cpp
@@ -353,7 +353,7 @@ WifiChip::WifiChip(
ChipId chip_id, bool is_primary,
const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal,
const std::weak_ptr<mode_controller::WifiModeController> mode_controller,
- const std::weak_ptr<iface_util::WifiIfaceUtil> iface_util,
+ const std::shared_ptr<iface_util::WifiIfaceUtil> iface_util,
const std::weak_ptr<feature_flags::WifiFeatureFlags> feature_flags,
const std::function<void(const std::string&)>& handler)
: chip_id_(chip_id),
@@ -986,14 +986,14 @@ WifiChip::createBridgedApIfaceInternal() {
}
}
br_ifaces_ap_instances_[br_ifname] = ap_instances;
- if (!iface_util_.lock()->createBridge(br_ifname)) {
+ if (!iface_util_->createBridge(br_ifname)) {
LOG(ERROR) << "Failed createBridge - br_name=" << br_ifname.c_str();
invalidateAndClearBridgedAp(br_ifname);
return {createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE), {}};
}
for (auto const& instance : ap_instances) {
// Bind ap instance interface to AP bridge
- if (!iface_util_.lock()->addIfaceToBridge(br_ifname, instance)) {
+ if (!iface_util_->addIfaceToBridge(br_ifname, instance)) {
LOG(ERROR) << "Failed add if to Bridge - if_name="
<< instance.c_str();
invalidateAndClearBridgedAp(br_ifname);
@@ -1054,8 +1054,7 @@ WifiStatus WifiChip::removeIfaceInstanceFromBridgedApIfaceInternal(
if (it.first == ifname) {
for (auto const& iface : it.second) {
if (iface == ifInstanceName) {
- if (!iface_util_.lock()->removeIfaceFromBridge(it.first,
- iface)) {
+ if (!iface_util_->removeIfaceFromBridge(it.first, iface)) {
LOG(ERROR)
<< "Failed to remove interface: " << ifInstanceName
<< " from " << ifname;
@@ -1086,7 +1085,7 @@ WifiChip::createNanIfaceInternal() {
}
bool is_dedicated_iface = true;
std::string ifname = getPredefinedNanIfaceName();
- if (ifname.empty() || !iface_util_.lock()->ifNameToIndex(ifname)) {
+ if (ifname.empty() || !iface_util_->ifNameToIndex(ifname)) {
// Use the first shared STA iface (wlan0) if a dedicated aware iface is
// not defined.
ifname = getFirstActiveWlanIfaceName();
@@ -1968,10 +1967,10 @@ std::string WifiChip::getWlanIfaceNameWithType(IfaceType type, unsigned idx) {
void WifiChip::invalidateAndClearBridgedApAll() {
for (auto const& it : br_ifaces_ap_instances_) {
for (auto const& iface : it.second) {
- iface_util_.lock()->removeIfaceFromBridge(it.first, iface);
+ iface_util_->removeIfaceFromBridge(it.first, iface);
legacy_hal_.lock()->deleteVirtualInterface(iface);
}
- iface_util_.lock()->deleteBridge(it.first);
+ iface_util_->deleteBridge(it.first);
}
br_ifaces_ap_instances_.clear();
}
@@ -1982,10 +1981,10 @@ void WifiChip::invalidateAndClearBridgedAp(const std::string& br_name) {
for (auto const& it : br_ifaces_ap_instances_) {
if (it.first == br_name) {
for (auto const& iface : it.second) {
- iface_util_.lock()->removeIfaceFromBridge(br_name, iface);
+ iface_util_->removeIfaceFromBridge(br_name, iface);
legacy_hal_.lock()->deleteVirtualInterface(iface);
}
- iface_util_.lock()->deleteBridge(br_name);
+ iface_util_->deleteBridge(br_name);
br_ifaces_ap_instances_.erase(br_name);
break;
}