FD.io VPP  v21.06
Vector Packet Processing
perfmon.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 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 
16 #ifndef __perfmon_perfmon_h
17 #define __perfmon_perfmon_h
18 
19 #include <linux/perf_event.h>
20 #include <vppinfra/clib.h>
21 #include <vppinfra/format.h>
22 #include <vppinfra/error.h>
23 #include <vppinfra/cpu.h>
24 #include <vlib/vlib.h>
25 
26 #define PERF_MAX_EVENTS 7 /* 3 fixed and 4 programmable */
27 
28 typedef enum
29 {
35 
36 typedef enum
37 {
42 
43 typedef struct
44 {
47  union
48  {
51  };
53  char *name;
54  char *description;
56 
57 typedef struct
58 {
60  int cpu;
61  pid_t pid;
62  char *name;
64 
65 typedef struct
66 {
67  char *name;
70 
74 
75 #define foreach_permon_offset_type \
76  _ (PERFMON_OFFSET_TYPE_MMAP, perfmon_dispatch_wrapper_mmap) \
77  _ (PERFMON_OFFSET_TYPE_METRICS, perfmon_dispatch_wrapper_metrics)
78 
80  struct perfmon_source *);
81 typedef struct perfmon_source
82 {
83  char *name;
84  char *description;
92 
93 struct perfmon_bundle;
94 
96  struct perfmon_bundle *);
97 
98 typedef struct perfmon_bundle
99 {
100  char *name;
101  char *description;
102  char *source;
103  char *footer;
109 
111 
115 
116  /* do not set manually */
120 
121 typedef struct
122 {
128 
129 typedef struct
130 {
131  CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
134  union
135  {
136  struct
137  {
139  } t[2];
141  };
143 
144 typedef struct
145 {
150  struct perf_event_mmap_page *mmap_pages[PERF_MAX_EVENTS];
152 
153 typedef struct
154 {
163  int *group_fds;
168 
170 
171 #define PERFMON_REGISTER_SOURCE(x) \
172  perfmon_source_t __perfmon_source_##x; \
173  static void __clib_constructor __perfmon_source_registration_##x (void) \
174  { \
175  perfmon_main_t *pm = &perfmon_main; \
176  __perfmon_source_##x.next = pm->sources; \
177  pm->sources = &__perfmon_source_##x; \
178  } \
179  perfmon_source_t __perfmon_source_##x
180 
181 #define PERFMON_REGISTER_BUNDLE(x) \
182  perfmon_bundle_t __perfmon_bundle_##x; \
183  static void __clib_constructor __perfmon_bundle_registration_##x (void) \
184  { \
185  perfmon_main_t *pm = &perfmon_main; \
186  __perfmon_bundle_##x.next = pm->bundles; \
187  pm->bundles = &__perfmon_bundle_##x; \
188  } \
189  perfmon_bundle_t __perfmon_bundle_##x
190 
194 
195 #define PERFMON_STRINGS(...) \
196  (char *[]) { __VA_ARGS__, 0 }
197 
198 #endif
char * footer
Definition: perfmon.h:103
char * name
Definition: perfmon.h:53
perfmon_bundle_init_fn_t * init_fn
Definition: perfmon.h:110
#define CLIB_CACHE_LINE_ALIGN_MARK(mark)
Definition: cache.h:60
uword * source_by_name
Definition: perfmon.h:159
perfmon_bundle_t * active_bundle
Definition: perfmon.h:160
unsigned long u64
Definition: types.h:89
perfmon_instance_t * instances
Definition: perfmon.h:68
perfmon_node_stats_t * node_stats
Definition: perfmon.h:148
perfmon_thread_runtime_t * thread_runtimes
Definition: perfmon.h:155
u32 instance_type
Definition: perfmon.h:50
format_function_t * format_config
Definition: perfmon.h:89
char * name
Definition: perfmon.h:100
perfmon_instance_type_t * default_instance_type
Definition: perfmon.h:165
struct perfmon_bundle perfmon_bundle_t
unsigned char u8
Definition: types.h:56
double f64
Definition: types.h:142
unsigned int u32
Definition: types.h:88
u8 *() format_function_t(u8 *s, va_list *args)
Definition: format.h:48
perfmon_instance_type_t * active_instance_type
Definition: perfmon.h:166
u32 type_from_instance
Definition: perfmon.h:45
perfmon_source_t * src
Definition: perfmon.h:117
vlib_node_function_t perfmon_dispatch_wrapper_metrics
Definition: perfmon.h:73
struct perfmon_bundle * next
Definition: perfmon.h:118
format_function_t * format_fn
Definition: perfmon.h:113
unsigned short u16
Definition: types.h:57
char * description
Definition: perfmon.h:84
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
clib_cpu_supports_func_t cpu_supports
Definition: perfmon.h:114
clib_error_t *() perfmon_bundle_init_fn_t(vlib_main_t *vm, struct perfmon_bundle *)
Definition: perfmon.h:95
perfmon_main_t perfmon_main
Definition: perfmon.c:27
perfmon_event_t * events
Definition: perfmon.h:86
perfmon_bundle_type_t type
Definition: perfmon.h:104
perfmon_offset_type_t
Definition: perfmon.h:36
#define PERF_MAX_EVENTS
Definition: perfmon.h:26
u32 exclude_kernel
Definition: perfmon.h:46
u8 value
Definition: qos.api:54
perfmon_source_t * sources
Definition: perfmon.h:158
clib_error_t *() perfmon_source_init_fn_t(vlib_main_t *vm, struct perfmon_source *)
Definition: perfmon.h:79
perfmon_instance_type_t * instances_by_type
Definition: perfmon.h:88
uword() vlib_node_function_t(struct vlib_main_t *vm, struct vlib_node_runtime_t *node, struct vlib_frame_t *frame)
Definition: node.h:54
char ** column_headers
Definition: perfmon.h:112
perfmon_source_init_fn_t * init_fn
Definition: perfmon.h:90
u32 n_events
Definition: perfmon.h:87
int is_running
Definition: perfmon.h:161
void perfmon_reset(vlib_main_t *vm)
Definition: perfmon.c:45
struct perfmon_source perfmon_source_t
f64 sample_time
Definition: perfmon.h:162
struct perfmon_source * next
Definition: perfmon.h:85
vlib_node_function_t perfmon_dispatch_wrapper_mmap
Definition: perfmon.h:71
int * fds_to_close
Definition: perfmon.h:164
perfmon_bundle_type_t
Definition: perfmon.h:28
perfmon_bundle_t * bundle
Definition: perfmon.h:149
int * group_fds
Definition: perfmon.h:163
u64 uword
Definition: types.h:112
clib_error_t * perfmon_start(vlib_main_t *vm, perfmon_bundle_t *)
Definition: perfmon.c:216
clib_error_t * perfmon_stop(vlib_main_t *vm)
Definition: perfmon.c:262
char * name
Definition: perfmon.h:83
int(* clib_cpu_supports_func_t)()
Definition: cpu.h:182
perfmon_offset_type_t offset_type
Definition: perfmon.h:105
uword * bundle_by_name
Definition: perfmon.h:157
char * description
Definition: perfmon.h:101
char * description
Definition: perfmon.h:54
perfmon_bundle_t * bundles
Definition: perfmon.h:156
char * source
Definition: perfmon.h:102