diff options
Diffstat (limited to 'net/dccp/ccids/lib/tfrc_equation.c')
-rw-r--r-- | net/dccp/ccids/lib/tfrc_equation.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/net/dccp/ccids/lib/tfrc_equation.c b/net/dccp/ccids/lib/tfrc_equation.c index 2f20a29cffe4..bc3dc2b2a849 100644 --- a/net/dccp/ccids/lib/tfrc_equation.c +++ b/net/dccp/ccids/lib/tfrc_equation.c | |||
@@ -658,7 +658,6 @@ u32 tfrc_calc_x(u16 s, u32 R, u32 p) | |||
658 | result = scaled_div(s, R); | 658 | result = scaled_div(s, R); |
659 | return scaled_div32(result, f); | 659 | return scaled_div32(result, f); |
660 | } | 660 | } |
661 | |||
662 | EXPORT_SYMBOL_GPL(tfrc_calc_x); | 661 | EXPORT_SYMBOL_GPL(tfrc_calc_x); |
663 | 662 | ||
664 | /** | 663 | /** |
@@ -693,5 +692,19 @@ u32 tfrc_calc_x_reverse_lookup(u32 fvalue) | |||
693 | index = tfrc_binsearch(fvalue, 0); | 692 | index = tfrc_binsearch(fvalue, 0); |
694 | return (index + 1) * 1000000 / TFRC_CALC_X_ARRSIZE; | 693 | return (index + 1) * 1000000 / TFRC_CALC_X_ARRSIZE; |
695 | } | 694 | } |
696 | |||
697 | EXPORT_SYMBOL_GPL(tfrc_calc_x_reverse_lookup); | 695 | EXPORT_SYMBOL_GPL(tfrc_calc_x_reverse_lookup); |
696 | |||
697 | /** | ||
698 | * tfrc_invert_loss_event_rate - Compute p so that 10^6 corresponds to 100% | ||
699 | * When @loss_event_rate is large, there is a chance that p is truncated to 0. | ||
700 | * To avoid re-entering slow-start in that case, we set p = TFRC_SMALLEST_P > 0. | ||
701 | */ | ||
702 | u32 tfrc_invert_loss_event_rate(u32 loss_event_rate) | ||
703 | { | ||
704 | if (loss_event_rate == UINT_MAX) /* see RFC 4342, 8.5 */ | ||
705 | return 0; | ||
706 | if (unlikely(loss_event_rate == 0)) /* map 1/0 into 100% */ | ||
707 | return 1000000; | ||
708 | return max_t(u32, scaled_div(1, loss_event_rate), TFRC_SMALLEST_P); | ||
709 | } | ||
710 | EXPORT_SYMBOL_GPL(tfrc_invert_loss_event_rate); | ||