xref: /freebsd/sys/dev/ixl/ixl_debug.h (revision 1719886f6d08408b834d270c59ffcfd821c8f63a)
1 /******************************************************************************
2 
3   Copyright (c) 2013-2018, Intel Corporation
4   All rights reserved.
5 
6   Redistribution and use in source and binary forms, with or without
7   modification, are permitted provided that the following conditions are met:
8 
9    1. Redistributions of source code must retain the above copyright notice,
10       this list of conditions and the following disclaimer.
11 
12    2. Redistributions in binary form must reproduce the above copyright
13       notice, this list of conditions and the following disclaimer in the
14       documentation and/or other materials provided with the distribution.
15 
16    3. Neither the name of the Intel Corporation nor the names of its
17       contributors may be used to endorse or promote products derived from
18       this software without specific prior written permission.
19 
20   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30   POSSIBILITY OF SUCH DAMAGE.
31 
32 ******************************************************************************/
33 
34 #ifndef _IXL_DEBUG_H_
35 #define _IXL_DEBUG_H_
36 
37 #define MAC_FORMAT "%02x:%02x:%02x:%02x:%02x:%02x"
38 #define MAC_FORMAT_ARGS(mac_addr) \
39 	(mac_addr)[0], (mac_addr)[1], (mac_addr)[2], (mac_addr)[3], \
40 	(mac_addr)[4], (mac_addr)[5]
41 #define ON_OFF_STR(is_set) ((is_set) ? "On" : "Off")
42 
43 #ifdef IXL_DEBUG
44 
45 #define _DBG_PRINTF(S, ...)		printf("%s: " S "\n", __func__, ##__VA_ARGS__)
46 #define _DEV_DBG_PRINTF(dev, S, ...)	device_printf(dev, "%s: " S "\n", __func__, ##__VA_ARGS__)
47 #define _IF_DBG_PRINTF(ifp, S, ...)	if_printf(ifp, "%s: " S "\n", __func__, ##__VA_ARGS__)
48 
49 /* Defines for printing generic debug information */
50 #define DPRINTF(...)			_DBG_PRINTF(__VA_ARGS__)
51 #define DDPRINTF(...)			_DEV_DBG_PRINTF(__VA_ARGS__)
52 #define IDPRINTF(...)			_IF_DBG_PRINTF(__VA_ARGS__)
53 
54 /* Defines for printing specific debug information */
55 #define DEBUG_INIT  1
56 #define DEBUG_IOCTL 1
57 #define DEBUG_HW    1
58 
59 #define INIT_DEBUGOUT(...)		if (DEBUG_INIT) _DBG_PRINTF(__VA_ARGS__)
60 #define INIT_DBG_DEV(...)		if (DEBUG_INIT) _DEV_DBG_PRINTF(__VA_ARGS__)
61 #define INIT_DBG_IF(...)		if (DEBUG_INIT) _IF_DBG_PRINTF(__VA_ARGS__)
62 
63 #define IOCTL_DEBUGOUT(...)		if (DEBUG_IOCTL) _DBG_PRINTF(__VA_ARGS__)
64 #define IOCTL_DBG_IF2(ifp, S, ...)	if (DEBUG_IOCTL) \
65 					    if_printf(ifp, S "\n", ##__VA_ARGS__)
66 #define IOCTL_DBG_IF(...)		if (DEBUG_IOCTL) _IF_DBG_PRINTF(__VA_ARGS__)
67 
68 #define HW_DEBUGOUT(...)		if (DEBUG_HW) _DBG_PRINTF(__VA_ARGS__)
69 
70 #else /* no IXL_DEBUG */
71 #define DEBUG_INIT  0
72 #define DEBUG_IOCTL 0
73 #define DEBUG_HW    0
74 
75 #define DPRINTF(...)
76 #define DDPRINTF(...)
77 #define IDPRINTF(...)
78 
79 #define INIT_DEBUGOUT(...)
80 #define INIT_DBG_DEV(...)
81 #define INIT_DBG_IF(...)
82 #define IOCTL_DEBUGOUT(...)
83 #define IOCTL_DBG_IF2(...)
84 #define IOCTL_DBG_IF(...)
85 #define HW_DEBUGOUT(...)
86 #endif /* IXL_DEBUG */
87 
88 enum ixl_dbg_mask {
89 	IXL_DBG_INFO			= 0x00000001,
90 	IXL_DBG_EN_DIS			= 0x00000002,
91 	IXL_DBG_AQ			= 0x00000004,
92 	IXL_DBG_NVMUPD			= 0x00000008,
93 	IXL_DBG_FILTER			= 0x00000010,
94 
95 	IXL_DEBUG_RSS			= 0x00000100,
96 
97 	IXL_DBG_IOV			= 0x00001000,
98 	IXL_DBG_IOV_VC			= 0x00002000,
99 
100 	IXL_DBG_SWITCH_INFO		= 0x00010000,
101 	IXL_DBG_I2C			= 0x00020000,
102 
103 	IXL_DBG_LINK			= 0x00100000,
104 
105 	IXL_DBG_ALL			= 0xFFFFFFFF
106 };
107 
108 enum iavf_dbg_mask {
109 	IAVF_DBG_INFO			= 0x00000001,
110 	IAVF_DBG_EN_DIS			= 0x00000002,
111 	IAVF_DBG_AQ			= 0x00000004,
112 	IAVF_DBG_INIT			= 0x00000008,
113 	IAVF_DBG_FILTER			= 0x00000010,
114 
115 	IAVF_DEBUG_RSS			= 0x00000100,
116 
117 	IAVF_DBG_VC			= 0x00001000,
118 
119 	IAVF_DBG_SWITCH_INFO		= 0x00010000,
120 
121 	IAVF_DBG_ALL			= 0xFFFFFFFF
122 };
123 
124 #endif /* _IXL_DEBUG_H_ */
125