Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 1 | /* |
| 2 | * TCP Vegas congestion control |
| 3 | * |
| 4 | * This is based on the congestion detection/avoidance scheme described in |
| 5 | * Lawrence S. Brakmo and Larry L. Peterson. |
| 6 | * "TCP Vegas: End to end congestion avoidance on a global internet." |
| 7 | * IEEE Journal on Selected Areas in Communication, 13(8):1465--1480, |
| 8 | * October 1995. Available from: |
| 9 | * ftp://ftp.cs.arizona.edu/xkernel/Papers/jsac.ps |
| 10 | * |
| 11 | * See http://www.cs.arizona.edu/xkernel/ for their implementation. |
| 12 | * The main aspects that distinguish this implementation from the |
| 13 | * Arizona Vegas implementation are: |
| 14 | * o We do not change the loss detection or recovery mechanisms of |
| 15 | * Linux in any way. Linux already recovers from losses quite well, |
| 16 | * using fine-grained timers, NewReno, and FACK. |
| 17 | * o To avoid the performance penalty imposed by increasing cwnd |
| 18 | * only every-other RTT during slow start, we increase during |
| 19 | * every RTT during slow start, just like Reno. |
| 20 | * o Largely to allow continuous cwnd growth during slow start, |
| 21 | * we use the rate at which ACKs come back as the "actual" |
| 22 | * rate, rather than the rate at which data is sent. |
| 23 | * o To speed convergence to the right rate, we set the cwnd |
| 24 | * to achieve the right ("actual") rate when we exit slow start. |
| 25 | * o To filter out the noise caused by delayed ACKs, we use the |
| 26 | * minimum RTT sample observed during the last RTT to calculate |
| 27 | * the actual rate. |
| 28 | * o When the sender re-starts from idle, it waits until it has |
| 29 | * received ACKs for an entire flight of new data before making |
| 30 | * a cwnd adjustment decision. The original Vegas implementation |
| 31 | * assumed senders never went idle. |
| 32 | */ |
| 33 | |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 34 | #include <linux/mm.h> |
| 35 | #include <linux/module.h> |
| 36 | #include <linux/skbuff.h> |
Arnaldo Carvalho de Melo | a8c2190 | 2005-08-12 12:56:38 -0300 | [diff] [blame] | 37 | #include <linux/inet_diag.h> |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 38 | |
| 39 | #include <net/tcp.h> |
| 40 | |
Stephen Hemminger | 7752237 | 2007-04-23 22:28:23 -0700 | [diff] [blame] | 41 | #include "tcp_vegas.h" |
| 42 | |
Doug Leith | 8d3a564 | 2008-12-09 00:13:04 -0800 | [diff] [blame] | 43 | static int alpha = 2; |
| 44 | static int beta = 4; |
| 45 | static int gamma = 1; |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 46 | |
| 47 | module_param(alpha, int, 0644); |
Doug Leith | 8d3a564 | 2008-12-09 00:13:04 -0800 | [diff] [blame] | 48 | MODULE_PARM_DESC(alpha, "lower bound of packets in network"); |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 49 | module_param(beta, int, 0644); |
Doug Leith | 8d3a564 | 2008-12-09 00:13:04 -0800 | [diff] [blame] | 50 | MODULE_PARM_DESC(beta, "upper bound of packets in network"); |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 51 | module_param(gamma, int, 0644); |
| 52 | MODULE_PARM_DESC(gamma, "limit on increase (scale by 2)"); |
| 53 | |
| 54 | |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 55 | /* There are several situations when we must "re-start" Vegas: |
| 56 | * |
| 57 | * o when a connection is established |
| 58 | * o after an RTO |
| 59 | * o after fast recovery |
| 60 | * o when we send a packet and there is no outstanding |
| 61 | * unacknowledged data (restarting an idle connection) |
| 62 | * |
| 63 | * In these circumstances we cannot do a Vegas calculation at the |
| 64 | * end of the first RTT, because any calculation we do is using |
| 65 | * stale info -- both the saved cwnd and congestion feedback are |
| 66 | * stale. |
| 67 | * |
| 68 | * Instead we must wait until the completion of an RTT during |
| 69 | * which we actually receive ACKs. |
| 70 | */ |
Stephen Hemminger | 7752237 | 2007-04-23 22:28:23 -0700 | [diff] [blame] | 71 | static void vegas_enable(struct sock *sk) |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 72 | { |
Arnaldo Carvalho de Melo | 6687e98 | 2005-08-10 04:03:31 -0300 | [diff] [blame] | 73 | const struct tcp_sock *tp = tcp_sk(sk); |
| 74 | struct vegas *vegas = inet_csk_ca(sk); |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 75 | |
| 76 | /* Begin taking Vegas samples next time we send something. */ |
| 77 | vegas->doing_vegas_now = 1; |
| 78 | |
| 79 | /* Set the beginning of the next send window. */ |
| 80 | vegas->beg_snd_nxt = tp->snd_nxt; |
| 81 | |
| 82 | vegas->cntRTT = 0; |
| 83 | vegas->minRTT = 0x7fffffff; |
| 84 | } |
| 85 | |
| 86 | /* Stop taking Vegas samples for now. */ |
Arnaldo Carvalho de Melo | 6687e98 | 2005-08-10 04:03:31 -0300 | [diff] [blame] | 87 | static inline void vegas_disable(struct sock *sk) |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 88 | { |
Arnaldo Carvalho de Melo | 6687e98 | 2005-08-10 04:03:31 -0300 | [diff] [blame] | 89 | struct vegas *vegas = inet_csk_ca(sk); |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 90 | |
| 91 | vegas->doing_vegas_now = 0; |
| 92 | } |
| 93 | |
Stephen Hemminger | 7752237 | 2007-04-23 22:28:23 -0700 | [diff] [blame] | 94 | void tcp_vegas_init(struct sock *sk) |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 95 | { |
Arnaldo Carvalho de Melo | 6687e98 | 2005-08-10 04:03:31 -0300 | [diff] [blame] | 96 | struct vegas *vegas = inet_csk_ca(sk); |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 97 | |
| 98 | vegas->baseRTT = 0x7fffffff; |
Arnaldo Carvalho de Melo | 6687e98 | 2005-08-10 04:03:31 -0300 | [diff] [blame] | 99 | vegas_enable(sk); |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 100 | } |
Stephen Hemminger | 7752237 | 2007-04-23 22:28:23 -0700 | [diff] [blame] | 101 | EXPORT_SYMBOL_GPL(tcp_vegas_init); |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 102 | |
| 103 | /* Do RTT sampling needed for Vegas. |
| 104 | * Basically we: |
| 105 | * o min-filter RTT samples from within an RTT to get the current |
| 106 | * propagation delay + queuing delay (we are min-filtering to try to |
| 107 | * avoid the effects of delayed ACKs) |
| 108 | * o min-filter RTT samples from a much longer window (forever for now) |
| 109 | * to find the propagation delay (baseRTT) |
| 110 | */ |
Stephen Hemminger | 30cfd0b | 2007-07-25 23:49:34 -0700 | [diff] [blame] | 111 | void tcp_vegas_pkts_acked(struct sock *sk, u32 cnt, s32 rtt_us) |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 112 | { |
Arnaldo Carvalho de Melo | 6687e98 | 2005-08-10 04:03:31 -0300 | [diff] [blame] | 113 | struct vegas *vegas = inet_csk_ca(sk); |
Stephen Hemminger | 164891a | 2007-04-23 22:26:16 -0700 | [diff] [blame] | 114 | u32 vrtt; |
| 115 | |
Stephen Hemminger | 30cfd0b | 2007-07-25 23:49:34 -0700 | [diff] [blame] | 116 | if (rtt_us < 0) |
Ilpo Järvinen | b9ce204 | 2007-06-15 15:08:43 -0700 | [diff] [blame] | 117 | return; |
| 118 | |
Stephen Hemminger | 164891a | 2007-04-23 22:26:16 -0700 | [diff] [blame] | 119 | /* Never allow zero rtt or baseRTT */ |
Stephen Hemminger | 30cfd0b | 2007-07-25 23:49:34 -0700 | [diff] [blame] | 120 | vrtt = rtt_us + 1; |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 121 | |
| 122 | /* Filter to find propagation delay: */ |
| 123 | if (vrtt < vegas->baseRTT) |
| 124 | vegas->baseRTT = vrtt; |
| 125 | |
| 126 | /* Find the min RTT during the last RTT to find |
| 127 | * the current prop. delay + queuing delay: |
| 128 | */ |
| 129 | vegas->minRTT = min(vegas->minRTT, vrtt); |
| 130 | vegas->cntRTT++; |
| 131 | } |
Stephen Hemminger | 7752237 | 2007-04-23 22:28:23 -0700 | [diff] [blame] | 132 | EXPORT_SYMBOL_GPL(tcp_vegas_pkts_acked); |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 133 | |
Stephen Hemminger | 7752237 | 2007-04-23 22:28:23 -0700 | [diff] [blame] | 134 | void tcp_vegas_state(struct sock *sk, u8 ca_state) |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 135 | { |
| 136 | |
| 137 | if (ca_state == TCP_CA_Open) |
Arnaldo Carvalho de Melo | 6687e98 | 2005-08-10 04:03:31 -0300 | [diff] [blame] | 138 | vegas_enable(sk); |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 139 | else |
Arnaldo Carvalho de Melo | 6687e98 | 2005-08-10 04:03:31 -0300 | [diff] [blame] | 140 | vegas_disable(sk); |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 141 | } |
Stephen Hemminger | 7752237 | 2007-04-23 22:28:23 -0700 | [diff] [blame] | 142 | EXPORT_SYMBOL_GPL(tcp_vegas_state); |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 143 | |
| 144 | /* |
| 145 | * If the connection is idle and we are restarting, |
| 146 | * then we don't want to do any Vegas calculations |
| 147 | * until we get fresh RTT samples. So when we |
| 148 | * restart, we reset our Vegas state to a clean |
| 149 | * slate. After we get acks for this flight of |
| 150 | * packets, _then_ we can make Vegas calculations |
| 151 | * again. |
| 152 | */ |
Stephen Hemminger | 7752237 | 2007-04-23 22:28:23 -0700 | [diff] [blame] | 153 | void tcp_vegas_cwnd_event(struct sock *sk, enum tcp_ca_event event) |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 154 | { |
| 155 | if (event == CA_EVENT_CWND_RESTART || |
| 156 | event == CA_EVENT_TX_START) |
Arnaldo Carvalho de Melo | 6687e98 | 2005-08-10 04:03:31 -0300 | [diff] [blame] | 157 | tcp_vegas_init(sk); |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 158 | } |
Stephen Hemminger | 7752237 | 2007-04-23 22:28:23 -0700 | [diff] [blame] | 159 | EXPORT_SYMBOL_GPL(tcp_vegas_cwnd_event); |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 160 | |
Doug Leith | c80a5cd | 2009-05-25 22:44:59 -0700 | [diff] [blame^] | 161 | static inline u32 tcp_vegas_ssthresh(struct tcp_sock *tp) |
| 162 | { |
| 163 | return min(tp->snd_ssthresh, tp->snd_cwnd-1); |
| 164 | } |
| 165 | |
Ilpo Järvinen | c3a05c6 | 2007-12-02 00:47:59 +0200 | [diff] [blame] | 166 | static void tcp_vegas_cong_avoid(struct sock *sk, u32 ack, u32 in_flight) |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 167 | { |
Arnaldo Carvalho de Melo | 6687e98 | 2005-08-10 04:03:31 -0300 | [diff] [blame] | 168 | struct tcp_sock *tp = tcp_sk(sk); |
| 169 | struct vegas *vegas = inet_csk_ca(sk); |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 170 | |
Harvey Harrison | ab59859 | 2008-05-01 02:47:38 -0700 | [diff] [blame] | 171 | if (!vegas->doing_vegas_now) { |
| 172 | tcp_reno_cong_avoid(sk, ack, in_flight); |
| 173 | return; |
| 174 | } |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 175 | |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 176 | if (after(ack, vegas->beg_snd_nxt)) { |
| 177 | /* Do the Vegas once-per-RTT cwnd adjustment. */ |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 178 | |
| 179 | /* Save the extent of the current window so we can use this |
| 180 | * at the end of the next RTT. |
| 181 | */ |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 182 | vegas->beg_snd_nxt = tp->snd_nxt; |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 183 | |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 184 | /* We do the Vegas calculations only if we got enough RTT |
| 185 | * samples that we can be reasonably sure that we got |
| 186 | * at least one RTT sample that wasn't from a delayed ACK. |
| 187 | * If we only had 2 samples total, |
| 188 | * then that means we're getting only 1 ACK per RTT, which |
| 189 | * means they're almost certainly delayed ACKs. |
| 190 | * If we have 3 samples, we should be OK. |
| 191 | */ |
| 192 | |
| 193 | if (vegas->cntRTT <= 2) { |
| 194 | /* We don't have enough RTT samples to do the Vegas |
| 195 | * calculation, so we'll behave like Reno. |
| 196 | */ |
Ilpo Järvinen | c3a05c6 | 2007-12-02 00:47:59 +0200 | [diff] [blame] | 197 | tcp_reno_cong_avoid(sk, ack, in_flight); |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 198 | } else { |
Lachlan Andrew | 1591311 | 2008-04-30 01:04:03 -0700 | [diff] [blame] | 199 | u32 rtt, diff; |
| 200 | u64 target_cwnd; |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 201 | |
| 202 | /* We have enough RTT samples, so, using the Vegas |
| 203 | * algorithm, we determine if we should increase or |
| 204 | * decrease cwnd, and by how much. |
| 205 | */ |
| 206 | |
| 207 | /* Pluck out the RTT we are using for the Vegas |
| 208 | * calculations. This is the min RTT seen during the |
| 209 | * last RTT. Taking the min filters out the effects |
| 210 | * of delayed ACKs, at the cost of noticing congestion |
| 211 | * a bit later. |
| 212 | */ |
| 213 | rtt = vegas->minRTT; |
| 214 | |
| 215 | /* Calculate the cwnd we should have, if we weren't |
| 216 | * going too fast. |
| 217 | * |
| 218 | * This is: |
| 219 | * (actual rate in segments) * baseRTT |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 220 | */ |
Doug Leith | 8d3a564 | 2008-12-09 00:13:04 -0800 | [diff] [blame] | 221 | target_cwnd = tp->snd_cwnd * vegas->baseRTT / rtt; |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 222 | |
| 223 | /* Calculate the difference between the window we had, |
| 224 | * and the window we would like to have. This quantity |
| 225 | * is the "Diff" from the Arizona Vegas papers. |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 226 | */ |
Doug Leith | 8d3a564 | 2008-12-09 00:13:04 -0800 | [diff] [blame] | 227 | diff = tp->snd_cwnd * (rtt-vegas->baseRTT) / vegas->baseRTT; |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 228 | |
Doug Leith | c80a5cd | 2009-05-25 22:44:59 -0700 | [diff] [blame^] | 229 | if (diff > gamma && tp->snd_cwnd <= tp->snd_ssthresh) { |
Xiaoliang (David) Wei | c940587 | 2007-10-29 20:24:36 -0700 | [diff] [blame] | 230 | /* Going too fast. Time to slow down |
| 231 | * and switch to congestion avoidance. |
| 232 | */ |
Xiaoliang (David) Wei | c940587 | 2007-10-29 20:24:36 -0700 | [diff] [blame] | 233 | |
| 234 | /* Set cwnd to match the actual rate |
| 235 | * exactly: |
| 236 | * cwnd = (actual rate) * baseRTT |
| 237 | * Then we add 1 because the integer |
| 238 | * truncation robs us of full link |
| 239 | * utilization. |
| 240 | */ |
Doug Leith | 8d3a564 | 2008-12-09 00:13:04 -0800 | [diff] [blame] | 241 | tp->snd_cwnd = min(tp->snd_cwnd, (u32)target_cwnd+1); |
Doug Leith | c80a5cd | 2009-05-25 22:44:59 -0700 | [diff] [blame^] | 242 | tp->snd_ssthresh = tcp_vegas_ssthresh(tp); |
Xiaoliang (David) Wei | c940587 | 2007-10-29 20:24:36 -0700 | [diff] [blame] | 243 | |
| 244 | } else if (tp->snd_cwnd <= tp->snd_ssthresh) { |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 245 | /* Slow start. */ |
Stephen Hemminger | 7faffa1 | 2005-11-10 17:07:24 -0800 | [diff] [blame] | 246 | tcp_slow_start(tp); |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 247 | } else { |
| 248 | /* Congestion avoidance. */ |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 249 | |
| 250 | /* Figure out where we would like cwnd |
| 251 | * to be. |
| 252 | */ |
| 253 | if (diff > beta) { |
| 254 | /* The old window was too fast, so |
| 255 | * we slow down. |
| 256 | */ |
Doug Leith | 8d3a564 | 2008-12-09 00:13:04 -0800 | [diff] [blame] | 257 | tp->snd_cwnd--; |
Doug Leith | c80a5cd | 2009-05-25 22:44:59 -0700 | [diff] [blame^] | 258 | tp->snd_ssthresh |
| 259 | = tcp_vegas_ssthresh(tp); |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 260 | } else if (diff < alpha) { |
| 261 | /* We don't have enough extra packets |
| 262 | * in the network, so speed up. |
| 263 | */ |
Doug Leith | 8d3a564 | 2008-12-09 00:13:04 -0800 | [diff] [blame] | 264 | tp->snd_cwnd++; |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 265 | } else { |
| 266 | /* Sending just as fast as we |
| 267 | * should be. |
| 268 | */ |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 269 | } |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 270 | } |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 271 | |
Stephen Hemminger | 7faffa1 | 2005-11-10 17:07:24 -0800 | [diff] [blame] | 272 | if (tp->snd_cwnd < 2) |
| 273 | tp->snd_cwnd = 2; |
| 274 | else if (tp->snd_cwnd > tp->snd_cwnd_clamp) |
| 275 | tp->snd_cwnd = tp->snd_cwnd_clamp; |
Doug Leith | a6af2d6 | 2008-12-04 17:17:18 -0800 | [diff] [blame] | 276 | |
| 277 | tp->snd_ssthresh = tcp_current_ssthresh(sk); |
Stephen Hemminger | 7faffa1 | 2005-11-10 17:07:24 -0800 | [diff] [blame] | 278 | } |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 279 | |
Thomas Young | 5b49561 | 2005-12-06 16:16:34 -0800 | [diff] [blame] | 280 | /* Wipe the slate clean for the next RTT. */ |
| 281 | vegas->cntRTT = 0; |
| 282 | vegas->minRTT = 0x7fffffff; |
| 283 | } |
Thomas Young | 74cb879 | 2006-01-04 13:59:32 -0800 | [diff] [blame] | 284 | /* Use normal slow start */ |
YOSHIFUJI Hideaki | e905a9e | 2007-02-09 23:24:47 +0900 | [diff] [blame] | 285 | else if (tp->snd_cwnd <= tp->snd_ssthresh) |
Thomas Young | 74cb879 | 2006-01-04 13:59:32 -0800 | [diff] [blame] | 286 | tcp_slow_start(tp); |
YOSHIFUJI Hideaki | e905a9e | 2007-02-09 23:24:47 +0900 | [diff] [blame] | 287 | |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 288 | } |
| 289 | |
| 290 | /* Extract info for Tcp socket info provided via netlink. */ |
Stephen Hemminger | 7752237 | 2007-04-23 22:28:23 -0700 | [diff] [blame] | 291 | void tcp_vegas_get_info(struct sock *sk, u32 ext, struct sk_buff *skb) |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 292 | { |
Arnaldo Carvalho de Melo | 6687e98 | 2005-08-10 04:03:31 -0300 | [diff] [blame] | 293 | const struct vegas *ca = inet_csk_ca(sk); |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 294 | if (ext & (1 << (INET_DIAG_VEGASINFO - 1))) { |
Thomas Graf | e9195d6 | 2007-03-22 23:27:01 -0700 | [diff] [blame] | 295 | struct tcpvegas_info info = { |
| 296 | .tcpv_enabled = ca->doing_vegas_now, |
| 297 | .tcpv_rttcnt = ca->cntRTT, |
| 298 | .tcpv_rtt = ca->baseRTT, |
| 299 | .tcpv_minrtt = ca->minRTT, |
| 300 | }; |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 301 | |
Thomas Graf | e9195d6 | 2007-03-22 23:27:01 -0700 | [diff] [blame] | 302 | nla_put(skb, INET_DIAG_VEGASINFO, sizeof(info), &info); |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 303 | } |
| 304 | } |
Stephen Hemminger | 7752237 | 2007-04-23 22:28:23 -0700 | [diff] [blame] | 305 | EXPORT_SYMBOL_GPL(tcp_vegas_get_info); |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 306 | |
| 307 | static struct tcp_congestion_ops tcp_vegas = { |
Stephen Hemminger | 164891a | 2007-04-23 22:26:16 -0700 | [diff] [blame] | 308 | .flags = TCP_CONG_RTT_STAMP, |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 309 | .init = tcp_vegas_init, |
| 310 | .ssthresh = tcp_reno_ssthresh, |
| 311 | .cong_avoid = tcp_vegas_cong_avoid, |
| 312 | .min_cwnd = tcp_reno_min_cwnd, |
Stephen Hemminger | 164891a | 2007-04-23 22:26:16 -0700 | [diff] [blame] | 313 | .pkts_acked = tcp_vegas_pkts_acked, |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 314 | .set_state = tcp_vegas_state, |
| 315 | .cwnd_event = tcp_vegas_cwnd_event, |
| 316 | .get_info = tcp_vegas_get_info, |
| 317 | |
| 318 | .owner = THIS_MODULE, |
| 319 | .name = "vegas", |
| 320 | }; |
| 321 | |
| 322 | static int __init tcp_vegas_register(void) |
| 323 | { |
Alexey Dobriyan | 74975d4 | 2006-08-25 17:10:33 -0700 | [diff] [blame] | 324 | BUILD_BUG_ON(sizeof(struct vegas) > ICSK_CA_PRIV_SIZE); |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 325 | tcp_register_congestion_control(&tcp_vegas); |
| 326 | return 0; |
| 327 | } |
| 328 | |
| 329 | static void __exit tcp_vegas_unregister(void) |
| 330 | { |
| 331 | tcp_unregister_congestion_control(&tcp_vegas); |
| 332 | } |
| 333 | |
| 334 | module_init(tcp_vegas_register); |
| 335 | module_exit(tcp_vegas_unregister); |
| 336 | |
| 337 | MODULE_AUTHOR("Stephen Hemminger"); |
| 338 | MODULE_LICENSE("GPL"); |
| 339 | MODULE_DESCRIPTION("TCP Vegas"); |