PBUF_POOL_SIZE/IP_REASS_MAX_PBUFS are only scaled up for large TFTP
block sizes when CONFIG_TFTP_BLOCKSIZE is strictly greater than
TFTP_BLOCKSIZE_THRESHOLD (4096). Since the threshold itself is 4096,
setting CONFIG_TFTP_BLOCKSIZE=4096 exactly falls through to the small
fixed pool (PBUF_POOL_SIZE=8, IP_REASS_MAX_PBUFS=4) instead of the
scaled one.

At blocksize 4096, the full UDP datagram (4096 data + 4-byte TFTP
header + 8-byte UDP header = 4108 bytes) exceeds the usable IP fragment
size (1480 bytes) and is split into 3 IP fragments that lwIP must
reassemble on receive. The scaled sizing accounts for this explicitly
(giving PBUF_POOL_SIZE=9, IP_REASS_MAX_PBUFS=5), so the threshold
should include the boundary value rather than exclude it.

Change the comparison to '>=' so that CONFIG_TFTP_BLOCKSIZE=4096 also
gets the scaled pool sizing.

Fixes: 67586012490a ("net: lwip: scale buffer pool size with TFTP block size")
Signed-off-by: Padmarao Begari <[email protected]>
---
 lib/lwip/u-boot/lwipopts.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/lwip/u-boot/lwipopts.h b/lib/lwip/u-boot/lwipopts.h
index 8dae004f1a2..733478a0cda 100644
--- a/lib/lwip/u-boot/lwipopts.h
+++ b/lib/lwip/u-boot/lwipopts.h
@@ -72,7 +72,7 @@
 #define PBUF_POOL_RESERVE               4
 #define TFTP_BLOCKSIZE_THRESHOLD        4096
 
-#if defined(CONFIG_TFTP_BLOCKSIZE) && (CONFIG_TFTP_BLOCKSIZE > 
TFTP_BLOCKSIZE_THRESHOLD)
+#if defined(CONFIG_TFTP_BLOCKSIZE) && (CONFIG_TFTP_BLOCKSIZE >= 
TFTP_BLOCKSIZE_THRESHOLD)
 #define PBUF_POOL_SIZE                 (((CONFIG_TFTP_BLOCKSIZE + 
(IP_FRAG_MTU_USABLE - 1)) / \
                                          IP_FRAG_MTU_USABLE) + 
PBUF_POOL_HEADROOM)
 #define IP_REASS_MAX_PBUFS             (PBUF_POOL_SIZE - PBUF_POOL_RESERVE)
-- 
2.34.1

Reply via email to