Skip to content

Commit

Permalink
Merge pull request #14086 from leandrolanzieri/pr/gnrc/queue_size_exp
Browse files Browse the repository at this point in the history
gnrc: Use exponent to configure message queue sizes
  • Loading branch information
miri64 authored Jun 15, 2020
2 parents f013993 + dbfe0d8 commit 1ad2d07
Show file tree
Hide file tree
Showing 22 changed files with 245 additions and 69 deletions.
21 changes: 19 additions & 2 deletions sys/include/net/gnrc/gomach/gomach.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@
extern "C" {
#endif

/**
* @defgroup net_gnrc_gomach_conf GNRC GoMacH compile configuration
* @ingroup net_gnrc_conf
* @{
*/
/**
* @brief The default duration of GoMacH's wake-up period (WP).
*
Expand Down Expand Up @@ -342,13 +347,25 @@ extern "C" {
#endif

/**
* @brief Default message queue size to use for the GoMacH thread.
* @brief Default message queue size to use for the GoMacH 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.
*
* The value of this macro should be enough for supporting the manipulation of
* GoMacH.
*/
#ifndef CONFIG_GNRC_GOMACH_IPC_MSG_QUEUE_SIZE_EXP
#define CONFIG_GNRC_GOMACH_IPC_MSG_QUEUE_SIZE_EXP (3U)
#endif
/** @} */

/**
* @brief Message queue size to use for the GoMacH thread.
*/
#ifndef GNRC_GOMACH_IPC_MSG_QUEUE_SIZE
#define GNRC_GOMACH_IPC_MSG_QUEUE_SIZE (8U)
#define GNRC_GOMACH_IPC_MSG_QUEUE_SIZE (1 << CONFIG_GNRC_GOMACH_IPC_MSG_QUEUE_SIZE_EXP)
#endif

/**
Expand Down
18 changes: 15 additions & 3 deletions sys/include/net/gnrc/ipv6.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
*
Expand Down
21 changes: 19 additions & 2 deletions sys/include/net/gnrc/lwmac/lwmac.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@
extern "C" {
#endif

/**
* @defgroup net_gnrc_lwmac_conf GNRC LWMAC compile configurations
* @ingroup net_gnrc_conf
* @{
*/
/**
* @brief Time between consecutive wake-ups.
*
Expand Down Expand Up @@ -287,14 +292,26 @@ extern "C" {
#endif

/**
* @brief Default message queue size to use for the LWMAC thread.
* @brief Default message queue size to use for the LWMAC 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.
*
* The value of this macro should be enough for supporting the manipulation of
* LWMAC.
*
*/
#ifndef CONFIG_GNRC_LWMAC_IPC_MSG_QUEUE_SIZE_EXP
#define CONFIG_GNRC_LWMAC_IPC_MSG_QUEUE_SIZE_EXP (3U)
#endif
/** @} */

/**
* @brief Message queue size to use for the LWMAC thread.
*/
#ifndef GNRC_LWMAC_IPC_MSG_QUEUE_SIZE
#define GNRC_LWMAC_IPC_MSG_QUEUE_SIZE (8U)
#define GNRC_LWMAC_IPC_MSG_QUEUE_SIZE (1 << CONFIG_GNRC_LWMAC_IPC_MSG_QUEUE_SIZE_EXP)
#endif

/**
Expand Down
20 changes: 16 additions & 4 deletions sys/include/net/gnrc/netif/conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,19 @@ extern "C" {
#endif

/**
* @brief Message queue size for network interface threads
* @brief Default message queue size for network interface threads (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.
*
* @attention This has influence on the used stack memory of the thread, so
* the thread's stack size might need to be adapted if this is
* changed.
*/
#ifndef CONFIG_GNRC_NETIF_MSG_QUEUE_SIZE
#define CONFIG_GNRC_NETIF_MSG_QUEUE_SIZE (16U)
#ifndef CONFIG_GNRC_NETIF_MSG_QUEUE_SIZE_EXP
#define CONFIG_GNRC_NETIF_MSG_QUEUE_SIZE_EXP (4U)
#endif

/**
Expand Down Expand Up @@ -151,10 +156,17 @@ extern "C" {
#ifndef CONFIG_GNRC_NETIF_MIN_WAIT_AFTER_SEND_US
#define CONFIG_GNRC_NETIF_MIN_WAIT_AFTER_SEND_US (0U)
#endif
/** @} */

/**
* @brief Message queue size for network interface threads
*/
#ifndef GNRC_NETIF_MSG_QUEUE_SIZE
#define GNRC_NETIF_MSG_QUEUE_SIZE (1 << CONFIG_GNRC_NETIF_MSG_QUEUE_SIZE_EXP)
#endif

#ifdef __cplusplus
}
#endif

#endif /* NET_GNRC_NETIF_CONF_H */
/** @} */
23 changes: 20 additions & 3 deletions sys/include/net/gnrc/nettest.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
extern "C" {
#endif

/**
* @defgroup net_gnrc_nettest_conf GNRC NETAPI test compile configurations
* @ingroup net_gnrc_conf
* @{
*/
/**
* @brief Timeout for tests in microseconds
*/
Expand All @@ -61,12 +66,24 @@ extern "C" {
#endif

/**
* @brief Default message queue size to use for the nettest thread.
* @brief Default message queue size to use for the nettest 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 GNRC_NETTEST_MSG_QUEUE_SIZE
#define GNRC_NETTEST_MSG_QUEUE_SIZE (8U)
#ifndef CONFIG_GNRC_NETTEST_MSG_QUEUE_SIZE_EXP
#define CONFIG_GNRC_NETTEST_MSG_QUEUE_SIZE_EXP (3U)
#endif
/** @} */

/**
* @brief Message queue size to use for the nettest thread.
*/
#ifndef GNRC_NETTEST_MSG_QUEUE_SIZE
#define GNRC_NETTEST_MSG_QUEUE_SIZE (1 << CONFIG_GNRC_NETTEST_MSG_QUEUE_SIZE_EXP)
#endif

/**
* @brief Type for get/set callbacks.
Expand Down
18 changes: 15 additions & 3 deletions sys/include/net/gnrc/rpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,22 @@ extern "C" {
#endif

/**
* @brief Default message queue size to use for the RPL thread.
* @brief Default message queue size to use for the RPL 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_RPL_MSG_QUEUE_SIZE_EXP
#define CONFIG_GNRC_RPL_MSG_QUEUE_SIZE_EXP (3U)
#endif

/**
* @brief Message queue size to use for the RPL thread.
*/
#ifndef CONFIG_GNRC_RPL_MSG_QUEUE_SIZE
#define CONFIG_GNRC_RPL_MSG_QUEUE_SIZE (8U)
#ifndef GNRC_RPL_MSG_QUEUE_SIZE
#define GNRC_RPL_MSG_QUEUE_SIZE (1 << CONFIG_GNRC_RPL_MSG_QUEUE_SIZE_EXP)
#endif

/**
Expand Down
17 changes: 14 additions & 3 deletions sys/include/net/gnrc/sixlowpan/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,14 @@ extern "C" {
#endif

/**
* @brief Default message queue size to use for the 6LoWPAN thread.
* @brief Default message queue size to use for the 6LoWPAN 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_SIXLOWPAN_MSG_QUEUE_SIZE
#define CONFIG_GNRC_SIXLOWPAN_MSG_QUEUE_SIZE (8U)
#ifndef CONFIG_GNRC_SIXLOWPAN_MSG_QUEUE_SIZE_EXP
#define CONFIG_GNRC_SIXLOWPAN_MSG_QUEUE_SIZE_EXP (3U)
#endif

/**
Expand Down Expand Up @@ -307,6 +311,13 @@ extern "C" {
#endif
/** @} */

/**
* @brief Message queue size to use for the 6LoWPAN thread.
*/
#ifndef GNRC_SIXLOWPAN_MSG_QUEUE_SIZE
#define GNRC_SIXLOWPAN_MSG_QUEUE_SIZE (1 << CONFIG_GNRC_SIXLOWPAN_MSG_QUEUE_SIZE_EXP)
#endif

#ifdef __cplusplus
}
#endif
Expand Down
1 change: 1 addition & 0 deletions sys/include/net/gnrc/tcp/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ extern "C" {
/**
* @defgroup net_gnrc_tcp_conf GNRC TCP compile configurations
* @ingroup net_gnrc_conf
* @ingroup net_gnrc_tcp
*
* ## Calculating RTO
* To calculate retransmission timeout (RTO), Round Trip Time (RTT) needs to be
Expand Down
18 changes: 17 additions & 1 deletion sys/include/net/gnrc/tcp/tcb.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,26 @@
extern "C" {
#endif

/**
* @{
* @ingroup net_gnrc_tcp_conf
* @brief Size of the TCB mbox (as exponent of 2^n).
*
* As the mbox buffer 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
* mbox.
*/
#ifndef CONFIG_GNRC_TCP_TCB_MBOX_SIZE_EXP
#define CONFIG_GNRC_TCP_TCB_MBOX_SIZE_EXP (3U)
#endif
/** @} */

/**
* @brief Size of the TCB mbox
*/
#define GNRC_TCP_TCB_MBOX_SIZE (8U)
#ifndef GNRC_TCP_TCB_MBOX_SIZE
#define GNRC_TCP_TCB_MBOX_SIZE (1 << CONFIG_GNRC_TCP_TCB_MBOX_SIZE_EXP)
#endif

/**
* @brief Transmission control block of GNRC TCP.
Expand Down
23 changes: 20 additions & 3 deletions sys/include/net/gnrc/udp.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,19 @@ extern "C" {
#endif

/**
* @brief Default message queue size for the UDP thread
* @defgroup net_gnrc_udp_conf GNRC UDP compile configurations
* @ingroup net_gnrc_conf
* @{
*/
#ifndef GNRC_UDP_MSG_QUEUE_SIZE
#define GNRC_UDP_MSG_QUEUE_SIZE (8U)
/**
* @brief Default message queue size for the UDP 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_UDP_MSG_QUEUE_SIZE_EXP
#define CONFIG_GNRC_UDP_MSG_QUEUE_SIZE_EXP (3U)
#endif

/**
Expand All @@ -52,6 +61,14 @@ extern "C" {
#ifndef GNRC_UDP_STACK_SIZE
#define GNRC_UDP_STACK_SIZE (THREAD_STACKSIZE_DEFAULT)
#endif
/** @} */

/**
* @brief Message queue size to use for the UDP thread.
*/
#ifndef GNRC_UDP_MSG_QUEUE_SIZE
#define GNRC_UDP_MSG_QUEUE_SIZE (1 << CONFIG_GNRC_UDP_MSG_QUEUE_SIZE_EXP)
#endif

/**
* @brief Calculate the checksum for the given packet
Expand Down
10 changes: 7 additions & 3 deletions sys/net/gnrc/netif/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ menuconfig KCONFIG_MODULE_GNRC_NETIF

if KCONFIG_MODULE_GNRC_NETIF

config GNRC_NETIF_MSG_QUEUE_SIZE
int "Message queue size for network interface threads"
default 16
config GNRC_NETIF_MSG_QUEUE_SIZE_EXP
int "Exponent for the message queue size for network interface threads (as 2^n)"
default 4
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.

config GNRC_NETIF_IPV6_ADDRS_NUMOF
int "Maximum number of unicast and anycast addresses per interface"
Expand Down
4 changes: 2 additions & 2 deletions sys/net/gnrc/netif/gnrc_netif.c
Original file line number Diff line number Diff line change
Expand Up @@ -1463,7 +1463,7 @@ static void *_gnrc_netif_thread(void *args)
netdev_t *dev;
int res;
msg_t reply = { .type = GNRC_NETAPI_MSG_TYPE_ACK };
msg_t msg_queue[CONFIG_GNRC_NETIF_MSG_QUEUE_SIZE];
msg_t msg_queue[GNRC_NETIF_MSG_QUEUE_SIZE];

DEBUG("gnrc_netif: starting thread %i\n", sched_active_pid);
netif = args;
Expand All @@ -1478,7 +1478,7 @@ static void *_gnrc_netif_thread(void *args)
#endif /* MODULE_GNRC_NETIF_EVENTS */

/* setup the link-layer's message queue */
msg_init_queue(msg_queue, CONFIG_GNRC_NETIF_MSG_QUEUE_SIZE);
msg_init_queue(msg_queue, GNRC_NETIF_MSG_QUEUE_SIZE);
/* register the event callback with the device driver */
dev->event_callback = _event_cb;
dev->context = netif;
Expand Down
6 changes: 3 additions & 3 deletions sys/net/gnrc/netif/init_devs/auto_init_cc110x.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@
#include "cc110x_params.h"
#include "log.h"
#include "msg.h"
#include "net/gnrc/netif/conf.h" /* <- CONFIG_GNRC_NETIF_MSG_QUEUE_SIZE */
#include "net/gnrc/netif/conf.h" /* <- GNRC_NETIF_MSG_QUEUE_SIZE */
#define ENABLE_DEBUG (0)
#include "debug.h"

#ifndef CC110X_EXTRA_STACKSIZE
/**
* @brief Additional stack size required by the driver
*
* With increasing of CONFIG_GNRC_NETIF_MSG_QUEUE_SIZE the required stack size
* With increasing of GNRC_NETIF_MSG_QUEUE_SIZE the required stack size
* increases as well. A queue size of 8 messages works with default stack size,
* so we increase the stack by `sizeof(msg_t)` for each additional element
*/
#define CC110X_EXTRA_STACKSIZE ((CONFIG_GNRC_NETIF_MSG_QUEUE_SIZE - 8) * sizeof(msg_t))
#define CC110X_EXTRA_STACKSIZE ((GNRC_NETIF_MSG_QUEUE_SIZE - 8) * sizeof(msg_t))
#endif

/**
Expand Down
Loading

0 comments on commit 1ad2d07

Please sign in to comment.