sch_generic.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665
  1. #ifndef __NET_SCHED_GENERIC_H
  2. #define __NET_SCHED_GENERIC_H
  3. #include <linux/netdevice.h>
  4. #include <linux/types.h>
  5. #include <linux/rcupdate.h>
  6. #include <linux/module.h>
  7. #include <linux/pkt_sched.h>
  8. #include <linux/pkt_cls.h>
  9. #include <net/gen_stats.h>
  10. #include <net/rtnetlink.h>
  11. struct Qdisc_ops;
  12. struct qdisc_walker;
  13. struct tcf_walker;
  14. struct module;
  15. struct qdisc_rate_table {
  16. struct tc_ratespec rate;
  17. u32 data[256];
  18. struct qdisc_rate_table *next;
  19. int refcnt;
  20. };
  21. enum qdisc_state_t {
  22. __QDISC_STATE_SCHED,
  23. __QDISC_STATE_DEACTIVATED,
  24. __QDISC_STATE_THROTTLED,
  25. };
  26. /*
  27. * following bits are only changed while qdisc lock is held
  28. */
  29. enum qdisc___state_t {
  30. __QDISC___STATE_RUNNING = 1,
  31. };
  32. struct qdisc_size_table {
  33. struct rcu_head rcu;
  34. struct list_head list;
  35. struct tc_sizespec szopts;
  36. int refcnt;
  37. u16 data[];
  38. };
  39. struct Qdisc {
  40. int (*enqueue)(struct sk_buff *skb, struct Qdisc *dev);
  41. struct sk_buff * (*dequeue)(struct Qdisc *dev);
  42. unsigned flags;
  43. #define TCQ_F_BUILTIN 1
  44. #define TCQ_F_INGRESS 2
  45. #define TCQ_F_CAN_BYPASS 4
  46. #define TCQ_F_MQROOT 8
  47. #define TCQ_F_WARN_NONWC (1 << 16)
  48. int padded;
  49. struct Qdisc_ops *ops;
  50. struct qdisc_size_table __rcu *stab;
  51. struct list_head list;
  52. u32 handle;
  53. u32 parent;
  54. atomic_t refcnt;
  55. struct gnet_stats_rate_est rate_est;
  56. int (*reshape_fail)(struct sk_buff *skb,
  57. struct Qdisc *q);
  58. void *u32_node;
  59. /* This field is deprecated, but it is still used by CBQ
  60. * and it will live until better solution will be invented.
  61. */
  62. struct Qdisc *__parent;
  63. struct netdev_queue *dev_queue;
  64. struct Qdisc *next_sched;
  65. struct sk_buff *gso_skb;
  66. /*
  67. * For performance sake on SMP, we put highly modified fields at the end
  68. */
  69. unsigned long state;
  70. struct sk_buff_head q;
  71. struct gnet_stats_basic_packed bstats;
  72. unsigned int __state;
  73. struct gnet_stats_queue qstats;
  74. struct rcu_head rcu_head;
  75. spinlock_t busylock;
  76. u32 limit;
  77. };
  78. static inline bool qdisc_is_running(const struct Qdisc *qdisc)
  79. {
  80. return (qdisc->__state & __QDISC___STATE_RUNNING) ? true : false;
  81. }
  82. static inline bool qdisc_run_begin(struct Qdisc *qdisc)
  83. {
  84. if (qdisc_is_running(qdisc))
  85. return false;
  86. qdisc->__state |= __QDISC___STATE_RUNNING;
  87. return true;
  88. }
  89. static inline void qdisc_run_end(struct Qdisc *qdisc)
  90. {
  91. qdisc->__state &= ~__QDISC___STATE_RUNNING;
  92. }
  93. static inline bool qdisc_is_throttled(const struct Qdisc *qdisc)
  94. {
  95. return test_bit(__QDISC_STATE_THROTTLED, &qdisc->state) ? true : false;
  96. }
  97. static inline void qdisc_throttled(struct Qdisc *qdisc)
  98. {
  99. set_bit(__QDISC_STATE_THROTTLED, &qdisc->state);
  100. }
  101. static inline void qdisc_unthrottled(struct Qdisc *qdisc)
  102. {
  103. clear_bit(__QDISC_STATE_THROTTLED, &qdisc->state);
  104. }
  105. struct Qdisc_class_ops {
  106. /* Child qdisc manipulation */
  107. struct netdev_queue * (*select_queue)(struct Qdisc *, struct tcmsg *);
  108. int (*graft)(struct Qdisc *, unsigned long cl,
  109. struct Qdisc *, struct Qdisc **);
  110. struct Qdisc * (*leaf)(struct Qdisc *, unsigned long cl);
  111. void (*qlen_notify)(struct Qdisc *, unsigned long);
  112. /* Class manipulation routines */
  113. unsigned long (*get)(struct Qdisc *, u32 classid);
  114. void (*put)(struct Qdisc *, unsigned long);
  115. int (*change)(struct Qdisc *, u32, u32,
  116. struct nlattr **, unsigned long *);
  117. int (*delete)(struct Qdisc *, unsigned long);
  118. void (*walk)(struct Qdisc *, struct qdisc_walker * arg);
  119. /* Filter manipulation */
  120. struct tcf_proto ** (*tcf_chain)(struct Qdisc *, unsigned long);
  121. unsigned long (*bind_tcf)(struct Qdisc *, unsigned long,
  122. u32 classid);
  123. void (*unbind_tcf)(struct Qdisc *, unsigned long);
  124. /* rtnetlink specific */
  125. int (*dump)(struct Qdisc *, unsigned long,
  126. struct sk_buff *skb, struct tcmsg*);
  127. int (*dump_stats)(struct Qdisc *, unsigned long,
  128. struct gnet_dump *);
  129. };
  130. struct Qdisc_ops {
  131. struct Qdisc_ops *next;
  132. const struct Qdisc_class_ops *cl_ops;
  133. char id[IFNAMSIZ];
  134. int priv_size;
  135. int (*enqueue)(struct sk_buff *, struct Qdisc *);
  136. struct sk_buff * (*dequeue)(struct Qdisc *);
  137. struct sk_buff * (*peek)(struct Qdisc *);
  138. unsigned int (*drop)(struct Qdisc *);
  139. int (*init)(struct Qdisc *, struct nlattr *arg);
  140. void (*reset)(struct Qdisc *);
  141. void (*destroy)(struct Qdisc *);
  142. int (*change)(struct Qdisc *, struct nlattr *arg);
  143. void (*attach)(struct Qdisc *);
  144. int (*dump)(struct Qdisc *, struct sk_buff *);
  145. int (*dump_stats)(struct Qdisc *, struct gnet_dump *);
  146. struct module *owner;
  147. };
  148. struct tcf_result {
  149. unsigned long class;
  150. u32 classid;
  151. };
  152. struct tcf_proto_ops {
  153. struct tcf_proto_ops *next;
  154. char kind[IFNAMSIZ];
  155. int (*classify)(struct sk_buff *,
  156. const struct tcf_proto *,
  157. struct tcf_result *);
  158. int (*init)(struct tcf_proto*);
  159. void (*destroy)(struct tcf_proto*);
  160. unsigned long (*get)(struct tcf_proto*, u32 handle);
  161. void (*put)(struct tcf_proto*, unsigned long);
  162. int (*change)(struct tcf_proto*, unsigned long,
  163. u32 handle, struct nlattr **,
  164. unsigned long *);
  165. int (*delete)(struct tcf_proto*, unsigned long);
  166. void (*walk)(struct tcf_proto*, struct tcf_walker *arg);
  167. /* rtnetlink specific */
  168. int (*dump)(struct tcf_proto*, unsigned long,
  169. struct sk_buff *skb, struct tcmsg*);
  170. struct module *owner;
  171. };
  172. struct tcf_proto {
  173. /* Fast access part */
  174. struct tcf_proto *next;
  175. void *root;
  176. int (*classify)(struct sk_buff *,
  177. const struct tcf_proto *,
  178. struct tcf_result *);
  179. __be16 protocol;
  180. /* All the rest */
  181. u32 prio;
  182. u32 classid;
  183. struct Qdisc *q;
  184. void *data;
  185. const struct tcf_proto_ops *ops;
  186. };
  187. struct qdisc_skb_cb {
  188. unsigned int pkt_len;
  189. long data[];
  190. };
  191. static inline int qdisc_qlen(struct Qdisc *q)
  192. {
  193. return q->q.qlen;
  194. }
  195. static inline struct qdisc_skb_cb *qdisc_skb_cb(const struct sk_buff *skb)
  196. {
  197. return (struct qdisc_skb_cb *)skb->cb;
  198. }
  199. static inline spinlock_t *qdisc_lock(struct Qdisc *qdisc)
  200. {
  201. return &qdisc->q.lock;
  202. }
  203. static inline struct Qdisc *qdisc_root(struct Qdisc *qdisc)
  204. {
  205. return qdisc->dev_queue->qdisc;
  206. }
  207. static inline struct Qdisc *qdisc_root_sleeping(struct Qdisc *qdisc)
  208. {
  209. return qdisc->dev_queue->qdisc_sleeping;
  210. }
  211. /* The qdisc root lock is a mechanism by which to top level
  212. * of a qdisc tree can be locked from any qdisc node in the
  213. * forest. This allows changing the configuration of some
  214. * aspect of the qdisc tree while blocking out asynchronous
  215. * qdisc access in the packet processing paths.
  216. *
  217. * It is only legal to do this when the root will not change
  218. * on us. Otherwise we'll potentially lock the wrong qdisc
  219. * root. This is enforced by holding the RTNL semaphore, which
  220. * all users of this lock accessor must do.
  221. */
  222. static inline spinlock_t *qdisc_root_lock(struct Qdisc *qdisc)
  223. {
  224. struct Qdisc *root = qdisc_root(qdisc);
  225. ASSERT_RTNL();
  226. return qdisc_lock(root);
  227. }
  228. static inline spinlock_t *qdisc_root_sleeping_lock(struct Qdisc *qdisc)
  229. {
  230. struct Qdisc *root = qdisc_root_sleeping(qdisc);
  231. ASSERT_RTNL();
  232. return qdisc_lock(root);
  233. }
  234. static inline struct net_device *qdisc_dev(struct Qdisc *qdisc)
  235. {
  236. return qdisc->dev_queue->dev;
  237. }
  238. static inline void sch_tree_lock(struct Qdisc *q)
  239. {
  240. spin_lock_bh(qdisc_root_sleeping_lock(q));
  241. }
  242. static inline void sch_tree_unlock(struct Qdisc *q)
  243. {
  244. spin_unlock_bh(qdisc_root_sleeping_lock(q));
  245. }
  246. #define tcf_tree_lock(tp) sch_tree_lock((tp)->q)
  247. #define tcf_tree_unlock(tp) sch_tree_unlock((tp)->q)
  248. extern struct Qdisc noop_qdisc;
  249. extern struct Qdisc_ops noop_qdisc_ops;
  250. extern struct Qdisc_ops pfifo_fast_ops;
  251. extern struct Qdisc_ops mq_qdisc_ops;
  252. struct Qdisc_class_common {
  253. u32 classid;
  254. struct hlist_node hnode;
  255. };
  256. struct Qdisc_class_hash {
  257. struct hlist_head *hash;
  258. unsigned int hashsize;
  259. unsigned int hashmask;
  260. unsigned int hashelems;
  261. };
  262. static inline unsigned int qdisc_class_hash(u32 id, u32 mask)
  263. {
  264. id ^= id >> 8;
  265. id ^= id >> 4;
  266. return id & mask;
  267. }
  268. static inline struct Qdisc_class_common *
  269. qdisc_class_find(struct Qdisc_class_hash *hash, u32 id)
  270. {
  271. struct Qdisc_class_common *cl;
  272. struct hlist_node *n;
  273. unsigned int h;
  274. h = qdisc_class_hash(id, hash->hashmask);
  275. hlist_for_each_entry(cl, n, &hash->hash[h], hnode) {
  276. if (cl->classid == id)
  277. return cl;
  278. }
  279. return NULL;
  280. }
  281. extern int qdisc_class_hash_init(struct Qdisc_class_hash *);
  282. extern void qdisc_class_hash_insert(struct Qdisc_class_hash *, struct Qdisc_class_common *);
  283. extern void qdisc_class_hash_remove(struct Qdisc_class_hash *, struct Qdisc_class_common *);
  284. extern void qdisc_class_hash_grow(struct Qdisc *, struct Qdisc_class_hash *);
  285. extern void qdisc_class_hash_destroy(struct Qdisc_class_hash *);
  286. extern void dev_init_scheduler(struct net_device *dev);
  287. extern void dev_shutdown(struct net_device *dev);
  288. extern void dev_activate(struct net_device *dev);
  289. extern void dev_deactivate(struct net_device *dev);
  290. extern void dev_deactivate_many(struct list_head *head);
  291. extern struct Qdisc *dev_graft_qdisc(struct netdev_queue *dev_queue,
  292. struct Qdisc *qdisc);
  293. extern void qdisc_reset(struct Qdisc *qdisc);
  294. extern void qdisc_destroy(struct Qdisc *qdisc);
  295. extern void qdisc_tree_decrease_qlen(struct Qdisc *qdisc, unsigned int n);
  296. extern struct Qdisc *qdisc_alloc(struct netdev_queue *dev_queue,
  297. struct Qdisc_ops *ops);
  298. extern struct Qdisc *qdisc_create_dflt(struct netdev_queue *dev_queue,
  299. struct Qdisc_ops *ops, u32 parentid);
  300. extern void __qdisc_calculate_pkt_len(struct sk_buff *skb,
  301. const struct qdisc_size_table *stab);
  302. extern void tcf_destroy(struct tcf_proto *tp);
  303. extern void tcf_destroy_chain(struct tcf_proto **fl);
  304. /* Reset all TX qdiscs greater then index of a device. */
  305. static inline void qdisc_reset_all_tx_gt(struct net_device *dev, unsigned int i)
  306. {
  307. struct Qdisc *qdisc;
  308. for (; i < dev->num_tx_queues; i++) {
  309. qdisc = netdev_get_tx_queue(dev, i)->qdisc;
  310. if (qdisc) {
  311. spin_lock_bh(qdisc_lock(qdisc));
  312. qdisc_reset(qdisc);
  313. spin_unlock_bh(qdisc_lock(qdisc));
  314. }
  315. }
  316. }
  317. static inline void qdisc_reset_all_tx(struct net_device *dev)
  318. {
  319. qdisc_reset_all_tx_gt(dev, 0);
  320. }
  321. /* Are all TX queues of the device empty? */
  322. static inline bool qdisc_all_tx_empty(const struct net_device *dev)
  323. {
  324. unsigned int i;
  325. for (i = 0; i < dev->num_tx_queues; i++) {
  326. struct netdev_queue *txq = netdev_get_tx_queue(dev, i);
  327. const struct Qdisc *q = txq->qdisc;
  328. if (q->q.qlen)
  329. return false;
  330. }
  331. return true;
  332. }
  333. /* Are any of the TX qdiscs changing? */
  334. static inline bool qdisc_tx_changing(struct net_device *dev)
  335. {
  336. unsigned int i;
  337. for (i = 0; i < dev->num_tx_queues; i++) {
  338. struct netdev_queue *txq = netdev_get_tx_queue(dev, i);
  339. if (txq->qdisc != txq->qdisc_sleeping)
  340. return true;
  341. }
  342. return false;
  343. }
  344. /* Is the device using the noop qdisc on all queues? */
  345. static inline bool qdisc_tx_is_noop(const struct net_device *dev)
  346. {
  347. unsigned int i;
  348. for (i = 0; i < dev->num_tx_queues; i++) {
  349. struct netdev_queue *txq = netdev_get_tx_queue(dev, i);
  350. if (txq->qdisc != &noop_qdisc)
  351. return false;
  352. }
  353. return true;
  354. }
  355. static inline unsigned int qdisc_pkt_len(const struct sk_buff *skb)
  356. {
  357. return qdisc_skb_cb(skb)->pkt_len;
  358. }
  359. /* additional qdisc xmit flags (NET_XMIT_MASK in linux/netdevice.h) */
  360. enum net_xmit_qdisc_t {
  361. __NET_XMIT_STOLEN = 0x00010000,
  362. __NET_XMIT_BYPASS = 0x00020000,
  363. };
  364. #ifdef CONFIG_NET_CLS_ACT
  365. #define net_xmit_drop_count(e) ((e) & __NET_XMIT_STOLEN ? 0 : 1)
  366. #else
  367. #define net_xmit_drop_count(e) (1)
  368. #endif
  369. static inline void qdisc_calculate_pkt_len(struct sk_buff *skb,
  370. const struct Qdisc *sch)
  371. {
  372. #ifdef CONFIG_NET_SCHED
  373. struct qdisc_size_table *stab = rcu_dereference_bh(sch->stab);
  374. if (stab)
  375. __qdisc_calculate_pkt_len(skb, stab);
  376. #endif
  377. }
  378. static inline int qdisc_enqueue(struct sk_buff *skb, struct Qdisc *sch)
  379. {
  380. qdisc_calculate_pkt_len(skb, sch);
  381. return sch->enqueue(skb, sch);
  382. }
  383. static inline int qdisc_enqueue_root(struct sk_buff *skb, struct Qdisc *sch)
  384. {
  385. qdisc_skb_cb(skb)->pkt_len = skb->len;
  386. return qdisc_enqueue(skb, sch) & NET_XMIT_MASK;
  387. }
  388. static inline void bstats_update(struct gnet_stats_basic_packed *bstats,
  389. const struct sk_buff *skb)
  390. {
  391. bstats->bytes += qdisc_pkt_len(skb);
  392. bstats->packets += skb_is_gso(skb) ? skb_shinfo(skb)->gso_segs : 1;
  393. }
  394. static inline void qdisc_bstats_update(struct Qdisc *sch,
  395. const struct sk_buff *skb)
  396. {
  397. bstats_update(&sch->bstats, skb);
  398. }
  399. static inline int __qdisc_enqueue_tail(struct sk_buff *skb, struct Qdisc *sch,
  400. struct sk_buff_head *list)
  401. {
  402. __skb_queue_tail(list, skb);
  403. sch->qstats.backlog += qdisc_pkt_len(skb);
  404. return NET_XMIT_SUCCESS;
  405. }
  406. static inline int qdisc_enqueue_tail(struct sk_buff *skb, struct Qdisc *sch)
  407. {
  408. return __qdisc_enqueue_tail(skb, sch, &sch->q);
  409. }
  410. static inline struct sk_buff *__qdisc_dequeue_head(struct Qdisc *sch,
  411. struct sk_buff_head *list)
  412. {
  413. struct sk_buff *skb = __skb_dequeue(list);
  414. if (likely(skb != NULL)) {
  415. sch->qstats.backlog -= qdisc_pkt_len(skb);
  416. qdisc_bstats_update(sch, skb);
  417. }
  418. return skb;
  419. }
  420. static inline struct sk_buff *qdisc_dequeue_head(struct Qdisc *sch)
  421. {
  422. return __qdisc_dequeue_head(sch, &sch->q);
  423. }
  424. static inline unsigned int __qdisc_queue_drop_head(struct Qdisc *sch,
  425. struct sk_buff_head *list)
  426. {
  427. struct sk_buff *skb = __skb_dequeue(list);
  428. if (likely(skb != NULL)) {
  429. unsigned int len = qdisc_pkt_len(skb);
  430. sch->qstats.backlog -= len;
  431. kfree_skb(skb);
  432. return len;
  433. }
  434. return 0;
  435. }
  436. static inline unsigned int qdisc_queue_drop_head(struct Qdisc *sch)
  437. {
  438. return __qdisc_queue_drop_head(sch, &sch->q);
  439. }
  440. static inline struct sk_buff *__qdisc_dequeue_tail(struct Qdisc *sch,
  441. struct sk_buff_head *list)
  442. {
  443. struct sk_buff *skb = __skb_dequeue_tail(list);
  444. if (likely(skb != NULL))
  445. sch->qstats.backlog -= qdisc_pkt_len(skb);
  446. return skb;
  447. }
  448. static inline struct sk_buff *qdisc_dequeue_tail(struct Qdisc *sch)
  449. {
  450. return __qdisc_dequeue_tail(sch, &sch->q);
  451. }
  452. static inline struct sk_buff *qdisc_peek_head(struct Qdisc *sch)
  453. {
  454. return skb_peek(&sch->q);
  455. }
  456. /* generic pseudo peek method for non-work-conserving qdisc */
  457. static inline struct sk_buff *qdisc_peek_dequeued(struct Qdisc *sch)
  458. {
  459. /* we can reuse ->gso_skb because peek isn't called for root qdiscs */
  460. if (!sch->gso_skb) {
  461. sch->gso_skb = sch->dequeue(sch);
  462. if (sch->gso_skb)
  463. /* it's still part of the queue */
  464. sch->q.qlen++;
  465. }
  466. return sch->gso_skb;
  467. }
  468. /* use instead of qdisc->dequeue() for all qdiscs queried with ->peek() */
  469. static inline struct sk_buff *qdisc_dequeue_peeked(struct Qdisc *sch)
  470. {
  471. struct sk_buff *skb = sch->gso_skb;
  472. if (skb) {
  473. sch->gso_skb = NULL;
  474. sch->q.qlen--;
  475. } else {
  476. skb = sch->dequeue(sch);
  477. }
  478. return skb;
  479. }
  480. static inline void __qdisc_reset_queue(struct Qdisc *sch,
  481. struct sk_buff_head *list)
  482. {
  483. /*
  484. * We do not know the backlog in bytes of this list, it
  485. * is up to the caller to correct it
  486. */
  487. __skb_queue_purge(list);
  488. }
  489. static inline void qdisc_reset_queue(struct Qdisc *sch)
  490. {
  491. __qdisc_reset_queue(sch, &sch->q);
  492. sch->qstats.backlog = 0;
  493. }
  494. static inline unsigned int __qdisc_queue_drop(struct Qdisc *sch,
  495. struct sk_buff_head *list)
  496. {
  497. struct sk_buff *skb = __qdisc_dequeue_tail(sch, list);
  498. if (likely(skb != NULL)) {
  499. unsigned int len = qdisc_pkt_len(skb);
  500. kfree_skb(skb);
  501. return len;
  502. }
  503. return 0;
  504. }
  505. static inline unsigned int qdisc_queue_drop(struct Qdisc *sch)
  506. {
  507. return __qdisc_queue_drop(sch, &sch->q);
  508. }
  509. static inline int qdisc_drop(struct sk_buff *skb, struct Qdisc *sch)
  510. {
  511. kfree_skb(skb);
  512. sch->qstats.drops++;
  513. return NET_XMIT_DROP;
  514. }
  515. static inline int qdisc_reshape_fail(struct sk_buff *skb, struct Qdisc *sch)
  516. {
  517. sch->qstats.drops++;
  518. #ifdef CONFIG_NET_CLS_ACT
  519. if (sch->reshape_fail == NULL || sch->reshape_fail(skb, sch))
  520. goto drop;
  521. return NET_XMIT_SUCCESS;
  522. drop:
  523. #endif
  524. kfree_skb(skb);
  525. return NET_XMIT_DROP;
  526. }
  527. /* Length to Time (L2T) lookup in a qdisc_rate_table, to determine how
  528. long it will take to send a packet given its size.
  529. */
  530. static inline u32 qdisc_l2t(struct qdisc_rate_table* rtab, unsigned int pktlen)
  531. {
  532. int slot = pktlen + rtab->rate.cell_align + rtab->rate.overhead;
  533. if (slot < 0)
  534. slot = 0;
  535. slot >>= rtab->rate.cell_log;
  536. if (slot > 255)
  537. return rtab->data[255]*(slot >> 8) + rtab->data[slot & 0xFF];
  538. return rtab->data[slot];
  539. }
  540. #ifdef CONFIG_NET_CLS_ACT
  541. static inline struct sk_buff *skb_act_clone(struct sk_buff *skb, gfp_t gfp_mask,
  542. int action)
  543. {
  544. struct sk_buff *n;
  545. n = skb_clone(skb, gfp_mask);
  546. if (n) {
  547. n->tc_verd = SET_TC_VERD(n->tc_verd, 0);
  548. n->tc_verd = CLR_TC_OK2MUNGE(n->tc_verd);
  549. n->tc_verd = CLR_TC_MUNGED(n->tc_verd);
  550. }
  551. return n;
  552. }
  553. #endif
  554. #endif