mirror of
https://github.com/torvalds/linux.git
synced 2026-06-04 12:35:52 +02:00
net/mlx5: Add hardware extended range support for PTP adjtime and adjphase
Capable hardware can use an extended range for offsetting the clock. An extended range of [-200000,200000] is used instead of [-32768,32767] for the delta/phase parameter of the adjtime/adjphase ptp_clock_info callbacks. Signed-off-by: Rahul Rameshbabu <rrameshbabu@nvidia.com> Reviewed-by: Gal Pressman <gal@nvidia.com> Reviewed-by: Tariq Toukan <tariqt@nvidia.com> Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
This commit is contained in:
parent
8e11a68e2e
commit
d3c8a33a5c
|
|
@ -69,6 +69,13 @@ enum {
|
|||
MLX5_MTPPS_FS_OUT_PULSE_DURATION_NS = BIT(0xa),
|
||||
};
|
||||
|
||||
enum {
|
||||
MLX5_MTUTC_OPERATION_ADJUST_TIME_MIN = S16_MIN,
|
||||
MLX5_MTUTC_OPERATION_ADJUST_TIME_MAX = S16_MAX,
|
||||
MLX5_MTUTC_OPERATION_ADJUST_TIME_EXTENDED_MIN = -200000,
|
||||
MLX5_MTUTC_OPERATION_ADJUST_TIME_EXTENDED_MAX = 200000,
|
||||
};
|
||||
|
||||
static bool mlx5_real_time_mode(struct mlx5_core_dev *mdev)
|
||||
{
|
||||
return (mlx5_is_real_time_rq(mdev) || mlx5_is_real_time_sq(mdev));
|
||||
|
|
@ -86,6 +93,22 @@ static bool mlx5_modify_mtutc_allowed(struct mlx5_core_dev *mdev)
|
|||
return MLX5_CAP_MCAM_FEATURE(mdev, ptpcyc2realtime_modify);
|
||||
}
|
||||
|
||||
static bool mlx5_is_mtutc_time_adj_cap(struct mlx5_core_dev *mdev, s64 delta)
|
||||
{
|
||||
s64 min = MLX5_MTUTC_OPERATION_ADJUST_TIME_MIN;
|
||||
s64 max = MLX5_MTUTC_OPERATION_ADJUST_TIME_MAX;
|
||||
|
||||
if (MLX5_CAP_MCAM_FEATURE(mdev, mtutc_time_adjustment_extended_range)) {
|
||||
min = MLX5_MTUTC_OPERATION_ADJUST_TIME_EXTENDED_MIN;
|
||||
max = MLX5_MTUTC_OPERATION_ADJUST_TIME_EXTENDED_MAX;
|
||||
}
|
||||
|
||||
if (delta < min || delta > max)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static int mlx5_set_mtutc(struct mlx5_core_dev *dev, u32 *mtutc, u32 size)
|
||||
{
|
||||
u32 out[MLX5_ST_SZ_DW(mtutc_reg)] = {};
|
||||
|
|
@ -288,8 +311,8 @@ static int mlx5_ptp_adjtime_real_time(struct mlx5_core_dev *mdev, s64 delta)
|
|||
if (!mlx5_modify_mtutc_allowed(mdev))
|
||||
return 0;
|
||||
|
||||
/* HW time adjustment range is s16. If out of range, settime instead */
|
||||
if (delta < S16_MIN || delta > S16_MAX) {
|
||||
/* HW time adjustment range is checked. If out of range, settime instead */
|
||||
if (!mlx5_is_mtutc_time_adj_cap(mdev, delta)) {
|
||||
struct timespec64 ts;
|
||||
s64 ns;
|
||||
|
||||
|
|
@ -328,7 +351,12 @@ static int mlx5_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
|
|||
|
||||
static int mlx5_ptp_adjphase(struct ptp_clock_info *ptp, s32 delta)
|
||||
{
|
||||
if (delta < S16_MIN || delta > S16_MAX)
|
||||
struct mlx5_clock *clock = container_of(ptp, struct mlx5_clock, ptp_info);
|
||||
struct mlx5_core_dev *mdev;
|
||||
|
||||
mdev = container_of(clock, struct mlx5_core_dev, clock);
|
||||
|
||||
if (!mlx5_is_mtutc_time_adj_cap(mdev, delta))
|
||||
return -ERANGE;
|
||||
|
||||
return mlx5_ptp_adjtime(ptp, delta);
|
||||
|
|
|
|||
|
|
@ -9941,7 +9941,9 @@ struct mlx5_ifc_pcam_reg_bits {
|
|||
};
|
||||
|
||||
struct mlx5_ifc_mcam_enhanced_features_bits {
|
||||
u8 reserved_at_0[0x5d];
|
||||
u8 reserved_at_0[0x51];
|
||||
u8 mtutc_time_adjustment_extended_range[0x1];
|
||||
u8 reserved_at_52[0xb];
|
||||
u8 mcia_32dwords[0x1];
|
||||
u8 out_pulse_duration_ns[0x1];
|
||||
u8 npps_period[0x1];
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user