Improvement of RTL8139 driver under VxWorks system

Publisher:石头上种庄稼Latest update time:2012-03-27 Source: 电子工程师 Keywords:VxWorks  TL8139  Driver Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Introduction

RTL8139 is a fast Ethernet controller produced by Realtek Semiconductor Co., Ltd. in Taiwan. It provides an interface that complies with the PCI2.2 standard, is compatible with the IEEE802.3u 100BASE-T specification, supports IEEE-802.3x full-duplex flow control, supports 10Mbit.s-1/100Mbit.s-1 full-duplex and half-duplex self-adaptation, is cheap, has stable performance, and is one of the most widely used Ethernet controllers in PCs and telecommunications terminal products. The drivers of RTL8139 under various operating systems can be downloaded from the Realtek website, including the drivers under the VxWorks system, and C source code is provided. However, in embedded systems, for different hardware platforms, it is often necessary to modify the driver to improve its stability and efficiency. Based on the hardware platform of MPC8241 CPU, this paper proposes improvement measures for the driver of RTL8139 under the VxWorks system.

1 Introduction to the hardware platform

Figure 1 shows a partial hardware block diagram of a switch terminal device.

The CPU uses the MPC8241, one of the PowerPC series processors of Motorola. In addition to the embedded 32-bit PowerPC processor core, the chip also integrates the MPC107 bridge, providing a PCI interface to connect with the RTL8139. There is a memory controller on the bridge, with 16MB SDRAM and 4 MBFlash. The CPU clock is 166MHz, the SDRAM clock is 66MHz, and the PCI clock is 33MHz. The RTL8139 works at 10Mbit/s, half-duplex mode, and is connected to the Internet through a hub. Its function is to forward data packets composed of voice signals, requiring 1200pps (data packets per second), and the CPU occupancy rate is not higher than 50%.

VxWorks supports Ethernet controller drivers in END (Added Network Driver) format, and provides a MUX layer as the interface between the network protocol and the Ethernet controller driver. MUX specifies the interface functions of the driver. The RTL8139 driver Rtl8139End.c is a code written completely in END format, providing all the interface functions specified by the MUX layer. As long as the RTL8139 PCI configuration space register is written, the PCI space first address, interrupt vector number and interrupt priority parameters are passed in sysRtl8139End.c, and the driver loader is driven in END format, RTL8139 can run smoothly after successful loading.

2 Problems to be solved in the driver

If the sending and receiving rate of data packets is uniform, RTL8139 can fully meet the requirements mentioned above, but there are often bursts of data packets on the Internet, and the receiving FIFO and sending FIFO of RTL8139 are only 2Kb. In addition, RTL8139 adopts a complete copy method for sending and receiving data packets. During the burst of data packets, the CPU occupancy rate is too high, and there is no time to process too many data packets, resulting in packet loss. In Rtl8139End.c, the driver's packet buffer and the protocol stack's memory pool are completely separate. There is a copy process for both packet reception and transmission, while high-performance Ethernet controllers generally only need to copy once when sending. In this way, the CPU needs to copy once more for each packet received and sent. This is an important reason for the low performance of RTL8139. However, this packet processing method is determined by hardware and cannot be changed by the driver. In fact, in the case of a large number of burst packets, it is allowed for the Ethernet controller to lose packets, but after the burst time, the normal packet receiving and sending process should be restored. However, when running Rtl8139End.c on the hardware platform introduced in the previous article, a Sniffer is used on the PC to continuously send packets to RTL8139. The test time is tens of seconds. After stopping the packet sending, the ping command is used on the PC to test whether RTL8139 can return packets normally. The result is that it cannot be pinged through, indicating that the packet receiving and sending process of RTL8139 is interrupted due to too many burst packets and cannot be restored.

Analyzing the Rtl8139End.c program, its packet sending process is shown in Figure 2.

[page]

RTL8139 has 4 transmit descriptors, each with its own transmit status registers TSD0~TSD3 and transmit start address registers TSAD0~TSAD3. Each transmit descriptor can send 1 data packet. In the function Rtl8139Send(), apply for 1 transmit data packet buffer, copy the data packet passed down by the protocol stack into the buffer, then write the first address of the buffer into the transmit start address register, and finally fill in the transmit status register, and set its OWN position to 0, indicating that the buffer is handed over to the transmit DMA management of RTL8139 and the transmit operation is started. After the transmission is completed, RTL8139 generates an interrupt, enters the interrupt service routine Rtl8139Int(), calls Rtl8139HandleSendInt(), and reads the transmit status register in this function. If the OWN bit is 1, it means that the transmit DMA operation is completed and the corresponding transmit buffer is released; otherwise, it means that the transmit DMA operation is not completed, and the transmit buffer is still owned by the RTL8139 hardware. Check the OWN bit again when entering the transmit interrupt next time. This cycle repeats until the OWN bit becomes 1, and then the corresponding send buffer can be released, and the send descriptor it occupies becomes available.

The above process can be summarized into two points:

a) Apply for a data packet buffer in Rtl8139Send() and occupy a send descriptor;

b) Release the corresponding data packet buffer and send descriptor in Rtl8139Int().

From the above analysis, it can be seen that as long as there is no problem in these two links of packet sending, the packet sending process will not be interrupted. In addition, in Rtl8139HandleSendInt(), not only one packet buffer and descriptor are released, but all descriptors and corresponding packet buffers that have started the packet sending operation and the OWN bit of the send status register becomes 1 are released. This can enhance the stability of the program. In the case of burst packets, the CPU may not have time to respond to the interrupt, that is, the interrupt is lost, but as long as there is still one descriptor available, the interrupt can be entered after the packet sending is completed, and all the previously occupied buffers and descriptors can be released. If there are too many burst packets, the CPU does not respond to four consecutive packet interrupts, and all the send descriptors are occupied. The next time Rtl8139Send() is entered, there will be no send descriptors available, and there will be no more packet interrupts. Rtl8139HandleSendInt() will not be called, and the send descriptors cannot be released. The packet sending process is interrupted and cannot be restored. This is why the above RTL8139 cannot be pinged.

3 Solution

According to the above analysis, the packet sending process can only be restored by releasing the occupied send descriptors and send buffers, which can be achieved by calling Rtl8139HandleSendInt() once. MPC8241 has 4 timers (TimerO~Timer3) integrated in the chip, and TimerO can be used to generate hardware timing interrupts. In the interrupt service program, netJobAdd() is called with the Rtl8139HandleSendInt function pointer as the entry parameter, so that Rtl8139HandleSendInt() can be executed regularly to release the occupied send descriptors in time. This requires adding the following code to Rtl8139Start():


Among them: (pDrvCtrl->TxRingFree<0) means there is no idle transmit descriptor.

The modified driver is tested again using the method described in the previous article. After the Sniffer stops sending packets, RTL8139 can recover. Using Smartbit test, send packets to RTL8139 at half-duplex and 10 Mbit/s line speed. After the packet stops sending, RTL8139 can still recover. Use Smartbit to send packets to RTL8139 at a uniform rate of 1 200pps, with a packet length of 240 bytes. The test results are: RTL8139 does not lose packets, and the CPU occupancy rate is 45%.

4 Conclusion

The method introduced in this article can effectively enhance the robustness of the program without reducing efficiency. It runs stably for a long time on the switch terminal, and the performance fully meets the requirements.

Keywords:VxWorks  TL8139  Driver Reference address:Improvement of RTL8139 driver under VxWorks system

Previous article:Design and implementation of VOIP based on CS4281 sound card in VxWorks
Next article:Research and Improvement of UDP Protocol Stack Efficiency under VxWorks

Recommended ReadingLatest update time:2024-11-16 17:33

Driver Development of MISC Device AD7859L Based on Linux
  1 Introduction   In embedded systems, embedded processors based on ARM micro-core have become the mainstream of the market. With the widespread application of ARM technology, building an embedded operating system for ARM architecture has become a hot issue in the measurement industry. When adding a new external devi
[Microcontroller]
Driver Development of MISC Device AD7859L Based on Linux
Rear-wheel drive Fiesta! Ford develops wheel hub motor drive technology
If "wheel hub motor" is still a new thing for you, then you must read the following news carefully: Ford Motor Company and auto parts manufacturer Schaeffler (internationally renowned) are jointly developing wheel hub motor drive technology, and they will use this technology to build the first "rear-wheel drive" Fiest
[Automotive Electronics]
Rear-wheel drive Fiesta! Ford develops wheel hub motor drive technology
S3C2440 RTC real-time clock driver configuration and modification under Linux
The support for S3C2440 RTC under Linux is very complete. We only need to make simple modifications to use RTC 1、vi arch/arm/mach-s3c2440/mach-smdk2440.c static struct platform_device *smdk2440_devices __initdata = { &s3c_device_usb, &s3c_device_lcd, &s3c_device_wdt, &s3c_device_i2c0,
[Microcontroller]
Analysis on the trend of high-speed drive motors for new energy vehicles
Analysis on the trend of high-speed drive motors for new energy vehicles High-speed motors in the industry generally refer to motors with speeds exceeding 10,000 r/min. The high-speed drive motors of new energy vehicles can increase power, thereby improving vehicle dynamics, or maintain the same power and dynam
[Embedded]
Analysis on the trend of high-speed drive motors for new energy vehicles
Analysis of LED lighting driver design
To design a product, we must first determine which LED package structure to use; then consider how to adapt to these packages; we have few options, and the optical structure is built on these packages; many of our creative ideas cannot be fully utilized. 1. Problems in the applicat
[Power Management]
Schaeffler: Wheel drive solutions for future urban transportation
With the continuous acceleration of urbanization, the population density in cities is increasing. It is estimated that by 2050, more than two-thirds of the world's population will live in cities. Under this development trend, urban transportation will face huge challenges - future cities urgently need efficient, energ
[Automotive Electronics]
Schaeffler: Wheel drive solutions for future urban transportation
IIC Topic 2 - STM32 driving AT24C02
1 Overview The EEPROM chip model on the MiniSTM32 development board is 24C02. The total capacity of the chip is 256 bytes, and the chip is connected to the outside through the IIC bus. Here we directly use the AT24C02 on the Atom board, mainly for learning software programming. 2. Hardware Connection The thre
[Microcontroller]
IIC Topic 2 - STM32 driving AT24C02
ON Semiconductor's advanced LED driver solutions for different applications
Today, high-brightness LEDs have been comprehensively improved in terms of light output, energy efficiency and cost. They also have many advantages such as compactness, low-voltage operation and environmental protection, and their application scope is constantly expanding. In the future, LED lighting will have par
[Power Management]
ON Semiconductor's advanced LED driver solutions for different applications
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号