From b0168f5fdd57fe8f9c0345da9b2837b90e175425 Mon Sep 17 00:00:00 2001 From: Leandro Lanzieri Date: Fri, 15 May 2020 09:47:09 +0200 Subject: [PATCH] gnrc/ipv6: Configure queue size with exponent This changes the configuration macro to be the exponent of 2^n, as the message queue size needs to be always power of 2. --- sys/include/net/gnrc/ipv6.h | 18 +++++++++++++++--- sys/net/gnrc/network_layer/ipv6/Kconfig | 10 +++++++--- sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c | 4 ++-- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/sys/include/net/gnrc/ipv6.h b/sys/include/net/gnrc/ipv6.h index d5d10b635b..e230824a03 100644 --- a/sys/include/net/gnrc/ipv6.h +++ b/sys/include/net/gnrc/ipv6.h @@ -138,10 +138,15 @@ extern "C" { #endif /** - * @brief Default message queue size to use for the IPv6 thread. + * @brief Default message queue size to use for the IPv6 thread (as exponent + * of 2^n). + * + * As the queue size ALWAYS needs to be power of two, this option + * represents the exponent of 2^n, which will be used as the size of + * the queue. */ -#ifndef CONFIG_GNRC_IPV6_MSG_QUEUE_SIZE -#define CONFIG_GNRC_IPV6_MSG_QUEUE_SIZE (8U) +#ifndef CONFIG_GNRC_IPV6_MSG_QUEUE_SIZE_EXP +#define CONFIG_GNRC_IPV6_MSG_QUEUE_SIZE_EXP (3U) #endif #ifdef DOXYGEN @@ -164,6 +169,13 @@ extern "C" { #endif /* DOXYGEN */ /** @} */ +/** + * @brief Message queue size to use for the IPv6 thread. + */ +#ifndef GNRC_IPV6_MSG_QUEUE_SIZE +#define GNRC_IPV6_MSG_QUEUE_SIZE (1 << CONFIG_GNRC_IPV6_MSG_QUEUE_SIZE_EXP) +#endif + /** * @brief The PID to the IPv6 thread. * diff --git a/sys/net/gnrc/network_layer/ipv6/Kconfig b/sys/net/gnrc/network_layer/ipv6/Kconfig index 06fa33b52c..13c713b45f 100644 --- a/sys/net/gnrc/network_layer/ipv6/Kconfig +++ b/sys/net/gnrc/network_layer/ipv6/Kconfig @@ -14,9 +14,13 @@ menuconfig KCONFIG_MODULE_GNRC_IPV6 if KCONFIG_MODULE_GNRC_IPV6 -config GNRC_IPV6_MSG_QUEUE_SIZE - int "Default message queue size to use for the IPv6 thread" - default 8 +config GNRC_IPV6_MSG_QUEUE_SIZE_EXP + int "Exponent for the message queue size used for the IPv6 thread (as 2^n)" + default 3 + help + As the queue size ALWAYS needs to be power of two, this option + represents the exponent of 2^n, which will be used as the size of + the queue. endif # KCONFIG_MODULE_GNRC_IPV6 diff --git a/sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c b/sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c index 55961e70de..b774a669f6 100644 --- a/sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c +++ b/sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c @@ -173,12 +173,12 @@ static void _dispatch_next_header(gnrc_pktsnip_t *pkt, unsigned nh, static void *_event_loop(void *args) { - msg_t msg, reply, msg_q[CONFIG_GNRC_IPV6_MSG_QUEUE_SIZE]; + msg_t msg, reply, msg_q[GNRC_IPV6_MSG_QUEUE_SIZE]; gnrc_netreg_entry_t me_reg = GNRC_NETREG_ENTRY_INIT_PID(GNRC_NETREG_DEMUX_CTX_ALL, sched_active_pid); (void)args; - msg_init_queue(msg_q, CONFIG_GNRC_IPV6_MSG_QUEUE_SIZE); + msg_init_queue(msg_q, GNRC_IPV6_MSG_QUEUE_SIZE); /* initialize fragmentation data-structures */ #ifdef MODULE_GNRC_IPV6_EXT_FRAG