网络接口卡驱动开发全解析
1. 网络接口卡统计信息收集
要从网络接口卡(NIC)收集统计信息,可通过执行适当的用户模式命令来触发 mycard_get_stats() 函数的调用。例如,要查找通过 eth0 接口接收的数据包数量,可以执行以下命令:
bash> cat /sys/class/net/eth0/statistics/rx_packets
124664
WiFi 驱动程序除了实现 get_stats() 方法外,还需要实现 get_wireless_stats() 方法来跟踪一些与传统 NIC 无关的参数。
2. 网络接口卡配置
NIC 驱动程序需要支持负责设置和获取设备参数的用户空间工具。以 Ethtool 为例,它用于配置以太网 NIC 的参数。为了支持 Ethtool ,底层 NIC 驱动程序需要完成以下步骤:
1. 填充 ethtool_ops 结构体:
#include <linux/ethtool.h>
/* Ethtool_ops methods */
struct ethtool_ops mycard_ethtool_ops = {
/* ... */
.get_eeprom = mycard_get_eeprom,
超级会员免费看
订阅专栏 解锁全文
2248

被折叠的 条评论
为什么被折叠?



