Merge pull request #14138 from akshaim/Kconfig_mac
gnrc/mac : Expose configurations to Kconfig
This commit is contained in:
commit
3ce8efd4cb
@ -98,12 +98,12 @@ static inline void gnrc_netif_set_tx_feedback(gnrc_netif_t *netif,
|
|||||||
/**
|
/**
|
||||||
* @brief Queues the packet into the related transmission packet queue in netdev_t::tx.
|
* @brief Queues the packet into the related transmission packet queue in netdev_t::tx.
|
||||||
* Note that, in case the `gnrc_mac_tx_neighbor_t` structure is in used (indicated
|
* Note that, in case the `gnrc_mac_tx_neighbor_t` structure is in used (indicated
|
||||||
* by `GNRC_MAC_NEIGHBOR_COUNT != 0`), this function queues the packet to
|
* by `CONFIG_GNRC_MAC_NEIGHBOR_COUNT != 0`), this function queues the packet to
|
||||||
* the queue associated to the pkt's destination neighbor, including a
|
* the queue associated to the pkt's destination neighbor, including a
|
||||||
* `broadcast-neighbor` (neighbor id is `0` in netdev_t::tx::neighbors) which
|
* `broadcast-neighbor` (neighbor id is `0` in netdev_t::tx::neighbors) which
|
||||||
* specifically stores broadcasting packets.
|
* specifically stores broadcasting packets.
|
||||||
* On the other hand, if `gnrc_mac_tx_neighbor_t` structure is not in used (indicated
|
* On the other hand, if `gnrc_mac_tx_neighbor_t` structure is not in used (indicated
|
||||||
* by `GNRC_MAC_NEIGHBOR_COUNT == 0`), this function queues the packet into the single
|
* by `CONFIG_GNRC_MAC_NEIGHBOR_COUNT == 0`), this function queues the packet into the single
|
||||||
* priority TX queue defined in in netdev_t::tx.
|
* priority TX queue defined in in netdev_t::tx.
|
||||||
*
|
*
|
||||||
* @param[in,out] tx gnrc_mac transmission management object
|
* @param[in,out] tx gnrc_mac transmission management object
|
||||||
|
|||||||
@ -21,6 +21,8 @@
|
|||||||
* @author Shuguo Zhuo <shuguo.zhuo@inria.fr>
|
* @author Shuguo Zhuo <shuguo.zhuo@inria.fr>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "kernel_defines.h"
|
||||||
|
|
||||||
#ifndef NET_GNRC_MAC_MAC_H
|
#ifndef NET_GNRC_MAC_MAC_H
|
||||||
#define NET_GNRC_MAC_MAC_H
|
#define NET_GNRC_MAC_MAC_H
|
||||||
|
|
||||||
@ -29,41 +31,94 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The default rx queue size for incoming packets
|
* @defgroup net_gnrc_mac_conf GNRC MAC compile configurations
|
||||||
|
* @ingroup net_gnrc_conf
|
||||||
|
* @{
|
||||||
*/
|
*/
|
||||||
#ifndef GNRC_MAC_RX_QUEUE_SIZE
|
/**
|
||||||
#define GNRC_MAC_RX_QUEUE_SIZE (8U)
|
* @brief Default message queue size to use for the incoming packets (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_MAC_RX_QUEUE_SIZE_EXP
|
||||||
|
#define CONFIG_GNRC_MAC_RX_QUEUE_SIZE_EXP (3U)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The default buffer size for storing dispatching packets
|
* @brief Default buffer size to use for storing dispatching packets (as
|
||||||
|
* exponent of 2^n).
|
||||||
|
*
|
||||||
|
* As the 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 buffer.
|
||||||
*/
|
*/
|
||||||
#ifndef GNRC_MAC_DISPATCH_BUFFER_SIZE
|
#ifndef CONFIG_GNRC_MAC_DISPATCH_BUFFER_SIZE_EXP
|
||||||
#define GNRC_MAC_DISPATCH_BUFFER_SIZE (8U)
|
#define CONFIG_GNRC_MAC_DISPATCH_BUFFER_SIZE_EXP (3U)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Count of neighbor nodes in one-hop distance
|
* @brief Count of neighbor nodes in one-hop distance.
|
||||||
*/
|
*/
|
||||||
#ifndef GNRC_MAC_NEIGHBOR_COUNT
|
#ifndef CONFIG_GNRC_MAC_NEIGHBOR_COUNT
|
||||||
#define GNRC_MAC_NEIGHBOR_COUNT (8U)
|
#define CONFIG_GNRC_MAC_NEIGHBOR_COUNT (8U)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The default queue size for transmission packets coming from higher layers
|
* @brief Default queue size for transmission packets coming from higher
|
||||||
|
* layers (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 buffer.
|
||||||
*/
|
*/
|
||||||
#ifndef GNRC_MAC_TX_QUEUE_SIZE
|
#ifndef CONFIG_GNRC_MAC_TX_QUEUE_SIZE_EXP
|
||||||
#define GNRC_MAC_TX_QUEUE_SIZE (8U)
|
#define CONFIG_GNRC_MAC_TX_QUEUE_SIZE_EXP (3U)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Disable MAC radio duty-cycle recording and displaying.
|
||||||
|
*/
|
||||||
|
#ifdef DOXYGEN
|
||||||
|
#define CONFIG_GNRC_MAC_DISABLE_DUTYCYCLE_RECORD
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Enable/disable MAC radio duty-cycle recording and displaying.
|
* @brief Enable/disable MAC radio duty-cycle recording and displaying.
|
||||||
*
|
*
|
||||||
* Set "1" to enable, set "0" to disable.
|
* Set "1" to enable, set "0" to disable.
|
||||||
|
* @deprecated Use inverse @ref CONFIG_GNRC_MAC_DISABLE_DUTYCYCLE_RECORD
|
||||||
|
* instead. Will be removed after 2021.01 release.
|
||||||
*/
|
*/
|
||||||
#ifndef GNRC_MAC_ENABLE_DUTYCYCLE_RECORD
|
#ifndef GNRC_MAC_ENABLE_DUTYCYCLE_RECORD
|
||||||
|
#if IS_ACTIVE(CONFIG_GNRC_MAC_DISABLE_DUTYCYCLE_RECORD)
|
||||||
|
#define GNRC_MAC_ENABLE_DUTYCYCLE_RECORD (0)
|
||||||
|
#else
|
||||||
#define GNRC_MAC_ENABLE_DUTYCYCLE_RECORD (1U)
|
#define GNRC_MAC_ENABLE_DUTYCYCLE_RECORD (1U)
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
/** @} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The default rx queue size for incoming packets
|
||||||
|
*/
|
||||||
|
#ifndef GNRC_MAC_RX_QUEUE_SIZE
|
||||||
|
#define GNRC_MAC_RX_QUEUE_SIZE (1 << CONFIG_GNRC_MAC_RX_QUEUE_SIZE_EXP)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The default buffer size for storing dispatching packets
|
||||||
|
*/
|
||||||
|
#ifndef GNRC_MAC_DISPATCH_BUFFER_SIZE
|
||||||
|
#define GNRC_MAC_DISPATCH_BUFFER_SIZE (1 << CONFIG_GNRC_MAC_DISPATCH_BUFFER_SIZE_EXP)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The default queue size for transmission packets coming from higher
|
||||||
|
* layers
|
||||||
|
*/
|
||||||
|
#ifndef GNRC_MAC_TX_QUEUE_SIZE
|
||||||
|
#define GNRC_MAC_TX_QUEUE_SIZE (1 << CONFIG_GNRC_MAC_TX_QUEUE_SIZE_EXP)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@ -115,7 +115,7 @@ typedef struct {
|
|||||||
#endif /* ((GNRC_MAC_RX_QUEUE_SIZE != 0) && (GNRC_MAC_DISPATCH_BUFFER_SIZE != 0)) || defined(DOXYGEN) */
|
#endif /* ((GNRC_MAC_RX_QUEUE_SIZE != 0) && (GNRC_MAC_DISPATCH_BUFFER_SIZE != 0)) || defined(DOXYGEN) */
|
||||||
#endif /* ((GNRC_MAC_RX_QUEUE_SIZE != 0) || (GNRC_MAC_DISPATCH_BUFFER_SIZE != 0)) || defined(DOXYGEN) */
|
#endif /* ((GNRC_MAC_RX_QUEUE_SIZE != 0) || (GNRC_MAC_DISPATCH_BUFFER_SIZE != 0)) || defined(DOXYGEN) */
|
||||||
|
|
||||||
#if (GNRC_MAC_NEIGHBOR_COUNT != 0) || defined(DOXYGEN)
|
#if (CONFIG_GNRC_MAC_NEIGHBOR_COUNT != 0) || defined(DOXYGEN)
|
||||||
/**
|
/**
|
||||||
* @brief type for storing states of TX neighbor node.
|
* @brief type for storing states of TX neighbor node.
|
||||||
*/
|
*/
|
||||||
@ -162,9 +162,9 @@ typedef struct {
|
|||||||
GNRC_MAC_PHASE_UNINITIALIZED, \
|
GNRC_MAC_PHASE_UNINITIALIZED, \
|
||||||
}
|
}
|
||||||
#endif /* (GNRC_MAC_TX_QUEUE_SIZE != 0) || defined(DOXYGEN) */
|
#endif /* (GNRC_MAC_TX_QUEUE_SIZE != 0) || defined(DOXYGEN) */
|
||||||
#endif /* (GNRC_MAC_NEIGHBOR_COUNT != 0) || defined(DOXYGEN) */
|
#endif /* (CONFIG_GNRC_MAC_NEIGHBOR_COUNT != 0) || defined(DOXYGEN) */
|
||||||
|
|
||||||
#if ((GNRC_MAC_TX_QUEUE_SIZE != 0) || (GNRC_MAC_NEIGHBOR_COUNT != 0)) || defined(DOXYGEN)
|
#if ((GNRC_MAC_TX_QUEUE_SIZE != 0) || (CONFIG_GNRC_MAC_NEIGHBOR_COUNT != 0)) || defined(DOXYGEN)
|
||||||
/**
|
/**
|
||||||
* @brief MAC internal type for storing transmission state parameters and
|
* @brief MAC internal type for storing transmission state parameters and
|
||||||
* state machines.
|
* state machines.
|
||||||
@ -173,18 +173,18 @@ typedef struct {
|
|||||||
* \#ifdef directives when applicable.
|
* \#ifdef directives when applicable.
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
#if (GNRC_MAC_NEIGHBOR_COUNT != 0) || defined(DOXYGEN)
|
#if (CONFIG_GNRC_MAC_NEIGHBOR_COUNT != 0) || defined(DOXYGEN)
|
||||||
gnrc_mac_tx_neighbor_t neighbors[GNRC_MAC_NEIGHBOR_COUNT + 1]; /**< Neighbor information units for one-hop neighbors.
|
gnrc_mac_tx_neighbor_t neighbors[CONFIG_GNRC_MAC_NEIGHBOR_COUNT + 1]; /**< Neighbor information units for one-hop neighbors.
|
||||||
First unit is for broadcast (+1) */
|
First unit is for broadcast (+1) */
|
||||||
gnrc_mac_tx_neighbor_t *current_neighbor; /**< Neighbor information unit of destination node to which
|
gnrc_mac_tx_neighbor_t *current_neighbor; /**< Neighbor information unit of destination node to which
|
||||||
the current packet will be sent */
|
the current packet will be sent */
|
||||||
#endif /* (GNRC_MAC_NEIGHBOR_COUNT != 0) || defined(DOXYGEN) */
|
#endif /* (CONFIG_GNRC_MAC_NEIGHBOR_COUNT != 0) || defined(DOXYGEN) */
|
||||||
|
|
||||||
#if (GNRC_MAC_TX_QUEUE_SIZE != 0) || defined(DOXYGEN)
|
#if (GNRC_MAC_TX_QUEUE_SIZE != 0) || defined(DOXYGEN)
|
||||||
#if (GNRC_MAC_NEIGHBOR_COUNT == 0) || defined(DOXYGEN)
|
#if (CONFIG_GNRC_MAC_NEIGHBOR_COUNT == 0) || defined(DOXYGEN)
|
||||||
gnrc_priority_pktqueue_t queue; /**< If neighbor queues is not used, define
|
gnrc_priority_pktqueue_t queue; /**< If neighbor queues is not used, define
|
||||||
a single queue for managing TX packets. */
|
a single queue for managing TX packets. */
|
||||||
#endif /* (GNRC_MAC_NEIGHBOR_COUNT == 0) || defined(DOXYGEN) */
|
#endif /* (CONFIG_GNRC_MAC_NEIGHBOR_COUNT == 0) || defined(DOXYGEN) */
|
||||||
|
|
||||||
gnrc_priority_pktqueue_node_t _queue_nodes[GNRC_MAC_TX_QUEUE_SIZE]; /**< Shared buffer for TX queue nodes */
|
gnrc_priority_pktqueue_node_t _queue_nodes[GNRC_MAC_TX_QUEUE_SIZE]; /**< Shared buffer for TX queue nodes */
|
||||||
gnrc_pktsnip_t *packet; /**< currently scheduled packet for sending */
|
gnrc_pktsnip_t *packet; /**< currently scheduled packet for sending */
|
||||||
@ -219,26 +219,26 @@ typedef struct {
|
|||||||
/**
|
/**
|
||||||
* @brief Static initializer for gnrc_mac_tx_t.
|
* @brief Static initializer for gnrc_mac_tx_t.
|
||||||
*/
|
*/
|
||||||
#if ((GNRC_MAC_TX_QUEUE_SIZE != 0) && (GNRC_MAC_NEIGHBOR_COUNT != 0)) || defined(DOXYGEN)
|
#if ((GNRC_MAC_TX_QUEUE_SIZE != 0) && (CONFIG_GNRC_MAC_NEIGHBOR_COUNT != 0)) || defined(DOXYGEN)
|
||||||
#define GNRC_MAC_TX_INIT { \
|
#define GNRC_MAC_TX_INIT { \
|
||||||
{ GNRC_MAC_TX_NEIGHBOR_INIT }, \
|
{ GNRC_MAC_TX_NEIGHBOR_INIT }, \
|
||||||
NULL, \
|
NULL, \
|
||||||
{ PRIORITY_PKTQUEUE_NODE_INIT(0, NULL) }, \
|
{ PRIORITY_PKTQUEUE_NODE_INIT(0, NULL) }, \
|
||||||
NULL, \
|
NULL, \
|
||||||
}
|
}
|
||||||
#elif ((GNRC_MAC_TX_QUEUE_SIZE != 0) && (GNRC_MAC_NEIGHBOR_COUNT == 0)) || defined(DOXYGEN)
|
#elif ((GNRC_MAC_TX_QUEUE_SIZE != 0) && (CONFIG_GNRC_MAC_NEIGHBOR_COUNT == 0)) || defined(DOXYGEN)
|
||||||
#define GNRC_MAC_TX_INIT { \
|
#define GNRC_MAC_TX_INIT { \
|
||||||
PRIORITY_PKTQUEUE_INIT, \
|
PRIORITY_PKTQUEUE_INIT, \
|
||||||
{ PRIORITY_PKTQUEUE_NODE_INIT(0, NULL) }, \
|
{ PRIORITY_PKTQUEUE_NODE_INIT(0, NULL) }, \
|
||||||
NULL, \
|
NULL, \
|
||||||
}
|
}
|
||||||
#elif ((GNRC_MAC_TX_QUEUE_SIZE == 0) && (GNRC_MAC_NEIGHBOR_COUNT != 0)) || defined(DOXYGEN)
|
#elif ((GNRC_MAC_TX_QUEUE_SIZE == 0) && (CONFIG_GNRC_MAC_NEIGHBOR_COUNT != 0)) || defined(DOXYGEN)
|
||||||
#define GNRC_MAC_TX_INIT { \
|
#define GNRC_MAC_TX_INIT { \
|
||||||
{ GNRC_MAC_TX_NEIGHBOR_INIT }, \
|
{ GNRC_MAC_TX_NEIGHBOR_INIT }, \
|
||||||
NULL, \
|
NULL, \
|
||||||
}
|
}
|
||||||
#endif /* ((GNRC_MAC_TX_QUEUE_SIZE != 0) && (GNRC_MAC_NEIGHBOR_COUNT != 0)) || defined(DOXYGEN) */
|
#endif /* ((GNRC_MAC_TX_QUEUE_SIZE != 0) && (CONFIG_GNRC_MAC_NEIGHBOR_COUNT != 0)) || defined(DOXYGEN) */
|
||||||
#endif /* ((GNRC_MAC_TX_QUEUE_SIZE != 0) || (GNRC_MAC_NEIGHBOR_COUNT != 0)) || defined(DOXYGEN) */
|
#endif /* ((GNRC_MAC_TX_QUEUE_SIZE != 0) || (CONFIG_GNRC_MAC_NEIGHBOR_COUNT != 0)) || defined(DOXYGEN) */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@ -90,16 +90,16 @@ typedef struct {
|
|||||||
*/
|
*/
|
||||||
gnrc_mac_rx_t rx;
|
gnrc_mac_rx_t rx;
|
||||||
#endif /* ((GNRC_MAC_RX_QUEUE_SIZE != 0) || (GNRC_MAC_DISPATCH_BUFFER_SIZE != 0)) || DOXYGEN */
|
#endif /* ((GNRC_MAC_RX_QUEUE_SIZE != 0) || (GNRC_MAC_DISPATCH_BUFFER_SIZE != 0)) || DOXYGEN */
|
||||||
#if ((GNRC_MAC_TX_QUEUE_SIZE != 0) || (GNRC_MAC_NEIGHBOR_COUNT != 0)) || DOXYGEN
|
#if ((GNRC_MAC_TX_QUEUE_SIZE != 0) || (CONFIG_GNRC_MAC_NEIGHBOR_COUNT != 0)) || DOXYGEN
|
||||||
/**
|
/**
|
||||||
* @brief MAC internal object which stores transmission parameters, queues, and
|
* @brief MAC internal object which stores transmission parameters, queues, and
|
||||||
* state machines.
|
* state machines.
|
||||||
*
|
*
|
||||||
* @note Only available if @ref GNRC_MAC_TX_QUEUE_SIZE or
|
* @note Only available if @ref GNRC_MAC_TX_QUEUE_SIZE or
|
||||||
* @ref GNRC_MAC_NEIGHBOR_COUNT is greater than 0.
|
* @ref CONFIG_GNRC_MAC_NEIGHBOR_COUNT is greater than 0.
|
||||||
*/
|
*/
|
||||||
gnrc_mac_tx_t tx;
|
gnrc_mac_tx_t tx;
|
||||||
#endif /* ((GNRC_MAC_TX_QUEUE_SIZE != 0) || (GNRC_MAC_NEIGHBOR_COUNT == 0)) || DOXYGEN */
|
#endif /* ((GNRC_MAC_TX_QUEUE_SIZE != 0) || (CONFIG_GNRC_MAC_NEIGHBOR_COUNT == 0)) || DOXYGEN */
|
||||||
|
|
||||||
#if defined(MODULE_GNRC_LWMAC) || defined(MODULE_GNRC_GOMACH)
|
#if defined(MODULE_GNRC_LWMAC) || defined(MODULE_GNRC_GOMACH)
|
||||||
gnrc_mac_prot_t prot;
|
gnrc_mac_prot_t prot;
|
||||||
|
|||||||
@ -9,6 +9,7 @@ menu "GNRC Network stack"
|
|||||||
|
|
||||||
rsource "application_layer/dhcpv6/Kconfig"
|
rsource "application_layer/dhcpv6/Kconfig"
|
||||||
rsource "link_layer/lorawan/Kconfig"
|
rsource "link_layer/lorawan/Kconfig"
|
||||||
|
rsource "link_layer/mac/Kconfig"
|
||||||
rsource "netif/Kconfig"
|
rsource "netif/Kconfig"
|
||||||
rsource "network_layer/ipv6/Kconfig"
|
rsource "network_layer/ipv6/Kconfig"
|
||||||
rsource "network_layer/sixlowpan/Kconfig"
|
rsource "network_layer/sixlowpan/Kconfig"
|
||||||
|
|||||||
@ -1166,11 +1166,11 @@ bool gnrc_gomach_find_next_tx_neighbor(gnrc_netif_t *netif)
|
|||||||
* thus to be more fair. */
|
* thus to be more fair. */
|
||||||
uint8_t j = netif->mac.tx.last_tx_neighbor_id + 1;
|
uint8_t j = netif->mac.tx.last_tx_neighbor_id + 1;
|
||||||
|
|
||||||
if (j >= GNRC_MAC_NEIGHBOR_COUNT) {
|
if (j >= CONFIG_GNRC_MAC_NEIGHBOR_COUNT) {
|
||||||
j = 1;
|
j = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint8_t i = 1; i < GNRC_MAC_NEIGHBOR_COUNT; i++) {
|
for (uint8_t i = 1; i < CONFIG_GNRC_MAC_NEIGHBOR_COUNT; i++) {
|
||||||
if (gnrc_priority_pktqueue_length(&netif->mac.tx.neighbors[j].queue) > 0) {
|
if (gnrc_priority_pktqueue_length(&netif->mac.tx.neighbors[j].queue) > 0) {
|
||||||
netif->mac.tx.last_tx_neighbor_id = j;
|
netif->mac.tx.last_tx_neighbor_id = j;
|
||||||
next = (int) j;
|
next = (int) j;
|
||||||
@ -1178,7 +1178,7 @@ bool gnrc_gomach_find_next_tx_neighbor(gnrc_netif_t *netif)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
j++;
|
j++;
|
||||||
if (j >= GNRC_MAC_NEIGHBOR_COUNT) {
|
if (j >= CONFIG_GNRC_MAC_NEIGHBOR_COUNT) {
|
||||||
j = 1;
|
j = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1388,7 +1388,7 @@ void gnrc_gomach_update_neighbor_phase(gnrc_netif_t *netif)
|
|||||||
{
|
{
|
||||||
assert(netif != NULL);
|
assert(netif != NULL);
|
||||||
|
|
||||||
for (uint8_t i = 1; i < GNRC_MAC_NEIGHBOR_COUNT; i++) {
|
for (uint8_t i = 1; i < CONFIG_GNRC_MAC_NEIGHBOR_COUNT; i++) {
|
||||||
if (netif->mac.tx.neighbors[i].mac_type == GNRC_GOMACH_TYPE_KNOWN) {
|
if (netif->mac.tx.neighbors[i].mac_type == GNRC_GOMACH_TYPE_KNOWN) {
|
||||||
long int tmp = netif->mac.tx.neighbors[i].cp_phase -
|
long int tmp = netif->mac.tx.neighbors[i].cp_phase -
|
||||||
netif->mac.prot.gomach.backoff_phase_us;
|
netif->mac.prot.gomach.backoff_phase_us;
|
||||||
@ -1422,7 +1422,7 @@ void gnrc_gomach_update_neighbor_pubchan(gnrc_netif_t *netif)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Toggle TX neighbors' current channel. */
|
/* Toggle TX neighbors' current channel. */
|
||||||
for (uint8_t i = 1; i < GNRC_MAC_NEIGHBOR_COUNT; i++) {
|
for (uint8_t i = 1; i < CONFIG_GNRC_MAC_NEIGHBOR_COUNT; i++) {
|
||||||
if (netif->mac.tx.neighbors[i].mac_type == GNRC_GOMACH_TYPE_KNOWN) {
|
if (netif->mac.tx.neighbors[i].mac_type == GNRC_GOMACH_TYPE_KNOWN) {
|
||||||
if (netif->mac.tx.neighbors[i].pub_chanseq == netif->mac.prot.gomach.pub_channel_1) {
|
if (netif->mac.tx.neighbors[i].pub_chanseq == netif->mac.prot.gomach.pub_channel_1) {
|
||||||
netif->mac.tx.neighbors[i].pub_chanseq = netif->mac.prot.gomach.pub_channel_2;
|
netif->mac.tx.neighbors[i].pub_chanseq = netif->mac.prot.gomach.pub_channel_2;
|
||||||
|
|||||||
@ -201,7 +201,7 @@ static gnrc_mac_tx_neighbor_t *_next_tx_neighbor(gnrc_netif_t *netif)
|
|||||||
gnrc_mac_tx_neighbor_t *next = NULL;
|
gnrc_mac_tx_neighbor_t *next = NULL;
|
||||||
uint32_t phase_nearest = GNRC_LWMAC_PHASE_MAX;
|
uint32_t phase_nearest = GNRC_LWMAC_PHASE_MAX;
|
||||||
|
|
||||||
for (unsigned i = 0; i < GNRC_MAC_NEIGHBOR_COUNT; i++) {
|
for (unsigned i = 0; i < CONFIG_GNRC_MAC_NEIGHBOR_COUNT; i++) {
|
||||||
if (gnrc_priority_pktqueue_length(&netif->mac.tx.neighbors[i].queue) > 0) {
|
if (gnrc_priority_pktqueue_length(&netif->mac.tx.neighbors[i].queue) > 0) {
|
||||||
/* Unknown destinations are initialized with their phase at the end
|
/* Unknown destinations are initialized with their phase at the end
|
||||||
* of the local interval, so known destinations that still wakeup
|
* of the local interval, so known destinations that still wakeup
|
||||||
|
|||||||
46
sys/net/gnrc/link_layer/mac/Kconfig
Normal file
46
sys/net/gnrc/link_layer/mac/Kconfig
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
# Copyright (c) 2020 Freie Universitaet Berlin
|
||||||
|
#
|
||||||
|
# This file is subject to the terms and conditions of the GNU Lesser
|
||||||
|
# General Public License v2.1. See the file LICENSE in the top level
|
||||||
|
# directory for more details.
|
||||||
|
#
|
||||||
|
menuconfig KCONFIG_MODULE_GNRC_MAC
|
||||||
|
bool "Configure GNRC MAC"
|
||||||
|
depends on MODULE_GNRC_MAC
|
||||||
|
help
|
||||||
|
Configure the GNRC MAC using Kconfig.
|
||||||
|
|
||||||
|
if KCONFIG_MODULE_GNRC_MAC
|
||||||
|
|
||||||
|
config GNRC_MAC_RX_QUEUE_SIZE_EXP
|
||||||
|
int "Exponent for the RX queue size (resulting in the queue size 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 RX
|
||||||
|
queue for incoming packets.
|
||||||
|
|
||||||
|
config GNRC_MAC_DISPATCH_BUFFER_SIZE_EXP
|
||||||
|
int "Exponent for the dispatch buffer size (resulting in the buffer size 2^n)"
|
||||||
|
default 3
|
||||||
|
help
|
||||||
|
As the 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
|
||||||
|
dispatch buffer for storing dispatching packets.
|
||||||
|
|
||||||
|
config GNRC_MAC_NEIGHBOR_COUNT
|
||||||
|
int "Count of neighbor nodes in one-hop distance"
|
||||||
|
default 8
|
||||||
|
|
||||||
|
config GNRC_MAC_TX_QUEUE_SIZE_EXP
|
||||||
|
int "Exponent for the TX queue size (resulting in the queue size 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 TX
|
||||||
|
queue for transmission packets coming from higher layers.
|
||||||
|
|
||||||
|
config GNRC_MAC_DISABLE_DUTYCYCLE_RECORD
|
||||||
|
bool "Disable MAC radio duty-cycle recording and displaying"
|
||||||
|
|
||||||
|
endif # KCONFIG_MODULE_GNRC_MAC
|
||||||
@ -47,7 +47,7 @@ gnrc_priority_pktqueue_node_t *_alloc_pktqueue_node(gnrc_priority_pktqueue_node_
|
|||||||
#endif /* ((GNRC_MAC_TX_QUEUE_SIZE != 0) || (GNRC_MAC_RX_QUEUE_SIZE != 0)) */
|
#endif /* ((GNRC_MAC_TX_QUEUE_SIZE != 0) || (GNRC_MAC_RX_QUEUE_SIZE != 0)) */
|
||||||
|
|
||||||
#if GNRC_MAC_TX_QUEUE_SIZE != 0
|
#if GNRC_MAC_TX_QUEUE_SIZE != 0
|
||||||
#if GNRC_MAC_NEIGHBOR_COUNT != 0
|
#if CONFIG_GNRC_MAC_NEIGHBOR_COUNT != 0
|
||||||
/* Find the neighbor's id based on the given address */
|
/* Find the neighbor's id based on the given address */
|
||||||
int _gnrc_mac_find_neighbor(gnrc_mac_tx_t *tx, const uint8_t *dst_addr, int addr_len)
|
int _gnrc_mac_find_neighbor(gnrc_mac_tx_t *tx, const uint8_t *dst_addr, int addr_len)
|
||||||
{
|
{
|
||||||
@ -59,7 +59,7 @@ int _gnrc_mac_find_neighbor(gnrc_mac_tx_t *tx, const uint8_t *dst_addr, int addr
|
|||||||
neighbors = tx->neighbors;
|
neighbors = tx->neighbors;
|
||||||
|
|
||||||
/* Don't attempt to find broadcast neighbor, so start at index 1 */
|
/* Don't attempt to find broadcast neighbor, so start at index 1 */
|
||||||
for (int i = 1; i <= (signed)GNRC_MAC_NEIGHBOR_COUNT; i++) {
|
for (int i = 1; i <= (signed)CONFIG_GNRC_MAC_NEIGHBOR_COUNT; i++) {
|
||||||
if (neighbors[i].l2_addr_len == addr_len) {
|
if (neighbors[i].l2_addr_len == addr_len) {
|
||||||
if (memcmp(&(neighbors[i].l2_addr), dst_addr, addr_len) == 0) {
|
if (memcmp(&(neighbors[i].l2_addr), dst_addr, addr_len) == 0) {
|
||||||
return i;
|
return i;
|
||||||
@ -78,7 +78,7 @@ int _gnrc_mac_free_neighbor(gnrc_mac_tx_t *tx)
|
|||||||
neighbors = tx->neighbors;
|
neighbors = tx->neighbors;
|
||||||
|
|
||||||
/* Don't attempt to free broadcast neighbor, so start at index 1 */
|
/* Don't attempt to free broadcast neighbor, so start at index 1 */
|
||||||
for (int i = 1; i <= (signed)GNRC_MAC_NEIGHBOR_COUNT; i++) {
|
for (int i = 1; i <= (signed)CONFIG_GNRC_MAC_NEIGHBOR_COUNT; i++) {
|
||||||
if ((gnrc_priority_pktqueue_length(&(neighbors[i].queue)) == 0) &&
|
if ((gnrc_priority_pktqueue_length(&(neighbors[i].queue)) == 0) &&
|
||||||
(&neighbors[i] != tx->current_neighbor)) {
|
(&neighbors[i] != tx->current_neighbor)) {
|
||||||
/* Mark as free */
|
/* Mark as free */
|
||||||
@ -98,7 +98,7 @@ int _gnrc_mac_alloc_neighbor(gnrc_mac_tx_t *tx)
|
|||||||
neighbors = tx->neighbors;
|
neighbors = tx->neighbors;
|
||||||
|
|
||||||
/* Don't attempt to allocate broadcast neighbor, so start at index 1 */
|
/* Don't attempt to allocate broadcast neighbor, so start at index 1 */
|
||||||
for (int i = 1; i <= (signed)GNRC_MAC_NEIGHBOR_COUNT; i++) {
|
for (int i = 1; i <= (signed)CONFIG_GNRC_MAC_NEIGHBOR_COUNT; i++) {
|
||||||
if (neighbors[i].l2_addr_len == 0) {
|
if (neighbors[i].l2_addr_len == 0) {
|
||||||
gnrc_priority_pktqueue_init(&(neighbors[i].queue));
|
gnrc_priority_pktqueue_init(&(neighbors[i].queue));
|
||||||
return i;
|
return i;
|
||||||
@ -118,14 +118,14 @@ void _gnrc_mac_init_neighbor(gnrc_mac_tx_neighbor_t *neighbor, const uint8_t *ad
|
|||||||
neighbor->phase = GNRC_MAC_PHASE_MAX;
|
neighbor->phase = GNRC_MAC_PHASE_MAX;
|
||||||
memcpy(&(neighbor->l2_addr), addr, len);
|
memcpy(&(neighbor->l2_addr), addr, len);
|
||||||
}
|
}
|
||||||
#endif /* GNRC_MAC_NEIGHBOR_COUNT != 0 */
|
#endif /* CONFIG_GNRC_MAC_NEIGHBOR_COUNT != 0 */
|
||||||
|
|
||||||
bool gnrc_mac_queue_tx_packet(gnrc_mac_tx_t *tx, uint32_t priority, gnrc_pktsnip_t *pkt)
|
bool gnrc_mac_queue_tx_packet(gnrc_mac_tx_t *tx, uint32_t priority, gnrc_pktsnip_t *pkt)
|
||||||
{
|
{
|
||||||
assert(tx != NULL);
|
assert(tx != NULL);
|
||||||
assert(pkt != NULL);
|
assert(pkt != NULL);
|
||||||
|
|
||||||
#if GNRC_MAC_NEIGHBOR_COUNT == 0
|
#if CONFIG_GNRC_MAC_NEIGHBOR_COUNT == 0
|
||||||
|
|
||||||
gnrc_priority_pktqueue_node_t *node;
|
gnrc_priority_pktqueue_node_t *node;
|
||||||
node = _alloc_pktqueue_node(tx->_queue_nodes, GNRC_MAC_TX_QUEUE_SIZE);
|
node = _alloc_pktqueue_node(tx->_queue_nodes, GNRC_MAC_TX_QUEUE_SIZE);
|
||||||
@ -177,7 +177,7 @@ bool gnrc_mac_queue_tx_packet(gnrc_mac_tx_t *tx, uint32_t priority, gnrc_pktsnip
|
|||||||
/* No neighbor entries left */
|
/* No neighbor entries left */
|
||||||
if (neighbor_id < 0) {
|
if (neighbor_id < 0) {
|
||||||
DEBUG("[gnrc_mac-int] No neighbor entries left, maybe increase "
|
DEBUG("[gnrc_mac-int] No neighbor entries left, maybe increase "
|
||||||
"GNRC_MAC_NEIGHBOR_COUNT for better performance\n");
|
"CONFIG_GNRC_MAC_NEIGHBOR_COUNT for better performance\n");
|
||||||
|
|
||||||
/* Try to free an unused queue */
|
/* Try to free an unused queue */
|
||||||
neighbor_id = _gnrc_mac_free_neighbor(tx);
|
neighbor_id = _gnrc_mac_free_neighbor(tx);
|
||||||
@ -210,7 +210,7 @@ bool gnrc_mac_queue_tx_packet(gnrc_mac_tx_t *tx, uint32_t priority, gnrc_pktsnip
|
|||||||
neighbor_id);
|
neighbor_id);
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
#endif /* GNRC_MAC_NEIGHBOR_COUNT == 0 */
|
#endif /* CONFIG_GNRC_MAC_NEIGHBOR_COUNT == 0 */
|
||||||
}
|
}
|
||||||
#endif /* GNRC_MAC_TX_QUEUE_SIZE != 0 */
|
#endif /* GNRC_MAC_TX_QUEUE_SIZE != 0 */
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
USEMODULE += gnrc_priority_pktqueue
|
USEMODULE += gnrc_priority_pktqueue
|
||||||
USEMODULE += gnrc_mac
|
USEMODULE += gnrc_mac
|
||||||
CFLAGS += -DGNRC_MAC_TX_QUEUE_SIZE=4 -DGNRC_MAC_NEIGHBOR_COUNT=4
|
|
||||||
|
# Set CFLAGS if not being set via Kconfig
|
||||||
|
CFLAGS += $(if $(CONFIG_KCONFIG_MODULE_GNRC_MAC),,-DGNRC_MAC_TX_QUEUE_SIZE=4 -DCONFIG_GNRC_MAC_NEIGHBOR_COUNT=4)
|
||||||
|
|||||||
@ -33,7 +33,7 @@ static void set_up(void)
|
|||||||
* correctly queue the packet to the corresponded priority packet queue.
|
* correctly queue the packet to the corresponded priority packet queue.
|
||||||
*
|
*
|
||||||
* In case when the `gnrc_mac_tx_neighbor_t` structure is in used (indicated by
|
* In case when the `gnrc_mac_tx_neighbor_t` structure is in used (indicated by
|
||||||
* by `GNRC_MAC_NEIGHBOR_COUNT != 0`), `test_gnrc_mac_queue_tx_packet()` successively
|
* by `CONFIG_GNRC_MAC_NEIGHBOR_COUNT != 0`), `test_gnrc_mac_queue_tx_packet()` successively
|
||||||
* queues 4 packets, which are pkt1, pkt2, pkt3 and pkt_bcast, into a defined `tx`
|
* queues 4 packets, which are pkt1, pkt2, pkt3 and pkt_bcast, into a defined `tx`
|
||||||
* (type of `gnrc_mac_tx_t`). Pkt1, pkt2 have the same destination address of "0x76b6",
|
* (type of `gnrc_mac_tx_t`). Pkt1, pkt2 have the same destination address of "0x76b6",
|
||||||
* , pkt3 is heading for "0x447e", while pkt_bcast is for broadcasting.
|
* , pkt3 is heading for "0x447e", while pkt_bcast is for broadcasting.
|
||||||
@ -42,7 +42,7 @@ static void set_up(void)
|
|||||||
* queued to `tx::neighbors[0]::queue`.
|
* queued to `tx::neighbors[0]::queue`.
|
||||||
*
|
*
|
||||||
* In case when the `gnrc_mac_tx_neighbor_t` structure is not in used (indicated by
|
* In case when the `gnrc_mac_tx_neighbor_t` structure is not in used (indicated by
|
||||||
* by `GNRC_MAC_NEIGHBOR_COUNT == 0`), `test_gnrc_mac_queue_tx_packet()` successively
|
* by `CONFIG_GNRC_MAC_NEIGHBOR_COUNT == 0`), `test_gnrc_mac_queue_tx_packet()` successively
|
||||||
* queues 4 packets, which are pkt1, pkt2, pkt3 and pkt_bcast, into a defined `tx`
|
* queues 4 packets, which are pkt1, pkt2, pkt3 and pkt_bcast, into a defined `tx`
|
||||||
* (type of `gnrc_mac_tx_t`). Pkt1, pkt2 have the same destination address of "0x76b6",
|
* (type of `gnrc_mac_tx_t`). Pkt1, pkt2 have the same destination address of "0x76b6",
|
||||||
* , pkt3 is heading for "0x447e", while pkt_bcast is for broadcasting.
|
* , pkt3 is heading for "0x447e", while pkt_bcast is for broadcasting.
|
||||||
@ -90,7 +90,7 @@ static void test_gnrc_mac_queue_tx_packet(void)
|
|||||||
LL_APPEND(hdr, pkt3);
|
LL_APPEND(hdr, pkt3);
|
||||||
pkt3 = hdr;
|
pkt3 = hdr;
|
||||||
|
|
||||||
#if GNRC_MAC_NEIGHBOR_COUNT != 0
|
#if CONFIG_GNRC_MAC_NEIGHBOR_COUNT != 0
|
||||||
|
|
||||||
gnrc_pktsnip_t *pkt_head;
|
gnrc_pktsnip_t *pkt_head;
|
||||||
TEST_ASSERT(gnrc_mac_queue_tx_packet(&tx,1,pkt1));
|
TEST_ASSERT(gnrc_mac_queue_tx_packet(&tx,1,pkt1));
|
||||||
@ -172,7 +172,7 @@ static void test_gnrc_mac_queue_tx_packet(void)
|
|||||||
TEST_ASSERT(0 == gnrc_priority_pktqueue_length(&tx.queue));
|
TEST_ASSERT(0 == gnrc_priority_pktqueue_length(&tx.queue));
|
||||||
TEST_ASSERT_EQUAL_STRING(TEST_STRING8, pkt_head->next->data);
|
TEST_ASSERT_EQUAL_STRING(TEST_STRING8, pkt_head->next->data);
|
||||||
|
|
||||||
#endif /* GNRC_MAC_NEIGHBOR_COUNT != 0 */
|
#endif /* CONFIG_GNRC_MAC_NEIGHBOR_COUNT != 0 */
|
||||||
}
|
}
|
||||||
#endif /* GNRC_MAC_TX_QUEUE_SIZE != 0 */
|
#endif /* GNRC_MAC_TX_QUEUE_SIZE != 0 */
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user