2 /**************************************************************************
4 Copyright (c) 2007, Chelsio Inc.
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
10 1. Redistributions of source code must retain the above copyright notice,
11 this list of conditions and the following disclaimer.
13 2. Neither the name of the Chelsio Corporation nor the names of its
14 contributors may be used to endorse or promote products derived from
15 this software without specific prior written permission.
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.
29 ***************************************************************************/
30 #include <sys/cdefs.h>
31 __FBSDID("$FreeBSD$");
33 #include <sys/param.h>
34 #include <sys/systm.h>
35 #include <sys/kernel.h>
37 #include <sys/module.h>
38 #include <sys/pciio.h>
40 #include <machine/bus.h>
41 #include <machine/resource.h>
42 #include <sys/bus_dma.h>
44 #include <sys/ioccom.h>
46 #include <sys/mutex.h>
47 #include <sys/rwlock.h>
48 #include <sys/linker.h>
49 #include <sys/firmware.h>
50 #include <sys/socket.h>
51 #include <sys/sockio.h>
53 #include <sys/sysctl.h>
54 #include <sys/syslog.h>
55 #include <sys/queue.h>
56 #include <sys/taskqueue.h>
58 #include <sys/queue.h>
59 #include <sys/libkern.h>
61 #include <netinet/in.h>
63 #include <contrib/rdma/ib_verbs.h>
64 #include <contrib/rdma/ib_umem.h>
65 #include <contrib/rdma/ib_user_verbs.h>
69 #include <cxgb_include.h>
70 #include <ulp/iw_cxgb/iw_cxgb_wr.h>
71 #include <ulp/iw_cxgb/iw_cxgb_hal.h>
72 #include <ulp/iw_cxgb/iw_cxgb_provider.h>
73 #include <ulp/iw_cxgb/iw_cxgb_cm.h>
74 #include <ulp/iw_cxgb/iw_cxgb.h>
75 #include <ulp/iw_cxgb/iw_cxgb_resource.h>
76 #include <ulp/iw_cxgb/iw_cxgb_user.h>
78 #include <dev/cxgb/cxgb_include.h>
79 #include <dev/cxgb/ulp/iw_cxgb/iw_cxgb_wr.h>
80 #include <dev/cxgb/ulp/iw_cxgb/iw_cxgb_hal.h>
81 #include <dev/cxgb/ulp/iw_cxgb/iw_cxgb_provider.h>
82 #include <dev/cxgb/ulp/iw_cxgb/iw_cxgb_cm.h>
83 #include <dev/cxgb/ulp/iw_cxgb/iw_cxgb.h>
84 #include <dev/cxgb/ulp/iw_cxgb/iw_cxgb_resource.h>
85 #include <dev/cxgb/ulp/iw_cxgb/iw_cxgb_user.h>
88 void cxio_dump_tpt(struct cxio_rdev *rdev, uint32_t stag)
90 struct ch_mem_range *m;
95 m = kmalloc(sizeof(*m) + size, M_NOWAIT);
97 CTR1(KTR_IW_CXGB, "%s couldn't allocate memory.", __FUNCTION__);
100 m->mem_id = MEM_PMRX;
101 m->addr = (stag>>8) * 32 + rdev->rnic_info.tpt_base;
103 CTR3(KTR_IW_CXGB, "%s TPT addr 0x%x len %d", __FUNCTION__, m->addr, m->len);
104 rc = rdev->t3cdev_p->ctl(rdev->t3cdev_p, RDMA_GET_MEM, m);
106 CTR2(KTR_IW_CXGB, "%s toectl returned error %d", __FUNCTION__, rc);
111 data = (u64 *)m->buf;
113 CTR2(KTR_IW_CXGB, "TPT %08x: %016llx", m->addr, (unsigned long long) *data);
121 void cxio_dump_pbl(struct cxio_rdev *rdev, uint32_t pbl_addr, uint32_t len, u8 shift)
123 struct ch_mem_range *m;
129 npages = (len + (1ULL << shift) - 1) >> shift;
130 size = npages * sizeof(u64);
132 m = kmalloc(sizeof(*m) + size, M_NOWAIT);
134 CTR1(KTR_IW_CXGB, "%s couldn't allocate memory.", __FUNCTION__);
137 m->mem_id = MEM_PMRX;
140 CTR4(KTR_IW_CXGB, "%s PBL addr 0x%x len %d depth %d",
141 __FUNCTION__, m->addr, m->len, npages);
142 rc = rdev->t3cdev_p->ctl(rdev->t3cdev_p, RDMA_GET_MEM, m);
144 CTR2(KTR_IW_CXGB, "%s toectl returned error %d", __FUNCTION__, rc);
149 data = (u64 *)m->buf;
151 CTR2(KTR_IW_CXGB, "PBL %08x: %016llx", m->addr, (unsigned long long) *data);
159 void cxio_dump_wqe(union t3_wr *wqe)
161 uint64_t *data = (uint64_t *)wqe;
162 uint32_t size = (uint32_t)(be64toh(*data) & 0xff);
167 CTR2(KTR_IW_CXGB, "WQE %p: %016llx", data,
168 (unsigned long long) be64toh(*data));
174 void cxio_dump_wce(struct t3_cqe *wce)
176 uint64_t *data = (uint64_t *)wce;
177 int size = sizeof(*wce);
180 CTR2(KTR_IW_CXGB, "WCE %p: %016llx", data,
181 (unsigned long long) be64toh(*data));
187 void cxio_dump_rqt(struct cxio_rdev *rdev, uint32_t hwtid, int nents)
189 struct ch_mem_range *m;
190 int size = nents * 64;
194 m = kmalloc(sizeof(*m) + size, M_NOWAIT);
196 CTR1(KTR_IW_CXGB, "%s couldn't allocate memory.", __FUNCTION__);
199 m->mem_id = MEM_PMRX;
200 m->addr = ((hwtid)<<10) + rdev->rnic_info.rqt_base;
202 CTR3(KTR_IW_CXGB, "%s RQT addr 0x%x len %d", __FUNCTION__, m->addr, m->len);
203 rc = rdev->t3cdev_p->ctl(rdev->t3cdev_p, RDMA_GET_MEM, m);
205 CTR2(KTR_IW_CXGB, "%s toectl returned error %d", __FUNCTION__, rc);
210 data = (u64 *)m->buf;
212 CTR2(KTR_IW_CXGB, "RQT %08x: %016llx", m->addr, (unsigned long long) *data);
220 void cxio_dump_tcb(struct cxio_rdev *rdev, uint32_t hwtid)
222 struct ch_mem_range *m;
227 m = kmalloc(sizeof(*m) + size, M_NOWAIT);
229 CTR1(KTR_IW_CXGB, "%s couldn't allocate memory.", __FUNCTION__);
233 m->addr = hwtid * size;
235 CTR3(KTR_IW_CXGB, "%s TCB %d len %d", __FUNCTION__, m->addr, m->len);
236 rc = rdev->t3cdev_p->ctl(rdev->t3cdev_p, RDMA_GET_MEM, m);
238 CTR2(KTR_IW_CXGB, "%s toectl returned error %d", __FUNCTION__, rc);
243 data = (uint32_t *)m->buf;
245 printf("%2u: %08x %08x %08x %08x %08x %08x %08x %08x\n",
247 *(data+2), *(data+3), *(data),*(data+1),
248 *(data+6), *(data+7), *(data+4), *(data+5));