Subject: Re: new TIODCDTIMESTAMP patch
To: None <jonathan@DSG.Stanford.EDU>
From: Chris Torek <torek@BSDI.COM>
List: tech-kern
Date: 04/21/1998 18:50:02
>Are there any apps that care about an in-kernel timestamp of the "most
>recent" input char, irrespective of which char it is?

Probably not.

>My take is that you'd probably want two distinct _separate_ timestamps
>here: one for the data stream and one for the DCD edge(s).

If this *is* the case, you would probably want a separate mode (the
virtual equivalent of a line discipline) for stamping input data
-- but I had gathered that non-PPS clocks did not have a DCD (or
DTR or whatever other pin you might need because of serial port
weirdness) stamp, so that the situation was always one or the other,
never both.  That does not mean that character-at-a-time stamping
should be enabled through this particular interface (see below),
although it would be an option.

>> GTSTAMP might well be in common code (while STSTAMP gets examined by
>> the driver -- maybe DCD is not available on particular serial
>> ports).

>But putting these in common code loses, unless we also move the
>timestamp value to the struct tty.

You misunderstand: GTSTAMP does not retrieve the time stamp itself.
Rather, it retrieves the current "time stamp mode" setting (so that
you can get the mode, set a new mode, run for a while, and restore
the old mode).  There should be at least one more ioctl (which
needs a name -- GETLASTSTAMP?) to get the most recent timestamp
(which, in the brave new POSIX world, should now be a timespec
rather than a timeval).

>What would you recommend: a distinct ioctl() to fetch each kind of
>timestamp, or one ioctl() which takes a timeval/timespec and an
>encoding of which timestamp stream (and resolution) to fetch?

I have no strong opinions on how to implement per-character time
stamps, although line-discipline- or virtual-equivalent-wise, an
interleaved data stream of the form <character,timestamp> (where
each of those two components is a fixed number of bytes) might be
the best method.  (It avoids the synchronization problems inherent
in separate datastreams.  The kernel code for appending and reading
the interleaved data would presumably maintain the record boundaries,
rather like datagram sockets, to avoid the half-a-record problem.)

If per-character time stamping were a line discipline, that mode
would be set with TIOCSETD (and be independent of any PPS-style
stamping).

Chris