From 428a2790b3a3f8227b13ba397d251cbbaed09678 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=8B=E8=B6=85?= Date: Thu, 31 Mar 2022 16:28:01 +0800 Subject: [PATCH] add parameter in lwip for modify performance --- components/net/Kconfig | 28 +++++++++++++++++ components/net/lwip-2.0.2/src/lwipopts.h | 38 +++++++++++++++++------ components/net/lwip-2.1.2/src/lwipopts.h | 39 ++++++++++++++++++------ 3 files changed, 86 insertions(+), 19 deletions(-) diff --git a/components/net/Kconfig b/components/net/Kconfig index 3a4f39ed49..01786e4f8d 100644 --- a/components/net/Kconfig +++ b/components/net/Kconfig @@ -212,10 +212,26 @@ config RT_USING_LWIP int "the number of struct netconns" default 8 + config RT_MEMP_NUM_TCPIP_MSG_API + int "the number of struct tcpip_msg ,which are used for callback/timeout API communication" + default 16 + + config RT_MEMP_NUM_TCPIP_MSG_INPKT + int "the number of struct tcpip_msg ,which are used for incoming packets" + default 16 + config RT_LWIP_PBUF_NUM int "the number of PBUF" default 16 + config RT_LWIP_PBUF_STRUCT_NUM + int "the number of pbuf struct" + default 16 + + config RT_LWIP_NETBUF_NUM + int "the number of netbuf struct" + default 16 + config RT_LWIP_RAW_PCB_NUM int "the number of raw connection" default 4 @@ -225,6 +241,14 @@ config RT_USING_LWIP default 8 if RT_USING_DFS_NFS default 4 + config RT_UDP_RECVMBOX_SIZE + int "the number of udp recv mbox num" + default 16 + + config RT_RECV_BUFSIZE_DEFAULT + int "this is the default value for recv_bufsize, the unit is KB" + default 64 + if RT_LWIP_TCP config RT_LWIP_TCP_PCB_NUM int "the number of TCP socket" @@ -241,6 +265,10 @@ config RT_USING_LWIP config RT_LWIP_TCP_WND int "the size of TCP send window" default 8196 + + config RT_TCP_RECVMBOX_SIZE + int "the number of tcp recv mbox num" + default 16 endif config RT_LWIP_TCPTHREAD_PRIORITY diff --git a/components/net/lwip-2.0.2/src/lwipopts.h b/components/net/lwip-2.0.2/src/lwipopts.h index 09bd223aa4..bc774fcd3f 100644 --- a/components/net/lwip-2.0.2/src/lwipopts.h +++ b/components/net/lwip-2.0.2/src/lwipopts.h @@ -5,6 +5,9 @@ #define ERRNO 1 +#define LWIP_SOCKET_SELECT 1 +#define LWIP_SOCKET_POLL 1 + #define LWIP_IPV4 1 #ifdef RT_USING_LWIP_IPV6 @@ -235,7 +238,6 @@ #else #define MEM_ALIGNMENT 4 #endif - #define MEMP_OVERFLOW_CHECK 1 //// #define LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT 1 //// //#define MEM_LIBC_MALLOC 1 @@ -248,8 +250,9 @@ /* MEMP_NUM_PBUF: the number of memp struct pbufs. If the application sends a lot of data out of ROM (or other static memory), this should be set high. */ -#define MEMP_NUM_PBUF 32 //16 - +#ifdef RT_LWIP_PBUF_STRUCT_NUM +#define MEMP_NUM_PBUF RT_LWIP_PBUF_STRUCT_NUM //16 +#endif /* the number of struct netconns */ #ifdef RT_MEMP_NUM_NETCONN #define MEMP_NUM_NETCONN RT_MEMP_NUM_NETCONN @@ -282,15 +285,24 @@ * setting in the lwip opts.h */ /* MEMP_NUM_NETBUF: the number of struct netbufs. */ -// #define MEMP_NUM_NETBUF 2 + +#ifdef RT_LWIP_NETBUF_NUM +#define MEMP_NUM_NETBUF RT_LWIP_NETBUF_NUM +#endif + /* MEMP_NUM_NETCONN: the number of struct netconns. */ // #define MEMP_NUM_NETCONN 4 /* MEMP_NUM_TCPIP_MSG_*: the number of struct tcpip_msg, which is used for sequential API communication and incoming packets. Used in src/api/tcpip.c. */ -// #define MEMP_NUM_TCPIP_MSG_API 16 -// #define MEMP_NUM_TCPIP_MSG_INPKT 16 +#ifdef RT_MEMP_NUM_TCPIP_MSG_API +#define MEMP_NUM_TCPIP_MSG_API RT_MEMP_NUM_TCPIP_MSG_API +#endif + +#ifdef RT_MEMP_NUM_TCPIP_MSG_INPKT +#define MEMP_NUM_TCPIP_MSG_INPKT RT_MEMP_NUM_TCPIP_MSG_INPKT +#endif /* ---------- Pbuf options ---------- */ /* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */ @@ -381,7 +393,10 @@ #define TCPIP_THREAD_STACKSIZE 4096 #endif #define TCPIP_THREAD_NAME "tcpip" -#define DEFAULT_TCP_RECVMBOX_SIZE 10 + +#ifdef RT_TCP_RECVMBOX_SIZE +#define DEFAULT_TCP_RECVMBOX_SIZE RT_TCP_RECVMBOX_SIZE +#endif /* ---------- ARP options ---------- */ #define LWIP_ARP 1 @@ -447,7 +462,10 @@ #define LWIP_UDPLITE 0 #define UDP_TTL 255 -#define DEFAULT_UDP_RECVMBOX_SIZE 1 + +#ifdef RT_UDP_RECVMBOX_SIZE +#define DEFAULT_UDP_RECVMBOX_SIZE RT_UDP_RECVMBOX_SIZE +#endif /* ---------- RAW options ---------- */ #ifdef RT_LWIP_RAW @@ -604,8 +622,8 @@ /** * If LWIP_SO_RCVBUF is used, this is the default value for recv_bufsize. */ -#ifndef RECV_BUFSIZE_DEFAULT -#define RECV_BUFSIZE_DEFAULT 8192 +#ifdef RT_RECV_BUFSIZE_DEFAULT +#define RECV_BUFSIZE_DEFAULT RT_RECV_BUFSIZE_DEFAULT*1024 #endif /** diff --git a/components/net/lwip-2.1.2/src/lwipopts.h b/components/net/lwip-2.1.2/src/lwipopts.h index 220bb6fa41..a0d9cad463 100644 --- a/components/net/lwip-2.1.2/src/lwipopts.h +++ b/components/net/lwip-2.1.2/src/lwipopts.h @@ -243,7 +243,12 @@ #endif /* ---------- Memory options ---------- */ +#ifdef RT_LWIP_MEM_ALIGNMENT +#define MEM_ALIGNMENT RT_LWIP_MEM_ALIGNMENT +#else #define MEM_ALIGNMENT 4 +#endif + #define MEMP_OVERFLOW_CHECK 1 //// #define LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT 1 //// //#define MEM_LIBC_MALLOC 1 @@ -256,8 +261,9 @@ /* MEMP_NUM_PBUF: the number of memp struct pbufs. If the application sends a lot of data out of ROM (or other static memory), this should be set high. */ -#define MEMP_NUM_PBUF 32 //16 - +#ifdef RT_LWIP_PBUF_STRUCT_NUM +#define MEMP_NUM_PBUF RT_LWIP_PBUF_STRUCT_NUM //16 +#endif /* the number of struct netconns */ #ifdef RT_MEMP_NUM_NETCONN #define MEMP_NUM_NETCONN RT_MEMP_NUM_NETCONN @@ -290,15 +296,24 @@ * setting in the lwip opts.h */ /* MEMP_NUM_NETBUF: the number of struct netbufs. */ -// #define MEMP_NUM_NETBUF 2 + +#ifdef RT_LWIP_NETBUF_NUM +#define MEMP_NUM_NETBUF RT_LWIP_NETBUF_NUM +#endif + /* MEMP_NUM_NETCONN: the number of struct netconns. */ // #define MEMP_NUM_NETCONN 4 /* MEMP_NUM_TCPIP_MSG_*: the number of struct tcpip_msg, which is used for sequential API communication and incoming packets. Used in src/api/tcpip.c. */ -// #define MEMP_NUM_TCPIP_MSG_API 16 -// #define MEMP_NUM_TCPIP_MSG_INPKT 16 +#ifdef RT_MEMP_NUM_TCPIP_MSG_API +#define MEMP_NUM_TCPIP_MSG_API RT_MEMP_NUM_TCPIP_MSG_API +#endif + +#ifdef RT_MEMP_NUM_TCPIP_MSG_INPKT +#define MEMP_NUM_TCPIP_MSG_INPKT RT_MEMP_NUM_TCPIP_MSG_INPKT +#endif /* ---------- Pbuf options ---------- */ /* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */ @@ -389,7 +404,10 @@ #define TCPIP_THREAD_STACKSIZE 4096 #endif #define TCPIP_THREAD_NAME "tcpip" -#define DEFAULT_TCP_RECVMBOX_SIZE 10 + +#ifdef RT_TCP_RECVMBOX_SIZE +#define DEFAULT_TCP_RECVMBOX_SIZE RT_TCP_RECVMBOX_SIZE +#endif /* ---------- ARP options ---------- */ #define LWIP_ARP 1 @@ -455,7 +473,10 @@ #define LWIP_UDPLITE 0 #define UDP_TTL 255 -#define DEFAULT_UDP_RECVMBOX_SIZE 1 + +#ifdef RT_UDP_RECVMBOX_SIZE +#define DEFAULT_UDP_RECVMBOX_SIZE RT_UDP_RECVMBOX_SIZE +#endif /* ---------- RAW options ---------- */ #ifdef RT_LWIP_RAW @@ -612,8 +633,8 @@ /** * If LWIP_SO_RCVBUF is used, this is the default value for recv_bufsize. */ -#ifndef RECV_BUFSIZE_DEFAULT -#define RECV_BUFSIZE_DEFAULT 8192 +#ifdef RT_RECV_BUFSIZE_DEFAULT +#define RECV_BUFSIZE_DEFAULT RT_RECV_BUFSIZE_DEFAULT*1024 #endif /** -- Gitee