diff options
author | Arnaldo Carvalho de Melo <acme@mandriva.com> | 2005-09-09 01:38:35 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@mandriva.com> | 2005-09-09 01:38:35 -0400 |
commit | b0e567806d16586629468c824dfb2e71155df7da (patch) | |
tree | 70f5905fae3270985fed1050335c56598fd32646 /net/dccp/ccids | |
parent | 954ee31f366fabe53fb450482789258fe552f40b (diff) |
[DCCP] Introduce dccp_timestamp
To start the timestamps with 0.0ms, easing the integer maths in the CCIDs, this
probably will be reworked to use the to be introduced struct timeval_offset
infrastructure out of skb_get_timestamp, etc.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
Diffstat (limited to 'net/dccp/ccids')
-rw-r--r-- | net/dccp/ccids/ccid3.c | 27 | ||||
-rw-r--r-- | net/dccp/ccids/ccid3.h | 2 | ||||
-rw-r--r-- | net/dccp/ccids/lib/packet_history.h | 3 |
3 files changed, 17 insertions, 15 deletions
diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c index 145aafafe4e2..348e6fb262c3 100644 --- a/net/dccp/ccids/ccid3.c +++ b/net/dccp/ccids/ccid3.c | |||
@@ -169,7 +169,7 @@ static void ccid3_hc_tx_update_x(struct sock *sk) | |||
169 | } else { | 169 | } else { |
170 | struct timeval now; | 170 | struct timeval now; |
171 | 171 | ||
172 | do_gettimeofday(&now); | 172 | dccp_timestamp(sk, &now); |
173 | if (timeval_delta(&now, &hctx->ccid3hctx_t_ld) >= | 173 | if (timeval_delta(&now, &hctx->ccid3hctx_t_ld) >= |
174 | hctx->ccid3hctx_rtt) { | 174 | hctx->ccid3hctx_rtt) { |
175 | hctx->ccid3hctx_x = max_t(u32, min_t(u32, hctx->ccid3hctx_x_recv, | 175 | hctx->ccid3hctx_x = max_t(u32, min_t(u32, hctx->ccid3hctx_x_recv, |
@@ -317,7 +317,7 @@ static int ccid3_hc_tx_send_packet(struct sock *sk, | |||
317 | dccp_tx_hist_add_entry(&hctx->ccid3hctx_hist, new_packet); | 317 | dccp_tx_hist_add_entry(&hctx->ccid3hctx_hist, new_packet); |
318 | } | 318 | } |
319 | 319 | ||
320 | do_gettimeofday(&now); | 320 | dccp_timestamp(sk, &now); |
321 | 321 | ||
322 | switch (hctx->ccid3hctx_state) { | 322 | switch (hctx->ccid3hctx_state) { |
323 | case TFRC_SSTATE_NO_SENT: | 323 | case TFRC_SSTATE_NO_SENT: |
@@ -382,7 +382,7 @@ static void ccid3_hc_tx_packet_sent(struct sock *sk, int more, int len) | |||
382 | return; | 382 | return; |
383 | } | 383 | } |
384 | 384 | ||
385 | do_gettimeofday(&now); | 385 | dccp_timestamp(sk, &now); |
386 | 386 | ||
387 | /* check if we have sent a data packet */ | 387 | /* check if we have sent a data packet */ |
388 | if (len > 0) { | 388 | if (len > 0) { |
@@ -461,6 +461,7 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
461 | struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; | 461 | struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; |
462 | struct ccid3_options_received *opt_recv; | 462 | struct ccid3_options_received *opt_recv; |
463 | struct dccp_tx_hist_entry *packet; | 463 | struct dccp_tx_hist_entry *packet; |
464 | struct timeval now; | ||
464 | unsigned long next_tmout; | 465 | unsigned long next_tmout; |
465 | u32 t_elapsed; | 466 | u32 t_elapsed; |
466 | u32 pinv; | 467 | u32 pinv; |
@@ -508,7 +509,8 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
508 | } | 509 | } |
509 | 510 | ||
510 | /* Update RTT */ | 511 | /* Update RTT */ |
511 | r_sample = timeval_now_delta(&packet->dccphtx_tstamp); | 512 | dccp_timestamp(sk, &now); |
513 | r_sample = timeval_delta(&now, &packet->dccphtx_tstamp); | ||
512 | if (unlikely(r_sample <= t_elapsed)) | 514 | if (unlikely(r_sample <= t_elapsed)) |
513 | LIMIT_NETDEBUG(KERN_WARNING | 515 | LIMIT_NETDEBUG(KERN_WARNING |
514 | "%s: r_sample=%uus, t_elapsed=%uus\n", | 516 | "%s: r_sample=%uus, t_elapsed=%uus\n", |
@@ -774,7 +776,7 @@ static void ccid3_hc_rx_send_feedback(struct sock *sk) | |||
774 | 776 | ||
775 | ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk); | 777 | ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk); |
776 | 778 | ||
777 | do_gettimeofday(&now); | 779 | dccp_timestamp(sk, &now); |
778 | 780 | ||
779 | switch (hcrx->ccid3hcrx_state) { | 781 | switch (hcrx->ccid3hcrx_state) { |
780 | case TFRC_RSTATE_NO_DATA: | 782 | case TFRC_RSTATE_NO_DATA: |
@@ -903,10 +905,9 @@ found: | |||
903 | if (rtt == 0) | 905 | if (rtt == 0) |
904 | rtt = 1; | 906 | rtt = 1; |
905 | 907 | ||
906 | delta = timeval_now_delta(&hcrx->ccid3hcrx_tstamp_last_feedback); | 908 | dccp_timestamp(sk, &tstamp); |
907 | x_recv = hcrx->ccid3hcrx_bytes_recv * USEC_PER_SEC; | 909 | delta = timeval_delta(&tstamp, &hcrx->ccid3hcrx_tstamp_last_feedback); |
908 | if (likely(delta > 1)) | 910 | x_recv = usecs_div(hcrx->ccid3hcrx_bytes_recv, delta); |
909 | x_recv /= delta; | ||
910 | 911 | ||
911 | tmp1 = (u64)x_recv * (u64)rtt; | 912 | tmp1 = (u64)x_recv * (u64)rtt; |
912 | do_div(tmp1,10000000); | 913 | do_div(tmp1,10000000); |
@@ -981,7 +982,7 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
981 | if (opt_recv->dccpor_timestamp_echo == 0) | 982 | if (opt_recv->dccpor_timestamp_echo == 0) |
982 | break; | 983 | break; |
983 | p_prev = hcrx->ccid3hcrx_rtt; | 984 | p_prev = hcrx->ccid3hcrx_rtt; |
984 | do_gettimeofday(&now); | 985 | dccp_timestamp(sk, &now); |
985 | timeval_sub_usecs(&now, opt_recv->dccpor_timestamp_echo * 10); | 986 | timeval_sub_usecs(&now, opt_recv->dccpor_timestamp_echo * 10); |
986 | r_sample = timeval_usecs(&now); | 987 | r_sample = timeval_usecs(&now); |
987 | t_elapsed = opt_recv->dccpor_elapsed_time * 10; | 988 | t_elapsed = opt_recv->dccpor_elapsed_time * 10; |
@@ -1013,7 +1014,7 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
1013 | return; | 1014 | return; |
1014 | } | 1015 | } |
1015 | 1016 | ||
1016 | packet = dccp_rx_hist_entry_new(ccid3_rx_hist, opt_recv->dccpor_ndp, | 1017 | packet = dccp_rx_hist_entry_new(ccid3_rx_hist, sk, opt_recv->dccpor_ndp, |
1017 | skb, SLAB_ATOMIC); | 1018 | skb, SLAB_ATOMIC); |
1018 | if (packet == NULL) { | 1019 | if (packet == NULL) { |
1019 | ccid3_pr_debug("%s, sk=%p, Not enough mem to add rx packet " | 1020 | ccid3_pr_debug("%s, sk=%p, Not enough mem to add rx packet " |
@@ -1045,7 +1046,7 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
1045 | if (ins != 0) | 1046 | if (ins != 0) |
1046 | break; | 1047 | break; |
1047 | 1048 | ||
1048 | do_gettimeofday(&now); | 1049 | dccp_timestamp(sk, &now); |
1049 | if (timeval_delta(&now, &hcrx->ccid3hcrx_tstamp_last_ack) >= | 1050 | if (timeval_delta(&now, &hcrx->ccid3hcrx_tstamp_last_ack) >= |
1050 | hcrx->ccid3hcrx_rtt) { | 1051 | hcrx->ccid3hcrx_rtt) { |
1051 | hcrx->ccid3hcrx_tstamp_last_ack = now; | 1052 | hcrx->ccid3hcrx_tstamp_last_ack = now; |
@@ -1100,7 +1101,7 @@ static int ccid3_hc_rx_init(struct sock *sk) | |||
1100 | hcrx->ccid3hcrx_state = TFRC_RSTATE_NO_DATA; | 1101 | hcrx->ccid3hcrx_state = TFRC_RSTATE_NO_DATA; |
1101 | INIT_LIST_HEAD(&hcrx->ccid3hcrx_hist); | 1102 | INIT_LIST_HEAD(&hcrx->ccid3hcrx_hist); |
1102 | INIT_LIST_HEAD(&hcrx->ccid3hcrx_li_hist); | 1103 | INIT_LIST_HEAD(&hcrx->ccid3hcrx_li_hist); |
1103 | do_gettimeofday(&hcrx->ccid3hcrx_tstamp_last_ack); | 1104 | dccp_timestamp(sk, &hcrx->ccid3hcrx_tstamp_last_ack); |
1104 | hcrx->ccid3hcrx_tstamp_last_feedback = hcrx->ccid3hcrx_tstamp_last_ack; | 1105 | hcrx->ccid3hcrx_tstamp_last_feedback = hcrx->ccid3hcrx_tstamp_last_ack; |
1105 | hcrx->ccid3hcrx_rtt = 5000; /* XXX 5ms for now... */ | 1106 | hcrx->ccid3hcrx_rtt = 5000; /* XXX 5ms for now... */ |
1106 | return 0; | 1107 | return 0; |
diff --git a/net/dccp/ccids/ccid3.h b/net/dccp/ccids/ccid3.h index ee8cbace6630..58be6125b695 100644 --- a/net/dccp/ccids/ccid3.h +++ b/net/dccp/ccids/ccid3.h | |||
@@ -115,7 +115,7 @@ struct ccid3_hc_rx_sock { | |||
115 | u64 ccid3hcrx_seqno_last_counter:48, | 115 | u64 ccid3hcrx_seqno_last_counter:48, |
116 | ccid3hcrx_state:8, | 116 | ccid3hcrx_state:8, |
117 | ccid3hcrx_last_counter:4; | 117 | ccid3hcrx_last_counter:4; |
118 | unsigned long ccid3hcrx_rtt; | 118 | u32 ccid3hcrx_rtt; |
119 | u32 ccid3hcrx_p; | 119 | u32 ccid3hcrx_p; |
120 | u32 ccid3hcrx_bytes_recv; | 120 | u32 ccid3hcrx_bytes_recv; |
121 | struct timeval ccid3hcrx_tstamp_last_feedback; | 121 | struct timeval ccid3hcrx_tstamp_last_feedback; |
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; |