Commit 9191fe87 authored by Alessandro Rubini's avatar Alessandro Rubini

arch-wrpc (and doc): finally fix the clock class

This sets the clock class in arch-wrpc in a way more aligned to the
standard. A grandmaster is 6 if locked to atomic or gps, but
52 if it is designated grandmaster but doesn't lock to a primary source
(this is was we poor developers experience).  A "master" is 187,
the old default, and a slave-only remains 255 as it has always been.

This also removes the ability to stop the program while it waits
for the pll to lock. It can only succeed or timeout.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 68ad6479
......@@ -82,7 +82,7 @@ int wrc_ptp_set_mode(int mode)
struct pp_instance *ppi = &ppi_static;
struct pp_globals *ppg = ppi->glbs;
typeof(ppg->rt_opts->clock_quality.clockClass) *class_ptr;
int error = 0;
/*
* We need to change the class in the default options.
* Unfortunately, ppg->rt_opts may be yet unassigned when this runs
......@@ -107,7 +107,7 @@ int wrc_ptp_set_mode(int mode)
WR_DSPOR(ppi)->wrConfig = WR_M_ONLY;
ppi->master_only = TRUE;
ppi->slave_only = FALSE;
*class_ptr = PP_CLASS_WR_GM_UNLOCKED;
*class_ptr = PP_CLASS_DEFAULT;
spll_init(SPLL_MODE_FREE_RUNNING_MASTER, 0, 1);
lock_timeout = LOCK_TIMEOUT_FM;
break;
......@@ -128,22 +128,25 @@ int wrc_ptp_set_mode(int mode)
while (!spll_check_lock(0) && lock_timeout) {
timer_delay(TICS_PER_SECOND);
pp_printf(".");
if (timer_get_tics() - start_tics > lock_timeout) {
pp_printf("\nLock timeout.\n");
return -ETIMEDOUT;
} else if (uart_read_byte() == 27) {
pp_printf("\n");
return -EINTR;
pp_printf("\nLock timeout.");
error = -ETIMEDOUT;
break;
}
pp_printf(".");
}
pp_printf("\n");
/* If we can't lock to the atomic/gps, we say it in the class */
if (error && mode == WRC_MODE_GM)
*class_ptr = PP_CLASS_WR_GM_UNLOCKED;
/* Success or failure, we enable pps */
if (mode == WRC_MODE_MASTER || mode == WRC_MODE_GM)
shw_pps_gen_enable_output(1);
ptp_mode = mode;
return 0;
return error;
}
int wrc_ptp_get_mode()
......
......@@ -35,7 +35,7 @@
@setchapternewpage off
@set update-month September 2013
@set update-month October 2013
@finalout
......@@ -381,12 +381,12 @@ enable frame diagnostics for a specific port, you can use:
./ppsi -f /etc/ppsi.conf -C "port eth1; diagnostics 02"
@end smallexample
Each configuration item is made up of a keywork and an optional
Each configuration item is made up of a keyword and an optional
argument. The argument can be either a number or a string. The
parser looks up keywords in three tables: a global table, an
architecture-specific table and an extension-specific table.
Currently not architectures or extensions provide configuration
Currently no architectures or extensions provide configuration
keywords, while the list of global items is on show in @t{lib/conf.c},
as the @t{pp_global_arglines} array. Future versions of this manual
may document the keywords, if the time allows it.
......@@ -395,6 +395,26 @@ may document the keywords, if the time allows it.
configuration options. This applies to the priorities, intervals and
thresholds, as well as the @i{slave-only} flag.
@c ##########################################################################
@node PTP Clock Class
@chapter PTP Clock Class
The clock class value (@t{clockClass}), a field of the ``clock quality''
structure, can be specified in the configuration file for the architectures
that support such a file.
For the White Rabbit node (@t{arch-wrpc}) the class is defined
according to build-time constants, set forth in @t{constants.h}.
When the node is configured as grandmaster (WRPC shell command @t{mode
gm}), the class is set to 6 (a clock synchronized to a primary
reference time source). However, if the internal PLL can not lock in
a 60 seconds timeout, the class is set to 52: a clock that will never
be a slave, but is not currently connected to a primary time source.
When the node is configured as master, it uses class 187, i.e.
a clock that may be a slave of another clock.
@c ##########################################################################
@node Diagnostics
@chapter Diagnostics
......
......@@ -30,11 +30,11 @@
#define PP_DEFAULT_SYNC_RECEIPT_TIMEOUT 3
#define PP_DEFAULT_ANNOUNCE_RECEIPT_TIMEOUT 6 /* 3 by default */
/* Clock classes (pag 55, PTP-2008) */
/* Clock classes (pag 55, PTP-2008). See ppsi-manual for an explanation */
#define PP_CLASS_SLAVE_ONLY 255
#define PP_CLASS_DEFAULT 187
#define PP_CLASS_WR_GM_LOCKED 6
#define PP_CLASS_WR_GM_UNLOCKED 7
#define PP_CLASS_WR_GM_UNLOCKED 52
#define PP_DEFAULT_CLOCK_ACCURACY 0xFE
#define PP_DEFAULT_PRIORITY1 128
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment