The hardware ringbuffer - PowerPoint PPT Presentation

About This Presentation
Title:

The hardware ringbuffer

Description:

The hardware ringbuffer. Understanding the RTL-8139 ... Burse Size. W. R. A. P. 0. L. O. N. G. R. U. N. T. B. C. A. S. T. M. C. A. S. T. M. A. C. A. L. L ... – PowerPoint PPT presentation

Number of Views:88
Avg rating:3.0/5.0
Slides: 17
Provided by: ProfessorA2
Learn more at: https://www.cs.usfca.edu
Category:

less

Transcript and Presenter's Notes

Title: The hardware ringbuffer


1
The hardware ringbuffer
  • Understanding the RTL-8139 mechanism for packet
    reception

2
Implementing a ringbuffer
Start address
Buffer length
Buffer storage
datum
datum
datum
datum
TAIL
HEAD
TAIL where to insert the next datum HEAD
where to remove the next datum
3
Some ringbuffer details
  • When HEAD TAIL the buffer is empty
  • The HEAD and TAIL pointers advance to the end of
    the buffer, then wrap around
  • Some storage always remains unused
  • When sizes of stored data-items are not uniform,
    then the size of each item must be stored
    somewhere probably with the item itself

4
RealTeks implementation
Receive Buffer Start Address
Receive Configuration Register
(includes size of the buffer)
Buffer storage
data
data
data
CAPR Current Address of Packet to
Read (minus 16 bytes)
CBR Current Buffer
Register (4-byte aligned)
packet header (4-bytes)
packet data (size varies)
5
Packet-Header Format
15 14 13
5 4 3
2 1 0
M A R
P A M
B A R
reserved
I S E
R U N T
L O N G
C R C
F A E
R O K
Packet Status (least significant 16 bits)
31

16
Packet Length (most significant 16 bits)
LEGEND ROK Received OK MAR (Multicast
Address Received) FAE Frame Alignment Error
PAM (Physical Address Matched) CRC CRC
Error BAR (Broadcast Address Received) LONG
Packet length exceeds 4KB RUNT Packet size
below 64 bytes ISE Invalid Symbol Error
6
Receive Algorithm
  • Reset controller (bit 4 in register CR)
  • Allocate memory and program RBSTART
  • Enable reception (bit 3 in register CR)
  • Configure reception (RXCONFIG register)
  • Adjust CAPR for size of allocated buffer
  • Optionally unmask the receive interrupts
  • Await received packet(s) (bit 0 in CR)

7
Recall RXCONFIG layout
32-bit register (offsets 0x44-0x47)
31 28 27
24 23
18 17 16
reserved
Early Receive Threshold
reserved
Mult ER INT
Rx ERR 8
15 13 12 11 10
8 7 5 4 3 2
1 0
Rx FIFO Threshold
Rx Buf Length
Max DMA Burse Size
W R A P
0
L O N G
R U N T
B C A S T
M C A S T
M A C
A L L
8
How to configure Rx
  • Buffer length is the most crucial parameter
  • 8KB (00) with or without wrap
  • 16KB (01) with or without wrap
  • 32KB (10) with or without wrap
  • 64KB (11) (wrap is automatic)
  • Next is which packets to receive
  • Broadcast, Multicast and MAC-Address Match
  • (You do NOT want to receive ALL packets)

9
What about thresholds?
  • The Linux driver offers us guidance
  • Can use none as Early Rx Threshold
  • Can use none as Rx FIFO Threshold
  • Can use a reserved DMA Burst size
  • So the Linux driver used 0x0000E70E
  • But you can experiment with other values

10
In-class exercise 1
  • Install our user8139.c device-driver, and take
    note of its buffers physical address
  • Install our dram.c device-driver, and use
    fileview to look at the NIC Receive Buffer
  • Then modify nicstudy.cpp so that it will enable
    (and configure) packet-recption
  • Use fileview to look at received packets

11
In-class exercise 2
  • Now enhance your modified version of the
    nicstudy application so that it will display a
    succession of received packets (using both
    hexadecimal and ascii formats), in a manner
    similar to our rxtester.cpp demo
  • Be sure you disable the packet reception before
    you remove user8139.ko from the kernel or
    risk a system crash (Why?)

12
The /etc/ethers file
  • This file describes the list of associations of
    Ethernet-addresses with IP-addresses
  • Its a text file, created with a text editor
  • Each line describes one correspondence
  • xxxxxxxxxxxx 138.202.171.30
  • But comments start with a -character
  • A sample ethers file is on our website

13
Dynamic Address Resolution
  • A standard Internet Protocol service exists which
    provides a dynamic way for stations to discover
    the Ethernet address that goes with a given
    IP-address
  • It is called Address Resolution Protocol

14
ARP request
A
B
request
C
D
E
Station A wants to know the Ethernet Address
for station B So A broadcasts an ARP
request-packet to all other stations
15

ARP reply
A
B
reply
C
D
E
Station B recognizes that the request is for
its Ethernet Address. So B replies directly to
A, and other stations ignore the request.
16
ARP packet-format
packet-header
ARP packet-data
0806
Destn MAC
Source MAC
PTYPE0008
HTYPE0001
broadcast address for ARP request
OPER0001/0002
PLEN04
HLEN (01)
source hardware address (6 bytes)
source protocol address (4 bytes)
destination hardware address (6 bytes)
All zeros for an ARP request
destination protocol address (4 bytes)
Write a Comment
User Comments (0)
About PowerShow.com