Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Our ‘recv1000.c’ driver products Similarities, ‘push’ versus ‘pull’, Sleep/wakeup, Driver’s components, NIC’s interrupts work, Interrupt event-types, Interrupt Mask Set/Read, Interrupt Mask Clear, Interrupt Cause Read. | Our ‘recv1000.c’ driver Implementing a ‘packet-receive’ capability with the Intel 82573L network interface controller Similarities • There exist quite a few similarities between implementing the ‘transmit-capability’ and the ‘receive-capability’ in a device-driver for Intel’s 82573L ethernet controller: – – – – Identical device-discovery and ioremap steps Same steps for ‘global reset’ of the hardware Comparable data-structure initializations Parallel setups for the TX and RX registers • But there also are a few fundamental differences (such as ‘active’ versus ‘passive’ roles for driver) ‘push’ versus ‘pull’ Host memory transmit packet buffer Ethernet controller push transmit-FIFO to/from LAN receive packet buffer pull receive-FIFO The ‘write()’ routine in our ‘xmit1000.c’ driver could transfer data at any time, but the ‘read()’ routine in our ‘recv1000.c’ driver has to wait for data to arrive. So to avoid doing any wasteful busy-waiting, our ‘recv1000.c’ driver can use the Linux kernel’s sleep/wakeup mechanism – if it enables NIC’s interrupts! Sleep/wakeup • We will need to employ a wait-queue, we will need to enable device-interrupts, and we will need to write and install the code for an interrupt service routine (ISR) • So our ‘recv1000.c’ driver will have a few additional code and data components that were absent in our ‘xmit1000.c’ driver Driver’s components my_isr() wait_queue_head This function will awaken any sleeping reader-task my_fops read ‘struct’ holds one function-pointer my_read() This function will program the actual data-transfer my_get_info() This function will allow us to inspect the receive-descriptors module_init() This function will detect and configure the hardware, define page-mappings, allocate and initialize the descriptors, install our ISR and enable interrupts, start the ‘receive’ engine, create the pseudo-file and register ‘my_fops’ module_exit() This function will do needed ‘cleanup’ when it’s time to unload our