Commit Graph

94 Commits (f2ffeae0f43934285d30a0cf882841c2de1c80a7)

Author SHA1 Message Date
Richard Cochran f2ffeae0f4 Automatically clear any port fault after fifteen seconds.
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>
2012-03-24 12:46:24 +01:00
Richard Cochran 2607806579 Rationalize the port reset logic.
This commit makes each pair of port functions, open/close and
initialize/disable, balance each other in how they allocate or free
resources. This change lays some ground work to allow proper fault
handling and disable/enable logic later on.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-03-21 14:12:04 +01:00
Richard Cochran 1b78bb0b54 Add a missing doxygen comment to the main program.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-03-21 13:57:05 +01:00
Richard Cochran 0ca8143da5 Remove a useless variable from the file descriptor array data type.
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>
2012-03-21 13:55:56 +01:00
Richard Cochran 39b10a5a16 Add a method to remove a port from the clock's polling array.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-03-21 13:08:09 +01:00
Richard Cochran 2ff091b14b Throw a fault event if the BMC algorithm fails.
That makes more sense than re-initializing, perhaps.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-03-21 12:20:45 +01:00
Richard Cochran 3ff62648fa Make the number of transmit time stamp retries configurable.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-03-20 20:19:25 +01:00
Richard Cochran da69203517 Rework the configuration file interface.
This change will make it easier to extend the configuration file contents
to include arbitrary new data structures.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-03-20 20:09:40 +01:00
Richard Cochran 32d461d4ed Add a transport over raw Ethernet packets.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-03-18 09:31:21 +01:00
Richard Cochran 5dbca8a6cd Add a header defining the Ethernet header and MAC addresses.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-03-18 09:31:21 +01:00
Richard Cochran 7d54d444f5 Leave some headroom in the message buffers.
This room will be used by the Layer 2 protocols.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-03-18 09:31:21 +01:00
Richard Cochran aa142c5240 Improve error reporting on receive path.
In some error cases, no message is logged. Now we always complain loudly
when an error occurs.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-03-18 09:31:21 +01:00
Richard Cochran 9d4d68e667 Add missing release method to the UDPv4 transport.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-03-17 17:30:21 +01:00
Richard Cochran 319aae1403 Move some sharable socket code into its own source file.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-03-17 17:30:21 +01:00
Richard Cochran 9c9dc35f13 Clean up dynamic fields when closing a port.
In the course of development we added more and more allocations into the
port code without freeing them on close. We do not yet call the close
function, so there was never an issue. Once we start to reset the ports,
to clear faults for example, then we will need this.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-03-13 09:11:01 +01:00
Richard Cochran 29463cd306 Make the transport layer more opaque.
Although the UDP/IPv4 layer does not need any state per instance (other
than the two file descriptors), the raw Ethernet layer will need this.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-03-13 08:28:37 +01:00
Richard Cochran 7421e74aca Clear out saved time stamps after setting the clock.
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>
2012-03-11 10:58:24 +01:00
Richard Cochran 2fcac204de Do not calculate the path delay without valid sync time stamps.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-03-11 10:52:01 +01:00
Richard Cochran e38488ae48 Add time value operations to clear to zero and test for zero.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-03-11 10:46:45 +01:00
Richard Cochran 5f0c034494 Throw an error at the port level on missing transmit time stamps.
We always wait for the transmit time stamp after sending an event message.
Thus a missing time stamp is clearly a fault, even if the hardware can
only handle one time stamp at a time.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-03-11 10:04:42 +01:00
Richard Cochran 51162c01af Warn loudly whenever event messages are missing time stamps.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-03-11 09:53:28 +01:00
Richard Cochran a9e88a0a49 Fix segfault after missing transmit time stamp.
If the networking stack fails to provide a transmit time stamp, then we
might feed uninitialized stack data to the CMSG(3) macros. This can result
in a segfault or other badness.

The fix is to simply clear the control buffer in advance.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-03-11 09:45:23 +01:00
Richard Cochran 150da0cba9 Remove silly and incorrect error message.
Commit 32133050 introduced a bug that gives a bogus error message on
every 'general' (non-event) PTP packet. If we want to catch missing
time stamps, then it has to occur at the port level.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-03-04 11:33:22 +01:00
Richard Cochran eb5b7b1e60 Verbosely identify the port and message after network errors.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-03-04 08:36:37 +01:00
Richard Cochran 321330501f Be more verbose about errors on the receive path.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-03-04 08:23:40 +01:00
Richard Cochran 6daff667c5 Initialize the time properties data set.
We can reuse the same function that sets the data sets in case of
becoming grand master.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-02-26 18:03:16 +01:00
Richard Cochran d6ce3fbb3d Fix compilation for uclinux toolchain lacking <sys/timerfd.h>
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-02-19 18:26:54 +01:00
Richard Cochran 4d0b2e5001 Clean up all of the binaries for the 'distclean' target.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-02-19 18:26:38 +01:00
Richard Cochran 4b10792002 Add a utility program to set driver level time stamping policy.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-01-24 19:22:13 +01:00
Richard Cochran af3cbb5fbd Add a tool to synchronize the system time from a PTP hardware clock.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-01-24 19:12:57 +01:00
Richard Cochran 43bd313eb1 Go ahead and use a negative path delay estimate.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-01-21 15:24:15 +01:00
Richard Cochran 6d73cea86a Implement timeouts with log seconds less than zero.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-01-09 10:04:43 +01:00
Richard Cochran c0ebf12f79 Add command line options to control the logging destination.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-01-09 10:04:43 +01:00
Richard Cochran 86ddff4a0a Print messages to the syslog by default.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-01-09 10:04:43 +01:00
Richard Cochran 222c9bb62b Fix the port finite state machine.
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>
2012-01-07 08:07:56 +01:00
Richard Cochran c2fad7bd51 Fix the BMC state decision algorithm.
We failed to make the distinction between plain old "better" and
"better by topology," but the BMC algorithm really counts on this.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-01-07 08:07:56 +01:00
Richard Cochran 807ec32c96 Fix wrong result from the best master clock algorithm.
The BMC should never return 'faulty', and I don't know what I was thinking
here, so let's just fix it.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-01-07 08:07:56 +01:00
Richard Cochran 335100c1a6 Differentiate the BMC related logging from the synchronization logging.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-01-07 08:07:56 +01:00
Richard Cochran a442a928f8 Fix typo in the initial priority field of the parent data set.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-01-07 08:07:56 +01:00
Richard Cochran ba6cf8b767 uClinux: provide missing system calls.
The timerfd calls are missing from Sourcery CodeBench Lite 2011.09-23.
We can remove this code once these calls are properly integrated into a
current tool chain.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-01-07 08:07:56 +01:00
Richard Cochran 59163df8b1 Make use of the configuration file for the port data set.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-01-07 08:07:55 +01:00
Richard Cochran 1092c4237b Make use of the configuration file for the default data set.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-01-07 08:07:55 +01:00
Richard Cochran ec5e783e84 Add code to read a configuration file.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-01-07 08:07:55 +01:00
Richard Cochran 32ee558ef8 Add a command line option to set the message level.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-01-07 08:07:55 +01:00
Richard Cochran f135133a88 Print the synchronization statistics at the information level.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-01-07 08:07:55 +01:00
Richard Cochran 0536aa7413 Issue a warning when the path delay turns out negative.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-01-07 08:07:55 +01:00
Richard Cochran e47549e73f Ignore messages from ourselves and from the wrong domain.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-01-07 08:07:55 +01:00
Richard Cochran 851675833a Do not print debug messages by default.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-01-07 08:07:55 +01:00
Richard Cochran 95185673f5 Fix message leak in the port event handler.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-01-07 08:07:55 +01:00
Richard Cochran 50b82c200d Do not treat signaling and management messages as errors.
Instead we just ignore them for now.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-01-07 08:07:55 +01:00