From 962b37bb28724bdf28abbe5d48350adba6000ed4 Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Sat, 5 Dec 2020 15:05:13 +0100 Subject: ipcpd: Add RIB statistics for flow allocator The RIB will now show some stats for the flow allocator, including congestion avoidance statistics. This is needed before decoupling the data transfer component and the flow allocator as some current stats show in DT will move to FA. Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- src/ipcpd/unicast/pol/ca-mb-ecn.c | 41 ++++++++++++++++++++++++++++++++++++++- src/ipcpd/unicast/pol/ca-mb-ecn.h | 4 ++++ src/ipcpd/unicast/pol/ca-nop.c | 3 ++- 3 files changed, 46 insertions(+), 2 deletions(-) (limited to 'src/ipcpd/unicast/pol') diff --git a/src/ipcpd/unicast/pol/ca-mb-ecn.c b/src/ipcpd/unicast/pol/ca-mb-ecn.c index 03f7044d..0542e291 100644 --- a/src/ipcpd/unicast/pol/ca-mb-ecn.c +++ b/src/ipcpd/unicast/pol/ca-mb-ecn.c @@ -35,6 +35,7 @@ #include #include +#include /* congestion avoidance constants */ #define CA_SHFT 5 /* Average over 32 pkts */ @@ -72,7 +73,8 @@ struct pol_ca_ops mb_ecn_ca_ops = { .ctx_update_rcv = mb_ecn_ctx_update_rcv, .ctx_update_ece = mb_ecn_ctx_update_ece, .wnd_wait = mb_ecn_wnd_wait, - .calc_ecn = mb_ecn_calc_ecn + .calc_ecn = mb_ecn_calc_ecn, + .print_stats = mb_ecn_print_stats }; void * mb_ecn_ctx_create(void) @@ -229,3 +231,40 @@ uint8_t mb_ecn_calc_ecn(int fd, return (uint8_t) (q >> ECN_Q_SHFT); } + +ssize_t mb_ecn_print_stats(void * _ctx, + char * buf, + size_t len) +{ + struct mb_ecn_ctx* ctx = _ctx; + char * regime; + + if (len < 1024) + return 0; + + if (!ctx->tx_cav) + regime = "Slow start"; + else if (ctx->tx_ece) + regime = "Multiplicative dec"; + else + regime = "Additive inc"; + + sprintf(buf, + "Congestion avoidance algorithm: %20s\n" + "Upstream congestion level: %20u\n" + "Upstream packet counter: %20zu\n" + "Downstream congestion level: %20u\n" + "Downstream packet counter: %20zu\n" + "Congestion window size (ns): %20zu\n" + "Packets in this window: %20zu\n" + "Bytes in this window: %20zu\n" + "Max bytes in this window: %20zu\n" + "Current congestion regime: %20s\n", + "Multi-bit ECN", + ctx->rx_ece, ctx->rx_ctr, + ctx->tx_ece, ctx->tx_ctr, (size_t) (1 << ctx->tx_mul), + ctx->tx_wpc, ctx->tx_wbc, ctx->tx_wbl, + regime); + + return strlen(buf); +} diff --git a/src/ipcpd/unicast/pol/ca-mb-ecn.h b/src/ipcpd/unicast/pol/ca-mb-ecn.h index 456b9b13..945b0df5 100644 --- a/src/ipcpd/unicast/pol/ca-mb-ecn.h +++ b/src/ipcpd/unicast/pol/ca-mb-ecn.h @@ -45,6 +45,10 @@ void mb_ecn_wnd_wait(ca_wnd_t wnd); uint8_t mb_ecn_calc_ecn(int fd, size_t len); +ssize_t mb_ecn_print_stats(void * ctx, + char * buf, + size_t len); + extern struct pol_ca_ops mb_ecn_ca_ops; #endif /* OUROBOROS_IPCPD_UNICAST_CA_MB_ECN_H */ diff --git a/src/ipcpd/unicast/pol/ca-nop.c b/src/ipcpd/unicast/pol/ca-nop.c index d0d89a2e..15b253ca 100644 --- a/src/ipcpd/unicast/pol/ca-nop.c +++ b/src/ipcpd/unicast/pol/ca-nop.c @@ -31,7 +31,8 @@ struct pol_ca_ops nop_ca_ops = { .ctx_update_rcv = nop_ctx_update_rcv, .ctx_update_ece = nop_ctx_update_ece, .wnd_wait = nop_wnd_wait, - .calc_ecn = nop_calc_ecn + .calc_ecn = nop_calc_ecn, + .print_stats = NULL }; void * nop_ctx_create(void) -- cgit v1.2.3