From efec608c157add4fef31e57652a180ddafd6948a Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Fri, 24 Mar 2023 11:26:53 +0100 Subject: [PATCH] wifi: EMLSR Manager notifies STA wifi MAC of EMLSR mode changes --- src/wifi/model/eht/emlsr-manager.cc | 4 ++-- src/wifi/model/sta-wifi-mac.cc | 33 +++++++++++++++++++++++++++++ src/wifi/model/sta-wifi-mac.h | 15 +++++++++++++ 3 files changed, 50 insertions(+), 2 deletions(-) diff --git a/src/wifi/model/eht/emlsr-manager.cc b/src/wifi/model/eht/emlsr-manager.cc index d633e6b77..24c206478 100644 --- a/src/wifi/model/eht/emlsr-manager.cc +++ b/src/wifi/model/eht/emlsr-manager.cc @@ -330,9 +330,9 @@ EmlsrManager::ChangeEmlsrMode() m_emlsrLinks.swap(*m_nextEmlsrLinks); m_nextEmlsrLinks.reset(); - // TODO Make other non-AP STAs operating on the corresponding EMLSR links transition to + // Make other non-AP STAs operating on the corresponding EMLSR links transition to // active mode or passive mode (depending on whether EMLSR mode has been enabled or disabled) - + m_staMac->NotifyEmlsrModeChanged(m_emlsrLinks); NotifyEmlsrModeChanged(); } diff --git a/src/wifi/model/sta-wifi-mac.cc b/src/wifi/model/sta-wifi-mac.cc index 43faebc69..c1740492c 100644 --- a/src/wifi/model/sta-wifi-mac.cc +++ b/src/wifi/model/sta-wifi-mac.cc @@ -288,6 +288,39 @@ StaWifiMac::GetCurrentChannel(uint8_t linkId) const return {ch, phy->GetPhyBand()}; } +void +StaWifiMac::NotifyEmlsrModeChanged(const std::set& linkIds) +{ + NS_LOG_FUNCTION(this << linkIds.size()); + + for (const auto& [linkId, lnk] : GetLinks()) + { + auto& link = GetStaLink(lnk); + + if (linkIds.count(linkId) > 0) + { + // EMLSR mode enabled + link.emlsrEnabled = true; + link.pmMode = WIFI_PM_ACTIVE; + } + else + { + // EMLSR mode disabled + if (link.emlsrEnabled) + { + link.pmMode = WIFI_PM_POWERSAVE; + } + link.emlsrEnabled = false; + } + } +} + +bool +StaWifiMac::IsEmlsrLink(uint8_t linkId) const +{ + return GetLink(linkId).emlsrEnabled; +} + void StaWifiMac::SendProbeRequest(uint8_t linkId) { diff --git a/src/wifi/model/sta-wifi-mac.h b/src/wifi/model/sta-wifi-mac.h index fced80373..04ac0bc72 100644 --- a/src/wifi/model/sta-wifi-mac.h +++ b/src/wifi/model/sta-wifi-mac.h @@ -294,6 +294,20 @@ class StaWifiMac : public WifiMac void NotifyChannelSwitching(uint8_t linkId) override; + /** + * Notify the MAC that EMLSR mode has changed on the given set of links. + * + * \param linkIds the IDs of the links that are now EMLSR links (EMLSR mode is disabled + * on other links) + */ + void NotifyEmlsrModeChanged(const std::set& linkIds); + + /** + * \param linkId the ID of the given link + * \return whether the EMLSR mode is enabled on the given link + */ + bool IsEmlsrLink(uint8_t linkId) const; + /** * Assign a fixed random variable stream number to the random variables * used by this model. Return the number of streams (possibly zero) that @@ -324,6 +338,7 @@ class StaWifiMac : public WifiMac WifiPowerManagementMode pmMode{WIFI_PM_ACTIVE}; /**< the current PM mode, if the STA is associated, or the PM mode to switch to upon association, otherwise */ + bool emlsrEnabled{false}; //!< whether EMLSR mode is enabled on this link }; /**