[PATCH v6 0/4] PTP protocol support in lib/net
Rajesh Kumar
rajesh3.kumar at intel.com
Thu May 7 12:13:10 CEST 2026
Add IEEE 1588-2019 Precision Time Protocol (PTP) support to DPDK via a
new header library in lib/net/. This patchset provides wire-format packet
structure definitions and inline helpers for Transparent Clock and
ordinary clock applications.
## Design Rationale
Following DPDK conventions for protocol libraries (rte_tcp.h, rte_ip.h),
PTP definitions are provided as a header-only library with inline functions
for zero-overhead packet processing. All functions are suitable for
real-time, performance-critical code paths.
## Contents
**Patch 1:** lib/net/rte_ptp.h - Header structures and inline helpers
- rte_ptp_port_id: 10-byte port identity with EUI-64 clock ID
- rte_ptp_hdr: 34-byte PTP v2 common message header
- rte_ptp_timestamp: 10-byte nanosecond-precision timestamp
- Message type constants (Sync, Delay_Req, Announce, etc.)
- Flag field bits (two-step, unicast, leap indicator)
- Inline helpers: rte_ptp_msg_type(), rte_ptp_seq_id(), rte_ptp_is_event(),
rte_ptp_correction_ns(), rte_ptp_add_correction(), rte_ptp_timestamp_to_ns()
**Patch 2:** examples/ptp_tap_relay_sw - Software PTP Transparent Clock relay
- Relays PTP packets between a DPDK-bound physical NIC and Linux TAP interface
- Software timestamp-based residence time measurement (CLOCK_MONOTONIC)
- Accumulates residence time to PTP correctionField per IEEE 1588-2019 §10.2
- Handles L2, VLAN/QinQ, UDP/IPv4, UDP/IPv6 PTP encapsulations
- Works with unmodified Linux kernel and stock DPDK (no patches required)
- Compatible with standard linuxptp (ptp4l) tooling
**Patch 3:** doc/guides/rel_notes/release_26_07.rst - Release notes update
**Patch 4:** examples/ptpclient - Update to use lib/net PTP definitions
- Uses RTE_ETHER_TYPE_1588 constant
- Adds lib/net dependency
## Testing
- Build: `ninja -C build` — clean compilation
- Examples: Both ptpclient and ptp_tap_relay_sw compile and link correctly
- No stale references to old patterns or removed functions
## Changelog
v6 changes:
- Restructured to lib/net (header-only, following lib/net conventions)
- Removed separate DPI library functions (moved to example-local ptp_parse.h)
- Removed app/test unit tests (library now header-only, example-driven testing)
- Removed programmer's guide doc (lib/net headers use Doxygen API docs only)
Rajesh Kumar (4):
lib/net: add IEEE 1588 PTP v2 protocol header definitions
examples/ptp_tap_relay_sw: add PTP software transparent clock relay
doc: update release notes for PTP protocol library
examples/ptpclient: use shared PTP library definitions
MAINTAINERS | 6 +
doc/guides/rel_notes/release_26_07.rst | 12 +
doc/guides/sample_app_ug/ptp_tap_relay_sw.rst | 212 +++++++++
examples/ptp_tap_relay_sw/Makefile | 41 ++
examples/ptp_tap_relay_sw/meson.build | 13 +
examples/ptp_tap_relay_sw/ptp_parse.h | 211 +++++++++
examples/ptp_tap_relay_sw/ptp_tap_relay_sw.c | 432 ++++++++++++++++++
examples/ptpclient/meson.build | 1 +
examples/ptpclient/ptpclient.c | 4 +-
lib/net/meson.build | 1 +
lib/net/rte_ptp.h | 264 +++++++++++
11 files changed, 1195 insertions(+), 2 deletions(-)
create mode 100644 doc/guides/sample_app_ug/ptp_tap_relay_sw.rst
create mode 100644 examples/ptp_tap_relay_sw/Makefile
create mode 100644 examples/ptp_tap_relay_sw/meson.build
create mode 100644 examples/ptp_tap_relay_sw/ptp_parse.h
create mode 100644 examples/ptp_tap_relay_sw/ptp_tap_relay_sw.c
create mode 100644 lib/net/rte_ptp.h
--
2.53.0
More information about the dev
mailing list