Overhaul error, information, and debug logging.

Obtained from:	Netflix
MFC after:	3 days
This commit is contained in:
Scott Long 2013-07-19 00:12:41 +00:00
parent dddb618e3f
commit 1610f95c56
8 changed files with 356 additions and 286 deletions

View File

@ -81,7 +81,8 @@ static int mps_transition_operational(struct mps_softc *sc);
static void mps_startup(void *arg);
static int mps_send_iocinit(struct mps_softc *sc);
static int mps_attach_log(struct mps_softc *sc);
static __inline void mps_complete_command(struct mps_command *cm);
static __inline void mps_complete_command(struct mps_softc *sc,
struct mps_command *cm);
static void mps_dispatch_event(struct mps_softc *sc, uintptr_t data,
MPI2_EVENT_NOTIFICATION_REPLY *reply);
static void mps_config_complete(struct mps_softc *sc, struct mps_command *cm);
@ -195,7 +196,7 @@ static int
mps_message_unit_reset(struct mps_softc *sc, int sleep_flag)
{
mps_dprint(sc, MPS_TRACE, "%s\n", __func__);
MPS_FUNCTRACE(sc);
mps_regwrite(sc, MPI2_DOORBELL_OFFSET,
MPI2_FUNCTION_IOC_MESSAGE_UNIT_RESET <<
@ -217,14 +218,14 @@ mps_transition_ready(struct mps_softc *sc)
int error, tries = 0;
int sleep_flags;
mps_dprint(sc, MPS_TRACE, "%s\n", __func__);
MPS_FUNCTRACE(sc);
/* If we are in attach call, do not sleep */
sleep_flags = (sc->mps_flags & MPS_FLAGS_ATTACH_DONE)
? CAN_SLEEP:NO_SLEEP;
error = 0;
while (tries++ < 5) {
reg = mps_regread(sc, MPI2_DOORBELL_OFFSET);
mps_dprint(sc, MPS_INFO, "Doorbell= 0x%x\n", reg);
mps_dprint(sc, MPS_INIT, "Doorbell= 0x%x\n", reg);
/*
* Ensure the IOC is ready to talk. If it's not, try
@ -250,7 +251,7 @@ mps_transition_ready(struct mps_softc *sc)
error = 0;
break;
} else if (state == MPI2_IOC_STATE_FAULT) {
mps_dprint(sc, MPS_INFO, "IOC in fault state 0x%x\n",
mps_dprint(sc, MPS_FAULT, "IOC in fault state 0x%x, resetting\n",
state & MPI2_DOORBELL_FAULT_CODE_MASK);
mps_diag_reset(sc, sleep_flags);
} else if (state == MPI2_IOC_STATE_OPERATIONAL) {
@ -283,11 +284,11 @@ mps_transition_operational(struct mps_softc *sc)
uint32_t reg, state;
int error;
mps_dprint(sc, MPS_TRACE, "%s\n", __func__);
MPS_FUNCTRACE(sc);
error = 0;
reg = mps_regread(sc, MPI2_DOORBELL_OFFSET);
mps_dprint(sc, MPS_INFO, "Doorbell= 0x%x\n", reg);
mps_dprint(sc, MPS_INIT, "Doorbell= 0x%x\n", reg);
state = reg & MPI2_IOC_STATE_MASK;
if (state != MPI2_IOC_STATE_READY) {
@ -318,25 +319,28 @@ mps_reinit(struct mps_softc *sc)
int error;
uint32_t db;
mps_printf(sc, "%s sc %p\n", __func__, sc);
MPS_FUNCTRACE(sc);
mtx_assert(&sc->mps_mtx, MA_OWNED);
if (sc->mps_flags & MPS_FLAGS_DIAGRESET) {
mps_printf(sc, "%s reset already in progress\n", __func__);
mps_dprint(sc, MPS_INIT, "%s reset already in progress\n",
__func__);
return 0;
}
mps_dprint(sc, MPS_INFO, "Reinitializing controller,\n");
/* make sure the completion callbacks can recognize they're getting
* a NULL cm_reply due to a reset.
*/
sc->mps_flags |= MPS_FLAGS_DIAGRESET;
mps_printf(sc, "%s mask interrupts\n", __func__);
mps_dprint(sc, MPS_INIT, "%s mask interrupts\n", __func__);
mps_mask_intr(sc);
error = mps_diag_reset(sc, CAN_SLEEP);
if (error != 0) {
/* XXXSL No need to panic here */
panic("%s hard reset failed with error %d\n",
__func__, error);
}
@ -354,6 +358,7 @@ mps_reinit(struct mps_softc *sc)
/* get the chip out of the reset state */
error = mps_transition_operational(sc);
if (error != 0)
/* XXXSL No need to panic here */
panic("%s transition operational failed with error %d\n",
__func__, error);
@ -368,14 +373,14 @@ mps_reinit(struct mps_softc *sc)
mps_regwrite(sc, MPI2_REPLY_POST_HOST_INDEX_OFFSET, sc->replypostindex);
db = mps_regread(sc, MPI2_DOORBELL_OFFSET);
mps_printf(sc, "%s doorbell 0x%08x\n", __func__, db);
mps_dprint(sc, MPS_INIT, "%s doorbell 0x%08x\n", __func__, db);
mps_printf(sc, "%s unmask interrupts post %u free %u\n", __func__,
sc->replypostindex, sc->replyfreeindex);
mps_dprint(sc, MPS_INIT, "%s unmask interrupts post %u free %u\n",
__func__, sc->replypostindex, sc->replyfreeindex);
mps_unmask_intr(sc);
mps_printf(sc, "%s restarting post %u free %u\n", __func__,
mps_dprint(sc, MPS_INIT, "%s restarting post %u free %u\n", __func__,
sc->replypostindex, sc->replyfreeindex);
/* restart will reload the event masks clobbered by the reset, and
@ -384,9 +389,8 @@ mps_reinit(struct mps_softc *sc)
mps_reregister_events(sc);
/* the end of discovery will release the simq, so we're done. */
mps_printf(sc, "%s finished sc %p post %u free %u\n",
__func__, sc,
sc->replypostindex, sc->replyfreeindex);
mps_dprint(sc, MPS_INFO, "%s finished sc %p post %u free %u\n",
__func__, sc, sc->replypostindex, sc->replyfreeindex);
sc->mps_flags &= ~MPS_FLAGS_DIAGRESET;
@ -411,7 +415,7 @@ mps_wait_db_ack(struct mps_softc *sc, int timeout, int sleep_flag)
do {
int_status = mps_regread(sc, MPI2_HOST_INTERRUPT_STATUS_OFFSET);
if (!(int_status & MPI2_HIS_SYS2IOC_DB_STATUS)) {
mps_dprint(sc, MPS_INFO,
mps_dprint(sc, MPS_INIT,
"%s: successfull count(%d), timeout(%d)\n",
__func__, count, timeout);
return 0;
@ -546,7 +550,7 @@ mps_request_sync(struct mps_softc *sc, void *req, MPI2_DEFAULT_REPLY *reply,
count = MIN((reply_sz / 4), ioc_sz) * 2;
if (count < ioc_sz * 2) {
residual = ioc_sz * 2 - count;
mps_dprint(sc, MPS_FAULT, "Driver error, throwing away %d "
mps_dprint(sc, MPS_ERROR, "Driver error, throwing away %d "
"residual message words\n", residual);
}
@ -592,7 +596,8 @@ static void
mps_enqueue_request(struct mps_softc *sc, struct mps_command *cm)
{
reply_descriptor rd;
mps_dprint(sc, MPS_TRACE, "%s SMID %u cm %p ccb %p\n", __func__,
MPS_FUNCTRACE(sc);
mps_dprint(sc, MPS_TRACE, "SMID %u cm %p ccb %p\n",
cm->cm_desc.Default.SMID, cm, cm->cm_ccb);
if (sc->mps_flags & MPS_FLAGS_ATTACH_DONE && !(sc->mps_flags & MPS_FLAGS_SHUTDOWN))
@ -620,7 +625,7 @@ mps_get_iocfacts(struct mps_softc *sc, MPI2_IOC_FACTS_REPLY *facts)
MPI2_IOC_FACTS_REQUEST request;
int error, req_sz, reply_sz;
mps_dprint(sc, MPS_TRACE, "%s\n", __func__);
MPS_FUNCTRACE(sc);
req_sz = sizeof(MPI2_IOC_FACTS_REQUEST);
reply_sz = sizeof(MPI2_IOC_FACTS_REPLY);
@ -641,7 +646,7 @@ mps_get_portfacts(struct mps_softc *sc, MPI2_PORT_FACTS_REPLY *facts, int port)
struct mps_command *cm;
int error;
mps_dprint(sc, MPS_TRACE, "%s\n", __func__);
MPS_FUNCTRACE(sc);
if ((cm = mps_alloc_command(sc)) == NULL)
return (EBUSY);
@ -677,7 +682,7 @@ mps_send_iocinit(struct mps_softc *sc)
MPI2_DEFAULT_REPLY reply;
int req_sz, reply_sz, error;
mps_dprint(sc, MPS_TRACE, "%s\n", __func__);
MPS_FUNCTRACE(sc);
req_sz = sizeof(MPI2_IOC_INIT_REQUEST);
reply_sz = sizeof(MPI2_IOC_INIT_REPLY);
@ -711,7 +716,7 @@ mps_send_iocinit(struct mps_softc *sc)
if ((reply.IOCStatus & MPI2_IOCSTATUS_MASK) != MPI2_IOCSTATUS_SUCCESS)
error = ENXIO;
mps_dprint(sc, MPS_INFO, "IOCInit status= 0x%x\n", reply.IOCStatus);
mps_dprint(sc, MPS_INIT, "IOCInit status= 0x%x\n", reply.IOCStatus);
return (error);
}
@ -1008,7 +1013,7 @@ mps_get_tunables(struct mps_softc *sc)
char tmpstr[80];
/* XXX default to some debugging for now */
sc->mps_debug = MPS_FAULT;
sc->mps_debug = MPS_INFO|MPS_FAULT;
sc->disable_msix = 0;
sc->disable_msi = 0;
sc->max_chains = MPS_CHAIN_FRAMES;
@ -1123,7 +1128,7 @@ mps_attach(struct mps_softc *sc)
mps_get_tunables(sc);
mps_dprint(sc, MPS_TRACE, "%s\n", __func__);
MPS_FUNCTRACE(sc);
mtx_init(&sc->mps_mtx, "MPT2SAS lock", NULL, MTX_DEF);
callout_init_mtx(&sc->periodic, &sc->mps_mtx, 0);
@ -1297,7 +1302,7 @@ mps_attach(struct mps_softc *sc)
sc->mps_ich.ich_func = mps_startup;
sc->mps_ich.ich_arg = sc;
if (config_intrhook_establish(&sc->mps_ich) != 0) {
mps_dprint(sc, MPS_FAULT, "Cannot establish MPS config hook\n");
mps_dprint(sc, MPS_ERROR, "Cannot establish MPS config hook\n");
error = EINVAL;
}
@ -1308,7 +1313,7 @@ mps_attach(struct mps_softc *sc)
mpssas_ir_shutdown, sc, SHUTDOWN_PRI_DEFAULT);
if (sc->shutdown_eh == NULL)
mps_dprint(sc, MPS_FAULT, "shutdown event registration "
mps_dprint(sc, MPS_ERROR, "shutdown event registration "
"failed\n");
mps_setup_sysctl(sc);
@ -1347,8 +1352,7 @@ mps_periodic(void *arg)
db = mps_regread(sc, MPI2_DOORBELL_OFFSET);
if ((db & MPI2_IOC_STATE_MASK) == MPI2_IOC_STATE_FAULT) {
device_printf(sc->mps_dev, "IOC Fault 0x%08x, Resetting\n", db);
mps_dprint(sc, MPS_FAULT, "IOC Fault 0x%08x, Resetting\n", db);
mps_reinit(sc);
}
@ -1365,12 +1369,13 @@ mps_log_evt_handler(struct mps_softc *sc, uintptr_t data,
switch (event->Event) {
case MPI2_EVENT_LOG_DATA:
device_printf(sc->mps_dev, "MPI2_EVENT_LOG_DATA:\n");
hexdump(event->EventData, event->EventDataLength, NULL, 0);
mps_dprint(sc, MPS_EVENT, "MPI2_EVENT_LOG_DATA:\n");
if (sc->mps_debug & MPS_EVENT)
hexdump(event->EventData, event->EventDataLength, NULL, 0);
break;
case MPI2_EVENT_LOG_ENTRY_ADDED:
entry = (MPI2_EVENT_DATA_LOG_ENTRY_ADDED *)event->EventData;
mps_dprint(sc, MPS_INFO, "MPI2_EVENT_LOG_ENTRY_ADDED event "
mps_dprint(sc, MPS_EVENT, "MPI2_EVENT_LOG_ENTRY_ADDED event "
"0x%x Sequence %d:\n", entry->LogEntryQualifier,
entry->LogSequence);
break;
@ -1504,29 +1509,35 @@ mps_free(struct mps_softc *sc)
}
static __inline void
mps_complete_command(struct mps_command *cm)
mps_complete_command(struct mps_softc *sc, struct mps_command *cm)
{
MPS_FUNCTRACE(sc);
if (cm == NULL) {
mps_dprint(sc, MPS_ERROR, "Completing NULL command\n");
return;
}
if (cm->cm_flags & MPS_CM_FLAGS_POLLED)
cm->cm_flags |= MPS_CM_FLAGS_COMPLETE;
if (cm->cm_complete != NULL) {
mps_dprint(cm->cm_sc, MPS_TRACE,
mps_dprint(sc, MPS_TRACE,
"%s cm %p calling cm_complete %p data %p reply %p\n",
__func__, cm, cm->cm_complete, cm->cm_complete_data,
cm->cm_reply);
cm->cm_complete(cm->cm_sc, cm);
cm->cm_complete(sc, cm);
}
if (cm->cm_flags & MPS_CM_FLAGS_WAKEUP) {
mps_dprint(cm->cm_sc, MPS_TRACE, "%s: waking up %p\n",
__func__, cm);
mps_dprint(sc, MPS_TRACE, "waking up %p\n", cm);
wakeup(cm);
}
if (cm->cm_sc->io_cmds_active != 0) {
cm->cm_sc->io_cmds_active--;
} else {
mps_dprint(cm->cm_sc, MPS_INFO, "Warning: io_cmds_active is "
mps_dprint(sc, MPS_ERROR, "Warning: io_cmds_active is "
"out of sync - resynching to 0\n");
}
}
@ -1572,7 +1583,7 @@ mps_sas_log_info(struct mps_softc *sc , u32 log_info)
break;
}
mps_dprint(sc, MPS_INFO, "log_info(0x%08x): originator(%s), "
mps_dprint(sc, MPS_LOG, "log_info(0x%08x): originator(%s), "
"code(0x%02x), sub_code(0x%04x)\n", log_info,
originator_str, sas_loginfo.dw.code,
sas_loginfo.dw.subcode);
@ -1750,7 +1761,7 @@ mps_intr_locked(void *data)
case MPI2_RPY_DESCRIPT_FLAGS_RAID_ACCELERATOR_SUCCESS:
default:
/* Unhandled */
device_printf(sc->mps_dev, "Unhandled reply 0x%x\n",
mps_dprint(sc, MPS_ERROR, "Unhandled reply 0x%x\n",
desc->Default.ReplyFlags);
cm = NULL;
break;
@ -1761,7 +1772,7 @@ mps_intr_locked(void *data)
// Print Error reply frame
if (cm->cm_reply)
mps_display_reply_info(sc,cm->cm_reply);
mps_complete_command(cm);
mps_complete_command(sc, cm);
}
desc->Words.Low = 0xffffffff;
@ -1794,7 +1805,7 @@ mps_dispatch_event(struct mps_softc *sc, uintptr_t data,
}
if (handled == 0)
device_printf(sc->mps_dev, "Unhandled event 0x%x\n", le16toh(event));
mps_dprint(sc, MPS_EVENT, "Unhandled event 0x%x\n", le16toh(event));
/*
* This is the only place that the event/reply should be freed.
@ -2197,7 +2208,8 @@ mps_data_cb(void *arg, bus_dma_segment_t *segs, int nsegs, int error)
* user they did the wrong thing.
*/
if ((cm->cm_max_segs != 0) && (nsegs > cm->cm_max_segs)) {
mps_printf(sc, "%s: warning: busdma returned %d segments, "
mps_dprint(sc, MPS_ERROR,
"%s: warning: busdma returned %d segments, "
"more than the %d allowed\n", __func__, nsegs,
cm->cm_max_segs);
}
@ -2243,9 +2255,10 @@ mps_data_cb(void *arg, bus_dma_segment_t *segs, int nsegs, int error)
sflags, nsegs - i);
if (error != 0) {
/* Resource shortage, roll back! */
mps_dprint(sc, MPS_INFO, "out of chain frames\n");
mps_dprint(sc, MPS_INFO, "Out of chain frames, "
"consider increasing hw.mps.max_chains.\n");
cm->cm_flags |= MPS_CM_FLAGS_CHAIN_FAILED;
mps_complete_command(cm);
mps_complete_command(sc, cm);
return;
}
}
@ -2444,6 +2457,7 @@ mps_config_complete(struct mps_softc *sc, struct mps_command *cm)
MPI2_CONFIG_REPLY *reply;
struct mps_config_params *params;
MPS_FUNCTRACE(sc);
params = cm->cm_complete_data;
if (cm->cm_data != NULL) {

View File

@ -927,8 +927,9 @@ _mapping_get_dev_info(struct mps_softc *sc,
sas_address = (sas_address << 32) |
sas_device_pg0.SASAddress.Low;
}
mps_dprint(sc, MPS_INFO, "SAS Address for SATA "
"device = %jx\n", sas_address);
mps_dprint(sc, MPS_MAPPING,
"SAS Address for SATA device = %jx\n",
sas_address);
} else {
sas_address =
sas_device_pg0.SASAddress.High;

View File

@ -198,11 +198,11 @@ mps_pci_attach(device_t dev)
pci_write_config(dev, PCIR_COMMAND, command, 2);
command = pci_read_config(dev, PCIR_COMMAND, 2);
if ((command & PCIM_CMD_BUSMASTEREN) == 0) {
device_printf(dev, "Cannot enable PCI busmaster\n");
mps_printf(sc, "Cannot enable PCI busmaster\n");
return (ENXIO);
}
if ((command & PCIM_CMD_MEMEN) == 0) {
device_printf(dev, "PCI memory window not available\n");
mps_printf(sc, "PCI memory window not available\n");
return (ENXIO);
}
@ -210,7 +210,7 @@ mps_pci_attach(device_t dev)
sc->mps_regs_rid = PCIR_BAR(1);
if ((sc->mps_regs_resource = bus_alloc_resource_any(dev,
SYS_RES_MEMORY, &sc->mps_regs_rid, RF_ACTIVE)) == NULL) {
device_printf(dev, "Cannot allocate PCI registers\n");
mps_printf(sc, "Cannot allocate PCI registers\n");
return (ENXIO);
}
sc->mps_btag = rman_get_bustag(sc->mps_regs_resource);
@ -228,7 +228,7 @@ mps_pci_attach(device_t dev)
0, /* flags */
NULL, NULL, /* lockfunc, lockarg */
&sc->mps_parent_dmat)) {
device_printf(dev, "Cannot allocate parent DMA tag\n");
mps_printf(sc, "Cannot allocate parent DMA tag\n");
mps_pci_free(sc);
return (ENOMEM);
}
@ -260,14 +260,14 @@ mps_pci_setup_interrupts(struct mps_softc *sc)
sc->mps_irq[0] = bus_alloc_resource_any(dev, SYS_RES_IRQ,
&sc->mps_irq_rid[0], RF_SHAREABLE | RF_ACTIVE);
if (sc->mps_irq[0] == NULL) {
device_printf(dev, "Cannot allocate INTx interrupt\n");
mps_printf(sc, "Cannot allocate INTx interrupt\n");
return (ENXIO);
}
error = bus_setup_intr(dev, sc->mps_irq[0],
INTR_TYPE_BIO | INTR_MPSAFE, NULL, mps_intr, sc,
&sc->mps_intrhand[0]);
if (error)
device_printf(dev, "Cannot setup INTx interrupt\n");
mps_printf(sc, "Cannot setup INTx interrupt\n");
} else {
sc->mps_flags |= MPS_FLAGS_MSI;
for (i = 0; i < MPS_MSI_COUNT; i++) {
@ -275,7 +275,7 @@ mps_pci_setup_interrupts(struct mps_softc *sc)
sc->mps_irq[i] = bus_alloc_resource_any(dev,
SYS_RES_IRQ, &sc->mps_irq_rid[i], RF_ACTIVE);
if (sc->mps_irq[i] == NULL) {
device_printf(dev,
mps_printf(sc,
"Cannot allocate MSI interrupt\n");
return (ENXIO);
}
@ -283,7 +283,7 @@ mps_pci_setup_interrupts(struct mps_softc *sc)
INTR_TYPE_BIO | INTR_MPSAFE, NULL, mps_intr_msi,
sc, &sc->mps_intrhand[i]);
if (error) {
device_printf(dev,
mps_printf(sc,
"Cannot setup MSI interrupt %d\n", i);
break;
}

File diff suppressed because it is too large Load Diff

View File

@ -191,7 +191,7 @@ mpssas_fw_work(struct mps_softc *sc, struct mps_fw_event_work *fw_event)
struct mpssas_softc *sassc;
sassc = sc->sassc;
mps_dprint(sc, MPS_INFO, "(%d)->(%s) Working on Event: [%x]\n",
mps_dprint(sc, MPS_EVENT, "(%d)->(%s) Working on Event: [%x]\n",
event_count++,__func__,fw_event->event);
switch (fw_event->event) {
case MPI2_EVENT_SAS_TOPOLOGY_CHANGE_LIST:
@ -374,24 +374,24 @@ mpssas_fw_work(struct mps_softc *sc, struct mps_fw_event_work *fw_event)
/*
* Informational only.
*/
mps_dprint(sc, MPS_INFO, "Received IR Volume event:\n");
mps_dprint(sc, MPS_EVENT, "Received IR Volume event:\n");
switch (event_data->ReasonCode) {
case MPI2_EVENT_IR_VOLUME_RC_SETTINGS_CHANGED:
mps_dprint(sc, MPS_INFO, " Volume Settings "
mps_dprint(sc, MPS_EVENT, " Volume Settings "
"changed from 0x%x to 0x%x for Volome with "
"handle 0x%x", le32toh(event_data->PreviousValue),
le32toh(event_data->NewValue),
le16toh(event_data->VolDevHandle));
break;
case MPI2_EVENT_IR_VOLUME_RC_STATUS_FLAGS_CHANGED:
mps_dprint(sc, MPS_INFO, " Volume Status "
mps_dprint(sc, MPS_EVENT, " Volume Status "
"changed from 0x%x to 0x%x for Volome with "
"handle 0x%x", le32toh(event_data->PreviousValue),
le32toh(event_data->NewValue),
le16toh(event_data->VolDevHandle));
break;
case MPI2_EVENT_IR_VOLUME_RC_STATE_CHANGED:
mps_dprint(sc, MPS_INFO, " Volume State "
mps_dprint(sc, MPS_EVENT, " Volume State "
"changed from 0x%x to 0x%x for Volome with "
"handle 0x%x", le32toh(event_data->PreviousValue),
le32toh(event_data->NewValue),
@ -440,10 +440,10 @@ mpssas_fw_work(struct mps_softc *sc, struct mps_fw_event_work *fw_event)
/*
* Informational only.
*/
mps_dprint(sc, MPS_INFO, "Received IR Phys Disk event:\n");
mps_dprint(sc, MPS_EVENT, "Received IR Phys Disk event:\n");
switch (event_data->ReasonCode) {
case MPI2_EVENT_IR_PHYSDISK_RC_SETTINGS_CHANGED:
mps_dprint(sc, MPS_INFO, " Phys Disk Settings "
mps_dprint(sc, MPS_EVENT, " Phys Disk Settings "
"changed from 0x%x to 0x%x for Phys Disk Number "
"%d and handle 0x%x at Enclosure handle 0x%x, Slot "
"%d", le32toh(event_data->PreviousValue),
@ -453,7 +453,7 @@ mpssas_fw_work(struct mps_softc *sc, struct mps_fw_event_work *fw_event)
le16toh(event_data->EnclosureHandle), le16toh(event_data->Slot));
break;
case MPI2_EVENT_IR_PHYSDISK_RC_STATUS_FLAGS_CHANGED:
mps_dprint(sc, MPS_INFO, " Phys Disk Status changed "
mps_dprint(sc, MPS_EVENT, " Phys Disk Status changed "
"from 0x%x to 0x%x for Phys Disk Number %d and "
"handle 0x%x at Enclosure handle 0x%x, Slot %d",
le32toh(event_data->PreviousValue),
@ -462,7 +462,7 @@ mpssas_fw_work(struct mps_softc *sc, struct mps_fw_event_work *fw_event)
le16toh(event_data->EnclosureHandle), le16toh(event_data->Slot));
break;
case MPI2_EVENT_IR_PHYSDISK_RC_STATE_CHANGED:
mps_dprint(sc, MPS_INFO, " Phys Disk State changed "
mps_dprint(sc, MPS_EVENT, " Phys Disk State changed "
"from 0x%x to 0x%x for Phys Disk Number %d and "
"handle 0x%x at Enclosure handle 0x%x, Slot %d",
le32toh(event_data->PreviousValue),
@ -518,8 +518,8 @@ mpssas_fw_work(struct mps_softc *sc, struct mps_fw_event_work *fw_event)
/*
* Informational only.
*/
mps_dprint(sc, MPS_INFO, "Received IR Op Status event:\n");
mps_dprint(sc, MPS_INFO, " RAID Operation of %d is %d "
mps_dprint(sc, MPS_EVENT, "Received IR Op Status event:\n");
mps_dprint(sc, MPS_EVENT, " RAID Operation of %d is %d "
"percent complete for Volume with handle 0x%x",
event_data->RAIDOperation, event_data->PercentComplete,
le16toh(event_data->VolDevHandle));
@ -577,7 +577,7 @@ mpssas_fw_work(struct mps_softc *sc, struct mps_fw_event_work *fw_event)
break;
}
mps_dprint(sc, MPS_INFO, "(%d)->(%s) Event Free: [%x]\n",event_count,__func__, fw_event->event);
mps_dprint(sc, MPS_EVENT, "(%d)->(%s) Event Free: [%x]\n",event_count,__func__, fw_event->event);
mpssas_fw_event_free(sc, fw_event);
}
@ -669,7 +669,7 @@ mpssas_add_device(struct mps_softc *sc, u16 handle, u8 linkrate){
error = ENXIO;
goto out;
}
mps_dprint(sc, MPS_INFO, "SAS Address from SAS device page0 = %jx\n",
mps_dprint(sc, MPS_MAPPING, "SAS Address from SAS device page0 = %jx\n",
sas_address);
targ = &sassc->targets[id];
targ->devinfo = device_info;
@ -696,12 +696,12 @@ mpssas_add_device(struct mps_softc *sc, u16 handle, u8 linkrate){
SLIST_INIT(&targ->luns);
mps_describe_devinfo(targ->devinfo, devstring, 80);
mps_dprint(sc, MPS_INFO, "Found device <%s> <%s> <0x%04x> <%d/%d>\n", devstring,
mps_dprint(sc, MPS_MAPPING, "Found device <%s> <%s> <0x%04x> <%d/%d>\n", devstring,
mps_describe_table(mps_linkrate_names, targ->linkrate),
targ->handle, targ->encl_handle, targ->encl_slot);
if ((sassc->flags & MPSSAS_IN_STARTUP) == 0)
mpssas_rescan_target(sc, targ);
mps_dprint(sc, MPS_INFO, "Target id 0x%x added\n", targ->tid);
mps_dprint(sc, MPS_MAPPING, "Target id 0x%x added\n", targ->tid);
out:
mpssas_startup_decrement(sassc);
return (error);
@ -734,11 +734,11 @@ mpssas_get_sas_address_for_sata_disk(struct mps_softc *sc,
(try_count < 5));
if (rc == 0 && !ioc_status && !sas_status) {
mps_dprint(sc, MPS_INFO, "%s: got SATA identify successfully "
mps_dprint(sc, MPS_MAPPING, "%s: got SATA identify successfully "
"for handle = 0x%x with try_count = %d\n",
__func__, handle, try_count);
} else {
mps_dprint(sc, MPS_INFO, "%s: handle = 0x%x failed\n",
mps_dprint(sc, MPS_MAPPING, "%s: handle = 0x%x failed\n",
__func__, handle);
return -1;
}
@ -887,7 +887,7 @@ mpssas_volume_add(struct mps_softc *sc, u16 handle)
SLIST_INIT(&targ->luns);
if ((sassc->flags & MPSSAS_IN_STARTUP) == 0)
mpssas_rescan_target(sc, targ);
mps_dprint(sc, MPS_INFO, "RAID target id %d added (WWID = 0x%jx)\n",
mps_dprint(sc, MPS_MAPPING, "RAID target id %d added (WWID = 0x%jx)\n",
targ->tid, wwid);
out:
mpssas_startup_decrement(sassc);

View File

@ -205,17 +205,17 @@ mps_print_iocfacts(struct mps_softc *sc, MPI2_IOC_FACTS_REPLY *facts)
MPS_PRINTFIELD(sc, facts, IOCNumber, %d);
MPS_PRINTFIELD(sc, facts, IOCExceptions, 0x%x);
MPS_PRINTFIELD(sc, facts, MaxChainDepth, %d);
mps_dprint_field(sc, MPS_INFO, "WhoInit: %s\n",
mps_dprint_field(sc, MPS_XINFO, "WhoInit: %s\n",
mps_describe_table(mps_whoinit_names, facts->WhoInit));
MPS_PRINTFIELD(sc, facts, NumberOfPorts, %d);
MPS_PRINTFIELD(sc, facts, RequestCredit, %d);
MPS_PRINTFIELD(sc, facts, ProductID, 0x%x);
mps_dprint_field(sc, MPS_INFO, "IOCCapabilities: %b\n",
mps_dprint_field(sc, MPS_XINFO, "IOCCapabilities: %b\n",
facts->IOCCapabilities, "\20" "\3ScsiTaskFull" "\4DiagTrace"
"\5SnapBuf" "\6ExtBuf" "\7EEDP" "\10BiDirTarg" "\11Multicast"
"\14TransRetry" "\15IR" "\16EventReplay" "\17RaidAccel"
"\20MSIXIndex" "\21HostDisc");
mps_dprint_field(sc, MPS_INFO, "FWVersion= %d-%d-%d-%d\n",
mps_dprint_field(sc, MPS_XINFO, "FWVersion= %d-%d-%d-%d\n",
facts->FWVersion.Struct.Major,
facts->FWVersion.Struct.Minor,
facts->FWVersion.Struct.Unit,
@ -225,7 +225,7 @@ mps_print_iocfacts(struct mps_softc *sc, MPI2_IOC_FACTS_REPLY *facts)
MPS_PRINTFIELD(sc, facts, MaxTargets, %d);
MPS_PRINTFIELD(sc, facts, MaxSasExpanders, %d);
MPS_PRINTFIELD(sc, facts, MaxEnclosures, %d);
mps_dprint_field(sc, MPS_INFO, "ProtocolFlags: %b\n",
mps_dprint_field(sc, MPS_XINFO, "ProtocolFlags: %b\n",
facts->ProtocolFlags, "\20" "\1ScsiTarg" "\2ScsiInit");
MPS_PRINTFIELD(sc, facts, HighPriorityCredit, %d);
MPS_PRINTFIELD(sc, facts, MaxReplyDescriptorPostQueueDepth, %d);
@ -263,7 +263,7 @@ mps_print_sasdev0(struct mps_softc *sc, MPI2_CONFIG_PAGE_SAS_DEV_0 *buf)
MPS_PRINTFIELD_START(sc, "SAS Device Page 0");
MPS_PRINTFIELD(sc, buf, Slot, %d);
MPS_PRINTFIELD(sc, buf, EnclosureHandle, 0x%x);
mps_dprint_field(sc, MPS_INFO, "SASAddress: 0x%jx\n",
mps_dprint_field(sc, MPS_XINFO, "SASAddress: 0x%jx\n",
mps_to_u64(&buf->SASAddress));
MPS_PRINTFIELD(sc, buf, ParentDevHandle, 0x%x);
MPS_PRINTFIELD(sc, buf, PhyNum, %d);
@ -271,7 +271,7 @@ mps_print_sasdev0(struct mps_softc *sc, MPI2_CONFIG_PAGE_SAS_DEV_0 *buf)
MPS_PRINTFIELD(sc, buf, DevHandle, 0x%x);
MPS_PRINTFIELD(sc, buf, AttachedPhyIdentifier, 0x%x);
MPS_PRINTFIELD(sc, buf, ZoneGroup, %d);
mps_dprint_field(sc, MPS_INFO, "DeviceInfo: %b,%s\n", buf->DeviceInfo,
mps_dprint_field(sc, MPS_XINFO, "DeviceInfo: %b,%s\n", buf->DeviceInfo,
"\20" "\4SataHost" "\5SmpInit" "\6StpInit" "\7SspInit"
"\10SataDev" "\11SmpTarg" "\12StpTarg" "\13SspTarg" "\14Direct"
"\15LsiDev" "\16AtapiDev" "\17SepDev",
@ -279,7 +279,7 @@ mps_print_sasdev0(struct mps_softc *sc, MPI2_CONFIG_PAGE_SAS_DEV_0 *buf)
MPS_PRINTFIELD(sc, buf, Flags, 0x%x);
MPS_PRINTFIELD(sc, buf, PhysicalPort, %d);
MPS_PRINTFIELD(sc, buf, MaxPortConnections, %d);
mps_dprint_field(sc, MPS_INFO, "DeviceName: 0x%jx\n",
mps_dprint_field(sc, MPS_XINFO, "DeviceName: 0x%jx\n",
mps_to_u64(&buf->DeviceName));
MPS_PRINTFIELD(sc, buf, PortGroups, %d);
MPS_PRINTFIELD(sc, buf, DmaGroup, %d);
@ -390,17 +390,17 @@ mps_print_expander1(struct mps_softc *sc, MPI2_CONFIG_PAGE_EXPANDER_1 *buf)
MPS_PRINTFIELD(sc, buf, NumPhys, %d);
MPS_PRINTFIELD(sc, buf, Phy, %d);
MPS_PRINTFIELD(sc, buf, NumTableEntriesProgrammed, %d);
mps_dprint_field(sc, MPS_INFO, "ProgrammedLinkRate: %s (0x%x)\n",
mps_dprint_field(sc, MPS_XINFO, "ProgrammedLinkRate: %s (0x%x)\n",
mps_describe_table(mps_linkrate_names,
(buf->ProgrammedLinkRate >> 4) & 0xf), buf->ProgrammedLinkRate);
mps_dprint_field(sc, MPS_INFO, "HwLinkRate: %s (0x%x)\n",
mps_dprint_field(sc, MPS_XINFO, "HwLinkRate: %s (0x%x)\n",
mps_describe_table(mps_linkrate_names,
(buf->HwLinkRate >> 4) & 0xf), buf->HwLinkRate);
MPS_PRINTFIELD(sc, buf, AttachedDevHandle, 0x%04x);
mps_dprint_field(sc, MPS_INFO, "PhyInfo Reason: %s (0x%x)\n",
mps_dprint_field(sc, MPS_XINFO, "PhyInfo Reason: %s (0x%x)\n",
mps_describe_table(mps_phyinfo_reason_names,
(buf->PhyInfo >> 16) & 0xf), buf->PhyInfo);
mps_dprint_field(sc, MPS_INFO, "AttachedDeviceInfo: %b,%s\n",
mps_dprint_field(sc, MPS_XINFO, "AttachedDeviceInfo: %b,%s\n",
buf->AttachedDeviceInfo, "\20" "\4SATAhost" "\5SMPinit" "\6STPinit"
"\7SSPinit" "\10SATAdev" "\11SMPtarg" "\12STPtarg" "\13SSPtarg"
"\14Direct" "\15LSIdev" "\16ATAPIdev" "\17SEPdev",
@ -408,14 +408,14 @@ mps_print_expander1(struct mps_softc *sc, MPI2_CONFIG_PAGE_EXPANDER_1 *buf)
buf->AttachedDeviceInfo & 0x03));
MPS_PRINTFIELD(sc, buf, ExpanderDevHandle, 0x%04x);
MPS_PRINTFIELD(sc, buf, ChangeCount, %d);
mps_dprint_field(sc, MPS_INFO, "NegotiatedLinkRate: %s (0x%x)\n",
mps_dprint_field(sc, MPS_XINFO, "NegotiatedLinkRate: %s (0x%x)\n",
mps_describe_table(mps_linkrate_names,
buf->NegotiatedLinkRate & 0xf), buf->NegotiatedLinkRate);
MPS_PRINTFIELD(sc, buf, PhyIdentifier, %d);
MPS_PRINTFIELD(sc, buf, AttachedPhyIdentifier, %d);
MPS_PRINTFIELD(sc, buf, DiscoveryInfo, 0x%x);
MPS_PRINTFIELD(sc, buf, AttachedPhyInfo, 0x%x);
mps_dprint_field(sc, MPS_INFO, "AttachedPhyInfo Reason: %s (0x%x)\n",
mps_dprint_field(sc, MPS_XINFO, "AttachedPhyInfo Reason: %s (0x%x)\n",
mps_describe_table(mps_phyinfo_reason_names,
buf->AttachedPhyInfo & 0xf), buf->AttachedPhyInfo);
MPS_PRINTFIELD(sc, buf, ZoneGroup, %d);
@ -429,21 +429,21 @@ mps_print_sasphy0(struct mps_softc *sc, MPI2_CONFIG_PAGE_SAS_PHY_0 *buf)
MPS_PRINTFIELD(sc, buf, OwnerDevHandle, 0x%04x);
MPS_PRINTFIELD(sc, buf, AttachedDevHandle, 0x%04x);
MPS_PRINTFIELD(sc, buf, AttachedPhyIdentifier, %d);
mps_dprint_field(sc, MPS_INFO, "AttachedPhyInfo Reason: %s (0x%x)\n",
mps_dprint_field(sc, MPS_XINFO, "AttachedPhyInfo Reason: %s (0x%x)\n",
mps_describe_table(mps_phyinfo_reason_names,
buf->AttachedPhyInfo & 0xf), buf->AttachedPhyInfo);
mps_dprint_field(sc, MPS_INFO, "ProgrammedLinkRate: %s (0x%x)\n",
mps_dprint_field(sc, MPS_XINFO, "ProgrammedLinkRate: %s (0x%x)\n",
mps_describe_table(mps_linkrate_names,
(buf->ProgrammedLinkRate >> 4) & 0xf), buf->ProgrammedLinkRate);
mps_dprint_field(sc, MPS_INFO, "HwLinkRate: %s (0x%x)\n",
mps_dprint_field(sc, MPS_XINFO, "HwLinkRate: %s (0x%x)\n",
mps_describe_table(mps_linkrate_names,
(buf->HwLinkRate >> 4) & 0xf), buf->HwLinkRate);
MPS_PRINTFIELD(sc, buf, ChangeCount, %d);
MPS_PRINTFIELD(sc, buf, Flags, 0x%x);
mps_dprint_field(sc, MPS_INFO, "PhyInfo Reason: %s (0x%x)\n",
mps_dprint_field(sc, MPS_XINFO, "PhyInfo Reason: %s (0x%x)\n",
mps_describe_table(mps_phyinfo_reason_names,
(buf->PhyInfo >> 16) & 0xf), buf->PhyInfo);
mps_dprint_field(sc, MPS_INFO, "NegotiatedLinkRate: %s (0x%x)\n",
mps_dprint_field(sc, MPS_XINFO, "NegotiatedLinkRate: %s (0x%x)\n",
mps_describe_table(mps_linkrate_names,
buf->NegotiatedLinkRate & 0xf), buf->NegotiatedLinkRate);
}

View File

@ -677,7 +677,7 @@ mps_user_command(struct mps_softc *sc, struct mps_usr_command *cmd)
hdr = (MPI2_REQUEST_HEADER *)cm->cm_req;
mps_dprint(sc, MPS_INFO, "mps_user_command: req %p %d rpl %p %d\n",
mps_dprint(sc, MPS_USER, "mps_user_command: req %p %d rpl %p %d\n",
cmd->req, cmd->req_len, cmd->rpl, cmd->rpl_len );
if (cmd->req_len > (int)sc->facts->IOCRequestFrameSize * 4) {
@ -688,7 +688,7 @@ mps_user_command(struct mps_softc *sc, struct mps_usr_command *cmd)
if (err != 0)
goto RetFreeUnlocked;
mps_dprint(sc, MPS_INFO, "mps_user_command: Function %02X "
mps_dprint(sc, MPS_USER, "mps_user_command: Function %02X "
"MsgFlags %02X\n", hdr->Function, hdr->MsgFlags );
if (cmd->len > 0) {
@ -742,7 +742,7 @@ mps_user_command(struct mps_softc *sc, struct mps_usr_command *cmd)
copyout(rpl, cmd->rpl, sz);
if (buf != NULL)
copyout(buf, cmd->buf, cmd->len);
mps_dprint(sc, MPS_INFO, "mps_user_command: reply size %d\n", sz );
mps_dprint(sc, MPS_USER, "mps_user_command: reply size %d\n", sz );
RetFreeUnlocked:
mps_lock(sc);
@ -771,7 +771,7 @@ mps_user_pass_thru(struct mps_softc *sc, mps_pass_thru_t *data)
*/
mps_lock(sc);
if (sc->mps_flags & MPS_FLAGS_BUSY) {
mps_dprint(sc, MPS_INFO, "%s: Only one passthru command "
mps_dprint(sc, MPS_USER, "%s: Only one passthru command "
"allowed at a single time.", __func__);
mps_unlock(sc);
return (EBUSY);
@ -803,7 +803,7 @@ mps_user_pass_thru(struct mps_softc *sc, mps_pass_thru_t *data)
} else
return (EINVAL);
mps_dprint(sc, MPS_INFO, "%s: req 0x%jx %d rpl 0x%jx %d "
mps_dprint(sc, MPS_USER, "%s: req 0x%jx %d rpl 0x%jx %d "
"data in 0x%jx %d data out 0x%jx %d data dir %d\n", __func__,
data->PtrRequest, data->RequestSize, data->PtrReply,
data->ReplySize, data->PtrData, data->DataSize,
@ -823,7 +823,7 @@ mps_user_pass_thru(struct mps_softc *sc, mps_pass_thru_t *data)
}
function = tmphdr.Function;
mps_dprint(sc, MPS_INFO, "%s: Function %02X MsgFlags %02X\n", __func__,
mps_dprint(sc, MPS_USER, "%s: Function %02X MsgFlags %02X\n", __func__,
function, tmphdr.MsgFlags);
/*
@ -1252,7 +1252,7 @@ mps_release_fw_diag_buffer(struct mps_softc *sc,
*/
*return_code = MPS_FW_DIAG_ERROR_RELEASE_FAILED;
if (!pBuffer->enabled) {
mps_dprint(sc, MPS_INFO, "%s: This buffer type is not supported "
mps_dprint(sc, MPS_USER, "%s: This buffer type is not supported "
"by the IOC", __func__);
return (MPS_DIAG_FAILURE);
}
@ -1795,7 +1795,7 @@ mps_user_diag_action(struct mps_softc *sc, mps_diag_action_t *data)
* Only allow one diag action at one time.
*/
if (sc->mps_flags & MPS_FLAGS_BUSY) {
mps_dprint(sc, MPS_INFO, "%s: Only one FW diag command "
mps_dprint(sc, MPS_USER, "%s: Only one FW diag command "
"allowed at a single time.", __func__);
return (EBUSY);
}
@ -1982,7 +1982,7 @@ mps_user_reg_access(struct mps_softc *sc, mps_reg_access_t *data)
*/
case REG_IO_READ:
case REG_IO_WRITE:
mps_dprint(sc, MPS_INFO, "IO access is not supported. "
mps_dprint(sc, MPS_USER, "IO access is not supported. "
"Use memory access.");
status = EINVAL;
break;
@ -2170,7 +2170,7 @@ mps_ioctl(struct cdev *dev, u_long cmd, void *arg, int flag,
printf("Port Enable did not complete after Diag "
"Reset msleep error %d.\n", msleep_ret);
else
mps_dprint(sc, MPS_INFO,
mps_dprint(sc, MPS_USER,
"Hard Reset with Port Enable completed in %d seconds.\n",
(uint32_t) (time_uptime - reinit_start));
break;

View File

@ -581,11 +581,17 @@ mps_unlock(struct mps_softc *sc)
mtx_unlock(&sc->mps_mtx);
}
#define MPS_INFO (1 << 0)
#define MPS_TRACE (1 << 1)
#define MPS_FAULT (1 << 2)
#define MPS_EVENT (1 << 3)
#define MPS_LOG (1 << 4)
#define MPS_INFO (1 << 0) /* Basic info */
#define MPS_FAULT (1 << 1) /* Hardware faults */
#define MPS_EVENT (1 << 2) /* Event data from the controller */
#define MPS_LOG (1 << 3) /* Log data from the controller */
#define MPS_RECOVERY (1 << 4) /* Command error recovery tracing */
#define MPS_ERROR (1 << 5) /* Parameter errors, programming bugs */
#define MPS_INIT (1 << 6) /* Things related to system init */
#define MPS_XINFO (1 << 7) /* More detailed/noisy info */
#define MPS_USER (1 << 8) /* Trace user-generated commands */
#define MPS_MAPPING (1 << 9) /* Trace device mappings */
#define MPS_TRACE (1 << 10) /* Function-by-function trace */
#define mps_printf(sc, args...) \
device_printf((sc)->mps_dev, ##args)
@ -598,23 +604,23 @@ do { \
#define mps_dprint(sc, level, msg, args...) \
do { \
if (sc->mps_debug & level) \
device_printf(sc->mps_dev, msg, ##args); \
if ((sc)->mps_debug & (level)) \
device_printf((sc)->mps_dev, msg, ##args); \
} while (0)
#define mps_dprint_field(sc, level, msg, args...) \
do { \
if (sc->mps_debug & level) \
if ((sc)->mps_debug & (level)) \
printf("\t" msg, ##args); \
} while (0)
#define MPS_PRINTFIELD_START(sc, tag...) \
mps_dprint((sc), MPS_INFO, ##tag); \
mps_dprint_field((sc), MPS_INFO, ":\n")
mps_dprint((sc), MPS_XINFO, ##tag); \
mps_dprint_field((sc), MPS_XINFO, ":\n")
#define MPS_PRINTFIELD_END(sc, tag) \
mps_dprint((sc), MPS_INFO, tag "\n")
mps_dprint((sc), MPS_XINFO, tag "\n")
#define MPS_PRINTFIELD(sc, facts, attr, fmt) \
mps_dprint_field((sc), MPS_INFO, #attr ": " #fmt "\n", (facts)->attr)
mps_dprint_field((sc), MPS_XINFO, #attr ": " #fmt "\n", (facts)->attr)
#define MPS_EVENTFIELD_START(sc, tag...) \
mps_dprint((sc), MPS_EVENT, ##tag); \
@ -622,6 +628,9 @@ do { \
#define MPS_EVENTFIELD(sc, facts, attr, fmt) \
mps_dprint_field((sc), MPS_EVENT, #attr ": " #fmt "\n", (facts)->attr)
#define MPS_FUNCTRACE(sc) \
mps_dprint((sc), MPS_TRACE, "%s\n", __func__)
#define CAN_SLEEP 1
#define NO_SLEEP 0