Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/ic Some whitespace cleanup. Initial forcelout support.



details:   https://anonhg.NetBSD.org/src/rev/3c066f0d78cc
branches:  trunk
changeset: 512123:3c066f0d78cc
user:      mjacob <mjacob%NetBSD.org@localhost>
date:      Fri Jul 06 16:15:38 2001 +0000

description:
Some whitespace cleanup. Initial forcelout support.

Fix longstanding bug where we should have been checking
against Channel B's settings to see whether to apply tag
usage. Oops.

Some more 2300 support- macroize access to request queue in/out pointers.
Firmware crashes now handled in platform outer code via an isp_async call.

If we get a LIP, and we're on a private or public loop, kill off all
active commands as if they had been killed by a 'SCSI Bus Reset'. I've
seen data corruption on commands that complete 'normally' after a LIP.
Bad.

diffstat:

 sys/dev/ic/isp.c |  96 ++++++++++++++++++++++++++++++++++---------------------
 1 files changed, 59 insertions(+), 37 deletions(-)

diffs (truncated from 307 to 300 lines):

diff -r 72fede13f842 -r 3c066f0d78cc sys/dev/ic/isp.c
--- a/sys/dev/ic/isp.c  Fri Jul 06 16:09:38 2001 +0000
+++ b/sys/dev/ic/isp.c  Fri Jul 06 16:15:38 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: isp.c,v 1.77 2001/05/25 21:45:55 mjacob Exp $ */
+/* $NetBSD: isp.c,v 1.78 2001/07/06 16:15:38 mjacob Exp $ */
 /*
  * This driver, which is contained in NetBSD in the files:
  *
@@ -98,7 +98,7 @@
     "Target %d Loop ID 0x%x (Port 0x%x) => Loop 0x%x (Port 0x%x)";
 static const char portdup[] =
     "Target %d duplicates Target %d- killing off both";
-static const char retained[] = 
+static const char retained[] =
     "Retaining Loop ID 0x%x for Target %d (Port 0x%x)";
 static const char lretained[] =
     "Retained login of Target %d (Loop ID 0x%x) Port 0x%x";
@@ -362,11 +362,11 @@
                        isp->isp_type = ISP_HA_SCSI_1040B;
                        isp->isp_clock = 60;
                        break;
-               case 6: 
+               case 6:
                        revname = "1040C";
                        isp->isp_type = ISP_HA_SCSI_1040C;
                        isp->isp_clock = 60;
-                        break; 
+                        break;
                }
                /*
                 * Now, while we're at it, gather info about ultra
@@ -1124,7 +1124,7 @@
         */
        fcp->isp_fwoptions |= ICBOPT_PDBCHANGE_AE;
 
-       
+
        /*
         * Make sure that target role reflects into fwoptions.
         */
@@ -1597,7 +1597,7 @@
         * Make sure we're okay for doing this right now.
         */
        if (fcp->isp_loopstate != LOOP_PDB_RCVD &&
-           fcp->isp_loopstate != LOOP_FSCAN_DONE && 
+           fcp->isp_loopstate != LOOP_FSCAN_DONE &&
            fcp->isp_loopstate != LOOP_LSCAN_DONE) {
                return (-1);
        }
@@ -1690,7 +1690,7 @@
                    isp_getpdb(isp, lp->loopid, &pdb) == 0) {
                        int nrole;
                        u_int64_t nwwnn, nwwpn;
-                       nwwnn = 
+                       nwwnn =
                            (((u_int64_t)pdb.pdb_nodename[0]) << 56) |
                            (((u_int64_t)pdb.pdb_nodename[1]) << 48) |
                            (((u_int64_t)pdb.pdb_nodename[2]) << 40) |
@@ -1699,7 +1699,7 @@
                            (((u_int64_t)pdb.pdb_nodename[5]) << 16) |
                            (((u_int64_t)pdb.pdb_nodename[6]) <<  8) |
                            (((u_int64_t)pdb.pdb_nodename[7]));
-                       nwwpn = 
+                       nwwpn =
                            (((u_int64_t)pdb.pdb_portname[0]) << 56) |
                            (((u_int64_t)pdb.pdb_portname[1]) << 48) |
                            (((u_int64_t)pdb.pdb_portname[2]) << 40) |
@@ -1713,7 +1713,7 @@
                        if (pdb.pdb_loopid == lp->loopid && lp->portid ==
                            (u_int32_t) BITS2WORD(pdb.pdb_portid_bits) &&
                            nwwnn == lp->node_wwn && nwwpn == lp->port_wwn &&
-                           lp->roles == nrole) {
+                           lp->roles == nrole && lp->force_logout == 0) {
                                lp->loggedin = lp->valid = 1;
                                isp_prt(isp, ISP_LOGINFO, lretained,
                                    (int) (lp - fcp->portdb),
@@ -1722,6 +1722,8 @@
                        }
                }
 
+               lp->force_logout = 0;
+
                if (fcp->isp_fwstate != FW_READY ||
                    fcp->isp_loopstate != LOOP_SYNCING_PDB) {
                        return (-1);
@@ -2103,6 +2105,8 @@
                 * No need to notify anyone- go for the next one.
                 */
                if (i < hival) {
+                       isp_prt(isp, ISP_LOGINFO, retained,
+                           fcp->portdb[i].loopid, i, fcp->portdb[i].portid);
                        continue;
                }
 
@@ -2154,7 +2158,7 @@
                /*
                 * Tell the outside world we've gone
                 * away and erase our pdb entry.
-                * 
+                *
                 */
                loopid = lp - fcp->portdb;
                (void) isp_async(isp, ISPASYNC_PROMENADE, &loopid);
@@ -2585,6 +2589,7 @@
                }
        } else {
                sdparam *sdp = (sdparam *)isp->isp_param;
+               sdp += XS_CHANNEL(xs);
                if ((sdp->isp_devparam[target].cur_dflags & DPARM_TQING) &&
                    XS_TAG_P(xs)) {
                        reqp->req_flags = XS_TAG_TYPE(xs);
@@ -2933,22 +2938,24 @@
        if (isp->isp_state != ISP_RUNSTATE) {
                isp_prt(isp, ISP_LOGWARN,
                    "interrupt (isr=%x, sema=%x) when not ready", isr, sema);
-               ISP_WRITE(isp, INMAILBOX5, ISP_READ(isp, OUTMAILBOX5));
+               WRITE_RESPONSE_QUEUE_IN_POINTER(isp,
+                   READ_RESPONSE_QUEUE_OUT_POINTER(isp));
                ISP_WRITE(isp, HCCR, HCCR_CMD_CLEAR_RISC_INT);
                ISP_WRITE(isp, BIU_SEMA, 0);
                return (1);
        }
 
        /*
-        * You *must* read OUTMAILBOX5 prior to clearing the RISC interrupt.
+        * You *must* read the Response Queue Out Pointer
+        * prior to clearing the RISC interrupt.
         */
        optr = isp->isp_residx;
 
        if (IS_2100(isp)) {
                i = 0;
                do {
-                       iptr = ISP_READ(isp, OUTMAILBOX5);
-                       junk = ISP_READ(isp, OUTMAILBOX5);
+                       iptr = READ_RESPONSE_QUEUE_OUT_POINTER(isp);
+                       junk = READ_RESPONSE_QUEUE_OUT_POINTER(isp);
                } while (junk != iptr && ++i < 1000);
 
                if (iptr != junk) {
@@ -2958,7 +2965,7 @@
                        return (1);
                }
        } else {
-               iptr = ISP_READ(isp, OUTMAILBOX5);
+               iptr = READ_RESPONSE_QUEUE_OUT_POINTER(isp);
        }
 
        if (sema) {
@@ -3027,7 +3034,7 @@
                        if (sp->req_header.rqs_flags & RQSFLAG_CONTINUATION) {
                                isp_prt(isp, ISP_LOGWARN,
                                    "continuation segment");
-                               ISP_WRITE(isp, INMAILBOX5, optr);
+                               WRITE_RESPONSE_QUEUE_IN_POINTER(isp, optr);
                                continue;
                        }
                        if (sp->req_header.rqs_flags & RQSFLAG_FULL) {
@@ -3059,7 +3066,7 @@
                            "bad request handle %d (type 0x%x, flags 0x%x)",
                            sp->req_handle, sp->req_header.rqs_entry_type,
                            sp->req_header.rqs_flags);
-                       ISP_WRITE(isp, INMAILBOX5, optr);
+                       WRITE_RESPONSE_QUEUE_IN_POINTER(isp, optr);
                        continue;
                }
                xs = isp_find_xs(isp, sp->req_handle);
@@ -3068,7 +3075,7 @@
                        isp_prt(isp, ISP_LOGERR,
                            "cannot find handle 0x%x in xflist",
                            sp->req_handle);
-                       ISP_WRITE(isp, INMAILBOX5, optr);
+                       WRITE_RESPONSE_QUEUE_IN_POINTER(isp, optr);
                        continue;
                }
                isp_destroy_handle(isp, sp->req_handle);
@@ -3203,8 +3210,8 @@
         * ISP's notion of what we've seen so far.
         */
        if (nlooked) {
-               ISP_WRITE(isp, INMAILBOX5, optr);
-               isp->isp_reqodx = ISP_READ(isp, OUTMAILBOX4);
+               WRITE_RESPONSE_QUEUE_IN_POINTER(isp, optr);
+               isp->isp_reqodx = READ_REQUEST_QUEUE_OUT_POINTER(isp);
        }
 
        isp->isp_residx = optr;
@@ -3242,14 +3249,7 @@
                isp_async(isp, ISPASYNC_BUS_RESET, &bus);
                break;
        case ASYNC_SYSTEM_ERROR:
-               mbox = ISP_READ(isp, OUTMAILBOX1);
-               isp_prt(isp, ISP_LOGERR,
-                   "Internal Firmware Error @ RISC Addr 0x%x", mbox);
-               ISP_DUMPREGS(isp, "Firmware Error");
-               isp_reinit(isp);
-#ifdef ISP_TARGET_MODE
-               isp_target_async(isp, bus, ASYNC_SYSTEM_ERROR);
-#endif
+               isp_async(isp, ISPASYNC_FW_CRASH, NULL);
                /* no point continuing after this */
                return (-1);
 
@@ -3267,7 +3267,7 @@
                 * We don't need to be chatty about this- just unlatch things
                 * and move on.
                 */
-               mbox = ISP_READ(isp, OUTMAILBOX4);
+               mbox = READ_REQUEST_QUEUE_OUT_POINTER(isp);
                break;
 
        case ASYNC_TIMEOUT_RESET:
@@ -3371,6 +3371,29 @@
 #ifdef ISP_TARGET_MODE
                isp_target_async(isp, bus, mbox);
 #endif
+               /*
+                * We've had problems with data corruption occuring on
+                * commands that complete (with no apparent error) after
+                * we receive a LIP. This has been observed mostly on
+                * Local Loop topologies. To be safe, let's just mark
+                * all active commands as dead.
+                */
+               if (FCPARAM(isp)->isp_topo == TOPO_NL_PORT ||
+                   FCPARAM(isp)->isp_topo == TOPO_FL_PORT) {
+                       int i, j;
+                       for (i = j = 0; i < isp->isp_maxcmds; i++) {
+                               XS_T *xs;
+                               xs = isp->isp_xflist[i];
+                               if (xs != NULL) {
+                                       j++;
+                                       XS_SETERR(xs, HBA_BUSRESET);
+                               }
+                       }
+                       if (j) {
+                               isp_prt(isp, ISP_LOGERR,
+                                   "LIP destroyed %d active commands", j);
+                       }
+               }
                break;
 
        case ASYNC_LOOP_UP:
@@ -3738,8 +3761,8 @@
                break;
 
        case RQCS_XACT_ERR3:
-               isp_prt(isp, ISP_LOGERR, xact3, XS_TGT(xs),
-                   XS_LUN(xs), XS_CHANNEL(xs));
+               isp_prt(isp, ISP_LOGERR, xact3,
+                   XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
                break;
 
        case RQCS_BAD_ENTRY:
@@ -3819,7 +3842,6 @@
                        XS_SETERR(xs, HBA_SELTIMEOUT);
                }
                return;
-
        case RQCS_PORT_LOGGED_OUT:
                /*
                 * It was there (maybe)- treat as a selection timeout.
@@ -4565,7 +4587,7 @@
                        sdp->isp_devparam[tgt].dev_flags &= ~DPARM_QFRZ;
 
                        mbs.param[2] = sdp->isp_devparam[tgt].dev_flags;
-                       
+
                        /*
                         * Insist that PARITY must be enabled
                         * if SYNC or WIDE is enabled.
@@ -5176,7 +5198,7 @@
        sdparam *sdp = (sdparam *) isp->isp_param;
        sdp += bus;
 
-       sdp->isp_fifo_threshold = 
+       sdp->isp_fifo_threshold =
            ISP1080_NVRAM_FIFO_THRESHOLD(nvram_data);
 
        sdp->isp_initiator_id =
@@ -5253,7 +5275,7 @@
        sdp->isp_fifo_threshold =
            ISP12160_NVRAM_FIFO_THRESHOLD(nvram_data);
 
-       sdp->isp_initiator_id = 
+       sdp->isp_initiator_id =
            ISP12160_NVRAM_INITIATOR_ID(nvram_data, bus);
 
        sdp->isp_bus_reset_delay =
@@ -5338,7 +5360,7 @@
                isp_prt(isp, ISP_LOGCONFIG, "NVRAM Port WWN 0x%08x%08x",
                    (u_int32_t) (wwn >> 32), (u_int32_t) (wwn & 0xffffffff));
                if ((wwn >> 60) == 0) {
-                       wwn |= (((u_int64_t) 2)<< 60); 
+                       wwn |= (((u_int64_t) 2)<< 60);
                }
        }
        fcp->isp_portwwn = wwn;
@@ -5347,7 +5369,7 @@
                isp_prt(isp, ISP_LOGCONFIG, "NVRAM Node WWN 0x%08x%08x",



Home | Main Index | Thread Index | Old Index