[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20241008104650.3276569-1-maheshb@google.com>
Date: Tue, 8 Oct 2024 03:46:50 -0700
From: Mahesh Bandewar <maheshb@...gle.com>
To: Netdev <netdev@...r.kernel.org>, Tariq Toukan <tariqt@...dia.com>,
Yishai Hadas <yishaih@...dia.com>
Cc: Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>,
David Miller <davem@...emloft.net>, Paolo Abeni <pabeni@...hat.com>,
Richard Cochran <richardcochran@...il.com>, Mahesh Bandewar <mahesh@...dewar.net>,
Mahesh Bandewar <maheshb@...gle.com>
Subject: [PATCH net-next 2/2] mlx4: add gettimex64() ptp method
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@...gle.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
Powered by blists - more mailing lists