1139749Simp/*- 2101704Smjacob * Debug routines for LSI '909 FC adapters. 3101704Smjacob * FreeBSD Version. 4101704Smjacob * 5101704Smjacob * Copyright (c) 2000, 2001 by Greg Ansley 6101704Smjacob * 7101704Smjacob * Redistribution and use in source and binary forms, with or without 8101704Smjacob * modification, are permitted provided that the following conditions 9101704Smjacob * are met: 10101704Smjacob * 1. Redistributions of source code must retain the above copyright 11101704Smjacob * notice immediately at the beginning of the file, without modification, 12101704Smjacob * this list of conditions, and the following disclaimer. 13101704Smjacob * 2. The name of the author may not be used to endorse or promote products 14101704Smjacob * derived from this software without specific prior written permission. 15101704Smjacob * 16101704Smjacob * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17101704Smjacob * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18101704Smjacob * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19101704Smjacob * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR 20101704Smjacob * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21101704Smjacob * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22101704Smjacob * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23101704Smjacob * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24101704Smjacob * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25101704Smjacob * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26101704Smjacob * SUCH DAMAGE. 27147883Sscottl * 28101704Smjacob */ 29156000Smjacob/*- 30156000Smjacob * Copyright (c) 2002, 2006 by Matthew Jacob 31156000Smjacob * All rights reserved. 32156000Smjacob * 33156000Smjacob * Redistribution and use in source and binary forms, with or without 34156000Smjacob * modification, are permitted provided that the following conditions are 35156000Smjacob * met: 36156000Smjacob * 1. Redistributions of source code must retain the above copyright 37156000Smjacob * notice, this list of conditions and the following disclaimer. 38156000Smjacob * 2. Redistributions in binary form must reproduce at minimum a disclaimer 39156000Smjacob * substantially similar to the "NO WARRANTY" disclaimer below 40156000Smjacob * ("Disclaimer") and any redistribution must be conditioned upon including 41156000Smjacob * a substantially similar Disclaimer requirement for further binary 42156000Smjacob * redistribution. 43156000Smjacob * 3. Neither the names of the above listed copyright holders nor the names 44156000Smjacob * of any contributors may be used to endorse or promote products derived 45156000Smjacob * from this software without specific prior written permission. 46156000Smjacob * 47156000Smjacob * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 48156000Smjacob * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 49156000Smjacob * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 50156000Smjacob * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 51156000Smjacob * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 52156000Smjacob * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 53156000Smjacob * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 54156000Smjacob * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 55156000Smjacob * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 56156000Smjacob * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF THE COPYRIGHT 57156000Smjacob * OWNER OR CONTRIBUTOR IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 58156000Smjacob * 59156000Smjacob * Support from Chris Ellsworth in order to make SAS adapters work 60156000Smjacob * is gratefully acknowledged. 61159052Smjacob * 62159052Smjacob * Support from LSI-Logic has also gone a great deal toward making this a 63159052Smjacob * workable subsystem and is gratefully acknowledged. 64156000Smjacob */ 65101704Smjacob 66134123Sobrien#include <sys/cdefs.h> 67134123Sobrien__FBSDID("$FreeBSD: stable/10/sys/dev/mpt/mpt_debug.c 315826 2017-03-23 06:52:29Z mav $"); 68134123Sobrien 69147883Sscottl#include <dev/mpt/mpt.h> 70147883Sscottl 71147883Sscottl#include <dev/mpt/mpilib/mpi_ioc.h> 72147883Sscottl#include <dev/mpt/mpilib/mpi_init.h> 73147883Sscottl#include <dev/mpt/mpilib/mpi_fc.h> 74157117Smjacob#include <dev/mpt/mpilib/mpi_targ.h> 75147883Sscottl 76147883Sscottl#include <cam/scsi/scsi_all.h> 77147883Sscottl 78103914Smjacob#include <machine/stdarg.h> /* for use by mpt_prt below */ 79101704Smjacob 80101704Smjacobstruct Error_Map { 81101704Smjacob int Error_Code; 82101704Smjacob char *Error_String; 83101704Smjacob}; 84101704Smjacob 85101704Smjacobstatic const struct Error_Map IOC_Status[] = { 86101704Smjacob{ MPI_IOCSTATUS_SUCCESS, "Success" }, 87101704Smjacob{ MPI_IOCSTATUS_INVALID_FUNCTION, "IOC: Invalid Function" }, 88101704Smjacob{ MPI_IOCSTATUS_BUSY, "IOC: Busy" }, 89101704Smjacob{ MPI_IOCSTATUS_INVALID_SGL, "IOC: Invalid SGL" }, 90101704Smjacob{ MPI_IOCSTATUS_INTERNAL_ERROR, "IOC: Internal Error" }, 91101704Smjacob{ MPI_IOCSTATUS_RESERVED, "IOC: Reserved" }, 92101704Smjacob{ MPI_IOCSTATUS_INSUFFICIENT_RESOURCES, "IOC: Insufficient Resources" }, 93101704Smjacob{ MPI_IOCSTATUS_INVALID_FIELD, "IOC: Invalid Field" }, 94101704Smjacob{ MPI_IOCSTATUS_INVALID_STATE, "IOC: Invalid State" }, 95101704Smjacob{ MPI_IOCSTATUS_CONFIG_INVALID_ACTION, "Invalid Action" }, 96101704Smjacob{ MPI_IOCSTATUS_CONFIG_INVALID_TYPE, "Invalid Type" }, 97101704Smjacob{ MPI_IOCSTATUS_CONFIG_INVALID_PAGE, "Invalid Page" }, 98101704Smjacob{ MPI_IOCSTATUS_CONFIG_INVALID_DATA, "Invalid Data" }, 99101704Smjacob{ MPI_IOCSTATUS_CONFIG_NO_DEFAULTS, "No Defaults" }, 100101704Smjacob{ MPI_IOCSTATUS_CONFIG_CANT_COMMIT, "Can't Commit" }, 101101704Smjacob{ MPI_IOCSTATUS_SCSI_RECOVERED_ERROR, "SCSI: Recoverd Error" }, 102101704Smjacob{ MPI_IOCSTATUS_SCSI_INVALID_BUS, "SCSI: Invalid Bus" }, 103101704Smjacob{ MPI_IOCSTATUS_SCSI_INVALID_TARGETID, "SCSI: Invalid Target ID" }, 104101704Smjacob{ MPI_IOCSTATUS_SCSI_DEVICE_NOT_THERE, "SCSI: Device Not There" }, 105101704Smjacob{ MPI_IOCSTATUS_SCSI_DATA_OVERRUN, "SCSI: Data Overrun" }, 106101704Smjacob{ MPI_IOCSTATUS_SCSI_DATA_UNDERRUN, "SCSI: Data Underrun" }, 107101704Smjacob{ MPI_IOCSTATUS_SCSI_IO_DATA_ERROR, "SCSI: Data Error" }, 108101704Smjacob{ MPI_IOCSTATUS_SCSI_PROTOCOL_ERROR, "SCSI: Protocol Error" }, 109101704Smjacob{ MPI_IOCSTATUS_SCSI_TASK_TERMINATED, "SCSI: Task Terminated" }, 110101704Smjacob{ MPI_IOCSTATUS_SCSI_RESIDUAL_MISMATCH, "SCSI: Residual Mismatch" }, 111101704Smjacob{ MPI_IOCSTATUS_SCSI_TASK_MGMT_FAILED, "SCSI: Task Management Failed" }, 112101704Smjacob{ MPI_IOCSTATUS_SCSI_IOC_TERMINATED, "SCSI: IOC Bus Reset" }, 113101704Smjacob{ MPI_IOCSTATUS_SCSI_EXT_TERMINATED, "SCSI: External Bus Reset" }, 114101704Smjacob{ MPI_IOCSTATUS_TARGET_PRIORITY_IO, "SCSI Target: Priority I/O" }, 115101704Smjacob{ MPI_IOCSTATUS_TARGET_INVALID_PORT, "SCSI Target: Invalid Port" }, 116101704Smjacob{ MPI_IOCSTATUS_TARGET_INVALID_IOCINDEX, "SCSI Target: Invalid IOC Index" }, 117101704Smjacob{ MPI_IOCSTATUS_TARGET_ABORTED, "SCSI Target: Aborted" }, 118101704Smjacob{ MPI_IOCSTATUS_TARGET_NO_CONN_RETRYABLE, "SCSI Target: No Connection (Retryable)" }, 119101704Smjacob{ MPI_IOCSTATUS_TARGET_NO_CONNECTION, "SCSI Target: No Connection" }, 120101704Smjacob{ MPI_IOCSTATUS_TARGET_XFER_COUNT_MISMATCH,"SCSI Target: Transfer Count Mismatch" }, 121101704Smjacob{ MPI_IOCSTATUS_TARGET_FC_ABORTED, "FC: Aborted" }, 122220945Smarius{ MPI_IOCSTATUS_TARGET_FC_RX_ID_INVALID, "FC: Receive ID Invalid" }, 123220945Smarius{ MPI_IOCSTATUS_TARGET_FC_DID_INVALID, "FC: Receive DID Invalid" }, 124101704Smjacob{ MPI_IOCSTATUS_TARGET_FC_NODE_LOGGED_OUT,"FC: Node Logged Out" }, 125101704Smjacob{ MPI_IOCSTATUS_LAN_DEVICE_NOT_FOUND, "LAN: Device Not Found" }, 126101704Smjacob{ MPI_IOCSTATUS_LAN_DEVICE_FAILURE, "LAN: Device Not Failure" }, 127101704Smjacob{ MPI_IOCSTATUS_LAN_TRANSMIT_ERROR, "LAN: Transmit Error" }, 128101704Smjacob{ MPI_IOCSTATUS_LAN_TRANSMIT_ABORTED, "LAN: Transmit Aborted" }, 129220945Smarius{ MPI_IOCSTATUS_LAN_RECEIVE_ERROR, "LAN: Receive Error" }, 130220945Smarius{ MPI_IOCSTATUS_LAN_RECEIVE_ABORTED, "LAN: Receive Aborted" }, 131101704Smjacob{ MPI_IOCSTATUS_LAN_PARTIAL_PACKET, "LAN: Partial Packet" }, 132101704Smjacob{ MPI_IOCSTATUS_LAN_CANCELED, "LAN: Canceled" }, 133101704Smjacob{ -1, 0}, 134101704Smjacob}; 135101704Smjacob 136101704Smjacobstatic const struct Error_Map IOC_Func[] = { 137101704Smjacob{ MPI_FUNCTION_SCSI_IO_REQUEST, "SCSI IO Request" }, 138101704Smjacob{ MPI_FUNCTION_SCSI_TASK_MGMT, "SCSI Task Management" }, 139101704Smjacob{ MPI_FUNCTION_IOC_INIT, "IOC Init" }, 140101704Smjacob{ MPI_FUNCTION_IOC_FACTS, "IOC Facts" }, 141101704Smjacob{ MPI_FUNCTION_CONFIG, "Config" }, 142101704Smjacob{ MPI_FUNCTION_PORT_FACTS, "Port Facts" }, 143101704Smjacob{ MPI_FUNCTION_PORT_ENABLE, "Port Enable" }, 144101704Smjacob{ MPI_FUNCTION_EVENT_NOTIFICATION, "Event Notification" }, 145147883Sscottl{ MPI_FUNCTION_EVENT_ACK, "Event Ack" }, 146101704Smjacob{ MPI_FUNCTION_FW_DOWNLOAD, "FW Download" }, 147101704Smjacob{ MPI_FUNCTION_TARGET_CMD_BUFFER_POST, "SCSI Target Command Buffer" }, 148101704Smjacob{ MPI_FUNCTION_TARGET_ASSIST, "Target Assist" }, 149101704Smjacob{ MPI_FUNCTION_TARGET_STATUS_SEND, "Target Status Send" }, 150101704Smjacob{ MPI_FUNCTION_TARGET_MODE_ABORT, "Target Mode Abort" }, 151101704Smjacob{ -1, 0}, 152101704Smjacob}; 153101704Smjacob 154101704Smjacobstatic const struct Error_Map IOC_Event[] = { 155101704Smjacob{ MPI_EVENT_NONE, "None" }, 156101704Smjacob{ MPI_EVENT_LOG_DATA, "LogData" }, 157101704Smjacob{ MPI_EVENT_STATE_CHANGE, "State Change" }, 158101704Smjacob{ MPI_EVENT_UNIT_ATTENTION, "Unit Attention" }, 159101704Smjacob{ MPI_EVENT_IOC_BUS_RESET, "IOC Bus Reset" }, 160101704Smjacob{ MPI_EVENT_EXT_BUS_RESET, "External Bus Reset" }, 161101704Smjacob{ MPI_EVENT_RESCAN, "Rescan" }, 162101704Smjacob{ MPI_EVENT_LINK_STATUS_CHANGE, "Link Status Change" }, 163101704Smjacob{ MPI_EVENT_LOOP_STATE_CHANGE, "Loop State Change" }, 164101704Smjacob{ MPI_EVENT_LOGOUT, "Logout" }, 165101704Smjacob{ MPI_EVENT_EVENT_CHANGE, "EventChange" }, 166101704Smjacob{ -1, 0}, 167101704Smjacob}; 168101704Smjacob 169101704Smjacobstatic const struct Error_Map IOC_SCSIState[] = { 170101704Smjacob{ MPI_SCSI_STATE_AUTOSENSE_VALID, "AutoSense_Valid" }, 171101704Smjacob{ MPI_SCSI_STATE_AUTOSENSE_FAILED, "AutoSense_Failed" }, 172101704Smjacob{ MPI_SCSI_STATE_NO_SCSI_STATUS, "No_SCSI_Status" }, 173101704Smjacob{ MPI_SCSI_STATE_TERMINATED, "State_Terminated" }, 174101704Smjacob{ MPI_SCSI_STATE_RESPONSE_INFO_VALID, "Repsonse_Info_Valid" }, 175101704Smjacob{ MPI_SCSI_STATE_QUEUE_TAG_REJECTED, "Queue Tag Rejected" }, 176101704Smjacob{ -1, 0}, 177101704Smjacob}; 178101704Smjacob 179101704Smjacobstatic const struct Error_Map IOC_SCSIStatus[] = { 180101704Smjacob{ SCSI_STATUS_OK, "OK" }, 181101704Smjacob{ SCSI_STATUS_CHECK_COND, "Check Condition" }, 182101704Smjacob{ SCSI_STATUS_COND_MET, "Check Condition Met" }, 183101704Smjacob{ SCSI_STATUS_BUSY, "Busy" }, 184101704Smjacob{ SCSI_STATUS_INTERMED, "Intermidiate Condition" }, 185101704Smjacob{ SCSI_STATUS_INTERMED_COND_MET, "Intermidiate Condition Met" }, 186101704Smjacob{ SCSI_STATUS_RESERV_CONFLICT, "Reservation Conflict" }, 187101704Smjacob{ SCSI_STATUS_CMD_TERMINATED, "Command Terminated" }, 188101704Smjacob{ SCSI_STATUS_QUEUE_FULL, "Queue Full" }, 189101704Smjacob{ -1, 0}, 190101704Smjacob}; 191101704Smjacob 192101704Smjacobstatic const struct Error_Map IOC_Diag[] = { 193147883Sscottl{ MPI_DIAG_DRWE, "DWE" }, 194147883Sscottl{ MPI_DIAG_FLASH_BAD_SIG, "FLASH_Bad" }, 195147883Sscottl{ MPI_DIAGNOSTIC_OFFSET, "Offset" }, 196147883Sscottl{ MPI_DIAG_RESET_ADAPTER, "Reset" }, 197147883Sscottl{ MPI_DIAG_DISABLE_ARM, "DisARM" }, 198147883Sscottl{ MPI_DIAG_MEM_ENABLE, "DME" }, 199101704Smjacob{ -1, 0 }, 200101704Smjacob}; 201101704Smjacob 202147883Sscottlstatic const struct Error_Map IOC_SCSITMType[] = { 203147883Sscottl{ MPI_SCSITASKMGMT_TASKTYPE_ABORT_TASK, "Abort Task" }, 204147883Sscottl{ MPI_SCSITASKMGMT_TASKTYPE_ABRT_TASK_SET, "Abort Task Set" }, 205147883Sscottl{ MPI_SCSITASKMGMT_TASKTYPE_TARGET_RESET, "Target Reset" }, 206147883Sscottl{ MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS, "Reset Bus" }, 207147883Sscottl{ MPI_SCSITASKMGMT_TASKTYPE_LOGICAL_UNIT_RESET, "Logical Unit Reset" }, 208147883Sscottl{ -1, 0 }, 209147883Sscottl}; 210101704Smjacob 211101704Smjacobstatic char * 212101704Smjacobmpt_ioc_status(int code) 213101704Smjacob{ 214101704Smjacob const struct Error_Map *status = IOC_Status; 215101704Smjacob static char buf[64]; 216101704Smjacob while (status->Error_Code >= 0) { 217101704Smjacob if (status->Error_Code == (code & MPI_IOCSTATUS_MASK)) 218101704Smjacob return status->Error_String; 219101704Smjacob status++; 220101704Smjacob } 221101704Smjacob snprintf(buf, sizeof buf, "Unknown (0x%08x)", code); 222101704Smjacob return buf; 223101704Smjacob} 224101704Smjacob 225101704Smjacobchar * 226101704Smjacobmpt_ioc_diag(u_int32_t code) 227101704Smjacob{ 228101704Smjacob const struct Error_Map *status = IOC_Diag; 229101704Smjacob static char buf[128]; 230101704Smjacob char *ptr = buf; 231101704Smjacob char *end = &buf[128]; 232101704Smjacob buf[0] = '\0'; 233101704Smjacob ptr += snprintf(buf, sizeof buf, "(0x%08x)", code); 234101704Smjacob while (status->Error_Code >= 0) { 235101704Smjacob if ((status->Error_Code & code) != 0) 236101704Smjacob ptr += snprintf(ptr, (size_t)(end-ptr), "%s ", 237101704Smjacob status->Error_String); 238101704Smjacob status++; 239101704Smjacob } 240101704Smjacob return buf; 241101704Smjacob} 242101704Smjacob 243101704Smjacobstatic char * 244101704Smjacobmpt_ioc_function(int code) 245101704Smjacob{ 246101704Smjacob const struct Error_Map *status = IOC_Func; 247101704Smjacob static char buf[64]; 248101704Smjacob while (status->Error_Code >= 0) { 249101704Smjacob if (status->Error_Code == code) 250101704Smjacob return status->Error_String; 251101704Smjacob status++; 252101704Smjacob } 253101704Smjacob snprintf(buf, sizeof buf, "Unknown (0x%08x)", code); 254101704Smjacob return buf; 255101704Smjacob} 256157354Smjacob 257101704Smjacobstatic char * 258101704Smjacobmpt_ioc_event(int code) 259101704Smjacob{ 260101704Smjacob const struct Error_Map *status = IOC_Event; 261101704Smjacob static char buf[64]; 262101704Smjacob while (status->Error_Code >= 0) { 263101704Smjacob if (status->Error_Code == code) 264101704Smjacob return status->Error_String; 265101704Smjacob status++; 266101704Smjacob } 267101704Smjacob snprintf(buf, sizeof buf, "Unknown (0x%08x)", code); 268101704Smjacob return buf; 269101704Smjacob} 270157354Smjacob 271101704Smjacobstatic char * 272101704Smjacobmpt_scsi_state(int code) 273101704Smjacob{ 274101704Smjacob const struct Error_Map *status = IOC_SCSIState; 275101704Smjacob static char buf[128]; 276101704Smjacob char *ptr = buf; 277101704Smjacob char *end = &buf[128]; 278101704Smjacob buf[0] = '\0'; 279101704Smjacob ptr += snprintf(buf, sizeof buf, "(0x%08x)", code); 280101704Smjacob while (status->Error_Code >= 0) { 281101704Smjacob if ((status->Error_Code & code) != 0) 282101704Smjacob ptr += snprintf(ptr, (size_t)(end-ptr), "%s ", 283101704Smjacob status->Error_String); 284101704Smjacob status++; 285101704Smjacob } 286101704Smjacob return buf; 287101704Smjacob} 288224493Smarius 289101704Smjacobstatic char * 290101704Smjacobmpt_scsi_status(int code) 291101704Smjacob{ 292101704Smjacob const struct Error_Map *status = IOC_SCSIStatus; 293101704Smjacob static char buf[64]; 294101704Smjacob while (status->Error_Code >= 0) { 295101704Smjacob if (status->Error_Code == code) 296101704Smjacob return status->Error_String; 297101704Smjacob status++; 298101704Smjacob } 299101704Smjacob snprintf(buf, sizeof buf, "Unknown (0x%08x)", code); 300101704Smjacob return buf; 301101704Smjacob} 302224493Smarius 303224493Smariusstatic const char * 304101704Smjacobmpt_who(int who_init) 305101704Smjacob{ 306224493Smarius const char *who; 307101704Smjacob 308101704Smjacob switch (who_init) { 309101704Smjacob case MPT_DB_INIT_NOONE: who = "No One"; break; 310101704Smjacob case MPT_DB_INIT_BIOS: who = "BIOS"; break; 311101704Smjacob case MPT_DB_INIT_ROMBIOS: who = "ROM BIOS"; break; 312101704Smjacob case MPT_DB_INIT_PCIPEER: who = "PCI Peer"; break; 313101704Smjacob case MPT_DB_INIT_HOST: who = "Host Driver"; break; 314101704Smjacob case MPT_DB_INIT_MANUFACTURE: who = "Manufacturing"; break; 315101704Smjacob default: who = "Unknown"; break; 316101704Smjacob } 317101704Smjacob return who; 318101704Smjacob} 319101704Smjacob 320224493Smariusstatic const char * 321101704Smjacobmpt_state(u_int32_t mb) 322101704Smjacob{ 323224493Smarius const char *text; 324101704Smjacob 325101704Smjacob switch (MPT_STATE(mb)) { 326101704Smjacob case MPT_DB_STATE_RESET: text = "Reset"; break; 327101704Smjacob case MPT_DB_STATE_READY: text = "Ready"; break; 328101704Smjacob case MPT_DB_STATE_RUNNING:text = "Running"; break; 329101704Smjacob case MPT_DB_STATE_FAULT: text = "Fault"; break; 330101704Smjacob default: text = "Unknown"; break; 331101704Smjacob } 332101704Smjacob return text; 333132107Sstefanf} 334101704Smjacob 335147883Sscottlstatic char * 336147883Sscottlmpt_scsi_tm_type(int code) 337147883Sscottl{ 338147883Sscottl const struct Error_Map *status = IOC_SCSITMType; 339147883Sscottl static char buf[64]; 340147883Sscottl while (status->Error_Code >= 0) { 341147883Sscottl if (status->Error_Code == code) 342147883Sscottl return status->Error_String; 343147883Sscottl status++; 344147883Sscottl } 345147883Sscottl snprintf(buf, sizeof buf, "Unknown (0x%08x)", code); 346147883Sscottl return buf; 347147883Sscottl} 348147883Sscottl 349101704Smjacobvoid 350101704Smjacobmpt_print_db(u_int32_t mb) 351101704Smjacob{ 352224493Smarius 353101704Smjacob printf("mpt mailbox: (0x%x) State %s WhoInit %s\n", 354101704Smjacob mb, mpt_state(mb), mpt_who(MPT_WHO(mb))); 355101704Smjacob} 356101704Smjacob 357101704Smjacob/*****************************************************************************/ 358101704Smjacob/* Reply functions */ 359101704Smjacob/*****************************************************************************/ 360101704Smjacobstatic void 361101704Smjacobmpt_print_reply_hdr(MSG_DEFAULT_REPLY *msg) 362101704Smjacob{ 363224493Smarius 364101704Smjacob printf("%s Reply @ %p\n", mpt_ioc_function(msg->Function), msg); 365101704Smjacob printf("\tIOC Status %s\n", mpt_ioc_status(msg->IOCStatus)); 366156041Smjacob printf("\tIOCLogInfo 0x%08x\n", msg->IOCLogInfo); 367101704Smjacob printf("\tMsgLength 0x%02x\n", msg->MsgLength); 368101704Smjacob printf("\tMsgFlags 0x%02x\n", msg->MsgFlags); 369156041Smjacob printf("\tMsgContext 0x%08x\n", msg->MsgContext); 370101704Smjacob} 371101704Smjacob 372101704Smjacobstatic void 373101704Smjacobmpt_print_init_reply(MSG_IOC_INIT_REPLY *msg) 374101704Smjacob{ 375224493Smarius 376101704Smjacob mpt_print_reply_hdr((MSG_DEFAULT_REPLY *)msg); 377101704Smjacob printf("\tWhoInit %s\n", mpt_who(msg->WhoInit)); 378101704Smjacob printf("\tMaxDevices 0x%02x\n", msg->MaxDevices); 379101704Smjacob printf("\tMaxBuses 0x%02x\n", msg->MaxBuses); 380101704Smjacob} 381101704Smjacob 382101704Smjacobstatic void 383101704Smjacobmpt_print_ioc_facts(MSG_IOC_FACTS_REPLY *msg) 384101704Smjacob{ 385224493Smarius 386101704Smjacob mpt_print_reply_hdr((MSG_DEFAULT_REPLY *)msg); 387101704Smjacob printf("\tIOCNumber %d\n", msg->IOCNumber); 388101704Smjacob printf("\tMaxChainDepth %d\n", msg->MaxChainDepth); 389101704Smjacob printf("\tWhoInit %s\n", mpt_who(msg->WhoInit)); 390101704Smjacob printf("\tBlockSize %d\n", msg->BlockSize); 391101704Smjacob printf("\tFlags %d\n", msg->Flags); 392101704Smjacob printf("\tReplyQueueDepth %d\n", msg->ReplyQueueDepth); 393101704Smjacob printf("\tReqFrameSize 0x%04x\n", msg->RequestFrameSize); 394156041Smjacob printf("\tFW Version 0x%08x\n", msg->FWVersion.Word); 395101704Smjacob printf("\tProduct ID 0x%04x\n", msg->ProductID); 396101704Smjacob printf("\tCredits 0x%04x\n", msg->GlobalCredits); 397101704Smjacob printf("\tPorts %d\n", msg->NumberOfPorts); 398101704Smjacob printf("\tEventState 0x%02x\n", msg->EventState); 399156041Smjacob printf("\tHostMFA_HA 0x%08x\n", msg->CurrentHostMfaHighAddr); 400156041Smjacob printf("\tSenseBuf_HA 0x%08x\n", 401101704Smjacob msg->CurrentSenseBufferHighAddr); 402101704Smjacob printf("\tRepFrameSize 0x%04x\n", msg->CurReplyFrameSize); 403101704Smjacob printf("\tMaxDevices 0x%02x\n", msg->MaxDevices); 404101704Smjacob printf("\tMaxBuses 0x%02x\n", msg->MaxBuses); 405156041Smjacob printf("\tFWImageSize 0x%04x\n", msg->FWImageSize); 406101704Smjacob} 407101704Smjacob 408101704Smjacobstatic void 409101704Smjacobmpt_print_enable_reply(MSG_PORT_ENABLE_REPLY *msg) 410101704Smjacob{ 411224493Smarius 412101704Smjacob mpt_print_reply_hdr((MSG_DEFAULT_REPLY *)msg); 413101704Smjacob printf("\tPort: %d\n", msg->PortNumber); 414101704Smjacob} 415101704Smjacob 416101704Smjacobstatic void 417101704Smjacobmpt_print_scsi_io_reply(MSG_SCSI_IO_REPLY *msg) 418101704Smjacob{ 419224493Smarius 420101704Smjacob mpt_print_reply_hdr((MSG_DEFAULT_REPLY *)msg); 421101704Smjacob printf("\tBus: %d\n", msg->Bus); 422101704Smjacob printf("\tTargetID %d\n", msg->TargetID); 423101704Smjacob printf("\tCDBLength %d\n", msg->CDBLength); 424101704Smjacob printf("\tSCSI Status: %s\n", mpt_scsi_status(msg->SCSIStatus)); 425101704Smjacob printf("\tSCSI State: %s\n", mpt_scsi_state(msg->SCSIState)); 426156041Smjacob printf("\tTransferCnt 0x%04x\n", msg->TransferCount); 427156041Smjacob printf("\tSenseCnt 0x%04x\n", msg->SenseCount); 428156041Smjacob printf("\tResponseInfo 0x%08x\n", msg->ResponseInfo); 429101704Smjacob} 430101704Smjacob 431101704Smjacobstatic void 432101704Smjacobmpt_print_event_notice(MSG_EVENT_NOTIFY_REPLY *msg) 433101704Smjacob{ 434224493Smarius 435101704Smjacob mpt_print_reply_hdr((MSG_DEFAULT_REPLY *)msg); 436101704Smjacob printf("\tEvent: %s\n", mpt_ioc_event(msg->Event)); 437156041Smjacob printf("\tEventContext 0x%04x\n", msg->EventContext); 438101704Smjacob printf("\tAckRequired %d\n", msg->AckRequired); 439101704Smjacob printf("\tEventDataLength %d\n", msg->EventDataLength); 440101704Smjacob printf("\tContinuation %d\n", msg->MsgFlags & 0x80); 441101704Smjacob switch(msg->Event) { 442101704Smjacob case MPI_EVENT_LOG_DATA: 443156041Smjacob printf("\tEvtLogData: 0x%04x\n", msg->Data[0]); 444101704Smjacob break; 445101704Smjacob 446101704Smjacob case MPI_EVENT_UNIT_ATTENTION: 447156041Smjacob printf("\tTargetID: 0x%04x\n", 448156041Smjacob msg->Data[0] & 0xff); 449156041Smjacob printf("\tBus: 0x%04x\n", 450156041Smjacob (msg->Data[0] >> 8) & 0xff); 451101704Smjacob break; 452101704Smjacob 453101704Smjacob case MPI_EVENT_IOC_BUS_RESET: 454101704Smjacob case MPI_EVENT_EXT_BUS_RESET: 455101704Smjacob case MPI_EVENT_RESCAN: 456156041Smjacob printf("\tPort: %d\n", 457156041Smjacob (msg->Data[0] >> 8) & 0xff); 458101704Smjacob break; 459101704Smjacob 460101704Smjacob case MPI_EVENT_LINK_STATUS_CHANGE: 461156041Smjacob printf("\tLinkState: %d\n", 462156041Smjacob msg->Data[0] & 0xff); 463156041Smjacob printf("\tPort: %d\n", 464156041Smjacob (msg->Data[1] >> 8) & 0xff); 465101704Smjacob break; 466101704Smjacob 467101704Smjacob case MPI_EVENT_LOOP_STATE_CHANGE: 468156041Smjacob printf("\tType: %d\n", 469156041Smjacob (msg->Data[0] >> 16) & 0xff); 470156041Smjacob printf("\tChar3: 0x%02x\n", 471156041Smjacob (msg->Data[0] >> 8) & 0xff); 472156041Smjacob printf("\tChar4: 0x%02x\n", 473156041Smjacob (msg->Data[0] ) & 0xff); 474156041Smjacob printf("\tPort: %d\n", 475156041Smjacob (msg->Data[1] >> 8) & 0xff); 476101704Smjacob break; 477101704Smjacob 478101704Smjacob case MPI_EVENT_LOGOUT: 479156041Smjacob printf("\tN_PortId: 0x%04x\n", msg->Data[0]); 480156041Smjacob printf("\tPort: %d\n", 481156041Smjacob (msg->Data[1] >> 8) & 0xff); 482101704Smjacob break; 483101704Smjacob } 484101704Smjacob 485101704Smjacob} 486101704Smjacob 487101704Smjacobvoid 488101704Smjacobmpt_print_reply(void *vmsg) 489101704Smjacob{ 490101704Smjacob MSG_DEFAULT_REPLY *msg = vmsg; 491101704Smjacob 492101704Smjacob switch (msg->Function) { 493101704Smjacob case MPI_FUNCTION_EVENT_NOTIFICATION: 494101704Smjacob mpt_print_event_notice((MSG_EVENT_NOTIFY_REPLY *)msg); 495101704Smjacob break; 496101704Smjacob case MPI_FUNCTION_PORT_ENABLE: 497101704Smjacob mpt_print_enable_reply((MSG_PORT_ENABLE_REPLY *)msg); 498101704Smjacob break; 499101704Smjacob case MPI_FUNCTION_IOC_FACTS: 500101704Smjacob mpt_print_ioc_facts((MSG_IOC_FACTS_REPLY *)msg); 501101704Smjacob break; 502101704Smjacob case MPI_FUNCTION_IOC_INIT: 503101704Smjacob mpt_print_init_reply((MSG_IOC_INIT_REPLY *)msg); 504101704Smjacob break; 505101704Smjacob case MPI_FUNCTION_SCSI_IO_REQUEST: 506158935Smjacob case MPI_FUNCTION_RAID_SCSI_IO_PASSTHROUGH: 507101704Smjacob mpt_print_scsi_io_reply((MSG_SCSI_IO_REPLY *)msg); 508101704Smjacob break; 509101704Smjacob default: 510101704Smjacob mpt_print_reply_hdr((MSG_DEFAULT_REPLY *)msg); 511101704Smjacob break; 512101704Smjacob } 513101704Smjacob} 514101704Smjacob 515101704Smjacob/*****************************************************************************/ 516101704Smjacob/* Request functions */ 517101704Smjacob/*****************************************************************************/ 518101704Smjacobstatic void 519101704Smjacobmpt_print_request_hdr(MSG_REQUEST_HEADER *req) 520101704Smjacob{ 521241874Smarius 522101704Smjacob printf("%s @ %p\n", mpt_ioc_function(req->Function), req); 523101704Smjacob printf("\tChain Offset 0x%02x\n", req->ChainOffset); 524101704Smjacob printf("\tMsgFlags 0x%02x\n", req->MsgFlags); 525156041Smjacob printf("\tMsgContext 0x%08x\n", req->MsgContext); 526101704Smjacob} 527101704Smjacob 528224493Smariusstatic void 529101704Smjacobmpt_print_scsi_io_request(MSG_SCSI_IO_REQUEST *orig_msg) 530101704Smjacob{ 531101704Smjacob MSG_SCSI_IO_REQUEST local, *msg = &local; 532101704Smjacob int i; 533101704Smjacob 534101704Smjacob bcopy(orig_msg, msg, sizeof (MSG_SCSI_IO_REQUEST)); 535101704Smjacob mpt_print_request_hdr((MSG_REQUEST_HEADER *)msg); 536101704Smjacob printf("\tBus: %d\n", msg->Bus); 537101704Smjacob printf("\tTargetID %d\n", msg->TargetID); 538101704Smjacob printf("\tSenseBufferLength %d\n", msg->SenseBufferLength); 539315826Smav printf("\tLUN: 0x%jx\n", (uintmax_t)be64dec(msg->LUN)); 540156041Smjacob printf("\tControl 0x%08x ", msg->Control); 541101704Smjacob#define MPI_PRINT_FIELD(x) \ 542101704Smjacob case MPI_SCSIIO_CONTROL_ ## x : \ 543101704Smjacob printf(" " #x " "); \ 544101704Smjacob break 545101704Smjacob 546101704Smjacob switch (msg->Control & MPI_SCSIIO_CONTROL_DATADIRECTION_MASK) { 547101704Smjacob MPI_PRINT_FIELD(NODATATRANSFER); 548101704Smjacob MPI_PRINT_FIELD(WRITE); 549101704Smjacob MPI_PRINT_FIELD(READ); 550101704Smjacob default: 551101704Smjacob printf(" Invalid DIR! "); 552101704Smjacob break; 553101704Smjacob } 554101704Smjacob switch (msg->Control & MPI_SCSIIO_CONTROL_TASKATTRIBUTE_MASK) { 555101704Smjacob MPI_PRINT_FIELD(SIMPLEQ); 556101704Smjacob MPI_PRINT_FIELD(HEADOFQ); 557101704Smjacob MPI_PRINT_FIELD(ORDEREDQ); 558101704Smjacob MPI_PRINT_FIELD(ACAQ); 559101704Smjacob MPI_PRINT_FIELD(UNTAGGED); 560101704Smjacob MPI_PRINT_FIELD(NO_DISCONNECT); 561101704Smjacob default: 562101704Smjacob printf(" Unknown attribute! "); 563101704Smjacob break; 564101704Smjacob } 565101704Smjacob 566101704Smjacob printf("\n"); 567101704Smjacob#undef MPI_PRINT_FIELD 568101704Smjacob 569156041Smjacob printf("\tDataLength\t0x%08x\n", msg->DataLength); 570156041Smjacob printf("\tSenseBufAddr\t0x%08x\n", msg->SenseBufferLowAddr); 571101704Smjacob printf("\tCDB[0:%d]\t", msg->CDBLength); 572101704Smjacob for (i = 0; i < msg->CDBLength; i++) 573101704Smjacob printf("%02x ", msg->CDB[i]); 574101704Smjacob printf("\n"); 575155521Smjacob 576155521Smjacob if ((msg->Control & MPI_SCSIIO_CONTROL_DATADIRECTION_MASK) != 577155521Smjacob MPI_SCSIIO_CONTROL_NODATATRANSFER ) { 578155521Smjacob mpt_dump_sgl(&orig_msg->SGL, 579155521Smjacob ((char *)&orig_msg->SGL)-(char *)orig_msg); 580155521Smjacob } 581101704Smjacob} 582101704Smjacob 583147883Sscottlstatic void 584147883Sscottlmpt_print_scsi_tmf_request(MSG_SCSI_TASK_MGMT *msg) 585147883Sscottl{ 586224493Smarius 587147883Sscottl mpt_print_request_hdr((MSG_REQUEST_HEADER *)msg); 588315826Smav printf("\tLun 0x%jx\n", (uintmax_t)be64dec(msg->LUN)); 589147883Sscottl printf("\tTaskType %s\n", mpt_scsi_tm_type(msg->TaskType)); 590156041Smjacob printf("\tTaskMsgContext 0x%08x\n", msg->TaskMsgContext); 591147883Sscottl} 592147883Sscottl 593157117Smjacob 594157117Smjacobstatic void 595157117Smjacobmpt_print_scsi_target_assist_request(PTR_MSG_TARGET_ASSIST_REQUEST msg) 596157117Smjacob{ 597224493Smarius 598157117Smjacob mpt_print_request_hdr((MSG_REQUEST_HEADER *)msg); 599157117Smjacob printf("\tStatusCode 0x%02x\n", msg->StatusCode); 600157117Smjacob printf("\tTargetAssist 0x%02x\n", msg->TargetAssistFlags); 601157117Smjacob printf("\tQueueTag 0x%04x\n", msg->QueueTag); 602157117Smjacob printf("\tReplyWord 0x%08x\n", msg->ReplyWord); 603315826Smav printf("\tLun 0x%jx\n", (uintmax_t)be64dec(msg->LUN)); 604157117Smjacob printf("\tRelativeOff 0x%08x\n", msg->RelativeOffset); 605157117Smjacob printf("\tDataLength 0x%08x\n", msg->DataLength); 606157117Smjacob mpt_dump_sgl(msg->SGL, 0); 607157117Smjacob} 608157117Smjacob 609157117Smjacobstatic void 610157117Smjacobmpt_print_scsi_target_status_send_request(MSG_TARGET_STATUS_SEND_REQUEST *msg) 611157117Smjacob{ 612157117Smjacob SGE_IO_UNION x; 613224493Smarius 614157117Smjacob mpt_print_request_hdr((MSG_REQUEST_HEADER *)msg); 615157117Smjacob printf("\tStatusCode 0x%02x\n", msg->StatusCode); 616157117Smjacob printf("\tStatusFlags 0x%02x\n", msg->StatusFlags); 617157117Smjacob printf("\tQueueTag 0x%04x\n", msg->QueueTag); 618157117Smjacob printf("\tReplyWord 0x%08x\n", msg->ReplyWord); 619315826Smav printf("\tLun 0x%jx\n", (uintmax_t)be64dec(msg->LUN)); 620157117Smjacob x.u.Simple = msg->StatusDataSGE; 621157117Smjacob mpt_dump_sgl(&x, 0); 622157117Smjacob} 623157117Smjacob 624101704Smjacobvoid 625101704Smjacobmpt_print_request(void *vreq) 626101704Smjacob{ 627101704Smjacob MSG_REQUEST_HEADER *req = vreq; 628101704Smjacob 629101704Smjacob switch (req->Function) { 630101704Smjacob case MPI_FUNCTION_SCSI_IO_REQUEST: 631158935Smjacob case MPI_FUNCTION_RAID_SCSI_IO_PASSTHROUGH: 632101704Smjacob mpt_print_scsi_io_request((MSG_SCSI_IO_REQUEST *)req); 633101704Smjacob break; 634147883Sscottl case MPI_FUNCTION_SCSI_TASK_MGMT: 635147883Sscottl mpt_print_scsi_tmf_request((MSG_SCSI_TASK_MGMT *)req); 636157117Smjacob break; 637157117Smjacob case MPI_FUNCTION_TARGET_ASSIST: 638157117Smjacob mpt_print_scsi_target_assist_request( 639157117Smjacob (PTR_MSG_TARGET_ASSIST_REQUEST)req); 640157117Smjacob break; 641157117Smjacob case MPI_FUNCTION_TARGET_STATUS_SEND: 642157117Smjacob mpt_print_scsi_target_status_send_request( 643157117Smjacob (MSG_TARGET_STATUS_SEND_REQUEST *)req); 644157117Smjacob break; 645101704Smjacob default: 646101704Smjacob mpt_print_request_hdr(req); 647101704Smjacob break; 648101704Smjacob } 649101704Smjacob} 650101704Smjacob 651224493Smarius#if 0 652224493Smariustypedef struct mpt_decode_entry { 653224493Smarius char *name; 654224493Smarius u_int value; 655224493Smarius u_int mask; 656224493Smarius} mpt_decode_entry_t; 657224493Smarius 658224493Smariusstatic int 659147883Sscottlmpt_decode_value(mpt_decode_entry_t *table, u_int num_entries, 660147883Sscottl const char *name, u_int value, u_int *cur_column, 661147883Sscottl u_int wrap_point) 662101704Smjacob{ 663147883Sscottl int printed; 664147883Sscottl u_int printed_mask; 665147883Sscottl u_int dummy_column; 666101704Smjacob 667147883Sscottl if (cur_column == NULL) { 668147883Sscottl dummy_column = 0; 669147883Sscottl cur_column = &dummy_column; 670101704Smjacob } 671147883Sscottl 672147883Sscottl if (*cur_column >= wrap_point) { 673147883Sscottl printf("\n"); 674147883Sscottl *cur_column = 0; 675147883Sscottl } 676147883Sscottl printed = printf("%s[0x%x]", name, value); 677147883Sscottl if (table == NULL) { 678147883Sscottl printed += printf(" "); 679147883Sscottl *cur_column += printed; 680147883Sscottl return (printed); 681147883Sscottl } 682147883Sscottl printed_mask = 0; 683147883Sscottl while (printed_mask != 0xFF) { 684147883Sscottl int entry; 685147883Sscottl 686147883Sscottl for (entry = 0; entry < num_entries; entry++) { 687147883Sscottl if (((value & table[entry].mask) 688147883Sscottl != table[entry].value) 689147883Sscottl || ((printed_mask & table[entry].mask) 690147883Sscottl == table[entry].mask)) 691147883Sscottl continue; 692147883Sscottl 693147883Sscottl printed += printf("%s%s", 694147883Sscottl printed_mask == 0 ? ":(" : "|", 695147883Sscottl table[entry].name); 696147883Sscottl printed_mask |= table[entry].mask; 697147883Sscottl break; 698147883Sscottl } 699147883Sscottl if (entry >= num_entries) 700147883Sscottl break; 701147883Sscottl } 702147883Sscottl if (printed_mask != 0) 703147883Sscottl printed += printf(") "); 704147883Sscottl else 705147883Sscottl printed += printf(" "); 706147883Sscottl *cur_column += printed; 707147883Sscottl return (printed); 708132107Sstefanf} 709101704Smjacob 710224493Smariusstatic const mpt_decode_entry_t req_state_parse_table[] = { 711147883Sscottl { "REQ_FREE", 0x00, 0xff }, 712147883Sscottl { "REQ_ALLOCATED", 0x01, 0x01 }, 713147883Sscottl { "REQ_QUEUED", 0x02, 0x02 }, 714147883Sscottl { "REQ_DONE", 0x04, 0x04 }, 715147883Sscottl { "REQ_TIMEDOUT", 0x08, 0x08 }, 716147883Sscottl { "REQ_NEED_WAKEUP", 0x10, 0x10 } 717147883Sscottl}; 718147883Sscottl 719224493Smariusstatic void 720147883Sscottlmpt_req_state(mpt_req_state_t state) 721147883Sscottl{ 722224493Smarius 723147883Sscottl mpt_decode_value(req_state_parse_table, 724147883Sscottl NUM_ELEMENTS(req_state_parse_table), 725147883Sscottl "REQ_STATE", state, NULL, 80); 726147883Sscottl} 727224493Smarius#endif 728147883Sscottl 729155521Smjacob#define LAST_SGE ( \ 730155521Smjacob MPI_SGE_FLAGS_END_OF_LIST | \ 731155521Smjacob MPI_SGE_FLAGS_END_OF_BUFFER| \ 732155521Smjacob MPI_SGE_FLAGS_LAST_ELEMENT) 733155521Smjacobvoid 734155521Smjacobmpt_dump_sgl(SGE_IO_UNION *su, int offset) 735101704Smjacob{ 736101704Smjacob SGE_SIMPLE32 *se = (SGE_SIMPLE32 *) su; 737155521Smjacob const char allfox[4] = { 0xff, 0xff, 0xff, 0xff }; 738155521Smjacob void *nxtaddr = se; 739155521Smjacob void *lim; 740155521Smjacob int flags; 741101704Smjacob 742155521Smjacob /* 743155521Smjacob * Can't be any bigger than this. 744155521Smjacob */ 745155521Smjacob lim = &((char *)se)[MPT_REQUEST_AREA - offset]; 746155521Smjacob 747101704Smjacob do { 748101704Smjacob int iprt; 749101704Smjacob 750101704Smjacob printf("\t"); 751155521Smjacob if (memcmp(se, allfox, 4) == 0) { 752155521Smjacob uint32_t *nxt = (uint32_t *)se; 753155521Smjacob printf("PAD %p\n", se); 754155521Smjacob nxtaddr = nxt + 1; 755155521Smjacob se = nxtaddr; 756155521Smjacob flags = 0; 757155521Smjacob continue; 758155521Smjacob } 759155521Smjacob nxtaddr = se + 1; 760101704Smjacob flags = MPI_SGE_GET_FLAGS(se->FlagsLength); 761101704Smjacob switch (flags & MPI_SGE_FLAGS_ELEMENT_MASK) { 762101704Smjacob case MPI_SGE_FLAGS_SIMPLE_ELEMENT: 763155521Smjacob if (flags & MPI_SGE_FLAGS_64_BIT_ADDRESSING) { 764155521Smjacob SGE_SIMPLE64 *se64 = (SGE_SIMPLE64 *)se; 765156041Smjacob printf("SE64 %p: Addr=0x%08x%08x FlagsLength" 766156041Smjacob "=0x%0x\n", se64, se64->Address.High, 767155521Smjacob se64->Address.Low, se64->FlagsLength); 768155521Smjacob nxtaddr = se64 + 1; 769155521Smjacob } else { 770156041Smjacob printf("SE32 %p: Addr=0x%0x FlagsLength=0x%0x" 771155521Smjacob "\n", se, se->Address, se->FlagsLength); 772155521Smjacob } 773101704Smjacob printf(" "); 774101704Smjacob break; 775101704Smjacob case MPI_SGE_FLAGS_CHAIN_ELEMENT: 776155521Smjacob if (flags & MPI_SGE_FLAGS_64_BIT_ADDRESSING) { 777155521Smjacob SGE_CHAIN64 *ce64 = (SGE_CHAIN64 *) se; 778156041Smjacob printf("CE64 %p: Addr=0x%08x%08x NxtChnO=0x%x " 779156041Smjacob "Flgs=0x%x Len=0x%0x\n", ce64, 780155521Smjacob ce64->Address.High, ce64->Address.Low, 781155521Smjacob ce64->NextChainOffset, 782155521Smjacob ce64->Flags, ce64->Length); 783155521Smjacob nxtaddr = ce64 + 1; 784155521Smjacob } else { 785155521Smjacob SGE_CHAIN32 *ce = (SGE_CHAIN32 *) se; 786156041Smjacob printf("CE32 %p: Addr=0x%0x NxtChnO=0x%x " 787156041Smjacob " Flgs=0x%x Len=0x%0x\n", ce, ce->Address, 788155521Smjacob ce->NextChainOffset, ce->Flags, ce->Length); 789155521Smjacob } 790101704Smjacob flags = 0; 791101704Smjacob break; 792101704Smjacob case MPI_SGE_FLAGS_TRANSACTION_ELEMENT: 793101704Smjacob printf("TE32 @ %p\n", se); 794101704Smjacob flags = 0; 795101704Smjacob break; 796101704Smjacob } 797101704Smjacob iprt = 0; 798101704Smjacob#define MPT_PRINT_FLAG(x) \ 799101704Smjacob if (flags & MPI_SGE_FLAGS_ ## x ) { \ 800101704Smjacob if (iprt == 0) { \ 801101704Smjacob printf("\t"); \ 802101704Smjacob } \ 803101704Smjacob printf(" "); \ 804101704Smjacob printf( #x ); \ 805101704Smjacob iprt++; \ 806101704Smjacob } 807101704Smjacob MPT_PRINT_FLAG(LOCAL_ADDRESS); 808101704Smjacob MPT_PRINT_FLAG(HOST_TO_IOC); 809101704Smjacob MPT_PRINT_FLAG(64_BIT_ADDRESSING); 810101704Smjacob MPT_PRINT_FLAG(LAST_ELEMENT); 811101704Smjacob MPT_PRINT_FLAG(END_OF_BUFFER); 812101704Smjacob MPT_PRINT_FLAG(END_OF_LIST); 813101704Smjacob#undef MPT_PRINT_FLAG 814101704Smjacob if (iprt) 815101704Smjacob printf("\n"); 816155521Smjacob se = nxtaddr; 817155521Smjacob if ((flags & LAST_SGE) == LAST_SGE) { 818155521Smjacob break; 819155521Smjacob } 820155521Smjacob } while ((flags & MPI_SGE_FLAGS_END_OF_LIST) == 0 && nxtaddr < lim); 821101704Smjacob} 822103914Smjacob 823158935Smjacobvoid 824160290Smjacobmpt_dump_data(struct mpt_softc *mpt, const char *msg, void *addr, int len) 825160290Smjacob{ 826160290Smjacob int offset; 827160290Smjacob uint8_t *cp = addr; 828224493Smarius 829160290Smjacob mpt_prt(mpt, "%s:", msg); 830160290Smjacob for (offset = 0; offset < len; offset++) { 831160290Smjacob if ((offset & 0xf) == 0) { 832160290Smjacob mpt_prtc(mpt, "\n"); 833160290Smjacob } 834160290Smjacob mpt_prtc(mpt, " %02x", cp[offset]); 835160290Smjacob } 836160290Smjacob mpt_prtc(mpt, "\n"); 837160290Smjacob} 838160290Smjacob 839160290Smjacobvoid 840158935Smjacobmpt_dump_request(struct mpt_softc *mpt, request_t *req) 841158935Smjacob{ 842158935Smjacob uint32_t *pReq = req->req_vbuf; 843164990Smjacob int o; 844224493Smarius 845158935Smjacob mpt_prt(mpt, "Send Request %d (%jx):", 846158935Smjacob req->index, (uintmax_t) req->req_pbuf); 847164990Smjacob for (o = 0; o < mpt->ioc_facts.RequestFrameSize; o++) { 848164990Smjacob if ((o & 0x7) == 0) { 849158935Smjacob mpt_prtc(mpt, "\n"); 850158935Smjacob mpt_prt(mpt, " "); 851158935Smjacob } 852164990Smjacob mpt_prtc(mpt, " %08x", pReq[o]); 853158935Smjacob } 854158935Smjacob mpt_prtc(mpt, "\n"); 855158935Smjacob} 856158935Smjacob 857103914Smjacobvoid 858147883Sscottlmpt_prt(struct mpt_softc *mpt, const char *fmt, ...) 859103914Smjacob{ 860103914Smjacob va_list ap; 861147883Sscottl 862103914Smjacob printf("%s: ", device_get_nameunit(mpt->dev)); 863103914Smjacob va_start(ap, fmt); 864103914Smjacob vprintf(fmt, ap); 865103914Smjacob va_end(ap); 866103914Smjacob} 867147883Sscottl 868147883Sscottlvoid 869147883Sscottlmpt_prtc(struct mpt_softc *mpt, const char *fmt, ...) 870147883Sscottl{ 871147883Sscottl va_list ap; 872147883Sscottl 873147883Sscottl va_start(ap, fmt); 874147883Sscottl vprintf(fmt, ap); 875147883Sscottl va_end(ap); 876147883Sscottl} 877