aboutsummaryrefslogtreecommitdiffstats
path: root/net/dccp/timer.c
diff options
context:
space:
mode:
authorGerrit Renker <gerrit@erg.abdn.ac.uk>2007-09-26 01:40:13 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-10 19:52:35 -0400
commit4c70f383e0c0273c4092c4efdb414be0966978b7 (patch)
tree733cc2497ec68c74d42ed6d8f6978b24152a3de0 /net/dccp/timer.c
parentaa97efd97acefb7d3dcd864adb878c7ce34061b3 (diff)
[DCCP]: Provide 10s of microsecond timesource
This provides a timesource, conveniently used for DCCP timestamps, which returns the elapsed time in 10s of microseconds since initialisation. This makes for a wrap-around time of about 11.9 hours, which should be sufficient for most applications. Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk> Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dccp/timer.c')
-rw-r--r--net/dccp/timer.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/net/dccp/timer.c b/net/dccp/timer.c
index 0197a41c256a..3af067354bd4 100644
--- a/net/dccp/timer.c
+++ b/net/dccp/timer.c
@@ -291,3 +291,24 @@ void dccp_init_xmit_timers(struct sock *sk)
291 inet_csk_init_xmit_timers(sk, &dccp_write_timer, &dccp_delack_timer, 291 inet_csk_init_xmit_timers(sk, &dccp_write_timer, &dccp_delack_timer,
292 &dccp_keepalive_timer); 292 &dccp_keepalive_timer);
293} 293}
294
295static ktime_t dccp_timestamp_seed;
296/**
297 * dccp_timestamp - 10s of microseconds time source
298 * Returns the number of 10s of microseconds since loading DCCP. This is native
299 * DCCP time difference format (RFC 4340, sec. 13).
300 * Please note: This will wrap around about circa every 11.9 hours.
301 */
302u32 dccp_timestamp(void)
303{
304 s64 delta = ktime_us_delta(ktime_get_real(), dccp_timestamp_seed);
305
306 do_div(delta, 10);
307 return delta;
308}
309EXPORT_SYMBOL_GPL(dccp_timestamp);
310
311void __init dccp_timestamping_init(void)
312{
313 dccp_timestamp_seed = ktime_get_real();
314}