summaryrefslogtreecommitdiffstats
path: root/sys/sys
diff options
context:
space:
mode:
authorlstewart <lstewart@FreeBSD.org>2011-11-21 13:34:29 +0000
committerlstewart <lstewart@FreeBSD.org>2011-11-21 13:34:29 +0000
commit09887e1dc59517a663f8c91773f1c14f4fdf069d (patch)
treea4ba0cb7247e0f91775a586bd52518db93b7fe95 /sys/sys
parentb95134ea01e46b282074a03ea01be1fc9d95a328 (diff)
downloadFreeBSD-src-09887e1dc59517a663f8c91773f1c14f4fdf069d.zip
FreeBSD-src-09887e1dc59517a663f8c91773f1c14f4fdf069d.tar.gz
- Add Pulse-Per-Second timestamping using raw ffcounter and corresponding
ffclock time in seconds. - Add IOCTL to retrieve ffclock timestamps from userland. Committed on behalf of Julien Ridoux and Darryl Veitch from the University of Melbourne, Australia, as part of the FreeBSD Foundation funded "Feed-Forward Clock Synchronization Algorithms" project. For more information, see http://www.synclab.org/radclock/ Submitted by: Julien Ridoux (jridoux at unimelb edu au)
Diffstat (limited to 'sys/sys')
-rw-r--r--sys/sys/timepps.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/sys/sys/timepps.h b/sys/sys/timepps.h
index cde9396..8083f33 100644
--- a/sys/sys/timepps.h
+++ b/sys/sys/timepps.h
@@ -6,6 +6,12 @@
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
+ * Copyright (c) 2011 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * Portions of this software were developed by Julien Ridoux at the University
+ * of Melbourne under sponsorship from the FreeBSD Foundation.
+ *
* $FreeBSD$
*
* The is a FreeBSD version of the RFC 2783 API for Pulse Per Second
@@ -15,6 +21,7 @@
#ifndef _SYS_TIMEPPS_H_
#define _SYS_TIMEPPS_H_
+#include <sys/_ffcounter.h>
#include <sys/ioccom.h>
#include <sys/time.h>
@@ -43,6 +50,16 @@ typedef struct {
int current_mode; /* current mode bits */
} pps_info_t;
+typedef struct {
+ pps_seq_t assert_sequence; /* assert event seq # */
+ pps_seq_t clear_sequence; /* clear event seq # */
+ pps_timeu_t assert_tu;
+ pps_timeu_t clear_tu;
+ ffcounter assert_ffcount; /* ffcounter on assert event */
+ ffcounter clear_ffcount; /* ffcounter on clear event */
+ int current_mode; /* current mode bits */
+} pps_info_ffc_t;
+
#define assert_timestamp assert_tu.tspec
#define clear_timestamp clear_tu.tspec
@@ -79,6 +96,10 @@ typedef struct {
#define PPS_TSFMT_TSPEC 0x1000
#define PPS_TSFMT_NTPFP 0x2000
+#define PPS_TSCLK_FBCK 0x10000
+#define PPS_TSCLK_FFWD 0x20000
+#define PPS_TSCLK_MASK 0x30000
+
#define PPS_KC_HARDPPS 0
#define PPS_KC_HARDPPS_PLL 1
#define PPS_KC_HARDPPS_FLL 2
@@ -89,6 +110,12 @@ struct pps_fetch_args {
struct timespec timeout;
};
+struct pps_fetch_ffc_args {
+ int tsformat;
+ pps_info_ffc_t pps_info_buf_ffc;
+ struct timespec timeout;
+};
+
struct pps_kcbind_args {
int kernel_consumer;
int edge;
@@ -102,18 +129,21 @@ struct pps_kcbind_args {
#define PPS_IOC_GETCAP _IOR('1', 5, int)
#define PPS_IOC_FETCH _IOWR('1', 6, struct pps_fetch_args)
#define PPS_IOC_KCBIND _IOW('1', 7, struct pps_kcbind_args)
+#define PPS_IOC_FETCH_FFCOUNTER _IOWR('1', 8, struct pps_fetch_ffc_args)
#ifdef _KERNEL
struct pps_state {
/* Capture information. */
struct timehands *capth;
+ struct fftimehands *capffth;
unsigned capgen;
unsigned capcount;
/* State information. */
pps_params_t ppsparam;
pps_info_t ppsinfo;
+ pps_info_ffc_t ppsinfo_ffc;
int kcmode;
int ppscap;
struct timecounter *ppstc;
@@ -184,6 +214,25 @@ time_pps_fetch(pps_handle_t handle, const int tsformat,
}
static __inline int
+time_pps_fetch_ffc(pps_handle_t handle, const int tsformat,
+ pps_info_ffc_t *ppsinfobuf, const struct timespec *timeout)
+{
+ struct pps_fetch_ffc_args arg;
+ int error;
+
+ arg.tsformat = tsformat;
+ if (timeout == NULL) {
+ arg.timeout.tv_sec = -1;
+ arg.timeout.tv_nsec = -1;
+ } else {
+ arg.timeout = *timeout;
+ }
+ error = ioctl(handle, PPS_IOC_FETCH_FFCOUNTER, &arg);
+ *ppsinfobuf = arg.pps_info_buf_ffc;
+ return (error);
+}
+
+static __inline int
time_pps_kcbind(pps_handle_t handle, const int kernel_consumer,
const int edge, const int tsformat)
{
OpenPOWER on IntegriCloud