wifi: Use enum class for Trigger Frame types

This commit is contained in:
Stefano Avallone
2023-01-14 17:03:49 +01:00
parent 83d44c91f7
commit 535452880e
4 changed files with 65 additions and 54 deletions

View File

@@ -1068,7 +1068,7 @@ CtrlBAckResponseHeader::ResetBitmap(std::size_t index)
* Trigger frame - User Info field
***********************************/
CtrlTriggerUserInfoField::CtrlTriggerUserInfoField(uint8_t triggerType)
CtrlTriggerUserInfoField::CtrlTriggerUserInfoField(TriggerFrameType triggerType)
: m_aid12(0),
m_ruAllocation(0),
m_ulFecCodingType(false),
@@ -1123,14 +1123,15 @@ CtrlTriggerUserInfoField::GetSerializedSize() const
switch (m_triggerType)
{
case BASIC_TRIGGER:
case BFRP_TRIGGER:
case TriggerFrameType::BASIC_TRIGGER:
case TriggerFrameType::BFRP_TRIGGER:
size += 1;
break;
case MU_BAR_TRIGGER:
case TriggerFrameType::MU_BAR_TRIGGER:
size +=
m_muBarTriggerDependentUserInfo.GetSerializedSize(); // BAR Control and BAR Information
break;
default:;
// The Trigger Dependent User Info subfield is not present in the other variants
}
@@ -1140,10 +1141,12 @@ CtrlTriggerUserInfoField::GetSerializedSize() const
Buffer::Iterator
CtrlTriggerUserInfoField::Serialize(Buffer::Iterator start) const
{
NS_ABORT_MSG_IF(m_triggerType == BFRP_TRIGGER, "BFRP Trigger frame is not supported");
NS_ABORT_MSG_IF(m_triggerType == GCR_MU_BAR_TRIGGER,
NS_ABORT_MSG_IF(m_triggerType == TriggerFrameType::BFRP_TRIGGER,
"BFRP Trigger frame is not supported");
NS_ABORT_MSG_IF(m_triggerType == TriggerFrameType::GCR_MU_BAR_TRIGGER,
"GCR-MU-BAR Trigger frame is not supported");
NS_ABORT_MSG_IF(m_triggerType == NFRP_TRIGGER, "NFRP Trigger frame is not supported");
NS_ABORT_MSG_IF(m_triggerType == TriggerFrameType::NFRP_TRIGGER,
"NFRP Trigger frame is not supported");
Buffer::Iterator i = start;
@@ -1171,11 +1174,11 @@ CtrlTriggerUserInfoField::Serialize(Buffer::Iterator start) const
// leads to setting the Reserved bit to zero
i.WriteU8(m_ulTargetRssi);
if (m_triggerType == BASIC_TRIGGER)
if (m_triggerType == TriggerFrameType::BASIC_TRIGGER)
{
i.WriteU8(m_basicTriggerDependentUserInfo);
}
else if (m_triggerType == MU_BAR_TRIGGER)
else if (m_triggerType == TriggerFrameType::MU_BAR_TRIGGER)
{
m_muBarTriggerDependentUserInfo.Serialize(i);
i.Next(m_muBarTriggerDependentUserInfo.GetSerializedSize());
@@ -1187,10 +1190,12 @@ CtrlTriggerUserInfoField::Serialize(Buffer::Iterator start) const
Buffer::Iterator
CtrlTriggerUserInfoField::Deserialize(Buffer::Iterator start)
{
NS_ABORT_MSG_IF(m_triggerType == BFRP_TRIGGER, "BFRP Trigger frame is not supported");
NS_ABORT_MSG_IF(m_triggerType == GCR_MU_BAR_TRIGGER,
NS_ABORT_MSG_IF(m_triggerType == TriggerFrameType::BFRP_TRIGGER,
"BFRP Trigger frame is not supported");
NS_ABORT_MSG_IF(m_triggerType == TriggerFrameType::GCR_MU_BAR_TRIGGER,
"GCR-MU-BAR Trigger frame is not supported");
NS_ABORT_MSG_IF(m_triggerType == NFRP_TRIGGER, "NFRP Trigger frame is not supported");
NS_ABORT_MSG_IF(m_triggerType == TriggerFrameType::NFRP_TRIGGER,
"NFRP Trigger frame is not supported");
Buffer::Iterator i = start;
@@ -1216,11 +1221,11 @@ CtrlTriggerUserInfoField::Deserialize(Buffer::Iterator start)
m_ulTargetRssi = i.ReadU8() & 0x7f; // B39 is reserved
if (m_triggerType == BASIC_TRIGGER)
if (m_triggerType == TriggerFrameType::BASIC_TRIGGER)
{
m_basicTriggerDependentUserInfo = i.ReadU8();
}
else if (m_triggerType == MU_BAR_TRIGGER)
else if (m_triggerType == TriggerFrameType::MU_BAR_TRIGGER)
{
uint32_t len = m_muBarTriggerDependentUserInfo.Deserialize(i);
i.Next(len);
@@ -1232,7 +1237,7 @@ CtrlTriggerUserInfoField::Deserialize(Buffer::Iterator start)
TriggerFrameType
CtrlTriggerUserInfoField::GetType() const
{
return static_cast<TriggerFrameType>(m_triggerType);
return m_triggerType;
}
void
@@ -1481,7 +1486,7 @@ CtrlTriggerUserInfoField::SetBasicTriggerDepUserInfo(uint8_t spacingFactor,
uint8_t tidLimit,
AcIndex prefAc)
{
NS_ABORT_MSG_IF(m_triggerType != BASIC_TRIGGER, "Not a Basic Trigger Frame");
NS_ABORT_MSG_IF(m_triggerType != TriggerFrameType::BASIC_TRIGGER, "Not a Basic Trigger Frame");
m_basicTriggerDependentUserInfo = (spacingFactor & 0x03) |
(tidLimit & 0x07) << 2
@@ -1492,7 +1497,7 @@ CtrlTriggerUserInfoField::SetBasicTriggerDepUserInfo(uint8_t spacingFactor,
uint8_t
CtrlTriggerUserInfoField::GetMpduMuSpacingFactor() const
{
NS_ABORT_MSG_IF(m_triggerType != BASIC_TRIGGER, "Not a Basic Trigger Frame");
NS_ABORT_MSG_IF(m_triggerType != TriggerFrameType::BASIC_TRIGGER, "Not a Basic Trigger Frame");
return m_basicTriggerDependentUserInfo & 0x03;
}
@@ -1500,7 +1505,7 @@ CtrlTriggerUserInfoField::GetMpduMuSpacingFactor() const
uint8_t
CtrlTriggerUserInfoField::GetTidAggregationLimit() const
{
NS_ABORT_MSG_IF(m_triggerType != BASIC_TRIGGER, "Not a Basic Trigger Frame");
NS_ABORT_MSG_IF(m_triggerType != TriggerFrameType::BASIC_TRIGGER, "Not a Basic Trigger Frame");
return (m_basicTriggerDependentUserInfo & 0x1c) >> 2;
}
@@ -1508,7 +1513,7 @@ CtrlTriggerUserInfoField::GetTidAggregationLimit() const
AcIndex
CtrlTriggerUserInfoField::GetPreferredAc() const
{
NS_ABORT_MSG_IF(m_triggerType != BASIC_TRIGGER, "Not a Basic Trigger Frame");
NS_ABORT_MSG_IF(m_triggerType != TriggerFrameType::BASIC_TRIGGER, "Not a Basic Trigger Frame");
return AcIndex((m_basicTriggerDependentUserInfo & 0xc0) >> 6);
}
@@ -1516,7 +1521,8 @@ CtrlTriggerUserInfoField::GetPreferredAc() const
void
CtrlTriggerUserInfoField::SetMuBarTriggerDepUserInfo(const CtrlBAckRequestHeader& bar)
{
NS_ABORT_MSG_IF(m_triggerType != MU_BAR_TRIGGER, "Not a MU-BAR Trigger frame");
NS_ABORT_MSG_IF(m_triggerType != TriggerFrameType::MU_BAR_TRIGGER,
"Not a MU-BAR Trigger frame");
NS_ABORT_MSG_IF(bar.GetType().m_variant != BlockAckReqType::COMPRESSED &&
bar.GetType().m_variant != BlockAckReqType::MULTI_TID,
"BAR Control indicates it is neither the Compressed nor the Multi-TID variant");
@@ -1526,7 +1532,8 @@ CtrlTriggerUserInfoField::SetMuBarTriggerDepUserInfo(const CtrlBAckRequestHeader
const CtrlBAckRequestHeader&
CtrlTriggerUserInfoField::GetMuBarTriggerDepUserInfo() const
{
NS_ABORT_MSG_IF(m_triggerType != MU_BAR_TRIGGER, "Not a MU-BAR Trigger frame");
NS_ABORT_MSG_IF(m_triggerType != TriggerFrameType::MU_BAR_TRIGGER,
"Not a MU-BAR Trigger frame");
return m_muBarTriggerDependentUserInfo;
}
@@ -1538,7 +1545,7 @@ CtrlTriggerUserInfoField::GetMuBarTriggerDepUserInfo() const
NS_OBJECT_ENSURE_REGISTERED(CtrlTriggerHeader);
CtrlTriggerHeader::CtrlTriggerHeader()
: m_triggerType(0),
: m_triggerType(TriggerFrameType::BASIC_TRIGGER),
m_ulLength(0),
m_moreTF(false),
m_csRequired(false),
@@ -1635,7 +1642,7 @@ CtrlTriggerHeader::GetSerializedSize() const
size += 8; // Common Info (excluding Trigger Dependent Common Info)
// Add the size of the Trigger Dependent Common Info subfield
if (m_triggerType == GCR_MU_BAR_TRIGGER)
if (m_triggerType == TriggerFrameType::GCR_MU_BAR_TRIGGER)
{
size += 4;
}
@@ -1653,15 +1660,17 @@ CtrlTriggerHeader::GetSerializedSize() const
void
CtrlTriggerHeader::Serialize(Buffer::Iterator start) const
{
NS_ABORT_MSG_IF(m_triggerType == BFRP_TRIGGER, "BFRP Trigger frame is not supported");
NS_ABORT_MSG_IF(m_triggerType == GCR_MU_BAR_TRIGGER,
NS_ABORT_MSG_IF(m_triggerType == TriggerFrameType::BFRP_TRIGGER,
"BFRP Trigger frame is not supported");
NS_ABORT_MSG_IF(m_triggerType == TriggerFrameType::GCR_MU_BAR_TRIGGER,
"GCR-MU-BAR Trigger frame is not supported");
NS_ABORT_MSG_IF(m_triggerType == NFRP_TRIGGER, "NFRP Trigger frame is not supported");
NS_ABORT_MSG_IF(m_triggerType == TriggerFrameType::NFRP_TRIGGER,
"NFRP Trigger frame is not supported");
Buffer::Iterator i = start;
uint64_t commonInfo = 0;
commonInfo |= (m_triggerType & 0x0f);
commonInfo |= (static_cast<uint8_t>(m_triggerType) & 0x0f);
commonInfo |= (m_ulLength & 0x0fff) << 4;
commonInfo |= (m_moreTF ? 1 << 16 : 0);
commonInfo |= (m_csRequired ? 1 << 17 : 0);
@@ -1687,7 +1696,7 @@ CtrlTriggerHeader::Deserialize(Buffer::Iterator start)
uint64_t commonInfo = i.ReadLsbtohU64();
m_triggerType = (commonInfo & 0x0f);
m_triggerType = static_cast<TriggerFrameType>(commonInfo & 0x0f);
m_ulLength = (commonInfo >> 4) & 0x0fff;
m_moreTF = (commonInfo >> 16) & 0x01;
m_csRequired = (commonInfo >> 17) & 0x01;
@@ -1697,10 +1706,12 @@ CtrlTriggerHeader::Deserialize(Buffer::Iterator start)
m_ulSpatialReuse = (commonInfo >> 37) & 0xffff;
m_userInfoFields.clear();
NS_ABORT_MSG_IF(m_triggerType == BFRP_TRIGGER, "BFRP Trigger frame is not supported");
NS_ABORT_MSG_IF(m_triggerType == GCR_MU_BAR_TRIGGER,
NS_ABORT_MSG_IF(m_triggerType == TriggerFrameType::BFRP_TRIGGER,
"BFRP Trigger frame is not supported");
NS_ABORT_MSG_IF(m_triggerType == TriggerFrameType::GCR_MU_BAR_TRIGGER,
"GCR-MU-BAR Trigger frame is not supported");
NS_ABORT_MSG_IF(m_triggerType == NFRP_TRIGGER, "NFRP Trigger frame is not supported");
NS_ABORT_MSG_IF(m_triggerType == TriggerFrameType::NFRP_TRIGGER,
"NFRP Trigger frame is not supported");
bool isPadding = false;
@@ -1733,7 +1744,7 @@ CtrlTriggerHeader::SetType(TriggerFrameType type)
TriggerFrameType
CtrlTriggerHeader::GetType() const
{
return static_cast<TriggerFrameType>(m_triggerType);
return m_triggerType;
}
const char*
@@ -1746,7 +1757,7 @@ const char*
CtrlTriggerHeader::GetTypeString(TriggerFrameType type)
{
#define FOO(x) \
case x: \
case TriggerFrameType::x: \
return #x; \
break;
@@ -1769,49 +1780,49 @@ CtrlTriggerHeader::GetTypeString(TriggerFrameType type)
bool
CtrlTriggerHeader::IsBasic() const
{
return (m_triggerType == BASIC_TRIGGER);
return (m_triggerType == TriggerFrameType::BASIC_TRIGGER);
}
bool
CtrlTriggerHeader::IsBfrp() const
{
return (m_triggerType == BFRP_TRIGGER);
return (m_triggerType == TriggerFrameType::BFRP_TRIGGER);
}
bool
CtrlTriggerHeader::IsMuBar() const
{
return (m_triggerType == MU_BAR_TRIGGER);
return (m_triggerType == TriggerFrameType::MU_BAR_TRIGGER);
}
bool
CtrlTriggerHeader::IsMuRts() const
{
return (m_triggerType == MU_RTS_TRIGGER);
return (m_triggerType == TriggerFrameType::MU_RTS_TRIGGER);
}
bool
CtrlTriggerHeader::IsBsrp() const
{
return (m_triggerType == BSRP_TRIGGER);
return (m_triggerType == TriggerFrameType::BSRP_TRIGGER);
}
bool
CtrlTriggerHeader::IsGcrMuBar() const
{
return (m_triggerType == GCR_MU_BAR_TRIGGER);
return (m_triggerType == TriggerFrameType::GCR_MU_BAR_TRIGGER);
}
bool
CtrlTriggerHeader::IsBqrp() const
{
return (m_triggerType == BQRP_TRIGGER);
return (m_triggerType == TriggerFrameType::BQRP_TRIGGER);
}
bool
CtrlTriggerHeader::IsNfrp() const
{
return (m_triggerType == NFRP_TRIGGER);
return (m_triggerType == TriggerFrameType::NFRP_TRIGGER);
}
void

View File

@@ -555,7 +555,7 @@ class CtrlBAckResponseHeader : public Header
* \ingroup wifi
* The different Trigger frame types.
*/
enum TriggerFrameType : uint8_t
enum class TriggerFrameType : uint8_t
{
BASIC_TRIGGER = 0, // Basic
BFRP_TRIGGER = 1, // Beamforming Report Poll
@@ -583,7 +583,7 @@ class CtrlTriggerUserInfoField
*
* \param triggerType the Trigger frame type
*/
CtrlTriggerUserInfoField(uint8_t triggerType);
CtrlTriggerUserInfoField(TriggerFrameType triggerType);
/**
* Copy assignment operator.
*
@@ -852,7 +852,7 @@ class CtrlTriggerUserInfoField
} m_bits26To31; //!< Fields occupying bits 26-31 in the User Info field
uint8_t m_ulTargetRssi; //!< Expected receive signal power
uint8_t m_triggerType; //!< Trigger frame type
TriggerFrameType m_triggerType; //!< Trigger frame type
uint8_t m_basicTriggerDependentUserInfo; //!< Basic Trigger variant of Trigger Dependent User
//!< Info subfield
CtrlBAckRequestHeader
@@ -1244,14 +1244,14 @@ class CtrlTriggerHeader : public Header
/**
* Common Info field
*/
uint8_t m_triggerType; //!< Trigger type
uint16_t m_ulLength; //!< Value for the L-SIG Length field
bool m_moreTF; //!< True if a subsequent Trigger frame follows
bool m_csRequired; //!< Carrier Sense required
uint8_t m_ulBandwidth; //!< UL BW subfield
uint8_t m_giAndLtfType; //!< GI And LTF Type subfield
uint8_t m_apTxPower; //!< Tx Power used by AP to transmit the Trigger Frame
uint16_t m_ulSpatialReuse; //!< Value for the Spatial Reuse field in HE-SIG-A
TriggerFrameType m_triggerType; //!< Trigger type
uint16_t m_ulLength; //!< Value for the L-SIG Length field
bool m_moreTF; //!< True if a subsequent Trigger frame follows
bool m_csRequired; //!< Carrier Sense required
uint8_t m_ulBandwidth; //!< UL BW subfield
uint8_t m_giAndLtfType; //!< GI And LTF Type subfield
uint8_t m_apTxPower; //!< Tx Power used by AP to transmit the Trigger Frame
uint16_t m_ulSpatialReuse; //!< Value for the Spatial Reuse field in HE-SIG-A
/**
* List of User Info fields
*/

View File

@@ -88,7 +88,7 @@ GetMuBarSize(std::list<BlockAckReqType> types)
WifiMacHeader hdr;
hdr.SetType(WIFI_MAC_CTL_TRIGGER);
CtrlTriggerHeader trigger;
trigger.SetType(MU_BAR_TRIGGER);
trigger.SetType(TriggerFrameType::MU_BAR_TRIGGER);
for (auto& t : types)
{
auto userInfo = trigger.AddUserInfoField();

View File

@@ -5486,7 +5486,7 @@ TestUlOfdmaPowerControl::SendMuBar(std::vector<uint16_t> staIds)
// Build MU-BAR trigger frame
CtrlTriggerHeader muBar;
muBar.SetType(MU_BAR_TRIGGER);
muBar.SetType(TriggerFrameType::MU_BAR_TRIGGER);
muBar.SetMoreTF(true);
muBar.SetCsRequired(true);
muBar.SetUlBandwidth(DEFAULT_CHANNEL_WIDTH);