Commit Graph

61 Commits (380ee349f6f2885ef4527e64deaa7983e0051000)

Author SHA1 Message Date
Vedang Patel 78b4b780da clock: add APIs to access servo and servo_state
Make servo and it's current state available outside clock.c

Signed-off-by: Vedang Patel <vedang.patel@intel.com>
2019-05-08 21:29:48 -07:00
Anders Selhammer 1173e774dd Introduce the maxStepsRemoved attribute
Add attribute maxStepsRemoved which is included in IEEE1588-2017 (v2.1)
It is an optional attribute which can decide if an Announce message is
considered in the operation of the BMCA or not.

Signed-off-by: Anders Selhammer <anders.selhammer@est.tech>
2018-09-30 18:39:39 -07:00
Rafaël Carré 3c7fa5dd42 clock_send_notification: msg_len is unused
message length is already included in the msg structure

Signed-off-by: Rafaël Carré <funman@videolan.org>
2018-06-25 07:24:17 -07:00
Richard Cochran 8f2b1db4fd clock: Add a method to determine whether a clock is free running.
This will be needed by the end-to-end transparent clock code.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-05-01 07:01:57 -07:00
Richard Cochran 6f96ebb7b8 Refactor the data set comparison function variable.
There is no need to keep two copies of the data set comparison
function.  This patch adds a method that allows the port code to
obtain the function from the clock code.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-04-24 21:39:10 -07:00
Michael Brown c9f3fad780 clock: Remove open-coded conversion of struct timespec
The function clock_check_ts() performs open-coded manipulation of a
struct timespec instead of using the tmv_t abstractions.

Use the existing tmv_t abstractions to convert from struct timespec to
nanoseconds, and modify the prototype of clock_check_ts() to match
that of the underlying clockcheck_sample().

Signed-off-by: Michael Brown <mbrown@fensystems.co.uk>
2018-03-17 19:04:28 -07:00
Richard Cochran 36550e415c clock: Introduce a method to obtain the last synchronization time.
The NetSync Monitor protocol will require us to report the time stamp of
the last synchronization.  This patch adds new the method.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-07 19:28:25 -08:00
Richard Cochran fb2c979182 clock: Introduce a method to get the current dataset.
As part of the NetSync Monitor protocol, the port will need to have
access to the current data set.  This patch adds the appropriate
function.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-07 19:28:25 -08:00
Hangbin Liu 1440f09384 clock: add clock_required_modes to obtain the required time stamping mode
Separate required_modes setting from clock_create so we can obtain the
required time stamping flags from other place.

Add enum timestamping in struct clock to store the time stamping mode.

Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
2017-10-14 05:34:18 -07:00
Hangbin Liu c149a3dbc1 port: add FD_RTNL event to track per-port status
With rtnl socket we can track link status per port(except UDS port).

We can make sure we get the correct interface and latest status with function
port_link_status().

At the same time we need to set clock sde after link down. But we return
EV_FAULT_DETECTED in port_event(), which will not set clock sde. So we need
to set it in port_link_status().

Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
2017-07-13 07:19:57 +02:00
Richard Cochran d825b1d549 Let the clock code figure the PHC index.
The code that determines the index of the PHC device is useful to all
kinds of clock devices.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2016-04-03 14:45:41 +02:00
Richard Cochran 9c8fe6a94e clock: specify type at creation time.
Store the type in the clock object explicitly.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2016-04-03 14:45:41 +02:00
Richard Cochran adf36154f5 clock: offer a method to get the first port in the list.
This function will allow the TC code to iterate over the ports without
calling into the clock logic.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2016-04-03 14:45:41 +02:00
Richard Cochran 948d511550 clock: offer a method to get the type rather than the number of ports.
The port code is not interested in the number of ports but rather the
clock type.  Since the polymorphic clock object will be able to report
its own type, this patch changes the clock interface accordingly.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2016-04-03 14:45:41 +02:00
Richard Cochran fd2eb9411f Move the clock type enumeration into the clock header.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2016-04-03 14:45:41 +02:00
Richard Cochran bbe55fbea4 clock: remove redundant parameter from the create method.
There is no need for the 'ifaces' parameter since the list of network
interfaces is already present in the configuration.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2016-04-03 14:45:41 +02:00
Richard Cochran 9b27664cfc clock: simplify the create method.
With the new configuration API, there is no need to pass the default data
set.  Instead, the clock code can read the configuration directly.  This
patch simplifies the clock create method by removing the 'dds' parameter
and moving the code that initialized the data set into the clock module.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2016-04-03 14:45:41 +02:00
Richard Cochran 8836f3cc67 config: convert 'clock_servo' to the new scheme.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2015-08-23 21:09:46 +02:00
Richard Cochran ed566513e0 config: convert 'time_stamping' to the new scheme.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2015-08-23 21:09:46 +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
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
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 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 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 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
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
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 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 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 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
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
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
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 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
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
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 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 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
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 08a6a14e6c ptp4l: pull iface into the configure settings
this patch modifies the ptp4l.c and config settings so that the iface list is
inside the cfg_settings structure

-v2
* Moved "struct interface" into config.h

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 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
Jacob Keller 0afedd7993 ptp4l: use ethtool operation to double check PHC
If the new ethtool operation is supported, then use it to verify that the PHC
selected by the user is correct. If the user doesn't specify a PHC and ethtool
is supported then automatically select the PHC device.

If the user specifies a PHC device, and the ethtool operation is suppported,
automatically confirm that the PHC device requested is correct. This check is
performed for all ports, in order to verify that a boundary clock setup is
valid.

The check for PHC device validity is not done in the transport because the
only thing necessary for performing the check is the port name. Handled this
in the port_open code instead.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
2012-05-10 06:53:15 +02:00
Richard Cochran b35a45d1a4 Add a command line option to select the peer delay mechanism.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-04-05 17:48:59 +02:00