diff options
Diffstat (limited to 'net/dccp/ccids')
-rw-r--r-- | net/dccp/ccids/ccid3.c | 321 | ||||
-rw-r--r-- | net/dccp/ccids/ccid3.h | 16 | ||||
-rw-r--r-- | net/dccp/ccids/lib/packet_history.h | 3 |
3 files changed, 170 insertions, 170 deletions
diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c index 7bf3b3a91e97..38aa84986118 100644 --- a/net/dccp/ccids/ccid3.c +++ b/net/dccp/ccids/ccid3.c | |||
@@ -43,12 +43,22 @@ | |||
43 | #include "ccid3.h" | 43 | #include "ccid3.h" |
44 | 44 | ||
45 | /* | 45 | /* |
46 | * Reason for maths with 10 here is to avoid 32 bit overflow when a is big. | 46 | * Reason for maths here is to avoid 32 bit overflow when a is big. |
47 | * With this we get close to the limit. | ||
47 | */ | 48 | */ |
48 | static inline u32 usecs_div(const u32 a, const u32 b) | 49 | static inline u32 usecs_div(const u32 a, const u32 b) |
49 | { | 50 | { |
50 | const u32 tmp = a * (USEC_PER_SEC / 10); | 51 | const u32 div = a < (UINT_MAX / (USEC_PER_SEC / 10)) ? 10 : |
51 | return b > 20 ? tmp / (b / 10) : tmp; | 52 | a < (UINT_MAX / (USEC_PER_SEC / 50)) ? 50 : |
53 | a < (UINT_MAX / (USEC_PER_SEC / 100)) ? 100 : | ||
54 | a < (UINT_MAX / (USEC_PER_SEC / 500)) ? 500 : | ||
55 | a < (UINT_MAX / (USEC_PER_SEC / 1000)) ? 1000 : | ||
56 | a < (UINT_MAX / (USEC_PER_SEC / 5000)) ? 5000 : | ||
57 | a < (UINT_MAX / (USEC_PER_SEC / 10000)) ? 10000 : | ||
58 | a < (UINT_MAX / (USEC_PER_SEC / 50000)) ? 50000 : | ||
59 | 100000; | ||
60 | const u32 tmp = a * (USEC_PER_SEC / div); | ||
61 | return (b >= 2 * div) ? tmp / (b / div) : tmp; | ||
52 | } | 62 | } |
53 | 63 | ||
54 | static int ccid3_debug; | 64 | static int ccid3_debug; |
@@ -68,13 +78,11 @@ static struct dccp_li_hist *ccid3_li_hist; | |||
68 | 78 | ||
69 | static int ccid3_init(struct sock *sk) | 79 | static int ccid3_init(struct sock *sk) |
70 | { | 80 | { |
71 | ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk); | ||
72 | return 0; | 81 | return 0; |
73 | } | 82 | } |
74 | 83 | ||
75 | static void ccid3_exit(struct sock *sk) | 84 | static void ccid3_exit(struct sock *sk) |
76 | { | 85 | { |
77 | ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk); | ||
78 | } | 86 | } |
79 | 87 | ||
80 | /* TFRC sender states */ | 88 | /* TFRC sender states */ |
@@ -102,8 +110,7 @@ static const char *ccid3_tx_state_name(enum ccid3_hc_tx_states state) | |||
102 | static inline void ccid3_hc_tx_set_state(struct sock *sk, | 110 | static inline void ccid3_hc_tx_set_state(struct sock *sk, |
103 | enum ccid3_hc_tx_states state) | 111 | enum ccid3_hc_tx_states state) |
104 | { | 112 | { |
105 | struct dccp_sock *dp = dccp_sk(sk); | 113 | struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); |
106 | struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; | ||
107 | enum ccid3_hc_tx_states oldstate = hctx->ccid3hctx_state; | 114 | enum ccid3_hc_tx_states oldstate = hctx->ccid3hctx_state; |
108 | 115 | ||
109 | ccid3_pr_debug("%s(%p) %-8.8s -> %s\n", | 116 | ccid3_pr_debug("%s(%p) %-8.8s -> %s\n", |
@@ -144,8 +151,7 @@ static inline void ccid3_calc_new_delta(struct ccid3_hc_tx_sock *hctx) | |||
144 | */ | 151 | */ |
145 | static void ccid3_hc_tx_update_x(struct sock *sk) | 152 | static void ccid3_hc_tx_update_x(struct sock *sk) |
146 | { | 153 | { |
147 | struct dccp_sock *dp = dccp_sk(sk); | 154 | struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); |
148 | struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; | ||
149 | 155 | ||
150 | /* To avoid large error in calcX */ | 156 | /* To avoid large error in calcX */ |
151 | if (hctx->ccid3hctx_p >= TFRC_SMALLEST_P) { | 157 | if (hctx->ccid3hctx_p >= TFRC_SMALLEST_P) { |
@@ -159,7 +165,7 @@ static void ccid3_hc_tx_update_x(struct sock *sk) | |||
159 | } else { | 165 | } else { |
160 | struct timeval now; | 166 | struct timeval now; |
161 | 167 | ||
162 | do_gettimeofday(&now); | 168 | dccp_timestamp(sk, &now); |
163 | if (timeval_delta(&now, &hctx->ccid3hctx_t_ld) >= | 169 | if (timeval_delta(&now, &hctx->ccid3hctx_t_ld) >= |
164 | hctx->ccid3hctx_rtt) { | 170 | hctx->ccid3hctx_rtt) { |
165 | hctx->ccid3hctx_x = max_t(u32, min_t(u32, hctx->ccid3hctx_x_recv, | 171 | hctx->ccid3hctx_x = max_t(u32, min_t(u32, hctx->ccid3hctx_x_recv, |
@@ -174,9 +180,8 @@ static void ccid3_hc_tx_update_x(struct sock *sk) | |||
174 | static void ccid3_hc_tx_no_feedback_timer(unsigned long data) | 180 | static void ccid3_hc_tx_no_feedback_timer(unsigned long data) |
175 | { | 181 | { |
176 | struct sock *sk = (struct sock *)data; | 182 | struct sock *sk = (struct sock *)data; |
177 | struct dccp_sock *dp = dccp_sk(sk); | ||
178 | unsigned long next_tmout = 0; | 183 | unsigned long next_tmout = 0; |
179 | struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; | 184 | struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); |
180 | 185 | ||
181 | bh_lock_sock(sk); | 186 | bh_lock_sock(sk); |
182 | if (sock_owned_by_user(sk)) { | 187 | if (sock_owned_by_user(sk)) { |
@@ -274,20 +279,20 @@ static int ccid3_hc_tx_send_packet(struct sock *sk, | |||
274 | struct sk_buff *skb, int len) | 279 | struct sk_buff *skb, int len) |
275 | { | 280 | { |
276 | struct dccp_sock *dp = dccp_sk(sk); | 281 | struct dccp_sock *dp = dccp_sk(sk); |
277 | struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; | 282 | struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); |
278 | struct dccp_tx_hist_entry *new_packet; | 283 | struct dccp_tx_hist_entry *new_packet; |
279 | struct timeval now; | 284 | struct timeval now; |
280 | long delay; | 285 | long delay; |
281 | int rc = -ENOTCONN; | 286 | int rc = -ENOTCONN; |
282 | 287 | ||
283 | /* Check if pure ACK or Terminating*/ | 288 | BUG_ON(hctx == NULL || hctx->ccid3hctx_state == TFRC_SSTATE_TERM); |
284 | 289 | ||
290 | /* Check if pure ACK or Terminating*/ | ||
285 | /* | 291 | /* |
286 | * XXX: We only call this function for DATA and DATAACK, on, these | 292 | * XXX: We only call this function for DATA and DATAACK, on, these |
287 | * packets can have zero length, but why the comment about "pure ACK"? | 293 | * packets can have zero length, but why the comment about "pure ACK"? |
288 | */ | 294 | */ |
289 | if (hctx == NULL || len == 0 || | 295 | if (unlikely(len == 0)) |
290 | hctx->ccid3hctx_state == TFRC_SSTATE_TERM) | ||
291 | goto out; | 296 | goto out; |
292 | 297 | ||
293 | /* See if last packet allocated was not sent */ | 298 | /* See if last packet allocated was not sent */ |
@@ -297,23 +302,20 @@ static int ccid3_hc_tx_send_packet(struct sock *sk, | |||
297 | SLAB_ATOMIC); | 302 | SLAB_ATOMIC); |
298 | 303 | ||
299 | rc = -ENOBUFS; | 304 | rc = -ENOBUFS; |
300 | if (new_packet == NULL) { | 305 | if (unlikely(new_packet == NULL)) { |
301 | ccid3_pr_debug("%s, sk=%p, not enough mem to add " | 306 | LIMIT_NETDEBUG(KERN_WARNING "%s: %s, sk=%p, not enough " |
302 | "to history, send refused\n", | 307 | "mem to add to history, send refused\n", |
303 | dccp_role(sk), sk); | 308 | __FUNCTION__, dccp_role(sk), sk); |
304 | goto out; | 309 | goto out; |
305 | } | 310 | } |
306 | 311 | ||
307 | dccp_tx_hist_add_entry(&hctx->ccid3hctx_hist, new_packet); | 312 | dccp_tx_hist_add_entry(&hctx->ccid3hctx_hist, new_packet); |
308 | } | 313 | } |
309 | 314 | ||
310 | do_gettimeofday(&now); | 315 | dccp_timestamp(sk, &now); |
311 | 316 | ||
312 | switch (hctx->ccid3hctx_state) { | 317 | switch (hctx->ccid3hctx_state) { |
313 | case TFRC_SSTATE_NO_SENT: | 318 | case TFRC_SSTATE_NO_SENT: |
314 | ccid3_pr_debug("%s, sk=%p, first packet(%llu)\n", | ||
315 | dccp_role(sk), sk, dp->dccps_gss); | ||
316 | |||
317 | hctx->ccid3hctx_no_feedback_timer.function = ccid3_hc_tx_no_feedback_timer; | 319 | hctx->ccid3hctx_no_feedback_timer.function = ccid3_hc_tx_no_feedback_timer; |
318 | hctx->ccid3hctx_no_feedback_timer.data = (unsigned long)sk; | 320 | hctx->ccid3hctx_no_feedback_timer.data = (unsigned long)sk; |
319 | sk_reset_timer(sk, &hctx->ccid3hctx_no_feedback_timer, | 321 | sk_reset_timer(sk, &hctx->ccid3hctx_no_feedback_timer, |
@@ -321,7 +323,7 @@ static int ccid3_hc_tx_send_packet(struct sock *sk, | |||
321 | hctx->ccid3hctx_last_win_count = 0; | 323 | hctx->ccid3hctx_last_win_count = 0; |
322 | hctx->ccid3hctx_t_last_win_count = now; | 324 | hctx->ccid3hctx_t_last_win_count = now; |
323 | ccid3_hc_tx_set_state(sk, TFRC_SSTATE_NO_FBACK); | 325 | ccid3_hc_tx_set_state(sk, TFRC_SSTATE_NO_FBACK); |
324 | hctx->ccid3hctx_t_ipi = TFRC_INITIAL_TIMEOUT; | 326 | hctx->ccid3hctx_t_ipi = TFRC_INITIAL_IPI; |
325 | 327 | ||
326 | /* Set nominal send time for initial packet */ | 328 | /* Set nominal send time for initial packet */ |
327 | hctx->ccid3hctx_t_nom = now; | 329 | hctx->ccid3hctx_t_nom = now; |
@@ -334,7 +336,6 @@ static int ccid3_hc_tx_send_packet(struct sock *sk, | |||
334 | case TFRC_SSTATE_FBACK: | 336 | case TFRC_SSTATE_FBACK: |
335 | delay = (timeval_delta(&now, &hctx->ccid3hctx_t_nom) - | 337 | delay = (timeval_delta(&now, &hctx->ccid3hctx_t_nom) - |
336 | hctx->ccid3hctx_delta); | 338 | hctx->ccid3hctx_delta); |
337 | ccid3_pr_debug("send_packet delay=%ld\n", delay); | ||
338 | delay /= -1000; | 339 | delay /= -1000; |
339 | /* divide by -1000 is to convert to ms and get sign right */ | 340 | /* divide by -1000 is to convert to ms and get sign right */ |
340 | rc = delay > 0 ? delay : 0; | 341 | rc = delay > 0 ? delay : 0; |
@@ -348,29 +349,25 @@ static int ccid3_hc_tx_send_packet(struct sock *sk, | |||
348 | } | 349 | } |
349 | 350 | ||
350 | /* Can we send? if so add options and add to packet history */ | 351 | /* Can we send? if so add options and add to packet history */ |
351 | if (rc == 0) | 352 | if (rc == 0) { |
353 | dp->dccps_hc_tx_insert_options = 1; | ||
352 | new_packet->dccphtx_ccval = | 354 | new_packet->dccphtx_ccval = |
353 | DCCP_SKB_CB(skb)->dccpd_ccval = | 355 | DCCP_SKB_CB(skb)->dccpd_ccval = |
354 | hctx->ccid3hctx_last_win_count; | 356 | hctx->ccid3hctx_last_win_count; |
357 | } | ||
355 | out: | 358 | out: |
356 | return rc; | 359 | return rc; |
357 | } | 360 | } |
358 | 361 | ||
359 | static void ccid3_hc_tx_packet_sent(struct sock *sk, int more, int len) | 362 | static void ccid3_hc_tx_packet_sent(struct sock *sk, int more, int len) |
360 | { | 363 | { |
361 | struct dccp_sock *dp = dccp_sk(sk); | 364 | const struct dccp_sock *dp = dccp_sk(sk); |
362 | struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; | 365 | struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); |
363 | struct timeval now; | 366 | struct timeval now; |
364 | 367 | ||
365 | BUG_ON(hctx == NULL); | 368 | BUG_ON(hctx == NULL || hctx->ccid3hctx_state == TFRC_SSTATE_TERM); |
366 | |||
367 | if (hctx->ccid3hctx_state == TFRC_SSTATE_TERM) { | ||
368 | ccid3_pr_debug("%s, sk=%p, while state is TFRC_SSTATE_TERM!\n", | ||
369 | dccp_role(sk), sk); | ||
370 | return; | ||
371 | } | ||
372 | 369 | ||
373 | do_gettimeofday(&now); | 370 | dccp_timestamp(sk, &now); |
374 | 371 | ||
375 | /* check if we have sent a data packet */ | 372 | /* check if we have sent a data packet */ |
376 | if (len > 0) { | 373 | if (len > 0) { |
@@ -378,14 +375,14 @@ static void ccid3_hc_tx_packet_sent(struct sock *sk, int more, int len) | |||
378 | struct dccp_tx_hist_entry *packet; | 375 | struct dccp_tx_hist_entry *packet; |
379 | 376 | ||
380 | packet = dccp_tx_hist_head(&hctx->ccid3hctx_hist); | 377 | packet = dccp_tx_hist_head(&hctx->ccid3hctx_hist); |
381 | if (packet == NULL) { | 378 | if (unlikely(packet == NULL)) { |
382 | printk(KERN_CRIT "%s: packet doesn't exists in " | 379 | LIMIT_NETDEBUG(KERN_WARNING "%s: packet doesn't " |
383 | "history!\n", __FUNCTION__); | 380 | "exists in history!\n", __FUNCTION__); |
384 | return; | 381 | return; |
385 | } | 382 | } |
386 | if (packet->dccphtx_sent) { | 383 | if (unlikely(packet->dccphtx_sent)) { |
387 | printk(KERN_CRIT "%s: no unsent packet in history!\n", | 384 | LIMIT_NETDEBUG(KERN_WARNING "%s: no unsent packet in " |
388 | __FUNCTION__); | 385 | "history!\n", __FUNCTION__); |
389 | return; | 386 | return; |
390 | } | 387 | } |
391 | packet->dccphtx_tstamp = now; | 388 | packet->dccphtx_tstamp = now; |
@@ -445,24 +442,18 @@ static void ccid3_hc_tx_packet_sent(struct sock *sk, int more, int len) | |||
445 | 442 | ||
446 | static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | 443 | static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) |
447 | { | 444 | { |
448 | struct dccp_sock *dp = dccp_sk(sk); | 445 | const struct dccp_sock *dp = dccp_sk(sk); |
449 | struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; | 446 | struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); |
450 | struct ccid3_options_received *opt_recv; | 447 | struct ccid3_options_received *opt_recv; |
451 | struct dccp_tx_hist_entry *packet; | 448 | struct dccp_tx_hist_entry *packet; |
449 | struct timeval now; | ||
452 | unsigned long next_tmout; | 450 | unsigned long next_tmout; |
453 | u32 t_elapsed; | 451 | u32 t_elapsed; |
454 | u32 pinv; | 452 | u32 pinv; |
455 | u32 x_recv; | 453 | u32 x_recv; |
456 | u32 r_sample; | 454 | u32 r_sample; |
457 | 455 | ||
458 | if (hctx == NULL) | 456 | BUG_ON(hctx == NULL || hctx->ccid3hctx_state == TFRC_SSTATE_TERM); |
459 | return; | ||
460 | |||
461 | if (hctx->ccid3hctx_state == TFRC_SSTATE_TERM) { | ||
462 | ccid3_pr_debug("%s, sk=%p, received a packet when " | ||
463 | "terminating!\n", dccp_role(sk), sk); | ||
464 | return; | ||
465 | } | ||
466 | 457 | ||
467 | /* we are only interested in ACKs */ | 458 | /* we are only interested in ACKs */ |
468 | if (!(DCCP_SKB_CB(skb)->dccpd_type == DCCP_PKT_ACK || | 459 | if (!(DCCP_SKB_CB(skb)->dccpd_type == DCCP_PKT_ACK || |
@@ -471,7 +462,7 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
471 | 462 | ||
472 | opt_recv = &hctx->ccid3hctx_options_received; | 463 | opt_recv = &hctx->ccid3hctx_options_received; |
473 | 464 | ||
474 | t_elapsed = dp->dccps_options_received.dccpor_elapsed_time; | 465 | t_elapsed = dp->dccps_options_received.dccpor_elapsed_time * 10; |
475 | x_recv = opt_recv->ccid3or_receive_rate; | 466 | x_recv = opt_recv->ccid3or_receive_rate; |
476 | pinv = opt_recv->ccid3or_loss_event_rate; | 467 | pinv = opt_recv->ccid3or_loss_event_rate; |
477 | 468 | ||
@@ -486,19 +477,24 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
486 | /* get t_recvdata from history */ | 477 | /* get t_recvdata from history */ |
487 | packet = dccp_tx_hist_find_entry(&hctx->ccid3hctx_hist, | 478 | packet = dccp_tx_hist_find_entry(&hctx->ccid3hctx_hist, |
488 | DCCP_SKB_CB(skb)->dccpd_ack_seq); | 479 | DCCP_SKB_CB(skb)->dccpd_ack_seq); |
489 | if (packet == NULL) { | 480 | if (unlikely(packet == NULL)) { |
490 | ccid3_pr_debug("%s, sk=%p, seqno %llu(%s) does't " | 481 | LIMIT_NETDEBUG(KERN_WARNING "%s: %s, sk=%p, seqno " |
491 | "exist in history!\n", | 482 | "%llu(%s) does't exist in history!\n", |
492 | dccp_role(sk), sk, | 483 | __FUNCTION__, dccp_role(sk), sk, |
493 | DCCP_SKB_CB(skb)->dccpd_ack_seq, | 484 | (unsigned long long)DCCP_SKB_CB(skb)->dccpd_ack_seq, |
494 | dccp_packet_name(DCCP_SKB_CB(skb)->dccpd_type)); | 485 | dccp_packet_name(DCCP_SKB_CB(skb)->dccpd_type)); |
495 | return; | 486 | return; |
496 | } | 487 | } |
497 | 488 | ||
498 | /* Update RTT */ | 489 | /* Update RTT */ |
499 | r_sample = timeval_now_delta(&packet->dccphtx_tstamp); | 490 | dccp_timestamp(sk, &now); |
500 | /* FIXME: */ | 491 | r_sample = timeval_delta(&now, &packet->dccphtx_tstamp); |
501 | // r_sample -= usecs_to_jiffies(t_elapsed * 10); | 492 | if (unlikely(r_sample <= t_elapsed)) |
493 | LIMIT_NETDEBUG(KERN_WARNING "%s: r_sample=%uus, " | ||
494 | "t_elapsed=%uus\n", | ||
495 | __FUNCTION__, r_sample, t_elapsed); | ||
496 | else | ||
497 | r_sample -= t_elapsed; | ||
502 | 498 | ||
503 | /* Update RTT estimate by | 499 | /* Update RTT estimate by |
504 | * If (No feedback recv) | 500 | * If (No feedback recv) |
@@ -591,11 +587,11 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
591 | 587 | ||
592 | static void ccid3_hc_tx_insert_options(struct sock *sk, struct sk_buff *skb) | 588 | static void ccid3_hc_tx_insert_options(struct sock *sk, struct sk_buff *skb) |
593 | { | 589 | { |
594 | const struct dccp_sock *dp = dccp_sk(sk); | 590 | const struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); |
595 | struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; | 591 | |
592 | BUG_ON(hctx == NULL); | ||
596 | 593 | ||
597 | if (hctx == NULL || !(sk->sk_state == DCCP_OPEN || | 594 | if (!(sk->sk_state == DCCP_OPEN || sk->sk_state == DCCP_PARTOPEN)) |
598 | sk->sk_state == DCCP_PARTOPEN)) | ||
599 | return; | 595 | return; |
600 | 596 | ||
601 | DCCP_SKB_CB(skb)->dccpd_ccval = hctx->ccid3hctx_last_win_count; | 597 | DCCP_SKB_CB(skb)->dccpd_ccval = hctx->ccid3hctx_last_win_count; |
@@ -606,12 +602,11 @@ static int ccid3_hc_tx_parse_options(struct sock *sk, unsigned char option, | |||
606 | unsigned char *value) | 602 | unsigned char *value) |
607 | { | 603 | { |
608 | int rc = 0; | 604 | int rc = 0; |
609 | struct dccp_sock *dp = dccp_sk(sk); | 605 | const struct dccp_sock *dp = dccp_sk(sk); |
610 | struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; | 606 | struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); |
611 | struct ccid3_options_received *opt_recv; | 607 | struct ccid3_options_received *opt_recv; |
612 | 608 | ||
613 | if (hctx == NULL) | 609 | BUG_ON(hctx == NULL); |
614 | return 0; | ||
615 | 610 | ||
616 | opt_recv = &hctx->ccid3hctx_options_received; | 611 | opt_recv = &hctx->ccid3hctx_options_received; |
617 | 612 | ||
@@ -625,10 +620,10 @@ static int ccid3_hc_tx_parse_options(struct sock *sk, unsigned char option, | |||
625 | 620 | ||
626 | switch (option) { | 621 | switch (option) { |
627 | case TFRC_OPT_LOSS_EVENT_RATE: | 622 | case TFRC_OPT_LOSS_EVENT_RATE: |
628 | if (len != 4) { | 623 | if (unlikely(len != 4)) { |
629 | ccid3_pr_debug("%s, sk=%p, invalid len for " | 624 | LIMIT_NETDEBUG(KERN_WARNING "%s: %s, sk=%p, invalid " |
630 | "TFRC_OPT_LOSS_EVENT_RATE\n", | 625 | "len for TFRC_OPT_LOSS_EVENT_RATE\n", |
631 | dccp_role(sk), sk); | 626 | __FUNCTION__, dccp_role(sk), sk); |
632 | rc = -EINVAL; | 627 | rc = -EINVAL; |
633 | } else { | 628 | } else { |
634 | opt_recv->ccid3or_loss_event_rate = ntohl(*(u32 *)value); | 629 | opt_recv->ccid3or_loss_event_rate = ntohl(*(u32 *)value); |
@@ -646,10 +641,10 @@ static int ccid3_hc_tx_parse_options(struct sock *sk, unsigned char option, | |||
646 | opt_recv->ccid3or_loss_intervals_len); | 641 | opt_recv->ccid3or_loss_intervals_len); |
647 | break; | 642 | break; |
648 | case TFRC_OPT_RECEIVE_RATE: | 643 | case TFRC_OPT_RECEIVE_RATE: |
649 | if (len != 4) { | 644 | if (unlikely(len != 4)) { |
650 | ccid3_pr_debug("%s, sk=%p, invalid len for " | 645 | LIMIT_NETDEBUG(KERN_WARNING "%s: %s, sk=%p, invalid " |
651 | "TFRC_OPT_RECEIVE_RATE\n", | 646 | "len for TFRC_OPT_RECEIVE_RATE\n", |
652 | dccp_role(sk), sk); | 647 | __FUNCTION__, dccp_role(sk), sk); |
653 | rc = -EINVAL; | 648 | rc = -EINVAL; |
654 | } else { | 649 | } else { |
655 | opt_recv->ccid3or_receive_rate = ntohl(*(u32 *)value); | 650 | opt_recv->ccid3or_receive_rate = ntohl(*(u32 *)value); |
@@ -668,13 +663,11 @@ static int ccid3_hc_tx_init(struct sock *sk) | |||
668 | struct dccp_sock *dp = dccp_sk(sk); | 663 | struct dccp_sock *dp = dccp_sk(sk); |
669 | struct ccid3_hc_tx_sock *hctx; | 664 | struct ccid3_hc_tx_sock *hctx; |
670 | 665 | ||
671 | ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk); | 666 | dp->dccps_hc_tx_ccid_private = kmalloc(sizeof(*hctx), gfp_any()); |
672 | 667 | if (dp->dccps_hc_tx_ccid_private == NULL) | |
673 | hctx = dp->dccps_hc_tx_ccid_private = kmalloc(sizeof(*hctx), | ||
674 | gfp_any()); | ||
675 | if (hctx == NULL) | ||
676 | return -ENOMEM; | 668 | return -ENOMEM; |
677 | 669 | ||
670 | hctx = ccid3_hc_tx_sk(sk); | ||
678 | memset(hctx, 0, sizeof(*hctx)); | 671 | memset(hctx, 0, sizeof(*hctx)); |
679 | 672 | ||
680 | if (dp->dccps_packet_size >= TFRC_MIN_PACKET_SIZE && | 673 | if (dp->dccps_packet_size >= TFRC_MIN_PACKET_SIZE && |
@@ -696,9 +689,8 @@ static int ccid3_hc_tx_init(struct sock *sk) | |||
696 | static void ccid3_hc_tx_exit(struct sock *sk) | 689 | static void ccid3_hc_tx_exit(struct sock *sk) |
697 | { | 690 | { |
698 | struct dccp_sock *dp = dccp_sk(sk); | 691 | struct dccp_sock *dp = dccp_sk(sk); |
699 | struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; | 692 | struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); |
700 | 693 | ||
701 | ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk); | ||
702 | BUG_ON(hctx == NULL); | 694 | BUG_ON(hctx == NULL); |
703 | 695 | ||
704 | ccid3_hc_tx_set_state(sk, TFRC_SSTATE_TERM); | 696 | ccid3_hc_tx_set_state(sk, TFRC_SSTATE_TERM); |
@@ -738,8 +730,7 @@ static const char *ccid3_rx_state_name(enum ccid3_hc_rx_states state) | |||
738 | static inline void ccid3_hc_rx_set_state(struct sock *sk, | 730 | static inline void ccid3_hc_rx_set_state(struct sock *sk, |
739 | enum ccid3_hc_rx_states state) | 731 | enum ccid3_hc_rx_states state) |
740 | { | 732 | { |
741 | struct dccp_sock *dp = dccp_sk(sk); | 733 | struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk); |
742 | struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private; | ||
743 | enum ccid3_hc_rx_states oldstate = hcrx->ccid3hcrx_state; | 734 | enum ccid3_hc_rx_states oldstate = hcrx->ccid3hcrx_state; |
744 | 735 | ||
745 | ccid3_pr_debug("%s(%p) %-8.8s -> %s\n", | 736 | ccid3_pr_debug("%s(%p) %-8.8s -> %s\n", |
@@ -751,14 +742,14 @@ static inline void ccid3_hc_rx_set_state(struct sock *sk, | |||
751 | 742 | ||
752 | static void ccid3_hc_rx_send_feedback(struct sock *sk) | 743 | static void ccid3_hc_rx_send_feedback(struct sock *sk) |
753 | { | 744 | { |
745 | struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk); | ||
754 | struct dccp_sock *dp = dccp_sk(sk); | 746 | struct dccp_sock *dp = dccp_sk(sk); |
755 | struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private; | ||
756 | struct dccp_rx_hist_entry *packet; | 747 | struct dccp_rx_hist_entry *packet; |
757 | struct timeval now; | 748 | struct timeval now; |
758 | 749 | ||
759 | ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk); | 750 | ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk); |
760 | 751 | ||
761 | do_gettimeofday(&now); | 752 | dccp_timestamp(sk, &now); |
762 | 753 | ||
763 | switch (hcrx->ccid3hcrx_state) { | 754 | switch (hcrx->ccid3hcrx_state) { |
764 | case TFRC_RSTATE_NO_DATA: | 755 | case TFRC_RSTATE_NO_DATA: |
@@ -767,11 +758,8 @@ static void ccid3_hc_rx_send_feedback(struct sock *sk) | |||
767 | case TFRC_RSTATE_DATA: { | 758 | case TFRC_RSTATE_DATA: { |
768 | const u32 delta = timeval_delta(&now, | 759 | const u32 delta = timeval_delta(&now, |
769 | &hcrx->ccid3hcrx_tstamp_last_feedback); | 760 | &hcrx->ccid3hcrx_tstamp_last_feedback); |
770 | 761 | hcrx->ccid3hcrx_x_recv = usecs_div(hcrx->ccid3hcrx_bytes_recv, | |
771 | hcrx->ccid3hcrx_x_recv = (hcrx->ccid3hcrx_bytes_recv * | 762 | delta); |
772 | USEC_PER_SEC); | ||
773 | if (likely(delta > 1)) | ||
774 | hcrx->ccid3hcrx_x_recv /= delta; | ||
775 | } | 763 | } |
776 | break; | 764 | break; |
777 | default: | 765 | default: |
@@ -782,10 +770,10 @@ static void ccid3_hc_rx_send_feedback(struct sock *sk) | |||
782 | } | 770 | } |
783 | 771 | ||
784 | packet = dccp_rx_hist_find_data_packet(&hcrx->ccid3hcrx_hist); | 772 | packet = dccp_rx_hist_find_data_packet(&hcrx->ccid3hcrx_hist); |
785 | if (packet == NULL) { | 773 | if (unlikely(packet == NULL)) { |
786 | printk(KERN_CRIT "%s: %s, sk=%p, no data packet in history!\n", | 774 | LIMIT_NETDEBUG(KERN_WARNING "%s: %s, sk=%p, no data packet " |
787 | __FUNCTION__, dccp_role(sk), sk); | 775 | "in history!\n", |
788 | dump_stack(); | 776 | __FUNCTION__, dccp_role(sk), sk); |
789 | return; | 777 | return; |
790 | } | 778 | } |
791 | 779 | ||
@@ -801,17 +789,18 @@ static void ccid3_hc_rx_send_feedback(struct sock *sk) | |||
801 | hcrx->ccid3hcrx_pinv = ~0; | 789 | hcrx->ccid3hcrx_pinv = ~0; |
802 | else | 790 | else |
803 | hcrx->ccid3hcrx_pinv = 1000000 / hcrx->ccid3hcrx_p; | 791 | hcrx->ccid3hcrx_pinv = 1000000 / hcrx->ccid3hcrx_p; |
792 | dp->dccps_hc_rx_insert_options = 1; | ||
804 | dccp_send_ack(sk); | 793 | dccp_send_ack(sk); |
805 | } | 794 | } |
806 | 795 | ||
807 | static void ccid3_hc_rx_insert_options(struct sock *sk, struct sk_buff *skb) | 796 | static void ccid3_hc_rx_insert_options(struct sock *sk, struct sk_buff *skb) |
808 | { | 797 | { |
809 | const struct dccp_sock *dp = dccp_sk(sk); | 798 | const struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk); |
810 | u32 x_recv, pinv; | 799 | u32 x_recv, pinv; |
811 | struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private; | ||
812 | 800 | ||
813 | if (hcrx == NULL || !(sk->sk_state == DCCP_OPEN || | 801 | BUG_ON(hcrx == NULL); |
814 | sk->sk_state == DCCP_PARTOPEN)) | 802 | |
803 | if (!(sk->sk_state == DCCP_OPEN || sk->sk_state == DCCP_PARTOPEN)) | ||
815 | return; | 804 | return; |
816 | 805 | ||
817 | DCCP_SKB_CB(skb)->dccpd_ccval = hcrx->ccid3hcrx_last_counter; | 806 | DCCP_SKB_CB(skb)->dccpd_ccval = hcrx->ccid3hcrx_last_counter; |
@@ -837,8 +826,7 @@ static void ccid3_hc_rx_insert_options(struct sock *sk, struct sk_buff *skb) | |||
837 | 826 | ||
838 | static u32 ccid3_hc_rx_calc_first_li(struct sock *sk) | 827 | static u32 ccid3_hc_rx_calc_first_li(struct sock *sk) |
839 | { | 828 | { |
840 | struct dccp_sock *dp = dccp_sk(sk); | 829 | struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk); |
841 | struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private; | ||
842 | struct dccp_rx_hist_entry *entry, *next, *tail = NULL; | 830 | struct dccp_rx_hist_entry *entry, *next, *tail = NULL; |
843 | u32 rtt, delta, x_recv, fval, p, tmp2; | 831 | u32 rtt, delta, x_recv, fval, p, tmp2; |
844 | struct timeval tstamp = { 0, }; | 832 | struct timeval tstamp = { 0, }; |
@@ -869,17 +857,17 @@ static u32 ccid3_hc_rx_calc_first_li(struct sock *sk) | |||
869 | } | 857 | } |
870 | } | 858 | } |
871 | 859 | ||
872 | if (step == 0) { | 860 | if (unlikely(step == 0)) { |
873 | printk(KERN_CRIT "%s: %s, sk=%p, packet history contains no " | 861 | LIMIT_NETDEBUG(KERN_WARNING "%s: %s, sk=%p, packet history " |
874 | "data packets!\n", | 862 | "contains no data packets!\n", |
875 | __FUNCTION__, dccp_role(sk), sk); | 863 | __FUNCTION__, dccp_role(sk), sk); |
876 | return ~0; | 864 | return ~0; |
877 | } | 865 | } |
878 | 866 | ||
879 | if (interval == 0) { | 867 | if (unlikely(interval == 0)) { |
880 | ccid3_pr_debug("%s, sk=%p, Could not find a win_count " | 868 | LIMIT_NETDEBUG(KERN_WARNING "%s: %s, sk=%p, Could not find a " |
881 | "interval > 0. Defaulting to 1\n", | 869 | "win_count interval > 0. Defaulting to 1\n", |
882 | dccp_role(sk), sk); | 870 | __FUNCTION__, dccp_role(sk), sk); |
883 | interval = 1; | 871 | interval = 1; |
884 | } | 872 | } |
885 | found: | 873 | found: |
@@ -889,10 +877,9 @@ found: | |||
889 | if (rtt == 0) | 877 | if (rtt == 0) |
890 | rtt = 1; | 878 | rtt = 1; |
891 | 879 | ||
892 | delta = timeval_now_delta(&hcrx->ccid3hcrx_tstamp_last_feedback); | 880 | dccp_timestamp(sk, &tstamp); |
893 | x_recv = hcrx->ccid3hcrx_bytes_recv * USEC_PER_SEC; | 881 | delta = timeval_delta(&tstamp, &hcrx->ccid3hcrx_tstamp_last_feedback); |
894 | if (likely(delta > 1)) | 882 | x_recv = usecs_div(hcrx->ccid3hcrx_bytes_recv, delta); |
895 | x_recv /= delta; | ||
896 | 883 | ||
897 | tmp1 = (u64)x_recv * (u64)rtt; | 884 | tmp1 = (u64)x_recv * (u64)rtt; |
898 | do_div(tmp1,10000000); | 885 | do_div(tmp1,10000000); |
@@ -911,8 +898,7 @@ found: | |||
911 | 898 | ||
912 | static void ccid3_hc_rx_update_li(struct sock *sk, u64 seq_loss, u8 win_loss) | 899 | static void ccid3_hc_rx_update_li(struct sock *sk, u64 seq_loss, u8 win_loss) |
913 | { | 900 | { |
914 | struct dccp_sock *dp = dccp_sk(sk); | 901 | struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk); |
915 | struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private; | ||
916 | 902 | ||
917 | if (seq_loss != DCCP_MAX_SEQNO + 1 && | 903 | if (seq_loss != DCCP_MAX_SEQNO + 1 && |
918 | list_empty(&hcrx->ccid3hcrx_li_hist)) { | 904 | list_empty(&hcrx->ccid3hcrx_li_hist)) { |
@@ -924,14 +910,14 @@ static void ccid3_hc_rx_update_li(struct sock *sk, u64 seq_loss, u8 win_loss) | |||
924 | if (li_tail == NULL) | 910 | if (li_tail == NULL) |
925 | return; | 911 | return; |
926 | li_tail->dccplih_interval = ccid3_hc_rx_calc_first_li(sk); | 912 | li_tail->dccplih_interval = ccid3_hc_rx_calc_first_li(sk); |
927 | } | 913 | } else |
928 | /* FIXME: find end of interval */ | 914 | LIMIT_NETDEBUG(KERN_WARNING "%s: FIXME: find end of " |
915 | "interval\n", __FUNCTION__); | ||
929 | } | 916 | } |
930 | 917 | ||
931 | static void ccid3_hc_rx_detect_loss(struct sock *sk) | 918 | static void ccid3_hc_rx_detect_loss(struct sock *sk) |
932 | { | 919 | { |
933 | struct dccp_sock *dp = dccp_sk(sk); | 920 | struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk); |
934 | struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private; | ||
935 | u8 win_loss; | 921 | u8 win_loss; |
936 | const u64 seq_loss = dccp_rx_hist_detect_loss(&hcrx->ccid3hcrx_hist, | 922 | const u64 seq_loss = dccp_rx_hist_detect_loss(&hcrx->ccid3hcrx_hist, |
937 | &hcrx->ccid3hcrx_li_hist, | 923 | &hcrx->ccid3hcrx_li_hist, |
@@ -942,22 +928,19 @@ static void ccid3_hc_rx_detect_loss(struct sock *sk) | |||
942 | 928 | ||
943 | static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) | 929 | static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) |
944 | { | 930 | { |
945 | struct dccp_sock *dp = dccp_sk(sk); | 931 | struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk); |
946 | struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private; | ||
947 | const struct dccp_options_received *opt_recv; | 932 | const struct dccp_options_received *opt_recv; |
948 | struct dccp_rx_hist_entry *packet; | 933 | struct dccp_rx_hist_entry *packet; |
949 | struct timeval now; | 934 | struct timeval now; |
950 | u8 win_count; | 935 | u8 win_count; |
951 | u32 p_prev; | 936 | u32 p_prev, r_sample, t_elapsed; |
952 | int ins; | 937 | int ins; |
953 | 938 | ||
954 | if (hcrx == NULL) | 939 | BUG_ON(hcrx == NULL || |
955 | return; | 940 | !(hcrx->ccid3hcrx_state == TFRC_RSTATE_NO_DATA || |
956 | |||
957 | BUG_ON(!(hcrx->ccid3hcrx_state == TFRC_RSTATE_NO_DATA || | ||
958 | hcrx->ccid3hcrx_state == TFRC_RSTATE_DATA)); | 941 | hcrx->ccid3hcrx_state == TFRC_RSTATE_DATA)); |
959 | 942 | ||
960 | opt_recv = &dp->dccps_options_received; | 943 | opt_recv = &dccp_sk(sk)->dccps_options_received; |
961 | 944 | ||
962 | switch (DCCP_SKB_CB(skb)->dccpd_type) { | 945 | switch (DCCP_SKB_CB(skb)->dccpd_type) { |
963 | case DCCP_PKT_ACK: | 946 | case DCCP_PKT_ACK: |
@@ -967,10 +950,24 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
967 | if (opt_recv->dccpor_timestamp_echo == 0) | 950 | if (opt_recv->dccpor_timestamp_echo == 0) |
968 | break; | 951 | break; |
969 | p_prev = hcrx->ccid3hcrx_rtt; | 952 | p_prev = hcrx->ccid3hcrx_rtt; |
970 | do_gettimeofday(&now); | 953 | dccp_timestamp(sk, &now); |
971 | hcrx->ccid3hcrx_rtt = timeval_usecs(&now) - | 954 | timeval_sub_usecs(&now, opt_recv->dccpor_timestamp_echo * 10); |
972 | (opt_recv->dccpor_timestamp_echo - | 955 | r_sample = timeval_usecs(&now); |
973 | opt_recv->dccpor_elapsed_time) * 10; | 956 | t_elapsed = opt_recv->dccpor_elapsed_time * 10; |
957 | |||
958 | if (unlikely(r_sample <= t_elapsed)) | ||
959 | LIMIT_NETDEBUG(KERN_WARNING "%s: r_sample=%uus, " | ||
960 | "t_elapsed=%uus\n", | ||
961 | __FUNCTION__, r_sample, t_elapsed); | ||
962 | else | ||
963 | r_sample -= t_elapsed; | ||
964 | |||
965 | if (hcrx->ccid3hcrx_state == TFRC_RSTATE_NO_DATA) | ||
966 | hcrx->ccid3hcrx_rtt = r_sample; | ||
967 | else | ||
968 | hcrx->ccid3hcrx_rtt = (hcrx->ccid3hcrx_rtt * 9) / 10 + | ||
969 | r_sample / 10; | ||
970 | |||
974 | if (p_prev != hcrx->ccid3hcrx_rtt) | 971 | if (p_prev != hcrx->ccid3hcrx_rtt) |
975 | ccid3_pr_debug("%s, New RTT=%luus, elapsed time=%u\n", | 972 | ccid3_pr_debug("%s, New RTT=%luus, elapsed time=%u\n", |
976 | dccp_role(sk), hcrx->ccid3hcrx_rtt, | 973 | dccp_role(sk), hcrx->ccid3hcrx_rtt, |
@@ -978,19 +975,16 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
978 | break; | 975 | break; |
979 | case DCCP_PKT_DATA: | 976 | case DCCP_PKT_DATA: |
980 | break; | 977 | break; |
981 | default: | 978 | default: /* We're not interested in other packet types, move along */ |
982 | ccid3_pr_debug("%s, sk=%p, not DATA/DATAACK/ACK packet(%s)\n", | ||
983 | dccp_role(sk), sk, | ||
984 | dccp_packet_name(DCCP_SKB_CB(skb)->dccpd_type)); | ||
985 | return; | 979 | return; |
986 | } | 980 | } |
987 | 981 | ||
988 | packet = dccp_rx_hist_entry_new(ccid3_rx_hist, opt_recv->dccpor_ndp, | 982 | packet = dccp_rx_hist_entry_new(ccid3_rx_hist, sk, opt_recv->dccpor_ndp, |
989 | skb, SLAB_ATOMIC); | 983 | skb, SLAB_ATOMIC); |
990 | if (packet == NULL) { | 984 | if (unlikely(packet == NULL)) { |
991 | ccid3_pr_debug("%s, sk=%p, Not enough mem to add rx packet " | 985 | LIMIT_NETDEBUG(KERN_WARNING "%s: %s, sk=%p, Not enough mem to " |
992 | "to history (consider it lost)!", | 986 | "add rx packet to history, consider it lost!\n", |
993 | dccp_role(sk), sk); | 987 | __FUNCTION__, dccp_role(sk), sk); |
994 | return; | 988 | return; |
995 | } | 989 | } |
996 | 990 | ||
@@ -1017,7 +1011,7 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
1017 | if (ins != 0) | 1011 | if (ins != 0) |
1018 | break; | 1012 | break; |
1019 | 1013 | ||
1020 | do_gettimeofday(&now); | 1014 | dccp_timestamp(sk, &now); |
1021 | if (timeval_delta(&now, &hcrx->ccid3hcrx_tstamp_last_ack) >= | 1015 | if (timeval_delta(&now, &hcrx->ccid3hcrx_tstamp_last_ack) >= |
1022 | hcrx->ccid3hcrx_rtt) { | 1016 | hcrx->ccid3hcrx_rtt) { |
1023 | hcrx->ccid3hcrx_tstamp_last_ack = now; | 1017 | hcrx->ccid3hcrx_tstamp_last_ack = now; |
@@ -1056,11 +1050,11 @@ static int ccid3_hc_rx_init(struct sock *sk) | |||
1056 | 1050 | ||
1057 | ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk); | 1051 | ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk); |
1058 | 1052 | ||
1059 | hcrx = dp->dccps_hc_rx_ccid_private = kmalloc(sizeof(*hcrx), | 1053 | dp->dccps_hc_rx_ccid_private = kmalloc(sizeof(*hcrx), gfp_any()); |
1060 | gfp_any()); | 1054 | if (dp->dccps_hc_rx_ccid_private == NULL) |
1061 | if (hcrx == NULL) | ||
1062 | return -ENOMEM; | 1055 | return -ENOMEM; |
1063 | 1056 | ||
1057 | hcrx = ccid3_hc_rx_sk(sk); | ||
1064 | memset(hcrx, 0, sizeof(*hcrx)); | 1058 | memset(hcrx, 0, sizeof(*hcrx)); |
1065 | 1059 | ||
1066 | if (dp->dccps_packet_size >= TFRC_MIN_PACKET_SIZE && | 1060 | if (dp->dccps_packet_size >= TFRC_MIN_PACKET_SIZE && |
@@ -1072,23 +1066,18 @@ static int ccid3_hc_rx_init(struct sock *sk) | |||
1072 | hcrx->ccid3hcrx_state = TFRC_RSTATE_NO_DATA; | 1066 | hcrx->ccid3hcrx_state = TFRC_RSTATE_NO_DATA; |
1073 | INIT_LIST_HEAD(&hcrx->ccid3hcrx_hist); | 1067 | INIT_LIST_HEAD(&hcrx->ccid3hcrx_hist); |
1074 | INIT_LIST_HEAD(&hcrx->ccid3hcrx_li_hist); | 1068 | INIT_LIST_HEAD(&hcrx->ccid3hcrx_li_hist); |
1075 | /* | 1069 | dccp_timestamp(sk, &hcrx->ccid3hcrx_tstamp_last_ack); |
1076 | * XXX this seems to be paranoid, need to think more about this, for | 1070 | hcrx->ccid3hcrx_tstamp_last_feedback = hcrx->ccid3hcrx_tstamp_last_ack; |
1077 | * now start with something different than zero. -acme | 1071 | hcrx->ccid3hcrx_rtt = 5000; /* XXX 5ms for now... */ |
1078 | */ | ||
1079 | hcrx->ccid3hcrx_rtt = USEC_PER_SEC / 5; | ||
1080 | return 0; | 1072 | return 0; |
1081 | } | 1073 | } |
1082 | 1074 | ||
1083 | static void ccid3_hc_rx_exit(struct sock *sk) | 1075 | static void ccid3_hc_rx_exit(struct sock *sk) |
1084 | { | 1076 | { |
1077 | struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk); | ||
1085 | struct dccp_sock *dp = dccp_sk(sk); | 1078 | struct dccp_sock *dp = dccp_sk(sk); |
1086 | struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private; | ||
1087 | 1079 | ||
1088 | ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk); | 1080 | BUG_ON(hcrx == NULL); |
1089 | |||
1090 | if (hcrx == NULL) | ||
1091 | return; | ||
1092 | 1081 | ||
1093 | ccid3_hc_rx_set_state(sk, TFRC_RSTATE_TERM); | 1082 | ccid3_hc_rx_set_state(sk, TFRC_RSTATE_TERM); |
1094 | 1083 | ||
@@ -1104,12 +1093,14 @@ static void ccid3_hc_rx_exit(struct sock *sk) | |||
1104 | 1093 | ||
1105 | static void ccid3_hc_rx_get_info(struct sock *sk, struct tcp_info *info) | 1094 | static void ccid3_hc_rx_get_info(struct sock *sk, struct tcp_info *info) |
1106 | { | 1095 | { |
1107 | const struct dccp_sock *dp = dccp_sk(sk); | 1096 | const struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk); |
1108 | const struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private; | ||
1109 | 1097 | ||
1110 | if (hcrx == NULL) | 1098 | /* Listen socks doesn't have a private CCID block */ |
1099 | if (sk->sk_state == DCCP_LISTEN) | ||
1111 | return; | 1100 | return; |
1112 | 1101 | ||
1102 | BUG_ON(hcrx == NULL); | ||
1103 | |||
1113 | info->tcpi_ca_state = hcrx->ccid3hcrx_state; | 1104 | info->tcpi_ca_state = hcrx->ccid3hcrx_state; |
1114 | info->tcpi_options |= TCPI_OPT_TIMESTAMPS; | 1105 | info->tcpi_options |= TCPI_OPT_TIMESTAMPS; |
1115 | info->tcpi_rcv_rtt = hcrx->ccid3hcrx_rtt; | 1106 | info->tcpi_rcv_rtt = hcrx->ccid3hcrx_rtt; |
@@ -1117,12 +1108,14 @@ static void ccid3_hc_rx_get_info(struct sock *sk, struct tcp_info *info) | |||
1117 | 1108 | ||
1118 | static void ccid3_hc_tx_get_info(struct sock *sk, struct tcp_info *info) | 1109 | static void ccid3_hc_tx_get_info(struct sock *sk, struct tcp_info *info) |
1119 | { | 1110 | { |
1120 | const struct dccp_sock *dp = dccp_sk(sk); | 1111 | const struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); |
1121 | const struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; | ||
1122 | 1112 | ||
1123 | if (hctx == NULL) | 1113 | /* Listen socks doesn't have a private CCID block */ |
1114 | if (sk->sk_state == DCCP_LISTEN) | ||
1124 | return; | 1115 | return; |
1125 | 1116 | ||
1117 | BUG_ON(hctx == NULL); | ||
1118 | |||
1126 | info->tcpi_rto = hctx->ccid3hctx_t_rto; | 1119 | info->tcpi_rto = hctx->ccid3hctx_t_rto; |
1127 | info->tcpi_rtt = hctx->ccid3hctx_rtt; | 1120 | info->tcpi_rtt = hctx->ccid3hctx_rtt; |
1128 | } | 1121 | } |
diff --git a/net/dccp/ccids/ccid3.h b/net/dccp/ccids/ccid3.h index ee8cbace6630..eb248778eea3 100644 --- a/net/dccp/ccids/ccid3.h +++ b/net/dccp/ccids/ccid3.h | |||
@@ -48,6 +48,8 @@ | |||
48 | /* Two seconds as per CCID3 spec */ | 48 | /* Two seconds as per CCID3 spec */ |
49 | #define TFRC_INITIAL_TIMEOUT (2 * USEC_PER_SEC) | 49 | #define TFRC_INITIAL_TIMEOUT (2 * USEC_PER_SEC) |
50 | 50 | ||
51 | #define TFRC_INITIAL_IPI (USEC_PER_SEC / 4) | ||
52 | |||
51 | /* In usecs - half the scheduling granularity as per RFC3448 4.6 */ | 53 | /* In usecs - half the scheduling granularity as per RFC3448 4.6 */ |
52 | #define TFRC_OPSYS_HALF_TIME_GRAN (USEC_PER_SEC / (2 * HZ)) | 54 | #define TFRC_OPSYS_HALF_TIME_GRAN (USEC_PER_SEC / (2 * HZ)) |
53 | 55 | ||
@@ -115,7 +117,7 @@ struct ccid3_hc_rx_sock { | |||
115 | u64 ccid3hcrx_seqno_last_counter:48, | 117 | u64 ccid3hcrx_seqno_last_counter:48, |
116 | ccid3hcrx_state:8, | 118 | ccid3hcrx_state:8, |
117 | ccid3hcrx_last_counter:4; | 119 | ccid3hcrx_last_counter:4; |
118 | unsigned long ccid3hcrx_rtt; | 120 | u32 ccid3hcrx_rtt; |
119 | u32 ccid3hcrx_p; | 121 | u32 ccid3hcrx_p; |
120 | u32 ccid3hcrx_bytes_recv; | 122 | u32 ccid3hcrx_bytes_recv; |
121 | struct timeval ccid3hcrx_tstamp_last_feedback; | 123 | struct timeval ccid3hcrx_tstamp_last_feedback; |
@@ -128,10 +130,14 @@ struct ccid3_hc_rx_sock { | |||
128 | u32 ccid3hcrx_x_recv; | 130 | u32 ccid3hcrx_x_recv; |
129 | }; | 131 | }; |
130 | 132 | ||
131 | #define ccid3_hc_tx_field(s,field) (s->dccps_hc_tx_ccid_private == NULL ? 0 : \ | 133 | static inline struct ccid3_hc_tx_sock *ccid3_hc_tx_sk(const struct sock *sk) |
132 | ((struct ccid3_hc_tx_sock *)s->dccps_hc_tx_ccid_private)->ccid3hctx_##field) | 134 | { |
135 | return dccp_sk(sk)->dccps_hc_tx_ccid_private; | ||
136 | } | ||
133 | 137 | ||
134 | #define ccid3_hc_rx_field(s,field) (s->dccps_hc_rx_ccid_private == NULL ? 0 : \ | 138 | static inline struct ccid3_hc_rx_sock *ccid3_hc_rx_sk(const struct sock *sk) |
135 | ((struct ccid3_hc_rx_sock *)s->dccps_hc_rx_ccid_private)->ccid3hcrx_##field) | 139 | { |
140 | return dccp_sk(sk)->dccps_hc_rx_ccid_private; | ||
141 | } | ||
136 | 142 | ||
137 | #endif /* _DCCP_CCID3_H_ */ | 143 | #endif /* _DCCP_CCID3_H_ */ |
diff --git a/net/dccp/ccids/lib/packet_history.h b/net/dccp/ccids/lib/packet_history.h index fb90a91aa93d..b375ebdb7dcf 100644 --- a/net/dccp/ccids/lib/packet_history.h +++ b/net/dccp/ccids/lib/packet_history.h | |||
@@ -134,6 +134,7 @@ static inline struct dccp_tx_hist_entry * | |||
134 | 134 | ||
135 | static inline struct dccp_rx_hist_entry * | 135 | static inline struct dccp_rx_hist_entry * |
136 | dccp_rx_hist_entry_new(struct dccp_rx_hist *hist, | 136 | dccp_rx_hist_entry_new(struct dccp_rx_hist *hist, |
137 | const struct sock *sk, | ||
137 | const u32 ndp, | 138 | const u32 ndp, |
138 | const struct sk_buff *skb, | 139 | const struct sk_buff *skb, |
139 | const unsigned int __nocast prio) | 140 | const unsigned int __nocast prio) |
@@ -148,7 +149,7 @@ static inline struct dccp_rx_hist_entry * | |||
148 | entry->dccphrx_ccval = dh->dccph_ccval; | 149 | entry->dccphrx_ccval = dh->dccph_ccval; |
149 | entry->dccphrx_type = dh->dccph_type; | 150 | entry->dccphrx_type = dh->dccph_type; |
150 | entry->dccphrx_ndp = ndp; | 151 | entry->dccphrx_ndp = ndp; |
151 | do_gettimeofday(&(entry->dccphrx_tstamp)); | 152 | dccp_timestamp(sk, &entry->dccphrx_tstamp); |
152 | } | 153 | } |
153 | 154 | ||
154 | return entry; | 155 | return entry; |