]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/qlxge/qls_dbg.c
Merge tag 'vendor/ena-com/2.4.0'
[FreeBSD/FreeBSD.git] / sys / dev / qlxge / qls_dbg.c
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3  *
4  * Copyright (c) 2013-2014 Qlogic Corporation
5  * All rights reserved.
6  *
7  *  Redistribution and use in source and binary forms, with or without
8  *  modification, are permitted provided that the following conditions
9  *  are met:
10  *
11  *  1. Redistributions of source code must retain the above copyright
12  *     notice, this list of conditions and the following disclaimer.
13  *  2. Redistributions in binary form must reproduce the above copyright
14  *     notice, this list of conditions and the following disclaimer in the
15  *     documentation and/or other materials provided with the distribution.
16  *
17  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  *  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  *  POSSIBILITY OF SUCH DAMAGE.
28  */
29 /*
30  * File : qls_dbg.c
31  * Author : David C Somayajulu, Qlogic Corporation, Aliso Viejo, CA 92656.
32  */
33 #include <sys/cdefs.h>
34 __FBSDID("$FreeBSD$");
35
36 #include "qls_os.h"
37 #include "qls_hw.h"
38 #include "qls_def.h"
39 #include "qls_inline.h"
40 #include "qls_ver.h"
41 #include "qls_glbl.h"
42 #include "qls_dbg.h"
43
44 uint32_t qls_dbg_level = 0 ;
45 /*
46  * Name: qls_dump_buf32
47  * Function: dumps a buffer as 32 bit words
48  */
49 void
50 qls_dump_buf32(qla_host_t *ha, const char *msg, void *dbuf32, uint32_t len32)
51 {
52         device_t dev;
53         uint32_t i = 0;
54         uint32_t *buf;
55
56         dev = ha->pci_dev;
57         buf = dbuf32;
58
59         device_printf(dev, "%s: %s dump start\n", __func__, msg);
60
61         while (len32 >= 4) {
62                 device_printf(dev,"0x%08x:\t0x%08x, 0x%08x, 0x%08x, 0x%08x,\n",
63                         i, buf[0], buf[1], buf[2], buf[3]);
64                 i += 4 * 4;
65                 len32 -= 4;
66                 buf += 4;
67         }
68         switch (len32) {
69         case 1:
70                 device_printf(dev,"0x%08x: 0x%08x\n", i, buf[0]);
71                 break;
72         case 2:
73                 device_printf(dev,"0x%08x: 0x%08x 0x%08x\n", i, buf[0], buf[1]);
74                 break;
75         case 3:
76                 device_printf(dev,"0x%08x: 0x%08x 0x%08x 0x%08x\n",
77                         i, buf[0], buf[1], buf[2]);
78                 break;
79         default:
80                 break;
81         }
82         device_printf(dev, "%s: %s dump end\n", __func__, msg);
83
84         return;
85 }
86
87 /*
88  * Name: qls_dump_buf16
89  * Function: dumps a buffer as 16 bit words
90  */
91 void
92 qls_dump_buf16(qla_host_t *ha, const char *msg, void *dbuf16, uint32_t len16)
93 {
94         device_t dev;
95         uint32_t i = 0;
96         uint16_t *buf;
97
98         dev = ha->pci_dev;
99         buf = dbuf16;
100
101         device_printf(dev, "%s: %s dump start\n", __func__, msg);
102
103         while (len16 >= 8) {
104                 device_printf(dev,"0x%08x: 0x%04x 0x%04x 0x%04x 0x%04x"
105                         " 0x%04x 0x%04x 0x%04x 0x%04x\n", i, buf[0],
106                         buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7]);
107                 i += 16;
108                 len16 -= 8;
109                 buf += 8;
110         }
111         switch (len16) {
112         case 1:
113                 device_printf(dev,"0x%08x: 0x%04x\n", i, buf[0]);
114                 break;
115         case 2:
116                 device_printf(dev,"0x%08x: 0x%04x 0x%04x\n", i, buf[0], buf[1]);
117                 break;
118         case 3:
119                 device_printf(dev,"0x%08x: 0x%04x 0x%04x 0x%04x\n",
120                         i, buf[0], buf[1], buf[2]);
121                 break;
122         case 4:
123                 device_printf(dev,"0x%08x: 0x%04x 0x%04x 0x%04x 0x%04x\n", i,
124                         buf[0], buf[1], buf[2], buf[3]);
125                 break;
126         case 5:
127                 device_printf(dev,"0x%08x:"
128                         " 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x\n", i,
129                         buf[0], buf[1], buf[2], buf[3], buf[4]);
130                 break;
131         case 6:
132                 device_printf(dev,"0x%08x:"
133                         " 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x\n", i,
134                         buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]);
135                 break;
136         case 7:
137                 device_printf(dev,"0x%04x: 0x%04x 0x%04x 0x%04x 0x%04x"
138                         " 0x%04x 0x%04x 0x%04x\n", i, buf[0], buf[1],
139                         buf[2], buf[3], buf[4], buf[5], buf[6]);
140                 break;
141         default:
142                 break;
143         }
144         device_printf(dev, "%s: %s dump end\n", __func__, msg);
145
146         return;
147 }
148
149 /*
150  * Name: qls_dump_buf8
151  * Function: dumps a buffer as bytes
152  */
153 void
154 qls_dump_buf8(qla_host_t *ha, const char *msg, void *dbuf, uint32_t len)
155 {
156         device_t dev;
157         uint32_t i = 0;
158         uint8_t *buf;
159
160         dev = ha->pci_dev;
161         buf = dbuf;
162
163         device_printf(dev, "%s: %s 0x%x dump start\n", __func__, msg, len);
164
165         while (len >= 16) {
166                 device_printf(dev,"0x%08x:"
167                         " %02x %02x %02x %02x %02x %02x %02x %02x"
168                         " %02x %02x %02x %02x %02x %02x %02x %02x\n", i,
169                         buf[0], buf[1], buf[2], buf[3],
170                         buf[4], buf[5], buf[6], buf[7],
171                         buf[8], buf[9], buf[10], buf[11],
172                         buf[12], buf[13], buf[14], buf[15]);
173                 i += 16;
174                 len -= 16;
175                 buf += 16;
176         }
177         switch (len) {
178         case 1:
179                 device_printf(dev,"0x%08x: %02x\n", i, buf[0]);
180                 break;
181         case 2:
182                 device_printf(dev,"0x%08x: %02x %02x\n", i, buf[0], buf[1]);
183                 break;
184         case 3:
185                 device_printf(dev,"0x%08x: %02x %02x %02x\n",
186                         i, buf[0], buf[1], buf[2]);
187                 break;
188         case 4:
189                 device_printf(dev,"0x%08x: %02x %02x %02x %02x\n", i,
190                         buf[0], buf[1], buf[2], buf[3]);
191                 break;
192         case 5:
193                 device_printf(dev,"0x%08x:"
194                         " %02x %02x %02x %02x %02x\n", i,
195                         buf[0], buf[1], buf[2], buf[3], buf[4]);
196                 break;
197         case 6:
198                 device_printf(dev,"0x%08x:"
199                         " %02x %02x %02x %02x %02x %02x\n", i,
200                         buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]);
201                 break;
202         case 7:
203                 device_printf(dev,"0x%08x:"
204                         " %02x %02x %02x %02x %02x %02x %02x\n", i,
205                         buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6]);
206                 break;
207         case 8:
208                 device_printf(dev,"0x%08x:"
209                         " %02x %02x %02x %02x %02x %02x %02x %02x\n", i,
210                         buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6],
211                         buf[7]);
212                 break;
213         case 9:
214                 device_printf(dev,"0x%08x:"
215                         " %02x %02x %02x %02x %02x %02x %02x %02x"
216                         " %02x\n", i,
217                         buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6],
218                         buf[7], buf[8]);
219                 break;
220         case 10:
221                 device_printf(dev,"0x%08x:"
222                         " %02x %02x %02x %02x %02x %02x %02x %02x"
223                         " %02x %02x\n", i,
224                         buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6],
225                         buf[7], buf[8], buf[9]);
226                 break;
227         case 11:
228                 device_printf(dev,"0x%08x:"
229                         " %02x %02x %02x %02x %02x %02x %02x %02x"
230                         " %02x %02x %02x\n", i,
231                         buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6],
232                         buf[7], buf[8], buf[9], buf[10]);
233                 break;
234         case 12:
235                 device_printf(dev,"0x%08x:"
236                         " %02x %02x %02x %02x %02x %02x %02x %02x"
237                         " %02x %02x %02x %02x\n", i,
238                         buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6],
239                         buf[7], buf[8], buf[9], buf[10], buf[11]);
240                 break;
241         case 13:
242                 device_printf(dev,"0x%08x:"
243                         " %02x %02x %02x %02x %02x %02x %02x %02x"
244                         " %02x %02x %02x %02x %02x\n", i,
245                         buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6],
246                         buf[7], buf[8], buf[9], buf[10], buf[11], buf[12]);
247                 break;
248         case 14:
249                 device_printf(dev,"0x%08x:"
250                         " %02x %02x %02x %02x %02x %02x %02x %02x"
251                         " %02x %02x %02x %02x %02x %02x\n", i,
252                         buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6],
253                         buf[7], buf[8], buf[9], buf[10], buf[11], buf[12],
254                         buf[13]);
255                 break;
256         case 15:
257                 device_printf(dev,"0x%08x:"
258                         " %02x %02x %02x %02x %02x %02x %02x %02x"
259                         " %02x %02x %02x %02x %02x %02x %02x\n", i,
260                         buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6],
261                         buf[7], buf[8], buf[9], buf[10], buf[11], buf[12],
262                         buf[13], buf[14]);
263                 break;
264         default:
265                 break;
266         }
267
268         device_printf(dev, "%s: %s dump end\n", __func__, msg);
269
270         return;
271 }
272
273 void
274 qls_dump_cq(qla_host_t *ha)
275 {
276         qls_dump_buf32(ha, "cq_icb", ha->rx_ring[0].cq_icb_vaddr,
277                 (sizeof (q81_cq_icb_t) >> 2));
278
279         device_printf(ha->pci_dev, "%s: lbq_addr_tbl_paddr  %p\n", __func__,
280                 (void *)ha->rx_ring[0].lbq_addr_tbl_paddr);
281
282         qls_dump_buf32(ha, "lbq_addr_tbl", ha->rx_ring[0].lbq_addr_tbl_vaddr,
283                 (PAGE_SIZE >> 2));
284
285         device_printf(ha->pci_dev, "%s: lbq_paddr  %p\n", __func__,
286                 (void *)ha->rx_ring[0].lbq_paddr);
287
288         qls_dump_buf32(ha, "lbq", ha->rx_ring[0].lbq_vaddr,
289                 (QLA_LBQ_SIZE >> 2));
290
291         device_printf(ha->pci_dev, "%s: sbq_addr_tbl_paddr  %p\n", __func__,
292                 (void *)ha->rx_ring[0].sbq_addr_tbl_paddr);
293
294         qls_dump_buf32(ha, "sbq_addr_tbl", ha->rx_ring[0].sbq_addr_tbl_vaddr,
295                 (PAGE_SIZE >> 2));
296
297         device_printf(ha->pci_dev, "%s: sbq_paddr  %p\n", __func__,
298                 (void *)ha->rx_ring[0].sbq_paddr);
299
300         qls_dump_buf32(ha, "sbq", ha->rx_ring[0].sbq_vaddr,
301                 (QLA_SBQ_SIZE >> 2) );
302
303         device_printf(ha->pci_dev, "%s: lb_paddr  %p\n", __func__,
304                 (void *)ha->rx_ring[0].lb_paddr);
305
306         return;
307 }