]> git.openfabrics.org - ~shefty/rdma-dev.git/commitdiff
[TCP]: congestion control API pass RTT in microseconds
authorStephen Hemminger <shemminger@linux-foundation.org>
Thu, 26 Jul 2007 06:49:34 +0000 (23:49 -0700)
committerDavid S. Miller <davem@sunset.davemloft.net>
Tue, 31 Jul 2007 09:27:57 +0000 (02:27 -0700)
This patch changes the API for the callback that is done after an ACK is
received. It solves a couple of issues:

  * Some congestion controls want higher resolution value of RTT
    (controlled by TCP_CONG_RTT_SAMPLE flag). These don't really want a ktime, but
    all compute a RTT in microseconds.

  * Other congestion control could use RTT at jiffies resolution.

To keep API consistent the units should be the same for both cases, just the
resolution should change.

Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
12 files changed:
include/net/tcp.h
net/ipv4/tcp_bic.c
net/ipv4/tcp_cubic.c
net/ipv4/tcp_htcp.c
net/ipv4/tcp_illinois.c
net/ipv4/tcp_input.c
net/ipv4/tcp_lp.c
net/ipv4/tcp_vegas.c
net/ipv4/tcp_vegas.h
net/ipv4/tcp_veno.c
net/ipv4/tcp_westwood.c
net/ipv4/tcp_yeah.c

index 8b404b1ef7c8ed7ba6025e8e7dab582105b0c1ae..c209361ab74a7ff00fe62da4b7b4a6a2ed1cb5eb 100644 (file)
@@ -660,7 +660,7 @@ struct tcp_congestion_ops {
        /* new value of cwnd after loss (optional) */
        u32  (*undo_cwnd)(struct sock *sk);
        /* hook for packet ack accounting (optional) */
-       void (*pkts_acked)(struct sock *sk, u32 num_acked, ktime_t last);
+       void (*pkts_acked)(struct sock *sk, u32 num_acked, s32 rtt_us);
        /* get info for inet_diag (optional) */
        void (*get_info)(struct sock *sk, u32 ext, struct sk_buff *skb);
 
index 519de091a94d01641f8ae5837abcc8943455fd25..4586211e3757f9b30c78b95bdbe1d1a858ea9070 100644 (file)
@@ -206,7 +206,7 @@ static void bictcp_state(struct sock *sk, u8 new_state)
 /* Track delayed acknowledgment ratio using sliding window
  * ratio = (15*ratio + sample) / 16
  */
-static void bictcp_acked(struct sock *sk, u32 cnt, ktime_t last)
+static void bictcp_acked(struct sock *sk, u32 cnt, s32 rtt)
 {
        const struct inet_connection_sock *icsk = inet_csk(sk);
 
index d17da30d82d675545526b55c30228fb03334db26..0c44bb67a67183d2a5ad9614d3beee41cce7e73c 100644 (file)
@@ -334,7 +334,7 @@ static void bictcp_state(struct sock *sk, u8 new_state)
 /* Track delayed acknowledgment ratio using sliding window
  * ratio = (15*ratio + sample) / 16
  */
-static void bictcp_acked(struct sock *sk, u32 cnt, ktime_t last)
+static void bictcp_acked(struct sock *sk, u32 cnt, s32 rtt_us)
 {
        const struct inet_connection_sock *icsk = inet_csk(sk);
 
index 08a02e6045c9c17733dbdac5c4873ce242bec9c5..fa61663ace3b0ca80a6d2967f0e564d4732600ef 100644 (file)
@@ -98,7 +98,7 @@ static inline void measure_rtt(struct sock *sk)
        }
 }
 
-static void measure_achieved_throughput(struct sock *sk, u32 pkts_acked, ktime_t last)
+static void measure_achieved_throughput(struct sock *sk, u32 pkts_acked, s32 rtt)
 {
        const struct inet_connection_sock *icsk = inet_csk(sk);
        const struct tcp_sock *tp = tcp_sk(sk);
index cc5de6f69d46f0e2f4fd81e8c4815780ba609bb4..64f1cbaf96e8a487bba6edc9398aeff535c2ec79 100644 (file)
@@ -83,18 +83,16 @@ static void tcp_illinois_init(struct sock *sk)
 }
 
 /* Measure RTT for each ack. */
-static void tcp_illinois_acked(struct sock *sk, u32 pkts_acked, ktime_t last)
+static void tcp_illinois_acked(struct sock *sk, u32 pkts_acked, s32 rtt)
 {
        struct illinois *ca = inet_csk_ca(sk);
-       u32 rtt;
 
        ca->acked = pkts_acked;
 
-       if (ktime_equal(last, net_invalid_timestamp()))
+       /* dup ack, no rtt sample */
+       if (rtt < 0)
                return;
 
-       rtt = ktime_to_us(net_timedelta(last));
-
        /* ignore bogus values, this prevents wraparound in alpha math */
        if (rtt > RTT_MAX)
                rtt = RTT_MAX;
index fec8a7a4dbaffa3781685fe9203b4c998482dc8d..4b255fe999d918870573bf5bfd239cfbc32d6203 100644 (file)
@@ -2490,12 +2490,23 @@ static int tcp_clean_rtx_queue(struct sock *sk, __s32 *seq_rtt_p)
                tcp_ack_update_rtt(sk, acked, seq_rtt);
                tcp_ack_packets_out(sk);
 
-               /* Is the ACK triggering packet unambiguous? */
-               if (acked & FLAG_RETRANS_DATA_ACKED)
-                       last_ackt = net_invalid_timestamp();
+               if (ca_ops->pkts_acked) {
+                       s32 rtt_us = -1;
+
+                       /* Is the ACK triggering packet unambiguous? */
+                       if (!(acked & FLAG_RETRANS_DATA_ACKED)) {
+                               /* High resolution needed and available? */
+                               if (ca_ops->flags & TCP_CONG_RTT_STAMP &&
+                                   !ktime_equal(last_ackt,
+                                                net_invalid_timestamp()))
+                                       rtt_us = ktime_us_delta(ktime_get_real(),
+                                                               last_ackt);
+                               else if (seq_rtt > 0)
+                                       rtt_us = jiffies_to_usecs(seq_rtt);
+                       }
 
-               if (ca_ops->pkts_acked)
-                       ca_ops->pkts_acked(sk, pkts_acked, last_ackt);
+                       ca_ops->pkts_acked(sk, pkts_acked, rtt_us);
+               }
        }
 
 #if FASTRETRANS_DEBUG > 0
index 80e140e3ec2d6db57529fc73494dc47600a48501..e7f5ef92cbd88ec0fd8f341e8bfed09da7b68dd0 100644 (file)
@@ -260,13 +260,13 @@ static void tcp_lp_rtt_sample(struct sock *sk, u32 rtt)
  * 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, ktime_t last)
+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 (!ktime_equal(last, net_invalid_timestamp()))
-               tcp_lp_rtt_sample(sk,  ktime_to_us(net_timedelta(last)));
+       if (rtt_us > 0)
+               tcp_lp_rtt_sample(sk, rtt_us);
 
        /* calc inference */
        if (tcp_time_stamp > tp->rx_opt.rcv_tsecr)
index 914e0307f7af2e89c58e7a29179dee64ebf29f3f..b49dedcda52df949c159db5b12635c9414a1538a 100644 (file)
@@ -112,16 +112,16 @@ EXPORT_SYMBOL_GPL(tcp_vegas_init);
  *   o min-filter RTT samples from a much longer window (forever for now)
  *     to find the propagation delay (baseRTT)
  */
-void tcp_vegas_pkts_acked(struct sock *sk, u32 cnt, ktime_t last)
+void tcp_vegas_pkts_acked(struct sock *sk, u32 cnt, s32 rtt_us)
 {
        struct vegas *vegas = inet_csk_ca(sk);
        u32 vrtt;
 
-       if (ktime_equal(last, net_invalid_timestamp()))
+       if (rtt_us < 0)
                return;
 
        /* Never allow zero rtt or baseRTT */
-       vrtt = ktime_to_us(net_timedelta(last)) + 1;
+       vrtt = rtt_us + 1;
 
        /* Filter to find propagation delay: */
        if (vrtt < vegas->baseRTT)
index 502fa8183634ae94bf5a5621aef666d545baa015..6c0eea2f8249bf6b08c85395c0ad4b4d8ef52b39 100644 (file)
@@ -17,7 +17,7 @@ struct vegas {
 
 extern void tcp_vegas_init(struct sock *sk);
 extern void tcp_vegas_state(struct sock *sk, u8 ca_state);
-extern void tcp_vegas_pkts_acked(struct sock *sk, u32 cnt, ktime_t last);
+extern void tcp_vegas_pkts_acked(struct sock *sk, u32 cnt, s32 rtt_us);
 extern void tcp_vegas_cwnd_event(struct sock *sk, enum tcp_ca_event event);
 extern void tcp_vegas_get_info(struct sock *sk, u32 ext, struct sk_buff *skb);
 
index 7a55ddf86032bdeab7bd0c48eca7358542c8f037..8fb2aee0b1a408171f43fd9e7b4d4987c6cc5f08 100644 (file)
@@ -69,16 +69,16 @@ static void tcp_veno_init(struct sock *sk)
 }
 
 /* Do rtt sampling needed for Veno. */
-static void tcp_veno_pkts_acked(struct sock *sk, u32 cnt, ktime_t last)
+static void tcp_veno_pkts_acked(struct sock *sk, u32 cnt, s32 rtt_us)
 {
        struct veno *veno = inet_csk_ca(sk);
        u32 vrtt;
 
-       if (ktime_equal(last, net_invalid_timestamp()))
+       if (rtt_us < 0)
                return;
 
        /* Never allow zero rtt or baseRTT */
-       vrtt = ktime_to_us(net_timedelta(last)) + 1;
+       vrtt = rtt_us + 1;
 
        /* Filter to find propagation delay: */
        if (vrtt < veno->basertt)
index e61e09dd513ed55c618ce5e7582ead8c9b99a4e1..20151d6a62413e09e4cb5b95d12fdb253148af61 100644 (file)
@@ -100,11 +100,12 @@ static void westwood_filter(struct westwood *w, u32 delta)
  * Called after processing group of packets.
  * but all westwood needs is the last sample of srtt.
  */
-static void tcp_westwood_pkts_acked(struct sock *sk, u32 cnt, ktime_t last)
+static void tcp_westwood_pkts_acked(struct sock *sk, u32 cnt, s32 rtt)
 {
        struct westwood *w = inet_csk_ca(sk);
-       if (cnt > 0)
-               w->rtt = tcp_sk(sk)->srtt >> 3;
+
+       if (rtt > 0)
+               w->rtt = usecs_to_jiffies(rtt);
 }
 
 /*
index c04b7c6ec7027ceb35e11d4ae23d5a4ce68a1479..c107fba7430e6c824c6aff448d0bdaf01e09eb8d 100644 (file)
@@ -58,7 +58,7 @@ static void tcp_yeah_init(struct sock *sk)
 }
 
 
-static void tcp_yeah_pkts_acked(struct sock *sk, u32 pkts_acked, ktime_t last)
+static void tcp_yeah_pkts_acked(struct sock *sk, u32 pkts_acked, s32 rtt_us)
 {
        const struct inet_connection_sock *icsk = inet_csk(sk);
        struct yeah *yeah = inet_csk_ca(sk);
@@ -66,7 +66,7 @@ static void tcp_yeah_pkts_acked(struct sock *sk, u32 pkts_acked, ktime_t last)
        if (icsk->icsk_ca_state == TCP_CA_Open)
                yeah->pkts_acked = pkts_acked;
 
-       tcp_vegas_pkts_acked(sk, pkts_acked, last);
+       tcp_vegas_pkts_acked(sk, pkts_acked, rtt_us);
 }
 
 static void tcp_yeah_cong_avoid(struct sock *sk, u32 ack,