tcp: drop tcp_bound_rto, merge content of it tcp_set_rto
[safe/jmp/linux-2.6] / net / ipv4 / tcp_lp.c
index 1f977b6..ce3c41f 100644 (file)
@@ -3,13 +3,8 @@
  *
  * TCP Low Priority is a distributed algorithm whose goal is to utilize only
  *   the excess network bandwidth as compared to the ``fair share`` of
- *   bandwidth as targeted by TCP. Available from:
- *     http://www.ece.rice.edu/~akuzma/Doc/akuzma/TCP-LP.pdf
+ *   bandwidth as targeted by TCP.
  *
- * Original Author:
- *   Aleksandar Kuzmanovic <akuzma@northwestern.edu>
- *
- * See http://www-ece.rice.edu/networks/TCP-LP/ for their implementation.
  * As of 2.6.13, Linux supports pluggable congestion control algorithms.
  * Due to the limitation of the API, we take the following changes from
  * the original TCP-LP implementation:
  *   o OWD is handled in relative format, where local time stamp will in
  *     tcp_time_stamp format.
  *
- * Port from 2.4.19 to 2.6.16 as module by:
- *   Wong Hoi Sing Edison <hswong3i@gmail.com>
- *   Hung Hing Lun <hlhung3i@gmail.com>
+ * Original Author:
+ *   Aleksandar Kuzmanovic <akuzma@northwestern.edu>
+ * Available from:
+ *   http://www.ece.rice.edu/~akuzma/Doc/akuzma/TCP-LP.pdf
+ * Original implementation for 2.4.19:
+ *   http://www-ece.rice.edu/networks/TCP-LP/
  *
- * Version: $Id: tcp_lp.c,v 1.22 2006-05-02 18:18:19 hswong3i Exp $
+ * 2.6.x module Authors:
+ *   Wong Hoi Sing, Edison <hswong3i@gmail.com>
+ *   Hung Hing Lun, Mike <hlhung3i@gmail.com>
+ * SourceForge project page:
+ *   http://tcp-lp-mod.sourceforge.net/
  */
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <net/tcp.h>
 
@@ -114,13 +115,12 @@ static void tcp_lp_init(struct sock *sk)
  * Will only call newReno CA when away from inference.
  * From TCP-LP's paper, this will be handled in additive increasement.
  */
-static void tcp_lp_cong_avoid(struct sock *sk, u32 ack, u32 rtt, u32 in_flight,
-                             int flag)
+static void tcp_lp_cong_avoid(struct sock *sk, u32 ack, u32 in_flight)
 {
        struct lp *lp = inet_csk_ca(sk);
 
        if (!(lp->flag & LP_WITHIN_INF))
-               tcp_reno_cong_avoid(sk, ack, rtt, in_flight, flag);
+               tcp_reno_cong_avoid(sk, ack, in_flight);
 }
 
 /**
@@ -153,16 +153,19 @@ static u32 tcp_lp_remote_hz_estimator(struct sock *sk)
        if (m < 0)
                m = -m;
 
-       if (rhz != 0) {
+       if (rhz > 0) {
                m -= rhz >> 6;  /* m is now error in remote HZ est */
                rhz += m;       /* 63/64 old + 1/64 new */
        } else
                rhz = m << 6;
 
+ out:
        /* record time for successful remote HZ calc */
-       lp->flag |= LP_VALID_RHZ;
+       if ((rhz >> 6) > 0)
+               lp->flag |= LP_VALID_RHZ;
+       else
+               lp->flag &= ~LP_VALID_RHZ;
 
- out:
        /* record reference time stamp */
        lp->remote_ref_time = tp->rx_opt.rcv_tsval;
        lp->local_ref_time = tp->rx_opt.rcv_tsecr;
@@ -214,7 +217,7 @@ static u32 tcp_lp_owd_calculator(struct sock *sk)
  *   3. calc smoothed OWD (SOWD).
  * Most ideas come from the original TCP-LP implementation.
  */
-static void tcp_lp_rtt_sample(struct sock *sk, u32 usrtt)
+static void tcp_lp_rtt_sample(struct sock *sk, u32 rtt)
 {
        struct lp *lp = inet_csk_ca(sk);
        s64 mowd = tcp_lp_owd_calculator(sk);
@@ -257,11 +260,14 @@ static void tcp_lp_rtt_sample(struct sock *sk, u32 usrtt)
  * newReno in increase case.
  * We work it out by following the idea from TCP-LP's paper directly
  */
-static void tcp_lp_pkts_acked(struct sock *sk, u32 num_acked)
+static void tcp_lp_pkts_acked(struct sock *sk, u32 num_acked, s32 rtt_us)
 {
        struct tcp_sock *tp = tcp_sk(sk);
        struct lp *lp = inet_csk_ca(sk);
 
+       if (rtt_us > 0)
+               tcp_lp_rtt_sample(sk, rtt_us);
+
        /* calc inference */
        if (tcp_time_stamp > tp->rx_opt.rcv_tsecr)
                lp->inference = 3 * (tcp_time_stamp - tp->rx_opt.rcv_tsecr);
@@ -308,11 +314,11 @@ static void tcp_lp_pkts_acked(struct sock *sk, u32 num_acked)
 }
 
 static struct tcp_congestion_ops tcp_lp = {
+       .flags = TCP_CONG_RTT_STAMP,
        .init = tcp_lp_init,
        .ssthresh = tcp_reno_ssthresh,
        .cong_avoid = tcp_lp_cong_avoid,
        .min_cwnd = tcp_reno_min_cwnd,
-       .rtt_sample = tcp_lp_rtt_sample,
        .pkts_acked = tcp_lp_pkts_acked,
 
        .owner = THIS_MODULE,
@@ -321,7 +327,7 @@ static struct tcp_congestion_ops tcp_lp = {
 
 static int __init tcp_lp_register(void)
 {
-       BUG_ON(sizeof(struct lp) > ICSK_CA_PRIV_SIZE);
+       BUILD_BUG_ON(sizeof(struct lp) > ICSK_CA_PRIV_SIZE);
        return tcp_register_congestion_control(&tcp_lp);
 }
 
@@ -333,6 +339,6 @@ static void __exit tcp_lp_unregister(void)
 module_init(tcp_lp_register);
 module_exit(tcp_lp_unregister);
 
-MODULE_AUTHOR("Wong Hoi Sing Edison, Hung Hing Lun");
+MODULE_AUTHOR("Wong Hoi Sing Edison, Hung Hing Lun Mike");
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("TCP Low Priority");