[LinuxPPS] [RFC] time_pps_createbyname()
Frank Kardel
kardel at ntp.org
Sun Aug 5 16:19:50 CEST 2007
Hello Rudolfo !
Thanks for your work providing a PPS source for Linux.
I have been looking quite a while into LinuxPPS and it's integration
into ntpd.
I see that integrating LinuxPPS into ntpd requires source modification
of quite a few drivers in ntpd. This is caused by a non-standard
way of implementing the PPSAPI (RFC2783). The motivation for this
is, as I understand, the wish to support more PPS capable devices that do
not necessarily have a PPSAPI implementation. While this is an
understandable goal it causes many headaches wrt/ ntpd integration.
The main headaches are:
- supporting a different version of PPSAPI in PPSAPI capable
refclocks.
- naming - there is still the need to configure the right sources and
ntpd configuration system is, while still improving, very limited
there. Much of the configuration magic is done by accessing well
known file names.
I believe the changing the PPSAPI causes more grief than it does good.
Scanning through this list there are many requests for supporting some
kind of refclock driver. There are patches for certain drivers out there,
but the world is far from perfect in this regard.
How about following a different path:
LinuxPPS already has everything there to support a standard PPSAPI
implementation
without the need to deviate from the other PPSAPI implementations.
Just three things are needed to get things working without much headaches:
- revert the PPSAPI implementation back to a clean file based one.
(yes I read your FAQs - read on)
- IMPORTANT: use the files listed via SYSFS and add the PPSAPI to
these files - gives you instant
file based PPSAPI via LinuxPPS which ntpd can use directly. Thus the
pps sources show up as PPSAPI
capable files in SYSFS.
- change refclock drivers to allow for a separate PPSAPI capable file
(PARSE already does this /dev/refclock-? and /dev/refclockpps-? for
PPSAPI,
ATOM would work out of the box).
This way
- ATOM can ve used without any patch.
- PARSE works out of the box and the other
- refclock drivers can grow separate PPS device files which benefits
them
in other PPSAPI environments also.
- number of separate patches for ntpd can be reduced (along with
maintenance
burden) to zero when all PPSAPI refclocks can make use of an
alternate PPSAPI file
- special casing in ntpd is removed.
- chances of integration increase because ntpd can be used out of
the box and
ntpd can use LinuxPPS out of th box too.
I think this proposal can reduce the many headaches and delivers more
benefits than
just clumsily supporting another non-standard PPS source.
The more we can keep special casing out of ntpd the better it is - the
ntp development
team just can not support every interface idea out there - thats why
PPSAPI was created.
We where entangled in roughly 4 different PPS capable PPS interfaces -
it was no
fun to maintain that.
For some comments about the headaches with LinuxPPS (old API) see
also https://support.ntp.org/bugs/show_bug.cgi?id=610
Thoughts ?
Best regards,
Frank Kardel (kardel at ntp.org)
Rodolfo Giometti wrote:
> Hello,
>
> I'm looking at userland API and I think we should define it better...
> I think we should force users to avoid using of time_pps_create() by
> modifying it as follow:
>
> int time_pps_create(int source, pps_handle_t *handle)
> {
> errno = EINVAL;
> return -1;
> }
>
> and adding a new and more appropriate function to obtain a PPS handle:
>
> int time_pps_createbyname(char *name, pps_handle_t *handle, int flags);
>
> This doesn't mean that other PPS implementations cannot define
> time_pps_create() but with the Linux one we _must_ avoid using it.
>
> The field "flags" can be used to specify searching criteria. For
> example:
>
> PPS_NAME match "name" with PPS source's name
> PPS_PATH match "name" with PPS source's path
> PPS_RANDOM just return at least one PPS source if present
> etc.
>
> So NTPD refclocks drivers can be easily modified as follow:
>
> /*
> * Start the PPSAPI interface if it is there. Default to use
> * the assert edge and do not enable the kernel hardpps.
> */
> #ifdef PPS_HAVE_CREATEBYNAME
> if (time_pps_createbyname(device, &up->handle, PPS_PATH) < 0) {
> #else
> if (time_pps_create(fd, &up->handle) < 0) {
> #endif
> up->handle = 0;
> msyslog(LOG_ERR,
> "refclock_nmea: time_pps_create failed: %m");
> return (1);
> }
> return(nmea_ppsapi(peer, 0, 0));
>
> Suggestions? :)
>
> Rodolfo
>
>
More information about the LinuxPPS
mailing list