tc_pedit.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __NET_TC_PED_H
  3. #define __NET_TC_PED_H
  4. #include <net/act_api.h>
  5. #include <linux/tc_act/tc_pedit.h>
  6. struct tcf_pedit_key_ex {
  7. enum pedit_header_type htype;
  8. enum pedit_cmd cmd;
  9. };
  10. struct tcf_pedit {
  11. struct tc_action common;
  12. unsigned char tcfp_nkeys;
  13. unsigned char tcfp_flags;
  14. struct tc_pedit_key *tcfp_keys;
  15. struct tcf_pedit_key_ex *tcfp_keys_ex;
  16. };
  17. #define to_pedit(a) ((struct tcf_pedit *)a)
  18. static inline bool is_tcf_pedit(const struct tc_action *a)
  19. {
  20. #ifdef CONFIG_NET_CLS_ACT
  21. if (a->ops && a->ops->type == TCA_ACT_PEDIT)
  22. return true;
  23. #endif
  24. return false;
  25. }
  26. static inline int tcf_pedit_nkeys(const struct tc_action *a)
  27. {
  28. return to_pedit(a)->tcfp_nkeys;
  29. }
  30. static inline u32 tcf_pedit_htype(const struct tc_action *a, int index)
  31. {
  32. if (to_pedit(a)->tcfp_keys_ex)
  33. return to_pedit(a)->tcfp_keys_ex[index].htype;
  34. return TCA_PEDIT_KEY_EX_HDR_TYPE_NETWORK;
  35. }
  36. static inline u32 tcf_pedit_cmd(const struct tc_action *a, int index)
  37. {
  38. if (to_pedit(a)->tcfp_keys_ex)
  39. return to_pedit(a)->tcfp_keys_ex[index].cmd;
  40. return __PEDIT_CMD_MAX;
  41. }
  42. static inline u32 tcf_pedit_mask(const struct tc_action *a, int index)
  43. {
  44. return to_pedit(a)->tcfp_keys[index].mask;
  45. }
  46. static inline u32 tcf_pedit_val(const struct tc_action *a, int index)
  47. {
  48. return to_pedit(a)->tcfp_keys[index].val;
  49. }
  50. static inline u32 tcf_pedit_offset(const struct tc_action *a, int index)
  51. {
  52. return to_pedit(a)->tcfp_keys[index].off;
  53. }
  54. #endif /* __NET_TC_PED_H */