This change adds cofig file parameters to configure CMLDS support
and access in PTP instances.

'cmlds_clockIdentity': This global setting assigns a CMLDS
clockIdentity to be used by a ptp4l instance on a PTP node that exposes
CMLDS over one or more links.

'run_cmlds': This per-port setting (0/1) declares that a port
will perform the role of a CMLDS Link Port (IEEE 1588, clause 16.6.1)
and execute CMLDS Pdelay transactions to conduct link
delay measurements and further convey those measurements to other
PTP instances on its node via MID_CMLDS_INFO_NP. Said another way,
this port will expose CMLDS.

'cmlds_portNumber': This per-port setting in a PTP instance
specifies the CMLDS Link Port portNumber.

Note that this is distinct from and independent of the portNumber
associated with the PTP Port.

In a PTP instance that exposes the CMLDS via a CMLDS Link Port, this
setting assigns the CMLDS Link Port portNumber.

In PTP instances that consume the CMLDS (using the COMMON_P2P
delay mechanism), this setting is used to target MID_CMLDS_INFO_NP
queries to a specific CMLDS Link Port.

'cmlds_uds_address': This per-port setting in ptp4l instances specifies
the 'uds_address' of a ptp4l instance on the PTP node that exposes the
CMLDS. A port which employs the COMMON_P2P delay mechanism would
communicate with the CMLDS over the UDS.

Co-authored-by: Andrew Zaborowski <andrew.zaborow...@intel.com>
Signed-off-by: Kishen Maloor <kishen.mal...@intel.com>
---
 config.c       |  4 ++++
 port.c         | 28 ++++++++++++++++++++++++++++
 port.h         |  8 ++++++++
 port_private.h |  4 ++++
 ptp4l.8        | 22 ++++++++++++++++++++++
 5 files changed, 66 insertions(+)

diff --git a/config.c b/config.c
index b104f1bb521a..3e7587ba81ab 100644
--- a/config.c
+++ b/config.c
@@ -245,6 +245,10 @@ struct config_item config_tab[] = {
        GLOB_ITEM_INT("clockAccuracy", 0xfe, 0, UINT8_MAX),
        GLOB_ITEM_INT("clockClass", 248, 0, UINT8_MAX),
        GLOB_ITEM_STR("clockIdentity", "000000.0000.000000"),
+       GLOB_ITEM_STR("cmlds_clockIdentity", "000000.0000.000000"),
+       PORT_ITEM_INT("run_cmlds", 0, 0, 1),
+       PORT_ITEM_INT("cmlds_portNumber", 0, 0, UINT16_MAX),
+       PORT_ITEM_STR("cmlds_uds_address", "/var/run/ptp4l"),
        GLOB_ITEM_INT("clock_class_threshold", CLOCK_CLASS_THRESHOLD_DEFAULT, 
6, CLOCK_CLASS_THRESHOLD_DEFAULT),
        GLOB_ITEM_ENU("clock_servo", CLOCK_SERVO_PI, clock_servo_enu),
        GLOB_ITEM_ENU("clock_type", CLOCK_TYPE_ORDINARY, clock_type_enu),
diff --git a/port.c b/port.c
index d467a69e519a..94ce037871f1 100644
--- a/port.c
+++ b/port.c
@@ -3301,6 +3301,8 @@ struct port *port_open(const char *phc_device,
        enum clock_type type = clock_type(clock);
        struct config *cfg = clock_config(clock);
        struct port *p = malloc(sizeof(*p));
+       char *cmlds_uds_address;
+       const char *cmlds_cid;
        int i;
 
        if (!p) {
@@ -3481,6 +3483,27 @@ struct port *port_open(const char *phc_device,
                        goto err_tsproc;
                }
        }
+
+       /* Store CMLDS parameters */
+       p->cmlds_enabled = config_get_int(cfg, p->name, "run_cmlds");
+
+       p->cmlds_portIdentity.portNumber = config_get_int(cfg, p->name, 
"cmlds_portNumber");
+
+       cmlds_uds_address = config_get_string(cfg, p->name, 
"cmlds_uds_address");
+       memset(&p->cmlds_uds_address, 0, sizeof(struct address));
+       p->cmlds_uds_address.sun.sun_family = AF_LOCAL;
+       strncpy(p->cmlds_uds_address.sun.sun_path, cmlds_uds_address,
+               sizeof(p->cmlds_uds_address.sun.sun_path) - 1);
+       p->cmlds_uds_address.len = sizeof(struct sockaddr_un);
+
+       cmlds_cid = config_get_string(cfg, NULL, "cmlds_clockIdentity");
+       if (strcmp(cmlds_cid, "000000.0000.000000") != 0) {
+               if (str2cid(cmlds_cid, &p->cmlds_portIdentity.clockIdentity)) {
+                       pr_err("failed to parse CMLDS clock identity");
+                       return NULL;
+               }
+       }
+
        return p;
 
 err_tsproc:
@@ -3508,6 +3531,11 @@ enum delay_mechanism port_delay_mechanism(struct port 
*port)
        return port->delayMechanism;
 }
 
+int port_cmlds_enabled(struct port *port)
+{
+       return port->cmlds_enabled;
+}
+
 int port_state_update(struct port *p, enum fsm_event event, int mdiff)
 {
        enum port_state next = p->state_machine(p->state, event, mdiff);
diff --git a/port.h b/port.h
index 57c8c2ffeb9e..96e0cf8aa970 100644
--- a/port.h
+++ b/port.h
@@ -364,4 +364,12 @@ void tc_cleanup(void);
  */
 void port_update_unicast_state(struct port *p);
 
+/**
+ * Query if a port exposes CMLDS.
+ *
+ * @param port  A port instance.
+ * @return One if CMLDS is exposed, zero otherwise.
+ */
+int port_cmlds_enabled(struct port *port);
+
 #endif
diff --git a/port_private.h b/port_private.h
index c9b02bc799f5..f5543076f76e 100644
--- a/port_private.h
+++ b/port_private.h
@@ -166,6 +166,10 @@ struct port {
        /* slave event monitoring */
        struct monitor *slave_event_monitor;
        bool unicast_state_dirty;
+       /* CMLDS parameters */
+       int cmlds_enabled;
+       struct PortIdentity cmlds_portIdentity;
+       struct address cmlds_uds_address;
 };
 
 #define portnum(p) (p->portIdentity.portNumber)
diff --git a/ptp4l.8 b/ptp4l.8
index 09ff108af102..d999352cd45a 100644
--- a/ptp4l.8
+++ b/ptp4l.8
@@ -159,6 +159,16 @@ collection of clocks must be synchronized by an external 
program, for
 example phc2sys(8) in "automatic" mode.
 The default is 0 (disabled).
 
+.TP
+.B cmlds_portNumber
+Specifies the CMLDS Link Port portNumber.
+The default is 0.
+
+.TP
+.B cmlds_uds_address
+Specifies the 'uds_address' of a ptp4l instance on the
+PTP node that exposes the CMLDS. The default is /var/run/ptp4l.
+
 .TP
 .B delayAsymmetry
 The time difference in nanoseconds of the transmit and receive
@@ -407,6 +417,12 @@ Relevant only with L2 transport. The default is 
01:1B:19:00:00:00.
 The MAC address to which peer delay messages should be sent.
 Relevant only with L2 transport. The default is 01:80:C2:00:00:0E.
 
+.TP
+.B run_cmlds
+Declares that a port will perform the role of a CMLDS Link Port (IEEE 1588,
+clause 16.6.1) and execute CMLDS Pdelay transactions to conduct link delay
+measurements. The default is zero or false.
+
 .TP
 .B serverOnly
 Setting this option to one (1) prevents the port from entering the
@@ -557,6 +573,12 @@ clock, and "E2E_TC" for end to end transparent clock.  An 
multi-port
 ordinary clock will automatically be configured as a boundary clock.
 The default is "OC".
 
+.TP
+.B cmlds_clockIdentity
+Assigns a CMLDS clockIdentity to be used by a ptp4l instance on a PTP
+node that exposes CMLDS over one or more links.
+The default is "000000.0000.000000".
+
 .TP
 .B dataset_comparison
 Specifies the method to be used when comparing data sets during the
-- 
2.31.1



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

Reply via email to