From dd30b37c47a196bd839ed29f3badd57f63d85bff Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Tue, 9 Mar 2021 14:31:34 +0100 Subject: [PATCH] gnrc_sixlowpan_frag_sfr: add support for queue-based ECN --- makefiles/pseudomodules.inc.mk | 4 + sys/Makefile.dep | 309 ++++++++++++++++-- sys/include/net/gnrc/sixlowpan/config.h | 78 +++++ sys/net/gnrc/Makefile.dep | 12 + .../network_layer/sixlowpan/frag/sfr/Kconfig | 50 +++ .../frag/sfr/gnrc_sixlowpan_frag_sfr.c | 45 ++- 6 files changed, 462 insertions(+), 36 deletions(-) diff --git a/makefiles/pseudomodules.inc.mk b/makefiles/pseudomodules.inc.mk index 9e17653459b56..f5b31f3650a0c 100644 --- a/makefiles/pseudomodules.inc.mk +++ b/makefiles/pseudomodules.inc.mk @@ -58,6 +58,10 @@ PSEUDOMODULES += gnrc_sixloenc PSEUDOMODULES += gnrc_sixlowpan_border_router_default PSEUDOMODULES += gnrc_sixlowpan_default PSEUDOMODULES += gnrc_sixlowpan_frag_hint +PSEUDOMODULES += gnrc_sixlowpan_frag_sfr_ecn +PSEUDOMODULES += gnrc_sixlowpan_frag_sfr_ecn_if_in +PSEUDOMODULES += gnrc_sixlowpan_frag_sfr_ecn_if_out +PSEUDOMODULES += gnrc_sixlowpan_frag_sfr_ecn_fqueue PSEUDOMODULES += gnrc_sixlowpan_frag_sfr_stats PSEUDOMODULES += gnrc_sixlowpan_iphc_nhc PSEUDOMODULES += gnrc_sixlowpan_nd_border_router diff --git a/sys/Makefile.dep b/sys/Makefile.dep index 73b0fa818b614..1699b098d98ff 100644 --- a/sys/Makefile.dep +++ b/sys/Makefile.dep @@ -1,13 +1,18 @@ ifneq (,$(filter arduino,$(USEMODULE))) - FEATURES_OPTIONAL += periph_adc FEATURES_OPTIONAL += periph_i2c FEATURES_OPTIONAL += periph_spi - FEATURES_REQUIRED += arduino - FEATURES_REQUIRED += cpp - FEATURES_REQUIRED += periph_gpio FEATURES_REQUIRED += periph_uart + FEATURES_REQUIRED += cpp SKETCH_MODULE ?= arduino_sketches USEMODULE += $(SKETCH_MODULE) +endif + + +ifneq (,$(filter arduino,$(USEMODULE))) + FEATURES_REQUIRED += arduino + FEATURES_OPTIONAL += arduino_pwm + FEATURES_OPTIONAL += periph_adc + FEATURES_REQUIRED += periph_gpio USEMODULE += fmt USEMODULE += xtimer endif @@ -16,11 +21,6 @@ ifneq (,$(filter arduino_pwm,$(FEATURES_USED))) FEATURES_REQUIRED += periph_pwm endif -# cannot be moved to GNRC's Makefile.dep, as module name neither starts or ends with gnrc -ifneq (,$(filter auto_init_gnrc_netif,$(USEMODULE))) - USEMODULE += gnrc_netif_init_devs -endif - ifneq (,$(filter congure_%,$(USEMODULE))) USEMODULE += congure endif @@ -42,21 +42,17 @@ ifneq (,$(filter i2c_scan,$(USEMODULE))) endif ifneq (,$(filter prng_fortuna,$(USEMODULE))) - USEMODULE += crypto_aes_128 + USEMODULE += crypto_aes endif -ifneq (,$(filter crypto_%,$(USEMODULE))) - USEMODULE += crypto +ifneq (,$(filter crypto_aes_%,$(USEMODULE))) + USEMODULE += crypto_aes endif -ifneq (,$(filter cipher_modes,$(USEMODULE))) +ifneq (,$(filter crypto_%,$(USEMODULE))) USEMODULE += crypto endif -ifneq (,$(filter crypto,$(USEMODULE))) - DEFAULT_MODULE += crypto_aes_128 -endif - ifneq (,$(filter sys_bus_%,$(USEMODULE))) USEMODULE += sys_bus USEMODULE += core_msg_bus @@ -64,7 +60,7 @@ endif ifneq (,$(filter ieee802154_security,$(USEMODULE))) USEMODULE += crypto - USEMODULE += crypto_aes_128 + USEMODULE += crypto_aes USEMODULE += cipher_modes endif @@ -76,6 +72,13 @@ ifneq (,$(filter trace,$(USEMODULE))) USEMODULE += xtimer endif +ifneq (,$(filter shell_commands,$(USEMODULE))) + ifneq (,$(filter dfplayer,$(USEMODULE))) + USEMODULE += auto_init_multimedia + USEMODULE += fmt + endif +endif + ifneq (,$(filter ssp,$(USEMODULE))) FEATURES_REQUIRED += ssp endif @@ -84,6 +87,10 @@ ifneq (,$(filter base64url,$(USEMODULE))) USEMODULE += base64 endif +ifneq (,$(filter auto_init_gnrc_netif,$(USEMODULE))) + USEMODULE += gnrc_netif_init_devs +endif + ifneq (,$(filter auto_init_saul,$(USEMODULE))) USEMODULE += saul_init_devs endif @@ -103,15 +110,31 @@ ifneq (,$(filter dhcpv6_client,$(USEMODULE))) USEMODULE += xtimer endif -ifneq (,$(filter fuzzing,$(USEMODULE))) - USEMODULE += netdev_test +ifneq (,$(filter gnrc_mac,$(USEMODULE))) + USEMODULE += gnrc_priority_pktqueue + USEMODULE += csma_sender + USEMODULE += evtimer + ifneq (,$(filter gnrc_netif,$(USEMODULE))) + USEMODULE += gnrc_netif_mac + endif +endif + +ifneq (,$(filter gnrc_gomach,$(USEMODULE))) USEMODULE += gnrc_netif - USEMODULE += gnrc_pktbuf_malloc + USEMODULE += gnrc_nettype_gomach + USEMODULE += random + USEMODULE += xtimer + USEMODULE += gnrc_mac + FEATURES_REQUIRED += periph_rtt endif -# include GNRC dependencies -ifneq (,$(filter gnrc% %gnrc,$(USEMODULE))) - include $(RIOTBASE)/sys/net/gnrc/Makefile.dep +ifneq (,$(filter gnrc_lorawan,$(USEMODULE))) + USEMODULE += xtimer + USEMODULE += random + USEMODULE += hashes + USEMODULE += crypto_aes + USEMODULE += netdev_layer + USEMODULE += gnrc_nettype_lorawan endif ifneq (,$(filter sntp,$(USEMODULE))) @@ -119,6 +142,13 @@ ifneq (,$(filter sntp,$(USEMODULE))) USEMODULE += xtimer endif +ifneq (,$(filter gnrc_netdev_default,$(USEMODULE))) + # enable default network devices on the platform + USEMODULE += netdev_default + USEMODULE += netdev + USEMODULE += gnrc_netif +endif + ifneq (,$(filter netdev_ieee802154,$(USEMODULE))) USEMODULE += ieee802154 USEMODULE += random @@ -130,16 +160,79 @@ ifneq (,$(filter netdev_ieee802154_submac,$(USEMODULE))) USEMODULE += ieee802154_submac endif +ifneq (,$(filter gnrc_dhcpv6_%, $(USEMODULE))) + USEMODULE += gnrc_dhcpv6 +endif + +ifneq (,$(filter gnrc_dhcpv6_client,$(USEMODULE))) + USEMODULE += dhcpv6_client + USEMODULE += gnrc_ipv6_nib + USEMODULE += gnrc_netif + USEMODULE += gnrc_sock_udp +endif + +ifneq (,$(filter gnrc_dhcpv6_client_6lbr,$(USEMODULE))) + USEMODULE += gnrc_dhcpv6_client +endif + +ifneq (,$(filter gnrc_uhcpc,$(USEMODULE))) + DEFAULT_MODULE += auto_init_gnrc_uhcpc + USEMODULE += uhcpc + USEMODULE += gnrc_sock_udp + USEMODULE += fmt +endif + ifneq (,$(filter uhcpc,$(USEMODULE))) USEMODULE += posix_inet endif +ifneq (,$(filter gnrc_%,$(filter-out gnrc_netapi gnrc_netreg gnrc_netif% gnrc_pkt%,$(USEMODULE)))) + USEMODULE += gnrc +endif + +ifneq (,$(filter gnrc_sock_%,$(USEMODULE))) + USEMODULE += gnrc_sock + ifneq (,$(filter sock_aux_timestamp,$(USEMODULE))) + USEMODULE += gnrc_netif_timestamp + endif +endif + +ifneq (,$(filter gnrc_sock_async,$(USEMODULE))) + USEMODULE += gnrc_netapi_callbacks +endif + +ifneq (,$(filter gnrc_sock_udp,$(USEMODULE))) + USEMODULE += gnrc_udp + USEMODULE += random # to generate random ports +endif + +ifneq (,$(filter gnrc_sock,$(USEMODULE))) + USEMODULE += gnrc_netapi_mbox + USEMODULE += sock +endif + +ifneq (,$(filter gnrc_netapi_mbox,$(USEMODULE))) + USEMODULE += core_mbox +endif + ifneq (,$(filter netdev_tap,$(USEMODULE))) USEMODULE += netif USEMODULE += netdev_eth USEMODULE += iolist endif +ifneq (,$(filter gnrc_rpl_p2p,$(USEMODULE))) + USEMODULE += gnrc_rpl +endif + +ifneq (,$(filter gnrc_rpl,$(USEMODULE))) + USEMODULE += gnrc_icmpv6 + USEMODULE += gnrc_ipv6_nib + USEMODULE += trickle + USEMODULE += xtimer + USEMODULE += evtimer +endif + ifneq (,$(filter trickle,$(USEMODULE))) USEMODULE += random USEMODULE += xtimer @@ -149,7 +242,43 @@ ifneq (,$(filter eui_provider,$(USEMODULE))) USEMODULE += luid endif -ifneq (,$(filter ieee802154 nrfmin esp_now cc110x,$(USEMODULE))) +ifneq (,$(filter gnrc_netif,$(USEMODULE))) + USEMODULE += netif + USEMODULE += l2util + USEMODULE += fmt + ifneq (,$(filter netdev_ieee802154_submac,$(USEMODULE))) + USEMODULE += gnrc_netif_pktq + endif + ifneq (,$(filter netdev_ieee802154,$(USEMODULE))) + USEMODULE += gnrc_netif_ieee802154 + endif + ifneq (,$(filter netdev_eth,$(USEMODULE))) + USEMODULE += gnrc_netif_ethernet + endif + ifneq (,$(filter gnrc_lorawan,$(USEMODULE))) + USEMODULE += gnrc_netif_lorawan + endif +endif + +ifneq (,$(filter gnrc_netif_bus,$(USEMODULE))) + USEMODULE += core_msg_bus +endif + +ifneq (,$(filter gnrc_netif_events,$(USEMODULE))) + USEMODULE += core_thread_flags + USEMODULE += event +endif + +ifneq (,$(filter ieee802154 nrfmin esp_now cc110x gnrc_sixloenc,$(USEMODULE))) + ifneq (,$(filter gnrc_ipv6, $(USEMODULE))) + USEMODULE += gnrc_sixlowpan + endif + ifneq (,$(filter gnrc_ipv6_default, $(USEMODULE))) + USEMODULE += gnrc_sixlowpan_default + endif + ifneq (,$(filter gnrc_ipv6_router_default, $(USEMODULE))) + USEMODULE += gnrc_sixlowpan_router_default + endif ifneq (,$(filter lwip%, $(USEMODULE))) USEMODULE += lwip_sixlowpan endif @@ -164,6 +293,60 @@ ifneq (,$(filter ipv6_hdr,$(USEMODULE))) USEMODULE += ipv6_addr endif +ifneq (,$(filter gnrc_ipv6_nib_6lbr,$(USEMODULE))) + USEMODULE += gnrc_ipv6_nib_6lr +endif + +ifneq (,$(filter gnrc_ipv6_nib_6lr,$(USEMODULE))) + USEMODULE += gnrc_ipv6_nib_6ln + USEMODULE += gnrc_ipv6_nib_router +endif + +ifneq (,$(filter gnrc_ipv6_nib_6ln,$(USEMODULE))) + USEMODULE += gnrc_ipv6_nib + USEMODULE += gnrc_sixlowpan_nd +endif + +ifneq (,$(filter gnrc_ipv6_nib_dns,$(USEMODULE))) + USEMODULE += gnrc_ipv6_nib +endif + +ifneq (,$(filter gnrc_ipv6_nib_router,$(USEMODULE))) + USEMODULE += gnrc_ipv6_nib +endif + +ifneq (,$(filter gnrc_ipv6_nib,$(USEMODULE))) + DEFAULT_MODULE += auto_init_gnrc_ipv6_nib + USEMODULE += evtimer + USEMODULE += gnrc_ndp + USEMODULE += gnrc_netif + USEMODULE += gnrc_netif_ipv6 + USEMODULE += ipv6_addr + USEMODULE += random +endif + +ifneq (,$(filter gnrc_udp,$(USEMODULE))) + DEFAULT_MODULE += auto_init_gnrc_udp + USEMODULE += gnrc_nettype_udp + USEMODULE += inet_csum + USEMODULE += udp +endif + +ifneq (,$(filter gnrc_tcp,$(USEMODULE))) + DEFAULT_MODULE += auto_init_gnrc_tcp + USEMODULE += gnrc_nettype_tcp + USEMODULE += inet_csum + USEMODULE += random + USEMODULE += tcp + USEMODULE += evtimer_mbox +endif + +ifneq (,$(filter gnrc_pktdump,$(USEMODULE))) + DEFAULT_MODULE += auto_init_gnrc_pktdump + USEMODULE += gnrc_pktbuf + USEMODULE += od +endif + ifneq (,$(filter ieee802154_submac,$(USEMODULE))) USEMODULE += xtimer endif @@ -238,21 +421,14 @@ ifneq (,$(filter isrpipe_read_timeout,$(USEMODULE))) endif ifneq (,$(filter shell_commands,$(USEMODULE))) - ifneq (,$(filter dfplayer,$(USEMODULE))) - USEMODULE += auto_init_multimedia - USEMODULE += fmt - endif - ifneq (,$(filter fib,$(USEMODULE))) USEMODULE += posix_inet endif - ifneq (,$(filter nimble_netif,$(USEMODULE))) USEMODULE += nimble_scanner USEMODULE += nimble_scanlist USEMODULE += fmt endif - ifneq (,$(filter openwsn_%,$(USEMODULE))) USEMODULE += netif USEMODULE += ipv6_addr @@ -278,6 +454,10 @@ ifneq (,$(filter posix_inet,$(USEMODULE))) USEMODULE += posix_headers endif +ifneq (,$(filter sema,$(USEMODULE))) + USEMODULE += xtimer +endif + ifneq (,$(filter sema_inv,$(USEMODULE))) USEMODULE += atomic_utils endif @@ -304,6 +484,52 @@ ifneq (,$(filter cpp11-compat,$(USEMODULE))) FEATURES_REQUIRED += libstdcpp endif +ifneq (,$(filter fuzzing,$(USEMODULE))) + USEMODULE += netdev_test + USEMODULE += gnrc_netif + USEMODULE += gnrc_pktbuf_malloc +endif + +ifneq (,$(filter gnrc,$(USEMODULE))) + USEMODULE += gnrc_netapi + USEMODULE += gnrc_netreg + USEMODULE += gnrc_netif + USEMODULE += gnrc_netif_hdr + USEMODULE += gnrc_pktbuf + ifneq (,$(filter sock_async, $(USEMODULE))) + USEMODULE += gnrc_sock_async + endif + ifneq (,$(filter sock_ip, $(USEMODULE))) + USEMODULE += gnrc_sock_ip + endif + ifneq (,$(filter sock_udp, $(USEMODULE))) + USEMODULE += gnrc_sock_udp + endif +endif + +ifneq (,$(filter gnrc_pktbuf, $(USEMODULE))) + ifeq (,$(filter gnrc_pktbuf_%, $(USEMODULE))) + USEMODULE += gnrc_pktbuf_static + endif + ifeq (gnrc_pktbuf_cmd,$(filter gnrc_pktbuf_%, $(USEMODULE))) + USEMODULE += gnrc_pktbuf_static + endif + DEFAULT_MODULE += auto_init_gnrc_pktbuf + USEMODULE += gnrc_pkt +endif + +ifneq (,$(filter gnrc_pktbuf_%, $(USEMODULE))) + USEMODULE += gnrc_pktbuf # make MODULE_GNRC_PKTBUF macro available for all implementations +endif + +ifneq (,$(filter gnrc_netif_%,$(USEMODULE))) + USEMODULE += gnrc_netif +endif + +ifneq (,$(filter gnrc_netif_pktq,$(USEMODULE))) + USEMODULE += xtimer +endif + ifneq (,$(filter netstats_%, $(USEMODULE))) USEMODULE += netstats endif @@ -313,6 +539,13 @@ ifneq (,$(filter netstats_neighbor_%, $(USEMODULE))) USEMODULE += xtimer endif +ifneq (,$(filter gnrc_lwmac,$(USEMODULE))) + USEMODULE += gnrc_netif + USEMODULE += gnrc_nettype_lwmac + USEMODULE += gnrc_mac + FEATURES_REQUIRED += periph_rtt +endif + ifneq (,$(filter pthread,$(USEMODULE))) USEMODULE += xtimer USEMODULE += timex @@ -450,6 +683,9 @@ ifneq (,$(filter sock_async_event,$(USEMODULE))) endif ifneq (,$(filter sock_async,$(USEMODULE))) + ifneq (,$(filter gnrc%,$(USEMODULE))) + USEMODULE += gnrc_sock_async + endif ifneq (,$(filter openwsn%,$(USEMODULE))) USEMODULE += openwsn_sock_async endif @@ -493,9 +729,12 @@ ifneq (,$(filter gcoap,$(USEMODULE))) USEMODULE += sock_util USEMODULE += event_callback USEMODULE += event_timeout - ifneq (,$(filter openwsn%,$(USEMODULE))) - USEMODULE += openwsn_sock_udp - endif +ifneq (,$(filter gnrc%,$(USEMODULE))) + USEMODULE += gnrc_sock_async +endif +ifneq (,$(filter openwsn%,$(USEMODULE))) + USEMODULE += openwsn_sock_udp +endif endif ifneq (,$(filter luid,$(USEMODULE))) diff --git a/sys/include/net/gnrc/sixlowpan/config.h b/sys/include/net/gnrc/sixlowpan/config.h index 343d17bb6c759..f13cf10e4ef13 100644 --- a/sys/include/net/gnrc/sixlowpan/config.h +++ b/sys/include/net/gnrc/sixlowpan/config.h @@ -301,6 +301,84 @@ extern "C" { #ifndef CONFIG_GNRC_SIXLOWPAN_SFR_DG_RETRIES #define CONFIG_GNRC_SIXLOWPAN_SFR_DG_RETRIES 0U #endif + +/** + * @brief The denominator for the factor for when to mark ECN on `netif` input + * queue state + * + * When `gnrc_sixlowpan_frag_sfr_ecn_if_in` is compiled in, nodes will set + * the ECN bit of an RFRAG header when the input queue of the outgoing `netif` + * is filled by + * @ref CONFIG_GNRC_SIXLOWPAN_SFR_ECN_IF_IN_NUM / @ref CONFIG_GNRC_SIXLOWPAN_SFR_ECN_IF_IN_DEN + */ +#ifndef CONFIG_GNRC_SIXLOWPAN_SFR_ECN_IF_IN_NUM +#define CONFIG_GNRC_SIXLOWPAN_SFR_ECN_IF_IN_NUM 1U +#endif + +/** + * @brief The denominator for the factor for when to mark ECN on `netif` input + * queue state + * + * When `gnrc_sixlowpan_frag_sfr_ecn_if_in` is compiled in, nodes will set the + * ECN bit of an RFRAG header when the input queue of the outgoing `netif` is + * filled by + * @ref CONFIG_GNRC_SIXLOWPAN_SFR_ECN_IF_IN_NUM / @ref CONFIG_GNRC_SIXLOWPAN_SFR_ECN_IF_IN_DEN + */ +#ifndef CONFIG_GNRC_SIXLOWPAN_SFR_ECN_IF_IN_DEN +#define CONFIG_GNRC_SIXLOWPAN_SFR_ECN_IF_IN_DEN 2U +#endif + +/** + * @brief The denominator for the factor for when to mark ECN on `netif` + * output queue state + * + * When `gnrc_sixlowpan_frag_sfr_ecn_if_out` is compiled in, nodes will set + * the ECN bit of an RFRAG header when the output queue of the outgoing `netif` + * is filled by + * @ref CONFIG_GNRC_SIXLOWPAN_SFR_ECN_IF_OUT_NUM / @ref CONFIG_GNRC_SIXLOWPAN_SFR_ECN_IF_OUT_DEN + */ +#ifndef CONFIG_GNRC_SIXLOWPAN_SFR_ECN_IF_OUT_NUM +#define CONFIG_GNRC_SIXLOWPAN_SFR_ECN_IF_OUT_NUM 1U +#endif + +/** + * @brief The denominator for the factor for when to mark ECN on `netif` + * output queue state + * + * When `gnrc_sixlowpan_frag_sfr_ecn_if_out` is compiled in, nodes will set the + * ECN bit of an RFRAG header when the output queue of the outgoing `netif` is + * filled by + * @ref CONFIG_GNRC_SIXLOWPAN_SFR_ECN_IF_OUT_NUM / @ref CONFIG_GNRC_SIXLOWPAN_SFR_ECN_IF_OUT_DEN + */ +#ifndef CONFIG_GNRC_SIXLOWPAN_SFR_ECN_IF_OUT_DEN +#define CONFIG_GNRC_SIXLOWPAN_SFR_ECN_IF_OUT_DEN 2U +#endif + +/** + * @brief The numerator for the factor for when to mark ECN on frame queue + * state + * + * When `gnrc_sixlowpan_frag_sfr_ecn_fqueue` is compiled in, nodes will set the + * ECN bit of an RFRAG header when the input queue of the outgoing `netif` is + * filled by + * @ref CONFIG_GNRC_SIXLOWPAN_SFR_ECN_FQUEUE_NUM / @ref CONFIG_GNRC_SIXLOWPAN_SFR_ECN_FQUEUE_DEN + */ +#ifndef CONFIG_GNRC_SIXLOWPAN_SFR_ECN_FQUEUE_NUM +#define CONFIG_GNRC_SIXLOWPAN_SFR_ECN_FQUEUE_NUM 1U +#endif + +/** + * @brief The denominator for the factor for when to mark ECN on frame queue + * state + * + * When `gnrc_sixlowpan_frag_sfr_ecn_fqueue` is compiled in, nodes will set the + * ECN bit of an RFRAG header when the input queue of the outgoing `netif` is + * filled by + * @ref CONFIG_GNRC_SIXLOWPAN_SFR_ECN_FQUEUE_NUM / @ref CONFIG_GNRC_SIXLOWPAN_SFR_ECN_FQUEUE_DEN + */ +#ifndef CONFIG_GNRC_SIXLOWPAN_SFR_ECN_FQUEUE_DEN +#define CONFIG_GNRC_SIXLOWPAN_SFR_ECN_FQUEUE_DEN 2U +#endif /** @} */ /** diff --git a/sys/net/gnrc/Makefile.dep b/sys/net/gnrc/Makefile.dep index 8d76b02003445..5d4db165ca86c 100644 --- a/sys/net/gnrc/Makefile.dep +++ b/sys/net/gnrc/Makefile.dep @@ -202,6 +202,18 @@ ifneq (,$(filter gnrc_sixlowpan_frag_sfr,$(USEMODULE))) endif endif +ifneq (,$(filter gnrc_sixlowpan_frag_sfr_ecn_%,$(USEMODULE))) + USEMODULE += gnrc_sixlowpan_frag_sfr_ecn +endif + +ifneq (,$(filter gnrc_sixlowpan_frag_sfr_ecn_if_out,$(USEMODULE))) + USEMODULE += gnrc_netif_pktq +endif + +ifneq (,$(filter gnrc_sixlowpan_frag_sfr_ecn,$(USEMODULE))) + USEMODULE += gnrc_sixlowpan_frag_sfr +endif + ifneq (,$(filter gnrc_sixlowpan_frag_sfr_stats,$(USEMODULE))) USEMODULE += gnrc_sixlowpan_frag_sfr endif diff --git a/sys/net/gnrc/network_layer/sixlowpan/frag/sfr/Kconfig b/sys/net/gnrc/network_layer/sixlowpan/frag/sfr/Kconfig index 3db6a9e11a205..a7a9ef739772f 100644 --- a/sys/net/gnrc/network_layer/sixlowpan/frag/sfr/Kconfig +++ b/sys/net/gnrc/network_layer/sixlowpan/frag/sfr/Kconfig @@ -98,4 +98,54 @@ config GNRC_SIXLOWPAN_SFR_DG_RETRIES int "The maximum number of retries from scratch for a particular datagram (MaxDatagramRetries)" default 0 +menuconfig KCONFIG_USEMODULE_GNRC_SIXLOWPAN_FRAG_SFR_ECN_NETIF + bool "Configure SFR ECN based on netif queue" + depends on USEMODULE_GNRC_SIXLOWPAN_FRAG_SFR_ECN_NETIF + +if KCONFIG_USEMODULE_GNRC_SIXLOWPAN_FRAG_SFR_ECN_NETIF +config GNRC_SIXLOWPAN_SFR_ECN_NETIF_NUM + int "The numerator for the factor for when to mark ECN on `netif` queue state" + default 1 + help + When `gnrc_sixlowpan_frag_sfr_ecn_netif` is compiled in, nodes will set + the ECN bit of an RFRAG header when the input queue of the outgoing + `netif` is filled by + @ref CONFIG_GNRC_SIXLOWPAN_SFR_ECN_NETIF_NUM / @ref CONFIG_GNRC_SIXLOWPAN_SFR_ECN_NETIF_DEN + + +config GNRC_SIXLOWPAN_SFR_ECN_NETIF_DEN + int "The denominator for the factor for when to mark ECN on `netif` queue state" + default 2 + help + When `gnrc_sixlowpan_frag_sfr_ecn_netif` is compiled in, nodes will set + the ECN bit of an RFRAG header when the input queue of the outgoing + `netif` is filled by + @ref CONFIG_GNRC_SIXLOWPAN_SFR_ECN_NETIF_NUM / @ref CONFIG_GNRC_SIXLOWPAN_SFR_ECN_NETIF_DEN +endif + +menuconfig KCONFIG_USEMODULE_GNRC_SIXLOWPAN_FRAG_SFR_ECN_FQUEUE + bool "Configure SFR ECN based on SFR's frame queue" + depends on USEMODULE_GNRC_SIXLOWPAN_FRAG_SFR_ECN_FQUEUE + +if KCONFIG_USEMODULE_GNRC_SIXLOWPAN_FRAG_SFR_ECN_FQUEUE +config GNRC_SIXLOWPAN_SFR_ECN_FQUEUE_NUM + int "The numerator for the factor for when to mark ECN on frame queue state" + default 1 + help + When `gnrc_sixlowpan_frag_sfr_ecn_fqueue` is compiled in, nodes will set + the ECN bit of an RFRAG header when the input queue of the outgoing + `netif` is filled by + @ref CONFIG_GNRC_SIXLOWPAN_SFR_ECN_FQUEUE_NUM / @ref CONFIG_GNRC_SIXLOWPAN_SFR_ECN_FQUEUE_DEN + + +config GNRC_SIXLOWPAN_SFR_ECN_FQUEUE_DEN + int "The denominator for the factor for when to mark ECN on frame queue state" + default 2 + help + When `gnrc_sixlowpan_frag_sfr_ecn_fqueue` is compiled in, nodes will set + the ECN bit of an RFRAG header when the input queue of the outgoing + `netif` is filled by + @ref CONFIG_GNRC_SIXLOWPAN_SFR_ECN_FQUEUE_NUM / @ref CONFIG_GNRC_SIXLOWPAN_SFR_ECN_FQUEUE_DEN +endif + endif diff --git a/sys/net/gnrc/network_layer/sixlowpan/frag/sfr/gnrc_sixlowpan_frag_sfr.c b/sys/net/gnrc/network_layer/sixlowpan/frag/sfr/gnrc_sixlowpan_frag_sfr.c index 8058a5b545c62..7b4a8e9476025 100644 --- a/sys/net/gnrc/network_layer/sixlowpan/frag/sfr/gnrc_sixlowpan_frag_sfr.c +++ b/sys/net/gnrc/network_layer/sixlowpan/frag/sfr/gnrc_sixlowpan_frag_sfr.c @@ -23,6 +23,7 @@ #endif #include "net/gnrc/neterr.h" #include "net/gnrc/netif/internal.h" +#include "net/gnrc/netif/pktq.h" #include "net/gnrc/pkt.h" #include "net/gnrc/sixlowpan.h" #include "net/gnrc/sixlowpan/config.h" @@ -741,8 +742,50 @@ static uint16_t _find_offset_and_copy_rest(uint8_t *data, gnrc_pktsnip_t **pkt, static bool _send_frame(gnrc_pktsnip_t *frame, void *ctx, unsigned page) { - uint32_t now = xtimer_now_usec(); + uint32_t now; + uint32_t if_gap; + + if (IS_USED(MODULE_GNRC_SIXLOWPAN_FRAG_SFR_ECN) && + (sixlowpan_sfr_rfrag_is(frame->next->data))) { + int queue_state = 0; + int queue_size = 0; + + if (IS_USED(MODULE_GNRC_SIXLOWPAN_FRAG_SFR_ECN_IF_IN)) { + gnrc_netif_t *netif = gnrc_netif_hdr_get_netif(frame->data); + + assert(frame->type == GNRC_NETTYPE_NETIF); + assert(frame->next->type == GNRC_NETTYPE_SIXLOWPAN); + queue_state = msg_avail_thread(netif->pid); + queue_size = msg_queue_capacity(netif->pid); + assert(queue_size > 0); + + if ((queue_state * CONFIG_GNRC_SIXLOWPAN_SFR_ECN_IF_IN_DEN) > + (queue_size * CONFIG_GNRC_SIXLOWPAN_SFR_ECN_IF_IN_NUM)) { + sixlowpan_sfr_set_ecn(frame->next->data); + } + } + if (IS_USED(MODULE_GNRC_SIXLOWPAN_FRAG_SFR_ECN_IF_OUT)) { + queue_state = gnrc_netif_pktq_usage(); + queue_size = CONFIG_GNRC_NETIF_PKTQ_POOL_SIZE; + + if ((queue_state * CONFIG_GNRC_SIXLOWPAN_SFR_ECN_IF_OUT_DEN) > + (queue_size * CONFIG_GNRC_SIXLOWPAN_SFR_ECN_IF_OUT_NUM)) { + sixlowpan_sfr_set_ecn(frame->next->data); + } + } + + if (IS_USED(MODULE_GNRC_SIXLOWPAN_FRAG_SFR_ECN_FQUEUE)) { + queue_state = clist_count(&_frame_queue); + queue_size = FRAME_QUEUE_POOL_SIZE; + + if ((queue_state * CONFIG_GNRC_SIXLOWPAN_SFR_ECN_FQUEUE_DEN) > + (queue_size * CONFIG_GNRC_SIXLOWPAN_SFR_ECN_FQUEUE_NUM)) { + sixlowpan_sfr_set_ecn(frame->next->data); + } + } + } + now = xtimer_now_usec(); if ((CONFIG_GNRC_SIXLOWPAN_SFR_INTER_FRAME_GAP_US == 0) || ((now - _last_frame_sent) > CONFIG_GNRC_SIXLOWPAN_SFR_INTER_FRAME_GAP_US)) { DEBUG("6lo sfr: dispatch frame to network interface\n");