diff options
Diffstat (limited to 'drivers/infiniband/hw/cxgb3/cxio_dbg.c')
-rw-r--r-- | drivers/infiniband/hw/cxgb3/cxio_dbg.c | 207 |
1 files changed, 207 insertions, 0 deletions
diff --git a/drivers/infiniband/hw/cxgb3/cxio_dbg.c b/drivers/infiniband/hw/cxgb3/cxio_dbg.c new file mode 100644 index 00000000000..5a7306f5efa --- /dev/null +++ b/drivers/infiniband/hw/cxgb3/cxio_dbg.c | |||
@@ -0,0 +1,207 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2006 Chelsio, Inc. All rights reserved. | ||
3 | * Copyright (c) 2006 Open Grid Computing, Inc. All rights reserved. | ||
4 | * | ||
5 | * This software is available to you under a choice of one of two | ||
6 | * licenses. You may choose to be licensed under the terms of the GNU | ||
7 | * General Public License (GPL) Version 2, available from the file | ||
8 | * COPYING in the main directory of this source tree, or the | ||
9 | * OpenIB.org BSD license below: | ||
10 | * | ||
11 | * Redistribution and use in source and binary forms, with or | ||
12 | * without modification, are permitted provided that the following | ||
13 | * conditions are met: | ||
14 | * | ||
15 | * - Redistributions of source code must retain the above | ||
16 | * copyright notice, this list of conditions and the following | ||
17 | * disclaimer. | ||
18 | * | ||
19 | * - Redistributions in binary form must reproduce the above | ||
20 | * copyright notice, this list of conditions and the following | ||
21 | * disclaimer in the documentation and/or other materials | ||
22 | * provided with the distribution. | ||
23 | * | ||
24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
25 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
26 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
27 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
28 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
29 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
30 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
31 | * SOFTWARE. | ||
32 | */ | ||
33 | #ifdef DEBUG | ||
34 | #include <linux/types.h> | ||
35 | #include "common.h" | ||
36 | #include "cxgb3_ioctl.h" | ||
37 | #include "cxio_hal.h" | ||
38 | #include "cxio_wr.h" | ||
39 | |||
40 | void cxio_dump_tpt(struct cxio_rdev *rdev, u32 stag) | ||
41 | { | ||
42 | struct ch_mem_range *m; | ||
43 | u64 *data; | ||
44 | int rc; | ||
45 | int size = 32; | ||
46 | |||
47 | m = kmalloc(sizeof(*m) + size, GFP_ATOMIC); | ||
48 | if (!m) { | ||
49 | PDBG("%s couldn't allocate memory.\n", __FUNCTION__); | ||
50 | return; | ||
51 | } | ||
52 | m->mem_id = MEM_PMRX; | ||
53 | m->addr = (stag>>8) * 32 + rdev->rnic_info.tpt_base; | ||
54 | m->len = size; | ||
55 | PDBG("%s TPT addr 0x%x len %d\n", __FUNCTION__, m->addr, m->len); | ||
56 | rc = rdev->t3cdev_p->ctl(rdev->t3cdev_p, RDMA_GET_MEM, m); | ||
57 | if (rc) { | ||
58 | PDBG("%s toectl returned error %d\n", __FUNCTION__, rc); | ||
59 | kfree(m); | ||
60 | return; | ||
61 | } | ||
62 | |||
63 | data = (u64 *)m->buf; | ||
64 | while (size > 0) { | ||
65 | PDBG("TPT %08x: %016llx\n", m->addr, (unsigned long long) *data); | ||
66 | size -= 8; | ||
67 | data++; | ||
68 | m->addr += 8; | ||
69 | } | ||
70 | kfree(m); | ||
71 | } | ||
72 | |||
73 | void cxio_dump_pbl(struct cxio_rdev *rdev, u32 pbl_addr, uint len, u8 shift) | ||
74 | { | ||
75 | struct ch_mem_range *m; | ||
76 | u64 *data; | ||
77 | int rc; | ||
78 | int size, npages; | ||
79 | |||
80 | shift += 12; | ||
81 | npages = (len + (1ULL << shift) - 1) >> shift; | ||
82 | size = npages * sizeof(u64); | ||
83 | |||
84 | m = kmalloc(sizeof(*m) + size, GFP_ATOMIC); | ||
85 | if (!m) { | ||
86 | PDBG("%s couldn't allocate memory.\n", __FUNCTION__); | ||
87 | return; | ||
88 | } | ||
89 | m->mem_id = MEM_PMRX; | ||
90 | m->addr = pbl_addr; | ||
91 | m->len = size; | ||
92 | PDBG("%s PBL addr 0x%x len %d depth %d\n", | ||
93 | __FUNCTION__, m->addr, m->len, npages); | ||
94 | rc = rdev->t3cdev_p->ctl(rdev->t3cdev_p, RDMA_GET_MEM, m); | ||
95 | if (rc) { | ||
96 | PDBG("%s toectl returned error %d\n", __FUNCTION__, rc); | ||
97 | kfree(m); | ||
98 | return; | ||
99 | } | ||
100 | |||
101 | data = (u64 *)m->buf; | ||
102 | while (size > 0) { | ||
103 | PDBG("PBL %08x: %016llx\n", m->addr, (unsigned long long) *data); | ||
104 | size -= 8; | ||
105 | data++; | ||
106 | m->addr += 8; | ||
107 | } | ||
108 | kfree(m); | ||
109 | } | ||
110 | |||
111 | void cxio_dump_wqe(union t3_wr *wqe) | ||
112 | { | ||
113 | __be64 *data = (__be64 *)wqe; | ||
114 | uint size = (uint)(be64_to_cpu(*data) & 0xff); | ||
115 | |||
116 | if (size == 0) | ||
117 | size = 8; | ||
118 | while (size > 0) { | ||
119 | PDBG("WQE %p: %016llx\n", data, | ||
120 | (unsigned long long) be64_to_cpu(*data)); | ||
121 | size--; | ||
122 | data++; | ||
123 | } | ||
124 | } | ||
125 | |||
126 | void cxio_dump_wce(struct t3_cqe *wce) | ||
127 | { | ||
128 | __be64 *data = (__be64 *)wce; | ||
129 | int size = sizeof(*wce); | ||
130 | |||
131 | while (size > 0) { | ||
132 | PDBG("WCE %p: %016llx\n", data, | ||
133 | (unsigned long long) be64_to_cpu(*data)); | ||
134 | size -= 8; | ||
135 | data++; | ||
136 | } | ||
137 | } | ||
138 | |||
139 | void cxio_dump_rqt(struct cxio_rdev *rdev, u32 hwtid, int nents) | ||
140 | { | ||
141 | struct ch_mem_range *m; | ||
142 | int size = nents * 64; | ||
143 | u64 *data; | ||
144 | int rc; | ||
145 | |||
146 | m = kmalloc(sizeof(*m) + size, GFP_ATOMIC); | ||
147 | if (!m) { | ||
148 | PDBG("%s couldn't allocate memory.\n", __FUNCTION__); | ||
149 | return; | ||
150 | } | ||
151 | m->mem_id = MEM_PMRX; | ||
152 | m->addr = ((hwtid)<<10) + rdev->rnic_info.rqt_base; | ||
153 | m->len = size; | ||
154 | PDBG("%s RQT addr 0x%x len %d\n", __FUNCTION__, m->addr, m->len); | ||
155 | rc = rdev->t3cdev_p->ctl(rdev->t3cdev_p, RDMA_GET_MEM, m); | ||
156 | if (rc) { | ||
157 | PDBG("%s toectl returned error %d\n", __FUNCTION__, rc); | ||
158 | kfree(m); | ||
159 | return; | ||
160 | } | ||
161 | |||
162 | data = (u64 *)m->buf; | ||
163 | while (size > 0) { | ||
164 | PDBG("RQT %08x: %016llx\n", m->addr, (unsigned long long) *data); | ||
165 | size -= 8; | ||
166 | data++; | ||
167 | m->addr += 8; | ||
168 | } | ||
169 | kfree(m); | ||
170 | } | ||
171 | |||
172 | void cxio_dump_tcb(struct cxio_rdev *rdev, u32 hwtid) | ||
173 | { | ||
174 | struct ch_mem_range *m; | ||
175 | int size = TCB_SIZE; | ||
176 | u32 *data; | ||
177 | int rc; | ||
178 | |||
179 | m = kmalloc(sizeof(*m) + size, GFP_ATOMIC); | ||
180 | if (!m) { | ||
181 | PDBG("%s couldn't allocate memory.\n", __FUNCTION__); | ||
182 | return; | ||
183 | } | ||
184 | m->mem_id = MEM_CM; | ||
185 | m->addr = hwtid * size; | ||
186 | m->len = size; | ||
187 | PDBG("%s TCB %d len %d\n", __FUNCTION__, m->addr, m->len); | ||
188 | rc = rdev->t3cdev_p->ctl(rdev->t3cdev_p, RDMA_GET_MEM, m); | ||
189 | if (rc) { | ||
190 | PDBG("%s toectl returned error %d\n", __FUNCTION__, rc); | ||
191 | kfree(m); | ||
192 | return; | ||
193 | } | ||
194 | |||
195 | data = (u32 *)m->buf; | ||
196 | while (size > 0) { | ||
197 | printk("%2u: %08x %08x %08x %08x %08x %08x %08x %08x\n", | ||
198 | m->addr, | ||
199 | *(data+2), *(data+3), *(data),*(data+1), | ||
200 | *(data+6), *(data+7), *(data+4), *(data+5)); | ||
201 | size -= 32; | ||
202 | data += 8; | ||
203 | m->addr += 32; | ||
204 | } | ||
205 | kfree(m); | ||
206 | } | ||
207 | #endif | ||