Linux Network Driver programming (1)

Source: Internet
Author: User
Article title: Linux Network Driver programming (1 ). Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
1. Linux system device driver overview
  
1.1 Linux device driver categories
  
Linux Device Drivers account for a large proportion of the Linux kernel source code. the source code length is increasing, mainly because of the increase in the driver program. During the continuous upgrade of the Linux kernel, the driver structure is still relatively stable. In the changes from 2.0.xx to 2.2.xx, the compilation of the driver has made some changes, but only a small amount of work is required from the 2.0.xx driver to the 2.2.xx porting.
  
Linux devices include character devices, block devices, and network devices. Character devices are devices that do not cache data during access. Block devices can read and write data in a cache, and block devices must be able to access random resources. Character devices do not have this requirement. Typical character devices include the mouse, keyboard, and serial port. Block equipment mainly includes hard disk equipment, CD-ROM and so on. A file system must be installed on a block device to enter the operating system.
  
Network devices are specially processed in Linux. Linux's network system is mainly based on BSD unix socket mechanism. A special data structure (sk_buff) is defined between the system and the driver for data transmission. The system supports the caching of sent and received data, provides traffic control mechanisms, and supports multiple protocols.
  
1.2 compile some basic concepts of the driver
  
No matter what the operating system driver is, there are some general concepts. The support provided by the operating system to the driver is also roughly the same. The following describes some basic requirements for network device drivers.
  
1.2.1 sending and receiving
  
This is the most basic function of a network device. A network card does nothing more than sending and receiving. So the driver should tell the system where your sending function is, and the system will call your sending program when there is data to be sent. In addition, the driver directly controls the hardware, so the network hardware receives the data first, that is, the driver, it processes the raw data and sends it to the system. Here, the operating system must provide two mechanisms: one is to find the sending function of the driver, and the other is to send the received data to the system. The driver sends the received data to the system.
  
1.2.2 interruption
  
Interruptions play an important role in modern computer structures. The operating system must provide the driver's ability to respond to interruptions. Generally, an interrupt handler is registered in the system. The operating system calls the processing program of the driver when the hardware is interrupted. Linux supports interrupt sharing, that is, multiple devices share one interrupt.
  
1.2.3 clock
  
Clock is used in many places when implementing the driver. For example, timeout processing in some protocols and hardware polling without interruption mechanisms. The operating system should provide a timing mechanism for the driver. Generally, it refers to the clock function that is called back after the specified time. In the network driver, if the hardware is not interrupted, the timer can provide poll to access the hardware. Or timeout retransmission required for some protocols.
  
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.