libosmocore  0.6.3
Osmocom core library
rate_ctr.h
Go to the documentation of this file.
1 #ifndef _RATE_CTR_H
2 #define _RATE_CTR_H
3 
10 #include <stdint.h>
11 
12 #include <osmocom/core/linuxlist.h>
13 
15 #define RATE_CTR_INTV_NUM 4
16 
23 };
24 
27  uint64_t last;
28  uint64_t rate;
29 };
30 
32 struct rate_ctr {
33  uint64_t current;
36 };
37 
39 struct rate_ctr_desc {
40  const char *name;
41  const char *description;
42 };
43 
47  const char *group_name_prefix;
49  const char *group_description;
51  const unsigned int num_ctr;
53  const struct rate_ctr_desc *ctr_desc;
54 };
55 
59  struct llist_head list;
61  const struct rate_ctr_group_desc *desc;
63  unsigned int idx;
65  struct rate_ctr ctr[0];
66 };
67 
68 struct rate_ctr_group *rate_ctr_group_alloc(void *ctx,
69  const struct rate_ctr_group_desc *desc,
70  unsigned int idx);
71 
72 void rate_ctr_group_free(struct rate_ctr_group *grp);
73 
74 void rate_ctr_add(struct rate_ctr *ctr, int inc);
75 
77 static inline void rate_ctr_inc(struct rate_ctr *ctr)
78 {
79  rate_ctr_add(ctr, 1);
80 }
81 
82 int rate_ctr_init(void *tall_ctx);
83 
84 struct rate_ctr_group *rate_ctr_get_group_by_name_idx(const char *name, const unsigned int idx);
85 const struct rate_ctr *rate_ctr_get_by_name(const struct rate_ctr_group *ctrg, const char *name);
86 
88 #endif /* RATE_CTR_H */