Re: [RFC PATCH] ptp: extend offset ioctls to expose raw free-running cycles

From: Carolina Jubran
Date: Thu Jun 12 2025 - 05:15:59 EST




On 11/06/2025 6:29, Richard Cochran wrote:
On Tue, Jun 10, 2025 at 08:19:05PM +0300, Carolina Jubran wrote:

@@ -398,8 +423,14 @@ long ptp_ioctl(struct posix_clock_context *pccontext, unsigned int cmd,
break;
}
sts.clockid = extoff->clockid;
+ cycles = !!(extoff->rsv[0] & PTP_OFFSET_CYCLES);
for (i = 0; i < extoff->n_samples; i++) {
- err = ptp->info->gettimex64(ptp->info, &ts, &sts);
+ if (cycles)
+ err = ptp->info->getcyclesx64(ptp->info, &ts,
+ &sts);
+ else
+ err = ptp->info->gettimex64(ptp->info, &ts,
+ &sts);

ugh...

@@ -86,9 +111,15 @@
*
*/
struct ptp_clock_time {
- __s64 sec; /* seconds */
- __u32 nsec; /* nanoseconds */
- __u32 reserved;
+ union {
+ struct {
+ __s64 sec; /* seconds */
+ __u32 nsec; /* nanoseconds */
+ __u32 reserved;
+ };
+ __u64 cycles;
+ };
+
};

This overloading of an ioctl with even more flags goes too far.
Why not just add a new ioctl in a clean way?

Thanks,
Richard

Hi Richard,

Thanks for the feedback. I will add new ioctls and resend.

Carolina