qla_dbg.c revision 250340
1254721Semaste/* 2254721Semaste * Copyright (c) 2011-2013 Qlogic Corporation 3254721Semaste * All rights reserved. 4254721Semaste * 5254721Semaste * Redistribution and use in source and binary forms, with or without 6254721Semaste * modification, are permitted provided that the following conditions 7254721Semaste * are met: 8254721Semaste * 9254721Semaste * 1. Redistributions of source code must retain the above copyright 10254721Semaste * notice, this list of conditions and the following disclaimer. 11254721Semaste * 2. Redistributions in binary form must reproduce the above copyright 12254721Semaste * notice, this list of conditions and the following disclaimer in the 13254721Semaste * documentation and/or other materials provided with the distribution. 14254721Semaste * 15254721Semaste * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16254721Semaste * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17254721Semaste * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18254721Semaste * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19254721Semaste * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20288943Sdim * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21254721Semaste * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22288943Sdim * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23280031Sdim * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24280031Sdim * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25254721Semaste * POSSIBILITY OF SUCH DAMAGE. 26254721Semaste */ 27254721Semaste/* 28254721Semaste * File : qla_dbg.c 29296417Sdim * Author : David C Somayajulu, Qlogic Corporation, Aliso Viejo, CA 92656. 30254721Semaste */ 31254721Semaste 32254721Semaste#include <sys/cdefs.h> 33254721Semaste__FBSDID("$FreeBSD: head/sys/dev/qlxgb/qla_dbg.c 250340 2013-05-07 22:58:42Z davidcs $"); 34254721Semaste 35254721Semaste#include "qla_os.h" 36254721Semaste#include "qla_reg.h" 37254721Semaste#include "qla_hw.h" 38254721Semaste#include "qla_def.h" 39254721Semaste#include "qla_inline.h" 40254721Semaste#include "qla_ver.h" 41254721Semaste#include "qla_glbl.h" 42254721Semaste#include "qla_dbg.h" 43254721Semaste 44254721Semaste 45254721Semasteuint32_t dbg_level = 0 ; 46254721Semaste/* 47254721Semaste * Name: qla_dump_buf32 48254721Semaste * Function: dumps a buffer as 32 bit words 49254721Semaste */ 50254721Semastevoid qla_dump_buf32(qla_host_t *ha, char *msg, void *dbuf32, uint32_t len32) 51254721Semaste{ 52254721Semaste device_t dev; 53254721Semaste uint32_t i = 0; 54254721Semaste uint32_t *buf; 55254721Semaste 56254721Semaste dev = ha->pci_dev; 57254721Semaste buf = dbuf32; 58254721Semaste 59254721Semaste device_printf(dev, "%s: %s dump start\n", __func__, msg); 60254721Semaste 61254721Semaste while (len32 >= 4) { 62254721Semaste device_printf(dev,"0x%08x: 0x%08x 0x%08x 0x%08x 0x%08x\n", 63254721Semaste i, buf[0], buf[1], buf[2], buf[3]); 64254721Semaste i += 4 * 4; 65254721Semaste len32 -= 4; 66254721Semaste buf += 4; 67254721Semaste } 68254721Semaste switch (len32) { 69254721Semaste case 1: 70254721Semaste device_printf(dev,"0x%08x: 0x%08x\n", i, buf[0]); 71254721Semaste break; 72254721Semaste case 2: 73254721Semaste device_printf(dev,"0x%08x: 0x%08x 0x%08x\n", i, buf[0], buf[1]); 74254721Semaste break; 75254721Semaste case 3: 76254721Semaste device_printf(dev,"0x%08x: 0x%08x 0x%08x 0x%08x\n", 77254721Semaste i, buf[0], buf[1], buf[2]); 78254721Semaste break; 79254721Semaste default: 80296417Sdim break; 81254721Semaste } 82296417Sdim device_printf(dev, "%s: %s dump end\n", __func__, msg); 83296417Sdim} 84254721Semaste 85254721Semaste/* 86254721Semaste * Name: qla_dump_buf16 87254721Semaste * Function: dumps a buffer as 16 bit words 88254721Semaste */ 89254721Semastevoid qla_dump_buf16(qla_host_t *ha, char *msg, void *dbuf16, uint32_t len16) 90254721Semaste{ 91254721Semaste device_t dev; 92254721Semaste uint32_t i = 0; 93254721Semaste uint16_t *buf; 94254721Semaste 95254721Semaste dev = ha->pci_dev; 96254721Semaste buf = dbuf16; 97254721Semaste 98254721Semaste device_printf(dev, "%s: %s dump start\n", __func__, msg); 99254721Semaste 100254721Semaste while (len16 >= 8) { 101254721Semaste device_printf(dev,"0x%08x: 0x%04x 0x%04x 0x%04x 0x%04x" 102254721Semaste " 0x%04x 0x%04x 0x%04x 0x%04x\n", i, buf[0], 103254721Semaste buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7]); 104254721Semaste i += 16; 105254721Semaste len16 -= 8; 106254721Semaste buf += 8; 107254721Semaste } 108254721Semaste switch (len16) { 109254721Semaste case 1: 110254721Semaste device_printf(dev,"0x%08x: 0x%04x\n", i, buf[0]); 111258054Semaste break; 112288943Sdim case 2: 113296417Sdim device_printf(dev,"0x%08x: 0x%04x 0x%04x\n", i, buf[0], buf[1]); 114254721Semaste break; 115288943Sdim case 3: 116288943Sdim device_printf(dev,"0x%08x: 0x%04x 0x%04x 0x%04x\n", 117288943Sdim i, buf[0], buf[1], buf[2]); 118254721Semaste break; 119254721Semaste case 4: 120254721Semaste device_printf(dev,"0x%08x: 0x%04x 0x%04x 0x%04x 0x%04x\n", i, 121254721Semaste buf[0], buf[1], buf[2], buf[3]); 122296417Sdim break; 123254721Semaste case 5: 124296417Sdim device_printf(dev,"0x%08x:" 125296417Sdim " 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x\n", i, 126254721Semaste buf[0], buf[1], buf[2], buf[3], buf[4]); 127254721Semaste break; 128254721Semaste case 6: 129254721Semaste device_printf(dev,"0x%08x:" 130254721Semaste " 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x\n", i, 131254721Semaste buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]); 132254721Semaste break; 133254721Semaste case 7: 134254721Semaste device_printf(dev,"0x%04x: 0x%04x 0x%04x 0x%04x 0x%04x" 135254721Semaste " 0x%04x 0x%04x 0x%04x\n", i, buf[0], buf[1], 136254721Semaste buf[2], buf[3], buf[4], buf[5], buf[6]); 137254721Semaste break; 138254721Semaste default: 139288943Sdim break; 140288943Sdim } 141288943Sdim device_printf(dev, "%s: %s dump end\n", __func__, msg); 142288943Sdim} 143254721Semaste 144254721Semaste/* 145254721Semaste * Name: qla_dump_buf8 146254721Semaste * Function: dumps a buffer as bytes 147254721Semaste */ 148254721Semastevoid qla_dump_buf8(qla_host_t *ha, char *msg, void *dbuf, uint32_t len) 149288943Sdim{ 150288943Sdim device_t dev; 151288943Sdim uint32_t i = 0; 152288943Sdim uint8_t *buf; 153288943Sdim 154254721Semaste dev = ha->pci_dev; 155288943Sdim buf = dbuf; 156254721Semaste 157254721Semaste device_printf(dev, "%s: %s 0x%x dump start\n", __func__, msg, len); 158254721Semaste 159254721Semaste while (len >= 16) { 160280031Sdim device_printf(dev,"0x%08x:" 161280031Sdim " %02x %02x %02x %02x %02x %02x %02x %02x" 162280031Sdim " %02x %02x %02x %02x %02x %02x %02x %02x\n", i, 163280031Sdim buf[0], buf[1], buf[2], buf[3], 164254721Semaste buf[4], buf[5], buf[6], buf[7], 165254721Semaste buf[8], buf[9], buf[10], buf[11], 166296417Sdim buf[12], buf[13], buf[14], buf[15]); 167254721Semaste i += 16; 168254721Semaste len -= 16; 169254721Semaste buf += 16; 170254721Semaste } 171254721Semaste switch (len) { 172254721Semaste case 1: 173276479Sdim device_printf(dev,"0x%08x: %02x\n", i, buf[0]); 174288943Sdim break; 175254721Semaste case 2: 176254721Semaste device_printf(dev,"0x%08x: %02x %02x\n", i, buf[0], buf[1]); 177276479Sdim break; 178276479Sdim case 3: 179288943Sdim device_printf(dev,"0x%08x: %02x %02x %02x\n", 180288943Sdim i, buf[0], buf[1], buf[2]); 181254721Semaste break; 182254721Semaste case 4: 183288943Sdim device_printf(dev,"0x%08x: %02x %02x %02x %02x\n", i, 184254721Semaste buf[0], buf[1], buf[2], buf[3]); 185254721Semaste break; 186254721Semaste case 5: 187254721Semaste device_printf(dev,"0x%08x:" 188254721Semaste " %02x %02x %02x %02x %02x\n", i, 189254721Semaste buf[0], buf[1], buf[2], buf[3], buf[4]); 190254721Semaste break; 191254721Semaste case 6: 192254721Semaste device_printf(dev,"0x%08x:" 193254721Semaste " %02x %02x %02x %02x %02x %02x\n", i, 194254721Semaste buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]); 195254721Semaste break; 196254721Semaste case 7: 197254721Semaste device_printf(dev,"0x%08x:" 198254721Semaste " %02x %02x %02x %02x %02x %02x %02x\n", i, 199254721Semaste buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6]); 200254721Semaste break; 201254721Semaste case 8: 202254721Semaste device_printf(dev,"0x%08x:" 203254721Semaste " %02x %02x %02x %02x %02x %02x %02x %02x\n", i, 204254721Semaste buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], 205254721Semaste buf[7]); 206254721Semaste break; 207258054Semaste case 9: 208258054Semaste device_printf(dev,"0x%08x:" 209258054Semaste " %02x %02x %02x %02x %02x %02x %02x %02x" 210258054Semaste " %02x\n", i, 211258054Semaste buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], 212258054Semaste buf[7], buf[8]); 213258054Semaste break; 214258054Semaste case 10: 215258054Semaste device_printf(dev,"0x%08x:" 216258054Semaste " %02x %02x %02x %02x %02x %02x %02x %02x" 217258054Semaste " %02x %02x\n", i, 218258054Semaste buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], 219254721Semaste buf[7], buf[8], buf[9]); 220254721Semaste break; 221288943Sdim case 11: 222254721Semaste device_printf(dev,"0x%08x:" 223254721Semaste " %02x %02x %02x %02x %02x %02x %02x %02x" 224254721Semaste " %02x %02x %02x\n", i, 225254721Semaste buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], 226254721Semaste buf[7], buf[8], buf[9], buf[10]); 227254721Semaste break; 228254721Semaste case 12: 229254721Semaste device_printf(dev,"0x%08x:" 230254721Semaste " %02x %02x %02x %02x %02x %02x %02x %02x" 231254721Semaste " %02x %02x %02x %02x\n", i, 232254721Semaste buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], 233254721Semaste buf[7], buf[8], buf[9], buf[10], buf[11]); 234254721Semaste break; 235254721Semaste case 13: 236254721Semaste device_printf(dev,"0x%08x:" 237254721Semaste " %02x %02x %02x %02x %02x %02x %02x %02x" 238254721Semaste " %02x %02x %02x %02x %02x\n", i, 239254721Semaste buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], 240254721Semaste buf[7], buf[8], buf[9], buf[10], buf[11], buf[12]); 241254721Semaste break; 242254721Semaste case 14: 243288943Sdim device_printf(dev,"0x%08x:" 244288943Sdim " %02x %02x %02x %02x %02x %02x %02x %02x" 245288943Sdim " %02x %02x %02x %02x %02x %02x\n", i, 246288943Sdim buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], 247288943Sdim buf[7], buf[8], buf[9], buf[10], buf[11], buf[12], 248254721Semaste buf[13]); 249288943Sdim break; 250254721Semaste case 15: 251296417Sdim device_printf(dev,"0x%08x:" 252296417Sdim " %02x %02x %02x %02x %02x %02x %02x %02x" 253296417Sdim " %02x %02x %02x %02x %02x %02x %02x\n", i, 254296417Sdim buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], 255296417Sdim buf[7], buf[8], buf[9], buf[10], buf[11], buf[12], 256296417Sdim buf[13], buf[14]); 257288943Sdim break; 258288943Sdim default: 259288943Sdim break; 260288943Sdim } 261288943Sdim 262288943Sdim device_printf(dev, "%s: %s dump end\n", __func__, msg); 263288943Sdim} 264288943Sdim