【linux驱动分析】之dm9000驱动分析(四):net_device结构体

本文详细分析了Linux内核中的net_device结构体,它用于描述网络设备的主要特性,包括I/O数据、设备配置和网络功能等。通过对源代码的逐行解读,读者可以深入了解该结构体在设备驱动和网络协议栈中的作用。
摘要由CSDN通过智能技术生成
net_device结构体,定义在include/linux/netdevice.h中,这是一个很复杂的结构体,先把代码清单列出来,再用到的过程中,逐步分析,最后来这里做个总结。
下面的代码是linux-2.6.38中的。
  1 /*
  2  *    The DEVICE structure.
  3  *    Actually, this whole structure is a big mistake.  It mixes I/O
  4  *    data with strictly "high-level" data, and it has to know about
  5  *    almost every data structure used in the INET module.
  6  *
  7  *    FIXME: cleanup struct net_device such that network protocol info
  8  *    moves out.
  9  */
 10 
 11 struct net_device {
 12 
 13     /*
 14      * This is the first field of the "visible" part of this structure
 15      * (i.e. as seen by users in the "Space.c" file).  It is the name
 16      * of the interface.
 17      */
 18     char            name[IFNAMSIZ];
 19 
 20     struct pm_qos_request_list pm_qos_req;
 21 
 22     /* device name hash chain */
 23     struct hlist_node    name_hlist;
 24     /* snmp alias */
 25     char             *ifalias;
 26 
 27     /*
 28      *    I/O specific fields
 29      *    FIXME: Merge these and struct ifmap into one
 30      */
 31     unsigned long        mem_end;    /* shared mem end    */
 32     unsigned long        mem_start;    /* shared mem start    */
 33     unsigned long        base_addr;    /* device I/O address    */
 34     unsigned int        irq;        /* device IRQ number    */
 35 
 36     /*
 37      *    Some hardware also needs these fields, but they are not
 38      *    part of the usual set specified in Space.c.
 39      */
 40 
 41     unsigned char        if_port;    /* Selectable AUI, TP,..*/
 42     unsigned char        dma;        /* DMA channel        */
 43 
 44     unsigned long        state;
 45 
 46     struct list_head    dev_list;
 47     struct list_head    napi_list;
 48     struct list_head    unreg_list;
 49 
 50     /* Net device features */
 51     unsigned long        features;
 52 #define NETIF_F_SG        1    /* Scatter/gather IO. */
 53 #define NETIF_F_IP_CSUM        2    /* Can checksum TCP/UDP over IPv4. */
 54 #define NETIF_F_NO_CSUM        4    /* Does not require checksum. F.e. loopack. */
 55 #define NETIF_F_HW_CSUM        8    /* Can checksum all the packets. */
 56 #define NETIF_F_IPV6_CSUM    16    /* Can checksum TCP/UDP over IPV6 */
 57 #define NETIF_F_HIGHDMA        32    /* Can DMA to high memory. */
 58 #define NETIF_F_FRAGLIST    64    /* Scatter/gather IO. */
 59 #define NETIF_F_HW_VLAN_TX    128    /* Transmit VLAN hw acceleration */
 60 #define NETIF_F_HW_VLAN_RX    256    /* Receive VLAN hw acceleration */
 61 #define NETIF_F_HW_VLAN_FILTER    512    /* Receive filtering on VLAN */
 62 #define NETIF_F_VLAN_CHALLENGED    1024    /* Device cannot handle VLAN packets */
 63 #define NETIF_F_GSO        2048    /* Enable software GSO. */
 64 #define NETIF_F_LLTX        4096    /* LockLess TX - deprecated. Please */
 65                     /* do not use LLTX in new drivers */
 66 #define NETIF_F_NETNS_LOCAL    8192    /* Does not change network namespaces */
 67 #define NETIF_F_GRO        16384    /* Generic receive offload */
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值