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