| 1 | #ifndef _LTT_CHANNELS_H |
| 2 | #define _LTT_CHANNELS_H |
| 3 | |
| 4 | /* |
| 5 | * Copyright (C) 2008 Mathieu Desnoyers (mathieu.desnoyers@polymtl.ca) |
| 6 | * |
| 7 | * Dynamic tracer channel allocation. |
| 8 | |
| 9 | * Dual LGPL v2.1/GPL v2 license. |
| 10 | */ |
| 11 | |
| 12 | #include <linux/limits.h> |
| 13 | #include <linux/kref.h> |
| 14 | #include <linux/list.h> |
| 15 | #include <linux/timer.h> |
| 16 | #include <linux/ltt-core.h> |
| 17 | |
| 18 | #define EVENTS_PER_CHANNEL 65536 |
| 19 | |
| 20 | #define LTT_READ_TIMER_INTERVAL 10000 /* us */ |
| 21 | |
| 22 | /* |
| 23 | * Forward declaration of locking-specific per-cpu buffer structure. |
| 24 | */ |
| 25 | struct ltt_trace; |
| 26 | struct ltt_serialize_closure; |
| 27 | struct ltt_probe_private_data; |
| 28 | |
| 29 | /* Serialization callback '%k' */ |
| 30 | typedef size_t (*ltt_serialize_cb)(struct ltt_chanbuf *buf, size_t buf_offset, |
| 31 | struct ltt_serialize_closure *closure, |
| 32 | void *serialize_private, |
| 33 | unsigned int stack_pos_ctx, |
| 34 | int *largest_align, |
| 35 | const char *fmt, va_list *args); |
| 36 | |
| 37 | struct ltt_probe_private_data { |
| 38 | struct ltt_trace *trace; /* |
| 39 | * Target trace, for metadata |
| 40 | * or statedump. |
| 41 | */ |
| 42 | ltt_serialize_cb serializer; /* |
| 43 | * Serialization function override. |
| 44 | */ |
| 45 | void *serialize_private; /* |
| 46 | * Private data for serialization |
| 47 | * functions. |
| 48 | */ |
| 49 | }; |
| 50 | |
| 51 | struct ltt_channel_setting { |
| 52 | unsigned int sb_size; |
| 53 | unsigned int n_sb; |
| 54 | int overwrite; |
| 55 | unsigned long switch_timer_interval; |
| 56 | unsigned long read_timer_interval; |
| 57 | struct kref kref; /* Number of references to structure content */ |
| 58 | struct list_head list; |
| 59 | unsigned int index; /* index of channel in trace channel array */ |
| 60 | u16 free_event_id; /* Next event ID to allocate */ |
| 61 | char name[PATH_MAX]; |
| 62 | }; |
| 63 | |
| 64 | int ltt_channels_register(const char *name); |
| 65 | int ltt_channels_unregister(const char *name, int compacting); |
| 66 | int ltt_channels_set_default(const char *name, |
| 67 | unsigned int subbuf_size, |
| 68 | unsigned int subbuf_cnt); |
| 69 | const char *ltt_channels_get_name_from_index(unsigned int index); |
| 70 | int ltt_channels_get_index_from_name(const char *name); |
| 71 | int ltt_channels_trace_ref(void); |
| 72 | struct ltt_chan *ltt_channels_trace_alloc(unsigned int *nr_channels, |
| 73 | int overwrite, int active); |
| 74 | void ltt_channels_trace_free(struct ltt_chan *channels, |
| 75 | unsigned int nr_channels); |
| 76 | void ltt_channels_trace_set_timer(struct ltt_channel_setting *chan, |
| 77 | unsigned long interval); |
| 78 | |
| 79 | int _ltt_channels_get_event_id(const char *channel, const char *name); |
| 80 | int ltt_channels_get_event_id(const char *channel, const char *name); |
| 81 | void _ltt_channels_reset_event_ids(void); |
| 82 | |
| 83 | #endif /* _LTT_CHANNELS_H */ |