[Linuxptp-devel] [PATCH RFC 5/7] port: Check for virtual clocks.
PTP IEEE 1588 stack for Linux
Brought to you by:
rcochran
From: Miroslav L. <mli...@re...> - 2022-01-13 15:55:15
|
If the PHC specified with the phc_index or -p option is a virtual clock of the interface, bind sockets to the virtual clock instead of the real clock to get correct timestamps. Signed-off-by: Miroslav Lichvar <mli...@re...> --- port.c | 7 ++++++- ptp4l.8 | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/port.c b/port.c index a84ba66..5a5741d 100644 --- a/port.c +++ b/port.c @@ -3133,7 +3133,12 @@ struct port *port_open(const char *phc_device, pr_warning("%s: get_ts_info not supported", p->log_name); } else if (p->phc_index >= 0 && p->phc_index != interface_phc_index(interface)) { - if (p->jbod) { + if (rtnl_iface_has_vclock(interface_name(interface), + p->phc_index)) { + pr_info("%s: /dev/ptp%d is virtual clock", + p->log_name, p->phc_index); + interface_set_vclock(interface, phc_index); + } else if (p->jbod) { pr_warning("%s: just a bunch of devices", p->log_name); p->phc_index = interface_phc_index(interface); } else if (phc_device) { diff --git a/ptp4l.8 b/ptp4l.8 index 1d6f078..e53fcc4 100644 --- a/ptp4l.8 +++ b/ptp4l.8 @@ -377,6 +377,9 @@ The default is 0 (disabled). .TP .B phc_index Specifies the index of the PHC to be used for synchronization and timestamping. +This option is useful with Linux kernels 5.17 and later, which allow multiple +virtual clocks to be created on top of a free-running hardware clock by writing +to /sys/class/ptp/ptp*/n_vclocks. The default is -1, which means the index will be set to the PHC associated with the interface, or the device specified by the \fB-p\fP option. .TP -- 2.33.1 |