aboutsummaryrefslogtreecommitdiffstats
path: root/net/dccp/ccids/ccid2.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/dccp/ccids/ccid2.c')
-rw-r--r--net/dccp/ccids/ccid2.c322
1 files changed, 161 insertions, 161 deletions
diff --git a/net/dccp/ccids/ccid2.c b/net/dccp/ccids/ccid2.c
index 0675fd6215c2..a47a8c918ee8 100644
--- a/net/dccp/ccids/ccid2.c
+++ b/net/dccp/ccids/ccid2.c
@@ -33,20 +33,20 @@
33static int ccid2_debug; 33static int ccid2_debug;
34#define ccid2_pr_debug(format, a...) DCCP_PR_DEBUG(ccid2_debug, format, ##a) 34#define ccid2_pr_debug(format, a...) DCCP_PR_DEBUG(ccid2_debug, format, ##a)
35 35
36static void ccid2_hc_tx_check_sanity(const struct ccid2_hc_tx_sock *hctx) 36static void ccid2_hc_tx_check_sanity(const struct ccid2_hc_tx_sock *hc)
37{ 37{
38 int len = 0; 38 int len = 0;
39 int pipe = 0; 39 int pipe = 0;
40 struct ccid2_seq *seqp = hctx->tx_seqh; 40 struct ccid2_seq *seqp = hc->tx_seqh;
41 41
42 /* there is data in the chain */ 42 /* there is data in the chain */
43 if (seqp != hctx->tx_seqt) { 43 if (seqp != hc->tx_seqt) {
44 seqp = seqp->ccid2s_prev; 44 seqp = seqp->ccid2s_prev;
45 len++; 45 len++;
46 if (!seqp->ccid2s_acked) 46 if (!seqp->ccid2s_acked)
47 pipe++; 47 pipe++;
48 48
49 while (seqp != hctx->tx_seqt) { 49 while (seqp != hc->tx_seqt) {
50 struct ccid2_seq *prev = seqp->ccid2s_prev; 50 struct ccid2_seq *prev = seqp->ccid2s_prev;
51 51
52 len++; 52 len++;
@@ -63,30 +63,30 @@ static void ccid2_hc_tx_check_sanity(const struct ccid2_hc_tx_sock *hctx)
63 } 63 }
64 } 64 }
65 65
66 BUG_ON(pipe != hctx->tx_pipe); 66 BUG_ON(pipe != hc->tx_pipe);
67 ccid2_pr_debug("len of chain=%d\n", len); 67 ccid2_pr_debug("len of chain=%d\n", len);
68 68
69 do { 69 do {
70 seqp = seqp->ccid2s_prev; 70 seqp = seqp->ccid2s_prev;
71 len++; 71 len++;
72 } while (seqp != hctx->tx_seqh); 72 } while (seqp != hc->tx_seqh);
73 73
74 ccid2_pr_debug("total len=%d\n", len); 74 ccid2_pr_debug("total len=%d\n", len);
75 BUG_ON(len != hctx->tx_seqbufc * CCID2_SEQBUF_LEN); 75 BUG_ON(len != hc->tx_seqbufc * CCID2_SEQBUF_LEN);
76} 76}
77#else 77#else
78#define ccid2_pr_debug(format, a...) 78#define ccid2_pr_debug(format, a...)
79#define ccid2_hc_tx_check_sanity(hctx) 79#define ccid2_hc_tx_check_sanity(hc)
80#endif 80#endif
81 81
82static int ccid2_hc_tx_alloc_seq(struct ccid2_hc_tx_sock *hctx) 82static int ccid2_hc_tx_alloc_seq(struct ccid2_hc_tx_sock *hc)
83{ 83{
84 struct ccid2_seq *seqp; 84 struct ccid2_seq *seqp;
85 int i; 85 int i;
86 86
87 /* check if we have space to preserve the pointer to the buffer */ 87 /* check if we have space to preserve the pointer to the buffer */
88 if (hctx->tx_seqbufc >= (sizeof(hctx->tx_seqbuf) / 88 if (hc->tx_seqbufc >= (sizeof(hc->tx_seqbuf) /
89 sizeof(struct ccid2_seq *))) 89 sizeof(struct ccid2_seq *)))
90 return -ENOMEM; 90 return -ENOMEM;
91 91
92 /* allocate buffer and initialize linked list */ 92 /* allocate buffer and initialize linked list */
@@ -102,29 +102,29 @@ static int ccid2_hc_tx_alloc_seq(struct ccid2_hc_tx_sock *hctx)
102 seqp->ccid2s_prev = &seqp[CCID2_SEQBUF_LEN - 1]; 102 seqp->ccid2s_prev = &seqp[CCID2_SEQBUF_LEN - 1];
103 103
104 /* This is the first allocation. Initiate the head and tail. */ 104 /* This is the first allocation. Initiate the head and tail. */
105 if (hctx->tx_seqbufc == 0) 105 if (hc->tx_seqbufc == 0)
106 hctx->tx_seqh = hctx->tx_seqt = seqp; 106 hc->tx_seqh = hc->tx_seqt = seqp;
107 else { 107 else {
108 /* link the existing list with the one we just created */ 108 /* link the existing list with the one we just created */
109 hctx->tx_seqh->ccid2s_next = seqp; 109 hc->tx_seqh->ccid2s_next = seqp;
110 seqp->ccid2s_prev = hctx->tx_seqh; 110 seqp->ccid2s_prev = hc->tx_seqh;
111 111
112 hctx->tx_seqt->ccid2s_prev = &seqp[CCID2_SEQBUF_LEN - 1]; 112 hc->tx_seqt->ccid2s_prev = &seqp[CCID2_SEQBUF_LEN - 1];
113 seqp[CCID2_SEQBUF_LEN - 1].ccid2s_next = hctx->tx_seqt; 113 seqp[CCID2_SEQBUF_LEN - 1].ccid2s_next = hc->tx_seqt;
114 } 114 }
115 115
116 /* store the original pointer to the buffer so we can free it */ 116 /* store the original pointer to the buffer so we can free it */
117 hctx->tx_seqbuf[hctx->tx_seqbufc] = seqp; 117 hc->tx_seqbuf[hc->tx_seqbufc] = seqp;
118 hctx->tx_seqbufc++; 118 hc->tx_seqbufc++;
119 119
120 return 0; 120 return 0;
121} 121}
122 122
123static int ccid2_hc_tx_send_packet(struct sock *sk, struct sk_buff *skb) 123static int ccid2_hc_tx_send_packet(struct sock *sk, struct sk_buff *skb)
124{ 124{
125 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk); 125 struct ccid2_hc_tx_sock *hc = ccid2_hc_tx_sk(sk);
126 126
127 if (hctx->tx_pipe < hctx->tx_cwnd) 127 if (hc->tx_pipe < hc->tx_cwnd)
128 return 0; 128 return 0;
129 129
130 return 1; /* XXX CCID should dequeue when ready instead of polling */ 130 return 1; /* XXX CCID should dequeue when ready instead of polling */
@@ -155,10 +155,10 @@ static void ccid2_change_l_ack_ratio(struct sock *sk, u32 val)
155 dp->dccps_l_ack_ratio = val; 155 dp->dccps_l_ack_ratio = val;
156} 156}
157 157
158static void ccid2_change_srtt(struct ccid2_hc_tx_sock *hctx, long val) 158static void ccid2_change_srtt(struct ccid2_hc_tx_sock *hc, long val)
159{ 159{
160 ccid2_pr_debug("change SRTT to %ld\n", val); 160 ccid2_pr_debug("change SRTT to %ld\n", val);
161 hctx->tx_srtt = val; 161 hc->tx_srtt = val;
162} 162}
163 163
164static void ccid2_start_rto_timer(struct sock *sk); 164static void ccid2_start_rto_timer(struct sock *sk);
@@ -166,44 +166,44 @@ static void ccid2_start_rto_timer(struct sock *sk);
166static void ccid2_hc_tx_rto_expire(unsigned long data) 166static void ccid2_hc_tx_rto_expire(unsigned long data)
167{ 167{
168 struct sock *sk = (struct sock *)data; 168 struct sock *sk = (struct sock *)data;
169 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk); 169 struct ccid2_hc_tx_sock *hc = ccid2_hc_tx_sk(sk);
170 long s; 170 long s;
171 171
172 bh_lock_sock(sk); 172 bh_lock_sock(sk);
173 if (sock_owned_by_user(sk)) { 173 if (sock_owned_by_user(sk)) {
174 sk_reset_timer(sk, &hctx->tx_rtotimer, jiffies + HZ / 5); 174 sk_reset_timer(sk, &hc->tx_rtotimer, jiffies + HZ / 5);
175 goto out; 175 goto out;
176 } 176 }
177 177
178 ccid2_pr_debug("RTO_EXPIRE\n"); 178 ccid2_pr_debug("RTO_EXPIRE\n");
179 179
180 ccid2_hc_tx_check_sanity(hctx); 180 ccid2_hc_tx_check_sanity(hc);
181 181
182 /* back-off timer */ 182 /* back-off timer */
183 hctx->tx_rto <<= 1; 183 hc->tx_rto <<= 1;
184 184
185 s = hctx->tx_rto / HZ; 185 s = hc->tx_rto / HZ;
186 if (s > 60) 186 if (s > 60)
187 hctx->tx_rto = 60 * HZ; 187 hc->tx_rto = 60 * HZ;
188 188
189 ccid2_start_rto_timer(sk); 189 ccid2_start_rto_timer(sk);
190 190
191 /* adjust pipe, cwnd etc */ 191 /* adjust pipe, cwnd etc */
192 hctx->tx_ssthresh = hctx->tx_cwnd / 2; 192 hc->tx_ssthresh = hc->tx_cwnd / 2;
193 if (hctx->tx_ssthresh < 2) 193 if (hc->tx_ssthresh < 2)
194 hctx->tx_ssthresh = 2; 194 hc->tx_ssthresh = 2;
195 hctx->tx_cwnd = 1; 195 hc->tx_cwnd = 1;
196 hctx->tx_pipe = 0; 196 hc->tx_pipe = 0;
197 197
198 /* clear state about stuff we sent */ 198 /* clear state about stuff we sent */
199 hctx->tx_seqt = hctx->tx_seqh; 199 hc->tx_seqt = hc->tx_seqh;
200 hctx->tx_packets_acked = 0; 200 hc->tx_packets_acked = 0;
201 201
202 /* clear ack ratio state. */ 202 /* clear ack ratio state. */
203 hctx->tx_rpseq = 0; 203 hc->tx_rpseq = 0;
204 hctx->tx_rpdupack = -1; 204 hc->tx_rpdupack = -1;
205 ccid2_change_l_ack_ratio(sk, 1); 205 ccid2_change_l_ack_ratio(sk, 1);
206 ccid2_hc_tx_check_sanity(hctx); 206 ccid2_hc_tx_check_sanity(hc);
207out: 207out:
208 bh_unlock_sock(sk); 208 bh_unlock_sock(sk);
209 sock_put(sk); 209 sock_put(sk);
@@ -211,40 +211,40 @@ out:
211 211
212static void ccid2_start_rto_timer(struct sock *sk) 212static void ccid2_start_rto_timer(struct sock *sk)
213{ 213{
214 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk); 214 struct ccid2_hc_tx_sock *hc = ccid2_hc_tx_sk(sk);
215 215
216 ccid2_pr_debug("setting RTO timeout=%ld\n", hctx->tx_rto); 216 ccid2_pr_debug("setting RTO timeout=%ld\n", hc->tx_rto);
217 217
218 BUG_ON(timer_pending(&hctx->tx_rtotimer)); 218 BUG_ON(timer_pending(&hc->tx_rtotimer));
219 sk_reset_timer(sk, &hctx->tx_rtotimer, jiffies + hctx->tx_rto); 219 sk_reset_timer(sk, &hc->tx_rtotimer, jiffies + hc->tx_rto);
220} 220}
221 221
222static void ccid2_hc_tx_packet_sent(struct sock *sk, int more, unsigned int len) 222static void ccid2_hc_tx_packet_sent(struct sock *sk, int more, unsigned int len)
223{ 223{
224 struct dccp_sock *dp = dccp_sk(sk); 224 struct dccp_sock *dp = dccp_sk(sk);
225 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk); 225 struct ccid2_hc_tx_sock *hc = ccid2_hc_tx_sk(sk);
226 struct ccid2_seq *next; 226 struct ccid2_seq *next;
227 227
228 hctx->tx_pipe++; 228 hc->tx_pipe++;
229 229
230 hctx->tx_seqh->ccid2s_seq = dp->dccps_gss; 230 hc->tx_seqh->ccid2s_seq = dp->dccps_gss;
231 hctx->tx_seqh->ccid2s_acked = 0; 231 hc->tx_seqh->ccid2s_acked = 0;
232 hctx->tx_seqh->ccid2s_sent = jiffies; 232 hc->tx_seqh->ccid2s_sent = jiffies;
233 233
234 next = hctx->tx_seqh->ccid2s_next; 234 next = hc->tx_seqh->ccid2s_next;
235 /* check if we need to alloc more space */ 235 /* check if we need to alloc more space */
236 if (next == hctx->tx_seqt) { 236 if (next == hc->tx_seqt) {
237 if (ccid2_hc_tx_alloc_seq(hctx)) { 237 if (ccid2_hc_tx_alloc_seq(hc)) {
238 DCCP_CRIT("packet history - out of memory!"); 238 DCCP_CRIT("packet history - out of memory!");
239 /* FIXME: find a more graceful way to bail out */ 239 /* FIXME: find a more graceful way to bail out */
240 return; 240 return;
241 } 241 }
242 next = hctx->tx_seqh->ccid2s_next; 242 next = hc->tx_seqh->ccid2s_next;
243 BUG_ON(next == hctx->tx_seqt); 243 BUG_ON(next == hc->tx_seqt);
244 } 244 }
245 hctx->tx_seqh = next; 245 hc->tx_seqh = next;
246 246
247 ccid2_pr_debug("cwnd=%d pipe=%d\n", hctx->tx_cwnd, hctx->tx_pipe); 247 ccid2_pr_debug("cwnd=%d pipe=%d\n", hc->tx_cwnd, hc->tx_pipe);
248 248
249 /* 249 /*
250 * FIXME: The code below is broken and the variables have been removed 250 * FIXME: The code below is broken and the variables have been removed
@@ -267,12 +267,12 @@ static void ccid2_hc_tx_packet_sent(struct sock *sk, int more, unsigned int len)
267 */ 267 */
268#if 0 268#if 0
269 /* Ack Ratio. Need to maintain a concept of how many windows we sent */ 269 /* Ack Ratio. Need to maintain a concept of how many windows we sent */
270 hctx->tx_arsent++; 270 hc->tx_arsent++;
271 /* We had an ack loss in this window... */ 271 /* We had an ack loss in this window... */
272 if (hctx->tx_ackloss) { 272 if (hc->tx_ackloss) {
273 if (hctx->tx_arsent >= hctx->tx_cwnd) { 273 if (hc->tx_arsent >= hc->tx_cwnd) {
274 hctx->tx_arsent = 0; 274 hc->tx_arsent = 0;
275 hctx->tx_ackloss = 0; 275 hc->tx_ackloss = 0;
276 } 276 }
277 } else { 277 } else {
278 /* No acks lost up to now... */ 278 /* No acks lost up to now... */
@@ -282,28 +282,28 @@ static void ccid2_hc_tx_packet_sent(struct sock *sk, int more, unsigned int len)
282 int denom = dp->dccps_l_ack_ratio * dp->dccps_l_ack_ratio - 282 int denom = dp->dccps_l_ack_ratio * dp->dccps_l_ack_ratio -
283 dp->dccps_l_ack_ratio; 283 dp->dccps_l_ack_ratio;
284 284
285 denom = hctx->tx_cwnd * hctx->tx_cwnd / denom; 285 denom = hc->tx_cwnd * hc->tx_cwnd / denom;
286 286
287 if (hctx->tx_arsent >= denom) { 287 if (hc->tx_arsent >= denom) {
288 ccid2_change_l_ack_ratio(sk, dp->dccps_l_ack_ratio - 1); 288 ccid2_change_l_ack_ratio(sk, dp->dccps_l_ack_ratio - 1);
289 hctx->tx_arsent = 0; 289 hc->tx_arsent = 0;
290 } 290 }
291 } else { 291 } else {
292 /* we can't increase ack ratio further [1] */ 292 /* we can't increase ack ratio further [1] */
293 hctx->tx_arsent = 0; /* or maybe set it to cwnd*/ 293 hc->tx_arsent = 0; /* or maybe set it to cwnd*/
294 } 294 }
295 } 295 }
296#endif 296#endif
297 297
298 /* setup RTO timer */ 298 /* setup RTO timer */
299 if (!timer_pending(&hctx->tx_rtotimer)) 299 if (!timer_pending(&hc->tx_rtotimer))
300 ccid2_start_rto_timer(sk); 300 ccid2_start_rto_timer(sk);
301 301
302#ifdef CONFIG_IP_DCCP_CCID2_DEBUG 302#ifdef CONFIG_IP_DCCP_CCID2_DEBUG
303 do { 303 do {
304 struct ccid2_seq *seqp = hctx->tx_seqt; 304 struct ccid2_seq *seqp = hc->tx_seqt;
305 305
306 while (seqp != hctx->tx_seqh) { 306 while (seqp != hc->tx_seqh) {
307 ccid2_pr_debug("out seq=%llu acked=%d time=%lu\n", 307 ccid2_pr_debug("out seq=%llu acked=%d time=%lu\n",
308 (unsigned long long)seqp->ccid2s_seq, 308 (unsigned long long)seqp->ccid2s_seq,
309 seqp->ccid2s_acked, seqp->ccid2s_sent); 309 seqp->ccid2s_acked, seqp->ccid2s_sent);
@@ -311,7 +311,7 @@ static void ccid2_hc_tx_packet_sent(struct sock *sk, int more, unsigned int len)
311 } 311 }
312 } while (0); 312 } while (0);
313 ccid2_pr_debug("=========\n"); 313 ccid2_pr_debug("=========\n");
314 ccid2_hc_tx_check_sanity(hctx); 314 ccid2_hc_tx_check_sanity(hc);
315#endif 315#endif
316} 316}
317 317
@@ -379,9 +379,9 @@ out_invalid_option:
379 379
380static void ccid2_hc_tx_kill_rto_timer(struct sock *sk) 380static void ccid2_hc_tx_kill_rto_timer(struct sock *sk)
381{ 381{
382 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk); 382 struct ccid2_hc_tx_sock *hc = ccid2_hc_tx_sk(sk);
383 383
384 sk_stop_timer(sk, &hctx->tx_rtotimer); 384 sk_stop_timer(sk, &hc->tx_rtotimer);
385 ccid2_pr_debug("deleted RTO timer\n"); 385 ccid2_pr_debug("deleted RTO timer\n");
386} 386}
387 387
@@ -389,75 +389,75 @@ static inline void ccid2_new_ack(struct sock *sk,
389 struct ccid2_seq *seqp, 389 struct ccid2_seq *seqp,
390 unsigned int *maxincr) 390 unsigned int *maxincr)
391{ 391{
392 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk); 392 struct ccid2_hc_tx_sock *hc = ccid2_hc_tx_sk(sk);
393 393
394 if (hctx->tx_cwnd < hctx->tx_ssthresh) { 394 if (hc->tx_cwnd < hc->tx_ssthresh) {
395 if (*maxincr > 0 && ++hctx->tx_packets_acked == 2) { 395 if (*maxincr > 0 && ++hc->tx_packets_acked == 2) {
396 hctx->tx_cwnd += 1; 396 hc->tx_cwnd += 1;
397 *maxincr -= 1; 397 *maxincr -= 1;
398 hctx->tx_packets_acked = 0; 398 hc->tx_packets_acked = 0;
399 } 399 }
400 } else if (++hctx->tx_packets_acked >= hctx->tx_cwnd) { 400 } else if (++hc->tx_packets_acked >= hc->tx_cwnd) {
401 hctx->tx_cwnd += 1; 401 hc->tx_cwnd += 1;
402 hctx->tx_packets_acked = 0; 402 hc->tx_packets_acked = 0;
403 } 403 }
404 404
405 /* update RTO */ 405 /* update RTO */
406 if (hctx->tx_srtt == -1 || 406 if (hc->tx_srtt == -1 ||
407 time_after(jiffies, hctx->tx_lastrtt + hctx->tx_srtt)) { 407 time_after(jiffies, hc->tx_lastrtt + hc->tx_srtt)) {
408 unsigned long r = (long)jiffies - (long)seqp->ccid2s_sent; 408 unsigned long r = (long)jiffies - (long)seqp->ccid2s_sent;
409 int s; 409 int s;
410 410
411 /* first measurement */ 411 /* first measurement */
412 if (hctx->tx_srtt == -1) { 412 if (hc->tx_srtt == -1) {
413 ccid2_pr_debug("R: %lu Time=%lu seq=%llu\n", 413 ccid2_pr_debug("R: %lu Time=%lu seq=%llu\n",
414 r, jiffies, 414 r, jiffies,
415 (unsigned long long)seqp->ccid2s_seq); 415 (unsigned long long)seqp->ccid2s_seq);
416 ccid2_change_srtt(hctx, r); 416 ccid2_change_srtt(hc, r);
417 hctx->tx_rttvar = r >> 1; 417 hc->tx_rttvar = r >> 1;
418 } else { 418 } else {
419 /* RTTVAR */ 419 /* RTTVAR */
420 long tmp = hctx->tx_srtt - r; 420 long tmp = hc->tx_srtt - r;
421 long srtt; 421 long srtt;
422 422
423 if (tmp < 0) 423 if (tmp < 0)
424 tmp *= -1; 424 tmp *= -1;
425 425
426 tmp >>= 2; 426 tmp >>= 2;
427 hctx->tx_rttvar *= 3; 427 hc->tx_rttvar *= 3;
428 hctx->tx_rttvar >>= 2; 428 hc->tx_rttvar >>= 2;
429 hctx->tx_rttvar += tmp; 429 hc->tx_rttvar += tmp;
430 430
431 /* SRTT */ 431 /* SRTT */
432 srtt = hctx->tx_srtt; 432 srtt = hc->tx_srtt;
433 srtt *= 7; 433 srtt *= 7;
434 srtt >>= 3; 434 srtt >>= 3;
435 tmp = r >> 3; 435 tmp = r >> 3;
436 srtt += tmp; 436 srtt += tmp;
437 ccid2_change_srtt(hctx, srtt); 437 ccid2_change_srtt(hc, srtt);
438 } 438 }
439 s = hctx->tx_rttvar << 2; 439 s = hc->tx_rttvar << 2;
440 /* clock granularity is 1 when based on jiffies */ 440 /* clock granularity is 1 when based on jiffies */
441 if (!s) 441 if (!s)
442 s = 1; 442 s = 1;
443 hctx->tx_rto = hctx->tx_srtt + s; 443 hc->tx_rto = hc->tx_srtt + s;
444 444
445 /* must be at least a second */ 445 /* must be at least a second */
446 s = hctx->tx_rto / HZ; 446 s = hc->tx_rto / HZ;
447 /* DCCP doesn't require this [but I like it cuz my code sux] */ 447 /* DCCP doesn't require this [but I like it cuz my code sux] */
448#if 1 448#if 1
449 if (s < 1) 449 if (s < 1)
450 hctx->tx_rto = HZ; 450 hc->tx_rto = HZ;
451#endif 451#endif
452 /* max 60 seconds */ 452 /* max 60 seconds */
453 if (s > 60) 453 if (s > 60)
454 hctx->tx_rto = HZ * 60; 454 hc->tx_rto = HZ * 60;
455 455
456 hctx->tx_lastrtt = jiffies; 456 hc->tx_lastrtt = jiffies;
457 457
458 ccid2_pr_debug("srtt: %ld rttvar: %ld rto: %ld (HZ=%d) R=%lu\n", 458 ccid2_pr_debug("srtt: %ld rttvar: %ld rto: %ld (HZ=%d) R=%lu\n",
459 hctx->tx_srtt, hctx->tx_rttvar, 459 hc->tx_srtt, hc->tx_rttvar,
460 hctx->tx_rto, HZ, r); 460 hc->tx_rto, HZ, r);
461 } 461 }
462 462
463 /* we got a new ack, so re-start RTO timer */ 463 /* we got a new ack, so re-start RTO timer */
@@ -467,40 +467,40 @@ static inline void ccid2_new_ack(struct sock *sk,
467 467
468static void ccid2_hc_tx_dec_pipe(struct sock *sk) 468static void ccid2_hc_tx_dec_pipe(struct sock *sk)
469{ 469{
470 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk); 470 struct ccid2_hc_tx_sock *hc = ccid2_hc_tx_sk(sk);
471 471
472 if (hctx->tx_pipe == 0) 472 if (hc->tx_pipe == 0)
473 DCCP_BUG("pipe == 0"); 473 DCCP_BUG("pipe == 0");
474 else 474 else
475 hctx->tx_pipe--; 475 hc->tx_pipe--;
476 476
477 if (hctx->tx_pipe == 0) 477 if (hc->tx_pipe == 0)
478 ccid2_hc_tx_kill_rto_timer(sk); 478 ccid2_hc_tx_kill_rto_timer(sk);
479} 479}
480 480
481static void ccid2_congestion_event(struct sock *sk, struct ccid2_seq *seqp) 481static void ccid2_congestion_event(struct sock *sk, struct ccid2_seq *seqp)
482{ 482{
483 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk); 483 struct ccid2_hc_tx_sock *hc = ccid2_hc_tx_sk(sk);
484 484
485 if (time_before(seqp->ccid2s_sent, hctx->tx_last_cong)) { 485 if (time_before(seqp->ccid2s_sent, hc->tx_last_cong)) {
486 ccid2_pr_debug("Multiple losses in an RTT---treating as one\n"); 486 ccid2_pr_debug("Multiple losses in an RTT---treating as one\n");
487 return; 487 return;
488 } 488 }
489 489
490 hctx->tx_last_cong = jiffies; 490 hc->tx_last_cong = jiffies;
491 491
492 hctx->tx_cwnd = hctx->tx_cwnd / 2 ? : 1U; 492 hc->tx_cwnd = hc->tx_cwnd / 2 ? : 1U;
493 hctx->tx_ssthresh = max(hctx->tx_cwnd, 2U); 493 hc->tx_ssthresh = max(hc->tx_cwnd, 2U);
494 494
495 /* Avoid spurious timeouts resulting from Ack Ratio > cwnd */ 495 /* Avoid spurious timeouts resulting from Ack Ratio > cwnd */
496 if (dccp_sk(sk)->dccps_l_ack_ratio > hctx->tx_cwnd) 496 if (dccp_sk(sk)->dccps_l_ack_ratio > hc->tx_cwnd)
497 ccid2_change_l_ack_ratio(sk, hctx->tx_cwnd); 497 ccid2_change_l_ack_ratio(sk, hc->tx_cwnd);
498} 498}
499 499
500static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) 500static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
501{ 501{
502 struct dccp_sock *dp = dccp_sk(sk); 502 struct dccp_sock *dp = dccp_sk(sk);
503 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk); 503 struct ccid2_hc_tx_sock *hc = ccid2_hc_tx_sk(sk);
504 u64 ackno, seqno; 504 u64 ackno, seqno;
505 struct ccid2_seq *seqp; 505 struct ccid2_seq *seqp;
506 unsigned char *vector; 506 unsigned char *vector;
@@ -509,7 +509,7 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
509 int done = 0; 509 int done = 0;
510 unsigned int maxincr = 0; 510 unsigned int maxincr = 0;
511 511
512 ccid2_hc_tx_check_sanity(hctx); 512 ccid2_hc_tx_check_sanity(hc);
513 /* check reverse path congestion */ 513 /* check reverse path congestion */
514 seqno = DCCP_SKB_CB(skb)->dccpd_seq; 514 seqno = DCCP_SKB_CB(skb)->dccpd_seq;
515 515
@@ -518,21 +518,21 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
518 * -sorbo. 518 * -sorbo.
519 */ 519 */
520 /* need to bootstrap */ 520 /* need to bootstrap */
521 if (hctx->tx_rpdupack == -1) { 521 if (hc->tx_rpdupack == -1) {
522 hctx->tx_rpdupack = 0; 522 hc->tx_rpdupack = 0;
523 hctx->tx_rpseq = seqno; 523 hc->tx_rpseq = seqno;
524 } else { 524 } else {
525 /* check if packet is consecutive */ 525 /* check if packet is consecutive */
526 if (dccp_delta_seqno(hctx->tx_rpseq, seqno) == 1) 526 if (dccp_delta_seqno(hc->tx_rpseq, seqno) == 1)
527 hctx->tx_rpseq = seqno; 527 hc->tx_rpseq = seqno;
528 /* it's a later packet */ 528 /* it's a later packet */
529 else if (after48(seqno, hctx->tx_rpseq)) { 529 else if (after48(seqno, hc->tx_rpseq)) {
530 hctx->tx_rpdupack++; 530 hc->tx_rpdupack++;
531 531
532 /* check if we got enough dupacks */ 532 /* check if we got enough dupacks */
533 if (hctx->tx_rpdupack >= NUMDUPACK) { 533 if (hc->tx_rpdupack >= NUMDUPACK) {
534 hctx->tx_rpdupack = -1; /* XXX lame */ 534 hc->tx_rpdupack = -1; /* XXX lame */
535 hctx->tx_rpseq = 0; 535 hc->tx_rpseq = 0;
536 536
537 ccid2_change_l_ack_ratio(sk, 2 * dp->dccps_l_ack_ratio); 537 ccid2_change_l_ack_ratio(sk, 2 * dp->dccps_l_ack_ratio);
538 } 538 }
@@ -541,7 +541,7 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
541 541
542 /* check forward path congestion */ 542 /* check forward path congestion */
543 /* still didn't send out new data packets */ 543 /* still didn't send out new data packets */
544 if (hctx->tx_seqh == hctx->tx_seqt) 544 if (hc->tx_seqh == hc->tx_seqt)
545 return; 545 return;
546 546
547 switch (DCCP_SKB_CB(skb)->dccpd_type) { 547 switch (DCCP_SKB_CB(skb)->dccpd_type) {
@@ -553,14 +553,14 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
553 } 553 }
554 554
555 ackno = DCCP_SKB_CB(skb)->dccpd_ack_seq; 555 ackno = DCCP_SKB_CB(skb)->dccpd_ack_seq;
556 if (after48(ackno, hctx->tx_high_ack)) 556 if (after48(ackno, hc->tx_high_ack))
557 hctx->tx_high_ack = ackno; 557 hc->tx_high_ack = ackno;
558 558
559 seqp = hctx->tx_seqt; 559 seqp = hc->tx_seqt;
560 while (before48(seqp->ccid2s_seq, ackno)) { 560 while (before48(seqp->ccid2s_seq, ackno)) {
561 seqp = seqp->ccid2s_next; 561 seqp = seqp->ccid2s_next;
562 if (seqp == hctx->tx_seqh) { 562 if (seqp == hc->tx_seqh) {
563 seqp = hctx->tx_seqh->ccid2s_prev; 563 seqp = hc->tx_seqh->ccid2s_prev;
564 break; 564 break;
565 } 565 }
566 } 566 }
@@ -570,7 +570,7 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
570 * packets per acknowledgement. Rounding up avoids that cwnd is not 570 * packets per acknowledgement. Rounding up avoids that cwnd is not
571 * advanced when Ack Ratio is 1 and gives a slight edge otherwise. 571 * advanced when Ack Ratio is 1 and gives a slight edge otherwise.
572 */ 572 */
573 if (hctx->tx_cwnd < hctx->tx_ssthresh) 573 if (hc->tx_cwnd < hc->tx_ssthresh)
574 maxincr = DIV_ROUND_UP(dp->dccps_l_ack_ratio, 2); 574 maxincr = DIV_ROUND_UP(dp->dccps_l_ack_ratio, 2);
575 575
576 /* go through all ack vectors */ 576 /* go through all ack vectors */
@@ -589,7 +589,7 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
589 * seqnos. 589 * seqnos.
590 */ 590 */
591 while (after48(seqp->ccid2s_seq, ackno)) { 591 while (after48(seqp->ccid2s_seq, ackno)) {
592 if (seqp == hctx->tx_seqt) { 592 if (seqp == hc->tx_seqt) {
593 done = 1; 593 done = 1;
594 break; 594 break;
595 } 595 }
@@ -621,7 +621,7 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
621 (unsigned long long)seqp->ccid2s_seq); 621 (unsigned long long)seqp->ccid2s_seq);
622 ccid2_hc_tx_dec_pipe(sk); 622 ccid2_hc_tx_dec_pipe(sk);
623 } 623 }
624 if (seqp == hctx->tx_seqt) { 624 if (seqp == hc->tx_seqt) {
625 done = 1; 625 done = 1;
626 break; 626 break;
627 } 627 }
@@ -640,11 +640,11 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
640 /* The state about what is acked should be correct now 640 /* The state about what is acked should be correct now
641 * Check for NUMDUPACK 641 * Check for NUMDUPACK
642 */ 642 */
643 seqp = hctx->tx_seqt; 643 seqp = hc->tx_seqt;
644 while (before48(seqp->ccid2s_seq, hctx->tx_high_ack)) { 644 while (before48(seqp->ccid2s_seq, hc->tx_high_ack)) {
645 seqp = seqp->ccid2s_next; 645 seqp = seqp->ccid2s_next;
646 if (seqp == hctx->tx_seqh) { 646 if (seqp == hc->tx_seqh) {
647 seqp = hctx->tx_seqh->ccid2s_prev; 647 seqp = hc->tx_seqh->ccid2s_prev;
648 break; 648 break;
649 } 649 }
650 } 650 }
@@ -655,7 +655,7 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
655 if (done == NUMDUPACK) 655 if (done == NUMDUPACK)
656 break; 656 break;
657 } 657 }
658 if (seqp == hctx->tx_seqt) 658 if (seqp == hc->tx_seqt)
659 break; 659 break;
660 seqp = seqp->ccid2s_prev; 660 seqp = seqp->ccid2s_prev;
661 } 661 }
@@ -678,86 +678,86 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
678 ccid2_congestion_event(sk, seqp); 678 ccid2_congestion_event(sk, seqp);
679 ccid2_hc_tx_dec_pipe(sk); 679 ccid2_hc_tx_dec_pipe(sk);
680 } 680 }
681 if (seqp == hctx->tx_seqt) 681 if (seqp == hc->tx_seqt)
682 break; 682 break;
683 seqp = seqp->ccid2s_prev; 683 seqp = seqp->ccid2s_prev;
684 } 684 }
685 685
686 hctx->tx_seqt = last_acked; 686 hc->tx_seqt = last_acked;
687 } 687 }
688 688
689 /* trim acked packets in tail */ 689 /* trim acked packets in tail */
690 while (hctx->tx_seqt != hctx->tx_seqh) { 690 while (hc->tx_seqt != hc->tx_seqh) {
691 if (!hctx->tx_seqt->ccid2s_acked) 691 if (!hc->tx_seqt->ccid2s_acked)
692 break; 692 break;
693 693
694 hctx->tx_seqt = hctx->tx_seqt->ccid2s_next; 694 hc->tx_seqt = hc->tx_seqt->ccid2s_next;
695 } 695 }
696 696
697 ccid2_hc_tx_check_sanity(hctx); 697 ccid2_hc_tx_check_sanity(hc);
698} 698}
699 699
700static int ccid2_hc_tx_init(struct ccid *ccid, struct sock *sk) 700static int ccid2_hc_tx_init(struct ccid *ccid, struct sock *sk)
701{ 701{
702 struct ccid2_hc_tx_sock *hctx = ccid_priv(ccid); 702 struct ccid2_hc_tx_sock *hc = ccid_priv(ccid);
703 struct dccp_sock *dp = dccp_sk(sk); 703 struct dccp_sock *dp = dccp_sk(sk);
704 u32 max_ratio; 704 u32 max_ratio;
705 705
706 /* RFC 4341, 5: initialise ssthresh to arbitrarily high (max) value */ 706 /* RFC 4341, 5: initialise ssthresh to arbitrarily high (max) value */
707 hctx->tx_ssthresh = ~0U; 707 hc->tx_ssthresh = ~0U;
708 708
709 /* 709 /*
710 * RFC 4341, 5: "The cwnd parameter is initialized to at most four 710 * RFC 4341, 5: "The cwnd parameter is initialized to at most four
711 * packets for new connections, following the rules from [RFC3390]". 711 * packets for new connections, following the rules from [RFC3390]".
712 * We need to convert the bytes of RFC3390 into the packets of RFC 4341. 712 * We need to convert the bytes of RFC3390 into the packets of RFC 4341.
713 */ 713 */
714 hctx->tx_cwnd = clamp(4380U / dp->dccps_mss_cache, 2U, 4U); 714 hc->tx_cwnd = clamp(4380U / dp->dccps_mss_cache, 2U, 4U);
715 715
716 /* Make sure that Ack Ratio is enabled and within bounds. */ 716 /* Make sure that Ack Ratio is enabled and within bounds. */
717 max_ratio = DIV_ROUND_UP(hctx->tx_cwnd, 2); 717 max_ratio = DIV_ROUND_UP(hc->tx_cwnd, 2);
718 if (dp->dccps_l_ack_ratio == 0 || dp->dccps_l_ack_ratio > max_ratio) 718 if (dp->dccps_l_ack_ratio == 0 || dp->dccps_l_ack_ratio > max_ratio)
719 dp->dccps_l_ack_ratio = max_ratio; 719 dp->dccps_l_ack_ratio = max_ratio;
720 720
721 /* XXX init ~ to window size... */ 721 /* XXX init ~ to window size... */
722 if (ccid2_hc_tx_alloc_seq(hctx)) 722 if (ccid2_hc_tx_alloc_seq(hc))
723 return -ENOMEM; 723 return -ENOMEM;
724 724
725 hctx->tx_rto = 3 * HZ; 725 hc->tx_rto = 3 * HZ;
726 ccid2_change_srtt(hctx, -1); 726 ccid2_change_srtt(hc, -1);
727 hctx->tx_rttvar = -1; 727 hc->tx_rttvar = -1;
728 hctx->tx_rpdupack = -1; 728 hc->tx_rpdupack = -1;
729 hctx->tx_last_cong = jiffies; 729 hc->tx_last_cong = jiffies;
730 setup_timer(&hctx->tx_rtotimer, ccid2_hc_tx_rto_expire, 730 setup_timer(&hc->tx_rtotimer, ccid2_hc_tx_rto_expire,
731 (unsigned long)sk); 731 (unsigned long)sk);
732 732
733 ccid2_hc_tx_check_sanity(hctx); 733 ccid2_hc_tx_check_sanity(hc);
734 return 0; 734 return 0;
735} 735}
736 736
737static void ccid2_hc_tx_exit(struct sock *sk) 737static void ccid2_hc_tx_exit(struct sock *sk)
738{ 738{
739 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk); 739 struct ccid2_hc_tx_sock *hc = ccid2_hc_tx_sk(sk);
740 int i; 740 int i;
741 741
742 ccid2_hc_tx_kill_rto_timer(sk); 742 ccid2_hc_tx_kill_rto_timer(sk);
743 743
744 for (i = 0; i < hctx->tx_seqbufc; i++) 744 for (i = 0; i < hc->tx_seqbufc; i++)
745 kfree(hctx->tx_seqbuf[i]); 745 kfree(hc->tx_seqbuf[i]);
746 hctx->tx_seqbufc = 0; 746 hc->tx_seqbufc = 0;
747} 747}
748 748
749static void ccid2_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) 749static void ccid2_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
750{ 750{
751 const struct dccp_sock *dp = dccp_sk(sk); 751 const struct dccp_sock *dp = dccp_sk(sk);
752 struct ccid2_hc_rx_sock *hcrx = ccid2_hc_rx_sk(sk); 752 struct ccid2_hc_rx_sock *hc = ccid2_hc_rx_sk(sk);
753 753
754 switch (DCCP_SKB_CB(skb)->dccpd_type) { 754 switch (DCCP_SKB_CB(skb)->dccpd_type) {
755 case DCCP_PKT_DATA: 755 case DCCP_PKT_DATA:
756 case DCCP_PKT_DATAACK: 756 case DCCP_PKT_DATAACK:
757 hcrx->rx_data++; 757 hc->rx_data++;
758 if (hcrx->rx_data >= dp->dccps_r_ack_ratio) { 758 if (hc->rx_data >= dp->dccps_r_ack_ratio) {
759 dccp_send_ack(sk); 759 dccp_send_ack(sk);
760 hcrx->rx_data = 0; 760 hc->rx_data = 0;
761 } 761 }
762 break; 762 break;
763 } 763 }