Skip to content

Commit

Permalink
[mle] reorder Mle class member variables (#9320)
Browse files Browse the repository at this point in the history
This commit reorders member variables in the `Mle` class, bringing
booleans and `uint`s of the same size close to each other to avoid
alignment gaps.
  • Loading branch information
abtink authored Jul 31, 2023
1 parent dc97b87 commit a361aeb
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 67 deletions.
45 changes: 23 additions & 22 deletions src/core/thread/mle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,42 +74,43 @@ Mle::Mle(Instance &aInstance)
: InstanceLocator(aInstance)
, mRetrieveNewNetworkData(false)
, mRequestRouteTlv(false)
, mHasRestored(false)
, mReceivedResponseFromParent(false)
, mInitiallyAttachedAsSleepy(false)
#if OPENTHREAD_FTD
, mWasLeader(false)
#endif
, mRole(kRoleDisabled)
, mNeighborTable(aInstance)
, mDeviceMode(DeviceMode::kModeRxOnWhenIdle)
, mAttachState(kAttachStateIdle)
, mReattachState(kReattachStop)
, mAttachCounter(0)
, mAnnounceDelay(kAnnounceTimeout)
, mAttachTimer(aInstance)
, mDelayedResponseTimer(aInstance)
, mMessageTransmissionTimer(aInstance)
#if OPENTHREAD_FTD
, mWasLeader(false)
#endif
, mAttachMode(kAnyPartition)
, mChildUpdateAttempts(0)
, mChildUpdateRequestState(kChildUpdateRequestNone)
, mDataRequestAttempts(0)
, mDataRequestState(kDataRequestNone)
, mAddressRegistrationMode(kAppendAllAddresses)
, mHasRestored(false)
, mReceivedResponseFromParent(false)
, mInitiallyAttachedAsSleepy(false)
, mSocket(aInstance)
, mChildUpdateRequestState(kChildUpdateRequestNone)
, mParentRequestCounter(0)
, mChildUpdateAttempts(0)
, mDataRequestAttempts(0)
, mAnnounceChannel(0)
, mAlternateChannel(0)
, mRloc16(Mac::kShortAddrInvalid)
, mPreviousParentRloc(Mac::kShortAddrInvalid)
, mAttachCounter(0)
, mAnnounceDelay(kAnnounceTimeout)
, mAlternatePanId(Mac::kPanIdBroadcast)
, mTimeout(kMleEndDeviceTimeout)
#if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE
, mCslTimeout(kDefaultCslTimeout)
#endif
, mRloc16(Mac::kShortAddrInvalid)
, mPreviousParentRloc(Mac::kShortAddrInvalid)
, mAlternateTimestamp(0)
, mNeighborTable(aInstance)
, mSocket(aInstance)
#if OPENTHREAD_CONFIG_PARENT_SEARCH_ENABLE
, mParentSearch(aInstance)
#endif
, mAnnounceChannel(0)
, mAlternateChannel(0)
, mAlternatePanId(Mac::kPanIdBroadcast)
, mAlternateTimestamp(0)
, mAttachTimer(aInstance)
, mDelayedResponseTimer(aInstance)
, mMessageTransmissionTimer(aInstance)
, mDetachGracefullyTimer(aInstance)
{
mParent.Init(aInstance);
Expand Down
95 changes: 50 additions & 45 deletions src/core/thread/mle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1294,69 +1294,74 @@ class Mle : public InstanceLocator, private NonCopyable

static const otMeshLocalPrefix kMeshLocalPrefixInit;

Ip6::Netif::UnicastAddress mLeaderAloc;
LeaderData mLeaderData;
bool mRetrieveNewNetworkData : 1;
bool mRequestRouteTlv : 1;
DeviceRole mRole;
Parent mParent;
NeighborTable mNeighborTable;
DeviceMode mDeviceMode;
AttachState mAttachState;
uint8_t mParentRequestCounter;
ReattachState mReattachState;
uint16_t mAttachCounter;
uint16_t mAnnounceDelay;
AttachTimer mAttachTimer;
DelayTimer mDelayedResponseTimer;
MsgTxTimer mMessageTransmissionTimer;
bool mRetrieveNewNetworkData : 1;
bool mRequestRouteTlv : 1;
bool mHasRestored : 1;
bool mReceivedResponseFromParent : 1;
bool mInitiallyAttachedAsSleepy : 1;
#if OPENTHREAD_FTD
uint8_t mLinkRequestAttempts;
bool mWasLeader;
bool mWasLeader : 1;
#endif
MessageQueue mDelayedResponses;
TxChallenge mParentRequestChallenge;

DeviceRole mRole;
DeviceMode mDeviceMode;
AttachState mAttachState;
ReattachState mReattachState;
AttachMode mAttachMode;
ParentCandidate mParentCandidate;
uint8_t mChildUpdateAttempts;
ChildUpdateRequestState mChildUpdateRequestState;
uint8_t mDataRequestAttempts;
DataRequestState mDataRequestState;
AddressRegistrationMode mAddressRegistrationMode;
bool mHasRestored;
bool mReceivedResponseFromParent;
bool mInitiallyAttachedAsSleepy;
Ip6::Udp::Socket mSocket;
uint32_t mTimeout;
#if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE
uint32_t mCslTimeout;
ChildUpdateRequestState mChildUpdateRequestState;

uint8_t mParentRequestCounter;
uint8_t mChildUpdateAttempts;
uint8_t mDataRequestAttempts;
uint8_t mAnnounceChannel;
uint8_t mAlternateChannel;
#if OPENTHREAD_FTD
uint8_t mLinkRequestAttempts;
#endif
uint16_t mRloc16;
uint16_t mPreviousParentRloc;
uint16_t mAttachCounter;
uint16_t mAnnounceDelay;
uint16_t mAlternatePanId;
uint32_t mTimeout;
#if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE
uint32_t mCslTimeout;
#endif
uint64_t mAlternateTimestamp;
#if OPENTHREAD_CONFIG_UPTIME_ENABLE
uint64_t mLastUpdatedTimestamp;
#endif

LeaderData mLeaderData;
Parent mParent;
NeighborTable mNeighborTable;
MessageQueue mDelayedResponses;
TxChallenge mParentRequestChallenge;
ParentCandidate mParentCandidate;
Ip6::Udp::Socket mSocket;
Counters mCounters;
#if OPENTHREAD_CONFIG_PARENT_SEARCH_ENABLE
ParentSearch mParentSearch;
#endif
uint8_t mAnnounceChannel;
uint8_t mAlternateChannel;
uint16_t mAlternatePanId;
uint64_t mAlternateTimestamp;
#if OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE
ServiceAloc mServiceAlocs[kMaxServiceAlocs];
#endif
Counters mCounters;
#if OPENTHREAD_CONFIG_UPTIME_ENABLE
uint64_t mLastUpdatedTimestamp;
#endif
Ip6::Netif::UnicastAddress mLinkLocal64;
Ip6::Netif::UnicastAddress mMeshLocal64;
Ip6::Netif::UnicastAddress mMeshLocal16;
Ip6::Netif::MulticastAddress mLinkLocalAllThreadNodes;
Ip6::Netif::MulticastAddress mRealmLocalAllThreadNodes;
DetachGracefullyTimer mDetachGracefullyTimer;
Callback<otDetachGracefullyCallback> mDetachGracefullyCallback;
#if OPENTHREAD_CONFIG_MLE_PARENT_RESPONSE_CALLBACK_API_ENABLE
Callback<otThreadParentResponseCallback> mParentResponseCallback;
#endif
AttachTimer mAttachTimer;
DelayTimer mDelayedResponseTimer;
MsgTxTimer mMessageTransmissionTimer;
DetachGracefullyTimer mDetachGracefullyTimer;
Ip6::Netif::UnicastAddress mLinkLocal64;
Ip6::Netif::UnicastAddress mMeshLocal64;
Ip6::Netif::UnicastAddress mMeshLocal16;
Ip6::Netif::MulticastAddress mLinkLocalAllThreadNodes;
Ip6::Netif::MulticastAddress mRealmLocalAllThreadNodes;
Ip6::Netif::UnicastAddress mLeaderAloc;
};

} // namespace Mle
Expand Down

0 comments on commit a361aeb

Please sign in to comment.