stats: refactor
[vpp.git] / src / vlib / stats / shared.h
1 /* SPDX-License-Identifier: Apache-2.0
2  * Copyright(c) 2022 Cisco Systems, Inc.
3  */
4
5 #ifndef included_stat_segment_shared_h
6 #define included_stat_segment_shared_h
7
8 typedef enum
9 {
10   STAT_DIR_TYPE_ILLEGAL = 0,
11   STAT_DIR_TYPE_SCALAR_INDEX,
12   STAT_DIR_TYPE_COUNTER_VECTOR_SIMPLE,
13   STAT_DIR_TYPE_COUNTER_VECTOR_COMBINED,
14   STAT_DIR_TYPE_ERROR_INDEX,
15   STAT_DIR_TYPE_NAME_VECTOR,
16   STAT_DIR_TYPE_EMPTY,
17   STAT_DIR_TYPE_SYMLINK,
18 } stat_directory_type_t;
19
20 typedef struct
21 {
22   stat_directory_type_t type;
23   union
24   {
25     struct
26     {
27       uint32_t index1;
28       uint32_t index2;
29     };
30     uint64_t index;
31     uint64_t value;
32     void *data;
33     uint8_t **string_vector;
34   };
35 #define VLIB_STATS_MAX_NAME_SZ 128
36   char name[VLIB_STATS_MAX_NAME_SZ];
37 } vlib_stats_entry_t;
38
39 /*
40  * Shared header first in the shared memory segment.
41  */
42 typedef struct
43 {
44   uint64_t version;
45   void *base;
46   volatile uint64_t epoch;
47   volatile uint64_t in_progress;
48   volatile vlib_stats_entry_t *directory_vector;
49   volatile uint64_t **error_vector;
50 } vlib_stats_shared_header_t;
51
52 #endif /* included_stat_segment_shared_h */