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