[PATCH v10 net-next 0/3] Implement PTP support in netdevsim
From: Maciek Machnikowski <hidden>
Date: 2026-08-15 06:32:07
This patchset adds support to the PTP HW timestamping emulation in the netdevsim. It uses existing binding between netdevsim and ptp_mock driver to generate transmit and receive timestamps. It also adds the selftest to verify the hw timestamping functionality running over netdevsim. v10: - Drop the local_irq_save()/local_irq_restore() around the PHC reads. v9: - Unshare the skb instead of copying it - Move the PTP timestamping off the xmit fast path - Sample the TX and RX PHCs with IRQs disabled to keep the reads adjacent - Validate the hwtstamp config before touching device state - Report a -1 PHC index from ethtool for ports without a PHC (VFs) - Clamp the ptp4l poll timeout in the selftest to a non-negative value v8: - Fix the lockless tstamp_config access in netdevsim with READ_ONCE()/WRITE_ONCE() - Clarify the TX/RX timestamp handling in netdevsim comments v7: - Moved the test script to tools/testing/selftest/drivers/net - Optimized implementation to avoid potential edge cases reported v6: - Enable PTP Mock in the tools/testing/selftests/net/config v5: - Rebase v4: - Check if Rx timestamps are enabled before generating a timestamp - Replace bash selftest script with a python one - Optimized Tx timestamp generation v3: - Fixed shellcheck issues in the selftest/net/ptp.sh - Added selftest/net/ptp.sh to the selftest/net/Makefile - Modified ptp_mock to use spin_lock_irqsave v2: - Added selftest/net/ptp.sh - Modified ptp_mock to use spin_lock_bh - Populate ethtool defaults using ethtool_op_get_ts_info Maciek Machnikowski (3): ptp_mock: Expose ptp_clock_info to external drivers netdevsim: Implement basic ptp support selftests: drivers/net: Implement ptp4l sync test using netdevsim drivers/net/netdevsim/ethtool.c | 15 +++ drivers/net/netdevsim/netdev.c | 104 +++++++++++++++++++ drivers/net/netdevsim/netdevsim.h | 1 + drivers/ptp/ptp_mock.c | 26 +++-- include/linux/ptp_mock.h | 5 + tools/testing/selftests/drivers/net/Makefile | 1 + tools/testing/selftests/drivers/net/config | 1 + tools/testing/selftests/drivers/net/ptp.py | 84 +++++++++++++++ 8 files changed, 229 insertions(+), 8 deletions(-) create mode 100755 tools/testing/selftests/drivers/net/ptp.py -- 2.55.0