net/tcp: contig received data to reducing iob consumption

Fragmentation of network data will intensify iob consumption, if
the device receives a message storm of fragmented packets, the iob
cache will not be effectively used, this is not allowed on iot devices
since the resources of such devices are limited. Of course, this
also takes some disadvantages: data needs to be copied.
This option will brings some balance on resource-constrained devices,
enable this config to reduce the consumption of iob, the received iob
buffers will be merged into the contiguous iob chain.

Signed-off-by: chao an <anchao@xiaomi.com>
This commit is contained in:
chao an 2022-12-18 17:12:28 +08:00 committed by Xiang Xiao
parent 56a4e90dc4
commit 794adc5814
2 changed files with 22 additions and 0 deletions

View File

@ -194,6 +194,20 @@ config NET_TCP_WRBUFFER_DUMP
endif # NET_TCP_WRITE_BUFFERS
config NET_TCP_RECV_CONTIG
bool "Enable TCP/IP receive data in a continuous poll"
default y
---help---
This option will enable TCP/IP receive data into a continuous iob chain.
Fragmentation of network data will intensify iob consumption, if
the device receives a message storm of fragmented packets, the iob
cache will not be effectively used, this is not allowed on iot devices
since the resources of such devices are limited. Of course, this
also takes some disadvantages: data needs to be copied.
This option will brings some balance on resource-constrained devices,
enable this config to reduce the consumption of iob, the received iob
buffers will be merged into the contiguous iob chain.
config NET_TCPBACKLOG
bool "TCP/IP backlog support"
default n

View File

@ -258,6 +258,14 @@ uint16_t tcp_datahandler(FAR struct net_driver_s *dev,
iob_concat(conn->readahead, iob);
}
#ifdef CONFIG_NET_TCP_RECV_CONTIG
/* Merge an iob chain into a continuous space, thereby reducing iob
* consumption.
*/
conn->readahead = iob_contig(conn->readahead);
#endif
netdev_iob_clear(dev);
#ifdef CONFIG_NET_TCP_NOTIFIER