2 * ltt/ltt-event-header.c
4 * (C) Copyright 2010 - Mathieu Desnoyers (mathieu.desnoyers@efficios.com)
9 * Mathieu Desnoyers (mathieu.desnoyers@efficios.com)
11 * Dual LGPL v2.1/GPL v2 license.
14 #include <linux/module.h>
15 #include "ltt-tracer.h"
17 void ltt_write_event_header_slow(const struct lib_ring_buffer_config
*config
,
18 struct lib_ring_buffer_ctx
*ctx
,
19 u16 eID
, u32 event_size
)
21 struct event_header header
;
24 switch (ctx
->rflags
) {
25 case LTT_RFLAG_ID_SIZE_TSC
:
26 header
.id_time
= 29 << LTT_TSC_BITS
;
28 case LTT_RFLAG_ID_SIZE
:
29 header
.id_time
= 30 << LTT_TSC_BITS
;
32 header
.id_time
= 31 << LTT_TSC_BITS
;
39 header
.id_time
|= (u32
)ctx
->tsc
& LTT_TSC_MASK
;
40 lib_ring_buffer_write(config
, ctx
, &header
, sizeof(header
));
42 switch (ctx
->rflags
) {
43 case LTT_RFLAG_ID_SIZE_TSC
:
44 small_size
= (u16
)min_t(u32
, event_size
, LTT_MAX_SMALL_SIZE
);
45 lib_ring_buffer_write(config
, ctx
, &eID
, sizeof(u16
));
46 lib_ring_buffer_write(config
, ctx
, &small_size
, sizeof(u16
));
47 if (small_size
== LTT_MAX_SMALL_SIZE
)
48 lib_ring_buffer_write(config
, ctx
, &event_size
,
50 lib_ring_buffer_align_ctx(ctx
, sizeof(u64
));
51 lib_ring_buffer_write(config
, ctx
, &ctx
->tsc
, sizeof(u64
));
53 case LTT_RFLAG_ID_SIZE
:
54 small_size
= (u16
)min_t(u32
, event_size
, LTT_MAX_SMALL_SIZE
);
55 lib_ring_buffer_write(config
, ctx
, &eID
, sizeof(u16
));
56 lib_ring_buffer_write(config
, ctx
, &small_size
, sizeof(u16
));
57 if (small_size
== LTT_MAX_SMALL_SIZE
)
58 lib_ring_buffer_write(config
, ctx
, &event_size
,
62 lib_ring_buffer_write(config
, ctx
, &eID
, sizeof(u16
));
66 EXPORT_SYMBOL_GPL(ltt_write_event_header_slow
);