14 #include <linux/module.h>
15 #include <linux/netdevice.h>
19 #include <linux/rtnetlink.h>
23 #include <linux/bitops.h>
24 #include <asm/types.h>
31 static unsigned long linkwatch_flags;
32 static unsigned long linkwatch_nextevent;
40 static unsigned char default_operstate(
const struct net_device *
dev)
42 if (!netif_carrier_ok(dev))
46 if (netif_dormant(dev))
53 static void rfc2863_policy(
struct net_device *dev)
55 unsigned char operstate = default_operstate(dev);
82 if (!netif_carrier_ok(dev) || netif_dormant(dev))
87 static bool linkwatch_urgent_event(
struct net_device *dev)
89 if (!netif_running(dev))
95 return netif_carrier_ok(dev) && qdisc_tx_changing(dev);
99 static void linkwatch_add_event(
struct net_device *dev)
108 spin_unlock_irqrestore(&lweventlist_lock, flags);
112 static void linkwatch_schedule_work(
int urgent)
141 static void linkwatch_do_dev(
struct net_device *dev)
156 if (netif_carrier_ok(dev))
166 static void __linkwatch_run_queue(
int urgent_only)
179 linkwatch_nextevent = jiffies +
HZ;
181 else if (
time_after(linkwatch_nextevent, jiffies + HZ))
182 linkwatch_nextevent = jiffies;
186 spin_lock_irq(&lweventlist_lock);
187 list_splice_init(&lweventlist, &wrk);
189 while (!list_empty(&wrk)) {
194 if (urgent_only && !linkwatch_urgent_event(dev)) {
198 spin_unlock_irq(&lweventlist_lock);
199 linkwatch_do_dev(dev);
200 spin_lock_irq(&lweventlist_lock);
203 if (!list_empty(&lweventlist))
204 linkwatch_schedule_work(0);
205 spin_unlock_irq(&lweventlist_lock);
218 spin_unlock_irqrestore(&lweventlist_lock, flags);
220 linkwatch_do_dev(dev);
227 __linkwatch_run_queue(0);
234 __linkwatch_run_queue(
time_after(linkwatch_nextevent, jiffies));
241 bool urgent = linkwatch_urgent_event(dev);
244 linkwatch_add_event(dev);
248 linkwatch_schedule_work(urgent);