|
FD.io VPP
v21.06-3-gbb25fbf28
Vector Packet Processing
|
Go to the documentation of this file.
49 #ifndef included_clib_elog_h
50 #define included_clib_elog_h
110 char *enum_strings[];
299 word type_index, track_index;
305 type_index = (
word)
type->type_index_plus_one - 1;
328 e->
track = track_index;
439 #define __ELOG_TYPE_VAR(f) f
440 #define __ELOG_TRACK_VAR(f) f
442 #define ELOG_TYPE_DECLARE(f) static elog_event_type_t __ELOG_TYPE_VAR(f)
444 #define ELOG_TYPE_INIT_FORMAT_AND_FUNCTION(fmt,func) \
445 { .format = fmt, .function = func, }
447 #define ELOG_TYPE_INIT(fmt) \
448 ELOG_TYPE_INIT_FORMAT_AND_FUNCTION(fmt,(char *) __FUNCTION__)
450 #define ELOG_TYPE_DECLARE_HELPER(f,fmt,func) \
451 static elog_event_type_t __ELOG_TYPE_VAR(f) = \
452 ELOG_TYPE_INIT_FORMAT_AND_FUNCTION (fmt, func)
454 #define ELOG_TYPE_DECLARE_FORMAT_AND_FUNCTION(f,fmt) \
455 ELOG_TYPE_DECLARE_HELPER (f, fmt, (char *) __FUNCTION__)
457 #define ELOG_TYPE_DECLARE_FORMAT(f,fmt) \
458 ELOG_TYPE_DECLARE_HELPER (f, fmt, 0)
462 #define ELOG_TYPE(f,fmt) ELOG_TYPE_DECLARE_FORMAT_AND_FUNCTION(f,fmt)
463 #define ELOG_TYPE_D(f) ELOG_TYPE_DECLARE_FORMAT (f, #f " %d")
464 #define ELOG_TYPE_X(f) ELOG_TYPE_DECLARE_FORMAT (f, #f " 0x%x")
465 #define ELOG_TYPE_DF(f) ELOG_TYPE_DECLARE_FORMAT_AND_FUNCTION (f, #f " %d")
466 #define ELOG_TYPE_XF(f) ELOG_TYPE_DECLARE_FORMAT_AND_FUNCTION (f, #f " 0x%x")
467 #define ELOG_TYPE_FD(f) ELOG_TYPE_DECLARE_FORMAT_AND_FUNCTION (f, #f " %d")
468 #define ELOG_TYPE_FX(f) ELOG_TYPE_DECLARE_FORMAT_AND_FUNCTION (f, #f " 0x%x")
470 #define ELOG_TRACK_DECLARE(f) static elog_track_t __ELOG_TRACK_VAR(f)
471 #define ELOG_TRACK(f) ELOG_TRACK_DECLARE(f) = { .name = #f, }
474 #define ELOG(em,f,data) elog ((em), &__ELOG_TYPE_VAR(f), data)
475 #define ELOG_INLINE(em,f,data) elog_inline ((em), &__ELOG_TYPE_VAR(f), data)
478 #define ELOG_TRACK_DATA(em,f,track) \
479 elog_data ((em), &__ELOG_TYPE_VAR(f), &__ELOG_TRACK_VAR(track))
480 #define ELOG_TRACK_DATA_INLINE(em,f,track) \
481 elog_data_inline ((em), &__ELOG_TYPE_VAR(f), &__ELOG_TRACK_VAR(track))
484 #define ELOG_DATA(em,f) elog_data ((em), &__ELOG_TYPE_VAR (f), &(em)->default_track)
485 #define ELOG_DATA_INLINE(em,f) elog_data_inline ((em), &__ELOG_TYPE_VAR (f), &(em)->default_track)
static void elog_reset_buffer(elog_main_t *em)
Reset the event buffer.
f64 time
Absolute time as floating point number in seconds.
char * format
Format string.
elog_track_t * tracks
Vector of tracks.
u8 data[20]
20-bytes of data follows, pads to 32 bytes.
char * name
Track name vector.
static void elog_track_inline(elog_main_t *em, elog_event_type_t *type, elog_track_t *track, u32 data)
Log a single-datum event to a specific track.
__clib_export clib_error_t * unserialize(serialize_main_t *m,...)
static void * elog_event_data_inline(elog_main_t *em, elog_event_type_t *type, elog_track_t *track, u64 cpu_time)
Allocate an event to be filled in by the caller.
static void elog(elog_main_t *em, elog_event_type_t *type, u32 data)
Log a single-datum event.
u32 n_total_events_disable_limit
When count reaches limit logging is disabled.
u32 n_enum_strings
Number of elements in string enum table.
static void * elog_data(elog_main_t *em, elog_event_type_t *type, elog_track_t *track)
f64 nsec_per_cpu_clock
Use serialize_time and init_time to give estimate for cpu clock frequency.
elog_event_type_t * event_types
Vector of event types.
char ** enum_strings_vector
String table as a vector constructed when type is registered.
static clib_error_t * elog_read_file(elog_main_t *em, char *clib_file)
u8 * format_elog_event(u8 *s, va_list *va)
elog_event_t * elog_peek_events(elog_main_t *em)
convert event ring events to events, and return them as a vector.
u8 * format_elog_track(u8 *s, va_list *args)
u32 track_index_plus_one
Set to one when track has been added to main structure.
void * elog_event_data(elog_main_t *em, elog_event_type_t *type, elog_track_t *track, u64 cpu_time)
elog_event_t * elog_get_events(elog_main_t *em)
convert event ring events to events, and return them as a vector.
elog_event_t * event_ring
Vector of events (circular buffer).
static uword elog_buffer_capacity(elog_main_t *em)
Return number of events which can fit in the event buffer.
word elog_track_register(elog_main_t *em, elog_track_t *t)
register an event track
clib_error_t * elog_write_file_not_inline(elog_main_t *em, char *clib_file, int flush_ring)
static void elog_track(elog_main_t *em, elog_event_type_t *type, elog_track_t *track, u32 data)
Log a single-datum event to a specific track, non-inline version.
__clib_export clib_error_t * serialize_open_clib_file(serialize_main_t *m, char *file)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
__clib_export clib_error_t * serialize(serialize_main_t *m,...)
u32 n_total_events
Total number of events in buffer.
char * format_args
Specifies how arguments to format are parsed from event data.
u64 cpu
CPU cycle counter.
elog_time_stamp_t serialize_time
__clib_export clib_error_t * unserialize_open_clib_file(serialize_main_t *m, char *file)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
char * format_one_elog_event(void *em_arg, void *ep_arg)
char * string_table
Events may refer to strings in string table.
elog_track_t default_track
Default track.
uword event_ring_size
Power of 2 number of elements in ring.
void unserialize_elog_main(serialize_main_t *m, va_list *va)
__clib_export void serialize_close(serialize_main_t *m)
u8 * format_elog_track_name(u8 *s, va_list *va)
u64 os_nsec
OS timer in nano secs since epoch 3/30/2017, see elog_time_now()
#define clib_atomic_fetch_add(a, b)
u16 track
Track for this event.
void elog_alloc(elog_main_t *em, u32 n_events)
static uword elog_is_enabled(elog_main_t *em)
event logging enabled predicate
static void * elog_data_inline(elog_main_t *em, elog_event_type_t *type, elog_track_t *track)
void elog_resize(elog_main_t *em, u32 n_events)
word elog_event_type_register(elog_main_t *em, elog_event_type_t *t)
register an event type
description fragment has unexpected format
void elog_init(elog_main_t *em, u32 n_events)
static void elog_inline(elog_main_t *em, elog_event_type_t *type, u32 data)
Log a single-datum event, inline version.
static clib_error_t * elog_write_file(elog_main_t *em, char *clib_file, int flush_ring)
static void elog_disable_after_events(elog_main_t *em, uword n)
disable logging after specified number of ievents have been logged.
void elog_time_now(elog_time_stamp_t *et)
static void elog_disable_trigger(elog_main_t *em)
void elog_merge(elog_main_t *dst, u8 *dst_tag, elog_main_t *src, u8 *src_tag, f64 align_tweak)
uword * string_table_hash
clib_error_t * elog_read_file_not_inline(elog_main_t *em, char *clib_file)
__clib_export void unserialize_close(serialize_main_t *m)
elog_event_t placeholder_event
Dummy event to use when logger is disabled.
u32 type_index_plus_one
Type index plus one assigned to this type.
u32 elog_string(elog_main_t *em, char *format,...)
add a string to the event-log string table
u16 event_type
Event type index.
void serialize_elog_main(serialize_main_t *m, va_list *va)
uword * event_type_by_format
Hash table mapping type format to type index.
static u64 clib_cpu_time_now(void)
static uword is_pow2(uword x)
uword * lock
SMP lock, non-zero means locking required.
static void elog_enable_disable(elog_main_t *em, int is_enabled)
Enable or disable event logging.
elog_event_t * events
Vector of events converted to generic form after collection.
vl_api_fib_path_type_t type
static uword elog_n_events_in_buffer(elog_main_t *em)
Return number of events in the event-log buffer.
u64 time_cycles
Absolute time stamp in CPU clock cycles.
static void * elog_event_data_not_inline(elog_main_t *em, elog_event_type_t *type, elog_track_t *track, u64 cpu_time)
Allocate an event to be filled in by the caller, non-inline.
clib_time_t cpu_timer
Place holder for CPU clock frequency.