Skip to content

Commit 071995c

Browse files
Eran Ben ElishaSaeed Mahameed
authored andcommitted
net/mlx5: Verify Hardware supports requested ptp function on a given pin
Fix a bug where driver did not verify Hardware pin capabilities for PTP functions. Fixes: ee7f122 ("net/mlx5e: Implement 1PPS support") Signed-off-by: Eran Ben Elisha <[email protected]> Reviewed-by: Ariel Levkovich <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 88c8cf9 commit 071995c

File tree

1 file changed

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

1 file changed

+22
-1
lines changed

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

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,10 +408,31 @@ static int mlx5_ptp_enable(struct ptp_clock_info *ptp,
408408
return 0;
409409
}
410410

411+
enum {
412+
MLX5_MTPPS_REG_CAP_PIN_X_MODE_SUPPORT_PPS_IN = BIT(0),
413+
MLX5_MTPPS_REG_CAP_PIN_X_MODE_SUPPORT_PPS_OUT = BIT(1),
414+
};
415+
411416
static int mlx5_ptp_verify(struct ptp_clock_info *ptp, unsigned int pin,
412417
enum ptp_pin_function func, unsigned int chan)
413418
{
414-
return (func == PTP_PF_PHYSYNC) ? -EOPNOTSUPP : 0;
419+
struct mlx5_clock *clock = container_of(ptp, struct mlx5_clock,
420+
ptp_info);
421+
422+
switch (func) {
423+
case PTP_PF_NONE:
424+
return 0;
425+
case PTP_PF_EXTTS:
426+
return !(clock->pps_info.pin_caps[pin] &
427+
MLX5_MTPPS_REG_CAP_PIN_X_MODE_SUPPORT_PPS_IN);
428+
case PTP_PF_PEROUT:
429+
return !(clock->pps_info.pin_caps[pin] &
430+
MLX5_MTPPS_REG_CAP_PIN_X_MODE_SUPPORT_PPS_OUT);
431+
default:
432+
return -EOPNOTSUPP;
433+
}
434+
435+
return -EOPNOTSUPP;
415436
}
416437

417438
static const struct ptp_clock_info mlx5_ptp_clock_info = {

0 commit comments

Comments
 (0)