]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - net/dccp/ccids/lib/tfrc_equation.c
Merge tag 'v2.6.37' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[mv-sheeva.git] / net / dccp / ccids / lib / tfrc_equation.c
index 22ca1cf0eb5503fe6ed2db69172771f0e207b182..a052a4377e262a6f2e1af8e354cfd649f006e343 100644 (file)
@@ -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);
+}