diff options
Diffstat (limited to 'net/ipv4/tcp_vegas.c')
-rw-r--r-- | net/ipv4/tcp_vegas.c | 57 |
1 files changed, 27 insertions, 30 deletions
diff --git a/net/ipv4/tcp_vegas.c b/net/ipv4/tcp_vegas.c index 5c484dceb967..73e19cf7df21 100644 --- a/net/ipv4/tcp_vegas.c +++ b/net/ipv4/tcp_vegas.c | |||
@@ -38,6 +38,8 @@ | |||
38 | 38 | ||
39 | #include <net/tcp.h> | 39 | #include <net/tcp.h> |
40 | 40 | ||
41 | #include "tcp_vegas.h" | ||
42 | |||
41 | /* Default values of the Vegas variables, in fixed-point representation | 43 | /* Default values of the Vegas variables, in fixed-point representation |
42 | * with V_PARAM_SHIFT bits to the right of the binary point. | 44 | * with V_PARAM_SHIFT bits to the right of the binary point. |
43 | */ | 45 | */ |
@@ -54,17 +56,6 @@ module_param(gamma, int, 0644); | |||
54 | MODULE_PARM_DESC(gamma, "limit on increase (scale by 2)"); | 56 | MODULE_PARM_DESC(gamma, "limit on increase (scale by 2)"); |
55 | 57 | ||
56 | 58 | ||
57 | /* Vegas variables */ | ||
58 | struct vegas { | ||
59 | u32 beg_snd_nxt; /* right edge during last RTT */ | ||
60 | u32 beg_snd_una; /* left edge during last RTT */ | ||
61 | u32 beg_snd_cwnd; /* saves the size of the cwnd */ | ||
62 | u8 doing_vegas_now;/* if true, do vegas for this RTT */ | ||
63 | u16 cntRTT; /* # of RTTs measured within last RTT */ | ||
64 | u32 minRTT; /* min of RTTs measured within last RTT (in usec) */ | ||
65 | u32 baseRTT; /* the min of all Vegas RTT measurements seen (in usec) */ | ||
66 | }; | ||
67 | |||
68 | /* There are several situations when we must "re-start" Vegas: | 59 | /* There are several situations when we must "re-start" Vegas: |
69 | * | 60 | * |
70 | * o when a connection is established | 61 | * o when a connection is established |
@@ -81,7 +72,7 @@ struct vegas { | |||
81 | * Instead we must wait until the completion of an RTT during | 72 | * Instead we must wait until the completion of an RTT during |
82 | * which we actually receive ACKs. | 73 | * which we actually receive ACKs. |
83 | */ | 74 | */ |
84 | static inline void vegas_enable(struct sock *sk) | 75 | static void vegas_enable(struct sock *sk) |
85 | { | 76 | { |
86 | const struct tcp_sock *tp = tcp_sk(sk); | 77 | const struct tcp_sock *tp = tcp_sk(sk); |
87 | struct vegas *vegas = inet_csk_ca(sk); | 78 | struct vegas *vegas = inet_csk_ca(sk); |
@@ -104,13 +95,14 @@ static inline void vegas_disable(struct sock *sk) | |||
104 | vegas->doing_vegas_now = 0; | 95 | vegas->doing_vegas_now = 0; |
105 | } | 96 | } |
106 | 97 | ||
107 | static void tcp_vegas_init(struct sock *sk) | 98 | void tcp_vegas_init(struct sock *sk) |
108 | { | 99 | { |
109 | struct vegas *vegas = inet_csk_ca(sk); | 100 | struct vegas *vegas = inet_csk_ca(sk); |
110 | 101 | ||
111 | vegas->baseRTT = 0x7fffffff; | 102 | vegas->baseRTT = 0x7fffffff; |
112 | vegas_enable(sk); | 103 | vegas_enable(sk); |
113 | } | 104 | } |
105 | EXPORT_SYMBOL_GPL(tcp_vegas_init); | ||
114 | 106 | ||
115 | /* Do RTT sampling needed for Vegas. | 107 | /* Do RTT sampling needed for Vegas. |
116 | * Basically we: | 108 | * Basically we: |
@@ -120,10 +112,13 @@ static void tcp_vegas_init(struct sock *sk) | |||
120 | * o min-filter RTT samples from a much longer window (forever for now) | 112 | * o min-filter RTT samples from a much longer window (forever for now) |
121 | * to find the propagation delay (baseRTT) | 113 | * to find the propagation delay (baseRTT) |
122 | */ | 114 | */ |
123 | static void tcp_vegas_rtt_calc(struct sock *sk, u32 usrtt) | 115 | void tcp_vegas_pkts_acked(struct sock *sk, u32 cnt, ktime_t last) |
124 | { | 116 | { |
125 | struct vegas *vegas = inet_csk_ca(sk); | 117 | struct vegas *vegas = inet_csk_ca(sk); |
126 | u32 vrtt = usrtt + 1; /* Never allow zero rtt or baseRTT */ | 118 | u32 vrtt; |
119 | |||
120 | /* Never allow zero rtt or baseRTT */ | ||
121 | vrtt = ktime_to_us(net_timedelta(last)) + 1; | ||
127 | 122 | ||
128 | /* Filter to find propagation delay: */ | 123 | /* Filter to find propagation delay: */ |
129 | if (vrtt < vegas->baseRTT) | 124 | if (vrtt < vegas->baseRTT) |
@@ -135,8 +130,9 @@ static void tcp_vegas_rtt_calc(struct sock *sk, u32 usrtt) | |||
135 | vegas->minRTT = min(vegas->minRTT, vrtt); | 130 | vegas->minRTT = min(vegas->minRTT, vrtt); |
136 | vegas->cntRTT++; | 131 | vegas->cntRTT++; |
137 | } | 132 | } |
133 | EXPORT_SYMBOL_GPL(tcp_vegas_pkts_acked); | ||
138 | 134 | ||
139 | static void tcp_vegas_state(struct sock *sk, u8 ca_state) | 135 | void tcp_vegas_state(struct sock *sk, u8 ca_state) |
140 | { | 136 | { |
141 | 137 | ||
142 | if (ca_state == TCP_CA_Open) | 138 | if (ca_state == TCP_CA_Open) |
@@ -144,6 +140,7 @@ static void tcp_vegas_state(struct sock *sk, u8 ca_state) | |||
144 | else | 140 | else |
145 | vegas_disable(sk); | 141 | vegas_disable(sk); |
146 | } | 142 | } |
143 | EXPORT_SYMBOL_GPL(tcp_vegas_state); | ||
147 | 144 | ||
148 | /* | 145 | /* |
149 | * If the connection is idle and we are restarting, | 146 | * If the connection is idle and we are restarting, |
@@ -154,12 +151,13 @@ static void tcp_vegas_state(struct sock *sk, u8 ca_state) | |||
154 | * packets, _then_ we can make Vegas calculations | 151 | * packets, _then_ we can make Vegas calculations |
155 | * again. | 152 | * again. |
156 | */ | 153 | */ |
157 | static void tcp_vegas_cwnd_event(struct sock *sk, enum tcp_ca_event event) | 154 | void tcp_vegas_cwnd_event(struct sock *sk, enum tcp_ca_event event) |
158 | { | 155 | { |
159 | if (event == CA_EVENT_CWND_RESTART || | 156 | if (event == CA_EVENT_CWND_RESTART || |
160 | event == CA_EVENT_TX_START) | 157 | event == CA_EVENT_TX_START) |
161 | tcp_vegas_init(sk); | 158 | tcp_vegas_init(sk); |
162 | } | 159 | } |
160 | EXPORT_SYMBOL_GPL(tcp_vegas_cwnd_event); | ||
163 | 161 | ||
164 | static void tcp_vegas_cong_avoid(struct sock *sk, u32 ack, | 162 | static void tcp_vegas_cong_avoid(struct sock *sk, u32 ack, |
165 | u32 seq_rtt, u32 in_flight, int flag) | 163 | u32 seq_rtt, u32 in_flight, int flag) |
@@ -336,30 +334,29 @@ static void tcp_vegas_cong_avoid(struct sock *sk, u32 ack, | |||
336 | } | 334 | } |
337 | 335 | ||
338 | /* Extract info for Tcp socket info provided via netlink. */ | 336 | /* Extract info for Tcp socket info provided via netlink. */ |
339 | static void tcp_vegas_get_info(struct sock *sk, u32 ext, | 337 | void tcp_vegas_get_info(struct sock *sk, u32 ext, struct sk_buff *skb) |
340 | struct sk_buff *skb) | ||
341 | { | 338 | { |
342 | const struct vegas *ca = inet_csk_ca(sk); | 339 | const struct vegas *ca = inet_csk_ca(sk); |
343 | if (ext & (1 << (INET_DIAG_VEGASINFO - 1))) { | 340 | if (ext & (1 << (INET_DIAG_VEGASINFO - 1))) { |
344 | struct tcpvegas_info *info; | 341 | struct tcpvegas_info info = { |
345 | 342 | .tcpv_enabled = ca->doing_vegas_now, | |
346 | info = RTA_DATA(__RTA_PUT(skb, INET_DIAG_VEGASINFO, | 343 | .tcpv_rttcnt = ca->cntRTT, |
347 | sizeof(*info))); | 344 | .tcpv_rtt = ca->baseRTT, |
348 | 345 | .tcpv_minrtt = ca->minRTT, | |
349 | info->tcpv_enabled = ca->doing_vegas_now; | 346 | }; |
350 | info->tcpv_rttcnt = ca->cntRTT; | 347 | |
351 | info->tcpv_rtt = ca->baseRTT; | 348 | nla_put(skb, INET_DIAG_VEGASINFO, sizeof(info), &info); |
352 | info->tcpv_minrtt = ca->minRTT; | ||
353 | rtattr_failure: ; | ||
354 | } | 349 | } |
355 | } | 350 | } |
351 | EXPORT_SYMBOL_GPL(tcp_vegas_get_info); | ||
356 | 352 | ||
357 | static struct tcp_congestion_ops tcp_vegas = { | 353 | static struct tcp_congestion_ops tcp_vegas = { |
354 | .flags = TCP_CONG_RTT_STAMP, | ||
358 | .init = tcp_vegas_init, | 355 | .init = tcp_vegas_init, |
359 | .ssthresh = tcp_reno_ssthresh, | 356 | .ssthresh = tcp_reno_ssthresh, |
360 | .cong_avoid = tcp_vegas_cong_avoid, | 357 | .cong_avoid = tcp_vegas_cong_avoid, |
361 | .min_cwnd = tcp_reno_min_cwnd, | 358 | .min_cwnd = tcp_reno_min_cwnd, |
362 | .rtt_sample = tcp_vegas_rtt_calc, | 359 | .pkts_acked = tcp_vegas_pkts_acked, |
363 | .set_state = tcp_vegas_state, | 360 | .set_state = tcp_vegas_state, |
364 | .cwnd_event = tcp_vegas_cwnd_event, | 361 | .cwnd_event = tcp_vegas_cwnd_event, |
365 | .get_info = tcp_vegas_get_info, | 362 | .get_info = tcp_vegas_get_info, |