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:
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
15 #ifndef __included_stats_h__
16 #define __included_stats_h__
19 #include <vlib/vlib.h>
20 #include <vnet/vnet.h>
21 #include <vnet/interface.h>
23 #include <vlib/threads.h>
24 #include <vnet/fib/fib_table.h>
25 #include <vlib/unix/unix.h>
26 #include <vlibmemory/api.h>
27 #include <vlibmemory/unix_shared_memory_queue.h>
28 #include <vlibapi/api_helper_macros.h>
33 volatile u32 release_hint;
37 } data_structure_lock_t;
40 * @brief stats request registration indexes
43 /* from .../vnet/vnet/ip/lookup.c. Yuck */
44 typedef CLIB_PACKED (struct
46 ip4_address_t address;
47 u32 address_length: 6;
51 /* see interface.api */
64 } vnet_simple_counter_t;
69 u64 rx_packets; /**< packet counter */
70 u64 rx_bytes; /**< byte counter */
71 u64 tx_packets; /**< packet counter */
72 u64 tx_bytes; /**< byte counter */
73 } vnet_combined_counter_t;
77 ip6_address_t address;
85 ip4_route_t *ip4routes;
86 ip6_route_t *ip6routes;
99 } client_registration_reply_t;
103 #define stats_reg(n) IDX_##n,
104 #include <vpp/stats/stats.reg>
111 //Standard client information
113 vpe_client_registration_t *clients;
116 } vpe_client_stats_registration_t;
122 pthread_t thread_self;
123 pthread_t thread_handle;
125 u32 stats_poll_interval_in_seconds;
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)
133 * The values in the vector refer to pools.
135 * The pool is of type vpe_client_stats_registration_t
137 * This typedef consists of:
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.
144 * stats_registrations[IDX_INTERFACE_SIMPLE_COUNTERS] refers to a pool
145 * containing elements:
147 * u32 item = sw_if_index1
148 * clients = ["clienta","clientb"]
150 * When clients == NULL the pool element is freed. When the pool is empty
153 * 0 == pool_elts(stats_registrations[IDX_INTERFACE_SIMPLE_COUNTERS]
155 * then there is no need to process INTERFACE_SIMPLE_COUNTERS
157 * Note that u32 item = ~0 is the simple case for ALL interfaces or fibs.
161 uword **stats_registration_hash;
162 vpe_client_stats_registration_t **stats_registrations;
164 /* control-plane data structure lock */
165 data_structure_lock_t *data_structure_lock;
167 /* bail out of FIB walk if set */
168 clib_longjmp_t jmp_buf;
170 /* Vectors for Distribution funcs: do_ip4_fibs and do_ip6_fibs. */
171 do_ip46_fibs_t do_ip46_fibs;
174 Working vector vars so as to not thrash memory allocator.
175 Has effect of making "static"
177 vpe_client_stats_registration_t **regs_tmp;
178 vpe_client_registration_t **clients_tmp;
181 vlib_main_t *vlib_main;
182 vnet_main_t *vnet_main;
183 vnet_interface_main_t *interface_main;
184 api_main_t *api_main;
187 extern stats_main_t stats_main;
189 void dslock (stats_main_t * sm, int release_hint, int tag);
190 void dsunlock (stats_main_t * sm);
192 #endif /* __included_stats_h__ */
195 * fd.io coding-style-patch-verification: ON
198 * eval: (c-set-style "gnu")