diff --git a/net/tcp/Kconfig b/net/tcp/Kconfig index bea9f5159f..c0a42f3727 100644 --- a/net/tcp/Kconfig +++ b/net/tcp/Kconfig @@ -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 diff --git a/net/tcp/tcp_callback.c b/net/tcp/tcp_callback.c index 6d27baa457..9640224ccd 100644 --- a/net/tcp/tcp_callback.c +++ b/net/tcp/tcp_callback.c @@ -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