mirror of
https://github.com/espressif/openthread.git
synced 2026-07-30 23:57:47 +00:00
[mpl] use TimeTicker for aging mSeedSet entries (#8488)
This commit updates the `Ip6::Mpl` to use `TimeTicker` instead of its own `Timer` to age the entries in its `mSeedSet`. This commit also updates the default number of seed entries by 3 to use the memory saved by using `TimeTicker`.
This commit is contained in:
@@ -124,6 +124,11 @@ void TimeTicker::HandleTimer(void)
|
||||
Get<MlrManager>().HandleTimeTick();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (mReceivers & Mask(kIp6Mpl))
|
||||
{
|
||||
Get<Ip6::Mpl>().HandleTimeTick();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ot
|
||||
|
||||
@@ -72,6 +72,7 @@ public:
|
||||
kDuaManager, ///< `DuaManager`
|
||||
kMlrManager, ///< `MlrManager`
|
||||
kNetworkDataNotifier, ///< `NetworkData::Notifier`
|
||||
kIp6Mpl, ///< `Ip6::Mpl`
|
||||
|
||||
kNumReceivers, ///< Number of receivers.
|
||||
};
|
||||
|
||||
@@ -136,7 +136,7 @@
|
||||
*
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_MPL_SEED_SET_ENTRIES
|
||||
#define OPENTHREAD_CONFIG_MPL_SEED_SET_ENTRIES 32
|
||||
#define OPENTHREAD_CONFIG_MPL_SEED_SET_ENTRIES 35
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
||||
@@ -46,7 +46,6 @@ namespace Ip6 {
|
||||
|
||||
Mpl::Mpl(Instance &aInstance)
|
||||
: InstanceLocator(aInstance)
|
||||
, mSeedSetTimer(aInstance)
|
||||
, mSequence(0)
|
||||
#if OPENTHREAD_FTD
|
||||
, mRetransmissionTimer(aInstance)
|
||||
@@ -252,19 +251,16 @@ Error Mpl::UpdateSeedSet(uint16_t aSeedId, uint8_t aSequence)
|
||||
insert->mSequence = aSequence;
|
||||
insert->mLifetime = kSeedEntryLifetime;
|
||||
|
||||
if (!mSeedSetTimer.IsRunning())
|
||||
{
|
||||
mSeedSetTimer.Start(kSeedEntryLifetimeDt);
|
||||
}
|
||||
Get<TimeTicker>().RegisterReceiver(TimeTicker::kIp6Mpl);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
void Mpl::HandleSeedSetTimer(void)
|
||||
void Mpl::HandleTimeTick(void)
|
||||
{
|
||||
bool startTimer = false;
|
||||
int j = 0;
|
||||
bool continueRxingTicks = false;
|
||||
int j = 0;
|
||||
|
||||
for (int i = 0; i < kNumSeedEntries && mSeedSet[i].mLifetime; i++)
|
||||
{
|
||||
@@ -272,8 +268,8 @@ void Mpl::HandleSeedSetTimer(void)
|
||||
|
||||
if (mSeedSet[i].mLifetime > 0)
|
||||
{
|
||||
mSeedSet[j++] = mSeedSet[i];
|
||||
startTimer = true;
|
||||
mSeedSet[j++] = mSeedSet[i];
|
||||
continueRxingTicks = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -282,9 +278,9 @@ void Mpl::HandleSeedSetTimer(void)
|
||||
mSeedSet[j].mLifetime = 0;
|
||||
}
|
||||
|
||||
if (startTimer)
|
||||
if (!continueRxingTicks)
|
||||
{
|
||||
mSeedSetTimer.Start(kSeedEntryLifetimeDt);
|
||||
Get<TimeTicker>().UnregisterReceiver(TimeTicker::kIp6Mpl);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include "common/locator.hpp"
|
||||
#include "common/message.hpp"
|
||||
#include "common/non_copyable.hpp"
|
||||
#include "common/time_ticker.hpp"
|
||||
#include "common/timer.hpp"
|
||||
#include "net/ip6_headers.hpp"
|
||||
|
||||
@@ -185,6 +186,8 @@ private:
|
||||
*/
|
||||
class Mpl : public InstanceLocator, private NonCopyable
|
||||
{
|
||||
friend class ot::TimeTicker;
|
||||
|
||||
public:
|
||||
/**
|
||||
* This constructor initializes the MPL object.
|
||||
@@ -244,14 +247,11 @@ private:
|
||||
uint8_t mLifetime;
|
||||
};
|
||||
|
||||
void HandleSeedSetTimer(void);
|
||||
void HandleTimeTick(void);
|
||||
Error UpdateSeedSet(uint16_t aSeedId, uint8_t aSequence);
|
||||
|
||||
using SeedSetTimer = TimerMilliIn<Mpl, &Mpl::HandleSeedSetTimer>;
|
||||
|
||||
SeedEntry mSeedSet[kNumSeedEntries];
|
||||
SeedSetTimer mSeedSetTimer;
|
||||
uint8_t mSequence;
|
||||
SeedEntry mSeedSet[kNumSeedEntries];
|
||||
uint8_t mSequence;
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
static constexpr uint8_t kChildTimerExpirations = 0; // MPL retransmissions for Children.
|
||||
|
||||
Reference in New Issue
Block a user