If the transportSpecific value is configured to be 1, compute t3c using
the 802.1AS math instead of the 1588 math.
The 1588 defined computation using variable names from this project is:
D = [(t4 - t1) - (t3 - t2) - c1 - c2]/2
The existing code combines the corrections into a variable t3c which we
can get the value of by isolating t3, c1 and c2:
t3c = t3 + c1 + c2
The 802.1AS defined computation is:
D = [(t4 - t1) - (t3 - t2) + c1 - c2]/2
Again, isolating t3, c1 and c2 for 802.1AS:
t3c = t3 + c2 - c1
This has been tested against the MOTU Switch based on the KSZ9567 with
non-zero correction fields based on the 802.1AS equation as well as MOTU
audio interfaces that don't utilize the correction fields.
Signed-off-by: Dylan Robinson <[email protected]>
---
msg.h | 3 +++
port.c | 8 +++++++-
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/msg.h b/msg.h
index cbd09e7..484435d 100644
--- a/msg.h
+++ b/msg.h
@@ -37,6 +37,9 @@
#define MAJOR_VERSION_MASK 0x0f
+/* Values for the transportSpecific field */
+#define TS_IEEE_8021AS (1<<4)
+
/* Values for the messageType field */
#define SYNC 0x0
#define DELAY_REQ 0x1
diff --git a/port.c b/port.c
index d551bef..a97b6f3 100644
--- a/port.c
+++ b/port.c
@@ -2433,7 +2433,13 @@ static void port_peer_delay(struct port *p)
t3 = timestamp_to_tmv(fup->ts.pdu);
c2 = correction_to_tmv(fup->header.correction);
calc:
- t3c = tmv_add(t3, tmv_add(c1, c2));
+ /* 802.1AS specifies the peer delay computation differently than 1588.
Do
+ * the 802.1AS computation if transportSpecific matches 802.1AS
profile. */
+ if (p->transportSpecific == TS_IEEE_8021AS) {
+ t3c = tmv_add(t3, tmv_sub(c2, c1));
+ } else {
+ t3c = tmv_add(t3, tmv_add(c1, c2));
+ }
if (p->follow_up_info)
port_nrate_calculate(p, t3c, t4);
--
2.30.2
_______________________________________________
Linuxptp-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel