Merge branch 'tj-percpu' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/misc...
[safe/jmp/linux-2.6] / net / ipv4 / tcp_hybla.c
index 13a6634..c209e05 100644 (file)
@@ -10,7 +10,6 @@
  *    root at danielinux.net
  */
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <net/tcp.h>
 
@@ -33,19 +32,20 @@ MODULE_PARM_DESC(rtt0, "reference rout trip time (ms)");
 
 
 /* This is called to refresh values for hybla parameters */
-static inline void hybla_recalc_param (struct tcp_sock *tp)
+static inline void hybla_recalc_param (struct sock *sk)
 {
-       struct hybla *ca = tcp_ca(tp);
+       struct hybla *ca = inet_csk_ca(sk);
 
-       ca->rho_3ls = max_t(u32, tp->srtt / msecs_to_jiffies(rtt0), 8);
+       ca->rho_3ls = max_t(u32, tcp_sk(sk)->srtt / msecs_to_jiffies(rtt0), 8);
        ca->rho = ca->rho_3ls >> 3;
        ca->rho2_7ls = (ca->rho_3ls * ca->rho_3ls) << 1;
        ca->rho2 = ca->rho2_7ls >>7;
 }
 
-static void hybla_init(struct tcp_sock *tp)
+static void hybla_init(struct sock *sk)
 {
-       struct hybla *ca = tcp_ca(tp);
+       struct tcp_sock *tp = tcp_sk(sk);
+       struct hybla *ca = inet_csk_ca(sk);
 
        ca->rho = 0;
        ca->rho2 = 0;
@@ -57,17 +57,16 @@ static void hybla_init(struct tcp_sock *tp)
        tp->snd_cwnd_clamp = 65535;
 
        /* 1st Rho measurement based on initial srtt */
-       hybla_recalc_param(tp);
+       hybla_recalc_param(sk);
 
        /* set minimum rtt as this is the 1st ever seen */
        ca->minrtt = tp->srtt;
        tp->snd_cwnd = ca->rho;
 }
 
-static void hybla_state(struct tcp_sock *tp, u8 ca_state)
+static void hybla_state(struct sock *sk, u8 ca_state)
 {
-       struct hybla *ca = tcp_ca(tp);
-
+       struct hybla *ca = inet_csk_ca(sk);
        ca->hybla_en = (ca_state == TCP_CA_Open);
 }
 
@@ -86,27 +85,29 @@ static inline u32 hybla_fraction(u32 odds)
  *     o Give cwnd a new value based on the model proposed
  *     o remember increments <1
  */
-static void hybla_cong_avoid(struct tcp_sock *tp, u32 ack, u32 rtt,
-                           u32 in_flight, int flag)
+static void hybla_cong_avoid(struct sock *sk, u32 ack, u32 in_flight)
 {
-       struct hybla *ca = tcp_ca(tp);
+       struct tcp_sock *tp = tcp_sk(sk);
+       struct hybla *ca = inet_csk_ca(sk);
        u32 increment, odd, rho_fractions;
        int is_slowstart = 0;
 
        /*  Recalculate rho only if this srtt is the lowest */
        if (tp->srtt < ca->minrtt){
-               hybla_recalc_param(tp);
+               hybla_recalc_param(sk);
                ca->minrtt = tp->srtt;
        }
 
-       if (!ca->hybla_en)
-               return tcp_reno_cong_avoid(tp, ack, rtt, in_flight, flag);
+       if (!tcp_is_cwnd_limited(sk, in_flight))
+               return;
 
-       if (in_flight < tp->snd_cwnd)
+       if (!ca->hybla_en) {
+               tcp_reno_cong_avoid(sk, ack, in_flight);
                return;
+       }
 
        if (ca->rho == 0)
-               hybla_recalc_param(tp);
+               hybla_recalc_param(sk);
 
        rho_fractions = ca->rho_3ls - (ca->rho << 3);
 
@@ -144,12 +145,16 @@ static void hybla_cong_avoid(struct tcp_sock *tp, u32 ack, u32 rtt,
        ca->snd_cwnd_cents += odd;
 
        /* check when fractions goes >=128 and increase cwnd by 1. */
-       while(ca->snd_cwnd_cents >= 128) {
+       while (ca->snd_cwnd_cents >= 128) {
                tp->snd_cwnd++;
                ca->snd_cwnd_cents -= 128;
                tp->snd_cwnd_cnt = 0;
        }
-
+       /* check when cwnd has not been incremented for a while */
+       if (increment == 0 && odd == 0 && tp->snd_cwnd_cnt >= tp->snd_cwnd) {
+               tp->snd_cwnd++;
+               tp->snd_cwnd_cnt = 0;
+       }
        /* clamp down slowstart cwnd to ssthresh value. */
        if (is_slowstart)
                tp->snd_cwnd = min(tp->snd_cwnd, tp->snd_ssthresh);
@@ -170,7 +175,7 @@ static struct tcp_congestion_ops tcp_hybla = {
 
 static int __init hybla_register(void)
 {
-       BUG_ON(sizeof(struct hybla) > TCP_CA_PRIV_SIZE);
+       BUILD_BUG_ON(sizeof(struct hybla) > ICSK_CA_PRIV_SIZE);
        return tcp_register_congestion_control(&tcp_hybla);
 }