FD.io VPP
v18.10-34-gcce845e
Vector Packet Processing
Main Page
Related Pages
Modules
Namespaces
Data Structures
Source
Files
Symbols
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
23
/* Default socket to exchange segment fd */
24
#define STAT_SEGMENT_SOCKET_FILE "/run/vpp/stats.sock"
25
26
typedef
enum
27
{
28
STAT_DIR_TYPE_ILLEGAL
= 0,
29
STAT_DIR_TYPE_SCALAR_INDEX
,
30
STAT_DIR_TYPE_COUNTER_VECTOR_SIMPLE
,
31
STAT_DIR_TYPE_COUNTER_VECTOR_COMBINED
,
32
STAT_DIR_TYPE_ERROR_INDEX
,
33
}
stat_directory_type_t
;
34
35
typedef
enum
36
{
37
STAT_COUNTER_VECTOR_RATE
= 0,
38
STAT_COUNTER_INPUT_RATE
,
39
STAT_COUNTER_LAST_UPDATE
,
40
STAT_COUNTER_LAST_STATS_CLEAR
,
41
STAT_COUNTER_HEARTBEAT
,
42
STAT_COUNTER_NODE_CLOCKS
,
43
STAT_COUNTER_NODE_VECTORS
,
44
STAT_COUNTER_NODE_CALLS
,
45
STAT_COUNTER_NODE_SUSPENDS
,
46
STAT_COUNTERS
47
}
stat_segment_counter_t
;
48
49
#define foreach_stat_segment_counter_name \
50
_(VECTOR_RATE, SCALAR_INDEX, vector_rate,) \
51
_(INPUT_RATE, SCALAR_INDEX, input_rate,) \
52
_(LAST_UPDATE, SCALAR_INDEX, last_update,) \
53
_(LAST_STATS_CLEAR, SCALAR_INDEX, last_stats_clear,) \
54
_(HEARTBEAT, SCALAR_INDEX, heartbeat,) \
55
_(NODE_CLOCKS, COUNTER_VECTOR_SIMPLE, clocks, /node) \
56
_(NODE_VECTORS, COUNTER_VECTOR_SIMPLE, vectors, /node) \
57
_(NODE_CALLS, COUNTER_VECTOR_SIMPLE, calls, /node) \
58
_(NODE_SUSPENDS, COUNTER_VECTOR_SIMPLE, suspends, /node)
59
60
typedef
struct
61
{
62
stat_directory_type_t
type
;
63
union
{
64
uint64_t
offset
;
65
uint64_t
index
;
66
uint64_t
value
;
67
};
68
uint64_t
offset_vector
;
69
char
name
[128];
// TODO change this to pointer to "somewhere"
70
}
stat_segment_directory_entry_t
;
71
72
/* Default stat segment 32m */
73
#define STAT_SEGMENT_DEFAULT_SIZE (32<<20)
74
75
/*
76
* Shared header first in the shared memory segment.
77
*/
78
typedef
struct
79
{
80
atomic_int_fast64_t
epoch
;
81
atomic_int_fast64_t
in_progress
;
82
atomic_int_fast64_t
directory_offset
;
83
atomic_int_fast64_t
error_offset
;
84
atomic_int_fast64_t
stats_offset
;
85
}
stat_segment_shared_header_t
;
86
87
static
inline
uint64_t
88
stat_segment_offset
(
void
*start,
void
*data)
89
{
90
return
(
char
*) data - (
char
*) start;
91
}
92
93
static
inline
void
*
94
stat_segment_pointer
(
void
*start, uint64_t
offset
)
95
{
96
return
((
char
*) start + offset);
97
}
98
99
typedef
struct
100
{
101
/* statistics segment */
102
uword
*
directory_vector_by_name
;
103
stat_segment_directory_entry_t
*
directory_vector
;
104
clib_spinlock_t
*
stat_segment_lockp
;
105
clib_socket_t
*
socket
;
106
u8
*
socket_name
;
107
ssize_t
memory_size
;
108
u8
node_counters_enabled
;
109
void
*
heap
;
110
stat_segment_shared_header_t
*
shared_header
;
/* pointer to shared memory segment */
111
int
memfd
;
112
113
u64
last_input_packets
;
114
}
stat_segment_main_t
;
115
116
extern
stat_segment_main_t
stat_segment_main
;
117
118
#endif
stat_segment_main_t::heap
void * heap
Definition:
stat_segment.h:109
STAT_DIR_TYPE_ERROR_INDEX
Definition:
stat_segment.h:32
stat_segment_directory_entry_t
Definition:
stat_segment.h:60
stat_segment_main
stat_segment_main_t stat_segment_main
Definition:
stat_segment.c:25
stat_segment_main_t::shared_header
stat_segment_shared_header_t * shared_header
Definition:
stat_segment.h:110
stat_segment_directory_entry_t::index
uint64_t index
Definition:
stat_segment.h:65
stat_segment_main_t::directory_vector
stat_segment_directory_entry_t * directory_vector
Definition:
stat_segment.h:103
u64
unsigned long u64
Definition:
types.h:89
STAT_DIR_TYPE_SCALAR_INDEX
Definition:
stat_segment.h:29
STAT_COUNTER_VECTOR_RATE
Definition:
stat_segment.h:37
stat_directory_type_t
stat_directory_type_t
Definition:
stat_segment.h:26
stat_segment_offset
static uint64_t stat_segment_offset(void *start, void *data)
Definition:
stat_segment.h:88
STAT_DIR_TYPE_ILLEGAL
Definition:
stat_segment.h:28
stat_segment_main_t::memory_size
ssize_t memory_size
Definition:
stat_segment.h:107
u8
unsigned char u8
Definition:
types.h:56
stat_segment_shared_header_t::in_progress
atomic_int_fast64_t in_progress
Definition:
stat_segment.h:81
STAT_COUNTER_NODE_CLOCKS
Definition:
stat_segment.h:42
stat_segment_directory_entry_t::value
uint64_t value
Definition:
stat_segment.h:66
STAT_COUNTER_INPUT_RATE
Definition:
stat_segment.h:38
stat_segment_main_t::node_counters_enabled
u8 node_counters_enabled
Definition:
stat_segment.h:108
stat_segment_pointer
static void * stat_segment_pointer(void *start, uint64_t offset)
Definition:
stat_segment.h:94
stat_segment_directory_entry_t::offset
uint64_t offset
Definition:
stat_segment.h:64
STAT_COUNTER_HEARTBEAT
Definition:
stat_segment.h:41
stat_segment_counter_t
stat_segment_counter_t
Definition:
stat_segment.h:35
stat_segment_main_t::memfd
int memfd
Definition:
stat_segment.h:111
name
u8 name[64]
Definition:
memclnt.api:151
STAT_COUNTER_LAST_UPDATE
Definition:
stat_segment.h:39
STAT_COUNTER_NODE_VECTORS
Definition:
stat_segment.h:43
stat_segment_main_t::last_input_packets
u64 last_input_packets
Definition:
stat_segment.h:113
vlib.h
stat_segment_directory_entry_t::offset_vector
uint64_t offset_vector
Definition:
stat_segment.h:68
clib_spinlock_t
Definition:
lock.h:45
STAT_DIR_TYPE_COUNTER_VECTOR_SIMPLE
Definition:
stat_segment.h:30
socket.h
stat_segment_main_t
Definition:
stat_segment.h:99
STAT_DIR_TYPE_COUNTER_VECTOR_COMBINED
Definition:
stat_segment.h:31
clib_socket_t
struct _socket_t clib_socket_t
stat_segment_shared_header_t::epoch
atomic_int_fast64_t epoch
Definition:
stat_segment.h:80
STAT_COUNTER_NODE_SUSPENDS
Definition:
stat_segment.h:45
STAT_COUNTER_NODE_CALLS
Definition:
stat_segment.h:44
clib_bihash_value
template key/value backing page structure
Definition:
bihash_doc.h:44
stat_segment_shared_header_t
Definition:
stat_segment.h:78
stat_segment_main_t::directory_vector_by_name
uword * directory_vector_by_name
Definition:
stat_segment.h:102
uword
u64 uword
Definition:
types.h:112
stat_segment_main_t::socket_name
u8 * socket_name
Definition:
stat_segment.h:106
stat_segment_main_t::socket
clib_socket_t * socket
Definition:
stat_segment.h:105
stat_segment_shared_header_t::stats_offset
atomic_int_fast64_t stats_offset
Definition:
stat_segment.h:84
STAT_COUNTERS
Definition:
stat_segment.h:46
stat_segment_shared_header_t::error_offset
atomic_int_fast64_t error_offset
Definition:
stat_segment.h:83
STAT_COUNTER_LAST_STATS_CLEAR
Definition:
stat_segment.h:40
stat_segment_main_t::stat_segment_lockp
clib_spinlock_t * stat_segment_lockp
Definition:
stat_segment.h:104
stat_segment_shared_header_t::directory_offset
atomic_int_fast64_t directory_offset
Definition:
stat_segment.h:82
stat_segment_directory_entry_t::type
stat_directory_type_t type
Definition:
stat_segment.h:62
src
vpp
stats
stat_segment.h
Generated on Thu May 16 2019 14:27:08 for FD.io VPP by
1.8.11