2 * Debug routines for LSI '909 FC adapters.
5 * Copyright (c) 2000, 2001 by Greg Ansley
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice immediately at the beginning of the file, without modification,
12 * this list of conditions, and the following disclaimer.
13 * 2. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
20 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * Additional Copyright (c) 2002 by Matthew Jacob under same license.
31 #include <sys/cdefs.h>
32 __FBSDID("$FreeBSD$");
34 #include <dev/mpt/mpt.h>
36 #include <dev/mpt/mpilib/mpi_ioc.h>
37 #include <dev/mpt/mpilib/mpi_init.h>
38 #include <dev/mpt/mpilib/mpi_fc.h>
40 #include <cam/scsi/scsi_all.h>
42 #include <machine/stdarg.h> /* for use by mpt_prt below */
49 static const struct Error_Map IOC_Status[] = {
50 { MPI_IOCSTATUS_SUCCESS, "Success" },
51 { MPI_IOCSTATUS_INVALID_FUNCTION, "IOC: Invalid Function" },
52 { MPI_IOCSTATUS_BUSY, "IOC: Busy" },
53 { MPI_IOCSTATUS_INVALID_SGL, "IOC: Invalid SGL" },
54 { MPI_IOCSTATUS_INTERNAL_ERROR, "IOC: Internal Error" },
55 { MPI_IOCSTATUS_RESERVED, "IOC: Reserved" },
56 { MPI_IOCSTATUS_INSUFFICIENT_RESOURCES, "IOC: Insufficient Resources" },
57 { MPI_IOCSTATUS_INVALID_FIELD, "IOC: Invalid Field" },
58 { MPI_IOCSTATUS_INVALID_STATE, "IOC: Invalid State" },
59 { MPI_IOCSTATUS_CONFIG_INVALID_ACTION, "Invalid Action" },
60 { MPI_IOCSTATUS_CONFIG_INVALID_TYPE, "Invalid Type" },
61 { MPI_IOCSTATUS_CONFIG_INVALID_PAGE, "Invalid Page" },
62 { MPI_IOCSTATUS_CONFIG_INVALID_DATA, "Invalid Data" },
63 { MPI_IOCSTATUS_CONFIG_NO_DEFAULTS, "No Defaults" },
64 { MPI_IOCSTATUS_CONFIG_CANT_COMMIT, "Can't Commit" },
65 { MPI_IOCSTATUS_SCSI_RECOVERED_ERROR, "SCSI: Recoverd Error" },
66 { MPI_IOCSTATUS_SCSI_INVALID_BUS, "SCSI: Invalid Bus" },
67 { MPI_IOCSTATUS_SCSI_INVALID_TARGETID, "SCSI: Invalid Target ID" },
68 { MPI_IOCSTATUS_SCSI_DEVICE_NOT_THERE, "SCSI: Device Not There" },
69 { MPI_IOCSTATUS_SCSI_DATA_OVERRUN, "SCSI: Data Overrun" },
70 { MPI_IOCSTATUS_SCSI_DATA_UNDERRUN, "SCSI: Data Underrun" },
71 { MPI_IOCSTATUS_SCSI_IO_DATA_ERROR, "SCSI: Data Error" },
72 { MPI_IOCSTATUS_SCSI_PROTOCOL_ERROR, "SCSI: Protocol Error" },
73 { MPI_IOCSTATUS_SCSI_TASK_TERMINATED, "SCSI: Task Terminated" },
74 { MPI_IOCSTATUS_SCSI_RESIDUAL_MISMATCH, "SCSI: Residual Mismatch" },
75 { MPI_IOCSTATUS_SCSI_TASK_MGMT_FAILED, "SCSI: Task Management Failed" },
76 { MPI_IOCSTATUS_SCSI_IOC_TERMINATED, "SCSI: IOC Bus Reset" },
77 { MPI_IOCSTATUS_SCSI_EXT_TERMINATED, "SCSI: External Bus Reset" },
78 { MPI_IOCSTATUS_TARGET_PRIORITY_IO, "SCSI Target: Priority I/O" },
79 { MPI_IOCSTATUS_TARGET_INVALID_PORT, "SCSI Target: Invalid Port" },
80 { MPI_IOCSTATUS_TARGET_INVALID_IOCINDEX, "SCSI Target: Invalid IOC Index" },
81 { MPI_IOCSTATUS_TARGET_ABORTED, "SCSI Target: Aborted" },
82 { MPI_IOCSTATUS_TARGET_NO_CONN_RETRYABLE, "SCSI Target: No Connection (Retryable)" },
83 { MPI_IOCSTATUS_TARGET_NO_CONNECTION, "SCSI Target: No Connection" },
84 { MPI_IOCSTATUS_TARGET_XFER_COUNT_MISMATCH,"SCSI Target: Transfer Count Mismatch" },
85 { MPI_IOCSTATUS_TARGET_FC_ABORTED, "FC: Aborted" },
86 { MPI_IOCSTATUS_TARGET_FC_RX_ID_INVALID, "FC: Recieve ID Invalid" },
87 { MPI_IOCSTATUS_TARGET_FC_DID_INVALID, "FC: Recieve DID Invalid" },
88 { MPI_IOCSTATUS_TARGET_FC_NODE_LOGGED_OUT,"FC: Node Logged Out" },
89 { MPI_IOCSTATUS_LAN_DEVICE_NOT_FOUND, "LAN: Device Not Found" },
90 { MPI_IOCSTATUS_LAN_DEVICE_FAILURE, "LAN: Device Not Failure" },
91 { MPI_IOCSTATUS_LAN_TRANSMIT_ERROR, "LAN: Transmit Error" },
92 { MPI_IOCSTATUS_LAN_TRANSMIT_ABORTED, "LAN: Transmit Aborted" },
93 { MPI_IOCSTATUS_LAN_RECEIVE_ERROR, "LAN: Recieve Error" },
94 { MPI_IOCSTATUS_LAN_RECEIVE_ABORTED, "LAN: Recieve Aborted" },
95 { MPI_IOCSTATUS_LAN_PARTIAL_PACKET, "LAN: Partial Packet" },
96 { MPI_IOCSTATUS_LAN_CANCELED, "LAN: Canceled" },
100 static const struct Error_Map IOC_Func[] = {
101 { MPI_FUNCTION_SCSI_IO_REQUEST, "SCSI IO Request" },
102 { MPI_FUNCTION_SCSI_TASK_MGMT, "SCSI Task Management" },
103 { MPI_FUNCTION_IOC_INIT, "IOC Init" },
104 { MPI_FUNCTION_IOC_FACTS, "IOC Facts" },
105 { MPI_FUNCTION_CONFIG, "Config" },
106 { MPI_FUNCTION_PORT_FACTS, "Port Facts" },
107 { MPI_FUNCTION_PORT_ENABLE, "Port Enable" },
108 { MPI_FUNCTION_EVENT_NOTIFICATION, "Event Notification" },
109 { MPI_FUNCTION_EVENT_ACK, "Event Ack" },
110 { MPI_FUNCTION_FW_DOWNLOAD, "FW Download" },
111 { MPI_FUNCTION_TARGET_CMD_BUFFER_POST, "SCSI Target Command Buffer" },
112 { MPI_FUNCTION_TARGET_ASSIST, "Target Assist" },
113 { MPI_FUNCTION_TARGET_STATUS_SEND, "Target Status Send" },
114 { MPI_FUNCTION_TARGET_MODE_ABORT, "Target Mode Abort" },
115 { MPI_FUNCTION_TARGET_FC_BUF_POST_LINK_SRVC, "FC: Link Service Buffers" },
116 { MPI_FUNCTION_TARGET_FC_RSP_LINK_SRVC, "FC: Link Service Response" },
117 { MPI_FUNCTION_TARGET_FC_EX_SEND_LINK_SRVC, "FC: Send Extended Link Service" },
118 { MPI_FUNCTION_TARGET_FC_ABORT, "FC: Abort" },
119 { MPI_FUNCTION_FC_LINK_SRVC_BUF_POST, "FC: Link Service Buffers" },
120 { MPI_FUNCTION_FC_LINK_SRVC_RSP, "FC: Link Server Response" },
121 { MPI_FUNCTION_FC_EX_LINK_SRVC_SEND, "FC: Send Extended Link Service" },
122 { MPI_FUNCTION_FC_ABORT, "FC: Abort" },
123 { MPI_FUNCTION_FW_UPLOAD, "FW Upload" },
124 { MPI_FUNCTION_FC_COMMON_TRANSPORT_SEND, "FC: Send Common Transport" },
125 { MPI_FUNCTION_FC_PRIMITIVE_SEND, "FC: Send Primitive" },
126 { MPI_FUNCTION_RAID_ACTION, "RAID Action" },
127 { MPI_FUNCTION_RAID_SCSI_IO_PASSTHROUGH, "RAID SCSI Pass-Through" },
128 { MPI_FUNCTION_TOOLBOX, "Toolbox Command" },
129 { MPI_FUNCTION_SCSI_ENCLOSURE_PROCESSOR, "SCSI Enclosure Proc. Command" },
130 { MPI_FUNCTION_MAILBOX, "Mailbox Command" },
131 { MPI_FUNCTION_LAN_SEND, "LAN Send" },
132 { MPI_FUNCTION_LAN_RECEIVE, "LAN Recieve" },
133 { MPI_FUNCTION_LAN_RESET, "LAN Reset" },
134 { MPI_FUNCTION_IOC_MESSAGE_UNIT_RESET, "IOC Message Unit Reset" },
135 { MPI_FUNCTION_IO_UNIT_RESET, "IO Unit Reset" },
136 { MPI_FUNCTION_HANDSHAKE, "Handshake" },
137 { MPI_FUNCTION_REPLY_FRAME_REMOVAL, "Reply Frame Removal" },
141 static const struct Error_Map IOC_Event[] = {
142 { MPI_EVENT_NONE, "None" },
143 { MPI_EVENT_LOG_DATA, "LogData" },
144 { MPI_EVENT_STATE_CHANGE, "State Change" },
145 { MPI_EVENT_UNIT_ATTENTION, "Unit Attention" },
146 { MPI_EVENT_IOC_BUS_RESET, "IOC Bus Reset" },
147 { MPI_EVENT_EXT_BUS_RESET, "External Bus Reset" },
148 { MPI_EVENT_RESCAN, "Rescan" },
149 { MPI_EVENT_LINK_STATUS_CHANGE, "Link Status Change" },
150 { MPI_EVENT_LOOP_STATE_CHANGE, "Loop State Change" },
151 { MPI_EVENT_LOGOUT, "Logout" },
152 { MPI_EVENT_EVENT_CHANGE, "EventChange" },
156 static const struct Error_Map IOC_SCSIState[] = {
157 { MPI_SCSI_STATE_AUTOSENSE_VALID, "AutoSense_Valid" },
158 { MPI_SCSI_STATE_AUTOSENSE_FAILED, "AutoSense_Failed" },
159 { MPI_SCSI_STATE_NO_SCSI_STATUS, "No_SCSI_Status" },
160 { MPI_SCSI_STATE_TERMINATED, "State_Terminated" },
161 { MPI_SCSI_STATE_RESPONSE_INFO_VALID, "Repsonse_Info_Valid" },
162 { MPI_SCSI_STATE_QUEUE_TAG_REJECTED, "Queue Tag Rejected" },
166 static const struct Error_Map IOC_SCSIStatus[] = {
167 { SCSI_STATUS_OK, "OK" },
168 { SCSI_STATUS_CHECK_COND, "Check Condition" },
169 { SCSI_STATUS_COND_MET, "Check Condition Met" },
170 { SCSI_STATUS_BUSY, "Busy" },
171 { SCSI_STATUS_INTERMED, "Intermidiate Condition" },
172 { SCSI_STATUS_INTERMED_COND_MET, "Intermidiate Condition Met" },
173 { SCSI_STATUS_RESERV_CONFLICT, "Reservation Conflict" },
174 { SCSI_STATUS_CMD_TERMINATED, "Command Terminated" },
175 { SCSI_STATUS_QUEUE_FULL, "Queue Full" },
179 static const struct Error_Map IOC_Diag[] = {
180 { MPI_DIAG_DRWE, "DWE" },
181 { MPI_DIAG_FLASH_BAD_SIG, "FLASH_Bad" },
182 { MPI_DIAGNOSTIC_OFFSET, "Offset" },
183 { MPI_DIAG_RESET_ADAPTER, "Reset" },
184 { MPI_DIAG_DISABLE_ARM, "DisARM" },
185 { MPI_DIAG_MEM_ENABLE, "DME" },
189 static const struct Error_Map IOC_SCSITMType[] = {
190 { MPI_SCSITASKMGMT_TASKTYPE_ABORT_TASK, "Abort Task" },
191 { MPI_SCSITASKMGMT_TASKTYPE_ABRT_TASK_SET, "Abort Task Set" },
192 { MPI_SCSITASKMGMT_TASKTYPE_TARGET_RESET, "Target Reset" },
193 { MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS, "Reset Bus" },
194 { MPI_SCSITASKMGMT_TASKTYPE_LOGICAL_UNIT_RESET, "Logical Unit Reset" },
198 static void mpt_dump_sgl(SGE_IO_UNION *sgl);
201 mpt_ioc_status(int code)
203 const struct Error_Map *status = IOC_Status;
205 while (status->Error_Code >= 0) {
206 if (status->Error_Code == (code & MPI_IOCSTATUS_MASK))
207 return status->Error_String;
210 snprintf(buf, sizeof buf, "Unknown (0x%08x)", code);
215 mpt_ioc_diag(u_int32_t code)
217 const struct Error_Map *status = IOC_Diag;
218 static char buf[128];
220 char *end = &buf[128];
222 ptr += snprintf(buf, sizeof buf, "(0x%08x)", code);
223 while (status->Error_Code >= 0) {
224 if ((status->Error_Code & code) != 0)
225 ptr += snprintf(ptr, (size_t)(end-ptr), "%s ",
226 status->Error_String);
233 mpt_ioc_function(int code)
235 const struct Error_Map *status = IOC_Func;
237 while (status->Error_Code >= 0) {
238 if (status->Error_Code == code)
239 return status->Error_String;
242 snprintf(buf, sizeof buf, "Unknown (0x%08x)", code);
246 mpt_ioc_event(int code)
248 const struct Error_Map *status = IOC_Event;
250 while (status->Error_Code >= 0) {
251 if (status->Error_Code == code)
252 return status->Error_String;
255 snprintf(buf, sizeof buf, "Unknown (0x%08x)", code);
259 mpt_scsi_state(int code)
261 const struct Error_Map *status = IOC_SCSIState;
262 static char buf[128];
264 char *end = &buf[128];
266 ptr += snprintf(buf, sizeof buf, "(0x%08x)", code);
267 while (status->Error_Code >= 0) {
268 if ((status->Error_Code & code) != 0)
269 ptr += snprintf(ptr, (size_t)(end-ptr), "%s ",
270 status->Error_String);
276 mpt_scsi_status(int code)
278 const struct Error_Map *status = IOC_SCSIStatus;
280 while (status->Error_Code >= 0) {
281 if (status->Error_Code == code)
282 return status->Error_String;
285 snprintf(buf, sizeof buf, "Unknown (0x%08x)", code);
289 mpt_who(int who_init)
294 case MPT_DB_INIT_NOONE: who = "No One"; break;
295 case MPT_DB_INIT_BIOS: who = "BIOS"; break;
296 case MPT_DB_INIT_ROMBIOS: who = "ROM BIOS"; break;
297 case MPT_DB_INIT_PCIPEER: who = "PCI Peer"; break;
298 case MPT_DB_INIT_HOST: who = "Host Driver"; break;
299 case MPT_DB_INIT_MANUFACTURE: who = "Manufacturing"; break;
300 default: who = "Unknown"; break;
306 mpt_state(u_int32_t mb)
310 switch (MPT_STATE(mb)) {
311 case MPT_DB_STATE_RESET: text = "Reset"; break;
312 case MPT_DB_STATE_READY: text = "Ready"; break;
313 case MPT_DB_STATE_RUNNING:text = "Running"; break;
314 case MPT_DB_STATE_FAULT: text = "Fault"; break;
315 default: text = "Unknown"; break;
321 mpt_scsi_tm_type(int code)
323 const struct Error_Map *status = IOC_SCSITMType;
325 while (status->Error_Code >= 0) {
326 if (status->Error_Code == code)
327 return status->Error_String;
330 snprintf(buf, sizeof buf, "Unknown (0x%08x)", code);
335 mpt_print_db(u_int32_t mb)
337 printf("mpt mailbox: (0x%x) State %s WhoInit %s\n",
338 mb, mpt_state(mb), mpt_who(MPT_WHO(mb)));
341 /*****************************************************************************/
342 /* Reply functions */
343 /*****************************************************************************/
345 mpt_print_reply_hdr(MSG_DEFAULT_REPLY *msg)
347 printf("%s Reply @ %p\n", mpt_ioc_function(msg->Function), msg);
348 printf("\tIOC Status %s\n", mpt_ioc_status(msg->IOCStatus));
349 printf("\tIOCLogInfo 0x%08x\n", msg->IOCLogInfo);
350 printf("\tMsgLength 0x%02x\n", msg->MsgLength);
351 printf("\tMsgFlags 0x%02x\n", msg->MsgFlags);
352 printf("\tMsgContext 0x%08x\n", msg->MsgContext);
356 mpt_print_init_reply(MSG_IOC_INIT_REPLY *msg)
358 mpt_print_reply_hdr((MSG_DEFAULT_REPLY *)msg);
359 printf("\tWhoInit %s\n", mpt_who(msg->WhoInit));
360 printf("\tMaxDevices 0x%02x\n", msg->MaxDevices);
361 printf("\tMaxBuses 0x%02x\n", msg->MaxBuses);
365 mpt_print_ioc_facts(MSG_IOC_FACTS_REPLY *msg)
367 mpt_print_reply_hdr((MSG_DEFAULT_REPLY *)msg);
368 printf("\tIOCNumber %d\n", msg->IOCNumber);
369 printf("\tMaxChainDepth %d\n", msg->MaxChainDepth);
370 printf("\tWhoInit %s\n", mpt_who(msg->WhoInit));
371 printf("\tBlockSize %d\n", msg->BlockSize);
372 printf("\tFlags %d\n", msg->Flags);
373 printf("\tReplyQueueDepth %d\n", msg->ReplyQueueDepth);
374 printf("\tReqFrameSize 0x%04x\n", msg->RequestFrameSize);
375 printf("\tFW Version 0x%08x\n", msg->FWVersion.Word);
376 printf("\tProduct ID 0x%04x\n", msg->ProductID);
377 printf("\tCredits 0x%04x\n", msg->GlobalCredits);
378 printf("\tPorts %d\n", msg->NumberOfPorts);
379 printf("\tEventState 0x%02x\n", msg->EventState);
380 printf("\tHostMFA_HA 0x%08x\n", msg->CurrentHostMfaHighAddr);
381 printf("\tSenseBuf_HA 0x%08x\n",
382 msg->CurrentSenseBufferHighAddr);
383 printf("\tRepFrameSize 0x%04x\n", msg->CurReplyFrameSize);
384 printf("\tMaxDevices 0x%02x\n", msg->MaxDevices);
385 printf("\tMaxBuses 0x%02x\n", msg->MaxBuses);
386 printf("\tFWImageSize 0x%04x\n", msg->FWImageSize);
390 mpt_print_enable_reply(MSG_PORT_ENABLE_REPLY *msg)
392 mpt_print_reply_hdr((MSG_DEFAULT_REPLY *)msg);
393 printf("\tPort: %d\n", msg->PortNumber);
397 mpt_print_scsi_io_reply(MSG_SCSI_IO_REPLY *msg)
399 mpt_print_reply_hdr((MSG_DEFAULT_REPLY *)msg);
400 printf("\tBus: %d\n", msg->Bus);
401 printf("\tTargetID %d\n", msg->TargetID);
402 printf("\tCDBLength %d\n", msg->CDBLength);
403 printf("\tSCSI Status: %s\n", mpt_scsi_status(msg->SCSIStatus));
404 printf("\tSCSI State: %s\n", mpt_scsi_state(msg->SCSIState));
405 printf("\tTransferCnt 0x%04x\n", msg->TransferCount);
406 printf("\tSenseCnt 0x%04x\n", msg->SenseCount);
407 printf("\tResponseInfo 0x%08x\n", msg->ResponseInfo);
413 mpt_print_event_notice(MSG_EVENT_NOTIFY_REPLY *msg)
415 mpt_print_reply_hdr((MSG_DEFAULT_REPLY *)msg);
416 printf("\tEvent: %s\n", mpt_ioc_event(msg->Event));
417 printf("\tEventContext 0x%04x\n", msg->EventContext);
418 printf("\tAckRequired %d\n", msg->AckRequired);
419 printf("\tEventDataLength %d\n", msg->EventDataLength);
420 printf("\tContinuation %d\n", msg->MsgFlags & 0x80);
422 case MPI_EVENT_LOG_DATA:
423 printf("\tEvtLogData: 0x%04x\n", msg->Data[0]);
426 case MPI_EVENT_UNIT_ATTENTION:
427 printf("\tTargetID: 0x%04x\n",
428 msg->Data[0] & 0xff);
429 printf("\tBus: 0x%04x\n",
430 (msg->Data[0] >> 8) & 0xff);
433 case MPI_EVENT_IOC_BUS_RESET:
434 case MPI_EVENT_EXT_BUS_RESET:
435 case MPI_EVENT_RESCAN:
436 printf("\tPort: %d\n",
437 (msg->Data[0] >> 8) & 0xff);
440 case MPI_EVENT_LINK_STATUS_CHANGE:
441 printf("\tLinkState: %d\n",
442 msg->Data[0] & 0xff);
443 printf("\tPort: %d\n",
444 (msg->Data[1] >> 8) & 0xff);
447 case MPI_EVENT_LOOP_STATE_CHANGE:
448 printf("\tType: %d\n",
449 (msg->Data[0] >> 16) & 0xff);
450 printf("\tChar3: 0x%02x\n",
451 (msg->Data[0] >> 8) & 0xff);
452 printf("\tChar4: 0x%02x\n",
453 (msg->Data[0] ) & 0xff);
454 printf("\tPort: %d\n",
455 (msg->Data[1] >> 8) & 0xff);
458 case MPI_EVENT_LOGOUT:
459 printf("\tN_PortId: 0x%04x\n", msg->Data[0]);
460 printf("\tPort: %d\n",
461 (msg->Data[1] >> 8) & 0xff);
468 mpt_print_reply(void *vmsg)
470 MSG_DEFAULT_REPLY *msg = vmsg;
472 switch (msg->Function) {
473 case MPI_FUNCTION_EVENT_NOTIFICATION:
474 mpt_print_event_notice((MSG_EVENT_NOTIFY_REPLY *)msg);
476 case MPI_FUNCTION_PORT_ENABLE:
477 mpt_print_enable_reply((MSG_PORT_ENABLE_REPLY *)msg);
479 case MPI_FUNCTION_IOC_FACTS:
480 mpt_print_ioc_facts((MSG_IOC_FACTS_REPLY *)msg);
482 case MPI_FUNCTION_IOC_INIT:
483 mpt_print_init_reply((MSG_IOC_INIT_REPLY *)msg);
485 case MPI_FUNCTION_SCSI_IO_REQUEST:
486 mpt_print_scsi_io_reply((MSG_SCSI_IO_REPLY *)msg);
489 mpt_print_reply_hdr((MSG_DEFAULT_REPLY *)msg);
494 /*****************************************************************************/
495 /* Request functions */
496 /*****************************************************************************/
498 mpt_print_request_hdr(MSG_REQUEST_HEADER *req)
500 printf("%s @ %p\n", mpt_ioc_function(req->Function), req);
501 printf("\tChain Offset 0x%02x\n", req->ChainOffset);
502 printf("\tMsgFlags 0x%02x\n", req->MsgFlags);
503 printf("\tMsgContext 0x%08x\n", req->MsgContext);
507 mpt_print_scsi_io_request(MSG_SCSI_IO_REQUEST *orig_msg)
509 MSG_SCSI_IO_REQUEST local, *msg = &local;
512 bcopy(orig_msg, msg, sizeof (MSG_SCSI_IO_REQUEST));
513 mpt_print_request_hdr((MSG_REQUEST_HEADER *)msg);
514 printf("\tBus: %d\n", msg->Bus);
515 printf("\tTargetID %d\n", msg->TargetID);
516 printf("\tSenseBufferLength %d\n", msg->SenseBufferLength);
517 printf("\tLUN: 0x%0x\n", msg->LUN[1]);
518 printf("\tControl 0x%08x ", msg->Control);
519 #define MPI_PRINT_FIELD(x) \
520 case MPI_SCSIIO_CONTROL_ ## x : \
521 printf(" " #x " "); \
524 switch (msg->Control & MPI_SCSIIO_CONTROL_DATADIRECTION_MASK) {
525 MPI_PRINT_FIELD(NODATATRANSFER);
526 MPI_PRINT_FIELD(WRITE);
527 MPI_PRINT_FIELD(READ);
529 printf(" Invalid DIR! ");
532 switch (msg->Control & MPI_SCSIIO_CONTROL_TASKATTRIBUTE_MASK) {
533 MPI_PRINT_FIELD(SIMPLEQ);
534 MPI_PRINT_FIELD(HEADOFQ);
535 MPI_PRINT_FIELD(ORDEREDQ);
536 MPI_PRINT_FIELD(ACAQ);
537 MPI_PRINT_FIELD(UNTAGGED);
538 MPI_PRINT_FIELD(NO_DISCONNECT);
540 printf(" Unknown attribute! ");
545 #undef MPI_PRINT_FIELD
547 printf("\tDataLength\t0x%08x\n", msg->DataLength);
548 printf("\tSenseBufAddr\t0x%08x\n", msg->SenseBufferLowAddr);
549 printf("\tCDB[0:%d]\t", msg->CDBLength);
550 for (i = 0; i < msg->CDBLength; i++)
551 printf("%02x ", msg->CDB[i]);
553 mpt_dump_sgl(&orig_msg->SGL);
557 mpt_print_scsi_tmf_request(MSG_SCSI_TASK_MGMT *msg)
559 mpt_print_request_hdr((MSG_REQUEST_HEADER *)msg);
560 printf("\tLun 0x%02x\n", msg->LUN[1]);
561 printf("\tTaskType %s\n", mpt_scsi_tm_type(msg->TaskType));
562 printf("\tTaskMsgContext 0x%08x\n", msg->TaskMsgContext);
566 mpt_print_request(void *vreq)
568 MSG_REQUEST_HEADER *req = vreq;
570 switch (req->Function) {
571 case MPI_FUNCTION_SCSI_IO_REQUEST:
572 mpt_print_scsi_io_request((MSG_SCSI_IO_REQUEST *)req);
574 case MPI_FUNCTION_SCSI_TASK_MGMT:
575 mpt_print_scsi_tmf_request((MSG_SCSI_TASK_MGMT *)req);
577 mpt_print_request_hdr(req);
583 mpt_decode_value(mpt_decode_entry_t *table, u_int num_entries,
584 const char *name, u_int value, u_int *cur_column,
591 if (cur_column == NULL) {
593 cur_column = &dummy_column;
596 if (*cur_column >= wrap_point) {
600 printed = printf("%s[0x%x]", name, value);
602 printed += printf(" ");
603 *cur_column += printed;
607 while (printed_mask != 0xFF) {
610 for (entry = 0; entry < num_entries; entry++) {
611 if (((value & table[entry].mask)
612 != table[entry].value)
613 || ((printed_mask & table[entry].mask)
614 == table[entry].mask))
617 printed += printf("%s%s",
618 printed_mask == 0 ? ":(" : "|",
620 printed_mask |= table[entry].mask;
623 if (entry >= num_entries)
626 if (printed_mask != 0)
627 printed += printf(") ");
629 printed += printf(" ");
630 *cur_column += printed;
634 static mpt_decode_entry_t req_state_parse_table[] = {
635 { "REQ_FREE", 0x00, 0xff },
636 { "REQ_ALLOCATED", 0x01, 0x01 },
637 { "REQ_QUEUED", 0x02, 0x02 },
638 { "REQ_DONE", 0x04, 0x04 },
639 { "REQ_TIMEDOUT", 0x08, 0x08 },
640 { "REQ_NEED_WAKEUP", 0x10, 0x10 }
644 mpt_req_state(mpt_req_state_t state)
646 mpt_decode_value(req_state_parse_table,
647 NUM_ELEMENTS(req_state_parse_table),
648 "REQ_STATE", state, NULL, 80);
652 mpt_dump_sgl(SGE_IO_UNION *su)
654 SGE_SIMPLE32 *se = (SGE_SIMPLE32 *) su;
657 iCount = MPT_SGL_MAX;
662 flags = MPI_SGE_GET_FLAGS(se->FlagsLength);
663 switch (flags & MPI_SGE_FLAGS_ELEMENT_MASK) {
664 case MPI_SGE_FLAGS_SIMPLE_ELEMENT:
666 printf("SE32 %p: Addr=0x%0x FlagsLength=0x%0x\n",
667 se, se->Address, se->FlagsLength);
671 case MPI_SGE_FLAGS_CHAIN_ELEMENT:
673 SGE_CHAIN32 *ce = (SGE_CHAIN32 *) se;
674 printf("CE32 %p: Addr=0x%0x NxtChnO=0x%x Flgs=0x%x "
675 "Len=0x%0x\n", ce, ce->Address, ce->NextChainOffset,
676 ce->Flags, ce->Length);
680 case MPI_SGE_FLAGS_TRANSACTION_ELEMENT:
681 printf("TE32 @ %p\n", se);
686 #define MPT_PRINT_FLAG(x) \
687 if (flags & MPI_SGE_FLAGS_ ## x ) { \
695 MPT_PRINT_FLAG(LOCAL_ADDRESS);
696 MPT_PRINT_FLAG(HOST_TO_IOC);
697 MPT_PRINT_FLAG(64_BIT_ADDRESSING);
698 MPT_PRINT_FLAG(LAST_ELEMENT);
699 MPT_PRINT_FLAG(END_OF_BUFFER);
700 MPT_PRINT_FLAG(END_OF_LIST);
701 #undef MPT_PRINT_FLAG
706 } while ((flags & MPI_SGE_FLAGS_END_OF_LIST) == 0 && iCount != 0);
710 mpt_prt(struct mpt_softc *mpt, const char *fmt, ...)
714 printf("%s: ", device_get_nameunit(mpt->dev));
721 mpt_prtc(struct mpt_softc *mpt, const char *fmt, ...)