module_param(tcp_friendliness, int, 0644);
MODULE_PARM_DESC(tcp_friendliness, "turn on/off tcp friendliness");
-#include <asm/div64.h>
-
/* BIC TCP Parameters */
struct bictcp {
u32 cnt; /* increase cwnd by 1 after ACKs */
tcp_sk(sk)->snd_ssthresh = initial_ssthresh;
}
-/* 64bit divisor, dividend and result. dynamic precision */
-static inline u_int64_t div64_64(u_int64_t dividend, u_int64_t divisor)
-{
- u_int32_t d = divisor;
-
- if (divisor > 0xffffffffULL) {
- unsigned int shift = fls(divisor >> 32);
-
- d = divisor >> shift;
- dividend >>= shift;
- }
-
- /* avoid 64 bit division if possible */
- if (dividend >> 32)
- do_div(dividend, d);
- else
- dividend = (uint32_t) dividend / d;
-
- return dividend;
-}
-
/*
* calculate the cubic root of x using Newton-Raphson
*/
static u32 cubic_root(u64 a)
{
- u32 x, x1;
+ u32 x;
/* Initial estimate is based on:
* cbrt(x) = exp(log(x) / 3)
*/
x = 1u << (fls64(a)/3);
- /*
- * Iteration based on:
- * 2
- * x = ( 2 * x + a / x ) / 3
- * k+1 k k
- */
- do {
- x1 = x;
- x = (2 * x + (uint32_t) div64_64(a, x*x)) / 3;
- } while (abs(x1 - x) > 1);
+ /* converges to 32 bits in 3 iterations */
+ x = (2 * x + (u32)div64_64(a, (u64)x*(u64)x)) / 3;
+ x = (2 * x + (u32)div64_64(a, (u64)x*(u64)x)) / 3;
+ x = (2 * x + (u32)div64_64(a, (u64)x*(u64)x)) / 3;
return x;
}