Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup Throttle Flow mechanism from CRMP #4294

Merged
merged 1 commit into from
Jan 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/messaging/ExchangeContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ class DLL_EXPORT ExchangeContext : public ReferenceCounted<ExchangeContext, Exch
* with the message being sent.

* @retval #CHIP_ERROR_INVALID_ARGUMENT if an invalid argument was passed to this SendMessage API.
* @retval #CHIP_ERROR_SEND_THROTTLED if this exchange context has been throttled when using the
* CHIP reliable messaging protocol.
* @retval #CHIP_ERROR_WRONG_MSG_VERSION_FOR_EXCHANGE if there is a mismatch in the specific send operation and the
* CHIP message protocol version that is supported.
* @retval #CHIP_ERROR_NOT_CONNECTED if the context was associated with a connection that is now
Expand Down
33 changes: 1 addition & 32 deletions src/messaging/ReliableMessageContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace Messaging {

ReliableMessageContext::ReliableMessageContext() :
mManager(nullptr), mExchange(nullptr), mDelegate(nullptr), mConfig(gDefaultReliableMessageProtocolConfig), mNextAckTimeTick(0),
mThrottleTimeoutTick(0), mPendingPeerAckId(0)
mPendingPeerAckId(0)
{}

void ReliableMessageContext::Init(ReliableMessageManager * manager, ExchangeContext * exchange)
Expand Down Expand Up @@ -332,37 +332,6 @@ CHIP_ERROR ReliableMessageContext::HandleNeedsAck(uint32_t MessageId, BitFlags<u
return err;
}

CHIP_ERROR ReliableMessageContext::HandleThrottleFlow(uint32_t PauseTimeMillis)
{
// Expire any virtual ticks that have expired so all wakeup sources reflect the current time
mManager->ExpireTicks();

// Flow Control Message Received; Adjust Throttle timeout accordingly.
// A PauseTimeMillis of zero indicates that peer is unthrottling this Exchange.

if (0 != PauseTimeMillis)
{
mThrottleTimeoutTick =
static_cast<uint16_t>(mManager->GetTickCounterFromTimeDelta(System::Timer::GetCurrentEpoch() + PauseTimeMillis));
mManager->PauseRetransTable(this, PauseTimeMillis);
}
else
{
mThrottleTimeoutTick = 0;
mManager->ResumeRetransTable(this);
}

// Call OnThrottleRcvd application callback
if (mDelegate)
{
mDelegate->OnThrottleRcvd(PauseTimeMillis);
}

// Schedule next physical wakeup
mManager->StartTimer();
return CHIP_NO_ERROR;
}

/**
* Send a SecureChannel::StandaloneAck message.
*
Expand Down
9 changes: 3 additions & 6 deletions src/messaging/ReliableMessageContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ class ReliableMessageDelegate
virtual ~ReliableMessageDelegate() {}

/* Application callbacks */
virtual void OnThrottleRcvd(uint32_t pauseTime) = 0; /**< Application callback for received Throttle message. */
virtual void OnSendError(CHIP_ERROR err) = 0; /**< Application callback for error while sending. */
virtual void OnAckRcvd() = 0; /**< Application callback for received acknowledgment. */
virtual void OnSendError(CHIP_ERROR err) = 0; /**< Application callback for error while sending. */
virtual void OnAckRcvd() = 0; /**< Application callback for received acknowledgment. */
};

class ReliableMessageContext
Expand Down Expand Up @@ -111,7 +110,6 @@ class ReliableMessageContext
void Release();
CHIP_ERROR HandleRcvdAck(uint32_t AckMsgId);
CHIP_ERROR HandleNeedsAck(uint32_t MessageId, BitFlags<uint32_t, MessageFlagValues> Flags);
CHIP_ERROR HandleThrottleFlow(uint32_t PauseTimeMillis);

private:
friend class ReliableMessageManager;
Expand All @@ -121,8 +119,7 @@ class ReliableMessageContext
ExchangeContext * mExchange;
ReliableMessageDelegate * mDelegate;
ReliableMessageProtocolConfig mConfig;
uint16_t mNextAckTimeTick; // Next time for triggering Solo Ack
uint16_t mThrottleTimeoutTick; // Timeout until when Throttle is On when ThrottleEnabled is set
uint16_t mNextAckTimeTick; // Next time for triggering Solo Ack
uint32_t mPendingPeerAckId;
};

Expand Down
20 changes: 0 additions & 20 deletions src/messaging/ReliableMessageManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,21 +233,11 @@ void ReliableMessageManager::ExpireTicks()
}
});

// Process Throttle Time
// Check Throttle timeout stored in EC to set/unset Throttle flag
for (int i = 0; i < CHIP_CONFIG_RMP_RETRANS_TABLE_SIZE; i++)
{
ReliableMessageContext * rc = mRetransTable[i].rc;
if (rc)
{
// Process Retransmit Table
// Decrement Throttle timeout by elapsed timeticks
TickProceed(rc->mThrottleTimeoutTick, deltaTicks);
#if defined(RMP_TICKLESS_DEBUG)
ChipLogProgress(ExchangeManager, "ReliableMessageManager::ExpireTicks set mThrottleTimeoutTick to %u",
mRetransTable[i].nextRetransTimeTick);
#endif

// Decrement Retransmit timeout by elapsed timeticks
TickProceed(mRetransTable[i].nextRetransTimeTick, deltaTicks);
#if defined(RMP_TICKLESS_DEBUG)
Expand Down Expand Up @@ -530,16 +520,6 @@ void ReliableMessageManager::StartTimer()
ReliableMessageContext * rc = mRetransTable[i].rc;
if (rc)
{
// When do we need to next wake up for throttle retransmission?
if (rc->mThrottleTimeoutTick != 0 && rc->mThrottleTimeoutTick < nextWakeTimeTick)
{
nextWakeTimeTick = rc->mThrottleTimeoutTick;
foundWake = true;
#if defined(RMP_TICKLESS_DEBUG)
ChipLogProgress(ExchangeManager, "ReliableMessageManager::StartTimer throttle timeout %u", nextWakeTimeTick);
#endif
}

// When do we need to next wake up for ReliableMessageProtocol retransmit?
if (mRetransTable[i].nextRetransTimeTick < nextWakeTimeTick)
{
Expand Down
1 change: 0 additions & 1 deletion src/messaging/tests/TestReliableMessageProtocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ class ReliableMessageDelegateObject : public ReliableMessageDelegate
~ReliableMessageDelegateObject() override {}

/* Application callbacks */
void OnThrottleRcvd(uint32_t pauseTime) override {}
void OnSendError(CHIP_ERROR err) override { SendErrorCalled = true; }
void OnAckRcvd() override {}

Expand Down