summaryrefslogtreecommitdiff
path: root/wifi/1.5/default/wifi_iface_util.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_iface_util.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_iface_util.cpp')
-rw-r--r--wifi/1.5/default/wifi_iface_util.cpp30
1 files changed, 21 insertions, 9 deletions
diff --git a/wifi/1.5/default/wifi_iface_util.cpp b/wifi/1.5/default/wifi_iface_util.cpp
index 2a0aef8906..d1434e3a41 100644
--- a/wifi/1.5/default/wifi_iface_util.cpp
+++ b/wifi/1.5/default/wifi_iface_util.cpp
@@ -41,8 +41,10 @@ namespace implementation {
namespace iface_util {
WifiIfaceUtil::WifiIfaceUtil(
- const std::weak_ptr<wifi_system::InterfaceTool> iface_tool)
+ const std::weak_ptr<wifi_system::InterfaceTool> iface_tool,
+ const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal)
: iface_tool_(iface_tool),
+ legacy_hal_(legacy_hal),
random_mac_address_(nullptr),
event_handlers_map_() {}
@@ -59,14 +61,20 @@ bool WifiIfaceUtil::setMacAddress(const std::string& iface_name,
return false;
}
#endif
- if (!iface_tool_.lock()->SetMacAddress(iface_name.c_str(), mac)) {
- LOG(ERROR) << "SetMacAddress failed.";
- return false;
- }
+ bool success = iface_tool_.lock()->SetMacAddress(iface_name.c_str(), mac);
#ifndef WIFI_AVOID_IFACE_RESET_MAC_CHANGE
if (!iface_tool_.lock()->SetUpState(iface_name.c_str(), true)) {
- LOG(ERROR) << "SetUpState(true) failed.";
- return false;
+ LOG(ERROR) << "SetUpState(true) failed. Wait for driver ready.";
+ // Wait for driver ready and try to set iface UP again
+ if (legacy_hal_.lock()->waitForDriverReady() !=
+ legacy_hal::WIFI_SUCCESS) {
+ LOG(ERROR) << "SetUpState(true) wait for driver ready failed.";
+ return false;
+ }
+ if (!iface_tool_.lock()->SetUpState(iface_name.c_str(), true)) {
+ LOG(ERROR) << "SetUpState(true) failed after retry.";
+ return false;
+ }
}
#endif
IfaceEventHandlers event_handlers = {};
@@ -77,8 +85,12 @@ bool WifiIfaceUtil::setMacAddress(const std::string& iface_name,
if (event_handlers.on_state_toggle_off_on != nullptr) {
event_handlers.on_state_toggle_off_on(iface_name);
}
- LOG(DEBUG) << "Successfully SetMacAddress.";
- return true;
+ if (!success) {
+ LOG(ERROR) << "SetMacAddress failed.";
+ } else {
+ LOG(DEBUG) << "SetMacAddress succeeded.";
+ }
+ return success;
}
std::array<uint8_t, 6> WifiIfaceUtil::getOrCreateRandomMacAddress() {