Skip to content

Commit 6138e68

Browse files
richardcochrandavem330
authored andcommitted
ptp: Introduce strict checking of external time stamp options.
User space may request time stamps on rising edges, falling edges, or both. However, the particular mode may or may not be supported in the hardware or in the driver. This patch adds a "strict" flag that tells drivers to ensure that the requested mode will be honored. Signed-off-by: Richard Cochran <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 592025a commit 6138e68

File tree

7 files changed

+15
-6
lines changed

7 files changed

+15
-6
lines changed

drivers/net/dsa/mv88e6xxx/ptp.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,8 @@ static int mv88e6352_ptp_enable_extts(struct mv88e6xxx_chip *chip,
276276
/* Reject requests with unsupported flags */
277277
if (rq->extts.flags & ~(PTP_ENABLE_FEATURE |
278278
PTP_RISING_EDGE |
279-
PTP_FALLING_EDGE))
279+
PTP_FALLING_EDGE |
280+
PTP_STRICT_FLAGS))
280281
return -EOPNOTSUPP;
281282

282283
pin = ptp_find_pin(chip->ptp_clock, PTP_PF_EXTTS, rq->extts.index);

drivers/net/ethernet/intel/igb/igb_ptp.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,8 @@ static int igb_ptp_feature_enable_i210(struct ptp_clock_info *ptp,
524524
/* Reject requests with unsupported flags */
525525
if (rq->extts.flags & ~(PTP_ENABLE_FEATURE |
526526
PTP_RISING_EDGE |
527-
PTP_FALLING_EDGE))
527+
PTP_FALLING_EDGE |
528+
PTP_STRICT_FLAGS))
528529
return -EOPNOTSUPP;
529530

530531
if (on) {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,8 @@ static int mlx5_extts_configure(struct ptp_clock_info *ptp,
239239
/* Reject requests with unsupported flags */
240240
if (rq->extts.flags & ~(PTP_ENABLE_FEATURE |
241241
PTP_RISING_EDGE |
242-
PTP_FALLING_EDGE))
242+
PTP_FALLING_EDGE |
243+
PTP_STRICT_FLAGS))
243244
return -EOPNOTSUPP;
244245

245246
if (rq->extts.index >= clock->ptp_info.n_pins)

drivers/net/ethernet/renesas/ravb_ptp.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,8 @@ static int ravb_ptp_extts(struct ptp_clock_info *ptp,
185185
/* Reject requests with unsupported flags */
186186
if (req->flags & ~(PTP_ENABLE_FEATURE |
187187
PTP_RISING_EDGE |
188-
PTP_FALLING_EDGE))
188+
PTP_FALLING_EDGE |
189+
PTP_STRICT_FLAGS))
189190
return -EOPNOTSUPP;
190191

191192
if (req->index)

drivers/net/phy/dp83640.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,8 @@ static int ptp_dp83640_enable(struct ptp_clock_info *ptp,
472472
/* Reject requests with unsupported flags */
473473
if (rq->extts.flags & ~(PTP_ENABLE_FEATURE |
474474
PTP_RISING_EDGE |
475-
PTP_FALLING_EDGE))
475+
PTP_FALLING_EDGE |
476+
PTP_STRICT_FLAGS))
476477
return -EOPNOTSUPP;
477478
index = rq->extts.index;
478479
if (index >= N_EXT_TS)

drivers/ptp/ptp_chardev.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ long ptp_ioctl(struct posix_clock *pc, unsigned int cmd, unsigned long arg)
150150
break;
151151
}
152152
if (cmd == PTP_EXTTS_REQUEST2) {
153+
/* Tell the drivers to check the flags carefully. */
154+
req.extts.flags |= PTP_STRICT_FLAGS;
153155
/* Make sure no reserved bit is set. */
154156
if ((req.extts.flags & ~PTP_EXTTS_VALID_FLAGS) ||
155157
req.extts.rsv[0] || req.extts.rsv[1]) {

include/uapi/linux/ptp_clock.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,16 @@
3131
#define PTP_ENABLE_FEATURE (1<<0)
3232
#define PTP_RISING_EDGE (1<<1)
3333
#define PTP_FALLING_EDGE (1<<2)
34+
#define PTP_STRICT_FLAGS (1<<3)
3435
#define PTP_EXTTS_EDGES (PTP_RISING_EDGE | PTP_FALLING_EDGE)
3536

3637
/*
3738
* flag fields valid for the new PTP_EXTTS_REQUEST2 ioctl.
3839
*/
3940
#define PTP_EXTTS_VALID_FLAGS (PTP_ENABLE_FEATURE | \
4041
PTP_RISING_EDGE | \
41-
PTP_FALLING_EDGE)
42+
PTP_FALLING_EDGE | \
43+
PTP_STRICT_FLAGS)
4244

4345
/*
4446
* flag fields valid for the original PTP_EXTTS_REQUEST ioctl.

0 commit comments

Comments
 (0)