Commit Graph

88 Commits (7d8f31da45fe30c5a53efee4c8ae1454d5b44df5)

Author SHA1 Message Date
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