From: Andrew Zaborowski <andrew.zaborow...@intel.com>

This change implements the COMMON_P2P DM by issuing a request
to the CMLDS for CommonMeanLinkDelayInformation upon expiry of
the delay timer and handles the response to assimilate the
received meanPathDelay and NRR.

Signed-off-by: Andrew Zaborowski <andrew.zaborow...@intel.com>
---
 port.c | 35 ++++++++++++++++++++++++++++++++++-
 1 file changed, 34 insertions(+), 1 deletion(-)

diff --git a/port.c b/port.c
index ad13a919f161..946b8235ecd5 100644
--- a/port.c
+++ b/port.c
@@ -1685,6 +1685,10 @@ int port_delay_request(struct port *p)
 {
        struct ptp_message *msg;
 
+       if (p->delayMechanism == DM_COMMON_P2P) {
+               return port_request_cmlds_info(p);
+       }
+
        /* Time to send a new request, forget current pdelay resp and fup */
        if (p->peer_delay_resp) {
                msg_put(p->peer_delay_resp);
@@ -2597,6 +2601,9 @@ calc:
                                 p->nrate.ratio);
        }
 
+       p->peer_delay_t1 = t1;
+       p->peer_delay_t2 = t2;
+
        msg_put(p->peer_delay_req);
        p->peer_delay_req = NULL;
 }
@@ -3767,7 +3774,33 @@ int process_cmlds_response(struct port *p,
                 cmlds->scaledNeighborRateRatio, cmlds->egress_ts,
                 cmlds->rx_ts);
 
-       /* COMMON_P2P DM implementation goes here */
+       if (!cmlds->serviceMeasurementValid) {
+               p->pdr_missing++;
+               port_capable(p);
+               return 0;
+       }
+
+       /* Note: the CMLDS may be using a different local clock.  Do not track
+        * the CMLDS-clock-to-local-clock rate ratio at this time as the
+        * difference should be small, or nul with vclocks.
+        */
+       p->pdr_missing = 0;
+       p->peerMeanPathDelay = cmlds->meanLinkDelay;
+       p->peer_delay = nanoseconds_to_tmv(p->peerMeanPathDelay >> 16);
+       p->nrate.ratio = 1.0 + (double) cmlds->scaledNeighborRateRatio / 
POW2_41;
+
+       /* Note: this determines the value of port_capable(p), however
+        * p->peer_portid itself is not actually used outside of the Pdelay FSM.
+        */
+       p->peer_portid_valid = true;
+       p->nrate.ratio_valid = true;
+
+       if (p->state == PS_UNCALIBRATED || p->state == PS_SLAVE) {
+               clock_peer_delay(p->clock, p->peer_delay,
+                                nanoseconds_to_tmv(cmlds->egress_ts),
+                                nanoseconds_to_tmv(cmlds->rx_ts),
+                                p->nrate.ratio);
+       }
 
        return 0;
 }
-- 
2.31.1



_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to