FD.io VPP
v19.01.3-6-g70449b9b9
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 <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_INPUT_RATE
,
28
STAT_COUNTER_LAST_UPDATE
,
29
STAT_COUNTER_LAST_STATS_CLEAR
,
30
STAT_COUNTER_HEARTBEAT
,
31
STAT_COUNTER_NODE_CLOCKS
,
32
STAT_COUNTER_NODE_VECTORS
,
33
STAT_COUNTER_NODE_CALLS
,
34
STAT_COUNTER_NODE_SUSPENDS
,
35
STAT_COUNTERS
36
}
stat_segment_counter_t
;
37
38
#define foreach_stat_segment_counter_name \
39
_(VECTOR_RATE, SCALAR_INDEX, vector_rate,) \
40
_(INPUT_RATE, SCALAR_INDEX, input_rate,) \
41
_(LAST_UPDATE, SCALAR_INDEX, last_update,) \
42
_(LAST_STATS_CLEAR, SCALAR_INDEX, last_stats_clear,) \
43
_(HEARTBEAT, SCALAR_INDEX, heartbeat,) \
44
_(NODE_CLOCKS, COUNTER_VECTOR_SIMPLE, clocks, /node) \
45
_(NODE_VECTORS, COUNTER_VECTOR_SIMPLE, vectors, /node) \
46
_(NODE_CALLS, COUNTER_VECTOR_SIMPLE, calls, /node) \
47
_(NODE_SUSPENDS, COUNTER_VECTOR_SIMPLE, suspends, /node)
48
49
typedef
struct
50
{
51
stat_directory_type_t
type
;
52
union
{
53
uint64_t
offset
;
54
uint64_t
index
;
55
uint64_t
value
;
56
};
57
uint64_t
offset_vector
;
58
char
name
[128];
// TODO change this to pointer to "somewhere"
59
}
stat_segment_directory_entry_t
;
60
61
/* Default stat segment 32m */
62
#define STAT_SEGMENT_DEFAULT_SIZE (32<<20)
63
64
/*
65
* Shared header first in the shared memory segment.
66
*/
67
typedef
struct
68
{
69
atomic_int_fast64_t
epoch
;
70
atomic_int_fast64_t
in_progress
;
71
atomic_int_fast64_t
directory_offset
;
72
atomic_int_fast64_t
error_offset
;
73
atomic_int_fast64_t
stats_offset
;
74
}
stat_segment_shared_header_t
;
75
76
static
inline
uint64_t
77
stat_segment_offset
(
void
*start,
void
*data)
78
{
79
return
(
char
*) data - (
char
*) start;
80
}
81
82
static
inline
void
*
83
stat_segment_pointer
(
void
*start, uint64_t
offset
)
84
{
85
return
((
char
*) start + offset);
86
}
87
88
typedef
struct
89
{
90
/* statistics segment */
91
uword
*
directory_vector_by_name
;
92
stat_segment_directory_entry_t
*
directory_vector
;
93
clib_spinlock_t
*
stat_segment_lockp
;
94
clib_socket_t
*
socket
;
95
u8
*
socket_name
;
96
ssize_t
memory_size
;
97
u8
node_counters_enabled
;
98
void
*
heap
;
99
stat_segment_shared_header_t
*
shared_header
;
/* pointer to shared memory segment */
100
int
memfd
;
101
102
u64
last_input_packets
;
103
}
stat_segment_main_t
;
104
105
extern
stat_segment_main_t
stat_segment_main
;
106
107
#endif
stat_segment_main_t::heap
void * heap
Definition:
stat_segment.h:98
stat_segment_directory_entry_t
Definition:
stat_segment.h:49
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:99
stat_client.h
stat_segment_directory_entry_t::index
uint64_t index
Definition:
stat_segment.h:54
stat_segment_main_t::directory_vector
stat_segment_directory_entry_t * directory_vector
Definition:
stat_segment.h:92
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:77
stat_segment_main_t::memory_size
ssize_t memory_size
Definition:
stat_segment.h:96
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:70
STAT_COUNTER_NODE_CLOCKS
Definition:
stat_segment.h:31
stat_segment_directory_entry_t::value
uint64_t value
Definition:
stat_segment.h:55
STAT_COUNTER_INPUT_RATE
Definition:
stat_segment.h:27
stat_segment_main_t::node_counters_enabled
u8 node_counters_enabled
Definition:
stat_segment.h:97
stat_segment_pointer
static void * stat_segment_pointer(void *start, uint64_t offset)
Definition:
stat_segment.h:83
stat_segment_directory_entry_t::offset
uint64_t offset
Definition:
stat_segment.h:53
STAT_COUNTER_HEARTBEAT
Definition:
stat_segment.h:30
stat_segment_counter_t
stat_segment_counter_t
Definition:
stat_segment.h:24
stat_segment_main_t::memfd
int memfd
Definition:
stat_segment.h:100
name
u8 name[64]
Definition:
memclnt.api:152
STAT_COUNTER_LAST_UPDATE
Definition:
stat_segment.h:28
STAT_COUNTER_NODE_VECTORS
Definition:
stat_segment.h:32
stat_segment_main_t::last_input_packets
u64 last_input_packets
Definition:
stat_segment.h:102
stat_directory_type_t
stat_directory_type_t
Definition:
stat_client.h:24
vlib.h
stat_segment_directory_entry_t::offset_vector
uint64_t offset_vector
Definition:
stat_segment.h:57
clib_spinlock_t
Definition:
lock.h:45
socket.h
stat_segment_main_t
Definition:
stat_segment.h:88
clib_socket_t
struct _socket_t clib_socket_t
stat_segment_shared_header_t::epoch
atomic_int_fast64_t epoch
Definition:
stat_segment.h:69
STAT_COUNTER_NODE_SUSPENDS
Definition:
stat_segment.h:34
STAT_COUNTER_NODE_CALLS
Definition:
stat_segment.h:33
clib_bihash_value
template key/value backing page structure
Definition:
bihash_doc.h:44
stat_segment_shared_header_t
Definition:
stat_segment.h:67
stat_segment_main_t::directory_vector_by_name
uword * directory_vector_by_name
Definition:
stat_segment.h:91
uword
u64 uword
Definition:
types.h:112
stat_segment_main_t::socket_name
u8 * socket_name
Definition:
stat_segment.h:95
stat_segment_main_t::socket
clib_socket_t * socket
Definition:
stat_segment.h:94
stat_segment_shared_header_t::stats_offset
atomic_int_fast64_t stats_offset
Definition:
stat_segment.h:73
STAT_COUNTERS
Definition:
stat_segment.h:35
stat_segment_shared_header_t::error_offset
atomic_int_fast64_t error_offset
Definition:
stat_segment.h:72
STAT_COUNTER_LAST_STATS_CLEAR
Definition:
stat_segment.h:29
stat_segment_main_t::stat_segment_lockp
clib_spinlock_t * stat_segment_lockp
Definition:
stat_segment.h:93
stat_segment_shared_header_t::directory_offset
atomic_int_fast64_t directory_offset
Definition:
stat_segment.h:71
stat_segment_directory_entry_t::type
stat_directory_type_t type
Definition:
stat_segment.h:51
src
vpp
stats
stat_segment.h
Generated on Sun Dec 8 2019 18:03:41 for FD.io VPP by
1.8.13