Skip to content

Commit

Permalink
[System] Remove LwIP from EFR32 OpenThread implementation (#17512)
Browse files Browse the repository at this point in the history
* Remove LwIP from EFR32 OpenThread platform impl
  • Loading branch information
jepenven-silabs authored Apr 19, 2022
1 parent 03ea72d commit ff32d56
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/inet/UDPEndPointImplOpenThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void UDPEndPointImplOT::handleUdpReceive(void * aContext, otMessage * aMessage,
payload->SetDataLength(static_cast<uint16_t>(msgLen + sizeof(IPPacketInfo)));

ep->Retain();
CHIP_ERROR err = ep->GetSystemLayer().ScheduleLambda([ep, p = System::LwIPPacketBufferView::UnsafeGetLwIPpbuf(payload)] {
CHIP_ERROR err = ep->GetSystemLayer().ScheduleLambda([ep, p = payload.Get()] {
ep->HandleDataReceived(System::PacketBufferHandle::Adopt(p));
ep->Release();
});
Expand Down
1 change: 1 addition & 0 deletions src/platform/EFR32/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ chip_mdns = "platform"
chip_inet_config_enable_ipv4 = false
chip_inet_config_enable_tcp_endpoint = false
chip_system_config_use_open_thread_inet_endpoints = true
chip_with_lwip = false

chip_build_tests = false

Expand Down
20 changes: 20 additions & 0 deletions src/system/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,21 @@ if (chip_project_config_include_dirs == [] &&
chip_project_config_include_dirs += [ "${chip_root}/config/standalone" ]
}

if (chip_device_platform == "cc13x2_26x2") {
import("//build_overrides/ti_simplelink_sdk.gni")
} else if (chip_device_platform == "efr32") {
import("//build_overrides/efr32_sdk.gni")
} else if (chip_device_platform == "qpg") {
import("//build_overrides/qpg_sdk.gni")
import("${qpg_sdk_build_root}/qpg_sdk.gni")
} else if (chip_device_platform == "k32w0") {
import("//build_overrides/k32w0_sdk.gni")
} else if (chip_device_platform == "p6") {
import("//build_overrides/p6.gni")
} else if (chip_device_platform == "cyw30739") {
import("//build_overrides/cyw30739_sdk.gni")
}

buildconfig_header("system_buildconfig") {
header = "SystemBuildConfig.h"
header_dir = "system"
Expand Down Expand Up @@ -123,6 +138,11 @@ source_set("system_config_header") {
if (target_cpu != "esp32") {
if (chip_system_config_use_lwip) {
public_deps += [ "${chip_root}/src/lwip" ]
} else {
if (chip_device_platform == "efr32") {
public_deps += [ "${efr32_sdk_build_root}:efr32_sdk" ]
}
# Add platform here as needed.
}
}
}
Expand Down
9 changes: 8 additions & 1 deletion src/system/SystemConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@

/*--- Sanity check on the build configuration logic. ---*/

#if !(CHIP_SYSTEM_CONFIG_USE_LWIP || CHIP_SYSTEM_CONFIG_USE_SOCKETS || CHIP_SYSTEM_CONFIG_USE_NETWORK_FRAMEWORK)
#if !(CHIP_SYSTEM_CONFIG_USE_LWIP || CHIP_SYSTEM_CONFIG_USE_SOCKETS || CHIP_SYSTEM_CONFIG_USE_NETWORK_FRAMEWORK || \
CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT)
#error "REQUIRED: CHIP_SYSTEM_CONFIG_USE_LWIP || CHIP_SYSTEM_CONFIG_USE_SOCKETS || CHIP_SYSTEM_CONFIG_USE_NETWORK_FRAMEWORK"
#endif // !(CHIP_SYSTEM_CONFIG_USE_LWIP || CHIP_SYSTEM_CONFIG_USE_SOCKETS || CHIP_SYSTEM_USE_NETWORK_FRAMEWORK)

Expand All @@ -110,6 +111,12 @@
#error "FORBIDDEN: CHIP_SYSTEM_CONFIG_USE_NETWORK_FRAMEWORK && CHIP_SYSTEM_CONFIG_USE_SOCKETS"
#endif // CHIP_SYSTEM_CONFIG_USE_NETWORK_FRAMEWORK && CHIP_SYSTEM_CONFIG_USE_SOCKETS

#if CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT && \
(CHIP_SYSTEM_CONFIG_USE_NETWORK_FRAMEWORK || CHIP_SYSTEM_CONFIG_USE_SOCKETS || CHIP_SYSTEM_CONFIG_USE_LWIP)
#error \
"FORBIDDEN: CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT && ( CHIP_SYSTEM_CONFIG_USE_NETWORK_FRAMEWORK || CHIP_SYSTEM_CONFIG_USE_SOCKETS || CHIP_SYSTEM_CONFIG_USE_LWIP )"
#endif

// clang-format off

/**
Expand Down
2 changes: 1 addition & 1 deletion src/system/SystemLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class DLL_EXPORT Layer
Layer & operator=(const Layer &) = delete;
};

#if CHIP_SYSTEM_CONFIG_USE_LWIP
#if CHIP_SYSTEM_CONFIG_USE_LWIP || CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT

class LayerLwIP : public Layer
{
Expand Down
2 changes: 2 additions & 0 deletions src/system/SystemLayerImplLwIP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ CHIP_ERROR LayerImplLwIP::Init()
{
VerifyOrReturnError(mLayerState.SetInitializing(), CHIP_ERROR_INCORRECT_STATE);

#if CHIP_SYSTEM_CONFIG_USE_LWIP
RegisterLwIPErrorFormatter();
#endif // CHIP_SYSTEM_CONFIG_USE_LWIP

VerifyOrReturnError(mLayerState.SetInitialized(), CHIP_ERROR_INCORRECT_STATE);
return CHIP_NO_ERROR;
Expand Down
5 changes: 4 additions & 1 deletion src/system/SystemMutex.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ class DLL_EXPORT Mutex
~Mutex();

static CHIP_ERROR Init(Mutex & aMutex);
#if CHIP_SYSTEM_CONFIG_FREERTOS_LOCKING
inline bool isInitialized() { return mInitialized; }
#endif // CHIP_SYSTEM_CONFIG_FREERTOS_LOCKING

void Lock(); /**< Acquire the mutual exclusion lock, blocking the current thread indefinitely if necessary. */
void Unlock(); /**< Release the mutual exclusion lock (can block on some systems until scheduler completes). */
Expand All @@ -91,7 +94,7 @@ class DLL_EXPORT Mutex
StaticSemaphore_t mFreeRTOSSemaphoreObj;
#endif // (configSUPPORT_STATIC_ALLOCATION == 1)
volatile SemaphoreHandle_t mFreeRTOSSemaphore = nullptr;
volatile int mInitialized = 0;
volatile bool mInitialized = 0;
#endif // CHIP_SYSTEM_CONFIG_FREERTOS_LOCKING

#if CHIP_SYSTEM_CONFIG_MBED_LOCKING
Expand Down
7 changes: 6 additions & 1 deletion src/system/SystemPacketBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,12 @@ PacketBufferHandle PacketBufferHandle::New(size_t aAvailableSize, uint16_t aRese
#elif CHIP_SYSTEM_PACKETBUFFER_FROM_CHIP_POOL

static_cast<void>(lBlockSize);

#if !CHIP_SYSTEM_CONFIG_NO_LOCKING && CHIP_SYSTEM_CONFIG_FREERTOS_LOCKING
if (!sBufferPoolMutex.isInitialized())
{
Mutex::Init(sBufferPoolMutex);
}
#endif
LOCK_BUF_POOL();

lPacket = PacketBuffer::sFreeList;
Expand Down
19 changes: 2 additions & 17 deletions src/system/SystemPacketBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,8 @@ class DLL_EXPORT PacketBufferHandle
#endif
}

PacketBuffer * Get() const { return mBuffer; }

protected:
#if CHIP_SYSTEM_CONFIG_USE_LWIP
// For use via LwIPPacketBufferView only.
Expand All @@ -677,8 +679,6 @@ class DLL_EXPORT PacketBufferHandle
return PacketBufferHandle(buffer);
}

PacketBuffer * Get() const { return mBuffer; }

bool operator==(const PacketBufferHandle & aOther) { return mBuffer == aOther.mBuffer; }

#if CHIP_SYSTEM_PACKETBUFFER_HAS_RIGHTSIZE
Expand Down Expand Up @@ -809,15 +809,6 @@ namespace Inet {
class UDPEndPointImplLwIP;
} // namespace Inet

#if CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT
// TODO : Temp Implementation issue : 13085
// Still use LwIP buffer even if using OpenThread UDP implementation
// since decoupling of LwIP from OpenThread is still in progress
namespace Inet {
class UDPEndPointImplOT;
} // namespace Inet
#endif

namespace System {

/**
Expand All @@ -835,12 +826,6 @@ class LwIPPacketBufferView : public PacketBufferHandle
*/
static struct pbuf * UnsafeGetLwIPpbuf(const PacketBufferHandle & handle) { return PacketBufferHandle::GetLwIPpbuf(handle); }
friend class Inet::UDPEndPointImplLwIP;
#if CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT
// TODO : Temp Implementation issue : 13085
// Still use LwIP buffer even if using OpenThread UDP implementation
// since decoupling of LwIP from OpenThread is still in progress
friend class Inet::UDPEndPointImplOT;
#endif
};

} // namespace System
Expand Down
3 changes: 2 additions & 1 deletion src/system/system.gni
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ declare_args() {

declare_args() {
# Event loop type.
if (chip_system_config_use_lwip) {
if (chip_system_config_use_lwip ||
chip_system_config_use_open_thread_inet_endpoints) {
chip_system_config_event_loop = "LwIP"
} else {
chip_system_config_event_loop = "Select"
Expand Down
1 change: 1 addition & 0 deletions src/test_driver/efr32/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ chip_monolithic_tests = true
#Fix me : Test driver should use same config as examples
# Problem : Linker issue if set to true
chip_system_config_use_open_thread_inet_endpoints = false
chip_with_lwip = true

0 comments on commit ff32d56

Please sign in to comment.