1 /* $FreeBSD$ */ 2 /* 3 * Debug routines for LSI '909 FC adapters. 4 * FreeBSD Version. 5 * 6 * Copyright (c) 2000, 2001 by Greg Ansley 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice immediately at the beginning of the file, without modification, 13 * this list of conditions, and the following disclaimer. 14 * 2. The name of the author may not be used to endorse or promote products 15 * derived from this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18 * 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 AUTHOR OR CONTRIBUTORS BE LIABLE FOR 21 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 /* 30 * Additional Copyright (c) 2002 by Matthew Jacob under same license. 31 */ 32 33 #include <dev/mpt/mpt_freebsd.h> 34 35 struct Error_Map { 36 int Error_Code; 37 char *Error_String; 38 }; 39 40 static const struct Error_Map IOC_Status[] = { 41 { MPI_IOCSTATUS_SUCCESS, "Success" }, 42 { MPI_IOCSTATUS_INVALID_FUNCTION, "IOC: Invalid Function" }, 43 { MPI_IOCSTATUS_BUSY, "IOC: Busy" }, 44 { MPI_IOCSTATUS_INVALID_SGL, "IOC: Invalid SGL" }, 45 { MPI_IOCSTATUS_INTERNAL_ERROR, "IOC: Internal Error" }, 46 { MPI_IOCSTATUS_RESERVED, "IOC: Reserved" }, 47 { MPI_IOCSTATUS_INSUFFICIENT_RESOURCES, "IOC: Insufficient Resources" }, 48 { MPI_IOCSTATUS_INVALID_FIELD, "IOC: Invalid Field" }, 49 { MPI_IOCSTATUS_INVALID_STATE, "IOC: Invalid State" }, 50 { MPI_IOCSTATUS_CONFIG_INVALID_ACTION, "Invalid Action" }, 51 { MPI_IOCSTATUS_CONFIG_INVALID_TYPE, "Invalid Type" }, 52 { MPI_IOCSTATUS_CONFIG_INVALID_PAGE, "Invalid Page" }, 53 { MPI_IOCSTATUS_CONFIG_INVALID_DATA, "Invalid Data" }, 54 { MPI_IOCSTATUS_CONFIG_NO_DEFAULTS, "No Defaults" }, 55 { MPI_IOCSTATUS_CONFIG_CANT_COMMIT, "Can't Commit" }, 56 { MPI_IOCSTATUS_SCSI_RECOVERED_ERROR, "SCSI: Recoverd Error" }, 57 { MPI_IOCSTATUS_SCSI_INVALID_BUS, "SCSI: Invalid Bus" }, 58 { MPI_IOCSTATUS_SCSI_INVALID_TARGETID, "SCSI: Invalid Target ID" }, 59 { MPI_IOCSTATUS_SCSI_DEVICE_NOT_THERE, "SCSI: Device Not There" }, 60 { MPI_IOCSTATUS_SCSI_DATA_OVERRUN, "SCSI: Data Overrun" }, 61 { MPI_IOCSTATUS_SCSI_DATA_UNDERRUN, "SCSI: Data Underrun" }, 62 { MPI_IOCSTATUS_SCSI_IO_DATA_ERROR, "SCSI: Data Error" }, 63 { MPI_IOCSTATUS_SCSI_PROTOCOL_ERROR, "SCSI: Protocol Error" }, 64 { MPI_IOCSTATUS_SCSI_TASK_TERMINATED, "SCSI: Task Terminated" }, 65 { MPI_IOCSTATUS_SCSI_RESIDUAL_MISMATCH, "SCSI: Residual Mismatch" }, 66 { MPI_IOCSTATUS_SCSI_TASK_MGMT_FAILED, "SCSI: Task Management Failed" }, 67 { MPI_IOCSTATUS_SCSI_IOC_TERMINATED, "SCSI: IOC Bus Reset" }, 68 { MPI_IOCSTATUS_SCSI_EXT_TERMINATED, "SCSI: External Bus Reset" }, 69 { MPI_IOCSTATUS_TARGET_PRIORITY_IO, "SCSI Target: Priority I/O" }, 70 { MPI_IOCSTATUS_TARGET_INVALID_PORT, "SCSI Target: Invalid Port" }, 71 { MPI_IOCSTATUS_TARGET_INVALID_IOCINDEX, "SCSI Target: Invalid IOC Index" }, 72 { MPI_IOCSTATUS_TARGET_ABORTED, "SCSI Target: Aborted" }, 73 { MPI_IOCSTATUS_TARGET_NO_CONN_RETRYABLE, "SCSI Target: No Connection (Retryable)" }, 74 { MPI_IOCSTATUS_TARGET_NO_CONNECTION, "SCSI Target: No Connection" }, 75 { MPI_IOCSTATUS_TARGET_XFER_COUNT_MISMATCH,"SCSI Target: Transfer Count Mismatch" }, 76 { MPI_IOCSTATUS_TARGET_FC_ABORTED, "FC: Aborted" }, 77 { MPI_IOCSTATUS_TARGET_FC_RX_ID_INVALID, "FC: Recieve ID Invalid" }, 78 { MPI_IOCSTATUS_TARGET_FC_DID_INVALID, "FC: Recieve DID Invalid" }, 79 { MPI_IOCSTATUS_TARGET_FC_NODE_LOGGED_OUT,"FC: Node Logged Out" }, 80 { MPI_IOCSTATUS_LAN_DEVICE_NOT_FOUND, "LAN: Device Not Found" }, 81 { MPI_IOCSTATUS_LAN_DEVICE_FAILURE, "LAN: Device Not Failure" }, 82 { MPI_IOCSTATUS_LAN_TRANSMIT_ERROR, "LAN: Transmit Error" }, 83 { MPI_IOCSTATUS_LAN_TRANSMIT_ABORTED, "LAN: Transmit Aborted" }, 84 { MPI_IOCSTATUS_LAN_RECEIVE_ERROR, "LAN: Recieve Error" }, 85 { MPI_IOCSTATUS_LAN_RECEIVE_ABORTED, "LAN: Recieve Aborted" }, 86 { MPI_IOCSTATUS_LAN_PARTIAL_PACKET, "LAN: Partial Packet" }, 87 { MPI_IOCSTATUS_LAN_CANCELED, "LAN: Canceled" }, 88 { -1, 0}, 89 }; 90 91 static const struct Error_Map IOC_Func[] = { 92 { MPI_FUNCTION_SCSI_IO_REQUEST, "SCSI IO Request" }, 93 { MPI_FUNCTION_SCSI_TASK_MGMT, "SCSI Task Management" }, 94 { MPI_FUNCTION_IOC_INIT, "IOC Init" }, 95 { MPI_FUNCTION_IOC_FACTS, "IOC Facts" }, 96 { MPI_FUNCTION_CONFIG, "Config" }, 97 { MPI_FUNCTION_PORT_FACTS, "Port Facts" }, 98 { MPI_FUNCTION_PORT_ENABLE, "Port Enable" }, 99 { MPI_FUNCTION_EVENT_NOTIFICATION, "Event Notification" }, 100 { MPI_FUNCTION_FW_DOWNLOAD, "FW Download" }, 101 { MPI_FUNCTION_TARGET_CMD_BUFFER_POST, "SCSI Target Command Buffer" }, 102 { MPI_FUNCTION_TARGET_ASSIST, "Target Assist" }, 103 { MPI_FUNCTION_TARGET_STATUS_SEND, "Target Status Send" }, 104 { MPI_FUNCTION_TARGET_MODE_ABORT, "Target Mode Abort" }, 105 { MPI_FUNCTION_TARGET_FC_BUF_POST_LINK_SRVC, "FC: Link Service Buffers" }, 106 { MPI_FUNCTION_TARGET_FC_RSP_LINK_SRVC, "FC: Link Service Response" }, 107 { MPI_FUNCTION_TARGET_FC_EX_SEND_LINK_SRVC, "FC: Send Extended Link Service" }, 108 { MPI_FUNCTION_TARGET_FC_ABORT, "FC: Abort" }, 109 { MPI_FUNCTION_LAN_SEND, "LAN Send" }, 110 { MPI_FUNCTION_LAN_RECEIVE, "LAN Recieve" }, 111 { MPI_FUNCTION_LAN_RESET, "LAN Reset" }, 112 { -1, 0}, 113 }; 114 115 static const struct Error_Map IOC_Event[] = { 116 { MPI_EVENT_NONE, "None" }, 117 { MPI_EVENT_LOG_DATA, "LogData" }, 118 { MPI_EVENT_STATE_CHANGE, "State Change" }, 119 { MPI_EVENT_UNIT_ATTENTION, "Unit Attention" }, 120 { MPI_EVENT_IOC_BUS_RESET, "IOC Bus Reset" }, 121 { MPI_EVENT_EXT_BUS_RESET, "External Bus Reset" }, 122 { MPI_EVENT_RESCAN, "Rescan" }, 123 { MPI_EVENT_LINK_STATUS_CHANGE, "Link Status Change" }, 124 { MPI_EVENT_LOOP_STATE_CHANGE, "Loop State Change" }, 125 { MPI_EVENT_LOGOUT, "Logout" }, 126 { MPI_EVENT_EVENT_CHANGE, "EventChange" }, 127 { -1, 0}, 128 }; 129 130 static const struct Error_Map IOC_SCSIState[] = { 131 { MPI_SCSI_STATE_AUTOSENSE_VALID, "AutoSense_Valid" }, 132 { MPI_SCSI_STATE_AUTOSENSE_FAILED, "AutoSense_Failed" }, 133 { MPI_SCSI_STATE_NO_SCSI_STATUS, "No_SCSI_Status" }, 134 { MPI_SCSI_STATE_TERMINATED, "State_Terminated" }, 135 { MPI_SCSI_STATE_RESPONSE_INFO_VALID, "Repsonse_Info_Valid" }, 136 { MPI_SCSI_STATE_QUEUE_TAG_REJECTED, "Queue Tag Rejected" }, 137 { -1, 0}, 138 }; 139 140 static const struct Error_Map IOC_SCSIStatus[] = { 141 { SCSI_STATUS_OK, "OK" }, 142 { SCSI_STATUS_CHECK_COND, "Check Condition" }, 143 { SCSI_STATUS_COND_MET, "Check Condition Met" }, 144 { SCSI_STATUS_BUSY, "Busy" }, 145 { SCSI_STATUS_INTERMED, "Intermidiate Condition" }, 146 { SCSI_STATUS_INTERMED_COND_MET, "Intermidiate Condition Met" }, 147 { SCSI_STATUS_RESERV_CONFLICT, "Reservation Conflict" }, 148 { SCSI_STATUS_CMD_TERMINATED, "Command Terminated" }, 149 { SCSI_STATUS_QUEUE_FULL, "Queue Full" }, 150 { -1, 0}, 151 }; 152 153 static const struct Error_Map IOC_Diag[] = { 154 { MPT_DIAG_ENABLED, "DWE" }, 155 { MPT_DIAG_FLASHBAD, "FLASH_Bad" }, 156 { MPT_DIAG_TTLI, "TTLI" }, 157 { MPT_DIAG_RESET_IOC, "Reset" }, 158 { MPT_DIAG_ARM_DISABLE, "DisARM" }, 159 { MPT_DIAG_DME, "DME" }, 160 { -1, 0 }, 161 }; 162 163 164 static void mpt_dump_sgl(SGE_IO_UNION *sgl); 165 166 static char * 167 mpt_ioc_status(int code) 168 { 169 const struct Error_Map *status = IOC_Status; 170 static char buf[64]; 171 while (status->Error_Code >= 0) { 172 if (status->Error_Code == (code & MPI_IOCSTATUS_MASK)) 173 return status->Error_String; 174 status++; 175 } 176 snprintf(buf, sizeof buf, "Unknown (0x%08x)", code); 177 return buf; 178 } 179 180 char * 181 mpt_ioc_diag(u_int32_t code) 182 { 183 const struct Error_Map *status = IOC_Diag; 184 static char buf[128]; 185 char *ptr = buf; 186 char *end = &buf[128]; 187 buf[0] = '\0'; 188 ptr += snprintf(buf, sizeof buf, "(0x%08x)", code); 189 while (status->Error_Code >= 0) { 190 if ((status->Error_Code & code) != 0) 191 ptr += snprintf(ptr, (size_t)(end-ptr), "%s ", 192 status->Error_String); 193 status++; 194 } 195 return buf; 196 } 197 198 static char * 199 mpt_ioc_function(int code) 200 { 201 const struct Error_Map *status = IOC_Func; 202 static char buf[64]; 203 while (status->Error_Code >= 0) { 204 if (status->Error_Code == code) 205 return status->Error_String; 206 status++; 207 } 208 snprintf(buf, sizeof buf, "Unknown (0x%08x)", code); 209 return buf; 210 } 211 static char * 212 mpt_ioc_event(int code) 213 { 214 const struct Error_Map *status = IOC_Event; 215 static char buf[64]; 216 while (status->Error_Code >= 0) { 217 if (status->Error_Code == code) 218 return status->Error_String; 219 status++; 220 } 221 snprintf(buf, sizeof buf, "Unknown (0x%08x)", code); 222 return buf; 223 } 224 static char * 225 mpt_scsi_state(int code) 226 { 227 const struct Error_Map *status = IOC_SCSIState; 228 static char buf[128]; 229 char *ptr = buf; 230 char *end = &buf[128]; 231 buf[0] = '\0'; 232 ptr += snprintf(buf, sizeof buf, "(0x%08x)", code); 233 while (status->Error_Code >= 0) { 234 if ((status->Error_Code & code) != 0) 235 ptr += snprintf(ptr, (size_t)(end-ptr), "%s ", 236 status->Error_String); 237 status++; 238 } 239 return buf; 240 } 241 static char * 242 mpt_scsi_status(int code) 243 { 244 const struct Error_Map *status = IOC_SCSIStatus; 245 static char buf[64]; 246 while (status->Error_Code >= 0) { 247 if (status->Error_Code == code) 248 return status->Error_String; 249 status++; 250 } 251 snprintf(buf, sizeof buf, "Unknown (0x%08x)", code); 252 return buf; 253 } 254 static char * 255 mpt_who(int who_init) 256 { 257 char *who; 258 259 switch (who_init) { 260 case MPT_DB_INIT_NOONE: who = "No One"; break; 261 case MPT_DB_INIT_BIOS: who = "BIOS"; break; 262 case MPT_DB_INIT_ROMBIOS: who = "ROM BIOS"; break; 263 case MPT_DB_INIT_PCIPEER: who = "PCI Peer"; break; 264 case MPT_DB_INIT_HOST: who = "Host Driver"; break; 265 case MPT_DB_INIT_MANUFACTURE: who = "Manufacturing"; break; 266 default: who = "Unknown"; break; 267 } 268 return who; 269 } 270 271 static char * 272 mpt_state(u_int32_t mb) 273 { 274 char *text; 275 276 switch (MPT_STATE(mb)) { 277 case MPT_DB_STATE_RESET: text = "Reset"; break; 278 case MPT_DB_STATE_READY: text = "Ready"; break; 279 case MPT_DB_STATE_RUNNING:text = "Running"; break; 280 case MPT_DB_STATE_FAULT: text = "Fault"; break; 281 default: text = "Unknown"; break; 282 } 283 return text; 284 }; 285 286 void 287 mpt_print_db(u_int32_t mb) 288 { 289 printf("mpt mailbox: (0x%x) State %s WhoInit %s\n", 290 mb, mpt_state(mb), mpt_who(MPT_WHO(mb))); 291 } 292 293 /*****************************************************************************/ 294 /* Reply functions */ 295 /*****************************************************************************/ 296 static void 297 mpt_print_reply_hdr(MSG_DEFAULT_REPLY *msg) 298 { 299 printf("%s Reply @ %p\n", mpt_ioc_function(msg->Function), msg); 300 printf("\tIOC Status %s\n", mpt_ioc_status(msg->IOCStatus)); 301 printf("\tIOCLogInfo 0x%08x\n", msg->IOCLogInfo); 302 printf("\tMsgLength 0x%02x\n", msg->MsgLength); 303 printf("\tMsgFlags 0x%02x\n", msg->MsgFlags); 304 printf("\tMsgContext 0x%08x\n", msg->MsgContext); 305 } 306 307 static void 308 mpt_print_init_reply(MSG_IOC_INIT_REPLY *msg) 309 { 310 mpt_print_reply_hdr((MSG_DEFAULT_REPLY *)msg); 311 printf("\tWhoInit %s\n", mpt_who(msg->WhoInit)); 312 printf("\tMaxDevices 0x%02x\n", msg->MaxDevices); 313 printf("\tMaxBuses 0x%02x\n", msg->MaxBuses); 314 } 315 316 static void 317 mpt_print_ioc_facts(MSG_IOC_FACTS_REPLY *msg) 318 { 319 mpt_print_reply_hdr((MSG_DEFAULT_REPLY *)msg); 320 printf("\tIOCNumber %d\n", msg->IOCNumber); 321 printf("\tMaxChainDepth %d\n", msg->MaxChainDepth); 322 printf("\tWhoInit %s\n", mpt_who(msg->WhoInit)); 323 printf("\tBlockSize %d\n", msg->BlockSize); 324 printf("\tFlags %d\n", msg->Flags); 325 printf("\tReplyQueueDepth %d\n", msg->ReplyQueueDepth); 326 printf("\tReqFrameSize 0x%04x\n", msg->RequestFrameSize); 327 printf("\tFW Version 0x%08x\n", msg->FWVersion.Word); 328 printf("\tProduct ID 0x%04x\n", msg->ProductID); 329 printf("\tCredits 0x%04x\n", msg->GlobalCredits); 330 printf("\tPorts %d\n", msg->NumberOfPorts); 331 printf("\tEventState 0x%02x\n", msg->EventState); 332 printf("\tHostMFA_HA 0x%08x\n", msg->CurrentHostMfaHighAddr); 333 printf("\tSenseBuf_HA 0x%08x\n", 334 msg->CurrentSenseBufferHighAddr); 335 printf("\tRepFrameSize 0x%04x\n", msg->CurReplyFrameSize); 336 printf("\tMaxDevices 0x%02x\n", msg->MaxDevices); 337 printf("\tMaxBuses 0x%02x\n", msg->MaxBuses); 338 printf("\tFWImageSize 0x%04x\n", msg->FWImageSize); 339 } 340 341 static void 342 mpt_print_enable_reply(MSG_PORT_ENABLE_REPLY *msg) 343 { 344 mpt_print_reply_hdr((MSG_DEFAULT_REPLY *)msg); 345 printf("\tPort: %d\n", msg->PortNumber); 346 } 347 348 static void 349 mpt_print_scsi_io_reply(MSG_SCSI_IO_REPLY *msg) 350 { 351 mpt_print_reply_hdr((MSG_DEFAULT_REPLY *)msg); 352 printf("\tBus: %d\n", msg->Bus); 353 printf("\tTargetID %d\n", msg->TargetID); 354 printf("\tCDBLength %d\n", msg->CDBLength); 355 printf("\tSCSI Status: %s\n", mpt_scsi_status(msg->SCSIStatus)); 356 printf("\tSCSI State: %s\n", mpt_scsi_state(msg->SCSIState)); 357 printf("\tTransferCnt 0x%04x\n", msg->TransferCount); 358 printf("\tSenseCnt 0x%04x\n", msg->SenseCount); 359 printf("\tResponseInfo 0x%08x\n", msg->ResponseInfo); 360 } 361 362 363 364 static void 365 mpt_print_event_notice(MSG_EVENT_NOTIFY_REPLY *msg) 366 { 367 mpt_print_reply_hdr((MSG_DEFAULT_REPLY *)msg); 368 printf("\tEvent: %s\n", mpt_ioc_event(msg->Event)); 369 printf("\tEventContext 0x%04x\n", msg->EventContext); 370 printf("\tAckRequired %d\n", msg->AckRequired); 371 printf("\tEventDataLength %d\n", msg->EventDataLength); 372 printf("\tContinuation %d\n", msg->MsgFlags & 0x80); 373 switch(msg->Event) { 374 case MPI_EVENT_LOG_DATA: 375 printf("\tEvtLogData: 0x%04x\n", msg->Data[0]); 376 break; 377 378 case MPI_EVENT_UNIT_ATTENTION: 379 printf("\tTargetID: 0x%04x\n", 380 msg->Data[0] & 0xff); 381 printf("\tBus: 0x%04x\n", 382 (msg->Data[0] >> 8) & 0xff); 383 break; 384 385 case MPI_EVENT_IOC_BUS_RESET: 386 case MPI_EVENT_EXT_BUS_RESET: 387 case MPI_EVENT_RESCAN: 388 printf("\tPort: %d\n", 389 (msg->Data[0] >> 8) & 0xff); 390 break; 391 392 case MPI_EVENT_LINK_STATUS_CHANGE: 393 printf("\tLinkState: %d\n", 394 msg->Data[0] & 0xff); 395 printf("\tPort: %d\n", 396 (msg->Data[1] >> 8) & 0xff); 397 break; 398 399 case MPI_EVENT_LOOP_STATE_CHANGE: 400 printf("\tType: %d\n", 401 (msg->Data[0] >> 16) & 0xff); 402 printf("\tChar3: 0x%02x\n", 403 (msg->Data[0] >> 8) & 0xff); 404 printf("\tChar4: 0x%02x\n", 405 (msg->Data[0] ) & 0xff); 406 printf("\tPort: %d\n", 407 (msg->Data[1] >> 8) & 0xff); 408 break; 409 410 case MPI_EVENT_LOGOUT: 411 printf("\tN_PortId: 0x%04x\n", msg->Data[0]); 412 printf("\tPort: %d\n", 413 (msg->Data[1] >> 8) & 0xff); 414 break; 415 } 416 417 } 418 419 void 420 mpt_print_reply(void *vmsg) 421 { 422 MSG_DEFAULT_REPLY *msg = vmsg; 423 424 switch (msg->Function) { 425 case MPI_FUNCTION_EVENT_NOTIFICATION: 426 mpt_print_event_notice((MSG_EVENT_NOTIFY_REPLY *)msg); 427 break; 428 case MPI_FUNCTION_PORT_ENABLE: 429 mpt_print_enable_reply((MSG_PORT_ENABLE_REPLY *)msg); 430 break; 431 case MPI_FUNCTION_IOC_FACTS: 432 mpt_print_ioc_facts((MSG_IOC_FACTS_REPLY *)msg); 433 break; 434 case MPI_FUNCTION_IOC_INIT: 435 mpt_print_init_reply((MSG_IOC_INIT_REPLY *)msg); 436 break; 437 case MPI_FUNCTION_SCSI_IO_REQUEST: 438 mpt_print_scsi_io_reply((MSG_SCSI_IO_REPLY *)msg); 439 break; 440 default: 441 mpt_print_reply_hdr((MSG_DEFAULT_REPLY *)msg); 442 break; 443 } 444 } 445 446 /*****************************************************************************/ 447 /* Request functions */ 448 /*****************************************************************************/ 449 static void 450 mpt_print_request_hdr(MSG_REQUEST_HEADER *req) 451 { 452 printf("%s @ %p\n", mpt_ioc_function(req->Function), req); 453 printf("\tChain Offset 0x%02x\n", req->ChainOffset); 454 printf("\tMsgFlags 0x%02x\n", req->MsgFlags); 455 printf("\tMsgContext 0x%08x\n", req->MsgContext); 456 } 457 458 void 459 mpt_print_scsi_io_request(MSG_SCSI_IO_REQUEST *orig_msg) 460 { 461 MSG_SCSI_IO_REQUEST local, *msg = &local; 462 int i; 463 464 bcopy(orig_msg, msg, sizeof (MSG_SCSI_IO_REQUEST)); 465 mpt_print_request_hdr((MSG_REQUEST_HEADER *)msg); 466 printf("\tBus: %d\n", msg->Bus); 467 printf("\tTargetID %d\n", msg->TargetID); 468 printf("\tSenseBufferLength %d\n", msg->SenseBufferLength); 469 printf("\tLUN: 0x%0x\n", msg->LUN[1]); 470 printf("\tControl 0x%08x ", msg->Control); 471 #define MPI_PRINT_FIELD(x) \ 472 case MPI_SCSIIO_CONTROL_ ## x : \ 473 printf(" " #x " "); \ 474 break 475 476 switch (msg->Control & MPI_SCSIIO_CONTROL_DATADIRECTION_MASK) { 477 MPI_PRINT_FIELD(NODATATRANSFER); 478 MPI_PRINT_FIELD(WRITE); 479 MPI_PRINT_FIELD(READ); 480 default: 481 printf(" Invalid DIR! "); 482 break; 483 } 484 switch (msg->Control & MPI_SCSIIO_CONTROL_TASKATTRIBUTE_MASK) { 485 MPI_PRINT_FIELD(SIMPLEQ); 486 MPI_PRINT_FIELD(HEADOFQ); 487 MPI_PRINT_FIELD(ORDEREDQ); 488 MPI_PRINT_FIELD(ACAQ); 489 MPI_PRINT_FIELD(UNTAGGED); 490 MPI_PRINT_FIELD(NO_DISCONNECT); 491 default: 492 printf(" Unknown attribute! "); 493 break; 494 } 495 496 printf("\n"); 497 #undef MPI_PRINT_FIELD 498 499 printf("\tDataLength\t0x%08x\n", msg->DataLength); 500 printf("\tSenseBufAddr\t0x%08x\n", msg->SenseBufferLowAddr); 501 printf("\tCDB[0:%d]\t", msg->CDBLength); 502 for (i = 0; i < msg->CDBLength; i++) 503 printf("%02x ", msg->CDB[i]); 504 printf("\n"); 505 mpt_dump_sgl(&orig_msg->SGL); 506 } 507 508 void 509 mpt_print_request(void *vreq) 510 { 511 MSG_REQUEST_HEADER *req = vreq; 512 513 switch (req->Function) { 514 case MPI_FUNCTION_SCSI_IO_REQUEST: 515 mpt_print_scsi_io_request((MSG_SCSI_IO_REQUEST *)req); 516 break; 517 default: 518 mpt_print_request_hdr(req); 519 break; 520 } 521 } 522 523 char * 524 mpt_req_state(enum mpt_req_state state) 525 { 526 char *text; 527 528 switch (state) { 529 case REQ_FREE: text = "Free"; break; 530 case REQ_IN_PROGRESS: text = "In Progress"; break; 531 case REQ_ON_CHIP: text = "On Chip"; break; 532 case REQ_TIMEOUT: text = "Timeout"; break; 533 default: text = "Unknown"; break; 534 } 535 return text; 536 }; 537 538 static void 539 mpt_dump_sgl(SGE_IO_UNION *su) 540 { 541 SGE_SIMPLE32 *se = (SGE_SIMPLE32 *) su; 542 int iCount, flags; 543 544 iCount = MPT_SGL_MAX; 545 do { 546 int iprt; 547 548 printf("\t"); 549 flags = MPI_SGE_GET_FLAGS(se->FlagsLength); 550 switch (flags & MPI_SGE_FLAGS_ELEMENT_MASK) { 551 case MPI_SGE_FLAGS_SIMPLE_ELEMENT: 552 { 553 printf("SE32 %p: Addr=0x%0x FlagsLength=0x%0x\n", 554 se, se->Address, se->FlagsLength); 555 printf(" "); 556 break; 557 } 558 case MPI_SGE_FLAGS_CHAIN_ELEMENT: 559 { 560 SGE_CHAIN32 *ce = (SGE_CHAIN32 *) se; 561 printf("CE32 %p: Addr=0x%0x NxtChnO=0x%x Flgs=0x%x " 562 "Len=0x%0x\n", ce, ce->Address, ce->NextChainOffset, 563 ce->Flags, ce->Length); 564 flags = 0; 565 break; 566 } 567 case MPI_SGE_FLAGS_TRANSACTION_ELEMENT: 568 printf("TE32 @ %p\n", se); 569 flags = 0; 570 break; 571 } 572 iprt = 0; 573 #define MPT_PRINT_FLAG(x) \ 574 if (flags & MPI_SGE_FLAGS_ ## x ) { \ 575 if (iprt == 0) { \ 576 printf("\t"); \ 577 } \ 578 printf(" "); \ 579 printf( #x ); \ 580 iprt++; \ 581 } 582 MPT_PRINT_FLAG(LOCAL_ADDRESS); 583 MPT_PRINT_FLAG(HOST_TO_IOC); 584 MPT_PRINT_FLAG(64_BIT_ADDRESSING); 585 MPT_PRINT_FLAG(LAST_ELEMENT); 586 MPT_PRINT_FLAG(END_OF_BUFFER); 587 MPT_PRINT_FLAG(END_OF_LIST); 588 #undef MPT_PRINT_FLAG 589 if (iprt) 590 printf("\n"); 591 se++; 592 iCount -= 1; 593 } while ((flags & MPI_SGE_FLAGS_END_OF_LIST) == 0 && iCount != 0); 594 } 595