linux kernel 工程师
全部博文(99)
分类: LINUX
2014-02-17 16:01:19
1. e1000_probe 函数里面
INIT_DELAYED_WORK(&adapter->watchdog_task, e1000_watchdog);
初始化workqueue。
2. 当需要更新link 状态时,使用
schedule_delayed_work(&adapter->watchdog_task, 1);
来调度watchdog_task
3. e1000_watchdog 函数里面
通过
netif_carrier_on/netif_carrier_off 函数, 调用linkwatch_fire_event
4. link_watch.c
static DECLARE_DELAYED_WORK(linkwatch_work, linkwatch_event);
/* Must be called with the rtnl semaphore held */
void linkwatch_run_queue(void)
{
__linkwatch_run_queue(0);
}
static void linkwatch_event(struct work_struct *dummy)
{
rtnl_lock();
__linkwatch_run_queue(time_after(linkwatch_nextevent, jiffies));
rtnl_unlock();
}
5.
static void linkwatch_do_dev(struct net_device *dev)
{
/*
* Make sure the above read is complete since it can be
* rewritten as soon as we clear the bit below.
*/
smp_mb__before_clear_bit();
/* We are about to handle this device,
* so new events can be accepted
*/
clear_bit(__LINK_STATE_LINKWATCH_PENDING, &dev->state);
rfc2863_policy(dev);
if (dev->flags & IFF_UP) {
if (netif_carrier_ok(dev))
dev_activate(dev);
else
dev_deactivate(dev);
netdev_state_change(dev);
}
dev_put(dev);
}