From 67b22d8783cfc97c9329fecf13cd4ca6ac4a7fb9 Mon Sep 17 00:00:00 2001 From: Simon Brummer Date: Sat, 4 Jul 2020 09:19:54 +0200 Subject: [PATCH] gnrc_tcp: requested changes --- sys/include/net/gnrc/tcp/config.h | 18 ++++++++++++++++++ sys/net/gnrc/transport_layer/tcp/Kconfig | 14 ++++++++++++++ sys/net/gnrc/transport_layer/tcp/gnrc_tcp.c | 2 ++ .../transport_layer/tcp/gnrc_tcp_eventloop.c | 2 ++ .../gnrc/transport_layer/tcp/internal/common.h | 10 ++-------- 5 files changed, 38 insertions(+), 8 deletions(-) diff --git a/sys/include/net/gnrc/tcp/config.h b/sys/include/net/gnrc/tcp/config.h index 7afc667929..9c95fb55aa 100644 --- a/sys/include/net/gnrc/tcp/config.h +++ b/sys/include/net/gnrc/tcp/config.h @@ -167,6 +167,24 @@ extern "C" { #ifndef CONFIG_GNRC_TCP_PROBE_UPPER_BOUND #define CONFIG_GNRC_TCP_PROBE_UPPER_BOUND (60U * US_PER_SEC) #endif + +/** + * @brief Message queue size for TCP API internal messaging + * @note The number of elements in a message queue must be a power of two. + * This value defines the exponent of 2^n. + */ +#ifndef CONFIG_GNRC_TCP_MSG_QUEUE_SIZE_EXP +#define CONFIG_GNRC_TCP_MSG_QUEUE_SIZE_EXP (2U) +#endif + +/** + * @brief Message queue size for the TCP eventloop + * @note The number of elements in a message queue must be a power of two. + * This value defines the exponent of 2^n. + */ +#ifndef CONFIG_GNRC_TCP_EVENTLOOP_MSG_QUEUE_SIZE_EXP +#define CONFIG_GNRC_TCP_EVENTLOOP_MSG_QUEUE_SIZE_EXP (3U) +#endif /** @} */ #ifdef __cplusplus diff --git a/sys/net/gnrc/transport_layer/tcp/Kconfig b/sys/net/gnrc/transport_layer/tcp/Kconfig index 7d2c822934..d3c81d7541 100644 --- a/sys/net/gnrc/transport_layer/tcp/Kconfig +++ b/sys/net/gnrc/transport_layer/tcp/Kconfig @@ -112,4 +112,18 @@ config GNRC_TCP_PROBE_UPPER_BOUND int "Lower bound for the duration between probes in microseconds" default 60000000 +config GNRC_TCP_MSG_QUEUE_SIZE_SIZE_EXP + int "Message queue size for TCP API internal messaging (as exponent of 2^n)" + default 2 + help + The number of elements in a message queue must be always a power of two. + This value defines the exponent of 2^n. + +config GNRC_TCP_EVENTLOOP_MSG_QUEUE_SIZE_SIZE_EXP + int "Message queue size for the TCP eventloop (as exponent of 2^n)" + default 3 + help + The number of elements in a message queue must be always a power of two. + This value defines the exponent of 2^n. + endif # KCONFIG_MODULE_GNRC_TCP diff --git a/sys/net/gnrc/transport_layer/tcp/gnrc_tcp.c b/sys/net/gnrc/transport_layer/tcp/gnrc_tcp.c index cdf6214b90..0e79efc62a 100644 --- a/sys/net/gnrc/transport_layer/tcp/gnrc_tcp.c +++ b/sys/net/gnrc/transport_layer/tcp/gnrc_tcp.c @@ -39,6 +39,8 @@ #define ENABLE_DEBUG (0) #include "debug.h" +#define TCP_MSG_QUEUE_SIZE (1 << CONFIG_GNRC_TCP_MSG_QUEUE_SIZE_EXP) + /** * @brief Allocate memory for GNRC TCP thread stack. */ diff --git a/sys/net/gnrc/transport_layer/tcp/gnrc_tcp_eventloop.c b/sys/net/gnrc/transport_layer/tcp/gnrc_tcp_eventloop.c index 253ea588d4..00b467e375 100644 --- a/sys/net/gnrc/transport_layer/tcp/gnrc_tcp_eventloop.c +++ b/sys/net/gnrc/transport_layer/tcp/gnrc_tcp_eventloop.c @@ -34,6 +34,8 @@ #define ENABLE_DEBUG (0) #include "debug.h" +#define TCP_EVENTLOOP_MSG_QUEUE_SIZE (1 << CONFIG_GNRC_TCP_EVENTLOOP_MSG_QUEUE_SIZE_EXP) + static msg_t _eventloop_msg_queue[TCP_EVENTLOOP_MSG_QUEUE_SIZE]; /** diff --git a/sys/net/gnrc/transport_layer/tcp/internal/common.h b/sys/net/gnrc/transport_layer/tcp/internal/common.h index e6a788864e..c8d0291fa3 100644 --- a/sys/net/gnrc/transport_layer/tcp/internal/common.h +++ b/sys/net/gnrc/transport_layer/tcp/internal/common.h @@ -39,11 +39,6 @@ extern "C" { */ #define PORT_UNSPEC (0) -/** - * @brief Message queue size for messaging between thread contexts - */ -#define TCP_MSG_QUEUE_SIZE (8U) - /** * @brief TCB status flags * @{ @@ -57,9 +52,8 @@ extern "C" { * @brief Defines for "eventloop" thread settings. * @{ */ -#define TCP_EVENTLOOP_MSG_QUEUE_SIZE (8U) -#define TCP_EVENTLOOP_PRIO (THREAD_PRIORITY_MAIN - 2U) -#define TCP_EVENTLOOP_STACK_SIZE (THREAD_STACKSIZE_DEFAULT) +#define TCP_EVENTLOOP_PRIO (THREAD_PRIORITY_MAIN - 2U) +#define TCP_EVENTLOOP_STACK_SIZE (THREAD_STACKSIZE_DEFAULT) /** @} */ /**