RTL8139: Difference between revisions

Jump to navigation Jump to search
2,781 bytes added ,  7 years ago
Information on packet transmission.
[unchecked revision][unchecked revision]
No edit summary
(Information on packet transmission.)
Line 141:
outportb(ioaddr + 0x37, 0x0C); // Sets the RE and TE bits high
</source>
 
=== Transmitting Packets ===
The RTL8139 NIC uses a round robin style for transmitting packets. It has four transmit buffer (a.k.a. transmit start) registers, and four transmit status/command registers. The transmit start registers are each 32 bits long, and are in I/O offsets 0x20, 0x24, 0x28 and 0x2C. The transmit status/command registers are also each 32 bits long and are in I/O offsets 0x10, 0x14, 0x18 and 0x1C. Each pair of transmit start and status registers work together (i.e. registers 0x20 and 0x10 work together, 0x24 and 0x14 work together, etc.)
 
After performing a controller reset as mentioned above, the controller ignores all transmit registers except pair zero (i.e. register 0x20 for the transmit start and register 0x10 for the status/command.) After software transmits a packet using those registers, the round robin counter increments, to use pair one (i.e. register 0x24 for the transmit start and register 0x14 for the status/command.) This continues until pair number three, which is the last transmit register pair, and the counter then overflows and goes back to pair number zero. When the controller is using a specific transmit register pair, all other transmit registers are ignored, and cannot be used to transmit packets at all. Software is responsible for keeping track which pair is being used.
 
Each transmit start register contains the 32-bit physical address of the packet which is to be sent over the network.
 
Each transmit status/command register contains various bit fields that control the transmission of the packet. The table below only gives a brief about these bits. For the full format, take a look at the RTL8139 specification under "External links" below.
 
{| width="70%" border="1"
|-
|'''Bit Range'''
|'''Description'''
|-
|0-12
|'''Data size.''' This field contains the total size of the data to be sent across the network. The maximum value for this field is 1792, and larger numbers will cause an error.
|-
|13
|'''Own bit.''' When this bit is set to 1, the controller is idle and not performing any DMA transfers on this descriptor. The driver sets this bit to zero to tell the controller to start transmitting the packet. The bit then remains zero until the entire packet has been copied from RAM into the controller's internal memory via DMA. The default value after a reset is one. Setting this bit to zero also clears all other status bits in this register.
|-
|15
|'''Transmit OK.''' After the own bit has been set by the hardware, indicating the DMA transfer has completed, the hardware will start to transmit the packet across the actual network. This bit will be set to one after the network transmission has completed.
|}
 
== ISR Handler ==
Line 158 ⟶ 182:
== External Links ==
 
* [https://github.com/omarrx024/xos/tree/master/rtl8139 xOS RTL8139 Driver] (MIT license)
* http://www.magnesium.net/~wpaul/rt/spec-8139cp(150).pdf, Datasheet for the RTL8139C
* http://www.cs.usfca.edu/~cruse/cs326f04/RTL8139D_DataSheet.pdf, Datasheet for the RTL8139D, has more information
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu