Skip to content

Commit 9aadae3

Browse files
committed
net/mlx5: Add helper functions for PTP callbacks
jira LE-3615 Rebuild_History Non-Buildable kernel-5.14.0-570.28.1.el9_6 commit-author Jianbo Liu <[email protected]> commit e3ad54f The PTP callback functions should not be used directly by internal callers. Add helpers that can be used internally and externally. Signed-off-by: Jianbo Liu <[email protected]> Reviewed-by: Carolina Jubran <[email protected]> Reviewed-by: Dragos Tatulea <[email protected]> Signed-off-by: Tariq Toukan <[email protected]> Reviewed-by: Mateusz Polchlopek <[email protected]> Signed-off-by: Paolo Abeni <[email protected]> (cherry picked from commit e3ad54f) Signed-off-by: Jonathan Maple <[email protected]>
1 parent 1d04c78 commit 9aadae3

File tree

1 file changed

+22
-10
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core/lib

1 file changed

+22
-10
lines changed

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

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,21 +119,26 @@ static u32 mlx5_ptp_shift_constant(u32 dev_freq_khz)
119119
ilog2((U32_MAX / NSEC_PER_MSEC) * dev_freq_khz));
120120
}
121121

122+
static s32 mlx5_clock_getmaxphase(struct mlx5_core_dev *mdev)
123+
{
124+
return MLX5_CAP_MCAM_FEATURE(mdev, mtutc_time_adjustment_extended_range) ?
125+
MLX5_MTUTC_OPERATION_ADJUST_TIME_EXTENDED_MAX :
126+
MLX5_MTUTC_OPERATION_ADJUST_TIME_MAX;
127+
}
128+
122129
static s32 mlx5_ptp_getmaxphase(struct ptp_clock_info *ptp)
123130
{
124131
struct mlx5_clock *clock = container_of(ptp, struct mlx5_clock, ptp_info);
125132
struct mlx5_core_dev *mdev;
126133

127134
mdev = container_of(clock, struct mlx5_core_dev, clock);
128135

129-
return MLX5_CAP_MCAM_FEATURE(mdev, mtutc_time_adjustment_extended_range) ?
130-
MLX5_MTUTC_OPERATION_ADJUST_TIME_EXTENDED_MAX :
131-
MLX5_MTUTC_OPERATION_ADJUST_TIME_MAX;
136+
return mlx5_clock_getmaxphase(mdev);
132137
}
133138

134139
static bool mlx5_is_mtutc_time_adj_cap(struct mlx5_core_dev *mdev, s64 delta)
135140
{
136-
s64 max = mlx5_ptp_getmaxphase(&mdev->clock.ptp_info);
141+
s64 max = mlx5_clock_getmaxphase(mdev);
137142

138143
if (delta < -max || delta > max)
139144
return false;
@@ -361,15 +366,12 @@ static int mlx5_ptp_settime_real_time(struct mlx5_core_dev *mdev,
361366
return mlx5_set_mtutc(mdev, in, sizeof(in));
362367
}
363368

364-
static int mlx5_ptp_settime(struct ptp_clock_info *ptp, const struct timespec64 *ts)
369+
static int mlx5_clock_settime(struct mlx5_core_dev *mdev, struct mlx5_clock *clock,
370+
const struct timespec64 *ts)
365371
{
366-
struct mlx5_clock *clock = container_of(ptp, struct mlx5_clock, ptp_info);
367372
struct mlx5_timer *timer = &clock->timer;
368-
struct mlx5_core_dev *mdev;
369373
unsigned long flags;
370374

371-
mdev = container_of(clock, struct mlx5_core_dev, clock);
372-
373375
if (mlx5_modify_mtutc_allowed(mdev)) {
374376
int err = mlx5_ptp_settime_real_time(mdev, ts);
375377

@@ -385,6 +387,16 @@ static int mlx5_ptp_settime(struct ptp_clock_info *ptp, const struct timespec64
385387
return 0;
386388
}
387389

390+
static int mlx5_ptp_settime(struct ptp_clock_info *ptp, const struct timespec64 *ts)
391+
{
392+
struct mlx5_clock *clock = container_of(ptp, struct mlx5_clock, ptp_info);
393+
struct mlx5_core_dev *mdev;
394+
395+
mdev = container_of(clock, struct mlx5_core_dev, clock);
396+
397+
return mlx5_clock_settime(mdev, clock, ts);
398+
}
399+
388400
static
389401
struct timespec64 mlx5_ptp_gettimex_real_time(struct mlx5_core_dev *mdev,
390402
struct ptp_system_timestamp *sts)
@@ -1129,7 +1141,7 @@ static void mlx5_init_timer_clock(struct mlx5_core_dev *mdev)
11291141
struct timespec64 ts;
11301142

11311143
ktime_get_real_ts64(&ts);
1132-
mlx5_ptp_settime(&clock->ptp_info, &ts);
1144+
mlx5_clock_settime(mdev, clock, &ts);
11331145
}
11341146
}
11351147

0 commit comments

Comments
 (0)