Commit Graph

179 Commits (0bb690c16cb28071e49f9b4c1d0c43a211da8e4b)

Author SHA1 Message Date
Richard Cochran 76f8d5eb48 config: convert 'timeSource' to the new scheme.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2015-08-23 21:09:45 +02:00
Richard Cochran 5277396b3a config: convert 'sanity_freq_limit' to the new scheme.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2015-08-23 21:09:45 +02:00
Richard Cochran 0aff268a4e config: convert 'kernel_leap' to the new scheme.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2015-08-23 21:09:45 +02:00
Richard Cochran f2da3cc484 config: convert 'summary_interval' to the new scheme.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2015-08-23 21:09:45 +02:00
Richard Cochran 2816133b5e config: convert 'gmCapable' to the new scheme.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2015-08-23 21:09:45 +02:00
Richard Cochran 5eeea13652 config: convert 'free_running' to the new scheme.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2015-08-23 21:09:45 +02:00
Richard Cochran eaa70f165f config: port: convert 'delay_filter_length' to the new scheme.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2015-08-23 21:09:45 +02:00
Richard Cochran ffa7d49df6 config: clock, port: convert 'freq_est_interval' to the new scheme.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2015-08-23 21:09:45 +02:00
Richard Cochran bde8ef4360 servo: store the configuration in the servo data structure.
This will allow removing the code that passes configuration options via
global variables.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2015-08-23 21:09:45 +02:00
Richard Cochran b297f22a82 clock: add a method to obtain the configuration.
This function allows the ports to read configuration variables without
changing the port method signatures.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2015-08-16 11:20:23 +02:00
Richard Cochran 1579b7893b clock: store the configuration in the clock data structure.
This will help us to simplify the passing of parameters between the main
program. clock, and ports.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2015-08-16 11:20:23 +02:00
Richard Cochran 2318432b94 clock: support management SET of the priority attributes.
This patch adds support for changing the priority1 and priority2
elements of the "default data set" at run time.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2015-07-24 21:59:43 +02:00
Miroslav Lichvar f0b0c1116a servo: add support for weighted samples.
Add weight parameter to the sample function. Samples with smaller weight
are less reliable, they can be ignored by the servo or the adjustments
of the clock can be smaller.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2015-03-27 10:58:04 +01:00
Miroslav Lichvar 06fcfe123c tsproc: add raw and weighting modes.
Add new time stamp processing modes to return raw delay and offset based
on the raw delay instead of the long-term filtered delay, and to return
also a weight of the sample. The weight is set to the ratio between the
two delays. This gives smaller weight to samples where the sync and/or
delay messages were delayed significantly in the network and possibly
include a large error.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2015-03-27 10:58:04 +01:00
Miroslav Lichvar c452e862dd Refactor time stamp processing.
Introduce a time stamp processor for offset/delay calculations and use
it in the clock and port modules.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2015-03-27 10:58:04 +01:00
Miroslav Lichvar 6813fd7c3d Convert and correct time stamps early.
Convert time stamps to tmv_t and apply all corrections before passing
them to clock/port functions to reduce the number of parameters.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2015-03-27 10:58:04 +01:00
Richard Cochran a96797a7fc clock: Introduce a function to switch the PTP Hardware Clock.
When switching clock devices in JBOD mode, we need to be able to reset the
servo. The existing servo_reset() function will not serve us well, because
in this case we also need to seed the existing frequency offset and limit.
This patch adds a new method that simply starts the servo from scratch.

In the unlikely event of a resource allocation failure, the method will
simply continue to use the previous device, which is better than nothing
and certainly preferable to bailing out the program.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2014-12-17 16:15:25 +01:00
Richard Cochran a4264b3e6e trivial: do not assign a FP constant to an integer.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2014-11-07 19:47:36 +01:00
Miroslav Lichvar 50d5c63e16 clock: keep ports in specified order.
When adding a new port, put it at the end of the list instead of head.
This restores the order of received management messages as was before
commit 08575133.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2014-11-07 18:57:40 +01:00
Jiri Benc 5e0196d647 Dynamic allocation of interface config entries
Remove the limit of MAX_PORTS ports also when parsing command line
arguments.

Signed-off-by: Jiri Benc <jbenc@redhat.com>
2014-09-21 13:15:59 +02:00
Jiri Benc c017adc8d1 Remember last used port number
For the ports to be truly created and removed dynamically, the last used
port number has to be remembered by the clock and used for port creation.

Signed-off-by: Jiri Benc <jbenc@redhat.com>
2014-09-21 13:15:59 +02:00
Jiri Benc 83f637fb8e Lazy regeneration of pollfd
There's no need to regenerate pollfd multiple times during batches of port
operations (like creating of the clock). Just be lazy and regenerate it only
once it's needed.

Signed-off-by: Jiri Benc <jbenc@redhat.com>
2014-09-21 13:15:59 +02:00
Jiri Benc 08575133b3 Dynamic port allocation
Remove the limit of MAX_PORTS ports (default 8) and keep the ports in
a linked list. This allows ptp4l to be used on large machines and in the
future, it will allow dynamic adding and removing of ports while ptp4l is
running.

For this to work, pollfd needs to be dynamically allocated. Changed pollfd
handling from clock_install_fda/clock_remove_fda to notification
(clock_fda_changed), where the clock will rebuild pollfd by querying all its
ports.

Signed-off-by: Jiri Benc <jbenc@redhat.com>
2014-09-21 13:15:59 +02:00
Jiri Benc 48a8425ff7 Make uds port a separate field in struct clock
The uds port is handled specially in almost all cases, it doesn't behave
like the rest of ports in the port array. Make it a standalone member of
struct clock.

Signed-off-by: Jiri Benc <jbenc@redhat.com>
2014-09-21 13:15:59 +02:00
Jiri Benc 2d1a88ca5d Put fault_fd into struct port
The fault timer file descriptor is a per port item, put it inside struct
port where other per port file descriptors are kept.

Signed-off-by: Jiri Benc <jbenc@redhat.com>
2014-09-21 13:15:59 +02:00
Miroslav Lichvar 70dd682349 Prefix TLV IDs.
To avoid conflicts in generic names add TLV_ prefix to all TLV IDs
defined in tlv.h.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2014-07-09 06:31:25 +02:00
Miroslav Lichvar 2aa6b10c3b Add leap function to servo.
Introduce a new function to inform the servo about upcoming leap second.
This is used when the kernel leap is disabled to allow the servo to
handle better the sudden 1 second step in the offset when the leap
second is inserted or deleted.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2014-06-22 09:30:30 +02:00
Miroslav Lichvar fefd5b4b05 Set TAI offset of system clock.
When synchronizing the system clock and the PTP UTC offset is valid and
traceable, set the TAI offset of the clock to have correct CLOCK_TAI
(which is implemented in the kernel as CLOCK_REALTIME + TAI offset).

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2014-06-22 09:23:55 +02:00
Jiri Benc 424bbde8fc Custom management TLV PORT_PROPERTIES_NP
Will be used by phc2sys to find out interfaces corresponding to ports.

Signed-off-by: Jiri Benc <jbenc@redhat.com>
2014-05-06 20:09:00 +02:00
Jiri Benc 648197153e clock: event notification
Split management message creation to more fine-grained functions to allow
notification messages to be created.

The new clock_management_fill_response is called from
clock_management_get_response (so the function behaves exactly the same as
before this patch) and from a new clock_notify_event function. The
difference is clock_management_get_response uses the request message to
construct the reply message, while clock_notify_event constructs the reply
message based on the notification id.

Signed-off-by: Jiri Benc <jbenc@redhat.com>
2014-05-06 20:08:59 +02:00
Jiri Benc 0e8efe418c Subscription time limit
Add expiration time to subscriptions; they need to be renewed before they
expiry. This way, the subscription automatically times out when phc2sys is
killed.

Signed-off-by: Jiri Benc <jbenc@redhat.com>
2014-05-06 20:08:59 +02:00
Jiri Benc 5104e3e56b Event subscribing
This puts groundwork for event subscription and notification. The individual
events are added by subsequent patches.

Signed-off-by: Jiri Benc <jbenc@redhat.com>
2014-05-06 20:08:58 +02:00
Jiri Benc d6e4173e19 Remove unneeded parameter in port_forward
This parameter was made obsolete by the common address refactoring.

Signed-off-by: Jiri Benc <jbenc@redhat.com>
2014-05-03 13:56:57 +02:00
Jiri Benc ba577d7123 Respond with an error to management messages to non-existing ports
Signed-off-by: Jiri Benc <jbenc@redhat.com>
2014-05-03 13:56:57 +02:00
Jiri Benc ea7a7882e5 Move common code into port_prepare_and_send
The task of preparing the message for transmission and sending it appears
at many places. Unify them into a new function.

Signed-off-by: Jiri Benc <jbenc@redhat.com>
2014-03-26 16:59:45 +01:00
Jiri Benc 4ed4c0ef5a Move check of TLV length for management COMMAND messages
Currently, it is assumed that the management TLV data of management COMMAND
messages is always empty. This is not true for the INITIALIZE command and
also for a custom command we'll be introducing.

Move the check to msg_post_recv and let it check only the TLVs defined by
the standard.

Signed-off-by: Jiri Benc <jbenc@redhat.com>
2014-03-26 16:59:45 +01:00
Miroslav Lichvar 61de819d56 Include clock rate ratio in delay calculation.
With the new linreg servo the frequency offset and time offset are
controlled separately. The ratio between master's frequency and the
current frequency of the local clock is known and can be used when
calculating delay or peer delay to improve their accuracy.

This greatly improves the stability of the delay when the servo is
correcting a large offset.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2014-03-14 09:52:40 +01:00
Miroslav Lichvar 91e240679b Restrict SET actions to UDS port.
Setting GRANDMASTER_SETTINGS_NP is allowed only from UDS, but
PORT_DATA_SET can be set from any port. Move the port check to
clock_manage(), so all clock and port SET actions are restricted
to the UDS port.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2014-02-25 14:15:49 +01:00
Miroslav Lichvar 7d773a9b93 Initialize clock rate ratio.
This fixes cumulativeScaledRateOffset reported in TIME_STATUS_NP before
the rate ratio is updated from port.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2014-02-25 14:15:49 +01:00
Miroslav Lichvar 85cebe0265 Fix conversion of cumulativeScaledRateOffset in TIME_STATUS_NP.
This fixes reporting of negative offsets.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2014-02-25 14:15:49 +01:00
Miroslav Lichvar 9190959693 Fix new -Wformat warnings.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2014-02-14 16:17:28 +01:00
Richard Cochran 21889c5e7e uds: take the interface data off the stack.
The 'struct interface' for the UDS port is allocated on the stack, and
when this gets passed to port_open, the port instance takes a pointer to
the string in the 'name' field. Currently this is harmless for the UDS
port, but it is not good form. This patch fixes the issue by making the
interface part of the clock instance.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Reported-by: Miroslav Lichvar <mlichvar@redhat.com>
2014-01-08 18:59:11 +01:00
Miroslav Lichvar f7d745f8fa Change level of negative path delay messages to debug.
Negative path delay measurements are expected with E2E, the user doesn't
need to know when that happens.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2014-01-08 15:50:02 +01:00
Miroslav Lichvar 647bce1c0c Clarify c1, c2, c3 in negative path delay log message.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2014-01-08 15:50:02 +01:00
Miroslav Lichvar e63a6ea89b Adjust tick length with system clock.
This increases the maximum frequency adjustment of the system clock
from 500 ppm to 10%.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2014-01-04 14:36:35 +01:00
Richard Cochran c00889f9eb Fix filter allocation failure on the UDS port.
Although it does not need to, the UDS port tries to allocate a filter,
just as any normal port would. Since the given length is zero, the
filter tries to allocate storage of size zero. When running with
uClibc, calloc(1, 0) returns NULL, but glibc is apparently returning
"a unique pointer value that can later be successfully passed to
free()." Both behaviors are allowed (see MALLOC(3)).

This patch works around the issue by letting the UDS port have a
filter of length one.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-12-26 19:09:26 +01:00
Richard Cochran 3aedebe74b clock: add missing call to clockcheck_destroy.
This patch lets the clock release allocated memory when shutting down. The
main benefit is just to exhibit good form and to make valgrind happier.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-12-26 10:48:25 +01:00
Richard Cochran e2586af94a Merge Miroslav's random PTP timeout branch.
Conflicts:
	makefile
2013-12-19 19:20:58 +01:00
Richard Cochran bdbda10c73 Introduce the gmCapable flag for use with 802.1AS clocks.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-12-01 20:32:05 +01:00
Miroslav Lichvar 85a1bcfa8e Add options to configure delay filter.
Add new options delay_filter and delay_filter_length to select the
filter and its length. They set both the clock delay filter and the port
peer delay filter. The default is now moving median with 10 samples.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-10-30 21:54:07 +01:00