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