Skip to content

Support exposing raw cycle counters in PTP and mlx5

Tariq Toukan linux-rdma lkml netdev 2 versions – Applied

Status from this message: This series was applied to netdev/net-next.git (main)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest3 patches 8 repliesApplied 3/3
  2. v13 patches 12 repliesSuperseded

Changes in v2 from the cover letter

- Extend the cover letter with more motivation and use cases.

[1]
This patch series introduces support for exposing the raw free-running cycle counter of PTP hardware clocks. When the device is in free-running mode, it emits timestamps as raw cycle values instead of nanoseconds. These values may be passed directly to user space through:

- fwctl: exposes internal device event records that include raw cycle-based timestamps.

- DPDK: retrieves CQEs that contain raw cycle counters, which are passed to user space unmodified.

Patches in v2 All 3 applied

#Subject and filesSizeRepliesApplied
1/3ptp: Add ioctl commands to expose raw cycle counter valuesdrivers/ptp/ptp_chardev.c include/uapi/linux/ptp_clock.h+30 -88 repliesApplied
2/3net/mlx5: Extract MTCTR register read logic into helper functiondrivers/net/ethernet/mellanox/mlx5/core/lib/clock.c+27 -120 repliesApplied
3/3net/mlx5: Support getcyclesx and getcrosscyclesdrivers/net/ethernet/mellanox/mlx5/core/lib/clock.c+73 -10 repliesApplied

Reviews trailers per patch

All 3 patches have a Reviewed-by or Acked-by.

PatchDragos TatuleaRichard Cochran
1/3R-b A-b
2/3R-b
3/3R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH net-next V2 0/3] Support exposing raw cycle counters in PTP and mlx5

Hi,

This series by Carolina adds support in ptp and usage in mlx5 for exposing the raw free-running cycle counter of PTP hardware clocks.

This is V2. Find previous one here:
https://lore.kernel.org/all/[email protected]/

Find detailed description by Carolina below [1].

Regards,
Tariq

V2:
- Extend the cover letter with more motivation and use cases.

[1]
This patch series introduces support for exposing the raw free-running cycle counter of PTP hardware clocks. When the device is in free-running mode, it emits timestamps as raw cycle values instead of nanoseconds. These values may be passed directly to user space through:

- fwctl: exposes internal device event records that include raw cycle-based timestamps.

- DPDK: retrieves CQEs that contain raw cycle counters, which are passed to user space unmodified.

To address this, the series introduces two new ioctl commands that allow userspace to query the device's raw cycle counter together with host time:

- PTP_SYS_OFFSET_PRECISE_CYCLES

- PTP_SYS_OFFSET_EXTENDED_CYCLES

These commands work like their existing counterparts but return the device timestamp in cycle units instead of real-time nanoseconds. This allows user space to collect (cycle, time) pairs and build a mapping between the device’s free-running clock and host time.

This can also be useful in the XDP fast path: if a driver inserts the raw cycle value into metadata instead of a real-time timestamp, it can avoid the overhead of converting cycles to time in the kernel. Then userspace can resolve the cycle-to-time mapping using this ioctl when needed.

The ioctl enables user space to correlate those with host time, without requiring the PHC to be synchronized, so long as the drift remains stable during collection.

Adds the new PTP ioctls and integrates support in ptp_ioctl():
- ptp: Add ioctl commands to expose raw cycle counter values

Support for exposing raw cycles in mlx5:
- net/mlx5: Extract MTCTR register read logic into helper function
- net/mlx5: Support getcyclesx and getcrosscycles

Carolina Jubran (3):
ptp: Add ioctl commands to expose raw cycle counter values net/mlx5: Extract MTCTR register read logic into helper function net/mlx5: Support getcyclesx and getcrosscycles

 .../ethernet/mellanox/mlx5/core/lib/clock.c   | 113 ++++++++++++++++--
 drivers/ptp/ptp_chardev.c                     |  34 ++++--
 include/uapi/linux/ptp_clock.h                |   4 +
 3 files changed, 130 insertions(+), 21 deletions(-)

base-commit: bc4c0a48bdad7f225740b8e750fdc1da6d85e1eb

Signature · 1 line
2.40.1