Now that a complete functional API is in place, there is no need to expose
the inner workings of the network interface data type. This patch converts
it into an opaque type while leaving the list marker visible to users
through a simple form of "friendly exposition".
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
In order to eventually hide the implementation details of the interface,
users will need to be able to create and destroy instances thereof. This
patch adds the needed methods.
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
The ts_label field of the interface is set in different ways by different
callers. In order to prevent users from open coding the logic that sets
the label, this patch adds an appropriate method.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
The name field of the interface is set in different ways by different
callers. In order to prevent users from open coding the logic that sets
the name, this patch adds an appropriate method.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
In many cases, the time stamping label will be the same as the name of
the interface. In order to prevent users from open coding the logic that
initializes the label from the interface name, this patch add an
appropriate method.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
In order to prevent users from open coding this logic, this patch
provides a method that populates the time stamping information from
the interface label.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Many of the users only require a read only reference to the time
stamping label of the interface. This patch adds an appropriate
method.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Many of the users only require a read only reference to the interface name.
This patch adds an appropriate method.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Up until now, the users of the interface data structure simply access
its fields without restriction. This patch takes the first step
towards abstracting this data structure by giving it a file of its
very own.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
The function to open a posix clock never modifies the passed in
string. This patch adds the const keyword to ensure this function
stays that way.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Three of the rtnl methods never modify the strings passed in. This
patch adds the const keyword to ensure these functions stay that way.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
The two methods, config_create_interface and config_read, never modify the
strings passed in. This patch adds the const keyword to ensure these
functions stay that way.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Any program that links to the servo interface must also link with the
implementations of that interface. Similarly, the filter and network
transport interfaces each require their implementations. This patch
re-factors the makefile to reflect this fact in order to simplify
adding new programs making use of these interfaces.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
This fixes an issue with free running clocks. When the master clock id
changes the measured master/local ratio should be reset. If it isn't,
and the local clock becomes master, then the last measured ratio to
the old master continues to be used in peer delay calculations. If a
bad master/local ration calculation triggers this state change the
port can get "stuck" in not "asCapable" mode.
Signed-off-by: Erik Hons <erik.hons@ni.com>
Don't require each port to have its own master table specified in the
config. Instead of ports claming configured tables, clone the table in
each port, so different ports don't interfere with each other.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
A single, external PTP Hardware Clock device may be wired to one or more
MAC devices, providing the MACs with an input clock. This patch adds
support for such a hardware architecture by letting the command line PHC
override the one discovered via the ethtool ioctl.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
The sysoff_measure() function gained an additional parameter some time
ago, but the legacy method for older kernels without PTP_SYS_OFFSET was
overlooked. This patch brings the legacy method up to date again.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
In port_synchronize(), when the clock returned SERVO_UNLOCKED and
port_dispatch() triggered a switch of the PHC, the variable "s" would
point to a servo which was already freed and the following call of
servo_offset_threshold() would read invalid memory.
Don't save the servo before dispatching the port.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
Fixes: 3f5f5653d7 ("port: Add interval update mechanism.")
TLV_PORT_PROPERTIES_NP messages serve for querying of port properties, such
as timestamp type and, prominently, netdevice name associated with the
port. pmc however does not support this query, which makes it difficult to
access this information e.g. from scripts. Add this support to pmc.
Signed-off-by: Mykola Zhuravel <mykola@mellanox.com>
Signed-off-by: Petr Machata <petrm@mellanox.com>
TLV_PORT_PROPERTIES_NP carries, among other attributes, a timestamp type
used for that port. In order to make it possible to format the value for
user consumption, introduce a new function ts_str().
Signed-off-by: Petr Machata <petrm@mellanox.com>
In commit 2b5bec8d27 ("pmc: Add a new TLV to obtain per-port
statistics"), pmc gained a new TLV to obtain port stats from ptp4l. Mention
the TLV in the pmc man page.
Signed-off-by: Petr Machata <petrm@mellanox.com>
mc6_addr holds the parsed multicast address to which messages should be sent.
But since each port can have a different scope, and the primary MC address
depends on the scope, it really can't be stored in a global variable. Move both
to struct udp6.
Additionally, document the fact that the primary multicast address is changed at
runtime.
Reported-by: Alex Veber <alexve@mellanox.com>
Signed-off-by: Petr Machata <petrm@mellanox.com>
Add struct PortStats to keep per-port number of messages sent and received,
split by message type. Bump TX counters after messages are sent
successfully, and RX counters after a message is received. To keep things
simple, reserve one counter for each theoretically possible message type,
including the reserved ones.
Signed-off-by: Petr Machata <petrm@mellanox.com>
The two programs, phc2sys and phc_ctl, use nearly identical subroutines to
open an instance of a dynamic posix clock. In anticipation of yet a third
program with similar needs, this patch refactors the common code into the
utilities.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
The order of the options list has gone a bit astray. This patch
restores the ordering.
Fixes: 450b1ed844 ("port: Add inhibit_delay_req.")
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
ptp4l -f default.cfg complains:
unknown option inhibit_pdelay_req at line 41 in global section
failed to parse configuration file /etc/linuxptp/default.cfg
Fixes: 450b1ed844 ("port: Add inhibit_delay_req.")
Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
Users may need to use different socket priorities for ptp4l traffic for
the purpose of traffic shaping. An example is to route ptp4l traffic
through a specific Linux egress queue using the mqprio qdisc.
- Update raw.c open_socket() to accept a socket_priority parameter
- Add the socket_priority option to config.c and the default.cfg config
file. The option defaults to 0.
CC: "Ong, Boon Leong" <boon.leong.ong@intel.com>
CC: "Wong, Vincent Por Yin" <vincent.por.yin.wong@intel.com>
Signed-off-by: Khor, Isaac Shi Yan <isaac.shi.yan.khor@intel.com>
struct hwtstamp_config.rx_filter passed to SIOCSHWTSTAMP can be updated by
the kernel with the value of HWTSTAMP_FILTER_SOME. That indicates that all
requested packets will be timestamped, and some others as well.
Update hwts_init() to recognize this as a valid response in HWTS_FILTER_NORMAL
mode, instead of rejecting it as mismatch.
Cc: "Keller, Jacob E" <jacob.e.keller@intel.com>
Cc: "Geva, Erez" <erez.geva.ext@siemens.com>
Signed-off-by: Petr Machata <petrm@mellanox.com>
Set the announce, sync and delay request intervals in the example
configs per the G.8275.1 and G.8275.2 recommendations. Enable the L2
transport in G.8275.1.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>