FD.io VPP  v17.10-9-gd594711
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 <vlib/unix/unix.h>
26 #include <vlibmemory/api.h>
29 
30 typedef struct
31 {
32  volatile u32 lock;
33  volatile u32 release_hint;
36  int tag;
38 
39 /**
40  * @brief stats request registration indexes
41  *
42  */
43 /* from .../vnet/vnet/ip/lookup.c. Yuck */
44 typedef CLIB_PACKED (struct
45  {
46  ip4_address_t address;
47 u32 address_length: 6;
48 u32 index: 26;
49  }) ip4_route_t;
50 
51 /* see interface.api */
52 typedef struct
53 {
65 
66 typedef struct
67 {
69  u64 rx_packets; /**< packet counter */
70  u64 rx_bytes; /**< byte counter */
71  u64 tx_packets; /**< packet counter */
72  u64 tx_bytes; /**< byte counter */
74 
75 typedef struct
76 {
80 } ip6_route_t;
81 
82 
83 typedef struct
84 {
85  ip4_route_t *ip4routes;
91 
92 typedef struct
93 {
100 
101 typedef enum
102 {
103 #define stats_reg(n) IDX_##n,
104 #include <vpp/stats/stats.reg>
105 #undef stats_reg
108 
109 typedef struct
110 {
111  //Standard client information
115 
117 
118 
119 typedef struct
120 {
121  void *mheap;
122  pthread_t thread_self;
123  pthread_t thread_handle;
124 
127 
128  /*
129  * stats_registrations is a vector, indexed by
130  * IDX_xxxx_COUNTER generated for each streaming
131  * stat a client can register for. (see stats.reg)
132  *
133  * The values in the vector refer to pools.
134  *
135  * The pool is of type vpe_client_stats_registration_t
136  *
137  * This typedef consists of:
138  *
139  * u32 item: This is the instance of the IDX_xxxx_COUNTER a
140  * client is interested in.
141  * vpe_client_registration_t *clients: The list of clients interested.
142  *
143  * e.g.
144  * stats_registrations[IDX_INTERFACE_SIMPLE_COUNTERS] refers to a pool
145  * containing elements:
146  *
147  * u32 item = sw_if_index1
148  * clients = ["clienta","clientb"]
149  *
150  * When clients == NULL the pool element is freed. When the pool is empty
151  *
152  * ie
153  * 0 == pool_elts(stats_registrations[IDX_INTERFACE_SIMPLE_COUNTERS]
154  *
155  * then there is no need to process INTERFACE_SIMPLE_COUNTERS
156  *
157  * Note that u32 item = ~0 is the simple case for ALL interfaces or fibs.
158  *
159  */
160 
163 
164  /* control-plane data structure lock */
166 
167  /* bail out of FIB walk if set */
169 
170  /* Vectors for Distribution funcs: do_ip4_fibs and do_ip6_fibs. */
172 
173  /*
174  Working vector vars so as to not thrash memory allocator.
175  Has effect of making "static"
176  */
179 
180  /* convenience */
185 } stats_main_t;
186 
188 
189 void dslock (stats_main_t * sm, int release_hint, int tag);
190 void dsunlock (stats_main_t * sm);
191 
192 #endif /* __included_stats_h__ */
193 
194 /*
195  * fd.io coding-style-patch-verification: ON
196  *
197  * Local Variables:
198  * eval: (c-set-style "gnu")
199  * End:
200  */
stats_reg_index_t
Definition: stats.h:101
vpe_client_registration_t ** clients_tmp
Definition: stats.h:178
do_ip46_fibs_t do_ip46_fibs
Definition: stats.h:171
pthread_t thread_handle
Definition: stats.h:123
vpe_client_registration_t * clients
Definition: stats.h:113
stats_main_t stats_main
Definition: stats.h:187
hash_pair_t ** pvec
Definition: stats.h:88
u32 enable_poller
Definition: stats.h:126
vlib_main_t * vlib_main
Definition: stats.h:181
u64 rx_bytes
byte counter
Definition: stats.h:70
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:33
vpe_client_stats_registration_t ** regs_tmp
Definition: stats.h:177
int i32
Definition: types.h:81
pthread_t thread_self
Definition: stats.h:122
unsigned long u64
Definition: types.h:89
volatile u32 lock
Definition: stats.h:32
ip6_route_t * ip6routes
Definition: stats.h:86
ip4_route_t * ip4routes
Definition: stats.h:85
u32 index
Definition: stats.h:79
void * mheap
Definition: stats.h:121
API main structure, used by both vpp and binary API clients.
Definition: api_common.h:182
void dsunlock(stats_main_t *sm)
Definition: stats.c:226
uword * results
Definition: stats.h:89
clib_longjmp_t jmp_buf
Definition: stats.h:168
api_main_t * api_main
Definition: stats.h:184
void dslock(stats_main_t *sm, int release_hint, int tag)
Definition: stats.c:193
u64 tx_packets
packet counter
Definition: stats.h:71
unsigned int u32
Definition: types.h:88
uword ** stats_registration_hash
Definition: stats.h:161
vpe_client_stats_registration_t ** stats_registrations
Definition: stats.h:162
fib_table_t ** fibs
Definition: stats.h:87
u32 stats_poll_interval_in_seconds
Definition: stats.h:125
u64 uword
Definition: types.h:112
data_structure_lock_t * data_structure_lock
Definition: stats.h:165
unsigned short u16
Definition: types.h:57
vnet_interface_main_t * interface_main
Definition: stats.h:183
u32 address_length
Definition: stats.h:78
u64 tx_bytes
byte counter
Definition: stats.h:72
vnet_main_t * vnet_main
Definition: stats.h:182
A protocol Independent FIB table.
Definition: fib_table.h:35
ip6_address_t address
Definition: stats.h:77
u64 rx_packets
packet counter
Definition: stats.h:69