Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

congure: initial import of a congestion control framework #15951

Merged
merged 5 commits into from
Feb 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .murdock
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
: ${TEST_BOARDS_LLVM_COMPILE:=""}

: ${TEST_KCONFIG_samr21_xpro:="examples/hello-world tests/periph_*
tests/test_tools tests/xtimer_* tests/ztimer_*
tests/test_tools tests/congure_* tests/xtimer_* tests/ztimer_*
tests/driver_ad7746 tests/driver_adcxx1c tests/driver_ads101x tests/driver_adt101x
tests/driver_adt7310 tests/driver_adxl345 tests/driver_aip31068 tests/driver_apa102
tests/driver_apds99xx tests/driver_apds99xx_full tests/driver_at tests/driver_at24cxxx
Expand All @@ -25,9 +25,9 @@ tests/mtd_mapper tests/driver_o* tests/driver_p* tests/driver_q*
tests/driver_r* tests/driver_s* tests/driver_t* tests/driver_u*
tests/driver_v*"}
: ${TEST_KCONFIG_native:="examples/hello-world tests/periph_* tests/sys_crypto
tests/test_tools tests/prng_* tests/xtimer_* tests/ztimer_* tests/driver_ws281x
tests/posix_sleep tests/pkg_umorse tests/cb_mux* tests/eepreg tests/shell
tests/struct_tm_utility"}
tests/test_tools tests/congure_* tests/prng_* tests/xtimer_* tests/ztimer_*
tests/driver_ws281x tests/posix_sleep tests/pkg_umorse tests/cb_mux* tests/eepreg
tests/shell tests/struct_tm_utility"}

: ${TEST_WITH_CONFIG_SUPPORTED:="examples/suit_update tests/driver_at86rf2xx_aes"}

Expand Down
2 changes: 2 additions & 0 deletions dist/tools/uncrustify/whitelist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@ cpu/riscv_common/include/.*\.h
cpu/riscv_common/periph/.*\.c
sys/riotboot/.*\.h
sys/riotboot/.*\.c
sys/congure.*\.c
sys/include/congure.*\.h
sys/ztimer/.*\.c
sys/include/ztimer.*\.h
1 change: 1 addition & 0 deletions sys/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ rsource "cb_mux/Kconfig"
rsource "checksum/Kconfig"
rsource "color/Kconfig"
rsource "crypto/Kconfig"
rsource "congure/Kconfig"
rsource "div/Kconfig"
rsource "embunit/Kconfig"
rsource "entropy_source/Kconfig"
Expand Down
8 changes: 8 additions & 0 deletions sys/Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ ifneq (,$(filter arduino_pwm,$(FEATURES_USED)))
FEATURES_REQUIRED += periph_pwm
endif

ifneq (,$(filter congure_%,$(USEMODULE)))
USEMODULE += congure
endif

ifneq (,$(filter congure_test,$(USEMODULE)))
USEMODULE += fmt
endif

ifneq (,$(filter eepreg,$(USEMODULE)))
FEATURES_REQUIRED += periph_eeprom
endif
Expand Down
28 changes: 28 additions & 0 deletions sys/congure/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright (c) 2021 Freie Universität 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.

if !TEST_KCONFIG
menu "CongURE congestion control abstraction"
depends on USEMODULE_CONGURE

rsource "mock/Kconfig"
rsource "test/Kconfig"

endmenu # CongURE congestion control abstraction
endif # !TEST_KCONFIG

if TEST_KCONFIG
menuconfig MODULE_CONGURE
bool "CongURE congestion control abstraction"
depends on TEST_KCONFIG

if MODULE_CONGURE

rsource "mock/Kconfig"
rsource "test/Kconfig"

endif # MODULE_CONGURE
endif # TEST_KCONFIG
8 changes: 8 additions & 0 deletions sys/congure/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
ifneq (,$(filter congure_mock,$(USEMODULE)))
DIRS += mock
endif
ifneq (,$(filter congure_test,$(USEMODULE)))
DIRS += test
endif

include $(RIOTBASE)/Makefile.base
3 changes: 3 additions & 0 deletions sys/congure/mock/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
config MODULE_CONGURE_MOCK
bool "CongURE mock implementation for testing"
depends on MODULE_CONGURE
3 changes: 3 additions & 0 deletions sys/congure/mock/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
MODULE := congure_mock

include $(RIOTBASE)/Makefile.base
121 changes: 121 additions & 0 deletions sys/congure/mock/congure_mock.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
/*
* Copyright (C) 2021 Freie Universität 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.
*/

/**
* @{
*
* @file
* @author Martine Lenders <m.lenders@fu-berlin.de>
*/

#include "congure/mock.h"

static void _snd_init(congure_snd_t *cong, void *ctx);
static int32_t _snd_inter_msg_interval(congure_snd_t *cong, unsigned msg_size);
static void _snd_report_msg_sent(congure_snd_t *cong, unsigned msg_size);
static void _snd_report_msg_discarded(congure_snd_t *cong, unsigned msg_size);
static void _snd_report_msgs_lost(congure_snd_t *cong, congure_snd_msg_t *msgs);
static void _snd_report_msgs_timeout(congure_snd_t *cong,
congure_snd_msg_t *msgs);
static void _snd_report_msg_acked(congure_snd_t *cong, congure_snd_msg_t *msg,
congure_snd_ack_t *ack);
static void _snd_report_ecn_ce(congure_snd_t *cong, ztimer_now_t time);

static const congure_snd_driver_t _driver = {
.init = _snd_init,
.inter_msg_interval = _snd_inter_msg_interval,
.report_msg_sent = _snd_report_msg_sent,
.report_msg_discarded = _snd_report_msg_discarded,
.report_msgs_timeout = _snd_report_msgs_timeout,
.report_msgs_lost = _snd_report_msgs_lost,
.report_msg_acked = _snd_report_msg_acked,
.report_ecn_ce = _snd_report_ecn_ce,
};

void congure_mock_snd_setup(congure_mock_snd_t *c)
{
c->super.driver = &_driver;
}

static void _snd_init(congure_snd_t *cong, void *ctx)
{
congure_mock_snd_t *c = (congure_mock_snd_t *)cong;

c->init_calls++;
c->init_args.c = &c->super;
c->init_args.ctx = ctx;
}

static int32_t _snd_inter_msg_interval(congure_snd_t *cong, unsigned msg_size)
{
congure_mock_snd_t *c = (congure_mock_snd_t *)cong;

c->inter_msg_interval_calls++;
c->inter_msg_interval_args.c = &c->super;
c->inter_msg_interval_args.msg_size = msg_size;
return -1;
}

static void _snd_report_msg_sent(congure_snd_t *cong, unsigned msg_size)
{
congure_mock_snd_t *c = (congure_mock_snd_t *)cong;

c->report_msg_sent_calls++;
c->report_msg_sent_args.c = &c->super;
c->report_msg_sent_args.msg_size = msg_size;
}

static void _snd_report_msg_discarded(congure_snd_t *cong, unsigned msg_size)
{
congure_mock_snd_t *c = (congure_mock_snd_t *)cong;

c->report_msg_discarded_calls++;
c->report_msg_discarded_args.c = &c->super;
c->report_msg_discarded_args.msg_size = msg_size;
}

static void _snd_report_msgs_lost(congure_snd_t *cong, congure_snd_msg_t *msgs)
{
congure_mock_snd_t *c = (congure_mock_snd_t *)cong;

c->report_msgs_lost_calls++;
c->report_msgs_lost_args.c = &c->super;
c->report_msgs_lost_args.msgs = msgs;
}

static void _snd_report_msgs_timeout(congure_snd_t *cong,
congure_snd_msg_t *msgs)
{
congure_mock_snd_t *c = (congure_mock_snd_t *)cong;

c->report_msgs_timeout_calls++;
c->report_msgs_timeout_args.c = &c->super;
c->report_msgs_timeout_args.msgs = msgs;
}

static void _snd_report_msg_acked(congure_snd_t *cong, congure_snd_msg_t *msg,
congure_snd_ack_t *ack)
{
congure_mock_snd_t *c = (congure_mock_snd_t *)cong;

c->report_msg_acked_calls++;
c->report_msg_acked_args.c = &c->super;
c->report_msg_acked_args.msg = msg;
c->report_msg_acked_args.ack = ack;
}

static void _snd_report_ecn_ce(congure_snd_t *cong, ztimer_now_t time)
{
congure_mock_snd_t *c = (congure_mock_snd_t *)cong;

c->report_ecn_ce_calls++;
c->report_ecn_ce_args.c = &c->super;
c->report_ecn_ce_args.time = time;
}

/** @} */
30 changes: 30 additions & 0 deletions sys/congure/test/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright (c) 2021 Freie Universität 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.

if !TEST_KCONFIG

menuconfig KCONFIG_USEMODULE_CONGURE_TEST
bool "Configure CongURE test framework"
depends on USEMODULE_CONGURE_TEST
help
Configure CongURE test framework via Kconfig.
if KCONFIG_USEMODULE_CONGURE_TEST
rsource "Kconfig.config"
endif # KCONFIG_USEMODULE_CONGURE_TEST

endif # !TEST_KCONFIG
if TEST_KCONFIG

menuconfig MODULE_CONGURE_TEST
bool "CongURE test framework"
depends on TEST_KCONFIG
select MODULE_FMT

if MODULE_CONGURE_TEST
rsource "Kconfig.config"
endif # MODULE_CONGURE_TEST

endif # TEST_KCONFIG
19 changes: 19 additions & 0 deletions sys/congure/test/Kconfig.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright (c) 2021 Freie Universität 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.
#

# XXX This file only is required since there is no easy way to use these config
# options with both the final MODULE_SHELL and KCONFIG_USEMODULE_SHELL in a
# nicely looking and easy to migrate way. After migration, the content of this
# file can be folded back into `sys/shell/Kconfig`

config CONGURE_TEST_LOST_MSG_POOL_SIZE
int "Pool size for the list elements for a lost message report"
default 4
help
@see congure_snd_driver_t::report_msg_lost
This defines the maximum number of 3-tuples you can use with
@ref congure_test_call_report() when argv[1] is msg_lost.
3 changes: 3 additions & 0 deletions sys/congure/test/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
MODULE := congure_test

include $(RIOTBASE)/Makefile.base
Loading