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