Skip to content

Commit

Permalink
Merge branch 'bufix/Backport_some_lwip_bugs_for_5.1_1115' into 'relea…
Browse files Browse the repository at this point in the history
…se/v5.1'

Bufix/backport some lwip bugs for 5.1 1115

See merge request espressif/esp-idf!27149
  • Loading branch information
jack0c committed Nov 20, 2023
2 parents a08c557 + 989e037 commit 2348a0a
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 4 deletions.
40 changes: 37 additions & 3 deletions components/lwip/Kconfig
Expand Up @@ -556,7 +556,7 @@ menu "LWIP"

Can be set lower to save RAM, the default value 1460(ipv4)/1440(ipv6) will give best throughput.
IPv4 TCP_MSS Range: 576 <= TCP_MSS <= 1460
IPv6 TCP_MSS Range: 1220<= TCP_mSS <= 1440
IPv6 TCP_MSS Range: 1220<= TCP_MSS <= 1440

config LWIP_TCP_TMR_INTERVAL
int "TCP timer interval(ms)"
Expand All @@ -581,7 +581,7 @@ menu "LWIP"

config LWIP_TCP_SND_BUF_DEFAULT
int "Default send buffer size"
default 5744 # 4 * default MSS
default 5760 # 4 * default MSS
range 2440 65535 if !LWIP_WND_SCALE
range 2440 1024000 if LWIP_WND_SCALE
help
Expand All @@ -598,7 +598,7 @@ menu "LWIP"

config LWIP_TCP_WND_DEFAULT
int "Default receive window size"
default 5744 # 4 * default MSS
default 5760 # 4 * default MSS
range 2440 65535 if !LWIP_WND_SCALE
range 2440 1024000 if LWIP_WND_SCALE
help
Expand Down Expand Up @@ -640,6 +640,40 @@ menu "LWIP"
Disable this option to save some RAM during TCP sessions, at the expense
of increased retransmissions if segments arrive out of order.

config LWIP_TCP_OOSEQ_TIMEOUT
int "Timeout for each pbuf queued in TCP OOSEQ, in RTOs."
depends on LWIP_TCP_QUEUE_OOSEQ
range 1 30
default 6
help
The timeout value is TCP_OOSEQ_TIMEOUT * RTO.

config LWIP_TCP_OOSEQ_MAX_PBUFS
int "The maximum number of pbufs queued on OOSEQ per pcb"
depends on LWIP_TCP_QUEUE_OOSEQ
range 0 12
default 4
help
If LWIP_TCP_OOSEQ_MAX_PBUFS = 0, TCP will not control the number of OOSEQ pbufs.

In a poor network environment, many out-of-order tcp pbufs will be received.
These out-of-order pbufs will be cached in the TCP out-of-order queue which will
cause Wi-Fi/Ethernet fail to release RX buffer in time.
It is possible that all RX buffers for MAC layer are used by OOSEQ.

Control the number of out-of-order pbufs to ensure that the MAC layer
has enough RX buffer to receive packets.

In the Wi-Fi scenario,recommended OOSEQ PBUFS Range:
0 <= TCP_OOSEQ_MAX_PBUFS <= CONFIG_ESP_WIFI_DYNAMIC_RX_BUFFER_NUM/(MAX_TCP_NUMBER + 1)

In the Ethernet scenario,recommended Ethernet OOSEQ PBUFS Range:
0 <= TCP_OOSEQ_MAX_PBUFS <= CONFIG_ETH_DMA_RX_BUFFER_NUM/(MAX_TCP_NUMBER + 1)

Within the recommended value range, the larger the value, the better the performance.

MAX_TCP_NUMBER represent Maximum number of TCP connections in Wi-Fi(STA+SoftAP) and Ethernet scenario.

config LWIP_TCP_SACK_OUT
bool "Support sending selective acknowledgements"
default n
Expand Down
2 changes: 1 addition & 1 deletion components/lwip/lwip
15 changes: 15 additions & 0 deletions components/lwip/port/include/lwipopts.h
Expand Up @@ -532,6 +532,21 @@ static inline uint32_t timeout_from_offered(uint32_t lease, uint32_t min)
#define TCP_QUEUE_OOSEQ 0
#endif

/**
* TCP_OOSEQ_MAX_PBUFS: The maximum number of pbufs
* queued on ooseq per pcb
*/
#if TCP_QUEUE_OOSEQ
#define TCP_OOSEQ_MAX_PBUFS CONFIG_LWIP_TCP_OOSEQ_MAX_PBUFS
#endif

/**
* TCP_OOSEQ_TIMEOUT: Timeout for each pbuf queued in TCP OOSEQ, in RTOs.
*/
#if TCP_QUEUE_OOSEQ
#define TCP_OOSEQ_TIMEOUT CONFIG_LWIP_TCP_OOSEQ_TIMEOUT
#endif

/**
* LWIP_TCP_SACK_OUT==1: TCP will support sending selective acknowledgements (SACKs).
*/
Expand Down

0 comments on commit 2348a0a

Please sign in to comment.