The patch adds rx timestamps in nanoseconds from boot for the received packets. The basic pkthdr rearrangement change in sys/mbuf.h was provided by Andrew. There are two accompanying M_ flags: M_TSTMP means that there is the timestamp and it was generated by hardware.
Another flag M_TSTMP_HPREC indicates that the timestamp is high-precision. Practically M_TSTMP_HPREC means that hardware guaranteed additional precision. E.g., for ConntectX all packets are stamped by hardware when PCIe transaction to write out the completion descriptor is performed, but PTP packet are stamped on ingress. For intel cards, when PTP assist is enabled, only PTP packets are stamped in the limited number of registers, so if intel cards ever start support this mechanism, they would always set M_TSTMP | M_TSTMP_HPREC if hw timestamp is ever available for the given packet.
I changed the SCM_TIMESTAMP and similar control messages to use hardware timestamp instead of the time of the packet ip v4 and ip v6 input processing, if M_TSTMP is set. It would be nice to add similar facility to the raw socket used to receive raw ethernet PTP packets, but it is out of scope right now, I believe.
Driver support is only implemented for ConnectX4/5. System timestamp is calculated based on the free-running counter timestamp provided by hardware. We periodically sample the counter to calibrate it against the system clock. The calculation of the system timestamp is somewhat delicate because all values are 64bit and overflow the naive formula for linear interpolation. I adjusted the calculation by dropping the least signifcant bits in advance, see the PREC shift in mlx5_mbuf_tstmp().