diff options
author | Stephen Hemminger <shemminger@linux-foundation.org> | 2007-04-24 01:28:23 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-04-26 01:29:46 -0400 |
commit | 7752237e9f07b316f81aebdc43f0d7c9a4ba0acf (patch) | |
tree | 6ec702ab8a81b123947cfcfae4b10cea0c27dc15 /net/ipv4/tcp_yeah.c | |
parent | 164891aadf1721fca4dce473bb0e0998181537c6 (diff) |
[TCP] TCP YEAH: Use vegas dont copy it.
Rather than using a copy of vegas code, the YEAH code should just have
it exported so there is common code.
Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/tcp_yeah.c')
-rw-r--r-- | net/ipv4/tcp_yeah.c | 53 |
1 files changed, 24 insertions, 29 deletions
diff --git a/net/ipv4/tcp_yeah.c b/net/ipv4/tcp_yeah.c index 81ef02c1649a..545ed237ab53 100644 --- a/net/ipv4/tcp_yeah.c +++ b/net/ipv4/tcp_yeah.c | |||
@@ -6,13 +6,14 @@ | |||
6 | * http://wil.cs.caltech.edu/pfldnet2007/paper/YeAH_TCP.pdf | 6 | * http://wil.cs.caltech.edu/pfldnet2007/paper/YeAH_TCP.pdf |
7 | * | 7 | * |
8 | */ | 8 | */ |
9 | #include <linux/mm.h> | ||
10 | #include <linux/module.h> | ||
11 | #include <linux/skbuff.h> | ||
12 | #include <linux/inet_diag.h> | ||
9 | 13 | ||
10 | #include "tcp_yeah.h" | 14 | #include <net/tcp.h> |
11 | 15 | ||
12 | /* Default values of the Vegas variables, in fixed-point representation | 16 | #include "tcp_vegas.h" |
13 | * with V_PARAM_SHIFT bits to the right of the binary point. | ||
14 | */ | ||
15 | #define V_PARAM_SHIFT 1 | ||
16 | 17 | ||
17 | #define TCP_YEAH_ALPHA 80 //lin number of packets queued at the bottleneck | 18 | #define TCP_YEAH_ALPHA 80 //lin number of packets queued at the bottleneck |
18 | #define TCP_YEAH_GAMMA 1 //lin fraction of queue to be removed per rtt | 19 | #define TCP_YEAH_GAMMA 1 //lin fraction of queue to be removed per rtt |
@@ -26,14 +27,7 @@ | |||
26 | 27 | ||
27 | /* YeAH variables */ | 28 | /* YeAH variables */ |
28 | struct yeah { | 29 | struct yeah { |
29 | /* Vegas */ | 30 | struct vegas vegas; /* must be first */ |
30 | u32 beg_snd_nxt; /* right edge during last RTT */ | ||
31 | u32 beg_snd_una; /* left edge during last RTT */ | ||
32 | u32 beg_snd_cwnd; /* saves the size of the cwnd */ | ||
33 | u8 doing_vegas_now;/* if true, do vegas for this RTT */ | ||
34 | u16 cntRTT; /* # of RTTs measured within last RTT */ | ||
35 | u32 minRTT; /* min of RTTs measured within last RTT (in usec) */ | ||
36 | u32 baseRTT; /* the min of all Vegas RTT measurements seen (in usec) */ | ||
37 | 31 | ||
38 | /* YeAH */ | 32 | /* YeAH */ |
39 | u32 lastQ; | 33 | u32 lastQ; |
@@ -84,9 +78,10 @@ static void tcp_yeah_cong_avoid(struct sock *sk, u32 ack, | |||
84 | if (!tcp_is_cwnd_limited(sk, in_flight)) | 78 | if (!tcp_is_cwnd_limited(sk, in_flight)) |
85 | return; | 79 | return; |
86 | 80 | ||
87 | if (tp->snd_cwnd <= tp->snd_ssthresh) { | 81 | if (tp->snd_cwnd <= tp->snd_ssthresh) |
88 | tcp_slow_start(tp); | 82 | tcp_slow_start(tp); |
89 | } else if (!yeah->doing_reno_now) { | 83 | |
84 | else if (!yeah->doing_reno_now) { | ||
90 | /* Scalable */ | 85 | /* Scalable */ |
91 | 86 | ||
92 | tp->snd_cwnd_cnt+=yeah->pkts_acked; | 87 | tp->snd_cwnd_cnt+=yeah->pkts_acked; |
@@ -110,19 +105,19 @@ static void tcp_yeah_cong_avoid(struct sock *sk, u32 ack, | |||
110 | } | 105 | } |
111 | } | 106 | } |
112 | 107 | ||
113 | /* The key players are v_beg_snd_una and v_beg_snd_nxt. | 108 | /* The key players are v_vegas.beg_snd_una and v_beg_snd_nxt. |
114 | * | 109 | * |
115 | * These are so named because they represent the approximate values | 110 | * These are so named because they represent the approximate values |
116 | * of snd_una and snd_nxt at the beginning of the current RTT. More | 111 | * of snd_una and snd_nxt at the beginning of the current RTT. More |
117 | * precisely, they represent the amount of data sent during the RTT. | 112 | * precisely, they represent the amount of data sent during the RTT. |
118 | * At the end of the RTT, when we receive an ACK for v_beg_snd_nxt, | 113 | * At the end of the RTT, when we receive an ACK for v_beg_snd_nxt, |
119 | * we will calculate that (v_beg_snd_nxt - v_beg_snd_una) outstanding | 114 | * we will calculate that (v_beg_snd_nxt - v_vegas.beg_snd_una) outstanding |
120 | * bytes of data have been ACKed during the course of the RTT, giving | 115 | * bytes of data have been ACKed during the course of the RTT, giving |
121 | * an "actual" rate of: | 116 | * an "actual" rate of: |
122 | * | 117 | * |
123 | * (v_beg_snd_nxt - v_beg_snd_una) / (rtt duration) | 118 | * (v_beg_snd_nxt - v_vegas.beg_snd_una) / (rtt duration) |
124 | * | 119 | * |
125 | * Unfortunately, v_beg_snd_una is not exactly equal to snd_una, | 120 | * Unfortunately, v_vegas.beg_snd_una is not exactly equal to snd_una, |
126 | * because delayed ACKs can cover more than one segment, so they | 121 | * because delayed ACKs can cover more than one segment, so they |
127 | * don't line up yeahly with the boundaries of RTTs. | 122 | * don't line up yeahly with the boundaries of RTTs. |
128 | * | 123 | * |
@@ -132,7 +127,7 @@ static void tcp_yeah_cong_avoid(struct sock *sk, u32 ack, | |||
132 | * So we keep track of our cwnd separately, in v_beg_snd_cwnd. | 127 | * So we keep track of our cwnd separately, in v_beg_snd_cwnd. |
133 | */ | 128 | */ |
134 | 129 | ||
135 | if (after(ack, yeah->beg_snd_nxt)) { | 130 | if (after(ack, yeah->vegas.beg_snd_nxt)) { |
136 | 131 | ||
137 | /* We do the Vegas calculations only if we got enough RTT | 132 | /* We do the Vegas calculations only if we got enough RTT |
138 | * samples that we can be reasonably sure that we got | 133 | * samples that we can be reasonably sure that we got |
@@ -143,7 +138,7 @@ static void tcp_yeah_cong_avoid(struct sock *sk, u32 ack, | |||
143 | * If we have 3 samples, we should be OK. | 138 | * If we have 3 samples, we should be OK. |
144 | */ | 139 | */ |
145 | 140 | ||
146 | if (yeah->cntRTT > 2) { | 141 | if (yeah->vegas.cntRTT > 2) { |
147 | u32 rtt, queue; | 142 | u32 rtt, queue; |
148 | u64 bw; | 143 | u64 bw; |
149 | 144 | ||
@@ -158,18 +153,18 @@ static void tcp_yeah_cong_avoid(struct sock *sk, u32 ack, | |||
158 | * of delayed ACKs, at the cost of noticing congestion | 153 | * of delayed ACKs, at the cost of noticing congestion |
159 | * a bit later. | 154 | * a bit later. |
160 | */ | 155 | */ |
161 | rtt = yeah->minRTT; | 156 | rtt = yeah->vegas.minRTT; |
162 | 157 | ||
163 | /* Compute excess number of packets above bandwidth | 158 | /* Compute excess number of packets above bandwidth |
164 | * Avoid doing full 64 bit divide. | 159 | * Avoid doing full 64 bit divide. |
165 | */ | 160 | */ |
166 | bw = tp->snd_cwnd; | 161 | bw = tp->snd_cwnd; |
167 | bw *= rtt - yeah->baseRTT; | 162 | bw *= rtt - yeah->vegas.baseRTT; |
168 | do_div(bw, rtt); | 163 | do_div(bw, rtt); |
169 | queue = bw; | 164 | queue = bw; |
170 | 165 | ||
171 | if (queue > TCP_YEAH_ALPHA || | 166 | if (queue > TCP_YEAH_ALPHA || |
172 | rtt - yeah->baseRTT > (yeah->baseRTT / TCP_YEAH_PHY)) { | 167 | rtt - yeah->vegas.baseRTT > (yeah->vegas.baseRTT / TCP_YEAH_PHY)) { |
173 | if (queue > TCP_YEAH_ALPHA | 168 | if (queue > TCP_YEAH_ALPHA |
174 | && tp->snd_cwnd > yeah->reno_count) { | 169 | && tp->snd_cwnd > yeah->reno_count) { |
175 | u32 reduction = min(queue / TCP_YEAH_GAMMA , | 170 | u32 reduction = min(queue / TCP_YEAH_GAMMA , |
@@ -208,13 +203,13 @@ static void tcp_yeah_cong_avoid(struct sock *sk, u32 ack, | |||
208 | /* Save the extent of the current window so we can use this | 203 | /* Save the extent of the current window so we can use this |
209 | * at the end of the next RTT. | 204 | * at the end of the next RTT. |
210 | */ | 205 | */ |
211 | yeah->beg_snd_una = yeah->beg_snd_nxt; | 206 | yeah->vegas.beg_snd_una = yeah->vegas.beg_snd_nxt; |
212 | yeah->beg_snd_nxt = tp->snd_nxt; | 207 | yeah->vegas.beg_snd_nxt = tp->snd_nxt; |
213 | yeah->beg_snd_cwnd = tp->snd_cwnd; | 208 | yeah->vegas.beg_snd_cwnd = tp->snd_cwnd; |
214 | 209 | ||
215 | /* Wipe the slate clean for the next RTT. */ | 210 | /* Wipe the slate clean for the next RTT. */ |
216 | yeah->cntRTT = 0; | 211 | yeah->vegas.cntRTT = 0; |
217 | yeah->minRTT = 0x7fffffff; | 212 | yeah->vegas.minRTT = 0x7fffffff; |
218 | } | 213 | } |
219 | } | 214 | } |
220 | 215 | ||