From: Daniel Dinca Date: Wed, 17 Nov 2021 17:37:01 +0000 (+0200) Subject: Add mailbox configuration options X-Git-Tag: RELEASE-0.6^0 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=1443cd90ffd22b1d667a34f91402082d46df9623;p=unikraft%2Flibs%2Flwip.git Add mailbox configuration options This fixes a bug where some packets are dropped because LWIP mailbox is bigger than the UDP and TCP mailboxes. This introduces the "LWIP stackthread mbox size" where you can now select the size for the input mailbox for the lwip thread. The sizes for the UDP and TCP mailboxes are now always bigger or equal to the LWIP input mailbox. You can select the factor by which they are greater in the "Sockets API" submenu. (i.e if you choose a factor of 2 for the UDP mailbox it will have the size 2*LWIP mailbox size). Signed-off-by: Daniel Dinca Reviewed-by: Simon Kuenzer Approved-by: Simon Kuenzer Tested-by: Unikraft CI GitHub-Pull-Request: #13 --- diff --git a/Config.uk b/Config.uk index 3b6aba9..be7e74c 100644 --- a/Config.uk +++ b/Config.uk @@ -123,6 +123,39 @@ config LWIP_THREADS Creates a core thread for the stack. endchoice +choice + prompt "Stack input mailbox size" + depends on LWIP_THREADS + default LWIP_STACKTHREAD_MBOX_SIZE_256 + config LWIP_STACKTHREAD_MBOX_SIZE_32 + bool "32" + config LWIP_STACKTHREAD_MBOX_SIZE_64 + bool "64" + config LWIP_STACKTHREAD_MBOX_SIZE_128 + bool "128" + config LWIP_STACKTHREAD_MBOX_SIZE_256 + bool "256" + config LWIP_STACKTHREAD_MBOX_SIZE_512 + bool "512" + config LWIP_STACKTHREAD_MBOX_SIZE_1024 + bool "1024" + config LWIP_STACKTHREAD_MBOX_SIZE_2048 + bool "2048" + help + This sets the size for the input mailbox that is used for receiving traffic from the network + interfaces. +endchoice + +config LWIP_STACKTHREAD_MBOX_SIZE + int + default 32 if LWIP_STACKTHREAD_MBOX_SIZE_32 + default 64 if LWIP_STACKTHREAD_MBOX_SIZE_64 + default 128 if LWIP_STACKTHREAD_MBOX_SIZE_128 + default 256 if LWIP_STACKTHREAD_MBOX_SIZE_256 + default 512 if LWIP_STACKTHREAD_MBOX_SIZE_512 + default 1024 if LWIP_STACKTHREAD_MBOX_SIZE_1024 + default 2048 if LWIP_STACKTHREAD_MBOX_SIZE_2048 + choice prompt "Memory allocation mode" default LWIP_HEAP @@ -247,10 +280,10 @@ config LWIP_DNS_TABLE_SIZE default 32 endif -config LWIP_SOCKET +menuconfig LWIP_SOCKET + depends on LWIP_THREADS && (LWIP_UDP || LWIP_TCP) bool "Socket API" select LIBVFSCORE - depends on LWIP_THREADS && (LWIP_UDP || LWIP_TCP) default y if LWIP_SOCKET @@ -269,6 +302,24 @@ if LWIP_SOCKET default y help Enable ppoll() implementation. + + config LWIP_UDP_RECVMBOX_FACTOR + int "Factor for UDP recvmbox" + depends on LWIP_UDP + range 1 5 + default 2 + help + How many times should the UDP recvmbox be bigger than the LWIP stackthread mbox size. + Default 2, maximum 5. + + config LWIP_TCP_RECVMBOX_FACTOR + int "Factor for TCP recvmbox" + depends on LWIP_TCP + range 1 5 + default 2 + help + How many times should the TCP recvmbox be bigger than the LWIP stackthread mbox size. + Default 2, maximum 5. endif menuconfig LWIP_DEBUG diff --git a/include/lwipopts.h b/include/lwipopts.h index 87b7329..4433bed 100644 --- a/include/lwipopts.h +++ b/include/lwipopts.h @@ -69,7 +69,10 @@ void sys_free(void *ptr); /* lightweight protection */ #define SYS_LIGHTWEIGHT_PROT 1 #define TCPIP_THREAD_NAME "lwip" -#define TCPIP_MBOX_SIZE 256 +#define TCPIP_MBOX_SIZE CONFIG_LWIP_STACKTHREAD_MBOX_SIZE +#define DEFAULT_UDP_RECVMBOX_SIZE ((CONFIG_LWIP_UDP_RECVMBOX_FACTOR) * (TCPIP_MBOX_SIZE)) +#define DEFAULT_TCP_RECVMBOX_SIZE ((CONFIG_LWIP_TCP_RECVMBOX_FACTOR) * (TCPIP_MBOX_SIZE)) +#define DEFAULT_ACCEPTMBOX_SIZE (TCPIP_MBOX_SIZE) #endif /* CONFIG_LWIP_NOTHREADS */ /** diff --git a/mailbox.c b/mailbox.c index b7dc263..1467fbc 100644 --- a/mailbox.c +++ b/mailbox.c @@ -32,14 +32,18 @@ #include #include #include +#include #include /* Creates an empty mailbox. */ err_t sys_mbox_new(sys_mbox_t *mbox, int size) { - if (size <= 0) - size = 32; + if (size <= 0) { + LWIP_DEBUGF(SOCKETS_DEBUG, + ("Mailbox created with default size.\n")); + size = TCPIP_MBOX_SIZE; + } UK_ASSERT(mbox); mbox->a = uk_alloc_get_default();