mirror of
https://github.com/espressif/openthread.git
synced 2026-08-18 08:29:52 +00:00
[ncp] enhance handling of outbound IP message over spinel (to host) (#2259)
This commit changes how the outbound datagram IPv6 messages (going from NCP to host over spinel) are handled. If NCP spinel buffer is full, new outbound messages are saved in a message queue and are transfered later (as soon as buffer space becomes available). This ensures that outbound IPv6 messages are never dropped due to spinel NCP buffer being full. To realize this, the following changes are made in this commit: (a) The behavior of methods `NcpFrameBuffer::InFrameFeedMessage()` and `SpinelEncoder::WriteMessage()` is changed so that the passed-in message ownership changes to NCP buffer ONLY when the entire spinel frame is written and the frame is successfully ended/finished. If the spinel frame gets discarded (e.g. no buffer space) the caller continues to own the message instance and should either free or save it. (b) The unit test `test_ncp_buffer` is changed to address and check for this change. (c) The `NcpBase::HandleDatagramFromStack()` is modified to implement/use a message queue to save outbound messages and try again to send the queued messages from `HandleFrameRemovedFromNcpBuffer()` callback (when spinel buffer becomes available).
This commit is contained in:
committed by
Jonathan Hui
parent
92ba27a1fa
commit
54fa0f1836
@@ -574,6 +574,10 @@ void TestNcpFrameBuffer(void)
|
||||
WriteTestFrame1(ncpBuffer,
|
||||
frame1IsHighPriority ? NcpFrameBuffer::kPriorityHigh : NcpFrameBuffer::kPriorityLow);
|
||||
|
||||
// Note that message will not be freed by the NCP buffer since the frame associated with it was discarded and
|
||||
// not yet finished/ended.
|
||||
otMessageFree(message);
|
||||
|
||||
VerifyAndRemoveFrame3(ncpBuffer);
|
||||
|
||||
// Start reading few bytes from the frame
|
||||
|
||||
Reference in New Issue
Block a user