tc_sample.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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->type == TCA_ACT_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. static inline struct psample_group *
  38. tcf_sample_psample_group(const struct tc_action *a)
  39. {
  40. return rcu_dereference(to_sample(a)->psample_group);
  41. }
  42. #endif /* __NET_TC_SAMPLE_H */