在真正的开始分析dm9000 driver的probe之前,首先来看看dm9000 驱动中几个十分重要的结构
1、dm9000_driver
static struct platform_driver dm9000_driver = {
.driver = {
.name = "dm9000",
.owner = THIS_MODULE,
.pm = &dm9000_drv_pm_ops,
},
.probe = dm9000_probe,
.remove = __devexit_p(dm9000_drv_remove),
};
dm9000_driver是platform_driver结构体变量,其中包含了重要的:驱动的名字(用来match)和几个重要操作函数。
2、dm9000_netdev_ops
static const struct net_device_ops dm9000_netdev_ops = {
.ndo_open = dm9000_open,
.ndo_stop = dm9000_stop,
.ndo_start_xmit = dm9000_start_xmit,
.ndo_tx_timeout = dm9000_timeout,
.ndo_set_multicast_list = dm9000_hash_table,
.ndo_do_ioctl = dm9000_ioctl,
.ndo_change_mtu = eth_change_mtu,
.ndo_validate_addr = eth_validate_addr,
.ndo_set_mac_address = eth_mac_addr,
#ifdef CONFIG_NET_POLL_CONTROLLER
.ndo_poll_controller = dm9000_poll_controller,
#endif
};
dm9000_netdev_ops是net_device_ops结构体变量, 其中定义了操作net_device的重要函数,我们在驱动程序中根据需要的操作要填充这些函数。
3、dm9000_ethtool_ops
static const struct ethtool_ops dm9000_ethtool_ops = {
.get_drvinfo = dm9000_get_drvinfo,
.get_settings = dm9000_get_settings,
.set_settings = dm9000_set_settings,
.get_msglevel = dm9000_get_msglevel,
.set_msglevel = dm9000_set_msglevel,
.nway_reset = dm9000_nway_reset,
.get_link = dm9000_get_link,
.get_eeprom_len = dm9000_get_eeprom_len,
.get_eeprom = dm9000_get_eeprom,
.set_eeprom = dm9000_set_eeprom,
.get_rx_csum = dm9000_get_rx_csum,
.set_rx_csum = dm9000_set_rx_csum,
.get_tx_csum = ethtool_op_get_tx_csum,
.set_tx_csum = dm9000_set_tx_csum,
};
dm9000_ethtool_ops是ethtool_ops结构体变量,为了支持ethtool,其中的函数主要是用于查询和设置网卡参数(当然也有的驱动程序可能不支持ethtool)。
4.board_info
/* Structure/enum declaration ------------------------------- */
typedef struct board_info {
void __iomem *io_addr; /* Register I/O base address */
void __iomem *io_data; /* Data I/O address */
u16 irq; /* IRQ */
u16 tx_pkt_cnt;
u16 queue_pkt_len;
u16 queue_start_addr;
u16 queue_ip_summed;
u16 dbug_cnt;
u8 io_mode; /* 0:word, 2:byte */
u8 phy_addr;
u8 imr_all;
unsigned int flags;
unsigned int in_suspend :1;
int debug_level;
enum dm9000_type type;
void (*inblk)(void __iomem *port, void *data, int length);
void (*outblk)(void __iomem *port, void *data, int length);
void (*dumpblk)(void __iomem *port, int length);
struct device *dev; /* parent device */
struct resource *addr_res; /* resources found */
struct resource *data_res;
struct resource *addr_req; /* resources requested */
struct resource *data_req;
struct resource *irq_res;
struct mutex addr_lock; /* phy and eeprom access lock */
struct delayed_work phy_poll;
struct net_device *ndev;
spinlock_t lock;
struct mii_if_info mii;
u32 msg_enable;
int rx_csum;
int can_csum;
int ip_summed;
} board_info_t;
board_info结构体用来保存芯片相关的一些私有信息。具体在代码中分析。
设计资源 培训 开发板 精华推荐
- 使用 LO 2 分频调制器的宽带、低误差矢量幅度 (EVM) 直接转换发射器
- 使用 NXP Semiconductors 的 TDA2582 的参考设计
- FRDM-KEAZ128: KEA Freedom评估板
- MAXREFDES1098:采用MAX17690的小尺寸,24V / 500mA,无光耦反激式DC-DC转换器,效率为92%
- FCDC00052,使用 ADP1829/ADP1864 PWM 降压控制器的参考设计
- L7806C的典型应用通过降压电阻降低功耗
- LT1634ACS8-4.096 微功率电压和电流基准的典型应用
- LT8609HMSE 3.3V 降压型稳压器的典型应用电路
- 使用 Infineon Technologies AG 的 IRU3137 的参考设计
- NCP3163INVGEVB,逆变器演示评估板