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