1f92363d1SSreekanth Reddy /*
2f92363d1SSreekanth Reddy * Logging Support for MPT (Message Passing Technology) based controllers
3f92363d1SSreekanth Reddy *
4f92363d1SSreekanth Reddy * This code is based on drivers/scsi/mpt3sas/mpt3sas_debug.c
5a4ffce0dSSreekanth Reddy * Copyright (C) 2012-2014 LSI Corporation
6a03bd153SSreekanth Reddy * Copyright (C) 2013-2014 Avago Technologies
7a03bd153SSreekanth Reddy * (mailto: MPT-FusionLinux.pdl@avagotech.com)
8f92363d1SSreekanth Reddy *
9f92363d1SSreekanth Reddy * This program is free software; you can redistribute it and/or
10f92363d1SSreekanth Reddy * modify it under the terms of the GNU General Public License
11f92363d1SSreekanth Reddy * as published by the Free Software Foundation; either version 2
12f92363d1SSreekanth Reddy * of the License, or (at your option) any later version.
13f92363d1SSreekanth Reddy *
14f92363d1SSreekanth Reddy * This program is distributed in the hope that it will be useful,
15f92363d1SSreekanth Reddy * but WITHOUT ANY WARRANTY; without even the implied warranty of
16f92363d1SSreekanth Reddy * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17f92363d1SSreekanth Reddy * GNU General Public License for more details.
18f92363d1SSreekanth Reddy *
19f92363d1SSreekanth Reddy * NO WARRANTY
20f92363d1SSreekanth Reddy * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
21f92363d1SSreekanth Reddy * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
22f92363d1SSreekanth Reddy * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
23f92363d1SSreekanth Reddy * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
24f92363d1SSreekanth Reddy * solely responsible for determining the appropriateness of using and
25f92363d1SSreekanth Reddy * distributing the Program and assumes all risks associated with its
26f92363d1SSreekanth Reddy * exercise of rights under this Agreement, including but not limited to
27f92363d1SSreekanth Reddy * the risks and costs of program errors, damage to or loss of data,
28f92363d1SSreekanth Reddy * programs or equipment, and unavailability or interruption of operations.
29f92363d1SSreekanth Reddy
30f92363d1SSreekanth Reddy * DISCLAIMER OF LIABILITY
31f92363d1SSreekanth Reddy * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
32f92363d1SSreekanth Reddy * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33f92363d1SSreekanth Reddy * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
34f92363d1SSreekanth Reddy * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
35f92363d1SSreekanth Reddy * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
36f92363d1SSreekanth Reddy * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
37f92363d1SSreekanth Reddy * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
38f92363d1SSreekanth Reddy
39f92363d1SSreekanth Reddy * You should have received a copy of the GNU General Public License
40f92363d1SSreekanth Reddy * along with this program; if not, write to the Free Software
41f92363d1SSreekanth Reddy * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
42f92363d1SSreekanth Reddy * USA.
43f92363d1SSreekanth Reddy */
44f92363d1SSreekanth Reddy
45f92363d1SSreekanth Reddy #ifndef MPT3SAS_DEBUG_H_INCLUDED
46f92363d1SSreekanth Reddy #define MPT3SAS_DEBUG_H_INCLUDED
47f92363d1SSreekanth Reddy
48f92363d1SSreekanth Reddy #define MPT_DEBUG 0x00000001
49f92363d1SSreekanth Reddy #define MPT_DEBUG_MSG_FRAME 0x00000002
50f92363d1SSreekanth Reddy #define MPT_DEBUG_SG 0x00000004
51f92363d1SSreekanth Reddy #define MPT_DEBUG_EVENTS 0x00000008
52f92363d1SSreekanth Reddy #define MPT_DEBUG_EVENT_WORK_TASK 0x00000010
53f92363d1SSreekanth Reddy #define MPT_DEBUG_INIT 0x00000020
54f92363d1SSreekanth Reddy #define MPT_DEBUG_EXIT 0x00000040
55f92363d1SSreekanth Reddy #define MPT_DEBUG_FAIL 0x00000080
56f92363d1SSreekanth Reddy #define MPT_DEBUG_TM 0x00000100
57f92363d1SSreekanth Reddy #define MPT_DEBUG_REPLY 0x00000200
58f92363d1SSreekanth Reddy #define MPT_DEBUG_HANDSHAKE 0x00000400
59f92363d1SSreekanth Reddy #define MPT_DEBUG_CONFIG 0x00000800
60f92363d1SSreekanth Reddy #define MPT_DEBUG_DL 0x00001000
61f92363d1SSreekanth Reddy #define MPT_DEBUG_RESET 0x00002000
62f92363d1SSreekanth Reddy #define MPT_DEBUG_SCSI 0x00004000
63f92363d1SSreekanth Reddy #define MPT_DEBUG_IOCTL 0x00008000
64f92363d1SSreekanth Reddy #define MPT_DEBUG_SAS 0x00020000
65f92363d1SSreekanth Reddy #define MPT_DEBUG_TRANSPORT 0x00040000
66f92363d1SSreekanth Reddy #define MPT_DEBUG_TASK_SET_FULL 0x00080000
67f92363d1SSreekanth Reddy
68f92363d1SSreekanth Reddy #define MPT_DEBUG_TRIGGER_DIAG 0x00200000
69f92363d1SSreekanth Reddy
70f92363d1SSreekanth Reddy
71f92363d1SSreekanth Reddy #define MPT_CHECK_LOGGING(IOC, CMD, BITS) \
72f92363d1SSreekanth Reddy { \
73f92363d1SSreekanth Reddy if (IOC->logging_level & BITS) \
74f92363d1SSreekanth Reddy CMD; \
75f92363d1SSreekanth Reddy }
76f92363d1SSreekanth Reddy
77f92363d1SSreekanth Reddy /*
78f92363d1SSreekanth Reddy * debug macros
79f92363d1SSreekanth Reddy */
80f92363d1SSreekanth Reddy
81f92363d1SSreekanth Reddy #define dprintk(IOC, CMD) \
82f92363d1SSreekanth Reddy MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG)
83f92363d1SSreekanth Reddy
84f92363d1SSreekanth Reddy #define dsgprintk(IOC, CMD) \
85f92363d1SSreekanth Reddy MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SG)
86f92363d1SSreekanth Reddy
87f92363d1SSreekanth Reddy #define devtprintk(IOC, CMD) \
88f92363d1SSreekanth Reddy MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_EVENTS)
89f92363d1SSreekanth Reddy
90f92363d1SSreekanth Reddy #define dewtprintk(IOC, CMD) \
91f92363d1SSreekanth Reddy MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_EVENT_WORK_TASK)
92f92363d1SSreekanth Reddy
93f92363d1SSreekanth Reddy #define dinitprintk(IOC, CMD) \
94f92363d1SSreekanth Reddy MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_INIT)
95f92363d1SSreekanth Reddy
96f92363d1SSreekanth Reddy #define dexitprintk(IOC, CMD) \
97f92363d1SSreekanth Reddy MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_EXIT)
98f92363d1SSreekanth Reddy
99f92363d1SSreekanth Reddy #define dfailprintk(IOC, CMD) \
100f92363d1SSreekanth Reddy MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_FAIL)
101f92363d1SSreekanth Reddy
102f92363d1SSreekanth Reddy #define dtmprintk(IOC, CMD) \
103f92363d1SSreekanth Reddy MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_TM)
104f92363d1SSreekanth Reddy
105f92363d1SSreekanth Reddy #define dreplyprintk(IOC, CMD) \
106f92363d1SSreekanth Reddy MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_REPLY)
107f92363d1SSreekanth Reddy
108f92363d1SSreekanth Reddy #define dhsprintk(IOC, CMD) \
109f92363d1SSreekanth Reddy MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_HANDSHAKE)
110f92363d1SSreekanth Reddy
111f92363d1SSreekanth Reddy #define dcprintk(IOC, CMD) \
112f92363d1SSreekanth Reddy MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_CONFIG)
113f92363d1SSreekanth Reddy
114f92363d1SSreekanth Reddy #define ddlprintk(IOC, CMD) \
115f92363d1SSreekanth Reddy MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_DL)
116f92363d1SSreekanth Reddy
117f92363d1SSreekanth Reddy #define drsprintk(IOC, CMD) \
118f92363d1SSreekanth Reddy MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_RESET)
119f92363d1SSreekanth Reddy
120f92363d1SSreekanth Reddy #define dsprintk(IOC, CMD) \
121f92363d1SSreekanth Reddy MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SCSI)
122f92363d1SSreekanth Reddy
123f92363d1SSreekanth Reddy #define dctlprintk(IOC, CMD) \
124f92363d1SSreekanth Reddy MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_IOCTL)
125f92363d1SSreekanth Reddy
126f92363d1SSreekanth Reddy #define dsasprintk(IOC, CMD) \
127f92363d1SSreekanth Reddy MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SAS)
128f92363d1SSreekanth Reddy
129f92363d1SSreekanth Reddy #define dsastransport(IOC, CMD) \
130f92363d1SSreekanth Reddy MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SAS_WIDE)
131f92363d1SSreekanth Reddy
132f92363d1SSreekanth Reddy #define dmfprintk(IOC, CMD) \
133f92363d1SSreekanth Reddy MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_MSG_FRAME)
134f92363d1SSreekanth Reddy
135f92363d1SSreekanth Reddy #define dtsfprintk(IOC, CMD) \
136f92363d1SSreekanth Reddy MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_TASK_SET_FULL)
137f92363d1SSreekanth Reddy
138f92363d1SSreekanth Reddy #define dtransportprintk(IOC, CMD) \
139f92363d1SSreekanth Reddy MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_TRANSPORT)
140f92363d1SSreekanth Reddy
141f92363d1SSreekanth Reddy #define dTriggerDiagPrintk(IOC, CMD) \
142f92363d1SSreekanth Reddy MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_TRIGGER_DIAG)
143f92363d1SSreekanth Reddy
144f92363d1SSreekanth Reddy
145f92363d1SSreekanth Reddy
146f92363d1SSreekanth Reddy /* inline functions for dumping debug data*/
147*af009411SSreekanth Reddy
148f92363d1SSreekanth Reddy /**
149f92363d1SSreekanth Reddy * _debug_dump_mf - print message frame contents
150f92363d1SSreekanth Reddy * @mpi_request: pointer to message frame
151f92363d1SSreekanth Reddy * @sz: number of dwords
152f92363d1SSreekanth Reddy */
153f92363d1SSreekanth Reddy static inline void
_debug_dump_mf(void * mpi_request,int sz)154f92363d1SSreekanth Reddy _debug_dump_mf(void *mpi_request, int sz)
155f92363d1SSreekanth Reddy {
156f92363d1SSreekanth Reddy int i;
157f92363d1SSreekanth Reddy __le32 *mfp = (__le32 *)mpi_request;
158f92363d1SSreekanth Reddy
159f92363d1SSreekanth Reddy pr_info("mf:\n\t");
160f92363d1SSreekanth Reddy for (i = 0; i < sz; i++) {
161f92363d1SSreekanth Reddy if (i && ((i % 8) == 0))
162f92363d1SSreekanth Reddy pr_info("\n\t");
163f92363d1SSreekanth Reddy pr_info("%08x ", le32_to_cpu(mfp[i]));
164f92363d1SSreekanth Reddy }
165f92363d1SSreekanth Reddy pr_info("\n");
166f92363d1SSreekanth Reddy }
167f92363d1SSreekanth Reddy /**
168f92363d1SSreekanth Reddy * _debug_dump_reply - print message frame contents
169f92363d1SSreekanth Reddy * @mpi_request: pointer to message frame
170f92363d1SSreekanth Reddy * @sz: number of dwords
171f92363d1SSreekanth Reddy */
172f92363d1SSreekanth Reddy static inline void
_debug_dump_reply(void * mpi_request,int sz)173f92363d1SSreekanth Reddy _debug_dump_reply(void *mpi_request, int sz)
174f92363d1SSreekanth Reddy {
175f92363d1SSreekanth Reddy int i;
176f92363d1SSreekanth Reddy __le32 *mfp = (__le32 *)mpi_request;
177f92363d1SSreekanth Reddy
178f92363d1SSreekanth Reddy pr_info("reply:\n\t");
179f92363d1SSreekanth Reddy for (i = 0; i < sz; i++) {
180f92363d1SSreekanth Reddy if (i && ((i % 8) == 0))
181f92363d1SSreekanth Reddy pr_info("\n\t");
182f92363d1SSreekanth Reddy pr_info("%08x ", le32_to_cpu(mfp[i]));
183f92363d1SSreekanth Reddy }
184f92363d1SSreekanth Reddy pr_info("\n");
185f92363d1SSreekanth Reddy }
186f92363d1SSreekanth Reddy /**
187f92363d1SSreekanth Reddy * _debug_dump_config - print config page contents
188f92363d1SSreekanth Reddy * @mpi_request: pointer to message frame
189f92363d1SSreekanth Reddy * @sz: number of dwords
190f92363d1SSreekanth Reddy */
191f92363d1SSreekanth Reddy static inline void
_debug_dump_config(void * mpi_request,int sz)192f92363d1SSreekanth Reddy _debug_dump_config(void *mpi_request, int sz)
193f92363d1SSreekanth Reddy {
194f92363d1SSreekanth Reddy int i;
195f92363d1SSreekanth Reddy __le32 *mfp = (__le32 *)mpi_request;
196f92363d1SSreekanth Reddy
197f92363d1SSreekanth Reddy pr_info("config:\n\t");
198f92363d1SSreekanth Reddy for (i = 0; i < sz; i++) {
199f92363d1SSreekanth Reddy if (i && ((i % 8) == 0))
200f92363d1SSreekanth Reddy pr_info("\n\t");
201f92363d1SSreekanth Reddy pr_info("%08x ", le32_to_cpu(mfp[i]));
202f92363d1SSreekanth Reddy }
203f92363d1SSreekanth Reddy pr_info("\n");
204f92363d1SSreekanth Reddy }
205f92363d1SSreekanth Reddy
206f92363d1SSreekanth Reddy #endif /* MPT3SAS_DEBUG_H_INCLUDED */
207