Xilinx-CNS / sfptpd

Solarflare Enhanced PTP Daemon. Use multiple PTP and PPS sources and sync local clocks together in one integrated application with high quality timestamp filtering, supporting bonds and VLANs, real time and long term stats reporting.
Other
25 stars 4 forks source link

Add tstool and option to deduplicate phc devices #16

Open abower-amd opened 3 weeks ago

abower-amd commented 3 weeks ago

Drivers for non-Solarflare NICs which present multiple PHC devices for the same underlying clock break sfptpd's monolithic model of managing clock sync between all the NICs on the system as well as any remote sync involved because sfptpd cannot discover the true underlying relationship between the PHC devices and their underlying clocks.

This patch series adds an option phc_dedup on which can be used in the [general] configuration section to perform a destructive calibration exercise at startup to determine mappings between PHC devices and underlying clocks in order to choose which devices sfptpd should use for syncing.

A new tool, tstool, is also added which can help with testing this feature along with other useful control and status operations. This means that similar tools supplied with other PTP daemons do not need to be installed when sfptpd is installed, simply to script some system administration housekeeping exercises.

Here are some useful command examples:

tstool clock list
tstool clock info phc1
tstool clock get phc1
tstool clock step phc1 1.000
tstool clock set_to phc1 system
tstool clock diff phc1 phc2
tstool clock dedup
tstool interface list
tstool interface info enp4s0f0
tstool interface set_ts on all
$ sudo build/tstool clock diff eno8303 ens1f0
2024-10-11 15:40:12.666234: info: phc0: using diff method SYS_OFFSET_EXTENDED
2024-10-11 15:40:12.666734: info: phc1: using diff method SYS_OFFSET_EXTENDED
2024-10-11 15:40:12.668510: info: phc2: using diff method SYS_OFFSET_PRECISE
phc0-phc2: -0.508612751000
$ sudo build/tstool clock step eno8303 0.5
2024-10-11 15:40:34.953420: info: phc0: using diff method SYS_OFFSET_EXTENDED
2024-10-11 15:40:34.954127: info: phc1: using diff method SYS_OFFSET_EXTENDED
2024-10-11 15:40:34.955823: info: phc2: using diff method SYS_OFFSET_PRECISE
2024-10-11 15:40:34.957185: info: clock phc0: applying offset 0.500000000 seconds
$ sudo build/tstool clock diff eno8303 ens1f0
2024-10-11 15:40:37.407696: info: phc0: using diff method SYS_OFFSET_EXTENDED
2024-10-11 15:40:37.408176: info: phc1: using diff method SYS_OFFSET_EXTENDED
2024-10-11 15:40:37.409940: info: phc2: using diff method SYS_OFFSET_PRECISE
phc0-phc2: -0.008619378000

And an example of the deduplication process:

$ sudo build/tstool clock dedup
2024-07-15 10:55:49.803383: info: phc0: using diff method SYS_OFFSET_EXTENDED
2024-07-15 10:55:49.804448: info: phc1: using diff method SYS_OFFSET_EXTENDED
2024-07-15 10:55:49.805479: info: phc2: using diff method SYS_OFFSET_EXTENDED
2024-07-15 10:55:49.806482: info: phc4: using diff method SYS_OFFSET_EXTENDED
2024-07-15 10:55:49.809066: info: phc3: using diff method SYS_OFFSET_PRECISE
2024-07-15 10:55:49.811074: notice: clock: identifying duplicate phc clocks, a destructive operation
2024-07-15 10:55:49.811122: info: interface eno1: suspended hardware timestamping
2024-07-15 10:55:49.811180: info: interface eno2: suspended hardware timestamping
2024-07-15 10:55:49.811254: info: interface eno3: suspended hardware timestamping
2024-07-15 10:55:49.811332: info: interface eno4: suspended hardware timestamping
2024-07-15 10:55:49.811394: info: clock phc0: applying offset -1.000000000 seconds
2024-07-15 10:55:50.811652: info: clock phc0: deduplication: phc0 governs phc1
2024-07-15 10:55:50.811728: info: clock phc0: deduplication: phc0 governs phc2
2024-07-15 10:55:50.811789: info: clock phc0: deduplication: phc0 governs phc4
2024-07-15 10:55:50.811799: info: clock phc0: applying offset 1.000000000 seconds
2024-07-15 10:55:51.811934: info: clock phc1: applying offset -1.000000000 seconds
2024-07-15 10:55:52.812167: info: clock phc1: deduplication: did not take test adjustment
2024-07-15 10:55:52.812307: info: clock phc1: applying offset 1.000000000 seconds
2024-07-15 10:55:53.812467: info: clock phc2: applying offset -1.000000000 seconds
2024-07-15 10:55:54.812700: info: clock phc2: deduplication: did not take test adjustment
2024-07-15 10:55:54.812843: info: clock phc2: applying offset 1.000000000 seconds
2024-07-15 10:55:55.812996: info: clock phc4: applying offset -1.000000000 seconds
2024-07-15 10:55:56.813225: info: clock phc4: deduplication: did not take test adjustment
2024-07-15 10:55:56.813366: info: clock phc4: applying offset 1.000000000 seconds
2024-07-15 10:55:57.813498: notice: clock: identification of duplicate phc clocks complete
2024-07-15 10:55:57.813538: info: interface eno1: restored hardware timestamping setting
2024-07-15 10:55:57.813553: info: interface eno2: restored hardware timestamping setting
2024-07-15 10:55:57.813569: info: interface: reassigned eno2 to nic id 0
2024-07-15 10:55:57.813585: info: interface eno3: restored hardware timestamping setting
2024-07-15 10:55:57.813597: info: interface: reassigned eno3 to nic id 0
2024-07-15 10:55:57.813617: info: interface eno4: restored hardware timestamping setting
2024-07-15 10:55:57.813628: info: interface: reassigned eno4 to nic id 0