1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32#ifdef DEBUG
33#include <linux/types.h>
34#include <linux/slab.h>
35#include "common.h"
36#include "cxgb3_ioctl.h"
37#include "cxio_hal.h"
38#include "cxio_wr.h"
39
40void 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 return;
50
51 m->mem_id = MEM_PMRX;
52 m->addr = (stag>>8) * 32 + rdev->rnic_info.tpt_base;
53 m->len = size;
54 pr_debug("%s TPT addr 0x%x len %d\n", __func__, m->addr, m->len);
55 rc = rdev->t3cdev_p->ctl(rdev->t3cdev_p, RDMA_GET_MEM, m);
56 if (rc) {
57 pr_debug("%s toectl returned error %d\n", __func__, rc);
58 kfree(m);
59 return;
60 }
61
62 data = (u64 *)m->buf;
63 while (size > 0) {
64 pr_debug("TPT %08x: %016llx\n",
65 m->addr, (unsigned long long)*data);
66 size -= 8;
67 data++;
68 m->addr += 8;
69 }
70 kfree(m);
71}
72
73void 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 return;
87
88 m->mem_id = MEM_PMRX;
89 m->addr = pbl_addr;
90 m->len = size;
91 pr_debug("%s PBL addr 0x%x len %d depth %d\n",
92 __func__, m->addr, m->len, npages);
93 rc = rdev->t3cdev_p->ctl(rdev->t3cdev_p, RDMA_GET_MEM, m);
94 if (rc) {
95 pr_debug("%s toectl returned error %d\n", __func__, rc);
96 kfree(m);
97 return;
98 }
99
100 data = (u64 *)m->buf;
101 while (size > 0) {
102 pr_debug("PBL %08x: %016llx\n",
103 m->addr, (unsigned long long)*data);
104 size -= 8;
105 data++;
106 m->addr += 8;
107 }
108 kfree(m);
109}
110
111void 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 pr_debug("WQE %p: %016llx\n",
120 data, (unsigned long long)be64_to_cpu(*data));
121 size--;
122 data++;
123 }
124}
125
126void cxio_dump_wce(struct t3_cqe *wce)
127{
128 __be64 *data = (__be64 *)wce;
129 int size = sizeof(*wce);
130
131 while (size > 0) {
132 pr_debug("WCE %p: %016llx\n",
133 data, (unsigned long long)be64_to_cpu(*data));
134 size -= 8;
135 data++;
136 }
137}
138
139void 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 return;
149
150 m->mem_id = MEM_PMRX;
151 m->addr = ((hwtid)<<10) + rdev->rnic_info.rqt_base;
152 m->len = size;
153 pr_debug("%s RQT addr 0x%x len %d\n", __func__, m->addr, m->len);
154 rc = rdev->t3cdev_p->ctl(rdev->t3cdev_p, RDMA_GET_MEM, m);
155 if (rc) {
156 pr_debug("%s toectl returned error %d\n", __func__, rc);
157 kfree(m);
158 return;
159 }
160
161 data = (u64 *)m->buf;
162 while (size > 0) {
163 pr_debug("RQT %08x: %016llx\n",
164 m->addr, (unsigned long long)*data);
165 size -= 8;
166 data++;
167 m->addr += 8;
168 }
169 kfree(m);
170}
171
172void 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 return;
182
183 m->mem_id = MEM_CM;
184 m->addr = hwtid * size;
185 m->len = size;
186 pr_debug("%s TCB %d len %d\n", __func__, m->addr, m->len);
187 rc = rdev->t3cdev_p->ctl(rdev->t3cdev_p, RDMA_GET_MEM, m);
188 if (rc) {
189 pr_debug("%s toectl returned error %d\n", __func__, rc);
190 kfree(m);
191 return;
192 }
193
194 data = (u32 *)m->buf;
195 while (size > 0) {
196 printk("%2u: %08x %08x %08x %08x %08x %08x %08x %08x\n",
197 m->addr,
198 *(data+2), *(data+3), *(data),*(data+1),
199 *(data+6), *(data+7), *(data+4), *(data+5));
200 size -= 32;
201 data += 8;
202 m->addr += 32;
203 }
204 kfree(m);
205}
206#endif
207