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 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) (limited to 'src/ipcpd/unicast/pol/ca-mb-ecn.c') 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); +} -- cgit v1.2.3