Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef __NET_SCHED_GENERIC_H |
| 2 | #define __NET_SCHED_GENERIC_H |
| 3 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | #include <linux/netdevice.h> |
| 5 | #include <linux/types.h> |
| 6 | #include <linux/rcupdate.h> |
| 7 | #include <linux/module.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | #include <linux/pkt_sched.h> |
| 9 | #include <linux/pkt_cls.h> |
| 10 | #include <net/gen_stats.h> |
Thomas Graf | be577dd | 2007-03-22 11:55:50 -0700 | [diff] [blame] | 11 | #include <net/rtnetlink.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | |
| 13 | struct Qdisc_ops; |
| 14 | struct qdisc_walker; |
| 15 | struct tcf_walker; |
| 16 | struct module; |
| 17 | |
| 18 | struct qdisc_rate_table |
| 19 | { |
| 20 | struct tc_ratespec rate; |
| 21 | u32 data[256]; |
| 22 | struct qdisc_rate_table *next; |
| 23 | int refcnt; |
| 24 | }; |
| 25 | |
David S. Miller | e2627c8 | 2008-07-16 00:56:32 -0700 | [diff] [blame^] | 26 | enum qdisc_state_t |
| 27 | { |
| 28 | __QDISC_STATE_RUNNING, |
| 29 | }; |
| 30 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | struct Qdisc |
| 32 | { |
| 33 | int (*enqueue)(struct sk_buff *skb, struct Qdisc *dev); |
| 34 | struct sk_buff * (*dequeue)(struct Qdisc *dev); |
| 35 | unsigned flags; |
| 36 | #define TCQ_F_BUILTIN 1 |
| 37 | #define TCQ_F_THROTTLED 2 |
| 38 | #define TCQ_F_INGRESS 4 |
| 39 | int padded; |
| 40 | struct Qdisc_ops *ops; |
| 41 | u32 handle; |
| 42 | u32 parent; |
| 43 | atomic_t refcnt; |
David S. Miller | e2627c8 | 2008-07-16 00:56:32 -0700 | [diff] [blame^] | 44 | unsigned long state; |
David S. Miller | d3b753d | 2008-07-15 20:14:35 -0700 | [diff] [blame] | 45 | struct sk_buff *gso_skb; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | struct sk_buff_head q; |
David S. Miller | bb949fb | 2008-07-08 16:55:56 -0700 | [diff] [blame] | 47 | struct netdev_queue *dev_queue; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | struct list_head list; |
| 49 | |
| 50 | struct gnet_stats_basic bstats; |
| 51 | struct gnet_stats_queue qstats; |
| 52 | struct gnet_stats_rate_est rate_est; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | struct rcu_head q_rcu; |
| 54 | int (*reshape_fail)(struct sk_buff *skb, |
| 55 | struct Qdisc *q); |
| 56 | |
| 57 | /* This field is deprecated, but it is still used by CBQ |
| 58 | * and it will live until better solution will be invented. |
| 59 | */ |
| 60 | struct Qdisc *__parent; |
| 61 | }; |
| 62 | |
| 63 | struct Qdisc_class_ops |
| 64 | { |
| 65 | /* Child qdisc manipulation */ |
| 66 | int (*graft)(struct Qdisc *, unsigned long cl, |
| 67 | struct Qdisc *, struct Qdisc **); |
| 68 | struct Qdisc * (*leaf)(struct Qdisc *, unsigned long cl); |
Patrick McHardy | 43effa1 | 2006-11-29 17:35:48 -0800 | [diff] [blame] | 69 | void (*qlen_notify)(struct Qdisc *, unsigned long); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | |
| 71 | /* Class manipulation routines */ |
| 72 | unsigned long (*get)(struct Qdisc *, u32 classid); |
| 73 | void (*put)(struct Qdisc *, unsigned long); |
| 74 | int (*change)(struct Qdisc *, u32, u32, |
Patrick McHardy | 1e90474 | 2008-01-22 22:11:17 -0800 | [diff] [blame] | 75 | struct nlattr **, unsigned long *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | int (*delete)(struct Qdisc *, unsigned long); |
| 77 | void (*walk)(struct Qdisc *, struct qdisc_walker * arg); |
| 78 | |
| 79 | /* Filter manipulation */ |
| 80 | struct tcf_proto ** (*tcf_chain)(struct Qdisc *, unsigned long); |
| 81 | unsigned long (*bind_tcf)(struct Qdisc *, unsigned long, |
| 82 | u32 classid); |
| 83 | void (*unbind_tcf)(struct Qdisc *, unsigned long); |
| 84 | |
| 85 | /* rtnetlink specific */ |
| 86 | int (*dump)(struct Qdisc *, unsigned long, |
| 87 | struct sk_buff *skb, struct tcmsg*); |
| 88 | int (*dump_stats)(struct Qdisc *, unsigned long, |
| 89 | struct gnet_dump *); |
| 90 | }; |
| 91 | |
| 92 | struct Qdisc_ops |
| 93 | { |
| 94 | struct Qdisc_ops *next; |
Eric Dumazet | 20fea08 | 2007-11-14 01:44:41 -0800 | [diff] [blame] | 95 | const struct Qdisc_class_ops *cl_ops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | char id[IFNAMSIZ]; |
| 97 | int priv_size; |
| 98 | |
| 99 | int (*enqueue)(struct sk_buff *, struct Qdisc *); |
| 100 | struct sk_buff * (*dequeue)(struct Qdisc *); |
| 101 | int (*requeue)(struct sk_buff *, struct Qdisc *); |
| 102 | unsigned int (*drop)(struct Qdisc *); |
| 103 | |
Patrick McHardy | 1e90474 | 2008-01-22 22:11:17 -0800 | [diff] [blame] | 104 | int (*init)(struct Qdisc *, struct nlattr *arg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | void (*reset)(struct Qdisc *); |
| 106 | void (*destroy)(struct Qdisc *); |
Patrick McHardy | 1e90474 | 2008-01-22 22:11:17 -0800 | [diff] [blame] | 107 | int (*change)(struct Qdisc *, struct nlattr *arg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | |
| 109 | int (*dump)(struct Qdisc *, struct sk_buff *); |
| 110 | int (*dump_stats)(struct Qdisc *, struct gnet_dump *); |
| 111 | |
| 112 | struct module *owner; |
| 113 | }; |
| 114 | |
| 115 | |
| 116 | struct tcf_result |
| 117 | { |
| 118 | unsigned long class; |
| 119 | u32 classid; |
| 120 | }; |
| 121 | |
| 122 | struct tcf_proto_ops |
| 123 | { |
| 124 | struct tcf_proto_ops *next; |
| 125 | char kind[IFNAMSIZ]; |
| 126 | |
| 127 | int (*classify)(struct sk_buff*, struct tcf_proto*, |
| 128 | struct tcf_result *); |
| 129 | int (*init)(struct tcf_proto*); |
| 130 | void (*destroy)(struct tcf_proto*); |
| 131 | |
| 132 | unsigned long (*get)(struct tcf_proto*, u32 handle); |
| 133 | void (*put)(struct tcf_proto*, unsigned long); |
| 134 | int (*change)(struct tcf_proto*, unsigned long, |
Patrick McHardy | add93b6 | 2008-01-22 22:11:33 -0800 | [diff] [blame] | 135 | u32 handle, struct nlattr **, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | unsigned long *); |
| 137 | int (*delete)(struct tcf_proto*, unsigned long); |
| 138 | void (*walk)(struct tcf_proto*, struct tcf_walker *arg); |
| 139 | |
| 140 | /* rtnetlink specific */ |
| 141 | int (*dump)(struct tcf_proto*, unsigned long, |
| 142 | struct sk_buff *skb, struct tcmsg*); |
| 143 | |
| 144 | struct module *owner; |
| 145 | }; |
| 146 | |
| 147 | struct tcf_proto |
| 148 | { |
| 149 | /* Fast access part */ |
| 150 | struct tcf_proto *next; |
| 151 | void *root; |
| 152 | int (*classify)(struct sk_buff*, struct tcf_proto*, |
| 153 | struct tcf_result *); |
Al Viro | 66c6f52 | 2006-11-20 18:07:51 -0800 | [diff] [blame] | 154 | __be16 protocol; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 155 | |
| 156 | /* All the rest */ |
| 157 | u32 prio; |
| 158 | u32 classid; |
| 159 | struct Qdisc *q; |
| 160 | void *data; |
| 161 | struct tcf_proto_ops *ops; |
| 162 | }; |
| 163 | |
David S. Miller | 5ce2d48 | 2008-07-08 17:06:30 -0700 | [diff] [blame] | 164 | static inline struct net_device *qdisc_dev(struct Qdisc *qdisc) |
| 165 | { |
| 166 | return qdisc->dev_queue->dev; |
| 167 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 168 | |
| 169 | extern void qdisc_lock_tree(struct net_device *dev); |
| 170 | extern void qdisc_unlock_tree(struct net_device *dev); |
| 171 | |
David S. Miller | 5ce2d48 | 2008-07-08 17:06:30 -0700 | [diff] [blame] | 172 | #define sch_tree_lock(q) qdisc_lock_tree(qdisc_dev(q)) |
| 173 | #define sch_tree_unlock(q) qdisc_unlock_tree(qdisc_dev(q)) |
| 174 | #define tcf_tree_lock(tp) qdisc_lock_tree(qdisc_dev((tp)->q)) |
| 175 | #define tcf_tree_unlock(tp) qdisc_unlock_tree(qdisc_dev((tp)->q)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | |
Thomas Graf | e41a33e | 2005-07-05 14:14:30 -0700 | [diff] [blame] | 177 | extern struct Qdisc noop_qdisc; |
| 178 | extern struct Qdisc_ops noop_qdisc_ops; |
| 179 | |
Patrick McHardy | 6fe1c7a | 2008-07-05 23:21:31 -0700 | [diff] [blame] | 180 | struct Qdisc_class_common |
| 181 | { |
| 182 | u32 classid; |
| 183 | struct hlist_node hnode; |
| 184 | }; |
| 185 | |
| 186 | struct Qdisc_class_hash |
| 187 | { |
| 188 | struct hlist_head *hash; |
| 189 | unsigned int hashsize; |
| 190 | unsigned int hashmask; |
| 191 | unsigned int hashelems; |
| 192 | }; |
| 193 | |
| 194 | static inline unsigned int qdisc_class_hash(u32 id, u32 mask) |
| 195 | { |
| 196 | id ^= id >> 8; |
| 197 | id ^= id >> 4; |
| 198 | return id & mask; |
| 199 | } |
| 200 | |
| 201 | static inline struct Qdisc_class_common * |
| 202 | qdisc_class_find(struct Qdisc_class_hash *hash, u32 id) |
| 203 | { |
| 204 | struct Qdisc_class_common *cl; |
| 205 | struct hlist_node *n; |
| 206 | unsigned int h; |
| 207 | |
| 208 | h = qdisc_class_hash(id, hash->hashmask); |
| 209 | hlist_for_each_entry(cl, n, &hash->hash[h], hnode) { |
| 210 | if (cl->classid == id) |
| 211 | return cl; |
| 212 | } |
| 213 | return NULL; |
| 214 | } |
| 215 | |
| 216 | extern int qdisc_class_hash_init(struct Qdisc_class_hash *); |
| 217 | extern void qdisc_class_hash_insert(struct Qdisc_class_hash *, struct Qdisc_class_common *); |
| 218 | extern void qdisc_class_hash_remove(struct Qdisc_class_hash *, struct Qdisc_class_common *); |
| 219 | extern void qdisc_class_hash_grow(struct Qdisc *, struct Qdisc_class_hash *); |
| 220 | extern void qdisc_class_hash_destroy(struct Qdisc_class_hash *); |
| 221 | |
Thomas Graf | e41a33e | 2005-07-05 14:14:30 -0700 | [diff] [blame] | 222 | extern void dev_init_scheduler(struct net_device *dev); |
| 223 | extern void dev_shutdown(struct net_device *dev); |
| 224 | extern void dev_activate(struct net_device *dev); |
| 225 | extern void dev_deactivate(struct net_device *dev); |
| 226 | extern void qdisc_reset(struct Qdisc *qdisc); |
| 227 | extern void qdisc_destroy(struct Qdisc *qdisc); |
Patrick McHardy | 43effa1 | 2006-11-29 17:35:48 -0800 | [diff] [blame] | 228 | extern void qdisc_tree_decrease_qlen(struct Qdisc *qdisc, unsigned int n); |
David S. Miller | 5ce2d48 | 2008-07-08 17:06:30 -0700 | [diff] [blame] | 229 | extern struct Qdisc *qdisc_alloc(struct netdev_queue *dev_queue, |
David S. Miller | bb949fb | 2008-07-08 16:55:56 -0700 | [diff] [blame] | 230 | struct Qdisc_ops *ops); |
Thomas Graf | e41a33e | 2005-07-05 14:14:30 -0700 | [diff] [blame] | 231 | extern struct Qdisc *qdisc_create_dflt(struct net_device *dev, |
David S. Miller | bb949fb | 2008-07-08 16:55:56 -0700 | [diff] [blame] | 232 | struct netdev_queue *dev_queue, |
Patrick McHardy | 9f9afec | 2006-11-29 17:35:18 -0800 | [diff] [blame] | 233 | struct Qdisc_ops *ops, u32 parentid); |
Patrick McHardy | a48b5a6 | 2007-03-23 11:29:43 -0700 | [diff] [blame] | 234 | extern void tcf_destroy(struct tcf_proto *tp); |
Patrick McHardy | ff31ab5 | 2008-07-01 19:52:38 -0700 | [diff] [blame] | 235 | extern void tcf_destroy_chain(struct tcf_proto **fl); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 236 | |
David S. Miller | 5aa7099 | 2008-07-08 22:59:10 -0700 | [diff] [blame] | 237 | /* Reset all TX qdiscs of a device. */ |
| 238 | static inline void qdisc_reset_all_tx(struct net_device *dev) |
| 239 | { |
David S. Miller | e8a0464 | 2008-07-17 00:34:19 -0700 | [diff] [blame] | 240 | unsigned int i; |
| 241 | for (i = 0; i < dev->num_tx_queues; i++) |
| 242 | qdisc_reset(netdev_get_tx_queue(dev, i)->qdisc); |
David S. Miller | 5aa7099 | 2008-07-08 22:59:10 -0700 | [diff] [blame] | 243 | } |
| 244 | |
David S. Miller | 3e745dd | 2008-07-08 23:00:25 -0700 | [diff] [blame] | 245 | /* Are all TX queues of the device empty? */ |
| 246 | static inline bool qdisc_all_tx_empty(const struct net_device *dev) |
| 247 | { |
David S. Miller | e8a0464 | 2008-07-17 00:34:19 -0700 | [diff] [blame] | 248 | unsigned int i; |
| 249 | for (i = 0; i < dev->num_tx_queues; i++) { |
| 250 | struct netdev_queue *txq = netdev_get_tx_queue(dev, i); |
| 251 | const struct Qdisc *q = txq->qdisc; |
David S. Miller | 3e745dd | 2008-07-08 23:00:25 -0700 | [diff] [blame] | 252 | |
David S. Miller | e8a0464 | 2008-07-17 00:34:19 -0700 | [diff] [blame] | 253 | if (q->q.qlen) |
| 254 | return false; |
| 255 | } |
| 256 | return true; |
David S. Miller | 3e745dd | 2008-07-08 23:00:25 -0700 | [diff] [blame] | 257 | } |
| 258 | |
David S. Miller | 6fa9864 | 2008-07-08 23:01:06 -0700 | [diff] [blame] | 259 | /* Are any of the TX qdiscs changing? */ |
| 260 | static inline bool qdisc_tx_changing(struct net_device *dev) |
| 261 | { |
David S. Miller | e8a0464 | 2008-07-17 00:34:19 -0700 | [diff] [blame] | 262 | unsigned int i; |
| 263 | for (i = 0; i < dev->num_tx_queues; i++) { |
| 264 | struct netdev_queue *txq = netdev_get_tx_queue(dev, i); |
| 265 | if (txq->qdisc != txq->qdisc_sleeping) |
| 266 | return true; |
| 267 | } |
| 268 | return false; |
David S. Miller | 6fa9864 | 2008-07-08 23:01:06 -0700 | [diff] [blame] | 269 | } |
| 270 | |
David S. Miller | e8a0464 | 2008-07-17 00:34:19 -0700 | [diff] [blame] | 271 | /* Is the device using the noop qdisc on all queues? */ |
David S. Miller | 0529794 | 2008-07-08 23:01:27 -0700 | [diff] [blame] | 272 | static inline bool qdisc_tx_is_noop(const struct net_device *dev) |
| 273 | { |
David S. Miller | e8a0464 | 2008-07-17 00:34:19 -0700 | [diff] [blame] | 274 | unsigned int i; |
| 275 | for (i = 0; i < dev->num_tx_queues; i++) { |
| 276 | struct netdev_queue *txq = netdev_get_tx_queue(dev, i); |
| 277 | if (txq->qdisc != &noop_qdisc) |
| 278 | return false; |
| 279 | } |
| 280 | return true; |
David S. Miller | 0529794 | 2008-07-08 23:01:27 -0700 | [diff] [blame] | 281 | } |
| 282 | |
Thomas Graf | 9972b25 | 2005-06-18 22:57:26 -0700 | [diff] [blame] | 283 | static inline int __qdisc_enqueue_tail(struct sk_buff *skb, struct Qdisc *sch, |
| 284 | struct sk_buff_head *list) |
| 285 | { |
| 286 | __skb_queue_tail(list, skb); |
| 287 | sch->qstats.backlog += skb->len; |
| 288 | sch->bstats.bytes += skb->len; |
| 289 | sch->bstats.packets++; |
| 290 | |
| 291 | return NET_XMIT_SUCCESS; |
| 292 | } |
| 293 | |
| 294 | static inline int qdisc_enqueue_tail(struct sk_buff *skb, struct Qdisc *sch) |
| 295 | { |
| 296 | return __qdisc_enqueue_tail(skb, sch, &sch->q); |
| 297 | } |
| 298 | |
| 299 | static inline struct sk_buff *__qdisc_dequeue_head(struct Qdisc *sch, |
| 300 | struct sk_buff_head *list) |
| 301 | { |
| 302 | struct sk_buff *skb = __skb_dequeue(list); |
| 303 | |
| 304 | if (likely(skb != NULL)) |
| 305 | sch->qstats.backlog -= skb->len; |
| 306 | |
| 307 | return skb; |
| 308 | } |
| 309 | |
| 310 | static inline struct sk_buff *qdisc_dequeue_head(struct Qdisc *sch) |
| 311 | { |
| 312 | return __qdisc_dequeue_head(sch, &sch->q); |
| 313 | } |
| 314 | |
| 315 | static inline struct sk_buff *__qdisc_dequeue_tail(struct Qdisc *sch, |
| 316 | struct sk_buff_head *list) |
| 317 | { |
| 318 | struct sk_buff *skb = __skb_dequeue_tail(list); |
| 319 | |
| 320 | if (likely(skb != NULL)) |
| 321 | sch->qstats.backlog -= skb->len; |
| 322 | |
| 323 | return skb; |
| 324 | } |
| 325 | |
| 326 | static inline struct sk_buff *qdisc_dequeue_tail(struct Qdisc *sch) |
| 327 | { |
| 328 | return __qdisc_dequeue_tail(sch, &sch->q); |
| 329 | } |
| 330 | |
| 331 | static inline int __qdisc_requeue(struct sk_buff *skb, struct Qdisc *sch, |
| 332 | struct sk_buff_head *list) |
| 333 | { |
| 334 | __skb_queue_head(list, skb); |
| 335 | sch->qstats.backlog += skb->len; |
| 336 | sch->qstats.requeues++; |
| 337 | |
| 338 | return NET_XMIT_SUCCESS; |
| 339 | } |
| 340 | |
| 341 | static inline int qdisc_requeue(struct sk_buff *skb, struct Qdisc *sch) |
| 342 | { |
| 343 | return __qdisc_requeue(skb, sch, &sch->q); |
| 344 | } |
| 345 | |
| 346 | static inline void __qdisc_reset_queue(struct Qdisc *sch, |
| 347 | struct sk_buff_head *list) |
| 348 | { |
| 349 | /* |
| 350 | * We do not know the backlog in bytes of this list, it |
| 351 | * is up to the caller to correct it |
| 352 | */ |
| 353 | skb_queue_purge(list); |
| 354 | } |
| 355 | |
| 356 | static inline void qdisc_reset_queue(struct Qdisc *sch) |
| 357 | { |
| 358 | __qdisc_reset_queue(sch, &sch->q); |
| 359 | sch->qstats.backlog = 0; |
| 360 | } |
| 361 | |
| 362 | static inline unsigned int __qdisc_queue_drop(struct Qdisc *sch, |
| 363 | struct sk_buff_head *list) |
| 364 | { |
| 365 | struct sk_buff *skb = __qdisc_dequeue_tail(sch, list); |
| 366 | |
| 367 | if (likely(skb != NULL)) { |
| 368 | unsigned int len = skb->len; |
| 369 | kfree_skb(skb); |
| 370 | return len; |
| 371 | } |
| 372 | |
| 373 | return 0; |
| 374 | } |
| 375 | |
| 376 | static inline unsigned int qdisc_queue_drop(struct Qdisc *sch) |
| 377 | { |
| 378 | return __qdisc_queue_drop(sch, &sch->q); |
| 379 | } |
| 380 | |
| 381 | static inline int qdisc_drop(struct sk_buff *skb, struct Qdisc *sch) |
| 382 | { |
| 383 | kfree_skb(skb); |
| 384 | sch->qstats.drops++; |
| 385 | |
| 386 | return NET_XMIT_DROP; |
| 387 | } |
| 388 | |
| 389 | static inline int qdisc_reshape_fail(struct sk_buff *skb, struct Qdisc *sch) |
| 390 | { |
| 391 | sch->qstats.drops++; |
| 392 | |
Patrick McHardy | c3bc7cf | 2007-07-15 00:03:05 -0700 | [diff] [blame] | 393 | #ifdef CONFIG_NET_CLS_ACT |
Thomas Graf | 9972b25 | 2005-06-18 22:57:26 -0700 | [diff] [blame] | 394 | if (sch->reshape_fail == NULL || sch->reshape_fail(skb, sch)) |
| 395 | goto drop; |
| 396 | |
| 397 | return NET_XMIT_SUCCESS; |
| 398 | |
| 399 | drop: |
| 400 | #endif |
| 401 | kfree_skb(skb); |
| 402 | return NET_XMIT_DROP; |
| 403 | } |
| 404 | |
Jesper Dangaard Brouer | e9bef55 | 2007-09-12 16:35:24 +0200 | [diff] [blame] | 405 | /* Length to Time (L2T) lookup in a qdisc_rate_table, to determine how |
| 406 | long it will take to send a packet given its size. |
| 407 | */ |
| 408 | static inline u32 qdisc_l2t(struct qdisc_rate_table* rtab, unsigned int pktlen) |
| 409 | { |
Jesper Dangaard Brouer | e08b099 | 2007-09-12 16:36:28 +0200 | [diff] [blame] | 410 | int slot = pktlen + rtab->rate.cell_align + rtab->rate.overhead; |
| 411 | if (slot < 0) |
| 412 | slot = 0; |
Jesper Dangaard Brouer | e9bef55 | 2007-09-12 16:35:24 +0200 | [diff] [blame] | 413 | slot >>= rtab->rate.cell_log; |
| 414 | if (slot > 255) |
| 415 | return (rtab->data[255]*(slot >> 8) + rtab->data[slot & 0xFF]); |
| 416 | return rtab->data[slot]; |
| 417 | } |
| 418 | |
Jamal Hadi Salim | 12da81d | 2007-10-26 02:47:23 -0700 | [diff] [blame] | 419 | #ifdef CONFIG_NET_CLS_ACT |
| 420 | static inline struct sk_buff *skb_act_clone(struct sk_buff *skb, gfp_t gfp_mask) |
| 421 | { |
| 422 | struct sk_buff *n = skb_clone(skb, gfp_mask); |
| 423 | |
| 424 | if (n) { |
| 425 | n->tc_verd = SET_TC_VERD(n->tc_verd, 0); |
| 426 | n->tc_verd = CLR_TC_OK2MUNGE(n->tc_verd); |
| 427 | n->tc_verd = CLR_TC_MUNGED(n->tc_verd); |
Jamal Hadi Salim | 12da81d | 2007-10-26 02:47:23 -0700 | [diff] [blame] | 428 | } |
| 429 | return n; |
| 430 | } |
| 431 | #endif |
| 432 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 433 | #endif |