daniel-p-carvalho opened a new pull request, #20212: URL: https://github.com/apache/nuttx/pull/20212
> **Stacked on apache/nuttx#20211: its three commits are reviewed there and show up in this diff until it is merged. Only the last commit is new here.** ## Summary The MAC can timestamp the PTP frames it receives, but the STM32H7 driver did not use it. This PR adds `STM32_ETH_TIMESTAMP_RX` for the STM32H7, the option the legacy STM32 driver already has. The timestamp of a frame is a value of the system time of the MAC, the same time base as `/dev/ptp0`, and it is passed to the network stack in `d_rxtime`. The MAC writes the timestamp in a context descriptor after the last descriptor of the frame. The driver reads it before giving the frame to the stack. The timestamp goes over the address of the buffer in that descriptor, so the driver keeps the address of the buffer of each RX descriptor and restores it when the context descriptor is given back. The code that dropped the context descriptors used a pointer that was never set, and it is fixed by the same change. The PTP version 2 messages over Ethernet and over UDP are timestamped, except the announce, management and signaling messages. The other frames get a time of zero. ## Impact - Everything new is under `STM32_ETH_TIMESTAMP_RX` (default n, needs `STM32_ETH_PTP` and `NET_TIMESTAMP`), which is now selectable on the STM32H7. The table of RX buffers that the context descriptors need is the only change outside it, and it does not change what the driver does. - The timestamps are raw values of the counter, as for the legacy STM32, so the consumer has to use `/dev/ptp0` as its clock, as `apps/netutils/ptpd` does with `-H -p /dev/ptp0`. ## Testing Built with `STM32_ETH_TIMESTAMP_RX`, with and without `STM32_ETH_PTP_GPIO` and `PTP_CLOCK`, without errors or warnings. `./tools/checkpatch.sh -g upstream/master..HEAD` passes. On hardware, with a custom STM32H753 board and a DP83848 PHY, against a GNSS-referenced `ptp4l` grandmaster using the IEC/IEEE 61850-9-3 profile, over `AF_PACKET`: a program that receives the PTP frames with `SO_TIMESTAMPNS` and reads `/dev/ptp0` right after got, for Sync, Pdelay_Req, Pdelay_Resp and Pdelay_Resp_Follow_Up, timestamps 0.4 to 5 ms before the reading of the clock, which is the delay of the program, and always increasing. The Announce frames, that are not timestamped, got zero. It received 151 frames in 20 s. The peer-to-peer measurement with `ptpd` also needs the transmit timestamp, which is the next PR. -- 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]
