Skip to content

Commit 78c1b26

Browse files
Binary-EaterSaeed Mahameed
authored andcommitted
net/mlx5: Convert scaled ppm values outside the s32 range for PHC frequency adjustments
Represent scaled ppm as ppb to the device when the value in scaled ppm is not representable as a 32-bit signed integer. mlx5 devices only support a 32-bit field for the frequency adjustment value in units of either scaled ppm or ppb. Since mlx5 devices only support a 32-bit field for the frequency adjustment value independent of unit used, limit the maximum frequency adjustment to S32_MAX 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 4395d9d commit 78c1b26

File tree

1 file changed

+4
-2
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core/lib

1 file changed

+4
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,10 +393,12 @@ static int mlx5_ptp_freq_adj_real_time(struct mlx5_core_dev *mdev, long scaled_p
393393

394394
MLX5_SET(mtutc_reg, in, operation, MLX5_MTUTC_OPERATION_ADJUST_FREQ_UTC);
395395

396-
if (MLX5_CAP_MCAM_FEATURE(mdev, mtutc_freq_adj_units)) {
396+
if (MLX5_CAP_MCAM_FEATURE(mdev, mtutc_freq_adj_units) &&
397+
scaled_ppm <= S32_MAX && scaled_ppm >= S32_MIN) {
398+
/* HW scaled_ppm support on mlx5 devices only supports a 32-bit value */
397399
MLX5_SET(mtutc_reg, in, freq_adj_units,
398400
MLX5_MTUTC_FREQ_ADJ_UNITS_SCALED_PPM);
399-
MLX5_SET(mtutc_reg, in, freq_adjustment, scaled_ppm);
401+
MLX5_SET(mtutc_reg, in, freq_adjustment, (s32)scaled_ppm);
400402
} else {
401403
MLX5_SET(mtutc_reg, in, freq_adj_units, MLX5_MTUTC_FREQ_ADJ_UNITS_PPB);
402404
MLX5_SET(mtutc_reg, in, freq_adjustment, scaled_ppm_to_ppb(scaled_ppm));

0 commit comments

Comments
 (0)