examples/fips_validation: fix buffer overflow
[dpdk.git] / drivers / net / ark / ark_logs.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright (c) 2015-2018 Atomic Rules LLC
3  */
4
5 #ifndef _ARK_DEBUG_H_
6 #define _ARK_DEBUG_H_
7
8 #include <inttypes.h>
9 #include <rte_log.h>
10
11
12 /* Configuration option to pad TX packets to 60 bytes */
13 #ifdef RTE_LIBRTE_ARK_PAD_TX
14 #define ARK_TX_PAD_TO_60   1
15 #else
16 #define ARK_TX_PAD_TO_60   0
17 #endif
18
19 /* system camel case definition changed to upper case */
20 #define PRIU32 PRIu32
21 #define PRIU64 PRIu64
22
23 /* Format specifiers for string data pairs */
24 #define ARK_SU32  "\n\t%-20s    %'20" PRIU32
25 #define ARK_SU64  "\n\t%-20s    %'20" PRIU64
26 #define ARK_SU64X "\n\t%-20s    %#20" PRIx64
27 #define ARK_SPTR  "\n\t%-20s    %20p"
28
29 extern int ark_logtype;
30
31 #define PMD_DRV_LOG(level, fmt, args...)        \
32         rte_log(RTE_LOG_ ##level, ark_logtype, fmt, ## args)
33
34 /* Conditional trace definitions */
35 #define ARK_TRACE_ON(level, fmt, args...) \
36         PMD_DRV_LOG(level, fmt, ## args)
37
38 /* This pattern allows compiler check arguments even if disabled  */
39 #define ARK_TRACE_OFF(level, fmt, args...)                      \
40         do {                                                    \
41                 if (0)                                          \
42                         PMD_DRV_LOG(level, fmt, ## args);       \
43         } while (0)
44
45 /* tracing including the function name */
46 #define ARK_FUNC_ON(level, fmt, args...) \
47         PMD_DRV_LOG(level, "%s(): " fmt, __func__, ## args)
48
49 /* tracing including the function name */
50 #define ARK_FUNC_OFF(level, fmt, args...)                               \
51         do {                                                            \
52                 if (0)                                                  \
53                         PMD_DRV_LOG(level, "%s(): " fmt, __func__, ## args); \
54         } while (0)
55
56
57 /* Debug macro for tracing full behavior, function tracing and messages*/
58 #ifdef RTE_LIBRTE_ARK_DEBUG_TRACE
59 #define PMD_FUNC_LOG(level, fmt, ...) ARK_FUNC_ON(level, fmt, ##__VA_ARGS__)
60 #define PMD_DEBUG_LOG(level, fmt, ...) ARK_TRACE_ON(level, fmt, ##__VA_ARGS__)
61 #else
62 #define PMD_FUNC_LOG(level, fmt, ...) ARK_FUNC_OFF(level, fmt, ##__VA_ARGS__)
63 #define PMD_DEBUG_LOG(level, fmt, ...) ARK_TRACE_OFF(level, fmt, ##__VA_ARGS__)
64 #endif
65
66
67 /* Debug macro for reporting FPGA statistics */
68 #ifdef RTE_LIBRTE_ARK_DEBUG_STATS
69 #define PMD_STATS_LOG(level, fmt, ...) ARK_TRACE_ON(level, fmt, ##__VA_ARGS__)
70 #else
71 #define PMD_STATS_LOG(level, fmt, ...)  ARK_TRACE_OFF(level, fmt, ##__VA_ARGS__)
72 #endif
73
74
75 /* Debug macro for RX path */
76 #ifdef RTE_LIBRTE_ARK_DEBUG_RX
77 #define ARK_RX_DEBUG 1
78 #define PMD_RX_LOG(level, fmt, ...)  ARK_TRACE_ON(level, fmt, ##__VA_ARGS__)
79 #else
80 #define ARK_RX_DEBUG 0
81 #define PMD_RX_LOG(level, fmt, ...)  ARK_TRACE_OFF(level, fmt, ##__VA_ARGS__)
82 #endif
83
84 /* Debug macro for TX path */
85 #ifdef RTE_LIBRTE_ARK_DEBUG_TX
86 #define ARK_TX_DEBUG       1
87 #define PMD_TX_LOG(level, fmt, ...)  ARK_TRACE_ON(level, fmt, ##__VA_ARGS__)
88 #else
89 #define ARK_TX_DEBUG       0
90 #define PMD_TX_LOG(level, fmt, ...)  ARK_TRACE_OFF(level, fmt, ##__VA_ARGS__)
91 #endif
92
93 #endif