Skip to content

Commit

Permalink
UDPEndPointImplLwIP: Support LWIP_TCPIP_CORE_LOCKING=0
Browse files Browse the repository at this point in the history
Wrap calls to LwIP APIs in `tcpip_api_call()`, as required.
When `LWIP_TCPIP_CORE_LOCKING` is enabled, this internally becomes `LOCK_TCPIP_CORE/UNLOCK_TCPIP_CORE`
and when it isn't, it posts a message to the TCPIP task to run the function.

Added CHIP stack locking to the UDP receive function.
  • Loading branch information
rojer committed Sep 11, 2023
1 parent 8d0761d commit 9c120b8
Show file tree
Hide file tree
Showing 3 changed files with 158 additions and 115 deletions.
7 changes: 6 additions & 1 deletion src/inet/EndPointStateLwIP.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@

#pragma once

#include <inet/EndPointBasis.h>
#include <functional>

#include <inet/EndPointBasis.h>
#include <inet/IPAddress.h>

struct udp_pcb;
Expand All @@ -46,6 +47,10 @@ class DLL_EXPORT EndPointStateLwIP
UDP = 1,
TCP = 2
} mLwIPEndPointType;

// Synchronously runs a function within the TCPIP task's context.
static void RunOnTCPIP(std::function<void()>);
static err_t RunOnTCPIPRet(std::function<err_t()>);
};

} // namespace Inet
Expand Down
7 changes: 7 additions & 0 deletions src/inet/TCPEndPointImplLwIP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@
#include <lwip/tcp.h>
#include <lwip/tcpip.h>

static_assert(LWIP_VERSION_MAJOR > 1, "CHIP requires LwIP 2.0 or later");

#if !(CHIP_DEVICE_LAYER_TARGET_BL602 || CHIP_DEVICE_LAYER_TARGET_BL702 || CHIP_DEVICE_LAYER_TARGET_BL702L)
// TODO: Update to use RunOnTCPIP.
static_assert(LWIP_TCPIP_CORE_LOCKING, "CHIP requires config LWIP_TCPIP_CORE_LOCKING enabled");
#endif

namespace chip {
namespace Inet {

Expand Down
Loading

0 comments on commit 9c120b8

Please sign in to comment.