Re: [Linuxptp-devel] [PATCH v2 0/8] Convert to inclusive terminology, Part I

2021-01-13 Thread Peter Schneider

Am 11.01.21 um 22:30 schrieb Jacob Keller:



On 1/11/2021 9:05 AM, Richard Cochran wrote:

On Mon, Jan 11, 2021 at 10:07:41AM +0100, Miroslav Lichvar wrote:

What will happen with the "grandmaster" term? Does it stay, or should


No decision yet on that one.


it be replaced with something like "Primary time server"?


That sound reasonable to me.
  

My only concern is the risk that the next standard will use a
different terminology and linuxptp users will have have to go through
the transition twice.




I think I agree with Richard that much of the things we're renaming
don't strictly have to match. Plus, if we are able to influence the
standards towards this terminology we can avoid the potential.


We can choose the terminology we like without causing confusion.  In
fact, thanks to your insight of differentiating server/client and
source/sink, this project will have clear and helpful documentation!

The *only* things we'll have to adapt to the new standard (if and when
it ever appears) are the log messages that include port states.  Those
will optionally follow the new terminology.  For now, I'm keeping
almost all log messages unchanged, because some users are surely have
scripts that scrape through the logs.



That is correct, log messages are an interface to the outer world. We 
must take care of *not* to *force* customers to change their outer 
world, when *we* decide to change the [linux-]ptp world.




Right. We can worry about changing those once standards have caught up.
I also think it's important to use the correct terms for various states
and other standard-specific names when possible (much like how you keep
some of the standard names the same even if they do not follow coding
guidelines such as camel casing or not)



What about making log messages configurable? Kinda:
log_role_style  traditional
-or-
log_role_style  modern
-or-
log_role_style  ieee_xyz

This way,customers can switch to the new terminology when *they* are 
prepared to do so, and we can prepare the switching when we are not in a 
hurry.


The performance impact would be at most an additional computation of an 
"%s" format-string per log-message (where appropriate).


Kind regards,
Peter


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


[Linuxptp-devel] [PATCH 1/1] pmc: Fix LOG_SYNC_INTERVAL

2018-04-17 Thread Peter Schneider
Signed-off-by: Peter Schneider 
---
 pmc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pmc.c b/pmc.c
index 209a88a..6f23167 100644
--- a/pmc.c
+++ b/pmc.c
@@ -414,7 +414,7 @@ static void pmc_show(struct ptp_message *msg, FILE *fp)
break;
case TLV_LOG_SYNC_INTERVAL:
mtd = (struct management_tlv_datum *) mgt->data;
-   fprintf(fp, "ANNOUNCE_RECEIPT_TIMEOUT "
+   fprintf(fp, "LOG_SYNC_INTERVAL "
IFMT "logSyncInterval %hhd", mtd->val);
break;
case TLV_VERSION_NUMBER:
-- 
2.14.3


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH 0/1] pmc: fix wrong management id in LOG_SYNC_INTERVAL

2018-04-17 Thread Peter Schneider
In pmc, there is a little bug (only text, not functional):
When pmc is called with the management id 'LOG_SYNC_INTERVAL',
the response is '... seq 0 RESPONSE MANAGEMENT ANNOUNCE_RECEIPT_TIMEOUT' .
It should be '... seq 0 RESPONSE MANAGEMENT LOG_SYNC_INTERVAL'.
This patch fixes this.

Peter Schneider (1):
  pmc: Fix LOG_SYNC_INTERVAL

 pmc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.14.3


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH v4 10/12] phc2sys.c: Implement handling of Long options

2018-04-15 Thread Peter Schneider
Signed-off-by: Peter Schneider 
---
 phc2sys.c | 20 +---
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/phc2sys.c b/phc2sys.c
index 4a0051f..9e81052 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -1342,11 +1342,9 @@ int main(int argc, char *argv[])
char *config = NULL, *dst_name = NULL, *progname, *src_name = NULL;
struct clock *src, *dst;
struct config *cfg;
-   int autocfg = 0, rt = 0;
-   int c, domain_number = 0, pps_fd = -1;
-   int r = -1, wait_sync = 0;
-   int print_level = LOG_INFO;
-   int ntpshm_segment;
+   struct option *opts;
+   int autocfg = 0, c, domain_number = 0, index, ntpshm_segment;
+   int pps_fd = -1, print_level = LOG_INFO, r = -1, rt = 0, wait_sync = 0;
double phc_rate, tmp;
struct node node = {
.phc_readings = 5,
@@ -1360,15 +1358,23 @@ int main(int argc, char *argv[])
return -1;
}
 
+   opts = config_long_options(cfg);
+
config_set_double(cfg, "pi_proportional_const", KP);
config_set_double(cfg, "pi_integral_const", KI);
 
/* Process the command line arguments. */
progname = strrchr(argv[0], '/');
progname = progname ? 1+progname : argv[0];
-   while (EOF != (c = getopt(argc, argv,
- 
"arc:d:f:s:E:P:I:S:F:R:N:O:L:M:i:u:wn:xz:l:t:mqvh"))) {
+   while (EOF != (c = getopt_long(argc, argv,
+   
"arc:d:f:s:E:P:I:S:F:R:N:O:L:M:i:u:wn:xz:l:t:mqvh",
+   opts, &index))) {
switch (c) {
+   case 0:
+   if (config_parse_option(cfg, opts[index].name, optarg)) 
{
+   goto bad_usage;
+   }
+   break;
case 'a':
autocfg = 1;
break;
-- 
2.14.3


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH v4 03/12] phc2sys.c: Replace variable 'message_tag'

2018-04-15 Thread Peter Schneider
Replaced usage of variable 'message_tag' with struct config item
'message_tag'. Original variable removed.

Signed-off-by: Peter Schneider 
---
 phc2sys.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/phc2sys.c b/phc2sys.c
index 1234a6a..9158dde 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -1338,7 +1338,7 @@ static void usage(char *progname)
 
 int main(int argc, char *argv[])
 {
-   char *progname, *message_tag = NULL;
+   char *progname;
char *src_name = NULL, *dst_name = NULL;
struct clock *src, *dst;
struct config *cfg;
@@ -1487,7 +1487,9 @@ int main(int argc, char *argv[])
}
break;
case 't':
-   message_tag = optarg;
+   if (config_set_string(cfg, "message_tag", optarg)) {
+   goto end;
+   }
break;
case 'm':
verbose = 1;
@@ -1531,7 +1533,7 @@ int main(int argc, char *argv[])
}
 
print_set_progname(progname);
-   print_set_tag(message_tag);
+   print_set_tag(config_get_string(cfg, NULL, "message_tag"));
print_set_verbose(verbose);
print_set_syslog(use_syslog);
print_set_level(config_get_int(cfg, NULL, "logging_level"));
-- 
2.14.3


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH v4 09/12] phc2sys.c: Implement configuration file handling

2018-04-15 Thread Peter Schneider
Signed-off-by: Peter Schneider 
---
 phc2sys.c | 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/phc2sys.c b/phc2sys.c
index 494ac10..4a0051f 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -1313,6 +1313,7 @@ static void usage(char *progname)
" -O [offset]slave-master time offset (0)\n"
" -w wait for ptp4l\n"
" common options:\n"
+   " -f [file]  configuration file\n"
" -E [pi|linreg] clock servo (pi)\n"
" -P [kp]proportional constant (0.7)\n"
" -I [ki]integration constant (0.3)\n"
@@ -1338,8 +1339,7 @@ static void usage(char *progname)
 
 int main(int argc, char *argv[])
 {
-   char *progname;
-   char *src_name = NULL, *dst_name = NULL;
+   char *config = NULL, *dst_name = NULL, *progname, *src_name = NULL;
struct clock *src, *dst;
struct config *cfg;
int autocfg = 0, rt = 0;
@@ -1367,7 +1367,7 @@ int main(int argc, char *argv[])
progname = strrchr(argv[0], '/');
progname = progname ? 1+progname : argv[0];
while (EOF != (c = getopt(argc, argv,
- 
"arc:d:s:E:P:I:S:F:R:N:O:L:M:i:u:wn:xz:l:t:mqvh"))) {
+ 
"arc:d:f:s:E:P:I:S:F:R:N:O:L:M:i:u:wn:xz:l:t:mqvh"))) {
switch (c) {
case 'a':
autocfg = 1;
@@ -1386,6 +1386,9 @@ int main(int argc, char *argv[])
goto end;
}
break;
+   case 'f':
+   config = optarg;
+   break;
case 'i':
fprintf(stderr,
"'-i' has been deprecated. please use '-s' 
instead.\n");
@@ -1518,6 +1521,10 @@ int main(int argc, char *argv[])
}
}
 
+   if (config && (c = config_read(config, cfg))) {
+   return c;
+   }
+
if (autocfg && (src_name || dst_name || pps_fd >= 0 || wait_sync || 
node.forced_sync_offset)) {
fprintf(stderr,
"autoconfiguration cannot be mixed with manual config 
options.\n");
-- 
2.14.3


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH v4 00/12] phc2sys: long-opts/cfg-file/tS

2018-04-15 Thread Peter Schneider
This patch series changes phc2sys. It implements the possibility to use a
configuration file, enables the usage of long options and allows
configuring the transportSpecific value.
Changes proposed by Anders and Richard added.

Peter Schneider (12):
  phc2sys.c: Replace variable 'domain_number
  phc2sys.c: Replace variable 'print_level'
  phc2sys.c: Replace variable 'message_tag'
  phc2sys.c: Replace variable 'verbose'
  phc2sys.c: Replace usage of variable 'use_syslog'
  phc2sys.c: Sync variable 'node.clock_servo with cfg item
  phc2sys.c: Sync variable 'node.kernel_leap with cfg item
  phc2sys.c: Sync variable 'node.sanity_freq_limit with cfg item
  phc2sys.c: Implement configuration file handling
  phc2sys.c: Implement handling of Long options
  phc2sys.c: Implement using transportSpecific
  phc2sys.8: Doc long opts / cfgfile handling

 phc2sys.8 | 198 +-
 phc2sys.c |  97 --
 2 files changed, 262 insertions(+), 33 deletions(-)

-- 
2.14.3


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH v4 04/12] phc2sys.c: Replace variable 'verbose'

2018-04-15 Thread Peter Schneider
Replaced usage of variable 'verbose' with struct config item 'verbose'.
Original variable removed.

Signed-off-by: Peter Schneider 
---
 phc2sys.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/phc2sys.c b/phc2sys.c
index 9158dde..c5b48fa 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -1345,7 +1345,7 @@ int main(int argc, char *argv[])
int autocfg = 0, rt = 0;
int c, domain_number = 0, pps_fd = -1;
int r = -1, wait_sync = 0;
-   int print_level = LOG_INFO, use_syslog = 1, verbose = 0;
+   int print_level = LOG_INFO, use_syslog = 1;
int ntpshm_segment;
double phc_rate, tmp;
struct node node = {
@@ -1492,7 +1492,9 @@ int main(int argc, char *argv[])
}
break;
case 'm':
-   verbose = 1;
+   if (config_set_int(cfg, "verbose", 1)) {
+   goto end;
+   }
break;
case 'q':
use_syslog = 0;
@@ -1534,7 +1536,7 @@ int main(int argc, char *argv[])
 
print_set_progname(progname);
print_set_tag(config_get_string(cfg, NULL, "message_tag"));
-   print_set_verbose(verbose);
+   print_set_verbose(config_get_int(cfg, NULL, "verbose"));
print_set_syslog(use_syslog);
print_set_level(config_get_int(cfg, NULL, "logging_level"));
 
-- 
2.14.3


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH v4 07/12] phc2sys.c: Sync variable 'node.kernel_leap with cfg item

2018-04-15 Thread Peter Schneider
Use struct config item 'kernel_leap' for parameter handling. Copy this to
node.kernel_leap afterwards. Check for 'servo_type' == CLOCK_SERVO_NTPSHM.

Signed-off-by: Peter Schneider 
---
 phc2sys.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/phc2sys.c b/phc2sys.c
index 47284b4..04e7442 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -1352,7 +1352,6 @@ int main(int argc, char *argv[])
.sanity_freq_limit = 2,
.phc_readings = 5,
.phc_interval = 1.0,
-   .kernel_leap = 1,
};
 
handle_term_signals();
@@ -1469,7 +1468,9 @@ int main(int argc, char *argv[])
}
break;
case 'x':
-   node.kernel_leap = 0;
+   if (config_set_int(cfg, "kernel_leap", 0)) {
+   goto end;
+   }
break;
case 'z':
if (strlen(optarg) > MAX_IFNAME_SIZE) {
@@ -1543,7 +1544,12 @@ int main(int argc, char *argv[])
print_set_verbose(config_get_int(cfg, NULL, "verbose"));
print_set_syslog(config_get_int(cfg, NULL, "use_syslog"));
print_set_level(config_get_int(cfg, NULL, "logging_level"));
+
node.servo_type = config_get_int(cfg, NULL, "clock_servo");
+   if (node.servo_type == CLOCK_SERVO_NTPSHM) {
+   config_set_int(cfg, "kernel_leap", 0);
+   }
+   node.kernel_leap = config_get_int(cfg, NULL, "kernel_leap");
 
if (autocfg) {
if (init_pmc(cfg, &node))
-- 
2.14.3


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH v4 02/12] phc2sys.c: Replace variable 'print_level'

2018-04-15 Thread Peter Schneider
Replaced usage of variable 'print_level' with struct config item
'logging_level'. Original variable still used for range checking.

Signed-off-by: Peter Schneider 
---
 phc2sys.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/phc2sys.c b/phc2sys.c
index bf92caa..1234a6a 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -1481,8 +1481,10 @@ int main(int argc, char *argv[])
break;
case 'l':
if (get_arg_val_i(c, optarg, &print_level,
- PRINT_LEVEL_MIN, PRINT_LEVEL_MAX))
+ PRINT_LEVEL_MIN, PRINT_LEVEL_MAX) ||
+   config_set_int(cfg, "logging_level", print_level)) {
goto end;
+   }
break;
case 't':
message_tag = optarg;
@@ -1532,7 +1534,7 @@ int main(int argc, char *argv[])
print_set_tag(message_tag);
print_set_verbose(verbose);
print_set_syslog(use_syslog);
-   print_set_level(print_level);
+   print_set_level(config_get_int(cfg, NULL, "logging_level"));
 
if (autocfg) {
if (init_pmc(cfg, &node))
-- 
2.14.3


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH v4 08/12] phc2sys.c: Sync variable 'node.sanity_freq_limit with cfg item

2018-04-15 Thread Peter Schneider
Copy 'node.sanity_freq_limit' to struct config item 'sanity_freq_limit'.
Check for 'servo_type' == CLOCK_SERVO_NTPSHM.

Signed-off-by: Peter Schneider 
---
 phc2sys.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/phc2sys.c b/phc2sys.c
index 04e7442..494ac10 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -1349,7 +1349,6 @@ int main(int argc, char *argv[])
int ntpshm_segment;
double phc_rate, tmp;
struct node node = {
-   .sanity_freq_limit = 2,
.phc_readings = 5,
.phc_interval = 1.0,
};
@@ -1445,8 +1444,10 @@ int main(int argc, char *argv[])
node.forced_sync_offset = -1;
break;
case 'L':
-   if (get_arg_val_i(c, optarg, &node.sanity_freq_limit, 
0, INT_MAX))
+   if (get_arg_val_i(c, optarg, &node.sanity_freq_limit, 
0, INT_MAX) ||
+   config_set_int(cfg, "sanity_freq_limit", 
node.sanity_freq_limit)) {
goto end;
+   }
break;
case 'M':
if (get_arg_val_i(c, optarg, &ntpshm_segment, INT_MIN, 
INT_MAX) ||
@@ -1548,8 +1549,10 @@ int main(int argc, char *argv[])
node.servo_type = config_get_int(cfg, NULL, "clock_servo");
if (node.servo_type == CLOCK_SERVO_NTPSHM) {
config_set_int(cfg, "kernel_leap", 0);
+   config_set_int(cfg, "sanity_freq_limit", 0);
}
node.kernel_leap = config_get_int(cfg, NULL, "kernel_leap");
+   node.sanity_freq_limit = config_get_int(cfg, NULL, "sanity_freq_limit");
 
if (autocfg) {
if (init_pmc(cfg, &node))
-- 
2.14.3


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH v4 11/12] phc2sys.c: Implement using transportSpecific

2018-04-15 Thread Peter Schneider
Signed-off-by: Peter Schneider 
---
 phc2sys.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/phc2sys.c b/phc2sys.c
index 9e81052..c004066 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -904,7 +904,8 @@ static int init_pmc(struct config *cfg, struct node *node)
snprintf(uds_local, sizeof(uds_local), "/var/run/phc2sys.%d",
 getpid());
node->pmc = pmc_create(cfg, TRANS_UDS, uds_local, 0,
-  config_get_int(cfg, NULL, "domainNumber"), 0, 1);
+  config_get_int(cfg, NULL, "domainNumber"),
+  config_get_int(cfg, NULL, "transportSpecific") 
<< 4, 1);
if (!node->pmc) {
pr_err("failed to create pmc");
return -1;
-- 
2.14.3


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH v4 12/12] phc2sys.8: Doc long opts / cfgfile handling

2018-04-15 Thread Peter Schneider
Signed-off-by: Peter Schneider 
---
 phc2sys.8 | 198 +-
 1 file changed, 195 insertions(+), 3 deletions(-)

diff --git a/phc2sys.8 b/phc2sys.8
index 4fc4fa3..3b4b0e0 100644
--- a/phc2sys.8
+++ b/phc2sys.8
@@ -1,4 +1,4 @@
-.TH PHC2SYS 8 "November 2012" "linuxptp"
+.TH PHC2SYS 8 "April 2018" "linuxptp"
 .SH NAME
 phc2sys \- synchronize two or more clocks
 
@@ -8,10 +8,16 @@ phc2sys \- synchronize two or more clocks
 .B \-r
 ] [
 .B \-r
-] [ options ]
+] [
+.BI \-f " config-file"
+] [ options ] [
+.I long-options
+]
 .br
 .B phc2sys
 [
+.BI \-f " config-file"
+] [
 .BI \-d " pps-device"
 ] [
 .BI \-s " device"
@@ -21,7 +27,11 @@ phc2sys \- synchronize two or more clocks
 .BI \-O " offset"
 ] [
 .BI \-w
-] [ options ]
+] [ options ] [
+.I long-options
+]
+.I .\|.\|.
+
 
 .SH DESCRIPTION
 .B phc2sys
@@ -226,6 +236,167 @@ Display a help message.
 .B \-v
 Prints the software version and exits.
 
+.SH LONG OPTIONS
+
+Each and every configuration file option (see below in section
+.BR FILE\ OPTIONS)
+may also appear
+as a "long" style command line argument.  For example, the transportSpecific
+option may be set using either of these two forms:
+
+.RS
+\f(CW\-\-transportSpecific 1   \-\-transportSpecific=1\fP
+.RE
+
+Option values given on the command line override values in the global
+section of the configuration file (which, in turn overrides default
+values).
+
+.SH CONFIGURATION FILE
+
+The configuration file is divided into sections. Each section starts with a
+line containing its name enclosed in brackets and it follows with settings.
+Each setting is placed on a separate line, it contains the name of the
+option and the value separated by whitespace characters. Empty lines and lines
+starting with # are ignored.
+
+The global section (indicated as
+.BR [global] )
+sets the program options. This is the only used option.
+
+.SH FILE OPTIONS
+
+.TP
+.B domainNumber
+Specify the domain number used by phc2sys. The default is 0. Same as option
+.B \-n
+(see above).
+
+.TP
+.B kernel_leap
+When a leap second is announced, let the kernel apply it by stepping the
+clock instead of correcting the one-second offset with servo, which would
+correct the one-second offset slowly by changing the clock frequency
+(unless the step_threshold option is set to correct such offset by
+stepping). Relevant only with software time stamping. The default is 1
+(enabled). Same as option
+.B \-x
+(see above).
+
+The maximum logging level of messages which should be printed.
+The default is 6 (LOG_INFO). Same as option
+.B \-l
+(see above).
+
+.TP
+.B logging_level
+The maximum logging level of messages which should be printed.
+The default is 6 (LOG_INFO). Same as option
+.B \-l
+(see above).
+
+.TP
+.B message_tag
+The tag which is added to all messages printed to the standard output
+or system log. The default is an empty string (which cannot be set in
+the configuration file as the option requires an argument).
+Same as option
+.B \-t
+(see above).
+
+.TP
+.B sanity_freq_limit
+The maximum allowed frequency offset between uncorrected clock and the
+system monotonic clock in parts per billion (ppb). This is used as a
+sanity check of the synchronized clock. When a larger offset is measured,
+a warning message will be printed and the servo will be reset. When set
+to 0, the sanity check is disabled. The default is 2 (20%).
+Same as option
+.B \-L
+(see above).
+
+.TP
+.B clock_servo
+The servo which is used to synchronize the local clock. Valid values
+are "pi" for a PI controller, "linreg" for an adaptive controller using
+linear regression, "ntpshm" for the NTP SHM reference clock to allow
+another process to synchronize the local clock (the SHM segment number
+is set to the domain number), and "nullf" for a servo that always dials
+frequency offset zero (for use in SyncE nodes). The default is "pi."
+Same as option
+.B \-E
+(see above).
+
+.TP
+.B transportSpecific
+The transport specific field. Must be in the range 0 to 255.
+The default is 0.
+
+.TP
+.B use_syslog
+Print messages to the system log if enabled.  The default is 1 (enabled).
+Related to option
+.B \-q
+(see above).
+
+.TP
+.B verbose
+Print messages to the standard output if enabled.  The default is 0 (disabled).
+Related to option
+.B \-m
+(see above).
+
+.TP
+.B pi_proportional_const
+Specifies the proportional constant of the PI controller.
+Same as option
+.B \-P
+(see above).
+
+.TP
+.B pi_integral_const
+Specifies the integral constant of the PI controller.
+Same as option
+.B \-I
+(see above).
+
+.TP
+.B step_threshold
+Specifies the step threshold of the servo. It is the maximum offset that
+the servo corrects by changing the clock frequency instead of stepping
+the clock. The clock is stepped on start regardless of the option if the
+offset

[Linuxptp-devel] [PATCH v4 06/12] phc2sys.c: Sync variable 'node.clock_servo with cfg item

2018-04-15 Thread Peter Schneider
Use struct config item 'clock_servo' for parameter handling. Copy this to
node.servo_type afterwards.

Signed-off-by: Peter Schneider 
---
 phc2sys.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/phc2sys.c b/phc2sys.c
index 745b5c9..47284b4 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -1350,7 +1350,6 @@ int main(int argc, char *argv[])
double phc_rate, tmp;
struct node node = {
.sanity_freq_limit = 2,
-   .servo_type = CLOCK_SERVO_PI,
.phc_readings = 5,
.phc_interval = 1.0,
.kernel_leap = 1,
@@ -1397,11 +1396,14 @@ int main(int argc, char *argv[])
break;
case 'E':
if (!strcasecmp(optarg, "pi")) {
-   node.servo_type = CLOCK_SERVO_PI;
+   config_set_int(cfg, "clock_servo",
+  CLOCK_SERVO_PI);
} else if (!strcasecmp(optarg, "linreg")) {
-   node.servo_type = CLOCK_SERVO_LINREG;
+   config_set_int(cfg, "clock_servo",
+  CLOCK_SERVO_LINREG);
} else if (!strcasecmp(optarg, "ntpshm")) {
-   node.servo_type = CLOCK_SERVO_NTPSHM;
+   config_set_int(cfg, "clock_servo",
+  CLOCK_SERVO_NTPSHM);
} else {
fprintf(stderr,
"invalid servo name %s\n", optarg);
@@ -1541,6 +1543,7 @@ int main(int argc, char *argv[])
print_set_verbose(config_get_int(cfg, NULL, "verbose"));
print_set_syslog(config_get_int(cfg, NULL, "use_syslog"));
print_set_level(config_get_int(cfg, NULL, "logging_level"));
+   node.servo_type = config_get_int(cfg, NULL, "clock_servo");
 
if (autocfg) {
if (init_pmc(cfg, &node))
-- 
2.14.3


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH v4 01/12] phc2sys.c: Replace variable 'domain_number

2018-04-15 Thread Peter Schneider
Replaced usage of variable 'domain_number' with struct config item
'domainNumber'. Original variable still used for range checking. Removed
(now obsolete) third parameter of init_pmc().

Signed-off-by: Peter Schneider 
---
 phc2sys.c | 13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/phc2sys.c b/phc2sys.c
index 3a82cfe..bf92caa 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -897,13 +897,14 @@ static void send_subscription(struct node *node)
pmc_send_set_action(node->pmc, TLV_SUBSCRIBE_EVENTS_NP, &sen, 
sizeof(sen));
 }
 
-static int init_pmc(struct config *cfg, struct node *node, int domain_number)
+static int init_pmc(struct config *cfg, struct node *node)
 {
char uds_local[MAX_IFNAME_SIZE + 1];
 
snprintf(uds_local, sizeof(uds_local), "/var/run/phc2sys.%d",
 getpid());
-   node->pmc = pmc_create(cfg, TRANS_UDS, uds_local, 0, domain_number, 0, 
1);
+   node->pmc = pmc_create(cfg, TRANS_UDS, uds_local, 0,
+  config_get_int(cfg, NULL, "domainNumber"), 0, 1);
if (!node->pmc) {
pr_err("failed to create pmc");
return -1;
@@ -1460,8 +1461,10 @@ int main(int argc, char *argv[])
wait_sync = 1;
break;
case 'n':
-   if (get_arg_val_i(c, optarg, &domain_number, 0, 255))
+   if (get_arg_val_i(c, optarg, &domain_number, 0, 255) ||
+   config_set_int(cfg, "domainNumber", domain_number)) 
{
goto end;
+   }
break;
case 'x':
node.kernel_leap = 0;
@@ -1532,7 +1535,7 @@ int main(int argc, char *argv[])
print_set_level(print_level);
 
if (autocfg) {
-   if (init_pmc(cfg, &node, domain_number))
+   if (init_pmc(cfg, &node))
goto end;
if (auto_init_ports(&node, rt) < 0)
goto end;
@@ -1568,7 +1571,7 @@ int main(int argc, char *argv[])
r = -1;
 
if (wait_sync) {
-   if (init_pmc(cfg, &node, domain_number))
+   if (init_pmc(cfg, &node))
goto end;
 
while (is_running()) {
-- 
2.14.3


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH v4 05/12] phc2sys.c: Replace usage of variable 'use_syslog'

2018-04-15 Thread Peter Schneider
Replaced usage of variable 'use_syslog' with struct config item
'use_syslog'. Original variable removed.

Signed-off-by: Peter Schneider 
---
 phc2sys.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/phc2sys.c b/phc2sys.c
index c5b48fa..745b5c9 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -1345,7 +1345,7 @@ int main(int argc, char *argv[])
int autocfg = 0, rt = 0;
int c, domain_number = 0, pps_fd = -1;
int r = -1, wait_sync = 0;
-   int print_level = LOG_INFO, use_syslog = 1;
+   int print_level = LOG_INFO;
int ntpshm_segment;
double phc_rate, tmp;
struct node node = {
@@ -1497,7 +1497,9 @@ int main(int argc, char *argv[])
}
break;
case 'q':
-   use_syslog = 0;
+   if (config_set_int(cfg, "use_syslog", 0)) {
+   goto end;
+   }
break;
case 'v':
version_show(stdout);
@@ -1537,7 +1539,7 @@ int main(int argc, char *argv[])
print_set_progname(progname);
print_set_tag(config_get_string(cfg, NULL, "message_tag"));
print_set_verbose(config_get_int(cfg, NULL, "verbose"));
-   print_set_syslog(use_syslog);
+   print_set_syslog(config_get_int(cfg, NULL, "use_syslog"));
print_set_level(config_get_int(cfg, NULL, "logging_level"));
 
if (autocfg) {
-- 
2.14.3


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH v3 06/12] phc2sys.c: Handling of node.servo_type

2018-04-07 Thread Peter Schneider
Use struct config item 'clock_servo' for
parameter handling. Copy this to node.servo_type afterwards.

Signed-off-by: Peter Schneider 
---
 phc2sys.c | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/phc2sys.c b/phc2sys.c
index ad67438..5b244b2 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -1397,11 +1397,14 @@ int main(int argc, char *argv[])
break;
case 'E':
if (!strcasecmp(optarg, "pi")) {
-   node.servo_type = CLOCK_SERVO_PI;
+   config_set_int(cfg, "clock_servo",
+  CLOCK_SERVO_PI);
} else if (!strcasecmp(optarg, "linreg")) {
-   node.servo_type = CLOCK_SERVO_LINREG;
+   config_set_int(cfg, "clock_servo",
+  CLOCK_SERVO_LINREG);
} else if (!strcasecmp(optarg, "ntpshm")) {
-   node.servo_type = CLOCK_SERVO_NTPSHM;
+   config_set_int(cfg, "clock_servo",
+  CLOCK_SERVO_NTPSHM);
} else {
fprintf(stderr,
"invalid servo name %s\n", optarg);
@@ -1541,6 +1544,7 @@ int main(int argc, char *argv[])
print_set_verbose(config_get_int(cfg, NULL, "verbose"));
print_set_syslog(config_get_int(cfg, NULL, "use_syslog"));
print_set_level(config_get_int(cfg, NULL, "logging_level"));
+   node.servo_type = config_get_int(cfg, NULL, "clock_servo");
 
if (autocfg) {
if (init_pmc(cfg, &node))
-- 
2.14.3


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH v3 12/12] phc2sys.8: Doc long opts / cfgfile handling

2018-04-07 Thread Peter Schneider
Signed-off-by: Peter Schneider 
---
 phc2sys.8 | 198 +-
 1 file changed, 195 insertions(+), 3 deletions(-)

diff --git a/phc2sys.8 b/phc2sys.8
index 4fc4fa3..48bac47 100644
--- a/phc2sys.8
+++ b/phc2sys.8
@@ -1,4 +1,4 @@
-.TH PHC2SYS 8 "November 2012" "linuxptp"
+.TH PHC2SYS 8 "April 2017" "linuxptp"
 .SH NAME
 phc2sys \- synchronize two or more clocks
 
@@ -8,10 +8,16 @@ phc2sys \- synchronize two or more clocks
 .B \-r
 ] [
 .B \-r
-] [ options ]
+] [
+.BI \-f " config-file"
+] [ options ] [
+.I long-options
+]
 .br
 .B phc2sys
 [
+.BI \-f " config-file"
+] [
 .BI \-d " pps-device"
 ] [
 .BI \-s " device"
@@ -21,7 +27,11 @@ phc2sys \- synchronize two or more clocks
 .BI \-O " offset"
 ] [
 .BI \-w
-] [ options ]
+] [ options ] [
+.I long-options
+]
+.I .\|.\|.
+
 
 .SH DESCRIPTION
 .B phc2sys
@@ -226,6 +236,170 @@ Display a help message.
 .B \-v
 Prints the software version and exits.
 
+.SH LONG OPTIONS
+
+Each and every configuration file option (see below in section
+.BR FILE\ OPTIONS)
+may also appear
+as a "long" style command line argument.  For example, the transportSpecific
+option may be set using either of these two forms:
+
+.RS
+\f(CW\-\-transportSpecific 1   \-\-transportSpecific=1\fP
+.RE
+
+Option values given on the command line override values in the global
+section of the configuration file (which, in turn overrides default
+values).
+
+.SH CONFIGURATION FILE
+
+The configuration file is divided into sections. Each section starts with a
+line containing its name enclosed in brackets and it follows with settings.
+Each setting is placed on a separate line, it contains the name of the
+option and the value separated by whitespace characters. Empty lines and lines
+starting with # are ignored.
+
+The global section (indicated as
+.BR [global] )
+sets the program options. This is the only used option.
+
+.SH FILE OPTIONS
+
+.TP
+.B domainNumber
+Specify the domain number used by phc2sys. The default is 0. Same as option
+.B \-n
+(see above).
+
+.TP
+.B kernel_leap
+When a leap second is announced, let the kernel apply it by stepping the
+clock instead of correcting the one-second offset with servo, which would
+correct the one-second offset slowly by changing the clock frequency
+(unless the step_threshold option is set to correct such offset by
+stepping). Relevant only with software time stamping. The default is 1
+(enabled). Same as option
+.B \-x
+(see above).
+
+The maximum logging level of messages which should be printed.
+The default is 6 (LOG_INFO). Same as option
+.B \-l
+(see above).
+
+.TP
+.B logging_level
+The maximum logging level of messages which should be printed.
+The default is 6 (LOG_INFO). Same as option
+.B \-l
+(see above).
+
+.TP
+.B message_tag
+The tag which is added to all messages printed to the standard output
+or system log. The default is an empty string (which cannot be set in
+the configuration file as the option requires an argument).
+Same as option
+.B \-t
+(see above).
+
+.TP
+.B sanity_freq_limit
+The maximum allowed frequency offset between uncorrected clock and the
+system monotonic clock in parts per billion (ppb). This is used as a
+sanity check of the synchronized clock. When a larger offset is measured,
+a warning message will be printed and the servo will be reset. When set
+to 0, the sanity check is disabled. The default is 2 (20%).
+Same as option
+.B \-L
+(see above).
+
+.TP
+.B clock_servo
+The servo which is used to synchronize the local clock. Valid values
+are "pi" for a PI controller, "linreg" for an adaptive controller using
+linear regression, "ntpshm" for the NTP SHM reference clock to allow
+another process to synchronize the local clock (the SHM segment number
+is set to the domain number), and "nullf" for a servo that always dials
+frequency offset zero (for use in SyncE nodes). The default is "pi."
+Same as option
+.B \-E
+(see above).
+
+.TP
+.B transportSpecific
+The transport specific field. Must be in the range 0 to 255.
+The default is 0.
+
+.TP
+.B use_syslog
+Print messages to the system log if enabled.  The default is 1 (enabled).
+Related to option
+.B \-q
+(see above).
+
+.TP
+.B verbose
+Print messages to the standard output if enabled.  The default is 0 (disabled).
+Related to option
+.B \-m
+(see above).
+
+.TP
+There are more options, which SHOULD be working, but these are untested:
+
+.TP
+.B pi_proportional_const
+Specifies the proportional constant of the PI controller.
+Same as option
+.B \-P
+(see above).
+
+.TP
+.B pi_integral_const
+Specifies the integral constant of the PI controller.
+Same as option
+.B \-I
+(see above).
+
+.TP
+.B step_threshold
+Specifies the step threshold of the servo. It is the maximum offset that
+the servo corrects by changing the clock frequency instead of stepping

[Linuxptp-devel] [PATCH v3 05/12] phc2sys.c: Handlöing of use_syslog

2018-04-07 Thread Peter Schneider
Replaced usage of variable 'use_syslog'
with struct config item 'use_syslog'. Original variable removed.

Signed-off-by: Peter Schneider 
---
 phc2sys.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/phc2sys.c b/phc2sys.c
index edbdb85..ad67438 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -1345,7 +1345,7 @@ int main(int argc, char *argv[])
int autocfg = 0, rt = 0;
int c, domain_number = 0, pps_fd = -1;
int r = -1, wait_sync = 0;
-   int print_level = LOG_INFO, use_syslog = 1;
+   int print_level = LOG_INFO;
int ntpshm_segment;
double phc_rate, tmp;
struct node node = {
@@ -1497,7 +1497,9 @@ int main(int argc, char *argv[])
}
break;
case 'q':
-   use_syslog = 0;
+   if (config_set_int(cfg, "use_syslog", 0)) {
+   goto end;
+   }
break;
case 'v':
version_show(stdout);
@@ -1537,7 +1539,7 @@ int main(int argc, char *argv[])
print_set_progname(progname);
print_set_tag(config_get_string(cfg, NULL, "message_tag"));
print_set_verbose(config_get_int(cfg, NULL, "verbose"));
-   print_set_syslog(use_syslog);
+   print_set_syslog(config_get_int(cfg, NULL, "use_syslog"));
print_set_level(config_get_int(cfg, NULL, "logging_level"));
 
if (autocfg) {
-- 
2.14.3


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH v3 09/12] phc2sys.c: Implement configuration file handling

2018-04-07 Thread Peter Schneider
Signed-off-by: Peter Schneider 
---
 phc2sys.c | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/phc2sys.c b/phc2sys.c
index c2e7f70..d4f7f11 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -1313,6 +1313,7 @@ static void usage(char *progname)
" -O [offset]slave-master time offset (0)\n"
" -w wait for ptp4l\n"
" common options:\n"
+   " -f [file]  configuration file\n"
" -E [pi|linreg] clock servo (pi)\n"
" -P [kp]proportional constant (0.7)\n"
" -I [ki]integration constant (0.3)\n"
@@ -1339,6 +1340,7 @@ static void usage(char *progname)
 int main(int argc, char *argv[])
 {
char *progname;
+   char *config = NULL;
char *src_name = NULL, *dst_name = NULL;
struct clock *src, *dst;
struct config *cfg;
@@ -1370,7 +1372,7 @@ int main(int argc, char *argv[])
progname = strrchr(argv[0], '/');
progname = progname ? 1+progname : argv[0];
while (EOF != (c = getopt(argc, argv,
- 
"arc:d:s:E:P:I:S:F:R:N:O:L:M:i:u:wn:xz:l:t:mqvh"))) {
+ 
"arc:d:f:s:E:P:I:S:F:R:N:O:L:M:i:u:wn:xz:l:t:mqvh"))) {
switch (c) {
case 'a':
autocfg = 1;
@@ -1389,6 +1391,9 @@ int main(int argc, char *argv[])
goto end;
}
break;
+   case 'f':
+   config = optarg;
+   break;
case 'i':
fprintf(stderr,
"'-i' has been deprecated. please use '-s' 
instead.\n");
@@ -1520,6 +1525,10 @@ int main(int argc, char *argv[])
}
}
 
+   if (config && (c = config_read(config, cfg))) {
+   return c;
+   }
+
if (autocfg && (src_name || dst_name || pps_fd >= 0 || wait_sync || 
node.forced_sync_offset)) {
fprintf(stderr,
"autoconfiguration cannot be mixed with manual config 
options.\n");
-- 
2.14.3


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH v3 04/12] phc2sys.c: Handling of verbose

2018-04-07 Thread Peter Schneider
Replaced usage of variable 'verbose' with
struct config item 'verbose'. Original variable removed.

Signed-off-by: Peter Schneider 
---
 phc2sys.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/phc2sys.c b/phc2sys.c
index b402575..edbdb85 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -1345,7 +1345,7 @@ int main(int argc, char *argv[])
int autocfg = 0, rt = 0;
int c, domain_number = 0, pps_fd = -1;
int r = -1, wait_sync = 0;
-   int print_level = LOG_INFO, use_syslog = 1, verbose = 0;
+   int print_level = LOG_INFO, use_syslog = 1;
int ntpshm_segment;
double phc_rate, tmp;
struct node node = {
@@ -1492,7 +1492,9 @@ int main(int argc, char *argv[])
}
break;
case 'm':
-   verbose = 1;
+   if (config_set_int(cfg, "verbose", 1)) {
+   goto end;
+   }
break;
case 'q':
use_syslog = 0;
@@ -1534,7 +1536,7 @@ int main(int argc, char *argv[])
 
print_set_progname(progname);
print_set_tag(config_get_string(cfg, NULL, "message_tag"));
-   print_set_verbose(verbose);
+   print_set_verbose(config_get_int(cfg, NULL, "verbose"));
print_set_syslog(use_syslog);
print_set_level(config_get_int(cfg, NULL, "logging_level"));
 
-- 
2.14.3


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH v3 07/12] phc2sys.c: Handling of node.kernel_leap

2018-04-07 Thread Peter Schneider
Use struct config item 'kernel_leap' for
parameter handling. Copy this to node.kernel_leap afterwards. Check for
'servo_type' == CLOCK_SERVO_NTPSHM.

Signed-off-by: Peter Schneider 
---
 phc2sys.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/phc2sys.c b/phc2sys.c
index 5b244b2..0d7a10c 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -1470,7 +1470,9 @@ int main(int argc, char *argv[])
}
break;
case 'x':
-   node.kernel_leap = 0;
+   if (config_set_int(cfg, "kernel_leap", 0)) {
+   goto end;
+   }
break;
case 'z':
if (strlen(optarg) > MAX_IFNAME_SIZE) {
@@ -1544,7 +1546,12 @@ int main(int argc, char *argv[])
print_set_verbose(config_get_int(cfg, NULL, "verbose"));
print_set_syslog(config_get_int(cfg, NULL, "use_syslog"));
print_set_level(config_get_int(cfg, NULL, "logging_level"));
+
node.servo_type = config_get_int(cfg, NULL, "clock_servo");
+   if (node.servo_type == CLOCK_SERVO_NTPSHM) {
+   config_set_int(cfg, "kernel_leap", 0);
+   }
+   node.kernel_leap = config_get_int(cfg, NULL, "kernel_leap");
 
if (autocfg) {
if (init_pmc(cfg, &node))
-- 
2.14.3


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH v3 01/12] phc2sys.c: Handling of domain_number

2018-04-07 Thread Peter Schneider
Replaced usage of variable
'domain_number' with struct config item 'domainNumber'. Original variable
still used for range checking. Removed (now obsolete) third parameter of
init_pmc().

Signed-off-by: Peter Schneider 
---
 phc2sys.c | 13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/phc2sys.c b/phc2sys.c
index 3a82cfe..dc7cb28 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -897,13 +897,14 @@ static void send_subscription(struct node *node)
pmc_send_set_action(node->pmc, TLV_SUBSCRIBE_EVENTS_NP, &sen, 
sizeof(sen));
 }
 
-static int init_pmc(struct config *cfg, struct node *node, int domain_number)
+static int init_pmc(struct config *cfg, struct node *node)
 {
char uds_local[MAX_IFNAME_SIZE + 1];
 
snprintf(uds_local, sizeof(uds_local), "/var/run/phc2sys.%d",
 getpid());
-   node->pmc = pmc_create(cfg, TRANS_UDS, uds_local, 0, domain_number, 0, 
1);
+   node->pmc = pmc_create(cfg, TRANS_UDS, uds_local, 0,
+config_get_int(cfg, NULL, "domainNumber"), 0, 1);
if (!node->pmc) {
pr_err("failed to create pmc");
return -1;
@@ -1460,8 +1461,10 @@ int main(int argc, char *argv[])
wait_sync = 1;
break;
case 'n':
-   if (get_arg_val_i(c, optarg, &domain_number, 0, 255))
+   if (get_arg_val_i(c, optarg, &domain_number, 0, 255) ||
+   config_set_int(cfg, "domainNumber", domain_number)) 
{
goto end;
+   }
break;
case 'x':
node.kernel_leap = 0;
@@ -1532,7 +1535,7 @@ int main(int argc, char *argv[])
print_set_level(print_level);
 
if (autocfg) {
-   if (init_pmc(cfg, &node, domain_number))
+   if (init_pmc(cfg, &node))
goto end;
if (auto_init_ports(&node, rt) < 0)
goto end;
@@ -1568,7 +1571,7 @@ int main(int argc, char *argv[])
r = -1;
 
if (wait_sync) {
-   if (init_pmc(cfg, &node, domain_number))
+   if (init_pmc(cfg, &node))
goto end;
 
while (is_running()) {
-- 
2.14.3


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH v3 08/12] phc2sys.c: Handling of node.sanity_freq_limit

2018-04-07 Thread Peter Schneider
Copy 'node.sanity_freq_limit' to struct
config item 'sanity_freq_limit'. Check for 'servo_type' ==
CLOCK_SERVO_NTPSHM.

Signed-off-by: Peter Schneider 
---
 phc2sys.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/phc2sys.c b/phc2sys.c
index 0d7a10c..c2e7f70 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -1447,7 +1447,8 @@ int main(int argc, char *argv[])
node.forced_sync_offset = -1;
break;
case 'L':
-   if (get_arg_val_i(c, optarg, &node.sanity_freq_limit, 
0, INT_MAX))
+   if (get_arg_val_i(c, optarg, &node.sanity_freq_limit, 
0, INT_MAX) ||
+   config_set_int(cfg, "sanity_freq_limit", 
node.sanity_freq_limit))
goto end;
break;
case 'M':
@@ -1550,8 +1551,10 @@ int main(int argc, char *argv[])
node.servo_type = config_get_int(cfg, NULL, "clock_servo");
if (node.servo_type == CLOCK_SERVO_NTPSHM) {
config_set_int(cfg, "kernel_leap", 0);
+   config_set_int(cfg, "sanity_freq_limit", 0);
}
node.kernel_leap = config_get_int(cfg, NULL, "kernel_leap");
+   node.sanity_freq_limit = config_get_int(cfg, NULL, "sanity_freq_limit");
 
if (autocfg) {
if (init_pmc(cfg, &node))
-- 
2.14.3


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH v3 10/12] phc2sys.c: Implement handling of Long options

2018-04-07 Thread Peter Schneider
Signed-off-by: Peter Schneider 
---
 phc2sys.c | 13 +++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/phc2sys.c b/phc2sys.c
index d4f7f11..1ea0600 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -1344,11 +1344,13 @@ int main(int argc, char *argv[])
char *src_name = NULL, *dst_name = NULL;
struct clock *src, *dst;
struct config *cfg;
+   struct option *opts;
int autocfg = 0, rt = 0;
int c, domain_number = 0, pps_fd = -1;
int r = -1, wait_sync = 0;
int print_level = LOG_INFO;
int ntpshm_segment;
+   int index;
double phc_rate, tmp;
struct node node = {
.sanity_freq_limit = 2,
@@ -1365,15 +1367,22 @@ int main(int argc, char *argv[])
return -1;
}
 
+   opts = config_long_options(cfg);
+
config_set_double(cfg, "pi_proportional_const", KP);
config_set_double(cfg, "pi_integral_const", KI);
 
/* Process the command line arguments. */
progname = strrchr(argv[0], '/');
progname = progname ? 1+progname : argv[0];
-   while (EOF != (c = getopt(argc, argv,
- 
"arc:d:f:s:E:P:I:S:F:R:N:O:L:M:i:u:wn:xz:l:t:mqvh"))) {
+   while (EOF != (c = getopt_long(argc, argv,
+   
"arc:d:f:s:E:P:I:S:F:R:N:O:L:M:i:u:wn:xz:l:t:mqvh",
+   opts, &index))) {
switch (c) {
+   case 0:
+   if (config_parse_option(cfg, opts[index].name, optarg))
+   goto bad_usage;
+   break;
case 'a':
autocfg = 1;
break;
-- 
2.14.3


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH v3 00/12] phc2sys: long-opts/cfg-file/tS

2018-04-07 Thread Peter Schneider
This patch series changes phc2sys. It implements the possibility to use a
configuration file, enables the usage of long options and allows
configuring the transportSpecific value.
In contrast to v2 of this patch series, all (possibly) used options make
use of the config API.

Peter Schneider (12):
  phc2sys.c: Replaced usage of variable 'domain_number' with struct
config item 'domainNumber'. Original variable still used for range
checking. Removed (now obsolete) third parameter of init_pmc().
  phc2sys.c: Replaced usage of variable 'print_level' with struct config
item 'logging_level'. Original variable still used for range
checking.
  phc2sys.c: Replaced usage of variable 'message_tag' with struct config
item 'message_tag'. Original variable removed.
  phc2sys.c: Replaced usage of variable 'verbose' with struct config
item 'verbose'. Original variable removed.
  phc2sys.c: Replaced usage of variable 'use_syslog' with struct config
item 'use_syslog'. Original variable removed.
  phc2sys.c: Use struct config item 'clock_servo' for parameter
handling. Copy this to node.servo_type afterwards.
  phc2sys.c: Use struct config item 'kernel_leap' for parameter
handling. Copy this to node.kernel_leap afterwards. Check for
'servo_type' == CLOCK_SERVO_NTPSHM.
  phc2sys.c: Copy 'node.sanity_freq_limit' to struct config item
'sanity_freq_limit'. Check for 'servo_type' == CLOCK_SERVO_NTPSHM.
  phc2sys.c: Implement configuration file handling
  phc2sys.c: Implement handling of Long options
  phc2sys.c: Implement using transportSpecific value
  phc2sys.8: Doc long opts / cfgfile handling

 phc2sys.8 | 198 +-
 phc2sys.c |  88 +---
 2 files changed, 261 insertions(+), 25 deletions(-)

-- 
2.14.3


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH v3 03/12] phc2sys.c: Handling of message_tag

2018-04-07 Thread Peter Schneider
Replaced usage of variable 'message_tag'
with struct config item 'message_tag'. Original variable removed.

Signed-off-by: Peter Schneider 
---
 phc2sys.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/phc2sys.c b/phc2sys.c
index 7d5edad..b402575 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -1338,7 +1338,7 @@ static void usage(char *progname)
 
 int main(int argc, char *argv[])
 {
-   char *progname, *message_tag = NULL;
+   char *progname;
char *src_name = NULL, *dst_name = NULL;
struct clock *src, *dst;
struct config *cfg;
@@ -1487,7 +1487,9 @@ int main(int argc, char *argv[])
}
break;
case 't':
-   message_tag = optarg;
+   if (config_set_string(cfg, "message_tag", optarg)) {
+   goto end;
+   }
break;
case 'm':
verbose = 1;
@@ -1531,7 +1533,7 @@ int main(int argc, char *argv[])
}
 
print_set_progname(progname);
-   print_set_tag(message_tag);
+   print_set_tag(config_get_string(cfg, NULL, "message_tag"));
print_set_verbose(verbose);
print_set_syslog(use_syslog);
print_set_level(config_get_int(cfg, NULL, "logging_level"));
-- 
2.14.3


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH v3 02/12] phc2sys.c: Handling of print_level

2018-04-07 Thread Peter Schneider
Replaced usage of variable 'print_level'
with struct config item 'logging_level'. Original variable still used for
range checking.

Signed-off-by: Peter Schneider 
---
 phc2sys.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/phc2sys.c b/phc2sys.c
index dc7cb28..7d5edad 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -1481,8 +1481,10 @@ int main(int argc, char *argv[])
break;
case 'l':
if (get_arg_val_i(c, optarg, &print_level,
- PRINT_LEVEL_MIN, PRINT_LEVEL_MAX))
+ PRINT_LEVEL_MIN, PRINT_LEVEL_MAX) ||
+   config_set_int(cfg, "logging_level", print_level)) {
goto end;
+   }
break;
case 't':
message_tag = optarg;
@@ -1532,7 +1534,7 @@ int main(int argc, char *argv[])
print_set_tag(message_tag);
print_set_verbose(verbose);
print_set_syslog(use_syslog);
-   print_set_level(print_level);
+   print_set_level(config_get_int(cfg, NULL, "logging_level"));
 
if (autocfg) {
if (init_pmc(cfg, &node))
-- 
2.14.3


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH v3 11/12] phc2sys.c: Implement using transportSpecific value

2018-04-07 Thread Peter Schneider
Signed-off-by: Peter Schneider 
---
 phc2sys.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/phc2sys.c b/phc2sys.c
index 1ea0600..0d69f2b 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -904,7 +904,8 @@ static int init_pmc(struct config *cfg, struct node *node)
snprintf(uds_local, sizeof(uds_local), "/var/run/phc2sys.%d",
 getpid());
node->pmc = pmc_create(cfg, TRANS_UDS, uds_local, 0,
-config_get_int(cfg, NULL, "domainNumber"), 0, 1);
+config_get_int(cfg, NULL, "domainNumber"),
+config_get_int(cfg, NULL, "transportSpecific") << 4, 
1);
if (!node->pmc) {
pr_err("failed to create pmc");
return -1;
-- 
2.14.3


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH v2 0/4] phc2sys: long-opts/cfg-file/tS

2018-03-23 Thread Peter Schneider
 The first version of this path series had formatting issues. Therefore, I send 
the patches once more, with (hopefully) correct formatting.
 This patch series changes phc2sys. It implements the possibility to use a 
configuration file, enables the usage of long options and allows configuring 
the transportSpecific value.

Peter Schneider (4):
  phc2sys: Implement configuration file handling
  phc2sys: Implement handling of Long options
  phc2sys: Implement using transportSpecific value
  phc2sys: Doc long opts / cfgfile handling

 phc2sys.8 | 103 --
 phc2sys.c |  25 +--
 2 files changed, 123 insertions(+), 5 deletions(-)

-- 
2.14.3


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH v2 1/4] phc2sys: Implement configuration file handling

2018-03-23 Thread Peter Schneider
Signed-off-by: Peter Schneider 
---
 phc2sys.c | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/phc2sys.c b/phc2sys.c
index 5c54055..c2f0d8e 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -1286,6 +1286,7 @@ static void usage(char *progname)
" -O [offset]slave-master time offset (0)\n"
" -w wait for ptp4l\n"
" common options:\n"
+   " -f [file]  configuration file\n"
" -E [pi|linreg] clock servo (pi)\n"
" -P [kp]proportional constant (0.7)\n"
" -I [ki]integration constant (0.3)\n"
@@ -1312,6 +1313,7 @@ static void usage(char *progname)
 int main(int argc, char *argv[])
 {
char *progname, *message_tag = NULL;
+   char *config = NULL;
char *src_name = NULL, *dst_name = NULL;
struct clock *src, *dst;
struct config *cfg;
@@ -1343,7 +1345,7 @@ int main(int argc, char *argv[])
progname = strrchr(argv[0], '/');
progname = progname ? 1+progname : argv[0];
while (EOF != (c = getopt(argc, argv,
- 
"arc:d:s:E:P:I:S:F:R:N:O:L:M:i:u:wn:xz:l:t:mqvh"))) {
+ 
"arc:d:f:s:E:P:I:S:F:R:N:O:L:M:i:u:wn:xz:l:t:mqvh"))) {
switch (c) {
case 'a':
autocfg = 1;
@@ -1362,6 +1364,9 @@ int main(int argc, char *argv[])
goto end;
}
break;
+   case 'f':
+   config = optarg;
+   break;
case 'i':
fprintf(stderr,
"'-i' has been deprecated. please use '-s' 
instead.\n");
@@ -1477,6 +1482,10 @@ int main(int argc, char *argv[])
}
}
 
+   if (config && (c = config_read(config, cfg))) {
+   return c;
+   }
+
if (autocfg && (src_name || dst_name || pps_fd >= 0 || wait_sync || 
node.forced_sync_offset)) {
fprintf(stderr,
"autoconfiguration cannot be mixed with manual config 
options.\n");
-- 
2.14.3


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH v2 3/4] phc2sys: Implement using transportSpecific value

2018-03-23 Thread Peter Schneider
Signed-off-by: Peter Schneider 
---
 phc2sys.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/phc2sys.c b/phc2sys.c
index 278ab56..c6ab788 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -877,7 +877,8 @@ static int init_pmc(struct config *cfg, struct node *node, 
int domain_number)
 
snprintf(uds_local, sizeof(uds_local), "/var/run/phc2sys.%d",
 getpid());
-   node->pmc = pmc_create(cfg, TRANS_UDS, uds_local, 0, domain_number, 0, 
1);
+   node->pmc = pmc_create(cfg, TRANS_UDS, uds_local, 0, domain_number,
+  config_get_int(cfg, NULL, "transportSpecific") 
<< 4, 1);
if (!node->pmc) {
pr_err("failed to create pmc");
return -1;
-- 
2.14.3


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH v2 4/4] phc2sys: Doc long opts / cfgfile handling

2018-03-23 Thread Peter Schneider
Signed-off-by: Peter Schneider 
---
 phc2sys.8 | 103 --
 1 file changed, 101 insertions(+), 2 deletions(-)

diff --git a/phc2sys.8 b/phc2sys.8
index 4fc4fa3..fa2dbc9 100644
--- a/phc2sys.8
+++ b/phc2sys.8
@@ -8,10 +8,16 @@ phc2sys \- synchronize two or more clocks
 .B \-r
 ] [
 .B \-r
-] [ options ]
+] [
+.BI \-f " config-file"
+] [ options ] [
+.I long-options
+]
 .br
 .B phc2sys
 [
+.BI \-f " config-file"
+] [
 .BI \-d " pps-device"
 ] [
 .BI \-s " device"
@@ -21,7 +27,11 @@ phc2sys \- synchronize two or more clocks
 .BI \-O " offset"
 ] [
 .BI \-w
-] [ options ]
+] [ options ] [
+.I long-options
+]
+.I .\|.\|.
+
 
 .SH DESCRIPTION
 .B phc2sys
@@ -226,6 +236,77 @@ Display a help message.
 .B \-v
 Prints the software version and exits.
 
+.SH LONG OPTIONS
+
+Each and every configuration file option (see below in section
+.BR FILE\ OPTIONS)
+may also appear
+as a "long" style command line argument.  For example, the transportSpecific
+option may be set using either of these two forms:
+
+.RS
+\f(CW\-\-transportSpecific 1   \-\-transportSpecific=1\fP
+.RE
+
+Option values given on the command line override values in the global
+section of the configuration file (which, in turn overrides default
+values).
+
+.SH CONFIGURATION FILE
+
+The configuration file is divided into sections. Each section starts with a
+line containing its name enclosed in brackets and it follows with settings.
+Each setting is placed on a separate line, it contains the name of the
+option and the value separated by whitespace characters. Empty lines and lines
+starting with # are ignored.
+
+The global section (indicated as
+.BR [global] )
+sets the program options. This is the only used option.
+
+.SH FILE OPTIONS
+
+.TP
+.B transportSpecific
+The transport specific field. Must be in the range 0 to 255.
+The default is 0.
+
+.TP
+There are more options, which SHOULD be working, but these are untested:
+
+.TP
+.B pi_proportional_const
+Specifies the proportional constant of the PI controller.
+
+.TP
+.B pi_integral_const
+Specifies the integral constant of the PI controller.
+
+.TP
+.B step_threshold
+Specifies the step threshold of the servo. It is the maximum offset that
+the servo corrects by changing the clock frequency instea  of stepping
+the clock. The clock is stepped on start regardless of the option if the
+offset is larger than 20 microseconds (unless the -F option is used).
+It's  specified  in seconds. The value of 0.0 disables stepping after
+the start. The default is 0.0.
+
+.TP
+.B first_step_threshold
+Specify the step threshold applied only on the first update. It is the
+maximum offset that is corrected by adjusting clock. It's specified in
+seconds. The value of 0.0 disables stepping on start. The default is
+0.2 (20 microseconds).
+
+.TP
+.B ntpshm_segment
+The number of the SHM segment used by ntpshm servo.  The default is 0.
+
+.TP
+.B uds_address
+Specifies the address of the server's UNIX domain socket. The default
+is /var/run/ptp4
+
 .SH TIME SCALE USAGE
 
 .B Ptp4l
@@ -269,6 +350,12 @@ in the domain to its system clock.
 \f(CWphc2sys \-a \-rr\fP
 .RE
 
+Same as above, in an IEEE 802.1AS domain.
+
+.RS
+\f(CWphc2sys \-a \-rr --transportSpecific=1\fP
+.RE
+
 The host is a domain master, PTP clock is synchronized to system clock and the
 time offset is obtained from
 .BR ptp4l .
@@ -310,5 +397,17 @@ does not wait.
 \f(CWphc2sys \-s eth0 \-O \-35\fP
 .RE
 
+.SH WARNING
+
+Be cautious when the same configuration file is used for both ptp4l and 
phc2sys.
+Keep in mind, that values specified in the configuration file take precedence
+over their default values. If a certain option, which is common to ptp4l and
+phc2sys, is specified to a non-default value in the configuration file
+(p.e., for ptp4l), then this non-default value applies also for phc2sys. This
+might be not what is expected.
+
+To avoid securely these unexpected behaviour, different configuration files
+for ptp4l and phc2sys are recommended.
+
 .SH SEE ALSO
 .BR ptp4l (8)
-- 
2.14.3


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH v2 2/4] phc2sys: Implement handling of Long options

2018-03-23 Thread Peter Schneider
Signed-off-by: Peter Schneider 
---
 phc2sys.c | 13 +++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/phc2sys.c b/phc2sys.c
index c2f0d8e..278ab56 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -1317,11 +1317,13 @@ int main(int argc, char *argv[])
char *src_name = NULL, *dst_name = NULL;
struct clock *src, *dst;
struct config *cfg;
+   struct option *opts;
int autocfg = 0, rt = 0;
int c, domain_number = 0, pps_fd = -1;
int r = -1, wait_sync = 0;
int print_level = LOG_INFO, use_syslog = 1, verbose = 0;
int ntpshm_segment;
+   int index;
double phc_rate, tmp;
struct node node = {
.sanity_freq_limit = 2,
@@ -1338,15 +1340,22 @@ int main(int argc, char *argv[])
return -1;
}
 
+   opts = config_long_options(cfg);
+
config_set_double(cfg, "pi_proportional_const", KP);
config_set_double(cfg, "pi_integral_const", KI);
 
/* Process the command line arguments. */
progname = strrchr(argv[0], '/');
progname = progname ? 1+progname : argv[0];
-   while (EOF != (c = getopt(argc, argv,
- 
"arc:d:f:s:E:P:I:S:F:R:N:O:L:M:i:u:wn:xz:l:t:mqvh"))) {
+   while (EOF != (c = getopt_long(argc, argv,
+ 
"arc:d:f:s:E:P:I:S:F:R:N:O:L:M:i:u:wn:xz:l:t:mqvh",
+ opts, &index))) {
switch (c) {
+   case 0:
+   if (config_parse_option(cfg, opts[index].name, optarg))
+   goto bad_usage;
+   break;
case 'a':
autocfg = 1;
break;
-- 
2.14.3


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH v2 1/3] pmc_common: Preset uninitialized 'iface.ts_label' with 'iface.name'

2018-03-21 Thread Peter Schneider
pmc_create() calls transport_create(), which sets the open function
for the interface 'iface' to raw_open(), if Layer 2 is used. The
immediate following call of transport_open() calls raw_open(), which
uses the field .ts_label for opening, instead of the field .name
(which is used in the other transport layers). Therefore, the
field .name is copied here into the field .ts_label .

Signed-off-by: Peter Schneider 
---
 pmc_common.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/pmc_common.c b/pmc_common.c
index 91fffb3..850544c 100644
--- a/pmc_common.c
+++ b/pmc_common.c
@@ -93,6 +93,10 @@ struct pmc *pmc_create(struct config *cfg, enum 
transport_type transport_type,
}
 
strncpy(iface.name, iface_name, MAX_IFNAME_SIZE);
+   if (transport_type == TRANS_IEEE_802_3) {
+   strncpy(iface.ts_label, iface_name, MAX_IFNAME_SIZE);
+   }
+
if (transport_open(pmc->transport, &iface,
   &pmc->fdarray, TS_SOFTWARE)) {
pr_err("failed to open transport");
-- 
2.14.3


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH v2 2/3] pmc: add long options and configuration file

2018-03-21 Thread Peter Schneider
Signed-off-by: Peter Schneider 
---
 pmc.c | 61 +
 1 file changed, 53 insertions(+), 8 deletions(-)

diff --git a/pmc.c b/pmc.c
index 7c96a4d..6b16aaf 100644
--- a/pmc.c
+++ b/pmc.c
@@ -679,13 +679,16 @@ static void usage(char *progname)
 int main(int argc, char *argv[])
 {
const char *iface_name = NULL;
+   char *config = NULL;
char *progname;
int c, cnt, length, tmo = -1, batch_mode = 0, zero_datalen = 0;
+   int index;
int ret = 0;
char line[1024], *command = NULL, uds_local[MAX_IFNAME_SIZE + 1];
enum transport_type transport_type = TRANS_UDP_IPV4;
UInteger8 boundary_hops = 1, domain_number = 0, transport_specific = 0;
struct ptp_message *msg;
+   struct option *opts;
struct config *cfg;
 #define N_FD 2
struct pollfd pollfd[N_FD];
@@ -697,28 +700,55 @@ int main(int argc, char *argv[])
return -1;
}
 
+   opts = config_long_options(cfg);
+
/* Process the command line arguments. */
progname = strrchr(argv[0], '/');
progname = progname ? 1+progname : argv[0];
-   while (EOF != (c = getopt(argc, argv, "246u""b:d:hi:s:t:vz"))) {
+   while (EOF != (c = getopt_long(argc, argv, "246u""b:d:f:hi:s:t:vz",
+  opts, &index))) {
switch (c) {
+   case 0:
+   if (config_parse_option(cfg, opts[index].name, optarg)) 
{
+   ret = -1;
+   goto out;
+   }
+   break;
case '2':
-   transport_type = TRANS_IEEE_802_3;
+   if (config_set_int(cfg, "network_transport", 
TRANS_IEEE_802_3)) {
+   ret = -1;
+   goto out;
+   }
break;
case '4':
-   transport_type = TRANS_UDP_IPV4;
+   if (config_set_int(cfg, "network_transport", 
TRANS_UDP_IPV4)) {
+   ret = -1;
+   goto out;
+   }
break;
case '6':
-   transport_type = TRANS_UDP_IPV6;
+   if (config_set_int(cfg, "network_transport", 
TRANS_UDP_IPV6)) {
+   ret = -1;
+   goto out;
+   }
break;
case 'u':
-   transport_type = TRANS_UDS;
+   if (config_set_int(cfg, "network_transport", 
TRANS_UDS)) {
+   ret = -1;
+   goto out;
+   }
break;
case 'b':
boundary_hops = atoi(optarg);
break;
case 'd':
-   domain_number = atoi(optarg);
+   if (config_set_int(cfg, "domainNumber", atoi(optarg))) {
+   ret = -1;
+   goto out;
+   }
+   break;
+   case 'f':
+   config = optarg;
break;
case 'i':
iface_name = optarg;
@@ -736,8 +766,12 @@ int main(int argc, char *argv[])
}
break;
case 't':
-   if (1 == sscanf(optarg, "%x", &c))
-   transport_specific = c << 4;
+   if (1 == sscanf(optarg, "%x", &c)) {
+   if (config_set_int(cfg, "transportSpecific", 
c)) {
+   ret = -1;
+   goto out;
+   }
+   }
break;
case 'v':
version_show(stdout);
@@ -758,6 +792,15 @@ int main(int argc, char *argv[])
}
}
 
+   if (config && (c = config_read(config, cfg))) {
+   config_destroy(cfg);
+   return -1;
+   }
+
+   transport_type = config_get_int(cfg, NULL, "network_transport");
+   transport_specific = config_get_int(cfg, NULL, "transportSpecific") << 
4;
+   domain_number = config_get_int(cfg, NULL, "domainNumber");
+
if (!iface_name) {
if (transport_type == TRANS_UDS) {
snprintf

[Linuxptp-devel] [PATCH v2 3/3] pmc: Documentation for long opts / cfg file

2018-03-21 Thread Peter Schneider
Signed-off-by: Peter Schneider 
---
 pmc.8 | 71 +++
 1 file changed, 71 insertions(+)

diff --git a/pmc.8 b/pmc.8
index b113c78..87a343f 100644
--- a/pmc.8
+++ b/pmc.8
@@ -5,6 +5,8 @@ pmc \- PTP management client
 .SH SYNOPSIS
 .B pmc
 [
+.BI \-f " config-file"
+] [
 .B \-2
 |
 .B \-4
@@ -23,6 +25,8 @@ pmc \- PTP management client
 ] [
 .BI \-t " transport-specific-field"
 ] [
+.I long-options
+] [
 .B \-v
 ] [
 .B \-z
@@ -97,6 +101,61 @@ pmc program normally sends GET requests with properly 
formed TLV
 values. This option enables the legacy option of sending zero
 length TLV values instead.
 
+.SH LONG OPTIONS
+
+Each and every configuration file option (see below in sections
+.BR PROGRAM\ OPTIONS
+and
+.BR PORT\ OPTIONS )
+may also appear
+as a "long" style command line argument. For example, the transportSpecific
+option may be set using either of these two forms:
+
+.RS
+\f(CW\-\-transportSpecific 1   \-\-transportSpecific=1\fP
+.RE
+
+Option values given on the command line override values in the global
+section of the configuration file (which, in turn, overrides default
+values).
+
+.SH CONFIGURATION FILE
+
+The configuration file is divided into sections. Each section starts with a
+line containing its name enclosed in brackets and it follows with settings.
+Each setting is placed on a separate line, it contains the name of the
+option and the value separated by whitespace characters. Empty lines and lines
+starting with # are ignored.
+
+The global section (indicated as
+.BR [global] )
+sets the global program options as well as the default port specific options.
+Other sections are port specific sections and they override the default port
+options. The name of the section is the name of the configured port (e.g.
+.BR [eth0]
+).
+
+.SH PROGRAM OPTIONS
+.TP
+.B domainNumber
+The domain attribute of the local clock. The default is 0.
+
+.SH PORT OPTIONS
+.TP
+.B transportSpecific
+The transport specific field. Must be in the range 0 to 255.
+The default is 0.
+
+.TP
+.B network_transport
+Select the network transport. Possible values are UDPv4, UDPv6 and L2. The 
default
+is UDPv4.
+
+.TP
+.B ptp_dst_mac
+The MAC address to which PTP management messages should be sent. Relevant only 
with L2 transport. The default is 01:1B:19:00:00:00.
+
+
 .SH MANAGEMENT IDS
 
 .TP
@@ -148,5 +207,17 @@ length TLV values instead.
 .TP
 .B VERSION_NUMBER
 
+.SH WARNING
+
+Be cautious when the same configuration file is used for both ptp4l and pmc.
+Keep in mind, that values specified in the configuration file take precedence
+over their default values. If a certain option, which is common to ptp4l and
+pmc, is specified to a non-default value in the configuration file
+(p.e., for ptp4l), then this non-default value applies also for pmc. This
+might be not what is expected.
+
+To avoid securely these unexpected behaviour, different configuration files
+for ptp4l and pmc are recommended.
+
 .SH SEE ALSO
 .BR ptp4l (8)
-- 
2.14.3


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH v2 0/3] pmc: long opts / cfg file

2018-03-21 Thread Peter Schneider
Now trying with git send-email:


Peter Schneider (3):
  pmc_common: Preset uninitialized 'iface.ts_label' with 'iface.name'
  pmc: add long options and configuration file
  pmc: Documentation for long opts / cfg file

 pmc.8| 71 
 pmc.c| 61 ---
 pmc_common.c |  4 
 3 files changed, 128 insertions(+), 8 deletions(-)

-- 
2.14.3


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH 2/3] pmc(2): long opts / cfg file

2018-03-18 Thread Peter Schneider
diff --git a/pmc.c b/pmc.c
index 7c96a4d..6b16aaf 100644
--- a/pmc.c
+++ b/pmc.c
@@ -679,13 +679,16 @@ static void usage(char *progname)
 int main(int argc, char *argv[])
 {
const char *iface_name = NULL;
+   char *config = NULL;
char *progname;
int c, cnt, length, tmo = -1, batch_mode = 0, zero_datalen = 0;
+   int index;
int ret = 0;
char line[1024], *command = NULL, uds_local[MAX_IFNAME_SIZE + 1];
enum transport_type transport_type = TRANS_UDP_IPV4;
UInteger8 boundary_hops = 1, domain_number = 0, transport_specific = 0;
struct ptp_message *msg;
+   struct option *opts;
struct config *cfg;
 #define N_FD 2
struct pollfd pollfd[N_FD];
@@ -697,28 +700,55 @@ int main(int argc, char *argv[])
return -1;
}
 
+   opts = config_long_options(cfg);
+
/* Process the command line arguments. */
progname = strrchr(argv[0], '/');
progname = progname ? 1+progname : argv[0];
-   while (EOF != (c = getopt(argc, argv, "246u""b:d:hi:s:t:vz"))) {
+   while (EOF != (c = getopt_long(argc, argv, "246u""b:d:f:hi:s:t:vz",
+  opts, &index))) {
switch (c) {
+   case 0:
+   if (config_parse_option(cfg, opts[index].name, optarg)) 
{
+   ret = -1;
+   goto out;
+   }
+   break;
case '2':
-   transport_type = TRANS_IEEE_802_3;
+   if (config_set_int(cfg, "network_transport", 
TRANS_IEEE_802_3)) {
+   ret = -1;
+   goto out;
+   }
break;
case '4':
-   transport_type = TRANS_UDP_IPV4;
+   if (config_set_int(cfg, "network_transport", 
TRANS_UDP_IPV4)) {
+   ret = -1;
+   goto out;
+   }
break;
case '6':
-   transport_type = TRANS_UDP_IPV6;
+   if (config_set_int(cfg, "network_transport", 
TRANS_UDP_IPV6)) {
+   ret = -1;
+   goto out;
+   }
break;
case 'u':
-   transport_type = TRANS_UDS;
+   if (config_set_int(cfg, "network_transport", 
TRANS_UDS)) {
+   ret = -1;
+   goto out;
+   }
break;
case 'b':
boundary_hops = atoi(optarg);
break;
case 'd':
-   domain_number = atoi(optarg);
+   if (config_set_int(cfg, "domainNumber", atoi(optarg))) {
+   ret = -1;
+   goto out;
+   }
+   break;
+   case 'f':
+   config = optarg;
break;
case 'i':
iface_name = optarg;
@@ -736,8 +766,12 @@ int main(int argc, char *argv[])
}
break;
case 't':
-   if (1 == sscanf(optarg, "%x", &c))
-   transport_specific = c << 4;
+   if (1 == sscanf(optarg, "%x", &c)) {
+   if (config_set_int(cfg, "transportSpecific", 
c)) {
+   ret = -1;
+   goto out;
+   }
+   }
break;
case 'v':
version_show(stdout);
@@ -758,6 +792,15 @@ int main(int argc, char *argv[])
}
}
 
+   if (config && (c = config_read(config, cfg))) {
+   config_destroy(cfg);
+   return -1;
+   }
+
+   transport_type = config_get_int(cfg, NULL, "network_transport");
+   transport_specific = config_get_int(cfg, NULL, "transportSpecific") << 
4;
+   domain_number = config_get_int(cfg, NULL, "domainNumber");
+
if (!iface_name) {
if (transport_type == TRANS_UDS) {
snprintf(uds_local, sizeof(uds_local),
@@ -855,6 +898,8 @@ int main(int argc, char *argv[])
 
pmc_destroy(pmc);
msg_cleanup();
+
+out:
config_destroy(cfg);
return ret;
 }
-- 
2.14.3

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
__

[Linuxptp-devel] [PATCH 3/3] pmc(2): long opts / cfg file

2018-03-18 Thread Peter Schneider
diff --git a/pmc.8 b/pmc.8
index b113c78..e4cb1e1 100644
--- a/pmc.8
+++ b/pmc.8
@@ -5,6 +5,8 @@ pmc \- PTP management client
 .SH SYNOPSIS
 .B pmc
 [
+.BI \-f " config-file"
+] [
 .B \-2
 |
 .B \-4
@@ -23,6 +25,8 @@ pmc \- PTP management client
 ] [
 .BI \-t " transport-specific-field"
 ] [
+.I long-options
+] [
 .B \-v
 ] [
 .B \-z
@@ -97,6 +101,61 @@ pmc program normally sends GET requests with
properly formed TLV values. This option enables the legacy option of
sending zero length TLV values instead.
 
+.SH LONG OPTIONS
+
+Each and every configuration file option (see below in sections
+.BR PROGRAM\ OPTIONS
+and
+.BR PORT\ OPTIONS )
+may also appear
+as a "long" style command line argument. For example, the
transportSpecific +option may be set using either of these two forms:
+
+.RS
+\f(CW\-\-transportSpecific 1   \-\-transportSpecific=1\fP
+.RE
+
+Option values given on the command line override values in the global
+section of the configuration file (which, in turn, overrides default
+values).
+
+.SH CONFIGURATION FILE
+
+The configuration file is divided into sections. Each section starts
with a +line containing its name enclosed in brackets and it follows
with settings. +Each setting is placed on a separate line, it contains
the name of the +option and the value separated by whitespace
characters. Empty lines and lines +starting with # are ignored.
+
+The global section (indicated as
+.BR [global] )
+sets the global program options as well as the default port specific
options. +Other sections are port specific sections and they override
the default port +options. The name of the section is the name of the
configured port (e.g. +.BR [eth0]
+).
+
+.SH PROGRAM OPTIONS
+.TP
+.B domainNumber
+The domain attribute of the local clock. The default is 0.
+
+.SH PORT OPTIONS
+.TP
+.B transportSpecific
+The transport specific field. Must be in the range 0 to 255.
+The default is 0.
+
+.TP
+.B network_transport
+Select the network transport. Possible values are UDPv4, UDPv6 and L2.
The default +is UDPv4.
+
+.TP
+.B ptp_dst_mac
+The MAC address to which PTP management messages should be sent.
Relevant only with L2 transport. The default is 01:1B:19:00:00:00. +
+
 .SH MANAGEMENT IDS
 
 .TP
@@ -148,5 +207,17 @@ length TLV values instead.
 .TP
 .B VERSION_NUMBER
 
+.SH WARNING
+
+Be cautious when the same configuration file is used for both ptp4l
and pmc. +Keep in mind, that values specified in the configuration file
take precedence +over their default values. If a certain option, which
is common to ptp4l and +pmc, is specified to a non-default value in the
configuration file +(p.e., for ptp4l), then this non-default value
applies also for pmc. This +might be not what is expected.
+
+To avoid securely these unexpected behaviour, different configuration
files +for ptp4l and pmc are recommended.
+
 .SH SEE ALSO
 .BR ptp4l (8)
-- 
2.14.3

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH 0/3] pmc(2): long opts / cfg file

2018-03-18 Thread Peter Schneider
Peter Schneider (3):
  pmc_common: Preset uninitialized 'iface.ts_label' with 'iface.name'
  pmc: add long options and configuration file
  pmc: Documentation for long opts / cfg file

 pmc.8| 71
 
 pmc.c| 61 ---
 pmc_common.c |  4  3 files changed, 128 insertions(+), 8
 deletions(-)

-- 
2.14.3

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


Re: [Linuxptp-devel] [PATCH 1/3] pmc: long opts / cfg file

2018-03-18 Thread Peter Schneider

Am 17.03.2018 um 02:51 schrieb Richard Cochran:


Patch fails to apply.  You sent 8 spaces where there should be tabs.

Please check your mailer/editor/ide settings...
Sorry about this, thunderbird seems to be not friendly to tabs. I'll 
give Claws Mail a try.


Kind Regards,
Peter

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH 1/3] pmc(2): long opts / cfg file

2018-03-18 Thread Peter Schneider
diff --git a/pmc_common.c b/pmc_common.c
index 91fffb3..850544c 100644
--- a/pmc_common.c
+++ b/pmc_common.c
@@ -93,6 +93,10 @@ struct pmc *pmc_create(struct config *cfg, enum 
transport_type transport_type,
}
 
strncpy(iface.name, iface_name, MAX_IFNAME_SIZE);
+   if (transport_type == TRANS_IEEE_802_3) {
+   strncpy(iface.ts_label, iface_name, MAX_IFNAME_SIZE);
+   }
+
if (transport_open(pmc->transport, &iface,
   &pmc->fdarray, TS_SOFTWARE)) {
pr_err("failed to open transport");
-- 
2.14.3

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH 3/3] pmc: long opts / cfg file

2018-03-16 Thread Peter Schneider
pmc: Documentation for long opts / cfg file

Signed-off-by: Peter Schneider 
---
 pmc.8 | 71 +++
 1 file changed, 71 insertions(+)

diff --git a/pmc.8 b/pmc.8
index b113c78..e4cb1e1 100644
--- a/pmc.8
+++ b/pmc.8
@@ -5,6 +5,8 @@ pmc \- PTP management client
 .SH SYNOPSIS
 .B pmc
 [
+.BI \-f " config-file"
+] [
 .B \-2
 |
 .B \-4
@@ -23,6 +25,8 @@ pmc \- PTP management client
 ] [
 .BI \-t " transport-specific-field"
 ] [
+.I long-options
+] [
 .B \-v
 ] [
 .B \-z
@@ -97,6 +101,61 @@ pmc program normally sends GET requests with properly 
formed TLV
 values. This option enables the legacy option of sending zero
 length TLV values instead.

+.SH LONG OPTIONS
+
+Each and every configuration file option (see below in sections
+.BR PROGRAM\ OPTIONS
+and
+.BR PORT\ OPTIONS )
+may also appear
+as a "long" style command line argument. For example, the transportSpecific
+option may be set using either of these two forms:
+
+.RS
+\f(CW\-\-transportSpecific 1   \-\-transportSpecific=1\fP
+.RE
+
+Option values given on the command line override values in the global
+section of the configuration file (which, in turn, overrides default
+values).
+
+.SH CONFIGURATION FILE
+
+The configuration file is divided into sections. Each section starts with a
+line containing its name enclosed in brackets and it follows with settings.
+Each setting is placed on a separate line, it contains the name of the
+option and the value separated by whitespace characters. Empty lines and lines
+starting with # are ignored.
+
+The global section (indicated as
+.BR [global] )
+sets the global program options as well as the default port specific options.
+Other sections are port specific sections and they override the default port
+options. The name of the section is the name of the configured port (e.g.
+.BR [eth0]
+).
+
+.SH PROGRAM OPTIONS
+.TP
+.B domainNumber
+The domain attribute of the local clock. The default is 0.
+
+.SH PORT OPTIONS
+.TP
+.B transportSpecific
+The transport specific field. Must be in the range 0 to 255.
+The default is 0.
+
+.TP
+.B network_transport
+Select the network transport. Possible values are UDPv4, UDPv6 and L2. The 
default
+is UDPv4.
+
+.TP
+.B ptp_dst_mac
+The MAC address to which PTP management messages should be sent. Relevant only 
with L2 transport. The default is
01:1B:19:00:00:00.
+
+
 .SH MANAGEMENT IDS

 .TP
@@ -148,5 +207,17 @@ length TLV values instead.
 .TP
 .B VERSION_NUMBER

+.SH WARNING
+
+Be cautious when the same configuration file is used for both ptp4l and pmc.
+Keep in mind, that values specified in the configuration file take precedence
+over their default values. If a certain option, which is common to ptp4l and
+pmc, is specified to a non-default value in the configuration file
+(p.e., for ptp4l), then this non-default value applies also for pmc. This
+might be not what is expected.
+
+To avoid securely these unexpected behaviour, different configuration files
+for ptp4l and pmc are recommended.
+
 .SH SEE ALSO
 .BR ptp4l (8)
--
2.14.3

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH 2/3] pmc: long opts / cfg file

2018-03-16 Thread Peter Schneider
pmc: add long options and configuration file

Signed-off-by: Peter Schneider 
---
 pmc.c | 61 +
 1 file changed, 53 insertions(+), 8 deletions(-)

diff --git a/pmc.c b/pmc.c
index 7c96a4d..6b16aaf 100644
--- a/pmc.c
+++ b/pmc.c
@@ -679,13 +679,16 @@ static void usage(char *progname)
 int main(int argc, char *argv[])
 {
const char *iface_name = NULL;
+   char *config = NULL;
char *progname;
int c, cnt, length, tmo = -1, batch_mode = 0, zero_datalen = 0;
+   int index;
int ret = 0;
char line[1024], *command = NULL, uds_local[MAX_IFNAME_SIZE + 1];
enum transport_type transport_type = TRANS_UDP_IPV4;
UInteger8 boundary_hops = 1, domain_number = 0, transport_specific = 0;
struct ptp_message *msg;
+   struct option *opts;
struct config *cfg;
 #define N_FD 2
struct pollfd pollfd[N_FD];
@@ -697,28 +700,55 @@ int main(int argc, char *argv[])
return -1;
}

+   opts = config_long_options(cfg);
+
/* Process the command line arguments. */
progname = strrchr(argv[0], '/');
progname = progname ? 1+progname : argv[0];
-   while (EOF != (c = getopt(argc, argv, "246u""b:d:hi:s:t:vz"))) {
+   while (EOF != (c = getopt_long(argc, argv, "246u""b:d:f:hi:s:t:vz",
+  opts, &index))) {
switch (c) {
+   case 0:
+   if (config_parse_option(cfg, opts[index].name, optarg)) 
{
+   ret = -1;
+   goto out;
+   }
+   break;
case '2':
-   transport_type = TRANS_IEEE_802_3;
+   if (config_set_int(cfg, "network_transport", 
TRANS_IEEE_802_3)) {
+   ret = -1;
+   goto out;
+   }
break;
case '4':
-   transport_type = TRANS_UDP_IPV4;
+   if (config_set_int(cfg, "network_transport", 
TRANS_UDP_IPV4)) {
+   ret = -1;
+   goto out;
+   }
break;
case '6':
-   transport_type = TRANS_UDP_IPV6;
+   if (config_set_int(cfg, "network_transport", 
TRANS_UDP_IPV6)) {
+   ret = -1;
+   goto out;
+   }
break;
case 'u':
-   transport_type = TRANS_UDS;
+   if (config_set_int(cfg, "network_transport", 
TRANS_UDS)) {
+   ret = -1;
+   goto out;
+   }
break;
case 'b':
boundary_hops = atoi(optarg);
break;
case 'd':
-   domain_number = atoi(optarg);
+   if (config_set_int(cfg, "domainNumber", atoi(optarg))) {
+   ret = -1;
+   goto out;
+   }
+   break;
+   case 'f':
+   config = optarg;
break;
case 'i':
iface_name = optarg;
@@ -736,8 +766,12 @@ int main(int argc, char *argv[])
}
break;
case 't':
-   if (1 == sscanf(optarg, "%x", &c))
-   transport_specific = c << 4;
+   if (1 == sscanf(optarg, "%x", &c)) {
+   if (config_set_int(cfg, "transportSpecific", 
c)) {
+   ret = -1;
+   goto out;
+   }
+   }
break;
case 'v':
version_show(stdout);
@@ -758,6 +792,15 @@ int main(int argc, char *argv[])
}
}

+   if (config && (c = config_read(config, cfg))) {
+   config_destroy(cfg);
+   return -1;
+   }
+
+   transport_type = config_get_int(cfg, NULL, "network_transport");
+   transport_specific = config_get_int(cfg, NULL, "transportSpecific") << 
4;
+   domain_number = config_get_int(cfg, NULL, "domainNumber");
+
if (!iface_na

[Linuxptp-devel] [PATCH 1/3] pmc: long opts / cfg file

2018-03-16 Thread Peter Schneider
pmc_common: Preset uninitialized 'iface.ts_label' with
 'iface.name'

pmc_create() calls transport_create(), which sets the open function
for the interface 'iface' to raw_open(), if Layer 2 is used. The
immediate following call of transport_open() calls raw_open(), which
uses the field .ts_label for opening, instead of the field .name
(which is used the other transport layers). Therefore, the
field .name is copied here into the field .ts_label

Signed-off-by: Peter Schneider 
---
 pmc_common.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/pmc_common.c b/pmc_common.c
index 91fffb3..850544c 100644
--- a/pmc_common.c
+++ b/pmc_common.c
@@ -93,6 +93,10 @@ struct pmc *pmc_create(struct config *cfg, enum 
transport_type transport_type,
}

strncpy(iface.name, iface_name, MAX_IFNAME_SIZE);
+   if (transport_type == TRANS_IEEE_802_3) {
+   strncpy(iface.ts_label, iface_name, MAX_IFNAME_SIZE);
+   }
+
if (transport_open(pmc->transport, &iface,
   &pmc->fdarray, TS_SOFTWARE)) {
pr_err("failed to open transport");
-- 
2.14.3

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH 0/3] pmc: long opts / cfg file

2018-03-16 Thread Peter Schneider
Peter Schneider (3):
  pmc_common: Preset uninitialized 'iface.ts_label' with 'iface.name'
  pmc: add long options and configuration file
  pmc: Documentation for long opts / cfg file

 pmc.8| 71 
 pmc.c| 61 ---
 pmc_common.c |  4 
 3 files changed, 128 insertions(+), 8 deletions(-)

-- 
2.14.3


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH 4/4] phc2sys: long options / cfg file / transportSpecific

2018-03-14 Thread Peter Schneider
diff --git a/phc2sys.8 b/phc2sys.8
index 4fc4fa3..fa2dbc9 100644
--- a/phc2sys.8
+++ b/phc2sys.8
@@ -8,10 +8,16 @@ phc2sys \- synchronize two or more clocks
 .B \-r
 ] [
 .B \-r
-] [ options ]
+] [
+.BI \-f " config-file"
+] [ options ] [
+.I long-options
+]
 .br
 .B phc2sys
 [
+.BI \-f " config-file"
+] [
 .BI \-d " pps-device"
 ] [
 .BI \-s " device"
@@ -21,7 +27,11 @@ phc2sys \- synchronize two or more clocks
 .BI \-O " offset"
 ] [
 .BI \-w
-] [ options ]
+] [ options ] [
+.I long-options
+]
+.I .\|.\|.
+

 .SH DESCRIPTION
 .B phc2sys
@@ -226,6 +236,77 @@ Display a help message.
 .B \-v
 Prints the software version and exits.

+.SH LONG OPTIONS
+
+Each and every configuration file option (see below in section
+.BR FILE\ OPTIONS)
+may also appear
+as a "long" style command line argument.  For example, the transportSpecific
+option may be set using either of these two forms:
+
+.RS
+\f(CW\-\-transportSpecific 1   \-\-transportSpecific=1\fP
+.RE
+
+Option values given on the command line override values in the global
+section of the configuration file (which, in turn overrides default
+values).
+
+.SH CONFIGURATION FILE
+
+The configuration file is divided into sections. Each section starts with a
+line containing its name enclosed in brackets and it follows with settings.
+Each setting is placed on a separate line, it contains the name of the
+option and the value separated by whitespace characters. Empty lines and lines
+starting with # are ignored.
+
+The global section (indicated as
+.BR [global] )
+sets the program options. This is the only used option.
+
+.SH FILE OPTIONS
+
+.TP
+.B transportSpecific
+The transport specific field. Must be in the range 0 to 255.
+The default is 0.
+
+.TP
+There are more options, which SHOULD be working, but these are untested:
+
+.TP
+.B pi_proportional_const
+Specifies the proportional constant of the PI controller.
+
+.TP
+.B pi_integral_const
+Specifies the integral constant of the PI controller.
+
+.TP
+.B step_threshold
+Specifies the step threshold of the servo. It is the maximum offset that
+the servo corrects by changing the clock frequency instea  of stepping
+the clock. The clock is stepped on start regardless of the option if the
+offset is larger than 20 microseconds (unless the -F option is used).
+It's  specified  in seconds. The value of 0.0 disables stepping after
+the start. The default is 0.0.
+
+.TP
+.B first_step_threshold
+Specify the step threshold applied only on the first update. It is the
+maximum offset that is corrected by adjusting clock. It's specified in
+seconds. The value of 0.0 disables stepping on start. The default is
+0.2 (20 microseconds).
+
+.TP
+.B ntpshm_segment
+The number of the SHM segment used by ntpshm servo.  The default is 0.
+
+.TP
+.B uds_address
+Specifies the address of the server's UNIX domain socket. The default
+is /var/run/ptp4
+
 .SH TIME SCALE USAGE

 .B Ptp4l
@@ -269,6 +350,12 @@ in the domain to its system clock.
 \f(CWphc2sys \-a \-rr\fP
 .RE

+Same as above, in an IEEE 802.1AS domain.
+
+.RS
+\f(CWphc2sys \-a \-rr --transportSpecific=1\fP
+.RE
+
 The host is a domain master, PTP clock is synchronized to system clock and the
 time offset is obtained from
 .BR ptp4l .
@@ -310,5 +397,17 @@ does not wait.
 \f(CWphc2sys \-s eth0 \-O \-35\fP
 .RE

+.SH WARNING
+
+Be cautious when the same configuration file is used for both ptp4l and 
phc2sys.
+Keep in mind, that values specified in the configuration file take precedence
+over their default values. If a certain option, which is common to ptp4l and
+phc2sys, is specified to a non-default value in the configuration file
+(p.e., for ptp4l), then this non-default value applies also for phc2sys. This
+might be not what is expected.
+
+To avoid securely these unexpected behaviour, different configuration files
+for ptp4l and phc2sys are recommended.
+
 .SH SEE ALSO
 .BR ptp4l (8)

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH 3/4] phc2sys: long options / cfg file / transportSpecific

2018-03-14 Thread Peter Schneider
diff --git a/phc2sys.c b/phc2sys.c
index 278ab56..c6ab788 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -877,7 +877,8 @@ static int init_pmc(struct config *cfg, struct node *node, 
int domain_number)

snprintf(uds_local, sizeof(uds_local), "/var/run/phc2sys.%d",
 getpid());
-   node->pmc = pmc_create(cfg, TRANS_UDS, uds_local, 0, domain_number, 0, 
1);
+   node->pmc = pmc_create(cfg, TRANS_UDS, uds_local, 0, domain_number,
+  config_get_int(cfg, NULL, "transportSpecific") 
<< 4, 1);
if (!node->pmc) {
pr_err("failed to create pmc");
return -1;

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH 2/4] phc2sys: long options / cfg file / transportSpecific

2018-03-14 Thread Peter Schneider
diff --git a/phc2sys.c b/phc2sys.c
index c2f0d8e..278ab56 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -1317,11 +1317,13 @@ int main(int argc, char *argv[])
char *src_name = NULL, *dst_name = NULL;
struct clock *src, *dst;
struct config *cfg;
+   struct option *opts;
int autocfg = 0, rt = 0;
int c, domain_number = 0, pps_fd = -1;
int r = -1, wait_sync = 0;
int print_level = LOG_INFO, use_syslog = 1, verbose = 0;
int ntpshm_segment;
+   int index;
double phc_rate, tmp;
struct node node = {
.sanity_freq_limit = 2,
@@ -1338,15 +1340,22 @@ int main(int argc, char *argv[])
return -1;
}

+   opts = config_long_options(cfg);
+
config_set_double(cfg, "pi_proportional_const", KP);
config_set_double(cfg, "pi_integral_const", KI);

/* Process the command line arguments. */
progname = strrchr(argv[0], '/');
progname = progname ? 1+progname : argv[0];
-   while (EOF != (c = getopt(argc, argv,
- 
"arc:d:f:s:E:P:I:S:F:R:N:O:L:M:i:u:wn:xz:l:t:mqvh"))) {
+   while (EOF != (c = getopt_long(argc, argv,
+ 
"arc:d:f:s:E:P:I:S:F:R:N:O:L:M:i:u:wn:xz:l:t:mqvh",
+ opts, &index))) {
switch (c) {
+   case 0:
+   if (config_parse_option(cfg, opts[index].name, optarg))
+   goto bad_usage;
+   break;
case 'a':
autocfg = 1;
break;

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH 1/4] phc2sys: long options / cfg file / transportSpecific

2018-03-14 Thread Peter Schneider
diff --git a/phc2sys.c b/phc2sys.c
index 5c54055..c2f0d8e 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -1286,6 +1286,7 @@ static void usage(char *progname)
" -O [offset]slave-master time offset (0)\n"
" -w wait for ptp4l\n"
" common options:\n"
+   " -f [file]  configuration file\n"
" -E [pi|linreg] clock servo (pi)\n"
" -P [kp]proportional constant (0.7)\n"
" -I [ki]integration constant (0.3)\n"
@@ -1312,6 +1313,7 @@ static void usage(char *progname)
 int main(int argc, char *argv[])
 {
char *progname, *message_tag = NULL;
+   char *config = NULL;
char *src_name = NULL, *dst_name = NULL;
struct clock *src, *dst;
struct config *cfg;
@@ -1343,7 +1345,7 @@ int main(int argc, char *argv[])
progname = strrchr(argv[0], '/');
progname = progname ? 1+progname : argv[0];
while (EOF != (c = getopt(argc, argv,
- 
"arc:d:s:E:P:I:S:F:R:N:O:L:M:i:u:wn:xz:l:t:mqvh"))) {
+ 
"arc:d:f:s:E:P:I:S:F:R:N:O:L:M:i:u:wn:xz:l:t:mqvh"))) {
switch (c) {
case 'a':
autocfg = 1;
@@ -1362,6 +1364,9 @@ int main(int argc, char *argv[])
goto end;
}
break;
+   case 'f':
+   config = optarg;
+   break;
case 'i':
fprintf(stderr,
"'-i' has been deprecated. please use '-s' 
instead.\n");
@@ -1477,6 +1482,10 @@ int main(int argc, char *argv[])
}
}

+   if (config && (c = config_read(config, cfg))) {
+   return c;
+   }
+
if (autocfg && (src_name || dst_name || pps_fd >= 0 || wait_sync || 
node.forced_sync_offset)) {
fprintf(stderr,
"autoconfiguration cannot be mixed with manual config 
options.\n");

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH 0/4] phc2sys: long options / cfg file / transportSpecific

2018-03-14 Thread Peter Schneider
As promised, this is a set of patches to enable long options,
specifying a configuration file, and specifying the transportSpecific
value.

Patch 1:Enable configuration file on command line
Patch 2:Enable long options
Patch 3:Add transportSpecific functionality
Patch 4:Documentation

Only specifying the 'transportSpecific' value is tested. Some other long
 options from cfg-file should work out of the box, but these are
untested (mentioned in the man page, Patch 4/4).
I did neither add new elements to the option list nor changes to add
other commandline parameters to the existing options (like, p.e.,
domainNumber)
Kind Regards,
Peter

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


Re: [Linuxptp-devel] [PATCH 4/5] phc2sys: long options / cfg file / transportSpecific

2018-03-14 Thread Peter Schneider
Am 14.03.2018 um 14:25 schrieb Anders Selhammer:

> ... 
> Why not get transportSpecific from cfg inside init_pmc() instead. Then you do 
> not need to declare transport_specific in main and no need to add extra in 
> parameter to init_pmc()

Yes, you're right. This would completely void Patch 1/5 and a change in Patch 
(old) 4/5. I will provide a reduced set of
patches.

Kind Regards,
Peter


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH 5/5] phc2sys: long options / cfg file / transportSpecific

2018-03-14 Thread Peter Schneider
diff --git a/phc2sys.8 b/phc2sys.8
index 4fc4fa3..fa2dbc9 100644
--- a/phc2sys.8
+++ b/phc2sys.8
@@ -8,10 +8,16 @@ phc2sys \- synchronize two or more clocks
 .B \-r
 ] [
 .B \-r
-] [ options ]
+] [
+.BI \-f " config-file"
+] [ options ] [
+.I long-options
+]
 .br
 .B phc2sys
 [
+.BI \-f " config-file"
+] [
 .BI \-d " pps-device"
 ] [
 .BI \-s " device"
@@ -21,7 +27,11 @@ phc2sys \- synchronize two or more clocks
 .BI \-O " offset"
 ] [
 .BI \-w
-] [ options ]
+] [ options ] [
+.I long-options
+]
+.I .\|.\|.
+

 .SH DESCRIPTION
 .B phc2sys
@@ -226,6 +236,77 @@ Display a help message.
 .B \-v
 Prints the software version and exits.

+.SH LONG OPTIONS
+
+Each and every configuration file option (see below in section
+.BR FILE\ OPTIONS)
+may also appear
+as a "long" style command line argument.  For example, the transportSpecific
+option may be set using either of these two forms:
+
+.RS
+\f(CW\-\-transportSpecific 1   \-\-transportSpecific=1\fP
+.RE
+
+Option values given on the command line override values in the global
+section of the configuration file (which, in turn overrides default
+values).
+
+.SH CONFIGURATION FILE
+
+The configuration file is divided into sections. Each section starts with a
+line containing its name enclosed in brackets and it follows with settings.
+Each setting is placed on a separate line, it contains the name of the
+option and the value separated by whitespace characters. Empty lines and lines
+starting with # are ignored.
+
+The global section (indicated as
+.BR [global] )
+sets the program options. This is the only used option.
+
+.SH FILE OPTIONS
+
+.TP
+.B transportSpecific
+The transport specific field. Must be in the range 0 to 255.
+The default is 0.
+
+.TP
+There are more options, which SHOULD be working, but these are untested:
+
+.TP
+.B pi_proportional_const
+Specifies the proportional constant of the PI controller.
+
+.TP
+.B pi_integral_const
+Specifies the integral constant of the PI controller.
+
+.TP
+.B step_threshold
+Specifies the step threshold of the servo. It is the maximum offset that
+the servo corrects by changing the clock frequency instea  of stepping
+the clock. The clock is stepped on start regardless of the option if the
+offset is larger than 20 microseconds (unless the -F option is used).
+It's  specified  in seconds. The value of 0.0 disables stepping after
+the start. The default is 0.0.
+
+.TP
+.B first_step_threshold
+Specify the step threshold applied only on the first update. It is the
+maximum offset that is corrected by adjusting clock. It's specified in
+seconds. The value of 0.0 disables stepping on start. The default is
+0.2 (20 microseconds).
+
+.TP
+.B ntpshm_segment
+The number of the SHM segment used by ntpshm servo.  The default is 0.
+
+.TP
+.B uds_address
+Specifies the address of the server's UNIX domain socket. The default
+is /var/run/ptp4
+
 .SH TIME SCALE USAGE

 .B Ptp4l
@@ -269,6 +350,12 @@ in the domain to its system clock.
 \f(CWphc2sys \-a \-rr\fP
 .RE

+Same as above, in an IEEE 802.1AS domain.
+
+.RS
+\f(CWphc2sys \-a \-rr --transportSpecific=1\fP
+.RE
+
 The host is a domain master, PTP clock is synchronized to system clock and the
 time offset is obtained from
 .BR ptp4l .
@@ -310,5 +397,17 @@ does not wait.
 \f(CWphc2sys \-s eth0 \-O \-35\fP
 .RE

+.SH WARNING
+
+Be cautious when the same configuration file is used for both ptp4l and 
phc2sys.
+Keep in mind, that values specified in the configuration file take precedence
+over their default values. If a certain option, which is common to ptp4l and
+phc2sys, is specified to a non-default value in the configuration file
+(p.e., for ptp4l), then this non-default value applies also for phc2sys. This
+might be not what is expected.
+
+To avoid securely these unexpected behaviour, different configuration files
+for ptp4l and phc2sys are recommended.
+
 .SH SEE ALSO
 .BR ptp4l (8)

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH 4/5] phc2sys: long options / cfg file / transportSpecific

2018-03-14 Thread Peter Schneider
diff --git a/phc2sys.c b/phc2sys.c
index 666ec0b..a9a72ff 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -1526,6 +1526,8 @@ int main(int argc, char *argv[])
print_set_syslog(use_syslog);
print_set_level(print_level);

+   transport_specific = config_get_int(cfg, NULL, "transportSpecific") << 
4;
+
if (autocfg) {
if (init_pmc(cfg, &node, domain_number, transport_specific))
goto end;

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH 3/5] phc2sys: long options / cfg file / transportSpecific

2018-03-14 Thread Peter Schneider
diff --git a/phc2sys.c b/phc2sys.c
index a62d177..666ec0b 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -1319,12 +1319,14 @@ int main(int argc, char *argv[])
char *src_name = NULL, *dst_name = NULL;
struct clock *src, *dst;
struct config *cfg;
+   struct option *opts;
int autocfg = 0, rt = 0;
int c, domain_number = 0, pps_fd = -1;
int r = -1, wait_sync = 0;
int print_level = LOG_INFO, use_syslog = 1, verbose = 0;
int ntpshm_segment;
int transport_specific = 0;
+   int index;
double phc_rate, tmp;
struct node node = {
.sanity_freq_limit = 2,
@@ -1341,15 +1343,22 @@ int main(int argc, char *argv[])
return -1;
}

+   opts = config_long_options(cfg);
+
config_set_double(cfg, "pi_proportional_const", KP);
config_set_double(cfg, "pi_integral_const", KI);

/* Process the command line arguments. */
progname = strrchr(argv[0], '/');
progname = progname ? 1+progname : argv[0];
-   while (EOF != (c = getopt(argc, argv,
- 
"arc:d:f:s:E:P:I:S:F:R:N:O:L:M:i:u:wn:xz:l:t:mqvh"))) {
+   while (EOF != (c = getopt_long(argc, argv,
+ 
"arc:d:f:s:E:P:I:S:F:R:N:O:L:M:i:u:wn:xz:l:t:mqvh",
+ opts, &index))) {
switch (c) {
+   case 0:
+   if (config_parse_option(cfg, opts[index].name, optarg))
+   goto bad_usage;
+   break;
case 'a':
autocfg = 1;
break;

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH 2/5] phc2sys: long options / cfg file / transportSpecific

2018-03-14 Thread Peter Schneider
diff --git a/phc2sys.c b/phc2sys.c
index 61ae7b0..a62d177 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -1288,6 +1288,7 @@ static void usage(char *progname)
" -O [offset]slave-master time offset (0)\n"
" -w wait for ptp4l\n"
" common options:\n"
+   " -f [file]  configuration file\n"
" -E [pi|linreg] clock servo (pi)\n"
" -P [kp]proportional constant (0.7)\n"
" -I [ki]integration constant (0.3)\n"
@@ -1314,6 +1315,7 @@ static void usage(char *progname)
 int main(int argc, char *argv[])
 {
char *progname, *message_tag = NULL;
+   char *config = NULL;
char *src_name = NULL, *dst_name = NULL;
struct clock *src, *dst;
struct config *cfg;
@@ -1346,7 +1348,7 @@ int main(int argc, char *argv[])
progname = strrchr(argv[0], '/');
progname = progname ? 1+progname : argv[0];
while (EOF != (c = getopt(argc, argv,
- 
"arc:d:s:E:P:I:S:F:R:N:O:L:M:i:u:wn:xz:l:t:mqvh"))) {
+ 
"arc:d:f:s:E:P:I:S:F:R:N:O:L:M:i:u:wn:xz:l:t:mqvh"))) {
switch (c) {
case 'a':
autocfg = 1;
@@ -1365,6 +1367,9 @@ int main(int argc, char *argv[])
goto end;
}
break;
+   case 'f':
+   config = optarg;
+   break;
case 'i':
fprintf(stderr,
"'-i' has been deprecated. please use '-s' 
instead.\n");
@@ -1480,6 +1485,10 @@ int main(int argc, char *argv[])
}
}

+   if (config && (c = config_read(config, cfg))) {
+   return c;
+   }
+
if (autocfg && (src_name || dst_name || pps_fd >= 0 || wait_sync || 
node.forced_sync_offset)) {
fprintf(stderr,
"autoconfiguration cannot be mixed with manual config 
options.\n");

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH 1/5] phc2sys: long options / cfg file / transportSpecific

2018-03-14 Thread Peter Schneider
diff --git a/phc2sys.c b/phc2sys.c
index 5c54055..61ae7b0 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -871,13 +871,15 @@ static void send_subscription(struct node *node)
pmc_send_set_action(node->pmc, TLV_SUBSCRIBE_EVENTS_NP, &sen, 
sizeof(sen));
 }

-static int init_pmc(struct config *cfg, struct node *node, int domain_number)
+static int init_pmc(struct config *cfg, struct node *node, int domain_number,
+   int transport_specific)
 {
char uds_local[MAX_IFNAME_SIZE + 1];

snprintf(uds_local, sizeof(uds_local), "/var/run/phc2sys.%d",
 getpid());
-   node->pmc = pmc_create(cfg, TRANS_UDS, uds_local, 0, domain_number, 0, 
1);
+   node->pmc = pmc_create(cfg, TRANS_UDS, uds_local, 0, domain_number,
+  transport_specific, 1);
if (!node->pmc) {
pr_err("failed to create pmc");
return -1;
@@ -1320,6 +1322,7 @@ int main(int argc, char *argv[])
int r = -1, wait_sync = 0;
int print_level = LOG_INFO, use_syslog = 1, verbose = 0;
int ntpshm_segment;
+   int transport_specific = 0;
double phc_rate, tmp;
struct node node = {
.sanity_freq_limit = 2,
@@ -1506,7 +1509,7 @@ int main(int argc, char *argv[])
print_set_level(print_level);

if (autocfg) {
-   if (init_pmc(cfg, &node, domain_number))
+   if (init_pmc(cfg, &node, domain_number, transport_specific))
goto end;
if (auto_init_ports(&node, rt) < 0)
goto end;
@@ -1542,7 +1545,7 @@ int main(int argc, char *argv[])
r = -1;

if (wait_sync) {
-   if (init_pmc(cfg, &node, domain_number))
+   if (init_pmc(cfg, &node, domain_number, transport_specific))
goto end;

while (is_running()) {

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH 0/5] phc2sys: long options / cfg file / transportSpecific

2018-03-14 Thread Peter Schneider
As promised, this is a set of patches to enable long options, a
specifying a configuration filele, and specifying the transportSpecific
value.

Patch 1:Add transportSpecific as parameter to init_pmc()
Patch 2:Enable configuration file on command line
Patch 3:Enable long options
Patch 4:Add transportSpecific functionality
Patch 5:Documentation

Only specifying the 'transportSpecific' value is tested. Some other long
 options from cfg-file should work out of the box, but these are
untested (mentioned in the man page, Patch 5.
I did neither add new elements to the option list nor changes to add
other commandline parameters to the existing options (like, p.e.,
domainNumber)
Kind Regards,
Peter

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


Re: [Linuxptp-devel] [PATCH 0/3] transportSpecific / 802.1AS

2018-03-12 Thread Peter Schneider

Am 12.03.2018 um 16:15 schrieb Richard Cochran:


...
Instead, we do want this:

$ cat > my.cfg
[global]
transportSpecific 1
^d

phc2sys -f my.cfg

and also long options:

phc2sys --transportSpecific=1


OK, I will change it according to this. Should be done within a day.



And the pmc program needs the same kind of change.


Also. In the worst case, it might take another day.

Kind Regards,
Peter

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH 3/3] transportSpecific / 802.1AS

2018-03-12 Thread Peter Schneider

diff --git a/phc2sys.8 b/phc2sys.8
index 4fc4fa3..d66284b 100644
--- a/phc2sys.8
+++ b/phc2sys.8
@@ -20,6 +20,8 @@ phc2sys \- synchronize two or more clocks
 ] [
 .BI \-O " offset"
 ] [
+.BI \-T " transport-specific-field"
+] [
 .BI \-w
 ] [ options ]

@@ -225,6 +227,11 @@ Display a help message.
 .TP
 .B \-v
 Prints the software version and exits.
+.TP
+.BI \-T " transport-specific-field"
+Specify the transport specific field in sent messages as a hexadecimal 
number.

+The default is 0x0.
+

 .SH TIME SCALE USAGE

diff --git a/phc2sys.c b/phc2sys.c
index 0ec1ea7..0efc89d 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -1304,6 +1304,7 @@ static void usage(char *progname)
" -z [path]  server address for UDS (/var/run/ptp4l)\n"
" -l [num]   set the logging level to 'num' (6)\n"
" -t [tag]   add tag to log messages\n"
+   " -T [0/1]   set transport specific value to 'num' 
(0)\n"

" -m print messages to stdout\n"
" -q do not print messages to the syslog\n"
" -v prints the software version and exits\n"

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH 2/3] transportSpecific / 802.1AS

2018-03-12 Thread Peter Schneider

diff --git a/phc2sys.c b/phc2sys.c
index 8f740c4..0ec1ea7 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -871,13 +871,16 @@ static void send_subscription(struct node *node)
pmc_send_set_action(node->pmc, TLV_SUBSCRIBE_EVENTS_NP, &sen, 
sizeof(sen));

 }

-static int init_pmc(struct config *cfg, struct node *node, int 
domain_number)
+static int init_pmc(struct config *cfg, struct node *node, int 
domain_number,

+   int transport_specific)
 {
char uds_local[MAX_IFNAME_SIZE + 1];

snprintf(uds_local, sizeof(uds_local), "/var/run/phc2sys.%d",
 getpid());
-   node->pmc = pmc_create(cfg, TRANS_UDS, uds_local, 0, 
domain_number, 0, 1);

+   node->pmc = pmc_create(cfg, TRANS_UDS, uds_local, 0, domain_number,
+  transport_specific, 1);
+
if (!node->pmc) {
pr_err("failed to create pmc");
return -1;
@@ -1511,7 +1514,7 @@ int main(int argc, char *argv[])
print_set_level(print_level);

if (autocfg) {
-   if (init_pmc(cfg, &node, domain_number))
+   if (init_pmc(cfg, &node, domain_number, transport_specific))
goto end;
if (auto_init_ports(&node, rt) < 0)
goto end;
@@ -1547,7 +1550,7 @@ int main(int argc, char *argv[])
r = -1;

if (wait_sync) {
-   if (init_pmc(cfg, &node, domain_number))
+   if (init_pmc(cfg, &node, domain_number, transport_specific))
goto end;

while (is_running()) {

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH 1/3] transportSpecific / 802.1AS

2018-03-12 Thread Peter Schneider

diff --git a/phc2sys.c b/phc2sys.c
index 5c54055..8f740c4 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -1317,6 +1317,7 @@ int main(int argc, char *argv[])
struct config *cfg;
int autocfg = 0, rt = 0;
int c, domain_number = 0, pps_fd = -1;
+   int transport_specific = 0;
int r = -1, wait_sync = 0;
int print_level = LOG_INFO, use_syslog = 1, verbose = 0;
int ntpshm_segment;
@@ -1343,7 +1344,7 @@ int main(int argc, char *argv[])
progname = strrchr(argv[0], '/');
progname = progname ? 1+progname : argv[0];
while (EOF != (c = getopt(argc, argv,
- 
"arc:d:s:E:P:I:S:F:R:N:O:L:M:i:u:wn:xz:l:t:mqvh"))) {
+ 
"arc:d:s:E:P:I:S:F:R:N:O:L:M:i:u:wn:xz:l:t:mqvhT:"))) {

switch (c) {
case 'a':
autocfg = 1;
@@ -1472,6 +1473,10 @@ int main(int argc, char *argv[])
usage(progname);
config_destroy(cfg);
return 0;
+   case 'T':
+   if (1 == sscanf(optarg, "%x", &c))
+   transport_specific = c << 4;
+   break;
default:
goto bad_usage;
}


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH 0/3] transportSpecific / 802.1AS

2018-03-12 Thread Peter Schneider
As promised, this is a set of patches to enable specifying the 
transportSpecific value via commandline.


Patch 1:add cmdline parameter for 'transportSpecific'
Patch 2:apply parameter 'transportSpecific'
Patch 3:Documentation

Kind Regards,
Peter

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


Re: [Linuxptp-devel] Planning release 1.9

2018-03-10 Thread Peter Schneider

Hi,

Am 10.03.2018 um 17:18 schrieb Richard Cochran:

...
I have reconsidered this, and actually these two changes would be nice
to have in the release.  Other people have complained out this too.
We can wait with the release.  Would you care to submit patches?


I will provide both patches on Monday. As I mentioned before, during 
this weekend I have no access to my sources.


Kind Regards,
Peter


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


Re: [Linuxptp-devel] Planning release 1.9

2018-03-09 Thread Peter Schneider

Hi all,

Am 08.03.2018 um 17:37 schrieb Richard Cochran:

...
Now it is time to cut the 1.9 release.  If you know of any outstanding
bugs or issues, please report them right away!


I have two issues, both concerning 802.1AS:
1) ph2c2sys uses in "autodetect" (-a -r) or "wait for ptp4l" (-w) mode 
pmc-functionality to do his job. Unfortunately, the constant value "0" 
is used for the transportSpecific parameter, which is wrong for 802.1AS, 
and thus avoids using these modes successfully in phc2sys.
I added an optional parameter to phc2sys ("-T 1"), which passes the 
802.1AS conformant value to the used pmc-functionality to make phc2sys 
work correct for 802.1AS.
Unfortunately, I have no access to my code during this weekend, so I can 
provide the patch not before Monday. It is only a good handfull of code 
and another handfull for the docs.


2) When using layer 2 for management via pmc command, the management 
PDUs are sent to further devices via the multicast address 
01:1B:19:00:00:00, which doesn't work for 802.1AS.
I made a quick solution which isn't usable publicly this way, but works 
for me: I read in and use a config file (to be precise: the very same 
which I use for ptp4l). Might be made more general usable by respecting 
the priority of command line parameters.
Another solution would be to pass a parameter down to the function 
pmc_send() to make this function use transport_peer() instead of 
transport_send(), but this would mess up a big bunch of code, so this 
isn't a real option. The smoothiest way might be to change the 
config_tab[] on the fly. Any suggestions what might be the best?



...
In one week's time I'll push v1.9 out the door.


Would be nice, if my first issue would make it into 1.9 . For the second 
issue, I don't see a realistic chance to provide a solid solution in time.


Kind Regards,
Peter

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel