diff options
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/ic/mpt.c | 425 | ||||
-rw-r--r-- | sys/dev/ic/mpt.h | 27 | ||||
-rw-r--r-- | sys/dev/ic/mpt_debug.c | 4 | ||||
-rw-r--r-- | sys/dev/ic/mpt_openbsd.c | 89 | ||||
-rw-r--r-- | sys/dev/ic/mpt_openbsd.h | 3 | ||||
-rw-r--r-- | sys/dev/pci/mpt_pci.c | 8 |
6 files changed, 273 insertions, 283 deletions
diff --git a/sys/dev/ic/mpt.c b/sys/dev/ic/mpt.c index 054af56fadc..1fa7631297f 100644 --- a/sys/dev/ic/mpt.c +++ b/sys/dev/ic/mpt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mpt.c,v 1.21 2005/12/10 11:45:43 miod Exp $ */ +/* $OpenBSD: mpt.c,v 1.22 2006/02/04 19:05:00 marco Exp $ */ /* $NetBSD: mpt.c,v 1.4 2003/11/02 11:07:45 wiz Exp $ */ /* @@ -46,9 +46,13 @@ #define MPT_MAX_TRIES 3 #define MPT_MAX_WAIT 300000 -static int maxwait_ack = 0; -static int maxwait_int = 0; -static int maxwait_state = 0; +static int maxwait_ack = 0; +static int maxwait_int = 0; +static int maxwait_state = 0; + +#ifdef MPT_DEBUG +int mpt_debug = 11; +#endif /* MPT_DEBUG */ __inline u_int32_t mpt_rd_db(struct mpt_softc *); __inline u_int32_t mpt_rd_intr(struct mpt_softc *); @@ -157,9 +161,7 @@ mpt_wait_state(struct mpt_softc *mpt, enum DB_STATE_BITS state) int mpt_soft_reset(struct mpt_softc *mpt) { - if (mpt->verbose) { - mpt_prt(mpt, "soft reset"); - } + DNPRINTF(10, "soft reset\n"); /* Have to use hard reset if we are not in Running state */ if (MPT_STATE(mpt_rd_db(mpt)) != MPT_DB_STATE_RUNNING) { @@ -205,9 +207,7 @@ mpt_hard_reset(struct mpt_softc *mpt) /* This extra read comes for the Linux source * released by LSI. It's function is undocumented! */ - if (mpt->verbose) { - mpt_prt(mpt, "hard reset"); - } + DNPRINTF(10, "hard reset\n"); mpt_read(mpt, MPT_OFFSET_FUBAR); /* Enable diagnostic registers */ @@ -342,20 +342,20 @@ void mpt_send_cmd(struct mpt_softc *mpt, struct req_entry *req) { req->sequence = mpt->sequence++; - if (mpt->verbose > 1) { - u_int32_t *pReq; - pReq = req->req_vbuf; - mpt_prt(mpt, "Send Request %d (0x%x):", - req->index, req->req_pbuf); - mpt_prt(mpt, "%08x %08x %08x %08x", - pReq[0], pReq[1], pReq[2], pReq[3]); - mpt_prt(mpt, "%08x %08x %08x %08x", - pReq[4], pReq[5], pReq[6], pReq[7]); - mpt_prt(mpt, "%08x %08x %08x %08x", - pReq[8], pReq[9], pReq[10], pReq[11]); - mpt_prt(mpt, "%08x %08x %08x %08x", - pReq[12], pReq[13], pReq[14], pReq[15]); - } + u_int32_t *pReq; + + pReq = req->req_vbuf; + DNPRINTF(50, "%s: Send Request %d (0x%x):\n", + DEVNAME(mpt), req->index, req->req_pbuf); + DNPRINTF(50, "%s: %08x %08x %08x %08x\n", + DEVNAME(mpt), pReq[0], pReq[1], pReq[2], pReq[3]); + DNPRINTF(50, "%s: %08x %08x %08x %08x\n", + DEVNAME(mpt), pReq[4], pReq[5], pReq[6], pReq[7]); + DNPRINTF(50, "%s: %08x %08x %08x %08x\n", + DEVNAME(mpt), pReq[8], pReq[9], pReq[10], pReq[11]); + DNPRINTF(50, "%s: %08x %08x %08x %08x\n", + DEVNAME(mpt), pReq[12], pReq[13], pReq[14], pReq[15]); + MPT_SYNC_REQ(mpt, req, BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE); req->debug = REQ_ON_CHIP; mpt_write(mpt, MPT_OFFSET_REQUEST_Q, (u_int32_t) req->req_pbuf); @@ -397,7 +397,9 @@ mpt_send_handshake_cmd(struct mpt_softc *mpt, size_t len, void *cmd) (MPT_STATE(data) != MPT_DB_STATE_FAULT)) || (MPT_DB_IS_IN_USE(data))) { mpt_prt(mpt, "handshake aborted due to invalid doorbell state"); +#ifdef MPT_DEBUG mpt_print_db(data); +#endif /* MPT_DEBUG */ return(EBUSY); } @@ -473,12 +475,14 @@ mpt_recv_handshake_reply(struct mpt_softc *mpt, size_t reply_len, void *reply) *data16++ = mpt_read(mpt, MPT_OFFSET_DOORBELL) & MPT_DB_DATA_MASK; mpt_write(mpt, MPT_OFFSET_INTR_STATUS, 0); +#ifdef MPT_DEBUG /* With the second word, we can now look at the length */ - if (mpt->verbose > 1 && ((reply_len >> 1) != hdr->MsgLength)) { - mpt_prt(mpt, "reply length does not match message length: " - "got 0x%02x, expected 0x%02x", - hdr->MsgLength << 2, reply_len << 1); - } + if ((reply_len >> 1) != hdr->MsgLength) + /* XXX don't remove brackets! */ + DNPRINTF(50, "%s: reply length does not match message length: " + "got 0x%02x, expected 0x%02x\n", + DEVNAME(mpt), hdr->MsgLength << 2, reply_len << 1); +#endif /* MPT_DEBUG */ /* Get rest of the reply; but don't overflow the provided buffer */ left = (hdr->MsgLength << 1) - 2; @@ -506,8 +510,10 @@ mpt_recv_handshake_reply(struct mpt_softc *mpt, size_t reply_len, void *reply) mpt_write(mpt, MPT_OFFSET_INTR_STATUS, 0); if ((hdr->IOCStatus & MPI_IOCSTATUS_MASK) != MPI_IOCSTATUS_SUCCESS) { - if (mpt->verbose > 1) +#ifdef MPT_DEBUG + if (mpt_debug > 50) mpt_print_reply(hdr); +#endif return (MPT_FAIL | hdr->IOCStatus); } @@ -587,10 +593,9 @@ mpt_send_ioc_init(struct mpt_softc *mpt, u_int32_t who) mpt->upload_fw = 1; } } - if (mpt->verbose > 1) { - mpt_prt(mpt, "flags %d, upload_fw %d", init.Flags, - mpt->upload_fw); - } + + DNPRINTF(10, "%s: flags %d, upload_fw %d\n", DEVNAME(mpt), init.Flags, + mpt->upload_fw); if ((error = mpt_send_handshake_cmd(mpt, sizeof init, &init)) != 0) { return(error); @@ -831,7 +836,8 @@ mpt_write_cfg_page(struct mpt_softc *mpt, int PageAddress, CONFIG_PAGE_HEADER *h void mpt_print_header(struct mpt_softc *mpt, char *s, CONFIG_PAGE_HEADER *phdr) { - mpt_prt(mpt, "%s %x: %x %x %x %x", + DNPRINTF(10,"%s: %s %x: %x %x %x %x\n", + DEVNAME(mpt), s, phdr->PageNumber, phdr->PageType, @@ -863,10 +869,9 @@ mpt_read_config_info_mfg(struct mpt_softc *mpt) mpt_prt(mpt, "Could not retrieve Manufacturing Page " "%i Header.", i); return (-1); - } else if (mpt->verbose > 1) { + } else mpt_print_header(mpt, "Manufacturing Header Page", phdr[i]); - } /* retrieve MFG config pages using retrieved headers */ rv = mpt_read_cfg_page(mpt, i, phdr[i]); @@ -877,8 +882,8 @@ mpt_read_config_info_mfg(struct mpt_softc *mpt) } } - /* mpt->verbose = 2; */ - if (mpt->verbose > 1) { +#ifdef MPT_DEBUG + if (mpt_debug > 10) { mpt_prt(mpt, "Manufacturing Page 0 data: %s %s %s %s %s", mpt->mpt_mfg_page0.ChipName, mpt->mpt_mfg_page0.ChipRevision, @@ -925,7 +930,7 @@ mpt_read_config_info_mfg(struct mpt_softc *mpt) } printf("\n"); } - /* mpt->verbose = 1; */ +#endif /* MPT_DEBUG */ return (0); } @@ -953,9 +958,8 @@ mpt_read_config_info_iou(struct mpt_softc *mpt) mpt_prt(mpt, "Could not retrieve IO Unit Page %i " "header.", i); return (-1); - } else if (mpt->verbose > 1) { + } else mpt_print_header(mpt, "IO Unit Header Page", phdr[i]); - } /* retrieve IO Unit config pages using retrieved headers */ rv = mpt_read_cfg_page(mpt, i, phdr[i]); @@ -973,23 +977,20 @@ mpt_read_config_info_iou(struct mpt_softc *mpt) } } - /* mpt->verbose = 2; */ - if (mpt->verbose > 1) { - mpt_prt(mpt, "IO Unit Page 0 data: %llx", - mpt->mpt_iou_page0.UniqueValue); - - mpt_prt(mpt, "IO Unit Page 1 data: %x", - mpt->mpt_iou_page1.Flags); - - mpt_prt(mpt, "IO Unit Page 2 data: %x %x %x %x %x %x", - mpt->mpt_iou_page2.Flags, - mpt->mpt_iou_page2.BiosVersion, - mpt->mpt_iou_page2.AdapterOrder[0], - mpt->mpt_iou_page2.AdapterOrder[1], - mpt->mpt_iou_page2.AdapterOrder[2], - mpt->mpt_iou_page2.AdapterOrder[3]); - } - /* mpt->verbose = 1; */ + DNPRINTF(10, "%s: IO Unit Page 0 data: %llx\n", + DEVNAME(mpt), + mpt->mpt_iou_page0.UniqueValue); + DNPRINTF(10, "%s: IO Unit Page 1 data: %x\n", + DEVNAME(mpt), + mpt->mpt_iou_page1.Flags); + DNPRINTF(10, "%s: IO Unit Page 2 data: %x %x %x %x %x %x\n", + DEVNAME(mpt), + mpt->mpt_iou_page2.Flags, + mpt->mpt_iou_page2.BiosVersion, + mpt->mpt_iou_page2.AdapterOrder[0], + mpt->mpt_iou_page2.AdapterOrder[1], + mpt->mpt_iou_page2.AdapterOrder[2], + mpt->mpt_iou_page2.AdapterOrder[3]); return (0); } @@ -1017,9 +1018,8 @@ mpt_read_config_info_ioc(struct mpt_softc *mpt) mpt_prt(mpt, "Could not retrieve IOC Page %i header.", i); return (-1); - } else if (mpt->verbose > 1) { + } else mpt_print_header(mpt, "IOC Header Page", phdr[i]); - } /* retrieve IOC config pages using retrieved headers */ rv = mpt_read_cfg_page(mpt, i, phdr[i]); @@ -1029,8 +1029,8 @@ mpt_read_config_info_ioc(struct mpt_softc *mpt) } } - /* mpt->verbose = 2; */ - if (mpt->verbose > 1) { +#ifdef MPT_DEBUG + if (mpt_debug > 10) { mpt_prt(mpt, "IOC Page 0 data: %x %x %x %x %x %x %x %x", mpt->mpt_ioc_page0.TotalNVStore, mpt->mpt_ioc_page0.FreeNVStore, @@ -1089,7 +1089,7 @@ mpt_read_config_info_ioc(struct mpt_softc *mpt) mpt->mpt_ioc_page4.SEP[i].SEPBus); } } - /* mpt->verbose = 1; */ +#endif /* MPT_DEBUG */ return (0); } @@ -1100,7 +1100,7 @@ mpt_read_config_info_ioc(struct mpt_softc *mpt) int mpt_read_config_info_raid(struct mpt_softc *mpt) { - int rv, i; + int rv; /* retrieve raid volume headers */ rv = mpt_read_cfg_header(mpt, MPI_CONFIG_PAGETYPE_RAID_VOLUME, 0, @@ -1108,10 +1108,9 @@ mpt_read_config_info_raid(struct mpt_softc *mpt) if (rv) { mpt_prt(mpt, "Could not retrieve RAID Volume Page 0 Header"); return (-1); - } else if (mpt->verbose > 1) { + } else mpt_print_header(mpt, "RAID Volume Header Page", &mpt->mpt_raidvol_page0.Header); - } /* retrieve raid volume page using retrieved headers */ rv = mpt_read_cfg_page(mpt, 0, &mpt->mpt_raidvol_page0.Header); @@ -1126,10 +1125,9 @@ mpt_read_config_info_raid(struct mpt_softc *mpt) if (rv) { mpt_prt(mpt, "Could not retrieve RAID Phys Disk Page 0 Header"); return (-1); - } else if (mpt->verbose > 1) { + } else mpt_print_header(mpt, "RAID Volume Physical Disk Page", &mpt->mpt_raidphys_page0.Header); - } /* retrieve raid physical disk page using retrieved headers */ rv = mpt_read_cfg_page(mpt, 0, &mpt->mpt_raidphys_page0.Header); @@ -1138,8 +1136,9 @@ mpt_read_config_info_raid(struct mpt_softc *mpt) return (-1); } - /* mpt->verbose = 2; */ - if (mpt->verbose > 1) { +#ifdef MPT_DEBUG + int i; + if (mpt_debug > 10) { mpt_prt(mpt, "RAID Volume Page 0 data: %x %x %x %x %x" "%x %x %x %x", mpt->mpt_raidvol_page0.VolumeType, @@ -1158,9 +1157,7 @@ mpt_read_config_info_raid(struct mpt_softc *mpt) mpt->mpt_raidvol_page0.PhysDisk[i].PhysDiskMap); } printf("\n"); - } - if (mpt->verbose > 1) { mpt_prt(mpt, "RAID Phyical Disk Page 0 data: %x %x %x %x %x" "%x %x %x", mpt->mpt_raidphys_page0.PhysDiskNum, @@ -1205,7 +1202,7 @@ mpt_read_config_info_raid(struct mpt_softc *mpt) mpt->mpt_raidphys_page0.ErrorData.SmartCount ); } - /* mpt->verbose = 1; */ +#endif /* MPT_DEBUG */ return (0); } @@ -1220,43 +1217,39 @@ mpt_read_config_info_spi(struct mpt_softc *mpt) rv = mpt_read_cfg_header(mpt, MPI_CONFIG_PAGETYPE_SCSI_PORT, 0, 0, &mpt->mpt_port_page0.Header); - if (rv) { + if (rv) return (-1); - } - if (mpt->verbose > 1) { - mpt_prt(mpt, "SPI Port Page 0 Header: %x %x %x %x", - mpt->mpt_port_page0.Header.PageVersion, - mpt->mpt_port_page0.Header.PageLength, - mpt->mpt_port_page0.Header.PageNumber, - mpt->mpt_port_page0.Header.PageType); - } + + DNPRINTF(10, "%s: SPI Port Page 0 Header: %x %x %x %x\n", + DEVNAME(mpt), + mpt->mpt_port_page0.Header.PageVersion, + mpt->mpt_port_page0.Header.PageLength, + mpt->mpt_port_page0.Header.PageNumber, + mpt->mpt_port_page0.Header.PageType); rv = mpt_read_cfg_header(mpt, MPI_CONFIG_PAGETYPE_SCSI_PORT, 1, 0, &mpt->mpt_port_page1.Header); - if (rv) { + if (rv) return (-1); - } - if (mpt->verbose > 1) { - mpt_prt(mpt, "SPI Port Page 1 Header: %x %x %x %x", - mpt->mpt_port_page1.Header.PageVersion, - mpt->mpt_port_page1.Header.PageLength, - mpt->mpt_port_page1.Header.PageNumber, - mpt->mpt_port_page1.Header.PageType); - } + + DNPRINTF(10, "%s: SPI Port Page 1 Header: %x %x %x %x\n", + DEVNAME(mpt), + mpt->mpt_port_page1.Header.PageVersion, + mpt->mpt_port_page1.Header.PageLength, + mpt->mpt_port_page1.Header.PageNumber, + mpt->mpt_port_page1.Header.PageType); rv = mpt_read_cfg_header(mpt, MPI_CONFIG_PAGETYPE_SCSI_PORT, 2, 0, &mpt->mpt_port_page2.Header); - if (rv) { + if (rv) return (-1); - } - if (mpt->verbose > 1) { - mpt_prt(mpt, "SPI Port Page 2 Header: %x %x %x %x", - mpt->mpt_port_page1.Header.PageVersion, - mpt->mpt_port_page1.Header.PageLength, - mpt->mpt_port_page1.Header.PageNumber, - mpt->mpt_port_page1.Header.PageType); - } + DNPRINTF(10, "%s: SPI Port Page 2 Header: %x %x %x %x\n", + DEVNAME(mpt), + mpt->mpt_port_page1.Header.PageVersion, + mpt->mpt_port_page1.Header.PageLength, + mpt->mpt_port_page1.Header.PageNumber, + mpt->mpt_port_page1.Header.PageType); for (i = 0; i < 16; i++) { rv = mpt_read_cfg_header(mpt, MPI_CONFIG_PAGETYPE_SCSI_DEVICE, @@ -1264,28 +1257,26 @@ mpt_read_config_info_spi(struct mpt_softc *mpt) if (rv) { return (-1); } - if (mpt->verbose > 1) { - mpt_prt(mpt, - "SPI Target %d Device Page 0 Header: %x %x %x %x", - i, mpt->mpt_dev_page0[i].Header.PageVersion, - mpt->mpt_dev_page0[i].Header.PageLength, - mpt->mpt_dev_page0[i].Header.PageNumber, - mpt->mpt_dev_page0[i].Header.PageType); - } + DNPRINTF(10, + "%s: SPI Target %d Device Page 0 Header: %x %x %x %x\n", + DEVNAME(mpt), + i, mpt->mpt_dev_page0[i].Header.PageVersion, + mpt->mpt_dev_page0[i].Header.PageLength, + mpt->mpt_dev_page0[i].Header.PageNumber, + mpt->mpt_dev_page0[i].Header.PageType); rv = mpt_read_cfg_header(mpt, MPI_CONFIG_PAGETYPE_SCSI_DEVICE, 1, i, &mpt->mpt_dev_page1[i].Header); if (rv) { return (-1); } - if (mpt->verbose > 1) { - mpt_prt(mpt, - "SPI Target %d Device Page 1 Header: %x %x %x %x", - i, mpt->mpt_dev_page1[i].Header.PageVersion, - mpt->mpt_dev_page1[i].Header.PageLength, - mpt->mpt_dev_page1[i].Header.PageNumber, - mpt->mpt_dev_page1[i].Header.PageType); - } + DNPRINTF(10, + "%s: SPI Target %d Device Page 1 Header: %x %x %x %x\n", + DEVNAME(mpt), + i, mpt->mpt_dev_page1[i].Header.PageVersion, + mpt->mpt_dev_page1[i].Header.PageLength, + mpt->mpt_dev_page1[i].Header.PageNumber, + mpt->mpt_dev_page1[i].Header.PageType); } /* @@ -1297,38 +1288,39 @@ mpt_read_config_info_spi(struct mpt_softc *mpt) rv = mpt_read_cfg_page(mpt, 0, &mpt->mpt_port_page0.Header); if (rv) { mpt_prt(mpt, "failed to read SPI Port Page 0"); - } else if (mpt->verbose > 1) { - mpt_prt(mpt, - "SPI Port Page 0: Capabilities %x PhysicalInterface %x", + } else + DNPRINTF(10, + "%s: SPI Port Page 0: Capabilities %x PhysicalInterface %x\n", + DEVNAME(mpt), mpt->mpt_port_page0.Capabilities, mpt->mpt_port_page0.PhysicalInterface); - } rv = mpt_read_cfg_page(mpt, 0, &mpt->mpt_port_page1.Header); if (rv) { mpt_prt(mpt, "failed to read SPI Port Page 1"); - } else if (mpt->verbose > 1) { - mpt_prt(mpt, - "SPI Port Page 1: Configuration %x OnBusTimerValue %x", + } else + DNPRINTF(10, + "%s: SPI Port Page 1: Configuration %x OnBusTimerValue %x\n", + DEVNAME(mpt), mpt->mpt_port_page1.Configuration, mpt->mpt_port_page1.OnBusTimerValue); - } rv = mpt_read_cfg_page(mpt, 0, &mpt->mpt_port_page2.Header); if (rv) { mpt_prt(mpt, "failed to read SPI Port Page 2"); - } else if (mpt->verbose > 1) { - mpt_prt(mpt, - "SPI Port Page 2: Flags %x Settings %x", + } else { + DNPRINTF(10, + "%s: SPI Port Page 2: Flags %x Settings %x\n", + DEVNAME(mpt), mpt->mpt_port_page2.PortFlags, mpt->mpt_port_page2.PortSettings); - for (i = 0; i < 16; i++) { - mpt_prt(mpt, - "SPI Port Page 2 Tgt %d: timo %x SF %x Flags %x", + for (i = 0; i < 16; i++) + DNPRINTF(10, + "%s: SPI Port Page 2 Tgt %d: timo %x SF %x Flags %x\n", + DEVNAME(mpt), i, mpt->mpt_port_page2.DeviceSettings[i].Timeout, mpt->mpt_port_page2.DeviceSettings[i].SyncFactor, mpt->mpt_port_page2.DeviceSettings[i].DeviceFlags); - } } for (i = 0; i < 16; i++) { @@ -1337,23 +1329,23 @@ mpt_read_config_info_spi(struct mpt_softc *mpt) mpt_prt(mpt, "cannot read SPI Tgt %d Device Page 0", i); continue; } - if (mpt->verbose > 1) { - mpt_prt(mpt, - "SPI Tgt %d Page 0: NParms %x Information %x", - i, mpt->mpt_dev_page0[i].NegotiatedParameters, - mpt->mpt_dev_page0[i].Information); - } + DNPRINTF(10, + "%s: SPI Tgt %d Page 0: NParms %x Information %x\n", + DEVNAME(mpt), + i, mpt->mpt_dev_page0[i].NegotiatedParameters, + mpt->mpt_dev_page0[i].Information); + rv = mpt_read_cfg_page(mpt, i, &mpt->mpt_dev_page1[i].Header); if (rv) { mpt_prt(mpt, "cannot read SPI Tgt %d Device Page 1", i); continue; } - if (mpt->verbose > 1) { - mpt_prt(mpt, - "SPI Tgt %d Page 1: RParms %x Configuration %x", - i, mpt->mpt_dev_page1[i].RequestedParameters, - mpt->mpt_dev_page1[i].Configuration); - } + + DNPRINTF(10, + "%s: SPI Tgt %d Page 1: RParms %x Configuration %x\n", + DEVNAME(mpt), + i, mpt->mpt_dev_page1[i].RequestedParameters, + mpt->mpt_dev_page1[i].Configuration); } return (0); } @@ -1397,24 +1389,24 @@ mpt_set_initial_config_spi(struct mpt_softc *mpt) tmp = mpt->mpt_dev_page1[i]; tmp.RequestedParameters = 0; tmp.Configuration = 0; - if (mpt->verbose > 1) { - mpt_prt(mpt, - "Set Tgt %d SPI DevicePage 1 values to %x 0 %x", - i, tmp.RequestedParameters, tmp.Configuration); - } - if (mpt_write_cfg_page(mpt, i, &tmp.Header)) { + DNPRINTF(10, + "%s: Set Tgt %d SPI DevicePage 1 values to %x 0 %x\n", + DEVNAME(mpt), + i, tmp.RequestedParameters, tmp.Configuration); + + if (mpt_write_cfg_page(mpt, i, &tmp.Header)) return (-1); - } - if (mpt_read_cfg_page(mpt, i, &tmp.Header)) { + + if (mpt_read_cfg_page(mpt, i, &tmp.Header)) return (-1); - } + mpt->mpt_dev_page1[i] = tmp; - if (mpt->verbose > 1) { - mpt_prt(mpt, - "SPI Tgt %d Page 1: RParm %x Configuration %x", i, - mpt->mpt_dev_page1[i].RequestedParameters, - mpt->mpt_dev_page1[i].Configuration); - } + DNPRINTF(10, + "%s: SPI Tgt %d Page 1: RParm %x Configuration %x\n", + DEVNAME(mpt), + i, + mpt->mpt_dev_page1[i].RequestedParameters, + mpt->mpt_dev_page1[i].Configuration); } return (0); } @@ -1439,9 +1431,8 @@ mpt_send_port_enable(struct mpt_softc *mpt, int port) enable_req->PortNumber = port; mpt_check_doorbell(mpt); - if (mpt->verbose > 1) { - mpt_prt(mpt, "enabling port %d", port); - } + DNPRINTF(10, "%s: enabling port %d\n", DEVNAME(mpt), port); + mpt_send_cmd(mpt, req); count = 0; @@ -1479,9 +1470,8 @@ mpt_send_event_request(struct mpt_softc *mpt, int onoff) enable_req->Switch = onoff; mpt_check_doorbell(mpt); - if (mpt->verbose > 1) { - mpt_prt(mpt, "%sabling async events", onoff? "en" : "dis"); - } + DNPRINTF(10, "%s: %sabling async events\n", + DEVNAME(mpt), onoff? "en" : "dis"); mpt_send_cmd(mpt, req); return (0); @@ -1524,10 +1514,9 @@ mpt_init(struct mpt_softc *mpt, u_int32_t who) mpt_init_request(mpt, &mpt->request_pool[val]); } - if (mpt->verbose > 1) { - mpt_prt(mpt, "doorbell req = %s", - mpt_ioc_diag(mpt_read(mpt, MPT_OFFSET_DOORBELL))); - } + DNPRINTF(10, "%s: doorbell req = %s\n", + DEVNAME(mpt), + mpt_ioc_diag(mpt_read(mpt, MPT_OFFSET_DOORBELL))); /* * Start by making sure we're not at FAULT or RESET state @@ -1565,12 +1554,12 @@ mpt_init(struct mpt_softc *mpt, u_int32_t who) continue; } - if (mpt->verbose > 1) { - mpt_prt(mpt, - "IOCFACTS: GlobalCredits=%d BlockSize=%u " - "Request Frame Size %u", facts.GlobalCredits, - facts.BlockSize, facts.RequestFrameSize); - } + DNPRINTF(10, + "%s: IOCFACTS: GlobalCredits=%d BlockSize=%u " + "Request Frame Size %u\n", + DEVNAME(mpt), facts.GlobalCredits, + facts.BlockSize, facts.RequestFrameSize); + mpt->mpt_global_credits = facts.GlobalCredits; mpt->request_frame_size = facts.RequestFrameSize; @@ -1585,12 +1574,11 @@ mpt_init(struct mpt_softc *mpt, u_int32_t who) continue; } - if (mpt->verbose > 1) { - mpt_prt(mpt, - "PORTFACTS: Type %x PFlags %x IID %d MaxDev %d", - pfp.PortType, pfp.ProtocolFlags, pfp.PortSCSIID, - pfp.MaxDevices); - } + DNPRINTF(10, + "%s: PORTFACTS: Type %x PFlags %x IID %d MaxDev %d\n", + DEVNAME(mpt), + pfp.PortType, pfp.ProtocolFlags, pfp.PortSCSIID, + pfp.MaxDevices); if (pfp.PortType != MPI_PORTFACTS_PORTTYPE_SCSI && pfp.PortType != MPI_PORTFACTS_PORTTYPE_FC) { @@ -1614,17 +1602,14 @@ mpt_init(struct mpt_softc *mpt, u_int32_t who) continue; } - if (mpt->verbose > 1) { - mpt_prt(mpt, "mpt_send_ioc_init ok"); - } + DNPRINTF(10, "%s: mpt_send_ioc_init ok\n", DEVNAME(mpt)); if (mpt_wait_state(mpt, MPT_DB_STATE_RUNNING) != MPT_OK) { mpt_prt(mpt, "IOC failed to go to run state"); continue; } - if (mpt->verbose > 1) { - mpt_prt(mpt, "IOC now at RUNSTATE"); - } + + DNPRINTF(10, "%s: IOC now at RUNSTATE\n", DEVNAME(mpt)); /* * Give it reply buffers @@ -1641,21 +1626,16 @@ mpt_init(struct mpt_softc *mpt, u_int32_t who) /* XXX MU correct place the call to fw_upload? */ if (mpt->upload_fw) { - if (mpt->verbose > 1) { - mpt_prt(mpt, "firmware upload required."); - } + DNPRINTF(10, "%s: firmware upload required\n", + DEVNAME(mpt)); - if (mpt_do_upload(mpt)) { + if (mpt_do_upload(mpt)) /* XXX MP should we panic? */ - mpt_prt(mpt, "firmware upload failure!"); - } - /* continue; */ - } - else { - if (mpt->verbose > 1) { - mpt_prt(mpt, "firmware upload not required."); - } + mpt_prt(mpt, "firmware upload failure"); } + else + DNPRINTF(10, "%sfirmware upload not required\n", + DEVNAME(mpt)); /* * Enable asynchronous event reporting @@ -1669,12 +1649,11 @@ mpt_init(struct mpt_softc *mpt, u_int32_t who) */ if (mpt->is_fc == 0) { - if (mpt_read_config_info_spi(mpt)) { + if (mpt_read_config_info_spi(mpt)) return (EIO); - } - if (mpt_set_initial_config_spi(mpt)) { + + if (mpt_set_initial_config_spi(mpt)) return (EIO); - } } /* @@ -1689,11 +1668,9 @@ mpt_init(struct mpt_softc *mpt, u_int32_t who) * if the vmware flag is set skip page retrival since it does * not support all of them. */ - if (mpt->vmware) { - if (mpt->verbose > 1) - mpt_prt(mpt, "running in vmware, skipping page" - "retrieval"); - } + if (mpt->vmware) + DNPRINTF(10, "%s: running in vmware, skipping page " + "retrieval\n", DEVNAME(mpt)); else { /* * Read manufacturing pages @@ -1736,9 +1713,7 @@ mpt_init(struct mpt_softc *mpt, u_int32_t who) continue; } - if (mpt->verbose > 1) { - mpt_prt(mpt, "enabled port 0"); - } + DNPRINTF(10, "%s: enabled port 0\n", DEVNAME(mpt)); /* Everything worked */ break; @@ -1749,9 +1724,7 @@ mpt_init(struct mpt_softc *mpt, u_int32_t who) return (EIO); } - if (mpt->verbose > 1) { - mpt_prt(mpt, "enabling interrupts"); - } + DNPRINTF(10, "%s: enabling interrupts\n", DEVNAME(mpt)); mpt_enable_ints(mpt); return (0); @@ -1822,10 +1795,8 @@ mpt_do_upload(struct mpt_softc *mpt) flags = MPI_SGE_FLAGS_SIMPLE_ELEMENT; - if (mpt->verbose > 1) { - mpt_prt(mpt, "assembling SG list (%d entries)", - mpt->fw_dmap->dm_nsegs); - } + DNPRINTF(20, "%s: assembling SG list (%d entries)\n", + DEVNAME(mpt), mpt->fw_dmap->dm_nsegs); for (i = 0; i < mpt->fw_dmap->dm_nsegs; i++, se++) { if (i == mpt->fw_dmap->dm_nsegs - 1) { @@ -1841,8 +1812,8 @@ mpt_do_upload(struct mpt_softc *mpt) sgeoffset += sizeof(*se); } - mpt_prt(mpt, "sending FW Upload request to IOC (size: %d, " - "img size: %d)", sgeoffset, mpt->fw_image_size); + DNPRINTF(10, "%s: sending FW Upload request to IOC (size: %d, " + "img size: %d)\n", DEVNAME(mpt), sgeoffset, mpt->fw_image_size); if ((error = mpt_send_handshake_cmd(mpt, sgeoffset, prequest)) != 0) { return(error); @@ -1858,18 +1829,16 @@ mpt_do_upload(struct mpt_softc *mpt) int status, transfer_sz; status = preply->IOCStatus; - if (mpt->verbose > 1) { - mpt_prt(mpt, "fw_upload reply status %d", status); - } + DNPRINTF(20, "%s: fw_upload reply status %d\n", + DEVNAME(mpt), status); if (status == MPI_IOCSTATUS_SUCCESS) { transfer_sz = preply->ActualImageSize; if (transfer_sz != mpt->fw_image_size) error = EFAULT; - } - else { - error = EFAULT; - } + } + else + error = EFAULT; } if (error == 0) { @@ -1895,7 +1864,7 @@ mpt_downloadboot(struct mpt_softc *mpt) MpiExtImageHeader_t *exthdr = NULL; int fw_size; u_int32_t diag0; -#if MPT_DEBUG +#ifdef MPT_DEBUG u_int32_t diag1; #endif int count = 0; diff --git a/sys/dev/ic/mpt.h b/sys/dev/ic/mpt.h index 6a89eb07ec9..24c1141e375 100644 --- a/sys/dev/ic/mpt.h +++ b/sys/dev/ic/mpt.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mpt.h,v 1.7 2005/12/03 04:00:08 marco Exp $ */ +/* $OpenBSD: mpt.h,v 1.8 2006/02/04 19:05:00 marco Exp $ */ /* $NetBSD: mpt.h,v 1.2 2003/07/08 10:06:31 itojun Exp $ */ /* @@ -41,6 +41,18 @@ #ifndef _DEV_IC_MPT_H_ #define _DEV_IC_MPT_H_ +#define DEVNAME(s) ((s)->mpt_dev.dv_xname) + +/* #define MPT_DEBUG */ +#ifdef MPT_DEBUG +extern int mpt_debug; +#define DPRINTF(x...) do { if (mpt_debug) printf(x); } while(0) +#define DNPRINTF(n,x...) do { if (mpt_debug > (n)) printf(x); } while(0) +#else +#define DPRINTF(x...) do { } while (0) +#define DNPRINTF(n,x...) do { } while (0) +#endif + #include <dev/ic/mpt_openbsd.h> #define MPT_OK (0) @@ -187,14 +199,19 @@ int mpt_alloc_fw_mem(struct mpt_softc *, int); void mpt_free_fw_mem(struct mpt_softc *); /* mpt_debug.c functions */ -void mpt_print_reply(void *); -void mpt_print_db(u_int32_t); +#ifdef MPT_DEBUG void mpt_print_config_reply(void *); -char *mpt_ioc_diag(u_int32_t); -char *mpt_req_state(enum mpt_req_state); void mpt_print_scsi_io_request(MSG_SCSI_IO_REQUEST *); void mpt_print_config_request(void *); void mpt_print_request(void *); +void mpt_print_db(u_int32_t); +void mpt_print_reply(void *); +char *mpt_ioc_diag(u_int32_t); +char *mpt_req_state(enum mpt_req_state); +#else +#define mpt_print_db(x) +#endif /* MPT_DEBUG */ + #endif /* _KERNEL */ #endif /* _DEV_IC_MPT_H_ */ diff --git a/sys/dev/ic/mpt_debug.c b/sys/dev/ic/mpt_debug.c index 30c41223ca1..b446b27138d 100644 --- a/sys/dev/ic/mpt_debug.c +++ b/sys/dev/ic/mpt_debug.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mpt_debug.c,v 1.4 2005/04/21 16:02:27 deraadt Exp $ */ +/* $OpenBSD: mpt_debug.c,v 1.5 2006/02/04 19:05:00 marco Exp $ */ /* $NetBSD: mpt_debug.c,v 1.2 2003/07/14 15:47:11 lukem Exp $ */ /* @@ -40,6 +40,7 @@ #include <dev/ic/mpt.h> +#ifdef MPT_DEBUG char *mpt_ioc_status(int); char *mpt_ioc_function(int); char *mpt_ioc_event(int); @@ -640,3 +641,4 @@ mpt_dump_sgl(SGE_IO_UNION *su) iCount -= 1; } while ((flags & MPI_SGE_FLAGS_END_OF_LIST) == 0 && iCount != 0); } +#endif /* MPT_DEBUG */ diff --git a/sys/dev/ic/mpt_openbsd.c b/sys/dev/ic/mpt_openbsd.c index 7319fde2f3a..4014768945f 100644 --- a/sys/dev/ic/mpt_openbsd.c +++ b/sys/dev/ic/mpt_openbsd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mpt_openbsd.c,v 1.31 2005/12/03 04:00:08 marco Exp $ */ +/* $OpenBSD: mpt_openbsd.c,v 1.32 2006/02/04 19:05:00 marco Exp $ */ /* $NetBSD: mpt_netbsd.c,v 1.7 2003/07/14 15:47:11 lukem Exp $ */ /* @@ -147,9 +147,7 @@ mpt_ppr(struct mpt_softc *mpt, struct scsi_link *sc_link, int speed, int flags) int error; struct scsi_inquiry_data inqbuf; - if (mpt->verbose > 1) { - mpt_prt(mpt, "Entering PPR"); - } + DNPRINTF(30, "Entering PPR\n"); if (mpt->is_fc) { /* @@ -244,13 +242,13 @@ mpt_ppr(struct mpt_softc *mpt, struct scsi_link *sc_link, int speed, int flags) } mpt->mpt_dev_page1[sc_link->target] = page1; - if (mpt->verbose > 1) { - mpt_prt(mpt, - "SPI Target %d Page 1: RequestedParameters %x Config %x", - sc_link->target, - mpt->mpt_dev_page1[sc_link->target].RequestedParameters, - mpt->mpt_dev_page1[sc_link->target].Configuration); - } + + DNPRINTF(30, + "%s: SPI Target %d Page 1: RequestedParameters %x Config %x\n", + DEVNAME(mpt), + sc_link->target, + mpt->mpt_dev_page1[sc_link->target].RequestedParameters, + mpt->mpt_dev_page1[sc_link->target].Configuration); /* * use INQUIRY for PPR two reasons: @@ -270,30 +268,25 @@ mpt_ppr(struct mpt_softc *mpt, struct scsi_link *sc_link, int speed, int flags) return 0; } - if (mpt->verbose > 1) { - mpt_prt(mpt, - "SPI Tgt %d Page 0: NParms %x Information %x", - sc_link->target, - page0.NegotiatedParameters, page0.Information); - } + DNPRINTF(30, + "%s: SPI Tgt %d Page 0: NParms %x Information %x\n", + DEVNAME(mpt), + sc_link->target, + page0.NegotiatedParameters, page0.Information); if (!(page0.NegotiatedParameters & 0x07) && (speed == U320)) { /* * if lowest 3 aren't set the PPR probably failed, * retry with other parameters */ - if (mpt->verbose > 1) { - mpt_prt(mpt, "U320 PPR failed"); - } + DNPRINTF(30, "%s: U320 PPR failed\n", DEVNAME(mpt)); return 0; } if ((((page0.NegotiatedParameters >> 8) & 0xff) > 0x09) && (speed == U160)) { /* if transfer period > 0x09 then U160 PPR failed, retry */ - if (mpt->verbose > 1) { - mpt_prt(mpt, "U160 PPR failed"); - } + DNPRINTF(30, "%s: U160 PPR failed\n", DEVNAME(mpt)); return 0; } @@ -437,11 +430,7 @@ mpt_attach(struct mpt_softc *mpt) } lptr->openings = MPT_MAX_REQUESTS(mpt) / lptr->adapter_buswidth; -#ifdef MPT_DEBUG - mpt->verbose = 2; -#endif - - mpt_prt(mpt, "IM support: %x", mpt->im_support); + DNPRINTF(10, "%s: IM support: %x\n", DEVNAME(mpt), mpt->im_support); (void) config_found(&mpt->mpt_dev, lptr, scsiprint); @@ -642,15 +631,16 @@ mpt_intr(void *arg) while (reply != MPT_REPLY_EMPTY) { nrepl++; - if (mpt->verbose > 1) { - if ((reply & MPT_CONTEXT_REPLY) != 0) { +#ifdef MPT_DEBUG + if (mpt_debug > 50) { + if ((reply & MPT_CONTEXT_REPLY) != 0) /* Address reply; IOC has something to say */ mpt_print_reply(MPT_REPLY_PTOV(mpt, reply)); - } else { + else /* Context reply; all went well */ mpt_prt(mpt, "context %u reply OK", reply); - } } +#endif /* MPT_DEBUG */ mpt_done(mpt, reply); reply = mpt_pop_reply_queue(mpt); } @@ -717,9 +707,12 @@ mpt_timeout(void *arg) mpt_read(mpt, MPT_OFFSET_INTR_STATUS), mpt_read(mpt, MPT_OFFSET_INTR_MASK), mpt_read(mpt, MPT_OFFSET_DOORBELL)); +#ifdef MPT_DEBUG mpt_prt(mpt, "request state: %s", mpt_req_state(req->debug)); - if (mpt->verbose > 1) - mpt_print_scsi_io_request((MSG_SCSI_IO_REQUEST *)req->req_vbuf); + mpt_print_scsi_io_request((MSG_SCSI_IO_REQUEST *)req->req_vbuf); +#else + mpt_prt(mpt, "request state: %i", req->debug); +#endif /* MPT_DEBUG */ for(index = 0; index < MPT_MAX_REQUESTS(mpt); index++) if (req == &mpt->request_pool[index]) { @@ -752,7 +745,8 @@ mpt_done(struct mpt_softc *mpt, uint32_t reply) /* XXX BUS_DMASYNC_POSTREAD XXX */ mpt_reply = MPT_REPLY_PTOV(mpt, reply); - if (mpt->verbose > 1) { +#ifdef MPT_DEBUG + if (mpt_debug > 50) { uint32_t *pReply = (uint32_t *) mpt_reply; mpt_prt(mpt, "Address Reply (index %u):", @@ -764,6 +758,7 @@ mpt_done(struct mpt_softc *mpt, uint32_t reply) mpt_prt(mpt, "%08x %08x %08x %08x", pReply[8], pReply[9], pReply[10], pReply[11]); } +#endif /* MPT_DEBUG */ index = mpt_reply->MsgContext; } @@ -799,8 +794,7 @@ mpt_done(struct mpt_softc *mpt, uint32_t reply) /* Short cut for task management replies; nothing more for us to do. */ if (mpt_req->Function == MPI_FUNCTION_SCSI_TASK_MGMT) { - if (mpt->verbose > 1) - mpt_prt(mpt, "mpt_done: TASK MGMT"); + DNPRINTF(50, "%s: mpt_done: TASK MGMT\n", DEVNAME(mpt)); goto done; } @@ -812,9 +806,8 @@ mpt_done(struct mpt_softc *mpt, uint32_t reply) * crash if it isn't. */ if (mpt_req->Function != MPI_FUNCTION_SCSI_IO_REQUEST) { - if (mpt->verbose > 1) - mpt_prt(mpt, "mpt_done: unknown Function 0x%x (0x%x)", - mpt_req->Function, index); + DNPRINTF(10, "%s: mpt_done: unknown Function 0x%x (0x%x)\n", + DEVNAME(mpt), mpt_req->Function, index); goto done; } @@ -826,13 +819,19 @@ mpt_done(struct mpt_softc *mpt, uint32_t reply) mpt_prt(mpt, "mpt_done: no scsi_xfer, index = 0x%x, seq = 0x%08x", req->index, req->sequence); +#ifdef MPT_DEBUG mpt_prt(mpt, "request state: %s", mpt_req_state(req->debug)); mpt_prt(mpt, "mpt_request:"); mpt_print_scsi_io_request((MSG_SCSI_IO_REQUEST *)req->req_vbuf); +#else + mpt_prt(mpt, "request state: %i", req->debug); +#endif /* MPT_DEBUG */ if (mpt_reply != NULL) { +#ifdef MPT_DEBUG mpt_prt(mpt, "mpt_reply:"); mpt_print_reply(mpt_reply); +#endif /* MPT_DEBUG */ } else { mpt_prt(mpt, "context reply: 0x%08x", reply); } @@ -1210,8 +1209,10 @@ mpt_run_xfer(struct mpt_softc *mpt, struct scsi_xfer *xs) MPI_SGE_FLAGS_SIMPLE_ELEMENT | MPI_SGE_FLAGS_END_OF_LIST)); } - if (mpt->verbose > 1) +#ifdef MPT_DEBUG + if (mpt_debug > 50) mpt_print_scsi_io_request(mpt_req); +#endif /* MPT_DEBUG */ s = splbio(); @@ -1260,8 +1261,10 @@ mpt_ctlop(struct mpt_softc *mpt, void *vmsg, uint32_t reply) { MSG_PORT_ENABLE_REPLY *msg = vmsg; int index = msg->MsgContext & ~0x80000000; - if (mpt->verbose > 1) - mpt_prt(mpt, "enable port reply index %d", index); + + DNPRINTF(10, "%s: enable port reply index %d\n", + DEVNAME(mpt), index); + if (index >= 0 && index < MPT_MAX_REQUESTS(mpt)) { struct req_entry *req = &mpt->request_pool[index]; req->debug = REQ_DONE; diff --git a/sys/dev/ic/mpt_openbsd.h b/sys/dev/ic/mpt_openbsd.h index c77c1de8db4..b032693c790 100644 --- a/sys/dev/ic/mpt_openbsd.h +++ b/sys/dev/ic/mpt_openbsd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mpt_openbsd.h,v 1.19 2005/12/03 04:00:08 marco Exp $ */ +/* $OpenBSD: mpt_openbsd.h,v 1.20 2006/02/04 19:05:00 marco Exp $ */ /* $NetBSD: mpt_netbsd.h,v 1.2 2003/04/16 23:02:14 thorpej Exp $ */ /* @@ -201,7 +201,6 @@ struct req_entry { struct mpt_softc { struct device mpt_dev; /* base device glue */ - int verbose; int is_fc; int bus; diff --git a/sys/dev/pci/mpt_pci.c b/sys/dev/pci/mpt_pci.c index 892be8c9204..9c007f54d98 100644 --- a/sys/dev/pci/mpt_pci.c +++ b/sys/dev/pci/mpt_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mpt_pci.c,v 1.11 2005/12/01 22:10:06 dlg Exp $ */ +/* $OpenBSD: mpt_pci.c,v 1.12 2006/02/04 19:05:00 marco Exp $ */ /* $NetBSD: mpt_pci.c,v 1.2 2003/07/14 15:47:26 lukem Exp $ */ /* @@ -280,9 +280,9 @@ mpt_pci_link_peer(struct mpt_softc *mpt) pci_decompose_tag(peer_psc->sc_pc, peer_psc->sc_tag, &peer_b, &peer_d, &peer_f); if (peer_b == b && peer_d == d) { - if (mpt->verbose) - mpt_prt(mpt, "linking with peer: %s", - peer_psc->sc_mpt.mpt_dev.dv_xname); + DNPRINTF(10, "%s: linking with peer: %s", + DEVNAME(mpt), + peer_psc->sc_mpt.mpt_dev.dv_xname); mpt->mpt2 = (struct mpt_softc *)peer_psc; peer_psc->sc_mpt.mpt2 = mpt; return; |