From a361aebc8b566ae9225c8163025550f2867bc112 Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Mon, 31 Jul 2023 10:41:06 -0700 Subject: [PATCH] [mle] reorder `Mle` class member variables (#9320) 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. --- src/core/thread/mle.cpp | 53 +++++++++++----------- src/core/thread/mle.hpp | 97 ++++++++++++++++++++++------------------- 2 files changed, 78 insertions(+), 72 deletions(-) diff --git a/src/core/thread/mle.cpp b/src/core/thread/mle.cpp index 34eb419bd..390bf3674 100644 --- a/src/core/thread/mle.cpp +++ b/src/core/thread/mle.cpp @@ -74,42 +74,43 @@ Mle::Mle(Instance &aInstance) : InstanceLocator(aInstance) , mRetrieveNewNetworkData(false) , mRequestRouteTlv(false) - , 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) +#if OPENTHREAD_FTD + , mWasLeader(false) +#endif + , mRole(kRoleDisabled) + , mDeviceMode(DeviceMode::kModeRxOnWhenIdle) + , mAttachState(kAttachStateIdle) + , mReattachState(kReattachStop) + , mAttachMode(kAnyPartition) + , mDataRequestState(kDataRequestNone) + , mAddressRegistrationMode(kAppendAllAddresses) + , 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); diff --git a/src/core/thread/mle.hpp b/src/core/thread/mle.hpp index 94d7b3892..cfba2cf55 100644 --- a/src/core/thread/mle.hpp +++ b/src/core/thread/mle.hpp @@ -1294,69 +1294,74 @@ private: 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; -#if OPENTHREAD_CONFIG_PARENT_SEARCH_ENABLE - ParentSearch mParentSearch; -#endif - uint8_t mAnnounceChannel; - uint8_t mAlternateChannel; + uint16_t mAttachCounter; + uint16_t mAnnounceDelay; uint16_t mAlternatePanId; - uint64_t mAlternateTimestamp; -#if OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE - ServiceAloc mServiceAlocs[kMaxServiceAlocs]; + uint32_t mTimeout; +#if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE + uint32_t mCslTimeout; #endif - Counters mCounters; + uint64_t mAlternateTimestamp; #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; + + 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 +#if OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE + ServiceAloc mServiceAlocs[kMaxServiceAlocs]; +#endif Callback mDetachGracefullyCallback; #if OPENTHREAD_CONFIG_MLE_PARENT_RESPONSE_CALLBACK_API_ENABLE Callback 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