Re: [Linuxptp-devel] [RFC PATCH v1 2/8] Add configuration options for CMLDS

2023-03-22 Thread Andrew Zaborowski
On Wed, 22 Mar 2023 at 05:17, Richard Cochran  wrote:
> On Mon, Mar 20, 2023 at 09:04:59PM -0700, Kishen Maloor wrote:
> > Yes, we would configure CMLDS just once per physical port on a PTP node.
>
> Okay, so the code should check this.
>
> (Haven't reviewed yet, maybe you handle that already?)

We do not because that would require IPC and largely depend on the
user to provide correct configuration.  Let me explain.

In a typical setup, you'd have one ptp4l instance per domain, each
with a different domainNumber, clockIdentity and uds_address.  You'd
configure one of these ptp4l instances to run the CMLDS for all of the
physical ports the machine has using run_cmlds=1.  The
cmlds_uds_address is option is how other instances know how to talk to
that one instance.  If your cmlds_uds_address values are wrong you
can't detect a run_cmlds misconfiguration, not with UDS at least.

Note: Since config.c falls back to searching [global] when no per-port
option is found, you would probably set run_cmlds=1 directly under
[global] for that one ptp4l session.  The reason this option is
per-port is that there's no requirement that all of the PTP Instances
(domains) use the same subset of links on the PTP Node so you may have
no single ptp4l instance that uses all of your ports and may need to
split the responsibility of prviding CMLDS between more than one
instance.

Best regards


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


Re: [Linuxptp-devel] [RFC PATCH v1 2/8] Add configuration options for CMLDS

2023-03-21 Thread Richard Cochran
On Mon, Mar 20, 2023 at 09:04:59PM -0700, Kishen Maloor wrote:
> Yes, we would configure CMLDS just once per physical port on a PTP node.

Okay, so the code should check this.

(Haven't reviewed yet, maybe you handle that already?)

Thanks,
Richard


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


Re: [Linuxptp-devel] [RFC PATCH v1 2/8] Add configuration options for CMLDS

2023-03-20 Thread Kishen Maloor
On 3/20/23 8:10 PM, Richard Cochran wrote:
> On Mon, Mar 20, 2023 at 02:40:30PM -0700, Kishen Maloor wrote:
>> On 3/20/23 12:31 PM, Richard Cochran wrote:
>>> On Sun, Mar 19, 2023 at 10:36:48PM -0400, Kishen Maloor wrote:
>>>
 '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
>>>
>>> How many ports may have run_cmlds == 1 ?
>>
>> We may configure 'run_cmlds=1' on as many (links) ports as we need.
> 
> But there should be at most one cmlds on a given physical port, right?

Yes, we would configure CMLDS just once per physical port on a PTP node.

> 
> Thanks,
> Richard



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


Re: [Linuxptp-devel] [RFC PATCH v1 2/8] Add configuration options for CMLDS

2023-03-20 Thread Richard Cochran
On Mon, Mar 20, 2023 at 02:40:30PM -0700, Kishen Maloor wrote:
> On 3/20/23 12:31 PM, Richard Cochran wrote:
> > On Sun, Mar 19, 2023 at 10:36:48PM -0400, Kishen Maloor wrote:
> > 
> >> '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
> > 
> > How many ports may have run_cmlds == 1 ?
> 
> We may configure 'run_cmlds=1' on as many (links) ports as we need.

But there should be at most one cmlds on a given physical port, right?

Thanks,
Richard


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


Re: [Linuxptp-devel] [RFC PATCH v1 2/8] Add configuration options for CMLDS

2023-03-20 Thread Kishen Maloor
On 3/20/23 12:31 PM, Richard Cochran wrote:
> On Sun, Mar 19, 2023 at 10:36:48PM -0400, Kishen Maloor wrote:
> 
>> '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
> 
> How many ports may have run_cmlds == 1 ?

We may configure 'run_cmlds=1' on as many (links) ports as we need.

> 
> Thanks,
> Richard
> 
> 



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


Re: [Linuxptp-devel] [RFC PATCH v1 2/8] Add configuration options for CMLDS

2023-03-20 Thread Richard Cochran
On Sun, Mar 19, 2023 at 10:36:48PM -0400, Kishen Maloor wrote:

> '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

How many ports may have run_cmlds == 1 ?

Thanks,
Richard




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


[Linuxptp-devel] [RFC PATCH v1 2/8] Add configuration options for CMLDS

2023-03-19 Thread Kishen Maloor
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 
Signed-off-by: Kishen Maloor 
---
 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", "00..00"),
+   GLOB_ITEM_STR("cmlds_clockIdentity", "00..00"),
+   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, "00..00") != 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 pa