Skip to content

Commit

Permalink
mlx4: add gettimex64() ptp method
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: NipaLocal <nipa@local>
  • Loading branch information
Mahesh Bandewar authored and NipaLocal committed Oct 9, 2024
1 parent 454f83f commit 2bac51a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions drivers/net/ethernet/mellanox/mlx4/en_clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
};
Expand Down

0 comments on commit 2bac51a

Please sign in to comment.