From fb18aa503cfdf31d4f0118fa1273d44194c212cc Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Tue, 28 Nov 2023 09:11:54 +0100 Subject: [PATCH] wifi: Use constexpr values instead of true/false when calling StartAccessAfterEvent --- src/wifi/model/eht/eht-frame-exchange-manager.cc | 14 ++++++++------ src/wifi/model/qos-txop.cc | 2 +- src/wifi/model/sta-wifi-mac.cc | 8 ++++++-- src/wifi/model/txop.cc | 6 +++--- src/wifi/model/txop.h | 9 +++++++++ src/wifi/model/wifi-mac.cc | 2 +- 6 files changed, 28 insertions(+), 13 deletions(-) diff --git a/src/wifi/model/eht/eht-frame-exchange-manager.cc b/src/wifi/model/eht/eht-frame-exchange-manager.cc index 040e9b4e1..3e5b6ad96 100644 --- a/src/wifi/model/eht/eht-frame-exchange-manager.cc +++ b/src/wifi/model/eht/eht-frame-exchange-manager.cc @@ -197,12 +197,14 @@ EhtFrameExchangeManager::StartTransmission(Ptr edca, uint16_t allowedWidth NS_LOG_DEBUG("No new TXOP attempts allowed while MediumSyncDelay is running"); // request channel access if needed when the MediumSyncDelay timer expires; in the // meantime no queued packet can be transmitted - Simulator::Schedule(emlsrManager->GetMediumSyncDuration() - *elapsed, - &Txop::StartAccessAfterEvent, - edca, - m_linkId, - false, // queued frames cannot be transmitted until MSD expires - false); // generate backoff regardless of medium busy + Simulator::Schedule( + emlsrManager->GetMediumSyncDuration() - *elapsed, + &Txop::StartAccessAfterEvent, + edca, + m_linkId, + Txop::DIDNT_HAVE_FRAMES_TO_TRANSMIT, // queued frames cannot be transmitted until + // MSD expires + Txop::DONT_CHECK_MEDIUM_BUSY); // generate backoff regardless of medium busy NotifyChannelReleased(edca); return false; } diff --git a/src/wifi/model/qos-txop.cc b/src/wifi/model/qos-txop.cc index e749580ac..6bde88f2b 100644 --- a/src/wifi/model/qos-txop.cc +++ b/src/wifi/model/qos-txop.cc @@ -138,7 +138,7 @@ QosTxop::QosTxop(AcIndex ac) // start access (if needed) on all the links for (const auto& [id, link] : GetLinks()) { - StartAccessAfterEvent(id, hasFramesToTransmit.at(id), true); + StartAccessAfterEvent(id, hasFramesToTransmit.at(id), CHECK_MEDIUM_BUSY); } })); m_queue->TraceConnectWithoutContext( diff --git a/src/wifi/model/sta-wifi-mac.cc b/src/wifi/model/sta-wifi-mac.cc index 6d95093cb..6bd638836 100644 --- a/src/wifi/model/sta-wifi-mac.cc +++ b/src/wifi/model/sta-wifi-mac.cc @@ -1452,13 +1452,17 @@ StaWifiMac::ReceiveAssocResp(Ptr mpdu, uint8_t linkId) { if (const auto txop = GetTxop()) { - txop->StartAccessAfterEvent(id, false, true); + txop->StartAccessAfterEvent(id, + Txop::DIDNT_HAVE_FRAMES_TO_TRANSMIT, + Txop::CHECK_MEDIUM_BUSY); } for (const auto [acIndex, ac] : wifiAcList) { if (const auto edca = GetQosTxop(acIndex)) { - edca->StartAccessAfterEvent(id, false, true); + edca->StartAccessAfterEvent(id, + Txop::DIDNT_HAVE_FRAMES_TO_TRANSMIT, + Txop::CHECK_MEDIUM_BUSY); } } } diff --git a/src/wifi/model/txop.cc b/src/wifi/model/txop.cc index 24b29ef22..c88d2c7e6 100644 --- a/src/wifi/model/txop.cc +++ b/src/wifi/model/txop.cc @@ -555,7 +555,7 @@ Txop::Queue(Ptr mpdu) this, linkId, hasFramesToTransmit.at(linkId), - true); + CHECK_MEDIUM_BUSY); } } } @@ -669,7 +669,7 @@ Txop::NotifyWakeUp(uint8_t linkId) { NS_LOG_FUNCTION(this << +linkId); // before wake up, no packet can be transmitted - StartAccessAfterEvent(linkId, false, false); + StartAccessAfterEvent(linkId, DIDNT_HAVE_FRAMES_TO_TRANSMIT, DONT_CHECK_MEDIUM_BUSY); } void @@ -679,7 +679,7 @@ Txop::NotifyOn() for (const auto& [id, link] : m_links) { // before being turned on, no packet can be transmitted - StartAccessAfterEvent(id, false, false); + StartAccessAfterEvent(id, DIDNT_HAVE_FRAMES_TO_TRANSMIT, DONT_CHECK_MEDIUM_BUSY); } } diff --git a/src/wifi/model/txop.h b/src/wifi/model/txop.h index 012656a5a..6eb59c7ce 100644 --- a/src/wifi/model/txop.h +++ b/src/wifi/model/txop.h @@ -412,6 +412,15 @@ class Txop : public Object */ void StartAccessAfterEvent(uint8_t linkId, bool hadFramesToTransmit, bool checkMediumBusy); + static constexpr bool HAD_FRAMES_TO_TRANSMIT = + true; //!< packets available for transmission were in the queue + static constexpr bool DIDNT_HAVE_FRAMES_TO_TRANSMIT = + false; //!< no packet available for transmission was in the queue + static constexpr bool CHECK_MEDIUM_BUSY = + true; //!< generation of backoff (also) depends on the busy/idle state of the medium + static constexpr bool DONT_CHECK_MEDIUM_BUSY = + false; //!< generation of backoff is independent of the busy/idle state of the medium + /** * \param nSlots the number of slots of the backoff. * \param linkId the ID of the given link diff --git a/src/wifi/model/wifi-mac.cc b/src/wifi/model/wifi-mac.cc index 0b3eea135..50c429f3a 100644 --- a/src/wifi/model/wifi-mac.cc +++ b/src/wifi/model/wifi-mac.cc @@ -1470,7 +1470,7 @@ WifiMac::UnblockUnicastTxOnLinks(WifiQueueBlockedReason reason, GetQosTxop(acIndex), linkId, hasFramesToTransmit, - true); // generate backoff if medium busy + Txop::CHECK_MEDIUM_BUSY); // generate backoff if medium busy } } }