psample.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __NET_PSAMPLE_H
  3. #define __NET_PSAMPLE_H
  4. #include <uapi/linux/psample.h>
  5. #include <linux/list.h>
  6. struct psample_group {
  7. struct list_head list;
  8. struct net *net;
  9. u32 group_num;
  10. u32 refcount;
  11. u32 seq;
  12. struct rcu_head rcu;
  13. };
  14. struct psample_metadata {
  15. u32 trunc_size;
  16. int in_ifindex;
  17. int out_ifindex;
  18. u16 out_tc;
  19. u64 out_tc_occ; /* bytes */
  20. u64 latency; /* nanoseconds */
  21. u8 out_tc_valid:1,
  22. out_tc_occ_valid:1,
  23. latency_valid:1,
  24. rate_as_probability:1,
  25. unused:4;
  26. const u8 *user_cookie;
  27. u32 user_cookie_len;
  28. };
  29. struct psample_group *psample_group_get(struct net *net, u32 group_num);
  30. void psample_group_take(struct psample_group *group);
  31. void psample_group_put(struct psample_group *group);
  32. struct sk_buff;
  33. #if IS_ENABLED(CONFIG_PSAMPLE)
  34. void psample_sample_packet(struct psample_group *group,
  35. const struct sk_buff *skb, u32 sample_rate,
  36. const struct psample_metadata *md);
  37. #else
  38. static inline void psample_sample_packet(struct psample_group *group,
  39. const struct sk_buff *skb,
  40. u32 sample_rate,
  41. const struct psample_metadata *md)
  42. {
  43. }
  44. #endif
  45. #endif /* __NET_PSAMPLE_H */