FD.io VPP
v19.08-27-gf4dcae4
Vector Packet Processing
Main Page
Related Pages
Modules
Namespaces
Data Structures
Source
Files
Symbols
•
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Modules
Pages
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 <stdatomic.h>
20
#include <
vlib/vlib.h
>
21
#include <
vppinfra/socket.h
>
22
#include <
vpp-api/client/stat_client.h
>
23
24
typedef
enum
25
{
26
STAT_COUNTER_VECTOR_RATE
= 0,
27
STAT_COUNTER_NUM_WORKER_THREADS
,
28
STAT_COUNTER_VECTOR_RATE_PER_WORKER
,
29
STAT_COUNTER_INPUT_RATE
,
30
STAT_COUNTER_LAST_UPDATE
,
31
STAT_COUNTER_LAST_STATS_CLEAR
,
32
STAT_COUNTER_HEARTBEAT
,
33
STAT_COUNTER_NODE_CLOCKS
,
34
STAT_COUNTER_NODE_VECTORS
,
35
STAT_COUNTER_NODE_CALLS
,
36
STAT_COUNTER_NODE_SUSPENDS
,
37
STAT_COUNTER_INTERFACE_NAMES
,
38
STAT_COUNTER_NODE_NAMES
,
39
STAT_COUNTER_MEM_STATSEG_TOTAL
,
40
STAT_COUNTER_MEM_STATSEG_USED
,
41
STAT_COUNTERS
42
}
stat_segment_counter_t
;
43
44
#define foreach_stat_segment_counter_name \
45
_(VECTOR_RATE, SCALAR_INDEX, vector_rate, /sys) \
46
_(VECTOR_RATE_PER_WORKER, COUNTER_VECTOR_SIMPLE, \
47
vector_rate_per_worker, /sys) \
48
_(NUM_WORKER_THREADS, SCALAR_INDEX, num_worker_threads, /sys) \
49
_(INPUT_RATE, SCALAR_INDEX, input_rate, /sys) \
50
_(LAST_UPDATE, SCALAR_INDEX, last_update, /sys) \
51
_(LAST_STATS_CLEAR, SCALAR_INDEX, last_stats_clear, /sys) \
52
_(HEARTBEAT, SCALAR_INDEX, heartbeat, /sys) \
53
_(NODE_CLOCKS, COUNTER_VECTOR_SIMPLE, clocks, /sys/node) \
54
_(NODE_VECTORS, COUNTER_VECTOR_SIMPLE, vectors, /sys/node) \
55
_(NODE_CALLS, COUNTER_VECTOR_SIMPLE, calls, /sys/node) \
56
_(NODE_SUSPENDS, COUNTER_VECTOR_SIMPLE, suspends, /sys/node) \
57
_(INTERFACE_NAMES, NAME_VECTOR, names, /if) \
58
_(NODE_NAMES, NAME_VECTOR, names, /sys/node) \
59
_(MEM_STATSEG_TOTAL, SCALAR_INDEX, total, /mem/statseg) \
60
_(MEM_STATSEG_USED, SCALAR_INDEX, used, /mem/statseg)
61
62
typedef
struct
63
{
64
stat_directory_type_t
type
;
65
union
{
66
uint64_t
offset
;
67
uint64_t
index
;
68
uint64_t
value
;
69
};
70
uint64_t
offset_vector
;
71
char
name
[128];
// TODO change this to pointer to "somewhere"
72
}
stat_segment_directory_entry_t
;
73
74
/* Default stat segment 32m */
75
#define STAT_SEGMENT_DEFAULT_SIZE (32<<20)
76
77
/* Shared segment memory layout version */
78
#define STAT_SEGMENT_VERSION 1
79
80
/*
81
* Shared header first in the shared memory segment.
82
*/
83
typedef
struct
84
{
85
u64
version
;
86
atomic_int_fast64_t
epoch
;
87
atomic_int_fast64_t
in_progress
;
88
atomic_int_fast64_t
directory_offset
;
89
atomic_int_fast64_t
error_offset
;
90
atomic_int_fast64_t
stats_offset
;
91
}
stat_segment_shared_header_t
;
92
93
static
inline
uint64_t
94
stat_segment_offset
(
void
*start,
void
*
data
)
95
{
96
return
(
char
*) data - (
char
*) start;
97
}
98
99
static
inline
void
*
100
stat_segment_pointer
(
void
*start, uint64_t
offset
)
101
{
102
return
((
char
*) start + offset);
103
}
104
105
typedef
void (*
stat_segment_update_fn
)(
stat_segment_directory_entry_t
* e,
u32
i
);
106
107
typedef
struct
{
108
u32
directory_index
;
109
stat_segment_update_fn
fn
;
110
u32
caller_index
;
111
}
stat_segment_gauges_pool_t
;
112
113
typedef
struct
114
{
115
/* internal, does not point to shared memory */
116
stat_segment_gauges_pool_t
*
gauges
;
117
118
/* statistics segment */
119
uword
*
directory_vector_by_name
;
120
stat_segment_directory_entry_t
*
directory_vector
;
121
u64
*
error_vector
;
122
u8
**
interfaces
;
123
u8
**
nodes
;
124
125
clib_spinlock_t
*
stat_segment_lockp
;
126
clib_socket_t
*
socket
;
127
u8
*
socket_name
;
128
ssize_t
memory_size
;
129
u8
node_counters_enabled
;
130
void
*
last
;
131
void
*
heap
;
132
stat_segment_shared_header_t
*
shared_header
;
/* pointer to shared memory segment */
133
int
memfd
;
134
135
u64
last_input_packets
;
// OLE REMOVE?
136
}
stat_segment_main_t
;
137
138
extern
stat_segment_main_t
stat_segment_main
;
139
140
clib_error_t
*
141
stat_segment_register_gauge
(
u8
*names,
stat_segment_update_fn
update_fn,
u32
index);
142
143
#endif
stat_segment_main_t::heap
void * heap
Definition:
stat_segment.h:131
stat_segment_directory_entry_t
Definition:
stat_segment.h:62
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:116
stat_segment_main_t::shared_header
stat_segment_shared_header_t * shared_header
Definition:
stat_segment.h:132
stat_client.h
stat_segment_directory_entry_t::index
uint64_t index
Definition:
stat_segment.h:67
STAT_COUNTER_NUM_WORKER_THREADS
Definition:
stat_segment.h:27
stat_segment_main_t::directory_vector
stat_segment_directory_entry_t * directory_vector
Definition:
stat_segment.h:120
u64
unsigned long u64
Definition:
types.h:89
STAT_COUNTER_VECTOR_RATE
Definition:
stat_segment.h:26
stat_segment_offset
static uint64_t stat_segment_offset(void *start, void *data)
Definition:
stat_segment.h:94
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:732
i
int i
Definition:
flowhash_template.h:376
stat_segment_main_t::error_vector
u64 * error_vector
Definition:
stat_segment.h:121
data
u8 data[128]
Definition:
ipsec.api:249
stat_segment_main_t::last
void * last
Definition:
stat_segment.h:130
stat_segment_main_t::memory_size
ssize_t memory_size
Definition:
stat_segment.h:128
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:105
stat_segment_shared_header_t::in_progress
atomic_int_fast64_t in_progress
Definition:
stat_segment.h:87
STAT_COUNTER_NODE_CLOCKS
Definition:
stat_segment.h:33
stat_segment_directory_entry_t::value
uint64_t value
Definition:
stat_segment.h:68
STAT_COUNTER_INTERFACE_NAMES
Definition:
stat_segment.h:37
stat_segment_gauges_pool_t::fn
stat_segment_update_fn fn
Definition:
stat_segment.h:109
u32
unsigned int u32
Definition:
types.h:88
STAT_COUNTER_NODE_NAMES
Definition:
stat_segment.h:38
STAT_COUNTER_MEM_STATSEG_TOTAL
Definition:
stat_segment.h:39
STAT_COUNTER_INPUT_RATE
Definition:
stat_segment.h:29
stat_segment_main_t::node_counters_enabled
u8 node_counters_enabled
Definition:
stat_segment.h:129
stat_segment_pointer
static void * stat_segment_pointer(void *start, uint64_t offset)
Definition:
stat_segment.h:100
stat_segment_directory_entry_t::offset
uint64_t offset
Definition:
stat_segment.h:66
STAT_COUNTER_HEARTBEAT
Definition:
stat_segment.h:32
stat_segment_counter_t
stat_segment_counter_t
Definition:
stat_segment.h:24
STAT_COUNTER_MEM_STATSEG_USED
Definition:
stat_segment.h:40
stat_segment_main_t::memfd
int memfd
Definition:
stat_segment.h:133
stat_segment_gauges_pool_t::caller_index
u32 caller_index
Definition:
stat_segment.h:110
name
u8 name[64]
Definition:
memclnt.api:152
STAT_COUNTER_LAST_UPDATE
Definition:
stat_segment.h:30
STAT_COUNTER_NODE_VECTORS
Definition:
stat_segment.h:34
stat_segment_gauges_pool_t
Definition:
stat_segment.h:107
stat_segment_main_t::last_input_packets
u64 last_input_packets
Definition:
stat_segment.h:135
stat_directory_type_t
stat_directory_type_t
Definition:
stat_client.h:27
vlib.h
stat_segment_directory_entry_t::offset_vector
uint64_t offset_vector
Definition:
stat_segment.h:70
clib_spinlock_t
Definition:
lock.h:49
socket.h
stat_segment_main_t
Definition:
stat_segment.h:113
clib_socket_t
struct _socket_t clib_socket_t
stat_segment_gauges_pool_t::directory_index
u32 directory_index
Definition:
stat_segment.h:108
stat_segment_shared_header_t::epoch
atomic_int_fast64_t epoch
Definition:
stat_segment.h:86
stat_segment_main_t::nodes
u8 ** nodes
Definition:
stat_segment.h:123
STAT_COUNTER_NODE_SUSPENDS
Definition:
stat_segment.h:36
clib_error_t
Definition:
clib_error.h:21
STAT_COUNTER_NODE_CALLS
Definition:
stat_segment.h:35
clib_bihash_value
template key/value backing page structure
Definition:
bihash_doc.h:44
stat_segment_shared_header_t
Definition:
stat_segment.h:83
STAT_COUNTER_VECTOR_RATE_PER_WORKER
Definition:
stat_segment.h:28
stat_segment_main_t::directory_vector_by_name
uword * directory_vector_by_name
Definition:
stat_segment.h:119
uword
u64 uword
Definition:
types.h:112
stat_segment_shared_header_t::version
u64 version
Definition:
stat_segment.h:85
stat_segment_main_t::socket_name
u8 * socket_name
Definition:
stat_segment.h:127
stat_segment_main_t::socket
clib_socket_t * socket
Definition:
stat_segment.h:126
stat_segment_shared_header_t::stats_offset
atomic_int_fast64_t stats_offset
Definition:
stat_segment.h:90
STAT_COUNTERS
Definition:
stat_segment.h:41
stat_segment_shared_header_t::error_offset
atomic_int_fast64_t error_offset
Definition:
stat_segment.h:89
STAT_COUNTER_LAST_STATS_CLEAR
Definition:
stat_segment.h:31
stat_segment_main_t::stat_segment_lockp
clib_spinlock_t * stat_segment_lockp
Definition:
stat_segment.h:125
stat_segment_shared_header_t::directory_offset
atomic_int_fast64_t directory_offset
Definition:
stat_segment.h:88
stat_segment_main_t::interfaces
u8 ** interfaces
Definition:
stat_segment.h:122
stat_segment_directory_entry_t::type
stat_directory_type_t type
Definition:
stat_segment.h:64
src
vpp
stats
stat_segment.h
Generated on Wed Sep 18 2019 17:45:14 for FD.io VPP by
1.8.11