From 18af29a3ffa356d3c5908c4eb8be47a6ff853e53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Apitzsch?= Date: Thu, 15 Feb 2024 09:05:58 +0100 Subject: [PATCH] wifi: Convert WifiTidToLinkMappingNegSupport to scoped enum --- CHANGES.md | 1 + src/wifi/model/ap-wifi-mac.cc | 6 ++-- src/wifi/model/eht/eht-configuration.cc | 39 ++++++++++++++++--------- src/wifi/model/eht/eht-configuration.h | 28 +++++++++++++++--- src/wifi/model/sta-wifi-mac.cc | 7 +++-- src/wifi/model/wifi-assoc-manager.cc | 3 +- src/wifi/test/wifi-mlo-test.cc | 2 +- 7 files changed, 61 insertions(+), 25 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 35182d576..ce36c1173 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -22,6 +22,7 @@ Changes from ns-3.41 to ns-3-dev * `InetSocketAddress::SetTos()` and `InetSocketAddress::GetTos()` have been removed. Applications have a new Attribute to set the IPv4 ToS field. +* (wifi) Deprecated `WIFI_TID_TO_LINK_MAPPING_{NOT_SUPPORTED,SAME_LINK_SET,ANY_LINK_SET}`. They have been replaced by `WifiTidToLinkMappingNegSupport::{NOT_SUPPORTED,SAME_LINK_SET,ANY_LINK_SET}`, respectively. ### Changes to build system diff --git a/src/wifi/model/ap-wifi-mac.cc b/src/wifi/model/ap-wifi-mac.cc index 6f17764a8..54e00b927 100644 --- a/src/wifi/model/ap-wifi-mac.cc +++ b/src/wifi/model/ap-wifi-mac.cc @@ -721,7 +721,7 @@ ApWifiMac::GetMultiLinkElement(uint8_t linkId, WifiMacType frameType, const Mac4 mldCapabilities->srsSupport = 0; EnumValue negSupport; ehtConfiguration->GetAttributeFailSafe("TidToLinkMappingNegSupport", negSupport); - mldCapabilities->tidToLinkMappingSupport = negSupport.Get(); + mldCapabilities->tidToLinkMappingSupport = static_cast(negSupport.Get()); mldCapabilities->freqSepForStrApMld = 0; // not supported yet mldCapabilities->aarSupport = 0; // not supported yet } @@ -1981,7 +1981,7 @@ ApWifiMac::ReceiveAssocRequest(const AssocReqRefVariant& assoc, EnumValue negSupport; ehtConfig->GetAttributeFailSafe("TidToLinkMappingNegSupport", negSupport); - if (negSupport.Get() == 0) + if (negSupport.Get() == WifiTidToLinkMappingNegSupport::NOT_SUPPORTED) { return failure("TID-to-Link Mapping negotiation not supported"); } @@ -2019,7 +2019,7 @@ ApWifiMac::ReceiveAssocRequest(const AssocReqRefVariant& assoc, break; } - if (negSupport.Get() == 1 && + if (negSupport.Get() == WifiTidToLinkMappingNegSupport::SAME_LINK_SET && !TidToLinkMappingValidForNegType1(dlMapping, ulMapping)) { return failure("Mapping TIDs to distinct link sets is incompatible with " diff --git a/src/wifi/model/eht/eht-configuration.cc b/src/wifi/model/eht/eht-configuration.cc index c098e530e..2c9d200f2 100644 --- a/src/wifi/model/eht/eht-configuration.cc +++ b/src/wifi/model/eht/eht-configuration.cc @@ -36,6 +36,21 @@ NS_LOG_COMPONENT_DEFINE("EhtConfiguration"); NS_OBJECT_ENSURE_REGISTERED(EhtConfiguration); +std::ostream& +operator<<(std::ostream& os, WifiTidToLinkMappingNegSupport negsupport) +{ + switch (negsupport) + { + case WifiTidToLinkMappingNegSupport::NOT_SUPPORTED: + return os << "NOT_SUPPORTED"; + case WifiTidToLinkMappingNegSupport::SAME_LINK_SET: + return os << "SAME_LINK_SET"; + case WifiTidToLinkMappingNegSupport::ANY_LINK_SET: + return os << "ANY_LINK_SET"; + }; + return os << "UNKNOWN(" << static_cast(negsupport) << ")"; +} + EhtConfiguration::EhtConfiguration() { NS_LOG_FUNCTION(this); @@ -94,19 +109,17 @@ EhtConfiguration::GetTypeId() UintegerValue(DEFAULT_MSD_MAX_N_TXOPS), MakeUintegerAccessor(&EhtConfiguration::m_msdMaxNTxops), MakeUintegerChecker(0, 15)) - .AddAttribute( - "TidToLinkMappingNegSupport", - "TID-to-Link Mapping Negotiation Support.", - EnumValue(WifiTidToLinkMappingNegSupport::WIFI_TID_TO_LINK_MAPPING_ANY_LINK_SET), - MakeEnumAccessor( - &EhtConfiguration::m_tidLinkMappingSupport), - MakeEnumChecker( - WifiTidToLinkMappingNegSupport::WIFI_TID_TO_LINK_MAPPING_NOT_SUPPORTED, - "NOT_SUPPORTED", - WifiTidToLinkMappingNegSupport::WIFI_TID_TO_LINK_MAPPING_SAME_LINK_SET, - "SAME_LINK_SET", - WifiTidToLinkMappingNegSupport::WIFI_TID_TO_LINK_MAPPING_ANY_LINK_SET, - "ANY_LINK_SET")) + .AddAttribute("TidToLinkMappingNegSupport", + "TID-to-Link Mapping Negotiation Support.", + EnumValue(WifiTidToLinkMappingNegSupport::ANY_LINK_SET), + MakeEnumAccessor( + &EhtConfiguration::m_tidLinkMappingSupport), + MakeEnumChecker(WifiTidToLinkMappingNegSupport::NOT_SUPPORTED, + "NOT_SUPPORTED", + WifiTidToLinkMappingNegSupport::SAME_LINK_SET, + "SAME_LINK_SET", + WifiTidToLinkMappingNegSupport::ANY_LINK_SET, + "ANY_LINK_SET")) .AddAttribute( "TidToLinkMappingDl", "A list-of-TIDs-indexed map of the list of links where the TIDs are mapped to " diff --git a/src/wifi/model/eht/eht-configuration.h b/src/wifi/model/eht/eht-configuration.h index eee68e13c..9d782b071 100644 --- a/src/wifi/model/eht/eht-configuration.h +++ b/src/wifi/model/eht/eht-configuration.h @@ -21,6 +21,7 @@ #ifndef EHT_CONFIGURATION_H #define EHT_CONFIGURATION_H +#include "ns3/deprecated.h" #include "ns3/nstime.h" #include "ns3/object.h" #include "ns3/wifi-utils.h" @@ -43,13 +44,32 @@ static constexpr uint8_t DEFAULT_MSD_MAX_N_TXOPS = 1; /** * \brief TID-to-Link Mapping Negotiation Support */ -enum WifiTidToLinkMappingNegSupport : uint8_t +enum class WifiTidToLinkMappingNegSupport : uint8_t { - WIFI_TID_TO_LINK_MAPPING_NOT_SUPPORTED = 0, - WIFI_TID_TO_LINK_MAPPING_SAME_LINK_SET = 1, - WIFI_TID_TO_LINK_MAPPING_ANY_LINK_SET = 3 + NOT_SUPPORTED = 0, + SAME_LINK_SET = 1, + ANY_LINK_SET = 3 }; +NS_DEPRECATED_3_42("Use WifiTidToLinkMappingNegSupport::NOT_SUPPORTED instead") +static constexpr auto WIFI_TID_TO_LINK_MAPPING_NOT_SUPPORTED = WifiTidToLinkMappingNegSupport:: + NOT_SUPPORTED; //!< \deprecated See WifiTidToLinkMappingNegSupport::NOT_SUPPORTED +NS_DEPRECATED_3_42("Use WifiTidToLinkMappingNegSupport::SAME_LINK_SET instead") +static constexpr auto WIFI_TID_TO_LINK_MAPPING_SAME_LINK_SET = WifiTidToLinkMappingNegSupport:: + SAME_LINK_SET; //!< \deprecated See WifiTidToLinkMappingNegSupport::SAME_LINK_SET +NS_DEPRECATED_3_42("Use WifiTidToLinkMappingNegSupport::ANY_LINK_SET instead") +static constexpr auto WIFI_TID_TO_LINK_MAPPING_ANY_LINK_SET = + WifiTidToLinkMappingNegSupport::ANY_LINK_SET; //!< \deprecated See + //!< WifiTidToLinkMappingNegSupport::ANY_LINK_SET + +/** + * \brief Stream insertion operator. + * \param [in] os The reference to the output stream. + * \param [in] negsupport The WifiTidToLinkMappingNegSupport. + * \return The reference to the output stream. + */ +std::ostream& operator<<(std::ostream& os, WifiTidToLinkMappingNegSupport negsupport); + /** * \brief EHT configuration * \ingroup wifi diff --git a/src/wifi/model/sta-wifi-mac.cc b/src/wifi/model/sta-wifi-mac.cc index dcb41833f..ee7c4b8b2 100644 --- a/src/wifi/model/sta-wifi-mac.cc +++ b/src/wifi/model/sta-wifi-mac.cc @@ -484,7 +484,7 @@ StaWifiMac::GetMultiLinkElement(bool isReassoc, uint8_t linkId) const EnumValue negSupport; ehtConfiguration->GetAttributeFailSafe("TidToLinkMappingNegSupport", negSupport); - mldCapabilities->tidToLinkMappingSupport = negSupport.Get(); + mldCapabilities->tidToLinkMappingSupport = static_cast(negSupport.Get()); mldCapabilities->freqSepForStrApMld = 0; // not supported yet mldCapabilities->aarSupport = 0; // not supported yet @@ -532,7 +532,7 @@ StaWifiMac::GetTidToLinkMappingElements(uint8_t apNegSupport) EnumValue negSupport; ehtConfig->GetAttributeFailSafe("TidToLinkMappingNegSupport", negSupport); - NS_ABORT_MSG_IF(negSupport.Get() == 0, + NS_ABORT_MSG_IF(negSupport.Get() == WifiTidToLinkMappingNegSupport::NOT_SUPPORTED, "Cannot request TID-to-Link Mapping if negotiation is not supported"); // store the mappings, so that we can enforce them when the AP MLD accepts them @@ -542,7 +542,8 @@ StaWifiMac::GetTidToLinkMappingElements(uint8_t apNegSupport) bool mappingValidForNegType1 = TidToLinkMappingValidForNegType1(m_dlTidLinkMappingInAssocReq, m_ulTidLinkMappingInAssocReq); NS_ABORT_MSG_IF( - negSupport.Get() == 1 && !mappingValidForNegType1, + negSupport.Get() == WifiTidToLinkMappingNegSupport::SAME_LINK_SET && + !mappingValidForNegType1, "Mapping TIDs to distinct link sets is incompatible with negotiation support of 1"); if (apNegSupport == 1 && !mappingValidForNegType1) diff --git a/src/wifi/model/wifi-assoc-manager.cc b/src/wifi/model/wifi-assoc-manager.cc index bf89585d5..4950de161 100644 --- a/src/wifi/model/wifi-assoc-manager.cc +++ b/src/wifi/model/wifi-assoc-manager.cc @@ -314,7 +314,8 @@ WifiAssocManager::CanSetupMultiLink(OptMleConstRef& mle, OptRnrConstRef& rnr) // mapping negotiation with the TID-To-Link Mapping Negotiation Support subfield of the // MLD Capabilities field of the Basic Multi-Link element it transmits to at least 1. // (Sec. 35.3.7.1.1 of 802.11be D3.1) - if (mldCapabilities->tidToLinkMappingSupport > 0 && negSupport.Get() == 0) + if (mldCapabilities->tidToLinkMappingSupport > 0 && + negSupport.Get() == WifiTidToLinkMappingNegSupport::NOT_SUPPORTED) { NS_LOG_DEBUG("AP MLD supports TID-to-Link Mapping negotiation, while we don't"); return false; diff --git a/src/wifi/test/wifi-mlo-test.cc b/src/wifi/test/wifi-mlo-test.cc index 437121666..ea627c1a4 100644 --- a/src/wifi/test/wifi-mlo-test.cc +++ b/src/wifi/test/wifi-mlo-test.cc @@ -939,7 +939,7 @@ MultiLinkSetupTest::DoSetup() // also advertises 0) or 1 (the AP MLD is discarded if it advertises a support of 3) auto staEhtConfig = m_staMacs[0]->GetEhtConfiguration(); staEhtConfig->SetAttribute("TidToLinkMappingNegSupport", - EnumValue(WIFI_TID_TO_LINK_MAPPING_ANY_LINK_SET)); + EnumValue(WifiTidToLinkMappingNegSupport::ANY_LINK_SET)); staEhtConfig->SetAttribute("TidToLinkMappingDl", StringValue(m_dlTidLinkMappingStr)); staEhtConfig->SetAttribute("TidToLinkMappingUl", StringValue(m_ulTidLinkMappingStr));