tc_gact.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __NET_TC_GACT_H
  3. #define __NET_TC_GACT_H
  4. #include <net/act_api.h>
  5. #include <linux/tc_act/tc_gact.h>
  6. struct tcf_gact {
  7. struct tc_action common;
  8. #ifdef CONFIG_GACT_PROB
  9. u16 tcfg_ptype;
  10. u16 tcfg_pval;
  11. int tcfg_paction;
  12. atomic_t packets;
  13. #endif
  14. };
  15. #define to_gact(a) ((struct tcf_gact *)a)
  16. static inline bool __is_tcf_gact_act(const struct tc_action *a, int act,
  17. bool is_ext)
  18. {
  19. #ifdef CONFIG_NET_CLS_ACT
  20. struct tcf_gact *gact;
  21. if (a->ops && a->ops->type != TCA_ACT_GACT)
  22. return false;
  23. gact = to_gact(a);
  24. if ((!is_ext && gact->tcf_action == act) ||
  25. (is_ext && TC_ACT_EXT_CMP(gact->tcf_action, act)))
  26. return true;
  27. #endif
  28. return false;
  29. }
  30. static inline bool is_tcf_gact_ok(const struct tc_action *a)
  31. {
  32. return __is_tcf_gact_act(a, TC_ACT_OK, false);
  33. }
  34. static inline bool is_tcf_gact_shot(const struct tc_action *a)
  35. {
  36. return __is_tcf_gact_act(a, TC_ACT_SHOT, false);
  37. }
  38. static inline bool is_tcf_gact_trap(const struct tc_action *a)
  39. {
  40. return __is_tcf_gact_act(a, TC_ACT_TRAP, false);
  41. }
  42. static inline bool is_tcf_gact_goto_chain(const struct tc_action *a)
  43. {
  44. return __is_tcf_gact_act(a, TC_ACT_GOTO_CHAIN, true);
  45. }
  46. static inline u32 tcf_gact_goto_chain_index(const struct tc_action *a)
  47. {
  48. return READ_ONCE(a->tcfa_action) & TC_ACT_EXT_VAL_MASK;
  49. }
  50. #endif /* __NET_TC_GACT_H */