sch_generic.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  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. #include <linux/bitops.h>
  14. #include <linux/module.h>
  15. #include <linux/types.h>
  16. #include <linux/kernel.h>
  17. #include <linux/sched.h>
  18. #include <linux/string.h>
  19. #include <linux/errno.h>
  20. #include <linux/netdevice.h>
  21. #include <linux/skbuff.h>
  22. #include <linux/rtnetlink.h>
  23. #include <linux/init.h>
  24. #include <linux/rcupdate.h>
  25. #include <linux/list.h>
  26. #include <net/pkt_sched.h>
  27. /* Main transmission queue. */
  28. /* Modifications to data participating in scheduling must be protected with
  29. * queue->lock spinlock.
  30. *
  31. * The idea is the following:
  32. * - enqueue, dequeue are serialized via top level device
  33. * spinlock queue->lock.
  34. * - ingress filtering is serialized via top level device
  35. * spinlock dev->rx_queue.lock.
  36. * - updates to tree and tree walking are only done under the rtnl mutex.
  37. */
  38. void qdisc_lock_tree(struct net_device *dev)
  39. __acquires(dev->tx_queue.lock)
  40. __acquires(dev->rx_queue.lock)
  41. {
  42. spin_lock_bh(&dev->tx_queue.lock);
  43. spin_lock(&dev->rx_queue.lock);
  44. }
  45. EXPORT_SYMBOL(qdisc_lock_tree);
  46. void qdisc_unlock_tree(struct net_device *dev)
  47. __releases(dev->rx_queue.lock)
  48. __releases(dev->tx_queue.lock)
  49. {
  50. spin_unlock(&dev->rx_queue.lock);
  51. spin_unlock_bh(&dev->tx_queue.lock);
  52. }
  53. EXPORT_SYMBOL(qdisc_unlock_tree);
  54. static inline int qdisc_qlen(struct Qdisc *q)
  55. {
  56. return q->q.qlen;
  57. }
  58. static inline int dev_requeue_skb(struct sk_buff *skb, struct net_device *dev,
  59. struct Qdisc *q)
  60. {
  61. if (unlikely(skb->next))
  62. dev->gso_skb = skb;
  63. else
  64. q->ops->requeue(skb, q);
  65. netif_schedule(dev);
  66. return 0;
  67. }
  68. static inline struct sk_buff *dev_dequeue_skb(struct net_device *dev,
  69. struct Qdisc *q)
  70. {
  71. struct sk_buff *skb;
  72. if ((skb = dev->gso_skb))
  73. dev->gso_skb = NULL;
  74. else
  75. skb = q->dequeue(q);
  76. return skb;
  77. }
  78. static inline int handle_dev_cpu_collision(struct sk_buff *skb,
  79. struct net_device *dev,
  80. struct Qdisc *q)
  81. {
  82. int ret;
  83. if (unlikely(dev->xmit_lock_owner == smp_processor_id())) {
  84. /*
  85. * Same CPU holding the lock. It may be a transient
  86. * configuration error, when hard_start_xmit() recurses. We
  87. * detect it by checking xmit owner and drop the packet when
  88. * deadloop is detected. Return OK to try the next skb.
  89. */
  90. kfree_skb(skb);
  91. if (net_ratelimit())
  92. printk(KERN_WARNING "Dead loop on netdevice %s, "
  93. "fix it urgently!\n", dev->name);
  94. ret = qdisc_qlen(q);
  95. } else {
  96. /*
  97. * Another cpu is holding lock, requeue & delay xmits for
  98. * some time.
  99. */
  100. __get_cpu_var(netdev_rx_stat).cpu_collision++;
  101. ret = dev_requeue_skb(skb, dev, q);
  102. }
  103. return ret;
  104. }
  105. /*
  106. * NOTE: Called under queue->lock with locally disabled BH.
  107. *
  108. * __LINK_STATE_QDISC_RUNNING guarantees only one CPU can process this
  109. * device at a time. queue->lock serializes queue accesses for
  110. * this device AND txq->qdisc pointer itself.
  111. *
  112. * netif_tx_lock serializes accesses to device driver.
  113. *
  114. * queue->lock and netif_tx_lock are mutually exclusive,
  115. * if one is grabbed, another must be free.
  116. *
  117. * Note, that this procedure can be called by a watchdog timer
  118. *
  119. * Returns to the caller:
  120. * 0 - queue is empty or throttled.
  121. * >0 - queue is not empty.
  122. *
  123. */
  124. static inline int qdisc_restart(struct net_device *dev)
  125. {
  126. struct netdev_queue *txq = &dev->tx_queue;
  127. struct Qdisc *q = txq->qdisc;
  128. struct sk_buff *skb;
  129. int ret = NETDEV_TX_BUSY;
  130. /* Dequeue packet */
  131. if (unlikely((skb = dev_dequeue_skb(dev, q)) == NULL))
  132. return 0;
  133. /* And release queue */
  134. spin_unlock(&txq->lock);
  135. HARD_TX_LOCK(dev, smp_processor_id());
  136. if (!netif_subqueue_stopped(dev, skb))
  137. ret = dev_hard_start_xmit(skb, dev);
  138. HARD_TX_UNLOCK(dev);
  139. spin_lock(&txq->lock);
  140. q = txq->qdisc;
  141. switch (ret) {
  142. case NETDEV_TX_OK:
  143. /* Driver sent out skb successfully */
  144. ret = qdisc_qlen(q);
  145. break;
  146. case NETDEV_TX_LOCKED:
  147. /* Driver try lock failed */
  148. ret = handle_dev_cpu_collision(skb, dev, q);
  149. break;
  150. default:
  151. /* Driver returned NETDEV_TX_BUSY - requeue skb */
  152. if (unlikely (ret != NETDEV_TX_BUSY && net_ratelimit()))
  153. printk(KERN_WARNING "BUG %s code %d qlen %d\n",
  154. dev->name, ret, q->q.qlen);
  155. ret = dev_requeue_skb(skb, dev, q);
  156. break;
  157. }
  158. return ret;
  159. }
  160. void __qdisc_run(struct net_device *dev)
  161. {
  162. unsigned long start_time = jiffies;
  163. while (qdisc_restart(dev)) {
  164. if (netif_queue_stopped(dev))
  165. break;
  166. /*
  167. * Postpone processing if
  168. * 1. another process needs the CPU;
  169. * 2. we've been doing it for too long.
  170. */
  171. if (need_resched() || jiffies != start_time) {
  172. netif_schedule(dev);
  173. break;
  174. }
  175. }
  176. clear_bit(__LINK_STATE_QDISC_RUNNING, &dev->state);
  177. }
  178. static void dev_watchdog(unsigned long arg)
  179. {
  180. struct net_device *dev = (struct net_device *)arg;
  181. struct netdev_queue *txq = &dev->tx_queue;
  182. netif_tx_lock(dev);
  183. if (txq->qdisc != &noop_qdisc) {
  184. if (netif_device_present(dev) &&
  185. netif_running(dev) &&
  186. netif_carrier_ok(dev)) {
  187. if (netif_queue_stopped(dev) &&
  188. time_after(jiffies, dev->trans_start + dev->watchdog_timeo)) {
  189. printk(KERN_INFO "NETDEV WATCHDOG: %s: transmit timed out\n",
  190. dev->name);
  191. dev->tx_timeout(dev);
  192. WARN_ON_ONCE(1);
  193. }
  194. if (!mod_timer(&dev->watchdog_timer, round_jiffies(jiffies + dev->watchdog_timeo)))
  195. dev_hold(dev);
  196. }
  197. }
  198. netif_tx_unlock(dev);
  199. dev_put(dev);
  200. }
  201. void __netdev_watchdog_up(struct net_device *dev)
  202. {
  203. if (dev->tx_timeout) {
  204. if (dev->watchdog_timeo <= 0)
  205. dev->watchdog_timeo = 5*HZ;
  206. if (!mod_timer(&dev->watchdog_timer,
  207. round_jiffies(jiffies + dev->watchdog_timeo)))
  208. dev_hold(dev);
  209. }
  210. }
  211. static void dev_watchdog_up(struct net_device *dev)
  212. {
  213. __netdev_watchdog_up(dev);
  214. }
  215. static void dev_watchdog_down(struct net_device *dev)
  216. {
  217. netif_tx_lock_bh(dev);
  218. if (del_timer(&dev->watchdog_timer))
  219. dev_put(dev);
  220. netif_tx_unlock_bh(dev);
  221. }
  222. /**
  223. * netif_carrier_on - set carrier
  224. * @dev: network device
  225. *
  226. * Device has detected that carrier.
  227. */
  228. void netif_carrier_on(struct net_device *dev)
  229. {
  230. if (test_and_clear_bit(__LINK_STATE_NOCARRIER, &dev->state)) {
  231. linkwatch_fire_event(dev);
  232. if (netif_running(dev))
  233. __netdev_watchdog_up(dev);
  234. }
  235. }
  236. EXPORT_SYMBOL(netif_carrier_on);
  237. /**
  238. * netif_carrier_off - clear carrier
  239. * @dev: network device
  240. *
  241. * Device has detected loss of carrier.
  242. */
  243. void netif_carrier_off(struct net_device *dev)
  244. {
  245. if (!test_and_set_bit(__LINK_STATE_NOCARRIER, &dev->state))
  246. linkwatch_fire_event(dev);
  247. }
  248. EXPORT_SYMBOL(netif_carrier_off);
  249. /* "NOOP" scheduler: the best scheduler, recommended for all interfaces
  250. under all circumstances. It is difficult to invent anything faster or
  251. cheaper.
  252. */
  253. static int noop_enqueue(struct sk_buff *skb, struct Qdisc * qdisc)
  254. {
  255. kfree_skb(skb);
  256. return NET_XMIT_CN;
  257. }
  258. static struct sk_buff *noop_dequeue(struct Qdisc * qdisc)
  259. {
  260. return NULL;
  261. }
  262. static int noop_requeue(struct sk_buff *skb, struct Qdisc* qdisc)
  263. {
  264. if (net_ratelimit())
  265. printk(KERN_DEBUG "%s deferred output. It is buggy.\n",
  266. skb->dev->name);
  267. kfree_skb(skb);
  268. return NET_XMIT_CN;
  269. }
  270. struct Qdisc_ops noop_qdisc_ops __read_mostly = {
  271. .id = "noop",
  272. .priv_size = 0,
  273. .enqueue = noop_enqueue,
  274. .dequeue = noop_dequeue,
  275. .requeue = noop_requeue,
  276. .owner = THIS_MODULE,
  277. };
  278. struct Qdisc noop_qdisc = {
  279. .enqueue = noop_enqueue,
  280. .dequeue = noop_dequeue,
  281. .flags = TCQ_F_BUILTIN,
  282. .ops = &noop_qdisc_ops,
  283. .list = LIST_HEAD_INIT(noop_qdisc.list),
  284. };
  285. EXPORT_SYMBOL(noop_qdisc);
  286. static struct Qdisc_ops noqueue_qdisc_ops __read_mostly = {
  287. .id = "noqueue",
  288. .priv_size = 0,
  289. .enqueue = noop_enqueue,
  290. .dequeue = noop_dequeue,
  291. .requeue = noop_requeue,
  292. .owner = THIS_MODULE,
  293. };
  294. static struct Qdisc noqueue_qdisc = {
  295. .enqueue = NULL,
  296. .dequeue = noop_dequeue,
  297. .flags = TCQ_F_BUILTIN,
  298. .ops = &noqueue_qdisc_ops,
  299. .list = LIST_HEAD_INIT(noqueue_qdisc.list),
  300. };
  301. static const u8 prio2band[TC_PRIO_MAX+1] =
  302. { 1, 2, 2, 2, 1, 2, 0, 0 , 1, 1, 1, 1, 1, 1, 1, 1 };
  303. /* 3-band FIFO queue: old style, but should be a bit faster than
  304. generic prio+fifo combination.
  305. */
  306. #define PFIFO_FAST_BANDS 3
  307. static inline struct sk_buff_head *prio2list(struct sk_buff *skb,
  308. struct Qdisc *qdisc)
  309. {
  310. struct sk_buff_head *list = qdisc_priv(qdisc);
  311. return list + prio2band[skb->priority & TC_PRIO_MAX];
  312. }
  313. static int pfifo_fast_enqueue(struct sk_buff *skb, struct Qdisc* qdisc)
  314. {
  315. struct sk_buff_head *list = prio2list(skb, qdisc);
  316. if (skb_queue_len(list) < qdisc_dev(qdisc)->tx_queue_len) {
  317. qdisc->q.qlen++;
  318. return __qdisc_enqueue_tail(skb, qdisc, list);
  319. }
  320. return qdisc_drop(skb, qdisc);
  321. }
  322. static struct sk_buff *pfifo_fast_dequeue(struct Qdisc* qdisc)
  323. {
  324. int prio;
  325. struct sk_buff_head *list = qdisc_priv(qdisc);
  326. for (prio = 0; prio < PFIFO_FAST_BANDS; prio++) {
  327. if (!skb_queue_empty(list + prio)) {
  328. qdisc->q.qlen--;
  329. return __qdisc_dequeue_head(qdisc, list + prio);
  330. }
  331. }
  332. return NULL;
  333. }
  334. static int pfifo_fast_requeue(struct sk_buff *skb, struct Qdisc* qdisc)
  335. {
  336. qdisc->q.qlen++;
  337. return __qdisc_requeue(skb, qdisc, prio2list(skb, qdisc));
  338. }
  339. static void pfifo_fast_reset(struct Qdisc* qdisc)
  340. {
  341. int prio;
  342. struct sk_buff_head *list = qdisc_priv(qdisc);
  343. for (prio = 0; prio < PFIFO_FAST_BANDS; prio++)
  344. __qdisc_reset_queue(qdisc, list + prio);
  345. qdisc->qstats.backlog = 0;
  346. qdisc->q.qlen = 0;
  347. }
  348. static int pfifo_fast_dump(struct Qdisc *qdisc, struct sk_buff *skb)
  349. {
  350. struct tc_prio_qopt opt = { .bands = PFIFO_FAST_BANDS };
  351. memcpy(&opt.priomap, prio2band, TC_PRIO_MAX+1);
  352. NLA_PUT(skb, TCA_OPTIONS, sizeof(opt), &opt);
  353. return skb->len;
  354. nla_put_failure:
  355. return -1;
  356. }
  357. static int pfifo_fast_init(struct Qdisc *qdisc, struct nlattr *opt)
  358. {
  359. int prio;
  360. struct sk_buff_head *list = qdisc_priv(qdisc);
  361. for (prio = 0; prio < PFIFO_FAST_BANDS; prio++)
  362. skb_queue_head_init(list + prio);
  363. return 0;
  364. }
  365. static struct Qdisc_ops pfifo_fast_ops __read_mostly = {
  366. .id = "pfifo_fast",
  367. .priv_size = PFIFO_FAST_BANDS * sizeof(struct sk_buff_head),
  368. .enqueue = pfifo_fast_enqueue,
  369. .dequeue = pfifo_fast_dequeue,
  370. .requeue = pfifo_fast_requeue,
  371. .init = pfifo_fast_init,
  372. .reset = pfifo_fast_reset,
  373. .dump = pfifo_fast_dump,
  374. .owner = THIS_MODULE,
  375. };
  376. struct Qdisc *qdisc_alloc(struct netdev_queue *dev_queue,
  377. struct Qdisc_ops *ops)
  378. {
  379. void *p;
  380. struct Qdisc *sch;
  381. unsigned int size;
  382. int err = -ENOBUFS;
  383. /* ensure that the Qdisc and the private data are 32-byte aligned */
  384. size = QDISC_ALIGN(sizeof(*sch));
  385. size += ops->priv_size + (QDISC_ALIGNTO - 1);
  386. p = kzalloc(size, GFP_KERNEL);
  387. if (!p)
  388. goto errout;
  389. sch = (struct Qdisc *) QDISC_ALIGN((unsigned long) p);
  390. sch->padded = (char *) sch - (char *) p;
  391. INIT_LIST_HEAD(&sch->list);
  392. skb_queue_head_init(&sch->q);
  393. sch->ops = ops;
  394. sch->enqueue = ops->enqueue;
  395. sch->dequeue = ops->dequeue;
  396. sch->dev_queue = dev_queue;
  397. dev_hold(qdisc_dev(sch));
  398. atomic_set(&sch->refcnt, 1);
  399. return sch;
  400. errout:
  401. return ERR_PTR(err);
  402. }
  403. struct Qdisc * qdisc_create_dflt(struct net_device *dev,
  404. struct netdev_queue *dev_queue,
  405. struct Qdisc_ops *ops,
  406. unsigned int parentid)
  407. {
  408. struct Qdisc *sch;
  409. sch = qdisc_alloc(dev_queue, ops);
  410. if (IS_ERR(sch))
  411. goto errout;
  412. sch->parent = parentid;
  413. if (!ops->init || ops->init(sch, NULL) == 0)
  414. return sch;
  415. qdisc_destroy(sch);
  416. errout:
  417. return NULL;
  418. }
  419. EXPORT_SYMBOL(qdisc_create_dflt);
  420. /* Under queue->lock and BH! */
  421. void qdisc_reset(struct Qdisc *qdisc)
  422. {
  423. const struct Qdisc_ops *ops = qdisc->ops;
  424. if (ops->reset)
  425. ops->reset(qdisc);
  426. }
  427. EXPORT_SYMBOL(qdisc_reset);
  428. /* this is the rcu callback function to clean up a qdisc when there
  429. * are no further references to it */
  430. static void __qdisc_destroy(struct rcu_head *head)
  431. {
  432. struct Qdisc *qdisc = container_of(head, struct Qdisc, q_rcu);
  433. kfree((char *) qdisc - qdisc->padded);
  434. }
  435. /* Under queue->lock and BH! */
  436. void qdisc_destroy(struct Qdisc *qdisc)
  437. {
  438. const struct Qdisc_ops *ops = qdisc->ops;
  439. if (qdisc->flags & TCQ_F_BUILTIN ||
  440. !atomic_dec_and_test(&qdisc->refcnt))
  441. return;
  442. list_del(&qdisc->list);
  443. gen_kill_estimator(&qdisc->bstats, &qdisc->rate_est);
  444. if (ops->reset)
  445. ops->reset(qdisc);
  446. if (ops->destroy)
  447. ops->destroy(qdisc);
  448. module_put(ops->owner);
  449. dev_put(qdisc_dev(qdisc));
  450. call_rcu(&qdisc->q_rcu, __qdisc_destroy);
  451. }
  452. EXPORT_SYMBOL(qdisc_destroy);
  453. void dev_activate(struct net_device *dev)
  454. {
  455. struct netdev_queue *txq = &dev->tx_queue;
  456. /* No queueing discipline is attached to device;
  457. create default one i.e. pfifo_fast for devices,
  458. which need queueing and noqueue_qdisc for
  459. virtual interfaces
  460. */
  461. if (txq->qdisc_sleeping == &noop_qdisc) {
  462. struct Qdisc *qdisc;
  463. if (dev->tx_queue_len) {
  464. qdisc = qdisc_create_dflt(dev, txq,
  465. &pfifo_fast_ops,
  466. TC_H_ROOT);
  467. if (qdisc == NULL) {
  468. printk(KERN_INFO "%s: activation failed\n", dev->name);
  469. return;
  470. }
  471. list_add_tail(&qdisc->list, &txq->qdisc_list);
  472. } else {
  473. qdisc = &noqueue_qdisc;
  474. }
  475. txq->qdisc_sleeping = qdisc;
  476. }
  477. if (!netif_carrier_ok(dev))
  478. /* Delay activation until next carrier-on event */
  479. return;
  480. spin_lock_bh(&txq->lock);
  481. rcu_assign_pointer(txq->qdisc, txq->qdisc_sleeping);
  482. if (txq->qdisc != &noqueue_qdisc) {
  483. dev->trans_start = jiffies;
  484. dev_watchdog_up(dev);
  485. }
  486. spin_unlock_bh(&txq->lock);
  487. }
  488. static void dev_deactivate_queue(struct net_device *dev,
  489. struct netdev_queue *dev_queue,
  490. struct Qdisc *qdisc_default)
  491. {
  492. struct Qdisc *qdisc = dev_queue->qdisc;
  493. if (qdisc) {
  494. dev_queue->qdisc = qdisc_default;
  495. qdisc_reset(qdisc);
  496. }
  497. }
  498. void dev_deactivate(struct net_device *dev)
  499. {
  500. struct sk_buff *skb;
  501. int running;
  502. spin_lock_bh(&dev->tx_queue.lock);
  503. dev_deactivate_queue(dev, &dev->tx_queue, &noop_qdisc);
  504. skb = dev->gso_skb;
  505. dev->gso_skb = NULL;
  506. spin_unlock_bh(&dev->tx_queue.lock);
  507. kfree_skb(skb);
  508. dev_watchdog_down(dev);
  509. /* Wait for outstanding qdisc-less dev_queue_xmit calls. */
  510. synchronize_rcu();
  511. /* Wait for outstanding qdisc_run calls. */
  512. do {
  513. while (test_bit(__LINK_STATE_QDISC_RUNNING, &dev->state))
  514. yield();
  515. /*
  516. * Double-check inside queue lock to ensure that all effects
  517. * of the queue run are visible when we return.
  518. */
  519. spin_lock_bh(&dev->tx_queue.lock);
  520. running = test_bit(__LINK_STATE_QDISC_RUNNING, &dev->state);
  521. spin_unlock_bh(&dev->tx_queue.lock);
  522. /*
  523. * The running flag should never be set at this point because
  524. * we've already set dev->qdisc to noop_qdisc *inside* the same
  525. * pair of spin locks. That is, if any qdisc_run starts after
  526. * our initial test it should see the noop_qdisc and then
  527. * clear the RUNNING bit before dropping the queue lock. So
  528. * if it is set here then we've found a bug.
  529. */
  530. } while (WARN_ON_ONCE(running));
  531. }
  532. static void dev_init_scheduler_queue(struct net_device *dev,
  533. struct netdev_queue *dev_queue,
  534. struct Qdisc *qdisc)
  535. {
  536. dev_queue->qdisc = qdisc;
  537. dev_queue->qdisc_sleeping = qdisc;
  538. INIT_LIST_HEAD(&dev_queue->qdisc_list);
  539. }
  540. void dev_init_scheduler(struct net_device *dev)
  541. {
  542. qdisc_lock_tree(dev);
  543. dev_init_scheduler_queue(dev, &dev->tx_queue, &noop_qdisc);
  544. dev_init_scheduler_queue(dev, &dev->rx_queue, NULL);
  545. qdisc_unlock_tree(dev);
  546. setup_timer(&dev->watchdog_timer, dev_watchdog, (unsigned long)dev);
  547. }
  548. static void dev_shutdown_scheduler_queue(struct net_device *dev,
  549. struct netdev_queue *dev_queue,
  550. struct Qdisc *qdisc_default)
  551. {
  552. struct Qdisc *qdisc = dev_queue->qdisc_sleeping;
  553. if (qdisc) {
  554. dev_queue->qdisc = qdisc_default;
  555. dev_queue->qdisc_sleeping = qdisc_default;
  556. qdisc_destroy(qdisc);
  557. }
  558. }
  559. void dev_shutdown(struct net_device *dev)
  560. {
  561. qdisc_lock_tree(dev);
  562. dev_shutdown_scheduler_queue(dev, &dev->tx_queue, &noop_qdisc);
  563. dev_shutdown_scheduler_queue(dev, &dev->rx_queue, NULL);
  564. BUG_TRAP(!timer_pending(&dev->watchdog_timer));
  565. qdisc_unlock_tree(dev);
  566. }