* [PATCH net-next 2/2] mlx4: add gettimex64() ptp method
@ 2024-10-08 10:46 Mahesh Bandewar
0 siblings, 0 replies; only message in thread
From: Mahesh Bandewar @ 2024-10-08 10:46 UTC (permalink / raw)
To: Netdev, Tariq Toukan, Yishai Hadas
Cc: Eric Dumazet, Jakub Kicinski, David Miller, Paolo Abeni,
Richard Cochran, Mahesh Bandewar, Mahesh Bandewar
Introduce the gettimex64() PTP method implementation, which enhances
the PTP clock read operation by providing pre- and post-timestamps to
determine the clock-read-call-width.
Signed-off-by: Mahesh Bandewar <maheshb@google.com>
---
drivers/net/ethernet/mellanox/mlx4/en_clock.c | 21 +++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_clock.c b/drivers/net/ethernet/mellanox/mlx4/en_clock.c
index 69c5e4c5e036..d3f6ece1531e 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_clock.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_clock.c
@@ -202,6 +202,26 @@ static int mlx4_en_phc_gettime(struct ptp_clock_info *ptp,
return 0;
}
+static int mlx4_en_phc_gettimex(struct ptp_clock_info *ptp,
+ struct timespec64 *ts,
+ struct ptp_system_timestamp *sts)
+{
+ struct mlx4_en_dev *mdev = container_of(ptp, struct mlx4_en_dev,
+ ptp_clock_info);
+ unsigned long flags;
+ u64 ns;
+
+ write_seqlock_irqsave(&mdev->clock_lock, flags);
+ /* refresh the clock_cache but get the pre/post ts */
+ mlx4_en_read_clock(mdev, sts);
+ ns = timecounter_read(&mdev->clock);
+ write_sequnlock_irqrestore(&mdev->clock_lock, flags);
+
+ *ts = ns_to_timespec64(ns);
+
+ return 0;
+}
+
/**
* mlx4_en_phc_settime - Set the current time on the hardware clock
* @ptp: ptp clock structure
@@ -255,6 +275,7 @@ static const struct ptp_clock_info mlx4_en_ptp_clock_info = {
.adjfine = mlx4_en_phc_adjfine,
.adjtime = mlx4_en_phc_adjtime,
.gettime64 = mlx4_en_phc_gettime,
+ .gettimex64 = mlx4_en_phc_gettimex,
.settime64 = mlx4_en_phc_settime,
.enable = mlx4_en_phc_enable,
};
--
2.47.0.rc0.187.ge670bccf7e-goog
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2024-10-08 10:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-08 10:46 [PATCH net-next 2/2] mlx4: add gettimex64() ptp method Mahesh Bandewar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).