aboutsummaryrefslogtreecommitdiffstats
path: root/net/dccp/ccids
diff options
context:
space:
mode:
authorGerrit Renker <gerrit@erg.abdn.ac.uk>2007-11-24 19:05:51 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 17:54:57 -0500
commit3deeadd74bbf916b502d307222833ffcf68db557 (patch)
tree86f33bdcbab3a6b48157e6aa381a5a1668935ed7 /net/dccp/ccids
parent63df18ad7fb91c65dafc89d3cf94a58a486ad416 (diff)
[CCID2]: Replace cwnd assignment-function with assignment
The current function ccid2_change_cwnd in effect makes only an assignment, as the test whether cwnd has reached 0 is only required when cwnd is halved. This patch simplifies the code by replacing the function with the assignment it performs. Furthermore, since ssthresh derives from cwnd and appears in many assignments and comparisons, the type of ssthresh has also been changed to match that of cwnd. Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk> Signed-off-by: Ian McDonald <ian.mcdonald@jandi.co.nz> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dccp/ccids')
-rw-r--r--net/dccp/ccids/ccid2.c22
-rw-r--r--net/dccp/ccids/ccid2.h2
2 files changed, 8 insertions, 16 deletions
diff --git a/net/dccp/ccids/ccid2.c b/net/dccp/ccids/ccid2.c
index a3c42cd00b00..747fa1c4e42e 100644
--- a/net/dccp/ccids/ccid2.c
+++ b/net/dccp/ccids/ccid2.c
@@ -165,12 +165,6 @@ static void ccid2_change_l_ack_ratio(struct sock *sk, u32 val)
165 dp->dccps_l_ack_ratio = val; 165 dp->dccps_l_ack_ratio = val;
166} 166}
167 167
168static void ccid2_change_cwnd(struct ccid2_hc_tx_sock *hctx, u32 val)
169{
170 hctx->ccid2hctx_cwnd = val? : 1;
171 ccid2_pr_debug("changed cwnd to %u\n", hctx->ccid2hctx_cwnd);
172}
173
174static void ccid2_change_srtt(struct ccid2_hc_tx_sock *hctx, long val) 168static void ccid2_change_srtt(struct ccid2_hc_tx_sock *hctx, long val)
175{ 169{
176 ccid2_pr_debug("change SRTT to %ld\n", val); 170 ccid2_pr_debug("change SRTT to %ld\n", val);
@@ -212,10 +206,10 @@ static void ccid2_hc_tx_rto_expire(unsigned long data)
212 206
213 /* adjust pipe, cwnd etc */ 207 /* adjust pipe, cwnd etc */
214 ccid2_change_pipe(hctx, 0); 208 ccid2_change_pipe(hctx, 0);
215 hctx->ccid2hctx_ssthresh = hctx->ccid2hctx_cwnd >> 1; 209 hctx->ccid2hctx_ssthresh = hctx->ccid2hctx_cwnd / 2;
216 if (hctx->ccid2hctx_ssthresh < 2) 210 if (hctx->ccid2hctx_ssthresh < 2)
217 hctx->ccid2hctx_ssthresh = 2; 211 hctx->ccid2hctx_ssthresh = 2;
218 ccid2_change_cwnd(hctx, 1); 212 hctx->ccid2hctx_cwnd = 1;
219 213
220 /* clear state about stuff we sent */ 214 /* clear state about stuff we sent */
221 hctx->ccid2hctx_seqt = hctx->ccid2hctx_seqh; 215 hctx->ccid2hctx_seqt = hctx->ccid2hctx_seqh;
@@ -440,7 +434,7 @@ static inline void ccid2_new_ack(struct sock *sk,
440 /* increase every 2 acks */ 434 /* increase every 2 acks */
441 hctx->ccid2hctx_ssacks++; 435 hctx->ccid2hctx_ssacks++;
442 if (hctx->ccid2hctx_ssacks == 2) { 436 if (hctx->ccid2hctx_ssacks == 2) {
443 ccid2_change_cwnd(hctx, hctx->ccid2hctx_cwnd+1); 437 hctx->ccid2hctx_cwnd++;
444 hctx->ccid2hctx_ssacks = 0; 438 hctx->ccid2hctx_ssacks = 0;
445 *maxincr = *maxincr - 1; 439 *maxincr = *maxincr - 1;
446 } 440 }
@@ -453,7 +447,7 @@ static inline void ccid2_new_ack(struct sock *sk,
453 hctx->ccid2hctx_acks++; 447 hctx->ccid2hctx_acks++;
454 448
455 if (hctx->ccid2hctx_acks >= hctx->ccid2hctx_cwnd) { 449 if (hctx->ccid2hctx_acks >= hctx->ccid2hctx_cwnd) {
456 ccid2_change_cwnd(hctx, hctx->ccid2hctx_cwnd + 1); 450 hctx->ccid2hctx_cwnd++;
457 hctx->ccid2hctx_acks = 0; 451 hctx->ccid2hctx_acks = 0;
458 } 452 }
459 } 453 }
@@ -543,10 +537,8 @@ static void ccid2_congestion_event(struct sock *sk, struct ccid2_seq *seqp)
543 537
544 hctx->ccid2hctx_last_cong = jiffies; 538 hctx->ccid2hctx_last_cong = jiffies;
545 539
546 ccid2_change_cwnd(hctx, hctx->ccid2hctx_cwnd >> 1); 540 hctx->ccid2hctx_cwnd = hctx->ccid2hctx_cwnd / 2 ? : 1U;
547 hctx->ccid2hctx_ssthresh = hctx->ccid2hctx_cwnd; 541 hctx->ccid2hctx_ssthresh = max(hctx->ccid2hctx_cwnd, 2U);
548 if (hctx->ccid2hctx_ssthresh < 2)
549 hctx->ccid2hctx_ssthresh = 2;
550 542
551 /* Avoid spurious timeouts resulting from Ack Ratio > cwnd */ 543 /* Avoid spurious timeouts resulting from Ack Ratio > cwnd */
552 if (dccp_sk(sk)->dccps_l_ack_ratio > hctx->ccid2hctx_cwnd) 544 if (dccp_sk(sk)->dccps_l_ack_ratio > hctx->ccid2hctx_cwnd)
@@ -759,7 +751,7 @@ static int ccid2_hc_tx_init(struct ccid *ccid, struct sock *sk)
759 u32 max_ratio; 751 u32 max_ratio;
760 752
761 /* RFC 4341, 5: initialise ssthresh to arbitrarily high (max) value */ 753 /* RFC 4341, 5: initialise ssthresh to arbitrarily high (max) value */
762 hctx->ccid2hctx_ssthresh = ~0; 754 hctx->ccid2hctx_ssthresh = ~0U;
763 755
764 /* 756 /*
765 * RFC 4341, 5: "The cwnd parameter is initialized to at most four 757 * RFC 4341, 5: "The cwnd parameter is initialized to at most four
diff --git a/net/dccp/ccids/ccid2.h b/net/dccp/ccids/ccid2.h
index 443f08a667a2..b72e9556a155 100644
--- a/net/dccp/ccids/ccid2.h
+++ b/net/dccp/ccids/ccid2.h
@@ -50,9 +50,9 @@ struct ccid2_seq {
50*/ 50*/
51struct ccid2_hc_tx_sock { 51struct ccid2_hc_tx_sock {
52 u32 ccid2hctx_cwnd; 52 u32 ccid2hctx_cwnd;
53 u32 ccid2hctx_ssthresh;
53 int ccid2hctx_ssacks; 54 int ccid2hctx_ssacks;
54 int ccid2hctx_acks; 55 int ccid2hctx_acks;
55 unsigned int ccid2hctx_ssthresh;
56 int ccid2hctx_pipe; 56 int ccid2hctx_pipe;
57 struct ccid2_seq *ccid2hctx_seqbuf[CCID2_SEQBUF_MAX]; 57 struct ccid2_seq *ccid2hctx_seqbuf[CCID2_SEQBUF_MAX];
58 int ccid2hctx_seqbufc; 58 int ccid2hctx_seqbufc;