* [PATCHv2 next 2/3] ptp: add ioctl interface for ptp_gettimex64any()
@ 2023-10-03 4:17 Mahesh Bandewar
2023-10-04 4:30 ` Richard Cochran
0 siblings, 1 reply; 3+ messages in thread
From: Mahesh Bandewar @ 2023-10-03 4:17 UTC (permalink / raw)
To: Netdev, Linux, David Miller, Jakub Kicinski, Eric Dumazet,
Paolo Abeni
Cc: Jonathan Corbet, John Stultz, Don Hatchett, Yuliang Li,
Mahesh Bandewar, Mahesh Bandewar, Richard Cochran,
Rahul Rameshbabu
add an ioctl op PTP_SYS_OFFSET_ANY2 to support ptp_gettimex64any() method
Signed-off-by: Mahesh Bandewar <maheshb@google.com>
CC: Richard Cochran <richardcochran@gmail.com>
CC: Rahul Rameshbabu <rrameshbabu@nvidia.com>
CC: "David S. Miller" <davem@davemloft.net>
CC: netdev@vger.kernel.org
---
drivers/ptp/ptp_chardev.c | 34 ++++++++++++++++++++++++++++++++++
include/uapi/linux/ptp_clock.h | 14 ++++++++++++++
2 files changed, 48 insertions(+)
diff --git a/drivers/ptp/ptp_chardev.c b/drivers/ptp/ptp_chardev.c
index 362bf756e6b7..fef1c7e7e6e6 100644
--- a/drivers/ptp/ptp_chardev.c
+++ b/drivers/ptp/ptp_chardev.c
@@ -110,6 +110,7 @@ long ptp_ioctl(struct posix_clock *pc, unsigned int cmd, unsigned long arg)
{
struct ptp_clock *ptp = container_of(pc, struct ptp_clock, clock);
struct ptp_sys_offset_extended *extoff = NULL;
+ struct ptp_sys_offset_any *anyoff = NULL;
struct ptp_sys_offset_precise precise_offset;
struct system_device_crosststamp xtstamp;
struct ptp_clock_info *ops = ptp->info;
@@ -324,6 +325,39 @@ long ptp_ioctl(struct posix_clock *pc, unsigned int cmd, unsigned long arg)
err = -EFAULT;
break;
+ case PTP_SYS_OFFSET_ANY2:
+ if (!ptp->info->gettimex64any) {
+ err = -EOPNOTSUPP;
+ break;
+ }
+ anyoff = memdup_user((void __user *)arg, sizeof(*anyoff));
+ if (IS_ERR(anyoff)) {
+ err = PTR_ERR(anyoff);
+ anyoff = NULL;
+ break;
+ }
+ if (anyoff->n_samples > PTP_MAX_SAMPLES
+ || anyoff->ts_type >= PTP_TS_MAX
+ || anyoff->rsv[0] || anyoff->rsv[1]) {
+ err = -EINVAL;
+ break;
+ }
+ for (i = 0; i < anyoff->n_samples; i++) {
+ err = ptp->info->gettimex64any(ptp->info, &ts, &sts,
+ anyoff->ts_type);
+ if (err)
+ goto out;
+ anyoff->ts[i][0].sec = sts.pre_ts.tv_sec;
+ anyoff->ts[i][0].nsec = sts.pre_ts.tv_nsec;
+ anyoff->ts[i][1].sec = ts.tv_sec;
+ anyoff->ts[i][1].nsec = ts.tv_nsec;
+ anyoff->ts[i][2].sec = sts.post_ts.tv_sec;
+ anyoff->ts[i][2].nsec = sts.post_ts.tv_nsec;
+ }
+ if (copy_to_user((void __user *)arg, anyoff, sizeof(*anyoff)))
+ err = -EFAULT;
+ break;
+
case PTP_SYS_OFFSET:
case PTP_SYS_OFFSET2:
sysoff = memdup_user((void __user *)arg, sizeof(*sysoff));
diff --git a/include/uapi/linux/ptp_clock.h b/include/uapi/linux/ptp_clock.h
index dc44e34f8146..b4e71e754b35 100644
--- a/include/uapi/linux/ptp_clock.h
+++ b/include/uapi/linux/ptp_clock.h
@@ -165,6 +165,18 @@ struct ptp_sys_offset_extended {
struct ptp_clock_time ts[PTP_MAX_SAMPLES][3];
};
+struct ptp_sys_offset_any {
+ unsigned int n_samples; /* Desired number of measurements. */
+ enum ptp_ts_types ts_type; /* One of the TS types */
+ unsigned int rsv[2]; /* Reserved for future use. */
+ /*
+ * Array of [TS, phc, TS] time stamps. The kernel will provide
+ * 3*n_samples time stamps.
+ * TS is any of the ts_type requested.
+ */
+ struct ptp_clock_time ts[PTP_MAX_SAMPLES][3];
+};
+
struct ptp_sys_offset_precise {
struct ptp_clock_time device;
struct ptp_clock_time sys_realtime;
@@ -231,6 +243,8 @@ struct ptp_pin_desc {
_IOWR(PTP_CLK_MAGIC, 17, struct ptp_sys_offset_precise)
#define PTP_SYS_OFFSET_EXTENDED2 \
_IOWR(PTP_CLK_MAGIC, 18, struct ptp_sys_offset_extended)
+#define PTP_SYS_OFFSET_ANY2 \
+ _IOWR(PTP_CLK_MAGIC, 19, struct ptp_sys_offset_any)
struct ptp_extts_event {
struct ptp_clock_time t; /* Time event occured. */
--
2.42.0.582.g8ccd20d70d-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCHv2 next 2/3] ptp: add ioctl interface for ptp_gettimex64any()
2023-10-03 4:17 [PATCHv2 next 2/3] ptp: add ioctl interface for ptp_gettimex64any() Mahesh Bandewar
@ 2023-10-04 4:30 ` Richard Cochran
2023-10-05 23:09 ` Mahesh Bandewar (महेश बंडेवार)
0 siblings, 1 reply; 3+ messages in thread
From: Richard Cochran @ 2023-10-04 4:30 UTC (permalink / raw)
To: Mahesh Bandewar
Cc: Netdev, Linux, David Miller, Jakub Kicinski, Eric Dumazet,
Paolo Abeni, Jonathan Corbet, John Stultz, Don Hatchett,
Yuliang Li, Mahesh Bandewar, Rahul Rameshbabu
On Mon, Oct 02, 2023 at 09:17:04PM -0700, Mahesh Bandewar wrote:
> add an ioctl op PTP_SYS_OFFSET_ANY2 to support ptp_gettimex64any() method
NAK.
> + case PTP_SYS_OFFSET_ANY2:
2?
What happended to 1?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCHv2 next 2/3] ptp: add ioctl interface for ptp_gettimex64any()
2023-10-04 4:30 ` Richard Cochran
@ 2023-10-05 23:09 ` Mahesh Bandewar (महेश बंडेवार)
0 siblings, 0 replies; 3+ messages in thread
From: Mahesh Bandewar (महेश बंडेवार) @ 2023-10-05 23:09 UTC (permalink / raw)
To: Richard Cochran
Cc: Netdev, Linux, David Miller, Jakub Kicinski, Eric Dumazet,
Paolo Abeni, Jonathan Corbet, John Stultz, Don Hatchett,
Yuliang Li, Mahesh Bandewar, Rahul Rameshbabu
On Tue, Oct 3, 2023 at 9:30 PM Richard Cochran <richardcochran@gmail.com> wrote:
>
> On Mon, Oct 02, 2023 at 09:17:04PM -0700, Mahesh Bandewar wrote:
> > add an ioctl op PTP_SYS_OFFSET_ANY2 to support ptp_gettimex64any() method
>
> NAK.
>
Could you elaborate?
> > + case PTP_SYS_OFFSET_ANY2:
>
> 2?
>
> What happended to 1?
My reading from the commit 415606588c61 ("PTP: introduce new versions
of IOCTLs") is that we have an issue with the version 1 and hence we
added ver 2 of the existing ops. Since it's a new implementation, I
can skip the old part and just implement ver 2.
However, I can do something like
#define PTP_SYS_OFFSET_ANY PTP_OFFSET_ANY2
is that something inline with the mix of ver 1 and ver 2 expectation?
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-10-05 23:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-03 4:17 [PATCHv2 next 2/3] ptp: add ioctl interface for ptp_gettimex64any() Mahesh Bandewar
2023-10-04 4:30 ` Richard Cochran
2023-10-05 23:09 ` Mahesh Bandewar (महेश बंडेवार)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox