tc_sample.h 918 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __NET_TC_SAMPLE_H
  3. #define __NET_TC_SAMPLE_H
  4. #include <net/act_api.h>
  5. #include <linux/tc_act/tc_sample.h>
  6. #include <net/psample.h>
  7. struct tcf_sample {
  8. struct tc_action common;
  9. u32 rate;
  10. bool truncate;
  11. u32 trunc_size;
  12. struct psample_group __rcu *psample_group;
  13. u32 psample_group_num;
  14. struct list_head tcfm_list;
  15. };
  16. #define to_sample(a) ((struct tcf_sample *)a)
  17. static inline bool is_tcf_sample(const struct tc_action *a)
  18. {
  19. #ifdef CONFIG_NET_CLS_ACT
  20. return a->ops && a->ops->id == TCA_ID_SAMPLE;
  21. #else
  22. return false;
  23. #endif
  24. }
  25. static inline __u32 tcf_sample_rate(const struct tc_action *a)
  26. {
  27. return to_sample(a)->rate;
  28. }
  29. static inline bool tcf_sample_truncate(const struct tc_action *a)
  30. {
  31. return to_sample(a)->truncate;
  32. }
  33. static inline int tcf_sample_trunc_size(const struct tc_action *a)
  34. {
  35. return to_sample(a)->trunc_size;
  36. }
  37. #endif /* __NET_TC_SAMPLE_H */