162306a36Sopenharmony_ci.. SPDX-License-Identifier: GPL-2.0
262306a36Sopenharmony_ci
362306a36Sopenharmony_ci================================================
462306a36Sopenharmony_ciPLIP: The Parallel Line Internet Protocol Device
562306a36Sopenharmony_ci================================================
662306a36Sopenharmony_ci
762306a36Sopenharmony_ciDonald Becker (becker@super.org)
862306a36Sopenharmony_ciI.D.A. Supercomputing Research Center, Bowie MD 20715
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ciAt some point T. Thorn will probably contribute text,
1162306a36Sopenharmony_ciTommy Thorn (tthorn@daimi.aau.dk)
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ciPLIP Introduction
1462306a36Sopenharmony_ci-----------------
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ciThis document describes the parallel port packet pusher for Net/LGX.
1762306a36Sopenharmony_ciThis device interface allows a point-to-point connection between two
1862306a36Sopenharmony_ciparallel ports to appear as a IP network interface.
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ciWhat is PLIP?
2162306a36Sopenharmony_ci=============
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_ciPLIP is Parallel Line IP, that is, the transportation of IP packages
2462306a36Sopenharmony_ciover a parallel port. In the case of a PC, the obvious choice is the
2562306a36Sopenharmony_ciprinter port.  PLIP is a non-standard, but [can use] uses the standard
2662306a36Sopenharmony_ciLapLink null-printer cable [can also work in turbo mode, with a PLIP
2762306a36Sopenharmony_cicable]. [The protocol used to pack IP packages, is a simple one
2862306a36Sopenharmony_ciinitiated by Crynwr.]
2962306a36Sopenharmony_ci
3062306a36Sopenharmony_ciAdvantages of PLIP
3162306a36Sopenharmony_ci==================
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ciIt's cheap, it's available everywhere, and it's easy.
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ciThe PLIP cable is all that's needed to connect two Linux boxes, and it
3662306a36Sopenharmony_cican be built for very few bucks.
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ciConnecting two Linux boxes takes only a second's decision and a few
3962306a36Sopenharmony_ciminutes' work, no need to search for a [supported] netcard. This might
4062306a36Sopenharmony_cieven be especially important in the case of notebooks, where netcards
4162306a36Sopenharmony_ciare not easily available.
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_ciNot requiring a netcard also means that apart from connecting the
4462306a36Sopenharmony_cicables, everything else is software configuration [which in principle
4562306a36Sopenharmony_cicould be made very easy.]
4662306a36Sopenharmony_ci
4762306a36Sopenharmony_ciDisadvantages of PLIP
4862306a36Sopenharmony_ci=====================
4962306a36Sopenharmony_ci
5062306a36Sopenharmony_ciDoesn't work over a modem, like SLIP and PPP. Limited range, 15 m.
5162306a36Sopenharmony_ciCan only be used to connect three (?) Linux boxes. Doesn't connect to
5262306a36Sopenharmony_cian existing Ethernet. Isn't standard (not even de facto standard, like
5362306a36Sopenharmony_ciSLIP).
5462306a36Sopenharmony_ci
5562306a36Sopenharmony_ciPerformance
5662306a36Sopenharmony_ci===========
5762306a36Sopenharmony_ci
5862306a36Sopenharmony_ciPLIP easily outperforms Ethernet cards....(ups, I was dreaming, but
5962306a36Sopenharmony_ciit *is* getting late. EOB)
6062306a36Sopenharmony_ci
6162306a36Sopenharmony_ciPLIP driver details
6262306a36Sopenharmony_ci-------------------
6362306a36Sopenharmony_ci
6462306a36Sopenharmony_ciThe Linux PLIP driver is an implementation of the original Crynwr protocol,
6562306a36Sopenharmony_cithat uses the parallel port subsystem of the kernel in order to properly
6662306a36Sopenharmony_cishare parallel ports between PLIP and other services.
6762306a36Sopenharmony_ci
6862306a36Sopenharmony_ciIRQs and trigger timeouts
6962306a36Sopenharmony_ci=========================
7062306a36Sopenharmony_ci
7162306a36Sopenharmony_ciWhen a parallel port used for a PLIP driver has an IRQ configured to it, the
7262306a36Sopenharmony_ciPLIP driver is signaled whenever data is sent to it via the cable, such that
7362306a36Sopenharmony_ciwhen no data is available, the driver isn't being used.
7462306a36Sopenharmony_ci
7562306a36Sopenharmony_ciHowever, on some machines it is hard, if not impossible, to configure an IRQ
7662306a36Sopenharmony_cito a certain parallel port, mainly because it is used by some other device.
7762306a36Sopenharmony_ciOn these machines, the PLIP driver can be used in IRQ-less mode, where
7862306a36Sopenharmony_cithe PLIP driver would constantly poll the parallel port for data waiting,
7962306a36Sopenharmony_ciand if such data is available, process it. This mode is less efficient than
8062306a36Sopenharmony_cithe IRQ mode, because the driver has to check the parallel port many times
8162306a36Sopenharmony_ciper second, even when no data at all is sent. Some rough measurements
8262306a36Sopenharmony_ciindicate that there isn't a noticeable performance drop when using IRQ-less
8362306a36Sopenharmony_cimode as compared to IRQ mode as far as the data transfer speed is involved.
8462306a36Sopenharmony_ciThere is a performance drop on the machine hosting the driver.
8562306a36Sopenharmony_ci
8662306a36Sopenharmony_ciWhen the PLIP driver is used in IRQ mode, the timeout used for triggering a
8762306a36Sopenharmony_cidata transfer (the maximal time the PLIP driver would allow the other side
8862306a36Sopenharmony_cibefore announcing a timeout, when trying to handshake a transfer of some
8962306a36Sopenharmony_cidata) is, by default, 500usec. As IRQ delivery is more or less immediate,
9062306a36Sopenharmony_cithis timeout is quite sufficient.
9162306a36Sopenharmony_ci
9262306a36Sopenharmony_ciWhen in IRQ-less mode, the PLIP driver polls the parallel port HZ times
9362306a36Sopenharmony_ciper second (where HZ is typically 100 on most platforms, and 1024 on an
9462306a36Sopenharmony_ciAlpha, as of this writing). Between two such polls, there are 10^6/HZ usecs.
9562306a36Sopenharmony_ciOn an i386, for example, 10^6/100 = 10000usec. It is easy to see that it is
9662306a36Sopenharmony_ciquite possible for the trigger timeout to expire between two such polls, as
9762306a36Sopenharmony_cithe timeout is only 500usec long. As a result, it is required to change the
9862306a36Sopenharmony_citrigger timeout on the *other* side of a PLIP connection, to about
9962306a36Sopenharmony_ci10^6/HZ usecs. If both sides of a PLIP connection are used in IRQ-less mode,
10062306a36Sopenharmony_cithis timeout is required on both sides.
10162306a36Sopenharmony_ci
10262306a36Sopenharmony_ciIt appears that in practice, the trigger timeout can be shorter than in the
10362306a36Sopenharmony_ciabove calculation. It isn't an important issue, unless the wire is faulty,
10462306a36Sopenharmony_ciin which case a long timeout would stall the machine when, for whatever
10562306a36Sopenharmony_cireason, bits are dropped.
10662306a36Sopenharmony_ci
10762306a36Sopenharmony_ciA utility that can perform this change in Linux is plipconfig, which is part
10862306a36Sopenharmony_ciof the net-tools package (its location can be found in the
10962306a36Sopenharmony_ciDocumentation/Changes file). An example command would be
11062306a36Sopenharmony_ci'plipconfig plipX trigger 10000', where plipX is the appropriate
11162306a36Sopenharmony_ciPLIP device.
11262306a36Sopenharmony_ci
11362306a36Sopenharmony_ciPLIP hardware interconnection
11462306a36Sopenharmony_ci-----------------------------
11562306a36Sopenharmony_ci
11662306a36Sopenharmony_ciPLIP uses several different data transfer methods.  The first (and the
11762306a36Sopenharmony_cionly one implemented in the early version of the code) uses a standard
11862306a36Sopenharmony_ciprinter "null" cable to transfer data four bits at a time using
11962306a36Sopenharmony_cidata bit outputs connected to status bit inputs.
12062306a36Sopenharmony_ci
12162306a36Sopenharmony_ciThe second data transfer method relies on both machines having
12262306a36Sopenharmony_cibi-directional parallel ports, rather than output-only ``printer``
12362306a36Sopenharmony_ciports.  This allows byte-wide transfers and avoids reconstructing
12462306a36Sopenharmony_cinibbles into bytes, leading to much faster transfers.
12562306a36Sopenharmony_ci
12662306a36Sopenharmony_ciParallel Transfer Mode 0 Cable
12762306a36Sopenharmony_ci==============================
12862306a36Sopenharmony_ci
12962306a36Sopenharmony_ciThe cable for the first transfer mode is a standard
13062306a36Sopenharmony_ciprinter "null" cable which transfers data four bits at a time using
13162306a36Sopenharmony_cidata bit outputs of the first port (machine T) connected to the
13262306a36Sopenharmony_cistatus bit inputs of the second port (machine R).  There are five
13362306a36Sopenharmony_cistatus inputs, and they are used as four data inputs and a clock (data
13462306a36Sopenharmony_cistrobe) input, arranged so that the data input bits appear as contiguous
13562306a36Sopenharmony_cibits with standard status register implementation.
13662306a36Sopenharmony_ci
13762306a36Sopenharmony_ciA cable that implements this protocol is available commercially as a
13862306a36Sopenharmony_ci"Null Printer" or "Turbo Laplink" cable.  It can be constructed with
13962306a36Sopenharmony_citwo DB-25 male connectors symmetrically connected as follows::
14062306a36Sopenharmony_ci
14162306a36Sopenharmony_ci    STROBE output	1*
14262306a36Sopenharmony_ci    D0->ERROR	2 - 15		15 - 2
14362306a36Sopenharmony_ci    D1->SLCT	3 - 13		13 - 3
14462306a36Sopenharmony_ci    D2->PAPOUT	4 - 12		12 - 4
14562306a36Sopenharmony_ci    D3->ACK	5 - 10		10 - 5
14662306a36Sopenharmony_ci    D4->BUSY	6 - 11		11 - 6
14762306a36Sopenharmony_ci    D5,D6,D7 are   7*, 8*, 9*
14862306a36Sopenharmony_ci    AUTOFD output 14*
14962306a36Sopenharmony_ci    INIT   output 16*
15062306a36Sopenharmony_ci    SLCTIN	17 - 17
15162306a36Sopenharmony_ci    extra grounds are 18*,19*,20*,21*,22*,23*,24*
15262306a36Sopenharmony_ci    GROUND	25 - 25
15362306a36Sopenharmony_ci
15462306a36Sopenharmony_ci    * Do not connect these pins on either end
15562306a36Sopenharmony_ci
15662306a36Sopenharmony_ciIf the cable you are using has a metallic shield it should be
15762306a36Sopenharmony_ciconnected to the metallic DB-25 shell at one end only.
15862306a36Sopenharmony_ci
15962306a36Sopenharmony_ciParallel Transfer Mode 1
16062306a36Sopenharmony_ci========================
16162306a36Sopenharmony_ci
16262306a36Sopenharmony_ciThe second data transfer method relies on both machines having
16362306a36Sopenharmony_cibi-directional parallel ports, rather than output-only ``printer``
16462306a36Sopenharmony_ciports.  This allows byte-wide transfers, and avoids reconstructing
16562306a36Sopenharmony_cinibbles into bytes.  This cable should not be used on unidirectional
16662306a36Sopenharmony_ci``printer`` (as opposed to ``parallel``) ports or when the machine
16762306a36Sopenharmony_ciisn't configured for PLIP, as it will result in output driver
16862306a36Sopenharmony_ciconflicts and the (unlikely) possibility of damage.
16962306a36Sopenharmony_ci
17062306a36Sopenharmony_ciThe cable for this transfer mode should be constructed as follows::
17162306a36Sopenharmony_ci
17262306a36Sopenharmony_ci    STROBE->BUSY 1 - 11
17362306a36Sopenharmony_ci    D0->D0	2 - 2
17462306a36Sopenharmony_ci    D1->D1	3 - 3
17562306a36Sopenharmony_ci    D2->D2	4 - 4
17662306a36Sopenharmony_ci    D3->D3	5 - 5
17762306a36Sopenharmony_ci    D4->D4	6 - 6
17862306a36Sopenharmony_ci    D5->D5	7 - 7
17962306a36Sopenharmony_ci    D6->D6	8 - 8
18062306a36Sopenharmony_ci    D7->D7	9 - 9
18162306a36Sopenharmony_ci    INIT -> ACK  16 - 10
18262306a36Sopenharmony_ci    AUTOFD->PAPOUT 14 - 12
18362306a36Sopenharmony_ci    SLCT->SLCTIN 13 - 17
18462306a36Sopenharmony_ci    GND->ERROR	18 - 15
18562306a36Sopenharmony_ci    extra grounds are 19*,20*,21*,22*,23*,24*
18662306a36Sopenharmony_ci    GROUND	25 - 25
18762306a36Sopenharmony_ci
18862306a36Sopenharmony_ci    * Do not connect these pins on either end
18962306a36Sopenharmony_ci
19062306a36Sopenharmony_ciOnce again, if the cable you are using has a metallic shield it should
19162306a36Sopenharmony_cibe connected to the metallic DB-25 shell at one end only.
19262306a36Sopenharmony_ci
19362306a36Sopenharmony_ciPLIP Mode 0 transfer protocol
19462306a36Sopenharmony_ci=============================
19562306a36Sopenharmony_ci
19662306a36Sopenharmony_ciThe PLIP driver is compatible with the "Crynwr" parallel port transfer
19762306a36Sopenharmony_cistandard in Mode 0.  That standard specifies the following protocol::
19862306a36Sopenharmony_ci
19962306a36Sopenharmony_ci   send header nibble '0x8'
20062306a36Sopenharmony_ci   count-low octet
20162306a36Sopenharmony_ci   count-high octet
20262306a36Sopenharmony_ci   ... data octets
20362306a36Sopenharmony_ci   checksum octet
20462306a36Sopenharmony_ci
20562306a36Sopenharmony_ciEach octet is sent as::
20662306a36Sopenharmony_ci
20762306a36Sopenharmony_ci	<wait for rx. '0x1?'>	<send 0x10+(octet&0x0F)>
20862306a36Sopenharmony_ci	<wait for rx. '0x0?'>	<send 0x00+((octet>>4)&0x0F)>
20962306a36Sopenharmony_ci
21062306a36Sopenharmony_ciTo start a transfer the transmitting machine outputs a nibble 0x08.
21162306a36Sopenharmony_ciThat raises the ACK line, triggering an interrupt in the receiving
21262306a36Sopenharmony_cimachine.  The receiving machine disables interrupts and raises its own ACK
21362306a36Sopenharmony_ciline.
21462306a36Sopenharmony_ci
21562306a36Sopenharmony_ciRestated::
21662306a36Sopenharmony_ci
21762306a36Sopenharmony_ci  (OUT is bit 0-4, OUT.j is bit j from OUT. IN likewise)
21862306a36Sopenharmony_ci  Send_Byte:
21962306a36Sopenharmony_ci     OUT := low nibble, OUT.4 := 1
22062306a36Sopenharmony_ci     WAIT FOR IN.4 = 1
22162306a36Sopenharmony_ci     OUT := high nibble, OUT.4 := 0
22262306a36Sopenharmony_ci     WAIT FOR IN.4 = 0
223