net: add NETDEV_TX_STAMP capability flag and SIOCGIFTSCAPS query ioctl - #20346
Open
daniel-p-carvalho wants to merge 3 commits into
Open
daniel-p-carvalho wants to merge 3 commits into
daniel-p-carvalho wants to merge 3 commits into
Conversation
daniel-p-carvalho
requested review from
antmerlino,
davids5,
fjpanag,
jerpelea and
xiaoxiang781216
as code owners
September 24, 2026 13:56
5 tasks
acassis
previously approved these changes
Sep 24, 2026
daniel-p-carvalho
marked this pull request as draft
September 24, 2026 17:21
Add the NETDEV_TX_STAMP capability flag to d_features, next to the existing NETDEV_RX_STAMP, so a driver can declare that it delivers hardware TX timestamps. Introduce SIOCGIFTSCAPS (_SIOC(0x0046)) socket ioctl to allow userspace applications (such as ptpd) to query network interface hardware timestamping capabilities (NETDEV_RX_STAMP and NETDEV_TX_STAMP) from dev->d_features via struct ifreq. Signed-off-by: Daniel P. Carvalho <danieloak@gmail.com> Assisted-by: Gemini:gemini-3.8-pro Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QRmWhQ8CrfkRzuw5WMUXwH
Advertise the NETDEV_TX_STAMP capability flag in stm32_ethinitialize() when CONFIG_STM32_ETH_TIMESTAMP_TX is enabled, indicating that the driver provides hardware TX timestamping. Signed-off-by: Daniel P. Carvalho <danieloak@gmail.com> Assisted-by: Gemini:gemini-3.8-pro Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QRmWhQ8CrfkRzuw5WMUXwH
Advertise NETDEV_TX_STAMP in dev.d_features during stm32_ethinitialize() when CONFIG_STM32_ETH_TIMESTAMP_TX is enabled, indicating that the STM32H7 Ethernet driver provides hardware TX timestamping. Signed-off-by: Daniel P. Carvalho <danieloak@gmail.com> Assisted-by: Gemini:gemini-3.8-pro Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QRmWhQ8CrfkRzuw5WMUXwH
daniel-p-carvalho
force-pushed
the
feat/netdev-txtstamp-caps
branch
from
September 24, 2026 17:38
8f8fef1 to
0bfa471
Compare
daniel-p-carvalho
marked this pull request as ready for review
September 24, 2026 21:26
acassis
approved these changes
Sep 25, 2026
| break; | ||
|
|
||
| case SIOCGIFTSCAPS: /* Gets timestamping capabilities */ | ||
| req->ifr_flags = dev->d_features & (NETDEV_RX_STAMP | |
Contributor
There was a problem hiding this comment.
but show we expose these flags through SIOCETHTOOL
|
|
||
| #define SIOCSIFFLAGS _SIOC(0x001a) /* Sets the interface flags */ | ||
| #define SIOCGIFFLAGS _SIOC(0x001b) /* Gets the interface flags */ | ||
| #define SIOCGIFTSCAPS _SIOC(0x0046) /* Gets timestamping capabilities */ |
Contributor
There was a problem hiding this comment.
should we return all feature bits
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
ptpd(companion PR netutils/ptpd: query timestamping capabilities via SIOCGIFTSCAPS nuttx-apps#3800) currently detects hardware TX timestamp support by trial and error (three consecutive failures, then a silent switch to software timestamps). The Linux equivalent solves this by having the driver statically declare the capability (SOF_TIMESTAMPING_TX_HARDWARE, read once viaethtool/SIOCETHTOOL); this PR adds the NuttX equivalent.NETDEV_TX_STAMP(1 << 4) added toinclude/nuttx/net/netdev.h, next to the existingNETDEV_RX_STAMP. A driver sets it ind_featuresto declare that it delivers hardware TX timestamps.SIOCGIFTSCAPSioctl (net/netdev/netdev_ioctl.c), returning the RX/TX timestamping bits ofd_featuresfor a named interface viastruct ifreq, following the same pattern already used bySIOCGIFFLAGS.arch/arm/src/stm32h7/stm32_ethernet.c) declaresNETDEV_TX_STAMPwhenCONFIG_STM32_ETH_TIMESTAMP_TXis enabled, mirroring the existingNETDEV_RX_STAMPdeclaration right above it.arch/arm/src/common/stm32/stm32_eth_m3m4_v1.c) declaresNETDEV_TX_STAMPthe same way.ptpdqueries this capability once at startup instead of detecting it by trial and error.Impact
NETDEV_TX_STAMPcapability flag andSIOCGIFTSCAPSioctl; no existing behavior changes for drivers that do not opt in.NETDEV_TX_STAMPind_featureswhenCONFIG_STM32_ETH_TIMESTAMP_TXis set. Both already deliver hardware TX timestamps today; this only makes that capability queryable, it does not change the timestamping behavior itself.NETDEV_TX_STAMP/SIOCGIFTSCAPSfollow the exact naming and usage pattern of the existingNETDEV_RX_STAMP/SIOCGIFFLAGS, self-documented by that symmetry.Testing
I confirm that changes are verified on local setup and works as intended:
CONFIG_STM32_ETH_TIMESTAMP_TX=y).CONFIG_STM32_ETH_TIMESTAMP_TX=y).Build log (STM32H7 board):
Runtime log,
ptpd -s -2 -H -B -P -i eth0 -p /dev/ptp0status query on the STM32H7 board:SIOCGIFTSCAPScorrectly reportsNETDEV_TX_STAMP, hardware TX timestamp active from the first packet:Same test on the STM32F1/F3/F4 board (
dmesgexcerpt, full PTP P2P exchange, hardware TX timestamp used throughout):10-minute soak against the Grandmaster (STM32H7 board): 0 ping failures over 19 samples at 30s intervals,
clock_source_validstayed1throughout,path_delay_nsstable between 9381-9395 ns.PR verification Self-Check