4 * Copyright(c) 2015 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #ifndef LTHREAD_DIAG_H_
35 #define LTHREAD_DIAG_H_
45 #include <rte_common.h>
47 #include "lthread_api.h"
48 #include "lthread_diag_api.h"
50 extern diag_callback diag_cb;
52 extern const char *diag_event_text[];
53 extern uint64_t diag_mask;
55 /* max size of name strings */
56 #define LT_MAX_NAME_SIZE 64
59 #define DISPLAY_OBJCACHE_QUEUES 1
62 * Generate a diagnostic trace or event in the case where an object is created.
64 * The value returned by the callback is stored in the object.
67 * pointer to the object that was created
72 #define DIAG_CREATE_EVENT(obj, ev) do { \
73 struct lthread *ct = RTE_PER_LCORE(this_sched)->current_lthread;\
74 if ((BIT(ev) & diag_mask) && (ev < LT_DIAG_EVENT_MAX)) { \
75 (obj)->diag_ref = (diag_cb)(rte_rdtsc(), \
79 diag_event_text[(ev)], \
86 * Generate a diagnostic trace event.
89 * pointer to the lthread, cond or mutex object
93 * object specific value ( see lthread_diag_api.h )
95 * object specific value ( see lthread_diag_api.h )
97 #define DIAG_EVENT(obj, ev, p1, p2) do { \
98 struct lthread *ct = RTE_PER_LCORE(this_sched)->current_lthread;\
99 if ((BIT(ev) & diag_mask) && (ev < LT_DIAG_EVENT_MAX)) { \
100 (diag_cb)(rte_rdtsc(), \
104 diag_event_text[(ev)], \
110 #define DIAG_COUNT_DEFINE(x) rte_atomic64_t count_##x
111 #define DIAG_COUNT_INIT(o, x) rte_atomic64_init(&((o)->count_##x))
112 #define DIAG_COUNT_INC(o, x) rte_atomic64_inc(&((o)->count_##x))
113 #define DIAG_COUNT_DEC(o, x) rte_atomic64_dec(&((o)->count_##x))
114 #define DIAG_COUNT(o, x) rte_atomic64_read(&((o)->count_##x))
120 /* no diagnostics configured */
122 #define DISPLAY_OBJCACHE_QUEUES 0
124 #define DIAG_CREATE_EVENT(obj, ev)
125 #define DIAG_EVENT(obj, ev, p1, p)
127 #define DIAG_COUNT_DEFINE(x)
128 #define DIAG_COUNT_INIT(o, x) do {} while (0)
129 #define DIAG_COUNT_INC(o, x) do {} while (0)
130 #define DIAG_COUNT_DEC(o, x) do {} while (0)
131 #define DIAG_COUNT(o, x) 0
133 #define DIAG_USED __rte_unused
135 #endif /* LTHREAD_DIAG */
141 #endif /* LTHREAD_DIAG_H_ */