The RealTek interface Introduction to the RTL-8139 network controller registers.

Slides:



Advertisements
Similar presentations
Lecture 101 Lecture 10: Kernel Modules and Device Drivers ECE 412: Microcomputer Laboratory.
Advertisements

Device Drivers. Linux Device Drivers Linux supports three types of hardware device: character, block and network –character devices: R/W without buffering.
May 12 th, 2002 Microprocessors. Introduction Motorola controls roughly 40% of the 32-bit embedded processor market ColdFire is the next generation 68K.
Code Composer Department of Electrical and Computer Engineering
Memory management.
Using VMX within Linux We explore the feasibility of executing ROM-BIOS code within the Linux x86_64 kernel.
The ATA/IDE Interface Can we write a character-mode device driver for the hard disk?
Dr A Sahu Dept of Comp Sc & Engg. IIT Guwahati. PCI Devices NIC Cards NIC card architecture Access to NIC register – PCI access.
The Linux PCI Interface An introduction to the PCI configuration space registers.
1 Fall 2005 Hardware Addressing and Frame Identification Qutaibah Malluhi CSE Department Qatar University.
Hardware-address filtering How can we send packets to just one node on our ‘anchor’ cluster?
A look at memory issues Data-transfers must occur between system memory and the network interface controller.
SiS 315 Graphics Engine Introduction to some capabilities of graphics accelerator hardware.
Accessing network hardware The Network Interface Controllers are part of a larger scheme used in modern PCs for device control.
Memory Management (II)
Exploring a modern NIC An introduction to programming the Intel 82573L gigabit ethernet network interface controller.
RTL-8139 experimentation Setting up an environment for studying the Network Controller.
Network Adapter Driver NCTU High Speed Network Lab.
Embedded Systems Programming Networking on the puppeteer.
Examining network packets Information about the RTL8139 needed for understanding our ‘watch235.c’ pseudo driver.
The ‘ioctl’ driver-function On implementing ‘show’ and ‘hide’ for the SiS 315 hardware cursor.
The hardware ringbuffer Understanding the RTL-8139 mechanism for packet reception.
Our ‘nic.c’ module We create a ‘character-mode’ device-driver for the 82573L NIC to use in futrure experiments.
Detecting PCI devices On identifying the peripheral equipment installed in our PC.
A device-driver for Video Memory Introduction to basic principles of the PC’s graphics display.
Chapter 9 Hardware Addressing & Frame Type Identification EE 526 Presentation by Ryan Star.
Introduction to the Intel x86’s support for “virtual” memory
1 Today I/O Systems Storage. 2 I/O Devices Many different kinds of I/O devices Software that controls them: device drivers.
Hardware-address filtering How can we send packets to just one node on our ‘anchor’ cluster?
Accessing the NIC A look at the mechanisms that software can use to interact with our 82573L network interface.
Notes for Lab 10 On implementing ‘show’ and ‘hide’ for the SiS 315 hardware cursor.
1-1 Ethernet Ethernet Controller How do you interface with an Ethernet PHY?
Chapter 1-3 The Ethernet LAN. Ethernet The networking protocol used in most modern computer networks is Ethernet. Ethernet is a CSMA/CD LAN protocol.
UART and UART Driver B. Ramamurthy.
DELTA TAU Data Systems, Inc. 1 UMAC TurboTurbo PMAC PCIGeo Drive Single Source Machine Control motion logic data Power PMAC Data Structures January 2012.
Hardware Definitions –Port: Point of connection –Bus: Interface Daisy Chain (A=>B=>…=>X) Shared Direct Device Access –Controller: Device Electronics –Registers:
Silberschatz, Galvin and Gagne  Operating System Concepts I/O Hardware Incredible variety of I/O devices.
OS provide a user-friendly environment and manage resources of the computer system. Operating systems manage: –Processes –Memory –Storage –I/O subsystem.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Principles of I/0 hardware.
1-1 Embedded Network Interface (ENI) API Concepts Shared RAM vs. FIFO modes ENI API’s.
Cis303a_chapt03-2a.ppt Range Overflow Fixed length of bits to hold numeric data Can hold a maximum positive number (unsigned) X X X X X X X X X X X X X.
CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University1 Input/Output CS 342 – Operating Systems Ibrahim Korpeoglu Bilkent University.
Ethernet Driver Changes for NET+OS V5.1. Design Changes Resides in bsp\devices\ethernet directory. Source code broken into more C files. Native driver.
NS Training Hardware.
8.1 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Paging Physical address space of a process can be noncontiguous Avoids.
Agilent Technologies Copyright 1999 H7211A+221 v Capture Filters, Logging, and Subnets: Module Objectives Create capture filters that control whether.
Accessing I/O Devices Processor Memory BUS I/O Device 1 I/O Device 2.
Chapter 9 Hardware Addressing and Frame Type Identification 1.Delivering and sending packets 2.Hardware addressing: specifying a destination 3. Broadcasting.
1 Ch 9 Hardware Addressing and Frame Type Identification.
Nevis FVTX Update Dave Winter FVTX Silicon Meeting 13 July 2006.
Digression on r/w ‘/proc’ files An application of kernel module programming to Super VGA graphics device control.
NS Training Hardware Traffic Flow Note: Traffic direction in the 1284 is classified as either forward or reverse. The forward direction is.
GROS ( G ROS ( G ROS IS IS A R OUTING R OUTING O PERATING O PERATING S YSTEM ) Batch : 6 Guide :Sabitha. S Hemant Pillai Dean John Abraham Krishnakumar.R.
1 Hardware Addressing and Frame Type Identification.
October 1, 2003Serguei A. Mokhov, 1 SOEN228, Winter 2003 Revision 1.2 Date: October 25, 2003.
Different Microprocessors Tamanna Haque Nipa Lecturer Dept. of Computer Science Stamford University Bangladesh.
DMA Driver APIs DMA State Diagram Loading Driver and Opening Channel DMA Channel Attributes Loading Data to a Channel Unloading Data from a Channel.
© 2008, Renesas Technology America, Inc., All Rights Reserved 1 Introduction Purpose  This training course demonstrates the Project Generator function.
LonWorks Introduction Hwayoung Chae.
What we’ve learned so far Ch. 6 Ch. 7 Ch. 8 Ch. 10 Ch. 11.
Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective.
Introduction to Networks v6.0
Serial mode of data transfer
Instructor Materials Chapter 5: Ethernet
COMPUTER NETWORKS CS610 Lecture-9 Hammad Khalid Khan.
Hardware Addressing and Frame Type Identification
© 2002, Cisco Systems, Inc. All rights reserved.
© 2002, Cisco Systems, Inc. All rights reserved.
Fixes and Enhancements
Using RealTek interrupts
Presentation transcript:

The RealTek interface Introduction to the RTL-8139 network controller registers

Device driver’s duties Summary of device-driver responsibilities: –Detect –Register –Reset –Allocate –Initialize –Enable –Configure –Manage

PCI device detection #include #define VID0x10EC // RealTek Corp #define DID0x8139// RTL8139 chip struct pci_dev *devp;// structure pointer devp = pci_find_device( VID, DID, NULL ); if ( devp == NULL ) return –ENODEV;

Two access methods The 8139 provides two ways for drivers to access its device-registers: –via io-port addresses (use ‘in’ and ‘out’) –via memory addresses (use ‘mov’, ‘and’, ‘or’) io_base = pci_resource_start( devp, 0 ); io_len = pci_resource_len( devp, 0 ); membase = pci_resource_start( devp, 1 ); memlen = pci_resource_len( devp, 1 );

Advantages/Disadvantages Memory-space access is faster and more flexible (can directly use x86 instructions) But memory-mapped access requires the setup of suitable entries in the system’s page-directory and page-table(s), and the driver-writer must consider caching issues and instruction-reordering by the compiler I/O port-access is more straightforward

How many registers? By either access-method, the RTL-8139 provides 256-byte programming interface Register-sizes vary: 8-bit, 16-bit, 32-bit Register-implementations vary: most are read/write; some are read-only, some are write-only; some are ‘reserved’; some may have undisclosed functions; some have clearly documented ‘side-effects’

You need these Manuals! RealTek has two official publications that are vital for writers of device-drivers: –RTL-8139D(L) Datasheet (60 pages) –RTL-8100 Programming Guide (10 pages) These docs are not protected by copyright, so we are providing copies for you to use

The Linux driver You can also look at the source-code for the Linux driver that operates our NICs: –See: ‘/usr/src/linux/drivers/net/8139too.c’ And there are other public-domain drivers for the 8139 controller as well The authors of these drivers have added comments in their code, which may help whenever the manuals are ambiguous

Examination at ‘runtime’ It is very helpful to look at the contents of the RTL-8139 registers while the network is being used (as programmed by another driver-writer) We have created a special device-driver that makes this possible: ‘mmap8139.c’ Using this driver, a companion program (‘nicregs.cpp’) displays all 8139 registers

Command Register byte-register at offset 0x37: 000ResetTxEn0 RxBuf empty r / or / w RxEn Legend: RxBuf empty (Receive Buffer is Empty): 1 = yes. 0 = no TxEn (Transmission is Enabled): 1 = yes, 0 = no RxEn (Reception is Enabled): 1 = yes, 0 – no Reset (Resets the controller): writing 0 to this bit has no effect; writing 1 to this bit initiates a ‘reset’ operation, placing all the NIC registers and internal buffers into a known default state; this bit automatically clears upon completion of the reset operation.

The six ID registers Six byte-registers (at offsets 0x00-0x05) hold the unique identification number of your network controller – known as the MAC address (Media Access Control) The transceiver uses the MAC-address to ‘filter out’ all packets on the local network that were not directed to your machine These six registers get initialized during power-on reset (and seem to be read-only)

Display of the MAC-address Here’s a programming loop that will print your MAC-address using the customary hexadecimal format: xx:xx:xx:xx:xx:xx unsigned char *reg = ; for (int i = 0; i < 6; i++) { char ch = ( i < 5 ) ? ‘:’ : ‘ ‘; printf( “%02X%c”, reg[ i ], ch ); }

Transmit Configuration 32-bit register (offsets 0x40-0x43): Hardware Version ID (Part A) Inter Frame Gap HWVER ID (Part B) GAP 2 LOOP BACK TEST CRCCRC MAX DMA BURST Transmission Retry Count CLR ABT

Receive Configuration 32-bit register (offsets 0x44-0x47) reserved Early Receive Threshold reserved Mult ER INT Rx ERR 8 Rx FIFO Threshold Rx Buf Length Max DMA Burse Size WRAPWRAP 0 LONGLONG RUNTRUNT BCASTBCAST MCASTMCAST MACMAC ALLALL

In-class exercise #1 Enhance the information displayed by the ‘nicregs.cpp’ demo-program by showing the workstation’s hostname: #include char hostname[ 64 ]; gethostname( hostname, 64 ); printf( “station is %s \n”, hostname );

In-class exercise #2 Enhance the ‘nicregs.cpp’ application, by adding ‘printf()’ statements to display the information in registers in a way that can more easily understood by humans: –Show the chip’s unique MAC address –Show the Transmit Configuration fields –Show the Receive Configuration fields –Show the Command Register settings