gen_stats.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __NET_GEN_STATS_H
  3. #define __NET_GEN_STATS_H
  4. #include <linux/gen_stats.h>
  5. #include <linux/socket.h>
  6. #include <linux/rtnetlink.h>
  7. #include <linux/pkt_sched.h>
  8. struct gnet_stats_basic_cpu {
  9. struct gnet_stats_basic_packed bstats;
  10. struct u64_stats_sync syncp;
  11. };
  12. struct net_rate_estimator;
  13. struct gnet_dump {
  14. spinlock_t * lock;
  15. struct sk_buff * skb;
  16. struct nlattr * tail;
  17. /* Backward compatibility */
  18. int compat_tc_stats;
  19. int compat_xstats;
  20. int padattr;
  21. void * xstats;
  22. int xstats_len;
  23. struct tc_stats tc_stats;
  24. };
  25. int gnet_stats_start_copy(struct sk_buff *skb, int type, spinlock_t *lock,
  26. struct gnet_dump *d, int padattr);
  27. int gnet_stats_start_copy_compat(struct sk_buff *skb, int type,
  28. int tc_stats_type, int xstats_type,
  29. spinlock_t *lock, struct gnet_dump *d,
  30. int padattr);
  31. int gnet_stats_copy_basic(const seqcount_t *running,
  32. struct gnet_dump *d,
  33. struct gnet_stats_basic_cpu __percpu *cpu,
  34. struct gnet_stats_basic_packed *b);
  35. void __gnet_stats_copy_basic(const seqcount_t *running,
  36. struct gnet_stats_basic_packed *bstats,
  37. struct gnet_stats_basic_cpu __percpu *cpu,
  38. struct gnet_stats_basic_packed *b);
  39. int gnet_stats_copy_rate_est(struct gnet_dump *d,
  40. struct net_rate_estimator __rcu **ptr);
  41. int gnet_stats_copy_queue(struct gnet_dump *d,
  42. struct gnet_stats_queue __percpu *cpu_q,
  43. struct gnet_stats_queue *q, __u32 qlen);
  44. int gnet_stats_copy_app(struct gnet_dump *d, void *st, int len);
  45. int gnet_stats_finish_copy(struct gnet_dump *d);
  46. int gen_new_estimator(struct gnet_stats_basic_packed *bstats,
  47. struct gnet_stats_basic_cpu __percpu *cpu_bstats,
  48. struct net_rate_estimator __rcu **rate_est,
  49. spinlock_t *stats_lock,
  50. seqcount_t *running, struct nlattr *opt);
  51. void gen_kill_estimator(struct net_rate_estimator __rcu **ptr);
  52. int gen_replace_estimator(struct gnet_stats_basic_packed *bstats,
  53. struct gnet_stats_basic_cpu __percpu *cpu_bstats,
  54. struct net_rate_estimator __rcu **ptr,
  55. spinlock_t *stats_lock,
  56. seqcount_t *running, struct nlattr *opt);
  57. bool gen_estimator_active(struct net_rate_estimator __rcu **ptr);
  58. bool gen_estimator_read(struct net_rate_estimator __rcu **ptr,
  59. struct gnet_stats_rate_est64 *sample);
  60. #endif