History

ptp: add PTP_SYS_OFFSET_EXTENDED ioctl

The PTP_SYS_OFFSET ioctl, which can be used to measure the offset between a PHC and the system clock, includes the total time that the driver needs to read the PHC timestamp. This typically involves reading of multiple PCI registers (sometimes in multiple iterations) and the register that contains the lowest bits of the timestamp is not read in the middle between the two readings of the system clock. This asymmetry causes the measured offset to have a significant error. Introduce a new ioctl, driver function, and helper functions, which allow the reading of the lowest register to be isolated from the other readings in order to reduce the asymmetry. The ioctl returns three timestamps for each measurement: - system time right before reading the lowest bits of the PHC timestamp - PHC time - system time immediately after reading the lowest bits of the PHC timestamp

Miroslav Lichvar committed 8 years ago

Commit 36180081 parent 83d0bdc3 files · +76 −0Browse files

Showing the changes to include/uapi/linux (1 of 3 files). Show all

Unified · Split

include/uapi/linux/ptp_clock.h+12−0
@@ -84,6 +84,16 @@ struct ptp_sys_offset { · 83 unmodified lines
84 struct ptp_clock_time ts[2 * PTP_MAX_SAMPLES + 1];84 struct ptp_clock_time ts[2 * PTP_MAX_SAMPLES + 1];
85};85};
86 86
87struct ptp_sys_offset_extended {
88 unsigned int n_samples; /* Desired number of measurements. */
89 unsigned int rsv[3]; /* Reserved for future use. */
90 /*
91 * Array of [system, phc, system] time stamps. The kernel will provide
92 * 3*n_samples time stamps.
93 */
94 struct ptp_clock_time ts[PTP_MAX_SAMPLES][3];
95};
96
87struct ptp_sys_offset_precise {97struct ptp_sys_offset_precise {
88 struct ptp_clock_time device;98 struct ptp_clock_time device;
89 struct ptp_clock_time sys_realtime;99 struct ptp_clock_time sys_realtime;
@@ -136,6 +146,8 @@ struct ptp_pin_desc { · 46 unmodified lines
136#define PTP_PIN_SETFUNC _IOW(PTP_CLK_MAGIC, 7, struct ptp_pin_desc)146#define PTP_PIN_SETFUNC _IOW(PTP_CLK_MAGIC, 7, struct ptp_pin_desc)
137#define PTP_SYS_OFFSET_PRECISE \147#define PTP_SYS_OFFSET_PRECISE \
138 _IOWR(PTP_CLK_MAGIC, 8, struct ptp_sys_offset_precise)148 _IOWR(PTP_CLK_MAGIC, 8, struct ptp_sys_offset_precise)
149#define PTP_SYS_OFFSET_EXTENDED \
150 _IOW(PTP_CLK_MAGIC, 9, struct ptp_sys_offset_extended)
139 151
140struct ptp_extts_event {152struct ptp_extts_event {
141 struct ptp_clock_time t; /* Time event occured. */153 struct ptp_clock_time t; /* Time event occured. */