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

From: Richard Cochran
Date: Tue Jun 10 2025 - 23:29:43 EST


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