tc_gact.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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->id != TCA_ID_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. static inline bool is_tcf_gact_continue(const struct tc_action *a)
  51. {
  52. return __is_tcf_gact_act(a, TC_ACT_UNSPEC, false);
  53. }
  54. static inline bool is_tcf_gact_reclassify(const struct tc_action *a)
  55. {
  56. return __is_tcf_gact_act(a, TC_ACT_RECLASSIFY, false);
  57. }
  58. static inline bool is_tcf_gact_pipe(const struct tc_action *a)
  59. {
  60. return __is_tcf_gact_act(a, TC_ACT_PIPE, false);
  61. }
  62. #endif /* __NET_TC_GACT_H */