xiaoxiang781216 commented on code in PR #20148: URL: https://github.com/apache/nuttx/pull/20148#discussion_r4021800353
########## include/nuttx/net/ioctl.h: ########## @@ -161,6 +161,10 @@ #define SIOCGIFVLAN _SIOC(0x0043) /* Get VLAN interface */ #define SIOCSIFVLAN _SIOC(0x0044) /* Set VLAN interface */ +/* PTP Timestamping *********************************************************/ + +#define SIOCG_TX_HW_TIMESTAMP _SIOC(0x0046) /* Get hardware TX timestamp */ Review Comment: > While looking into this I found drivers/timers/ptp_clock.c already implements a generic upper-half PTP hardware clock framework matching Linux's /dev/ptpN model closely - PTP_CLOCK_ADJTIME handling ADJ_FREQUENCY/ADJ_OFFSET via struct timex, the dynamic-clockid-to-fd conversion, etc. It has no registered lower-half driver anywhere in the tree yet, and its adjfine/adjphase ops map almost directly onto what this PR already implements in stm32_eth_ptp_adjust()/stm32_eth_ptp_adjphase(). I didn't know about it when I wrote this PR; ptp driver framework is implemented by @Donny9 to let eth driver provide ptp clock in a portable way. > migrating to it as a lower-half driver looks like the right direction for SIOCS_PTP_ADJFREQ/SIOCS_PTP_ADJPHASE, dropping both in favor of /dev/ptp0. yes, I think so. > SIOCG_TX_HW_TIMESTAMP is unrelated to that framework though - it's per-packet TX timestamp retrieval, not clock discipline, and there's no equivalent facility in ptp_clock.c for it; the real Linux equivalent there is SO_TIMESTAMPING/MSG_ERRQUEUE, which as noted isn't implemented in NuttX, so I don't see a smaller-scope alternative to keeping that one as a plain ioctl for now. > @wenquan2015 do some improvement in this area, which may simplify your code. > Would you rather I do the /dev/ptp0 migration for ADJFREQ/ADJPHASE in this PR, or land the current ioctls now and follow up separately? it's better to algin your improvement inside both kernel and userspace to Linux design, so we can use other ptp library and utility in the future. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
