netutils/ptpd: query timestamping capabilities via ETHTOOL_GET_TS_INFO - #3800
Merged
xiaoxiang781216 merged 2 commits intoSep 27, 2026
Merged
Conversation
cederom
requested changes
Sep 24, 2026
cederom
left a comment
Contributor
There was a problem hiding this comment.
Thank you @daniel-p-carvalho, please:
- Follow the PR requirements and template (summary, impact, testing), see https://github.com/apache/nuttx/blob/master/CONTRIBUTING.md.
- Please provide (extract) from build and runtime logs that prove build and runtime solution is working as expected. Overall description (aka "test plan") is not enough as it does not prove anything.
4 of 5 tasks
daniel-p-carvalho
force-pushed
the
feat/ptpd-txtstamp-caps
branch
from
September 24, 2026 14:42
815212a to
ebf2986
Compare
Contributor
Author
|
Updated the PR description to follow the template (Summary/Impact/Testing/Self-Check) with real build and runtime log excerpts from two boards tested against a physical PTP Grandmaster, per your request. Thanks for the pointer to the template. |
daniel-p-carvalho
marked this pull request as draft
September 24, 2026 16:23
daniel-p-carvalho
force-pushed
the
feat/ptpd-txtstamp-caps
branch
2 times, most recently
from
September 24, 2026 17:43
a857f7d to
e70f19d
Compare
daniel-p-carvalho
marked this pull request as ready for review
September 24, 2026 21:29
daniel-p-carvalho
force-pushed
the
feat/ptpd-txtstamp-caps
branch
from
September 24, 2026 21:34
e70f19d to
34afe7e
Compare
daniel-p-carvalho
force-pushed
the
feat/ptpd-txtstamp-caps
branch
from
September 25, 2026 01:18
34afe7e to
f9e3447
Compare
cederom
previously approved these changes
Sep 25, 2026
cederom
requested review from
acassis,
linguini1,
michallenc,
simbit18 and
xiaoxiang781216
September 25, 2026 09:48
daniel-p-carvalho
force-pushed
the
feat/ptpd-txtstamp-caps
branch
2 times, most recently
from
September 25, 2026 19:12
31aa7b1 to
a585df1
Compare
daniel-p-carvalho
force-pushed
the
feat/ptpd-txtstamp-caps
branch
from
September 26, 2026 14:08
a585df1 to
2b4a67c
Compare
Query interface hardware timestamping capabilities with the SIOCETHTOOL ETHTOOL_GET_TS_INFO ioctl during initialization, the same way linuxptp/ptp4l does on Linux, instead of detecting support through runtime trial and error. If the query itself fails, refuse to start. Remove the consecutive failure counter (hwts_tx_failures, PTP_HWTS_TX_MAX_FAILURES, hwts_tx_disabled). When hardware TX timestamping is supported and requested, report genuine runtime timeouts as errors (ptperr) instead of silently downgrading to software timestamping. Invalidate clock_source_valid in ptpd status while a hardware TX timestamp failure persists. Assisted-by: Gemini:gemini-3.8-pro Assisted-by: Claude:claude-sonnet-5 Signed-off-by: Daniel P. Carvalho <danieloak@gmail.com>
…ort. When ptpd runs over IEEE 802.3 (-2) with hardware timestamping and ETHTOOL_GET_TS_INFO does not report SOF_TIMESTAMPING_TX_HARDWARE, SOF_TIMESTAMPING_RX_HARDWARE and SOF_TIMESTAMPING_RAW_HARDWARE for the interface, refuse to start instead of logging a warning and running in software - the same way linuxptp/ptp4l refuses to start when hardware timestamping is configured but not reported as supported by ethtool, rather than silently degrading. The error message names the missing capability and points to -S, and the usage text documents the requirement. Hardware RX timestamps are required as well: without them the receive timestamps come from the system clock while the transmit ones come from the MAC, and the two cannot be combined into a meaningful delay. The check is limited to the 802.3 transport, the only one on which ptpd retrieves hardware TX timestamps. -H is the default with CONFIG_NET_TIMESTAMP, so applying it to the UDP transports would make a plain "ptpd" refuse to start on any interface whose driver does not report hardware timestamping, although it never needs that capability. Assisted-by: Claude:claude-sonnet-5 Signed-off-by: Daniel P. Carvalho <danieloak@gmail.com>
daniel-p-carvalho
force-pushed
the
feat/ptpd-txtstamp-caps
branch
from
September 26, 2026 14:10
2b4a67c to
6bb1283
Compare
acassis
approved these changes
Sep 26, 2026
xiaoxiang781216
approved these changes
Sep 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ptpdcurrently detects hardware TX timestamp support by trial and error (three consecutive failures, then a silent, permanent switch to software timestamps). This PR switches it to querying the interface's timestamping capabilities once at startup, the same waylinuxptp/ptp4ldoes on Linux (SIOCETHTOOLwithETHTOOL_GET_TS_INFO), and makes a genuine runtime failure visible instead of turning it into a silent, permanent mode switch.ptp_initialize_state()issuesETHTOOL_GET_TS_INFOonce for the configured interface (implemented by net/netdev: add NETDEV_TX_STAMP and SIOCETHTOOL ETHTOOL_GET_TS_INFO nuttx#20346). If-His requested on the IEEE 802.3 transport (-2) and the reportedso_timestampingdoes not containSOF_TIMESTAMPING_TX_HARDWARE,SOF_TIMESTAMPING_RX_HARDWAREandSOF_TIMESTAMPING_RAW_HARDWARE(or the ioctl itself fails),ptpdrefuses to start, likeptp4ldoes when hardware timestamping is configured but not reported byethtool. The error message names the missing capability and points to-S, e.g.Interface eth0 does not support hardware RX TX timestamping, use -S for software timestamps.ptpdretrieves hardware TX timestamps.-His the default withCONFIG_NET_TIMESTAMP, so applying it to the UDP transports would make a plainptpdrefuse to start on interfaces that never need the capability.hwts_tx_failures,PTP_HWTS_TX_MAX_FAILURESandhwts_tx_disabled. Hardware TX timestamp use (state->hwts_tx) is now a fixed capability read once, not a runtime state machine.ptp_get_tx_timestamp()timeout on an interface that already reported the capability (a failure at runtime, after startup succeeded) still falls back to the software timestamp for that single message, but it is no longer silent or permanent: it is logged withptperr(wasptpwarn) and invalidatesclock_source_validin theptpdstatus until the next hardware TX timestamp succeeds. Hardware timestamping is retried on every message rather than being disabled.-Husage text now documents that, with-2, it requires hardware RX and TX timestamp support from the interface.Impact
ptpd -2 -Hdecides between hardware and software timestamping (capability query instead of runtime detection), and how a hardware TX timestamp failure is reported.ptpd -2 -Hon an interface whose driver does not report hardware RX and TX timestamping now exits immediately with an error message instead of running silently in software timestamp mode after a few failed attempts. UDP transports (-4/-6, the default) and-Sare unaffected.ptpdis a userspace daemon; the driver-side capability declaration is in the companion net/netdev: add NETDEV_TX_STAMP and SIOCETHTOOL ETHTOOL_GET_TS_INFO nuttx#20346 PR.-Husage text insystem/ptpdnow states the capability requirement with-2.ptpd -2 -Hmust have their Ethernet driver declare hardware RX and TX timestamping (e.g.CONFIG_STM32_ETH_TIMESTAMP_RX=yandCONFIG_STM32_ETH_TIMESTAMP_TX=y).Testing
I confirm that changes are verified on local setup and works as intended:
sim).ptpd -s -2 -H -B -P -i eth0 -p /dev/ptp0); plus thesimtarget for the refusal-path check below. All tests use the head of this PR together with the head of net/netdev: add NETDEV_TX_STAMP and SIOCETHTOOL ETHTOOL_GET_TS_INFO nuttx#20346.CONFIG_STM32_ETH_TIMESTAMP_RX=y,CONFIG_STM32_ETH_TIMESTAMP_TX=y).CONFIG_STM32_ETH_TIMESTAMP_RX=y,CONFIG_STM32_ETH_TIMESTAMP_TX=y).Build log (STM32H7 board):
Runtime log, STM32H7 board,
ptpdstatus query (ptpd -t <pid>) 135 s after start: the daemon starts without the refusal error (both hardware capabilities are reported) andclock_source_validis1:Build log (STM32F1/F3/F4 board):
Runtime log, STM32F1/F3/F4 board (
dmesgexcerpt,CONFIG_DEBUG_PTP_*enabled), full PTP P2P exchange with hardware timestamps, no error or fallback message; the status query 142 s after start reportsclock_source_valid: 1,last_delta_ns: -2398,drift_ppb: -80163andpath_delay_ns: 9300:Refusal path,
ptpd -2 -H -i eth0on an interface that does not report hardware timestamping (simtarget, host build,eth0is the sim's virtual network device, which implements neitherNETDEV_RX_STAMPnorNETDEV_TX_STAMP;CONFIG_DEBUG_PTP_ERROR=y):PR verification Self-Check