1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2015 Intel Corporation
5 #ifndef LTHREAD_DIAG_H_
6 #define LTHREAD_DIAG_H_
16 #include <rte_common.h>
18 #include "lthread_api.h"
19 #include "lthread_diag_api.h"
21 extern diag_callback diag_cb;
23 extern const char *diag_event_text[];
24 extern uint64_t diag_mask;
26 /* max size of name strings */
27 #define LT_MAX_NAME_SIZE 64
30 #define DISPLAY_OBJCACHE_QUEUES 1
33 * Generate a diagnostic trace or event in the case where an object is created.
35 * The value returned by the callback is stored in the object.
38 * pointer to the object that was created
43 #define DIAG_CREATE_EVENT(obj, ev) do { \
44 struct lthread *ct = RTE_PER_LCORE(this_sched)->current_lthread;\
45 if ((BIT(ev) & diag_mask) && (ev < LT_DIAG_EVENT_MAX)) { \
46 (obj)->diag_ref = (diag_cb)(rte_rdtsc(), \
50 diag_event_text[(ev)], \
57 * Generate a diagnostic trace event.
60 * pointer to the lthread, cond or mutex object
64 * object specific value ( see lthread_diag_api.h )
66 * object specific value ( see lthread_diag_api.h )
68 #define DIAG_EVENT(obj, ev, p1, p2) do { \
69 struct lthread *ct = RTE_PER_LCORE(this_sched)->current_lthread;\
70 if ((BIT(ev) & diag_mask) && (ev < LT_DIAG_EVENT_MAX)) { \
71 (diag_cb)(rte_rdtsc(), \
75 diag_event_text[(ev)], \
81 #define DIAG_COUNT_DEFINE(x) rte_atomic64_t count_##x
82 #define DIAG_COUNT_INIT(o, x) rte_atomic64_init(&((o)->count_##x))
83 #define DIAG_COUNT_INC(o, x) rte_atomic64_inc(&((o)->count_##x))
84 #define DIAG_COUNT_DEC(o, x) rte_atomic64_dec(&((o)->count_##x))
85 #define DIAG_COUNT(o, x) rte_atomic64_read(&((o)->count_##x))
91 /* no diagnostics configured */
93 #define DISPLAY_OBJCACHE_QUEUES 0
95 #define DIAG_CREATE_EVENT(obj, ev)
96 #define DIAG_EVENT(obj, ev, p1, p)
98 #define DIAG_COUNT_DEFINE(x)
99 #define DIAG_COUNT_INIT(o, x) do {} while (0)
100 #define DIAG_COUNT_INC(o, x) do {} while (0)
101 #define DIAG_COUNT_DEC(o, x) do {} while (0)
102 #define DIAG_COUNT(o, x) 0
104 #define DIAG_USED __rte_unused
106 #endif /* LTHREAD_DIAG */
112 #endif /* LTHREAD_DIAG_H_ */