Skip to content

Commit

Permalink
net/mlx5: Add firmware support for MTUTC scaled_ppm frequency adjustm…
Browse files Browse the repository at this point in the history
…ents

When device is capable of handling scaled ppm values for adjusting
frequency, conversion to ppb will not be done by the driver. Instead, the
scaled ppm value will be passed directly to the device for the frequency
adjustment operation.

Signed-off-by: Rahul Rameshbabu <rrameshbabu@nvidia.com>
Reviewed-by: Gal Pressman <gal@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
  • Loading branch information
Rahul Rameshbabu authored and Saeed Mahameed committed Feb 4, 2023
1 parent 04937a0 commit b63636b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
15 changes: 12 additions & 3 deletions drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,15 +362,23 @@ static int mlx5_ptp_adjphase(struct ptp_clock_info *ptp, s32 delta)
return mlx5_ptp_adjtime(ptp, delta);
}

static int mlx5_ptp_adjfreq_real_time(struct mlx5_core_dev *mdev, s32 freq)
static int mlx5_ptp_freq_adj_real_time(struct mlx5_core_dev *mdev, long scaled_ppm)
{
u32 in[MLX5_ST_SZ_DW(mtutc_reg)] = {};

if (!mlx5_modify_mtutc_allowed(mdev))
return 0;

MLX5_SET(mtutc_reg, in, operation, MLX5_MTUTC_OPERATION_ADJUST_FREQ_UTC);
MLX5_SET(mtutc_reg, in, freq_adjustment, freq);

if (MLX5_CAP_MCAM_FEATURE(mdev, mtutc_freq_adj_units)) {
MLX5_SET(mtutc_reg, in, freq_adj_units,
MLX5_MTUTC_FREQ_ADJ_UNITS_SCALED_PPM);
MLX5_SET(mtutc_reg, in, freq_adjustment, scaled_ppm);
} else {
MLX5_SET(mtutc_reg, in, freq_adj_units, MLX5_MTUTC_FREQ_ADJ_UNITS_PPB);
MLX5_SET(mtutc_reg, in, freq_adjustment, scaled_ppm_to_ppb(scaled_ppm));
}

return mlx5_set_mtutc(mdev, in, sizeof(in));
}
Expand All @@ -385,7 +393,8 @@ static int mlx5_ptp_adjfine(struct ptp_clock_info *ptp, long scaled_ppm)
int err;

mdev = container_of(clock, struct mlx5_core_dev, clock);
err = mlx5_ptp_adjfreq_real_time(mdev, scaled_ppm_to_ppb(scaled_ppm));

err = mlx5_ptp_freq_adj_real_time(mdev, scaled_ppm);
if (err)
return err;

Expand Down
12 changes: 10 additions & 2 deletions include/linux/mlx5/mlx5_ifc.h
Original file line number Diff line number Diff line change
Expand Up @@ -9925,14 +9925,21 @@ struct mlx5_ifc_mpegc_reg_bits {
u8 reserved_at_60[0x100];
};

enum {
MLX5_MTUTC_FREQ_ADJ_UNITS_PPB = 0x0,
MLX5_MTUTC_FREQ_ADJ_UNITS_SCALED_PPM = 0x1,
};

enum {
MLX5_MTUTC_OPERATION_SET_TIME_IMMEDIATE = 0x1,
MLX5_MTUTC_OPERATION_ADJUST_TIME = 0x2,
MLX5_MTUTC_OPERATION_ADJUST_FREQ_UTC = 0x3,
};

struct mlx5_ifc_mtutc_reg_bits {
u8 reserved_at_0[0x1c];
u8 reserved_at_0[0x5];
u8 freq_adj_units[0x3];
u8 reserved_at_8[0x14];
u8 operation[0x4];

u8 freq_adjustment[0x20];
Expand Down Expand Up @@ -10005,7 +10012,8 @@ struct mlx5_ifc_pcam_reg_bits {
};

struct mlx5_ifc_mcam_enhanced_features_bits {
u8 reserved_at_0[0x51];
u8 reserved_at_0[0x50];
u8 mtutc_freq_adj_units[0x1];
u8 mtutc_time_adjustment_extended_range[0x1];
u8 reserved_at_52[0xb];
u8 mcia_32dwords[0x1];
Expand Down

0 comments on commit b63636b

Please sign in to comment.