gnrc/netif: 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:
parent
f62623caaf
commit
05962fe3ef
@ -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
|
||||
|
||||
/**
|
||||
@ -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 */
|
||||
/** @} */
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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;
|
||||
@ -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;
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
#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"
|
||||
|
||||
@ -32,11 +32,11 @@
|
||||
/**
|
||||
* @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
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user