linux网卡的fec功能,网络控制器驱动程序学习记录fec(1)

35833eaa271097e3ebabfcf86da98039.png

1,首先从模块加载函数module_init(fec_enet_module_init);

static int __init fec_enet_module_init(void)

{

struct net_device *dev;

int i, j, err;

DECLARE_MAC_BUF(mac);

printk("FEC ENET Version 0.2\n");

for (i = 0; (i < FEC_MAX_PORTS); i++) {

dev = alloc_etherdev(sizeof(struct fec_enet_private));//申请一个网络设备其格式是fec_enet_private

if (!dev)

return -ENOMEM;

err = fec_enet_init(dev);

if (err) {

free_netdev(dev);

continue;

}

/

net_dev_array[i]=dev;

/

if (register_netdev(dev) != 0) {

/* XXX: missing cleanup here */

free_netdev(dev);

return -EIO;

}

printk("%s: ethernet %s\n",

dev->name, print_mac(mac, dev->dev_addr));

}

return 0;

}

2,关键结构体fec_enet_private定义了网络设备所用到的所有私有资源

struct fec_enet_private {

/* Hardware registers of the FEC device */

volatile fec_t*hwp;

struct net_device *netdev;

/* The saved address of a sent-in-place packet/buffer, for skfree(). */

unsigned char *tx_bounce[TX_RING_SIZE];

structsk_buff* tx_skbuff[TX_RING_SIZE];

ushortskb_cur;

ushortskb_dirty;

/* CPM dual port RAM relative addresses.

*/

cbd_t*rx_bd_base;/* Address of Rx and Tx buffers. */

cbd_t*tx_bd_base;

cbd_t*cur_rx, *cur_tx;/* The next free ring entry */

cbd_t*dirty_tx;/* The ring entries to be free()ed. */

uinttx_full;

spinlock_t lock;

uintphy_id;

uintphy_id_done;

uintphy_status;

uintphy_speed;

phy_info_t const*phy;

struct work_struct phy_task;

volatile fec_t*phy_hwp;

uintsequence_done;

uintmii_phy_task_queued;

uintphy_addr;

intindex;

intopened;

intlink;

intold_link;

intfull_duplex;

#ifdef CONFIG_M5445X

intspeed_10;

struct timer_list phy_timer;

unsigned long sTime;

unsigned long rxCount;

unsigned long bktCount;

unsigned long mTime;

unsigned long pktCount;

unsigned long bpkt_state;//for broadcast packet reject state machine

unsigned long bpkt_flag;//flag for reject broadcast packet

unsigned long pTime;

unsigned long bpkt_msk;

unsigned long tLimit;

unsigned long tCount;

unsigned long pkt_acount;//the all packet count in current slot

unsigned long bpkt_rcount;//the boradcast packet count in current slot

unsigned long bpkt_rlimit;//the broadcast packet receive limit

unsigned long pCount;//the total packet count

unsigned long bCount;//the total broadcast packet count

unsigned long flux_aCount;//byte count for all packet

unsigned long flux_aCount_st; //sticky of byte count for all packet

unsigned long flux_bCount;//byte count for broadcast packet

unsigned long flux_bCount_st; //sticky of byte count for broadcast packet

unsigned long flux_dCount[32];

unsigned long flux_rTime[32];

unsigned lo

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值