【linux驅動分析】之dm9000驅動分析(五):另外幾個重要的結構體

除了sk_buff和net_device,dm9000驅動中用到的另外幾個重要的結構體
一、platform_driver
定義在include/linux/platform_device.h中,代碼如下:
1 struct platform_driver {
2     int (*probe)(struct platform_device *);
3     int (*remove)(struct platform_device *);
4     void (*shutdown)(struct platform_device *);
5     int (*suspend)(struct platform_device *, pm_message_t state);
6     int (*resume)(struct platform_device *);
7     struct device_driver driver;
8     const struct platform_device_id *id_table;
9 };
dm9000.c中的初始化:
1 static struct platform_driver dm9000_driver = {
2     .driver    = {
3         .name    = "dm9000",
4         .owner     = THIS_MODULE,
5         .pm     = &dm9000_drv_pm_ops,
6     },
7     .probe   = dm9000_probe,
8     .remove  = __devexit_p(dm9000_drv_remove),
9 };
二、net_device_ops
操作網絡設備的函數,定義在include/linux/netdevice.h中,它有很多成員,這裏只列出dm9000驅動用到的:
 1 static const struct net_device_ops dm9000_netdev_ops = {
 2     .ndo_open        = dm9000_open,
 3     .ndo_stop        = dm9000_stop,
 4     .ndo_start_xmit        = dm9000_start_xmit,
 5     .ndo_tx_timeout        = dm9000_timeout,
 6     .ndo_set_multicast_list    = dm9000_hash_table,
 7     .ndo_do_ioctl        = dm9000_ioctl,
 8     .ndo_change_mtu        = eth_change_mtu,
 9     .ndo_validate_addr    = eth_validate_addr,
10     .ndo_set_mac_address    = eth_mac_addr,
11 #ifdef CONFIG_NET_POLL_CONTROLLER
12     .ndo_poll_controller    = dm9000_poll_controller,
13 #endif
14 };

三、ethtool_ops
ethtool_ops定義在include/linux/ethtool.h中,它有很多成員,這裏只列出dm9000驅動用到的:
 1 static const struct ethtool_ops dm9000_ethtool_ops = {
 2     .get_drvinfo        = dm9000_get_drvinfo,
 3     .get_settings        = dm9000_get_settings,
 4     .set_settings        = dm9000_set_settings,
 5     .get_msglevel        = dm9000_get_msglevel,
 6     .set_msglevel        = dm9000_set_msglevel,
 7     .nway_reset        = dm9000_nway_reset,
 8     .get_link        = dm9000_get_link,
 9     .get_wol        = dm9000_get_wol,
10     .set_wol        = dm9000_set_wol,
11      .get_eeprom_len        = dm9000_get_eeprom_len,
12      .get_eeprom        = dm9000_get_eeprom,
13      .set_eeprom        = dm9000_set_eeprom,
14     .get_rx_csum        = dm9000_get_rx_csum,
15     .set_rx_csum        = dm9000_set_rx_csum,
16     .get_tx_csum        = ethtool_op_get_tx_csum,
17     .set_tx_csum        = dm9000_set_tx_csum,
18 };
四、board_info
用來保存芯片相關的一些信息。
 1 /* Structure/enum declaration ------------------------------- */
 2 typedef struct board_info {
 3 
 4     void __iomem    *io_addr;    /* Register I/O base address */
 5     void __iomem    *io_data;    /* Data I/O address */
 6     u16         irq;        /* IRQ */
 7 
 8     u16        tx_pkt_cnt;
 9     u16        queue_pkt_len;
10     u16        queue_start_addr;
11     u16        queue_ip_summed;
12     u16        dbug_cnt;
13     u8        io_mode;        /* 0:word, 2:byte */
14     u8        phy_addr;
15     u8        imr_all;
16 
17     unsigned int    flags;
18     unsigned int    in_suspend :1;
19     unsigned int    wake_supported :1;
20     int        debug_level;
21 
22     enum dm9000_type type;
23 
24     void (*inblk)(void __iomem *port, void *data, int length);
25     void (*outblk)(void __iomem *port, void *data, int length);
26     void (*dumpblk)(void __iomem *port, int length);
27 
28     struct device    *dev;         /* parent device */
29 
30     struct resource    *addr_res;   /* resources found */
31     struct resource *data_res;
32     struct resource    *addr_req;   /* resources requested */
33     struct resource *data_req;
34     struct resource *irq_res;
35 
36     int         irq_wake;
37 
38     struct mutex     addr_lock;    /* phy and eeprom access lock */
39 
40     struct delayed_work phy_poll;
41     struct net_device  *ndev;
42 
43     spinlock_t    lock;
44 
45     struct mii_if_info mii;
46     u32        msg_enable;
47     u32        wake_state;
48 
49     int        rx_csum;
50     int        can_csum;
51     int        ip_summed;
52 } board_info_t;

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章