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>
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>
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>
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>
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>
The new configuration code inadvertently causes the UDS port to use P2P
messaging when P2P is set as a global option. This results in a never
ending series of "missing timestamp" error messages from the UDS port as
it vainly tries to send peer delay requests.
This patch fixes the bug by changing the UDS delay mechanism back to zero
as it was before. This is the appropriate setting for the UDS port,
because it never leaves the listening state and thus never sends an E2E
delay request.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
This function allows the ports to read configuration variables without
changing the port method signatures.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
This puts groundwork for event subscription and notification. The individual
events are added by subsequent patches.
Signed-off-by: Jiri Benc <jbenc@redhat.com>
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>
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>