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/mpr_ioctl.h> 62 #include <dev/mpr/mprvar.h> 63 #include <dev/mpr/mpr_table.h> 64 65 char * 66 mpr_describe_table(struct mpr_table_lookup *table, u_int code) 67 { 68 int i; 69 70 for (i = 0; table[i].string != NULL; i++) { 71 if (table[i].code == code) 72 return(table[i].string); 73 } 74 return(table[i+1].string); 75 } 76 77 struct mpr_table_lookup mpr_event_names[] = { 78 {"LogData", 0x01}, 79 {"StateChange", 0x02}, 80 {"HardResetReceived", 0x05}, 81 {"EventChange", 0x0a}, 82 {"TaskSetFull", 0x0e}, 83 {"SasDeviceStatusChange", 0x0f}, 84 {"IrOperationStatus", 0x14}, 85 {"SasDiscovery", 0x16}, 86 {"SasBroadcastPrimitive", 0x17}, 87 {"SasInitDeviceStatusChange", 0x18}, 88 {"SasInitTableOverflow", 0x19}, 89 {"SasTopologyChangeList", 0x1c}, 90 {"SasEnclDeviceStatusChange", 0x1d}, 91 {"IrVolume", 0x1e}, 92 {"IrPhysicalDisk", 0x1f}, 93 {"IrConfigurationChangeList", 0x20}, 94 {"LogEntryAdded", 0x21}, 95 {"SasPhyCounter", 0x22}, 96 {"GpioInterrupt", 0x23}, 97 {"HbdPhyEvent", 0x24}, 98 {"SasQuiesce", 0x25}, 99 {"SasNotifyPrimitive", 0x26}, 100 {"TempThreshold", 0x27}, 101 {"HostMessage", 0x28}, 102 {"PowerPerformanceChange", 0x29}, 103 {"CableEvent", 0x34}, 104 {NULL, 0}, 105 {"Unknown Event", 0} 106 }; 107 108 struct mpr_table_lookup mpr_phystatus_names[] = { 109 {"NewTargetAdded", 0x01}, 110 {"TargetGone", 0x02}, 111 {"PHYLinkStatusChange", 0x03}, 112 {"PHYLinkStatusUnchanged", 0x04}, 113 {"TargetMissing", 0x05}, 114 {NULL, 0}, 115 {"Unknown Status", 0} 116 }; 117 118 struct mpr_table_lookup mpr_linkrate_names[] = { 119 {"PHY disabled", 0x01}, 120 {"Speed Negotiation Failed", 0x02}, 121 {"SATA OOB Complete", 0x03}, 122 {"SATA Port Selector", 0x04}, 123 {"SMP Reset in Progress", 0x05}, 124 {"1.5Gbps", 0x08}, 125 {"3.0Gbps", 0x09}, 126 {"6.0Gbps", 0x0a}, 127 {"12.0Gbps", 0x0b}, 128 {NULL, 0}, 129 {"LinkRate Unknown", 0x00} 130 }; 131 132 struct mpr_table_lookup mpr_sasdev0_devtype[] = { 133 {"End Device", 0x01}, 134 {"Edge Expander", 0x02}, 135 {"Fanout Expander", 0x03}, 136 {NULL, 0}, 137 {"No Device", 0x00} 138 }; 139 140 struct mpr_table_lookup mpr_phyinfo_reason_names[] = { 141 {"Power On", 0x01}, 142 {"Hard Reset", 0x02}, 143 {"SMP Phy Control Link Reset", 0x03}, 144 {"Loss DWORD Sync", 0x04}, 145 {"Multiplex Sequence", 0x05}, 146 {"I-T Nexus Loss Timer", 0x06}, 147 {"Break Timeout Timer", 0x07}, 148 {"PHY Test Function", 0x08}, 149 {NULL, 0}, 150 {"Unknown Reason", 0x00} 151 }; 152 153 struct mpr_table_lookup mpr_whoinit_names[] = { 154 {"System BIOS", 0x01}, 155 {"ROM BIOS", 0x02}, 156 {"PCI Peer", 0x03}, 157 {"Host Driver", 0x04}, 158 {"Manufacturing", 0x05}, 159 {NULL, 0}, 160 {"Not Initialized", 0x00} 161 }; 162 163 struct mpr_table_lookup mpr_sasdisc_reason[] = { 164 {"Discovery Started", 0x01}, 165 {"Discovery Complete", 0x02}, 166 {NULL, 0}, 167 {"Unknown", 0x00} 168 }; 169 170 struct mpr_table_lookup mpr_sastopo_exp[] = { 171 {"Added", 0x01}, 172 {"Not Responding", 0x02}, 173 {"Responding", 0x03}, 174 {"Delay Not Responding", 0x04}, 175 {NULL, 0}, 176 {"Unknown", 0x00} 177 }; 178 179 struct mpr_table_lookup mpr_sasdev_reason[] = { 180 {"SMART Data", 0x05}, 181 {"Unsupported", 0x07}, 182 {"Internal Device Reset", 0x08}, 183 {"Task Abort Internal", 0x09}, 184 {"Abort Task Set Internal", 0x0a}, 185 {"Clear Task Set Internal", 0x0b}, 186 {"Query Task Internal", 0x0c}, 187 {"Async Notification", 0x0d}, 188 {"Cmp Internal Device Reset", 0x0e}, 189 {"Cmp Task Abort Internal", 0x0f}, 190 {"Sata Init Failure", 0x10}, 191 {NULL, 0}, 192 {"Unknown", 0x00} 193 }; 194 195 void 196 mpr_describe_devinfo(uint32_t devinfo, char *string, int len) 197 { 198 snprintf(string, len, "%b,%s", devinfo, 199 "\20" "\4SataHost" "\5SmpInit" "\6StpInit" "\7SspInit" 200 "\10SataDev" "\11SmpTarg" "\12StpTarg" "\13SspTarg" "\14Direct" 201 "\15LsiDev" "\16AtapiDev" "\17SepDev", 202 mpr_describe_table(mpr_sasdev0_devtype, devinfo & 0x03)); 203 } 204 205 void 206 _mpr_print_iocfacts(struct mpr_softc *sc, MPI2_IOC_FACTS_REPLY *facts) 207 { 208 MPR_PRINTFIELD_START(sc, "IOCFacts"); 209 MPR_PRINTFIELD(sc, facts, MsgVersion, 0x%x); 210 MPR_PRINTFIELD(sc, facts, HeaderVersion, 0x%x); 211 MPR_PRINTFIELD(sc, facts, IOCNumber, %d); 212 MPR_PRINTFIELD(sc, facts, IOCExceptions, 0x%x); 213 MPR_PRINTFIELD(sc, facts, MaxChainDepth, %d); 214 mpr_print_field(sc, "WhoInit: %s\n", 215 mpr_describe_table(mpr_whoinit_names, facts->WhoInit)); 216 MPR_PRINTFIELD(sc, facts, NumberOfPorts, %d); 217 MPR_PRINTFIELD(sc, facts, MaxMSIxVectors, %d); 218 MPR_PRINTFIELD(sc, facts, RequestCredit, %d); 219 MPR_PRINTFIELD(sc, facts, ProductID, 0x%x); 220 mpr_print_field(sc, "IOCCapabilities: %b\n", 221 facts->IOCCapabilities, "\20" "\3ScsiTaskFull" "\4DiagTrace" 222 "\5SnapBuf" "\6ExtBuf" "\7EEDP" "\10BiDirTarg" "\11Multicast" 223 "\14TransRetry" "\15IR" "\16EventReplay" "\17RaidAccel" 224 "\20MSIXIndex" "\21HostDisc"); 225 mpr_print_field(sc, "FWVersion= %d-%d-%d-%d\n", 226 facts->FWVersion.Struct.Major, 227 facts->FWVersion.Struct.Minor, 228 facts->FWVersion.Struct.Unit, 229 facts->FWVersion.Struct.Dev); 230 MPR_PRINTFIELD(sc, facts, IOCRequestFrameSize, %d); 231 MPR_PRINTFIELD(sc, facts, MaxInitiators, %d); 232 MPR_PRINTFIELD(sc, facts, MaxTargets, %d); 233 MPR_PRINTFIELD(sc, facts, MaxSasExpanders, %d); 234 MPR_PRINTFIELD(sc, facts, MaxEnclosures, %d); 235 mpr_print_field(sc, "ProtocolFlags: %b\n", 236 facts->ProtocolFlags, "\20" "\1ScsiTarg" "\2ScsiInit"); 237 MPR_PRINTFIELD(sc, facts, HighPriorityCredit, %d); 238 MPR_PRINTFIELD(sc, facts, MaxReplyDescriptorPostQueueDepth, %d); 239 MPR_PRINTFIELD(sc, facts, ReplyFrameSize, %d); 240 MPR_PRINTFIELD(sc, facts, MaxVolumes, %d); 241 MPR_PRINTFIELD(sc, facts, MaxDevHandle, %d); 242 MPR_PRINTFIELD(sc, facts, MaxPersistentEntries, %d); 243 } 244 245 void 246 _mpr_print_portfacts(struct mpr_softc *sc, MPI2_PORT_FACTS_REPLY *facts) 247 { 248 249 MPR_PRINTFIELD_START(sc, "PortFacts"); 250 MPR_PRINTFIELD(sc, facts, PortNumber, %d); 251 MPR_PRINTFIELD(sc, facts, PortType, 0x%x); 252 MPR_PRINTFIELD(sc, facts, MaxPostedCmdBuffers, %d); 253 } 254 255 void 256 _mpr_print_event(struct mpr_softc *sc, MPI2_EVENT_NOTIFICATION_REPLY *event) 257 { 258 259 MPR_PRINTFIELD_START(sc, "EventReply"); 260 MPR_PRINTFIELD(sc, event, EventDataLength, %d); 261 MPR_PRINTFIELD(sc, event, AckRequired, %d); 262 mpr_print_field(sc, "Event: %s (0x%x)\n", 263 mpr_describe_table(mpr_event_names, event->Event), event->Event); 264 MPR_PRINTFIELD(sc, event, EventContext, 0x%x); 265 } 266 267 void 268 _mpr_print_sasdev0(struct mpr_softc *sc, MPI2_CONFIG_PAGE_SAS_DEV_0 *buf) 269 { 270 MPR_PRINTFIELD_START(sc, "SAS Device Page 0"); 271 MPR_PRINTFIELD(sc, buf, Slot, %d); 272 MPR_PRINTFIELD(sc, buf, EnclosureHandle, 0x%x); 273 mpr_print_field(sc, "SASAddress: 0x%jx\n", 274 mpr_to_u64(&buf->SASAddress)); 275 MPR_PRINTFIELD(sc, buf, ParentDevHandle, 0x%x); 276 MPR_PRINTFIELD(sc, buf, PhyNum, %d); 277 MPR_PRINTFIELD(sc, buf, AccessStatus, 0x%x); 278 MPR_PRINTFIELD(sc, buf, DevHandle, 0x%x); 279 MPR_PRINTFIELD(sc, buf, AttachedPhyIdentifier, 0x%x); 280 MPR_PRINTFIELD(sc, buf, ZoneGroup, %d); 281 mpr_print_field(sc, "DeviceInfo: %b,%s\n", buf->DeviceInfo, 282 "\20" "\4SataHost" "\5SmpInit" "\6StpInit" "\7SspInit" 283 "\10SataDev" "\11SmpTarg" "\12StpTarg" "\13SspTarg" "\14Direct" 284 "\15LsiDev" "\16AtapiDev" "\17SepDev", 285 mpr_describe_table(mpr_sasdev0_devtype, buf->DeviceInfo & 0x03)); 286 MPR_PRINTFIELD(sc, buf, Flags, 0x%x); 287 MPR_PRINTFIELD(sc, buf, PhysicalPort, %d); 288 MPR_PRINTFIELD(sc, buf, MaxPortConnections, %d); 289 mpr_print_field(sc, "DeviceName: 0x%jx\n", 290 mpr_to_u64(&buf->DeviceName)); 291 MPR_PRINTFIELD(sc, buf, PortGroups, %d); 292 MPR_PRINTFIELD(sc, buf, DmaGroup, %d); 293 MPR_PRINTFIELD(sc, buf, ControlGroup, %d); 294 } 295 296 void 297 _mpr_print_evt_sas(struct mpr_softc *sc, MPI2_EVENT_NOTIFICATION_REPLY *event) 298 { 299 300 _mpr_print_event(sc, event); 301 302 switch(event->Event) { 303 case MPI2_EVENT_SAS_DISCOVERY: 304 { 305 MPI2_EVENT_DATA_SAS_DISCOVERY *data; 306 307 data = (MPI2_EVENT_DATA_SAS_DISCOVERY *)&event->EventData; 308 mpr_print_field(sc, "Flags: %b\n", data->Flags, 309 "\20" "\1InProgress" "\2DeviceChange"); 310 mpr_print_field(sc, "ReasonCode: %s\n", 311 mpr_describe_table(mpr_sasdisc_reason, data->ReasonCode)); 312 MPR_PRINTFIELD(sc, data, PhysicalPort, %d); 313 mpr_print_field(sc, "DiscoveryStatus: %b\n", 314 data->DiscoveryStatus, "\20" 315 "\1Loop" "\2UnaddressableDev" "\3DupSasAddr" "\5SmpTimeout" 316 "\6ExpRouteFull" "\7RouteIndexError" "\10SmpFailed" 317 "\11SmpCrcError" "\12SubSubLink" "\13TableTableLink" 318 "\14UnsupDevice" "\15TableSubLink" "\16MultiDomain" 319 "\17MultiSub" "\20MultiSubSub" "\34DownstreamInit" 320 "\35MaxPhys" "\36MaxTargs" "\37MaxExpanders" 321 "\40MaxEnclosures"); 322 break; 323 } 324 case MPI2_EVENT_SAS_TOPOLOGY_CHANGE_LIST: 325 { 326 MPI2_EVENT_DATA_SAS_TOPOLOGY_CHANGE_LIST *data; 327 MPI2_EVENT_SAS_TOPO_PHY_ENTRY *phy; 328 int i, phynum; 329 330 data = (MPI2_EVENT_DATA_SAS_TOPOLOGY_CHANGE_LIST *) 331 &event->EventData; 332 MPR_PRINTFIELD(sc, data, EnclosureHandle, 0x%x); 333 MPR_PRINTFIELD(sc, data, ExpanderDevHandle, 0x%x); 334 MPR_PRINTFIELD(sc, data, NumPhys, %d); 335 MPR_PRINTFIELD(sc, data, NumEntries, %d); 336 MPR_PRINTFIELD(sc, data, StartPhyNum, %d); 337 mpr_print_field(sc, "ExpStatus: %s (0x%x)\n", 338 mpr_describe_table(mpr_sastopo_exp, data->ExpStatus), 339 data->ExpStatus); 340 MPR_PRINTFIELD(sc, data, PhysicalPort, %d); 341 for (i = 0; i < data->NumEntries; i++) { 342 phy = &data->PHY[i]; 343 phynum = data->StartPhyNum + i; 344 mpr_print_field(sc, 345 "PHY[%d].AttachedDevHandle: 0x%04x\n", phynum, 346 phy->AttachedDevHandle); 347 mpr_print_field(sc, 348 "PHY[%d].LinkRate: %s (0x%x)\n", phynum, 349 mpr_describe_table(mpr_linkrate_names, 350 (phy->LinkRate >> 4) & 0xf), phy->LinkRate); 351 mpr_print_field(sc, "PHY[%d].PhyStatus: %s\n", 352 phynum, mpr_describe_table(mpr_phystatus_names, 353 phy->PhyStatus)); 354 } 355 break; 356 } 357 case MPI2_EVENT_SAS_ENCL_DEVICE_STATUS_CHANGE: 358 { 359 MPI2_EVENT_DATA_SAS_ENCL_DEV_STATUS_CHANGE *data; 360 361 data = (MPI2_EVENT_DATA_SAS_ENCL_DEV_STATUS_CHANGE *) 362 &event->EventData; 363 MPR_PRINTFIELD(sc, data, EnclosureHandle, 0x%x); 364 mpr_print_field(sc, "ReasonCode: %s\n", 365 mpr_describe_table(mpr_sastopo_exp, data->ReasonCode)); 366 MPR_PRINTFIELD(sc, data, PhysicalPort, %d); 367 MPR_PRINTFIELD(sc, data, NumSlots, %d); 368 MPR_PRINTFIELD(sc, data, StartSlot, %d); 369 MPR_PRINTFIELD(sc, data, PhyBits, 0x%x); 370 break; 371 } 372 case MPI2_EVENT_SAS_DEVICE_STATUS_CHANGE: 373 { 374 MPI2_EVENT_DATA_SAS_DEVICE_STATUS_CHANGE *data; 375 376 data = (MPI2_EVENT_DATA_SAS_DEVICE_STATUS_CHANGE *) 377 &event->EventData; 378 MPR_PRINTFIELD(sc, data, TaskTag, 0x%x); 379 mpr_print_field(sc, "ReasonCode: %s\n", 380 mpr_describe_table(mpr_sasdev_reason, data->ReasonCode)); 381 MPR_PRINTFIELD(sc, data, ASC, 0x%x); 382 MPR_PRINTFIELD(sc, data, ASCQ, 0x%x); 383 MPR_PRINTFIELD(sc, data, DevHandle, 0x%x); 384 mpr_print_field(sc, "SASAddress: 0x%jx\n", 385 mpr_to_u64(&data->SASAddress)); 386 } 387 default: 388 break; 389 } 390 } 391 392 void 393 _mpr_print_expander1(struct mpr_softc *sc, MPI2_CONFIG_PAGE_EXPANDER_1 *buf) 394 { 395 MPR_PRINTFIELD_START(sc, "SAS Expander Page 1 #%d", buf->Phy); 396 MPR_PRINTFIELD(sc, buf, PhysicalPort, %d); 397 MPR_PRINTFIELD(sc, buf, NumPhys, %d); 398 MPR_PRINTFIELD(sc, buf, Phy, %d); 399 MPR_PRINTFIELD(sc, buf, NumTableEntriesProgrammed, %d); 400 mpr_print_field(sc, "ProgrammedLinkRate: %s (0x%x)\n", 401 mpr_describe_table(mpr_linkrate_names, 402 (buf->ProgrammedLinkRate >> 4) & 0xf), buf->ProgrammedLinkRate); 403 mpr_print_field(sc, "HwLinkRate: %s (0x%x)\n", 404 mpr_describe_table(mpr_linkrate_names, 405 (buf->HwLinkRate >> 4) & 0xf), buf->HwLinkRate); 406 MPR_PRINTFIELD(sc, buf, AttachedDevHandle, 0x%04x); 407 mpr_print_field(sc, "PhyInfo Reason: %s (0x%x)\n", 408 mpr_describe_table(mpr_phyinfo_reason_names, 409 (buf->PhyInfo >> 16) & 0xf), buf->PhyInfo); 410 mpr_print_field(sc, "AttachedDeviceInfo: %b,%s\n", 411 buf->AttachedDeviceInfo, "\20" "\4SATAhost" "\5SMPinit" "\6STPinit" 412 "\7SSPinit" "\10SATAdev" "\11SMPtarg" "\12STPtarg" "\13SSPtarg" 413 "\14Direct" "\15LSIdev" "\16ATAPIdev" "\17SEPdev", 414 mpr_describe_table(mpr_sasdev0_devtype, 415 buf->AttachedDeviceInfo & 0x03)); 416 MPR_PRINTFIELD(sc, buf, ExpanderDevHandle, 0x%04x); 417 MPR_PRINTFIELD(sc, buf, ChangeCount, %d); 418 mpr_print_field(sc, "NegotiatedLinkRate: %s (0x%x)\n", 419 mpr_describe_table(mpr_linkrate_names, 420 buf->NegotiatedLinkRate & 0xf), buf->NegotiatedLinkRate); 421 MPR_PRINTFIELD(sc, buf, PhyIdentifier, %d); 422 MPR_PRINTFIELD(sc, buf, AttachedPhyIdentifier, %d); 423 MPR_PRINTFIELD(sc, buf, DiscoveryInfo, 0x%x); 424 MPR_PRINTFIELD(sc, buf, AttachedPhyInfo, 0x%x); 425 mpr_print_field(sc, "AttachedPhyInfo Reason: %s (0x%x)\n", 426 mpr_describe_table(mpr_phyinfo_reason_names, 427 buf->AttachedPhyInfo & 0xf), buf->AttachedPhyInfo); 428 MPR_PRINTFIELD(sc, buf, ZoneGroup, %d); 429 MPR_PRINTFIELD(sc, buf, SelfConfigStatus, 0x%x); 430 } 431 432 void 433 _mpr_print_sasphy0(struct mpr_softc *sc, MPI2_CONFIG_PAGE_SAS_PHY_0 *buf) 434 { 435 MPR_PRINTFIELD_START(sc, "SAS PHY Page 0"); 436 MPR_PRINTFIELD(sc, buf, OwnerDevHandle, 0x%04x); 437 MPR_PRINTFIELD(sc, buf, AttachedDevHandle, 0x%04x); 438 MPR_PRINTFIELD(sc, buf, AttachedPhyIdentifier, %d); 439 mpr_print_field(sc, "AttachedPhyInfo Reason: %s (0x%x)\n", 440 mpr_describe_table(mpr_phyinfo_reason_names, 441 buf->AttachedPhyInfo & 0xf), buf->AttachedPhyInfo); 442 mpr_print_field(sc, "ProgrammedLinkRate: %s (0x%x)\n", 443 mpr_describe_table(mpr_linkrate_names, 444 (buf->ProgrammedLinkRate >> 4) & 0xf), buf->ProgrammedLinkRate); 445 mpr_print_field(sc, "HwLinkRate: %s (0x%x)\n", 446 mpr_describe_table(mpr_linkrate_names, 447 (buf->HwLinkRate >> 4) & 0xf), buf->HwLinkRate); 448 MPR_PRINTFIELD(sc, buf, ChangeCount, %d); 449 MPR_PRINTFIELD(sc, buf, Flags, 0x%x); 450 mpr_print_field(sc, "PhyInfo Reason: %s (0x%x)\n", 451 mpr_describe_table(mpr_phyinfo_reason_names, 452 (buf->PhyInfo >> 16) & 0xf), buf->PhyInfo); 453 mpr_print_field(sc, "NegotiatedLinkRate: %s (0x%x)\n", 454 mpr_describe_table(mpr_linkrate_names, 455 buf->NegotiatedLinkRate & 0xf), buf->NegotiatedLinkRate); 456 } 457 458 void 459 mpr_print_sgl(struct mpr_softc *sc, struct mpr_command *cm, int offset) 460 { 461 MPI2_IEEE_SGE_SIMPLE64 *ieee_sge; 462 MPI25_IEEE_SGE_CHAIN64 *ieee_sgc; 463 MPI2_SGE_SIMPLE64 *sge; 464 MPI2_REQUEST_HEADER *req; 465 struct mpr_chain *chain = NULL; 466 char *frame; 467 u_int i = 0, flags, length; 468 469 req = (MPI2_REQUEST_HEADER *)cm->cm_req; 470 frame = (char *)cm->cm_req; 471 ieee_sge = (MPI2_IEEE_SGE_SIMPLE64 *)&frame[offset * 4]; 472 sge = (MPI2_SGE_SIMPLE64 *)&frame[offset * 4]; 473 printf("SGL for command %p\n", cm); 474 475 hexdump(frame, 128, NULL, 0); 476 while ((frame != NULL) && (!(cm->cm_flags & MPR_CM_FLAGS_SGE_SIMPLE))) { 477 flags = ieee_sge->Flags; 478 length = le32toh(ieee_sge->Length); 479 printf("IEEE seg%d flags=0x%02x len=0x%08x addr=0x%016jx\n", i, 480 flags, length, mpr_to_u64(&ieee_sge->Address)); 481 if (flags & MPI25_IEEE_SGE_FLAGS_END_OF_LIST) 482 break; 483 ieee_sge++; 484 i++; 485 if (flags & MPI2_IEEE_SGE_FLAGS_CHAIN_ELEMENT) { 486 ieee_sgc = (MPI25_IEEE_SGE_CHAIN64 *)ieee_sge; 487 printf("IEEE chain flags=0x%x len=0x%x Offset=0x%x " 488 "Address=0x%016jx\n", ieee_sgc->Flags, 489 le32toh(ieee_sgc->Length), 490 ieee_sgc->NextChainOffset, 491 mpr_to_u64(&ieee_sgc->Address)); 492 if (chain == NULL) 493 chain = TAILQ_FIRST(&cm->cm_chain_list); 494 else 495 chain = TAILQ_NEXT(chain, chain_link); 496 frame = (char *)chain->chain; 497 ieee_sge = (MPI2_IEEE_SGE_SIMPLE64 *)frame; 498 hexdump(frame, 128, NULL, 0); 499 } 500 } 501 while ((frame != NULL) && (cm->cm_flags & MPR_CM_FLAGS_SGE_SIMPLE)) { 502 flags = le32toh(sge->FlagsLength) >> MPI2_SGE_FLAGS_SHIFT; 503 printf("seg%d flags=0x%02x len=0x%06x addr=0x%016jx\n", i, 504 flags, le32toh(sge->FlagsLength) & 0xffffff, 505 mpr_to_u64(&sge->Address)); 506 if (flags & (MPI2_SGE_FLAGS_END_OF_LIST | 507 MPI2_SGE_FLAGS_END_OF_BUFFER)) 508 break; 509 sge++; 510 i++; 511 } 512 } 513 514 void 515 mpr_print_scsiio_cmd(struct mpr_softc *sc, struct mpr_command *cm) 516 { 517 MPI2_SCSI_IO_REQUEST *req; 518 519 req = (MPI2_SCSI_IO_REQUEST *)cm->cm_req; 520 mpr_print_sgl(sc, cm, req->SGLOffset0); 521 } 522 523