One. Network Card driver Architecture analysis
1. Linux Network Subsystem
#系统调用接口层
Provides a unified way for applications to access the network subsystem.
#协议无关层
Provides a common way to use the Transport layer protocol.
#协议栈的实现
Implementing a specific network protocol
#设备无关层
Common interface for protocol and device-driven communication
#设备驱动程序
2. Important Data structures
2.1 Network card description structure
In the Linux kernel, each NIC is described by a "net_device" structure, and some of the key members are:
#char Name[ifnamsiz]
Device name, such as: eth%d
#unsigned Long Base_addr
I/O base Address
#const struct Net_device_ops *netdev_ops;
2.2 Network card Operation Collection
Description: Similar to the file_operations structure in character device drivers, the NET_DEVICE_OPS structure records the operations supported by the NIC.
static const struct Net_device_ops Dm9000_netdev_ops =
{
. ndo_open= Dm9000_open,
. ndo_stop= Dm9000_stop,
. ndo_start_xmit= Dm9000_start_xmit,
. ndo_do_ioctl= Dm9000_ioctl,
. ndo_validate_addr= Eth_validate_addr,
. ndo_set_mac_address= Eth_mac_addr,
};
2.3 Network Packets
Each network packet in the Linux kernel is described by a socket buffer struct struct sk_buff,
That is, a SK_BUFF structure is a network packet, and pointers to Sk_buff are often called SKB.
3. Network Card driver Architecture analysis
1. cs8900.c
Linux Network card driver programming (1)