Deleted Added
full compact
mpt_debug.c (139749) mpt_debug.c (147883)
1/*-
2 * Debug routines for LSI '909 FC adapters.
3 * FreeBSD Version.
4 *
5 * Copyright (c) 2000, 2001 by Greg Ansley
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 10 unchanged lines hidden (view full) ---

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
26 * SUCH DAMAGE.
1/*-
2 * Debug routines for LSI '909 FC adapters.
3 * FreeBSD Version.
4 *
5 * Copyright (c) 2000, 2001 by Greg Ansley
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 10 unchanged lines hidden (view full) ---

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
26 * SUCH DAMAGE.
27 */
28/*
27 *
29 * Additional Copyright (c) 2002 by Matthew Jacob under same license.
30 */
31
32#include <sys/cdefs.h>
28 * Additional Copyright (c) 2002 by Matthew Jacob under same license.
29 */
30
31#include <sys/cdefs.h>
33__FBSDID("$FreeBSD: head/sys/dev/mpt/mpt_debug.c 139749 2005-01-06 01:43:34Z imp $");
32__FBSDID("$FreeBSD: head/sys/dev/mpt/mpt_debug.c 147883 2005-07-10 15:05:39Z scottl $");
34
33
35#include <dev/mpt/mpt_freebsd.h>
34#include
35
36#include <dev/mpt/mpilib/mpi_ioc.h>
37#include <dev/mpt/mpilib/mpi_init.h>
38#include <dev/mpt/mpilib/mpi_fc.h>
39
40#include <cam/scsi/scsi_all.h>
41
36#include <machine/stdarg.h> /* for use by mpt_prt below */
37
38struct Error_Map {
39 int Error_Code;
40 char *Error_String;
41};
42
43static const struct Error_Map IOC_Status[] = {

--- 51 unchanged lines hidden (view full) ---

95{ MPI_FUNCTION_SCSI_IO_REQUEST, "SCSI IO Request" },
96{ MPI_FUNCTION_SCSI_TASK_MGMT, "SCSI Task Management" },
97{ MPI_FUNCTION_IOC_INIT, "IOC Init" },
98{ MPI_FUNCTION_IOC_FACTS, "IOC Facts" },
99{ MPI_FUNCTION_CONFIG, "Config" },
100{ MPI_FUNCTION_PORT_FACTS, "Port Facts" },
101{ MPI_FUNCTION_PORT_ENABLE, "Port Enable" },
102{ MPI_FUNCTION_EVENT_NOTIFICATION, "Event Notification" },
42#include <machine/stdarg.h> /* for use by mpt_prt below */
43
44struct Error_Map {
45 int Error_Code;
46 char *Error_String;
47};
48
49static const struct Error_Map IOC_Status[] = {

--- 51 unchanged lines hidden (view full) ---

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" },
103{ MPI_FUNCTION_FW_DOWNLOAD, "FW Download" },
104{ MPI_FUNCTION_TARGET_CMD_BUFFER_POST, "SCSI Target Command Buffer" },
105{ MPI_FUNCTION_TARGET_ASSIST, "Target Assist" },
106{ MPI_FUNCTION_TARGET_STATUS_SEND, "Target Status Send" },
107{ MPI_FUNCTION_TARGET_MODE_ABORT, "Target Mode Abort" },
108{ MPI_FUNCTION_TARGET_FC_BUF_POST_LINK_SRVC, "FC: Link Service Buffers" },
109{ MPI_FUNCTION_TARGET_FC_RSP_LINK_SRVC, "FC: Link Service Response" },
110{ MPI_FUNCTION_TARGET_FC_EX_SEND_LINK_SRVC, "FC: Send Extended Link Service" },
111{ MPI_FUNCTION_TARGET_FC_ABORT, "FC: Abort" },
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" },
112{ MPI_FUNCTION_LAN_SEND, "LAN Send" },
113{ MPI_FUNCTION_LAN_RECEIVE, "LAN Recieve" },
114{ MPI_FUNCTION_LAN_RESET, "LAN Reset" },
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" },
115{ -1, 0},
116};
117
118static const struct Error_Map IOC_Event[] = {
119{ MPI_EVENT_NONE, "None" },
120{ MPI_EVENT_LOG_DATA, "LogData" },
121{ MPI_EVENT_STATE_CHANGE, "State Change" },
122{ MPI_EVENT_UNIT_ATTENTION, "Unit Attention" },

--- 26 unchanged lines hidden (view full) ---

149{ SCSI_STATUS_INTERMED_COND_MET, "Intermidiate Condition Met" },
150{ SCSI_STATUS_RESERV_CONFLICT, "Reservation Conflict" },
151{ SCSI_STATUS_CMD_TERMINATED, "Command Terminated" },
152{ SCSI_STATUS_QUEUE_FULL, "Queue Full" },
153{ -1, 0},
154};
155
156static const struct Error_Map IOC_Diag[] = {
138{ -1, 0},
139};
140
141static 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" },

--- 26 unchanged lines hidden (view full) ---

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" },
176{ -1, 0},
177};
178
179static const struct Error_Map IOC_Diag[] = {
157{ MPT_DIAG_ENABLED, "DWE" },
158{ MPT_DIAG_FLASHBAD, "FLASH_Bad" },
159{ MPT_DIAG_TTLI, "TTLI" },
160{ MPT_DIAG_RESET_IOC, "Reset" },
161{ MPT_DIAG_ARM_DISABLE, "DisARM" },
162{ MPT_DIAG_DME, "DME" },
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" },
163{ -1, 0 },
164};
165
186{ -1, 0 },
187};
188
189static 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" },
195{ -1, 0 },
196};
166
167static void mpt_dump_sgl(SGE_IO_UNION *sgl);
168
169static char *
170mpt_ioc_status(int code)
171{
172 const struct Error_Map *status = IOC_Status;
173 static char buf[64];

--- 107 unchanged lines hidden (view full) ---

281 case MPT_DB_STATE_READY: text = "Ready"; break;
282 case MPT_DB_STATE_RUNNING:text = "Running"; break;
283 case MPT_DB_STATE_FAULT: text = "Fault"; break;
284 default: text = "Unknown"; break;
285 }
286 return text;
287}
288
197
198static void mpt_dump_sgl(SGE_IO_UNION *sgl);
199
200static char *
201mpt_ioc_status(int code)
202{
203 const struct Error_Map *status = IOC_Status;
204 static char buf[64];

--- 107 unchanged lines hidden (view full) ---

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;
316 }
317 return text;
318}
319
320static char *
321mpt_scsi_tm_type(int code)
322{
323 const struct Error_Map *status = IOC_SCSITMType;
324 static char buf[64];
325 while (status->Error_Code >= 0) {
326 if (status->Error_Code == code)
327 return status->Error_String;
328 status++;
329 }
330 snprintf(buf, sizeof buf, "Unknown (0x%08x)", code);
331 return buf;
332}
333
289void
290mpt_print_db(u_int32_t mb)
291{
292 printf("mpt mailbox: (0x%x) State %s WhoInit %s\n",
293 mb, mpt_state(mb), mpt_who(MPT_WHO(mb)));
294}
295
296/*****************************************************************************/

--- 206 unchanged lines hidden (view full) ---

503 printf("\tSenseBufAddr\t0x%08x\n", msg->SenseBufferLowAddr);
504 printf("\tCDB[0:%d]\t", msg->CDBLength);
505 for (i = 0; i < msg->CDBLength; i++)
506 printf("%02x ", msg->CDB[i]);
507 printf("\n");
508 mpt_dump_sgl(&orig_msg->SGL);
509}
510
334void
335mpt_print_db(u_int32_t mb)
336{
337 printf("mpt mailbox: (0x%x) State %s WhoInit %s\n",
338 mb, mpt_state(mb), mpt_who(MPT_WHO(mb)));
339}
340
341/*****************************************************************************/

--- 206 unchanged lines hidden (view full) ---

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]);
552 printf("\n");
553 mpt_dump_sgl(&orig_msg->SGL);
554}
555
556static void
557mpt_print_scsi_tmf_request(MSG_SCSI_TASK_MGMT *msg)
558{
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);
563}
564
511void
512mpt_print_request(void *vreq)
513{
514 MSG_REQUEST_HEADER *req = vreq;
515
516 switch (req->Function) {
517 case MPI_FUNCTION_SCSI_IO_REQUEST:
518 mpt_print_scsi_io_request((MSG_SCSI_IO_REQUEST *)req);
519 break;
565void
566mpt_print_request(void *vreq)
567{
568 MSG_REQUEST_HEADER *req = vreq;
569
570 switch (req->Function) {
571 case MPI_FUNCTION_SCSI_IO_REQUEST:
572 mpt_print_scsi_io_request((MSG_SCSI_IO_REQUEST *)req);
573 break;
574 case MPI_FUNCTION_SCSI_TASK_MGMT:
575 mpt_print_scsi_tmf_request((MSG_SCSI_TASK_MGMT *)req);
520 default:
521 mpt_print_request_hdr(req);
522 break;
523 }
524}
525
576 default:
577 mpt_print_request_hdr(req);
578 break;
579 }
580}
581
526char *
527mpt_req_state(enum mpt_req_state state)
582int
583mpt_decode_value(mpt_decode_entry_t *table, u_int num_entries,
584 const char *name, u_int value, u_int *cur_column,
585 u_int wrap_point)
528{
586{
529 char *text;
587 int printed;
588 u_int printed_mask;
589 u_int dummy_column;
530
590
531 switch (state) {
532 case REQ_FREE: text = "Free"; break;
533 case REQ_IN_PROGRESS: text = "In Progress"; break;
534 case REQ_ON_CHIP: text = "On Chip"; break;
535 case REQ_TIMEOUT: text = "Timeout"; break;
536 default: text = "Unknown"; break;
591 if (cur_column == NULL) {
592 dummy_column = 0;
593 cur_column = &dummy_column;
537 }
594 }
538 return text;
595
596 if (*cur_column >= wrap_point) {
597 printf("\n");
598 *cur_column = 0;
599 }
600 printed = printf("%s[0x%x]", name, value);
601 if (table == NULL) {
602 printed += printf(" ");
603 *cur_column += printed;
604 return (printed);
605 }
606 printed_mask = 0;
607 while (printed_mask != 0xFF) {
608 int entry;
609
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))
615 continue;
616
617 printed += printf("%s%s",
618 printed_mask == 0 ? ":(" : "|",
619 table[entry].name);
620 printed_mask |= table[entry].mask;
621 break;
622 }
623 if (entry >= num_entries)
624 break;
625 }
626 if (printed_mask != 0)
627 printed += printf(") ");
628 else
629 printed += printf(" ");
630 *cur_column += printed;
631 return (printed);
539}
540
632}
633
634static 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 }
641};
642
643void
644mpt_req_state(mpt_req_state_t state)
645{
646 mpt_decode_value(req_state_parse_table,
647 NUM_ELEMENTS(req_state_parse_table),
648 "REQ_STATE", state, NULL, 80);
649}
650
541static void
542mpt_dump_sgl(SGE_IO_UNION *su)
543{
544 SGE_SIMPLE32 *se = (SGE_SIMPLE32 *) su;
545 int iCount, flags;
546
547 iCount = MPT_SGL_MAX;
548 do {

--- 43 unchanged lines hidden (view full) ---

592 if (iprt)
593 printf("\n");
594 se++;
595 iCount -= 1;
596 } while ((flags & MPI_SGE_FLAGS_END_OF_LIST) == 0 && iCount != 0);
597}
598
599void
651static void
652mpt_dump_sgl(SGE_IO_UNION *su)
653{
654 SGE_SIMPLE32 *se = (SGE_SIMPLE32 *) su;
655 int iCount, flags;
656
657 iCount = MPT_SGL_MAX;
658 do {

--- 43 unchanged lines hidden (view full) ---

702 if (iprt)
703 printf("\n");
704 se++;
705 iCount -= 1;
706 } while ((flags & MPI_SGE_FLAGS_END_OF_LIST) == 0 && iCount != 0);
707}
708
709void
600mpt_prt(mpt_softc_t *mpt, const char *fmt, ...)
710mpt_prt(struct mpt_softc *mpt, const char *fmt, ...)
601{
602 va_list ap;
711{
712 va_list ap;
713
603 printf("%s: ", device_get_nameunit(mpt->dev));
604 va_start(ap, fmt);
605 vprintf(fmt, ap);
606 va_end(ap);
714 printf("%s: ", device_get_nameunit(mpt->dev));
715 va_start(ap, fmt);
716 vprintf(fmt, ap);
717 va_end(ap);
607 printf("\n");
608}
718}
719
720void
721mpt_prtc(struct mpt_softc *mpt, const char *fmt, ...)
722{
723 va_list ap;
724
725 va_start(ap, fmt);
726 vprintf(fmt, ap);
727 va_end(ap);
728}