daniel-p-carvalho commented on code in PR #20346:
URL: https://github.com/apache/nuttx/pull/20346#discussion_r4106580689
##########
net/netdev/netdev_ioctl.c:
##########
@@ -1088,6 +1089,11 @@ static int netdev_ifr_ioctl(FAR struct socket *psock,
int cmd,
req->ifr_flags = dev->d_flags;
break;
+ case SIOCGIFTSCAPS: /* Gets timestamping capabilities */
+ req->ifr_flags = dev->d_features & (NETDEV_RX_STAMP |
Review Comment:
`SIOCETHTOOL` and `ETHTOOL_GET_TS_INFO` are already defined in NuttX but not
implemented, and using them lets ptpd query the capabilities exactly like
linuxptp/ptp4l does. My plan is to rework the PR as follows:
- Add `struct ethtool_ts_info` to `include/nuttx/ethtool.h`, with the same
layout as Linux.
- Handle `SIOCETHTOOL` in `netdev_ioctl.c`: `ETHTOOL_GET_TS_INFO` fills
`so_timestamping` from `NETDEV_RX_STAMP`/`NETDEV_TX_STAMP` (`phc_index = -1`);
other commands are forwarded to the driver's `d_ioctl` when present, otherwise
`-ENOTTY`.
- Drop `SIOCGIFTSCAPS`.
- Keep `NETDEV_TX_STAMP` and its declaration in the STM32 and STM32H7
drivers.
For `so_timestamping` to carry this information, `SOF_TIMESTAMPING_*` need
their distinct Linux values: today they all alias `1 << SO_TIMESTAMPING`. This
does not change behaviour. `setsockopt(SO_TIMESTAMPING)` only checks for a
non-zero value and `getsockopt()` returns 0/1, so existing users (ptpd,
`testing/nettest/timestamp`) and binaries built with the old values keep
working. NuttX will still not honour individual flags (any non-zero value
enables timestamping); that stays as it is today and could be addressed in a
follow-up if needed.
apache/nuttx-apps#3800 will be updated to query `ETHTOOL_GET_TS_INFO` and
check `SOF_TIMESTAMPING_TX_HARDWARE`/`SOF_TIMESTAMPING_RX_HARDWARE`, so it no
longer depends on `NETDEV_*`.
Does that sound right to you?
--
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]