| 1 | /* |
| 2 | * Copyright (C) 2014 - David Goulet <dgoulet@efficios.com> |
| 3 | * |
| 4 | * This library is free software; you can redistribute it and/or modify it |
| 5 | * under the terms of the GNU Lesser General Public License, version 2.1 only, |
| 6 | * as published by the Free Software Foundation. |
| 7 | * |
| 8 | * This library is distributed in the hope that it will be useful, but WITHOUT |
| 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License |
| 11 | * for more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU Lesser General Public License |
| 14 | * along with this library; if not, write to the Free Software Foundation, |
| 15 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 16 | */ |
| 17 | |
| 18 | #ifndef LTTNG_CHANNEL_H |
| 19 | #define LTTNG_CHANNEL_H |
| 20 | |
| 21 | #include <lttng/domain.h> |
| 22 | #include <lttng/event.h> |
| 23 | #include <stdint.h> |
| 24 | |
| 25 | #ifdef __cplusplus |
| 26 | extern "C" { |
| 27 | #endif |
| 28 | |
| 29 | /* |
| 30 | * Tracer channel attributes. For both kernel and user-space. |
| 31 | * |
| 32 | * The structures should be initialized to zero before use. |
| 33 | */ |
| 34 | #define LTTNG_CHANNEL_ATTR_PADDING1 LTTNG_SYMBOL_NAME_LEN + 12 |
| 35 | struct lttng_channel_attr { |
| 36 | int overwrite; /* -1: session default, 1: overwrite, 0: discard */ |
| 37 | uint64_t subbuf_size; /* bytes, power of 2 */ |
| 38 | uint64_t num_subbuf; /* power of 2 */ |
| 39 | unsigned int switch_timer_interval; /* usec */ |
| 40 | unsigned int read_timer_interval; /* usec */ |
| 41 | enum lttng_event_output output; /* splice, mmap */ |
| 42 | /* LTTng 2.1 padding limit */ |
| 43 | uint64_t tracefile_size; /* bytes */ |
| 44 | uint64_t tracefile_count; /* number of tracefiles */ |
| 45 | /* LTTng 2.3 padding limit */ |
| 46 | unsigned int live_timer_interval; /* usec */ |
| 47 | /* LTTng 2.7 padding limit */ |
| 48 | uint32_t align_to_64; |
| 49 | union { |
| 50 | uint64_t padding; |
| 51 | void *ptr; |
| 52 | } extended; |
| 53 | |
| 54 | char padding[LTTNG_CHANNEL_ATTR_PADDING1]; |
| 55 | }; |
| 56 | |
| 57 | /* |
| 58 | * Channel information structure. For both kernel and user-space. |
| 59 | * |
| 60 | * The structures should be initialized to zero before use. |
| 61 | */ |
| 62 | #define LTTNG_CHANNEL_PADDING1 16 |
| 63 | struct lttng_channel { |
| 64 | char name[LTTNG_SYMBOL_NAME_LEN]; |
| 65 | uint32_t enabled; |
| 66 | struct lttng_channel_attr attr; |
| 67 | |
| 68 | char padding[LTTNG_CHANNEL_PADDING1]; |
| 69 | }; |
| 70 | |
| 71 | /* |
| 72 | */ |
| 73 | extern struct lttng_channel *lttng_channel_create(struct lttng_domain *domain); |
| 74 | |
| 75 | /* |
| 76 | */ |
| 77 | extern void lttng_channel_destroy(struct lttng_channel *channel); |
| 78 | |
| 79 | /* |
| 80 | * List the channel(s) of a session. |
| 81 | * |
| 82 | * The handle CAN NOT be NULL. |
| 83 | * |
| 84 | * Return the size (number of entries) of the "lttng_channel" array. Caller |
| 85 | * must free channels. On error, a negative LTTng error code is returned. |
| 86 | */ |
| 87 | extern int lttng_list_channels(struct lttng_handle *handle, |
| 88 | struct lttng_channel **channels); |
| 89 | |
| 90 | /* |
| 91 | * Create or enable a channel. |
| 92 | * |
| 93 | * The chan and handle params can not be NULL. |
| 94 | * |
| 95 | * Return 0 on success else a negative LTTng error code. |
| 96 | */ |
| 97 | extern int lttng_enable_channel(struct lttng_handle *handle, |
| 98 | struct lttng_channel *chan); |
| 99 | |
| 100 | /* |
| 101 | * Disable channel. |
| 102 | * |
| 103 | * Name and handle CAN NOT be NULL. |
| 104 | * |
| 105 | * Return 0 on success else a negative LTTng error code. |
| 106 | */ |
| 107 | extern int lttng_disable_channel(struct lttng_handle *handle, |
| 108 | const char *name); |
| 109 | |
| 110 | /* |
| 111 | * Set the default channel attributes for a specific domain and an allocated |
| 112 | * lttng_channel_attr pointer. |
| 113 | * |
| 114 | * If one or both arguments are NULL, nothing happens. |
| 115 | */ |
| 116 | extern void lttng_channel_set_default_attr(struct lttng_domain *domain, |
| 117 | struct lttng_channel_attr *attr); |
| 118 | |
| 119 | /* |
| 120 | * Get the discarded event count of a specific LTTng channel. |
| 121 | * |
| 122 | * Returns 0 on success, or a negative LTTng error code on error. |
| 123 | */ |
| 124 | extern int lttng_channel_get_discarded_event_count(struct lttng_channel *chan, |
| 125 | uint64_t *discarded_events); |
| 126 | |
| 127 | /* |
| 128 | * Get the lost packet count of a specific LTTng channel. |
| 129 | * |
| 130 | * Returns 0 on success, or a negative LTTng error code on error. |
| 131 | */ |
| 132 | extern int lttng_channel_get_lost_packet_count(struct lttng_channel *chan, |
| 133 | uint64_t *lost_packets); |
| 134 | |
| 135 | extern int lttng_channel_get_monitor_timer_interval(struct lttng_channel *chan, |
| 136 | uint64_t *monitor_timer_interval); |
| 137 | |
| 138 | extern int lttng_channel_set_monitor_timer_interval(struct lttng_channel *chan, |
| 139 | uint64_t monitor_timer_interval); |
| 140 | |
| 141 | extern int lttng_channel_get_blocking_timeout(struct lttng_channel *chan, |
| 142 | int64_t *blocking_timeout); |
| 143 | |
| 144 | extern int lttng_channel_set_blocking_timeout(struct lttng_channel *chan, |
| 145 | int64_t blocking_timeout); |
| 146 | |
| 147 | #ifdef __cplusplus |
| 148 | } |
| 149 | #endif |
| 150 | |
| 151 | #endif /* LTTNG_CHANNEL_H */ |