diff options
author | Arnaldo Carvalho de Melo <acme@mandriva.com> | 2006-03-21 01:05:37 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2006-03-21 01:05:37 -0500 |
commit | c0c736db7ef4a7bdc1a28f3de751cc7e9f720313 (patch) | |
tree | 0935933828ed9021920cb5a922506911398c16ab /net/dccp | |
parent | 45329e71eeb6cb483c6e7fe9e6f2849dd2932cb5 (diff) |
[DCCP] ccid2: coding style cleanups
No changes in the logic where made.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dccp')
-rw-r--r-- | net/dccp/ccids/ccid2.c | 76 |
1 files changed, 26 insertions, 50 deletions
diff --git a/net/dccp/ccids/ccid2.c b/net/dccp/ccids/ccid2.c index b40c4569a820..d4f9e2d33453 100644 --- a/net/dccp/ccids/ccid2.c +++ b/net/dccp/ccids/ccid2.c | |||
@@ -37,10 +37,7 @@ | |||
37 | 37 | ||
38 | static int ccid2_debug; | 38 | static int ccid2_debug; |
39 | 39 | ||
40 | #if 0 | 40 | #undef CCID2_DEBUG |
41 | #define CCID2_DEBUG | ||
42 | #endif | ||
43 | |||
44 | #ifdef CCID2_DEBUG | 41 | #ifdef CCID2_DEBUG |
45 | #define ccid2_pr_debug(format, a...) \ | 42 | #define ccid2_pr_debug(format, a...) \ |
46 | do { if (ccid2_debug) \ | 43 | do { if (ccid2_debug) \ |
@@ -56,10 +53,8 @@ static const int ccid2_seq_len = 128; | |||
56 | static void ccid2_hc_tx_check_sanity(const struct ccid2_hc_tx_sock *hctx) | 53 | static void ccid2_hc_tx_check_sanity(const struct ccid2_hc_tx_sock *hctx) |
57 | { | 54 | { |
58 | int len = 0; | 55 | int len = 0; |
59 | struct ccid2_seq *seqp; | ||
60 | int pipe = 0; | 56 | int pipe = 0; |
61 | 57 | struct ccid2_seq *seqp = hctx->ccid2hctx_seqh; | |
62 | seqp = hctx->ccid2hctx_seqh; | ||
63 | 58 | ||
64 | /* there is data in the chain */ | 59 | /* there is data in the chain */ |
65 | if (seqp != hctx->ccid2hctx_seqt) { | 60 | if (seqp != hctx->ccid2hctx_seqt) { |
@@ -69,9 +64,8 @@ static void ccid2_hc_tx_check_sanity(const struct ccid2_hc_tx_sock *hctx) | |||
69 | pipe++; | 64 | pipe++; |
70 | 65 | ||
71 | while (seqp != hctx->ccid2hctx_seqt) { | 66 | while (seqp != hctx->ccid2hctx_seqt) { |
72 | struct ccid2_seq *prev; | 67 | struct ccid2_seq *prev = seqp->ccid2s_prev; |
73 | 68 | ||
74 | prev = seqp->ccid2s_prev; | ||
75 | len++; | 69 | len++; |
76 | if (!prev->ccid2s_acked) | 70 | if (!prev->ccid2s_acked) |
77 | pipe++; | 71 | pipe++; |
@@ -92,7 +86,7 @@ static void ccid2_hc_tx_check_sanity(const struct ccid2_hc_tx_sock *hctx) | |||
92 | seqp = seqp->ccid2s_prev; | 86 | seqp = seqp->ccid2s_prev; |
93 | len++; | 87 | len++; |
94 | BUG_ON(len > ccid2_seq_len); | 88 | BUG_ON(len > ccid2_seq_len); |
95 | } while(seqp != hctx->ccid2hctx_seqh); | 89 | } while (seqp != hctx->ccid2hctx_seqh); |
96 | 90 | ||
97 | BUG_ON(len != ccid2_seq_len); | 91 | BUG_ON(len != ccid2_seq_len); |
98 | ccid2_pr_debug("total len=%d\n", len); | 92 | ccid2_pr_debug("total len=%d\n", len); |
@@ -141,7 +135,7 @@ static void ccid2_change_l_ack_ratio(struct sock *sk, int val) | |||
141 | * -sorbo. | 135 | * -sorbo. |
142 | */ | 136 | */ |
143 | if (val != 2) { | 137 | if (val != 2) { |
144 | struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk); | 138 | const struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk); |
145 | int max = hctx->ccid2hctx_cwnd / 2; | 139 | int max = hctx->ccid2hctx_cwnd / 2; |
146 | 140 | ||
147 | /* round up */ | 141 | /* round up */ |
@@ -179,9 +173,6 @@ static void ccid2_hc_tx_rto_expire(unsigned long data) | |||
179 | struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk); | 173 | struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk); |
180 | long s; | 174 | long s; |
181 | 175 | ||
182 | /* XXX I don't think i'm locking correctly | ||
183 | * -sorbo. | ||
184 | */ | ||
185 | bh_lock_sock(sk); | 176 | bh_lock_sock(sk); |
186 | if (sock_owned_by_user(sk)) { | 177 | if (sock_owned_by_user(sk)) { |
187 | sk_reset_timer(sk, &hctx->ccid2hctx_rtotimer, | 178 | sk_reset_timer(sk, &hctx->ccid2hctx_rtotimer, |
@@ -278,36 +269,33 @@ static void ccid2_hc_tx_packet_sent(struct sock *sk, int more, int len) | |||
278 | /* We had an ack loss in this window... */ | 269 | /* We had an ack loss in this window... */ |
279 | if (hctx->ccid2hctx_ackloss) { | 270 | if (hctx->ccid2hctx_ackloss) { |
280 | if (hctx->ccid2hctx_arsent >= hctx->ccid2hctx_cwnd) { | 271 | if (hctx->ccid2hctx_arsent >= hctx->ccid2hctx_cwnd) { |
281 | hctx->ccid2hctx_arsent = 0; | 272 | hctx->ccid2hctx_arsent = 0; |
282 | hctx->ccid2hctx_ackloss = 0; | 273 | hctx->ccid2hctx_ackloss = 0; |
283 | } | 274 | } |
284 | } | 275 | } else { |
285 | /* No acks lost up to now... */ | 276 | /* No acks lost up to now... */ |
286 | else { | ||
287 | /* decrease ack ratio if enough packets were sent */ | 277 | /* decrease ack ratio if enough packets were sent */ |
288 | if (dp->dccps_l_ack_ratio > 1) { | 278 | if (dp->dccps_l_ack_ratio > 1) { |
289 | /* XXX don't calculate denominator each time */ | 279 | /* XXX don't calculate denominator each time */ |
290 | int denom; | 280 | int denom = dp->dccps_l_ack_ratio * dp->dccps_l_ack_ratio - |
281 | dp->dccps_l_ack_ratio; | ||
291 | 282 | ||
292 | denom = dp->dccps_l_ack_ratio * dp->dccps_l_ack_ratio - | ||
293 | dp->dccps_l_ack_ratio; | ||
294 | denom = hctx->ccid2hctx_cwnd * hctx->ccid2hctx_cwnd / denom; | 283 | denom = hctx->ccid2hctx_cwnd * hctx->ccid2hctx_cwnd / denom; |
295 | 284 | ||
296 | if (hctx->ccid2hctx_arsent >= denom) { | 285 | if (hctx->ccid2hctx_arsent >= denom) { |
297 | ccid2_change_l_ack_ratio(sk, dp->dccps_l_ack_ratio - 1); | 286 | ccid2_change_l_ack_ratio(sk, dp->dccps_l_ack_ratio - 1); |
298 | hctx->ccid2hctx_arsent = 0; | 287 | hctx->ccid2hctx_arsent = 0; |
299 | } | 288 | } |
300 | } | 289 | } else { |
301 | /* we can't increase ack ratio further [1] */ | 290 | /* we can't increase ack ratio further [1] */ |
302 | else { | ||
303 | hctx->ccid2hctx_arsent = 0; /* or maybe set it to cwnd*/ | 291 | hctx->ccid2hctx_arsent = 0; /* or maybe set it to cwnd*/ |
304 | } | 292 | } |
305 | } | 293 | } |
306 | 294 | ||
307 | /* setup RTO timer */ | 295 | /* setup RTO timer */ |
308 | if (!timer_pending(&hctx->ccid2hctx_rtotimer)) { | 296 | if (!timer_pending(&hctx->ccid2hctx_rtotimer)) |
309 | ccid2_start_rto_timer(sk); | 297 | ccid2_start_rto_timer(sk); |
310 | } | 298 | |
311 | #ifdef CCID2_DEBUG | 299 | #ifdef CCID2_DEBUG |
312 | ccid2_pr_debug("pipe=%d\n", hctx->ccid2hctx_pipe); | 300 | ccid2_pr_debug("pipe=%d\n", hctx->ccid2hctx_pipe); |
313 | ccid2_pr_debug("Sent: seq=%llu\n", seq); | 301 | ccid2_pr_debug("Sent: seq=%llu\n", seq); |
@@ -320,7 +308,7 @@ static void ccid2_hc_tx_packet_sent(struct sock *sk, int more, int len) | |||
320 | seqp->ccid2s_sent); | 308 | seqp->ccid2s_sent); |
321 | seqp = seqp->ccid2s_next; | 309 | seqp = seqp->ccid2s_next; |
322 | } | 310 | } |
323 | } while(0); | 311 | } while (0); |
324 | ccid2_pr_debug("=========\n"); | 312 | ccid2_pr_debug("=========\n"); |
325 | ccid2_hc_tx_check_sanity(hctx); | 313 | ccid2_hc_tx_check_sanity(hctx); |
326 | #endif | 314 | #endif |
@@ -378,7 +366,6 @@ static int ccid2_ackvector(struct sock *sk, struct sk_buff *skb, int offset, | |||
378 | *vec = value; | 366 | *vec = value; |
379 | *veclen = len; | 367 | *veclen = len; |
380 | return offset + (opt_ptr - options); | 368 | return offset + (opt_ptr - options); |
381 | break; | ||
382 | } | 369 | } |
383 | } | 370 | } |
384 | 371 | ||
@@ -416,13 +403,11 @@ static inline void ccid2_new_ack(struct sock *sk, | |||
416 | hctx->ccid2hctx_ssacks = 0; | 403 | hctx->ccid2hctx_ssacks = 0; |
417 | *maxincr = *maxincr - 1; | 404 | *maxincr = *maxincr - 1; |
418 | } | 405 | } |
419 | } | 406 | } else { |
420 | /* increased cwnd enough for this single ack */ | 407 | /* increased cwnd enough for this single ack */ |
421 | else { | ||
422 | hctx->ccid2hctx_ssacks = 0; | 408 | hctx->ccid2hctx_ssacks = 0; |
423 | } | 409 | } |
424 | } | 410 | } else { |
425 | else { | ||
426 | hctx->ccid2hctx_ssacks = 0; | 411 | hctx->ccid2hctx_ssacks = 0; |
427 | hctx->ccid2hctx_acks++; | 412 | hctx->ccid2hctx_acks++; |
428 | 413 | ||
@@ -444,8 +429,7 @@ static inline void ccid2_new_ack(struct sock *sk, | |||
444 | r, jiffies, seqp->ccid2s_seq); | 429 | r, jiffies, seqp->ccid2s_seq); |
445 | hctx->ccid2hctx_srtt = r; | 430 | hctx->ccid2hctx_srtt = r; |
446 | hctx->ccid2hctx_rttvar = r >> 1; | 431 | hctx->ccid2hctx_rttvar = r >> 1; |
447 | } | 432 | } else { |
448 | else { | ||
449 | /* RTTVAR */ | 433 | /* RTTVAR */ |
450 | long tmp = hctx->ccid2hctx_srtt - r; | 434 | long tmp = hctx->ccid2hctx_srtt - r; |
451 | if (tmp < 0) | 435 | if (tmp < 0) |
@@ -528,12 +512,10 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
528 | if (hctx->ccid2hctx_rpdupack == -1) { | 512 | if (hctx->ccid2hctx_rpdupack == -1) { |
529 | hctx->ccid2hctx_rpdupack = 0; | 513 | hctx->ccid2hctx_rpdupack = 0; |
530 | hctx->ccid2hctx_rpseq = seqno; | 514 | hctx->ccid2hctx_rpseq = seqno; |
531 | } | 515 | } else { |
532 | else { | ||
533 | /* check if packet is consecutive */ | 516 | /* check if packet is consecutive */ |
534 | if ((hctx->ccid2hctx_rpseq + 1) == seqno) { | 517 | if ((hctx->ccid2hctx_rpseq + 1) == seqno) |
535 | hctx->ccid2hctx_rpseq++; | 518 | hctx->ccid2hctx_rpseq++; |
536 | } | ||
537 | /* it's a later packet */ | 519 | /* it's a later packet */ |
538 | else if (after48(seqno, hctx->ccid2hctx_rpseq)) { | 520 | else if (after48(seqno, hctx->ccid2hctx_rpseq)) { |
539 | hctx->ccid2hctx_rpdupack++; | 521 | hctx->ccid2hctx_rpdupack++; |
@@ -541,7 +523,6 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
541 | /* check if we got enough dupacks */ | 523 | /* check if we got enough dupacks */ |
542 | if (hctx->ccid2hctx_rpdupack >= | 524 | if (hctx->ccid2hctx_rpdupack >= |
543 | hctx->ccid2hctx_numdupack) { | 525 | hctx->ccid2hctx_numdupack) { |
544 | |||
545 | hctx->ccid2hctx_rpdupack = -1; /* XXX lame */ | 526 | hctx->ccid2hctx_rpdupack = -1; /* XXX lame */ |
546 | hctx->ccid2hctx_rpseq = 0; | 527 | hctx->ccid2hctx_rpseq = 0; |
547 | 528 | ||
@@ -559,7 +540,6 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
559 | case DCCP_PKT_ACK: | 540 | case DCCP_PKT_ACK: |
560 | case DCCP_PKT_DATAACK: | 541 | case DCCP_PKT_DATAACK: |
561 | break; | 542 | break; |
562 | |||
563 | default: | 543 | default: |
564 | return; | 544 | return; |
565 | } | 545 | } |
@@ -612,11 +592,9 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
612 | if (state == | 592 | if (state == |
613 | DCCP_ACKVEC_STATE_ECN_MARKED) { | 593 | DCCP_ACKVEC_STATE_ECN_MARKED) { |
614 | loss = 1; | 594 | loss = 1; |
615 | } | 595 | } else |
616 | else { | ||
617 | ccid2_new_ack(sk, seqp, | 596 | ccid2_new_ack(sk, seqp, |
618 | &maxincr); | 597 | &maxincr); |
619 | } | ||
620 | 598 | ||
621 | seqp->ccid2s_acked = 1; | 599 | seqp->ccid2s_acked = 1; |
622 | ccid2_pr_debug("Got ack for %llu\n", | 600 | ccid2_pr_debug("Got ack for %llu\n", |
@@ -648,13 +626,11 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
648 | while (1) { | 626 | while (1) { |
649 | if (seqp->ccid2s_acked) { | 627 | if (seqp->ccid2s_acked) { |
650 | done++; | 628 | done++; |
651 | if (done == hctx->ccid2hctx_numdupack) { | 629 | if (done == hctx->ccid2hctx_numdupack) |
652 | break; | 630 | break; |
653 | } | ||
654 | } | 631 | } |
655 | if (seqp == hctx->ccid2hctx_seqt) { | 632 | if (seqp == hctx->ccid2hctx_seqt) |
656 | break; | 633 | break; |
657 | } | ||
658 | seqp = seqp->ccid2s_prev; | 634 | seqp = seqp->ccid2s_prev; |
659 | } | 635 | } |
660 | 636 | ||
@@ -798,6 +774,6 @@ static __exit void ccid2_module_exit(void) | |||
798 | module_exit(ccid2_module_exit); | 774 | module_exit(ccid2_module_exit); |
799 | 775 | ||
800 | MODULE_AUTHOR("Andrea Bittau <a.bittau@cs.ucl.ac.uk>"); | 776 | MODULE_AUTHOR("Andrea Bittau <a.bittau@cs.ucl.ac.uk>"); |
801 | MODULE_DESCRIPTION("DCCP TCP CCID2 CCID"); | 777 | MODULE_DESCRIPTION("DCCP TCP-Like (CCID2) CCID"); |
802 | MODULE_LICENSE("GPL"); | 778 | MODULE_LICENSE("GPL"); |
803 | MODULE_ALIAS("net-dccp-ccid-2"); | 779 | MODULE_ALIAS("net-dccp-ccid-2"); |