Ken ICHIKAWA
2013-06-11 05:58:32 UTC
This patch adds -X option that doesn't allow to step the slave clock
based on the master clock when phc2sys starts.
Instead the offset is slowly corrected by changing the clock frequency
unless -S option is used.
This feature is usefull when we need to restart phc2sys without system
clock jump. Restarting phc2sys is needed to change the configuration.
Signed-off-by: Ken ICHIKAWA <***@jp.fujitsu.com>
---
phc2sys.8 | 14 ++++++++++++--
phc2sys.c | 15 +++++++++++++--
2 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/phc2sys.8 b/phc2sys.8
index 92081cf..86a0fc1 100644
--- a/phc2sys.8
+++ b/phc2sys.8
@@ -29,6 +29,8 @@ phc2sys \- synchronize two clocks
] [
.B \-x
] [
+.B \-X
+] [
.BI \-l " print-level"
] [
.B \-m
@@ -95,8 +97,10 @@ Specify the integral constant of the PI controller. The default is 0.3.
.BI \-S " step"
Specify the step threshold of the PI controller. It is the maximum offset that
the controller corrects by changing the clock frequency instead of stepping the
-clock. The clock is always stepped on start. The value of 0.0 disables stepping
-after the start. The default is 0.0.
+clock. The clock is always stepped on start (unless the
+.B \-X
+option is used). The value of 0.0 disables stepping after the start. The
+default is 0.0.
.TP
.BI \-R " update-rate"
Specify the slave clock update rate when running in the direct synchronization
@@ -140,6 +144,12 @@ clock frequency (unless the
.B \-S
option is used).
.TP
+.B \-X
+Don't allow the slave clock to be stepped on start so that the offset is
+always corrected slowly by changing the clock frequency (unless the
+.B \-S
+option is used).
+.TP
.BI \-l " print-level"
Set the maximum syslog level of messages which should be printed or sent to
the system logger. The default is 6 (LOG_INFO).
diff --git a/phc2sys.c b/phc2sys.c
index d4c9b65..108fcea 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -139,6 +139,7 @@ struct clock {
int leap;
int leap_set;
int kernel_leap;
+ int skip_step;
struct pmc *pmc;
int pmc_ds_idx;
int pmc_ds_requested;
@@ -200,7 +201,12 @@ static void update_clock(struct clock *clock,
case SERVO_UNLOCKED:
break;
case SERVO_JUMP:
- clockadj_step(clock->clkid, -offset);
+ if (clock->skip_step)
+ /* Skip step only once to avoid conflict
+ between -S option and -X option. */
+ clock->skip_step = 0;
+ else
+ clockadj_step(clock->clkid, -offset);
/* Fall through. */
case SERVO_LOCKED:
clockadj_set_freq(clock->clkid, -ppb);
@@ -562,6 +568,7 @@ static void usage(char *progname)
" -w wait for ptp4l\n"
" -n [num] domain number (0)\n"
" -x apply leap seconds by servo instead of kernel\n"
+ " -X don't allow to step on start\n"
" -l [num] set the logging level to 'num' (6)\n"
" -m print messages to stdout\n"
" -q do not print messages to the syslog\n"
@@ -584,6 +591,7 @@ int main(int argc, char *argv[])
.clkid = CLOCK_REALTIME,
.servo_state = SERVO_UNLOCKED,
.kernel_leap = 1,
+ .skip_step = 0,
};
configured_pi_kp = KP;
@@ -593,7 +601,7 @@ int main(int argc, char *argv[])
progname = strrchr(argv[0], '/');
progname = progname ? 1+progname : argv[0];
while (EOF != (c = getopt(argc, argv,
- "c:d:hs:P:I:S:R:N:O:i:u:wn:xl:mqv"))) {
+ "c:d:s:P:I:S:R:N:O:i:u:wn:xXl:mqvh"))) {
switch (c) {
case 'c':
dst_clock.clkid = clock_open(optarg);
@@ -666,6 +674,9 @@ int main(int argc, char *argv[])
case 'x':
dst_clock.kernel_leap = 0;
break;
+ case 'X':
+ dst_clock.skip_step = 1;
+ break;
case 'l':
if (get_arg_val_i(c, optarg, &print_level,
PRINT_LEVEL_MIN, PRINT_LEVEL_MAX))
based on the master clock when phc2sys starts.
Instead the offset is slowly corrected by changing the clock frequency
unless -S option is used.
This feature is usefull when we need to restart phc2sys without system
clock jump. Restarting phc2sys is needed to change the configuration.
Signed-off-by: Ken ICHIKAWA <***@jp.fujitsu.com>
---
phc2sys.8 | 14 ++++++++++++--
phc2sys.c | 15 +++++++++++++--
2 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/phc2sys.8 b/phc2sys.8
index 92081cf..86a0fc1 100644
--- a/phc2sys.8
+++ b/phc2sys.8
@@ -29,6 +29,8 @@ phc2sys \- synchronize two clocks
] [
.B \-x
] [
+.B \-X
+] [
.BI \-l " print-level"
] [
.B \-m
@@ -95,8 +97,10 @@ Specify the integral constant of the PI controller. The default is 0.3.
.BI \-S " step"
Specify the step threshold of the PI controller. It is the maximum offset that
the controller corrects by changing the clock frequency instead of stepping the
-clock. The clock is always stepped on start. The value of 0.0 disables stepping
-after the start. The default is 0.0.
+clock. The clock is always stepped on start (unless the
+.B \-X
+option is used). The value of 0.0 disables stepping after the start. The
+default is 0.0.
.TP
.BI \-R " update-rate"
Specify the slave clock update rate when running in the direct synchronization
@@ -140,6 +144,12 @@ clock frequency (unless the
.B \-S
option is used).
.TP
+.B \-X
+Don't allow the slave clock to be stepped on start so that the offset is
+always corrected slowly by changing the clock frequency (unless the
+.B \-S
+option is used).
+.TP
.BI \-l " print-level"
Set the maximum syslog level of messages which should be printed or sent to
the system logger. The default is 6 (LOG_INFO).
diff --git a/phc2sys.c b/phc2sys.c
index d4c9b65..108fcea 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -139,6 +139,7 @@ struct clock {
int leap;
int leap_set;
int kernel_leap;
+ int skip_step;
struct pmc *pmc;
int pmc_ds_idx;
int pmc_ds_requested;
@@ -200,7 +201,12 @@ static void update_clock(struct clock *clock,
case SERVO_UNLOCKED:
break;
case SERVO_JUMP:
- clockadj_step(clock->clkid, -offset);
+ if (clock->skip_step)
+ /* Skip step only once to avoid conflict
+ between -S option and -X option. */
+ clock->skip_step = 0;
+ else
+ clockadj_step(clock->clkid, -offset);
/* Fall through. */
case SERVO_LOCKED:
clockadj_set_freq(clock->clkid, -ppb);
@@ -562,6 +568,7 @@ static void usage(char *progname)
" -w wait for ptp4l\n"
" -n [num] domain number (0)\n"
" -x apply leap seconds by servo instead of kernel\n"
+ " -X don't allow to step on start\n"
" -l [num] set the logging level to 'num' (6)\n"
" -m print messages to stdout\n"
" -q do not print messages to the syslog\n"
@@ -584,6 +591,7 @@ int main(int argc, char *argv[])
.clkid = CLOCK_REALTIME,
.servo_state = SERVO_UNLOCKED,
.kernel_leap = 1,
+ .skip_step = 0,
};
configured_pi_kp = KP;
@@ -593,7 +601,7 @@ int main(int argc, char *argv[])
progname = strrchr(argv[0], '/');
progname = progname ? 1+progname : argv[0];
while (EOF != (c = getopt(argc, argv,
- "c:d:hs:P:I:S:R:N:O:i:u:wn:xl:mqv"))) {
+ "c:d:s:P:I:S:R:N:O:i:u:wn:xXl:mqvh"))) {
switch (c) {
case 'c':
dst_clock.clkid = clock_open(optarg);
@@ -666,6 +674,9 @@ int main(int argc, char *argv[])
case 'x':
dst_clock.kernel_leap = 0;
break;
+ case 'X':
+ dst_clock.skip_step = 1;
+ break;
case 'l':
if (get_arg_val_i(c, optarg, &print_level,
PRINT_LEVEL_MIN, PRINT_LEVEL_MAX))
--
1.7.1
1.7.1