Commit Graph

277 Commits (1486660e959f728e3a032cb832ee8b8ea9755ef3)

Author SHA1 Message Date
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
Miroslav Lichvar 2c9718f3c2 Add modular filter interface.
Similarly to the servo interface, allow multiple filters to be
used for delay filtering. Convert mave to the new interface.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-10-30 21:43:37 +01:00
Miroslav Lichvar ab84eade0a Make random() more random between machines.
Include also nanoseconds from the current time in the srandom() call.
This should significantly decrease the chance of two machines using the
same random sequence.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-10-27 14:03:05 +01:00
Miroslav Lichvar ed379b4028 Add clock sanity check.
Check the sanity of the synchronized clock by comparing its uncorrected
frequency with the system monotonic clock. When the measured frequency
offset is larger than the value of the sanity_freq_limit option (20% by
default), a warning message will be printed and the servo will be reset.
Setting the option to zero disables the check.

This is useful to detect when the clock is broken or adjusted by another
program.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-10-27 08:24:01 +01:00
Richard Cochran 25cf96d4ca Merge the configurable UDS server path branch. 2013-10-26 18:14:37 +02:00
Miroslav Lichvar 52c5e0cfc9 Don't calculate delay with old master's sync time stamp.
When a new master is selected, drop the old sync time stamp to prevent
calculating invalid delay in case delay_resp will be received before
first sync from the new master.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-10-11 19:44:50 +02:00
Richard Cochran e5ddfd491e Convert the hard coded UDS server path into a variable.
This patch changes the macro for the server socket address into a global
variable so that a subsequent patch can provide a way to set the variable.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-09-29 20:17:01 +02:00
Miroslav Lichvar 45493756f8 Don't try to forward messages to faulty UDS port.
When the socket couldn't be opened (e.g. in clknetsim), the file
descriptor is invalid and shouldn't be used for sending.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-09-23 19:26:18 +02:00
Miroslav Lichvar ad1b14e126 Fix port numbering in clock log messages.
Add 1 to port numbers printed in the log messages to make them
consistent with messages from port.c. The port number 0 is the UDS port,
which is last in the clock->port array.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-08-23 08:18:39 +02:00
Richard Cochran 46db400589 Become the grand master when all alone.
This patch cleans up the BMC logic to allow assuming the GM role when no
other clocks are found in the network. By allowing the "best" to be NULL,
we can let the BMC to naturally pick the local clock as GM. As an added
bonus, this also get rid of the hacky check for a lost master.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-07-14 21:48:23 +02:00
Richard Cochran 3695137619 Let the clock servo know the expected sync interval.
This patch adds a new servo method to let the algorithm know about the
master clock's reported sync message interval. This information can be
used by the servo to adapt its synchronization parameters.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-07-14 21:37:52 +02:00
Richard Cochran a367175b0d Throw a state decision event if the clock quality changes.
Management messages can cause a change in the clock quality. If this
happens, then it is time to run the Best Master Clock algorithm again.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-07-14 21:37:52 +02:00
Richard Cochran 12ab15818c Support configuration of the grand master settings.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-07-14 21:37:52 +02:00
Richard Cochran 24ecd786c8 Support the grand master settings management query.
This patch also replaces the hard coded logic for the UTC offset and the
time property flags with clock variables. This new clock state will be
used for adjusting the grand master attributes at run time.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-07-07 18:55:45 +02:00
Richard Cochran 4782d669c2 Add a clock variable to hold the value of the time source.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-07-07 18:55:45 +02:00
Richard Cochran c9ac677c98 No need to set kernel_leap twice in a row.
This patch removes a redundant initialization of the kernel_leap clock
variable. The field is already set in clock_create a few lines earlier.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-07-07 18:55:44 +02:00
Geoff Salmon 42b2173a4d Allow received GET management messages to have bodies
You'd probably expect the body of GET messages to be empty, but
interpretation #29 in
http://standards.ieee.org/findstds/interps/1588-2008.html implies
otherwise. With this change, ptp4l will respond to GETs containing
either an empty dataField or a dataField whose length matches the
managementId. If present, the contents of the dataField are ignored.

Signed-off-by: Geoff Salmon <gsalmon@se-instruments.com>
2013-06-28 07:38:59 +02:00
Miroslav Lichvar 026d422f8f ptp4l: Reset path delay when new master is selected.
When a new master is selected, drop the old path delay and don't
calculate the offset until the delay is measured again with the new
master.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-05-28 16:48:09 +02:00
Miroslav Lichvar 4929d50a3f Let kernel synchronize RTC to system clock.
Reset the STA_UNSYNC flag and maxerror value with every frequency update
to let the kernel synchronize the RTC to the system clock (11 minute mode).

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-04-09 07:08:45 +02:00
Miroslav Lichvar 7b162c4821 clockadj: Remove clkid parameter from set_leap function.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-04-09 07:08:44 +02:00
Richard Cochran 1f2c9de982 clockadj: remove useless clockid parameter.
The clockid parameter to the function to get the system clock's maximum
adjustment is redundant, so let us just remove it.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-04-09 07:06:20 +02:00
Richard Cochran 2ec3829bd4 Apply utc offset correction even when free running.
When using software time stamping and a free running clock, the
statistics appear to be off by the TAI offset. This patch fixes the
issue by setting the internal UTC timescale flag in such cases.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-04-05 20:22:25 +02:00
Miroslav Lichvar fce0aa0a2f Fix compiler warnings with -O2.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-04-05 09:14:29 +02:00
Miroslav Lichvar f8563452a8 ptp4l: Read system clock maximum frequency adjustment.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-04-05 09:11:17 +02:00
Miroslav Lichvar da347d7a36 ptp4l: Set clock frequency on start.
Due to a bug in older kernels, frequency reading may silently fail and
return 0. Set the frequency to the read value to make sure the servo
has the actual frequency of the clock.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-04-05 08:38:49 +02:00
Richard Cochran 1c4f99a0c3 Add a clock method to update the time properties data set.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-04-02 19:25:29 +02:00
Richard Cochran bd28acffb3 Merge branch 'mlichvar_leap'
Fixed up trivial conflict in the makefile.

Conflicts:
	makefile
2013-03-20 19:51:46 +01:00
Miroslav Lichvar 4e24248a71 Add options to not apply leap seconds in kernel.
Add kernel_leap option for ptp4l and -x option for phc2sys to disable
setting of the STA_INS/STA_DEL bit to slowly correct the one-second
offset by servo.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-03-20 19:37:40 +01:00
Miroslav Lichvar e21af97091 ptp4l: Handle leap seconds.
Extend the clock_utc_correct function to handle leap seconds announced
in the time properties data set. With software time stamping, it sets the
STA_INS/STA_DEL bit for the system clock. Clock updates are suspended
in the last second of the day.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-03-20 19:37:39 +01:00
Miroslav Lichvar 09667479b8 Add missing conversions from tmv_t to nanoseconds.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-03-20 19:37:39 +01:00
Miroslav Lichvar a29b1a4105 Move clock_adjtime wrapping to clockadj.c.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-03-20 19:37:39 +01:00
Delio Brignoli b936d35b6d Add support for multiple fault types
Signed-off-by: Delio Brignoli <dbrignoli@audioscience.com>
2013-03-20 19:10:22 +01:00
Delio Brignoli 455ebe7d22 Rename set_tmo() to set_tmo_log(), add set_tmo_lin()
Signed-off-by: Delio Brignoli <dbrignoli@audioscience.com>
2013-03-20 19:10:22 +01:00
Richard Cochran 2044d045b4 Add support for the timescale management request.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-03-03 20:26:00 +01:00
Richard Cochran 4dfcca733b Add support for the traceability management request.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-03-03 20:20:12 +01:00
Richard Cochran 32c8635aef Add support for the clock_accuracy management request.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-03-03 20:10:46 +01:00
Richard Cochran 78e37ebf0b Add support for the slave_only management request.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-03-03 20:06:17 +01:00
Richard Cochran bed1067d2b Add support for the domain management request.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-03-03 19:54:17 +01:00
Richard Cochran 8cc3a1f3b8 Add support for the priority2 management request.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-03-03 19:48:43 +01:00
Richard Cochran f0c0f7b121 Add support for the priority1 management request.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-03-03 19:41:06 +01:00
Geoff Salmon 36a5921e88 support GET CLOCK_DESCRIPTION and USER_DESCRIPTION mgmt messages
Signed-off-by: Geoff Salmon <gsalmon@se-instruments.com>
2013-02-25 18:11:03 +01:00
Miroslav Lichvar c547145834 Check shift used in freq_est and stats max_count calculation.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-02-12 19:59:50 +01:00
Miroslav Lichvar 7d8f31da45 Change stats max_count variables to unsigned.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-02-12 19:59:50 +01:00
Richard Cochran 1ce90fe160 Reduce the arguments to clock_create.
New clock options should go into 'struct default_ds' so that we can avoid
growing clock_create indefinitely.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-02-09 10:45:30 +01:00
Miroslav Lichvar 3136e3e46c Add summary statistics.
Add new options to ptp4l and phc2sys to print summary statistics of the
clock instead of the individual samples.

[ RC - Fix () function prototype with (void).
     - Use unsigned for sample counter.
     - Fix over-zealous line breaks. ]

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-02-09 10:09:25 +01:00
Richard Cochran c7098364f2 Make the counters for the frequency and rate estimators unsigned.
These are simple 'up' counters.
There is no need for negative values here.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-02-09 08:51:19 +01:00
Miroslav Lichvar cb5ebd9b24 Change label of frequency offset.
Change the label of the frequency offset in the clock messages printed
by ptp4l and phc2sys from "adj" to "freq" to indicate it's a frequency
value.

Also, modify clock_no_adjust() to print the frequency offset instead of
the ratio and use PRId64 instead of lld to print int64_t values.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-02-08 18:41:34 +01:00
Miroslav Lichvar 1e9db8b8dd Fix initialization of frequency estimation interval.
The clock_sync_interval() function is called when logSyncInterval
changes from zero. Call it also when the clock is created to have
fest.max_count set accordingly to freq_est_interval even with zero
logSyncInterval.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-02-08 18:41:34 +01:00
Geoff Salmon f8be779f28 send errors if mgmt tlv length doesn't match action
It's especially important to check that SET messages aren't empty.

Signed-off-by: Geoff Salmon <gsalmon@se-instruments.com>
2013-02-06 18:10:36 +01:00
Geoff Salmon 3921557672 send NOT_SUPPORTED errors for all unhandled, known management IDs
Now that there are clock/port_management_set functions, the IDs that
GETs are handled for, like DEFUALT_DATA_SET, still need to be in the
case for sending NOT_SUPPORTED errors.

Signed-off-by: Geoff Salmon <gsalmon@se-instruments.com>
2013-02-06 18:10:36 +01:00
Geoff Salmon 507bee9e73 adds stub clock/port_management_set functions
Signed-off-by: Geoff Salmon <gsalmon@se-instruments.com>
2013-02-06 18:10:36 +01:00
Geoff Salmon 1500605ff5 factors out functions for sending mgmt errors from clock and port
Adds port_management_send_error and clock_management_send_error to
avoid repeatedly checking the result of port_managment_send_error and
calling pr_err if it failed. Future patches send more mgmt errors so
this will avoid repeated code.

Signed-off-by: Geoff Salmon <gsalmon@se-instruments.com>
2013-02-06 18:10:35 +01:00
Geoff Salmon d5af4196fc fixes typo port_managment_error -> port_management_error
Signed-off-by: Geoff Salmon <gsalmon@se-instruments.com>
2013-02-06 18:10:35 +01:00
Geoff Salmon 09c2d1a652 adds clock description
Adds struct containing clock description info that will be needed for
USER_DESCRIPTION and CLOCK_DESCRIPTION management messages.

Signed-off-by: Geoff Salmon <gsalmon@se-instruments.com>
2013-02-04 12:22:11 +01:00
Richard Cochran 0dbdd9c2cd Stop handling file descriptor events after a port reset.
If the port resets itself after detecting a fault, then the polling events
for that port are no longer valid. This patch fixes a latent bug that
would appear if a fault and another event were to happen simultaneously.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-02-03 17:58:12 +01:00
Delio Brignoli da594e78d9 Make the fault reset interval a per-port configuration parameter.
A timeout of 15 seconds is not always acceptable, make it configurable.

By popular consensus, instead of using a linear number of seconds, use
the 2^N format for the time interval, just like the other intervals in
the PTP data sets. In addition to numeric values, let the configuration
file support 'ASAP' to have the fault reset immediately.

[RC - moved the handling of special case tmo=0 and added a break out
      of the fd event loop in case the fds have been closed.
    - changed the linear seconds option to log second instead.
    - changed the commit message to reflect the final version. ]

Signed-off-by: Delio Brignoli <dbrignoli@audioscience.com>
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-02-03 17:53:33 +01:00
Delio Brignoli eec07ae240 Fix fault-clearing timer being erroneously re-armed
Arm the fault-clearing timer only when an event causes a port to change state
to PS_FAULTY. Previously, if poll() returned because of an fd event other than
the fault-clearing timeout, the fault clearing timer would re-arm for
each port in PS_FAULTY state.

Signed-off-by: Delio Brignoli <dbrignoli@audioscience.com>
2013-01-30 18:05:38 +01:00
Miroslav Lichvar af2a4f47fb Modify PI servo to set frequency when jumping.
Similarly to the servo in phc2sys, when clock is stepped, set
immediately also its frequency. This significantly improves the initial
convergence with large frequency offsets.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-01-16 20:28:21 +01:00
Geoff Salmon 7607774f30 Avoid calling msg_pre_send/post_recv unless actually forwarding a message 2012-12-31 22:53:32 +01:00
Richard Cochran 2aaae0854e Distinguish between get and set management requests.
The code previously treated all supported request as 'get' actions and
ignored the actual action field in the message. This commit makes the
code look at the action field when processing the requests.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-12-04 13:25:50 +01:00
Richard Cochran 21840156c3 Respond to the time properties data set management query.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-12-02 18:57:38 +01:00
Richard Cochran aa6708d09a Use the management message memory layout for the timePropertiesDS.
Reforming the data structure in this way will greatly simplify the
implementation of the management message for this data set.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-12-02 11:24:31 +01:00
Richard Cochran b9a6767b3d Respond to the parent data set management query.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-12-02 09:13:55 +01:00
Richard Cochran cc7c724eb0 Respond to the default data set management query.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-12-02 07:51:19 +01:00
Richard Cochran 71c4bf203c Use the management message memory layout for the parentDS.
Reforming the data structure in this way will greatly simplify the
implementation of the management message for this data set.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-11-30 22:35:26 +01:00
Richard Cochran d60ccc7484 Use the management message memory layout for the defaultDS.
Reforming the data structure in this way will greatly simplify the
implementation of the management message for this data set.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-11-30 21:52:37 +01:00
Richard Cochran 1516be04e2 Ignore management response messages.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-11-30 11:39:21 +01:00
Miroslav Lichvar 7894339cdd Fix errors found by Coverity Static Analysis.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2012-10-18 19:58:40 +02:00
Jacob Keller d951ba421f ptp4l: modify clock_create to take servo as argument
this patch modifies the clock_create to take the servo type as an argument

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
2012-09-29 06:24:43 +02:00
Jacob Keller d67892abd7 ptp4l: modify servo setup to take an enum rather than string
passing a string as the servo type seems ugly when there are only a few
choices. This patch modifies the servo_create to take an enum instead.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
2012-09-29 06:24:43 +02:00
Richard Cochran 8f00d29265 Discover and utilize the initial clock frequency adjustment.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-09-22 11:30:50 +02:00
Delio Brignoli 1e6a169431 Do not expect or open a /dev/ptpX device when in free_running mode
Signed-off-by: Delio Brignoli <dbrignoli@audioscience.com>
2012-09-15 10:59:49 +02:00
Richard Cochran 6c54c31dca Introduce the time status management message.
This non-portable, implementation specific message is designed to inform
external programs about the relationship between the local clock and the
remote master clock.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-09-12 17:44:20 +02:00
Richard Cochran d4e761138e bugfix: use a sensible test to detect a new master.
The code to detect a new master used pointer equality using a stale
pointer within the clock instance. Instead, the clock needs to remember
the identity of the foreign master in order to correctly detect a
change of master.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-09-12 17:30:36 +02:00
Richard Cochran 8f5bd0edda Guard against divide by zero.
If a buggy driver or hardware delivers bogus time stamps, then we might
crash with a divide by zero exception.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-09-04 08:16:53 +02:00
Richard Cochran 35170cf6e4 Introduce a macro for the constant 2^41.
We are going to need this more than once for working with the
cumulativeScaledRateOffset fields.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-09-04 07:37:10 +02:00
Richard Cochran 8a4b2ab9b8 Remove unnecessary wait state from frequency estimator.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-09-02 14:40:27 +02:00
Richard Cochran 843661dfa2 Calculate the master/local rate ratio in two ways.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-09-02 14:40:07 +02:00
Richard Cochran 94dd186cdf Add a clock method to receive the follow up information TLV.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-09-02 14:40:07 +02:00
Richard Cochran f38338827b Provide the clock with the estimated neighbor rate ratio.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-09-02 14:40:07 +02:00
Richard Cochran db36fb52ca Reset the master/local frequency estimator when changing masters.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-09-02 14:40:06 +02:00
Richard Cochran 1bb8ebbdc5 Invert the frequency ratio estimation.
In 802.1AS-2011 the ratio is defined as master/local, so we should follow
suit.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-08-31 17:28:14 +02:00
Richard Cochran 829c785414 Rework the frequency ratio estimator to use the tmv functions.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-08-31 17:28:14 +02:00
Richard Cochran 845e947bcb Correct a comment about the frequency ratio estimation.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-08-31 17:28:14 +02:00
Richard Cochran 40dc2e13ef Make the clock release method a public function.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-08-27 21:09:59 +02:00
Richard Cochran 577d34facf Provide a method to release the message cache.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-08-27 21:09:10 +02:00
Richard Cochran 3936316468 Correct the TAI-UTC offset when it is reasonable to do so.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-08-27 18:57:43 +02:00
Richard Cochran 1bfb6fd217 Warn if the master's time properties are suspicious.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-08-26 20:36:43 +02:00
Richard Cochran ce745572b4 Use zero for the UDS port number.
Using 0xffff looks dumb in the log and in the pmc output.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-08-26 15:09:15 +02:00
Richard Cochran 420d48ce02 Use the ingress port identity for clock management replies.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-08-26 14:39:57 +02:00
Richard Cochran a25c5484d1 Create one special UDS port per clock.
This port is handled a bit differently than the others. Its only purpose
is to accept management messages from the local machine.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-08-25 11:43:35 +02:00
Richard Cochran 8c0393321e Respond to the current data set management query.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-08-22 07:36:33 +02:00
Richard Cochran 92c6c9149d Maintain the current data set.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-08-22 07:36:33 +02:00
Richard Cochran cd8996ecb9 Estimate the local/master frequency ratio when free running.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-08-21 20:10:35 +02:00
Richard Cochran 83be79df13 Provide a method to report the sync interval to the clock.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-08-21 20:10:35 +02:00
Richard Cochran e4c3fb2432 Free the clock's servo and moving average on destroy.
The destroy method is supposed to undo everything that the create does.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-08-21 16:22:18 +02:00
Jacob Keller 7a69db2379 ptp4l: Allow per-port customized port defaults
this patch allows each port to maintain its own pod structure since it is only
used in ports. This will allow the user to configure any special settings per
port. It takes a copy of the default pod, and a future patch will allow the
configuration file to set per-port specific changes

-v2
* Minor change to fix merge with previous patch

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
2012-08-21 14:30:54 +02:00
Jacob Keller 64dcf257e3 ptp4l: pass struct interface directly instead of passing it's sub arguments
the port_open function takes a large number of command options, a few of which
are actually all values of struct interface. This patch modifies the port_open
call to take a struct interface value instead of all the other values. This
simplifies the overall work necessary and allows for adding new port
configuration values by appending them to the struct interface

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
2012-08-21 07:28:14 +02:00
Jacob Keller 0499513f1e ptp4l: remove timestamping as a per-port configuration option
The current code for the timestamping mode does not allow interfaces to have
separate timestamping modes. This is (probably) due to hardware timestamping
mode being required on all ports to work properly.

This patch removes the timestamping field in the struct iface, and makes it a
clock variable which is really what the mode does anyways. Ports get passed
the timestamping mode but no longer appear as though they are separate.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
2012-08-21 07:28:14 +02:00
Richard Cochran edfb5fac84 Add storage fields for the path trace list.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-08-10 07:40:21 +02:00
Richard Cochran 353b0a2743 Answer all management requests with 'not supported'
Our management interface is not yet terribly useful,
but at least we are honest about it.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-08-05 21:46:03 +02:00
Richard Cochran 4f04c4139d Add a functional framework to manage the clock and its ports.
This commit only adds support for forwarding the management messages.
The actual local effects of the management commands still need to be
implemented.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-08-02 07:08:03 +02:00
Richard Cochran c1973c5e11 Update data sets after loss of foreign master.
If an announce timeout occurs on a port, and no other port is slaved, then
the clock must become a grand master by default.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-07-08 12:14:28 +02:00