Skip to content

Commit 4aea6a6

Browse files
Binary-EaterSaeed Mahameed
authored andcommitted
net/mlx5: Query maximum frequency adjustment of the PTP hardware clock
Some mlx5 devices do not support the default advertised maximum frequency adjustment value for the PTP hardware clock that is set by the driver. These devices need to be queried when initializing the clock functionality in order to get the maximum supported frequency adjustment value. This value can be greater than the minimum supported frequency adjustment across mlx5 devices (50 million ppb). Signed-off-by: Rahul Rameshbabu <rrameshbabu@nvidia.com> Reviewed-by: Tariq Toukan <tariqt@nvidia.com> Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
1 parent 78c1b26 commit 4aea6a6

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,13 +1000,35 @@ static void mlx5_init_clock_info(struct mlx5_core_dev *mdev)
10001000
info->frac = timer->tc.frac;
10011001
}
10021002

1003+
static void mlx5_init_timer_max_freq_adjustment(struct mlx5_core_dev *mdev)
1004+
{
1005+
struct mlx5_clock *clock = &mdev->clock;
1006+
u32 out[MLX5_ST_SZ_DW(mtutc_reg)] = {};
1007+
u32 in[MLX5_ST_SZ_DW(mtutc_reg)] = {};
1008+
u8 log_max_freq_adjustment = 0;
1009+
int err;
1010+
1011+
err = mlx5_core_access_reg(mdev, in, sizeof(in), out, sizeof(out),
1012+
MLX5_REG_MTUTC, 0, 0);
1013+
if (!err)
1014+
log_max_freq_adjustment =
1015+
MLX5_GET(mtutc_reg, out, log_max_freq_adjustment);
1016+
1017+
if (log_max_freq_adjustment)
1018+
clock->ptp_info.max_adj =
1019+
min(S32_MAX, 1 << log_max_freq_adjustment);
1020+
}
1021+
10031022
static void mlx5_init_timer_clock(struct mlx5_core_dev *mdev)
10041023
{
10051024
struct mlx5_clock *clock = &mdev->clock;
10061025

10071026
/* Configure the PHC */
10081027
clock->ptp_info = mlx5_ptp_clock_info;
10091028

1029+
if (MLX5_CAP_MCAM_REG(mdev, mtutc))
1030+
mlx5_init_timer_max_freq_adjustment(mdev);
1031+
10101032
mlx5_timecounter_init(mdev);
10111033
mlx5_init_clock_info(mdev);
10121034
mlx5_init_overflow_period(clock);

include/linux/mlx5/mlx5_ifc.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10103,7 +10103,10 @@ enum {
1010310103
struct mlx5_ifc_mtutc_reg_bits {
1010410104
u8 reserved_at_0[0x5];
1010510105
u8 freq_adj_units[0x3];
10106-
u8 reserved_at_8[0x14];
10106+
u8 reserved_at_8[0x3];
10107+
u8 log_max_freq_adjustment[0x5];
10108+
10109+
u8 reserved_at_10[0xc];
1010710110
u8 operation[0x4];
1010810111

1010910112
u8 freq_adjustment[0x20];

0 commit comments

Comments
 (0)