Commit | Line | Data |
---|---|---|
a58c490f | 1 | /* |
ab5be9fa | 2 | * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com> |
a58c490f | 3 | * |
ab5be9fa | 4 | * SPDX-License-Identifier: LGPL-2.1-only |
a58c490f | 5 | * |
a58c490f JG |
6 | */ |
7 | ||
8 | #ifndef LTTNG_ACTION_INTERNAL_H | |
9 | #define LTTNG_ACTION_INTERNAL_H | |
10 | ||
11 | #include <lttng/action/action.h> | |
12 | #include <common/macros.h> | |
13 | #include <common/buffer-view.h> | |
3647288f | 14 | #include <common/dynamic-buffer.h> |
9e620ea7 JG |
15 | #include <common/payload-view.h> |
16 | #include <common/payload.h> | |
a58c490f | 17 | #include <stdbool.h> |
72756a3f | 18 | #include <sys/types.h> |
c852ce4e | 19 | #include <urcu/ref.h> |
a58c490f | 20 | |
7f4d5b07 | 21 | struct lttng_rate_policy; |
2d57482c | 22 | |
a58c490f JG |
23 | typedef bool (*action_validate_cb)(struct lttng_action *action); |
24 | typedef void (*action_destroy_cb)(struct lttng_action *action); | |
3647288f | 25 | typedef int (*action_serialize_cb)(struct lttng_action *action, |
c0a66c84 | 26 | struct lttng_payload *payload); |
3dd04a6a JR |
27 | typedef bool (*action_equal_cb)(const struct lttng_action *a, |
28 | const struct lttng_action *b); | |
c0a66c84 JG |
29 | typedef ssize_t (*action_create_from_payload_cb)( |
30 | struct lttng_payload_view *view, | |
869a3c2d | 31 | struct lttng_action **action); |
7f4d5b07 | 32 | typedef const struct lttng_rate_policy *(*action_get_rate_policy_cb)( |
2d57482c | 33 | const struct lttng_action *action); |
a58c490f JG |
34 | |
35 | struct lttng_action { | |
c852ce4e | 36 | struct urcu_ref ref; |
a58c490f JG |
37 | enum lttng_action_type type; |
38 | action_validate_cb validate; | |
39 | action_serialize_cb serialize; | |
3dd04a6a | 40 | action_equal_cb equal; |
a58c490f | 41 | action_destroy_cb destroy; |
7f4d5b07 | 42 | action_get_rate_policy_cb get_rate_policy; |
2d57482c JR |
43 | |
44 | /* Internal use only. */ | |
45 | ||
46 | /* The number of time the actions was enqueued for execution. */ | |
47 | uint64_t execution_request_counter; | |
48 | /* | |
49 | * The number of time the action was actually executed. | |
7f4d5b07 | 50 | * Action rate policy can impact on this number. |
2d57482c JR |
51 | * */ |
52 | uint64_t execution_counter; | |
53 | /* | |
54 | * The number of time the action execution failed. | |
55 | */ | |
56 | uint64_t execution_failure_counter; | |
a58c490f JG |
57 | }; |
58 | ||
59 | struct lttng_action_comm { | |
60 | /* enum lttng_action_type */ | |
61 | int8_t action_type; | |
62 | } LTTNG_PACKED; | |
63 | ||
6acb3f46 SM |
64 | LTTNG_HIDDEN |
65 | void lttng_action_init(struct lttng_action *action, | |
66 | enum lttng_action_type type, | |
67 | action_validate_cb validate, | |
68 | action_serialize_cb serialize, | |
3dd04a6a | 69 | action_equal_cb equal, |
2d57482c | 70 | action_destroy_cb destroy, |
7f4d5b07 | 71 | action_get_rate_policy_cb get_rate_policy); |
6acb3f46 | 72 | |
a58c490f JG |
73 | LTTNG_HIDDEN |
74 | bool lttng_action_validate(struct lttng_action *action); | |
75 | ||
76 | LTTNG_HIDDEN | |
3647288f | 77 | int lttng_action_serialize(struct lttng_action *action, |
c0a66c84 | 78 | struct lttng_payload *buf); |
a58c490f JG |
79 | |
80 | LTTNG_HIDDEN | |
c0a66c84 | 81 | ssize_t lttng_action_create_from_payload(struct lttng_payload_view *view, |
a58c490f JG |
82 | struct lttng_action **action); |
83 | ||
3dd04a6a JR |
84 | LTTNG_HIDDEN |
85 | bool lttng_action_is_equal(const struct lttng_action *a, | |
86 | const struct lttng_action *b); | |
87 | ||
c852ce4e JG |
88 | LTTNG_HIDDEN |
89 | void lttng_action_get(struct lttng_action *action); | |
90 | ||
91 | LTTNG_HIDDEN | |
92 | void lttng_action_put(struct lttng_action *action); | |
93 | ||
10615eee JR |
94 | LTTNG_HIDDEN |
95 | const char* lttng_action_type_string(enum lttng_action_type action_type); | |
96 | ||
2d57482c JR |
97 | LTTNG_HIDDEN |
98 | void lttng_action_increase_execution_request_count(struct lttng_action *action); | |
99 | ||
100 | LTTNG_HIDDEN | |
101 | void lttng_action_increase_execution_count(struct lttng_action *action); | |
102 | ||
103 | LTTNG_HIDDEN | |
104 | void lttng_action_increase_execution_failure_count(struct lttng_action *action); | |
105 | ||
106 | LTTNG_HIDDEN | |
107 | bool lttng_action_should_execute(const struct lttng_action *action); | |
108 | ||
a58c490f | 109 | #endif /* LTTNG_ACTION_INTERNAL_H */ |