Commit 4aea6a6d authored by Rahul Rameshbabu's avatar Rahul Rameshbabu Committed by Saeed Mahameed
Browse files

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: default avatarRahul Rameshbabu <rrameshbabu@nvidia.com>
Reviewed-by: default avatarTariq Toukan <tariqt@nvidia.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
parent 78c1b267
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -1000,6 +1000,25 @@ static void mlx5_init_clock_info(struct mlx5_core_dev *mdev)
	info->frac = timer->tc.frac;
}

static void mlx5_init_timer_max_freq_adjustment(struct mlx5_core_dev *mdev)
{
	struct mlx5_clock *clock = &mdev->clock;
	u32 out[MLX5_ST_SZ_DW(mtutc_reg)] = {};
	u32 in[MLX5_ST_SZ_DW(mtutc_reg)] = {};
	u8 log_max_freq_adjustment = 0;
	int err;

	err = mlx5_core_access_reg(mdev, in, sizeof(in), out, sizeof(out),
				   MLX5_REG_MTUTC, 0, 0);
	if (!err)
		log_max_freq_adjustment =
			MLX5_GET(mtutc_reg, out, log_max_freq_adjustment);

	if (log_max_freq_adjustment)
		clock->ptp_info.max_adj =
			min(S32_MAX, 1 << log_max_freq_adjustment);
}

static void mlx5_init_timer_clock(struct mlx5_core_dev *mdev)
{
	struct mlx5_clock *clock = &mdev->clock;
@@ -1007,6 +1026,9 @@ static void mlx5_init_timer_clock(struct mlx5_core_dev *mdev)
	/* Configure the PHC */
	clock->ptp_info = mlx5_ptp_clock_info;

	if (MLX5_CAP_MCAM_REG(mdev, mtutc))
		mlx5_init_timer_max_freq_adjustment(mdev);

	mlx5_timecounter_init(mdev);
	mlx5_init_clock_info(mdev);
	mlx5_init_overflow_period(clock);
+4 −1
Original line number Diff line number Diff line
@@ -10103,7 +10103,10 @@ enum {
struct mlx5_ifc_mtutc_reg_bits {
	u8         reserved_at_0[0x5];
	u8         freq_adj_units[0x3];
	u8         reserved_at_8[0x14];
	u8         reserved_at_8[0x3];
	u8         log_max_freq_adjustment[0x5];

	u8         reserved_at_10[0xc];
	u8         operation[0x4];

	u8         freq_adjustment[0x20];