This change adds COMMON_P2P (IEEE 802.1AS-2020, clause 14.8.5) to the
enumeration of delay mechanisms and incorporates it into existing code
paths pertaining to DM_P2P to (where appropriate) maintain parity with
DM_P2P.

Co-authored-by: Andrew Zaborowski <andrew.zaborow...@intel.com>
Signed-off-by: Kishen Maloor <kishen.mal...@intel.com>
---
 config.c         |  1 +
 dm.h             |  3 +++
 port.c           | 15 +++++++++------
 unicast_client.c | 10 +++++++---
 4 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/config.c b/config.c
index 3e7587ba81ab..0482554feb28 100644
--- a/config.c
+++ b/config.c
@@ -173,6 +173,7 @@ static struct config_enum delay_mech_enu[] = {
        { "Auto", DM_AUTO },
        { "E2E",  DM_E2E },
        { "P2P",  DM_P2P },
+       { "COMMON_P2P", DM_COMMON_P2P },
        { "NONE", DM_NO_MECHANISM },
        { NULL, 0 },
 };
diff --git a/dm.h b/dm.h
index 47bd8474ca0d..80d1ce551166 100644
--- a/dm.h
+++ b/dm.h
@@ -34,6 +34,9 @@ enum delay_mechanism {
        /** Peer delay mechanism. */
        DM_P2P,
 
+       /** Peer delay as measured by CMLDS. */
+       DM_COMMON_P2P,
+
        /** No Delay Mechanism. */
        DM_NO_MECHANISM = 0xFE,
 };
diff --git a/port.c b/port.c
index 94ce037871f1..87780fd39caa 100644
--- a/port.c
+++ b/port.c
@@ -967,7 +967,8 @@ static int port_management_fill_response(struct port 
*target,
                ptp_text_copy(cd->userDescription, &desc->userDescription);
                buf += sizeof(struct PTPText) + cd->userDescription->length;
 
-               if (target->delayMechanism == DM_P2P) {
+               if (target->delayMechanism == DM_P2P ||
+                   target->delayMechanism == DM_COMMON_P2P) {
                        memcpy(buf, profile_id_p2p, PROFILE_ID_LEN);
                } else {
                        struct config *cfg = clock_config(target->clock);
@@ -1291,7 +1292,7 @@ int port_set_delay_tmo(struct port *p)
                return 0;
        }
 
-       if (p->delayMechanism == DM_P2P) {
+       if (p->delayMechanism == DM_P2P || p->delayMechanism == DM_COMMON_P2P) {
                return set_tmo_log(p->fda.fd[FD_DELAY_TIMER], 1,
                               p->logPdelayReqInterval);
        } else {
@@ -2128,7 +2129,7 @@ static int process_delay_req(struct port *p, struct 
ptp_message *m)
                return 0;
        }
 
-       if (p->delayMechanism == DM_P2P) {
+       if (p->delayMechanism == DM_P2P || p->delayMechanism == DM_COMMON_P2P) {
                pr_warning("%s: delay request on P2P port", p->log_name);
                return 0;
        }
@@ -2293,8 +2294,9 @@ int process_pdelay_req(struct port *p, struct ptp_message 
*m)
                return -1;
        }
 
-       if (p->delayMechanism == DM_E2E) {
-               pr_warning("%s: pdelay_req on E2E port", p->log_name);
+       if (p->delayMechanism == DM_E2E ||
+           p->delayMechanism == DM_COMMON_P2P) {
+               pr_warning("%s: pdelay_req on E2E or COMMON_P2P port", 
p->log_name);
                return 0;
        }
        if (p->delayMechanism == DM_AUTO) {
@@ -2756,7 +2758,7 @@ static void bc_dispatch(struct port *p, enum fsm_event 
event, int mdiff)
                return;
        }
 
-       if (p->delayMechanism == DM_P2P) {
+       if (p->delayMechanism == DM_P2P || p->delayMechanism == DM_COMMON_P2P) {
                port_p2p_transition(p, p->state);
        } else {
                port_e2e_transition(p, p->state);
@@ -2895,6 +2897,7 @@ static enum fsm_event bc_event(struct port *p, int 
fd_index)
 
                delay_req_prune(p);
                if (clock_slave_only(p->clock) && p->delayMechanism != DM_P2P &&
+                   p->delayMechanism != DM_COMMON_P2P &&
                    port_renew_transport(p)) {
                        return EV_FAULT_DETECTED;
                }
diff --git a/unicast_client.c b/unicast_client.c
index 0843554e355a..9053acc0b599 100644
--- a/unicast_client.c
+++ b/unicast_client.c
@@ -202,6 +202,7 @@ static int unicast_client_renew(struct port *p,
                        goto out;
                }
                if (p->delayMechanism != DM_P2P &&
+                   p->delayMechanism != DM_COMMON_P2P &&
                                p->delayMechanism != DM_NO_MECHANISM) {
                        err = attach_request(msg, p->logMinDelayReqInterval,
                                             DELAY_RESP,
@@ -256,6 +257,7 @@ static int unicast_client_sydy(struct port *p,
                goto out;
        }
        if (p->delayMechanism != DM_P2P &&
+           p->delayMechanism != DM_COMMON_P2P &&
                        p->delayMechanism != DM_NO_MECHANISM) {
                err = attach_request(msg, p->logMinDelayReqInterval, DELAY_RESP,
                                p->unicast_req_duration);
@@ -404,7 +406,8 @@ int unicast_client_initialize(struct port *p)
                        pr_warning("%s: unicast master transport mismatch",
                                   p->log_name);
                }
-               if (p->delayMechanism == DM_P2P) {
+               if (p->delayMechanism == DM_P2P ||
+                   p->delayMechanism == DM_COMMON_P2P) {
                        master->sydymsk = P2P_SYDY_MASK;
                } else if (p->delayMechanism == DM_NO_MECHANISM) {
                        master->sydymsk = E2E_SY_MASK;
@@ -463,7 +466,7 @@ void unicast_client_grant(struct port *p, struct 
ptp_message *m,
        pr_debug("%s: unicast %s granted for %u sec",
                 p->log_name, msg_type_string(mtype), g->durationField);
 
-       if (p->delayMechanism == DM_P2P) {
+       if (p->delayMechanism == DM_P2P || p->delayMechanism == DM_COMMON_P2P) {
                switch (mtype) {
                case DELAY_RESP:
                        return;
@@ -579,7 +582,8 @@ int unicast_client_timer(struct port *p)
                        err = unicast_client_renew(p, master);
                        break;
                }
-               if (p->delayMechanism == DM_P2P) {
+               if (p->delayMechanism == DM_P2P ||
+                   p->delayMechanism == DM_COMMON_P2P) {
                        unicast_client_peer_renew(p);
                }
        }
-- 
2.31.1



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

Reply via email to