diff options
| -rw-r--r-- | wifi/1.3/default/wifi_chip.cpp | 47 | ||||
| -rw-r--r-- | wifi/1.3/default/wifi_chip.h | 2 |
2 files changed, 25 insertions, 24 deletions
diff --git a/wifi/1.3/default/wifi_chip.cpp b/wifi/1.3/default/wifi_chip.cpp index 3acc487cb..2dcc33cfb 100644 --- a/wifi/1.3/default/wifi_chip.cpp +++ b/wifi/1.3/default/wifi_chip.cpp @@ -628,6 +628,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_) { @@ -808,13 +809,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 = allocateApIfaceName(); - + std::string ifname = allocateApIfaceName(); if (!if_nametoindex(ifname.c_str())) { legacy_hal::wifi_error legacy_status = legacy_hal_.lock()->QcAddInterface(getWlan0IfaceName(), ifname, @@ -983,9 +979,22 @@ std::pair<WifiStatus, sp<IWifiStaIface>> WifiChip::createStaIfaceInternal() { if (!canCurrentModeSupportIfaceOfTypeWithCurrentIfaces(IfaceType::STA)) { return {createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE), {}}; } + bool iface_created = false; std::string ifname = allocateStaIfaceName(); + 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_, iface_util_); 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"; @@ -1017,6 +1026,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); + } // Invalidate & remove any dependent objects first. invalidateAndRemoveDependencies(ifname); invalidateAndClear(sta_ifaces_, iface); @@ -1540,23 +1558,6 @@ 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 353abda98..2af6ebe04 100644 --- a/wifi/1.3/default/wifi_chip.h +++ b/wifi/1.3/default/wifi_chip.h @@ -245,7 +245,6 @@ 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_; @@ -271,6 +270,7 @@ class WifiChip : public V1_3::IWifiChip { event_cb_handler_; std::vector<sp<WifiApIface>> created_ap_ifaces_; + std::vector<sp<WifiStaIface>> created_sta_ifaces_; DISALLOW_COPY_AND_ASSIGN(WifiChip); }; |
