Development of Network Interface Card (NIC) RT-8139C Device … · 2016-09-01 · Development of...

8
Development of Network Interface Card (NIC) RT-8139C Device Driver in Linux for PowerPC Sai kumar Devulapalli1, Shilpa Chaudhari2 IStudent, M.Sc. (Engg.), 2Asst Professor & Program Manager Centre for Embedded Systems Design, M. S. Ramaiah School of Advanced Studies, Bangalore. Abstract Linux is playing a significant role in the embedded applications, and Device drivers take a major responsibility in developing the Linux kernel. This thesis is aimed at the design and implementation of a device driver for Network Interface Card (NIC) RT-8139C to transfer data from PC to the physical media, and from physical media to the upper layers between the NIC card to the outside world. This is realized using Linuxfor PQ2FADS (PowerQUlCC 11Family Application Development System) PowerPC target board To design and implement this device driver for NIC RT-8I39C on PQ2FADS PowerPC (target) board, operating System (OS) is required to enable the networkfunctionalities. So OS has to reside on the target board. Therefore porting of Linux OS has to be done on the PQ2FADS PowerPC board. Linux is conjigured to make a compact kernel image according to the application requirement for the development of device driver for NIC.Conjigured Linux kernel image is compiled and installed. The compiled kernel image is ported onto the embedded hardware PQ2FADS PowerPC board. As the Ethernet facility is available for x86 machines this thesis is aimed to give the same option for the PowerPC architectures. As Linux is portable on various architectures just by conjiguring the Linux kernel with the PowerPC will make the task easier. Device driver routines are designed in Linux for Network Interface Card. Soft code is written for the designed device routines in Linux for the NIC. The compiled Universal Bootloader (U-Boot) and the compact Linux kernel image suitable for the PowerPC processor are ported on to the PQ2FADS-ZU PowerPC target board. Routinesfor the NIC were written successfully and the data transfer between the NIC card and the outside world using Linux was demonstrated. Key Words: NlC RT-8139C Device Driver, PowerPC, Bootloader, Linux Kernel, PQ2FADS, Porting. 1. INTRODUCTION Nomenclature The reason to choose Realtek RTL-8139C is a highly integrated and cost-effective Fast Ethernet controller that provides 32-bit performance, and supports Full Duplex Flow Control [12]. The reason to choose Linux OS is it's an open source and freeware and it has very API CRC CRM ERSR IPC ISR LAN MAC NIC PCI PHY PPC PQ2FADS RCR RX TSR TX WOL Application Programmable Interface Cyclic Redundancy Check Clock Recovery Module Early Reception Status Register Inter Process Mechanism Interrupt Status Register Local Area Network Medium Access Control Layer Network Interface Card Peripheral Component Interface Physical Layer PowerPC PowerQUICC II Family Application Development System Receive Configuration Register Reception Transmission Status Register Transmission Wake-On-LAN good networking support and PPC architecture was chosen as it is a powerful 32-bit processor. Before porting Linux on to the PQ2FADS-ZU target board, there is a need to build a toolchain (cross-compiler, assembler, linker and other standard GNU tools) that generates a Linux image for the PQ2FADS-ZU target board on a standard x86 host PC [I]. Linux kernel is configured to make a compact kernel image according to the application requirement which is the development of device driver for network interface card.Configured kernel is compiled and installed, and the compiled Linux kernel image is ported onto the embedded hardware PQ2FADS-ZU PowerPC target board. Device driver routines are designed in linux for Network Interface Card .Soft code is written for the designed device routines in Linux for the NIC card. 2. SOFTWARE REQUIREMENTS AND HARDWARE SETUP To design and implement the device driver: Red Hat Linux 9.0, Metrowerks CodeWarrior 8.6, Linux kernel 2.4.20, Binary utilities (2. I 0.1), Bootstrap compiler (gcc-3.3.2), C library setup (glibc-2.3.2) and Glibc- linuxthreads (2.3.2) are the SfW requirements required. The HfW requirements include PQ2F ADS PowerPC Target Board, RT-8139C NlC Card, ATX Power Supply, Power Cable, Category 5 Ethernet Cable, RS- SAsTECH 44 Vol. VI, No.1, April 2007

Transcript of Development of Network Interface Card (NIC) RT-8139C Device … · 2016-09-01 · Development of...

Page 1: Development of Network Interface Card (NIC) RT-8139C Device … · 2016-09-01 · Development of Network Interface Card (NIC) RT-8139C Device Driver in Linux for PowerPC Sai kumar

Development of Network Interface Card (NIC)RT-8139C Device Driver in Linux for PowerPC

Sai kumar Devulapalli1, Shilpa Chaudhari2IStudent, M.Sc. (Engg.), 2Asst Professor & Program Manager

Centre for Embedded Systems Design, M. S. Ramaiah School of Advanced Studies, Bangalore.

AbstractLinux is playing a significant role in the embedded applications, and Device drivers take a major responsibility

in developing the Linux kernel. This thesis is aimed at the design and implementation of a device driver for NetworkInterface Card (NIC) RT-8139C to transfer data from PC to the physical media, and from physical media to the upperlayers between the NIC card to the outside world. This is realized using Linuxfor PQ2FADS (PowerQUlCC 11FamilyApplication Development System) PowerPC target board

To design and implement this device driver for NIC RT-8I39C on PQ2FADS PowerPC (target) board, operatingSystem (OS) is required to enable the networkfunctionalities. So OS has to reside on the target board. Therefore portingof Linux OS has to be done on the PQ2FADS PowerPC board. Linux is conjigured to make a compact kernel imageaccording to the application requirement for the development of device driver for NIC.Conjigured Linux kernel image iscompiled and installed. The compiled kernel image is ported onto the embedded hardware PQ2FADS PowerPC board.As the Ethernet facility is available for x86 machines this thesis is aimed to give the same option for the PowerPCarchitectures. As Linux is portable on various architectures just by conjiguring the Linux kernel with the PowerPC willmake the task easier.

Device driver routines are designed in Linux for Network Interface Card. Soft code is written for the designeddevice routines in Linux for the NIC. The compiled Universal Bootloader (U-Boot) and the compact Linux kernel imagesuitable for the PowerPC processor are ported on to the PQ2FADS-ZU PowerPC target board. Routinesfor the NIC werewritten successfully and the data transfer between the NIC card and the outside world using Linux was demonstrated.

Key Words: NlC RT-8139C Device Driver, PowerPC, Bootloader, Linux Kernel, PQ2FADS, Porting.

1. INTRODUCTION

Nomenclature

The reason to choose Realtek RTL-8139C is a highlyintegrated and cost-effective Fast Ethernet controllerthat provides 32-bit performance, and supports FullDuplex Flow Control [12]. The reason to choose LinuxOS is it's an open source and freeware and it has very

APICRCCRMERSRIPCISRLANMACNICPCIPHYPPCPQ2FADS

RCRRXTSRTXWOL

Application Programmable InterfaceCyclic Redundancy CheckClock Recovery ModuleEarly Reception Status RegisterInter Process Mechanism

Interrupt Status RegisterLocal Area Network

Medium Access Control LayerNetwork Interface Card

Peripheral Component InterfacePhysical LayerPowerPC

PowerQUICC II Family ApplicationDevelopment SystemReceive Configuration RegisterReceptionTransmission Status RegisterTransmissionWake-On-LAN

good networking support and PPC architecture waschosen as it is a powerful 32-bit processor. Beforeporting Linux on to the PQ2FADS-ZU target board,there is a need to build a toolchain (cross-compiler,assembler, linker and other standard GNU tools) thatgenerates a Linux image for the PQ2FADS-ZU targetboard on a standard x86 host PC [I]. Linux kernel isconfigured to make a compact kernel image accordingto the application requirement which is the developmentof device driver for network interface card.Configuredkernel is compiled and installed, and the compiledLinux kernel image is ported onto the embeddedhardware PQ2FADS-ZU PowerPC target board. Devicedriver routines are designed in linux for NetworkInterface Card .Soft code is written for the designeddevice routines in Linux for the NIC card.

2. SOFTWARE REQUIREMENTS ANDHARDWARE SETUP

To design and implement the device driver: Red HatLinux 9.0, Metrowerks CodeWarrior 8.6, Linux kernel2.4.20, Binary utilities (2. I0.1), Bootstrap compiler(gcc-3.3.2), C library setup (glibc-2.3.2) and Glibc­linuxthreads (2.3.2) are the SfW requirements required.The HfW requirements include PQ2F ADS PowerPCTarget Board, RT-8139C NlC Card, ATX PowerSupply, Power Cable, Category 5 Ethernet Cable, RS-

SAsTECH 44 Vol. VI, No.1, April 2007

Page 2: Development of Network Interface Card (NIC) RT-8139C Device … · 2016-09-01 · Development of Network Interface Card (NIC) RT-8139C Device Driver in Linux for PowerPC Sai kumar

232 Serial Cable, CodeWarrior USB TAP emulator,Parallel Cable.

3. PROCEDURE TO PORT LINUX ONPQ2FADS POWERPC TARGET BOARD

Linux is one of the operating systems that run on thePowerPC Processors. To port Linux on to thePQ2FADS PowerPC target board PPC target board, thesteps to be followed to build and install the Linux imageon to the PQ2FADS PowerPC Processor is shown in thefigure 1.3.1 Procedure for Tool Chain DevelopmentBefore keeping the Linux image on to the target board,there is a need to build a toolchain (cross-compiler,assembler, linker and other standard GNU tools) thatcould generate Linux image for the PowerPC [8] ofPQ2FADS target board on a standard x86 host PC. Inorder to build the tool chain, installing of four necessarypackages involved in the development of tool chain isshown in the figure 2.

The porting. sh script is written to build theselected toolchain. This script file avoids writing thewhole path each and every time.

Toolchain Development!Kernel Setup!

Root Filesystem Setup!Bootloader Setup

Fig. 1: Steps involved in the Portingexport PROJECT=porting-moduleexport PRJROOT=/home/msrsas/control-projectexport TARGET=ppc-linuxexport PREFIX=${PRJROOT}/toolsexport TARGET_PREFIX=$ {PREFIX}/$ {TARGET}exportPATH=${PREFIX}lbin :${ PATH}cd$PRJROOT

Binary Utilities Setup!Compiler Setup!C Library Setup!

Full Compiler Setup

Fig. 2: Necessary Packages involved in theDevelopment of Tool chain

SASTECH 45

Prepare a directory known as build-tools directory [1].Basically this directory contains installed tool chainpackages (Binary Utilities setup, Compiler setup, Clibrary setup, Full compiler) which are shown in thefigure 2.$ cd ${PRlROOT}lbuild-tools

$ mkdir build-binutils build-boot-gcc build-glibc build­geeThe selected versions for these packages, which aredownloaded from ftp.gnu.org [3], are:

~ Binary utilities setup: binutil-2. I0.1~ Kernel headers setup [4]: Iinux-2.4.20~ Bootstrap compiler setup: gcc-3.3.2~ C library setup: glibc-2.3.2 and~ Glibc-linuxthreads-2.3.2.

Unpack the Packages!Configuring the Packages!

Building the Packages!Installing the Packages

Figure 3: Steps to Build the Packages

After selecting the packages of the required versionssteps involved carrying out for the tool chain building isshown in the figure 3.The first step is to setup (unpack) the binutils package toextract its source code from the downloaded archive [3].

3.2 Binary Utilities Setup

$ cd ${PRlROOT}lbuild-tools$ tar xvzf binutils-2. 10.I.tar.gzThis will create a directory called binutils-2.10.1 withthe package's content. The configuration of the packagefor cross-platform development is the next step [1].$ cd build-binutils$ ..lbinutils-2.12.I/configure --target=$T ARGETprefix=${PREFIX}

Through this configure command; control thecreation of the Make files by passing the appropriateoptions to configure. By using this Make file, build theactual utilities using $ makeWith the package now built, install the binutils by using:$ make install

The binutils have now been installed inside the

directory pointed to by PREFIX. Check that the binutilshave been installed properly in the ${PREFIX}lbindirectory as shown in figure 4.

3.3 Bootstrap Compiler Setup

In contrast to the binutils package, the gee packagecontains one more extra utility known as, the GNU

Vol. VI, NO.1, April 2007

Page 3: Development of Network Interface Card (NIC) RT-8139C Device … · 2016-09-01 · Development of Network Interface Card (NIC) RT-8139C Device Driver in Linux for PowerPC Sai kumar

compiler, along with support components such asruntime libraries.$ cd ${PRJROOT}/build-tools$ tar xvzf gcc-3.3.2.tar.gz

This will create a directory called gcc-3.3.2 withthe package's content. The gee was configured in thedirectory, which was created for the bootstrap compilercd build-boot-gcc$..Igcc-3 .3.2/configure--target=$T ARGET-­prefix=${PREFIX} --without-headers --with-newlibenable-languages=c

$ Is $${PREFIX}/bin

ppc-linux-addr2Iine ppc-linux-ld ppc-linux-readelfppc-linux-objdump ppc-linux-nm ppc-linux-sizeppc-linux-as ppc-linux-ranlib ppc-linux-stringsppc-linux-gasp ppc-linux-ar ppc-linux-stripppc-linux-objcopy ppc-linux-c++filt

Fig. 4: Checking of the ...Ibin directory afterinstalling the Binary Utilities

On success, make file will be generated. Usingthat Makefile the compiler will be build with thecommand $ make all-gee. After the successful building,the GCC (Gnu's Cross compiler) is installed using thecommand $ make install-gee

The bootstrap compiler is now installed alongwith the binutils, and this can be crosschecked by re­listing the content of ${PREFIX}/bin [I]. The name ofthe compiler, like the utilities, is prep ended with thename of the target and additionally "ppe-linux-gee" willbe added as shown in the figure 5

$ Is $${PREFIX}/bin

ppc-linux-gcc ppc-linux-ld ppc-linux-readelppc-linux-objdump ppc-linux-nm ppc-linux-sizeppc-linux-addr2line ppc-linux-ranlib ppc-linux-stringsppc-linux-c++fiIt ppc-linux-ar ppc-linux-stripppc-linux-objcopy ppc-linux-gasp ppc-linux-as

Fig. 5: Checking of the ...Ibin directory afterinstalling the GNUs Cross-Compiler

3.4 Solution Procedure for Linux Kernel Setup

The procedure involved in the Linux kernel [4] Setup isshown in the figure 6. Linux 2.4.20 Kernel was used toport linux on to the PQ2FADS PowerPC target board[7].

selectinlthe Kernel

Configuring the Kernel!Compiling the Kernel!Building the Kernel

Fig. 6: Procedure for Linux Kernel Setup

$ cd $PRJROOT$ mkdir kernel$ cd kernel$ tar -xvjflinux-2.4.20.tar.bz2

This will create a directory called linux-2.4.20with the package's content. The linux kernel will beconfigured in the directory, which was created for thekernel setup

3.5 Configuring the Linux kernel

$ cd linux-2.4.20$ make ARCH=ppc CROSS_COMPlLE=ppc-linux­menuconfigLinux was configured by cross compiling with thePowerPC [8] using ppe-Iinux-By executing the command to configure the linux withthe PowerPC processor a window will be displayed toconfigure the kernel according to the desiredapplication.

Linux kernel need to be configured in such away that to make a small kernel image according to theapplication requirement, which in turn will be portedonto the embedded hardware board [2]. Here theconfiguration for the network file system support has tobe configured done for the purpose [5]of the devicedriver.

After completion of the kernel configuration, thenewly configured kernel was saved for the developmentof the required application. Crosschecking has to bedone to make sure whether the kernel configuration wasdone properly or not.

This verification was done by the creation ofversion.h file [I] inside the includelLinux directory oflinux-2.4.20.

3.6 Compiling the Linux Kernel

After configuring the kernel the kernel has to becompiled using $ make bzImage. When the kernel gotcompiled 'VmLinux" will be generated in the $ cdlinux-2.4.20 to make sure that the kernel got installledsuccessfully without any errors [4].

Along with the VmLinux, a zlmage will becreated in the archlppc/bootlimagesl which is used forthe porting purpose.

3.7 C Library Setup

The glibc package is made up of a number of librariesand is the most delicate and lengthy package build inthe process of Cross-Platform development toolchain[2]$ cd ${PRJROOT}/build-tools$ tar xvzf glibc-2.3.2.tar.gzThis will create a directory called glibc-2.3.2 with thepackage's content. In addition to the C library, Linuxthreads package was also extracted in the glibc directoryusing $tar-xvzfglibc-linuxthread-2.3.2.tar.gz-directory=glibc-2.2.4.After extracting the Linux threads, the C library wasbuild in the build-glibc directory$ cd build-glibc$CC=ppc-linux-gcc ..Iglibc-2.3.2/configure--host=$T ARGET --prefix=$PREFIX --enable-add-ons-­with-headers=${T ARGET ]REFlX}/include

Firstly, configure with CC=ppc-linux-gcc. Theeffect of this command is to set the Cc environment

SAsTECH 46 Vol. VI, No.1, April 2007

Page 4: Development of Network Interface Card (NIC) RT-8139C Device … · 2016-09-01 · Development of Network Interface Card (NIC) RT-8139C Device Driver in Linux for PowerPC Sai kumar

variable to ppc-linux-gcc. After configuring the Clibrary setup the glibc was compiled using $ make

The C library will be installed using $ makeinstallJoot=${TARGET_PREFIX} prefix="" installIn the above command install root

variable is used to specify the directory and this ensuresthat the library and its headers are installed in the target­dependent directory, which was assigned toTARGET PREFIX earlier.

3.8 Procedure to install u-boot on the Flash of

PQ2FADS-ZU board

U-boot knows as universal boot loader is used to buildthe PQ2FADS-ZU (IOOMHz) board. Once afterconfiguring and successful installing the (V-boot) bootloader different formats of U-boot files will be

generated. In that U-boot.bin image format is requiredfor the target board [I].

The steps below explain how to program u-bootinto the target board's flash memory.

I. CodeWarrior has to be installed.2. As Code Warrior is used for Windows, there is a need

to transfer the u-boot.bin image file to the windowssystem.3. Start CodeWarrior IDE.

4. Connect the USB TAP PRO to the debug connecterlabelled "COP/IT AG" on the PQ2F ADS board. Makesure to connect pin 1 of the ribbon cable connector to pin1 of the connector on the board.

5. Connect power to the PQ2FADS board andpower on the board.6. In CodeWarrior select "Tools -> Flash Programmer".7. Click the load Settings button and select the file:82xx]Q2] ADS_ZU.xml8. In Flash Programmer window, select "TargetConfiguration".

8a) Check the 'Use Custom Settings' box and select:Target Processor: 8280Connection: USBTAP PRO MCW

8b) Check the 'Use Target Initialization' box andMake sure that the path ends with theappropriate file for the specified target board:PQ2FADS-ZU:PQ2] ADS_ZU_ LocaUnit_1 OOMHz.cfg

8c) Target Memory BufferTarget Memory Buffer Address: 00000000Target Memory Buffer Size: 00020000

9. In the Flash Programmer window, select "FlashConfiguration" .

9a) 'Flash Memory Base Address' = FF800000.9b) 'Device' = LH28FO 16SC9c) 'Organization' = 2048Kx8x4

10. In Flash Programmer window, select "Erase / BlankCheck".

lOa) Check 'All Sectors' and check'EraselBlank Check Sectors Individually'.

lOb) click the Erase button.

11. In Flash Programmer, select "Program / Verify".II a) Check the 'use selected file' box.

Click the browse button and to go to the folderwhere you saved the u-boot.bin image.

lIb) Set the File Type to Auto Detect orBinarylRaw Format.

SAsTECH 47

11c) Check Restricted Address RangeStart = FF800000End = FFFFFFFF

lId) Check Offset Address: Offset = FFFOOOOO.lIe) Click the Program button. This will

take some time. Wait until the status boxindicates that the programming operation iscomplete.

lIt) Click the Verify button to verify thatthe flash was successful.

12. Power off the board and disconnect the USB Tapfrom the board.

13. The boot loader u-boot is now ready to be used.Return to Platform Creation Suite and continue with

the deploy process.The V-Boot sequence for the PQ2F ADS

PowerPC target board is shown in the figure 7.

U-Bootloaller

Execute: program

Timestmnll: well Mm' 716:57:05 2007Flash Devin': LlU8F016SCFlash Organization: 204SK*S *4Flash l\'Iemory Start Address: OXFFSOOOOOFlash Memory End Adllress: OXFFFFFFF

Using Algorithm: Sharp 8*4.elf

Loading Flash Device Driver at: OxOOOOOOOOFlash Driver Buffer is at: OxOOOO1800Flash Driver Buffer Size is: OxOOOlE800Done

Initialization Command Succeeded

Programming file C:\Documents andSettings\Administra tor\De sktop\u- boot. binTrying auto-detect ...............File is Not of type Motorola S-Record Format.File is NOT of type Elf Format.Auto-detection is successful.File is of type Binary/Raw Format.

Programming Ox00011111 bytes of Target

Memory at OxFFFOOOOO

Timestamp: Wed Mar 7 16:57:502007Close

Fig. 7: U-Boot sequence for the PQ2FADS board

Vol. VI, No.1, April 2007

Page 5: Development of Network Interface Card (NIC) RT-8139C Device … · 2016-09-01 · Development of Network Interface Card (NIC) RT-8139C Device Driver in Linux for PowerPC Sai kumar

3.9 Building a Root Filesystem (RFS)

A local RFS was installed on the CF card and a

BuysBox 1.1.0 infrastructure is used to build it. Linuxkernel must have a Root Filesystem, which consists ofthe startup files necessary to power up the system to afully running state. RFS will provide all the utilities likeIs, chmod etc. as well as the file system. There are twooptions to locate the RFS [5]. The first one is to keep itonto the same compact flash (in a different partition)where the system. ace file resides. The second is to bootdiskless and let the board find one on the network. Theprocedure for building both is same - the difference is inwhere to put and how to find them using kernel.BusyBox was configured and installed by downloadingit from the figure 8. The first step is configuration of theBusyBox [6].

3.10 Procedure to Design the Driver for NIC

The UNIX way of looking at devices distinguishesbetween three device types. Each module usuallyimplements one of these types, and thus is classifiableas a char module, a block module, or a network module[9].

3.11 Character Devices

A character (char) device is one that can be accessed asa stream of bytes (like a file); a char driver is in chargeof implementing this behavior. Such drivers usuallyimplement at1east the open, close, read, and writesystem calls.

General Configuration~ Support for devfs

Build Options~ Do you want to build BusyBox with a Cross

Compiler?

Login I Password Management Utilities~ Addgroup~ Delgroup~ Deluser

~ Getty~ Login~ Support for letclsecurity~ Passwd~ Su

~ Sulogin

Networking Utilities~ Inetd~ Ifconfig~ Ip~ netstat

~ nslookup~ telnet~ telnetd

Process Utilities

~ Top~ Support showing CPU usage percentage

Figure 8: Configuring the BusyBox

SAsTECH 48

3.12 Block Devices

Like character devices, the block devices are accessedby Filesystem nodes in the /dev directory. A blockdevice is something that can host a Filesystem, such as adisk.

3.13 Network Interfaces

Any network transaction is made through an interface,that is, a device that is able to exchange data with otherhosts. Usually, an interface is a hardware device, but itmight also be a pure software device, like the loopbackinterface. A network interface is in charge of sendingand receiving data packets, driven by the networksubsystem of the kernel, without knowing howindividual transactions map to the actual packets beingtransmitted. I addition to device drivers, otherfunctionalities, both hardware and software, aremodularized in the kernel [II].

3.14 Device Driver Design Flow for RT-8139C

Device drivers take a special role in Linux kernel. Thestation (STA) is the most basic component of thewireless network. A station is any device (As per the

thesis it is the NIC device) that contains the functionalityof the 802. I I protocol, that being MAC, PHY, and aconnection to the wireless media. Typically the 802. I Ifunctions are implemented in the hardware and softwareofa network interface card (NIC) [10].

~ This project is aimed to the data transfer fromsystem to physical media and to transfer from physicalmedia to upper layer as shown in the figure 9. BIOS willmap the device to system memory where starting andending addresses are located. These addresses will beused to send data and to receive the data.

~ This project consist of the following modules,init_module, probe function, tx-packet and rx-packet arethe important modules [9]. The init_module function willregister the driver to the global linked list that will bemaintained by the system.

~ The probe function will initialize some structuresand files. It will get the IRQ number, which will beassigned by the system while registering. The probefunction will construct private structure, whichcontains several information, which is required todo the transformation of data. It will find out thestarting & ending addresses that are mapped in.Probe function will enable and reset the device andsoon.

~ The tx-packet function will transmit the data fromsystem to physical media. The transmit path of RT­8139C makes use of4 descriptors [11] as shown inthe figure 9. These descriptors are used in roundrobin fashion. Each of these descriptors has a fixed110 address offset. As a descriptor is written PCIoperation starts and moves the packet in thememory, which the descriptor specifies to transmitFIFO.

~ This transmit FIFO is a 2k bytes buffer in the chipthat hold the data prepared to move to line (cable) as

Vol. VI, No.1, April 2007

Page 6: Development of Network Interface Card (NIC) RT-8139C Device … · 2016-09-01 · Development of Network Interface Card (NIC) RT-8139C Device Driver in Linux for PowerPC Sai kumar

shown in the figure 9. Data in transmit FIFO move toline when early transmit threshold is met. Early transmitthreshold is also specified in the descriptor.

3.15 Functional Description

3.15.1 Transmit Operation

The host CPU initiates the transmission by storing anentire packet of data in one of the descriptors in themain memory. When the entire packet has beentransferred to the Tx butTer, the RTL8139C is instructedto move the data from the Tx butTer to the internal

transmit FIFO in PCI bus master mode [12]. When thetransmit FIFO contains a complete packet or is filled tothe programmed threshold level, the RTL8139C beginspacket transmission.The host CPU initiates the

transmission by storing an entire packet of data in oneof the descriptors in the main memory. When the entirepacket has been transferred to the Tx butTer, theRTL8139C is instructed to move the data from the TxbutTer to the internal transmit FIFO in PCI bus mastermode [12]. When the transmit FIFO contains a completepacket or is filled tothe programmed threshold level, the RTL8I39C begins

packet transmission.

3.15.2 Receive Operation

The incoming packet is placed in the RTLSI39C's RxFIFO When the amount of data in the Rx FIFO reaches

the level defined in the Receive Configuration Register(RCR), the RTL8139C requests the PCI bus to begintransferring data to the Rx butTer in PCI bus mastermode. The Rx butTer should be pre-allocated andindicated in RCR before packet reception. All receivedpackets stored in Rx butTer, including Rx header and 4­byte CRC, are double-word alignment.

Physical MemoryProtocol Stack. (RAM)

Annlleat.ion La;er

TCP/UOPLaet' Cnbl~L~ •••••tPLa

et' *.T

Data Link:Laer ~ •-- ·Ne._k JA1elf'u", CU>l •*Virtual Memory Binet Me_~ ,,"ua I

ITx_Buff'_l_ yirt_Spoo::e

t~ Tx_Buff_I_PHY _Sp"""r-r-. •·--r Tx_B1.Iff_2_PHY -Spoo::e t

-.....•I

ITx..B1.Iff_2_Vilt_S~t ·I·ITx_B1.Iff_3_ yilt_Spacet-t Tx_Buff_3 _PHY _Spoo::et-r-. •·IITx_BWf_ 4_ Virt _Spoo::et~ Tx_Buff_<t.PHY _Spee.r-- ·I*1o,

BuIT IVirtSpoo::et-i Rx_Buff_l_PH\·_Sp""" ~I

·I•b...m:Q I

IFigure 9: The Design Flow ofTx and Rx of Data Packets

3.16 Adding Driver Module to the KernelFor the communication between the NIC card and the

outside world firstly the device driver modules writtenfor the NIC card has to be added to the Linux Kernel asa module. To include the written device driver module

the following command has to be used is$ gcc -I /usr/srclLinux 2.4.20/include/ filename.cAfter executing this command the driver modules willbe included in the linux directory.To verilY wheather it is included as a module or not byexecuting the following command as $ Ismod.Displays all the modules included to the kernel. Inorderto remove any of the modules from the kernel thefollowing command has to be executed

SAsTECH 49

$ rmmod <fiIename.ext>.

To insert the specific module in the required path usethe command $ Insmod <fiIename.o>.If the routines written by the device driver writer weresuccessful then the response from the connected systemas a reply with the number of packets transmitted,number of packets received, and number of bytes lost,packet size in bytes will be displayed (observed) asshown in the figure 10.Experimental set-up with along with the target with theoutput on NIC card is shown in the figure 10. The sameabove procedure has to be done on the twin systems tosee the communication between the two systems.

Vol. VI, No.1, April 2007

Page 7: Development of Network Interface Card (NIC) RT-8139C Device … · 2016-09-01 · Development of Network Interface Card (NIC) RT-8139C Device Driver in Linux for PowerPC Sai kumar

3.17 Recommendations of future work

3.17.1 Maximizing the Performance a GigabitEthernet NIC Interface

Ethernet NIC configuration has become more thansimply enabling the interface below TCPIIP or any otherLayer 3 and above protocol stacks. The two layersprovided by the existing DLPI device driver andhardware need some special understanding to ensurethat packets flow, in the first place [14]. Once packetflow is established, you must ensure that packets flowquickly and smoothly to those upper layer protocolstacks. To measure the performance of the devicedrivers, and to use those measurements to set the tunableparameters of the gigabit Ethernet drivers to maximizetheir performance.

3.17.2 Analytical Model and PerformanceAnalysis of a Network Interface Card

3.18 Executing the driver using Ping

Then use the ping IP address as $ ping ifconfig192.168.12.135.

One important issue for practitioners and academiciansis that there are almost no platforms based on analyticalmodels for testing the impact of various architecturaland design modifications for intelligent networkinterface cards [13]. Simulations are typically timeconsuming, especially for experimenting with differentscenarios and what-if analysis. So Analytical Model andPerformance Analysis of a Network Interface Card canbe done to see the performance of the NIC card.Concluding, every approach has a different motivationand a particular range of applications. Some solutionswere planned to provide an absolute solution to thecomplete set of device drivers and others are attemptingto provide tools only for a small subset of drivers. Thus,there is no standard tool for writing device drivers; itmeans that the absolute solutions haven't been found

yet.

Figure 10: Experimental Setup with the Communicating output to the Systems ofJP 192.168.12.200

3.19 CONCLUSIONS

Linux kernel has been configured accordingto embedded application requirement to make smallkernel image which will be ported on the PQ2FADSPowerPC Target Board. Here in this work I alsoexplained how to set up the development environment,compile, load, and run the resultant Linux on thePowerPC processor. Application is to be developed andadded to the kernel.

This project is aimed to do data transfer fromsystem to physical media and to transfer from physicalmedia to upper layer by porting Linux onto thePQ2FADS-ZU PowerPC target board. This projectincludes designing and writing the soft code for thedesigned routines of the NIC RT-8139C device tocommunicate between the NIC card and the outsideworld.

SAsTECH 50

REFERENCES

[I] Karim Yaghmour, Building Embedded LinuxSystems, O'Reilly Publishers, First Edition,April 2003, pp. 107-237.

[2] He Zhu and Xiaoqiang Chen, Porting Linux to aPowerPC, LINUX JOURNAL, October 1999.

[3] "GNUs", ftp://ft;-gnu.org/gnu, 2006. (Browsedon November 3' week)

[4] "Kernel", http://www.Kernel.org/, 2006.(Browsed on November 3'd week)

[5] P.Raghavan, Amol Lad and Sriram Nelakandan,Embedded Linux System Design andDevelopment, Auerbach Publications, BocaRaton, New York, 2006, pp. 89-124.

Vol. VI, No.1, April 2007

Page 8: Development of Network Interface Card (NIC) RT-8139C Device … · 2016-09-01 · Development of Network Interface Card (NIC) RT-8139C Device Driver in Linux for PowerPC Sai kumar

[6] "BusyBox", http://www.BusyBox.net/. 2005.(Browsed on December 151 week)

[7] Atlanta Linux Expo, "Porting of Linux on thePowerPC ", Atlanta, Georgia, October 23, 1998.

[8] MS.Thesis, "Linux on the PowerPC: OptimizingModern Operating Systems for Modernprocessors", New Mexico Institute ofTechnology May 1998

[9] Alessandro Rubini and JohnatthanCorbett,"Linux Ethernet Network Device Driver- A flow of code", July 2006. (White Paper).

[10] Introduction to IEEE 802.11, "Intelligraphicsdevice driver development ", IEEE-I 995.

[II] Ashfaq A.Khan, "Practical Linux Programming:Device Drivers, Embedded Systems, and theInternet", Charles River Media, Inc, FirstEdition, 2002.

SAsTECH 51

[12] Realtek Single Chip Fast EthernetController

RT-8139C, Specification Document, Realtek.

[13] N. Cherukuri, G.B. Kandira ju, N. Gautam, andA. Sivasubramaniam, "Analytical Model andPerformance Analysis of a Network InterfaceCard', Journal (205) International Journal ofModeling and Simulation, March 2004.

[14] Informit Network, "Maximizing thePerformance a Gigabit Ethernet NIC Interface",IEEE, December 2006.

Vol. VI, No.1, April 2007