FD.io VPP  v21.06-3-gbb25fbf28
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
vlib.h
perfmon_node_stats_t
Definition: perfmon.h:129
PERFMON_OFFSET_TYPE_METRICS
@ PERFMON_OFFSET_TYPE_METRICS
Definition: perfmon.h:39
perfmon_start
clib_error_t * perfmon_start(vlib_main_t *vm, perfmon_bundle_t *)
Definition: perfmon.c:216
perfmon_node_stats_t::n_packets
u64 n_packets
Definition: perfmon.h:133
perfmon_thread_runtime_t::n_events
u8 n_events
Definition: perfmon.h:146
perfmon_bundle_t
struct perfmon_bundle perfmon_bundle_t
perfmon_event_t::config
u64 config
Definition: perfmon.h:52
clib_cpu_supports_func_t
int(* clib_cpu_supports_func_t)()
Definition: cpu.h:182
PERFMON_BUNDLE_TYPE_NODE
@ PERFMON_BUNDLE_TYPE_NODE
Definition: perfmon.h:31
perfmon_instance_type_t::name
char * name
Definition: perfmon.h:67
perfmon_bundle::type
perfmon_bundle_type_t type
Definition: perfmon.h:104
perfmon_reading_t
Definition: perfmon.h:121
perfmon_source::events
perfmon_event_t * events
Definition: perfmon.h:86
perfmon_main_t::active_bundle
perfmon_bundle_t * active_bundle
Definition: perfmon.h:160
perfmon_event_t
Definition: perfmon.h:43
CLIB_CACHE_LINE_ALIGN_MARK
#define CLIB_CACHE_LINE_ALIGN_MARK(mark)
Definition: cache.h:60
perfmon_main_t
Definition: perfmon.h:153
perfmon_instance_type_t
Definition: perfmon.h:65
clib.h
perfmon_node_stats_t::n_calls
u64 n_calls
Definition: perfmon.h:132
perfmon_thread_runtime_t::n_nodes
u16 n_nodes
Definition: perfmon.h:147
perfmon_reading_t::time_enabled
u64 time_enabled
Definition: perfmon.h:124
perfmon_bundle::column_headers
char ** column_headers
Definition: perfmon.h:112
perfmon_main_t::bundles
perfmon_bundle_t * bundles
Definition: perfmon.h:156
PERFMON_BUNDLE_TYPE_UNKNOWN
@ PERFMON_BUNDLE_TYPE_UNKNOWN
Definition: perfmon.h:30
u16
unsigned short u16
Definition: types.h:57
perfmon_bundle
Definition: perfmon.h:98
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
perfmon_source::instances_by_type
perfmon_instance_type_t * instances_by_type
Definition: perfmon.h:88
perfmon_event_t::instance_type
u32 instance_type
Definition: perfmon.h:50
perfmon_source::name
char * name
Definition: perfmon.h:83
perfmon_source::n_events
u32 n_events
Definition: perfmon.h:87
vlib_node_function_t
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
perfmon_main_t::active_instance_type
perfmon_instance_type_t * active_instance_type
Definition: perfmon.h:166
perfmon_main_t::thread_runtimes
perfmon_thread_runtime_t * thread_runtimes
Definition: perfmon.h:155
perfmon_main_t::source_by_name
uword * source_by_name
Definition: perfmon.h:159
perfmon_source::init_fn
perfmon_source_init_fn_t * init_fn
Definition: perfmon.h:90
perfmon_source::next
struct perfmon_source * next
Definition: perfmon.h:85
perfmon_instance_t::type
u32 type
Definition: perfmon.h:59
perfmon_main_t::sources
perfmon_source_t * sources
Definition: perfmon.h:158
perfmon_event_t::type
u32 type
Definition: perfmon.h:49
error.h
perfmon_source
Definition: perfmon.h:81
PERFMON_BUNDLE_TYPE_THREAD
@ PERFMON_BUNDLE_TYPE_THREAD
Definition: perfmon.h:32
perfmon_source_t
struct perfmon_source perfmon_source_t
perfmon_main_t::sample_time
f64 sample_time
Definition: perfmon.h:162
perfmon_bundle::footer
char * footer
Definition: perfmon.h:103
perfmon_bundle::description
char * description
Definition: perfmon.h:101
uword
u64 uword
Definition: types.h:112
perfmon_bundle::offset_type
perfmon_offset_type_t offset_type
Definition: perfmon.h:105
perfmon_thread_runtime_t::bundle
perfmon_bundle_t * bundle
Definition: perfmon.h:149
perfmon_main
perfmon_main_t perfmon_main
Definition: perfmon.c:27
perfmon_offset_type_t
perfmon_offset_type_t
Definition: perfmon.h:36
PERFMON_BUNDLE_TYPE_SYSTEM
@ PERFMON_BUNDLE_TYPE_SYSTEM
Definition: perfmon.h:33
perfmon_main_t::fds_to_close
int * fds_to_close
Definition: perfmon.h:164
f64
double f64
Definition: types.h:142
format.h
PERFMON_OFFSET_TYPE_MMAP
@ PERFMON_OFFSET_TYPE_MMAP
Definition: perfmon.h:38
perfmon_source::format_config
format_function_t * format_config
Definition: perfmon.h:89
perfmon_dispatch_wrapper_metrics
vlib_node_function_t perfmon_dispatch_wrapper_metrics
Definition: perfmon.h:73
cpu.h
perfmon_bundle::source
char * source
Definition: perfmon.h:102
perfmon_bundle::metrics
u32 metrics[PERF_MAX_EVENTS]
Definition: perfmon.h:107
perfmon_event_t::exclude_kernel
u32 exclude_kernel
Definition: perfmon.h:46
perfmon_instance_t
Definition: perfmon.h:57
perfmon_reset
void perfmon_reset(vlib_main_t *vm)
Definition: perfmon.c:45
perfmon_bundle::init_fn
perfmon_bundle_init_fn_t * init_fn
Definition: perfmon.h:110
PERFMON_OFFSET_TYPE_MAX
@ PERFMON_OFFSET_TYPE_MAX
Definition: perfmon.h:40
format_function_t
u8 *() format_function_t(u8 *s, va_list *args)
Definition: format.h:48
PERF_MAX_EVENTS
#define PERF_MAX_EVENTS
Definition: perfmon.h:26
perfmon_main_t::group_fds
int * group_fds
Definition: perfmon.h:163
u64
unsigned long u64
Definition: types.h:89
perfmon_bundle::events
u32 events[PERF_MAX_EVENTS]
Definition: perfmon.h:106
perfmon_main_t::bundle_by_name
uword * bundle_by_name
Definition: perfmon.h:157
perfmon_bundle_init_fn_t
clib_error_t *() perfmon_bundle_init_fn_t(vlib_main_t *vm, struct perfmon_bundle *)
Definition: perfmon.h:95
u32
unsigned int u32
Definition: types.h:88
perfmon_instance_type_t::instances
perfmon_instance_t * instances
Definition: perfmon.h:68
perfmon_stop
clib_error_t * perfmon_stop(vlib_main_t *vm)
Definition: perfmon.c:262
perfmon_main_t::default_instance_type
perfmon_instance_type_t * default_instance_type
Definition: perfmon.h:165
perfmon_bundle::name
char * name
Definition: perfmon.h:100
perfmon_instance_t::pid
pid_t pid
Definition: perfmon.h:61
perfmon_reading_t::nr
u64 nr
Definition: perfmon.h:123
perfmon_main_t::is_running
int is_running
Definition: perfmon.h:161
perfmon_instance_t::name
char * name
Definition: perfmon.h:62
perfmon_event_t::name
char * name
Definition: perfmon.h:53
perfmon_event_t::type_from_instance
u32 type_from_instance
Definition: perfmon.h:45
perfmon_bundle::src
perfmon_source_t * src
Definition: perfmon.h:117
value
u8 value
Definition: qos.api:54
perfmon_thread_runtime_t
Definition: perfmon.h:144
perfmon_instance_t::cpu
int cpu
Definition: perfmon.h:60
vlib_main_t
Definition: main.h:102
perfmon_bundle::n_events
u32 n_events
Definition: perfmon.h:108
u8
unsigned char u8
Definition: types.h:56
clib_error_t
Definition: clib_error.h:21
perfmon_thread_runtime_t::node_stats
perfmon_node_stats_t * node_stats
Definition: perfmon.h:148
perfmon_event_t::description
char * description
Definition: perfmon.h:54
perfmon_source_init_fn_t
clib_error_t *() perfmon_source_init_fn_t(vlib_main_t *vm, struct perfmon_source *)
Definition: perfmon.h:79
perfmon_bundle::format_fn
format_function_t * format_fn
Definition: perfmon.h:113
perfmon_dispatch_wrapper_mmap
vlib_node_function_t perfmon_dispatch_wrapper_mmap
Definition: perfmon.h:71
perfmon_source::description
char * description
Definition: perfmon.h:84
perfmon_bundle_type_t
perfmon_bundle_type_t
Definition: perfmon.h:28
perfmon_bundle::next
struct perfmon_bundle * next
Definition: perfmon.h:118
perfmon_bundle::cpu_supports
clib_cpu_supports_func_t cpu_supports
Definition: perfmon.h:114
perfmon_reading_t::time_running
u64 time_running
Definition: perfmon.h:125