Commit Graph

134 Commits (110849d42247943b54672d1b5301ee2d2d1d6164)

Author SHA1 Message Date
Richard Cochran 3d7372d529 Fix memory leak, reference counting, and list handling in message code.
The message code is horribly broken in three ways.

1. Clearing the message also sets the reference count to zero.
2. The recycling code in msg_put does not test the reference count.
3. The allocation code does not remove the message from the pool,
   although this code was never reached because of point 2.

This patch fixes the issues and also adds some debugging code to trace
the message pool statistics.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-07-07 20:18:02 +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
Jacob Keller 821798da9d ptp4l: throw a fault for other port event failures
this patch makes sure every function is checked for a negative return value
and ensures that a fault is detected when these fail

-v2-
* Fixed only check the ones with return value

-v3-
* Modified the delay_req functions to return 0 on nonfault cases

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
2012-05-08 08:32:26 +02:00
Richard Cochran 4af8c74450 Use the peer transmission methods in the port logic.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-04-05 17:48:59 +02:00
Richard Cochran cd0fbc5c95 Throw a fault when multiple peers are detected.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-04-05 17:48:59 +02:00
Richard Cochran 9dc860642f Add a helper function to compare message source ports.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-04-05 17:48:59 +02:00
Richard Cochran 4df18c6fc9 Implement the port peer delay mechanism.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-04-05 17:48:50 +02:00
Richard Cochran d345ac5e4e Add port fields to remember peer delay messages.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-04-05 11:40:59 +02:00
Richard Cochran 2d06c5856d Warn when receiving delay requests on a peer to peer port.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-04-02 10:23:47 +02:00
Richard Cochran 04e59b0b27 Show every port state transition, including (re)initialization.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-03-24 13:14:47 +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 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 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 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 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 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 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 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 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 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 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 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 e2c02e49c7 Implement the master sync timer and message.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-01-07 08:07:55 +01:00
Richard Cochran 39f5b2c449 Fix delay response message format.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-01-07 08:07:54 +01:00
Richard Cochran e96d26f13f Group the sequence numbers together in one structure.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-01-07 08:07:54 +01:00
Richard Cochran 72703ba36a Implement the master announce timer and message.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-01-07 08:07:54 +01:00
Richard Cochran da17f75359 Implement the port master qualification timer.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-01-07 08:07:54 +01:00
Richard Cochran 62afef45db Clear all timers when changing port state.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-01-07 08:07:54 +01:00
Richard Cochran 10753faccf Implement the synchronization events.
This will allow a port to get from the uncalibrated into the slave state.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-01-07 08:07:54 +01:00
Richard Cochran 68aea3058c Use the timeout table for the delay request messages.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2011-11-27 14:24:03 +01:00
Richard Cochran ebd353aff6 Link it all together, but in slave-only mode.
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>
2011-11-13 12:39:49 +01:00
Richard Cochran dae76b951a Implement the port layer.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2011-11-13 08:41:05 +01:00