make test: add option for adding extra vpp config
[vpp.git] / src / vpp / stats / stats_to_be_deprecated.h
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>
28 #include <vlibapi/api_helper_macros.h>
29
30 typedef struct
31 {
32   volatile u32 lock;
33   volatile u32 release_hint;
34   u32 thread_index;
35   u32 count;
36   int tag;
37 } data_structure_lock_t;
38
39 /**
40  * @brief stats request registration indexes
41  *
42  */
43 /* from .../vnet/vnet/ip/lookup.c. Yuck */
44 /* *INDENT-OFF* */
45 typedef CLIB_PACKED (struct
46 {
47   ip4_address_t address;
48   u32 address_length: 6;
49   u32 index:         26;
50 }) ip4_route_t;
51 /* *INDENT-ON* */
52
53 typedef struct
54 {
55   ip6_address_t address;
56   u32 address_length;
57   u32 index;
58 } ip6_route_t;
59
60 typedef struct
61 {
62   ip4_route_t *ip4routes;
63   ip6_route_t *ip6routes;
64   mfib_prefix_t *mroutes;
65   fib_table_t **fibs;
66   mfib_table_t **mfibs;
67   hash_pair_t **pvec;
68   uword *results;
69 } do_ip46_fibs_t;
70
71 typedef struct
72 {
73   u16 msg_id;
74   u32 size;
75   u32 client_index;
76   u32 context;
77   i32 retval;
78 } client_registration_reply_t;
79
80 typedef enum
81 {
82 #define stats_reg(n) IDX_##n,
83 #include <vpp/stats/stats.reg>
84 #undef stats_reg
85   STATS_REG_N_IDX,
86 } stats_reg_index_t;
87
88 typedef struct
89 {
90   //Standard client information
91   uword *client_hash;
92   vpe_client_registration_t *clients;
93   u32 item;
94
95 } vpe_client_stats_registration_t;
96
97 typedef struct
98 {
99   void *mheap;
100   pthread_t thread_self;
101   pthread_t thread_handle;
102
103   u32 stats_poll_interval_in_seconds;
104   u32 enable_poller;
105
106   /*
107    * stats_registrations is a vector, indexed by
108    * IDX_xxxx_COUNTER generated for each streaming
109    * stat a client can register for. (see stats.reg)
110    *
111    * The values in the vector refer to pools.
112    *
113    * The pool is of type vpe_client_stats_registration_t
114    *
115    * This typedef consists of:
116    *
117    * u32 item: This is the instance of the IDX_xxxx_COUNTER a
118    *           client is interested in.
119    * vpe_client_registration_t *clients: The list of clients interested.
120    *
121    * e.g.
122    * stats_registrations[IDX_INTERFACE_SIMPLE_COUNTERS] refers to a pool
123    * containing elements:
124    *
125    * u32 item = sw_if_index1
126    * clients = ["clienta","clientb"]
127    *
128    * When clients == NULL the pool element is freed. When the pool is empty
129    *
130    * ie
131    * 0 == pool_elts(stats_registrations[IDX_INTERFACE_SIMPLE_COUNTERS]
132    *
133    * then there is no need to process INTERFACE_SIMPLE_COUNTERS
134    *
135    * Note that u32 item = ~0 is the simple case for ALL interfaces or fibs.
136    *
137    */
138
139   uword **stats_registration_hash;
140   vpe_client_stats_registration_t **stats_registrations;
141
142   /* control-plane data structure lock */
143   data_structure_lock_t *data_structure_lock;
144
145   /* bail out of FIB walk if set */
146   clib_longjmp_t jmp_buf;
147
148   /* Vectors for Distribution funcs: do_ip4_fibs and do_ip6_fibs. */
149   do_ip46_fibs_t do_ip46_fibs;
150
151   /*
152      Working vector vars so as to not thrash memory allocator.
153      Has effect of making "static"
154    */
155   vpe_client_stats_registration_t **regs_tmp;
156   vpe_client_registration_t **clients_tmp;
157
158   /* convenience */
159   vlib_main_t *vlib_main;
160   vnet_main_t *vnet_main;
161   vnet_interface_main_t *interface_main;
162   api_main_t *api_main;
163 } stats_main_t;
164
165 extern stats_main_t stats_main;
166
167 #endif /* __included_stats_h__ */
168
169 /*
170  * fd.io coding-style-patch-verification: ON
171  *
172  * Local Variables:
173  * eval: (c-set-style "gnu")
174  * End:
175  */