diff options
author | David S. Miller <davem@davemloft.net> | 2010-09-21 16:00:40 -0700 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-09-21 16:00:40 -0700 |
commit | 98e684bd5c927cb94ff23fb6f1dd34dd346a19cf (patch) | |
tree | 4274d2b1d7c5314e1bb4d33197211aa8faa08687 /net/dccp/ccids/lib/tfrc_equation.c | |
parent | e254c274ae19888e5693ba6d32576ab03a8ae8a4 (diff) | |
parent | 536bb20b45dee3f9b77b0d250f8ed0733a5cb025 (diff) |
Merge branch 'dccp' of git://eden-feed.erg.abdn.ac.uk/net-next-2.6
Diffstat (limited to 'net/dccp/ccids/lib/tfrc_equation.c')
-rw-r--r-- | net/dccp/ccids/lib/tfrc_equation.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/net/dccp/ccids/lib/tfrc_equation.c b/net/dccp/ccids/lib/tfrc_equation.c index 22ca1cf0eb55..a052a4377e26 100644 --- a/net/dccp/ccids/lib/tfrc_equation.c +++ b/net/dccp/ccids/lib/tfrc_equation.c @@ -687,3 +687,17 @@ u32 tfrc_calc_x_reverse_lookup(u32 fvalue) index = tfrc_binsearch(fvalue, 0); return (index + 1) * 1000000 / TFRC_CALC_X_ARRSIZE; } + +/** + * tfrc_invert_loss_event_rate - Compute p so that 10^6 corresponds to 100% + * When @loss_event_rate is large, there is a chance that p is truncated to 0. + * To avoid re-entering slow-start in that case, we set p = TFRC_SMALLEST_P > 0. + */ +u32 tfrc_invert_loss_event_rate(u32 loss_event_rate) +{ + if (loss_event_rate == UINT_MAX) /* see RFC 4342, 8.5 */ + return 0; + if (unlikely(loss_event_rate == 0)) /* map 1/0 into 100% */ + return 1000000; + return max_t(u32, scaled_div(1, loss_event_rate), TFRC_SMALLEST_P); +} |