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>
68 #include <cxgb_include.h>
69 #include <ulp/iw_cxgb/iw_cxgb_wr.h>
70 #include <ulp/iw_cxgb/iw_cxgb_hal.h>
71 #include <ulp/iw_cxgb/iw_cxgb_provider.h>
72 #include <ulp/iw_cxgb/iw_cxgb_cm.h>
73 #include <ulp/iw_cxgb/iw_cxgb.h>
74 #include <ulp/iw_cxgb/iw_cxgb_resource.h>
75 #include <ulp/iw_cxgb/iw_cxgb_user.h>
77 void cxio_dump_tpt(struct cxio_rdev *rdev, uint32_t stag)
79 struct ch_mem_range *m;
84 m = kmalloc(sizeof(*m) + size, M_NOWAIT);
86 CTR1(KTR_IW_CXGB, "%s couldn't allocate memory.", __FUNCTION__);
90 m->addr = (stag>>8) * 32 + rdev->rnic_info.tpt_base;
92 CTR3(KTR_IW_CXGB, "%s TPT addr 0x%x len %d", __FUNCTION__, m->addr, m->len);
93 rc = rdev->t3cdev_p->ctl(rdev->t3cdev_p, RDMA_GET_MEM, m);
95 CTR2(KTR_IW_CXGB, "%s toectl returned error %d", __FUNCTION__, rc);
100 data = (u64 *)m->buf;
102 CTR2(KTR_IW_CXGB, "TPT %08x: %016llx", m->addr, (unsigned long long) *data);
110 void cxio_dump_pbl(struct cxio_rdev *rdev, uint32_t pbl_addr, uint32_t len, u8 shift)
112 struct ch_mem_range *m;
118 npages = (len + (1ULL << shift) - 1) >> shift;
119 size = npages * sizeof(u64);
121 m = kmalloc(sizeof(*m) + size, M_NOWAIT);
123 CTR1(KTR_IW_CXGB, "%s couldn't allocate memory.", __FUNCTION__);
126 m->mem_id = MEM_PMRX;
129 CTR4(KTR_IW_CXGB, "%s PBL addr 0x%x len %d depth %d",
130 __FUNCTION__, m->addr, m->len, npages);
131 rc = rdev->t3cdev_p->ctl(rdev->t3cdev_p, RDMA_GET_MEM, m);
133 CTR2(KTR_IW_CXGB, "%s toectl returned error %d", __FUNCTION__, rc);
138 data = (u64 *)m->buf;
140 CTR2(KTR_IW_CXGB, "PBL %08x: %016llx", m->addr, (unsigned long long) *data);
148 void cxio_dump_wqe(union t3_wr *wqe)
150 uint64_t *data = (uint64_t *)wqe;
151 uint32_t size = (uint32_t)(be64toh(*data) & 0xff);
156 CTR2(KTR_IW_CXGB, "WQE %p: %016llx", data,
157 (unsigned long long) be64toh(*data));
163 void cxio_dump_wce(struct t3_cqe *wce)
165 uint64_t *data = (uint64_t *)wce;
166 int size = sizeof(*wce);
169 CTR2(KTR_IW_CXGB, "WCE %p: %016llx", data,
170 (unsigned long long) be64toh(*data));
176 void cxio_dump_rqt(struct cxio_rdev *rdev, uint32_t hwtid, int nents)
178 struct ch_mem_range *m;
179 int size = nents * 64;
183 m = kmalloc(sizeof(*m) + size, M_NOWAIT);
185 CTR1(KTR_IW_CXGB, "%s couldn't allocate memory.", __FUNCTION__);
188 m->mem_id = MEM_PMRX;
189 m->addr = ((hwtid)<<10) + rdev->rnic_info.rqt_base;
191 CTR3(KTR_IW_CXGB, "%s RQT addr 0x%x len %d", __FUNCTION__, m->addr, m->len);
192 rc = rdev->t3cdev_p->ctl(rdev->t3cdev_p, RDMA_GET_MEM, m);
194 CTR2(KTR_IW_CXGB, "%s toectl returned error %d", __FUNCTION__, rc);
199 data = (u64 *)m->buf;
201 CTR2(KTR_IW_CXGB, "RQT %08x: %016llx", m->addr, (unsigned long long) *data);
209 void cxio_dump_tcb(struct cxio_rdev *rdev, uint32_t hwtid)
211 struct ch_mem_range *m;
216 m = kmalloc(sizeof(*m) + size, M_NOWAIT);
218 CTR1(KTR_IW_CXGB, "%s couldn't allocate memory.", __FUNCTION__);
222 m->addr = hwtid * size;
224 CTR3(KTR_IW_CXGB, "%s TCB %d len %d", __FUNCTION__, m->addr, m->len);
225 rc = rdev->t3cdev_p->ctl(rdev->t3cdev_p, RDMA_GET_MEM, m);
227 CTR2(KTR_IW_CXGB, "%s toectl returned error %d", __FUNCTION__, rc);
232 data = (uint32_t *)m->buf;
234 printf("%2u: %08x %08x %08x %08x %08x %08x %08x %08x\n",
236 *(data+2), *(data+3), *(data),*(data+1),
237 *(data+6), *(data+7), *(data+4), *(data+5));