[Linuxptp-devel] [PATCH 2/2] Clock Class Threshold Feature addition for PTP4L

2021-02-14 Thread Karthikkumar V
Implemented code review comments.
This code changes brings in the ability to program the acceptable
clockClass threshold beyond which device will move to holdover/free-run.
Default clockClass threshold is 248.
Example Use-Case
This is needed in the cases where T-SC/T-BC Slave might want to listen
only on PRC clockCLass and anything beyond that might not be acceptible
and would want to go to holdover (with SyncE backup or internal
oscillator).

Signed-off-by: Karthikkumar V 
Signed-off-by: Ramana Reddy 
---
 clock.c | 4 ++--
 config.c| 2 +-
 configs/default.cfg | 2 +-
 port.c  | 7 +--
 ptp4l.8 | 5 +
 5 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/clock.c b/clock.c
index 542f409..c40476f 100644
--- a/clock.c
+++ b/clock.c
@@ -969,7 +969,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");
-   c->clock_class_threshold = config_get_int(config, NULL, 
"clockClassThreshold");
+   c->clock_class_threshold = config_get_int(config, NULL, 
"clock_class_threshold");
 
/* Harmonize the twoStepFlag with the time_stamping option. */
if (config_harmonize_onestep(config)) {
@@ -1660,7 +1660,7 @@ UInteger8 clock_max_steps_removed(struct clock *c)
 
 UInteger8 clock_get_clock_class_threshold(struct clock *c)
 {
-   if(c != NULL){
+   if (c != NULL) {
return c->clock_class_threshold;
}
return CLOCK_CLASS_THRESHOLD_DEFAULT; /* Return Default Value  */
diff --git a/config.c b/config.c
index 41735d3..c840d98 100644
--- a/config.c
+++ b/config.c
@@ -231,6 +231,7 @@ 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_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),
GLOB_ITEM_ENU("dataset_comparison", DS_CMP_IEEE1588, dataset_comp_enu),
@@ -332,7 +333,6 @@ struct config_item config_tab[] = {
GLOB_ITEM_INT("utc_offset", CURRENT_UTC_OFFSET, 0, INT_MAX),
GLOB_ITEM_INT("verbose", 0, 0, 1),
GLOB_ITEM_INT("write_phase_mode", 0, 0, 1),
-   GLOB_ITEM_INT("clockClassThreshold", CLOCK_CLASS_THRESHOLD_DEFAULT, 6, 
CLOCK_CLASS_THRESHOLD_DEFAULT),
 };
 
 static struct unicast_master_table *current_uc_mtab;
diff --git a/configs/default.cfg b/configs/default.cfg
index 473bbb9..e863239 100644
--- a/configs/default.cfg
+++ b/configs/default.cfg
@@ -29,7 +29,7 @@ logMinDelayReqInterval0
 logMinPdelayReqInterval0
 operLogPdelayReqInterval 0
 announceReceiptTimeout 3
-clockClassThreshold248
+clock_class_threshold  248
 syncReceiptTimeout 0
 delayAsymmetry 0
 fault_reset_interval   4
diff --git a/port.c b/port.c
index ae2a00e..024370f 100644
--- a/port.c
+++ b/port.c
@@ -1861,8 +1861,11 @@ int process_announce(struct port *p, struct ptp_message 
*m)
return result;
}
 
-   /* If the clock class is greater than clock_class_threshold , ignore 
this master */
-   if(m->announce.grandmasterClockQuality.clockClass > 
clock_get_clock_class_threshold(p->clock)){
+   if (m->announce.grandmasterClockQuality.clockClass >
+ clock_get_clock_class_threshold(p->clock)) {
+   pl_err(60, "%s: Master clock quality received is "
+  "greater than configured, ignoring master!",
+  p->log_name);
return result;
}
 
diff --git a/ptp4l.8 b/ptp4l.8
index 260aae3..b13471b 100644
--- a/ptp4l.8
+++ b/ptp4l.8
@@ -455,6 +455,11 @@ 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 clock_class_threshold
+The maximum clock class value from master, acceptible to sub-ordinate
+clock beyond which it moves out of lock state.
+The default value is 248.
+.TP
 
 .B domainNumber
 The domain attribute of the local clock.
-- 
1.8.3.1



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


[Linuxptp-devel] [PATCH 2/2] Clock Class Threshold Feature addition for PTP4L

2021-02-24 Thread Karthikkumar V
Incorporated Review Comments.

This code changes brings in the ability to program the acceptable
clockClass threshold beyond which device will move to holdover/free-run.
Default clockClass threshold is 248.
Example Use-Case:
This is needed in the cases where T-SC/T-BC Slave might want to listen
only on PRC clockCLass and anything beyond that might not be acceptible
and would want to go to holdover (with SyncE backup or internal oscillator).

Signed-off-by: Karthikkumar V 
Signed-off-by: Ramana Reddy 
---
 clock.c | 9 +++--
 configs/default.cfg | 2 +-
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/clock.c b/clock.c
index 6dd4661..0879e9b 100644
--- a/clock.c
+++ b/clock.c
@@ -136,7 +136,7 @@ struct clock {
struct monitor *slave_event_monitor;
int step_window_counter;
int step_window;
-  UInteger8 clock_class_threshold;
+   UInteger8 clock_class_threshold;
 };
 
 struct clock the_clock;
@@ -979,7 +979,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");
-  c->clock_class_threshold = config_get_int(config, NULL, 
"clock_class_threshold");
+   c->clock_class_threshold = config_get_int(config, NULL, 
"clock_class_threshold");
 
/* Harmonize the twoStepFlag with the time_stamping option. */
if (config_harmonize_onestep(config)) {
@@ -1715,10 +1715,7 @@ UInteger8 clock_max_steps_removed(struct clock *c)
 
 UInteger8 clock_get_clock_class_threshold(struct clock *c)
 {
-   if (c != NULL) {
-   return c->clock_class_threshold;
-   }
-   return CLOCK_CLASS_THRESHOLD_DEFAULT; /* Return Default Value  */
+   return c->clock_class_threshold;
 }
 
 
diff --git a/configs/default.cfg b/configs/default.cfg
index 3054ad6..b2ffa94 100644
--- a/configs/default.cfg
+++ b/configs/default.cfg
@@ -29,7 +29,6 @@ logMinDelayReqInterval0
 logMinPdelayReqInterval0
 operLogPdelayReqInterval 0
 announceReceiptTimeout 3
-clock_class_threshold  248
 syncReceiptTimeout 0
 delayAsymmetry 0
 fault_reset_interval   4
@@ -61,6 +60,7 @@ verbose   0
 summary_interval   0
 kernel_leap1
 check_fup_sync 0
+clock_class_threshold  248
 #
 # Servo Options
 #
-- 
1.8.3.1



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


Re: [Linuxptp-devel] [PATCH 2/2] Clock Class Threshold Feature addition for PTP4L

2021-02-16 Thread Jacob Keller



On 2/14/2021 9:59 PM, Karthikkumar V wrote:
> Implemented code review comments.
> This code changes brings in the ability to program the acceptable
> clockClass threshold beyond which device will move to holdover/free-run.
> Default clockClass threshold is 248.
> Example Use-Case
> This is needed in the cases where T-SC/T-BC Slave might want to listen
> only on PRC clockCLass and anything beyond that might not be acceptible
> and would want to go to holdover (with SyncE backup or internal
> oscillator).
> 
> Signed-off-by: Karthikkumar V 
> Signed-off-by: Ramana Reddy 
> ---
>  clock.c | 4 ++--
>  config.c| 2 +-
>  configs/default.cfg | 2 +-
>  port.c  | 7 +--
>  ptp4l.8 | 5 +
>  5 files changed, 14 insertions(+), 6 deletions(-)
> 
> diff --git a/clock.c b/clock.c
> index 542f409..c40476f 100644
> --- a/clock.c
> +++ b/clock.c
> @@ -969,7 +969,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");
> - c->clock_class_threshold = config_get_int(config, NULL, 
> "clockClassThreshold");
> + c->clock_class_threshold = config_get_int(config, NULL, 
> "clock_class_threshold");
>  


Why this change? It seems weird to remove this variable and introduce
another? clockClassThreshold is supposed to be the standard isn't it?

>   /* Harmonize the twoStepFlag with the time_stamping option. */
>   if (config_harmonize_onestep(config)) {
> @@ -1660,7 +1660,7 @@ UInteger8 clock_max_steps_removed(struct clock *c)
>  
>  UInteger8 clock_get_clock_class_threshold(struct clock *c)
>  {
> - if(c != NULL){
> + if (c != NULL) {
>   return c->clock_class_threshold;
>   }
>   return CLOCK_CLASS_THRESHOLD_DEFAULT; /* Return Default Value  */
> diff --git a/config.c b/config.c
> index 41735d3..c840d98 100644
> --- a/config.c
> +++ b/config.c
> @@ -231,6 +231,7 @@ 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_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),
>   GLOB_ITEM_ENU("dataset_comparison", DS_CMP_IEEE1588, dataset_comp_enu),
> @@ -332,7 +333,6 @@ struct config_item config_tab[] = {
>   GLOB_ITEM_INT("utc_offset", CURRENT_UTC_OFFSET, 0, INT_MAX),
>   GLOB_ITEM_INT("verbose", 0, 0, 1),
>   GLOB_ITEM_INT("write_phase_mode", 0, 0, 1),
> - GLOB_ITEM_INT("clockClassThreshold", CLOCK_CLASS_THRESHOLD_DEFAULT, 6, 
> CLOCK_CLASS_THRESHOLD_DEFAULT),
>  };
>  
>  static struct unicast_master_table *current_uc_mtab;
> diff --git a/configs/default.cfg b/configs/default.cfg
> index 473bbb9..e863239 100644
> --- a/configs/default.cfg
> +++ b/configs/default.cfg
> @@ -29,7 +29,7 @@ logMinDelayReqInterval  0
>  logMinPdelayReqInterval  0
>  operLogPdelayReqInterval 0
>  announceReceiptTimeout   3
> -clockClassThreshold  248
> +clock_class_threshold248
>  syncReceiptTimeout   0
>  delayAsymmetry   0
>  fault_reset_interval 4
> diff --git a/port.c b/port.c
> index ae2a00e..024370f 100644
> --- a/port.c
> +++ b/port.c
> @@ -1861,8 +1861,11 @@ int process_announce(struct port *p, struct 
> ptp_message *m)
>   return result;
>   }
>  
> - /* If the clock class is greater than clock_class_threshold , ignore 
> this master */
> - if(m->announce.grandmasterClockQuality.clockClass > 
> clock_get_clock_class_threshold(p->clock)){
> + if (m->announce.grandmasterClockQuality.clockClass >
> + clock_get_clock_class_threshold(p->clock)) {
> + pl_err(60, "%s: Master clock quality received is "
> +  "greater than configured, ignoring master!",
> +  p->log_name);
>   return result;
>   }
>  
> diff --git a/ptp4l.8 b/ptp4l.8
> index 260aae3..b13471b 100644
> --- a/ptp4l.8
> +++ b/ptp4l.8
> @@ -455,6 +455,11 @@ 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 clock_class_threshold
> +The maximum clock class value from master, acceptible to sub-ordinate
> +clock beyond which it moves out of lock state.
> +The default value is 248.
> +.TP
>  
>  .B domainNumber
>  The domain attribute of the local clock.
> 


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


Re: [Linuxptp-devel] [PATCH 2/2] Clock Class Threshold Feature addition for PTP4L

2021-02-16 Thread Richard Cochran
On Tue, Feb 16, 2021 at 02:08:44PM -0800, Jacob Keller wrote:
> On 2/14/2021 9:59 PM, Karthikkumar V wrote:
> > -   c->clock_class_threshold = config_get_int(config, NULL, 
> > "clockClassThreshold");
> > +   c->clock_class_threshold = config_get_int(config, NULL, 
> > "clock_class_threshold");
> >  
> 
> 
> Why this change? It seems weird to remove this variable and introduce
> another? clockClassThreshold is supposed to be the standard isn't it?

I think Karthikkumar made a delta patch to the previous one.

(and no, there is no clockClassThreshold in 1588)

Thanks,
Richard


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


Re: [Linuxptp-devel] [PATCH 2/2] Clock Class Threshold Feature addition for PTP4L

2021-02-16 Thread Ramana Reddy
Yes that's rite. There is no such field called clockClassThreshold while we 
have clockClass field
specified in 1588v2 spec. The naming convention from clockClassThreshold to 
clock_class_threshold
was changed as part of addressing review comments.

Thanks,
Ramana 

-Original Message-
From: Richard Cochran [mailto:richardcoch...@gmail.com] 
Sent: 17 February 2021 09:51
To: Jacob Keller
Cc: linuxptp-devel@lists.sourceforge.net
Subject: Re: [Linuxptp-devel] [PATCH 2/2] Clock Class Threshold Feature 
addition for PTP4L

CAUTION: This email originated from outside of Altiostar. Do not click on links 
or open attachments unless you recognize the sender and you are sure the 
content is safe. You will never be asked to reset your Altiostar password via 
email.


On Tue, Feb 16, 2021 at 02:08:44PM -0800, Jacob Keller wrote:
> On 2/14/2021 9:59 PM, Karthikkumar V wrote:
> > -   c->clock_class_threshold = config_get_int(config, NULL, 
> > "clockClassThreshold");
> > +   c->clock_class_threshold = config_get_int(config, NULL, 
> > "clock_class_threshold");
> >
>
>
> Why this change? It seems weird to remove this variable and introduce
> another? clockClassThreshold is supposed to be the standard isn't it?

I think Karthikkumar made a delta patch to the previous one.

(and no, there is no clockClassThreshold in 1588)

Thanks,
Richard


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


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


Re: [Linuxptp-devel] [PATCH 2/2] Clock Class Threshold Feature addition for PTP4L

2021-02-19 Thread Keller, Jacob E



> -Original Message-
> From: Richard Cochran 
> Sent: Tuesday, February 16, 2021 8:21 PM
> To: Keller, Jacob E 
> Cc: linuxptp-devel@lists.sourceforge.net
> Subject: Re: [Linuxptp-devel] [PATCH 2/2] Clock Class Threshold Feature 
> addition
> for PTP4L
> 
> On Tue, Feb 16, 2021 at 02:08:44PM -0800, Jacob Keller wrote:
> > On 2/14/2021 9:59 PM, Karthikkumar V wrote:
> > > - c->clock_class_threshold = config_get_int(config, NULL,
> "clockClassThreshold");
> > > + c->clock_class_threshold = config_get_int(config, NULL,
> "clock_class_threshold");
> > >
> >
> >
> > Why this change? It seems weird to remove this variable and introduce
> > another? clockClassThreshold is supposed to be the standard isn't it?
> 
> I think Karthikkumar made a delta patch to the previous one.
> 
> (and no, there is no clockClassThreshold in 1588)
> 


Ok, that makes more sense, thanks!

> Thanks,
> Richard


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


Re: [Linuxptp-devel] [PATCH 2/2] Clock Class Threshold Feature addition for PTP4L

2021-02-25 Thread Richard Cochran
On Thu, Feb 25, 2021 at 06:31:09AM +, Karthikkumar V wrote:

> diff --git a/clock.c b/clock.c
> index 6dd4661..0879e9b 100644
> --- a/clock.c
> +++ b/clock.c
> @@ -136,7 +136,7 @@ struct clock {
>   struct monitor *slave_event_monitor;
>   int step_window_counter;
>   int step_window;
> -  UInteger8 clock_class_threshold;
> + UInteger8 clock_class_threshold;

Please put this field just before max_steps_removed in the struct.

Also, can you squash this commit the first one together?

(git rebase -i)

Thanks,
Richard


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