[mesh-forwarder] MTD code size optimizations (#2469)

This commit is contained in:
Jonathan Hui
2018-01-17 20:18:09 +00:00
committed by GitHub
parent cc26bb7862
commit 5028d2f71b
10 changed files with 1246 additions and 1064 deletions
+2
View File
@@ -129,6 +129,8 @@
<ClCompile Include="..\..\src\core\thread\link_quality.cpp" />
<ClCompile Include="..\..\src\core\thread\lowpan.cpp" />
<ClCompile Include="..\..\src\core\thread\mesh_forwarder.cpp" />
<ClCompile Include="..\..\src\core\thread\mesh_forwarder_ftd.cpp" />
<ClCompile Include="..\..\src\core\thread\mesh_forwarder_mtd.cpp" />
<ClCompile Include="..\..\src\core\thread\mle.cpp" />
<ClCompile Include="..\..\src\core\thread\mle_router.cpp" />
<ClCompile Include="..\..\src\core\thread\network_data.cpp" />
@@ -219,6 +219,12 @@
<ClCompile Include="..\..\src\core\thread\mesh_forwarder.cpp">
<Filter>Source Files\thread</Filter>
</ClCompile>
<ClCompile Include="..\..\src\core\thread\mesh_forwarder_ftd.cpp">
<Filter>Source Files\thread</Filter>
</ClCompile>
<ClCompile Include="..\..\src\core\thread\mesh_forwarder_mtd.cpp">
<Filter>Source Files\thread</Filter>
</ClCompile>
<ClCompile Include="..\..\src\core\thread\mle.cpp">
<Filter>Source Files\thread</Filter>
</ClCompile>
@@ -137,6 +137,8 @@
<ClCompile Include="..\..\src\core\thread\link_quality.cpp" />
<ClCompile Include="..\..\src\core\thread\lowpan.cpp" />
<ClCompile Include="..\..\src\core\thread\mesh_forwarder.cpp" />
<ClCompile Include="..\..\src\core\thread\mesh_forwarder_ftd.cpp" />
<ClCompile Include="..\..\src\core\thread\mesh_forwarder_mtd.cpp" />
<ClCompile Include="..\..\src\core\thread\mle.cpp" />
<ClCompile Include="..\..\src\core\thread\mle_router.cpp" />
<ClCompile Include="..\..\src\core\thread\network_data.cpp" />
@@ -219,6 +219,12 @@
<ClCompile Include="..\..\src\core\thread\mesh_forwarder.cpp">
<Filter>Source Files\thread</Filter>
</ClCompile>
<ClCompile Include="..\..\src\core\thread\mesh_forwarder_ftd.cpp">
<Filter>Source Files\thread</Filter>
</ClCompile>
<ClCompile Include="..\..\src\core\thread\mesh_forwarder_mtd.cpp">
<Filter>Source Files\thread</Filter>
</ClCompile>
<ClCompile Include="..\..\src\core\thread\mle.cpp">
<Filter>Source Files\thread</Filter>
</ClCompile>
+2
View File
@@ -171,6 +171,8 @@ SOURCES_COMMON = \
thread/link_quality.cpp \
thread/lowpan.cpp \
thread/mesh_forwarder.cpp \
thread/mesh_forwarder_ftd.cpp \
thread/mesh_forwarder_mtd.cpp \
thread/mle.cpp \
thread/mle_router.cpp \
thread/network_data.cpp \
+5
View File
@@ -177,8 +177,13 @@ void otMessageGetBufferInfo(otInstance *aInstance, otBufferInfo *aBufferInfo)
instance.GetThreadNetif().GetMeshForwarder().GetReassemblyQueue().GetInfo(aBufferInfo->m6loReassemblyMessages,
aBufferInfo->m6loReassemblyBuffers);
#if OPENTHREAD_FTD
instance.GetThreadNetif().GetMeshForwarder().GetResolvingQueue().GetInfo(aBufferInfo->mArpMessages,
aBufferInfo->mArpBuffers);
#else
aBufferInfo->mArpMessages = 0;
aBufferInfo->mArpBuffers = 0;
#endif
instance.GetThreadNetif().GetIp6().GetSendQueue().GetInfo(aBufferInfo->mIp6Messages,
aBufferInfo->mIp6Buffers);
File diff suppressed because it is too large Load Diff
+33 -29
View File
@@ -199,14 +199,6 @@ public:
*/
const MessageQueue &GetReassemblyQueue(void) const { return mReassemblyList; }
/**
* This method returns a reference to the resolving queue.
*
* @returns A reference to the resolving queue.
*
*/
const MessageQueue &GetResolvingQueue(void) const { return mResolvingQueue; }
/**
* This method returns a reference to the data poll manager.
*
@@ -215,14 +207,6 @@ public:
*/
DataPollManager &GetDataPollManager(void) { return mDataPollManager; }
/**
* This method returns a reference to the source match controller.
*
* @returns A reference to the source match controller.
*
*/
SourceMatchController &GetSourceMatchController(void) { return mSourceMatchController; }
/**
* This method returns a reference to the IP level counters.
*
@@ -231,6 +215,24 @@ public:
*/
const otIpCounters &GetCounters(void) const { return mIpCounters; }
#if OPENTHREAD_FTD
/**
* This method returns a reference to the resolving queue.
*
* @returns A reference to the resolving queue.
*
*/
const MessageQueue &GetResolvingQueue(void) const { return mResolvingQueue; }
/**
* This method returns a reference to the source match controller.
*
* @returns A reference to the source match controller.
*
*/
SourceMatchController &GetSourceMatchController(void) { return mSourceMatchController; }
#endif
private:
enum
{
@@ -272,6 +274,7 @@ private:
otError GetMacDestinationAddress(const Ip6::Address &aIp6Addr, Mac::Address &aMacAddr);
otError GetMacSourceAddress(const Ip6::Address &aIp6Addr, Mac::Address &aMacAddr);
Message *GetDirectTransmission(void);
otError GetIndirectTransmission(void);
Message *GetIndirectTransmission(Child &aChild);
otError PrepareDiscoverRequest(void);
void PrepareIndirectTransmission(Message &aMessage, const Child &aChild);
@@ -290,6 +293,7 @@ private:
otError SendFragment(Message &aMessage, Mac::Frame &aFrame);
otError SendEmptyFrame(Mac::Frame &aFrame, bool aAckRequest);
otError UpdateIp6Route(Message &aMessage);
otError UpdateIp6RouteFtd(Ip6::Header &ip6Header);
otError UpdateMeshRoute(Message &aMessage);
otError HandleDatagram(Message &aMessage, const otThreadLinkInfo &aLinkInfo,
const Mac::Address &aMacSource);
@@ -303,6 +307,7 @@ private:
otError HandleFrameRequest(Mac::Frame &aFrame);
static void HandleSentFrame(Mac::Sender &aSender, Mac::Frame &aFrame, otError aError);
void HandleSentFrame(Mac::Frame &aFrame, otError aError);
void HandleSentFrameToChild(const Mac::Frame &aFrame, otError aError, const Mac::Address &macDest);
static void HandleDiscoverTimer(Timer &aTimer);
void HandleDiscoverTimer(void);
static void HandleReassemblyTimer(Timer &aTimer);
@@ -311,11 +316,7 @@ private:
void ScheduleTransmissionTask(void);
static void HandleDataPollTimeout(Mac::Receiver &aReceiver);
#if OPENTHREAD_FTD
#if OPENTHREAD_ENABLE_SERVICE
otError GetDestinationRlocByServiceAloc(uint16_t aServiceAloc, uint16_t &aMeshDest);
#endif // OPENTHREAD_ENABLE_SERVICE
#endif // OPENTHREAD_FTD
void LogIp6Message(MessageAction aAction, const Message &aMessage, const Mac::Address *aMacAddress,
otError aError);
@@ -327,17 +328,12 @@ private:
PriorityQueue mSendQueue;
MessageQueue mReassemblyList;
MessageQueue mResolvingQueue;
uint16_t mFragTag;
uint16_t mMessageNextOffset;
uint32_t mSendMessageFrameCounter;
Message *mSendMessage;
Message *mSendMessage;
bool mSendMessageIsARetransmission;
uint8_t mSendMessageMaxMacTxAttempts;
uint8_t mSendMessageKeyId;
uint8_t mSendMessageDataSequenceNumber;
uint8_t mStartChildIndex;
Mac::Address mMacSource;
Mac::Address mMacDest;
@@ -356,10 +352,18 @@ private:
uint16_t mRestorePanId;
bool mScanning;
DataPollManager mDataPollManager;
SourceMatchController mSourceMatchController;
otIpCounters mIpCounters;
#if OPENTHREAD_FTD
MessageQueue mResolvingQueue;
SourceMatchController mSourceMatchController;
uint32_t mSendMessageFrameCounter;
uint8_t mSendMessageKeyId;
uint8_t mSendMessageDataSequenceNumber;
uint8_t mStartChildIndex;
#endif
DataPollManager mDataPollManager;
};
/**
File diff suppressed because it is too large Load Diff
+92
View File
@@ -0,0 +1,92 @@
/*
* Copyright (c) 2018, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @file
* This file implements MTD-specific mesh forwarding of IPv6/6LoWPAN messages.
*/
#if OPENTHREAD_MTD
#define WPP_NAME "mesh_forwarder_mtd.tmh"
#include "mesh_forwarder.hpp"
namespace ot {
otError MeshForwarder::SendMessage(Message &aMessage)
{
otError error;
aMessage.SetDirectTransmission();
aMessage.SetOffset(0);
aMessage.SetDatagramTag(0);
SuccessOrExit(error = mSendQueue.Enqueue(aMessage));
mScheduleTransmissionTask.Post();
exit:
return error;
}
otError MeshForwarder::EvictIndirectMessage(void)
{
return OT_ERROR_NOT_FOUND;
}
otError MeshForwarder::GetIndirectTransmission(void)
{
return OT_ERROR_NOT_FOUND;
}
otError MeshForwarder::RemoveMessageFromSleepyChild(Message &aMessage, Child &aChild)
{
OT_UNUSED_VARIABLE(aMessage);
OT_UNUSED_VARIABLE(aChild);
return OT_ERROR_NOT_FOUND;
}
void MeshForwarder::HandleSentFrameToChild(const Mac::Frame &aFrame, otError aError, const Mac::Address &aMacDest)
{
OT_UNUSED_VARIABLE(aFrame);
OT_UNUSED_VARIABLE(aError);
OT_UNUSED_VARIABLE(aMacDest);
}
void MeshForwarder::HandleMesh(uint8_t *aFrame, uint8_t aFrameLength, const Mac::Address &aMacSource,
const otThreadLinkInfo &aLinkInfo)
{
OT_UNUSED_VARIABLE(aFrame);
OT_UNUSED_VARIABLE(aFrameLength);
OT_UNUSED_VARIABLE(aMacSource);
OT_UNUSED_VARIABLE(aLinkInfo);
}
} // namespace ot
#endif // OPENTHREAD_MTD