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 PTP 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 ++++ 4 files changed, 44 insertions(+) diff --git a/config.c b/config.c index cb4421f572c7..fdbcf3932485 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 d61e9b67e422..64c31aec5823 100644 --- a/port.c +++ b/port.c @@ -3299,6 +3299,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) { @@ -3479,6 +3481,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: @@ -3506,6 +3529,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 3b02d2fe45c4..7d36a8200896 100644 --- a/port_private.h +++ b/port_private.h @@ -164,6 +164,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) -- 2.31.1 _______________________________________________ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel