-static inline u32 bictcp_K(u32 dist, u32 srtt)
-{
- u64 d64;
- u32 d32;
- u32 count;
- u32 result;
-
- /* calculate the "K" for (wmax-cwnd) = c/rtt * K^3
- so K = cubic_root( (wmax-cwnd)*rtt/c )
- the unit of K is bictcp_HZ=2^10, not HZ
-
- c = bic_scale >> 10
- rtt = (tp->srtt >> 3 ) / HZ
-
- the following code has been designed and tested for
- cwnd < 1 million packets
- RTT < 100 seconds
- HZ < 1,000,00 (corresponding to 10 nano-second)
-
- */
-
- /* 1/c * 2^2*bictcp_HZ */
- d32 = (1 << (10+2*BICTCP_HZ)) / bic_scale;
- d64 = (__u64)d32;
-
- /* srtt * 2^count / HZ
- 1) to get a better accuracy of the following d32,
- the larger the "count", the better the accuracy
- 2) and avoid overflow of the following d64
- the larger the "count", the high possibility of overflow
- 3) so find a "count" between bictcp_hz-3 and bictcp_hz
- "count" may be less than bictcp_HZ,
- then d64 becomes 0. that is OK
- */
- d32 = srtt;
- count = 0;
- while (((d32 & 0x80000000)==0) && (count < BICTCP_HZ)){
- d32 = d32 << 1;
- count++;
- }
- d32 = d32 / HZ;
-
- /* (wmax-cwnd) * (srtt>>3 / HZ) / c * 2^(3*bictcp_HZ) */
- d64 = (d64 * dist * d32) >> (count+3-BICTCP_HZ);
-
- /* cubic root */
- d64 = cubic_root(d64);
-
- result = (u32)d64;
- return result;
-}
-