]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - net/sched/sch_generic.c
pkt_sched: Always use q->requeue in dev_requeue_skb().
[linux-2.6-omap-h63xx.git] / net / sched / sch_generic.c
1 /*
2  * net/sched/sch_generic.c      Generic packet scheduler routines.
3  *
4  *              This program is free software; you can redistribute it and/or
5  *              modify it under the terms of the GNU General Public License
6  *              as published by the Free Software Foundation; either version
7  *              2 of the License, or (at your option) any later version.
8  *
9  * Authors:     Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
10  *              Jamal Hadi Salim, <hadi@cyberus.ca> 990601
11  *              - Ingress support
12  */
13
14 #include <linux/bitops.h>
15 #include <linux/module.h>
16 #include <linux/types.h>
17 #include <linux/kernel.h>
18 #include <linux/sched.h>
19 #include <linux/string.h>
20 #include <linux/errno.h>
21 #include <linux/netdevice.h>
22 #include <linux/skbuff.h>
23 #include <linux/rtnetlink.h>
24 #include <linux/init.h>
25 #include <linux/rcupdate.h>
26 #include <linux/list.h>
27 #include <net/pkt_sched.h>
28
29 /* Main transmission queue. */
30
31 /* Modifications to data participating in scheduling must be protected with
32  * qdisc_lock(qdisc) spinlock.
33  *
34  * The idea is the following:
35  * - enqueue, dequeue are serialized via qdisc root lock
36  * - ingress filtering is also serialized via qdisc root lock
37  * - updates to tree and tree walking are only done under the rtnl mutex.
38  */
39
40 static inline int qdisc_qlen(struct Qdisc *q)
41 {
42         return q->q.qlen;
43 }
44
45 static inline int dev_requeue_skb(struct sk_buff *skb, struct Qdisc *q)
46 {
47         __skb_queue_head(&q->requeue, skb);
48
49         __netif_schedule(q);
50         return 0;
51 }
52
53 static inline struct sk_buff *dequeue_skb(struct Qdisc *q)
54 {
55         struct sk_buff *skb;
56
57         skb = __skb_dequeue(&q->requeue);
58         if (!skb)
59                 skb = q->dequeue(q);
60
61         return skb;
62 }
63
64 static inline int handle_dev_cpu_collision(struct sk_buff *skb,
65                                            struct netdev_queue *dev_queue,
66                                            struct Qdisc *q)
67 {
68         int ret;
69
70         if (unlikely(dev_queue->xmit_lock_owner == smp_processor_id())) {
71                 /*
72                  * Same CPU holding the lock. It may be a transient
73                  * configuration error, when hard_start_xmit() recurses. We
74                  * detect it by checking xmit owner and drop the packet when
75                  * deadloop is detected. Return OK to try the next skb.
76                  */
77                 kfree_skb(skb);
78                 if (net_ratelimit())
79                         printk(KERN_WARNING "Dead loop on netdevice %s, "
80                                "fix it urgently!\n", dev_queue->dev->name);
81                 ret = qdisc_qlen(q);
82         } else {
83                 /*
84                  * Another cpu is holding lock, requeue & delay xmits for
85                  * some time.
86                  */
87                 __get_cpu_var(netdev_rx_stat).cpu_collision++;
88                 ret = dev_requeue_skb(skb, q);
89         }
90
91         return ret;
92 }
93
94 /*
95  * NOTE: Called under qdisc_lock(q) with locally disabled BH.
96  *
97  * __QDISC_STATE_RUNNING guarantees only one CPU can process
98  * this qdisc at a time. qdisc_lock(q) serializes queue accesses for
99  * this queue.
100  *
101  *  netif_tx_lock serializes accesses to device driver.
102  *
103  *  qdisc_lock(q) and netif_tx_lock are mutually exclusive,
104  *  if one is grabbed, another must be free.
105  *
106  * Note, that this procedure can be called by a watchdog timer
107  *
108  * Returns to the caller:
109  *                              0  - queue is empty or throttled.
110  *                              >0 - queue is not empty.
111  *
112  */
113 static inline int qdisc_restart(struct Qdisc *q)
114 {
115         struct netdev_queue *txq;
116         int ret = NETDEV_TX_BUSY;
117         struct net_device *dev;
118         spinlock_t *root_lock;
119         struct sk_buff *skb;
120
121         /* Dequeue packet */
122         if (unlikely((skb = dequeue_skb(q)) == NULL))
123                 return 0;
124
125         root_lock = qdisc_lock(q);
126
127         /* And release qdisc */
128         spin_unlock(root_lock);
129
130         dev = qdisc_dev(q);
131         txq = netdev_get_tx_queue(dev, skb_get_queue_mapping(skb));
132
133         HARD_TX_LOCK(dev, txq, smp_processor_id());
134         if (!netif_tx_queue_stopped(txq) &&
135             !netif_tx_queue_frozen(txq))
136                 ret = dev_hard_start_xmit(skb, dev, txq);
137         HARD_TX_UNLOCK(dev, txq);
138
139         spin_lock(root_lock);
140
141         switch (ret) {
142         case NETDEV_TX_OK:
143                 /* Driver sent out skb successfully */
144                 ret = qdisc_qlen(q);
145                 break;
146
147         case NETDEV_TX_LOCKED:
148                 /* Driver try lock failed */
149                 ret = handle_dev_cpu_collision(skb, txq, q);
150                 break;
151
152         default:
153                 /* Driver returned NETDEV_TX_BUSY - requeue skb */
154                 if (unlikely (ret != NETDEV_TX_BUSY && net_ratelimit()))
155                         printk(KERN_WARNING "BUG %s code %d qlen %d\n",
156                                dev->name, ret, q->q.qlen);
157
158                 ret = dev_requeue_skb(skb, q);
159                 break;
160         }
161
162         if (ret && (netif_tx_queue_stopped(txq) ||
163                     netif_tx_queue_frozen(txq)))
164                 ret = 0;
165
166         return ret;
167 }
168
169 void __qdisc_run(struct Qdisc *q)
170 {
171         unsigned long start_time = jiffies;
172
173         while (qdisc_restart(q)) {
174                 /*
175                  * Postpone processing if
176                  * 1. another process needs the CPU;
177                  * 2. we've been doing it for too long.
178                  */
179                 if (need_resched() || jiffies != start_time) {
180                         __netif_schedule(q);
181                         break;
182                 }
183         }
184
185         clear_bit(__QDISC_STATE_RUNNING, &q->state);
186 }
187
188 static void dev_watchdog(unsigned long arg)
189 {
190         struct net_device *dev = (struct net_device *)arg;
191
192         netif_tx_lock(dev);
193         if (!qdisc_tx_is_noop(dev)) {
194                 if (netif_device_present(dev) &&
195                     netif_running(dev) &&
196                     netif_carrier_ok(dev)) {
197                         int some_queue_stopped = 0;
198                         unsigned int i;
199
200                         for (i = 0; i < dev->num_tx_queues; i++) {
201                                 struct netdev_queue *txq;
202
203                                 txq = netdev_get_tx_queue(dev, i);
204                                 if (netif_tx_queue_stopped(txq)) {
205                                         some_queue_stopped = 1;
206                                         break;
207                                 }
208                         }
209
210                         if (some_queue_stopped &&
211                             time_after(jiffies, (dev->trans_start +
212                                                  dev->watchdog_timeo))) {
213                                 char drivername[64];
214                                 WARN_ONCE(1, KERN_INFO "NETDEV WATCHDOG: %s (%s): transmit timed out\n",
215                                        dev->name, netdev_drivername(dev, drivername, 64));
216                                 dev->tx_timeout(dev);
217                         }
218                         if (!mod_timer(&dev->watchdog_timer,
219                                        round_jiffies(jiffies +
220                                                      dev->watchdog_timeo)))
221                                 dev_hold(dev);
222                 }
223         }
224         netif_tx_unlock(dev);
225
226         dev_put(dev);
227 }
228
229 void __netdev_watchdog_up(struct net_device *dev)
230 {
231         if (dev->tx_timeout) {
232                 if (dev->watchdog_timeo <= 0)
233                         dev->watchdog_timeo = 5*HZ;
234                 if (!mod_timer(&dev->watchdog_timer,
235                                round_jiffies(jiffies + dev->watchdog_timeo)))
236                         dev_hold(dev);
237         }
238 }
239
240 static void dev_watchdog_up(struct net_device *dev)
241 {
242         __netdev_watchdog_up(dev);
243 }
244
245 static void dev_watchdog_down(struct net_device *dev)
246 {
247         netif_tx_lock_bh(dev);
248         if (del_timer(&dev->watchdog_timer))
249                 dev_put(dev);
250         netif_tx_unlock_bh(dev);
251 }
252
253 /**
254  *      netif_carrier_on - set carrier
255  *      @dev: network device
256  *
257  * Device has detected that carrier.
258  */
259 void netif_carrier_on(struct net_device *dev)
260 {
261         if (test_and_clear_bit(__LINK_STATE_NOCARRIER, &dev->state)) {
262                 linkwatch_fire_event(dev);
263                 if (netif_running(dev))
264                         __netdev_watchdog_up(dev);
265         }
266 }
267 EXPORT_SYMBOL(netif_carrier_on);
268
269 /**
270  *      netif_carrier_off - clear carrier
271  *      @dev: network device
272  *
273  * Device has detected loss of carrier.
274  */
275 void netif_carrier_off(struct net_device *dev)
276 {
277         if (!test_and_set_bit(__LINK_STATE_NOCARRIER, &dev->state))
278                 linkwatch_fire_event(dev);
279 }
280 EXPORT_SYMBOL(netif_carrier_off);
281
282 /* "NOOP" scheduler: the best scheduler, recommended for all interfaces
283    under all circumstances. It is difficult to invent anything faster or
284    cheaper.
285  */
286
287 static int noop_enqueue(struct sk_buff *skb, struct Qdisc * qdisc)
288 {
289         kfree_skb(skb);
290         return NET_XMIT_CN;
291 }
292
293 static struct sk_buff *noop_dequeue(struct Qdisc * qdisc)
294 {
295         return NULL;
296 }
297
298 static int noop_requeue(struct sk_buff *skb, struct Qdisc* qdisc)
299 {
300         if (net_ratelimit())
301                 printk(KERN_DEBUG "%s deferred output. It is buggy.\n",
302                        skb->dev->name);
303         kfree_skb(skb);
304         return NET_XMIT_CN;
305 }
306
307 struct Qdisc_ops noop_qdisc_ops __read_mostly = {
308         .id             =       "noop",
309         .priv_size      =       0,
310         .enqueue        =       noop_enqueue,
311         .dequeue        =       noop_dequeue,
312         .requeue        =       noop_requeue,
313         .owner          =       THIS_MODULE,
314 };
315
316 static struct netdev_queue noop_netdev_queue = {
317         .qdisc          =       &noop_qdisc,
318 };
319
320 struct Qdisc noop_qdisc = {
321         .enqueue        =       noop_enqueue,
322         .dequeue        =       noop_dequeue,
323         .flags          =       TCQ_F_BUILTIN,
324         .ops            =       &noop_qdisc_ops,
325         .list           =       LIST_HEAD_INIT(noop_qdisc.list),
326         .requeue.lock   =       __SPIN_LOCK_UNLOCKED(noop_qdisc.q.lock),
327         .q.lock         =       __SPIN_LOCK_UNLOCKED(noop_qdisc.q.lock),
328         .dev_queue      =       &noop_netdev_queue,
329 };
330 EXPORT_SYMBOL(noop_qdisc);
331
332 static struct Qdisc_ops noqueue_qdisc_ops __read_mostly = {
333         .id             =       "noqueue",
334         .priv_size      =       0,
335         .enqueue        =       noop_enqueue,
336         .dequeue        =       noop_dequeue,
337         .requeue        =       noop_requeue,
338         .owner          =       THIS_MODULE,
339 };
340
341 static struct Qdisc noqueue_qdisc;
342 static struct netdev_queue noqueue_netdev_queue = {
343         .qdisc          =       &noqueue_qdisc,
344 };
345
346 static struct Qdisc noqueue_qdisc = {
347         .enqueue        =       NULL,
348         .dequeue        =       noop_dequeue,
349         .flags          =       TCQ_F_BUILTIN,
350         .ops            =       &noqueue_qdisc_ops,
351         .list           =       LIST_HEAD_INIT(noqueue_qdisc.list),
352         .requeue.lock   =       __SPIN_LOCK_UNLOCKED(noqueue_qdisc.q.lock),
353         .q.lock         =       __SPIN_LOCK_UNLOCKED(noqueue_qdisc.q.lock),
354         .dev_queue      =       &noqueue_netdev_queue,
355 };
356
357
358 static const u8 prio2band[TC_PRIO_MAX+1] =
359         { 1, 2, 2, 2, 1, 2, 0, 0 , 1, 1, 1, 1, 1, 1, 1, 1 };
360
361 /* 3-band FIFO queue: old style, but should be a bit faster than
362    generic prio+fifo combination.
363  */
364
365 #define PFIFO_FAST_BANDS 3
366
367 static inline struct sk_buff_head *prio2list(struct sk_buff *skb,
368                                              struct Qdisc *qdisc)
369 {
370         struct sk_buff_head *list = qdisc_priv(qdisc);
371         return list + prio2band[skb->priority & TC_PRIO_MAX];
372 }
373
374 static int pfifo_fast_enqueue(struct sk_buff *skb, struct Qdisc* qdisc)
375 {
376         struct sk_buff_head *list = prio2list(skb, qdisc);
377
378         if (skb_queue_len(list) < qdisc_dev(qdisc)->tx_queue_len) {
379                 qdisc->q.qlen++;
380                 return __qdisc_enqueue_tail(skb, qdisc, list);
381         }
382
383         return qdisc_drop(skb, qdisc);
384 }
385
386 static struct sk_buff *pfifo_fast_dequeue(struct Qdisc* qdisc)
387 {
388         int prio;
389         struct sk_buff_head *list = qdisc_priv(qdisc);
390
391         for (prio = 0; prio < PFIFO_FAST_BANDS; prio++) {
392                 if (!skb_queue_empty(list + prio)) {
393                         qdisc->q.qlen--;
394                         return __qdisc_dequeue_head(qdisc, list + prio);
395                 }
396         }
397
398         return NULL;
399 }
400
401 static int pfifo_fast_requeue(struct sk_buff *skb, struct Qdisc* qdisc)
402 {
403         qdisc->q.qlen++;
404         return __qdisc_requeue(skb, qdisc, prio2list(skb, qdisc));
405 }
406
407 static void pfifo_fast_reset(struct Qdisc* qdisc)
408 {
409         int prio;
410         struct sk_buff_head *list = qdisc_priv(qdisc);
411
412         for (prio = 0; prio < PFIFO_FAST_BANDS; prio++)
413                 __qdisc_reset_queue(qdisc, list + prio);
414
415         qdisc->qstats.backlog = 0;
416         qdisc->q.qlen = 0;
417 }
418
419 static int pfifo_fast_dump(struct Qdisc *qdisc, struct sk_buff *skb)
420 {
421         struct tc_prio_qopt opt = { .bands = PFIFO_FAST_BANDS };
422
423         memcpy(&opt.priomap, prio2band, TC_PRIO_MAX+1);
424         NLA_PUT(skb, TCA_OPTIONS, sizeof(opt), &opt);
425         return skb->len;
426
427 nla_put_failure:
428         return -1;
429 }
430
431 static int pfifo_fast_init(struct Qdisc *qdisc, struct nlattr *opt)
432 {
433         int prio;
434         struct sk_buff_head *list = qdisc_priv(qdisc);
435
436         for (prio = 0; prio < PFIFO_FAST_BANDS; prio++)
437                 skb_queue_head_init(list + prio);
438
439         return 0;
440 }
441
442 static struct Qdisc_ops pfifo_fast_ops __read_mostly = {
443         .id             =       "pfifo_fast",
444         .priv_size      =       PFIFO_FAST_BANDS * sizeof(struct sk_buff_head),
445         .enqueue        =       pfifo_fast_enqueue,
446         .dequeue        =       pfifo_fast_dequeue,
447         .requeue        =       pfifo_fast_requeue,
448         .init           =       pfifo_fast_init,
449         .reset          =       pfifo_fast_reset,
450         .dump           =       pfifo_fast_dump,
451         .owner          =       THIS_MODULE,
452 };
453
454 struct Qdisc *qdisc_alloc(struct netdev_queue *dev_queue,
455                           struct Qdisc_ops *ops)
456 {
457         void *p;
458         struct Qdisc *sch;
459         unsigned int size;
460         int err = -ENOBUFS;
461
462         /* ensure that the Qdisc and the private data are 32-byte aligned */
463         size = QDISC_ALIGN(sizeof(*sch));
464         size += ops->priv_size + (QDISC_ALIGNTO - 1);
465
466         p = kzalloc(size, GFP_KERNEL);
467         if (!p)
468                 goto errout;
469         sch = (struct Qdisc *) QDISC_ALIGN((unsigned long) p);
470         sch->padded = (char *) sch - (char *) p;
471
472         INIT_LIST_HEAD(&sch->list);
473         skb_queue_head_init(&sch->requeue);
474         skb_queue_head_init(&sch->q);
475         sch->ops = ops;
476         sch->enqueue = ops->enqueue;
477         sch->dequeue = ops->dequeue;
478         sch->dev_queue = dev_queue;
479         dev_hold(qdisc_dev(sch));
480         atomic_set(&sch->refcnt, 1);
481
482         return sch;
483 errout:
484         return ERR_PTR(err);
485 }
486
487 struct Qdisc * qdisc_create_dflt(struct net_device *dev,
488                                  struct netdev_queue *dev_queue,
489                                  struct Qdisc_ops *ops,
490                                  unsigned int parentid)
491 {
492         struct Qdisc *sch;
493
494         sch = qdisc_alloc(dev_queue, ops);
495         if (IS_ERR(sch))
496                 goto errout;
497         sch->parent = parentid;
498
499         if (!ops->init || ops->init(sch, NULL) == 0)
500                 return sch;
501
502         qdisc_destroy(sch);
503 errout:
504         return NULL;
505 }
506 EXPORT_SYMBOL(qdisc_create_dflt);
507
508 /* Under qdisc_lock(qdisc) and BH! */
509
510 void qdisc_reset(struct Qdisc *qdisc)
511 {
512         const struct Qdisc_ops *ops = qdisc->ops;
513
514         if (ops->reset)
515                 ops->reset(qdisc);
516 }
517 EXPORT_SYMBOL(qdisc_reset);
518
519 void qdisc_destroy(struct Qdisc *qdisc)
520 {
521         const struct Qdisc_ops  *ops = qdisc->ops;
522
523         if (qdisc->flags & TCQ_F_BUILTIN ||
524             !atomic_dec_and_test(&qdisc->refcnt))
525                 return;
526
527 #ifdef CONFIG_NET_SCHED
528         qdisc_list_del(qdisc);
529
530         qdisc_put_stab(qdisc->stab);
531 #endif
532         gen_kill_estimator(&qdisc->bstats, &qdisc->rate_est);
533         if (ops->reset)
534                 ops->reset(qdisc);
535         if (ops->destroy)
536                 ops->destroy(qdisc);
537
538         module_put(ops->owner);
539         dev_put(qdisc_dev(qdisc));
540
541         __skb_queue_purge(&qdisc->requeue);
542
543         kfree((char *) qdisc - qdisc->padded);
544 }
545 EXPORT_SYMBOL(qdisc_destroy);
546
547 static bool dev_all_qdisc_sleeping_noop(struct net_device *dev)
548 {
549         unsigned int i;
550
551         for (i = 0; i < dev->num_tx_queues; i++) {
552                 struct netdev_queue *txq = netdev_get_tx_queue(dev, i);
553
554                 if (txq->qdisc_sleeping != &noop_qdisc)
555                         return false;
556         }
557         return true;
558 }
559
560 static void attach_one_default_qdisc(struct net_device *dev,
561                                      struct netdev_queue *dev_queue,
562                                      void *_unused)
563 {
564         struct Qdisc *qdisc;
565
566         if (dev->tx_queue_len) {
567                 qdisc = qdisc_create_dflt(dev, dev_queue,
568                                           &pfifo_fast_ops, TC_H_ROOT);
569                 if (!qdisc) {
570                         printk(KERN_INFO "%s: activation failed\n", dev->name);
571                         return;
572                 }
573         } else {
574                 qdisc =  &noqueue_qdisc;
575         }
576         dev_queue->qdisc_sleeping = qdisc;
577 }
578
579 static void transition_one_qdisc(struct net_device *dev,
580                                  struct netdev_queue *dev_queue,
581                                  void *_need_watchdog)
582 {
583         struct Qdisc *new_qdisc = dev_queue->qdisc_sleeping;
584         int *need_watchdog_p = _need_watchdog;
585
586         if (!(new_qdisc->flags & TCQ_F_BUILTIN))
587                 clear_bit(__QDISC_STATE_DEACTIVATED, &new_qdisc->state);
588
589         rcu_assign_pointer(dev_queue->qdisc, new_qdisc);
590         if (need_watchdog_p && new_qdisc != &noqueue_qdisc)
591                 *need_watchdog_p = 1;
592 }
593
594 void dev_activate(struct net_device *dev)
595 {
596         int need_watchdog;
597
598         /* No queueing discipline is attached to device;
599            create default one i.e. pfifo_fast for devices,
600            which need queueing and noqueue_qdisc for
601            virtual interfaces
602          */
603
604         if (dev_all_qdisc_sleeping_noop(dev))
605                 netdev_for_each_tx_queue(dev, attach_one_default_qdisc, NULL);
606
607         if (!netif_carrier_ok(dev))
608                 /* Delay activation until next carrier-on event */
609                 return;
610
611         need_watchdog = 0;
612         netdev_for_each_tx_queue(dev, transition_one_qdisc, &need_watchdog);
613         transition_one_qdisc(dev, &dev->rx_queue, NULL);
614
615         if (need_watchdog) {
616                 dev->trans_start = jiffies;
617                 dev_watchdog_up(dev);
618         }
619 }
620
621 static void dev_deactivate_queue(struct net_device *dev,
622                                  struct netdev_queue *dev_queue,
623                                  void *_qdisc_default)
624 {
625         struct Qdisc *qdisc_default = _qdisc_default;
626         struct Qdisc *qdisc;
627
628         qdisc = dev_queue->qdisc;
629         if (qdisc) {
630                 spin_lock_bh(qdisc_lock(qdisc));
631
632                 if (!(qdisc->flags & TCQ_F_BUILTIN))
633                         set_bit(__QDISC_STATE_DEACTIVATED, &qdisc->state);
634
635                 rcu_assign_pointer(dev_queue->qdisc, qdisc_default);
636                 qdisc_reset(qdisc);
637
638                 spin_unlock_bh(qdisc_lock(qdisc));
639         }
640 }
641
642 static bool some_qdisc_is_busy(struct net_device *dev)
643 {
644         unsigned int i;
645
646         for (i = 0; i < dev->num_tx_queues; i++) {
647                 struct netdev_queue *dev_queue;
648                 spinlock_t *root_lock;
649                 struct Qdisc *q;
650                 int val;
651
652                 dev_queue = netdev_get_tx_queue(dev, i);
653                 q = dev_queue->qdisc_sleeping;
654                 root_lock = qdisc_lock(q);
655
656                 spin_lock_bh(root_lock);
657
658                 val = (test_bit(__QDISC_STATE_RUNNING, &q->state) ||
659                        test_bit(__QDISC_STATE_SCHED, &q->state));
660
661                 spin_unlock_bh(root_lock);
662
663                 if (val)
664                         return true;
665         }
666         return false;
667 }
668
669 void dev_deactivate(struct net_device *dev)
670 {
671         netdev_for_each_tx_queue(dev, dev_deactivate_queue, &noop_qdisc);
672         dev_deactivate_queue(dev, &dev->rx_queue, &noop_qdisc);
673
674         dev_watchdog_down(dev);
675
676         /* Wait for outstanding qdisc-less dev_queue_xmit calls. */
677         synchronize_rcu();
678
679         /* Wait for outstanding qdisc_run calls. */
680         while (some_qdisc_is_busy(dev))
681                 yield();
682 }
683
684 static void dev_init_scheduler_queue(struct net_device *dev,
685                                      struct netdev_queue *dev_queue,
686                                      void *_qdisc)
687 {
688         struct Qdisc *qdisc = _qdisc;
689
690         dev_queue->qdisc = qdisc;
691         dev_queue->qdisc_sleeping = qdisc;
692 }
693
694 void dev_init_scheduler(struct net_device *dev)
695 {
696         netdev_for_each_tx_queue(dev, dev_init_scheduler_queue, &noop_qdisc);
697         dev_init_scheduler_queue(dev, &dev->rx_queue, &noop_qdisc);
698
699         setup_timer(&dev->watchdog_timer, dev_watchdog, (unsigned long)dev);
700 }
701
702 static void shutdown_scheduler_queue(struct net_device *dev,
703                                      struct netdev_queue *dev_queue,
704                                      void *_qdisc_default)
705 {
706         struct Qdisc *qdisc = dev_queue->qdisc_sleeping;
707         struct Qdisc *qdisc_default = _qdisc_default;
708
709         if (qdisc) {
710                 rcu_assign_pointer(dev_queue->qdisc, qdisc_default);
711                 dev_queue->qdisc_sleeping = qdisc_default;
712
713                 qdisc_destroy(qdisc);
714         }
715 }
716
717 void dev_shutdown(struct net_device *dev)
718 {
719         netdev_for_each_tx_queue(dev, shutdown_scheduler_queue, &noop_qdisc);
720         shutdown_scheduler_queue(dev, &dev->rx_queue, &noop_qdisc);
721         WARN_ON(timer_pending(&dev->watchdog_timer));
722 }