FD.io VPP  v18.04-17-g3a0d853
Vector Packet Processing
stats.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifndef __included_stats_h__
16 #define __included_stats_h__
17 
18 #include <time.h>
19 #include <vlib/vlib.h>
20 #include <vnet/vnet.h>
21 #include <vnet/interface.h>
22 #include <pthread.h>
23 #include <vlib/threads.h>
24 #include <vnet/fib/fib_table.h>
25 #include <vnet/mfib/mfib_table.h>
26 #include <vlib/unix/unix.h>
27 #include <vlibmemory/api.h>
29 #include <svm/queue.h>
30 
31 typedef struct
32 {
33  volatile u32 lock;
34  volatile u32 release_hint;
37  int tag;
39 
40 /**
41  * @brief stats request registration indexes
42  *
43  */
44 /* from .../vnet/vnet/ip/lookup.c. Yuck */
45 /* *INDENT-OFF* */
46 typedef CLIB_PACKED (struct
47 {
48  ip4_address_t address;
49  u32 address_length: 6;
50  u32 index: 26;
51 }) ip4_route_t;
52 /* *INDENT-ON* */
53 
54 typedef struct
55 {
59 } ip6_route_t;
60 
61 typedef struct
62 {
63  ip4_route_t *ip4routes;
71 
72 typedef struct
73 {
80 
81 typedef enum
82 {
83 #define stats_reg(n) IDX_##n,
84 #include <vpp/stats/stats.reg>
85 #undef stats_reg
88 
89 typedef struct
90 {
91  //Standard client information
95 
97 
98 
99 typedef struct
100 {
101  void *mheap;
102  pthread_t thread_self;
103  pthread_t thread_handle;
104 
107 
108  /*
109  * stats_registrations is a vector, indexed by
110  * IDX_xxxx_COUNTER generated for each streaming
111  * stat a client can register for. (see stats.reg)
112  *
113  * The values in the vector refer to pools.
114  *
115  * The pool is of type vpe_client_stats_registration_t
116  *
117  * This typedef consists of:
118  *
119  * u32 item: This is the instance of the IDX_xxxx_COUNTER a
120  * client is interested in.
121  * vpe_client_registration_t *clients: The list of clients interested.
122  *
123  * e.g.
124  * stats_registrations[IDX_INTERFACE_SIMPLE_COUNTERS] refers to a pool
125  * containing elements:
126  *
127  * u32 item = sw_if_index1
128  * clients = ["clienta","clientb"]
129  *
130  * When clients == NULL the pool element is freed. When the pool is empty
131  *
132  * ie
133  * 0 == pool_elts(stats_registrations[IDX_INTERFACE_SIMPLE_COUNTERS]
134  *
135  * then there is no need to process INTERFACE_SIMPLE_COUNTERS
136  *
137  * Note that u32 item = ~0 is the simple case for ALL interfaces or fibs.
138  *
139  */
140 
143 
144  /* control-plane data structure lock */
146 
147  /* bail out of FIB walk if set */
149 
150  /* Vectors for Distribution funcs: do_ip4_fibs and do_ip6_fibs. */
152 
153  /*
154  Working vector vars so as to not thrash memory allocator.
155  Has effect of making "static"
156  */
159 
160  /* convenience */
165 } stats_main_t;
166 
167 extern stats_main_t stats_main;
168 
169 #endif /* __included_stats_h__ */
170 
171 /*
172  * fd.io coding-style-patch-verification: ON
173  *
174  * Local Variables:
175  * eval: (c-set-style "gnu")
176  * End:
177  */
stats_reg_index_t
Definition: stats.h:81
vpe_client_registration_t ** clients_tmp
Definition: stats.h:158
do_ip46_fibs_t do_ip46_fibs
Definition: stats.h:151
pthread_t thread_handle
Definition: stats.h:103
vpe_client_registration_t * clients
Definition: stats.h:93
stats_main_t stats_main
Definition: stats.c:25
hash_pair_t ** pvec
Definition: stats.h:68
mfib_table_t ** mfibs
Definition: stats.h:67
u32 enable_poller
Definition: stats.h:106
vlib_main_t * vlib_main
Definition: stats.h:161
typedef CLIB_PACKED(struct{ip4_address_t address;u32 address_length:6;u32 index:26;}) ip4_route_t
stats request registration indexes
volatile u32 release_hint
Definition: stats.h:34
vpe_client_stats_registration_t ** regs_tmp
Definition: stats.h:157
int i32
Definition: types.h:81
pthread_t thread_self
Definition: stats.h:102
volatile u32 lock
Definition: stats.h:33
ip6_route_t * ip6routes
Definition: stats.h:64
ip4_route_t * ip4routes
Definition: stats.h:63
u32 index
Definition: stats.h:58
void * mheap
Definition: stats.h:101
API main structure, used by both vpp and binary API clients.
Definition: api_common.h:199
uword * results
Definition: stats.h:69
clib_longjmp_t jmp_buf
Definition: stats.h:148
api_main_t * api_main
Definition: stats.h:164
Aggregrate type for a prefix.
Definition: mfib_types.h:24
unsigned int u32
Definition: types.h:88
uword ** stats_registration_hash
Definition: stats.h:141
vpe_client_stats_registration_t ** stats_registrations
Definition: stats.h:142
fib_table_t ** fibs
Definition: stats.h:66
u32 stats_poll_interval_in_seconds
Definition: stats.h:105
u64 uword
Definition: types.h:112
data_structure_lock_t * data_structure_lock
Definition: stats.h:145
unsigned short u16
Definition: types.h:57
vnet_interface_main_t * interface_main
Definition: stats.h:163
u32 address_length
Definition: stats.h:57
A protocol Independent IP multicast FIB table.
Definition: mfib_table.h:35
vnet_main_t * vnet_main
Definition: stats.h:162
mfib_prefix_t * mroutes
Definition: stats.h:65
A protocol Independent FIB table.
Definition: fib_table.h:69
ip6_address_t address
Definition: stats.h:56