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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
We are going to need this more than once for working with the
cumulativeScaledRateOffset fields.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
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>
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>
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>
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>
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>
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>
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>
The current port code is very defensive. As the code now stands, we throw
a fault whenever we cannot send or receive a packet. Even a downed link
on an interface will cause a port fault.
This commit adds a very simple minded way of clearing the faults. We just
try to enable the port again after waiting a bit.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
It was a cute idea to have the raw Ethernet layer use just one socket,
but it ended up not working on some specific PTP time stamping hardware.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
When we create a discontinuity in the clock time, we must avoid mixing
local time stamps from before and after the jump.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
The state machine needs to know whether a new master has just been
selected in order to choose between the slave and uncalibrated states.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
We already have a grand master state. Adding this event will simplify the
overall logic, since it will avoid the silly requirement to set the
qualification timeout to zero when entering the grand master state.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
If the path delay comes out negative, then something is amiss. In this
case, we just print a warning and ignore the path delay estimate.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
If software time stamping is to be used, then the servo will want to
have appropriate filtering.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
This is really just a first attempt using a hard coded length. Probably
it will be necessary to let the length be configurable and/or adaptable.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Since the master implementation is still lacking, we will just keep
the slave-only flag hard coded for now.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>