wifi: StaWifiMac and EHT FEM make use of functions to (un)block all queues

This commit is contained in:
Stefano Avallone
2024-09-04 16:22:56 +02:00
parent 41c64d18be
commit a47433e287
3 changed files with 39 additions and 42 deletions

View File

@@ -155,13 +155,9 @@ EhtFrameExchangeManager::UsingOtherEmlsrLink() const
{
return false;
}
auto apAddress = GetWifiRemoteStationManager()->GetMldAddress(m_bssid);
NS_ASSERT_MSG(apAddress, "MLD address not found for BSSID " << m_bssid);
// when EMLSR links are blocked, all TIDs are blocked (we test TID 0 here)
WifiContainerQueueId queueId(WIFI_QOSDATA_QUEUE, WIFI_UNICAST, *apAddress, 0);
auto mask = m_staMac->GetMacQueueScheduler()->GetQueueLinkMask(AC_BE, queueId, m_linkId);
NS_ASSERT_MSG(mask, "No mask for AP " << *apAddress << " on link " << m_linkId);
return mask->test(static_cast<std::size_t>(WifiQueueBlockedReason::USING_OTHER_EMLSR_LINK));
return m_staMac->GetMacQueueScheduler()->GetAllQueuesBlockedOnLink(
m_linkId,
WifiQueueBlockedReason::USING_OTHER_EMLSR_LINK);
}
bool

View File

@@ -30,6 +30,7 @@
#include "ns3/pair.h"
#include "ns3/pointer.h"
#include "ns3/random-variable-stream.h"
#include "ns3/shuffle.h"
#include "ns3/simulator.h"
#include "ns3/string.h"
@@ -1066,46 +1067,46 @@ StaWifiMac::BlockTxOnLink(uint8_t linkId, WifiQueueBlockedReason reason)
{
NS_LOG_FUNCTION(this << linkId << reason);
auto bssid = GetBssid(linkId);
auto apAddress = GetWifiRemoteStationManager(linkId)->GetMldAddress(bssid).value_or(bssid);
BlockUnicastTxOnLinks(reason, apAddress, {linkId});
// the only type of broadcast frames that a non-AP STA can send are management frames
for (const auto& [acIndex, ac] : wifiAcList)
{
GetMacQueueScheduler()->BlockQueues(reason,
acIndex,
{WIFI_MGT_QUEUE},
Mac48Address::GetBroadcast(),
GetFrameExchangeManager(linkId)->GetAddress(),
{},
{linkId});
}
GetMacQueueScheduler()->BlockAllQueues(reason, {linkId});
}
void
StaWifiMac::UnblockTxOnLink(std::set<uint8_t> linkIds, WifiQueueBlockedReason reason)
{
// shuffle link IDs not to unblock links always in the same order
std::vector<uint8_t> shuffledLinkIds(linkIds.cbegin(), linkIds.cend());
Shuffle(shuffledLinkIds.begin(), shuffledLinkIds.end(), m_shuffleLinkIdsGen.GetRv());
std::stringstream ss;
std::copy(linkIds.cbegin(), linkIds.cend(), std::ostream_iterator<uint16_t>(ss, " "));
NS_LOG_FUNCTION(this << ss.str() << reason);
const auto linkId = *linkIds.cbegin();
const auto bssid = GetBssid(linkId);
const auto apAddress =
GetWifiRemoteStationManager(linkId)->GetMldAddress(bssid).value_or(bssid);
UnblockUnicastTxOnLinks(reason, apAddress, linkIds);
// the only type of broadcast frames that a non-AP STA can send are management frames
for (const auto& [acIndex, ac] : wifiAcList)
if (g_log.IsEnabled(ns3::LOG_FUNCTION))
{
GetMacQueueScheduler()->UnblockQueues(reason,
acIndex,
{WIFI_MGT_QUEUE},
Mac48Address::GetBroadcast(),
GetFrameExchangeManager(linkId)->GetAddress(),
{},
linkIds);
std::copy(shuffledLinkIds.cbegin(),
shuffledLinkIds.cend(),
std::ostream_iterator<uint16_t>(ss, " "));
}
NS_LOG_FUNCTION(this << reason << ss.str());
for (const auto linkId : shuffledLinkIds)
{
std::map<AcIndex, bool> hasFramesToTransmit;
for (const auto& [acIndex, ac] : wifiAcList)
{
// save the status of the AC queues before unblocking the queues
hasFramesToTransmit[acIndex] = GetQosTxop(acIndex)->HasFramesToTransmit(linkId);
}
GetMacQueueScheduler()->UnblockAllQueues(reason, {linkId});
for (const auto& [acIndex, ac] : wifiAcList)
{
// request channel access if needed (schedule now because multiple invocations
// of this method may be done in a loop at the caller)
Simulator::ScheduleNow(&Txop::StartAccessAfterEvent,
GetQosTxop(acIndex),
linkId,
hasFramesToTransmit[acIndex],
Txop::CHECK_MEDIUM_BUSY); // generate backoff if medium busy
}
}
}

View File

@@ -965,6 +965,8 @@ class WifiMac : public Object
WifiDirection dir,
const WifiTidLinkMapping& mapping);
UniformRandomBitGenerator m_shuffleLinkIdsGen; //!< random number generator to shuffle link IDs
Ptr<MacRxMiddle> m_rxMiddle; //!< RX middle (defragmentation etc.)
Ptr<MacTxMiddle> m_txMiddle; //!< TX middle (aggregation etc.)
Ptr<Txop> m_txop; //!< TXOP used for transmission of frames to non-QoS peers.
@@ -1244,8 +1246,6 @@ class WifiMac : public Object
uint16_t m_mpduBufferSize; //!< BlockAck buffer size (in number of MPDUs)
uint32_t m_frameRetryLimit; //!< the frame retry limit
UniformRandomBitGenerator m_shuffleLinkIdsGen; //!< random number generator to shuffle link IDs
bool m_robustAVStreamingSupported; ///< flag whether robust AV streaming is supported
/// @brief DL TID-to-Link Mapping negotiated with an MLD (identified by its MLD address)