|
FD.io VPP
v21.06-3-gbb25fbf28
Vector Packet Processing
|
Go to the documentation of this file.
132 for (
i = 0;
i < l;
i++)
227 digits[0] = digits[1] = 0;
228 while (p[
i] >=
'0' && p[
i] <=
'9')
232 digits[
i] = p[
i] -
'0';
236 if (
i >= 1 &&
i <= 2)
241 *
number = 10 * digits[0] + digits[1];
259 if (
f[0] ==
'%' &&
f[1] !=
'%')
273 f +=
f[0] ==
'+' ||
f[0] ==
'-' ||
f[0] ==
'=';
276 while ((
f[0] >=
'0' &&
f[0] <=
'9') ||
f[0] ==
'.')
280 f +=
f[0] ==
'w' ||
f[0] ==
'l' ||
f[0] ==
'L';
285 ASSERT (*result_len >
f - percent);
286 l =
clib_min (
f - percent, *result_len - 1);
291 *result_len =
f -
fmt;
313 f_bytes =
sizeof (arg_format);
317 if (
a == 0 ||
a[0] == 0)
351 s =
format (s, arg_format, e);
353 else if (
a[0] ==
'T')
357 s =
format (s, arg_format, e);
360 s =
format (s, arg_format, l);
375 s =
format (s, arg_format, x);
380 s =
format (s, arg_format, d);
390 ASSERT (n_digits > 0 && n_digits <= 2);
411 f64 dt = va_arg (*args,
f64);
412 int track_index = va_arg (*args,
int);
421 if (e->
track != track_index)
442 u64 cpu_time_now, os_time_now_nsec;
447 #include <sys/syscall.h>
449 clock_gettime (CLOCK_REALTIME, &ts);
451 syscall (SYS_clock_gettime, CLOCK_REALTIME, &ts);
455 os_time_now_nsec = 1e9 * (ts.tv_sec - 1490885108) + ts.tv_nsec;
459 os_time_now_nsec = 0;
462 et->
cpu = cpu_time_now;
463 et->
os_nsec = os_time_now_nsec;
563 for (
i = 0;
i < n;
i++)
674 ASSERT (n_digits > 0 && n_digits <= 2);
704 u32 string_table_offset_for_src_events;
705 u32 track_offset_for_src_tracks;
715 string_table_offset_for_src_events =
vec_len (
dst->string_table);
729 new_name = (
char *)
format (0,
"%s:%s%c", dst_tag, t->
name, 0);
738 track_offset_for_src_tracks =
vec_len (
dst->tracks);
763 string_table_offset_for_src_events);
766 e->
track += track_offset_for_src_tracks;
771 f64 dt_event, dt_os_nsec, dt_clock_nsec;
774 if (
dst->serialize_time.cpu == 0)
776 dst->init_time =
src->init_time;
777 dst->serialize_time =
src->serialize_time;
778 dst->nsec_per_cpu_clock =
src->nsec_per_cpu_clock;
784 dt_event = dt_os_nsec;
787 (
dst->nsec_per_cpu_clock +
src->nsec_per_cpu_clock));
801 if (
fabs (
src->nsec_per_cpu_clock -
dst->nsec_per_cpu_clock) < 1e-2
802 &&
fabs (dt_os_nsec - dt_clock_nsec) < 100)
803 dt_event = dt_clock_nsec;
831 e->
time += dt_event + align_tweak;
836 dt_event = -dt_event;
837 for (e =
dst->events + 0; e < dst->
events + l; e++)
838 e->
time += dt_event + align_tweak;
851 ASSERT (
dst->cpu_timer.seconds_per_clock);
858 es =
dst->events +
i;
859 ed =
dst->event_ring +
i;
905 n_bytes = strlen ((
char *) d) + 1;
1035 int n = va_arg (*va,
int);
1037 for (
i = 0;
i < n;
i++)
1044 sizeof (t[
i].n_enum_strings));
1054 int n = va_arg (*va,
int);
1056 for (
i = 0;
i < n;
i++)
1063 sizeof (t[
i].n_enum_strings));
1064 vec_resize (t[
i].enum_strings_vector, t[
i].n_enum_strings);
1074 int n = va_arg (*va,
int);
1076 for (
i = 0;
i < n;
i++)
1086 int n = va_arg (*va,
int);
1088 for (
i = 0;
i < n;
i++)
1116 int flush_ring = va_arg (*va,
int);
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
serialize_function_t serialize_vec_8
__clib_export void elog_alloc(elog_main_t *em, u32 n_events)
static void serialize_integer(serialize_main_t *m, u64 x, u32 n_bytes)
#define vec_add(V, E, N)
Add N elements to end of vector V (no header, unspecified alignment)
void elog_time_now(elog_time_stamp_t *et)
f64 time
Absolute time as floating point number in seconds.
__clib_export clib_error_t * elog_read_file_not_inline(elog_main_t *em, char *clib_file)
char * format
Format string.
static void unserialize_elog_time_stamp(serialize_main_t *m, va_list *va)
elog_track_t * tracks
Vector of tracks.
serialize_function_t unserialize_vec_8
u8 data[20]
20-bytes of data follows, pads to 32 bytes.
#define clib_memcpy(d, s, n)
char * name
Track name vector.
__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.
u32 n_total_events_disable_limit
When count reaches limit logging is disabled.
u32 n_enum_strings
Number of elements in string enum table.
#define vec_end(v)
End (last data address) of vector.
elog_time_stamp_t init_time
Timestamps.
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.
static void serialize_elog_track(serialize_main_t *m, va_list *va)
#define hash_create_vec(elts, key_bytes, value_bytes)
char ** enum_strings_vector
String table as a vector constructed when type is registered.
#define vec_append(v1, v2)
Append v2 after v1.
static void unserialize_elog_event_type(serialize_main_t *m, va_list *va)
__clib_export u8 * format_elog_event(u8 *s, va_list *va)
#define hash_create_string(elts, value_bytes)
__clib_export u32 elog_string(elog_main_t *em, char *fmt,...)
add a string to the event-log string table
serialize_function_t unserialize_f32
static void maybe_fix_string_table_offset(elog_event_t *e, elog_event_type_t *t, u32 offset)
#define vec_serialize(m, v, f)
static uword elog_event_range(elog_main_t *em, uword *lo)
u32 track_index_plus_one
Set to one when track has been added to main structure.
__clib_export void * elog_event_data(elog_main_t *em, elog_event_type_t *type, elog_track_t *track, u64 cpu_time)
const char *const const double number
static i64 elog_time_stamp_diff_os_nsec(elog_time_stamp_t *t1, elog_time_stamp_t *t2)
#define clib_atomic_release(a)
elog_event_t * event_ring
Vector of events (circular buffer).
__clib_export void clib_time_init(clib_time_t *c)
static uword find_or_create_type(elog_main_t *em, elog_event_type_t *t)
#define vec_elt(v, i)
Get vector value at index i.
serialize_function_t unserialize_64
__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)
serialize_function_t serialize_f32
__clib_export clib_error_t * serialize(serialize_main_t *m,...)
u32 n_total_events
Total number of events in buffer.
__clib_export void serialize_elog_main(serialize_main_t *m, va_list *va)
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
char * format_args
Specifies how arguments to format are parsed from event data.
u64 cpu
CPU cycle counter.
static void elog_lock(elog_main_t *em)
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.
struct clib_bihash_value offset
template key/value backing page structure
char * string_table
Events may refer to strings in string table.
__clib_export char * format_one_elog_event(void *em_arg, void *ep_arg)
char * enum_strings[]
String table for enum/number to string formatting.
#define clib_atomic_test_and_set(a)
__clib_export void unserialize_elog_main(serialize_main_t *m, va_list *va)
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
void unserialize_check_magic(serialize_main_t *m, void *magic, u32 magic_bytes)
static uword parse_2digit_decimal(char *p, uword *number)
static void unserialize_integer(serialize_main_t *m, void *x, u32 n_bytes)
if(node->flags &VLIB_NODE_FLAG_TRACE) vnet_interface_output_trace(vm
elog_track_t default_track
Default track.
uword event_ring_size
Power of 2 number of elements in ring.
#define hash_set_mem(h, key, value)
#define clib_mem_unaligned(pointer, type)
sll srl srl sll sra u16x4 i
static perfmon_event_t events[]
__clib_export void serialize_close(serialize_main_t *m)
#define vec_unserialize(m, v, f)
serialize_function_t serialize_f64
#define CLIB_CACHE_LINE_BYTES
__clib_export void serialize_cstring(serialize_main_t *m, char *s)
clib_error_t * elog_write_file_not_inline(elog_main_t *em, char *clib_file, int flush_ring)
u64 os_nsec
OS timer in nano secs since epoch 3/30/2017, see elog_time_now()
__clib_export u8 * format_elog_track(u8 *s, va_list *args)
static i64 elog_time_stamp_diff_cpu(elog_time_stamp_t *t1, elog_time_stamp_t *t2)
u16 track
Track for this event.
static void unserialize_elog_track(serialize_main_t *m, va_list *va)
__clib_export void unserialize_cstring(serialize_main_t *m, char **s)
#define vec_free(V)
Free vector's memory (no header).
__clib_export void elog_resize(elog_main_t *em, u32 n_events)
template key/value backing page structure
#define hash_get_mem(h, key)
__clib_export u8 * format_elog_track_name(u8 *s, va_list *va)
description fragment has unexpected format
void serialize_magic(serialize_main_t *m, void *magic, u32 magic_bytes)
static u8 * fixed_format(u8 *s, char *fmt, char *result, uword *result_len)
#define vec_foreach(var, vec)
Vector iterator.
static int elog_cmp(void *a1, void *a2)
static void elog_alloc_internal(elog_main_t *em, u32 n_events, int free_ring)
__clib_export void elog_init(elog_main_t *em, u32 n_events)
static f64 elog_nsec_per_clock(elog_main_t *em)
#define vec_resize(V, N)
Resize a vector (no header, unspecified alignment) Add N elements to end of given vector V,...
char * function
Function name generating event.
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
uword * string_table_hash
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
static void serialize_elog_event(serialize_main_t *m, va_list *va)
__clib_export void elog_merge(elog_main_t *dst, u8 *dst_tag, elog_main_t *src, u8 *src_tag, f64 align_tweak)
serialize_function_t serialize_64
__clib_export void unserialize_close(serialize_main_t *m)
__clib_export word elog_track_register(elog_main_t *em, elog_track_t *t)
register an event track
u32 type_index_plus_one
Type index plus one assigned to this type.
static void unserialize_elog_event(serialize_main_t *m, va_list *va)
static uword max_pow2(uword x)
static void serialize_elog_time_stamp(serialize_main_t *m, va_list *va)
static void new_event_type(elog_main_t *em, uword i)
u16 event_type
Event type index.
static void elog_unlock(elog_main_t *em)
uword * event_type_by_format
Hash table mapping type format to type index.
static u64 clib_cpu_time_now(void)
static char * elog_serialize_magic
uword * lock
SMP lock, non-zero means locking required.
__clib_export elog_event_t * elog_peek_events(elog_main_t *em)
convert event ring events to events, and return them as a vector.
serialize_function_t unserialize_f64
elog_event_t * events
Vector of events converted to generic form after collection.
__clib_export elog_event_t * elog_get_events(elog_main_t *em)
convert event ring events to events, and return them as a vector.
vl_api_fib_path_type_t type
u64 time_cycles
Absolute time stamp in CPU clock cycles.
word elog_event_type_register(elog_main_t *em, elog_event_type_t *t)
register an event type
static void serialize_elog_event_type(serialize_main_t *m, va_list *va)
clib_time_t cpu_timer
Place holder for CPU clock frequency.