1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-15 09:33:50 +01:00

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.
This commit is contained in:
Leandro Lanzieri 2020-05-15 09:47:09 +02:00
parent 1992f57765
commit b0168f5fdd
No known key found for this signature in database
GPG Key ID: 13559905E2EBEAA5
3 changed files with 24 additions and 8 deletions

View File

@ -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.
*

View File

@ -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

View File

@ -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