On 4/28/2021 10:14 AM, Chris Rajula wrote:
> Thank you!
> 
> It seems like setting the 'step_threshold' solved the stepping issue for me.
> 
> Now, for a follow-up question:
> I've looked but have not yet found any guide(s) on how to perform the
> following from within a C program:
> 
>   * Retrieve the master's time
>   * Retrieve the offset between the slave's time and the master's time
> 

So, retrieving offset between the two clocks is pretty complex (hence
the entire reason PTP exists.. synchronizing clocks is hard!)

You can't just "clock_gettime" on each clock and compare. How do you
know those times were captured at the same time?

You might be able to use more advanced comparison methods such as PCIe
PTM (if the clock hardware on the PCIe device supports it, and if you're
comparing to the ART derived TSC clock...)

For local clocks you could also use the clock comparison functions that
have the kernel take clock_gettime inside the kernel and use an average.
But that is just an average, not very precise.

> I assume that it should be as simple as executing two calls to
> 'clock_gettime', but that implies that I'll have to pass the correct
> 'clockid_t' values to 'clock_gettime.
> Getting the system's main clock should be simple by just passing
> CLOCK_REALTIME, but how can I determine which value of 'clockid_t'
> corresponds to the slave's PTP-synchronized clock?
> 

You can use ethtool -T to get the PTP clock device, however.... See above.

> I've sifted through 'include/uapi/linux/time.h' but I can't seem to find
> any PTP-related clock definitions there.
> Or is my only recourse to go through the LinuxPTP userspace code?
> 
> Thanks,
> /Alex

I would recommend looking at how the ioctls for PTP. I don't think there
are generic offset comparison functions for clocks in general.

Thanks,
Jake


_______________________________________________
Linuxptp-users mailing list
Linuxptp-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-users

Reply via email to