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
8484 struct ptp_clock_time ts[2 * PTP_MAX_SAMPLES + 1];
8585 };
8686
87+struct 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+
8797 struct ptp_sys_offset_precise {
8898 struct ptp_clock_time device;
8999 struct ptp_clock_time sys_realtime;
@@ -136,6 +146,8 @@ struct ptp_pin_desc { · 46 unmodified lines
136146 #define PTP_PIN_SETFUNC _IOW(PTP_CLK_MAGIC, 7, struct ptp_pin_desc)
137147 #define PTP_SYS_OFFSET_PRECISE \
138148 _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)
139151
140152 struct ptp_extts_event {
141153 struct ptp_clock_time t; /* Time event occured. */