Re: [Linuxptp-devel] [PATCHv2 1/1] Introduce the maxStepsRemoved attribute

2018-09-30 Thread Richard Cochran
On Fri, Sep 14, 2018 at 10:57:30AM +0200, Anders Selhammer wrote:
> Add attribute maxStepsRemoved which is included in IEEE1588-2017 (v2.1)
> It is an optional attribute which can decide if an Announce message is
> considered in the operation of the BMCA or not.

Applied.

Thanks,
Richard


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


[Linuxptp-devel] [PATCHv2 1/1] Introduce the maxStepsRemoved attribute

2018-09-14 Thread Anders Selhammer
Add attribute maxStepsRemoved which is included in IEEE1588-2017 (v2.1)
It is an optional attribute which can decide if an Announce message is
considered in the operation of the BMCA or not.

Signed-off-by: Anders Selhammer 
---
 clock.c  | 7 +++
 clock.h  | 7 +++
 config.c | 1 +
 configs/G.8275.1.cfg | 1 +
 configs/G.8275.2.cfg | 1 +
 configs/default.cfg  | 1 +
 port.c   | 5 +
 ptp4l.8  | 7 +++
 8 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/clock.c b/clock.c
index faf2dea..47592ac 100644
--- a/clock.c
+++ b/clock.c
@@ -106,6 +106,7 @@ struct clock {
int utc_offset;
int time_flags;  /* grand master role */
int time_source; /* grand master role */
+   UInteger8 max_steps_removed;
enum servo_state servo_state;
enum timestamp_type timestamping;
tmv_t master_offset;
@@ -930,6 +931,7 @@ struct clock *clock_create(enum clock_type type, struct 
config *config,
}
c->default_dataset.localPriority =
config_get_int(config, NULL, "G.8275.defaultDS.localPriority");
+   c->max_steps_removed = config_get_int(config, NULL,"maxStepsRemoved");
 
/* Harmonize the twoStepFlag with the time_stamping option. */
if (config_harmonize_onestep(config)) {
@@ -1564,6 +1566,11 @@ int clock_slave_only(struct clock *c)
return c->dds.flags & DDS_SLAVE_ONLY;
 }
 
+UInteger8 clock_max_steps_removed(struct clock *c)
+{
+   return c->max_steps_removed;
+}
+
 UInteger16 clock_steps_removed(struct clock *c)
 {
return c->cur.stepsRemoved;
diff --git a/clock.h b/clock.h
index cc2910a..07aba18 100644
--- a/clock.h
+++ b/clock.h
@@ -261,6 +261,13 @@ int clock_poll(struct clock *c);
 int clock_slave_only(struct clock *c);
 
 /**
+ * Obtain the max steps removed field from a clock's default data set.
+ * @param c  The clock instance.
+ * @return   The value of the clock's max steps removed field.
+ */
+UInteger8 clock_max_steps_removed(struct clock *c);
+
+/**
  * Obtain the steps removed field from a clock's current data set.
  * @param c  The clock instance.
  * @return   The value of the clock's steps removed field.
diff --git a/config.c b/config.c
index 7914ba4..0181d2a 100644
--- a/config.c
+++ b/config.c
@@ -227,6 +227,7 @@ struct config_item config_tab[] = {
PORT_ITEM_INT("logSyncInterval", 0, INT8_MIN, INT8_MAX),
GLOB_ITEM_INT("logging_level", LOG_INFO, PRINT_LEVEL_MIN, 
PRINT_LEVEL_MAX),
PORT_ITEM_INT("masterOnly", 0, 0, 1),
+   GLOB_ITEM_INT("maxStepsRemoved", 255, 2, UINT8_MAX),
GLOB_ITEM_STR("message_tag", NULL),
GLOB_ITEM_STR("manufacturerIdentity", "00:00:00"),
GLOB_ITEM_INT("max_frequency", 9, 0, INT_MAX),
diff --git a/configs/G.8275.1.cfg b/configs/G.8275.1.cfg
index f40cda0..288fa4f 100644
--- a/configs/G.8275.1.cfg
+++ b/configs/G.8275.1.cfg
@@ -7,5 +7,6 @@
 [global]
 dataset_comparison G.8275.x
 G.8275.defaultDS.localPriority 128
+maxStepsRemoved255
 masterOnly 0
 G.8275.portDS.localPriority128
diff --git a/configs/G.8275.2.cfg b/configs/G.8275.2.cfg
index 3d7a908..15bc609 100644
--- a/configs/G.8275.2.cfg
+++ b/configs/G.8275.2.cfg
@@ -7,6 +7,7 @@
 [global]
 dataset_comparison G.8275.x
 G.8275.defaultDS.localPriority 128
+maxStepsRemoved255
 masterOnly 0
 G.8275.portDS.localPriority128
 hybrid_e2e 1
diff --git a/configs/default.cfg b/configs/default.cfg
index c5a8b57..2ac6eb7 100644
--- a/configs/default.cfg
+++ b/configs/default.cfg
@@ -17,6 +17,7 @@ dscp_event0
 dscp_general   0
 dataset_comparison ieee1588
 G.8275.defaultDS.localPriority 128
+maxStepsRemoved255
 #
 # Port Data Set
 #
diff --git a/port.c b/port.c
index 5e0aed7..01e99a2 100644
--- a/port.c
+++ b/port.c
@@ -1711,10 +1711,7 @@ int process_announce(struct port *p, struct ptp_message 
*m)
 {
int result = 0;
 
-   /* Do not qualify announce messages with stepsRemoved >= 255, see
-* IEEE1588-2008 section 9.3.2.5 (d)
-*/
-   if (m->announce.stepsRemoved >= 255) {
+   if (m->announce.stepsRemoved >= clock_max_steps_removed(p->clock)) {
return result;
}
 
diff --git a/ptp4l.8 b/ptp4l.8
index 10c5c2f..1c67df1 100644
--- a/ptp4l.8
+++ b/ptp4l.8
@@ -414,6 +414,13 @@ timing network without loops) only when using the default 
values of
 G.8275.defaultDS.localPriority and G.8275.portDS.localPriority.
 Careful network engineering is needed when using non-default values.
 .TP
+.B maxStepsRemoved
+When using this option, if the value of stepsRemoved of an Announce
+message is greater than or equal to the value of maxStepsRemoved the
+Announce message is not considered in the operation of the BMCA.
+The default value is 255.
+.TP
+
 .B domainNumber
 The domain attribute