8aff296312891d632bfb725cdb4f1788a0eb86c9
[deb_dpdk.git] / drivers / net / ark / ark_logs.h
1 /*-
2  * BSD LICENSE
3  *
4  * Copyright (c) 2015-2017 Atomic Rules LLC
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
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
16  * distribution.
17  * * Neither the name of copyright holder 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.
20  *
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.
32  */
33
34 #ifndef _ARK_DEBUG_H_
35 #define _ARK_DEBUG_H_
36
37 #include <inttypes.h>
38 #include <rte_log.h>
39
40
41 /* Configuration option to pad TX packets to 60 bytes */
42 #ifdef RTE_LIBRTE_ARK_PAD_TX
43 #define ARK_TX_PAD_TO_60   1
44 #else
45 #define ARK_TX_PAD_TO_60   0
46 #endif
47
48 /* system camel case definition changed to upper case */
49 #define PRIU32 PRIu32
50 #define PRIU64 PRIu64
51
52 /* Format specifiers for string data pairs */
53 #define ARK_SU32  "\n\t%-20s    %'20" PRIU32
54 #define ARK_SU64  "\n\t%-20s    %'20" PRIU64
55 #define ARK_SU64X "\n\t%-20s    %#20" PRIx64
56 #define ARK_SPTR  "\n\t%-20s    %20p"
57
58
59
60 #define PMD_DRV_LOG(level, fmt, args...)        \
61         RTE_LOG(level, PMD, fmt, ## args)
62
63 /* Conditional trace definitions */
64 #define ARK_TRACE_ON(level, fmt, ...)           \
65         RTE_LOG(level, PMD, fmt, ##__VA_ARGS__)
66
67 /* This pattern allows compiler check arguments even if disabled  */
68 #define ARK_TRACE_OFF(level, fmt, ...)                                  \
69         do {if (0) RTE_LOG(level, PMD, fmt, ##__VA_ARGS__); }           \
70         while (0)
71
72
73 /* tracing including the function name */
74 #define ARK_FUNC_ON(level, fmt, args...) \
75         RTE_LOG(level, PMD, "%s(): " fmt, __func__, ## args)
76
77 /* tracing including the function name */
78 #define ARK_FUNC_OFF(level, fmt, args...)                               \
79         do { if (0) RTE_LOG(level, PMD, "%s(): " fmt, __func__, ## args); } \
80         while (0)
81
82
83 /* Debug macro for tracing full behavior, function tracing and messages*/
84 #ifdef RTE_LIBRTE_ARK_DEBUG_TRACE
85 #define PMD_FUNC_LOG(level, fmt, ...) ARK_FUNC_ON(level, fmt, ##__VA_ARGS__)
86 #define PMD_DEBUG_LOG(level, fmt, ...) ARK_TRACE_ON(level, fmt, ##__VA_ARGS__)
87 #else
88 #define PMD_FUNC_LOG(level, fmt, ...) ARK_FUNC_OFF(level, fmt, ##__VA_ARGS__)
89 #define PMD_DEBUG_LOG(level, fmt, ...) ARK_TRACE_OFF(level, fmt, ##__VA_ARGS__)
90 #endif
91
92
93 /* Debug macro for reporting FPGA statistics */
94 #ifdef RTE_LIBRTE_ARK_DEBUG_STATS
95 #define PMD_STATS_LOG(level, fmt, ...) ARK_TRACE_ON(level, fmt, ##__VA_ARGS__)
96 #else
97 #define PMD_STATS_LOG(level, fmt, ...)  ARK_TRACE_OFF(level, fmt, ##__VA_ARGS__)
98 #endif
99
100
101 /* Debug macro for RX path */
102 #ifdef RTE_LIBRTE_ARK_DEBUG_RX
103 #define ARK_RX_DEBUG 1
104 #define PMD_RX_LOG(level, fmt, ...)  ARK_TRACE_ON(level, fmt, ##__VA_ARGS__)
105 #else
106 #define ARK_RX_DEBUG 0
107 #define PMD_RX_LOG(level, fmt, ...)  ARK_TRACE_OFF(level, fmt, ##__VA_ARGS__)
108 #endif
109
110 /* Debug macro for TX path */
111 #ifdef RTE_LIBRTE_ARK_DEBUG_TX
112 #define ARK_TX_DEBUG       1
113 #define PMD_TX_LOG(level, fmt, ...)  ARK_TRACE_ON(level, fmt, ##__VA_ARGS__)
114 #else
115 #define ARK_TX_DEBUG       0
116 #define PMD_TX_LOG(level, fmt, ...)  ARK_TRACE_OFF(level, fmt, ##__VA_ARGS__)
117 #endif
118
119 #endif