From cd4e2ab5b7f7b1a913bc7d334460ca9bf39681c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damian=20Kr=C3=B3lik?= <66667989+Damian-Nordic@users.noreply.github.com> Date: Mon, 13 May 2024 15:12:03 +0200 Subject: [PATCH] [nrfconnect] Optimize packet buffer size (#33137) (#33414) Matter requires that regular Matter messages fit in IPv6 MTU of 1280 bytes so the default packet buffer size of 1583 bytes seems excessively large for some configurations. Especially that the buffers only hold the UDP payload in the case of non-LWIP transports. There are two exceptions to the above though: 1. Minimal mDNS uses the same packet buffer pool and mDNS message size is not limited to 1280 bytes, so shrinking the buffer size below MTU might have a negative impact on the mDNS behavior. 2. Matter allows definining so called large messages that can be bigger than 1280 bytes and sent over TCP, but that is not implemented yet and will likely require a different allocation mechanism. Signed-off-by: Damian Krolik (cherry picked from commit 8e27412a6de6a66388f2c0a66c17a4bd8e999810) --- src/platform/nrfconnect/SystemPlatformConfig.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/platform/nrfconnect/SystemPlatformConfig.h b/src/platform/nrfconnect/SystemPlatformConfig.h index 1165bb203456e8..fb544466dcdd75 100644 --- a/src/platform/nrfconnect/SystemPlatformConfig.h +++ b/src/platform/nrfconnect/SystemPlatformConfig.h @@ -51,4 +51,18 @@ struct ChipDeviceEvent; #define CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE 15 #endif +#ifndef CHIP_SYSTEM_CONFIG_PACKETBUFFER_CAPACITY_MAX +#ifdef CONFIG_WIFI_NRF700X +// Minimal mDNS uses Matter packet buffers, so as long as minimal mDNS is used +// in Nordic's Wi-Fi solution, the packet buffers must be a bit bigger than what +// is required by Matter. +#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_CAPACITY_MAX CONFIG_NRF_WIFI_IFACE_MTU +#else +// Matter specification requires that Matter messages fit in IPV6 MTU of 1280B +// unless for large messages that can be sent over BTP or TCP. But those will +// likely require a separate buffer pool or employ chained buffers. +#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_CAPACITY_MAX 1280 +#endif // CONFIG_WIFI_NRF700X +#endif // CHIP_SYSTEM_CONFIG_PACKETBUFFER_CAPACITY_MAX + // ========== Platform-specific Configuration Overrides =========