iw_cxgb_dbg.c revision 178786
1 2/************************************************************************** 3 4Copyright (c) 2007, Chelsio Inc. 5All rights reserved. 6 7Redistribution and use in source and binary forms, with or without 8modification, are permitted provided that the following conditions are met: 9 10 1. Redistributions of source code must retain the above copyright notice, 11 this list of conditions and the following disclaimer. 12 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. 16 17THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 21LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27POSSIBILITY OF SUCH DAMAGE. 28 29***************************************************************************/ 30#include <sys/cdefs.h> 31__FBSDID("$FreeBSD: head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_dbg.c 178786 2008-05-05 18:46:18Z kmacy $"); 32 33#include <sys/param.h> 34#include <sys/systm.h> 35#include <sys/kernel.h> 36#include <sys/bus.h> 37#include <sys/module.h> 38#include <sys/pciio.h> 39#include <sys/conf.h> 40#include <machine/bus.h> 41#include <machine/resource.h> 42#include <sys/bus_dma.h> 43#include <sys/rman.h> 44#include <sys/ioccom.h> 45#include <sys/mbuf.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> 52#include <sys/smp.h> 53#include <sys/sysctl.h> 54#include <sys/syslog.h> 55#include <sys/queue.h> 56#include <sys/taskqueue.h> 57#include <sys/proc.h> 58#include <sys/queue.h> 59#include <sys/libkern.h> 60 61#include <netinet/in.h> 62 63#include <contrib/rdma/ib_verbs.h> 64#include <contrib/rdma/ib_umem.h> 65#include <contrib/rdma/ib_user_verbs.h> 66 67#ifdef DEBUG 68#ifdef CONFIG_DEFINED 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> 77#else 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> 86#endif 87 88void cxio_dump_tpt(struct cxio_rdev *rdev, uint32_t stag) 89{ 90 struct ch_mem_range *m; 91 u64 *data; 92 int rc; 93 int size = 32; 94 95 m = kmalloc(sizeof(*m) + size, M_NOWAIT); 96 if (!m) { 97 CTR1(KTR_IW_CXGB, "%s couldn't allocate memory.", __FUNCTION__); 98 return; 99 } 100 m->mem_id = MEM_PMRX; 101 m->addr = (stag>>8) * 32 + rdev->rnic_info.tpt_base; 102 m->len = size; 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); 105 if (rc) { 106 CTR2(KTR_IW_CXGB, "%s toectl returned error %d", __FUNCTION__, rc); 107 free(m, M_DEVBUF); 108 return; 109 } 110 111 data = (u64 *)m->buf; 112 while (size > 0) { 113 CTR2(KTR_IW_CXGB, "TPT %08x: %016llx", m->addr, (unsigned long long) *data); 114 size -= 8; 115 data++; 116 m->addr += 8; 117 } 118 free(m, M_DEVBUF); 119} 120 121void cxio_dump_pbl(struct cxio_rdev *rdev, uint32_t pbl_addr, uint32_t len, u8 shift) 122{ 123 struct ch_mem_range *m; 124 u64 *data; 125 int rc; 126 int size, npages; 127 128 shift += 12; 129 npages = (len + (1ULL << shift) - 1) >> shift; 130 size = npages * sizeof(u64); 131 132 m = kmalloc(sizeof(*m) + size, M_NOWAIT); 133 if (!m) { 134 CTR1(KTR_IW_CXGB, "%s couldn't allocate memory.", __FUNCTION__); 135 return; 136 } 137 m->mem_id = MEM_PMRX; 138 m->addr = pbl_addr; 139 m->len = size; 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); 143 if (rc) { 144 CTR2(KTR_IW_CXGB, "%s toectl returned error %d", __FUNCTION__, rc); 145 free(m, M_DEVBUF); 146 return; 147 } 148 149 data = (u64 *)m->buf; 150 while (size > 0) { 151 CTR2(KTR_IW_CXGB, "PBL %08x: %016llx", m->addr, (unsigned long long) *data); 152 size -= 8; 153 data++; 154 m->addr += 8; 155 } 156 free(m, M_DEVBUF); 157} 158 159void cxio_dump_wqe(union t3_wr *wqe) 160{ 161 uint64_t *data = (uint64_t *)wqe; 162 uint32_t size = (uint32_t)(be64_to_cpu(*data) & 0xff); 163 164 if (size == 0) 165 size = 8; 166 while (size > 0) { 167 CTR2(KTR_IW_CXGB, "WQE %p: %016llx", data, 168 (unsigned long long) be64_to_cpu(*data)); 169 size--; 170 data++; 171 } 172} 173 174void cxio_dump_wce(struct t3_cqe *wce) 175{ 176 uint64_t *data = (uint64_t *)wce; 177 int size = sizeof(*wce); 178 179 while (size > 0) { 180 CTR2(KTR_IW_CXGB, "WCE %p: %016llx", data, 181 (unsigned long long) be64_to_cpu(*data)); 182 size -= 8; 183 data++; 184 } 185} 186 187void cxio_dump_rqt(struct cxio_rdev *rdev, uint32_t hwtid, int nents) 188{ 189 struct ch_mem_range *m; 190 int size = nents * 64; 191 u64 *data; 192 int rc; 193 194 m = kmalloc(sizeof(*m) + size, M_NOWAIT); 195 if (!m) { 196 CTR1(KTR_IW_CXGB, "%s couldn't allocate memory.", __FUNCTION__); 197 return; 198 } 199 m->mem_id = MEM_PMRX; 200 m->addr = ((hwtid)<<10) + rdev->rnic_info.rqt_base; 201 m->len = size; 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); 204 if (rc) { 205 CTR2(KTR_IW_CXGB, "%s toectl returned error %d", __FUNCTION__, rc); 206 free(m, M_DEVBUF); 207 return; 208 } 209 210 data = (u64 *)m->buf; 211 while (size > 0) { 212 CTR2(KTR_IW_CXGB, "RQT %08x: %016llx", m->addr, (unsigned long long) *data); 213 size -= 8; 214 data++; 215 m->addr += 8; 216 } 217 free(m, M_DEVBUF); 218} 219 220void cxio_dump_tcb(struct cxio_rdev *rdev, uint32_t hwtid) 221{ 222 struct ch_mem_range *m; 223 int size = TCB_SIZE; 224 uint32_t *data; 225 int rc; 226 227 m = kmalloc(sizeof(*m) + size, M_NOWAIT); 228 if (!m) { 229 CTR1(KTR_IW_CXGB, "%s couldn't allocate memory.", __FUNCTION__); 230 return; 231 } 232 m->mem_id = MEM_CM; 233 m->addr = hwtid * size; 234 m->len = 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); 237 if (rc) { 238 CTR2(KTR_IW_CXGB, "%s toectl returned error %d", __FUNCTION__, rc); 239 free(m, M_DEVBUF); 240 return; 241 } 242 243 data = (uint32_t *)m->buf; 244 while (size > 0) { 245 printf("%2u: %08x %08x %08x %08x %08x %08x %08x %08x\n", 246 m->addr, 247 *(data+2), *(data+3), *(data),*(data+1), 248 *(data+6), *(data+7), *(data+4), *(data+5)); 249 size -= 32; 250 data += 8; 251 m->addr += 32; 252 } 253 free(m, M_DEVBUF); 254} 255#endif 256