Subject: Re: NTP pulse-per-second timestamp diffTo:
To: Jonathan Stone <jonathan@dsg.stanford.edu>
From: Bill Studenmund <wrstuden@loki.stanford.edu>
List: tech-kern
Date: 03/27/1998 10:14:27
On Fri, 27 Mar 1998, Jonathan Stone wrote:

> I would like to stick to the technical issues.  Can we *please* get
> back to discussing the TIOCDCDTIMETAMP patch?  Here it is again:
> 
> Index: com.c
> ===================================================================
> RCS file: /cvsroot/src/sys/dev/ic/com.c,v
> retrieving revision 1.143
> diff -c -r1.143 com.c
> *** com.c	1998/03/22 00:55:37	1.143
> --- com.c	1998/03/26 02:47:39
> ***************
> *** 603,608 ****
> --- 603,609 ----
>   		com_modem(sc, 0);
>   		(void) tsleep(sc, TTIPRI, ttclos, hz);
>   	}
> + 	sc->sc_dcd_timestamping = 0;
>   
>   	/* Turn off interrupts. */
>   #ifdef DDB
> ***************
> *** 933,938 ****
> --- 934,943 ----
>   		*(int *)data = bits;
>   		break;
>   	}
> + 	case TIOCDCDTIMESTAMP:
> + 		com->sc_dcd_timestamping = 1;
> + 		*(struct timeval *)data = com->dcd_timestamp;
> + 		break;
>   	default:
>   		error = ENOTTY;
>   		break;
> ***************
> *** 1749,1754 ****
> --- 1754,1763 ----
>   		sc->sc_msr = msr;
>   		if (ISSET(delta, sc->sc_msr_mask)) {
>   			SET(sc->sc_msr_delta, delta);
> + 
> + 			if (sc->sc_dcd_timestamping && ISSET(delta, MSR_DCD)) {
> + 				microtime(&sc->sc_dcd_timestamp);
> + 			}
>   
>   			/*
>   			 * Stop output immediately if we lose the output
> Index: comvar.h
> ===================================================================
> RCS file: /cvsroot/src/sys/dev/ic/comvar.h,v
> retrieving revision 1.22
> diff -c -r1.22 comvar.h
> *** comvar.h	1998/02/02 23:01:05	1.22
> --- comvar.h	1998/03/26 02:55:02
> ***************
> *** 109,114 ****
> --- 109,117 ----
>   	void (*disable) __P((struct com_softc *));
>   	int enabled;
>   
> + 	int	sc_dcd_timestamping;		/* boolean flag */
> + 	struct timeval	sc_dcd_timestamp;
> + 
>   #if NRND > 0 && defined(RND_COM)
>   	rndsource_element_t  rnd_source;
>   #endif
> 
> 
> 
> now, can somebody give me a sane, rational, technical explanation of
> where this is adding ``too much cruft'' to the serial driver?

I don't think this would be "too much cruft." Timestamping every
character, yes. But as you say, that's a different issue. :-)

These cahnges seem fairly simple and sane. They should drop into the zs
driver fairly well, too.

Two comments:

1) Maybe make it a kernel option, so folks who DON'T want it (and will
jump up and down about it :-) don't have to have it.

2) What actually uses that timestamp? Something in another code change?

Oh, how about 3. :-)  Maybe throw the variables into the tty structure
while leaving the ioctl code in the com driver.  That way there's an M.I.
way to get at the timestamps and little duplicated code, but a driver
which doesn't support it will reject the ioctl, never setting
dcd_timestamping.

Take care,

Bill