FD.io VPP  v19.04.4-rc0-5-ge88582fac
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>
23 
24 typedef enum
25 {
41 
42 #define foreach_stat_segment_counter_name \
43  _(VECTOR_RATE, SCALAR_INDEX, vector_rate, /sys) \
44  _(VECTOR_RATE_PER_WORKER, COUNTER_VECTOR_SIMPLE, \
45  vector_rate_per_worker, /sys) \
46  _(NUM_WORKER_THREADS, SCALAR_INDEX, num_worker_threads, /sys) \
47  _(INPUT_RATE, SCALAR_INDEX, input_rate, /sys) \
48  _(LAST_UPDATE, SCALAR_INDEX, last_update, /sys) \
49  _(LAST_STATS_CLEAR, SCALAR_INDEX, last_stats_clear, /sys) \
50  _(HEARTBEAT, SCALAR_INDEX, heartbeat, /sys) \
51  _(NODE_CLOCKS, COUNTER_VECTOR_SIMPLE, clocks, /sys/node) \
52  _(NODE_VECTORS, COUNTER_VECTOR_SIMPLE, vectors, /sys/node) \
53  _(NODE_CALLS, COUNTER_VECTOR_SIMPLE, calls, /sys/node) \
54  _(NODE_SUSPENDS, COUNTER_VECTOR_SIMPLE, suspends, /sys/node) \
55  _(INTERFACE_NAMES, NAME_VECTOR, names, /if) \
56  _(NODE_NAMES, NAME_VECTOR, names, /sys/node)
57 
58 typedef struct
59 {
61  union {
62  uint64_t offset;
63  uint64_t index;
64  uint64_t value;
65  };
66  uint64_t offset_vector;
67  char name[128]; // TODO change this to pointer to "somewhere"
69 
70 /* Default stat segment 32m */
71 #define STAT_SEGMENT_DEFAULT_SIZE (32<<20)
72 
73 /*
74  * Shared header first in the shared memory segment.
75  */
76 typedef struct
77 {
78  atomic_int_fast64_t epoch;
79  atomic_int_fast64_t in_progress;
80  atomic_int_fast64_t directory_offset;
81  atomic_int_fast64_t error_offset;
82  atomic_int_fast64_t stats_offset;
84 
85 static inline uint64_t
86 stat_segment_offset (void *start, void *data)
87 {
88  return (char *) data - (char *) start;
89 }
90 
91 static inline void *
92 stat_segment_pointer (void *start, uint64_t offset)
93 {
94  return ((char *) start + offset);
95 }
96 
98 
99 typedef struct {
104 
105 typedef struct
106 {
107  /* internal, does not point to shared memory */
109 
110  /* statistics segment */
115 
119  ssize_t memory_size;
121  void *last;
122  void *heap;
123  stat_segment_shared_header_t *shared_header; /* pointer to shared memory segment */
124  int memfd;
125 
126  u64 last_input_packets; // OLE REMOVE?
128 
130 
131 clib_error_t *
132 stat_segment_register_gauge (u8 *names, stat_segment_update_fn update_fn, u32 index);
133 
134 #endif
Definition: stat_segment.h:58
stat_segment_main_t stat_segment_main
Definition: stat_segment.c:25
stat_segment_gauges_pool_t * gauges
Definition: stat_segment.h:108
stat_segment_shared_header_t * shared_header
Definition: stat_segment.h:123
uint64_t index
Definition: stat_segment.h:63
stat_segment_directory_entry_t * directory_vector
Definition: stat_segment.h:112
unsigned long u64
Definition: types.h:89
static uint64_t stat_segment_offset(void *start, void *data)
Definition: stat_segment.h:86
clib_error_t * stat_segment_register_gauge(u8 *names, stat_segment_update_fn update_fn, u32 index)
Definition: stat_segment.c:714
int i
u8 data[128]
Definition: ipsec.api:248
unsigned char u8
Definition: types.h:56
void(* stat_segment_update_fn)(stat_segment_directory_entry_t *e, u32 i)
Definition: stat_segment.h:97
atomic_int_fast64_t in_progress
Definition: stat_segment.h:79
uint64_t value
Definition: stat_segment.h:64
stat_segment_update_fn fn
Definition: stat_segment.h:101
unsigned int u32
Definition: types.h:88
static void * stat_segment_pointer(void *start, uint64_t offset)
Definition: stat_segment.h:92
uint64_t offset
Definition: stat_segment.h:62
stat_segment_counter_t
Definition: stat_segment.h:24
u8 name[64]
Definition: memclnt.api:152
stat_directory_type_t
Definition: stat_client.h:27
uint64_t offset_vector
Definition: stat_segment.h:66
struct _socket_t clib_socket_t
atomic_int_fast64_t epoch
Definition: stat_segment.h:78
template key/value backing page structure
Definition: bihash_doc.h:44
uword * directory_vector_by_name
Definition: stat_segment.h:111
u64 uword
Definition: types.h:112
clib_socket_t * socket
Definition: stat_segment.h:117
atomic_int_fast64_t stats_offset
Definition: stat_segment.h:82
atomic_int_fast64_t error_offset
Definition: stat_segment.h:81
clib_spinlock_t * stat_segment_lockp
Definition: stat_segment.h:116
atomic_int_fast64_t directory_offset
Definition: stat_segment.h:80
stat_directory_type_t type
Definition: stat_segment.h:60