Re: [PATCHv3 next] ptp/ioctl: support MONOTONIC_RAW timestamps for PTP_SYS_OFFSET_EXTENDED

From: Paolo Abeni
Date: Fri Apr 26 2024 - 05:21:30 EST


On Mon, 2024-04-22 at 15:07 -0700, Mahesh Bandewar wrote:
> diff --git a/include/uapi/linux/ptp_clock.h b/include/uapi/linux/ptp_clock.h
> index 053b40d642de..02684d7e00e6 100644
> --- a/include/uapi/linux/ptp_clock.h
> +++ b/include/uapi/linux/ptp_clock.h
> @@ -155,13 +155,27 @@ struct ptp_sys_offset {
> struct ptp_clock_time ts[2 * PTP_MAX_SAMPLES + 1];
> };
>
> +/*
> + * ptp_sys_offset_extended - data structure for IOCTL operation
> + * PTP_SYS_OFFSET_EXTENDED
> + *
> + * @n_samples: Desired number of measurements.
> + * @clockid: clockid of a clock-base used for pre/post timestamps.
> + * @rsv: Reserved for future use.
> + * @ts: Array of samples in the form [pre-TS, PHC, post-TS]. The
> + * kernel provides @n_samples.
> + *
> + * History:
> + * v1: Initial implementation.
> + *
> + * v2: Use the first word of the reserved-field for @clockid. That's
> + * backword compatible since v1 expects @rsv[3] to be 0 while the

Minor nit ^^^ 'backward'

> + * clockid for CLOCK_REALTIME is '0'.
> + */
> struct ptp_sys_offset_extended {
> - unsigned int n_samples; /* Desired number of measurements. */
> - unsigned int rsv[3]; /* Reserved for future use. */
> - /*
> - * Array of [system, phc, system] time stamps. The kernel will provide
> - * 3*n_samples time stamps.
> - */
> + unsigned int n_samples;
> + __kernel_clockid_t clockid;
> + unsigned int rsv[2];

AFAICS, here you are using the 'old' rsv[0] as 'clockid'

Please either always use rsv[0] instead of rsv[2] or re-order the
fields.

Thanks,

Paolo