act_api.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. #ifndef __NET_ACT_API_H
  2. #define __NET_ACT_API_H
  3. /*
  4. * Public police action API for classifiers/qdiscs
  5. */
  6. #include <net/sch_generic.h>
  7. #include <net/pkt_sched.h>
  8. struct tcf_common {
  9. struct tcf_common *tcfc_next;
  10. u32 tcfc_index;
  11. int tcfc_refcnt;
  12. int tcfc_bindcnt;
  13. u32 tcfc_capab;
  14. int tcfc_action;
  15. struct tcf_t tcfc_tm;
  16. struct gnet_stats_basic_packed tcfc_bstats;
  17. struct gnet_stats_queue tcfc_qstats;
  18. struct gnet_stats_rate_est tcfc_rate_est;
  19. spinlock_t tcfc_lock;
  20. struct rcu_head tcfc_rcu;
  21. };
  22. #define tcf_next common.tcfc_next
  23. #define tcf_index common.tcfc_index
  24. #define tcf_refcnt common.tcfc_refcnt
  25. #define tcf_bindcnt common.tcfc_bindcnt
  26. #define tcf_capab common.tcfc_capab
  27. #define tcf_action common.tcfc_action
  28. #define tcf_tm common.tcfc_tm
  29. #define tcf_bstats common.tcfc_bstats
  30. #define tcf_qstats common.tcfc_qstats
  31. #define tcf_rate_est common.tcfc_rate_est
  32. #define tcf_lock common.tcfc_lock
  33. #define tcf_rcu common.tcfc_rcu
  34. struct tcf_police {
  35. struct tcf_common common;
  36. int tcfp_result;
  37. u32 tcfp_ewma_rate;
  38. u32 tcfp_burst;
  39. u32 tcfp_mtu;
  40. u32 tcfp_toks;
  41. u32 tcfp_ptoks;
  42. psched_time_t tcfp_t_c;
  43. struct qdisc_rate_table *tcfp_R_tab;
  44. struct qdisc_rate_table *tcfp_P_tab;
  45. };
  46. #define to_police(pc) \
  47. container_of(pc, struct tcf_police, common)
  48. struct tcf_hashinfo {
  49. struct tcf_common **htab;
  50. unsigned int hmask;
  51. rwlock_t *lock;
  52. };
  53. static inline unsigned int tcf_hash(u32 index, unsigned int hmask)
  54. {
  55. return index & hmask;
  56. }
  57. #ifdef CONFIG_NET_CLS_ACT
  58. #define ACT_P_CREATED 1
  59. #define ACT_P_DELETED 1
  60. struct tcf_act_hdr {
  61. struct tcf_common common;
  62. };
  63. struct tc_action {
  64. void *priv;
  65. struct tc_action_ops *ops;
  66. __u32 type; /* for backward compat(TCA_OLD_COMPAT) */
  67. __u32 order;
  68. struct tc_action *next;
  69. };
  70. #define TCA_CAP_NONE 0
  71. struct tc_action_ops {
  72. struct tc_action_ops *next;
  73. struct tcf_hashinfo *hinfo;
  74. char kind[IFNAMSIZ];
  75. __u32 type; /* TBD to match kind */
  76. __u32 capab; /* capabilities includes 4 bit version */
  77. struct module *owner;
  78. int (*act)(struct sk_buff *, struct tc_action *, struct tcf_result *);
  79. int (*get_stats)(struct sk_buff *, struct tc_action *);
  80. int (*dump)(struct sk_buff *, struct tc_action *, int, int);
  81. int (*cleanup)(struct tc_action *, int bind);
  82. int (*lookup)(struct tc_action *, u32);
  83. int (*init)(struct nlattr *, struct nlattr *, struct tc_action *, int , int);
  84. int (*walk)(struct sk_buff *, struct netlink_callback *, int, struct tc_action *);
  85. };
  86. extern struct tcf_common *tcf_hash_lookup(u32 index,
  87. struct tcf_hashinfo *hinfo);
  88. extern void tcf_hash_destroy(struct tcf_common *p, struct tcf_hashinfo *hinfo);
  89. extern int tcf_hash_release(struct tcf_common *p, int bind,
  90. struct tcf_hashinfo *hinfo);
  91. extern int tcf_generic_walker(struct sk_buff *skb, struct netlink_callback *cb,
  92. int type, struct tc_action *a);
  93. extern u32 tcf_hash_new_index(u32 *idx_gen, struct tcf_hashinfo *hinfo);
  94. extern int tcf_hash_search(struct tc_action *a, u32 index);
  95. extern struct tcf_common *tcf_hash_check(u32 index, struct tc_action *a,
  96. int bind, struct tcf_hashinfo *hinfo);
  97. extern struct tcf_common *tcf_hash_create(u32 index, struct nlattr *est,
  98. struct tc_action *a, int size,
  99. int bind, u32 *idx_gen,
  100. struct tcf_hashinfo *hinfo);
  101. extern void tcf_hash_insert(struct tcf_common *p, struct tcf_hashinfo *hinfo);
  102. extern int tcf_register_action(struct tc_action_ops *a);
  103. extern int tcf_unregister_action(struct tc_action_ops *a);
  104. extern void tcf_action_destroy(struct tc_action *a, int bind);
  105. extern int tcf_action_exec(struct sk_buff *skb, struct tc_action *a, struct tcf_result *res);
  106. extern struct tc_action *tcf_action_init(struct nlattr *nla, struct nlattr *est, char *n, int ovr, int bind);
  107. extern struct tc_action *tcf_action_init_1(struct nlattr *nla, struct nlattr *est, char *n, int ovr, int bind);
  108. extern int tcf_action_dump(struct sk_buff *skb, struct tc_action *a, int, int);
  109. extern int tcf_action_dump_old(struct sk_buff *skb, struct tc_action *a, int, int);
  110. extern int tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int, int);
  111. extern int tcf_action_copy_stats (struct sk_buff *,struct tc_action *, int);
  112. #endif /* CONFIG_NET_CLS_ACT */
  113. #endif