Merge branch 'master' of /home/trondmy/kernel/linux-2.6/
[powerpc.git] / net / ipv4 / tcp_cubic.c
index a60ef38..9a582fb 100644 (file)
                                          */
 #define        BICTCP_HZ               10      /* BIC HZ 2^10 = 1024 */
 
-static int fast_convergence = 1;
-static int max_increment = 16;
-static int beta = 819;         /* = 819/1024 (BICTCP_BETA_SCALE) */
-static int initial_ssthresh = 100;
-static int bic_scale = 41;
-static int tcp_friendliness = 1;
+static int fast_convergence __read_mostly = 1;
+static int max_increment __read_mostly = 16;
+static int beta __read_mostly = 819;   /* = 819/1024 (BICTCP_BETA_SCALE) */
+static int initial_ssthresh __read_mostly = 100;
+static int bic_scale __read_mostly = 41;
+static int tcp_friendliness __read_mostly = 1;
 
-static u32 cube_rtt_scale;
-static u32 beta_scale;
-static u64 cube_factor;
+static u32 cube_rtt_scale __read_mostly;
+static u32 beta_scale __read_mostly;
+static u64 cube_factor __read_mostly;
 
 /* Note parameters that are used for precomputing scale factors are read-only */
 module_param(fast_convergence, int, 0644);
@@ -175,42 +175,42 @@ static inline void bictcp_update(struct bictcp *ca, u32 cwnd)
                }
        }
 
-        /* cubic function - calc*/
-        /* calculate c * time^3 / rtt,
-         *  while considering overflow in calculation of time^3
+       /* cubic function - calc*/
+       /* calculate c * time^3 / rtt,
+        *  while considering overflow in calculation of time^3
         * (so time^3 is done by using 64 bit)
         * and without the support of division of 64bit numbers
         * (so all divisions are done by using 32 bit)
-         *  also NOTE the unit of those veriables
-         *       time  = (t - K) / 2^bictcp_HZ
-         *       c = bic_scale >> 10
+        *  also NOTE the unit of those veriables
+               time  = (t - K) / 2^bictcp_HZ
+               c = bic_scale >> 10
         * rtt  = (srtt >> 3) / HZ
         * !!! The following code does not have overflow problems,
         * if the cwnd < 1 million packets !!!
-         */
+        */
 
        /* change the unit from HZ to bictcp_HZ */
-        t = ((tcp_time_stamp + ca->delay_min - ca->epoch_start)
+       t = ((tcp_time_stamp + (ca->delay_min>>3) - ca->epoch_start)
             << BICTCP_HZ) / HZ;
 
-        if (t < ca->bic_K)             /* t - K */
+       if (t < ca->bic_K)              /* t - K */
                offs = ca->bic_K - t;
-        else
-                offs = t - ca->bic_K;
+       else
+               offs = t - ca->bic_K;
 
        /* c/rtt * (t-K)^3 */
        delta = (cube_rtt_scale * offs * offs * offs) >> (10+3*BICTCP_HZ);
-        if (t < ca->bic_K)                                     /* below origin*/
-                bic_target = ca->bic_origin_point - delta;
-        else                                                   /* above origin*/
-                bic_target = ca->bic_origin_point + delta;
+       if (t < ca->bic_K)                                      /* below origin*/
+               bic_target = ca->bic_origin_point - delta;
+       else                                                    /* above origin*/
+               bic_target = ca->bic_origin_point + delta;
 
-        /* cubic function - calc bictcp_cnt*/
-        if (bic_target > cwnd) {
+       /* cubic function - calc bictcp_cnt*/
+       if (bic_target > cwnd) {
                ca->cnt = cwnd / (bic_target - cwnd);
-        } else {
-                ca->cnt = 100 * cwnd;              /* very small increment*/
-        }
+       } else {
+               ca->cnt = 100 * cwnd;              /* very small increment*/
+       }
 
        if (ca->delay_min > 0) {
                /* max increment = Smax * rtt / 0.1  */
@@ -219,7 +219,7 @@ static inline void bictcp_update(struct bictcp *ca, u32 cwnd)
                        ca->cnt = min_cnt;
        }
 
-        /* slow start and low utilization  */
+       /* slow start and low utilization  */
        if (ca->loss_cwnd == 0)         /* could be aggressive in slow start */
                ca->cnt = 50;
 
@@ -227,9 +227,9 @@ static inline void bictcp_update(struct bictcp *ca, u32 cwnd)
        if (tcp_friendliness) {
                u32 scale = beta_scale;
                delta = (cwnd * scale) >> 3;
-               while (ca->ack_cnt > delta) {           /* update tcp cwnd */
-                       ca->ack_cnt -= delta;
-                       ca->tcp_cwnd++;
+               while (ca->ack_cnt > delta) {           /* update tcp cwnd */
+                       ca->ack_cnt -= delta;
+                       ca->tcp_cwnd++;
                }
 
                if (ca->tcp_cwnd > cwnd){       /* if bic is slower than tcp */
@@ -238,7 +238,7 @@ static inline void bictcp_update(struct bictcp *ca, u32 cwnd)
                        if (ca->cnt > max_cnt)
                                ca->cnt = max_cnt;
                }
-        }
+       }
 
        ca->cnt = (ca->cnt << ACK_RATIO_SHIFT) / ca->delayed_ack;
        if (ca->cnt == 0)                       /* cannot be zero */
@@ -259,7 +259,7 @@ static inline void measure_delay(struct sock *sk)
            (s32)(tcp_time_stamp - ca->epoch_start) < HZ)
                return;
 
-       delay = tcp_time_stamp - tp->rx_opt.rcv_tsecr;
+       delay = (tcp_time_stamp - tp->rx_opt.rcv_tsecr)<<3;
        if (delay == 0)
                delay = 1;
 
@@ -366,7 +366,7 @@ static int __init cubictcp_register(void)
 
        beta_scale = 8*(BICTCP_BETA_SCALE+beta)/ 3 / (BICTCP_BETA_SCALE - beta);
 
-       cube_rtt_scale = (bic_scale << 3) / 10; /* 1024*c/rtt */
+       cube_rtt_scale = (bic_scale * 10);      /* 1024*c/rtt */
 
        /* calculate the "K" for (wmax-cwnd) = c/rtt * K^3
         *  so K = cubic_root( (wmax-cwnd)*rtt/c )