From bb22630df7b5a9eb153b57cae613040fa7296265 Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Mon, 13 May 2024 10:41:15 +0200 Subject: [PATCH] wifi: Add a WifiMac method to check if TX is blocked on a link --- src/wifi/model/wifi-mac.cc | 19 +++++++++++++++++++ src/wifi/model/wifi-mac.h | 16 ++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/src/wifi/model/wifi-mac.cc b/src/wifi/model/wifi-mac.cc index 607428e56..46a1d45ef 100644 --- a/src/wifi/model/wifi-mac.cc +++ b/src/wifi/model/wifi-mac.cc @@ -1620,6 +1620,25 @@ WifiMac::UnblockUnicastTxOnLinks(WifiQueueBlockedReason reason, } } +bool +WifiMac::GetTxBlockedOnLink(AcIndex ac, + const WifiContainerQueueId& queueId, + uint8_t linkId, + WifiQueueBlockedReason reason) const +{ + auto mask = m_scheduler->GetQueueLinkMask(ac, queueId, linkId); + + if (!mask.has_value()) + { + return true; // the link may have not been setup + } + if (reason == WifiQueueBlockedReason::REASONS_COUNT) + { + return mask->any(); + } + return mask->test(static_cast(reason)); +} + void WifiMac::Enqueue(Ptr packet, Mac48Address to) { diff --git a/src/wifi/model/wifi-mac.h b/src/wifi/model/wifi-mac.h index 833ab708d..893bf349e 100644 --- a/src/wifi/model/wifi-mac.h +++ b/src/wifi/model/wifi-mac.h @@ -351,6 +351,22 @@ class WifiMac : public Object const Mac48Address& address, const std::set& linkIds); + /** + * Check whether the transmission of the packets in the given container queue of the given + * Access Category are blocked on the given link for the given reason (if any). + * + * \param ac the given Access Category + * \param queueId the given container queue + * \param linkId the ID of the given link + * \param reason the reason to block transmissions (REASONS_COUNT indicate no reason) + * \return whether transmission is blocked + */ + bool GetTxBlockedOnLink( + AcIndex ac, + const WifiContainerQueueId& queueId, + uint8_t linkId, + WifiQueueBlockedReason reason = WifiQueueBlockedReason::REASONS_COUNT) const; + /** * Return true if packets can be forwarded to the given destination, * false otherwise.