anchao commented on code in PR #7525:
URL: https://github.com/apache/nuttx/pull/7525#discussion_r1045246200


##########
net/tcp/Kconfig:
##########
@@ -51,11 +51,45 @@ config NET_TCPURGDATA
                compiled in. Urgent data (out-of-band data) is a rarely used 
TCP feature
                that is very seldom would be required.
 
-config NET_TCP_CONNS
-       int "Number of TCP/IP connections"
+config NET_TCP_PREALLOC_CONNS
+       int "Preallocated TCP/IP connections"
        default 8
        ---help---
-               Maximum number of TCP/IP connections (all tasks)
+               Number of TCP/IP connections (all tasks).
+               
+               This number of connections will be pre-allocated during system 
boot.
+               If dynamic connections allocation is enabled, more connections 
may
+               be allocated at a later time, as the system needs them. Else 
this
+               will be the maximum number of connections available to the 
system
+               at all times.
+
+               Set to 0 to disable (and rely only on dynamic allocations).
+
+config NET_TCP_ALLOC_CONNS
+       int "Dynamic TCP/IP connections allocation"
+       default 0

Review Comment:
   No need to add new config, use NET_ALLOC_CONNS instead



##########
net/tcp/tcp.h:
##########
@@ -104,6 +104,7 @@
 /* The TCP options flags */
 
 #define TCP_WSCALE            0x01U /* Window Scale option enabled */
+#define TCP_PREALLOC          0x02U /* TCP connection is preallocated */

Review Comment:
   Do not use the flag of tcp option field, if the alloc policy will be applied 
to other protocols,  use [(struct 
socket_conn_s)](https://github.com/apache/nuttx/blob/master/include/nuttx/net/net.h#L192-L226)



##########
net/tcp/Kconfig:
##########
@@ -51,11 +51,45 @@ config NET_TCPURGDATA
                compiled in. Urgent data (out-of-band data) is a rarely used 
TCP feature
                that is very seldom would be required.
 
-config NET_TCP_CONNS
-       int "Number of TCP/IP connections"
+config NET_TCP_PREALLOC_CONNS
+       int "Preallocated TCP/IP connections"
        default 8
        ---help---
-               Maximum number of TCP/IP connections (all tasks)
+               Number of TCP/IP connections (all tasks).
+               
+               This number of connections will be pre-allocated during system 
boot.
+               If dynamic connections allocation is enabled, more connections 
may
+               be allocated at a later time, as the system needs them. Else 
this
+               will be the maximum number of connections available to the 
system
+               at all times.
+
+               Set to 0 to disable (and rely only on dynamic allocations).
+
+config NET_TCP_ALLOC_CONNS
+       int "Dynamic TCP/IP connections allocation"
+       default 0
+       ---help---
+               Dynamic memory allocations for TCP/IP.
+
+               When set to 0 all dynamic allocations are disabled.
+
+               When set to 1 a new connection will be allocated every time,
+               and it will be free'd when no longer needed.
+
+               Setting this to 2 or more will allocate the connections in
+               batches (with batch size equal to this config). When a
+               connection is no longer needed, it will be returned to the
+               free connections pool, and it will never be deallocated!
+
+config NET_TCP_MAX_CONNS

Review Comment:
   If other protocols also require similar policies, wouldn't it be better to 
move the restrictions into the common Kconfig?
   NET_TCP_MAX_CONNS -> NET_ALLOC_MAXCONNS ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to