1 /* SPDX-License-Identifier: BSD-3-Clause */
2 /* Copyright (c) 2021, Intel Corporation
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * 3. Neither the name of the Intel Corporation nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31 /*$FreeBSD$*/
32
33 /**
34 * @file iavf_debug.h
35 * @brief Debug macros
36 *
37 * Contains definitions for useful debug macros which can be enabled by
38 * building with IAVF_DEBUG defined.
39 */
40 #ifndef _IAVF_DEBUG_H_
41 #define _IAVF_DEBUG_H_
42
43 #define MAC_FORMAT "%02x:%02x:%02x:%02x:%02x:%02x"
44 #define MAC_FORMAT_ARGS(mac_addr) \
45 (mac_addr)[0], (mac_addr)[1], (mac_addr)[2], (mac_addr)[3], \
46 (mac_addr)[4], (mac_addr)[5]
47
48 #ifdef IAVF_DEBUG
49
50 #define _DBG_PRINTF(S, ...) printf("%s: " S "\n", __func__, ##__VA_ARGS__)
51 #define _DEV_DBG_PRINTF(dev, S, ...) device_printf(dev, "%s: " S "\n", __func__, ##__VA_ARGS__)
52 #define _IF_DBG_PRINTF(ifp, S, ...) if_printf(ifp, "%s: " S "\n", __func__, ##__VA_ARGS__)
53
54 /* Defines for printing generic debug information */
55 #define DPRINTF(...) _DBG_PRINTF(__VA_ARGS__)
56 #define DDPRINTF(...) _DEV_DBG_PRINTF(__VA_ARGS__)
57 #define IDPRINTF(...) _IF_DBG_PRINTF(__VA_ARGS__)
58
59 /* Defines for printing specific debug information */
60 #define DEBUG_INIT 1
61 #define DEBUG_IOCTL 1
62 #define DEBUG_HW 1
63
64 #define INIT_DEBUGOUT(...) if (DEBUG_INIT) _DBG_PRINTF(__VA_ARGS__)
65 #define INIT_DBG_DEV(...) if (DEBUG_INIT) _DEV_DBG_PRINTF(__VA_ARGS__)
66 #define INIT_DBG_IF(...) if (DEBUG_INIT) _IF_DBG_PRINTF(__VA_ARGS__)
67
68 #define IOCTL_DEBUGOUT(...) if (DEBUG_IOCTL) _DBG_PRINTF(__VA_ARGS__)
69 #define IOCTL_DBG_IF2(ifp, S, ...) if (DEBUG_IOCTL) \
70 if_printf(ifp, S "\n", ##__VA_ARGS__)
71 #define IOCTL_DBG_IF(...) if (DEBUG_IOCTL) _IF_DBG_PRINTF(__VA_ARGS__)
72
73 #define HW_DEBUGOUT(...) if (DEBUG_HW) _DBG_PRINTF(__VA_ARGS__)
74
75 #else /* no IAVF_DEBUG */
76 #define DEBUG_INIT 0
77 #define DEBUG_IOCTL 0
78 #define DEBUG_HW 0
79
80 #define DPRINTF(...)
81 #define DDPRINTF(...)
82 #define IDPRINTF(...)
83
84 #define INIT_DEBUGOUT(...)
85 #define INIT_DBG_DEV(...)
86 #define INIT_DBG_IF(...)
87 #define IOCTL_DEBUGOUT(...)
88 #define IOCTL_DBG_IF2(...)
89 #define IOCTL_DBG_IF(...)
90 #define HW_DEBUGOUT(...)
91 #endif /* IAVF_DEBUG */
92
93 /**
94 * @enum iavf_dbg_mask
95 * @brief Bitmask values for various debug messages
96 *
97 * Enumeration of possible debug message categories, represented as a bitmask.
98 *
99 * Bits are set in the softc dbg_mask field indicating which messages are
100 * enabled.
101 *
102 * Used by debug print macros in order to compare the message type with the
103 * enabled bits in the dbg_mask to decide whether to print the message or not.
104 */
105 enum iavf_dbg_mask {
106 IAVF_DBG_INFO = 0x00000001,
107 IAVF_DBG_EN_DIS = 0x00000002,
108 IAVF_DBG_AQ = 0x00000004,
109 IAVF_DBG_INIT = 0x00000008,
110 IAVF_DBG_FILTER = 0x00000010,
111
112 IAVF_DBG_RSS = 0x00000100,
113
114 IAVF_DBG_VC = 0x00001000,
115
116 IAVF_DBG_SWITCH_INFO = 0x00010000,
117
118 IAVF_DBG_ALL = 0xFFFFFFFF
119 };
120
121 /* Debug printing */
122 void iavf_debug_core(device_t dev, uint32_t enabled_mask, uint32_t mask, char *fmt, ...) __printflike(4,5);
123
124 #define iavf_dbg(sc, m, s, ...) iavf_debug_core(sc->dev, sc->dbg_mask, m, s, ##__VA_ARGS__)
125 #define iavf_dbg_init(sc, s, ...) iavf_debug_core(sc->dev, sc->dbg_mask, IAVF_DBG_INIT, s, ##__VA_ARGS__)
126 #define iavf_dbg_info(sc, s, ...) iavf_debug_core(sc->dev, sc->dbg_mask, IAVF_DBG_INFO, s, ##__VA_ARGS__)
127 #define iavf_dbg_vc(sc, s, ...) iavf_debug_core(sc->dev, sc->dbg_mask, IAVF_DBG_VC, s, ##__VA_ARGS__)
128 #define iavf_dbg_filter(sc, s, ...) iavf_debug_core(sc->dev, sc->dbg_mask, IAVF_DBG_FILTER, s, ##__VA_ARGS__)
129 #define iavf_dbg_rss(sc, s, ...) iavf_debug_core(sc->dev, sc->dbg_mask, IAVF_DBG_RSS, s, ##__VA_ARGS__)
130
131 #endif /* _IAVF_DEBUG_H_ */
Cache object: f1a128257bb03914326ec39b1644860a
|