Implement the gettimexattrs64 callback in the ENA driver to support the PTP_SYS_OFFSET_EXTENDED_ATTRS ioctl. This enables applications to retrieve PHC timestamps with quality attributes through the standard PTP ioctl interface. The ENA device currently reports only error_bound. clock_status and timescale attributes are set to default values. Signed-off-by: Amit Bernstein Signed-off-by: Arthur Kiyanovski --- drivers/net/ethernet/amazon/ena/ena_phc.c | 59 +++++++++++++++++++---- 1 file changed, 49 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/amazon/ena/ena_phc.c b/drivers/net/ethernet/amazon/ena/ena_phc.c index 2bcb5af..2ce5d45 100644 --- a/drivers/net/ethernet/amazon/ena/ena_phc.c +++ b/drivers/net/ethernet/amazon/ena/ena_phc.c @@ -25,6 +25,44 @@ static int ena_phc_feature_enable(struct ptp_clock_info *clock_info, return -EOPNOTSUPP; } +static int ena_phc_gettimexattrs64(struct ptp_clock_info *clock_info, + struct timespec64 *ts, + struct ptp_system_timestamp *sts, + struct ptp_clock_attributes *att) +{ + struct ena_phc_info *phc_info = + container_of(clock_info, struct ena_phc_info, clock_info); + u32 error_bound_nsec; + unsigned long flags; + u64 timestamp_nsec; + int rc; + + spin_lock_irqsave(&phc_info->lock, flags); + + ptp_read_system_prets(sts); + + rc = ena_com_phc_get_timestamp(phc_info->adapter->ena_dev, + ×tamp_nsec, + &error_bound_nsec); + + ptp_read_system_postts(sts); + + spin_unlock_irqrestore(&phc_info->lock, flags); + + if (rc) + return rc; + + *ts = ns_to_timespec64(timestamp_nsec); + + if (att) { + att->error_bound = error_bound_nsec; + att->status = PTP_CLOCK_STATUS_UNKNOWN; + att->timescale = PTP_TIMESCALE_UNKNOWN; + } + + return 0; +} + static int ena_phc_gettimex64(struct ptp_clock_info *clock_info, struct timespec64 *ts, struct ptp_system_timestamp *sts) @@ -62,16 +100,17 @@ static int ena_phc_settime64(struct ptp_clock_info *clock_info, } static struct ptp_clock_info ena_ptp_clock_info = { - .owner = THIS_MODULE, - .n_alarm = 0, - .n_ext_ts = 0, - .n_per_out = 0, - .pps = 0, - .adjtime = ena_phc_adjtime, - .adjfine = ena_phc_adjfine, - .gettimex64 = ena_phc_gettimex64, - .settime64 = ena_phc_settime64, - .enable = ena_phc_feature_enable, + .owner = THIS_MODULE, + .n_alarm = 0, + .n_ext_ts = 0, + .n_per_out = 0, + .pps = 0, + .adjtime = ena_phc_adjtime, + .adjfine = ena_phc_adjfine, + .gettimexattrs64 = ena_phc_gettimexattrs64, + .gettimex64 = ena_phc_gettimex64, + .settime64 = ena_phc_settime64, + .enable = ena_phc_feature_enable, }; /* Enable/Disable PHC by the kernel, affects on the next init flow */ -- 2.47.3