FD.io VPP
v20.05.1-5-g09f167997
Vector Packet Processing
stat_segment.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2018 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 included_stat_segment_h
17
#define included_stat_segment_h
18
19
#include <
vlib/vlib.h
>
20
#include <
vppinfra/socket.h
>
21
#include <
vpp/stats/stat_segment_shared.h
>
22
23
typedef
enum
24
{
25
STAT_COUNTER_VECTOR_RATE
= 0,
26
STAT_COUNTER_NUM_WORKER_THREADS
,
27
STAT_COUNTER_VECTOR_RATE_PER_WORKER
,
28
STAT_COUNTER_INPUT_RATE
,
29
STAT_COUNTER_LAST_UPDATE
,
30
STAT_COUNTER_LAST_STATS_CLEAR
,
31
STAT_COUNTER_HEARTBEAT
,
32
STAT_COUNTER_NODE_CLOCKS
,
33
STAT_COUNTER_NODE_VECTORS
,
34
STAT_COUNTER_NODE_CALLS
,
35
STAT_COUNTER_NODE_SUSPENDS
,
36
STAT_COUNTER_INTERFACE_NAMES
,
37
STAT_COUNTER_NODE_NAMES
,
38
STAT_COUNTER_MEM_STATSEG_TOTAL
,
39
STAT_COUNTER_MEM_STATSEG_USED
,
40
STAT_COUNTERS
41
}
stat_segment_counter_t
;
42
43
#define foreach_stat_segment_counter_name \
44
_(VECTOR_RATE, SCALAR_INDEX, vector_rate, /sys) \
45
_(VECTOR_RATE_PER_WORKER, COUNTER_VECTOR_SIMPLE, \
46
vector_rate_per_worker, /sys) \
47
_(NUM_WORKER_THREADS, SCALAR_INDEX, num_worker_threads, /sys) \
48
_(INPUT_RATE, SCALAR_INDEX, input_rate, /sys) \
49
_(LAST_UPDATE, SCALAR_INDEX, last_update, /sys) \
50
_(LAST_STATS_CLEAR, SCALAR_INDEX, last_stats_clear, /sys) \
51
_(HEARTBEAT, SCALAR_INDEX, heartbeat, /sys) \
52
_(NODE_CLOCKS, COUNTER_VECTOR_SIMPLE, clocks, /sys/node) \
53
_(NODE_VECTORS, COUNTER_VECTOR_SIMPLE, vectors, /sys/node) \
54
_(NODE_CALLS, COUNTER_VECTOR_SIMPLE, calls, /sys/node) \
55
_(NODE_SUSPENDS, COUNTER_VECTOR_SIMPLE, suspends, /sys/node) \
56
_(INTERFACE_NAMES, NAME_VECTOR, names, /if) \
57
_(NODE_NAMES, NAME_VECTOR, names, /sys/node) \
58
_(MEM_STATSEG_TOTAL, SCALAR_INDEX, total, /mem/statseg) \
59
_(MEM_STATSEG_USED, SCALAR_INDEX, used, /mem/statseg)
60
61
/* Default stat segment 32m */
62
#define STAT_SEGMENT_DEFAULT_SIZE (32<<20)
63
64
/* Shared segment memory layout version */
65
#define STAT_SEGMENT_VERSION 1
66
67
#define STAT_SEGMENT_INDEX_INVALID UINT32_MAX
68
69
static
inline
uint64_t
70
stat_segment_offset
(
void
*start,
void
*
data
)
71
{
72
return
(
char
*) data - (
char
*) start;
73
}
74
75
typedef
void (*
stat_segment_update_fn
)(
stat_segment_directory_entry_t
* e,
u32
i
);
76
77
typedef
struct
{
78
u32
directory_index
;
79
stat_segment_update_fn
fn
;
80
u32
caller_index
;
81
}
stat_segment_gauges_pool_t
;
82
83
typedef
struct
84
{
85
/* internal, does not point to shared memory */
86
stat_segment_gauges_pool_t
*
gauges
;
87
88
/* statistics segment */
89
uword
*
directory_vector_by_name
;
90
stat_segment_directory_entry_t
*
directory_vector
;
91
u64
*
error_vector
;
92
u8
**
interfaces
;
93
u8
**
nodes
;
94
95
/* Update interval */
96
f64
update_interval
;
97
98
clib_spinlock_t
*
stat_segment_lockp
;
99
clib_socket_t
*
socket
;
100
u8
*
socket_name
;
101
ssize_t
memory_size
;
102
u8
node_counters_enabled
;
103
void
*
last
;
104
void
*
heap
;
105
stat_segment_shared_header_t
*
shared_header
;
/* pointer to shared memory segment */
106
int
memfd
;
107
108
u64
last_input_packets
;
// OLE REMOVE?
109
}
stat_segment_main_t
;
110
111
extern
stat_segment_main_t
stat_segment_main
;
112
113
clib_error_t
*
114
stat_segment_register_gauge
(
u8
*names,
stat_segment_update_fn
update_fn,
u32
index);
115
clib_error_t
*
116
stat_segment_register_state_counter
(
u8
*
name
,
u32
*index);
117
clib_error_t
*
118
stat_segment_deregister_state_counter
(
u32
index);
119
void
stat_segment_set_state_counter
(
u32
index,
u64
value
);
120
121
#endif
stat_segment_main_t::heap
void * heap
Definition:
stat_segment.h:104
stat_segment_register_state_counter
clib_error_t * stat_segment_register_state_counter(u8 *name, u32 *index)
Definition:
stat_segment.c:898
stat_segment_directory_entry_t
Definition:
stat_segment_shared.h:30
stat_segment_main
stat_segment_main_t stat_segment_main
Definition:
stat_segment.c:27
stat_segment_main_t::gauges
stat_segment_gauges_pool_t * gauges
Definition:
stat_segment.h:86
stat_segment_main_t::shared_header
stat_segment_shared_header_t * shared_header
Definition:
stat_segment.h:105
STAT_COUNTER_NUM_WORKER_THREADS
Definition:
stat_segment.h:26
stat_segment_main_t::directory_vector
stat_segment_directory_entry_t * directory_vector
Definition:
stat_segment.h:90
u64
unsigned long u64
Definition:
types.h:89
STAT_COUNTER_VECTOR_RATE
Definition:
stat_segment.h:25
stat_segment_offset
static uint64_t stat_segment_offset(void *start, void *data)
Definition:
stat_segment.h:70
stat_segment_register_gauge
clib_error_t * stat_segment_register_gauge(u8 *names, stat_segment_update_fn update_fn, u32 index)
Definition:
stat_segment.c:858
stat_segment_main_t::error_vector
u64 * error_vector
Definition:
stat_segment.h:91
stat_segment_set_state_counter
void stat_segment_set_state_counter(u32 index, u64 value)
Definition:
stat_segment.c:961
stat_segment_main_t::last
void * last
Definition:
stat_segment.h:103
stat_segment_main_t::memory_size
ssize_t memory_size
Definition:
stat_segment.h:101
u8
unsigned char u8
Definition:
types.h:56
stat_segment_update_fn
void(* stat_segment_update_fn)(stat_segment_directory_entry_t *e, u32 i)
Definition:
stat_segment.h:75
f64
double f64
Definition:
types.h:142
stat_segment_deregister_state_counter
clib_error_t * stat_segment_deregister_state_counter(u32 index)
Definition:
stat_segment.c:933
STAT_COUNTER_NODE_CLOCKS
Definition:
stat_segment.h:32
STAT_COUNTER_INTERFACE_NAMES
Definition:
stat_segment.h:36
stat_segment_gauges_pool_t::fn
stat_segment_update_fn fn
Definition:
stat_segment.h:79
u32
unsigned int u32
Definition:
types.h:88
STAT_COUNTER_NODE_NAMES
Definition:
stat_segment.h:37
STAT_COUNTER_MEM_STATSEG_TOTAL
Definition:
stat_segment.h:38
STAT_COUNTER_INPUT_RATE
Definition:
stat_segment.h:28
stat_segment_main_t::node_counters_enabled
u8 node_counters_enabled
Definition:
stat_segment.h:102
STAT_COUNTER_HEARTBEAT
Definition:
stat_segment.h:31
stat_segment_counter_t
stat_segment_counter_t
Definition:
stat_segment.h:23
STAT_COUNTER_MEM_STATSEG_USED
Definition:
stat_segment.h:39
stat_segment_main_t::memfd
int memfd
Definition:
stat_segment.h:106
stat_segment_gauges_pool_t::caller_index
u32 caller_index
Definition:
stat_segment.h:80
STAT_COUNTER_LAST_UPDATE
Definition:
stat_segment.h:29
STAT_COUNTER_NODE_VECTORS
Definition:
stat_segment.h:33
i
sll srl srl sll sra u16x4 i
Definition:
vector_sse42.h:317
stat_segment_gauges_pool_t
Definition:
stat_segment.h:77
stat_segment_main_t::last_input_packets
u64 last_input_packets
Definition:
stat_segment.h:108
vlib.h
name
string name[64]
Definition:
ip.api:44
clib_spinlock_t
Definition:
lock.h:51
value
u8 value
Definition:
qos.api:54
socket.h
data
u8 data[128]
Definition:
ipsec_types.api:89
stat_segment_main_t
Definition:
stat_segment.h:83
clib_socket_t
struct _socket_t clib_socket_t
stat_segment_main_t::update_interval
f64 update_interval
Definition:
stat_segment.h:96
stat_segment_gauges_pool_t::directory_index
u32 directory_index
Definition:
stat_segment.h:78
stat_segment_main_t::nodes
u8 ** nodes
Definition:
stat_segment.h:93
STAT_COUNTER_NODE_SUSPENDS
Definition:
stat_segment.h:35
clib_error_t
Definition:
clib_error.h:21
STAT_COUNTER_NODE_CALLS
Definition:
stat_segment.h:34
stat_segment_shared_header_t
Definition:
stat_segment_shared.h:45
STAT_COUNTER_VECTOR_RATE_PER_WORKER
Definition:
stat_segment.h:27
stat_segment_main_t::directory_vector_by_name
uword * directory_vector_by_name
Definition:
stat_segment.h:89
uword
u64 uword
Definition:
types.h:112
stat_segment_main_t::socket_name
u8 * socket_name
Definition:
stat_segment.h:100
stat_segment_main_t::socket
clib_socket_t * socket
Definition:
stat_segment.h:99
STAT_COUNTERS
Definition:
stat_segment.h:40
stat_segment_shared.h
STAT_COUNTER_LAST_STATS_CLEAR
Definition:
stat_segment.h:30
stat_segment_main_t::stat_segment_lockp
clib_spinlock_t * stat_segment_lockp
Definition:
stat_segment.h:98
stat_segment_main_t::interfaces
u8 ** interfaces
Definition:
stat_segment.h:92
src
vpp
stats
stat_segment.h
Generated on Wed Sep 9 2020 03:06:21 for FD.io VPP by
1.8.13