diff options
author | Arnaldo Carvalho de Melo <acme@ghostprotocols.net> | 2007-08-19 20:16:35 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-10 19:48:13 -0400 |
commit | 9823b7b5542858afe5b6a1e2df83b3847c28f3d6 (patch) | |
tree | 14be62612143fbcec66cd1b28a1d76564c578453 | |
parent | a272378d1128d1c60a463a315646c86d174ff74c (diff) |
[DCCP]: Convert dccp_sample_rtt to ktime_t
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/dccp/ccids/ccid3.c | 25 | ||||
-rw-r--r-- | net/dccp/dccp.h | 5 | ||||
-rw-r--r-- | net/dccp/input.c | 23 |
3 files changed, 23 insertions, 30 deletions
diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c index 1a0c5edb7b35..3524328db0b9 100644 --- a/net/dccp/ccids/ccid3.c +++ b/net/dccp/ccids/ccid3.c | |||
@@ -414,7 +414,7 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
414 | struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); | 414 | struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); |
415 | struct ccid3_options_received *opt_recv; | 415 | struct ccid3_options_received *opt_recv; |
416 | struct dccp_tx_hist_entry *packet; | 416 | struct dccp_tx_hist_entry *packet; |
417 | struct timeval now; | 417 | ktime_t now, t_hist; |
418 | unsigned long t_nfb; | 418 | unsigned long t_nfb; |
419 | u32 pinv, r_sample; | 419 | u32 pinv, r_sample; |
420 | 420 | ||
@@ -452,13 +452,13 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
452 | else /* can not exceed 100% */ | 452 | else /* can not exceed 100% */ |
453 | hctx->ccid3hctx_p = 1000000 / pinv; | 453 | hctx->ccid3hctx_p = 1000000 / pinv; |
454 | 454 | ||
455 | dccp_timestamp(sk, &now); | 455 | now = ktime_get_real(); |
456 | 456 | t_hist = timeval_to_ktime(packet->dccphtx_tstamp); | |
457 | /* | 457 | /* |
458 | * Calculate new round trip sample as per [RFC 3448, 4.3] by | 458 | * Calculate new round trip sample as per [RFC 3448, 4.3] by |
459 | * R_sample = (now - t_recvdata) - t_elapsed | 459 | * R_sample = (now - t_recvdata) - t_elapsed |
460 | */ | 460 | */ |
461 | r_sample = dccp_sample_rtt(sk, &now, &packet->dccphtx_tstamp); | 461 | r_sample = dccp_sample_rtt(sk, now, &t_hist); |
462 | 462 | ||
463 | /* | 463 | /* |
464 | * Update RTT estimate by | 464 | * Update RTT estimate by |
@@ -475,7 +475,7 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
475 | */ | 475 | */ |
476 | hctx->ccid3hctx_rtt = r_sample; | 476 | hctx->ccid3hctx_rtt = r_sample; |
477 | hctx->ccid3hctx_x = rfc3390_initial_rate(sk); | 477 | hctx->ccid3hctx_x = rfc3390_initial_rate(sk); |
478 | hctx->ccid3hctx_t_ld = timeval_to_ktime(now); | 478 | hctx->ccid3hctx_t_ld = now; |
479 | 479 | ||
480 | ccid3_update_send_interval(hctx); | 480 | ccid3_update_send_interval(hctx); |
481 | 481 | ||
@@ -882,6 +882,7 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
882 | struct dccp_rx_hist_entry *packet; | 882 | struct dccp_rx_hist_entry *packet; |
883 | u32 p_prev, r_sample, rtt_prev; | 883 | u32 p_prev, r_sample, rtt_prev; |
884 | int loss, payload_size; | 884 | int loss, payload_size; |
885 | ktime_t now; | ||
885 | 886 | ||
886 | BUG_ON(hcrx == NULL); | 887 | BUG_ON(hcrx == NULL); |
887 | 888 | ||
@@ -891,14 +892,12 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
891 | case DCCP_PKT_ACK: | 892 | case DCCP_PKT_ACK: |
892 | if (hcrx->ccid3hcrx_state == TFRC_RSTATE_NO_DATA) | 893 | if (hcrx->ccid3hcrx_state == TFRC_RSTATE_NO_DATA) |
893 | return; | 894 | return; |
894 | case DCCP_PKT_DATAACK: { | 895 | case DCCP_PKT_DATAACK: |
895 | struct timeval now; | ||
896 | |||
897 | if (opt_recv->dccpor_timestamp_echo == 0) | 896 | if (opt_recv->dccpor_timestamp_echo == 0) |
898 | break; | 897 | break; |
899 | rtt_prev = hcrx->ccid3hcrx_rtt; | 898 | rtt_prev = hcrx->ccid3hcrx_rtt; |
900 | dccp_timestamp(sk, &now); | 899 | now = ktime_get_real(); |
901 | r_sample = dccp_sample_rtt(sk, &now, NULL); | 900 | r_sample = dccp_sample_rtt(sk, now, NULL); |
902 | 901 | ||
903 | if (hcrx->ccid3hcrx_state == TFRC_RSTATE_NO_DATA) | 902 | if (hcrx->ccid3hcrx_state == TFRC_RSTATE_NO_DATA) |
904 | hcrx->ccid3hcrx_rtt = r_sample; | 903 | hcrx->ccid3hcrx_rtt = r_sample; |
@@ -911,7 +910,6 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
911 | dccp_role(sk), sk, hcrx->ccid3hcrx_rtt, | 910 | dccp_role(sk), sk, hcrx->ccid3hcrx_rtt, |
912 | opt_recv->dccpor_elapsed_time); | 911 | opt_recv->dccpor_elapsed_time); |
913 | break; | 912 | break; |
914 | } | ||
915 | case DCCP_PKT_DATA: | 913 | case DCCP_PKT_DATA: |
916 | break; | 914 | break; |
917 | default: /* We're not interested in other packet types, move along */ | 915 | default: /* We're not interested in other packet types, move along */ |
@@ -942,9 +940,7 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
942 | ccid3_hc_rx_send_feedback(sk); | 940 | ccid3_hc_rx_send_feedback(sk); |
943 | ccid3_hc_rx_set_state(sk, TFRC_RSTATE_DATA); | 941 | ccid3_hc_rx_set_state(sk, TFRC_RSTATE_DATA); |
944 | return; | 942 | return; |
945 | case TFRC_RSTATE_DATA: { | 943 | case TFRC_RSTATE_DATA: |
946 | ktime_t now; | ||
947 | |||
948 | hcrx->ccid3hcrx_bytes_recv += payload_size; | 944 | hcrx->ccid3hcrx_bytes_recv += payload_size; |
949 | if (loss) | 945 | if (loss) |
950 | break; | 946 | break; |
@@ -956,7 +952,6 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
956 | ccid3_hc_rx_send_feedback(sk); | 952 | ccid3_hc_rx_send_feedback(sk); |
957 | } | 953 | } |
958 | return; | 954 | return; |
959 | } | ||
960 | case TFRC_RSTATE_TERM: | 955 | case TFRC_RSTATE_TERM: |
961 | DCCP_BUG("%s(%p) - Illegal state TERM", dccp_role(sk), sk); | 956 | DCCP_BUG("%s(%p) - Illegal state TERM", dccp_role(sk), sk); |
962 | return; | 957 | return; |
diff --git a/net/dccp/dccp.h b/net/dccp/dccp.h index e2d74cd7eeeb..20a7bedfe996 100644 --- a/net/dccp/dccp.h +++ b/net/dccp/dccp.h | |||
@@ -13,6 +13,7 @@ | |||
13 | */ | 13 | */ |
14 | 14 | ||
15 | #include <linux/dccp.h> | 15 | #include <linux/dccp.h> |
16 | #include <linux/ktime.h> | ||
16 | #include <net/snmp.h> | 17 | #include <net/snmp.h> |
17 | #include <net/sock.h> | 18 | #include <net/sock.h> |
18 | #include <net/tcp.h> | 19 | #include <net/tcp.h> |
@@ -296,8 +297,8 @@ extern int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr, | |||
296 | extern int dccp_send_reset(struct sock *sk, enum dccp_reset_codes code); | 297 | extern int dccp_send_reset(struct sock *sk, enum dccp_reset_codes code); |
297 | extern void dccp_send_close(struct sock *sk, const int active); | 298 | extern void dccp_send_close(struct sock *sk, const int active); |
298 | extern int dccp_invalid_packet(struct sk_buff *skb); | 299 | extern int dccp_invalid_packet(struct sk_buff *skb); |
299 | extern u32 dccp_sample_rtt(struct sock *sk, struct timeval *t_recv, | 300 | extern u32 dccp_sample_rtt(struct sock *sk, ktime_t t_recv, |
300 | struct timeval *t_history); | 301 | ktime_t *t_history); |
301 | 302 | ||
302 | static inline int dccp_bad_service_code(const struct sock *sk, | 303 | static inline int dccp_bad_service_code(const struct sock *sk, |
303 | const __be32 service) | 304 | const __be32 service) |
diff --git a/net/dccp/input.c b/net/dccp/input.c index da6ec185ed5b..782cdb7292fa 100644 --- a/net/dccp/input.c +++ b/net/dccp/input.c | |||
@@ -301,12 +301,10 @@ static int dccp_rcv_request_sent_state_process(struct sock *sk, | |||
301 | goto out_invalid_packet; | 301 | goto out_invalid_packet; |
302 | 302 | ||
303 | /* Obtain RTT sample from SYN exchange (used by CCID 3) */ | 303 | /* Obtain RTT sample from SYN exchange (used by CCID 3) */ |
304 | if (dp->dccps_options_received.dccpor_timestamp_echo) { | 304 | if (dp->dccps_options_received.dccpor_timestamp_echo) |
305 | struct timeval now; | 305 | dp->dccps_syn_rtt = dccp_sample_rtt(sk, |
306 | 306 | ktime_get_real(), | |
307 | dccp_timestamp(sk, &now); | 307 | NULL); |
308 | dp->dccps_syn_rtt = dccp_sample_rtt(sk, &now, NULL); | ||
309 | } | ||
310 | 308 | ||
311 | if (dccp_msk(sk)->dccpms_send_ack_vector && | 309 | if (dccp_msk(sk)->dccpms_send_ack_vector && |
312 | dccp_ackvec_add(dp->dccps_hc_rx_ackvec, sk, | 310 | dccp_ackvec_add(dp->dccps_hc_rx_ackvec, sk, |
@@ -593,22 +591,21 @@ EXPORT_SYMBOL_GPL(dccp_rcv_state_process); | |||
593 | * @t_recv: receive timestamp of packet with timestamp echo | 591 | * @t_recv: receive timestamp of packet with timestamp echo |
594 | * @t_hist: packet history timestamp or NULL | 592 | * @t_hist: packet history timestamp or NULL |
595 | */ | 593 | */ |
596 | u32 dccp_sample_rtt(struct sock *sk, struct timeval *t_recv, | 594 | u32 dccp_sample_rtt(struct sock *sk, ktime_t t_recv, ktime_t *t_hist) |
597 | struct timeval *t_hist) | ||
598 | { | 595 | { |
599 | struct dccp_sock *dp = dccp_sk(sk); | 596 | struct dccp_sock *dp = dccp_sk(sk); |
600 | struct dccp_options_received *or = &dp->dccps_options_received; | 597 | struct dccp_options_received *or = &dp->dccps_options_received; |
601 | suseconds_t delta; | 598 | s64 delta; |
602 | 599 | ||
603 | if (t_hist == NULL) { | 600 | if (t_hist == NULL) { |
604 | if (!or->dccpor_timestamp_echo) { | 601 | if (!or->dccpor_timestamp_echo) { |
605 | DCCP_WARN("packet without timestamp echo\n"); | 602 | DCCP_WARN("packet without timestamp echo\n"); |
606 | return DCCP_SANE_RTT_MAX; | 603 | return DCCP_SANE_RTT_MAX; |
607 | } | 604 | } |
608 | timeval_sub_usecs(t_recv, or->dccpor_timestamp_echo * 10); | 605 | ktime_sub_us(t_recv, or->dccpor_timestamp_echo * 10); |
609 | delta = timeval_usecs(t_recv); | 606 | delta = ktime_to_us(t_recv); |
610 | } else | 607 | } else |
611 | delta = timeval_delta(t_recv, t_hist); | 608 | delta = ktime_us_delta(t_recv, *t_hist); |
612 | 609 | ||
613 | delta -= or->dccpor_elapsed_time * 10; /* either set or 0 */ | 610 | delta -= or->dccpor_elapsed_time * 10; /* either set or 0 */ |
614 | 611 | ||
@@ -616,7 +613,7 @@ u32 dccp_sample_rtt(struct sock *sk, struct timeval *t_recv, | |||
616 | DCCP_WARN("unusable RTT sample %ld, using min\n", (long)delta); | 613 | DCCP_WARN("unusable RTT sample %ld, using min\n", (long)delta); |
617 | return DCCP_SANE_RTT_MIN; | 614 | return DCCP_SANE_RTT_MIN; |
618 | } | 615 | } |
619 | if (unlikely(delta - (suseconds_t)DCCP_SANE_RTT_MAX > 0)) { | 616 | if (unlikely(delta - (s64)DCCP_SANE_RTT_MAX > 0)) { |
620 | DCCP_WARN("RTT sample %ld too large, using max\n", (long)delta); | 617 | DCCP_WARN("RTT sample %ld too large, using max\n", (long)delta); |
621 | return DCCP_SANE_RTT_MAX; | 618 | return DCCP_SANE_RTT_MAX; |
622 | } | 619 | } |