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