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_
41 #include <rte_common.h>
43 #include "lthread_api.h"
44 #include "lthread_diag_api.h"
46 extern diag_callback diag_cb;
48 extern const char *diag_event_text[];
49 extern uint64_t diag_mask;
51 /* max size of name strings */
52 #define LT_MAX_NAME_SIZE 64
55 #define DISPLAY_OBJCACHE_QUEUES 1
58 * Generate a diagnostic trace or event in the case where an object is created.
60 * The value returned by the callback is stored in the object.
63 * pointer to the object that was created
68 #define DIAG_CREATE_EVENT(obj, ev) do { \
69 struct lthread *ct = RTE_PER_LCORE(this_sched)->current_lthread;\
70 if ((BIT(ev) & diag_mask) && (ev < LT_DIAG_EVENT_MAX)) { \
71 (obj)->diag_ref = (diag_cb)(rte_rdtsc(), \
75 diag_event_text[(ev)], \
82 * Generate a diagnostic trace event.
85 * pointer to the lthread, cond or mutex object
89 * object specific value ( see lthread_diag_api.h )
91 * object specific value ( see lthread_diag_api.h )
93 #define DIAG_EVENT(obj, ev, p1, p2) do { \
94 struct lthread *ct = RTE_PER_LCORE(this_sched)->current_lthread;\
95 if ((BIT(ev) & diag_mask) && (ev < LT_DIAG_EVENT_MAX)) { \
96 (diag_cb)(rte_rdtsc(), \
100 diag_event_text[(ev)], \
106 #define DIAG_COUNT_DEFINE(x) rte_atomic64_t count_##x
107 #define DIAG_COUNT_INIT(o, x) rte_atomic64_init(&((o)->count_##x))
108 #define DIAG_COUNT_INC(o, x) rte_atomic64_inc(&((o)->count_##x))
109 #define DIAG_COUNT_DEC(o, x) rte_atomic64_dec(&((o)->count_##x))
110 #define DIAG_COUNT(o, x) rte_atomic64_read(&((o)->count_##x))
116 /* no diagnostics configured */
118 #define DISPLAY_OBJCACHE_QUEUES 0
120 #define DIAG_CREATE_EVENT(obj, ev)
121 #define DIAG_EVENT(obj, ev, p1, p)
123 #define DIAG_COUNT_DEFINE(x)
124 #define DIAG_COUNT_INIT(o, x) do {} while (0)
125 #define DIAG_COUNT_INC(o, x) do {} while (0)
126 #define DIAG_COUNT_DEC(o, x) do {} while (0)
127 #define DIAG_COUNT(o, x) 0
129 #define DIAG_USED __rte_unused
131 #endif /* LTHREAD_DIAG */
132 #endif /* LTHREAD_DIAG_H_ */