FD.io VPP  v21.06-3-gbb25fbf28
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>
22 
23 typedef enum
24 {
38 
39 /* clang-format off */
40 #define foreach_stat_segment_node_counter_name \
41  _ (NODE_CLOCKS, COUNTER_VECTOR_SIMPLE, clocks, /sys/node) \
42  _ (NODE_VECTORS, COUNTER_VECTOR_SIMPLE, vectors, /sys/node) \
43  _ (NODE_CALLS, COUNTER_VECTOR_SIMPLE, calls, /sys/node) \
44  _ (NODE_SUSPENDS, COUNTER_VECTOR_SIMPLE, suspends, /sys/node)
45 
46 #define foreach_stat_segment_counter_name \
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  _ (INTERFACE_NAMES, NAME_VECTOR, names, /if) \
53  _ (NODE_NAMES, NAME_VECTOR, names, /sys/node) \
54  foreach_stat_segment_node_counter_name
55 /* clang-format on */
56 
57 /* Default stat segment 32m */
58 #define STAT_SEGMENT_DEFAULT_SIZE (32<<20)
59 
60 /* Shared segment memory layout version */
61 #define STAT_SEGMENT_VERSION 2
62 
63 #define STAT_SEGMENT_INDEX_INVALID UINT32_MAX
64 
66 
67 typedef struct {
72 
73 typedef struct
74 {
75  /* internal, does not point to shared memory */
77 
78  /* statistics segment */
81  volatile u64 **error_vector;
83  u8 **nodes;
84 
85  /* Update interval */
87 
91  ssize_t memory_size;
94  void *last;
95  void *heap;
96  stat_segment_shared_header_t *shared_header; /* pointer to shared memory segment */
97  int memfd;
98 
99  u64 last_input_packets; // OLE REMOVE?
101 
103 
104 clib_error_t *
106 clib_error_t *
108 clib_error_t *
111 void stat_segment_poll_add (u32 vector_index, stat_segment_update_fn update_fn,
112  u32 caller_index, u32 interval);
113 
116 void vlib_stat_segment_lock (void);
117 void vlib_stat_segment_unlock (void);
118 void vlib_stats_register_symlink (void *oldheap, u8 *name, u32 index1,
119  u32 index2, u8 lock);
120 
121 void stat_provider_register_vector_rate (u32 num_workers);
122 
123 #endif
vlib.h
stat_segment_register_gauge
clib_error_t * stat_segment_register_gauge(u8 *names, stat_segment_update_fn update_fn, u32 index)
Definition: pnat_test_stubs.h:23
stat_segment_main_t::heap
void * heap
Definition: stat_segment.h:95
STAT_COUNTERS
@ STAT_COUNTERS
Definition: stat_segment.h:36
stat_segment_gauges_pool_t::directory_index
u32 directory_index
Definition: stat_segment.h:68
stat_segment_register_state_counter
clib_error_t * stat_segment_register_state_counter(u8 *name, u32 *index)
Definition: stat_segment.c:922
stat_segment_main_t::memory_size
ssize_t memory_size
Definition: stat_segment.h:91
stat_segment_main_t::shared_header
stat_segment_shared_header_t * shared_header
Definition: stat_segment.h:96
stat_segment_update_fn
void(* stat_segment_update_fn)(stat_segment_directory_entry_t *e, u32 i)
Definition: stat_segment.h:65
name
string name[64]
Definition: fib.api:25
stat_segment_main_t::directory_vector
stat_segment_directory_entry_t * directory_vector
Definition: stat_segment.h:80
stat_segment_gauges_pool_t
Definition: stat_segment.h:67
stat_segment_set_state_counter
void stat_segment_set_state_counter(u32 index, u64 value)
Definition: stat_segment.c:962
stat_segment_poll_add
void stat_segment_poll_add(u32 vector_index, stat_segment_update_fn update_fn, u32 caller_index, u32 interval)
Definition: stat_segment.c:884
vlib_stat_segment_unlock
void vlib_stat_segment_unlock(void)
Definition: stat_segment.c:38
STAT_COUNTER_INTERFACE_NAMES
@ STAT_COUNTER_INTERFACE_NAMES
Definition: stat_segment.h:34
stat_segment_main_t::gauges
stat_segment_gauges_pool_t * gauges
Definition: stat_segment.h:76
STAT_COUNTER_INPUT_RATE
@ STAT_COUNTER_INPUT_RATE
Definition: stat_segment.h:26
STAT_COUNTER_NODE_SUSPENDS
@ STAT_COUNTER_NODE_SUSPENDS
Definition: stat_segment.h:33
stat_directory_type_t
stat_directory_type_t
Definition: stat_segment_shared.h:19
stat_segment_main_t::last
void * last
Definition: stat_segment.h:94
stat_segment_main_t
Definition: stat_segment.h:73
stat_segment_deregister_state_counter
clib_error_t * stat_segment_deregister_state_counter(u32 index)
Definition: stat_segment.c:934
STAT_COUNTER_NODE_NAMES
@ STAT_COUNTER_NODE_NAMES
Definition: stat_segment.h:35
stat_segment_new_entry
u32 stat_segment_new_entry(u8 *name, stat_directory_type_t t)
Definition: stat_segment.c:393
stat_segment_gauges_pool_t::caller_index
u32 caller_index
Definition: stat_segment.h:70
vlib_stat_segment_lock
void vlib_stat_segment_lock(void)
Definition: stat_segment.c:30
stat_segment_main_t::last_input_packets
u64 last_input_packets
Definition: stat_segment.h:99
vlib_stats_register_symlink
void vlib_stats_register_symlink(void *oldheap, u8 *name, u32 index1, u32 index2, u8 lock)
Definition: stat_segment.c:249
STAT_COUNTER_NODE_VECTORS
@ STAT_COUNTER_NODE_VECTORS
Definition: stat_segment.h:31
stat_provider_register_vector_rate
void stat_provider_register_vector_rate(u32 num_workers)
Definition: stat_segment_provider.c:173
clib_spinlock_s
Definition: lock.h:51
uword
u64 uword
Definition: types.h:112
stat_segment_main_t::memfd
int memfd
Definition: stat_segment.h:97
STAT_COUNTER_LAST_UPDATE
@ STAT_COUNTER_LAST_UPDATE
Definition: stat_segment.h:27
i
sll srl srl sll sra u16x4 i
Definition: vector_sse42.h:261
f64
double f64
Definition: types.h:142
STAT_COUNTER_NODE_CALLS
@ STAT_COUNTER_NODE_CALLS
Definition: stat_segment.h:32
interval
u16 interval
Definition: vrrp.api:34
stat_segment_counter_t
stat_segment_counter_t
Definition: stat_segment.h:23
stat_segment_shared_header_t
Definition: stat_segment_shared.h:50
stat_segment_main_t::node_counters_enabled
u8 node_counters_enabled
Definition: stat_segment.h:93
STAT_COUNTER_NUM_WORKER_THREADS
@ STAT_COUNTER_NUM_WORKER_THREADS
Definition: stat_segment.h:25
stat_segment_directory_entry_t
Definition: stat_segment_shared.h:31
index
u32 index
Definition: flow_types.api:221
STAT_COUNTER_LAST_STATS_CLEAR
@ STAT_COUNTER_LAST_STATS_CLEAR
Definition: stat_segment.h:28
STAT_COUNTER_HEARTBEAT
@ STAT_COUNTER_HEARTBEAT
Definition: stat_segment.h:29
u64
unsigned long u64
Definition: types.h:89
stat_segment_main_t::socket
clib_socket_t * socket
Definition: stat_segment.h:89
stat_segment_gauges_pool_t::fn
stat_segment_update_fn fn
Definition: stat_segment.h:69
u32
unsigned int u32
Definition: types.h:88
stat_segment_main_t::nodes
u8 ** nodes
Definition: stat_segment.h:83
value
u8 value
Definition: qos.api:54
stat_segment_main_t::update_interval
f64 update_interval
Definition: stat_segment.h:86
stat_segment_main_t::directory_vector_by_name
uword * directory_vector_by_name
Definition: stat_segment.h:79
stat_segment_main_t::socket_name
u8 * socket_name
Definition: stat_segment.h:90
clib_mem_page_sz_t
clib_mem_page_sz_t
Definition: mem.h:57
u8
unsigned char u8
Definition: types.h:56
clib_error_t
Definition: clib_error.h:21
stat_segment_shared.h
stat_segment_main_t::log2_page_sz
clib_mem_page_sz_t log2_page_sz
Definition: stat_segment.h:92
stat_segment_main_t::interfaces
u8 ** interfaces
Definition: stat_segment.h:82
socket.h
clib_socket_t
struct _socket_t clib_socket_t
stat_segment_main
stat_segment_main_t stat_segment_main
Definition: stat_segment.c:24
vlib_stats_register_mem_heap
void vlib_stats_register_mem_heap(clib_mem_heap_t *heap)
Definition: stat_segment_provider.c:84
STAT_COUNTER_NODE_CLOCKS
@ STAT_COUNTER_NODE_CLOCKS
Definition: stat_segment.h:30
clib_mem_heap_t
Definition: mem.h:107
stat_segment_main_t::error_vector
volatile u64 ** error_vector
Definition: stat_segment.h:81
stat_segment_main_t::stat_segment_lockp
clib_spinlock_t * stat_segment_lockp
Definition: stat_segment.h:88