Path: blob/master/drivers/infiniband/hw/cxgb3/cxio_dbg.c
15112 views
/*1* Copyright (c) 2006 Chelsio, Inc. All rights reserved.2*3* This software is available to you under a choice of one of two4* licenses. You may choose to be licensed under the terms of the GNU5* General Public License (GPL) Version 2, available from the file6* COPYING in the main directory of this source tree, or the7* OpenIB.org BSD license below:8*9* Redistribution and use in source and binary forms, with or10* without modification, are permitted provided that the following11* conditions are met:12*13* - Redistributions of source code must retain the above14* copyright notice, this list of conditions and the following15* disclaimer.16*17* - Redistributions in binary form must reproduce the above18* copyright notice, this list of conditions and the following19* disclaimer in the documentation and/or other materials20* provided with the distribution.21*22* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,23* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF24* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND25* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS26* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN27* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN28* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE29* SOFTWARE.30*/31#ifdef DEBUG32#include <linux/types.h>33#include <linux/slab.h>34#include "common.h"35#include "cxgb3_ioctl.h"36#include "cxio_hal.h"37#include "cxio_wr.h"3839void cxio_dump_tpt(struct cxio_rdev *rdev, u32 stag)40{41struct ch_mem_range *m;42u64 *data;43int rc;44int size = 32;4546m = kmalloc(sizeof(*m) + size, GFP_ATOMIC);47if (!m) {48PDBG("%s couldn't allocate memory.\n", __func__);49return;50}51m->mem_id = MEM_PMRX;52m->addr = (stag>>8) * 32 + rdev->rnic_info.tpt_base;53m->len = size;54PDBG("%s TPT addr 0x%x len %d\n", __func__, m->addr, m->len);55rc = rdev->t3cdev_p->ctl(rdev->t3cdev_p, RDMA_GET_MEM, m);56if (rc) {57PDBG("%s toectl returned error %d\n", __func__, rc);58kfree(m);59return;60}6162data = (u64 *)m->buf;63while (size > 0) {64PDBG("TPT %08x: %016llx\n", m->addr, (unsigned long long) *data);65size -= 8;66data++;67m->addr += 8;68}69kfree(m);70}7172void cxio_dump_pbl(struct cxio_rdev *rdev, u32 pbl_addr, uint len, u8 shift)73{74struct ch_mem_range *m;75u64 *data;76int rc;77int size, npages;7879shift += 12;80npages = (len + (1ULL << shift) - 1) >> shift;81size = npages * sizeof(u64);8283m = kmalloc(sizeof(*m) + size, GFP_ATOMIC);84if (!m) {85PDBG("%s couldn't allocate memory.\n", __func__);86return;87}88m->mem_id = MEM_PMRX;89m->addr = pbl_addr;90m->len = size;91PDBG("%s PBL addr 0x%x len %d depth %d\n",92__func__, m->addr, m->len, npages);93rc = rdev->t3cdev_p->ctl(rdev->t3cdev_p, RDMA_GET_MEM, m);94if (rc) {95PDBG("%s toectl returned error %d\n", __func__, rc);96kfree(m);97return;98}99100data = (u64 *)m->buf;101while (size > 0) {102PDBG("PBL %08x: %016llx\n", m->addr, (unsigned long long) *data);103size -= 8;104data++;105m->addr += 8;106}107kfree(m);108}109110void cxio_dump_wqe(union t3_wr *wqe)111{112__be64 *data = (__be64 *)wqe;113uint size = (uint)(be64_to_cpu(*data) & 0xff);114115if (size == 0)116size = 8;117while (size > 0) {118PDBG("WQE %p: %016llx\n", data,119(unsigned long long) be64_to_cpu(*data));120size--;121data++;122}123}124125void cxio_dump_wce(struct t3_cqe *wce)126{127__be64 *data = (__be64 *)wce;128int size = sizeof(*wce);129130while (size > 0) {131PDBG("WCE %p: %016llx\n", data,132(unsigned long long) be64_to_cpu(*data));133size -= 8;134data++;135}136}137138void cxio_dump_rqt(struct cxio_rdev *rdev, u32 hwtid, int nents)139{140struct ch_mem_range *m;141int size = nents * 64;142u64 *data;143int rc;144145m = kmalloc(sizeof(*m) + size, GFP_ATOMIC);146if (!m) {147PDBG("%s couldn't allocate memory.\n", __func__);148return;149}150m->mem_id = MEM_PMRX;151m->addr = ((hwtid)<<10) + rdev->rnic_info.rqt_base;152m->len = size;153PDBG("%s RQT addr 0x%x len %d\n", __func__, m->addr, m->len);154rc = rdev->t3cdev_p->ctl(rdev->t3cdev_p, RDMA_GET_MEM, m);155if (rc) {156PDBG("%s toectl returned error %d\n", __func__, rc);157kfree(m);158return;159}160161data = (u64 *)m->buf;162while (size > 0) {163PDBG("RQT %08x: %016llx\n", m->addr, (unsigned long long) *data);164size -= 8;165data++;166m->addr += 8;167}168kfree(m);169}170171void cxio_dump_tcb(struct cxio_rdev *rdev, u32 hwtid)172{173struct ch_mem_range *m;174int size = TCB_SIZE;175u32 *data;176int rc;177178m = kmalloc(sizeof(*m) + size, GFP_ATOMIC);179if (!m) {180PDBG("%s couldn't allocate memory.\n", __func__);181return;182}183m->mem_id = MEM_CM;184m->addr = hwtid * size;185m->len = size;186PDBG("%s TCB %d len %d\n", __func__, m->addr, m->len);187rc = rdev->t3cdev_p->ctl(rdev->t3cdev_p, RDMA_GET_MEM, m);188if (rc) {189PDBG("%s toectl returned error %d\n", __func__, rc);190kfree(m);191return;192}193194data = (u32 *)m->buf;195while (size > 0) {196printk("%2u: %08x %08x %08x %08x %08x %08x %08x %08x\n",197m->addr,198*(data+2), *(data+3), *(data),*(data+1),199*(data+6), *(data+7), *(data+4), *(data+5));200size -= 32;201data += 8;202m->addr += 32;203}204kfree(m);205}206#endif207208209