Newsgroups: comp.os.linux.announce
From: tytso@ATHENA.MIT.EDU (Theodore Ts'o)
Subject: New tty drivers (alpha)
Message-ID: <1994Feb26.174213.28295@cs.cornell.edu>
Date: Sat, 26 Feb 1994 17:42:13 GMT
Approved: linux-announce@tc.cornell.edu (Matt Welsh)

I am happy to announce the ALPHA release of patchs to Linux's tty driver,
over 140k worth of patches.  Those patches can be found on
tsx-11.mit.edu, in:

	/pub/linux/ALPHA/tty/tty-patches.z
	/pub/linux/ALPHA/tty/tty-files.tar.gz

There are two main reasons for these patches.  The first is to allow new
low-level drivers to be written; these patches eliminate the hard-coded
TTY major number, and allow new low-level device drivers to pick and
choose new major numbers.

The second main feature added by this patch is that the line discpline
interfaces have been significantly revamped to speed up tty handling.
This should hopefully allow SLIP and PPP to be much faster, once those
modules have been rewritten to use the new line discpline interfaces.

Currently, SLIP and PPP round trip times under Linux are 80-100ms slower
than NetBSD.  Why is this?  Because the way the line discplines are
coded are amazingly inefficient.  

Currently, when a character comes into a serial port, the character is
stuffed into tty queue; then, a "bottom half" (i.e., software interrupt)
routine is called by the serial interrupt to actually process the
character.  This routine is line discpline dependent; in the case of
SLIP, it calls tty_read_data() to copy the characters out of the tty
queue, and into temporary buffer.  SLIP then calls slip_unensc() to
handle escape characters and framing characters, and during this step,
the characters are copied to yet another buffer.  If Van Jacobson
compression is turned on, then yet another copy takes place internally.
Finally, SLIP calls dev_rint() which allocates yet another buffer,
copies the packet one more time --- and signals a network "bottom half
routine".  But since all of this processing is happening in the serial
"bottom half routine", and you can't execute another bottom half routine
on top of another bottom half routine.  So, the actual SLIP packet
doesn't get processed until after the *next* interrupt, assuming that no
higher priority "bottom half routine" get invoked first.

In the new line discpline world, the tty driver is supposed to call a
given function for every character which is received at interrupt time.
The line discplines are requested to do as much processing as possible
at interrupt time, and to avoid "bottom half" routines if at all
possible.  However, since this being done as network code, it may not be
possible in cases, but it would be something to strive towards.  The
N_TTY line discpline is a good example of how that interface can be down
leaner and meaner.  Hopefully the SLIP and PPP drivers can be made
similarly laid.

To further discussions about the new tty drivers, I've created a new
mailing list, called linux-new-tty@tsx-11.mit.edu.  People who wish to
subscribe to linux-new-tty-request@tsx-11.mit.edu.  

						- Ted

P.S.  Here's the README for the tty patches....


The following patches significantly speed up the tty handling code.
It does so by establishing new interfaces for the low-level tty
drivers (i.e., the serial drivers, the pty drivers, etc.) and for the
tty line discplines (i.e., N_TTY mode, SLIP, PPP).

These patches also make it possible for new low-level device drivers
to be linked it, by removing the hard-coded assumption about the tty
major numbers that can be used.  To do this, the global tty_table[]
array has been removed, and replaced by a set of arrays maintained by
each driver, and pointed to by a tty_driver struct.  This structure
contains all of the information specific to the low-level driver, and
thus abstracts it away from the high level tty code.

The line discpline code has similarily been abstracted away.  The big
changes here are that the low level device drivers are now expected to
call a routine specified in the line discpline structure for each
incoming character *at* *interrupt* *time*.  Previously, the low level
driver merely stuffed the characters into a read queue, and then
called the line discpline "handler" in a software interrupt.  This
change allows the line discpline to do some fast interrupt level
processing, thus cutting overhead and reducing the number of times a
character has to be copied from buffer to buffer.

It turns out that with this change, enough overhead could be stripped
out of the N_TTY line discpline so that all of its processing can be
done at interrupt time, and so you don't even need to invoke a
software interrupt driver.  This will not always be the case, but it's
amazing how much lean and mean you can make code when you really put
your mind to it.  :-)

I've released these patches primarily so that people who are
interested in writing new low level tty drivers for ISDN, intelligent
serial boards, etc., and people who maintain the SLIP and PPP drivers
can (a) comment on the new interfaces, and (b) start coding to the new
interfaces.

Please send comments, bugs, suggestions, etc. to me.  Good luck, have
fun, and code safely!!!

					Theodore Ts'o
					<tytso@mit.edu>
					24-Feb-94

+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=

Note: this patch set was built on Thu Feb 24 08:25:29 EST 1994 using version: 

Linux version 0.99.15h (tytso@rt-11) #19 Thu Feb 24 07:33:43 EST 1994


