diff --git a/src/messaging/ReliableMessageProtocolConfig.h b/src/messaging/ReliableMessageProtocolConfig.h index 3dce56b9e98f56..2734e4ff22174b 100644 --- a/src/messaging/ReliableMessageProtocolConfig.h +++ b/src/messaging/ReliableMessageProtocolConfig.h @@ -129,14 +129,14 @@ namespace chip { #ifndef CHIP_CONFIG_RMP_RETRANS_TABLE_SIZE #if CHIP_SYSTEM_CONFIG_USE_LWIP -#if !LWIP_PBUF_FROM_CUSTOM_POOLS && PBUF_POOL_SIZE != 0 +#if !CHIP_SYSTEM_CONFIG_LWIP_PBUF_FROM_CUSTOM_POOL && PBUF_POOL_SIZE != 0 // Configure the table size to be less than the number of packet buffers to make sure // that not all buffers are held by the retransmission entries, in which case the device // is unable to receive an ACK and hence becomes unavailable until a message times out. #define CHIP_CONFIG_RMP_RETRANS_TABLE_SIZE std::min(PBUF_POOL_SIZE - 1, CHIP_CONFIG_MAX_EXCHANGE_CONTEXTS) #else #define CHIP_CONFIG_RMP_RETRANS_TABLE_SIZE CHIP_CONFIG_MAX_EXCHANGE_CONTEXTS -#endif // !LWIP_PBUF_FROM_CUSTOM_POOLS && PBUF_POOL_SIZE != 0 +#endif // !CHIP_SYSTEM_CONFIG_LWIP_PBUF_FROM_CUSTOM_POOL && PBUF_POOL_SIZE != 0 #else // CHIP_SYSTEM_CONFIG_USE_LWIP diff --git a/src/system/SystemConfig.h b/src/system/SystemConfig.h index 15e6abdb5d4e83..aa8acd57e5d30d 100644 --- a/src/system/SystemConfig.h +++ b/src/system/SystemConfig.h @@ -771,3 +771,20 @@ struct LwIPEvent; #define CHIP_SYSTEM_CONFIG_USE_ZEPHYR_EVENTFD 0 #endif #endif // CHIP_SYSTEM_CONFIG_USE_ZEPHYR_EVENTFD + +/** + * @def CHIP_SYSTEM_CONFIG_LWIP_PBUF_FROM_CUSTOM_POOL + * + * @brief + * Enable the use of lwIP pbufs from a custom pool + * + * This config option exist because not all platforms defines LWIP_PBUF_FROM_CUSTOM_POOLS in lwip/opt.h + * Defaults to LWIP_PBUF_FROM_CUSTOM_POOLS if defined, otherwise 0 + */ +#ifndef CHIP_SYSTEM_CONFIG_LWIP_PBUF_FROM_CUSTOM_POOL +#if defined(LWIP_PBUF_FROM_CUSTOM_POOLS) +#define CHIP_SYSTEM_CONFIG_LWIP_PBUF_FROM_CUSTOM_POOL LWIP_PBUF_FROM_CUSTOM_POOLS +#else +#define CHIP_SYSTEM_CONFIG_LWIP_PBUF_FROM_CUSTOM_POOL 0 +#endif // LWIP_PBUF_FROM_CUSTOM_POOLS +#endif // CHIP_SYSTEM_CONFIG_LWIP_PBUF_FROM_CUSTOM_POOL diff --git a/src/system/SystemPacketBufferInternal.h b/src/system/SystemPacketBufferInternal.h index e6acb76f6b6e80..96494335cddc85 100644 --- a/src/system/SystemPacketBufferInternal.h +++ b/src/system/SystemPacketBufferInternal.h @@ -82,7 +82,7 @@ * * True if packet buffers are allocated from an LwIP custom pool. */ -#if CHIP_SYSTEM_PACKETBUFFER_FROM_LWIP_POOL && !LWIP_PBUF_FROM_CUSTOM_POOLS +#if CHIP_SYSTEM_PACKETBUFFER_FROM_LWIP_POOL && !CHIP_SYSTEM_CONFIG_LWIP_PBUF_FROM_CUSTOM_POOL #define CHIP_SYSTEM_PACKETBUFFER_FROM_LWIP_STANDARD_POOL 1 #else #define CHIP_SYSTEM_PACKETBUFFER_FROM_LWIP_STANDARD_POOL 0 @@ -93,7 +93,7 @@ * * True if packet buffers are allocated from an LwIP custom pool. */ -#if CHIP_SYSTEM_PACKETBUFFER_FROM_LWIP_POOL && LWIP_PBUF_FROM_CUSTOM_POOLS +#if CHIP_SYSTEM_PACKETBUFFER_FROM_LWIP_POOL && CHIP_SYSTEM_CONFIG_LWIP_PBUF_FROM_CUSTOM_POOL #define CHIP_SYSTEM_PACKETBUFFER_FROM_LWIP_CUSTOM_POOL 1 #else #define CHIP_SYSTEM_PACKETBUFFER_FROM_LWIP_CUSTOM_POOL 0 diff --git a/src/system/SystemStats.cpp b/src/system/SystemStats.cpp index 5ef16369ccc853..3a844b6179040b 100644 --- a/src/system/SystemStats.cpp +++ b/src/system/SystemStats.cpp @@ -38,7 +38,7 @@ namespace System { namespace Stats { static const Label sStatsStrings[chip::System::Stats::kNumEntries] = { -#if CHIP_SYSTEM_CONFIG_USE_LWIP && LWIP_PBUF_FROM_CUSTOM_POOLS +#if CHIP_SYSTEM_CONFIG_USE_LWIP && CHIP_SYSTEM_CONFIG_LWIP_PBUF_FROM_CUSTOM_POOL #define LWIP_PBUF_MEMPOOL(name, num, payload, desc) "SystemLayer_Num" desc, #include "lwippools.h" #undef LWIP_PBUF_MEMPOOL @@ -107,7 +107,7 @@ bool Difference(Snapshot & result, Snapshot & after, Snapshot & before) void UpdateLwipPbufCounts(void) { -#if LWIP_PBUF_FROM_CUSTOM_POOLS +#if CHIP_SYSTEM_CONFIG_LWIP_PBUF_FROM_CUSTOM_POOL size_t lwip_pool_idx = PBUF_CUSTOM_POOL_IDX_END; size_t system_idx = 0; @@ -119,12 +119,12 @@ void UpdateLwipPbufCounts(void) system_idx++; } -#else // LWIP_PBUF_FROM_CUSTOM_POOLS +#else // CHIP_SYSTEM_CONFIG_LWIP_PBUF_FROM_CUSTOM_POOL chip::System::Stats::GetResourcesInUse()[kSystemLayer_NumPacketBufs] = MEMP_STATS_GET(used, MEMP_PBUF_POOL); chip::System::Stats::GetHighWatermarks()[kSystemLayer_NumPacketBufs] = MEMP_STATS_GET(max, MEMP_PBUF_POOL); -#endif // LWIP_PBUF_FROM_CUSTOM_POOLS +#endif // CHIP_SYSTEM_CONFIG_LWIP_PBUF_FROM_CUSTOM_POOL } #endif // CHIP_SYSTEM_CONFIG_USE_LWIP && LWIP_STATS && MEMP_STATS diff --git a/src/system/SystemStats.h b/src/system/SystemStats.h index 24c1dad9ae36c5..1184d14a3f03a8 100644 --- a/src/system/SystemStats.h +++ b/src/system/SystemStats.h @@ -47,7 +47,7 @@ namespace Stats { enum { -#if CHIP_SYSTEM_CONFIG_USE_LWIP && LWIP_PBUF_FROM_CUSTOM_POOLS +#if CHIP_SYSTEM_CONFIG_USE_LWIP && CHIP_SYSTEM_CONFIG_LWIP_PBUF_FROM_CUSTOM_POOL #define LWIP_PBUF_MEMPOOL(name, num, payload, desc) kSystemLayer_Num##name, #include "lwippools.h" #undef LWIP_PBUF_MEMPOOL