Currently it is very finicky to deploy linuxptp in an automated build
system and make KBUILD_OUTPUT pick up the output of "make
headers_install" in order for the application to make full use of the
features exposed by the runtime kernel. And the toolchain/libc will
almost certainly never contain recent enough kernel headers to be of any
use here. And there's no good reason for that: the application can probe
at runtime for the sysoff methods supported by the kernel anyway.
So let's provide the kernel definitions for sysoff, sysoff_precise and
sysoff_extended, such that SYSOFF_COMPILE_TIME_MISSING is not something
that will bother us any longer.
Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
Recently the Linux kernel's PTP Hardware Clock interface was expanded
to include a "write phase" mode where the clock servo in implemented
in hardware. This mode hearkens back to the tradition ntp_adjtime
interface, passing a measured offset into the kernel's servo.
This patch adds a new configuration option and logic to support the
write phase mode.
Because the hardware's adjustment bandwidth may be limited, this mode
is only activated when the servo reaches SERVO_LOCKED_STABLE state, in
order to achieve reasonably fast locking times. Users may control the
SERVO_LOCKED_STABLE state by configuring 'servo_offset_threshold' and
'servo_num_offset_values' accordingly.
Example configuration file highlights:
unicast_listen 1
logSyncInterval 0
logMinDelayReqInterval 0
first_step_threshold 0.001000000
step_threshold 0
clock_servo pi
write_phase_mode 1
servo_offset_threshold 50
servo_num_offset_values 10
tsproc_mode raw
Signed-off-by: Vincent Cheng <vincent.cheng.xh@renesas.com>
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Upcoming functionality will need to configure the input and output pins of
PHC devices. However, this requires fairly recent kernel support. This
patch adds the needed definitions for compiling with older kernel headers.
In addition, kernel v5.4 introduced a second set of ioctls for the
ancillary PTP Hardware Clock functionality. The original ioctls
failed to enforce the various flags and reversed fields, but the
second version has fixed the issues. Going forward, our user space
PTP stack ought to use the newer ioctls (if available) from day one.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
This patch add team interface activebackup mode support. As linux team use
genl netlink message, when we get a rtnl link change notify, we have to setup
a new genl socket and request the current active port.
v2: check nlmsg_len before copy rta_data
v3: a) Do not make rtnl_buf global as it may be freed by calling rtnl_close()
while we are using it in rtnl_link_status()
b) Reorder declarations of variables as reversed Christmas tree for
function rtnl_link_status()
c) remove rtnl_len
v4: Remove the first !rtnl_buf check in rtnl_link_status as it's alway true
v5: a) Re-order {nl, rtnl}_open and add function nl_close()
b) revert the v3_{a,c}, v4 changes, use nl_close to close genl fd
c) do not use len in get_team_active_iface() as it may mislead reader
v6: Return index at the end to fix fd leak in get_team_active_iface()
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
This patch adds new code that handles unicast service contracts,
sending messages according the negotiated schedule.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
We will want to use this macro in more than one source file. This patch
moves the macro into the common header for possibly undefined code.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
The 1588 standard defines one step operation for both Sync and
PDelay_Resp messages. Up until now, hardware with P2P one step has
been rare, and kernel support was lacking. This patch adds support of
the mode in anticipation of new kernel and hardware developments.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
I stumbled across a kernel commit that fixes the macro that convert
between file descriptors and clock ID types (see below). This patch
corrects the FD-to-clockid macro by casting to unsigned before
shifting.
commit 29f1b2b0fecfae69e31833836f1da3136696eee5
Author: Nick Desaulniers <nick.desaulniers@gmail.com>
Date: Thu Dec 28 22:11:36 2017 -0500
posix-timers: Prevent UB from shifting negative signed value
Shifting a negative signed number is undefined behavior. Looking at the
macros MAKE_PROCESS_CPUCLOCK and FD_TO_CLOCKID, it seems that the
subexpression:
(~(clockid_t) (pid) << 3)
where clockid_t resolves to a signed int, which once negated, is
undefined behavior to shift the value of if the results thus far are
negative.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Update function rtnl_link_status to get bond slave info. Pass the slave index
to call back functions. i.e. port_link_status.
Also check the interface index of rtnl message in function rtnl_link_status.
Then we don't need to check it in port_link_status.
Add ifndef IFLA_BOND_MAX in case we build linuxptp on kernel before v3.13-rc1.
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Unfortunately uClinux is rather inconsistent with respect to
clock_nanosleep(). Older versions of uclibc lack that function, while
newer versions may include the declaration but still lack the
definition, depending on whether pthreads are selected in the
configuration.
This patch works around uClinux shortcomings by using the library call
when available at compile time, otherwise falling back to syscall().
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
The current implementation fetches a transmit time stamp by polling on the
socket with pollfd.events set to zero, and then checking if POLLERR has
been returned by the kernel in pollfd.revents. This has the unfortunate
side effect of sleeping in poll() for the entire time out duration,
regardless of when the error queue becomes readable.
Linux kernel version 3.10 introduced a new socket option that allows
polling for transmit time stamps explicitly, waking the process as soon as
a time stamp becomes available. This patch enables the socket option,
falling back to the old behavior if necessary.
Suggested-by: Joe Schaack <jschaack@xes-inc.com>
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
In order to allow hwtstamp_ctl to use the non-destructive SIOCGHWTSTAMP
ioctl, we need to add it to missing.h, in order to prevent build failure
on older kernels which don't have this support.
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
This patch adds a semicolon forgotten in commit
5bf265e "missing: add onestep sync to missing.h"
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
this patch uses grep to test whether the net_tstamp.h header has
HWTSTAMP_TX_ONESTEP_SYNC flag defined. If it doesn't then we can simply define
it with the correct value. This works because proper drivers should just report
that the value is not allowed if they don't support onestep mode. This is the
cleanest way to ensure that linuxptp will still work on kernels which have not
defined the one step flag, and also works for any distributions which backport
the feature.
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
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>
This commit gets the project off to a good start. The header files provide
some basic data types and definitions.
The README file will most probably grow over time.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>