> -----Original Message-----
> From: Rodney Greenstreet [mailto:[email protected]]
> Sent: Thursday, August 03, 2017 2:22 PM
> To: [email protected]
> Cc: Rodney Greenstreet <[email protected]>
> Subject: [Linuxptp-devel] [PATCH 1/6] This patch adds a new flag '-t' that
> enables
> transparent clock mode. When active, the clock will be created as an E2E or
> P2P
> TC, depending on the configured delay mechanism.
>
> Signed-off-by: Richard Cochran <[email protected]>
> ---
> ptp4l.c | 39 +++++++++++++++++++++++++++++++++++----
> 1 file changed, 35 insertions(+), 4 deletions(-)
>
> diff --git a/ptp4l.c b/ptp4l.c
> index f01ff6f..8a1dd4b 100644
> --- a/ptp4l.c
> +++ b/ptp4l.c
> @@ -1,6 +1,6 @@
> /**
> * @file ptp4l.c
> - * @brief PTP Boundary Clock main program
> + * @brief PTP Boundary Clock or Transparent Clock main program
> * @note Copyright (C) 2011 Richard Cochran <[email protected]>
> *
> * This program is free software; you can redistribute it and/or modify
> @@ -61,6 +61,7 @@ static void usage(char *progname)
> " -p [dev] PTP hardware clock device to use, default auto\n"
> " (ignored for SOFTWARE/LEGACY HW time stamping)\n"
> " -s slave only mode (overrides configuration file)\n"
> + " -t transparent clock\n"
This should have a configuration option. I'm not convinced it deserves a lower
case letter, but it definitely should be a configure option.
> " -l [num] set the logging level to 'num'\n"
> " -m print messages to stdout\n"
> " -q do not print messages to the syslog\n"
> @@ -73,6 +74,7 @@ static void usage(char *progname)
> int main(int argc, char *argv[])
> {
> char *config = NULL, *req_phc = NULL, *progname;
> + enum clock_type type = CLOCK_TYPE_ORDINARY;
> int c, err = -1, index, print_level;
> struct clock *clock = NULL;
> struct option *opts;
> @@ -90,7 +92,7 @@ int main(int argc, char *argv[])
> /* Process the command line arguments. */
> progname = strrchr(argv[0], '/');
> progname = progname ? 1+progname : argv[0];
> - while (EOF != (c = getopt_long(argc, argv, "AEP246HSLf:i:p:sl:mqvh",
> + while (EOF != (c = getopt_long(argc, argv, "AEP246HSLf:i:p:stl:mqvh",
> opts, &index))) {
> switch (c) {
> case 0:
> @@ -151,6 +153,9 @@ int main(int argc, char *argv[])
> goto out;
> }
> break;
> + case 't':
> + type = CLOCK_TYPE_E2E;
This should probably be called: CLOCK_TYPE_TRANSPARENT.
> + break;
> case 'l':
> if (get_arg_val_i(c, optarg, &print_level,
> PRINT_LEVEL_MIN, PRINT_LEVEL_MAX))
> @@ -203,8 +208,34 @@ int main(int argc, char *argv[])
> goto out;
> }
>
> - clock = clock_create(cfg->n_interfaces > 1 ? CLOCK_TYPE_BOUNDARY :
> - CLOCK_TYPE_ORDINARY, cfg, req_phc);
> + switch (type) {
> + case CLOCK_TYPE_ORDINARY:
> + case CLOCK_TYPE_BOUNDARY:
> + if (cfg->n_interfaces > 1) {
> + type = CLOCK_TYPE_BOUNDARY;
> + }
> + break;
> + case CLOCK_TYPE_P2P:
I don't think CLOCK_TYPE_P2P and CLOCK_TYPE_E2E need to exist. Just use
CLOCK_TYPE_TRANSPARENT. Anywhere that you check the CLOCK_TYPE_E2E, check for
CLOCK_TYPE_TRANSPARENT and then check for whether it's DM_E2E or DM_P2P?
Hmm. If you must separate them this early, call them CLOCK_TYPE_TRANSPARENT_P2P
and CLOCK_TYPE_TRANSPARENT_E2E
> + case CLOCK_TYPE_E2E:
> + if (cfg->n_interfaces < 2) {
> + fprintf(stderr, "TC needs at least two interfaces\n");
> + goto out;
> + }
> + switch (config_get_int(cfg, NULL, "delay_mechanism")) {
> + case DM_AUTO:
> + case DM_E2E:
> + type = CLOCK_TYPE_E2E;
> + break;
> + case DM_P2P:
> + type = CLOCK_TYPE_P2P;
> + break;
> + }
> + break;
> + case CLOCK_TYPE_MANAGEMENT:
> + goto out;
> + }
> +
> + clock = clock_create(type, cfg, req_phc);
> if (!clock) {
> fprintf(stderr, "failed to create a clock\n");
> goto out;
> --
> 2.13.0
>
>
> ------------------------------------------------------------------------------
> 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
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/linuxptp-devel
------------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel