Linux RTL8002/RTL8012 Network Driver

This document describes the "ATP" Linux driver for commonly OEMed pocket (parallel port) ethernet adapters based on the Realtek RTL8002 and RTL8012 chips.

Index

Announcement

I've updated the "atp" driver for the RTL8002 based on the RTL8012 datasheet. The new driver should work with both chips, but I don't have a RTL8012 device to test with.

The new driver adds the following features over the v2.0.29 kernel version:

  • Multicast filter mode with a filter table for the 8012.
  • More accurate error counts (now that I know what the chip is reporting)
  • Better recovery from some errors.
  • Support for all kernel versions from 1.2.0 through the latest 2.1.*.
  • Loadable module support.
  • Switching the RTL8012 to and from printer pass-through mode. (This should also allow the RTL8012 to be detected when already in pass-through mode.)

Driver and Diagnostic source code

The following files are drop-in replacements for drivers/net/atp.[ch]:

Diagnostic

A diagnostic program is available from ftp://ftp.scyld.com/pub/diag/atp-diag.c It is one of the extensive Linux network adapter diagnostic and setup programs.

In 1997 Realtek made available the documentation for the second generation RTL8012 chip, which has lead to several driver improvements. http://www.realtek.com.tw/cn/cn.html.

Future plans

A future driver might add the bi-directional and ECP modes for the RTL8012.

Theory of Operation

The RTL8002 adapter seems to be built around a custom spin of the SEEQ controller core. It has a 32K internal packet buffer, of which the first 4K is devoted to transmit and the rest to receive. The controller maintains the queue of received packet and the packet buffer access pointer internally, with only 'reset to beginning' and 'skip to next packet' commands visible. The transmit packet queue holds two packets: both 'retransmit this packet' (due to collision) and 'transmit next packet' commands must be started by hand.

The station address is stored in a standard bit-serial EEPROM which must be read (ughh) by the device driver. Provisions exist in the chip for substituting a 74S288 PROM, but I haven't gotten reports of any models using it.

Unlike built-in devices, a pocket adapter can temporarily lose power without indication to the device driver. Thus the driver monitors for transmit timeouts or lack of receive activity and reinitializes the station address, receive filter (promiscuous, etc.) and transceiver.

The controller itself has two pages of 16 registers. The first bank contains contains the station address setting, and the second bank contains the multicast filter table (now used) and the EEPROM access registers. Most of the operational registers are visible in either bank. The registers are read and written 4 bits at a time in the basic printer-port mode. The four bit register address is presented on the data lines along with a few additional timing and control bits. The data is then read from status port or written to the data port.

Since the bulk data transfer of the actual packets through the slow parallel port dominates the driver's running time, four distinct data (non-register) transfer modes are provided by the adapter, two in each direction. In the first mode timing for the nibble transfers is provided through the data port. In the second mode the same timing is provided through the control port. In either case the data is read from the status port and written to the data port, just as when accessing registers.

In addition to the basic data transfer methods, several other transfer modes are supported. These are implemented by doing multiple reads of the data lines to allow them to stabilize. This delay seems to be needed on most machines. The data transfer mode is stored in the 'dev->if_port' field. Its default value is '4'. It may be overridden at boot-time using the third parameter to the "ether=..." initialization.

Bulk data writes to the packet buffer:
The first, faster method uses only the dataport (data modes 0, 2 and 4). The second (backup) method uses data and control regs (modes 1, 3 and 5). It should only be needed when there is skew between the individual data lines, or on some very old laptops where the high-order line of the printer port is used for some other purpose.

The header file "atp.h" provides inline functions that encapsulate the register and data access methods. These functions are hand-tuned to generate reasonable object code. This header file also documents my interpretations of the device registers.


Change Log

v1.04 of 3/29/97.
Added code to switch the RTL8012 to and from printer pass-through mode.
v1.07 (with v1.05 and 1.06 fixes) of 3/31/97.
Re-inserted the improved module code to support multiple cards.
Changed the timer monitoring code to be only started at open() time, and be stopped when the device is closed. This fixed the kernel crash that sometimes occured when removing the module.
Fixed an accept-all-multicast mode bug. The filter table is now filled with '0xff' instead of '1'.

Linux Network Drivers Page
SCYLD information.
Author: Donald Becker, becker@scyld.com
.
See the drivers for the contact email address. Do not bother sending email to zinc.anode@scyld.com, as email to that address adds your domain or IP address to the known-spammer list.
Linux Network Drivers Page
SCYLD information.
Author: Donald Becker
See the drivers for the contact email address. Do not bother sending email to zinc.anode@scyld.com, as email to that address adds your domain or IP address to the known-spammer list.