summaryrefslogtreecommitdiffstats
path: root/sys/dev/isp/isp.c
diff options
context:
space:
mode:
authormjacob <mjacob@FreeBSD.org>2006-07-16 20:11:50 +0000
committermjacob <mjacob@FreeBSD.org>2006-07-16 20:11:50 +0000
commit6e5be938656a65ca8234e3d530deb38bc1e034d3 (patch)
treeb6d3899027d728cf144aed227e8e02413efd7dd0 /sys/dev/isp/isp.c
parentcb8969e565057fcd3dbfefdb57899d0d2bb9b234 (diff)
downloadFreeBSD-src-6e5be938656a65ca8234e3d530deb38bc1e034d3.zip
FreeBSD-src-6e5be938656a65ca8234e3d530deb38bc1e034d3.tar.gz
Some rearrangement of headers to minimize diffs with outside of
FreeBSD repository and to clean up the license header so as to not pollute the license with file function. Zero all mailbox structures prior to use (just in case). Change the outgoing mailbox count for INIT_FIRMWARE to be correct.
Diffstat (limited to 'sys/dev/isp/isp.c')
-rw-r--r--sys/dev/isp/isp.c97
1 files changed, 53 insertions, 44 deletions
diff --git a/sys/dev/isp/isp.c b/sys/dev/isp/isp.c
index ccaacca..74125b4 100644
--- a/sys/dev/isp/isp.c
+++ b/sys/dev/isp/isp.c
@@ -1,7 +1,4 @@
/*-
- * Machine and OS Independent (well, as best as possible)
- * code for the Qlogic ISP SCSI adapters.
- *
* Copyright (c) 1997-2006 by Matthew Jacob
* All rights reserved.
*
@@ -28,14 +25,14 @@
*/
/*
+ * Machine and OS Independent (well, as best as possible)
+ * code for the Qlogic ISP SCSI adapters.
+ */
+/*
* Inspiration and ideas about this driver are from Erik Moe's Linux driver
* (qlogicisp.c) and Dave Miller's SBus version of same (qlogicisp.c). Some
* ideas dredged from the Solaris driver.
*/
-#ifdef __FreeBSD__
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-#endif
/*
* Include header file appropriate for platform we're building on.
@@ -44,6 +41,8 @@ __FBSDID("$FreeBSD$");
#include <dev/ic/isp_netbsd.h>
#endif
#ifdef __FreeBSD__
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
#include <dev/isp/isp_freebsd.h>
#endif
#ifdef __OpenBSD__
@@ -166,7 +165,6 @@ isp_reset(ispsoftc_t *isp)
char *btype = "????";
isp->isp_state = ISP_NILSTATE;
- MEMZERO(&mbs, sizeof (mbs));
/*
* Basic types (SCSI, FibreChannel and PCI or SBus)
@@ -205,6 +203,7 @@ isp_reset(ispsoftc_t *isp)
* Just in case it was paused...
*/
ISP_WRITE(isp, HCCR, HCCR_CMD_RELEASE);
+ MEMZERO(&mbs, sizeof (mbs));
mbs.param[0] = MBOX_ABOUT_FIRMWARE;
isp_mboxcmd(isp, &mbs, MBLOGNONE);
if (mbs.param[0] == MBOX_COMMAND_COMPLETE) {
@@ -596,6 +595,7 @@ again:
/*
* Do some sanity checking.
*/
+ MEMZERO(&mbs, sizeof (mbs));
mbs.param[0] = MBOX_NO_OP;
isp_mboxcmd(isp, &mbs, MBLOGALL);
if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
@@ -603,6 +603,7 @@ again:
}
if (IS_SCSI(isp)) {
+ MEMZERO(&mbs, sizeof (mbs));
mbs.param[0] = MBOX_MAILBOX_REG_TEST;
mbs.param[1] = 0xdead;
mbs.param[2] = 0xbeef;
@@ -650,6 +651,7 @@ again:
isp->isp_mbxworkp = &ptr[1];
isp->isp_mbxwrk0 = ptr[3] - 1;
isp->isp_mbxwrk1 = code_org + 1;
+ MEMZERO(&mbs, sizeof (mbs));
mbs.param[0] = MBOX_WRITE_RAM_WORD;
mbs.param[1] = code_org;
mbs.param[2] = ptr[0];
@@ -665,6 +667,7 @@ again:
/*
* Verify that it downloaded correctly.
*/
+ MEMZERO(&mbs, sizeof (mbs));
mbs.param[0] = MBOX_VERIFY_CHECKSUM;
mbs.param[1] = code_org;
isp_mboxcmd(isp, &mbs, MBLOGNONE);
@@ -687,10 +690,11 @@ again:
isp->isp_mbxwrk0 = ptr[3] - 1;
isp->isp_mbxwrk1 = ptr[5] + 1;
isp->isp_mbxwrk8 = ptr[4];
+ MEMZERO(&mbs, sizeof (mbs));
mbs.param[0] = MBOX_WRITE_RAM_WORD_EXTENDED;
- mbs.param[8] = ptr[4];
mbs.param[1] = ptr[5];
mbs.param[2] = ptr[0];
+ mbs.param[8] = ptr[4];
isp_mboxcmd(isp, &mbs, MBLOGNONE);
if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
isp_prt(isp, ISP_LOGERR,
@@ -703,10 +707,11 @@ again:
isp->isp_mbxwrk0 = ptr[3] - 1;
isp->isp_mbxwrk1 = ptr[5] + 1;
isp->isp_mbxwrk8 = ptr[4];
+ MEMZERO(&mbs, sizeof (mbs));
mbs.param[0] = MBOX_WRITE_RAM_WORD_EXTENDED;
- mbs.param[8] = ptr[4];
mbs.param[1] = ptr[5];
mbs.param[2] = ptr[0];
+ mbs.param[8] = ptr[4];
isp_mboxcmd(isp, &mbs, MBLOGNONE);
if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
isp_prt(isp, ISP_LOGERR,
@@ -729,6 +734,7 @@ again:
*/
+ MEMZERO(&mbs, sizeof (mbs));
mbs.param[0] = MBOX_EXEC_FIRMWARE;
mbs.param[1] = code_org;
if (IS_2322(isp) || IS_24XX(isp)) {
@@ -739,8 +745,8 @@ again:
}
mbs.obits |= 2;
}
-
isp_mboxcmd(isp, &mbs, MBLOGNONE);
+
/*
* Give it a chance to start.
*/
@@ -758,6 +764,7 @@ again:
}
}
+ MEMZERO(&mbs, sizeof (mbs));
mbs.param[0] = MBOX_ABOUT_FIRMWARE;
isp_mboxcmd(isp, &mbs, MBLOGALL);
if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
@@ -785,6 +792,7 @@ again:
isp->isp_fwrev[1] = mbs.param[2];
isp->isp_fwrev[2] = mbs.param[3];
}
+
isp_prt(isp, ISP_LOGCONFIG,
"Board Type %s, Chip Revision 0x%x, %s F/W Revision %d.%d.%d",
btype, isp->isp_revision, dodnld? "loaded" : "resident",
@@ -821,6 +829,7 @@ again:
isp->isp_romfw_rev[2]);
}
+ MEMZERO(&mbs, sizeof (mbs));
mbs.param[0] = MBOX_GET_FIRMWARE_STATUS;
isp_mboxcmd(isp, &mbs, MBLOGALL);
if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
@@ -946,6 +955,7 @@ isp_scsi_init(ispsoftc_t *isp)
/*
* Set ASYNC DATA SETUP time. This is very important.
*/
+ MEMZERO(&mbs, sizeof (mbs));
mbs.param[0] = MBOX_SET_ASYNC_DATA_SETUP_TIME;
mbs.param[1] = sdp_chan0->isp_async_data_setup;
mbs.param[2] = sdp_chan1->isp_async_data_setup;
@@ -957,6 +967,7 @@ isp_scsi_init(ispsoftc_t *isp)
/*
* Set ACTIVE Negation State.
*/
+ MEMZERO(&mbs, sizeof (mbs));
mbs.param[0] = MBOX_SET_ACT_NEG_STATE;
mbs.param[1] =
(sdp_chan0->isp_req_ack_active_neg << 4) |
@@ -965,6 +976,7 @@ isp_scsi_init(ispsoftc_t *isp)
(sdp_chan1->isp_req_ack_active_neg << 4) |
(sdp_chan1->isp_data_line_active_neg << 5);
+ MEMZERO(&mbs, sizeof (mbs));
isp_mboxcmd(isp, &mbs, MBLOGNONE);
if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
isp_prt(isp, ISP_LOGERR,
@@ -981,6 +993,7 @@ isp_scsi_init(ispsoftc_t *isp)
/*
* Set the Tag Aging limit
*/
+ MEMZERO(&mbs, sizeof (mbs));
mbs.param[0] = MBOX_SET_TAG_AGE_LIMIT;
mbs.param[1] = sdp_chan0->isp_tag_aging;
mbs.param[2] = sdp_chan1->isp_tag_aging;
@@ -994,6 +1007,7 @@ isp_scsi_init(ispsoftc_t *isp)
/*
* Set selection timeout.
*/
+ MEMZERO(&mbs, sizeof (mbs));
mbs.param[0] = MBOX_SET_SELECT_TIMEOUT;
mbs.param[1] = sdp_chan0->isp_selection_timeout;
mbs.param[2] = sdp_chan1->isp_selection_timeout;
@@ -1012,6 +1026,7 @@ isp_scsi_init(ispsoftc_t *isp)
*/
if (IS_ULTRA2(isp) || IS_1240(isp)) {
+ MEMZERO(&mbs, sizeof (mbs));
mbs.param[0] = MBOX_INIT_RES_QUEUE_A64;
mbs.param[1] = RESULT_QUEUE_LEN(isp);
mbs.param[2] = DMA_WD1(isp->isp_result_dma);
@@ -1025,6 +1040,7 @@ isp_scsi_init(ispsoftc_t *isp)
}
isp->isp_residx = mbs.param[5];
+ MEMZERO(&mbs, sizeof (mbs));
mbs.param[0] = MBOX_INIT_REQ_QUEUE_A64;
mbs.param[1] = RQUEST_QUEUE_LEN(isp);
mbs.param[2] = DMA_WD1(isp->isp_rquest_dma);
@@ -1038,6 +1054,7 @@ isp_scsi_init(ispsoftc_t *isp)
}
isp->isp_reqidx = isp->isp_reqodx = mbs.param[4];
} else {
+ MEMZERO(&mbs, sizeof (mbs));
mbs.param[0] = MBOX_INIT_RES_QUEUE;
mbs.param[1] = RESULT_QUEUE_LEN(isp);
mbs.param[2] = DMA_WD1(isp->isp_result_dma);
@@ -1049,6 +1066,7 @@ isp_scsi_init(ispsoftc_t *isp)
}
isp->isp_residx = mbs.param[5];
+ MEMZERO(&mbs, sizeof (mbs));
mbs.param[0] = MBOX_INIT_REQ_QUEUE;
mbs.param[1] = RQUEST_QUEUE_LEN(isp);
mbs.param[2] = DMA_WD1(isp->isp_rquest_dma);
@@ -1070,6 +1088,7 @@ isp_scsi_init(ispsoftc_t *isp)
* to assume not for them.
*/
+ MEMZERO(&mbs, sizeof (mbs));
mbs.param[0] = MBOX_SET_FW_FEATURES;
mbs.param[1] = 0;
if (IS_ULTRA2(isp))
@@ -1153,6 +1172,7 @@ isp_scsi_channel_init(ispsoftc_t *isp, int channel)
*/
sdp->isp_devparam[tgt].goal_flags = sdf = DPARM_DEFAULT;
#endif
+ MEMZERO(&mbs, sizeof (mbs));
mbs.param[0] = MBOX_SET_TARGET_PARAMS;
mbs.param[1] = (channel << 15) | (tgt << 8);
mbs.param[2] = sdf;
@@ -1170,6 +1190,7 @@ isp_scsi_channel_init(ispsoftc_t *isp, int channel)
isp_mboxcmd(isp, &mbs, MBLOGNONE);
if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
sdf = DPARM_SAFE_DFLT;
+ MEMZERO(&mbs, sizeof (mbs));
mbs.param[0] = MBOX_SET_TARGET_PARAMS;
mbs.param[1] = (tgt << 8) | (channel << 15);
mbs.param[2] = sdf;
@@ -1193,6 +1214,7 @@ isp_scsi_channel_init(ispsoftc_t *isp, int channel)
*/
sdp->isp_devparam[tgt].actv_flags = sdf & ~DPARM_TQING;
for (lun = 0; lun < (int) isp->isp_maxluns; lun++) {
+ MEMZERO(&mbs, sizeof (mbs));
mbs.param[0] = MBOX_SET_DEV_QUEUE_PARAMS;
mbs.param[1] = (channel << 15) | (tgt << 8) | lun;
mbs.param[2] = sdp->isp_max_queue_depth;
@@ -1395,7 +1417,6 @@ isp_fibre_init(ispsoftc_t *isp)
}
}
- MEMZERO(&mbs, sizeof (mbs));
/*
* For 22XX > 2.1.26 && 23XX, set some options.
@@ -1407,6 +1428,7 @@ isp_fibre_init(ispsoftc_t *isp)
* Turn on generate AE 8013 on all LIP Resets (2)
* Disable LIP F7 switching (8)
*/
+ MEMZERO(&mbs, sizeof (mbs));
mbs.param[0] = MBOX_SET_FIRMWARE_OPTIONS;
mbs.param[1] = 0xb;
mbs.param[2] = 0;
@@ -1466,14 +1488,15 @@ isp_fibre_init(ispsoftc_t *isp)
/*
* Init the firmware
*/
+ MEMZERO(&mbs, sizeof (mbs));
mbs.param[0] = MBOX_INIT_FIRMWARE;
- mbs.param[1] = 0;
mbs.param[2] = DMA_WD1(fcp->isp_scdma);
mbs.param[3] = DMA_WD0(fcp->isp_scdma);
- mbs.param[4] = 0;
- mbs.param[5] = 0;
mbs.param[6] = DMA_WD3(fcp->isp_scdma);
mbs.param[7] = DMA_WD2(fcp->isp_scdma);
+ isp_prt(isp, ISP_LOGDEBUG0, "INIT F/W from %p (%08x%08x)",
+ fcp->isp_scratch, (uint32_t) ((uint64_t)fcp->isp_scdma >> 32),
+ (uint32_t) fcp->isp_scdma);
MEMORYBARRIER(isp, SYNC_SFORDEV, 0, sizeof (*icbp));
isp_mboxcmd(isp, &mbs, MBLOGALL);
FC_SCRATCH_RELEASE(isp);
@@ -1505,16 +1528,8 @@ isp_getmap(ispsoftc_t *isp, fcpos_map_t *map)
MEMZERO(&mbs, sizeof (mbs));
mbs.param[0] = MBOX_GET_FC_AL_POSITION_MAP;
- mbs.param[1] = 0;
mbs.param[2] = DMA_WD1(fcp->isp_scdma);
mbs.param[3] = DMA_WD0(fcp->isp_scdma);
- /*
- * Unneeded. For the 2100, except for initializing f/w, registers
- * 4/5 have to not be written to.
- * mbs.param[4] = 0;
- * mbs.param[5] = 0;
- *
- */
mbs.param[6] = DMA_WD3(fcp->isp_scdma);
mbs.param[7] = DMA_WD2(fcp->isp_scdma);
FC_SCRATCH_ACQUIRE(isp);
@@ -1556,13 +1571,6 @@ isp_getpdb(ispsoftc_t *isp, int id, isp_pdb_t *pdbp)
}
mbs.param[2] = DMA_WD1(fcp->isp_scdma);
mbs.param[3] = DMA_WD0(fcp->isp_scdma);
- /*
- * Unneeded. For the 2100, except for initializing f/w, registers
- * 4/5 have to not be written to.
- * mbs.param[4] = 0;
- * mbs.param[5] = 0;
- *
- */
mbs.param[6] = DMA_WD3(fcp->isp_scdma);
mbs.param[7] = DMA_WD2(fcp->isp_scdma);
FC_SCRATCH_ACQUIRE(isp);
@@ -1821,6 +1829,7 @@ not_on_fabric:
fcp->isp_gbspeed = 1;
if (IS_23XX(isp)) {
+ MEMZERO(&mbs, sizeof (mbs));
mbs.param[0] = MBOX_GET_SET_DATA_RATE;
mbs.param[1] = MBGSD_GET_RATE;
/* mbs.param[2] undefined if we're just getting rate */
@@ -2056,8 +2065,6 @@ isp_pdb_sync(ispsoftc_t *isp)
} else {
mbs.param[1] = lp->loopid << 8;
}
- mbs.param[2] = 0;
- mbs.param[3] = 0;
isp_mboxcmd(isp, &mbs, MBLOGNONE);
isp_prt(isp, ISP_LOGINFO, plogout,
(int) (lp - fcp->portdb), lp->loopid,
@@ -2505,6 +2512,7 @@ isp_scan_loop(ispsoftc_t *isp)
static int
isp_fabric_mbox_cmd(ispsoftc_t *isp, mbreg_t *mbp)
{
+ /* the caller sets up the mailbox */
isp_mboxcmd(isp, mbp, MBLOGNONE);
if (mbp->param[0] != MBOX_COMMAND_COMPLETE) {
if (FCPARAM(isp)->isp_loopstate == LOOP_SCANNING_FABRIC) {
@@ -3466,7 +3474,6 @@ isp_control(ispsoftc_t *isp, ispctl_t ctl, void *arg)
* Issue a bus reset.
*/
mbs.param[0] = MBOX_BUS_RESET;
- mbs.param[2] = 0;
if (IS_SCSI(isp)) {
mbs.param[1] =
((sdparam *) isp->isp_param)->isp_bus_reset_delay;
@@ -3532,8 +3539,6 @@ isp_control(ispsoftc_t *isp, ispctl_t ctl, void *arg)
} else {
mbs.param[1] = tgt << 8;
}
- mbs.param[4] = 0;
- mbs.param[5] = 0;
mbs.param[6] = XS_LUN(xs);
} else {
mbs.param[1] = tgt << 8 | XS_LUN(xs);
@@ -3542,7 +3547,6 @@ isp_control(ispsoftc_t *isp, ispctl_t ctl, void *arg)
mbs.param[1] =
(bus << 15) | (XS_TGT(xs) << 8) | XS_LUN(xs);
}
- mbs.param[3] = 0;
mbs.param[2] = handle;
isp_mboxcmd(isp, &mbs, MBLOGALL & ~MBOX_COMMAND_ERROR);
if (mbs.param[0] == MBOX_COMMAND_COMPLETE) {
@@ -5316,7 +5320,7 @@ static const uint32_t mbpfc[] = {
ISPOPMAP(0x07, 0x03), /* 0x5d: MBOX_GET_SET_DATA_RATE */
ISPOPMAP(0x00, 0x00), /* 0x5e: */
ISPOPMAP(0x00, 0x00), /* 0x5f: */
- ISPOPMAP(0xfd, 0x31), /* 0x60: MBOX_INIT_FIRMWARE */
+ ISPOPMAP(0xcd, 0x31), /* 0x60: MBOX_INIT_FIRMWARE */
ISPOPMAP(0x00, 0x00), /* 0x61: */
ISPOPMAP(0x01, 0x01), /* 0x62: MBOX_INIT_LIP */
ISPOPMAP(0xcd, 0x03), /* 0x63: MBOX_GET_FC_AL_POSITION_MAP */
@@ -5572,6 +5576,8 @@ isp_mboxcmd(ispsoftc_t *isp, mbreg_t *mbp, int logmask)
for (box = 0; box < MAX_MAILBOX(isp); box++) {
if (ibits & (1 << box)) {
+ isp_prt(isp, ISP_LOGDEBUG1, "IN mbox %d = 0x%x", box,
+ mbp->param[box]);
ISP_WRITE(isp, MBOX_OFF(box), mbp->param[box]);
}
isp->isp_mboxtmp[box] = mbp->param[box] = 0;
@@ -5610,6 +5616,8 @@ isp_mboxcmd(ispsoftc_t *isp, mbreg_t *mbp, int logmask)
for (box = 0; box < MAX_MAILBOX(isp); box++) {
if (obits & (1 << box)) {
mbp->param[box] = isp->isp_mboxtmp[box];
+ isp_prt(isp, ISP_LOGDEBUG1, "OUT mbox %d = 0x%x", box,
+ mbp->param[box]);
}
}
@@ -5734,7 +5742,6 @@ isp_update_bus(ispsoftc_t *isp, int bus)
}
sdp = isp->isp_param;
sdp += bus;
- MEMZERO(&mbs, sizeof (mbs));
for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
uint16_t flags, period, offset;
@@ -5754,6 +5761,8 @@ isp_update_bus(ispsoftc_t *isp, int bus)
* current device state, get the current parameters.
*/
+ MEMZERO(&mbs, sizeof (mbs));
+
/*
* Refresh overrides set
*/
@@ -5780,9 +5789,7 @@ isp_update_bus(ispsoftc_t *isp, int bus)
mbs.param[2] |= DPARM_PARITY;
}
- if ((mbs.param[2] & DPARM_SYNC) == 0) {
- mbs.param[3] = 0;
- } else {
+ if (mbs.param[2] & DPARM_SYNC) {
mbs.param[3] =
(sdp->isp_devparam[tgt].goal_offset << 8) |
(sdp->isp_devparam[tgt].goal_period);
@@ -5847,10 +5854,8 @@ static void
isp_setdfltparm(ispsoftc_t *isp, int channel)
{
int tgt;
- mbreg_t mbs;
sdparam *sdp;
- MEMZERO(&mbs, sizeof (mbs));
if (IS_FC(isp)) {
fcparam *fcp = (fcparam *) isp->isp_param;
int nvfail;
@@ -5997,6 +6002,9 @@ isp_setdfltparm(ispsoftc_t *isp, int channel)
* Now try and see whether we have specific values for them.
*/
if ((isp->isp_confopts & ISP_CFG_NONVRAM) == 0) {
+ mbreg_t mbs;
+
+ MEMZERO(&mbs, sizeof (mbs));
mbs.param[0] = MBOX_GET_ACT_NEG_STATE;
isp_mboxcmd(isp, &mbs, MBLOGNONE);
if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
@@ -6960,6 +6968,7 @@ isp2300_fw_dump(ispsoftc_t *isp)
return;
}
ENABLE_INTS(isp);
+ MEMZERO(&mbs, sizeof (mbs));
mbs.param[0] = MBOX_READ_RAM_WORD;
mbs.param[1] = 0x800;
isp->isp_mbxworkp = (void *) ptr;
@@ -6973,8 +6982,8 @@ isp2300_fw_dump(ispsoftc_t *isp)
}
ptr = isp->isp_mbxworkp; /* finish fetch of final word */
*ptr++ = isp->isp_mboxtmp[2];
+ MEMZERO(&mbs, sizeof (mbs));
mbs.param[0] = MBOX_READ_RAM_WORD_EXTENDED;
- mbs.param[1] = 0;
mbs.param[8] = 1;
isp->isp_mbxworkp = (void *) ptr;
isp->isp_mbxwrk0 = 0xffff; /* continuation count */
OpenPOWER on IntegriCloud