FD.io VPP  v18.07.1-19-g511ce25
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 #include <svm/ssvm.h>
31 
32 /* Default socket to exchange segment fd */
33 #define STAT_SEGMENT_SOCKET_FILE "/run/vpp/stats.sock"
34 
35 typedef struct
36 {
37  volatile u32 lock;
38  volatile u32 release_hint;
41  int tag;
43 
44 /**
45  * @brief stats request registration indexes
46  *
47  */
48 /* from .../vnet/vnet/ip/lookup.c. Yuck */
49 /* *INDENT-OFF* */
50 typedef CLIB_PACKED (struct
51 {
54  u32 index: 26;
55 }) ip4_route_t;
56 /* *INDENT-ON* */
57 
58 typedef struct
59 {
63 } ip6_route_t;
64 
65 typedef struct
66 {
67  ip4_route_t *ip4routes;
75 
76 typedef struct
77 {
84 
85 typedef enum
86 {
87 #define stats_reg(n) IDX_##n,
88 #include <vpp/stats/stats.reg>
89 #undef stats_reg
92 
93 typedef struct
94 {
95  //Standard client information
99 
101 
102 
103 typedef struct
104 {
105  void *mheap;
106  pthread_t thread_self;
107  pthread_t thread_handle;
108 
111 
112  /*
113  * stats_registrations is a vector, indexed by
114  * IDX_xxxx_COUNTER generated for each streaming
115  * stat a client can register for. (see stats.reg)
116  *
117  * The values in the vector refer to pools.
118  *
119  * The pool is of type vpe_client_stats_registration_t
120  *
121  * This typedef consists of:
122  *
123  * u32 item: This is the instance of the IDX_xxxx_COUNTER a
124  * client is interested in.
125  * vpe_client_registration_t *clients: The list of clients interested.
126  *
127  * e.g.
128  * stats_registrations[IDX_INTERFACE_SIMPLE_COUNTERS] refers to a pool
129  * containing elements:
130  *
131  * u32 item = sw_if_index1
132  * clients = ["clienta","clientb"]
133  *
134  * When clients == NULL the pool element is freed. When the pool is empty
135  *
136  * ie
137  * 0 == pool_elts(stats_registrations[IDX_INTERFACE_SIMPLE_COUNTERS]
138  *
139  * then there is no need to process INTERFACE_SIMPLE_COUNTERS
140  *
141  * Note that u32 item = ~0 is the simple case for ALL interfaces or fibs.
142  *
143  */
144 
147 
148  /* control-plane data structure lock */
150 
151  /* bail out of FIB walk if set */
153 
154  /* Vectors for Distribution funcs: do_ip4_fibs and do_ip6_fibs. */
156 
157  /*
158  Working vector vars so as to not thrash memory allocator.
159  Has effect of making "static"
160  */
163 
164  /* statistics segment */
172 
173  /* Pointers to scalar stats maintained by the stat thread */
179 
180  /* Pointers to vector stats maintained by the stat thread */
184 
190 
191  /* convenience */
196 } stats_main_t;
197 
198 extern stats_main_t stats_main;
199 
200 /* Default stat segment 32m */
201 #define STAT_SEGMENT_DEFAULT_SIZE (32<<20)
202 
203 #define STAT_SEGMENT_OPAQUE_LOCK 0
204 #define STAT_SEGMENT_OPAQUE_DIR 1
205 #define STAT_SEGMENT_OPAQUE_EPOCH 2
206 
207 typedef enum
208 {
216 
217 typedef struct
218 {
219  stat_directory_type_t type;
220  void *value;
222 
224 
225 #endif /* __included_stats_h__ */
226 
227 /*
228  * fd.io coding-style-patch-verification: ON
229  *
230  * Local Variables:
231  * eval: (c-set-style "gnu")
232  * End:
233  */
stats_reg_index_t
Definition: stats.h:85
vpe_client_registration_t ** clients_tmp
Definition: stats.h:162
typedef address
Definition: ip_types.api:35
Definition: stats.h:217
do_ip46_fibs_t do_ip46_fibs
Definition: stats.h:155
f64 * vectors_per_node
Definition: stats.h:185
pthread_t thread_handle
Definition: stats.h:107
f64 * vector_rate_punt
Definition: stats.h:189
vpe_client_registration_t * clients
Definition: stats.h:97
stats_main_t stats_main
Definition: stats.c:28
hash_pair_t ** pvec
Definition: stats.h:72
mfib_table_t ** mfibs
Definition: stats.h:71
unsigned long u64
Definition: types.h:89
u32 enable_poller
Definition: stats.h:110
vlib_main_t * vlib_main
Definition: stats.h:192
f64 * vector_rate_ptr
Definition: stats.h:177
clib_socket_t * socket
Definition: stats.h:168
f64 * vector_rate_drop
Definition: stats.h:188
unsigned char u8
Definition: types.h:56
typedef CLIB_PACKED(struct{ip4_address_t address;u32 address_length:6;u32 index:26;}) ip4_route_t
stats request registration indexes
double f64
Definition: types.h:142
f64 * last_runtime_stats_clear_ptr
Definition: stats.h:176
volatile u32 release_hint
Definition: stats.h:38
stat_directory_type_t
Definition: stats.h:207
vpe_client_stats_registration_t ** regs_tmp
Definition: stats.h:161
pthread_t thread_self
Definition: stats.h:106
volatile u32 lock
Definition: stats.h:37
unsigned int u32
Definition: types.h:88
ip6_route_t * ip6routes
Definition: stats.h:68
uword * counter_vector_by_name
Definition: stats.h:166
u8 address_length
Definition: ip_types.api:42
uword memory_size
Definition: stats.h:170
unsigned short u16
Definition: types.h:57
vlib_node_t *** node_dups
Definition: stats.h:183
ip4_route_t * ip4routes
Definition: stats.h:67
u32 index
Definition: stats.h:62
void * mheap
Definition: stats.h:105
API main structure, used by both vpp and binary API clients.
Definition: api_common.h:201
u8 * socket_name
Definition: stats.h:169
uword * results
Definition: stats.h:73
clib_longjmp_t jmp_buf
Definition: stats.h:152
clib_spinlock_t * stat_segment_lockp
Definition: stats.h:167
f64 * last_runtime_ptr
Definition: stats.h:175
api_main_t * api_main
Definition: stats.h:195
Aggregrate type for a prefix.
Definition: mfib_types.h:24
signed int i32
Definition: types.h:81
uword ** stats_registration_hash
Definition: stats.h:145
vpe_client_stats_registration_t ** stats_registrations
Definition: stats.h:146
fib_table_t ** fibs
Definition: stats.h:70
struct _socket_t clib_socket_t
u32 stats_poll_interval_in_seconds
Definition: stats.h:109
void * value
Definition: stats.h:220
data_structure_lock_t * data_structure_lock
Definition: stats.h:149
u64 last_input_packets
Definition: stats.h:178
vnet_interface_main_t * interface_main
Definition: stats.h:194
f64 * vector_rate_out
Definition: stats.h:187
vlib_main_t ** stat_vms
Definition: stats.h:182
u64 uword
Definition: types.h:112
u32 address_length
Definition: stats.h:61
A protocol Independent IP multicast FIB table.
Definition: mfib_table.h:35
f64 * vector_rate_in
Definition: stats.h:186
u8 serialize_nodes
Definition: stats.h:171
ssvm_private_t stat_segment
Definition: stats.h:165
vnet_main_t * vnet_main
Definition: stats.h:193
void do_stat_segment_updates(stats_main_t *sm)
Definition: stat_segment.c:476
u8 * serialized_nodes
Definition: stats.h:181
mfib_prefix_t * mroutes
Definition: stats.h:69
A protocol Independent FIB table.
Definition: fib_table.h:69
ip6_address_t address
Definition: stats.h:60
stat_directory_type_t type
Definition: stats.h:219
f64 * input_rate_ptr
Definition: stats.h:174