From: Volodymyr Bendiuga <volodymyr.bendi...@westermo.se> This tiny patch provides generic solution for 1-step E2E & P2P Transparent Clocks.
Before revealing any further details, I want to state in plain words that changes brought about in this patch will only work for HW that is compliant with IEEE 1588 V2 standard, with regard to Transparent Clock and 1-step operation. That is to say, HW that is capable of updating correction field on-the-fly, for the following packets: 1. SYNC 2. DELAY_REQ 3. PDELAY_RESP Any deviation (in HW) from the standard will most likely produce unexpected results. The general idea is that in 1-step mode HW renders time stamps and updates correction field, without SW's intervantion in the process. To make linuxptp conform to 1-step TC, a set of simple yet effective changes must be introduced. The following paragraph is plausible for 1-step E2E TC: SYNC, DELAY_REQ and DELAY_RESP messages need to be forwarded by linuxptp, without any intrusion into packets content. No egress time stamp will be available for these packets, since HW will update correction field (for SYNC & DELAY_REQ) on-the-fly. With this in mind, linuxptp essentially needs to skip the code that fetches time stamps from kernel. No other changes are needed. As for 1-step P2P TC - allowing SYNC packets to simply flow through without collecting egress time stamp, makes the whole idea possible. Thanks to the fact that peer-2-peer mechanism works identically on all clock types, no other changes are necessary. 1-step related prerequisites for running TC in E2E mode: 1. --time_stampint=onestep Two different possibilities exist for 1-step P2P TC: 1. --time_stamping=onestep will result in TC updating correction field of SYNC packets in HW. Peer delay mechanism will work in 2-step mode though. 2. --time_stamping=p2p1step will make TC fully compatible with 1-step principles of IEEE 1588 V2 standard. NOTE: --twoStepFlag=0 must be valid for both E2E & P2P. Signed-off-by: Volodymyr Bendiuga <volodymyr.bendi...@gmail.com> --- tc.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tc.c b/tc.c index fb46603..1758128 100644 --- a/tc.c +++ b/tc.c @@ -285,6 +285,14 @@ static int tc_fwd_event(struct port *q, struct ptp_message *msg) } } + if (q->timestamping >= TS_ONESTEP) { + switch (msg_type(msg)) { + case SYNC: + case DELAY_REQ: + goto onestep; + } + } + /* Go back and gather the transmit time stamps. */ for (p = clock_first_port(q->clock); p; p = LIST_NEXT(p, list)) { if (tc_blocked(q, p, msg)) { @@ -307,6 +315,7 @@ static int tc_fwd_event(struct port *q, struct ptp_message *msg) tc_complete(q, p, msg, residence); } + onestep: return 0; } @@ -435,6 +444,13 @@ int tc_fwd_response(struct port *q, struct ptp_message *msg) if (tc_blocked(q, p, msg)) { continue; } + if (p->timestamping == TS_ONESTEP) { + if ((transport_send(p->trp, &p->fda, TRANS_GENERAL, msg)) <= 0) { + pr_err("tc failed to forward response on port %d", portnum(p)); + port_dispatch(p, EV_FAULT_DETECTED, 0); + } + continue; + } tc_complete(q, p, msg, tmv_zero()); } return 0; @@ -445,6 +461,9 @@ int tc_fwd_sync(struct port *q, struct ptp_message *msg) struct ptp_message *fup = NULL; int err; + if (q->timestamping >= TS_ONESTEP) + goto onestep; + if (one_step(msg)) { fup = msg_allocate(); if (!fup) { @@ -461,6 +480,8 @@ int tc_fwd_sync(struct port *q, struct ptp_message *msg) fup->follow_up.preciseOriginTimestamp = msg->sync.originTimestamp; msg->header.flagField[0] |= TWO_STEP; } + + onestep: err = tc_fwd_event(q, msg); if (err) { return err; -- 2.17.1 _______________________________________________ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel