ARM Linux驱动--DM9000网卡驱动分析


硬件平台:FL2440s3c2440

内核版本:2.6.35

主机平台:Ubuntu11.04

内核版本:2.6.39

 

1、下图是DM9000的引脚图

2、这里我们结合具体的开发板FL2440

下面是FL2440DM9000的引脚链接图

本人移植DM9000的时候将设备的资源定义放在了arch/arm/plat-s3c24xx/devs.c中,详情点击

下面是设备的资源定义

 
  1. /*DM9000*/  
  2. /* 定义该设备使用的资源 */  
  3. static struct resource s3c_dm9000_resource[] = {   
  4.         [0] = { /* 寄存器定义在mach-s3c2410/include/mach/map.h */  
  5.         .start = S3C24XX_PA_DM9000, /* 实际地址  0x20000300 */  
  6.         .end   = S3C24XX_PA_DM9000+ 0x3, /* 0x20000303 */  
  7.         .flags = IORESOURCE_MEM /* 资源标志为地址资源 */  
  8.         },   
  9.         [1]={   
  10.         .start = S3C24XX_PA_DM9000 + 0x4, //CMD pin is A2 0x20000304   
  11.         .end = S3C24XX_PA_DM9000 + 0x4 + 0x7c, // 0x20000380   
  12.         .flags = IORESOURCE_MEM /* 资源标志为地址资源 */  
  13.         },   
  14.         [2] = {   
  15.         .start = IRQ_EINT7, /* 中断为外部7号中断 */  
  16.         .end   = IRQ_EINT7, /* 中断为外部7号中断 */  
  17.         .flags = IORESOURCE_IRQ /* 资源标志为中断资源 */  
  18.         },   
  19. };   

这里可以看到,DM9000网卡使用的地址空间资源在nGCS4地址区域,所以上图的DM9000地址使能引脚连接nGCS4引脚。中断使用的是EINT7外部中断。

接着定义平台数据和平台设备,代码如下:

 
  1. /* 定义平台数据 */  
  2. static struct dm9000_plat_data s3c_device_dm9000_platdata = {   
  3.         .flags= DM9000_PLATF_16BITONLY,   
  4. };   
  5.   
  6. /* 定义平台设备 */  
  7. struct platform_device s3c_device_dm9000 = {   
  8.         .name= "dm9000"//设备名,该名称与平台设备驱动中的名称一致   
  9.         .id= 0,   
  10.         .num_resources= ARRAY_SIZE(s3c_dm9000_resource),   
  11.         .resource= s3c_dm9000_resource, //定义设备的资源   
  12.         .dev= {   
  13.                 .platform_data = &s3c_device_dm9000_platdata, //定义平台数据   
  14.          }   
  15. };   

最后导出函数符号,保存函数地址和名称

  1. EXPORT_SYMBOL(s3c_device_dm9000);  

3、设备启动的初始化过程

  1. MACHINE_START(S3C2440, "SMDK2440")  
  2.         /* Maintainer: Ben Dooks <ben-linux@fluff.org> */  
  3.         .phys_io        = S3C2410_PA_UART,  
  4.         .io_pg_offst    = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,  
  5.         .boot_params    = S3C2410_SDRAM_PA + 0x100,  
  6.   
  7.         .init_irq       = s3c24xx_init_irq,/* 初始化中断 */  
  8.         .map_io         = smdk2440_map_io,  
  9.         .init_machine   = smdk2440_machine_init,//定义设备的初始化函数   
  10.         .timer          = &s3c24xx_timer,  
  11. MACHINE_END  

而后会执行下面函数

  1. static void __init smdk2440_machine_init(void)  
  2. {  
  3.         s3c24xx_fb_set_platdata(&smdk2440_fb_info);  
  4.         s3c_i2c0_set_platdata(NULL);  
  5.           
  6.         s3c24xx_ts_set_platdata(&smdk2410_ts_cfg);/* Added by yan */  
  7.           
  8.         platform_add_devices(smdk2440_devices, ARRAY_SIZE(smdk2440_devices));/* 向平台中添加设备 */  
  9.         smdk_machine_init();  
  10. }  

下面是具体的设备列表

  1. static struct platform_device *smdk2440_devices[] __initdata = {  
  2.         &s3c_device_ohci,  
  3.         &s3c_device_lcd,/* ok */  
  4.         &s3c_device_wdt,/* ok */  
  5.         &s3c_device_i2c0,  
  6.         &s3c_device_iis,  
  7.         &s3c_device_rtc,/* ok */  
  8.         &s3c24xx_uda134x,  
  9.         &s3c_device_dm9000,  
  10.         &s3c_device_adc,/* ok */  
  11.         &s3c_device_ts,/* ok */  
  12.           
  13. };  

这样系统启动时,会给设备列表中的设备分配资源(地址资源和中断资源等)。

4、信息传输中的信息封装结构

4.1、sk_buff结构,定义在include/linux/skbuff.h

  1. struct sk_buff {  
  2.         /* These two members must be first. */  
  3.         struct sk_buff          *next;  
  4.         struct sk_buff          *prev;  
  5.   
  6.         ktime_t                 tstamp;  
  7.   
  8.         struct sock             *sk;  
  9.         struct net_device       *dev;  
  10.   
  11.         /* 
  12.          * This is the control buffer. It is free to use for every 
  13.          * layer. Please put your private variables there. If you 
  14.          * want to keep them across layers you have to do a skb_clone() 
  15.          * first. This is owned by whoever has the skb queued ATM. 
  16.          */  
  17.         char                    cb[48] __aligned(8);  
  18.   
  19.         unsigned long           _skb_refdst;  
  20. #ifdef CONFIG_XFRM   
  21.         struct  sec_path        *sp;  
  22. #endif   
  23.         unsigned int            len,  
  24.                                 data_len;  
  25.         __u16                   mac_len,  
  26.                                 hdr_len;  
  27.         union {  
  28.                 __wsum          csum;  
  29.                 struct {  
  30.                         __u16   csum_start;  
  31.                         __u16   csum_offset;  
  32.                 };  
  33.         };  
  34.         __u32                   priority;  
  35.         kmemcheck_bitfield_begin(flags1);  
  36.         __u8                    local_df:1,  
  37.                                 cloned:1,  
  38.                                 ip_summed:2,  
  39.                                 nohdr:1,  
  40.                                 nfctinfo:3;  
  41.         __u8                    pkt_type:3,  
  42.                                 fclone:2,  
  43.                                 ipvs_property:1,  
  44.                                 peeked:1,  
  45.                                 nf_trace:1;  
  46.         kmemcheck_bitfield_end(flags1);  
  47.         __be16                  protocol;  
  48.   
  49.         void                    (*destructor)(struct sk_buff *skb);  
  50. #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)   
  51.         struct nf_conntrack     *nfct;  
  52.         struct sk_buff          *nfct_reasm;  
  53. #endif   
  54. #ifdef CONFIG_BRIDGE_NETFILTER   
  55.         struct nf_bridge_info   *nf_bridge;  
  56. #endif   
  57.   
  58.         int                     skb_iif;  
  59. #ifdef CONFIG_NET_SCHED   
  60.         __u16                   tc_index;       /* traffic control index */  
  61. #ifdef CONFIG_NET_CLS_ACT   
  62.         __u16                   tc_verd;        /* traffic control verdict */  
  63. #endif   
  64. #endif   
  65.   
  66.         __u32                   rxhash;  
  67.   
  68.         kmemcheck_bitfield_begin(flags2);  
  69.         __u16                   queue_mapping:16;  
  70. #ifdef CONFIG_IPV6_NDISC_NODETYPE   
  71.         __u8                    ndisc_nodetype:2,  
  72.                                 deliver_no_wcard:1;  
  73. #else   
  74.         __u8                    deliver_no_wcard:1;  
  75. #endif   
  76.         kmemcheck_bitfield_end(flags2);  
  77.   
  78.         /* 0/14 bit hole */  
  79.   
  80. #ifdef CONFIG_NET_DMA   
  81.         dma_cookie_t            dma_cookie;  
  82. #endif   
  83. #ifdef CONFIG_NETWORK_SECMARK   
  84.         __u32                   secmark;  
  85. #endif   
  86.         union {  
  87.                 __u32           mark;  
  88.                 __u32           dropcount;  
  89.         };  
  90.   
  91.         __u16                   vlan_tci;  
  92.   
  93.         sk_buff_data_t          transport_header;  
  94.         sk_buff_data_t          network_header;  
  95.         sk_buff_data_t          mac_header;  
  96.         /* These elements must be at the end, see alloc_skb() for details.  */  
  97.         sk_buff_data_t          tail;  
  98.         sk_buff_data_t          end;  
  99.         unsigned char           *head,  
  100.                                 *data;  
  101.         unsigned int            truesize;  
  102.         atomic_t                users;  
  103. };  

元素的含义如下(摘自内核,源码,版本2.6.35.4
 *struct sk_buff - socket buffer
 * @next: Next buffer inlist
 * @prev: Previous buffer in list
 * @sk: Socketwe are owned by
 * @tstamp: Time we arrived
 * @dev:Device we arrived on/are leaving by
 * @transport_header:Transport layer header
 * @network_header: Network layerheader
 * @mac_header: Link layer header
 *@_skb_refdst: destination entry (with norefcount bit)
 * @sp:the security path, used for xfrm
 * @cb: Control buffer. Freefor use by every layer. Put private vars here
 * @len: Lengthof actual data
 * @data_len: Data length
 * @mac_len:Length of link layer header
 * @hdr_len: writable headerlength of cloned skb
 * @csum: Checksum (must includestart/offset pair)
 * @csum_start: Offset from skb->headwhere checksumming should start
 * @csum_offset: Offset fromcsum_start where checksum should be stored
 * @local_df:allow local fragmentation
 * @cloned: Head may be cloned(check refcnt to be sure)
 * @nohdr: Payload reference only,must not modify header
 * @pkt_type: Packet class
 *@fclone: skbuff clone status
 * @ip_summed: Driver fed us anIP checksum
 * @priority: Packet queueing priority
 *@users: User count - see {datagram,tcp}.c
 * @protocol:Packet protocol from driver
 * @truesize: Buffer size 
 *@head: Head of buffer
 * @data: Data head pointer
 *@tail: Tail pointer
 * @end: End pointer
 *@destructor: Destruct function
 * @mark: Generic packetmark
 * @nfct: Associated connection, if any
 *@ipvs_property: skbuff is owned by ipvs
 * @peeked: thispacket has been seen already, so stats have been
 * done forit, don't do them again
 * @nf_trace: netfilter packet traceflag
 * @nfctinfo: Relationship of this skb to theconnection
 * @nfct_reasm: netfilter conntrack re-assemblypointer
 * @nf_bridge: Saved data about a bridged frame - seebr_netfilter.c
 * @skb_iif: ifindex of device we arrivedon
 * @rxhash: the packet hash computed on receive
 *@queue_mapping: Queue mapping for multiqueue devices
 *@tc_index: Traffic control index
 * @tc_verd: traffic controlverdict
 * @ndisc_nodetype: router type (from link layer)
 *@dma_cookie: a cookie to one of several possible DMA operations
 *done by skb DMA functions
 * @secmark: security marking
 *@vlan_tci: vlan tag control information

关于sk_buff的更多分析见另

4.2、net_device

关于net_device一个非常庞大的结构体,定义在/inlcude/linux/netdevice.h中

如下:

  1. struct net_device {  
  2.   
  3.     /* 
  4.      * This is the first field of the "visible" part of this structure 
  5.      * (i.e. as seen by users in the "Space.c" file).  It is the name 
  6.      * the interface. 
  7.      */  
  8.     char            name[IFNAMSIZ];  
  9.   
  10.     struct pm_qos_request_list *pm_qos_req;  
  11.   
  12.     /* device name hash chain */  
  13.     struct hlist_node   name_hlist;  
  14.     /* snmp alias */  
  15.     char            *ifalias;  
  16.   
  17.     /* 
  18.      *  I/O specific fields 
  19.      *  FIXME: Merge these and struct ifmap into one 
  20.      */  
  21.     unsigned long       mem_end;    /* shared mem end   */  
  22.     unsigned long       mem_start;  /* shared mem start */  
  23.     unsigned long       base_addr;  /* device I/O address   */  
  24.     unsigned int        irq;        /* device IRQ number    */  
  25.   
  26.     /* 
  27.      *  Some hardware also needs these fields, but they are not 
  28.      *  part of the usual set specified in Space.c. 
  29.      */  
  30.   
  31.     unsigned char       if_port;    /* Selectable AUI, TP,..*/  
  32.     unsigned char       dma;        /* DMA channel      */  
  33.   
  34.     unsigned long       state;  
  35.   
  36.     struct list_head    dev_list;  
  37.     struct list_head    napi_list;  
  38.     struct list_head    unreg_list;  
  39.   
  40.     /* Net device features */  
  41.     unsigned long       features;  
  42. #define NETIF_F_SG      1   /* Scatter/gather IO. */   
  43. #define NETIF_F_IP_CSUM     2   /* Can checksum TCP/UDP over IPv4. */   
  44. #define NETIF_F_NO_CSUM     4   /* Does not require checksum. F.e. loopack. */   
  45. #define NETIF_F_HW_CSUM     8   /* Can checksum all the packets. */   
  46. #define NETIF_F_IPV6_CSUM   16  /* Can checksum TCP/UDP over IPV6 */   
  47. #define NETIF_F_HIGHDMA     32  /* Can DMA to high memory. */   
  48. #define NETIF_F_FRAGLIST    64  /* Scatter/gather IO. */   
  49. #define NETIF_F_HW_VLAN_TX  128 /* Transmit VLAN hw acceleration */   
  50. #define NETIF_F_HW_VLAN_RX  256 /* Receive VLAN hw acceleration */   
  51. #define NETIF_F_HW_VLAN_FILTER  512 /* Receive filtering on VLAN */   
  52. #define NETIF_F_VLAN_CHALLENGED 1024    /* Device cannot handle VLAN packets */   
  53. #define NETIF_F_GSO     2048    /* Enable software GSO. */   
  54. #define NETIF_F_LLTX        4096    /* LockLess TX - deprecated. Please */   
  55.                     /* do not use LLTX in new drivers */  
  56. #define NETIF_F_NETNS_LOCAL 8192    /* Does not change network namespaces */   
  57. #define NETIF_F_GRO     16384   /* Generic receive offload */   
  58. #define NETIF_F_LRO     32768   /* large receive offload */   
  59.   
  60. /* the GSO_MASK reserves bits 16 through 23 */  
  61. #define NETIF_F_FCOE_CRC    (1 << 24) /* FCoE CRC32 */   
  62. #define NETIF_F_SCTP_CSUM   (1 << 25) /* SCTP checksum offload */   
  63. #define NETIF_F_FCOE_MTU    (1 << 26) /* Supports max FCoE MTU, 2158 bytes*/   
  64. #define NETIF_F_NTUPLE      (1 << 27) /* N-tuple filters supported */   
  65. #define NETIF_F_RXHASH      (1 << 28) /* Receive hashing offload */   
  66.   
  67.     /* Segmentation offload features */  
  68. #define NETIF_F_GSO_SHIFT   16   
  69. #define NETIF_F_GSO_MASK    0x00ff0000   
  70. #define NETIF_F_TSO     (SKB_GSO_TCPV4 << NETIF_F_GSO_SHIFT)   
  71. #define NETIF_F_UFO     (SKB_GSO_UDP << NETIF_F_GSO_SHIFT)   
  72. #define NETIF_F_GSO_ROBUST  (SKB_GSO_DODGY << NETIF_F_GSO_SHIFT)   
  73. #define NETIF_F_TSO_ECN     (SKB_GSO_TCP_ECN << NETIF_F_GSO_SHIFT)   
  74. #define NETIF_F_TSO6        (SKB_GSO_TCPV6 << NETIF_F_GSO_SHIFT)   
  75. #define NETIF_F_FSO     (SKB_GSO_FCOE << NETIF_F_GSO_SHIFT)   
  76.   
  77.     /* List of features with software fallbacks. */  
  78. #define NETIF_F_GSO_SOFTWARE    (NETIF_F_TSO | NETIF_F_TSO_ECN | NETIF_F_TSO6)   
  79.   
  80.   
  81. #define NETIF_F_GEN_CSUM    (NETIF_F_NO_CSUM | NETIF_F_HW_CSUM)   
  82. #define NETIF_F_V4_CSUM     (NETIF_F_GEN_CSUM | NETIF_F_IP_CSUM)   
  83. #define NETIF_F_V6_CSUM     (NETIF_F_GEN_CSUM | NETIF_F_IPV6_CSUM)   
  84. #define NETIF_F_ALL_CSUM    (NETIF_F_V4_CSUM | NETIF_F_V6_CSUM)   
  85.   
  86.     /* 
  87.      * If one device supports one of these features, then enable them 
  88.      * for all in netdev_increment_features. 
  89.      */  
  90. #define NETIF_F_ONE_FOR_ALL (NETIF_F_GSO_SOFTWARE | NETIF_F_GSO_ROBUST | \   
  91.                  NETIF_F_SG | NETIF_F_HIGHDMA |     \  
  92.                  NETIF_F_FRAGLIST)  
  93.   
  94.     /* Interface index. Unique device identifier    */  
  95.     int         ifindex;  
  96.     int         iflink;  
  97.   
  98.     struct net_device_stats stats;  
  99.   
  100. #ifdef CONFIG_WIRELESS_EXT   
  101.     /* List of functions to handle Wireless Extensions (instead of ioctl). 
  102.      * See <net/iw_handler.h> for details. Jean II */  
  103.     const struct iw_handler_def *   wireless_handlers;  
  104.     /* Instance data managed by the core of Wireless Extensions. */  
  105.     struct iw_public_data * wireless_data;  
  106. #endif   
  107.     /* Management operations */  
  108.     const struct net_device_ops *netdev_ops;  
  109.     const struct ethtool_ops *ethtool_ops;  
  110.   
  111.     /* Hardware header description */  
  112.     const struct header_ops *header_ops;  
  113.   
  114.     unsigned int        flags;  /* interface flags (a la BSD)   */  
  115.     unsigned short      gflags;  
  116.         unsigned short          priv_flags; /* Like 'flags' but invisible to userspace. */  
  117.     unsigned short      padded; /* How much padding added by alloc_netdev() */  
  118.   
  119.     unsigned char       operstate; /* RFC2863 operstate */  
  120.     unsigned char       link_mode; /* mapping policy to operstate */  
  121.   
  122.     unsigned int        mtu;    /* interface MTU value      */  
  123.     unsigned short      type;   /* interface hardware type  */  
  124.     unsigned short      hard_header_len;    /* hardware hdr length  */  
  125.   
  126.     /* extra head- and tailroom the hardware may need, but not in all cases 
  127.      * can this be guaranteed, especially tailroom. Some cases also use 
  128.      * LL_MAX_HEADER instead to allocate the skb. 
  129.      */  
  130.     unsigned short      needed_headroom;  
  131.     unsigned short      needed_tailroom;  
  132.   
  133.     struct net_device   *master; /* Pointer to master device of a group, 
  134.                       * which this device is member of. 
  135.                       */  
  136.   
  137.     /* Interface address info. */  
  138.     unsigned char       perm_addr[MAX_ADDR_LEN]; /* permanent hw address */  
  139.     unsigned char       addr_len;   /* hardware address length  */  
  140.     unsigned short          dev_id;     /* for shared network cards */  
  141.   
  142.     spinlock_t      addr_list_lock;  
  143.     struct netdev_hw_addr_list  uc; /* Unicast mac addresses */  
  144.     struct netdev_hw_addr_list  mc; /* Multicast mac addresses */  
  145.     int         uc_promisc;  
  146.     unsigned int        promiscuity;  
  147.     unsigned int        allmulti;  
  148.   
  149.   
  150.     /* Protocol specific pointers */  
  151.       
  152. #ifdef CONFIG_NET_DSA   
  153.     void            *dsa_ptr;   /* dsa specific data */  
  154. #endif   
  155.     void            *atalk_ptr; /* AppleTalk link   */  
  156.     void            *ip_ptr;    /* IPv4 specific data   */  
  157.     void                    *dn_ptr;        /* DECnet specific data */  
  158.     void                    *ip6_ptr;       /* IPv6 specific data */  
  159.     void            *ec_ptr;    /* Econet specific data */  
  160.     void            *ax25_ptr;  /* AX.25 specific data */  
  161.     struct wireless_dev *ieee80211_ptr; /* IEEE 802.11 specific data, 
  162.                            assign before registering */  
  163.   
  164. /* 
  165.  * Cache line mostly used on receive path (including eth_type_trans()) 
  166.  */  
  167.     unsigned long       last_rx;    /* Time of last Rx  */  
  168.     /* Interface address info used in eth_type_trans() */  
  169.     unsigned char       *dev_addr;  /* hw address, (before bcast 
  170.                            because most packets are 
  171.                            unicast) */  
  172.   
  173.     struct netdev_hw_addr_list  dev_addrs; /* list of device 
  174.                               hw addresses */  
  175.   
  176.     unsigned char       broadcast[MAX_ADDR_LEN];    /* hw bcast add */  
  177.   
  178. #ifdef CONFIG_RPS   
  179.     struct kset     *queues_kset;  
  180.   
  181.     struct netdev_rx_queue  *_rx;  
  182.   
  183.     /* Number of RX queues allocated at alloc_netdev_mq() time  */  
  184.     unsigned int        num_rx_queues;  
  185. #endif   
  186.   
  187.     struct netdev_queue rx_queue;  
  188.   
  189.     struct netdev_queue *_tx ____cacheline_aligned_in_smp;  
  190.   
  191.     /* Number of TX queues allocated at alloc_netdev_mq() time  */  
  192.     unsigned int        num_tx_queues;  
  193.   
  194.     /* Number of TX queues currently active in device  */  
  195.     unsigned int        real_num_tx_queues;  
  196.   
  197.     /* root qdisc from userspace point of view */  
  198.     struct Qdisc        *qdisc;  
  199.   
  200.     unsigned long       tx_queue_len;   /* Max frames per queue allowed */  
  201.     spinlock_t      tx_global_lock;  
  202. /* 
  203.  * One part is mostly used on xmit path (device) 
  204.  */  
  205.     /* These may be needed for future network-power-down code. */  
  206.   
  207.     /* 
  208.      * trans_start here is expensive for high speed devices on SMP, 
  209.      * please use netdev_queue->trans_start instead. 
  210.      */  
  211.     unsigned long       trans_start;    /* Time (in jiffies) of last Tx */  
  212.   
  213.     int         watchdog_timeo; /* used by dev_watchdog() */  
  214.     struct timer_list   watchdog_timer;  
  215.   
  216.     /* Number of references to this device */  
  217.     atomic_t        refcnt ____cacheline_aligned_in_smp;  
  218.   
  219.     /* delayed register/unregister */  
  220.     struct list_head    todo_list;  
  221.     /* device index hash chain */  
  222.     struct hlist_node   index_hlist;  
  223.   
  224.     struct list_head    link_watch_list;  
  225.   
  226.     /* register/unregister state machine */  
  227.     enum { NETREG_UNINITIALIZED=0,  
  228.            NETREG_REGISTERED,   /* completed register_netdevice */  
  229.            NETREG_UNREGISTERING,    /* called unregister_netdevice */  
  230.            NETREG_UNREGISTERED, /* completed unregister todo */  
  231.            NETREG_RELEASED,     /* called free_netdev */  
  232.            NETREG_DUMMY,        /* dummy device for NAPI poll */  
  233.     } reg_state:16;  
  234.   
  235.     enum {  
  236.         RTNL_LINK_INITIALIZED,  
  237.         RTNL_LINK_INITIALIZING,  
  238.     } rtnl_link_state:16;  
  239.   
  240.     /* Called from unregister, can be used to call free_netdev */  
  241.     void (*destructor)(struct net_device *dev);  
  242.   
  243. #ifdef CONFIG_NETPOLL   
  244.     struct netpoll_info *npinfo;  
  245. #endif   
  246.   
  247. #ifdef CONFIG_NET_NS   
  248.     /* Network namespace this network device is inside */  
  249.     struct net      *nd_net;  
  250. #endif   
  251.   
  252.     /* mid-layer private */  
  253.     void            *ml_priv;  
  254.   
  255.     /* bridge stuff */  
  256.     struct net_bridge_port  *br_port;  
  257.     /* macvlan */  
  258.     struct macvlan_port *macvlan_port;  
  259.     /* GARP */  
  260.     struct garp_port    *garp_port;  
  261.   
  262.     /* class/net/name entry */  
  263.     struct device       dev;  
  264.     /* space for optional device, statistics, and wireless sysfs groups */  
  265.     const struct attribute_group *sysfs_groups[4];  
  266.   
  267.     /* rtnetlink link ops */  
  268.     const struct rtnl_link_ops *rtnl_link_ops;  
  269.   
  270.     /* VLAN feature mask */  
  271.     unsigned long vlan_features;  
  272.   
  273.     /* for setting kernel sock attribute on TCP connection setup */  
  274. #define GSO_MAX_SIZE        65536   
  275.     unsigned int        gso_max_size;  
  276.   
  277. #ifdef CONFIG_DCB   
  278.     /* Data Center Bridging netlink ops */  
  279.     const struct dcbnl_rtnl_ops *dcbnl_ops;  
  280. #endif   
  281.   
  282. #if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE)   
  283.     /* max exchange id for FCoE LRO by ddp */  
  284.     unsigned int        fcoe_ddp_xid;  
  285. #endif   
  286.     /* n-tuple filter list attached to this device */  
  287.     struct ethtool_rx_ntuple_list ethtool_ntuple_list;  
  288. };  

我还没有细细的分析这个结构体,驱动程序在probe函数中使用register_netdev()注册该结构体指明的设备,将内核操作硬件的函数个内核联系起来。

更多见下一节分析ARM-Linux驱动--DM9000网卡驱动分析(二)

  • 1
  • 2
  • 3
  • 4
  • 下一页

相关内容