SoW-2020-0003: Trace Hit Counters
[lttng-tools.git] / include / lttng / map / map-internal.h
CommitLineData
ebdb334b
JR
1/*
2 * Copyright (C) 2020 Francis Deslauriers <francis.deslauriers@efficios.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.1-only
5 *
6 */
7
8#ifndef LTTNG_MAP_INTERNAL_H
9#define LTTNG_MAP_INTERNAL_H
10
11#include <common/macros.h>
12#include <common/optional.h>
13#include <common/payload.h>
14#include <common/payload-view.h>
15#include <urcu/ref.h>
16
17#include "map.h"
18
19struct lttng_payload;
20struct lttng_payload_view;
21
22struct lttng_map {
23 /* Reference counting is only exposed to internal users. */
24 struct urcu_ref ref;
25
26 char *name;
27 LTTNG_OPTIONAL(bool) is_enabled;
28 enum lttng_map_bitness bitness;
29 enum lttng_map_boundary_policy boundary_policy;
30 enum lttng_domain_type domain;
31 enum lttng_buffer_type buffer_type;
32 bool coalesce_hits;
33 unsigned int dimension_count;
34 uint64_t *dimension_sizes;
35};
36
37struct lttng_map_list {
38 struct lttng_dynamic_pointer_array array;
39};
40
41struct lttng_map_key_value_pair {
42 char *key;
43 int64_t value;
44 bool has_overflowed;
45 bool has_underflowed;
46};
47
48struct lttng_map_key_value_pair_list {
49 enum lttng_map_key_value_pair_list_type type;
50 uint64_t id; /* pid_t or uid_t */
51 uint64_t cpu;
52 bool summed_all_cpus;
53 struct lttng_dynamic_pointer_array array;
54};
55
56struct lttng_map_content {
57 enum lttng_buffer_type type;
58 struct lttng_dynamic_pointer_array array;
59};
60
61struct lttng_map_comm {
62 uint32_t name_length /* Includes '\0' */;
63 uint32_t length;
64 uint8_t is_enabled;
65 uint8_t bitness;
66 uint8_t boundary_policy;
67 uint8_t domain;
68 uint8_t buffer_type;
69 uint8_t coalesce_hits;;
70 uint64_t dimension_count;
71
72 /* length excludes its own length. */
73 /* A name and dimension sizes follow. */
74 char payload[];
75} LTTNG_PACKED;
76
77struct lttng_map_list_comm {
78 uint32_t count;
79 /* Count * lttng_map_comm structure */
80 char payload[];
81} LTTNG_PACKED;
82
83struct lttng_map_key_value_pair_comm {
84 uint32_t key_length /* Includes '\0' */;
85 int64_t value;
86 uint8_t has_overflowed;
87 uint8_t has_underflowed;
88} LTTNG_PACKED;
89
90struct lttng_map_key_value_pair_list_comm {
91 uint32_t count;
92 uint8_t type; /* enum lttng_map_key_value_pair_list_type */
93 uint64_t id; /* pid_t or uid_t */
94 uint64_t cpu;
95 uint8_t summed_all_cpus;
96 /* Count * lttng_map_key_value_pair_comm structure */
97 char payload[];
98} LTTNG_PACKED;
99
100struct lttng_map_content_comm {
101 uint32_t count;
102 uint8_t type; /* enum lttng_buffer_type */
103 /* Count * lttng_map_key_value_pair_list structure */
104 char payload[];
105};
106
107LTTNG_HIDDEN
108ssize_t lttng_map_create_from_payload(struct lttng_payload_view *view,
109 struct lttng_map **map);
110
111LTTNG_HIDDEN
112int lttng_map_serialize(const struct lttng_map *map,
113 struct lttng_payload *payload);
114
115LTTNG_HIDDEN
116void lttng_map_get(struct lttng_map *map);
117
118LTTNG_HIDDEN
119void lttng_map_put(struct lttng_map *map);
120
121LTTNG_HIDDEN
122void lttng_map_set_is_enabled(struct lttng_map *map, bool enabled);
123
124/*
125 * Allocate a new list of maps.
126 * The returned object must be freed via lttng_map_list_destroy.
127 */
128LTTNG_HIDDEN
129struct lttng_map_list *lttng_map_list_create(void);
130
131/*
132 * Add a map to the maps set.
133 *
134 * A reference to the added map is acquired on behalf of the map set
135 * on success.
136 */
137LTTNG_HIDDEN
138enum lttng_map_status lttng_map_list_add(struct lttng_map_list *map_list,
139 struct lttng_map *map);
140
141LTTNG_HIDDEN
142ssize_t lttng_map_list_create_from_payload(struct lttng_payload_view *view,
143 struct lttng_map_list **map_list);
144
145/*
146 * Serialize a map list to an lttng_payload object.
147 * Return LTTNG_OK on success, negative lttng error code on error.
148 */
149LTTNG_HIDDEN
150int lttng_map_list_serialize(const struct lttng_map_list *map_list,
151 struct lttng_payload *payload);
152
153LTTNG_HIDDEN
154struct lttng_map_key_value_pair *lttng_map_key_value_pair_create(
155 const char *key, int64_t value);
156
157LTTNG_HIDDEN
158void lttng_map_key_value_pair_set_has_overflowed(
159 struct lttng_map_key_value_pair *key_value);
160
161LTTNG_HIDDEN
162void lttng_map_key_value_pair_set_has_underflowed(
163 struct lttng_map_key_value_pair *key_value);
164
165LTTNG_HIDDEN
166ssize_t lttng_map_key_value_pair_create_from_payload(
167 struct lttng_payload_view *view,
168 struct lttng_map_key_value_pair **key_value);
169
170LTTNG_HIDDEN
171int lttng_map_key_value_pair_serialize(
172 const struct lttng_map_key_value_pair *key_value,
173 struct lttng_payload *payload);
174
175LTTNG_HIDDEN
176void lttng_map_key_value_pair_destroy(
177 struct lttng_map_key_value_pair *key_value);
178
179LTTNG_HIDDEN
180struct lttng_map_key_value_pair_list *lttng_map_key_value_pair_list_create(
181 enum lttng_map_key_value_pair_list_type type,
182 bool summed_all_cpus);
183
184LTTNG_HIDDEN
185enum lttng_map_status lttng_map_key_value_pair_list_set_identifier(
186 struct lttng_map_key_value_pair_list *kv_pair_list,
187 uint64_t identifier);
188
189LTTNG_HIDDEN
190enum lttng_map_status lttng_map_key_value_pair_list_set_cpu(
191 struct lttng_map_key_value_pair_list *kv_pair_list,
192 uint64_t cpu);
193
194LTTNG_HIDDEN
195enum lttng_map_status lttng_map_key_value_pair_list_append_key_value(
196 struct lttng_map_key_value_pair_list *key_values,
197 struct lttng_map_key_value_pair *key_value);
198
199LTTNG_HIDDEN
200ssize_t lttng_map_key_value_pair_list_create_from_payload(
201 struct lttng_payload_view *view,
202 struct lttng_map_key_value_pair_list **key_values);
203
204LTTNG_HIDDEN
205int lttng_map_key_value_pair_list_serialize(
206 const struct lttng_map_key_value_pair_list *key_values,
207 struct lttng_payload *payload);
208
209LTTNG_HIDDEN
210struct lttng_map_content *lttng_map_content_create(
211 enum lttng_buffer_type type);
212
213LTTNG_HIDDEN
214enum lttng_map_status lttng_map_content_append_key_value_list(
215 struct lttng_map_content *map_content,
216 struct lttng_map_key_value_pair_list *kv_list);
217
218LTTNG_HIDDEN
219ssize_t lttng_map_content_create_from_payload(
220 struct lttng_payload_view *view,
221 struct lttng_map_content **map_content);
222
223LTTNG_HIDDEN
224int lttng_map_content_serialize(
225 const struct lttng_map_content *map_content,
226 struct lttng_payload *payload);
227
228#endif /* LTTNG_MAP_INTERNAL_H */
This page took 0.031157 seconds and 5 git commands to generate.