diff options
Diffstat (limited to 'wifi/1.2/default/wifi_chip.cpp')
-rw-r--r-- | wifi/1.2/default/wifi_chip.cpp | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/wifi/1.2/default/wifi_chip.cpp b/wifi/1.2/default/wifi_chip.cpp index 272520704e..1f15fe475c 100644 --- a/wifi/1.2/default/wifi_chip.cpp +++ b/wifi/1.2/default/wifi_chip.cpp @@ -598,6 +598,7 @@ void WifiChip::invalidateAndRemoveAllIfaces() { invalidateAndClearAll(p2p_ifaces_); invalidateAndClearAll(sta_ifaces_); invalidateAndClearAll(created_ap_ifaces_); + invalidateAndClearAll(created_sta_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_) { @@ -747,13 +748,8 @@ std::pair<WifiStatus, sp<IWifiApIface>> WifiChip::createApIfaceInternal() { return {createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE), {}}; } - std::string ifname = ""; bool iface_created = false; - if (feature_flags_.lock()->isDualInterfaceSupported()) - ifname = qcAllocateApIfaceName(); - else - ifname = allocateApOrStaIfaceName(); - + std::string ifname = allocateApOrStaIfaceName(); if (!if_nametoindex(ifname.c_str())) { legacy_hal::wifi_error legacy_status = legacy_hal_.lock()->QcAddInterface(getWlan0IfaceName(), ifname, @@ -914,9 +910,22 @@ std::pair<WifiStatus, sp<IWifiStaIface>> WifiChip::createStaIfaceInternal() { if (!canCurrentModeSupportIfaceOfType(IfaceType::STA)) { return {createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE), {}}; } + bool iface_created = false; std::string ifname = allocateApOrStaIfaceName(); + if (!if_nametoindex(ifname.c_str())) { + legacy_hal::wifi_error legacy_status = + legacy_hal_.lock()->QcAddInterface(getWlan0IfaceName(), ifname, + (uint32_t)IfaceType::STA); + 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<WifiStaIface> iface = new WifiStaIface(ifname, legacy_hal_); sta_ifaces_.push_back(iface); + if (iface_created) created_sta_ifaces_.push_back(iface); for (const auto& callback : event_cb_handler_.getCallbacks()) { if (!callback->onIfaceAdded(IfaceType::STA, ifname).isOk()) { LOG(ERROR) << "Failed to invoke onIfaceAdded callback"; @@ -947,6 +956,15 @@ WifiStatus WifiChip::removeStaIfaceInternal(const std::string& ifname) { if (!iface.get()) { return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS); } + if (findUsingName(created_sta_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_sta_ifaces_, iface); + } invalidateAndClear(sta_ifaces_, iface); for (const auto& callback : event_cb_handler_.getCallbacks()) { if (!callback->onIfaceRemoved(IfaceType::STA, ifname).isOk()) { @@ -1428,23 +1446,6 @@ std::string WifiChip::allocateApOrStaIfaceName() { return {}; } -// 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"; |