FD.io VPP  v20.01-48-g3e0dafb74
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 {
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 static inline uint64_t
68 stat_segment_offset (void *start, void *data)
69 {
70  return (char *) data - (char *) start;
71 }
72 
74 
75 typedef struct {
80 
81 typedef struct
82 {
83  /* internal, does not point to shared memory */
85 
86  /* statistics segment */
91  u8 **nodes;
92 
93  /* Update interval */
95 
99  ssize_t memory_size;
101  void *last;
102  void *heap;
103  stat_segment_shared_header_t *shared_header; /* pointer to shared memory segment */
104  int memfd;
105 
106  u64 last_input_packets; // OLE REMOVE?
108 
110 
111 clib_error_t *
112 stat_segment_register_gauge (u8 *names, stat_segment_update_fn update_fn, u32 index);
113 clib_error_t *
115 clib_error_t *
118 
119 #endif
clib_error_t * stat_segment_register_state_counter(u8 *name, u32 *index)
Definition: stat_segment.c:796
stat_segment_main_t stat_segment_main
Definition: stat_segment.c:27
stat_segment_gauges_pool_t * gauges
Definition: stat_segment.h:84
stat_segment_shared_header_t * shared_header
Definition: stat_segment.h:103
stat_segment_directory_entry_t * directory_vector
Definition: stat_segment.h:88
unsigned long u64
Definition: types.h:89
static uint64_t stat_segment_offset(void *start, void *data)
Definition: stat_segment.h:68
clib_error_t * stat_segment_register_gauge(u8 *names, stat_segment_update_fn update_fn, u32 index)
Definition: stat_segment.c:753
int i
void stat_segment_set_state_counter(u32 index, u64 value)
Definition: stat_segment.c:854
unsigned char u8
Definition: types.h:56
void(* stat_segment_update_fn)(stat_segment_directory_entry_t *e, u32 i)
Definition: stat_segment.h:73
double f64
Definition: types.h:142
clib_error_t * stat_segment_deregister_state_counter(u32 index)
Definition: stat_segment.c:833
stat_segment_update_fn fn
Definition: stat_segment.h:77
unsigned int u32
Definition: types.h:88
stat_segment_counter_t
Definition: stat_segment.h:23
string name[64]
Definition: ip.api:44
u8 value
Definition: qos.api:54
u8 data[128]
Definition: ipsec_types.api:87
struct _socket_t clib_socket_t
uword * directory_vector_by_name
Definition: stat_segment.h:87
u64 uword
Definition: types.h:112
clib_socket_t * socket
Definition: stat_segment.h:97
clib_spinlock_t * stat_segment_lockp
Definition: stat_segment.h:96