In 1-step insertion mode, egress PTP packets are modified in flight with a calculated timestamp. The PTP Timestamper logic takes in packet data from the TX interface, locates the embedded PTP packet, inserts the timestamp, (optionally) recalculates the UDP checksum, and recalculates the Ethernet FCS field.
- Ordinary/Boundary Clock Mode
- The time-of-day timestamp is inserted into a combination of the Timestamp and the correction field of the PTP packet. The DCMAC Subsystem only modifies the correction field.
- Transparent Clock
- The correction field contains a residence time which is calculated by subtracting the ingress timestamp and adding the egress timestamp (the difference is the residence time).
The DCMAC Subsystem performs packet-level
timestamp insertion using a read-modify-write method. When an outbound packet passes through
the TX PTP Insert logic, the existing value in the correction field is located using the
offset provided to the command port tx_ptp_cf_offset
field.
The egress timestamp, TS’egress, (provided by the PTP Timer
logic) is added to the value discovered in the PTP correction field. The PTP packet
timestamp field is left untouched.
The following table depicts the handling of the two PTP timestamp fields for each available timestamping mode. The timestamp field and incoming correction field columns contain the values that should be seeded into outbound PTP frames by the user logic. The outgoing correction field column is what is placed into the outbound correction field by the DCMAC Subsystem logic.
Mode | Timestamp Field | Incoming Correction Field | Outgoing Correction Field |
---|---|---|---|
Transparent | TSorig | CFingress - TS'ingress | CFingress - TS'ingress + TS'egress |
Ordinary/Boundary | TScurr | -TS'curr | - TS'curr + TS'egress |
From this table, it is apparent that the DCMAC Subsystem logic does not need to be aware of the selected timestamp mode, as it behaves the same way regardless of the selected mode. The user logic is responsible for setting appropriate initial timestamp values in both the Timestamp and correction fields of outbound PTP packets.
The DCMAC Subsystem supports different
modes to handle wraparound or saturation in the outgoing correction field when adding
TS’egress would cause an overflow. Setting ctl_tx_ptp_sat_enable
to zero causes the result to wrap around
(0x7FFFFFFF_FFFFFFFF -> 0x80000000_00000000). Setting ctl_tx_ptp_sat_enable
to one causes the result to saturate to maximum positive
(0x7FFFFFFFF_FFFFFFFF). Wraparound or saturation is normally used to handle the condition
when the incoming correction field is a large positive number and TS’egress is large enough to cause an overflow. However, if one of the TS’ingress/TS’curr or TS’egress timestamps has recently wrapped around while the other has
not, this can also cause an overflow condition. The downstream receiving node can possibly
detect if this condition occurred and adjust for it.
Alternatively, by adding a couple of bits of extra information to the
incoming correction field and setting ctl_tx_ptp_sat_enable
to two, the PTP insertion logic can detect this and automatically adjust for the wraparound.
The extra information required for this mode is:
- bit 62 of TS’ingress/TS’curr (placed into bit 0 of the incoming correction field)
- the sign bit of the ingress correction field (placed into bit 1 of the incoming correction field; use the sign of the incoming correction field if not in Transparent mode. If not in Transparent mode the incoming correction field is expected to be -TS'curr with a 1 in the sign field.)
If the result is still an actual overflow condition, the outgoing correction field is saturated. In this mode, bits [1:0] are cleared in the outgoing correction field.