1195534Sscottl/*- 2195534Sscottl * Copyright (c) 2009 Yahoo! Inc. 3195534Sscottl * All rights reserved. 4195534Sscottl * 5195534Sscottl * Redistribution and use in source and binary forms, with or without 6195534Sscottl * modification, are permitted provided that the following conditions 7195534Sscottl * are met: 8195534Sscottl * 1. Redistributions of source code must retain the above copyright 9195534Sscottl * notice, this list of conditions and the following disclaimer. 10195534Sscottl * 2. Redistributions in binary form must reproduce the above copyright 11195534Sscottl * notice, this list of conditions and the following disclaimer in the 12195534Sscottl * documentation and/or other materials provided with the distribution. 13195534Sscottl * 14195534Sscottl * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15195534Sscottl * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16195534Sscottl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17195534Sscottl * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18195534Sscottl * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19195534Sscottl * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20195534Sscottl * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21195534Sscottl * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22195534Sscottl * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23195534Sscottl * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24195534Sscottl * SUCH DAMAGE. 25195534Sscottl */ 26195534Sscottl 27195534Sscottl#include <sys/cdefs.h> 28195534Sscottl__FBSDID("$FreeBSD$"); 29195534Sscottl 30195534Sscottl/* Debugging tables for MPT2 */ 31195534Sscottl 32195534Sscottl/* TODO Move headers to mprvar */ 33195534Sscottl#include <sys/types.h> 34195534Sscottl#include <sys/param.h> 35195534Sscottl#include <sys/systm.h> 36195534Sscottl#include <sys/kernel.h> 37195534Sscottl#include <sys/selinfo.h> 38195534Sscottl#include <sys/module.h> 39195534Sscottl#include <sys/bus.h> 40195534Sscottl#include <sys/conf.h> 41195534Sscottl#include <sys/bio.h> 42195534Sscottl#include <sys/malloc.h> 43195534Sscottl#include <sys/uio.h> 44195534Sscottl#include <sys/sysctl.h> 45195534Sscottl#include <sys/queue.h> 46195534Sscottl#include <sys/kthread.h> 47195534Sscottl#include <sys/taskqueue.h> 48195534Sscottl 49195534Sscottl#include <machine/bus.h> 50195534Sscottl#include <machine/resource.h> 51195534Sscottl#include <sys/rman.h> 52195534Sscottl 53195534Sscottl#include <cam/scsi/scsi_all.h> 54195534Sscottl 55195534Sscottl#include <dev/mpr/mpi/mpi2_type.h> 56195534Sscottl#include <dev/mpr/mpi/mpi2.h> 57195534Sscottl#include <dev/mpr/mpi/mpi2_ioc.h> 58195534Sscottl#include <dev/mpr/mpi/mpi2_cnfg.h> 59195534Sscottl#include <dev/mpr/mpi/mpi2_init.h> 60195534Sscottl#include <dev/mpr/mpi/mpi2_tool.h> 61195534Sscottl#include <dev/mpr/mpr_ioctl.h> 62195534Sscottl#include <dev/mpr/mprvar.h> 63195534Sscottl#include <dev/mpr/mpr_table.h> 64195534Sscottl 65196656Smavchar * 66195534Sscottlmpr_describe_table(struct mpr_table_lookup *table, u_int code) 67195534Sscottl{ 68195534Sscottl int i; 69195534Sscottl 70195534Sscottl for (i = 0; table[i].string != NULL; i++) { 71195534Sscottl if (table[i].code == code) 72195534Sscottl return(table[i].string); 73195534Sscottl } 74199821Smav return(table[i+1].string); 75195534Sscottl} 76195534Sscottl 77195534Sscottlstruct mpr_table_lookup mpr_event_names[] = { 78195534Sscottl {"LogData", 0x01}, 79195534Sscottl {"StateChange", 0x02}, 80195534Sscottl {"HardResetReceived", 0x05}, 81203123Smav {"EventChange", 0x0a}, 82195534Sscottl {"TaskSetFull", 0x0e}, 83195534Sscottl {"SasDeviceStatusChange", 0x0f}, 84195534Sscottl {"IrOperationStatus", 0x14}, 85195534Sscottl {"SasDiscovery", 0x16}, 86195534Sscottl {"SasBroadcastPrimitive", 0x17}, 87195534Sscottl {"SasInitDeviceStatusChange", 0x18}, 88203108Smav {"SasInitTableOverflow", 0x19}, 89203123Smav {"SasTopologyChangeList", 0x1c}, 90195534Sscottl {"SasEnclDeviceStatusChange", 0x1d}, 91195534Sscottl {"IrVolume", 0x1e}, 92195534Sscottl {"IrPhysicalDisk", 0x1f}, 93195534Sscottl {"IrConfigurationChangeList", 0x20}, 94195534Sscottl {"LogEntryAdded", 0x21}, 95195534Sscottl {"SasPhyCounter", 0x22}, 96195534Sscottl {"GpioInterrupt", 0x23}, 97195534Sscottl {"HbdPhyEvent", 0x24}, 98195534Sscottl {NULL, 0}, 99199176Smav {"Unknown Event", 0} 100199176Smav}; 101203030Smav 102199176Smavstruct mpr_table_lookup mpr_phystatus_names[] = { 103199322Smav {"NewTargetAdded", 0x01}, 104199322Smav {"TargetGone", 0x02}, 105199322Smav {"PHYLinkStatusChange", 0x03}, 106199322Smav {"PHYLinkStatusUnchanged", 0x04}, 107199322Smav {"TargetMissing", 0x05}, 108199322Smav {NULL, 0}, 109199322Smav {"Unknown Status", 0} 110199322Smav}; 111203030Smav 112203123Smavstruct mpr_table_lookup mpr_linkrate_names[] = { 113199176Smav {"PHY disabled", 0x01}, 114203030Smav {"Speed Negotiation Failed", 0x02}, 115203030Smav {"SATA OOB Complete", 0x03}, 116203030Smav {"SATA Port Selector", 0x04}, 117203030Smav {"SMP Reset in Progress", 0x05}, 118203030Smav {"1.5Gbps", 0x08}, 119203030Smav {"3.0Gbps", 0x09}, 120203030Smav {"6.0Gbps", 0x0a}, 121203030Smav {NULL, 0}, 122203030Smav {"LinkRate Unknown", 0x00} 123203030Smav}; 124203030Smav 125203030Smavstruct mpr_table_lookup mpr_sasdev0_devtype[] = { 126203030Smav {"End Device", 0x01}, 127203030Smav {"Edge Expander", 0x02}, 128203030Smav {"Fanout Expander", 0x03}, 129203030Smav {NULL, 0}, 130203030Smav {"No Device", 0x00} 131203030Smav}; 132203030Smav 133203030Smavstruct mpr_table_lookup mpr_phyinfo_reason_names[] = { 134203030Smav {"Power On", 0x01}, 135203030Smav {"Hard Reset", 0x02}, 136203030Smav {"SMP Phy Control Link Reset", 0x03}, 137203030Smav {"Loss DWORD Sync", 0x04}, 138203030Smav {"Multiplex Sequence", 0x05}, 139203030Smav {"I-T Nexus Loss Timer", 0x06}, 140203030Smav {"Break Timeout Timer", 0x07}, 141203030Smav {"PHY Test Function", 0x08}, 142203030Smav {NULL, 0}, 143203030Smav {"Unknown Reason", 0x00} 144203030Smav}; 145203030Smav 146203030Smavstruct mpr_table_lookup mpr_whoinit_names[] = { 147203030Smav {"System BIOS", 0x01}, 148203030Smav {"ROM BIOS", 0x02}, 149203030Smav {"PCI Peer", 0x03}, 150203030Smav {"Host Driver", 0x04}, 151203030Smav {"Manufacturing", 0x05}, 152203030Smav {NULL, 0}, 153203030Smav {"Not Initialized", 0x00} 154203030Smav}; 155203030Smav 156203030Smavstruct mpr_table_lookup mpr_sasdisc_reason[] = { 157203030Smav {"Discovery Started", 0x01}, 158203030Smav {"Discovery Complete", 0x02}, 159203030Smav {NULL, 0}, 160203030Smav {"Unknown", 0x00} 161203030Smav}; 162203030Smav 163203030Smavstruct mpr_table_lookup mpr_sastopo_exp[] = { 164203030Smav {"Added", 0x01}, 165203030Smav {"Not Responding", 0x02}, 166203030Smav {"Responding", 0x03}, 167203123Smav {"Delay Not Responding", 0x04}, 168203123Smav {NULL, 0}, 169203030Smav {"Unknown", 0x00} 170203030Smav}; 171203030Smav 172203030Smavstruct mpr_table_lookup mpr_sasdev_reason[] = { 173203030Smav {"SMART Data", 0x05}, 174203030Smav {"Unsupported", 0x07}, 175203030Smav {"Internal Device Reset", 0x08}, 176203030Smav {"Task Abort Internal", 0x09}, 177203030Smav {"Abort Task Set Internal", 0x0a}, 178203030Smav {"Clear Task Set Internal", 0x0b}, 179203030Smav {"Query Task Internal", 0x0c}, 180203030Smav {"Async Notification", 0x0d}, 181203030Smav {"Cmp Internal Device Reset", 0x0e}, 182203030Smav {"Cmp Task Abort Internal", 0x0f}, 183203030Smav {"Sata Init Failure", 0x10}, 184203030Smav {NULL, 0}, 185203030Smav {"Unknown", 0x00} 186203030Smav}; 187203030Smav 188203030Smavvoid 189203030Smavmpr_describe_devinfo(uint32_t devinfo, char *string, int len) 190203030Smav{ 191203030Smav snprintf(string, len, "%b,%s", devinfo, 192203030Smav "\20" "\4SataHost" "\5SmpInit" "\6StpInit" "\7SspInit" 193203030Smav "\10SataDev" "\11SmpTarg" "\12StpTarg" "\13SspTarg" "\14Direct" 194203030Smav "\15LsiDev" "\16AtapiDev" "\17SepDev", 195203030Smav mpr_describe_table(mpr_sasdev0_devtype, devinfo & 0x03)); 196203030Smav} 197203030Smav 198203030Smavvoid 199203030Smavmpr_print_iocfacts(struct mpr_softc *sc, MPI2_IOC_FACTS_REPLY *facts) 200203030Smav{ 201203030Smav 202203030Smav MPR_PRINTFIELD_START(sc, "IOCFacts"); 203203030Smav MPR_PRINTFIELD(sc, facts, MsgVersion, 0x%x); 204203030Smav MPR_PRINTFIELD(sc, facts, HeaderVersion, 0x%x); 205203030Smav MPR_PRINTFIELD(sc, facts, IOCNumber, %d); 206203030Smav MPR_PRINTFIELD(sc, facts, IOCExceptions, 0x%x); 207203030Smav MPR_PRINTFIELD(sc, facts, MaxChainDepth, %d); 208203030Smav mpr_dprint_field(sc, MPR_XINFO, "WhoInit: %s\n", 209203030Smav mpr_describe_table(mpr_whoinit_names, facts->WhoInit)); 210203030Smav MPR_PRINTFIELD(sc, facts, NumberOfPorts, %d); 211203030Smav MPR_PRINTFIELD(sc, facts, RequestCredit, %d); 212203030Smav MPR_PRINTFIELD(sc, facts, ProductID, 0x%x); 213203030Smav mpr_dprint_field(sc, MPR_XINFO, "IOCCapabilities: %b\n", 214203030Smav facts->IOCCapabilities, "\20" "\3ScsiTaskFull" "\4DiagTrace" 215203030Smav "\5SnapBuf" "\6ExtBuf" "\7EEDP" "\10BiDirTarg" "\11Multicast" 216203030Smav "\14TransRetry" "\15IR" "\16EventReplay" "\17RaidAccel" 217203030Smav "\20MSIXIndex" "\21HostDisc"); 218203030Smav mpr_dprint_field(sc, MPR_XINFO, "FWVersion= %d-%d-%d-%d\n", 219203030Smav facts->FWVersion.Struct.Major, 220203030Smav facts->FWVersion.Struct.Minor, 221203030Smav facts->FWVersion.Struct.Unit, 222203030Smav facts->FWVersion.Struct.Dev); 223203030Smav MPR_PRINTFIELD(sc, facts, IOCRequestFrameSize, %d); 224203030Smav MPR_PRINTFIELD(sc, facts, MaxInitiators, %d); 225203030Smav MPR_PRINTFIELD(sc, facts, MaxTargets, %d); 226203030Smav MPR_PRINTFIELD(sc, facts, MaxSasExpanders, %d); 227203030Smav MPR_PRINTFIELD(sc, facts, MaxEnclosures, %d); 228203030Smav mpr_dprint_field(sc, MPR_XINFO, "ProtocolFlags: %b\n", 229203030Smav facts->ProtocolFlags, "\20" "\1ScsiTarg" "\2ScsiInit"); 230203030Smav MPR_PRINTFIELD(sc, facts, HighPriorityCredit, %d); 231203030Smav MPR_PRINTFIELD(sc, facts, MaxReplyDescriptorPostQueueDepth, %d); 232203030Smav MPR_PRINTFIELD(sc, facts, ReplyFrameSize, %d); 233203030Smav MPR_PRINTFIELD(sc, facts, MaxVolumes, %d); 234203030Smav MPR_PRINTFIELD(sc, facts, MaxDevHandle, %d); 235203030Smav MPR_PRINTFIELD(sc, facts, MaxPersistentEntries, %d); 236203030Smav} 237203030Smav 238203030Smavvoid 239203030Smavmpr_print_portfacts(struct mpr_softc *sc, MPI2_PORT_FACTS_REPLY *facts) 240203030Smav{ 241203030Smav 242203030Smav MPR_PRINTFIELD_START(sc, "PortFacts"); 243203030Smav MPR_PRINTFIELD(sc, facts, PortNumber, %d); 244199176Smav MPR_PRINTFIELD(sc, facts, PortType, 0x%x); 245199176Smav MPR_PRINTFIELD(sc, facts, MaxPostedCmdBuffers, %d); 246195534Sscottl} 247195534Sscottl 248195534Sscottlvoid 249199176Smavmpr_print_event(struct mpr_softc *sc, MPI2_EVENT_NOTIFICATION_REPLY *event) 250199322Smav{ 251199322Smav 252203030Smav MPR_EVENTFIELD_START(sc, "EventReply"); 253199322Smav MPR_EVENTFIELD(sc, event, EventDataLength, %d); 254199322Smav MPR_EVENTFIELD(sc, event, AckRequired, %d); 255199322Smav mpr_dprint_field(sc, MPR_EVENT, "Event: %s (0x%x)\n", 256199322Smav mpr_describe_table(mpr_event_names, event->Event), event->Event); 257199322Smav MPR_EVENTFIELD(sc, event, EventContext, 0x%x); 258199322Smav} 259199322Smav 260199322Smavvoid 261199322Smavmpr_print_sasdev0(struct mpr_softc *sc, MPI2_CONFIG_PAGE_SAS_DEV_0 *buf) 262203030Smav{ 263199322Smav MPR_PRINTFIELD_START(sc, "SAS Device Page 0"); 264199717Smav MPR_PRINTFIELD(sc, buf, Slot, %d); 265199717Smav MPR_PRINTFIELD(sc, buf, EnclosureHandle, 0x%x); 266199717Smav mpr_dprint_field(sc, MPR_XINFO, "SASAddress: 0x%jx\n", 267199717Smav mpr_to_u64(&buf->SASAddress)); 268199322Smav MPR_PRINTFIELD(sc, buf, ParentDevHandle, 0x%x); 269199322Smav MPR_PRINTFIELD(sc, buf, PhyNum, %d); 270199322Smav MPR_PRINTFIELD(sc, buf, AccessStatus, 0x%x); 271199322Smav MPR_PRINTFIELD(sc, buf, DevHandle, 0x%x); 272199322Smav MPR_PRINTFIELD(sc, buf, AttachedPhyIdentifier, 0x%x); 273199322Smav MPR_PRINTFIELD(sc, buf, ZoneGroup, %d); 274199322Smav mpr_dprint_field(sc, MPR_XINFO, "DeviceInfo: %b,%s\n", buf->DeviceInfo, 275199322Smav "\20" "\4SataHost" "\5SmpInit" "\6StpInit" "\7SspInit" 276199322Smav "\10SataDev" "\11SmpTarg" "\12StpTarg" "\13SspTarg" "\14Direct" 277199322Smav "\15LsiDev" "\16AtapiDev" "\17SepDev", 278199322Smav mpr_describe_table(mpr_sasdev0_devtype, buf->DeviceInfo & 0x03)); 279199322Smav MPR_PRINTFIELD(sc, buf, Flags, 0x%x); 280199322Smav MPR_PRINTFIELD(sc, buf, PhysicalPort, %d); 281199322Smav MPR_PRINTFIELD(sc, buf, MaxPortConnections, %d); 282199322Smav mpr_dprint_field(sc, MPR_XINFO, "DeviceName: 0x%jx\n", 283199322Smav mpr_to_u64(&buf->DeviceName)); 284199176Smav MPR_PRINTFIELD(sc, buf, PortGroups, %d); 285199176Smav MPR_PRINTFIELD(sc, buf, DmaGroup, %d); 286203030Smav MPR_PRINTFIELD(sc, buf, ControlGroup, %d); 287195534Sscottl} 288199322Smav 289199322Smavvoid 290199176Smavmpr_print_evt_sas(struct mpr_softc *sc, MPI2_EVENT_NOTIFICATION_REPLY *event) 291199176Smav{ 292203030Smav 293203030Smav mpr_print_event(sc, event); 294199176Smav 295199176Smav switch(event->Event) { 296199176Smav case MPI2_EVENT_SAS_DISCOVERY: 297199176Smav { 298199176Smav MPI2_EVENT_DATA_SAS_DISCOVERY *data; 299199176Smav 300199176Smav data = (MPI2_EVENT_DATA_SAS_DISCOVERY *)&event->EventData; 301195534Sscottl mpr_dprint_field(sc, MPR_EVENT, "Flags: %b\n", data->Flags, 302195534Sscottl "\20" "\1InProgress" "\2DeviceChange"); 303195534Sscottl mpr_dprint_field(sc, MPR_EVENT, "ReasonCode: %s\n", 304195534Sscottl mpr_describe_table(mpr_sasdisc_reason, data->ReasonCode)); 305195534Sscottl MPR_EVENTFIELD(sc, data, PhysicalPort, %d); 306195534Sscottl mpr_dprint_field(sc, MPR_EVENT, "DiscoveryStatus: %b\n", 307195534Sscottl data->DiscoveryStatus, "\20" 308195534Sscottl "\1Loop" "\2UnaddressableDev" "\3DupSasAddr" "\5SmpTimeout" 309199322Smav "\6ExpRouteFull" "\7RouteIndexError" "\10SmpFailed" 310199322Smav "\11SmpCrcError" "\12SubSubLink" "\13TableTableLink" 311203030Smav "\14UnsupDevice" "\15TableSubLink" "\16MultiDomain" 312196656Smav "\17MultiSub" "\20MultiSubSub" "\34DownstreamInit" 313195534Sscottl "\35MaxPhys" "\36MaxTargs" "\37MaxExpanders" 314195534Sscottl "\40MaxEnclosures"); 315199322Smav break; 316203030Smav } 317203030Smav case MPI2_EVENT_SAS_TOPOLOGY_CHANGE_LIST: 318203030Smav { 319199322Smav MPI2_EVENT_DATA_SAS_TOPOLOGY_CHANGE_LIST *data; 320199322Smav MPI2_EVENT_SAS_TOPO_PHY_ENTRY *phy; 321196656Smav int i, phynum; 322196656Smav 323195534Sscottl data = (MPI2_EVENT_DATA_SAS_TOPOLOGY_CHANGE_LIST *) 324195534Sscottl &event->EventData; 325195534Sscottl MPR_EVENTFIELD(sc, data, EnclosureHandle, 0x%x); 326195534Sscottl MPR_EVENTFIELD(sc, data, ExpanderDevHandle, 0x%x); 327195534Sscottl MPR_EVENTFIELD(sc, data, NumPhys, %d); 328195534Sscottl MPR_EVENTFIELD(sc, data, NumEntries, %d); 329195534Sscottl MPR_EVENTFIELD(sc, data, StartPhyNum, %d); 330195534Sscottl mpr_dprint_field(sc, MPR_EVENT, "ExpStatus: %s (0x%x)\n", 331195534Sscottl mpr_describe_table(mpr_sastopo_exp, data->ExpStatus), 332195534Sscottl data->ExpStatus); 333195534Sscottl MPR_EVENTFIELD(sc, data, PhysicalPort, %d); 334195534Sscottl for (i = 0; i < data->NumEntries; i++) { 335195534Sscottl phy = &data->PHY[i]; 336195534Sscottl phynum = data->StartPhyNum + i; 337195534Sscottl mpr_dprint_field(sc, MPR_EVENT, 338195534Sscottl "PHY[%d].AttachedDevHandle: 0x%04x\n", phynum, 339195534Sscottl phy->AttachedDevHandle); 340195534Sscottl mpr_dprint_field(sc, MPR_EVENT, 341195534Sscottl "PHY[%d].LinkRate: %s (0x%x)\n", phynum, 342195534Sscottl mpr_describe_table(mpr_linkrate_names, 343195534Sscottl (phy->LinkRate >> 4) & 0xf), phy->LinkRate); 344195534Sscottl mpr_dprint_field(sc,MPR_EVENT,"PHY[%d].PhyStatus: " 345195534Sscottl "%s\n", phynum, 346195534Sscottl mpr_describe_table(mpr_phystatus_names, 347199322Smav phy->PhyStatus)); 348199322Smav } 349199322Smav break; 350199322Smav } 351199322Smav case MPI2_EVENT_SAS_ENCL_DEVICE_STATUS_CHANGE: 352203108Smav { 353203108Smav MPI2_EVENT_DATA_SAS_ENCL_DEV_STATUS_CHANGE *data; 354195534Sscottl 355199322Smav data = (MPI2_EVENT_DATA_SAS_ENCL_DEV_STATUS_CHANGE *) 356199322Smav &event->EventData; 357199322Smav MPR_EVENTFIELD(sc, data, EnclosureHandle, 0x%x); 358199322Smav mpr_dprint_field(sc, MPR_EVENT, "ReasonCode: %s\n", 359199322Smav mpr_describe_table(mpr_sastopo_exp, data->ReasonCode)); 360199322Smav MPR_EVENTFIELD(sc, data, PhysicalPort, %d); 361199322Smav MPR_EVENTFIELD(sc, data, NumSlots, %d); 362199322Smav MPR_EVENTFIELD(sc, data, StartSlot, %d); 363199322Smav MPR_EVENTFIELD(sc, data, PhyBits, 0x%x); 364199322Smav break; 365199322Smav } 366199322Smav case MPI2_EVENT_SAS_DEVICE_STATUS_CHANGE: 367199322Smav { 368199322Smav MPI2_EVENT_DATA_SAS_DEVICE_STATUS_CHANGE *data; 369195534Sscottl 370199322Smav data = (MPI2_EVENT_DATA_SAS_DEVICE_STATUS_CHANGE *) 371199322Smav &event->EventData; 372199322Smav MPR_EVENTFIELD(sc, data, TaskTag, 0x%x); 373199322Smav mpr_dprint_field(sc, MPR_EVENT, "ReasonCode: %s\n", 374199322Smav mpr_describe_table(mpr_sasdev_reason, data->ReasonCode)); 375195534Sscottl MPR_EVENTFIELD(sc, data, ASC, 0x%x); 376195534Sscottl MPR_EVENTFIELD(sc, data, ASCQ, 0x%x); 377195534Sscottl MPR_EVENTFIELD(sc, data, DevHandle, 0x%x); 378195534Sscottl mpr_dprint_field(sc, MPR_EVENT, "SASAddress: 0x%jx\n", 379195534Sscottl mpr_to_u64(&data->SASAddress)); 380195534Sscottl } 381195534Sscottl default: 382196656Smav break; 383195534Sscottl } 384203123Smav} 385195534Sscottl 386195534Sscottlvoid 387196656Smavmpr_print_expander1(struct mpr_softc *sc, MPI2_CONFIG_PAGE_EXPANDER_1 *buf) 388195534Sscottl{ 389195534Sscottl MPR_PRINTFIELD_START(sc, "SAS Expander Page 1 #%d", buf->Phy); 390196656Smav MPR_PRINTFIELD(sc, buf, PhysicalPort, %d); 391203123Smav MPR_PRINTFIELD(sc, buf, NumPhys, %d); 392203123Smav MPR_PRINTFIELD(sc, buf, Phy, %d); 393203123Smav MPR_PRINTFIELD(sc, buf, NumTableEntriesProgrammed, %d); 394195534Sscottl mpr_dprint_field(sc, MPR_XINFO, "ProgrammedLinkRate: %s (0x%x)\n", 395195534Sscottl mpr_describe_table(mpr_linkrate_names, 396196656Smav (buf->ProgrammedLinkRate >> 4) & 0xf), buf->ProgrammedLinkRate); 397196656Smav mpr_dprint_field(sc, MPR_XINFO, "HwLinkRate: %s (0x%x)\n", 398196656Smav mpr_describe_table(mpr_linkrate_names, 399196656Smav (buf->HwLinkRate >> 4) & 0xf), buf->HwLinkRate); 400196656Smav MPR_PRINTFIELD(sc, buf, AttachedDevHandle, 0x%04x); 401196656Smav mpr_dprint_field(sc, MPR_XINFO, "PhyInfo Reason: %s (0x%x)\n", 402196656Smav mpr_describe_table(mpr_phyinfo_reason_names, 403196656Smav (buf->PhyInfo >> 16) & 0xf), buf->PhyInfo); 404195534Sscottl mpr_dprint_field(sc, MPR_XINFO, "AttachedDeviceInfo: %b,%s\n", 405195534Sscottl buf->AttachedDeviceInfo, "\20" "\4SATAhost" "\5SMPinit" "\6STPinit" 406195534Sscottl "\7SSPinit" "\10SATAdev" "\11SMPtarg" "\12STPtarg" "\13SSPtarg" 407196656Smav "\14Direct" "\15LSIdev" "\16ATAPIdev" "\17SEPdev", 408196656Smav mpr_describe_table(mpr_sasdev0_devtype, 409196656Smav buf->AttachedDeviceInfo & 0x03)); 410196656Smav MPR_PRINTFIELD(sc, buf, ExpanderDevHandle, 0x%04x); 411196656Smav MPR_PRINTFIELD(sc, buf, ChangeCount, %d); 412196656Smav mpr_dprint_field(sc, MPR_XINFO, "NegotiatedLinkRate: %s (0x%x)\n", 413196656Smav mpr_describe_table(mpr_linkrate_names, 414196656Smav buf->NegotiatedLinkRate & 0xf), buf->NegotiatedLinkRate); 415196656Smav MPR_PRINTFIELD(sc, buf, PhyIdentifier, %d); 416196656Smav MPR_PRINTFIELD(sc, buf, AttachedPhyIdentifier, %d); 417196656Smav MPR_PRINTFIELD(sc, buf, DiscoveryInfo, 0x%x); 418195534Sscottl MPR_PRINTFIELD(sc, buf, AttachedPhyInfo, 0x%x); 419196656Smav mpr_dprint_field(sc, MPR_XINFO, "AttachedPhyInfo Reason: %s (0x%x)\n", 420196656Smav mpr_describe_table(mpr_phyinfo_reason_names, 421196656Smav buf->AttachedPhyInfo & 0xf), buf->AttachedPhyInfo); 422196656Smav MPR_PRINTFIELD(sc, buf, ZoneGroup, %d); 423196656Smav MPR_PRINTFIELD(sc, buf, SelfConfigStatus, 0x%x); 424196656Smav} 425203108Smav 426203123Smavvoid 427203108Smavmpr_print_sasphy0(struct mpr_softc *sc, MPI2_CONFIG_PAGE_SAS_PHY_0 *buf) 428203108Smav{ 429203108Smav MPR_PRINTFIELD_START(sc, "SAS PHY Page 0"); 430203108Smav MPR_PRINTFIELD(sc, buf, OwnerDevHandle, 0x%04x); 431203108Smav MPR_PRINTFIELD(sc, buf, AttachedDevHandle, 0x%04x); 432203108Smav MPR_PRINTFIELD(sc, buf, AttachedPhyIdentifier, %d); 433203108Smav mpr_dprint_field(sc, MPR_XINFO, "AttachedPhyInfo Reason: %s (0x%x)\n", 434203108Smav mpr_describe_table(mpr_phyinfo_reason_names, 435203108Smav buf->AttachedPhyInfo & 0xf), buf->AttachedPhyInfo); 436195534Sscottl mpr_dprint_field(sc, MPR_XINFO, "ProgrammedLinkRate: %s (0x%x)\n", 437195534Sscottl mpr_describe_table(mpr_linkrate_names, 438195534Sscottl (buf->ProgrammedLinkRate >> 4) & 0xf), buf->ProgrammedLinkRate); 439195534Sscottl mpr_dprint_field(sc, MPR_XINFO, "HwLinkRate: %s (0x%x)\n", 440195534Sscottl mpr_describe_table(mpr_linkrate_names, 441195534Sscottl (buf->HwLinkRate >> 4) & 0xf), buf->HwLinkRate); 442195534Sscottl MPR_PRINTFIELD(sc, buf, ChangeCount, %d); 443195534Sscottl MPR_PRINTFIELD(sc, buf, Flags, 0x%x); 444195534Sscottl mpr_dprint_field(sc, MPR_XINFO, "PhyInfo Reason: %s (0x%x)\n", 445195534Sscottl mpr_describe_table(mpr_phyinfo_reason_names, 446195534Sscottl (buf->PhyInfo >> 16) & 0xf), buf->PhyInfo); 447195534Sscottl mpr_dprint_field(sc, MPR_XINFO, "NegotiatedLinkRate: %s (0x%x)\n", 448195534Sscottl mpr_describe_table(mpr_linkrate_names, 449195534Sscottl buf->NegotiatedLinkRate & 0xf), buf->NegotiatedLinkRate); 450195534Sscottl} 451195534Sscottl 452195534Sscottlvoid 453195534Sscottlmpr_print_sgl(struct mpr_softc *sc, struct mpr_command *cm, int offset) 454195534Sscottl{ 455195534Sscottl MPI2_IEEE_SGE_SIMPLE64 *ieee_sge; 456195534Sscottl MPI25_IEEE_SGE_CHAIN64 *ieee_sgc; 457195534Sscottl MPI2_SGE_SIMPLE64 *sge; 458195534Sscottl MPI2_REQUEST_HEADER *req; 459195534Sscottl struct mpr_chain *chain = NULL; 460195534Sscottl char *frame; 461195534Sscottl u_int i = 0, flags, length; 462195534Sscottl 463195534Sscottl req = (MPI2_REQUEST_HEADER *)cm->cm_req; 464195534Sscottl frame = (char *)cm->cm_req; 465195534Sscottl ieee_sge = (MPI2_IEEE_SGE_SIMPLE64 *)&frame[offset * 4]; 466195534Sscottl sge = (MPI2_SGE_SIMPLE64 *)&frame[offset * 4]; 467195534Sscottl printf("SGL for command %p\n", cm); 468195534Sscottl 469195534Sscottl hexdump(frame, 128, NULL, 0); 470195534Sscottl while ((frame != NULL) && (!(cm->cm_flags & MPR_CM_FLAGS_SGE_SIMPLE))) { 471195534Sscottl flags = ieee_sge->Flags; 472195534Sscottl length = le32toh(ieee_sge->Length); 473195534Sscottl printf("IEEE seg%d flags=0x%02x len=0x%08x addr=0x%016jx\n", i, 474195534Sscottl flags, length, mpr_to_u64(&ieee_sge->Address)); 475195534Sscottl if (flags & MPI25_IEEE_SGE_FLAGS_END_OF_LIST) 476195534Sscottl break; 477195534Sscottl ieee_sge++; 478195534Sscottl i++; 479195534Sscottl if (flags & MPI2_IEEE_SGE_FLAGS_CHAIN_ELEMENT) { 480195534Sscottl ieee_sgc = (MPI25_IEEE_SGE_CHAIN64 *)ieee_sge; 481195534Sscottl printf("IEEE chain flags=0x%x len=0x%x Offset=0x%x " 482195534Sscottl "Address=0x%016jx\n", ieee_sgc->Flags, 483195534Sscottl le32toh(ieee_sgc->Length), 484195534Sscottl ieee_sgc->NextChainOffset, 485195534Sscottl mpr_to_u64(&ieee_sgc->Address)); 486195534Sscottl if (chain == NULL) 487195534Sscottl chain = TAILQ_FIRST(&cm->cm_chain_list); 488195534Sscottl else 489195534Sscottl chain = TAILQ_NEXT(chain, chain_link); 490195534Sscottl frame = (char *)chain->chain; 491195534Sscottl ieee_sge = (MPI2_IEEE_SGE_SIMPLE64 *)frame; 492195534Sscottl hexdump(frame, 128, NULL, 0); 493195534Sscottl } 494195534Sscottl } 495195534Sscottl while ((frame != NULL) && (cm->cm_flags & MPR_CM_FLAGS_SGE_SIMPLE)) { 496195534Sscottl flags = le32toh(sge->FlagsLength) >> MPI2_SGE_FLAGS_SHIFT; 497195534Sscottl printf("seg%d flags=0x%02x len=0x%06x addr=0x%016jx\n", i, 498195534Sscottl flags, le32toh(sge->FlagsLength) & 0xffffff, 499195534Sscottl mpr_to_u64(&sge->Address)); 500195534Sscottl if (flags & (MPI2_SGE_FLAGS_END_OF_LIST | 501195534Sscottl MPI2_SGE_FLAGS_END_OF_BUFFER)) 502195534Sscottl break; 503195534Sscottl sge++; 504195534Sscottl i++; 505195534Sscottl } 506196656Smav} 507196656Smav 508196656Smavvoid 509196656Smavmpr_print_scsiio_cmd(struct mpr_softc *sc, struct mpr_command *cm) 510196656Smav{ 511196656Smav MPI2_SCSI_IO_REQUEST *req; 512196656Smav 513196656Smav req = (MPI2_SCSI_IO_REQUEST *)cm->cm_req; 514196656Smav mpr_print_sgl(sc, cm, req->SGLOffset0); 515196656Smav} 516196656Smav 517196656Smav