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 | |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 43 | /* Default values of the Vegas variables, in fixed-point representation |
| 44 | * with V_PARAM_SHIFT bits to the right of the binary point. |
| 45 | */ |
| 46 | #define V_PARAM_SHIFT 1 |
David S. Miller | d2e4bdc | 2006-11-28 14:37:38 -0800 | [diff] [blame] | 47 | static int alpha = 2<<V_PARAM_SHIFT; |
| 48 | static int beta = 4<<V_PARAM_SHIFT; |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 49 | static int gamma = 1<<V_PARAM_SHIFT; |
| 50 | |
| 51 | module_param(alpha, int, 0644); |
| 52 | MODULE_PARM_DESC(alpha, "lower bound of packets in network (scale by 2)"); |
| 53 | module_param(beta, int, 0644); |
| 54 | MODULE_PARM_DESC(beta, "upper bound of packets in network (scale by 2)"); |
| 55 | module_param(gamma, int, 0644); |
| 56 | MODULE_PARM_DESC(gamma, "limit on increase (scale by 2)"); |
| 57 | |
| 58 | |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 59 | /* There are several situations when we must "re-start" Vegas: |
| 60 | * |
| 61 | * o when a connection is established |
| 62 | * o after an RTO |
| 63 | * o after fast recovery |
| 64 | * o when we send a packet and there is no outstanding |
| 65 | * unacknowledged data (restarting an idle connection) |
| 66 | * |
| 67 | * In these circumstances we cannot do a Vegas calculation at the |
| 68 | * end of the first RTT, because any calculation we do is using |
| 69 | * stale info -- both the saved cwnd and congestion feedback are |
| 70 | * stale. |
| 71 | * |
| 72 | * Instead we must wait until the completion of an RTT during |
| 73 | * which we actually receive ACKs. |
| 74 | */ |
Stephen Hemminger | 7752237 | 2007-04-23 22:28:23 -0700 | [diff] [blame] | 75 | static void vegas_enable(struct sock *sk) |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 76 | { |
Arnaldo Carvalho de Melo | 6687e98 | 2005-08-10 04:03:31 -0300 | [diff] [blame] | 77 | const struct tcp_sock *tp = tcp_sk(sk); |
| 78 | struct vegas *vegas = inet_csk_ca(sk); |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 79 | |
| 80 | /* Begin taking Vegas samples next time we send something. */ |
| 81 | vegas->doing_vegas_now = 1; |
| 82 | |
| 83 | /* Set the beginning of the next send window. */ |
| 84 | vegas->beg_snd_nxt = tp->snd_nxt; |
| 85 | |
| 86 | vegas->cntRTT = 0; |
| 87 | vegas->minRTT = 0x7fffffff; |
| 88 | } |
| 89 | |
| 90 | /* Stop taking Vegas samples for now. */ |
Arnaldo Carvalho de Melo | 6687e98 | 2005-08-10 04:03:31 -0300 | [diff] [blame] | 91 | static inline void vegas_disable(struct sock *sk) |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 92 | { |
Arnaldo Carvalho de Melo | 6687e98 | 2005-08-10 04:03:31 -0300 | [diff] [blame] | 93 | struct vegas *vegas = inet_csk_ca(sk); |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 94 | |
| 95 | vegas->doing_vegas_now = 0; |
| 96 | } |
| 97 | |
Stephen Hemminger | 7752237 | 2007-04-23 22:28:23 -0700 | [diff] [blame] | 98 | void tcp_vegas_init(struct sock *sk) |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 99 | { |
Arnaldo Carvalho de Melo | 6687e98 | 2005-08-10 04:03:31 -0300 | [diff] [blame] | 100 | struct vegas *vegas = inet_csk_ca(sk); |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 101 | |
| 102 | vegas->baseRTT = 0x7fffffff; |
Arnaldo Carvalho de Melo | 6687e98 | 2005-08-10 04:03:31 -0300 | [diff] [blame] | 103 | vegas_enable(sk); |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 104 | } |
Stephen Hemminger | 7752237 | 2007-04-23 22:28:23 -0700 | [diff] [blame] | 105 | EXPORT_SYMBOL_GPL(tcp_vegas_init); |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 106 | |
| 107 | /* Do RTT sampling needed for Vegas. |
| 108 | * Basically we: |
| 109 | * o min-filter RTT samples from within an RTT to get the current |
| 110 | * propagation delay + queuing delay (we are min-filtering to try to |
| 111 | * avoid the effects of delayed ACKs) |
| 112 | * o min-filter RTT samples from a much longer window (forever for now) |
| 113 | * to find the propagation delay (baseRTT) |
| 114 | */ |
Stephen Hemminger | 30cfd0b | 2007-07-25 23:49:34 -0700 | [diff] [blame] | 115 | 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] | 116 | { |
Arnaldo Carvalho de Melo | 6687e98 | 2005-08-10 04:03:31 -0300 | [diff] [blame] | 117 | struct vegas *vegas = inet_csk_ca(sk); |
Stephen Hemminger | 164891a | 2007-04-23 22:26:16 -0700 | [diff] [blame] | 118 | u32 vrtt; |
| 119 | |
Stephen Hemminger | 30cfd0b | 2007-07-25 23:49:34 -0700 | [diff] [blame] | 120 | if (rtt_us < 0) |
Ilpo Järvinen | b9ce204 | 2007-06-15 15:08:43 -0700 | [diff] [blame] | 121 | return; |
| 122 | |
Stephen Hemminger | 164891a | 2007-04-23 22:26:16 -0700 | [diff] [blame] | 123 | /* Never allow zero rtt or baseRTT */ |
Stephen Hemminger | 30cfd0b | 2007-07-25 23:49:34 -0700 | [diff] [blame] | 124 | vrtt = rtt_us + 1; |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 125 | |
| 126 | /* Filter to find propagation delay: */ |
| 127 | if (vrtt < vegas->baseRTT) |
| 128 | vegas->baseRTT = vrtt; |
| 129 | |
| 130 | /* Find the min RTT during the last RTT to find |
| 131 | * the current prop. delay + queuing delay: |
| 132 | */ |
| 133 | vegas->minRTT = min(vegas->minRTT, vrtt); |
| 134 | vegas->cntRTT++; |
| 135 | } |
Stephen Hemminger | 7752237 | 2007-04-23 22:28:23 -0700 | [diff] [blame] | 136 | EXPORT_SYMBOL_GPL(tcp_vegas_pkts_acked); |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 137 | |
Stephen Hemminger | 7752237 | 2007-04-23 22:28:23 -0700 | [diff] [blame] | 138 | void tcp_vegas_state(struct sock *sk, u8 ca_state) |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 139 | { |
| 140 | |
| 141 | if (ca_state == TCP_CA_Open) |
Arnaldo Carvalho de Melo | 6687e98 | 2005-08-10 04:03:31 -0300 | [diff] [blame] | 142 | vegas_enable(sk); |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 143 | else |
Arnaldo Carvalho de Melo | 6687e98 | 2005-08-10 04:03:31 -0300 | [diff] [blame] | 144 | vegas_disable(sk); |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 145 | } |
Stephen Hemminger | 7752237 | 2007-04-23 22:28:23 -0700 | [diff] [blame] | 146 | EXPORT_SYMBOL_GPL(tcp_vegas_state); |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 147 | |
| 148 | /* |
| 149 | * If the connection is idle and we are restarting, |
| 150 | * then we don't want to do any Vegas calculations |
| 151 | * until we get fresh RTT samples. So when we |
| 152 | * restart, we reset our Vegas state to a clean |
| 153 | * slate. After we get acks for this flight of |
| 154 | * packets, _then_ we can make Vegas calculations |
| 155 | * again. |
| 156 | */ |
Stephen Hemminger | 7752237 | 2007-04-23 22:28:23 -0700 | [diff] [blame] | 157 | 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] | 158 | { |
| 159 | if (event == CA_EVENT_CWND_RESTART || |
| 160 | event == CA_EVENT_TX_START) |
Arnaldo Carvalho de Melo | 6687e98 | 2005-08-10 04:03:31 -0300 | [diff] [blame] | 161 | tcp_vegas_init(sk); |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 162 | } |
Stephen Hemminger | 7752237 | 2007-04-23 22:28:23 -0700 | [diff] [blame] | 163 | EXPORT_SYMBOL_GPL(tcp_vegas_cwnd_event); |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 164 | |
Ilpo Järvinen | c3a05c6 | 2007-12-02 00:47:59 +0200 | [diff] [blame] | 165 | 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] | 166 | { |
Arnaldo Carvalho de Melo | 6687e98 | 2005-08-10 04:03:31 -0300 | [diff] [blame] | 167 | struct tcp_sock *tp = tcp_sk(sk); |
| 168 | struct vegas *vegas = inet_csk_ca(sk); |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 169 | |
Harvey Harrison | ab59859 | 2008-05-01 02:47:38 -0700 | [diff] [blame] | 170 | if (!vegas->doing_vegas_now) { |
| 171 | tcp_reno_cong_avoid(sk, ack, in_flight); |
| 172 | return; |
| 173 | } |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 174 | |
| 175 | /* The key players are v_beg_snd_una and v_beg_snd_nxt. |
| 176 | * |
| 177 | * These are so named because they represent the approximate values |
| 178 | * of snd_una and snd_nxt at the beginning of the current RTT. More |
| 179 | * precisely, they represent the amount of data sent during the RTT. |
| 180 | * At the end of the RTT, when we receive an ACK for v_beg_snd_nxt, |
| 181 | * we will calculate that (v_beg_snd_nxt - v_beg_snd_una) outstanding |
| 182 | * bytes of data have been ACKed during the course of the RTT, giving |
| 183 | * an "actual" rate of: |
| 184 | * |
| 185 | * (v_beg_snd_nxt - v_beg_snd_una) / (rtt duration) |
| 186 | * |
| 187 | * Unfortunately, v_beg_snd_una is not exactly equal to snd_una, |
| 188 | * because delayed ACKs can cover more than one segment, so they |
| 189 | * don't line up nicely with the boundaries of RTTs. |
| 190 | * |
| 191 | * Another unfortunate fact of life is that delayed ACKs delay the |
| 192 | * advance of the left edge of our send window, so that the number |
| 193 | * of bytes we send in an RTT is often less than our cwnd will allow. |
| 194 | * So we keep track of our cwnd separately, in v_beg_snd_cwnd. |
| 195 | */ |
| 196 | |
| 197 | if (after(ack, vegas->beg_snd_nxt)) { |
| 198 | /* Do the Vegas once-per-RTT cwnd adjustment. */ |
| 199 | u32 old_wnd, old_snd_cwnd; |
| 200 | |
| 201 | |
| 202 | /* Here old_wnd is essentially the window of data that was |
| 203 | * sent during the previous RTT, and has all |
| 204 | * been acknowledged in the course of the RTT that ended |
| 205 | * with the ACK we just received. Likewise, old_snd_cwnd |
| 206 | * is the cwnd during the previous RTT. |
| 207 | */ |
| 208 | old_wnd = (vegas->beg_snd_nxt - vegas->beg_snd_una) / |
| 209 | tp->mss_cache; |
| 210 | old_snd_cwnd = vegas->beg_snd_cwnd; |
| 211 | |
| 212 | /* Save the extent of the current window so we can use this |
| 213 | * at the end of the next RTT. |
| 214 | */ |
| 215 | vegas->beg_snd_una = vegas->beg_snd_nxt; |
| 216 | vegas->beg_snd_nxt = tp->snd_nxt; |
| 217 | vegas->beg_snd_cwnd = tp->snd_cwnd; |
| 218 | |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 219 | /* We do the Vegas calculations only if we got enough RTT |
| 220 | * samples that we can be reasonably sure that we got |
| 221 | * at least one RTT sample that wasn't from a delayed ACK. |
| 222 | * If we only had 2 samples total, |
| 223 | * then that means we're getting only 1 ACK per RTT, which |
| 224 | * means they're almost certainly delayed ACKs. |
| 225 | * If we have 3 samples, we should be OK. |
| 226 | */ |
| 227 | |
| 228 | if (vegas->cntRTT <= 2) { |
| 229 | /* We don't have enough RTT samples to do the Vegas |
| 230 | * calculation, so we'll behave like Reno. |
| 231 | */ |
Ilpo Järvinen | c3a05c6 | 2007-12-02 00:47:59 +0200 | [diff] [blame] | 232 | tcp_reno_cong_avoid(sk, ack, in_flight); |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 233 | } else { |
Lachlan Andrew | 1591311 | 2008-04-30 01:04:03 -0700 | [diff] [blame] | 234 | u32 rtt, diff; |
| 235 | u64 target_cwnd; |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 236 | |
| 237 | /* We have enough RTT samples, so, using the Vegas |
| 238 | * algorithm, we determine if we should increase or |
| 239 | * decrease cwnd, and by how much. |
| 240 | */ |
| 241 | |
| 242 | /* Pluck out the RTT we are using for the Vegas |
| 243 | * calculations. This is the min RTT seen during the |
| 244 | * last RTT. Taking the min filters out the effects |
| 245 | * of delayed ACKs, at the cost of noticing congestion |
| 246 | * a bit later. |
| 247 | */ |
| 248 | rtt = vegas->minRTT; |
| 249 | |
| 250 | /* Calculate the cwnd we should have, if we weren't |
| 251 | * going too fast. |
| 252 | * |
| 253 | * This is: |
| 254 | * (actual rate in segments) * baseRTT |
| 255 | * We keep it as a fixed point number with |
| 256 | * V_PARAM_SHIFT bits to the right of the binary point. |
| 257 | */ |
Lachlan Andrew | 1591311 | 2008-04-30 01:04:03 -0700 | [diff] [blame] | 258 | target_cwnd = ((u64)old_wnd * vegas->baseRTT); |
| 259 | target_cwnd <<= V_PARAM_SHIFT; |
| 260 | do_div(target_cwnd, rtt); |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 261 | |
| 262 | /* Calculate the difference between the window we had, |
| 263 | * and the window we would like to have. This quantity |
| 264 | * is the "Diff" from the Arizona Vegas papers. |
| 265 | * |
| 266 | * Again, this is a fixed point number with |
| 267 | * V_PARAM_SHIFT bits to the right of the binary |
| 268 | * point. |
| 269 | */ |
| 270 | diff = (old_wnd << V_PARAM_SHIFT) - target_cwnd; |
| 271 | |
Xiaoliang (David) Wei | c940587 | 2007-10-29 20:24:36 -0700 | [diff] [blame] | 272 | if (diff > gamma && tp->snd_ssthresh > 2 ) { |
| 273 | /* Going too fast. Time to slow down |
| 274 | * and switch to congestion avoidance. |
| 275 | */ |
| 276 | tp->snd_ssthresh = 2; |
| 277 | |
| 278 | /* Set cwnd to match the actual rate |
| 279 | * exactly: |
| 280 | * cwnd = (actual rate) * baseRTT |
| 281 | * Then we add 1 because the integer |
| 282 | * truncation robs us of full link |
| 283 | * utilization. |
| 284 | */ |
| 285 | tp->snd_cwnd = min(tp->snd_cwnd, |
Lachlan Andrew | 1591311 | 2008-04-30 01:04:03 -0700 | [diff] [blame] | 286 | ((u32)target_cwnd >> |
Xiaoliang (David) Wei | c940587 | 2007-10-29 20:24:36 -0700 | [diff] [blame] | 287 | V_PARAM_SHIFT)+1); |
| 288 | |
| 289 | } else if (tp->snd_cwnd <= tp->snd_ssthresh) { |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 290 | /* Slow start. */ |
Stephen Hemminger | 7faffa1 | 2005-11-10 17:07:24 -0800 | [diff] [blame] | 291 | tcp_slow_start(tp); |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 292 | } else { |
| 293 | /* Congestion avoidance. */ |
| 294 | u32 next_snd_cwnd; |
| 295 | |
| 296 | /* Figure out where we would like cwnd |
| 297 | * to be. |
| 298 | */ |
| 299 | if (diff > beta) { |
| 300 | /* The old window was too fast, so |
| 301 | * we slow down. |
| 302 | */ |
| 303 | next_snd_cwnd = old_snd_cwnd - 1; |
| 304 | } else if (diff < alpha) { |
| 305 | /* We don't have enough extra packets |
| 306 | * in the network, so speed up. |
| 307 | */ |
| 308 | next_snd_cwnd = old_snd_cwnd + 1; |
| 309 | } else { |
| 310 | /* Sending just as fast as we |
| 311 | * should be. |
| 312 | */ |
| 313 | next_snd_cwnd = old_snd_cwnd; |
| 314 | } |
| 315 | |
| 316 | /* Adjust cwnd upward or downward, toward the |
| 317 | * desired value. |
| 318 | */ |
| 319 | if (next_snd_cwnd > tp->snd_cwnd) |
| 320 | tp->snd_cwnd++; |
| 321 | else if (next_snd_cwnd < tp->snd_cwnd) |
| 322 | tp->snd_cwnd--; |
| 323 | } |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 324 | |
Stephen Hemminger | 7faffa1 | 2005-11-10 17:07:24 -0800 | [diff] [blame] | 325 | if (tp->snd_cwnd < 2) |
| 326 | tp->snd_cwnd = 2; |
| 327 | else if (tp->snd_cwnd > tp->snd_cwnd_clamp) |
| 328 | tp->snd_cwnd = tp->snd_cwnd_clamp; |
| 329 | } |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 330 | |
Thomas Young | 5b49561 | 2005-12-06 16:16:34 -0800 | [diff] [blame] | 331 | /* Wipe the slate clean for the next RTT. */ |
| 332 | vegas->cntRTT = 0; |
| 333 | vegas->minRTT = 0x7fffffff; |
| 334 | } |
Thomas Young | 74cb879 | 2006-01-04 13:59:32 -0800 | [diff] [blame] | 335 | /* Use normal slow start */ |
YOSHIFUJI Hideaki | e905a9e | 2007-02-09 23:24:47 +0900 | [diff] [blame] | 336 | else if (tp->snd_cwnd <= tp->snd_ssthresh) |
Thomas Young | 74cb879 | 2006-01-04 13:59:32 -0800 | [diff] [blame] | 337 | tcp_slow_start(tp); |
YOSHIFUJI Hideaki | e905a9e | 2007-02-09 23:24:47 +0900 | [diff] [blame] | 338 | |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 339 | } |
| 340 | |
| 341 | /* Extract info for Tcp socket info provided via netlink. */ |
Stephen Hemminger | 7752237 | 2007-04-23 22:28:23 -0700 | [diff] [blame] | 342 | 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] | 343 | { |
Arnaldo Carvalho de Melo | 6687e98 | 2005-08-10 04:03:31 -0300 | [diff] [blame] | 344 | const struct vegas *ca = inet_csk_ca(sk); |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 345 | if (ext & (1 << (INET_DIAG_VEGASINFO - 1))) { |
Thomas Graf | e9195d6 | 2007-03-22 23:27:01 -0700 | [diff] [blame] | 346 | struct tcpvegas_info info = { |
| 347 | .tcpv_enabled = ca->doing_vegas_now, |
| 348 | .tcpv_rttcnt = ca->cntRTT, |
| 349 | .tcpv_rtt = ca->baseRTT, |
| 350 | .tcpv_minrtt = ca->minRTT, |
| 351 | }; |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 352 | |
Thomas Graf | e9195d6 | 2007-03-22 23:27:01 -0700 | [diff] [blame] | 353 | nla_put(skb, INET_DIAG_VEGASINFO, sizeof(info), &info); |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 354 | } |
| 355 | } |
Stephen Hemminger | 7752237 | 2007-04-23 22:28:23 -0700 | [diff] [blame] | 356 | EXPORT_SYMBOL_GPL(tcp_vegas_get_info); |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 357 | |
| 358 | static struct tcp_congestion_ops tcp_vegas = { |
Stephen Hemminger | 164891a | 2007-04-23 22:26:16 -0700 | [diff] [blame] | 359 | .flags = TCP_CONG_RTT_STAMP, |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 360 | .init = tcp_vegas_init, |
| 361 | .ssthresh = tcp_reno_ssthresh, |
| 362 | .cong_avoid = tcp_vegas_cong_avoid, |
| 363 | .min_cwnd = tcp_reno_min_cwnd, |
Stephen Hemminger | 164891a | 2007-04-23 22:26:16 -0700 | [diff] [blame] | 364 | .pkts_acked = tcp_vegas_pkts_acked, |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 365 | .set_state = tcp_vegas_state, |
| 366 | .cwnd_event = tcp_vegas_cwnd_event, |
| 367 | .get_info = tcp_vegas_get_info, |
| 368 | |
| 369 | .owner = THIS_MODULE, |
| 370 | .name = "vegas", |
| 371 | }; |
| 372 | |
| 373 | static int __init tcp_vegas_register(void) |
| 374 | { |
Alexey Dobriyan | 74975d4 | 2006-08-25 17:10:33 -0700 | [diff] [blame] | 375 | BUILD_BUG_ON(sizeof(struct vegas) > ICSK_CA_PRIV_SIZE); |
Stephen Hemminger | b87d856 | 2005-06-23 12:27:19 -0700 | [diff] [blame] | 376 | tcp_register_congestion_control(&tcp_vegas); |
| 377 | return 0; |
| 378 | } |
| 379 | |
| 380 | static void __exit tcp_vegas_unregister(void) |
| 381 | { |
| 382 | tcp_unregister_congestion_control(&tcp_vegas); |
| 383 | } |
| 384 | |
| 385 | module_init(tcp_vegas_register); |
| 386 | module_exit(tcp_vegas_unregister); |
| 387 | |
| 388 | MODULE_AUTHOR("Stephen Hemminger"); |
| 389 | MODULE_LICENSE("GPL"); |
| 390 | MODULE_DESCRIPTION("TCP Vegas"); |