mirror of
https://github.com/apache/nuttx-apps.git
synced 2026-10-03 12:18:10 +00:00
netutils/ptpd: Add egress latency compensation for TX timestamps.
The frame leaves the MAC later than the moment its hardware transmit timestamp is latched, because of the clock domain crossing and the PHY. This fixed delay is the egressLatency port parameter of IEEE 1588. Add the configured latency to every hardware transmit timestamp obtained through MSG_ERRQUEUE, the counterpart of the ingress compensation. - Add CONFIG_NETUTILS_PTPD_EGRESS_LATENCY_NS (default 0, which applies no compensation). - Add the -O option to override it at run time. - Add egress_latency_ns to struct ptpd_config_s. Software timestamps are not affected. Assisted-by: Claude:claude-sonnet-5 Signed-off-by: Daniel P. Carvalho <danieloak@gmail.com>
This commit is contained in:
parent
dd35d76edd
commit
c78e4d69ea
4 changed files with 38 additions and 1 deletions
|
|
@ -259,4 +259,25 @@ config NETUTILS_PTPD_INGRESS_LATENCY_NS
|
|||
for example by comparing a physical PPS output against a
|
||||
reference. The default of 0 applies no compensation.
|
||||
|
||||
config NETUTILS_PTPD_EGRESS_LATENCY_NS
|
||||
int "PTP hardware transmit timestamp latency (ns)"
|
||||
default 0
|
||||
range -1000000 1000000
|
||||
depends on NET_TIMESTAMP
|
||||
---help---
|
||||
Fixed delay, in nanoseconds, between the MAC latching a hardware
|
||||
transmit timestamp and the frame reaching the wire reference
|
||||
plane. This is the egressLatency port parameter of IEEE 1588: the
|
||||
clock domain crossing and the PHY make the frame leave later than
|
||||
the timestamp point.
|
||||
|
||||
The latency is added to every hardware transmit timestamp, so a
|
||||
positive value moves the timestamps later. It has no effect with
|
||||
software timestamping or when the driver does not provide
|
||||
hardware transmit timestamps. It can be overridden at run time
|
||||
with the -O option.
|
||||
|
||||
The value depends on the PHY and board and has to be measured.
|
||||
The default of 0 applies no compensation.
|
||||
|
||||
endif # NETUTILS_PTPD
|
||||
|
|
|
|||
|
|
@ -1128,6 +1128,12 @@ static int ptp_sendmsg(FAR struct ptp_state_s *state, FAR const void *buf,
|
|||
if (ptp_get_tx_timestamp(state, sendts) == OK)
|
||||
{
|
||||
state->hwts_tx_failures = 0;
|
||||
|
||||
/* The frame reaches the wire later than the MAC latches the
|
||||
* timestamp: compensate the egress latency.
|
||||
*/
|
||||
|
||||
timespec_add_ns(sendts, state->config->egress_latency_ns);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue