diff options
author | Gerrit Renker <gerrit@erg.abdn.ac.uk> | 2008-09-04 01:30:19 -0400 |
---|---|---|
committer | Gerrit Renker <gerrit@erg.abdn.ac.uk> | 2008-09-04 01:45:33 -0400 |
commit | 1fb87509606cb19f5f603e54c28af7da149049f3 (patch) | |
tree | 64ee5df4e564240effaee323f576443c87d8e5e8 /net/dccp/ccids/ccid2.c | |
parent | 88ddac513a4e7e04234214b600401ec22abfbb46 (diff) |
dccp ccid-2: Remove ccid2hc{tx,rx}_ prefixes
This patch fixes two problems caused by the ubiquitous long "hctx->ccid2htx_"
and "hcrx->ccid2hcrx_" prefixes:
* code becomes hard to read;
* multiple-line statements are almost inevitable even for simple expressions;
The prefixes are not really necessary (compare with "struct tcp_sock").
There had been previous discussion of this on dccp@vger, but so far this was
not followed up (most people agreed that the prefixes are too long).
Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>
Signed-off-by: Leandro Melo de Sales <leandroal@gmail.com>
Diffstat (limited to 'net/dccp/ccids/ccid2.c')
-rw-r--r-- | net/dccp/ccids/ccid2.c | 274 |
1 files changed, 135 insertions, 139 deletions
diff --git a/net/dccp/ccids/ccid2.c b/net/dccp/ccids/ccid2.c index c9ea19a4d85e..9728bbf0acea 100644 --- a/net/dccp/ccids/ccid2.c +++ b/net/dccp/ccids/ccid2.c | |||
@@ -39,16 +39,16 @@ static void ccid2_hc_tx_check_sanity(const struct ccid2_hc_tx_sock *hctx) | |||
39 | { | 39 | { |
40 | int len = 0; | 40 | int len = 0; |
41 | int pipe = 0; | 41 | int pipe = 0; |
42 | struct ccid2_seq *seqp = hctx->ccid2hctx_seqh; | 42 | struct ccid2_seq *seqp = hctx->seqh; |
43 | 43 | ||
44 | /* there is data in the chain */ | 44 | /* there is data in the chain */ |
45 | if (seqp != hctx->ccid2hctx_seqt) { | 45 | if (seqp != hctx->seqt) { |
46 | seqp = seqp->ccid2s_prev; | 46 | seqp = seqp->ccid2s_prev; |
47 | len++; | 47 | len++; |
48 | if (!seqp->ccid2s_acked) | 48 | if (!seqp->ccid2s_acked) |
49 | pipe++; | 49 | pipe++; |
50 | 50 | ||
51 | while (seqp != hctx->ccid2hctx_seqt) { | 51 | while (seqp != hctx->seqt) { |
52 | struct ccid2_seq *prev = seqp->ccid2s_prev; | 52 | struct ccid2_seq *prev = seqp->ccid2s_prev; |
53 | 53 | ||
54 | len++; | 54 | len++; |
@@ -65,16 +65,16 @@ static void ccid2_hc_tx_check_sanity(const struct ccid2_hc_tx_sock *hctx) | |||
65 | } | 65 | } |
66 | } | 66 | } |
67 | 67 | ||
68 | BUG_ON(pipe != hctx->ccid2hctx_pipe); | 68 | BUG_ON(pipe != hctx->pipe); |
69 | ccid2_pr_debug("len of chain=%d\n", len); | 69 | ccid2_pr_debug("len of chain=%d\n", len); |
70 | 70 | ||
71 | do { | 71 | do { |
72 | seqp = seqp->ccid2s_prev; | 72 | seqp = seqp->ccid2s_prev; |
73 | len++; | 73 | len++; |
74 | } while (seqp != hctx->ccid2hctx_seqh); | 74 | } while (seqp != hctx->seqh); |
75 | 75 | ||
76 | ccid2_pr_debug("total len=%d\n", len); | 76 | ccid2_pr_debug("total len=%d\n", len); |
77 | BUG_ON(len != hctx->ccid2hctx_seqbufc * CCID2_SEQBUF_LEN); | 77 | BUG_ON(len != hctx->seqbufc * CCID2_SEQBUF_LEN); |
78 | } | 78 | } |
79 | #else | 79 | #else |
80 | #define ccid2_pr_debug(format, a...) | 80 | #define ccid2_pr_debug(format, a...) |
@@ -87,8 +87,7 @@ static int ccid2_hc_tx_alloc_seq(struct ccid2_hc_tx_sock *hctx) | |||
87 | int i; | 87 | int i; |
88 | 88 | ||
89 | /* check if we have space to preserve the pointer to the buffer */ | 89 | /* check if we have space to preserve the pointer to the buffer */ |
90 | if (hctx->ccid2hctx_seqbufc >= (sizeof(hctx->ccid2hctx_seqbuf) / | 90 | if (hctx->seqbufc >= sizeof(hctx->seqbuf) / sizeof(struct ccid2_seq *)) |
91 | sizeof(struct ccid2_seq*))) | ||
92 | return -ENOMEM; | 91 | return -ENOMEM; |
93 | 92 | ||
94 | /* allocate buffer and initialize linked list */ | 93 | /* allocate buffer and initialize linked list */ |
@@ -104,20 +103,20 @@ static int ccid2_hc_tx_alloc_seq(struct ccid2_hc_tx_sock *hctx) | |||
104 | seqp->ccid2s_prev = &seqp[CCID2_SEQBUF_LEN - 1]; | 103 | seqp->ccid2s_prev = &seqp[CCID2_SEQBUF_LEN - 1]; |
105 | 104 | ||
106 | /* This is the first allocation. Initiate the head and tail. */ | 105 | /* This is the first allocation. Initiate the head and tail. */ |
107 | if (hctx->ccid2hctx_seqbufc == 0) | 106 | if (hctx->seqbufc == 0) |
108 | hctx->ccid2hctx_seqh = hctx->ccid2hctx_seqt = seqp; | 107 | hctx->seqh = hctx->seqt = seqp; |
109 | else { | 108 | else { |
110 | /* link the existing list with the one we just created */ | 109 | /* link the existing list with the one we just created */ |
111 | hctx->ccid2hctx_seqh->ccid2s_next = seqp; | 110 | hctx->seqh->ccid2s_next = seqp; |
112 | seqp->ccid2s_prev = hctx->ccid2hctx_seqh; | 111 | seqp->ccid2s_prev = hctx->seqh; |
113 | 112 | ||
114 | hctx->ccid2hctx_seqt->ccid2s_prev = &seqp[CCID2_SEQBUF_LEN - 1]; | 113 | hctx->seqt->ccid2s_prev = &seqp[CCID2_SEQBUF_LEN - 1]; |
115 | seqp[CCID2_SEQBUF_LEN - 1].ccid2s_next = hctx->ccid2hctx_seqt; | 114 | seqp[CCID2_SEQBUF_LEN - 1].ccid2s_next = hctx->seqt; |
116 | } | 115 | } |
117 | 116 | ||
118 | /* store the original pointer to the buffer so we can free it */ | 117 | /* store the original pointer to the buffer so we can free it */ |
119 | hctx->ccid2hctx_seqbuf[hctx->ccid2hctx_seqbufc] = seqp; | 118 | hctx->seqbuf[hctx->seqbufc] = seqp; |
120 | hctx->ccid2hctx_seqbufc++; | 119 | hctx->seqbufc++; |
121 | 120 | ||
122 | return 0; | 121 | return 0; |
123 | } | 122 | } |
@@ -126,7 +125,7 @@ static int ccid2_hc_tx_send_packet(struct sock *sk, struct sk_buff *skb) | |||
126 | { | 125 | { |
127 | struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk); | 126 | struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk); |
128 | 127 | ||
129 | if (hctx->ccid2hctx_pipe < hctx->ccid2hctx_cwnd) | 128 | if (hctx->pipe < hctx->cwnd) |
130 | return 0; | 129 | return 0; |
131 | 130 | ||
132 | return 1; /* XXX CCID should dequeue when ready instead of polling */ | 131 | return 1; /* XXX CCID should dequeue when ready instead of polling */ |
@@ -135,7 +134,7 @@ static int ccid2_hc_tx_send_packet(struct sock *sk, struct sk_buff *skb) | |||
135 | static void ccid2_change_l_ack_ratio(struct sock *sk, u32 val) | 134 | static void ccid2_change_l_ack_ratio(struct sock *sk, u32 val) |
136 | { | 135 | { |
137 | struct dccp_sock *dp = dccp_sk(sk); | 136 | struct dccp_sock *dp = dccp_sk(sk); |
138 | u32 max_ratio = DIV_ROUND_UP(ccid2_hc_tx_sk(sk)->ccid2hctx_cwnd, 2); | 137 | u32 max_ratio = DIV_ROUND_UP(ccid2_hc_tx_sk(sk)->cwnd, 2); |
139 | 138 | ||
140 | /* | 139 | /* |
141 | * Ensure that Ack Ratio does not exceed ceil(cwnd/2), which is (2) from | 140 | * Ensure that Ack Ratio does not exceed ceil(cwnd/2), which is (2) from |
@@ -160,7 +159,7 @@ static void ccid2_change_l_ack_ratio(struct sock *sk, u32 val) | |||
160 | static void ccid2_change_srtt(struct ccid2_hc_tx_sock *hctx, long val) | 159 | static void ccid2_change_srtt(struct ccid2_hc_tx_sock *hctx, long val) |
161 | { | 160 | { |
162 | ccid2_pr_debug("change SRTT to %ld\n", val); | 161 | ccid2_pr_debug("change SRTT to %ld\n", val); |
163 | hctx->ccid2hctx_srtt = val; | 162 | hctx->srtt = val; |
164 | } | 163 | } |
165 | 164 | ||
166 | static void ccid2_start_rto_timer(struct sock *sk); | 165 | static void ccid2_start_rto_timer(struct sock *sk); |
@@ -173,8 +172,7 @@ static void ccid2_hc_tx_rto_expire(unsigned long data) | |||
173 | 172 | ||
174 | bh_lock_sock(sk); | 173 | bh_lock_sock(sk); |
175 | if (sock_owned_by_user(sk)) { | 174 | if (sock_owned_by_user(sk)) { |
176 | sk_reset_timer(sk, &hctx->ccid2hctx_rtotimer, | 175 | sk_reset_timer(sk, &hctx->rtotimer, jiffies + HZ / 5); |
177 | jiffies + HZ / 5); | ||
178 | goto out; | 176 | goto out; |
179 | } | 177 | } |
180 | 178 | ||
@@ -183,28 +181,28 @@ static void ccid2_hc_tx_rto_expire(unsigned long data) | |||
183 | ccid2_hc_tx_check_sanity(hctx); | 181 | ccid2_hc_tx_check_sanity(hctx); |
184 | 182 | ||
185 | /* back-off timer */ | 183 | /* back-off timer */ |
186 | hctx->ccid2hctx_rto <<= 1; | 184 | hctx->rto <<= 1; |
187 | 185 | ||
188 | s = hctx->ccid2hctx_rto / HZ; | 186 | s = hctx->rto / HZ; |
189 | if (s > 60) | 187 | if (s > 60) |
190 | hctx->ccid2hctx_rto = 60 * HZ; | 188 | hctx->rto = 60 * HZ; |
191 | 189 | ||
192 | ccid2_start_rto_timer(sk); | 190 | ccid2_start_rto_timer(sk); |
193 | 191 | ||
194 | /* adjust pipe, cwnd etc */ | 192 | /* adjust pipe, cwnd etc */ |
195 | hctx->ccid2hctx_ssthresh = hctx->ccid2hctx_cwnd / 2; | 193 | hctx->ssthresh = hctx->cwnd / 2; |
196 | if (hctx->ccid2hctx_ssthresh < 2) | 194 | if (hctx->ssthresh < 2) |
197 | hctx->ccid2hctx_ssthresh = 2; | 195 | hctx->ssthresh = 2; |
198 | hctx->ccid2hctx_cwnd = 1; | 196 | hctx->cwnd = 1; |
199 | hctx->ccid2hctx_pipe = 0; | 197 | hctx->pipe = 0; |
200 | 198 | ||
201 | /* clear state about stuff we sent */ | 199 | /* clear state about stuff we sent */ |
202 | hctx->ccid2hctx_seqt = hctx->ccid2hctx_seqh; | 200 | hctx->seqt = hctx->seqh; |
203 | hctx->ccid2hctx_packets_acked = 0; | 201 | hctx->packets_acked = 0; |
204 | 202 | ||
205 | /* clear ack ratio state. */ | 203 | /* clear ack ratio state. */ |
206 | hctx->ccid2hctx_rpseq = 0; | 204 | hctx->rpseq = 0; |
207 | hctx->ccid2hctx_rpdupack = -1; | 205 | hctx->rpdupack = -1; |
208 | ccid2_change_l_ack_ratio(sk, 1); | 206 | ccid2_change_l_ack_ratio(sk, 1); |
209 | ccid2_hc_tx_check_sanity(hctx); | 207 | ccid2_hc_tx_check_sanity(hctx); |
210 | out: | 208 | out: |
@@ -216,11 +214,11 @@ static void ccid2_start_rto_timer(struct sock *sk) | |||
216 | { | 214 | { |
217 | struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk); | 215 | struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk); |
218 | 216 | ||
219 | ccid2_pr_debug("setting RTO timeout=%ld\n", hctx->ccid2hctx_rto); | 217 | ccid2_pr_debug("setting RTO timeout=%ld\n", hctx->rto); |
220 | 218 | ||
221 | BUG_ON(timer_pending(&hctx->ccid2hctx_rtotimer)); | 219 | BUG_ON(timer_pending(&hctx->rtotimer)); |
222 | sk_reset_timer(sk, &hctx->ccid2hctx_rtotimer, | 220 | sk_reset_timer(sk, &hctx->rtotimer, |
223 | jiffies + hctx->ccid2hctx_rto); | 221 | jiffies + hctx->rto); |
224 | } | 222 | } |
225 | 223 | ||
226 | static void ccid2_hc_tx_packet_sent(struct sock *sk, int more, unsigned int len) | 224 | static void ccid2_hc_tx_packet_sent(struct sock *sk, int more, unsigned int len) |
@@ -229,27 +227,26 @@ static void ccid2_hc_tx_packet_sent(struct sock *sk, int more, unsigned int len) | |||
229 | struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk); | 227 | struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk); |
230 | struct ccid2_seq *next; | 228 | struct ccid2_seq *next; |
231 | 229 | ||
232 | hctx->ccid2hctx_pipe++; | 230 | hctx->pipe++; |
233 | 231 | ||
234 | hctx->ccid2hctx_seqh->ccid2s_seq = dp->dccps_gss; | 232 | hctx->seqh->ccid2s_seq = dp->dccps_gss; |
235 | hctx->ccid2hctx_seqh->ccid2s_acked = 0; | 233 | hctx->seqh->ccid2s_acked = 0; |
236 | hctx->ccid2hctx_seqh->ccid2s_sent = jiffies; | 234 | hctx->seqh->ccid2s_sent = jiffies; |
237 | 235 | ||
238 | next = hctx->ccid2hctx_seqh->ccid2s_next; | 236 | next = hctx->seqh->ccid2s_next; |
239 | /* check if we need to alloc more space */ | 237 | /* check if we need to alloc more space */ |
240 | if (next == hctx->ccid2hctx_seqt) { | 238 | if (next == hctx->seqt) { |
241 | if (ccid2_hc_tx_alloc_seq(hctx)) { | 239 | if (ccid2_hc_tx_alloc_seq(hctx)) { |
242 | DCCP_CRIT("packet history - out of memory!"); | 240 | DCCP_CRIT("packet history - out of memory!"); |
243 | /* FIXME: find a more graceful way to bail out */ | 241 | /* FIXME: find a more graceful way to bail out */ |
244 | return; | 242 | return; |
245 | } | 243 | } |
246 | next = hctx->ccid2hctx_seqh->ccid2s_next; | 244 | next = hctx->seqh->ccid2s_next; |
247 | BUG_ON(next == hctx->ccid2hctx_seqt); | 245 | BUG_ON(next == hctx->seqt); |
248 | } | 246 | } |
249 | hctx->ccid2hctx_seqh = next; | 247 | hctx->seqh = next; |
250 | 248 | ||
251 | ccid2_pr_debug("cwnd=%d pipe=%d\n", hctx->ccid2hctx_cwnd, | 249 | ccid2_pr_debug("cwnd=%d pipe=%d\n", hctx->cwnd, hctx->pipe); |
252 | hctx->ccid2hctx_pipe); | ||
253 | 250 | ||
254 | /* | 251 | /* |
255 | * FIXME: The code below is broken and the variables have been removed | 252 | * FIXME: The code below is broken and the variables have been removed |
@@ -272,12 +269,12 @@ static void ccid2_hc_tx_packet_sent(struct sock *sk, int more, unsigned int len) | |||
272 | */ | 269 | */ |
273 | #if 0 | 270 | #if 0 |
274 | /* Ack Ratio. Need to maintain a concept of how many windows we sent */ | 271 | /* Ack Ratio. Need to maintain a concept of how many windows we sent */ |
275 | hctx->ccid2hctx_arsent++; | 272 | hctx->arsent++; |
276 | /* We had an ack loss in this window... */ | 273 | /* We had an ack loss in this window... */ |
277 | if (hctx->ccid2hctx_ackloss) { | 274 | if (hctx->ackloss) { |
278 | if (hctx->ccid2hctx_arsent >= hctx->ccid2hctx_cwnd) { | 275 | if (hctx->arsent >= hctx->cwnd) { |
279 | hctx->ccid2hctx_arsent = 0; | 276 | hctx->arsent = 0; |
280 | hctx->ccid2hctx_ackloss = 0; | 277 | hctx->ackloss = 0; |
281 | } | 278 | } |
282 | } else { | 279 | } else { |
283 | /* No acks lost up to now... */ | 280 | /* No acks lost up to now... */ |
@@ -287,28 +284,28 @@ static void ccid2_hc_tx_packet_sent(struct sock *sk, int more, unsigned int len) | |||
287 | int denom = dp->dccps_l_ack_ratio * dp->dccps_l_ack_ratio - | 284 | int denom = dp->dccps_l_ack_ratio * dp->dccps_l_ack_ratio - |
288 | dp->dccps_l_ack_ratio; | 285 | dp->dccps_l_ack_ratio; |
289 | 286 | ||
290 | denom = hctx->ccid2hctx_cwnd * hctx->ccid2hctx_cwnd / denom; | 287 | denom = hctx->cwnd * hctx->cwnd / denom; |
291 | 288 | ||
292 | if (hctx->ccid2hctx_arsent >= denom) { | 289 | if (hctx->arsent >= denom) { |
293 | ccid2_change_l_ack_ratio(sk, dp->dccps_l_ack_ratio - 1); | 290 | ccid2_change_l_ack_ratio(sk, dp->dccps_l_ack_ratio - 1); |
294 | hctx->ccid2hctx_arsent = 0; | 291 | hctx->arsent = 0; |
295 | } | 292 | } |
296 | } else { | 293 | } else { |
297 | /* we can't increase ack ratio further [1] */ | 294 | /* we can't increase ack ratio further [1] */ |
298 | hctx->ccid2hctx_arsent = 0; /* or maybe set it to cwnd*/ | 295 | hctx->arsent = 0; /* or maybe set it to cwnd*/ |
299 | } | 296 | } |
300 | } | 297 | } |
301 | #endif | 298 | #endif |
302 | 299 | ||
303 | /* setup RTO timer */ | 300 | /* setup RTO timer */ |
304 | if (!timer_pending(&hctx->ccid2hctx_rtotimer)) | 301 | if (!timer_pending(&hctx->rtotimer)) |
305 | ccid2_start_rto_timer(sk); | 302 | ccid2_start_rto_timer(sk); |
306 | 303 | ||
307 | #ifdef CONFIG_IP_DCCP_CCID2_DEBUG | 304 | #ifdef CONFIG_IP_DCCP_CCID2_DEBUG |
308 | do { | 305 | do { |
309 | struct ccid2_seq *seqp = hctx->ccid2hctx_seqt; | 306 | struct ccid2_seq *seqp = hctx->seqt; |
310 | 307 | ||
311 | while (seqp != hctx->ccid2hctx_seqh) { | 308 | while (seqp != hctx->seqh) { |
312 | ccid2_pr_debug("out seq=%llu acked=%d time=%lu\n", | 309 | ccid2_pr_debug("out seq=%llu acked=%d time=%lu\n", |
313 | (unsigned long long)seqp->ccid2s_seq, | 310 | (unsigned long long)seqp->ccid2s_seq, |
314 | seqp->ccid2s_acked, seqp->ccid2s_sent); | 311 | seqp->ccid2s_acked, seqp->ccid2s_sent); |
@@ -386,7 +383,7 @@ static void ccid2_hc_tx_kill_rto_timer(struct sock *sk) | |||
386 | { | 383 | { |
387 | struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk); | 384 | struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk); |
388 | 385 | ||
389 | sk_stop_timer(sk, &hctx->ccid2hctx_rtotimer); | 386 | sk_stop_timer(sk, &hctx->rtotimer); |
390 | ccid2_pr_debug("deleted RTO timer\n"); | 387 | ccid2_pr_debug("deleted RTO timer\n"); |
391 | } | 388 | } |
392 | 389 | ||
@@ -396,73 +393,73 @@ static inline void ccid2_new_ack(struct sock *sk, | |||
396 | { | 393 | { |
397 | struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk); | 394 | struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk); |
398 | 395 | ||
399 | if (hctx->ccid2hctx_cwnd < hctx->ccid2hctx_ssthresh) { | 396 | if (hctx->cwnd < hctx->ssthresh) { |
400 | if (*maxincr > 0 && ++hctx->ccid2hctx_packets_acked == 2) { | 397 | if (*maxincr > 0 && ++hctx->packets_acked == 2) { |
401 | hctx->ccid2hctx_cwnd += 1; | 398 | hctx->cwnd += 1; |
402 | *maxincr -= 1; | 399 | *maxincr -= 1; |
403 | hctx->ccid2hctx_packets_acked = 0; | 400 | hctx->packets_acked = 0; |
404 | } | 401 | } |
405 | } else if (++hctx->ccid2hctx_packets_acked >= hctx->ccid2hctx_cwnd) { | 402 | } else if (++hctx->packets_acked >= hctx->cwnd) { |
406 | hctx->ccid2hctx_cwnd += 1; | 403 | hctx->cwnd += 1; |
407 | hctx->ccid2hctx_packets_acked = 0; | 404 | hctx->packets_acked = 0; |
408 | } | 405 | } |
409 | 406 | ||
410 | /* update RTO */ | 407 | /* update RTO */ |
411 | if (hctx->ccid2hctx_srtt == -1 || | 408 | if (hctx->srtt == -1 || |
412 | time_after(jiffies, hctx->ccid2hctx_lastrtt + hctx->ccid2hctx_srtt)) { | 409 | time_after(jiffies, hctx->lastrtt + hctx->srtt)) { |
413 | unsigned long r = (long)jiffies - (long)seqp->ccid2s_sent; | 410 | unsigned long r = (long)jiffies - (long)seqp->ccid2s_sent; |
414 | int s; | 411 | int s; |
415 | 412 | ||
416 | /* first measurement */ | 413 | /* first measurement */ |
417 | if (hctx->ccid2hctx_srtt == -1) { | 414 | if (hctx->srtt == -1) { |
418 | ccid2_pr_debug("R: %lu Time=%lu seq=%llu\n", | 415 | ccid2_pr_debug("R: %lu Time=%lu seq=%llu\n", |
419 | r, jiffies, | 416 | r, jiffies, |
420 | (unsigned long long)seqp->ccid2s_seq); | 417 | (unsigned long long)seqp->ccid2s_seq); |
421 | ccid2_change_srtt(hctx, r); | 418 | ccid2_change_srtt(hctx, r); |
422 | hctx->ccid2hctx_rttvar = r >> 1; | 419 | hctx->rttvar = r >> 1; |
423 | } else { | 420 | } else { |
424 | /* RTTVAR */ | 421 | /* RTTVAR */ |
425 | long tmp = hctx->ccid2hctx_srtt - r; | 422 | long tmp = hctx->srtt - r; |
426 | long srtt; | 423 | long srtt; |
427 | 424 | ||
428 | if (tmp < 0) | 425 | if (tmp < 0) |
429 | tmp *= -1; | 426 | tmp *= -1; |
430 | 427 | ||
431 | tmp >>= 2; | 428 | tmp >>= 2; |
432 | hctx->ccid2hctx_rttvar *= 3; | 429 | hctx->rttvar *= 3; |
433 | hctx->ccid2hctx_rttvar >>= 2; | 430 | hctx->rttvar >>= 2; |
434 | hctx->ccid2hctx_rttvar += tmp; | 431 | hctx->rttvar += tmp; |
435 | 432 | ||
436 | /* SRTT */ | 433 | /* SRTT */ |
437 | srtt = hctx->ccid2hctx_srtt; | 434 | srtt = hctx->srtt; |
438 | srtt *= 7; | 435 | srtt *= 7; |
439 | srtt >>= 3; | 436 | srtt >>= 3; |
440 | tmp = r >> 3; | 437 | tmp = r >> 3; |
441 | srtt += tmp; | 438 | srtt += tmp; |
442 | ccid2_change_srtt(hctx, srtt); | 439 | ccid2_change_srtt(hctx, srtt); |
443 | } | 440 | } |
444 | s = hctx->ccid2hctx_rttvar << 2; | 441 | s = hctx->rttvar << 2; |
445 | /* clock granularity is 1 when based on jiffies */ | 442 | /* clock granularity is 1 when based on jiffies */ |
446 | if (!s) | 443 | if (!s) |
447 | s = 1; | 444 | s = 1; |
448 | hctx->ccid2hctx_rto = hctx->ccid2hctx_srtt + s; | 445 | hctx->rto = hctx->srtt + s; |
449 | 446 | ||
450 | /* must be at least a second */ | 447 | /* must be at least a second */ |
451 | s = hctx->ccid2hctx_rto / HZ; | 448 | s = hctx->rto / HZ; |
452 | /* DCCP doesn't require this [but I like it cuz my code sux] */ | 449 | /* DCCP doesn't require this [but I like it cuz my code sux] */ |
453 | #if 1 | 450 | #if 1 |
454 | if (s < 1) | 451 | if (s < 1) |
455 | hctx->ccid2hctx_rto = HZ; | 452 | hctx->rto = HZ; |
456 | #endif | 453 | #endif |
457 | /* max 60 seconds */ | 454 | /* max 60 seconds */ |
458 | if (s > 60) | 455 | if (s > 60) |
459 | hctx->ccid2hctx_rto = HZ * 60; | 456 | hctx->rto = HZ * 60; |
460 | 457 | ||
461 | hctx->ccid2hctx_lastrtt = jiffies; | 458 | hctx->lastrtt = jiffies; |
462 | 459 | ||
463 | ccid2_pr_debug("srtt: %ld rttvar: %ld rto: %ld (HZ=%d) R=%lu\n", | 460 | ccid2_pr_debug("srtt: %ld rttvar: %ld rto: %ld (HZ=%d) R=%lu\n", |
464 | hctx->ccid2hctx_srtt, hctx->ccid2hctx_rttvar, | 461 | hctx->srtt, hctx->rttvar, |
465 | hctx->ccid2hctx_rto, HZ, r); | 462 | hctx->rto, HZ, r); |
466 | } | 463 | } |
467 | 464 | ||
468 | /* we got a new ack, so re-start RTO timer */ | 465 | /* we got a new ack, so re-start RTO timer */ |
@@ -474,12 +471,12 @@ static void ccid2_hc_tx_dec_pipe(struct sock *sk) | |||
474 | { | 471 | { |
475 | struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk); | 472 | struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk); |
476 | 473 | ||
477 | if (hctx->ccid2hctx_pipe == 0) | 474 | if (hctx->pipe == 0) |
478 | DCCP_BUG("pipe == 0"); | 475 | DCCP_BUG("pipe == 0"); |
479 | else | 476 | else |
480 | hctx->ccid2hctx_pipe--; | 477 | hctx->pipe--; |
481 | 478 | ||
482 | if (hctx->ccid2hctx_pipe == 0) | 479 | if (hctx->pipe == 0) |
483 | ccid2_hc_tx_kill_rto_timer(sk); | 480 | ccid2_hc_tx_kill_rto_timer(sk); |
484 | } | 481 | } |
485 | 482 | ||
@@ -487,19 +484,19 @@ static void ccid2_congestion_event(struct sock *sk, struct ccid2_seq *seqp) | |||
487 | { | 484 | { |
488 | struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk); | 485 | struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk); |
489 | 486 | ||
490 | if (time_before(seqp->ccid2s_sent, hctx->ccid2hctx_last_cong)) { | 487 | if (time_before(seqp->ccid2s_sent, hctx->last_cong)) { |
491 | ccid2_pr_debug("Multiple losses in an RTT---treating as one\n"); | 488 | ccid2_pr_debug("Multiple losses in an RTT---treating as one\n"); |
492 | return; | 489 | return; |
493 | } | 490 | } |
494 | 491 | ||
495 | hctx->ccid2hctx_last_cong = jiffies; | 492 | hctx->last_cong = jiffies; |
496 | 493 | ||
497 | hctx->ccid2hctx_cwnd = hctx->ccid2hctx_cwnd / 2 ? : 1U; | 494 | hctx->cwnd = hctx->cwnd / 2 ? : 1U; |
498 | hctx->ccid2hctx_ssthresh = max(hctx->ccid2hctx_cwnd, 2U); | 495 | hctx->ssthresh = max(hctx->cwnd, 2U); |
499 | 496 | ||
500 | /* Avoid spurious timeouts resulting from Ack Ratio > cwnd */ | 497 | /* Avoid spurious timeouts resulting from Ack Ratio > cwnd */ |
501 | if (dccp_sk(sk)->dccps_l_ack_ratio > hctx->ccid2hctx_cwnd) | 498 | if (dccp_sk(sk)->dccps_l_ack_ratio > hctx->cwnd) |
502 | ccid2_change_l_ack_ratio(sk, hctx->ccid2hctx_cwnd); | 499 | ccid2_change_l_ack_ratio(sk, hctx->cwnd); |
503 | } | 500 | } |
504 | 501 | ||
505 | static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | 502 | static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) |
@@ -523,21 +520,21 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
523 | * -sorbo. | 520 | * -sorbo. |
524 | */ | 521 | */ |
525 | /* need to bootstrap */ | 522 | /* need to bootstrap */ |
526 | if (hctx->ccid2hctx_rpdupack == -1) { | 523 | if (hctx->rpdupack == -1) { |
527 | hctx->ccid2hctx_rpdupack = 0; | 524 | hctx->rpdupack = 0; |
528 | hctx->ccid2hctx_rpseq = seqno; | 525 | hctx->rpseq = seqno; |
529 | } else { | 526 | } else { |
530 | /* check if packet is consecutive */ | 527 | /* check if packet is consecutive */ |
531 | if (dccp_delta_seqno(hctx->ccid2hctx_rpseq, seqno) == 1) | 528 | if (dccp_delta_seqno(hctx->rpseq, seqno) == 1) |
532 | hctx->ccid2hctx_rpseq = seqno; | 529 | hctx->rpseq = seqno; |
533 | /* it's a later packet */ | 530 | /* it's a later packet */ |
534 | else if (after48(seqno, hctx->ccid2hctx_rpseq)) { | 531 | else if (after48(seqno, hctx->rpseq)) { |
535 | hctx->ccid2hctx_rpdupack++; | 532 | hctx->rpdupack++; |
536 | 533 | ||
537 | /* check if we got enough dupacks */ | 534 | /* check if we got enough dupacks */ |
538 | if (hctx->ccid2hctx_rpdupack >= NUMDUPACK) { | 535 | if (hctx->rpdupack >= NUMDUPACK) { |
539 | hctx->ccid2hctx_rpdupack = -1; /* XXX lame */ | 536 | hctx->rpdupack = -1; /* XXX lame */ |
540 | hctx->ccid2hctx_rpseq = 0; | 537 | hctx->rpseq = 0; |
541 | 538 | ||
542 | ccid2_change_l_ack_ratio(sk, 2 * dp->dccps_l_ack_ratio); | 539 | ccid2_change_l_ack_ratio(sk, 2 * dp->dccps_l_ack_ratio); |
543 | } | 540 | } |
@@ -546,7 +543,7 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
546 | 543 | ||
547 | /* check forward path congestion */ | 544 | /* check forward path congestion */ |
548 | /* still didn't send out new data packets */ | 545 | /* still didn't send out new data packets */ |
549 | if (hctx->ccid2hctx_seqh == hctx->ccid2hctx_seqt) | 546 | if (hctx->seqh == hctx->seqt) |
550 | return; | 547 | return; |
551 | 548 | ||
552 | switch (DCCP_SKB_CB(skb)->dccpd_type) { | 549 | switch (DCCP_SKB_CB(skb)->dccpd_type) { |
@@ -558,14 +555,14 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
558 | } | 555 | } |
559 | 556 | ||
560 | ackno = DCCP_SKB_CB(skb)->dccpd_ack_seq; | 557 | ackno = DCCP_SKB_CB(skb)->dccpd_ack_seq; |
561 | if (after48(ackno, hctx->ccid2hctx_high_ack)) | 558 | if (after48(ackno, hctx->high_ack)) |
562 | hctx->ccid2hctx_high_ack = ackno; | 559 | hctx->high_ack = ackno; |
563 | 560 | ||
564 | seqp = hctx->ccid2hctx_seqt; | 561 | seqp = hctx->seqt; |
565 | while (before48(seqp->ccid2s_seq, ackno)) { | 562 | while (before48(seqp->ccid2s_seq, ackno)) { |
566 | seqp = seqp->ccid2s_next; | 563 | seqp = seqp->ccid2s_next; |
567 | if (seqp == hctx->ccid2hctx_seqh) { | 564 | if (seqp == hctx->seqh) { |
568 | seqp = hctx->ccid2hctx_seqh->ccid2s_prev; | 565 | seqp = hctx->seqh->ccid2s_prev; |
569 | break; | 566 | break; |
570 | } | 567 | } |
571 | } | 568 | } |
@@ -575,7 +572,7 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
575 | * packets per acknowledgement. Rounding up avoids that cwnd is not | 572 | * packets per acknowledgement. Rounding up avoids that cwnd is not |
576 | * advanced when Ack Ratio is 1 and gives a slight edge otherwise. | 573 | * advanced when Ack Ratio is 1 and gives a slight edge otherwise. |
577 | */ | 574 | */ |
578 | if (hctx->ccid2hctx_cwnd < hctx->ccid2hctx_ssthresh) | 575 | if (hctx->cwnd < hctx->ssthresh) |
579 | maxincr = DIV_ROUND_UP(dp->dccps_l_ack_ratio, 2); | 576 | maxincr = DIV_ROUND_UP(dp->dccps_l_ack_ratio, 2); |
580 | 577 | ||
581 | /* go through all ack vectors */ | 578 | /* go through all ack vectors */ |
@@ -594,7 +591,7 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
594 | * seqnos. | 591 | * seqnos. |
595 | */ | 592 | */ |
596 | while (after48(seqp->ccid2s_seq, ackno)) { | 593 | while (after48(seqp->ccid2s_seq, ackno)) { |
597 | if (seqp == hctx->ccid2hctx_seqt) { | 594 | if (seqp == hctx->seqt) { |
598 | done = 1; | 595 | done = 1; |
599 | break; | 596 | break; |
600 | } | 597 | } |
@@ -626,7 +623,7 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
626 | (unsigned long long)seqp->ccid2s_seq); | 623 | (unsigned long long)seqp->ccid2s_seq); |
627 | ccid2_hc_tx_dec_pipe(sk); | 624 | ccid2_hc_tx_dec_pipe(sk); |
628 | } | 625 | } |
629 | if (seqp == hctx->ccid2hctx_seqt) { | 626 | if (seqp == hctx->seqt) { |
630 | done = 1; | 627 | done = 1; |
631 | break; | 628 | break; |
632 | } | 629 | } |
@@ -645,11 +642,11 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
645 | /* The state about what is acked should be correct now | 642 | /* The state about what is acked should be correct now |
646 | * Check for NUMDUPACK | 643 | * Check for NUMDUPACK |
647 | */ | 644 | */ |
648 | seqp = hctx->ccid2hctx_seqt; | 645 | seqp = hctx->seqt; |
649 | while (before48(seqp->ccid2s_seq, hctx->ccid2hctx_high_ack)) { | 646 | while (before48(seqp->ccid2s_seq, hctx->high_ack)) { |
650 | seqp = seqp->ccid2s_next; | 647 | seqp = seqp->ccid2s_next; |
651 | if (seqp == hctx->ccid2hctx_seqh) { | 648 | if (seqp == hctx->seqh) { |
652 | seqp = hctx->ccid2hctx_seqh->ccid2s_prev; | 649 | seqp = hctx->seqh->ccid2s_prev; |
653 | break; | 650 | break; |
654 | } | 651 | } |
655 | } | 652 | } |
@@ -660,7 +657,7 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
660 | if (done == NUMDUPACK) | 657 | if (done == NUMDUPACK) |
661 | break; | 658 | break; |
662 | } | 659 | } |
663 | if (seqp == hctx->ccid2hctx_seqt) | 660 | if (seqp == hctx->seqt) |
664 | break; | 661 | break; |
665 | seqp = seqp->ccid2s_prev; | 662 | seqp = seqp->ccid2s_prev; |
666 | } | 663 | } |
@@ -683,20 +680,20 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
683 | ccid2_congestion_event(sk, seqp); | 680 | ccid2_congestion_event(sk, seqp); |
684 | ccid2_hc_tx_dec_pipe(sk); | 681 | ccid2_hc_tx_dec_pipe(sk); |
685 | } | 682 | } |
686 | if (seqp == hctx->ccid2hctx_seqt) | 683 | if (seqp == hctx->seqt) |
687 | break; | 684 | break; |
688 | seqp = seqp->ccid2s_prev; | 685 | seqp = seqp->ccid2s_prev; |
689 | } | 686 | } |
690 | 687 | ||
691 | hctx->ccid2hctx_seqt = last_acked; | 688 | hctx->seqt = last_acked; |
692 | } | 689 | } |
693 | 690 | ||
694 | /* trim acked packets in tail */ | 691 | /* trim acked packets in tail */ |
695 | while (hctx->ccid2hctx_seqt != hctx->ccid2hctx_seqh) { | 692 | while (hctx->seqt != hctx->seqh) { |
696 | if (!hctx->ccid2hctx_seqt->ccid2s_acked) | 693 | if (!hctx->seqt->ccid2s_acked) |
697 | break; | 694 | break; |
698 | 695 | ||
699 | hctx->ccid2hctx_seqt = hctx->ccid2hctx_seqt->ccid2s_next; | 696 | hctx->seqt = hctx->seqt->ccid2s_next; |
700 | } | 697 | } |
701 | 698 | ||
702 | ccid2_hc_tx_check_sanity(hctx); | 699 | ccid2_hc_tx_check_sanity(hctx); |
@@ -709,17 +706,17 @@ static int ccid2_hc_tx_init(struct ccid *ccid, struct sock *sk) | |||
709 | u32 max_ratio; | 706 | u32 max_ratio; |
710 | 707 | ||
711 | /* RFC 4341, 5: initialise ssthresh to arbitrarily high (max) value */ | 708 | /* RFC 4341, 5: initialise ssthresh to arbitrarily high (max) value */ |
712 | hctx->ccid2hctx_ssthresh = ~0U; | 709 | hctx->ssthresh = ~0U; |
713 | 710 | ||
714 | /* | 711 | /* |
715 | * RFC 4341, 5: "The cwnd parameter is initialized to at most four | 712 | * RFC 4341, 5: "The cwnd parameter is initialized to at most four |
716 | * packets for new connections, following the rules from [RFC3390]". | 713 | * packets for new connections, following the rules from [RFC3390]". |
717 | * We need to convert the bytes of RFC3390 into the packets of RFC 4341. | 714 | * We need to convert the bytes of RFC3390 into the packets of RFC 4341. |
718 | */ | 715 | */ |
719 | hctx->ccid2hctx_cwnd = clamp(4380U / dp->dccps_mss_cache, 2U, 4U); | 716 | hctx->cwnd = clamp(4380U / dp->dccps_mss_cache, 2U, 4U); |
720 | 717 | ||
721 | /* Make sure that Ack Ratio is enabled and within bounds. */ | 718 | /* Make sure that Ack Ratio is enabled and within bounds. */ |
722 | max_ratio = DIV_ROUND_UP(hctx->ccid2hctx_cwnd, 2); | 719 | max_ratio = DIV_ROUND_UP(hctx->cwnd, 2); |
723 | if (dp->dccps_l_ack_ratio == 0 || dp->dccps_l_ack_ratio > max_ratio) | 720 | if (dp->dccps_l_ack_ratio == 0 || dp->dccps_l_ack_ratio > max_ratio) |
724 | dp->dccps_l_ack_ratio = max_ratio; | 721 | dp->dccps_l_ack_ratio = max_ratio; |
725 | 722 | ||
@@ -727,13 +724,12 @@ static int ccid2_hc_tx_init(struct ccid *ccid, struct sock *sk) | |||
727 | if (ccid2_hc_tx_alloc_seq(hctx)) | 724 | if (ccid2_hc_tx_alloc_seq(hctx)) |
728 | return -ENOMEM; | 725 | return -ENOMEM; |
729 | 726 | ||
730 | hctx->ccid2hctx_rto = 3 * HZ; | 727 | hctx->rto = 3 * HZ; |
731 | ccid2_change_srtt(hctx, -1); | 728 | ccid2_change_srtt(hctx, -1); |
732 | hctx->ccid2hctx_rttvar = -1; | 729 | hctx->rttvar = -1; |
733 | hctx->ccid2hctx_rpdupack = -1; | 730 | hctx->rpdupack = -1; |
734 | hctx->ccid2hctx_last_cong = jiffies; | 731 | hctx->last_cong = jiffies; |
735 | setup_timer(&hctx->ccid2hctx_rtotimer, ccid2_hc_tx_rto_expire, | 732 | setup_timer(&hctx->rtotimer, ccid2_hc_tx_rto_expire, (unsigned long)sk); |
736 | (unsigned long)sk); | ||
737 | 733 | ||
738 | ccid2_hc_tx_check_sanity(hctx); | 734 | ccid2_hc_tx_check_sanity(hctx); |
739 | return 0; | 735 | return 0; |
@@ -746,9 +742,9 @@ static void ccid2_hc_tx_exit(struct sock *sk) | |||
746 | 742 | ||
747 | ccid2_hc_tx_kill_rto_timer(sk); | 743 | ccid2_hc_tx_kill_rto_timer(sk); |
748 | 744 | ||
749 | for (i = 0; i < hctx->ccid2hctx_seqbufc; i++) | 745 | for (i = 0; i < hctx->seqbufc; i++) |
750 | kfree(hctx->ccid2hctx_seqbuf[i]); | 746 | kfree(hctx->seqbuf[i]); |
751 | hctx->ccid2hctx_seqbufc = 0; | 747 | hctx->seqbufc = 0; |
752 | } | 748 | } |
753 | 749 | ||
754 | static void ccid2_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) | 750 | static void ccid2_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) |
@@ -759,10 +755,10 @@ static void ccid2_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
759 | switch (DCCP_SKB_CB(skb)->dccpd_type) { | 755 | switch (DCCP_SKB_CB(skb)->dccpd_type) { |
760 | case DCCP_PKT_DATA: | 756 | case DCCP_PKT_DATA: |
761 | case DCCP_PKT_DATAACK: | 757 | case DCCP_PKT_DATAACK: |
762 | hcrx->ccid2hcrx_data++; | 758 | hcrx->data++; |
763 | if (hcrx->ccid2hcrx_data >= dp->dccps_r_ack_ratio) { | 759 | if (hcrx->data >= dp->dccps_r_ack_ratio) { |
764 | dccp_send_ack(sk); | 760 | dccp_send_ack(sk); |
765 | hcrx->ccid2hcrx_data = 0; | 761 | hcrx->data = 0; |
766 | } | 762 | } |
767 | break; | 763 | break; |
768 | } | 764 | } |