mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
Merge pull request #14252 from akshaim/Kconfig_csma
net/csma : Expose configurations to Kconfig
This commit is contained in:
commit
a3fa7e330d
@ -34,34 +34,40 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @defgroup net_csma_sender_conf CSMA/CA helper compile configurations
|
||||||
|
* @ingroup config
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
/**
|
/**
|
||||||
* @brief Default Minimal CSMA/CA Backoff Exponent
|
* @brief Default Minimal CSMA/CA Backoff Exponent
|
||||||
*/
|
*/
|
||||||
#ifndef CSMA_SENDER_MIN_BE_DEFAULT
|
#ifndef CONFIG_CSMA_SENDER_MIN_BE_DEFAULT
|
||||||
#define CSMA_SENDER_MIN_BE_DEFAULT (3U)
|
#define CONFIG_CSMA_SENDER_MIN_BE_DEFAULT (3U)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Default Maximal CSMA/CA Backoff Exponent
|
* @brief Default Maximal CSMA/CA Backoff Exponent
|
||||||
*/
|
*/
|
||||||
#ifndef CSMA_SENDER_MAX_BE_DEFAULT
|
#ifndef CONFIG_CSMA_SENDER_MAX_BE_DEFAULT
|
||||||
#define CSMA_SENDER_MAX_BE_DEFAULT (5U)
|
#define CONFIG_CSMA_SENDER_MAX_BE_DEFAULT (5U)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Default Maximal number of retries for sending
|
* @brief Default Maximal number of retries for sending
|
||||||
* a given packet with the CSMA/CA method
|
* a given packet with the CSMA/CA method
|
||||||
*/
|
*/
|
||||||
#ifndef CSMA_SENDER_MAX_BACKOFFS_DEFAULT
|
#ifndef CONFIG_CSMA_SENDER_MAX_BACKOFFS_DEFAULT
|
||||||
#define CSMA_SENDER_MAX_BACKOFFS_DEFAULT (4U)
|
#define CONFIG_CSMA_SENDER_MAX_BACKOFFS_DEFAULT (4U)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief CSMA/CA backoff period, in microseconds
|
* @brief CSMA/CA backoff period, in microseconds
|
||||||
*/
|
*/
|
||||||
#ifndef CSMA_SENDER_BACKOFF_PERIOD_UNIT
|
#ifndef CONFIG_CSMA_SENDER_BACKOFF_PERIOD_UNIT
|
||||||
#define CSMA_SENDER_BACKOFF_PERIOD_UNIT (320U)
|
#define CONFIG_CSMA_SENDER_BACKOFF_PERIOD_UNIT (320U)
|
||||||
#endif
|
#endif
|
||||||
|
/** @} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Configuration type for backoff
|
* @brief Configuration type for backoff
|
||||||
|
@ -4,4 +4,5 @@
|
|||||||
# General Public License v2.1. See the file LICENSE in the top level
|
# General Public License v2.1. See the file LICENSE in the top level
|
||||||
# directory for more details.
|
# directory for more details.
|
||||||
|
|
||||||
|
rsource "csma_sender/Kconfig"
|
||||||
rsource "ieee802154/Kconfig"
|
rsource "ieee802154/Kconfig"
|
||||||
|
42
sys/net/link_layer/csma_sender/Kconfig
Normal file
42
sys/net/link_layer/csma_sender/Kconfig
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
# 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_CSMA_SENDER
|
||||||
|
bool "Configure CSMA sender"
|
||||||
|
depends on MODULE_CSMA_SENDER
|
||||||
|
help
|
||||||
|
Configure the CSMA_SENDER using Kconfig.
|
||||||
|
|
||||||
|
if KCONFIG_MODULE_CSMA_SENDER
|
||||||
|
|
||||||
|
config CSMA_SENDER_MIN_BE_DEFAULT
|
||||||
|
int "Exponent for minimum CSMA/CA backoff time"
|
||||||
|
default 3
|
||||||
|
help
|
||||||
|
Configure 'CONFIG_CSMA_SENDER_MIN_BE_DEFAULT'. Minimum CSMA backoff time
|
||||||
|
is calculated as a function of 'CONFIG_CSMA_SENDER_BACKOFF_PERIOD_UNIT'
|
||||||
|
and the power of 'CONFIG_CSMA_SENDER_MIN_BE_DEFAULT'.
|
||||||
|
|
||||||
|
config CSMA_SENDER_MAX_BE_DEFAULT
|
||||||
|
int "Exponent for maximum CSMA/CA backoff time"
|
||||||
|
default 5
|
||||||
|
help
|
||||||
|
Configure 'CONFIG_CSMA_SENDER_MAX_BE_DEFAULT'. Maximum CSMA backoff time
|
||||||
|
is calculated as a function of 'CONFIG_CSMA_SENDER_BACKOFF_PERIOD_UNIT'
|
||||||
|
and the power of 'CONFIG_CSMA_SENDER_MAX_BE_DEFAULT'.
|
||||||
|
|
||||||
|
config CSMA_SENDER_MAX_BACKOFFS_DEFAULT
|
||||||
|
int "Maximum number of retries for CSMA/CA method"
|
||||||
|
default 4
|
||||||
|
|
||||||
|
config CSMA_SENDER_BACKOFF_PERIOD_UNIT
|
||||||
|
int "Backoff period for CSMA/CA in microseconds"
|
||||||
|
default 320
|
||||||
|
help
|
||||||
|
Configure 'CONFIG_CSMA_SENDER_BACKOFF_PERIOD_UNIT'. Maximum and Minimum
|
||||||
|
CSMA backoff time depends on unit times the value of this configuration.
|
||||||
|
|
||||||
|
endif # KCONFIG_MODULE_CSMA_SENDER
|
@ -38,10 +38,10 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
const csma_sender_conf_t CSMA_SENDER_CONF_DEFAULT = {
|
const csma_sender_conf_t CSMA_SENDER_CONF_DEFAULT = {
|
||||||
CSMA_SENDER_MIN_BE_DEFAULT,
|
CONFIG_CSMA_SENDER_MIN_BE_DEFAULT,
|
||||||
CSMA_SENDER_MAX_BE_DEFAULT,
|
CONFIG_CSMA_SENDER_MAX_BE_DEFAULT,
|
||||||
CSMA_SENDER_MAX_BACKOFFS_DEFAULT,
|
CONFIG_CSMA_SENDER_MAX_BACKOFFS_DEFAULT,
|
||||||
CSMA_SENDER_BACKOFF_PERIOD_UNIT
|
CONFIG_CSMA_SENDER_BACKOFF_PERIOD_UNIT
|
||||||
};
|
};
|
||||||
|
|
||||||
/*--------------------- "INTERNAL" UTILITY FUNCTIONS ---------------------*/
|
/*--------------------- "INTERNAL" UTILITY FUNCTIONS ---------------------*/
|
||||||
@ -63,11 +63,11 @@ static inline uint32_t choose_backoff_period(int be,
|
|||||||
if (be > conf->max_be) {
|
if (be > conf->max_be) {
|
||||||
be = conf->max_be;
|
be = conf->max_be;
|
||||||
}
|
}
|
||||||
uint32_t max_backoff = ((1 << be) - 1) * CSMA_SENDER_BACKOFF_PERIOD_UNIT;
|
uint32_t max_backoff = ((1 << be) - 1) * CONFIG_CSMA_SENDER_BACKOFF_PERIOD_UNIT;
|
||||||
|
|
||||||
uint32_t period = random_uint32() % max_backoff;
|
uint32_t period = random_uint32() % max_backoff;
|
||||||
if (period < CSMA_SENDER_BACKOFF_PERIOD_UNIT) {
|
if (period < CONFIG_CSMA_SENDER_BACKOFF_PERIOD_UNIT) {
|
||||||
period = CSMA_SENDER_BACKOFF_PERIOD_UNIT;
|
period = CONFIG_CSMA_SENDER_BACKOFF_PERIOD_UNIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
return period;
|
return period;
|
||||||
|
Loading…
Reference in New Issue
Block a user