DPDK 25.03.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
rte_trace_point_register.h
1/* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(C) 2020 Marvell International Ltd.
3 */
4
5#ifndef _RTE_TRACE_POINT_REGISTER_H_
6#define _RTE_TRACE_POINT_REGISTER_H_
7
8#ifdef _RTE_TRACE_POINT_H_
9#error for registration, include this file first before <rte_trace_point.h>
10#endif
11
12#include <rte_per_lcore.h>
13#include <rte_trace_point.h>
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19RTE_DECLARE_PER_LCORE(volatile int, trace_point_sz);
20
21#define RTE_TRACE_POINT_ARGS_COUNT_(_0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11,_12,_13,_14,_15,N, ...) \
22 N
23#define RTE_TRACE_POINT_ARGS_COUNT(...) \
24 RTE_TRACE_POINT_ARGS_COUNT_(__VA_ARGS__,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)
25
26#define RTE_TRACE_POINT_ARGS_1(a) __rte_unused a
27#define RTE_TRACE_POINT_ARGS_2(a, ...) __rte_unused a, RTE_TRACE_POINT_ARGS_1(__VA_ARGS__)
28#define RTE_TRACE_POINT_ARGS_3(a, ...) __rte_unused a, RTE_TRACE_POINT_ARGS_2(__VA_ARGS__)
29#define RTE_TRACE_POINT_ARGS_4(a, ...) __rte_unused a, RTE_TRACE_POINT_ARGS_3(__VA_ARGS__)
30#define RTE_TRACE_POINT_ARGS_5(a, ...) __rte_unused a, RTE_TRACE_POINT_ARGS_4(__VA_ARGS__)
31#define RTE_TRACE_POINT_ARGS_6(a, ...) __rte_unused a, RTE_TRACE_POINT_ARGS_5(__VA_ARGS__)
32#define RTE_TRACE_POINT_ARGS_7(a, ...) __rte_unused a, RTE_TRACE_POINT_ARGS_6(__VA_ARGS__)
33#define RTE_TRACE_POINT_ARGS_8(a, ...) __rte_unused a, RTE_TRACE_POINT_ARGS_7(__VA_ARGS__)
34#define RTE_TRACE_POINT_ARGS_9(a, ...) __rte_unused a, RTE_TRACE_POINT_ARGS_8(__VA_ARGS__)
35#define RTE_TRACE_POINT_ARGS_10(a, ...) __rte_unused a, RTE_TRACE_POINT_ARGS_9(__VA_ARGS__)
36#define RTE_TRACE_POINT_ARGS_11(a, ...) __rte_unused a, RTE_TRACE_POINT_ARGS_10(__VA_ARGS__)
37#define RTE_TRACE_POINT_ARGS_12(a, ...) __rte_unused a, RTE_TRACE_POINT_ARGS_11(__VA_ARGS__)
38#define RTE_TRACE_POINT_ARGS_13(a, ...) __rte_unused a, RTE_TRACE_POINT_ARGS_12(__VA_ARGS__)
39#define RTE_TRACE_POINT_ARGS_14(a, ...) __rte_unused a, RTE_TRACE_POINT_ARGS_13(__VA_ARGS__)
40#define RTE_TRACE_POINT_ARGS_15(a, ...) __rte_unused a, RTE_TRACE_POINT_ARGS_14(__VA_ARGS__)
41#define RTE_TRACE_POINT_ARGS_FUNC(a) RTE_TRACE_POINT_ARGS_ ## a
42#define RTE_TRACE_POINT_ARGS_EXPAND(...) __VA_ARGS__
43#define RTE_TRACE_POINT_ARGS_(N, ...) \
44 RTE_TRACE_POINT_ARGS_EXPAND(RTE_TRACE_POINT_ARGS_FUNC(N))(__VA_ARGS__)
45#define RTE_TRACE_POINT_ARGS(...) \
46 (RTE_TRACE_POINT_ARGS_(RTE_TRACE_POINT_ARGS_COUNT(0, __VA_ARGS__), __VA_ARGS__))
47
48#define __RTE_TRACE_POINT(_mode, _tp, _args, ...) \
49extern rte_trace_point_t __##_tp; \
50static __rte_always_inline void _tp _args { } \
51static __rte_always_inline void \
52_tp ## _register (void) \
53{ \
54 __rte_trace_point_emit_header_##_mode(&__##_tp); \
55 __VA_ARGS__ \
56}
57
58#define RTE_TRACE_POINT_REGISTER(trace, name) \
59rte_trace_point_t __rte_section("__rte_trace_point") __##trace; \
60static const char __##trace##_name[] = RTE_STR(name); \
61RTE_INIT(trace##_init) \
62{ \
63 if (!rte_trace_feature_is_enabled()) \
64 return; \
65 __rte_trace_point_register(&__##trace, __##trace##_name, \
66 trace ## _register); \
67}
68
69#define __rte_trace_point_emit_header_generic(t) \
70 RTE_PER_LCORE(trace_point_sz) = __RTE_TRACE_EVENT_HEADER_SZ
71
72#define __rte_trace_point_emit_header_fp(t) \
73 __rte_trace_point_emit_header_generic(t)
74
75#define __rte_trace_point_emit(name, in, type) \
76do { \
77 __rte_trace_point_emit_field(sizeof(type), name, RTE_STR(type)); \
78} while (0)
79
80#define rte_trace_point_emit_string(in) \
81do { \
82 __rte_trace_point_emit_field(__RTE_TRACE_EMIT_STRING_LEN_MAX, \
83 RTE_STR(in)"[32]", "string_bounded_t"); \
84} while (0)
85
86#define rte_trace_point_emit_blob(in, len) \
87do { \
88 __rte_trace_point_emit_field(sizeof(uint8_t), \
89 RTE_STR(in) "_size", \
90 RTE_STR(uint8_t)); \
91 __rte_trace_point_emit_field(RTE_TRACE_BLOB_LEN_MAX, \
92 RTE_STR(in)"[" RTE_STR(RTE_TRACE_BLOB_LEN_MAX)"]", \
93 RTE_STR(uint8_t)); \
94} while (0)
95
96#ifdef __cplusplus
97}
98#endif
99
100#endif /* _RTE_TRACE_POINT_REGISTER_H_ */
#define RTE_DECLARE_PER_LCORE(type, name)
Definition: rte_per_lcore.h:39