Re: Piggyback or line discipline, and how?

Theodore Y. Ts'o (tytso@mit.edu)
Wed, 24 Mar 1999 10:51:46 -0500 (EST)


Date: Wed, 24 Mar 1999 15:30:20 +0100
From: Morten Norman <marten.norman@intertex.se>

The device I target the driver for, is a combined V90 modem and smartcard
reader, IX36 SC, that connects to one RS232 port. Since IX36 SC uses one
serial line, it interleaves smartcard and modem data packets. Thus it
needs a driver that controls *one* COM port, and presents one modem device
(a "clone" of the COM port) and one ("new") smartcard device.

2) Use a line discipline. Does it work for me? I can't tell myself, since
I don't understand them. Everybody's talking about line
disciplines, and appears to know them by heart. Is there a
document I have missed?? The source isn't too obvious to learn
from here :-(

This is the probably the right approach. What you will need to do is
write something which looks like a line discpline to the serial driver,
and which looks like a tty driver to the end line discpline.

Here's a picture of the data flow in the tty layer:

User-mode program Network layer
| |
| |
NTTY line discpline SLIP/PPP line discpline
| /
\ /
\ /
TTY hardware driver
|
|
Hardware

Now what you want to do is to is to insert a shim layer between the
line discplines and the tty hardware driver, and the easist way to do
this would be to create a shim layer which consists of a line discpline
and a tty driver, back-to-back, like this:

User-mode program Network layer
| |
| |
NTTY line discpline SLIP/PPP line discpline
| /
| /
=============================
| IX36 SC tty driver |
| | |
| IX36 SC line discpline--+----> data for the smartcard
============================
|
|
Serial driver
|
|
Hardware

>From the point of view of the the user programs, there will be a new set
of tty devices which your driver will export. From the point of view of
the serial driver, at boot time a user-mode program will program the tty
so that its line discpline is assigned to your new IX36 SC line
discpline, so that your driver gets a copy of the raw serial datastream
(including indications of parity errors, framing errors, etc, which you
will need to pass up to the chain if you want the upper-layer line
discpline to see these errors).

As far as learning what the interfaces look like, my best suggestion is
to look at the comtrol Rocketport driver for an example of a fairly
clean tty driver (drivers/char/rocket.c), and the PPP line discpline as
an example of fairly easy to understand line discipline
(drivers/net/ppp.c). Also take a look at include/linux/tty_driver.h and
include/linux/tty_ldisc.h. The header files have a pretty good
documentation of the various functions which must be implemented by a
tty driver and a line discipline.

I hope this helps!

- Ted

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/