tc_sample.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. struct rcu_head rcu;
  16. };
  17. #define to_sample(a) ((struct tcf_sample *)a)
  18. static inline bool is_tcf_sample(const struct tc_action *a)
  19. {
  20. #ifdef CONFIG_NET_CLS_ACT
  21. return a->ops && a->ops->type == TCA_ACT_SAMPLE;
  22. #else
  23. return false;
  24. #endif
  25. }
  26. static inline __u32 tcf_sample_rate(const struct tc_action *a)
  27. {
  28. return to_sample(a)->rate;
  29. }
  30. static inline bool tcf_sample_truncate(const struct tc_action *a)
  31. {
  32. return to_sample(a)->truncate;
  33. }
  34. static inline int tcf_sample_trunc_size(const struct tc_action *a)
  35. {
  36. return to_sample(a)->trunc_size;
  37. }
  38. static inline struct psample_group *
  39. tcf_sample_psample_group(const struct tc_action *a)
  40. {
  41. return rcu_dereference(to_sample(a)->psample_group);
  42. }
  43. #endif /* __NET_TC_SAMPLE_H */