5#ifndef _RTE_TRACE_POINT_H_
6#define _RTE_TRACE_POINT_H_
24#include <rte_compat.h>
27#include <rte_stdatomic.h>
37typedef RTE_ATOMIC(uint64_t) rte_trace_point_t;
44#define RTE_TRACE_POINT_ARGS
47#define __RTE_TRACE_POINT(_mode, _tp, _args, ...) \
48extern rte_trace_point_t __##_tp; \
49static __rte_always_inline void \
52 __rte_trace_point_emit_header_##_mode(&__##_tp); \
80#define RTE_TRACE_POINT(tp, args, ...) \
81 __RTE_TRACE_POINT(generic, tp, args, __VA_ARGS__)
101#define RTE_TRACE_POINT_FP(tp, args, ...) \
102 __RTE_TRACE_POINT(fp, tp, args, __VA_ARGS__)
117#define RTE_TRACE_POINT_REGISTER(trace, name)
120#define rte_trace_point_emit_u64(val)
122#define rte_trace_point_emit_i64(val)
124#define rte_trace_point_emit_u32(val)
126#define rte_trace_point_emit_i32(val)
128#define rte_trace_point_emit_u16(val)
130#define rte_trace_point_emit_i16(val)
132#define rte_trace_point_emit_u8(val)
134#define rte_trace_point_emit_i8(val)
136#define rte_trace_point_emit_int(val)
138#define rte_trace_point_emit_long(val)
140#define rte_trace_point_emit_size_t(val)
142#define rte_trace_point_emit_float(val)
144#define rte_trace_point_emit_double(val)
146#define rte_trace_point_emit_ptr(val)
148#define rte_trace_point_emit_string(val)
158#define rte_trace_point_emit_blob(val, len)
163#define __RTE_TRACE_EMIT_STRING_LEN_MAX 32
165#define __RTE_TRACE_EVENT_HEADER_SZ sizeof(uint64_t)
168#define RTE_TRACE_BLOB_LEN_MAX 64
226__rte_trace_point_fp_is_enabled(
void)
228#ifdef RTE_ENABLE_TRACE_FP
241void __rte_trace_mem_per_thread_alloc(
void);
259void __rte_trace_point_emit_field(
size_t sz,
const char *field,
279int __rte_trace_point_register(rte_trace_point_t *trace,
const char *name,
280 void (*register_fn)(
void));
284#ifndef _RTE_TRACE_POINT_REGISTER_H_
285#ifdef ALLOW_EXPERIMENTAL_API
287#define __RTE_TRACE_EVENT_HEADER_ID_SHIFT (48)
289#define __RTE_TRACE_FIELD_SIZE_SHIFT 0
290#define __RTE_TRACE_FIELD_SIZE_MASK (0xffffULL << __RTE_TRACE_FIELD_SIZE_SHIFT)
291#define __RTE_TRACE_FIELD_ID_SHIFT (16)
292#define __RTE_TRACE_FIELD_ID_MASK (0xffffULL << __RTE_TRACE_FIELD_ID_SHIFT)
293#define __RTE_TRACE_FIELD_ENABLE_MASK (1ULL << 63)
294#define __RTE_TRACE_FIELD_ENABLE_DISCARD (1ULL << 62)
296struct __rte_trace_stream_header {
300 char thread_name[__RTE_TRACE_EMIT_STRING_LEN_MAX];
303struct __rte_trace_header {
306 struct __rte_trace_stream_header stream_header;
313__rte_trace_mem_get(uint64_t in)
315 struct __rte_trace_header *trace =
317 const uint16_t sz = in & __RTE_TRACE_FIELD_SIZE_MASK;
321 __rte_trace_mem_per_thread_alloc();
322 trace = (
struct __rte_trace_header *)(
RTE_PER_LCORE(trace_mem));
327 uint32_t offset = trace->offset;
328 if (
unlikely((offset + sz) >= trace->len)) {
330 if (
unlikely(in & __RTE_TRACE_FIELD_ENABLE_DISCARD))
339 trace->offset = offset;
345__rte_trace_point_emit_ev_header(
void *mem, uint64_t in)
351 ~(0xffffULL << __RTE_TRACE_EVENT_HEADER_ID_SHIFT);
352 val |= ((in & __RTE_TRACE_FIELD_ID_MASK) <<
353 (__RTE_TRACE_EVENT_HEADER_ID_SHIFT -
354 __RTE_TRACE_FIELD_ID_SHIFT));
356 *(uint64_t *)mem = val;
357 return RTE_PTR_ADD(mem, __RTE_TRACE_EVENT_HEADER_SZ);
360#define __rte_trace_point_emit_header_generic(t) \
363 if (!rte_trace_feature_is_enabled()) \
365 const uint64_t val = rte_atomic_load_explicit(t, rte_memory_order_acquire); \
366 if (likely(!(val & __RTE_TRACE_FIELD_ENABLE_MASK))) \
368 mem = __rte_trace_mem_get(val); \
369 if (unlikely(mem == NULL)) \
371 mem = __rte_trace_point_emit_ev_header(mem, val); \
374#define __rte_trace_point_emit_header_fp(t) \
375 if (!__rte_trace_point_fp_is_enabled()) \
377 __rte_trace_point_emit_header_generic(t)
379#define __rte_trace_point_emit(in, type) \
381 memcpy(mem, &(in), sizeof(in)); \
382 mem = RTE_PTR_ADD(mem, sizeof(in)); \
385#define rte_trace_point_emit_string(in) \
387 if (unlikely(in == NULL)) \
389 rte_strscpy((char *)mem, in, __RTE_TRACE_EMIT_STRING_LEN_MAX); \
390 mem = RTE_PTR_ADD(mem, __RTE_TRACE_EMIT_STRING_LEN_MAX); \
393#define rte_trace_point_emit_blob(in, len) \
395 if (unlikely(in == NULL)) \
397 if (len > RTE_TRACE_BLOB_LEN_MAX) \
398 len = RTE_TRACE_BLOB_LEN_MAX; \
399 __rte_trace_point_emit(len, uint8_t); \
400 memcpy(mem, in, len); \
401 memset(RTE_PTR_ADD(mem, len), 0, RTE_TRACE_BLOB_LEN_MAX - len); \
402 mem = RTE_PTR_ADD(mem, RTE_TRACE_BLOB_LEN_MAX); \
407#define __rte_trace_point_emit_header_generic(t) RTE_SET_USED(t)
408#define __rte_trace_point_emit_header_fp(t) RTE_SET_USED(t)
409#define __rte_trace_point_emit(in, type) RTE_SET_USED(in)
410#define rte_trace_point_emit_string(in) RTE_SET_USED(in)
411#define rte_trace_point_emit_blob(in, len) \
421#define rte_trace_point_emit_u64(in) __rte_trace_point_emit(in, uint64_t)
422#define rte_trace_point_emit_i64(in) __rte_trace_point_emit(in, int64_t)
423#define rte_trace_point_emit_u32(in) __rte_trace_point_emit(in, uint32_t)
424#define rte_trace_point_emit_i32(in) __rte_trace_point_emit(in, int32_t)
425#define rte_trace_point_emit_u16(in) __rte_trace_point_emit(in, uint16_t)
426#define rte_trace_point_emit_i16(in) __rte_trace_point_emit(in, int16_t)
427#define rte_trace_point_emit_u8(in) __rte_trace_point_emit(in, uint8_t)
428#define rte_trace_point_emit_i8(in) __rte_trace_point_emit(in, int8_t)
429#define rte_trace_point_emit_int(in) __rte_trace_point_emit(in, int32_t)
430#define rte_trace_point_emit_long(in) __rte_trace_point_emit(in, long)
431#define rte_trace_point_emit_size_t(in) __rte_trace_point_emit(in, size_t)
432#define rte_trace_point_emit_float(in) __rte_trace_point_emit(in, float)
433#define rte_trace_point_emit_double(in) __rte_trace_point_emit(in, double)
434#define rte_trace_point_emit_ptr(in) __rte_trace_point_emit(in, uintptr_t)
#define RTE_ALIGN_CEIL(val, align)
#define RTE_PTR_ADD(ptr, x)
#define __rte_always_inline
static uint64_t rte_get_tsc_cycles(void)
#define RTE_PER_LCORE(name)
#define RTE_DECLARE_PER_LCORE(type, name)
__rte_experimental bool rte_trace_point_is_enabled(rte_trace_point_t *tp)
__rte_experimental int rte_trace_point_disable(rte_trace_point_t *tp)
__rte_experimental int rte_trace_point_enable(rte_trace_point_t *tp)
__rte_experimental rte_trace_point_t * rte_trace_point_lookup(const char *name)
unsigned char rte_uuid_t[16]