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