aboutsummaryrefslogtreecommitdiffstats
path: root/net/dccp/ccids
diff options
context:
space:
mode:
authorGerrit Renker <gerrit@erg.abdn.ac.uk>2009-10-04 20:53:10 -0400
committerDavid S. Miller <davem@davemloft.net>2009-10-07 16:51:21 -0400
commitb1c00fe3cf8f54d97d20cdf196145a106f04bd63 (patch)
tree89a1e28ee2265d8b6d2f07c0fa1c2343ff264f8f /net/dccp/ccids
parent78122a52b39c9527fa3a32afbb6572964c17c651 (diff)
dccp ccid-2: Overhaul CCID naming convention 1/2
This patch starts a less problematic naming convention for CCID structs. The old naming convention used 'hc{tx,rx}->ccid?hc{tx,rx}->...' as recurring prefixes, which made the code * hard to write (not easy to fit into 80 characters); * hard to read (most of the space is occupied by prefixes). The new naming scheme: * struct entries for the TX socket are prefixed by 'tx_'; * and those for the RX socket are prefixed by 'rx_'. The identifiers then remain distinguishable when grep-ing through the tree: (a) RX/TX sockets are distinguished by the naming scheme, (b) individual CCIDs are distinguished by filename (ccid{2,3,4}.{c,h}). This first patch implements the scheme for CCID-2. Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk> Acked-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.c273
-rw-r--r--net/dccp/ccids/ccid2.h46
2 files changed, 158 insertions, 161 deletions
diff --git a/net/dccp/ccids/ccid2.c b/net/dccp/ccids/ccid2.c
index e8cf99e880b0..0675fd6215c2 100644
--- a/net/dccp/ccids/ccid2.c
+++ b/net/dccp/ccids/ccid2.c
@@ -37,16 +37,16 @@ static void ccid2_hc_tx_check_sanity(const struct ccid2_hc_tx_sock *hctx)
37{ 37{
38 int len = 0; 38 int len = 0;
39 int pipe = 0; 39 int pipe = 0;
40 struct ccid2_seq *seqp = hctx->ccid2hctx_seqh; 40 struct ccid2_seq *seqp = hctx->tx_seqh;
41 41
42 /* there is data in the chain */ 42 /* there is data in the chain */
43 if (seqp != hctx->ccid2hctx_seqt) { 43 if (seqp != hctx->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->ccid2hctx_seqt) { 49 while (seqp != hctx->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,16 +63,16 @@ 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->ccid2hctx_pipe); 66 BUG_ON(pipe != hctx->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->ccid2hctx_seqh); 72 } while (seqp != hctx->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->ccid2hctx_seqbufc * CCID2_SEQBUF_LEN); 75 BUG_ON(len != hctx->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...)
@@ -85,8 +85,8 @@ static int ccid2_hc_tx_alloc_seq(struct ccid2_hc_tx_sock *hctx)
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->ccid2hctx_seqbufc >= (sizeof(hctx->ccid2hctx_seqbuf) / 88 if (hctx->tx_seqbufc >= (sizeof(hctx->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,20 +102,20 @@ 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->ccid2hctx_seqbufc == 0) 105 if (hctx->tx_seqbufc == 0)
106 hctx->ccid2hctx_seqh = hctx->ccid2hctx_seqt = seqp; 106 hctx->tx_seqh = hctx->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->ccid2hctx_seqh->ccid2s_next = seqp; 109 hctx->tx_seqh->ccid2s_next = seqp;
110 seqp->ccid2s_prev = hctx->ccid2hctx_seqh; 110 seqp->ccid2s_prev = hctx->tx_seqh;
111 111
112 hctx->ccid2hctx_seqt->ccid2s_prev = &seqp[CCID2_SEQBUF_LEN - 1]; 112 hctx->tx_seqt->ccid2s_prev = &seqp[CCID2_SEQBUF_LEN - 1];
113 seqp[CCID2_SEQBUF_LEN - 1].ccid2s_next = hctx->ccid2hctx_seqt; 113 seqp[CCID2_SEQBUF_LEN - 1].ccid2s_next = hctx->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->ccid2hctx_seqbuf[hctx->ccid2hctx_seqbufc] = seqp; 117 hctx->tx_seqbuf[hctx->tx_seqbufc] = seqp;
118 hctx->ccid2hctx_seqbufc++; 118 hctx->tx_seqbufc++;
119 119
120 return 0; 120 return 0;
121} 121}
@@ -124,7 +124,7 @@ static 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 *hctx = ccid2_hc_tx_sk(sk);
126 126
127 if (hctx->ccid2hctx_pipe < hctx->ccid2hctx_cwnd) 127 if (hctx->tx_pipe < hctx->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 */
@@ -133,7 +133,7 @@ static int ccid2_hc_tx_send_packet(struct sock *sk, struct sk_buff *skb)
133static void ccid2_change_l_ack_ratio(struct sock *sk, u32 val) 133static void ccid2_change_l_ack_ratio(struct sock *sk, u32 val)
134{ 134{
135 struct dccp_sock *dp = dccp_sk(sk); 135 struct dccp_sock *dp = dccp_sk(sk);
136 u32 max_ratio = DIV_ROUND_UP(ccid2_hc_tx_sk(sk)->ccid2hctx_cwnd, 2); 136 u32 max_ratio = DIV_ROUND_UP(ccid2_hc_tx_sk(sk)->tx_cwnd, 2);
137 137
138 /* 138 /*
139 * Ensure that Ack Ratio does not exceed ceil(cwnd/2), which is (2) from 139 * Ensure that Ack Ratio does not exceed ceil(cwnd/2), which is (2) from
@@ -158,7 +158,7 @@ static void ccid2_change_l_ack_ratio(struct sock *sk, u32 val)
158static void ccid2_change_srtt(struct ccid2_hc_tx_sock *hctx, long val) 158static void ccid2_change_srtt(struct ccid2_hc_tx_sock *hctx, 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->ccid2hctx_srtt = val; 161 hctx->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);
@@ -171,8 +171,7 @@ static void ccid2_hc_tx_rto_expire(unsigned long data)
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->ccid2hctx_rtotimer, 174 sk_reset_timer(sk, &hctx->tx_rtotimer, jiffies + HZ / 5);
175 jiffies + HZ / 5);
176 goto out; 175 goto out;
177 } 176 }
178 177
@@ -181,28 +180,28 @@ static void ccid2_hc_tx_rto_expire(unsigned long data)
181 ccid2_hc_tx_check_sanity(hctx); 180 ccid2_hc_tx_check_sanity(hctx);
182 181
183 /* back-off timer */ 182 /* back-off timer */
184 hctx->ccid2hctx_rto <<= 1; 183 hctx->tx_rto <<= 1;
185 184
186 s = hctx->ccid2hctx_rto / HZ; 185 s = hctx->tx_rto / HZ;
187 if (s > 60) 186 if (s > 60)
188 hctx->ccid2hctx_rto = 60 * HZ; 187 hctx->tx_rto = 60 * HZ;
189 188
190 ccid2_start_rto_timer(sk); 189 ccid2_start_rto_timer(sk);
191 190
192 /* adjust pipe, cwnd etc */ 191 /* adjust pipe, cwnd etc */
193 hctx->ccid2hctx_ssthresh = hctx->ccid2hctx_cwnd / 2; 192 hctx->tx_ssthresh = hctx->tx_cwnd / 2;
194 if (hctx->ccid2hctx_ssthresh < 2) 193 if (hctx->tx_ssthresh < 2)
195 hctx->ccid2hctx_ssthresh = 2; 194 hctx->tx_ssthresh = 2;
196 hctx->ccid2hctx_cwnd = 1; 195 hctx->tx_cwnd = 1;
197 hctx->ccid2hctx_pipe = 0; 196 hctx->tx_pipe = 0;
198 197
199 /* clear state about stuff we sent */ 198 /* clear state about stuff we sent */
200 hctx->ccid2hctx_seqt = hctx->ccid2hctx_seqh; 199 hctx->tx_seqt = hctx->tx_seqh;
201 hctx->ccid2hctx_packets_acked = 0; 200 hctx->tx_packets_acked = 0;
202 201
203 /* clear ack ratio state. */ 202 /* clear ack ratio state. */
204 hctx->ccid2hctx_rpseq = 0; 203 hctx->tx_rpseq = 0;
205 hctx->ccid2hctx_rpdupack = -1; 204 hctx->tx_rpdupack = -1;
206 ccid2_change_l_ack_ratio(sk, 1); 205 ccid2_change_l_ack_ratio(sk, 1);
207 ccid2_hc_tx_check_sanity(hctx); 206 ccid2_hc_tx_check_sanity(hctx);
208out: 207out:
@@ -214,11 +213,10 @@ static void ccid2_start_rto_timer(struct sock *sk)
214{ 213{
215 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk); 214 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
216 215
217 ccid2_pr_debug("setting RTO timeout=%ld\n", hctx->ccid2hctx_rto); 216 ccid2_pr_debug("setting RTO timeout=%ld\n", hctx->tx_rto);
218 217
219 BUG_ON(timer_pending(&hctx->ccid2hctx_rtotimer)); 218 BUG_ON(timer_pending(&hctx->tx_rtotimer));
220 sk_reset_timer(sk, &hctx->ccid2hctx_rtotimer, 219 sk_reset_timer(sk, &hctx->tx_rtotimer, jiffies + hctx->tx_rto);
221 jiffies + hctx->ccid2hctx_rto);
222} 220}
223 221
224static 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)
@@ -227,27 +225,26 @@ static void ccid2_hc_tx_packet_sent(struct sock *sk, int more, unsigned int len)
227 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk); 225 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
228 struct ccid2_seq *next; 226 struct ccid2_seq *next;
229 227
230 hctx->ccid2hctx_pipe++; 228 hctx->tx_pipe++;
231 229
232 hctx->ccid2hctx_seqh->ccid2s_seq = dp->dccps_gss; 230 hctx->tx_seqh->ccid2s_seq = dp->dccps_gss;
233 hctx->ccid2hctx_seqh->ccid2s_acked = 0; 231 hctx->tx_seqh->ccid2s_acked = 0;
234 hctx->ccid2hctx_seqh->ccid2s_sent = jiffies; 232 hctx->tx_seqh->ccid2s_sent = jiffies;
235 233
236 next = hctx->ccid2hctx_seqh->ccid2s_next; 234 next = hctx->tx_seqh->ccid2s_next;
237 /* check if we need to alloc more space */ 235 /* check if we need to alloc more space */
238 if (next == hctx->ccid2hctx_seqt) { 236 if (next == hctx->tx_seqt) {
239 if (ccid2_hc_tx_alloc_seq(hctx)) { 237 if (ccid2_hc_tx_alloc_seq(hctx)) {
240 DCCP_CRIT("packet history - out of memory!"); 238 DCCP_CRIT("packet history - out of memory!");
241 /* FIXME: find a more graceful way to bail out */ 239 /* FIXME: find a more graceful way to bail out */
242 return; 240 return;
243 } 241 }
244 next = hctx->ccid2hctx_seqh->ccid2s_next; 242 next = hctx->tx_seqh->ccid2s_next;
245 BUG_ON(next == hctx->ccid2hctx_seqt); 243 BUG_ON(next == hctx->tx_seqt);
246 } 244 }
247 hctx->ccid2hctx_seqh = next; 245 hctx->tx_seqh = next;
248 246
249 ccid2_pr_debug("cwnd=%d pipe=%d\n", hctx->ccid2hctx_cwnd, 247 ccid2_pr_debug("cwnd=%d pipe=%d\n", hctx->tx_cwnd, hctx->tx_pipe);
250 hctx->ccid2hctx_pipe);
251 248
252 /* 249 /*
253 * 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
@@ -270,12 +267,12 @@ static void ccid2_hc_tx_packet_sent(struct sock *sk, int more, unsigned int len)
270 */ 267 */
271#if 0 268#if 0
272 /* 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 */
273 hctx->ccid2hctx_arsent++; 270 hctx->tx_arsent++;
274 /* We had an ack loss in this window... */ 271 /* We had an ack loss in this window... */
275 if (hctx->ccid2hctx_ackloss) { 272 if (hctx->tx_ackloss) {
276 if (hctx->ccid2hctx_arsent >= hctx->ccid2hctx_cwnd) { 273 if (hctx->tx_arsent >= hctx->tx_cwnd) {
277 hctx->ccid2hctx_arsent = 0; 274 hctx->tx_arsent = 0;
278 hctx->ccid2hctx_ackloss = 0; 275 hctx->tx_ackloss = 0;
279 } 276 }
280 } else { 277 } else {
281 /* No acks lost up to now... */ 278 /* No acks lost up to now... */
@@ -285,28 +282,28 @@ static void ccid2_hc_tx_packet_sent(struct sock *sk, int more, unsigned int len)
285 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 -
286 dp->dccps_l_ack_ratio; 283 dp->dccps_l_ack_ratio;
287 284
288 denom = hctx->ccid2hctx_cwnd * hctx->ccid2hctx_cwnd / denom; 285 denom = hctx->tx_cwnd * hctx->tx_cwnd / denom;
289 286
290 if (hctx->ccid2hctx_arsent >= denom) { 287 if (hctx->tx_arsent >= denom) {
291 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);
292 hctx->ccid2hctx_arsent = 0; 289 hctx->tx_arsent = 0;
293 } 290 }
294 } else { 291 } else {
295 /* we can't increase ack ratio further [1] */ 292 /* we can't increase ack ratio further [1] */
296 hctx->ccid2hctx_arsent = 0; /* or maybe set it to cwnd*/ 293 hctx->tx_arsent = 0; /* or maybe set it to cwnd*/
297 } 294 }
298 } 295 }
299#endif 296#endif
300 297
301 /* setup RTO timer */ 298 /* setup RTO timer */
302 if (!timer_pending(&hctx->ccid2hctx_rtotimer)) 299 if (!timer_pending(&hctx->tx_rtotimer))
303 ccid2_start_rto_timer(sk); 300 ccid2_start_rto_timer(sk);
304 301
305#ifdef CONFIG_IP_DCCP_CCID2_DEBUG 302#ifdef CONFIG_IP_DCCP_CCID2_DEBUG
306 do { 303 do {
307 struct ccid2_seq *seqp = hctx->ccid2hctx_seqt; 304 struct ccid2_seq *seqp = hctx->tx_seqt;
308 305
309 while (seqp != hctx->ccid2hctx_seqh) { 306 while (seqp != hctx->tx_seqh) {
310 ccid2_pr_debug("out seq=%llu acked=%d time=%lu\n", 307 ccid2_pr_debug("out seq=%llu acked=%d time=%lu\n",
311 (unsigned long long)seqp->ccid2s_seq, 308 (unsigned long long)seqp->ccid2s_seq,
312 seqp->ccid2s_acked, seqp->ccid2s_sent); 309 seqp->ccid2s_acked, seqp->ccid2s_sent);
@@ -384,7 +381,7 @@ static void ccid2_hc_tx_kill_rto_timer(struct sock *sk)
384{ 381{
385 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk); 382 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
386 383
387 sk_stop_timer(sk, &hctx->ccid2hctx_rtotimer); 384 sk_stop_timer(sk, &hctx->tx_rtotimer);
388 ccid2_pr_debug("deleted RTO timer\n"); 385 ccid2_pr_debug("deleted RTO timer\n");
389} 386}
390 387
@@ -394,73 +391,73 @@ static inline void ccid2_new_ack(struct sock *sk,
394{ 391{
395 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk); 392 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
396 393
397 if (hctx->ccid2hctx_cwnd < hctx->ccid2hctx_ssthresh) { 394 if (hctx->tx_cwnd < hctx->tx_ssthresh) {
398 if (*maxincr > 0 && ++hctx->ccid2hctx_packets_acked == 2) { 395 if (*maxincr > 0 && ++hctx->tx_packets_acked == 2) {
399 hctx->ccid2hctx_cwnd += 1; 396 hctx->tx_cwnd += 1;
400 *maxincr -= 1; 397 *maxincr -= 1;
401 hctx->ccid2hctx_packets_acked = 0; 398 hctx->tx_packets_acked = 0;
402 } 399 }
403 } else if (++hctx->ccid2hctx_packets_acked >= hctx->ccid2hctx_cwnd) { 400 } else if (++hctx->tx_packets_acked >= hctx->tx_cwnd) {
404 hctx->ccid2hctx_cwnd += 1; 401 hctx->tx_cwnd += 1;
405 hctx->ccid2hctx_packets_acked = 0; 402 hctx->tx_packets_acked = 0;
406 } 403 }
407 404
408 /* update RTO */ 405 /* update RTO */
409 if (hctx->ccid2hctx_srtt == -1 || 406 if (hctx->tx_srtt == -1 ||
410 time_after(jiffies, hctx->ccid2hctx_lastrtt + hctx->ccid2hctx_srtt)) { 407 time_after(jiffies, hctx->tx_lastrtt + hctx->tx_srtt)) {
411 unsigned long r = (long)jiffies - (long)seqp->ccid2s_sent; 408 unsigned long r = (long)jiffies - (long)seqp->ccid2s_sent;
412 int s; 409 int s;
413 410
414 /* first measurement */ 411 /* first measurement */
415 if (hctx->ccid2hctx_srtt == -1) { 412 if (hctx->tx_srtt == -1) {
416 ccid2_pr_debug("R: %lu Time=%lu seq=%llu\n", 413 ccid2_pr_debug("R: %lu Time=%lu seq=%llu\n",
417 r, jiffies, 414 r, jiffies,
418 (unsigned long long)seqp->ccid2s_seq); 415 (unsigned long long)seqp->ccid2s_seq);
419 ccid2_change_srtt(hctx, r); 416 ccid2_change_srtt(hctx, r);
420 hctx->ccid2hctx_rttvar = r >> 1; 417 hctx->tx_rttvar = r >> 1;
421 } else { 418 } else {
422 /* RTTVAR */ 419 /* RTTVAR */
423 long tmp = hctx->ccid2hctx_srtt - r; 420 long tmp = hctx->tx_srtt - r;
424 long srtt; 421 long srtt;
425 422
426 if (tmp < 0) 423 if (tmp < 0)
427 tmp *= -1; 424 tmp *= -1;
428 425
429 tmp >>= 2; 426 tmp >>= 2;
430 hctx->ccid2hctx_rttvar *= 3; 427 hctx->tx_rttvar *= 3;
431 hctx->ccid2hctx_rttvar >>= 2; 428 hctx->tx_rttvar >>= 2;
432 hctx->ccid2hctx_rttvar += tmp; 429 hctx->tx_rttvar += tmp;
433 430
434 /* SRTT */ 431 /* SRTT */
435 srtt = hctx->ccid2hctx_srtt; 432 srtt = hctx->tx_srtt;
436 srtt *= 7; 433 srtt *= 7;
437 srtt >>= 3; 434 srtt >>= 3;
438 tmp = r >> 3; 435 tmp = r >> 3;
439 srtt += tmp; 436 srtt += tmp;
440 ccid2_change_srtt(hctx, srtt); 437 ccid2_change_srtt(hctx, srtt);
441 } 438 }
442 s = hctx->ccid2hctx_rttvar << 2; 439 s = hctx->tx_rttvar << 2;
443 /* clock granularity is 1 when based on jiffies */ 440 /* clock granularity is 1 when based on jiffies */
444 if (!s) 441 if (!s)
445 s = 1; 442 s = 1;
446 hctx->ccid2hctx_rto = hctx->ccid2hctx_srtt + s; 443 hctx->tx_rto = hctx->tx_srtt + s;
447 444
448 /* must be at least a second */ 445 /* must be at least a second */
449 s = hctx->ccid2hctx_rto / HZ; 446 s = hctx->tx_rto / HZ;
450 /* 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] */
451#if 1 448#if 1
452 if (s < 1) 449 if (s < 1)
453 hctx->ccid2hctx_rto = HZ; 450 hctx->tx_rto = HZ;
454#endif 451#endif
455 /* max 60 seconds */ 452 /* max 60 seconds */
456 if (s > 60) 453 if (s > 60)
457 hctx->ccid2hctx_rto = HZ * 60; 454 hctx->tx_rto = HZ * 60;
458 455
459 hctx->ccid2hctx_lastrtt = jiffies; 456 hctx->tx_lastrtt = jiffies;
460 457
461 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",
462 hctx->ccid2hctx_srtt, hctx->ccid2hctx_rttvar, 459 hctx->tx_srtt, hctx->tx_rttvar,
463 hctx->ccid2hctx_rto, HZ, r); 460 hctx->tx_rto, HZ, r);
464 } 461 }
465 462
466 /* we got a new ack, so re-start RTO timer */ 463 /* we got a new ack, so re-start RTO timer */
@@ -472,12 +469,12 @@ static void ccid2_hc_tx_dec_pipe(struct sock *sk)
472{ 469{
473 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk); 470 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
474 471
475 if (hctx->ccid2hctx_pipe == 0) 472 if (hctx->tx_pipe == 0)
476 DCCP_BUG("pipe == 0"); 473 DCCP_BUG("pipe == 0");
477 else 474 else
478 hctx->ccid2hctx_pipe--; 475 hctx->tx_pipe--;
479 476
480 if (hctx->ccid2hctx_pipe == 0) 477 if (hctx->tx_pipe == 0)
481 ccid2_hc_tx_kill_rto_timer(sk); 478 ccid2_hc_tx_kill_rto_timer(sk);
482} 479}
483 480
@@ -485,19 +482,19 @@ static void ccid2_congestion_event(struct sock *sk, struct ccid2_seq *seqp)
485{ 482{
486 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk); 483 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
487 484
488 if (time_before(seqp->ccid2s_sent, hctx->ccid2hctx_last_cong)) { 485 if (time_before(seqp->ccid2s_sent, hctx->tx_last_cong)) {
489 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");
490 return; 487 return;
491 } 488 }
492 489
493 hctx->ccid2hctx_last_cong = jiffies; 490 hctx->tx_last_cong = jiffies;
494 491
495 hctx->ccid2hctx_cwnd = hctx->ccid2hctx_cwnd / 2 ? : 1U; 492 hctx->tx_cwnd = hctx->tx_cwnd / 2 ? : 1U;
496 hctx->ccid2hctx_ssthresh = max(hctx->ccid2hctx_cwnd, 2U); 493 hctx->tx_ssthresh = max(hctx->tx_cwnd, 2U);
497 494
498 /* Avoid spurious timeouts resulting from Ack Ratio > cwnd */ 495 /* Avoid spurious timeouts resulting from Ack Ratio > cwnd */
499 if (dccp_sk(sk)->dccps_l_ack_ratio > hctx->ccid2hctx_cwnd) 496 if (dccp_sk(sk)->dccps_l_ack_ratio > hctx->tx_cwnd)
500 ccid2_change_l_ack_ratio(sk, hctx->ccid2hctx_cwnd); 497 ccid2_change_l_ack_ratio(sk, hctx->tx_cwnd);
501} 498}
502 499
503static 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)
@@ -521,21 +518,21 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
521 * -sorbo. 518 * -sorbo.
522 */ 519 */
523 /* need to bootstrap */ 520 /* need to bootstrap */
524 if (hctx->ccid2hctx_rpdupack == -1) { 521 if (hctx->tx_rpdupack == -1) {
525 hctx->ccid2hctx_rpdupack = 0; 522 hctx->tx_rpdupack = 0;
526 hctx->ccid2hctx_rpseq = seqno; 523 hctx->tx_rpseq = seqno;
527 } else { 524 } else {
528 /* check if packet is consecutive */ 525 /* check if packet is consecutive */
529 if (dccp_delta_seqno(hctx->ccid2hctx_rpseq, seqno) == 1) 526 if (dccp_delta_seqno(hctx->tx_rpseq, seqno) == 1)
530 hctx->ccid2hctx_rpseq = seqno; 527 hctx->tx_rpseq = seqno;
531 /* it's a later packet */ 528 /* it's a later packet */
532 else if (after48(seqno, hctx->ccid2hctx_rpseq)) { 529 else if (after48(seqno, hctx->tx_rpseq)) {
533 hctx->ccid2hctx_rpdupack++; 530 hctx->tx_rpdupack++;
534 531
535 /* check if we got enough dupacks */ 532 /* check if we got enough dupacks */
536 if (hctx->ccid2hctx_rpdupack >= NUMDUPACK) { 533 if (hctx->tx_rpdupack >= NUMDUPACK) {
537 hctx->ccid2hctx_rpdupack = -1; /* XXX lame */ 534 hctx->tx_rpdupack = -1; /* XXX lame */
538 hctx->ccid2hctx_rpseq = 0; 535 hctx->tx_rpseq = 0;
539 536
540 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);
541 } 538 }
@@ -544,7 +541,7 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
544 541
545 /* check forward path congestion */ 542 /* check forward path congestion */
546 /* still didn't send out new data packets */ 543 /* still didn't send out new data packets */
547 if (hctx->ccid2hctx_seqh == hctx->ccid2hctx_seqt) 544 if (hctx->tx_seqh == hctx->tx_seqt)
548 return; 545 return;
549 546
550 switch (DCCP_SKB_CB(skb)->dccpd_type) { 547 switch (DCCP_SKB_CB(skb)->dccpd_type) {
@@ -556,14 +553,14 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
556 } 553 }
557 554
558 ackno = DCCP_SKB_CB(skb)->dccpd_ack_seq; 555 ackno = DCCP_SKB_CB(skb)->dccpd_ack_seq;
559 if (after48(ackno, hctx->ccid2hctx_high_ack)) 556 if (after48(ackno, hctx->tx_high_ack))
560 hctx->ccid2hctx_high_ack = ackno; 557 hctx->tx_high_ack = ackno;
561 558
562 seqp = hctx->ccid2hctx_seqt; 559 seqp = hctx->tx_seqt;
563 while (before48(seqp->ccid2s_seq, ackno)) { 560 while (before48(seqp->ccid2s_seq, ackno)) {
564 seqp = seqp->ccid2s_next; 561 seqp = seqp->ccid2s_next;
565 if (seqp == hctx->ccid2hctx_seqh) { 562 if (seqp == hctx->tx_seqh) {
566 seqp = hctx->ccid2hctx_seqh->ccid2s_prev; 563 seqp = hctx->tx_seqh->ccid2s_prev;
567 break; 564 break;
568 } 565 }
569 } 566 }
@@ -573,7 +570,7 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
573 * packets per acknowledgement. Rounding up avoids that cwnd is not 570 * packets per acknowledgement. Rounding up avoids that cwnd is not
574 * 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.
575 */ 572 */
576 if (hctx->ccid2hctx_cwnd < hctx->ccid2hctx_ssthresh) 573 if (hctx->tx_cwnd < hctx->tx_ssthresh)
577 maxincr = DIV_ROUND_UP(dp->dccps_l_ack_ratio, 2); 574 maxincr = DIV_ROUND_UP(dp->dccps_l_ack_ratio, 2);
578 575
579 /* go through all ack vectors */ 576 /* go through all ack vectors */
@@ -592,7 +589,7 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
592 * seqnos. 589 * seqnos.
593 */ 590 */
594 while (after48(seqp->ccid2s_seq, ackno)) { 591 while (after48(seqp->ccid2s_seq, ackno)) {
595 if (seqp == hctx->ccid2hctx_seqt) { 592 if (seqp == hctx->tx_seqt) {
596 done = 1; 593 done = 1;
597 break; 594 break;
598 } 595 }
@@ -624,7 +621,7 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
624 (unsigned long long)seqp->ccid2s_seq); 621 (unsigned long long)seqp->ccid2s_seq);
625 ccid2_hc_tx_dec_pipe(sk); 622 ccid2_hc_tx_dec_pipe(sk);
626 } 623 }
627 if (seqp == hctx->ccid2hctx_seqt) { 624 if (seqp == hctx->tx_seqt) {
628 done = 1; 625 done = 1;
629 break; 626 break;
630 } 627 }
@@ -643,11 +640,11 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
643 /* The state about what is acked should be correct now 640 /* The state about what is acked should be correct now
644 * Check for NUMDUPACK 641 * Check for NUMDUPACK
645 */ 642 */
646 seqp = hctx->ccid2hctx_seqt; 643 seqp = hctx->tx_seqt;
647 while (before48(seqp->ccid2s_seq, hctx->ccid2hctx_high_ack)) { 644 while (before48(seqp->ccid2s_seq, hctx->tx_high_ack)) {
648 seqp = seqp->ccid2s_next; 645 seqp = seqp->ccid2s_next;
649 if (seqp == hctx->ccid2hctx_seqh) { 646 if (seqp == hctx->tx_seqh) {
650 seqp = hctx->ccid2hctx_seqh->ccid2s_prev; 647 seqp = hctx->tx_seqh->ccid2s_prev;
651 break; 648 break;
652 } 649 }
653 } 650 }
@@ -658,7 +655,7 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
658 if (done == NUMDUPACK) 655 if (done == NUMDUPACK)
659 break; 656 break;
660 } 657 }
661 if (seqp == hctx->ccid2hctx_seqt) 658 if (seqp == hctx->tx_seqt)
662 break; 659 break;
663 seqp = seqp->ccid2s_prev; 660 seqp = seqp->ccid2s_prev;
664 } 661 }
@@ -681,20 +678,20 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
681 ccid2_congestion_event(sk, seqp); 678 ccid2_congestion_event(sk, seqp);
682 ccid2_hc_tx_dec_pipe(sk); 679 ccid2_hc_tx_dec_pipe(sk);
683 } 680 }
684 if (seqp == hctx->ccid2hctx_seqt) 681 if (seqp == hctx->tx_seqt)
685 break; 682 break;
686 seqp = seqp->ccid2s_prev; 683 seqp = seqp->ccid2s_prev;
687 } 684 }
688 685
689 hctx->ccid2hctx_seqt = last_acked; 686 hctx->tx_seqt = last_acked;
690 } 687 }
691 688
692 /* trim acked packets in tail */ 689 /* trim acked packets in tail */
693 while (hctx->ccid2hctx_seqt != hctx->ccid2hctx_seqh) { 690 while (hctx->tx_seqt != hctx->tx_seqh) {
694 if (!hctx->ccid2hctx_seqt->ccid2s_acked) 691 if (!hctx->tx_seqt->ccid2s_acked)
695 break; 692 break;
696 693
697 hctx->ccid2hctx_seqt = hctx->ccid2hctx_seqt->ccid2s_next; 694 hctx->tx_seqt = hctx->tx_seqt->ccid2s_next;
698 } 695 }
699 696
700 ccid2_hc_tx_check_sanity(hctx); 697 ccid2_hc_tx_check_sanity(hctx);
@@ -707,17 +704,17 @@ static int ccid2_hc_tx_init(struct ccid *ccid, struct sock *sk)
707 u32 max_ratio; 704 u32 max_ratio;
708 705
709 /* RFC 4341, 5: initialise ssthresh to arbitrarily high (max) value */ 706 /* RFC 4341, 5: initialise ssthresh to arbitrarily high (max) value */
710 hctx->ccid2hctx_ssthresh = ~0U; 707 hctx->tx_ssthresh = ~0U;
711 708
712 /* 709 /*
713 * 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
714 * packets for new connections, following the rules from [RFC3390]". 711 * packets for new connections, following the rules from [RFC3390]".
715 * 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.
716 */ 713 */
717 hctx->ccid2hctx_cwnd = clamp(4380U / dp->dccps_mss_cache, 2U, 4U); 714 hctx->tx_cwnd = clamp(4380U / dp->dccps_mss_cache, 2U, 4U);
718 715
719 /* Make sure that Ack Ratio is enabled and within bounds. */ 716 /* Make sure that Ack Ratio is enabled and within bounds. */
720 max_ratio = DIV_ROUND_UP(hctx->ccid2hctx_cwnd, 2); 717 max_ratio = DIV_ROUND_UP(hctx->tx_cwnd, 2);
721 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)
722 dp->dccps_l_ack_ratio = max_ratio; 719 dp->dccps_l_ack_ratio = max_ratio;
723 720
@@ -725,12 +722,12 @@ static int ccid2_hc_tx_init(struct ccid *ccid, struct sock *sk)
725 if (ccid2_hc_tx_alloc_seq(hctx)) 722 if (ccid2_hc_tx_alloc_seq(hctx))
726 return -ENOMEM; 723 return -ENOMEM;
727 724
728 hctx->ccid2hctx_rto = 3 * HZ; 725 hctx->tx_rto = 3 * HZ;
729 ccid2_change_srtt(hctx, -1); 726 ccid2_change_srtt(hctx, -1);
730 hctx->ccid2hctx_rttvar = -1; 727 hctx->tx_rttvar = -1;
731 hctx->ccid2hctx_rpdupack = -1; 728 hctx->tx_rpdupack = -1;
732 hctx->ccid2hctx_last_cong = jiffies; 729 hctx->tx_last_cong = jiffies;
733 setup_timer(&hctx->ccid2hctx_rtotimer, ccid2_hc_tx_rto_expire, 730 setup_timer(&hctx->tx_rtotimer, ccid2_hc_tx_rto_expire,
734 (unsigned long)sk); 731 (unsigned long)sk);
735 732
736 ccid2_hc_tx_check_sanity(hctx); 733 ccid2_hc_tx_check_sanity(hctx);
@@ -744,9 +741,9 @@ static void ccid2_hc_tx_exit(struct sock *sk)
744 741
745 ccid2_hc_tx_kill_rto_timer(sk); 742 ccid2_hc_tx_kill_rto_timer(sk);
746 743
747 for (i = 0; i < hctx->ccid2hctx_seqbufc; i++) 744 for (i = 0; i < hctx->tx_seqbufc; i++)
748 kfree(hctx->ccid2hctx_seqbuf[i]); 745 kfree(hctx->tx_seqbuf[i]);
749 hctx->ccid2hctx_seqbufc = 0; 746 hctx->tx_seqbufc = 0;
750} 747}
751 748
752static 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)
@@ -757,10 +754,10 @@ static void ccid2_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
757 switch (DCCP_SKB_CB(skb)->dccpd_type) { 754 switch (DCCP_SKB_CB(skb)->dccpd_type) {
758 case DCCP_PKT_DATA: 755 case DCCP_PKT_DATA:
759 case DCCP_PKT_DATAACK: 756 case DCCP_PKT_DATAACK:
760 hcrx->ccid2hcrx_data++; 757 hcrx->rx_data++;
761 if (hcrx->ccid2hcrx_data >= dp->dccps_r_ack_ratio) { 758 if (hcrx->rx_data >= dp->dccps_r_ack_ratio) {
762 dccp_send_ack(sk); 759 dccp_send_ack(sk);
763 hcrx->ccid2hcrx_data = 0; 760 hcrx->rx_data = 0;
764 } 761 }
765 break; 762 break;
766 } 763 }
diff --git a/net/dccp/ccids/ccid2.h b/net/dccp/ccids/ccid2.h
index 326ac90fb909..1ec6a30103bb 100644
--- a/net/dccp/ccids/ccid2.h
+++ b/net/dccp/ccids/ccid2.h
@@ -40,34 +40,34 @@ struct ccid2_seq {
40 40
41/** 41/**
42 * struct ccid2_hc_tx_sock - CCID2 TX half connection 42 * struct ccid2_hc_tx_sock - CCID2 TX half connection
43 * @ccid2hctx_{cwnd,ssthresh,pipe}: as per RFC 4341, section 5 43 * @tx_{cwnd,ssthresh,pipe}: as per RFC 4341, section 5
44 * @ccid2hctx_packets_acked - Ack counter for deriving cwnd growth (RFC 3465) 44 * @tx_packets_acked: Ack counter for deriving cwnd growth (RFC 3465)
45 * @ccid2hctx_lastrtt -time RTT was last measured 45 * @tx_lastrtt: time RTT was last measured
46 * @ccid2hctx_rpseq - last consecutive seqno 46 * @tx_rpseq: last consecutive seqno
47 * @ccid2hctx_rpdupack - dupacks since rpseq 47 * @tx_rpdupack: dupacks since rpseq
48 */ 48 */
49struct ccid2_hc_tx_sock { 49struct ccid2_hc_tx_sock {
50 u32 ccid2hctx_cwnd; 50 u32 tx_cwnd;
51 u32 ccid2hctx_ssthresh; 51 u32 tx_ssthresh;
52 u32 ccid2hctx_pipe; 52 u32 tx_pipe;
53 u32 ccid2hctx_packets_acked; 53 u32 tx_packets_acked;
54 struct ccid2_seq *ccid2hctx_seqbuf[CCID2_SEQBUF_MAX]; 54 struct ccid2_seq *tx_seqbuf[CCID2_SEQBUF_MAX];
55 int ccid2hctx_seqbufc; 55 int tx_seqbufc;
56 struct ccid2_seq *ccid2hctx_seqh; 56 struct ccid2_seq *tx_seqh;
57 struct ccid2_seq *ccid2hctx_seqt; 57 struct ccid2_seq *tx_seqt;
58 long ccid2hctx_rto; 58 long tx_rto;
59 long ccid2hctx_srtt; 59 long tx_srtt;
60 long ccid2hctx_rttvar; 60 long tx_rttvar;
61 unsigned long ccid2hctx_lastrtt; 61 unsigned long tx_lastrtt;
62 struct timer_list ccid2hctx_rtotimer; 62 struct timer_list tx_rtotimer;
63 u64 ccid2hctx_rpseq; 63 u64 tx_rpseq;
64 int ccid2hctx_rpdupack; 64 int tx_rpdupack;
65 unsigned long ccid2hctx_last_cong; 65 unsigned long tx_last_cong;
66 u64 ccid2hctx_high_ack; 66 u64 tx_high_ack;
67}; 67};
68 68
69struct ccid2_hc_rx_sock { 69struct ccid2_hc_rx_sock {
70 int ccid2hcrx_data; 70 int rx_data;
71}; 71};
72 72
73static inline struct ccid2_hc_tx_sock *ccid2_hc_tx_sk(const struct sock *sk) 73static inline struct ccid2_hc_tx_sock *ccid2_hc_tx_sk(const struct sock *sk)