1 /*-
2 * Copyright (c) 2009 Yahoo! Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27 /* Debugging tables for MPT2 */
28
29 /* TODO Move headers to mprvar */
30 #include <sys/types.h>
31 #include <sys/param.h>
32 #include <sys/systm.h>
33 #include <sys/kernel.h>
34 #include <sys/selinfo.h>
35 #include <sys/module.h>
36 #include <sys/bus.h>
37 #include <sys/conf.h>
38 #include <sys/bio.h>
39 #include <sys/malloc.h>
40 #include <sys/uio.h>
41 #include <sys/sysctl.h>
42 #include <sys/queue.h>
43 #include <sys/kthread.h>
44 #include <sys/taskqueue.h>
45
46 #include <machine/bus.h>
47 #include <machine/resource.h>
48 #include <sys/rman.h>
49
50 #include <cam/scsi/scsi_all.h>
51
52 #include <dev/mpr/mpi/mpi2_type.h>
53 #include <dev/mpr/mpi/mpi2.h>
54 #include <dev/mpr/mpi/mpi2_ioc.h>
55 #include <dev/mpr/mpi/mpi2_cnfg.h>
56 #include <dev/mpr/mpi/mpi2_init.h>
57 #include <dev/mpr/mpi/mpi2_tool.h>
58 #include <dev/mpr/mpi/mpi2_pci.h>
59 #include <dev/mpr/mpr_ioctl.h>
60 #include <dev/mpr/mprvar.h>
61 #include <dev/mpr/mpr_table.h>
62
63 char *
mpr_describe_table(struct mpr_table_lookup * table,u_int code)64 mpr_describe_table(struct mpr_table_lookup *table, u_int code)
65 {
66 int i;
67
68 for (i = 0; table[i].string != NULL; i++) {
69 if (table[i].code == code)
70 return(table[i].string);
71 }
72 return(table[i+1].string);
73 }
74
75 //SLM-Add new PCIe info to all of these tables
76 struct mpr_table_lookup mpr_event_names[] = {
77 {"LogData", 0x01},
78 {"StateChange", 0x02},
79 {"HardResetReceived", 0x05},
80 {"EventChange", 0x0a},
81 {"TaskSetFull", 0x0e},
82 {"SasDeviceStatusChange", 0x0f},
83 {"IrOperationStatus", 0x14},
84 {"SasDiscovery", 0x16},
85 {"SasBroadcastPrimitive", 0x17},
86 {"SasInitDeviceStatusChange", 0x18},
87 {"SasInitTableOverflow", 0x19},
88 {"SasTopologyChangeList", 0x1c},
89 {"SasEnclDeviceStatusChange", 0x1d},
90 {"IrVolume", 0x1e},
91 {"IrPhysicalDisk", 0x1f},
92 {"IrConfigurationChangeList", 0x20},
93 {"LogEntryAdded", 0x21},
94 {"SasPhyCounter", 0x22},
95 {"GpioInterrupt", 0x23},
96 {"HbdPhyEvent", 0x24},
97 {"SasQuiesce", 0x25},
98 {"SasNotifyPrimitive", 0x26},
99 {"TempThreshold", 0x27},
100 {"HostMessage", 0x28},
101 {"PowerPerformanceChange", 0x29},
102 {"PCIeDeviceStatusChange", 0x30},
103 {"PCIeEnumeration", 0x31},
104 {"PCIeTopologyChangeList", 0x32},
105 {"PCIeLinkCounter", 0x33},
106 {"CableEvent", 0x34},
107 {NULL, 0},
108 {"Unknown Event", 0}
109 };
110
111 struct mpr_table_lookup mpr_phystatus_names[] = {
112 {"NewTargetAdded", 0x01},
113 {"TargetGone", 0x02},
114 {"PHYLinkStatusChange", 0x03},
115 {"PHYLinkStatusUnchanged", 0x04},
116 {"TargetMissing", 0x05},
117 {NULL, 0},
118 {"Unknown Status", 0}
119 };
120
121 struct mpr_table_lookup mpr_linkrate_names[] = {
122 {"PHY disabled", 0x01},
123 {"Speed Negotiation Failed", 0x02},
124 {"SATA OOB Complete", 0x03},
125 {"SATA Port Selector", 0x04},
126 {"SMP Reset in Progress", 0x05},
127 {"1.5Gbps", 0x08},
128 {"3.0Gbps", 0x09},
129 {"6.0Gbps", 0x0a},
130 {"12.0Gbps", 0x0b},
131 {NULL, 0},
132 {"LinkRate Unknown", 0x00}
133 };
134
135 struct mpr_table_lookup mpr_sasdev0_devtype[] = {
136 {"End Device", 0x01},
137 {"Edge Expander", 0x02},
138 {"Fanout Expander", 0x03},
139 {NULL, 0},
140 {"No Device", 0x00}
141 };
142
143 struct mpr_table_lookup mpr_phyinfo_reason_names[] = {
144 {"Power On", 0x01},
145 {"Hard Reset", 0x02},
146 {"SMP Phy Control Link Reset", 0x03},
147 {"Loss DWORD Sync", 0x04},
148 {"Multiplex Sequence", 0x05},
149 {"I-T Nexus Loss Timer", 0x06},
150 {"Break Timeout Timer", 0x07},
151 {"PHY Test Function", 0x08},
152 {NULL, 0},
153 {"Unknown Reason", 0x00}
154 };
155
156 struct mpr_table_lookup mpr_whoinit_names[] = {
157 {"System BIOS", 0x01},
158 {"ROM BIOS", 0x02},
159 {"PCI Peer", 0x03},
160 {"Host Driver", 0x04},
161 {"Manufacturing", 0x05},
162 {NULL, 0},
163 {"Not Initialized", 0x00}
164 };
165
166 struct mpr_table_lookup mpr_sasdisc_reason[] = {
167 {"Discovery Started", 0x01},
168 {"Discovery Complete", 0x02},
169 {NULL, 0},
170 {"Unknown", 0x00}
171 };
172
173 struct mpr_table_lookup mpr_sastopo_exp[] = {
174 {"Added", 0x01},
175 {"Not Responding", 0x02},
176 {"Responding", 0x03},
177 {"Delay Not Responding", 0x04},
178 {NULL, 0},
179 {"Unknown", 0x00}
180 };
181
182 struct mpr_table_lookup mpr_sasdev_reason[] = {
183 {"SMART Data", 0x05},
184 {"Unsupported", 0x07},
185 {"Internal Device Reset", 0x08},
186 {"Task Abort Internal", 0x09},
187 {"Abort Task Set Internal", 0x0a},
188 {"Clear Task Set Internal", 0x0b},
189 {"Query Task Internal", 0x0c},
190 {"Async Notification", 0x0d},
191 {"Cmp Internal Device Reset", 0x0e},
192 {"Cmp Task Abort Internal", 0x0f},
193 {"Sata Init Failure", 0x10},
194 {NULL, 0},
195 {"Unknown", 0x00}
196 };
197
198 struct mpr_table_lookup mpr_pcie_linkrate_names[] = {
199 {"Port disabled", 0x01},
200 {"2.5GT/sec", 0x02},
201 {"5.0GT/sec", 0x03},
202 {"8.0GT/sec", 0x04},
203 {"16.0GT/sec", 0x05},
204 {NULL, 0},
205 {"LinkRate Unknown", 0x00}
206 };
207
208 struct mpr_table_lookup mpr_iocstatus_string[] = {
209 {"success", MPI2_IOCSTATUS_SUCCESS},
210 {"invalid function", MPI2_IOCSTATUS_INVALID_FUNCTION},
211 {"scsi recovered error", MPI2_IOCSTATUS_SCSI_RECOVERED_ERROR},
212 {"scsi invalid dev handle", MPI2_IOCSTATUS_SCSI_INVALID_DEVHANDLE},
213 {"scsi device not there", MPI2_IOCSTATUS_SCSI_DEVICE_NOT_THERE},
214 {"scsi data overrun", MPI2_IOCSTATUS_SCSI_DATA_OVERRUN},
215 {"scsi data underrun", MPI2_IOCSTATUS_SCSI_DATA_UNDERRUN},
216 {"scsi io data error", MPI2_IOCSTATUS_SCSI_IO_DATA_ERROR},
217 {"scsi protocol error", MPI2_IOCSTATUS_SCSI_PROTOCOL_ERROR},
218 {"scsi task terminated", MPI2_IOCSTATUS_SCSI_TASK_TERMINATED},
219 {"scsi residual mismatch", MPI2_IOCSTATUS_SCSI_RESIDUAL_MISMATCH},
220 {"scsi task mgmt failed", MPI2_IOCSTATUS_SCSI_TASK_MGMT_FAILED},
221 {"scsi ioc terminated", MPI2_IOCSTATUS_SCSI_IOC_TERMINATED},
222 {"scsi ext terminated", MPI2_IOCSTATUS_SCSI_EXT_TERMINATED},
223 {"eedp guard error", MPI2_IOCSTATUS_EEDP_GUARD_ERROR},
224 {"eedp ref tag error", MPI2_IOCSTATUS_EEDP_REF_TAG_ERROR},
225 {"eedp app tag error", MPI2_IOCSTATUS_EEDP_APP_TAG_ERROR},
226 {NULL, 0},
227 {"unknown", 0x00}
228 };
229
230 struct mpr_table_lookup mpr_scsi_status_string[] = {
231 {"good", MPI2_SCSI_STATUS_GOOD},
232 {"check condition", MPI2_SCSI_STATUS_CHECK_CONDITION},
233 {"condition met", MPI2_SCSI_STATUS_CONDITION_MET},
234 {"busy", MPI2_SCSI_STATUS_BUSY},
235 {"intermediate", MPI2_SCSI_STATUS_INTERMEDIATE},
236 {"intermediate condmet", MPI2_SCSI_STATUS_INTERMEDIATE_CONDMET},
237 {"reservation conflict", MPI2_SCSI_STATUS_RESERVATION_CONFLICT},
238 {"command terminated", MPI2_SCSI_STATUS_COMMAND_TERMINATED},
239 {"task set full", MPI2_SCSI_STATUS_TASK_SET_FULL},
240 {"aca active", MPI2_SCSI_STATUS_ACA_ACTIVE},
241 {"task aborted", MPI2_SCSI_STATUS_TASK_ABORTED},
242 {NULL, 0},
243 {"unknown", 0x00}
244 };
245
246 struct mpr_table_lookup mpr_scsi_taskmgmt_string[] = {
247 {"task mgmt request completed", MPI2_SCSITASKMGMT_RSP_TM_COMPLETE},
248 {"invalid frame", MPI2_SCSITASKMGMT_RSP_INVALID_FRAME},
249 {"task mgmt request not supp", MPI2_SCSITASKMGMT_RSP_TM_NOT_SUPPORTED},
250 {"task mgmt request failed", MPI2_SCSITASKMGMT_RSP_TM_FAILED},
251 {"task mgmt request_succeeded", MPI2_SCSITASKMGMT_RSP_TM_SUCCEEDED},
252 {"invalid lun", MPI2_SCSITASKMGMT_RSP_TM_INVALID_LUN},
253 {"overlapped tag attempt", 0xA},
254 {"task queued on IOC", MPI2_SCSITASKMGMT_RSP_IO_QUEUED_ON_IOC},
255 {NULL, 0},
256 {"unknown", 0x00}
257 };
258
259 void
mpr_describe_devinfo(uint32_t devinfo,char * string,int len)260 mpr_describe_devinfo(uint32_t devinfo, char *string, int len)
261 {
262 snprintf(string, len, "%b,%s", devinfo,
263 "\20" "\4SataHost" "\5SmpInit" "\6StpInit" "\7SspInit"
264 "\10SataDev" "\11SmpTarg" "\12StpTarg" "\13SspTarg" "\14Direct"
265 "\15LsiDev" "\16AtapiDev" "\17SepDev",
266 mpr_describe_table(mpr_sasdev0_devtype, devinfo & 0x03));
267 }
268
269 void
mpr_print_iocfacts(struct mpr_softc * sc,MPI2_IOC_FACTS_REPLY * facts)270 mpr_print_iocfacts(struct mpr_softc *sc, MPI2_IOC_FACTS_REPLY *facts)
271 {
272 MPR_PRINTFIELD_START(sc, "IOCFacts");
273 MPR_PRINTFIELD(sc, facts, MsgVersion, 0x%x);
274 MPR_PRINTFIELD(sc, facts, HeaderVersion, 0x%x);
275 MPR_PRINTFIELD(sc, facts, IOCNumber, %d);
276 MPR_PRINTFIELD(sc, facts, IOCExceptions, 0x%x);
277 MPR_PRINTFIELD(sc, facts, MaxChainDepth, %d);
278 mpr_print_field(sc, "WhoInit: %s\n",
279 mpr_describe_table(mpr_whoinit_names, facts->WhoInit));
280 MPR_PRINTFIELD(sc, facts, NumberOfPorts, %d);
281 MPR_PRINTFIELD(sc, facts, MaxMSIxVectors, %d);
282 MPR_PRINTFIELD(sc, facts, RequestCredit, %d);
283 MPR_PRINTFIELD(sc, facts, ProductID, 0x%x);
284 mpr_print_field(sc, "IOCCapabilities: %b\n",
285 facts->IOCCapabilities, "\20" "\3ScsiTaskFull" "\4DiagTrace"
286 "\5SnapBuf" "\6ExtBuf" "\7EEDP" "\10BiDirTarg" "\11Multicast"
287 "\14TransRetry" "\15IR" "\16EventReplay" "\17RaidAccel"
288 "\20MSIXIndex" "\21HostDisc");
289 mpr_print_field(sc, "FWVersion= %d-%d-%d-%d\n",
290 facts->FWVersion.Struct.Major,
291 facts->FWVersion.Struct.Minor,
292 facts->FWVersion.Struct.Unit,
293 facts->FWVersion.Struct.Dev);
294 MPR_PRINTFIELD(sc, facts, IOCRequestFrameSize, %d);
295 MPR_PRINTFIELD(sc, facts, MaxInitiators, %d);
296 MPR_PRINTFIELD(sc, facts, MaxTargets, %d);
297 MPR_PRINTFIELD(sc, facts, MaxSasExpanders, %d);
298 MPR_PRINTFIELD(sc, facts, MaxEnclosures, %d);
299 mpr_print_field(sc, "ProtocolFlags: %b\n",
300 facts->ProtocolFlags, "\20" "\1ScsiTarg" "\2ScsiInit");
301 MPR_PRINTFIELD(sc, facts, HighPriorityCredit, %d);
302 MPR_PRINTFIELD(sc, facts, MaxReplyDescriptorPostQueueDepth, %d);
303 MPR_PRINTFIELD(sc, facts, ReplyFrameSize, %d);
304 MPR_PRINTFIELD(sc, facts, MaxVolumes, %d);
305 MPR_PRINTFIELD(sc, facts, MaxDevHandle, %d);
306 MPR_PRINTFIELD(sc, facts, MaxPersistentEntries, %d);
307 }
308
309 void
mpr_print_portfacts(struct mpr_softc * sc,MPI2_PORT_FACTS_REPLY * facts)310 mpr_print_portfacts(struct mpr_softc *sc, MPI2_PORT_FACTS_REPLY *facts)
311 {
312
313 MPR_PRINTFIELD_START(sc, "PortFacts");
314 MPR_PRINTFIELD(sc, facts, PortNumber, %d);
315 MPR_PRINTFIELD(sc, facts, PortType, 0x%x);
316 MPR_PRINTFIELD_16(sc, facts, MaxPostedCmdBuffers, %d);
317 }
318
319 void
mpr_print_evt_generic(struct mpr_softc * sc,MPI2_EVENT_NOTIFICATION_REPLY * event)320 mpr_print_evt_generic(struct mpr_softc *sc, MPI2_EVENT_NOTIFICATION_REPLY *event)
321 {
322
323 MPR_PRINTFIELD_START(sc, "EventReply");
324 MPR_PRINTFIELD_16(sc, event, EventDataLength, %d);
325 MPR_PRINTFIELD(sc, event, AckRequired, %d);
326 mpr_print_field(sc, "Event: %s (0x%x)\n",
327 mpr_describe_table(mpr_event_names, le16toh(event->Event)), le16toh(event->Event));
328 MPR_PRINTFIELD_32(sc, event, EventContext, 0x%x);
329 }
330
331 void
mpr_print_sasdev0(struct mpr_softc * sc,MPI2_CONFIG_PAGE_SAS_DEV_0 * buf)332 mpr_print_sasdev0(struct mpr_softc *sc, MPI2_CONFIG_PAGE_SAS_DEV_0 *buf)
333 {
334 MPR_PRINTFIELD_START(sc, "SAS Device Page 0");
335 MPR_PRINTFIELD_16(sc, buf, Slot, %d);
336 MPR_PRINTFIELD_16(sc, buf, EnclosureHandle, 0x%x);
337 mpr_print_field(sc, "SASAddress: 0x%jx\n",
338 mpr_to_u64(&buf->SASAddress));
339 MPR_PRINTFIELD_16(sc, buf, ParentDevHandle, 0x%x);
340 MPR_PRINTFIELD(sc, buf, PhyNum, %d);
341 MPR_PRINTFIELD(sc, buf, AccessStatus, 0x%x);
342 MPR_PRINTFIELD_16(sc, buf, DevHandle, 0x%x);
343 MPR_PRINTFIELD(sc, buf, AttachedPhyIdentifier, 0x%x);
344 MPR_PRINTFIELD(sc, buf, ZoneGroup, %d);
345 mpr_print_field(sc, "DeviceInfo: %b,%s\n", le32toh(buf->DeviceInfo),
346 "\20" "\4SataHost" "\5SmpInit" "\6StpInit" "\7SspInit"
347 "\10SataDev" "\11SmpTarg" "\12StpTarg" "\13SspTarg" "\14Direct"
348 "\15LsiDev" "\16AtapiDev" "\17SepDev",
349 mpr_describe_table(mpr_sasdev0_devtype, buf->DeviceInfo & 0x03));
350 MPR_PRINTFIELD_16(sc, buf, Flags, 0x%x);
351 MPR_PRINTFIELD(sc, buf, PhysicalPort, %d);
352 MPR_PRINTFIELD(sc, buf, MaxPortConnections, %d);
353 mpr_print_field(sc, "DeviceName: 0x%jx\n",
354 mpr_to_u64(&buf->DeviceName));
355 MPR_PRINTFIELD(sc, buf, PortGroups, %d);
356 MPR_PRINTFIELD(sc, buf, DmaGroup, %d);
357 MPR_PRINTFIELD(sc, buf, ControlGroup, %d);
358 }
359
360 void
mpr_print_evt_sas(struct mpr_softc * sc,MPI2_EVENT_NOTIFICATION_REPLY * event)361 mpr_print_evt_sas(struct mpr_softc *sc, MPI2_EVENT_NOTIFICATION_REPLY *event)
362 {
363
364 mpr_print_evt_generic(sc, event);
365
366 switch(le16toh(event->Event)) {
367 case MPI2_EVENT_SAS_DISCOVERY:
368 {
369 MPI2_EVENT_DATA_SAS_DISCOVERY *data;
370
371 data = (MPI2_EVENT_DATA_SAS_DISCOVERY *)&event->EventData;
372 mpr_print_field(sc, "Flags: %b\n", data->Flags,
373 "\20" "\1InProgress" "\2DeviceChange");
374 mpr_print_field(sc, "ReasonCode: %s\n",
375 mpr_describe_table(mpr_sasdisc_reason, data->ReasonCode));
376 MPR_PRINTFIELD(sc, data, PhysicalPort, %d);
377 mpr_print_field(sc, "DiscoveryStatus: %b\n",
378 le32toh(data->DiscoveryStatus), "\20"
379 "\1Loop" "\2UnaddressableDev" "\3DupSasAddr" "\5SmpTimeout"
380 "\6ExpRouteFull" "\7RouteIndexError" "\10SmpFailed"
381 "\11SmpCrcError" "\12SubSubLink" "\13TableTableLink"
382 "\14UnsupDevice" "\15TableSubLink" "\16MultiDomain"
383 "\17MultiSub" "\20MultiSubSub" "\34DownstreamInit"
384 "\35MaxPhys" "\36MaxTargs" "\37MaxExpanders"
385 "\40MaxEnclosures");
386 break;
387 }
388 //SLM-add for PCIE EVENT too
389 case MPI2_EVENT_SAS_TOPOLOGY_CHANGE_LIST:
390 {
391 MPI2_EVENT_DATA_SAS_TOPOLOGY_CHANGE_LIST *data;
392 MPI2_EVENT_SAS_TOPO_PHY_ENTRY *phy;
393 int i, phynum;
394
395 data = (MPI2_EVENT_DATA_SAS_TOPOLOGY_CHANGE_LIST *)
396 &event->EventData;
397 MPR_PRINTFIELD_16(sc, data, EnclosureHandle, 0x%x);
398 MPR_PRINTFIELD_16(sc, data, ExpanderDevHandle, 0x%x);
399 MPR_PRINTFIELD(sc, data, NumPhys, %d);
400 MPR_PRINTFIELD(sc, data, NumEntries, %d);
401 MPR_PRINTFIELD(sc, data, StartPhyNum, %d);
402 mpr_print_field(sc, "ExpStatus: %s (0x%x)\n",
403 mpr_describe_table(mpr_sastopo_exp, data->ExpStatus),
404 data->ExpStatus);
405 MPR_PRINTFIELD(sc, data, PhysicalPort, %d);
406 for (i = 0; i < data->NumEntries; i++) {
407 phy = &data->PHY[i];
408 phynum = data->StartPhyNum + i;
409 mpr_print_field(sc,
410 "PHY[%d].AttachedDevHandle: 0x%04x\n", phynum,
411 le16toh(phy->AttachedDevHandle));
412 mpr_print_field(sc,
413 "PHY[%d].LinkRate: %s (0x%x)\n", phynum,
414 mpr_describe_table(mpr_linkrate_names,
415 (phy->LinkRate >> 4) & 0xf), phy->LinkRate);
416 mpr_print_field(sc, "PHY[%d].PhyStatus: %s\n",
417 phynum, mpr_describe_table(mpr_phystatus_names,
418 phy->PhyStatus));
419 }
420 break;
421 }
422 case MPI2_EVENT_SAS_ENCL_DEVICE_STATUS_CHANGE:
423 {
424 MPI2_EVENT_DATA_SAS_ENCL_DEV_STATUS_CHANGE *data;
425
426 data = (MPI2_EVENT_DATA_SAS_ENCL_DEV_STATUS_CHANGE *)
427 &event->EventData;
428 MPR_PRINTFIELD_16(sc, data, EnclosureHandle, 0x%x);
429 mpr_print_field(sc, "ReasonCode: %s\n",
430 mpr_describe_table(mpr_sastopo_exp, data->ReasonCode));
431 MPR_PRINTFIELD(sc, data, PhysicalPort, %d);
432 MPR_PRINTFIELD_16(sc, data, NumSlots, %d);
433 MPR_PRINTFIELD_16(sc, data, StartSlot, %d);
434 MPR_PRINTFIELD_32(sc, data, PhyBits, 0x%x);
435 break;
436 }
437 case MPI2_EVENT_SAS_DEVICE_STATUS_CHANGE:
438 {
439 MPI2_EVENT_DATA_SAS_DEVICE_STATUS_CHANGE *data;
440
441 data = (MPI2_EVENT_DATA_SAS_DEVICE_STATUS_CHANGE *)
442 &event->EventData;
443 MPR_PRINTFIELD_16(sc, data, TaskTag, 0x%x);
444 mpr_print_field(sc, "ReasonCode: %s\n",
445 mpr_describe_table(mpr_sasdev_reason, data->ReasonCode));
446 MPR_PRINTFIELD(sc, data, ASC, 0x%x);
447 MPR_PRINTFIELD(sc, data, ASCQ, 0x%x);
448 MPR_PRINTFIELD_16(sc, data, DevHandle, 0x%x);
449 mpr_print_field(sc, "SASAddress: 0x%jx\n",
450 mpr_to_u64(&data->SASAddress));
451 break;
452 }
453 case MPI2_EVENT_SAS_BROADCAST_PRIMITIVE:
454 {
455 MPI2_EVENT_DATA_SAS_BROADCAST_PRIMITIVE *data;
456
457 data = (MPI2_EVENT_DATA_SAS_BROADCAST_PRIMITIVE *)&event->EventData;
458 MPR_PRINTFIELD(sc, data, PhyNum, %d);
459 MPR_PRINTFIELD(sc, data, Port, %d);
460 MPR_PRINTFIELD(sc, data, PortWidth, %d);
461 MPR_PRINTFIELD(sc, data, Primitive, 0x%x);
462 break;
463 }
464 default:
465 break;
466 }
467 }
468
469 void
mpr_print_expander1(struct mpr_softc * sc,MPI2_CONFIG_PAGE_EXPANDER_1 * buf)470 mpr_print_expander1(struct mpr_softc *sc, MPI2_CONFIG_PAGE_EXPANDER_1 *buf)
471 {
472 MPR_PRINTFIELD_START(sc, "SAS Expander Page 1 #%d", buf->Phy);
473 MPR_PRINTFIELD(sc, buf, PhysicalPort, %d);
474 MPR_PRINTFIELD(sc, buf, NumPhys, %d);
475 MPR_PRINTFIELD(sc, buf, Phy, %d);
476 MPR_PRINTFIELD_16(sc, buf, NumTableEntriesProgrammed, %d);
477 mpr_print_field(sc, "ProgrammedLinkRate: %s (0x%x)\n",
478 mpr_describe_table(mpr_linkrate_names,
479 (buf->ProgrammedLinkRate >> 4) & 0xf), buf->ProgrammedLinkRate);
480 mpr_print_field(sc, "HwLinkRate: %s (0x%x)\n",
481 mpr_describe_table(mpr_linkrate_names,
482 (buf->HwLinkRate >> 4) & 0xf), buf->HwLinkRate);
483 MPR_PRINTFIELD_16(sc, buf, AttachedDevHandle, 0x%04x);
484 mpr_print_field(sc, "PhyInfo Reason: %s (0x%x)\n",
485 mpr_describe_table(mpr_phyinfo_reason_names,
486 (le32toh(buf->PhyInfo) >> 16) & 0xf), le32toh(buf->PhyInfo));
487 mpr_print_field(sc, "AttachedDeviceInfo: %b,%s\n",
488 le32toh(buf->AttachedDeviceInfo), "\20" "\4SATAhost" "\5SMPinit" "\6STPinit"
489 "\7SSPinit" "\10SATAdev" "\11SMPtarg" "\12STPtarg" "\13SSPtarg"
490 "\14Direct" "\15LSIdev" "\16ATAPIdev" "\17SEPdev",
491 mpr_describe_table(mpr_sasdev0_devtype,
492 le32toh(buf->AttachedDeviceInfo) & 0x03));
493 MPR_PRINTFIELD_16(sc, buf, ExpanderDevHandle, 0x%04x);
494 MPR_PRINTFIELD(sc, buf, ChangeCount, %d);
495 mpr_print_field(sc, "NegotiatedLinkRate: %s (0x%x)\n",
496 mpr_describe_table(mpr_linkrate_names,
497 buf->NegotiatedLinkRate & 0xf), buf->NegotiatedLinkRate);
498 MPR_PRINTFIELD(sc, buf, PhyIdentifier, %d);
499 MPR_PRINTFIELD(sc, buf, AttachedPhyIdentifier, %d);
500 MPR_PRINTFIELD(sc, buf, DiscoveryInfo, 0x%x);
501 MPR_PRINTFIELD_32(sc, buf, AttachedPhyInfo, 0x%x);
502 mpr_print_field(sc, "AttachedPhyInfo Reason: %s (0x%x)\n",
503 mpr_describe_table(mpr_phyinfo_reason_names,
504 le32toh(buf->AttachedPhyInfo) & 0xf), le32toh(buf->AttachedPhyInfo));
505 MPR_PRINTFIELD(sc, buf, ZoneGroup, %d);
506 MPR_PRINTFIELD(sc, buf, SelfConfigStatus, 0x%x);
507 }
508
509 void
mpr_print_sasphy0(struct mpr_softc * sc,MPI2_CONFIG_PAGE_SAS_PHY_0 * buf)510 mpr_print_sasphy0(struct mpr_softc *sc, MPI2_CONFIG_PAGE_SAS_PHY_0 *buf)
511 {
512 MPR_PRINTFIELD_START(sc, "SAS PHY Page 0");
513 MPR_PRINTFIELD_16(sc, buf, OwnerDevHandle, 0x%04x);
514 MPR_PRINTFIELD_16(sc, buf, AttachedDevHandle, 0x%04x);
515 MPR_PRINTFIELD(sc, buf, AttachedPhyIdentifier, %d);
516 mpr_print_field(sc, "AttachedPhyInfo Reason: %s (0x%x)\n",
517 mpr_describe_table(mpr_phyinfo_reason_names,
518 le32toh(buf->AttachedPhyInfo) & 0xf), le32toh(buf->AttachedPhyInfo));
519 mpr_print_field(sc, "ProgrammedLinkRate: %s (0x%x)\n",
520 mpr_describe_table(mpr_linkrate_names,
521 (buf->ProgrammedLinkRate >> 4) & 0xf), buf->ProgrammedLinkRate);
522 mpr_print_field(sc, "HwLinkRate: %s (0x%x)\n",
523 mpr_describe_table(mpr_linkrate_names,
524 (buf->HwLinkRate >> 4) & 0xf), buf->HwLinkRate);
525 MPR_PRINTFIELD(sc, buf, ChangeCount, %d);
526 MPR_PRINTFIELD(sc, buf, Flags, 0x%x);
527 mpr_print_field(sc, "PhyInfo Reason: %s (0x%x)\n",
528 mpr_describe_table(mpr_phyinfo_reason_names,
529 (le32toh(buf->PhyInfo) >> 16) & 0xf), le32toh(buf->PhyInfo));
530 mpr_print_field(sc, "NegotiatedLinkRate: %s (0x%x)\n",
531 mpr_describe_table(mpr_linkrate_names,
532 buf->NegotiatedLinkRate & 0xf), buf->NegotiatedLinkRate);
533 }
534
535 void
mpr_print_sgl(struct mpr_softc * sc,struct mpr_command * cm,int offset)536 mpr_print_sgl(struct mpr_softc *sc, struct mpr_command *cm, int offset)
537 {
538 MPI2_IEEE_SGE_SIMPLE64 *ieee_sge;
539 MPI25_IEEE_SGE_CHAIN64 *ieee_sgc;
540 MPI2_SGE_SIMPLE64 *sge;
541 struct mpr_chain *chain = NULL;
542 char *frame;
543 u_int i = 0, flags, length;
544
545 frame = (char *)cm->cm_req;
546 ieee_sge = (MPI2_IEEE_SGE_SIMPLE64 *)&frame[offset * 4];
547 sge = (MPI2_SGE_SIMPLE64 *)&frame[offset * 4];
548 printf("SGL for command %p\n", cm);
549
550 hexdump(frame, 128, NULL, 0);
551 while ((frame != NULL) && (!(cm->cm_flags & MPR_CM_FLAGS_SGE_SIMPLE))) {
552 flags = ieee_sge->Flags;
553 length = le32toh(ieee_sge->Length);
554 printf("IEEE seg%d flags=0x%02x len=0x%08x addr=0x%016jx\n", i,
555 flags, length, mpr_to_u64(&ieee_sge->Address));
556 if (flags & MPI25_IEEE_SGE_FLAGS_END_OF_LIST)
557 break;
558 ieee_sge++;
559 i++;
560 if (flags & MPI2_IEEE_SGE_FLAGS_CHAIN_ELEMENT) {
561 ieee_sgc = (MPI25_IEEE_SGE_CHAIN64 *)ieee_sge;
562 printf("IEEE chain flags=0x%x len=0x%x Offset=0x%x "
563 "Address=0x%016jx\n", ieee_sgc->Flags,
564 le32toh(ieee_sgc->Length),
565 ieee_sgc->NextChainOffset,
566 mpr_to_u64(&ieee_sgc->Address));
567 if (chain == NULL)
568 chain = TAILQ_FIRST(&cm->cm_chain_list);
569 else
570 chain = TAILQ_NEXT(chain, chain_link);
571 frame = (char *)chain->chain;
572 ieee_sge = (MPI2_IEEE_SGE_SIMPLE64 *)frame;
573 hexdump(frame, 128, NULL, 0);
574 }
575 }
576 while ((frame != NULL) && (cm->cm_flags & MPR_CM_FLAGS_SGE_SIMPLE)) {
577 flags = le32toh(sge->FlagsLength) >> MPI2_SGE_FLAGS_SHIFT;
578 printf("seg%d flags=0x%02x len=0x%06x addr=0x%016jx\n", i,
579 flags, le32toh(sge->FlagsLength) & 0xffffff,
580 mpr_to_u64(&sge->Address));
581 if (flags & (MPI2_SGE_FLAGS_END_OF_LIST |
582 MPI2_SGE_FLAGS_END_OF_BUFFER))
583 break;
584 sge++;
585 i++;
586 }
587 }
588
589 void
mpr_print_scsiio_cmd(struct mpr_softc * sc,struct mpr_command * cm)590 mpr_print_scsiio_cmd(struct mpr_softc *sc, struct mpr_command *cm)
591 {
592 MPI2_SCSI_IO_REQUEST *req;
593
594 req = (MPI2_SCSI_IO_REQUEST *)cm->cm_req;
595 mpr_print_sgl(sc, cm, req->SGLOffset0);
596 }
597