Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/ic Back out previous commit- the author is incorrect...



details:   https://anonhg.NetBSD.org/src/rev/f8333bdcbdd1
branches:  trunk
changeset: 494348:f8333bdcbdd1
user:      mjacob <mjacob%NetBSD.org@localhost>
date:      Wed Jul 05 22:20:51 2000 +0000

description:
Back out previous commit- the author is incorrect. There is no 'narrow'
Qlogic controller driven by this chipset. If they don't want the verbosity,
don't compile a DIAGNOSTIC kernel.

Major amount of mailbox command rewrites- hopefully should fix some of the
outstanding PRs.

Change header to note that this is no longer maintained at NASA/Ames.

diffstat:

 sys/dev/ic/isp.c |  1003 +++++++++++++++++++++++++----------------------------
 1 files changed, 479 insertions(+), 524 deletions(-)

diffs (truncated from 1250 to 300 lines):

diff -r a78803630778 -r f8333bdcbdd1 sys/dev/ic/isp.c
--- a/sys/dev/ic/isp.c  Wed Jul 05 22:15:04 2000 +0000
+++ b/sys/dev/ic/isp.c  Wed Jul 05 22:20:51 2000 +0000
@@ -1,35 +1,35 @@
-/* $NetBSD: isp.c,v 1.53 2000/06/03 22:44:43 fair Exp $ */
+/* $NetBSD: isp.c,v 1.54 2000/07/05 22:20:51 mjacob Exp $ */
 /*
- * Copyright (C) 1997, 1998, 1999 National Aeronautics & Space Administration
+ * Machine and OS Independent (well, as best as possible)
+ * code for the Qlogic ISP SCSI adapters.
+ *
+ * Copyright (c) 1997, 1998, 1999 by Matthew Jacob
+ * NASA/Ames Research Center
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
+ *    notice immediately at the beginning of the file, without modification,
+ *    this list of conditions, and the following disclaimer.
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
  * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission
+ *    derived from this software without specific prior written permission.
  *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * Machine and OS Independent (well, as best as possible)
- * code for the Qlogic ISP SCSI adapters.
- * Matthew Jacob <mjacob%nas.nasa.gov@localhost>
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
  */
 
 /*
@@ -113,7 +113,7 @@
        struct ispsoftc *isp;
 {
        mbreg_t mbs;
-       int loops, i, dodnld = 1;
+       int loops, i, touched, dodnld = 1;
        char *revname;
 
        isp->isp_state = ISP_NILSTATE;
@@ -138,7 +138,7 @@
         * case, we don't really use this yet, but we may in
         * the future.
         */
-       if (isp->isp_touched == 0) {
+       if ((touched = isp->isp_touched) == 0) {
                /*
                 * Just in case it was paused...
                 */
@@ -576,6 +576,8 @@
        else
                mbs.param[1] = 0x1000;
        isp_mboxcmd(isp, &mbs);
+       /* give it a chance to start */
+       SYS_DELAY(500);
 
        if (IS_SCSI(isp)) {
                /*
@@ -636,6 +638,46 @@
                return;
        }
        isp->isp_state = ISP_RESETSTATE;
+
+       /*
+        * Okay- now that we have new firmware running, we now (re)set our
+        * notion of how many luns we support. This is somewhat tricky because
+        * if we haven't loaded firmware, we don't have an easy way of telling
+        * how many luns we support.
+        *
+        * We'll make a simplifying assumption- if we loaded firmware, we
+        * are running with expanded lun firmware, otherwise not.
+        *
+        * Expanded lun firmware gives you 32 luns for SCSI cards and
+        * 65536 luns for Fibre Channel cards.
+        *
+        * Because the lun is in a a different position in the Request Queue
+        * Entry structure for Fibre Channel with expanded lun firmware, we
+        * can only support one lun (lun zero) when we don't know what kind
+        * of firmware we're running.
+        *
+        * Note that we only do this once (the first time thru isp_reset)
+        * because we may be called again after firmware has been loaded once
+        * and released.
+        */
+       if (touched == 0) {
+               if (dodnld) {
+                       if (IS_SCSI(isp)) {
+                               isp->isp_maxluns = 32;
+                       } else {
+                               isp->isp_maxluns = 65536;
+                       }
+               } else {
+                       if (IS_SCSI(isp)) {
+                               isp->isp_maxluns = 8;
+                       } else {
+                               PRINTF("%s: WARNING- cannot determine Expanded "
+                                   "LUN capability- limiting to one LUN\n",
+                                   isp->isp_name);
+                               isp->isp_maxluns = 1;
+                       }
+               }
+       }
 }
 
 /*
@@ -861,11 +903,11 @@
         * Set current per-target parameters to a safe minimum.
         */
        for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
-               int maxlun, lun;
+               int lun;
                u_int16_t sdf;
 
                if (sdp->isp_devparam[tgt].dev_enable == 0) {
-                       IDPRINTF(3, ("%s: skipping target %d bus %d settings\n",
+                       IDPRINTF(1, ("%s: skipping target %d bus %d settings\n",
                            isp->isp_name, tgt, channel));
                        continue;
                }
@@ -952,13 +994,7 @@
                 * seen yet.
                 */
                sdp->isp_devparam[tgt].cur_dflags &= ~DPARM_TQING;
-               if ((ISP_FW_REV(4, 55, 0) <= ISP_FW_REVX(isp->isp_fwrev) &&
-                   (ISP_FW_REV(5, 0, 0) > ISP_FW_REVX(isp->isp_fwrev))) ||
-                   (ISP_FW_REVX(isp->isp_fwrev) >= ISP_FW_REV(7, 55, 0)))
-                       maxlun = 32;
-               else
-                       maxlun = 8;
-               for (lun = 0; lun < maxlun; lun++) {
+               for (lun = 0; lun < isp->isp_maxluns; lun++) {
                        mbs.param[0] = MBOX_SET_DEV_QUEUE_PARAMS;
                        mbs.param[1] = (channel << 15) | (tgt << 8) | lun;
                        mbs.param[2] = sdp->isp_max_queue_depth;
@@ -1434,12 +1470,12 @@
        for (lim = loopid = 0; loopid < prange; loopid++) {
                lp = &tport[loopid];
                lp->node_wwn = isp_get_portname(isp, loopid, 1);
-               if (fcp->isp_loopstate != LOOP_PDB_RCVD)
+               if (fcp->isp_loopstate < LOOP_PDB_RCVD)
                        return (-1);
                if (lp->node_wwn == 0)
                        continue;
                lp->port_wwn = isp_get_portname(isp, loopid, 0);
-               if (fcp->isp_loopstate != LOOP_PDB_RCVD)
+               if (fcp->isp_loopstate < LOOP_PDB_RCVD)
                        return (-1);
                if (lp->port_wwn == 0) {
                        lp->node_wwn = 0;
@@ -1450,12 +1486,12 @@
                 * Get an entry....
                 */
                if (isp_getpdb(isp, loopid, &pdb) != 0) {
-                       if (fcp->isp_loopstate != LOOP_PDB_RCVD)
+                       if (fcp->isp_loopstate < LOOP_PDB_RCVD)
                                return (-1);
                        continue;
                }
 
-               if (fcp->isp_loopstate != LOOP_PDB_RCVD)
+               if (fcp->isp_loopstate < LOOP_PDB_RCVD)
                        return (-1);
 
                /*
@@ -2182,11 +2218,10 @@
                reqp->req_lun_trn = XS_LUN(xs);
                reqp->req_cdblen = XS_CDBLEN(xs);
        } else {
-#ifdef ISP2100_SCCLUN
-               t2reqp->req_scclun = XS_LUN(xs);
-#else
-               t2reqp->req_lun_trn = XS_LUN(xs);
-#endif
+               if (isp->isp_maxluns > 16)
+                       t2reqp->req_scclun = XS_LUN(xs);
+               else
+                       t2reqp->req_lun_trn = XS_LUN(xs);
        }
        MEMCPY(reqp->req_cdb, XS_CDBP(xs), XS_CDBLEN(xs));
 
@@ -2302,6 +2337,7 @@
 
        case ISPCTL_ABORT_CMD:
                xs = (ISP_SCSI_XFER_T *) arg;
+               tgt = XS_TGT(xs);
                handle = isp_find_handle(isp, xs);
                if (handle == 0) {
                        PRINTF("%s: isp_control- cannot find command to abort "
@@ -2311,14 +2347,14 @@
                bus = XS_CHANNEL(xs);
                mbs.param[0] = MBOX_ABORT;
                if (IS_FC(isp)) {
-#ifdef ISP2100_SCCLUN
-                       mbs.param[1] = XS_TGT(xs) << 8;
-                       mbs.param[4] = 0;
-                       mbs.param[5] = 0;
-                       mbs.param[6] = XS_LUN(xs);
-#else
-                       mbs.param[1] = XS_TGT(xs) << 8 | XS_LUN(xs);
-#endif
+                       if (isp->isp_maxluns > 16) {
+                               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);
+                       }
                } else {
                        mbs.param[1] =
                            (bus << 15) | (XS_TGT(xs) << 8) | XS_LUN(xs);
@@ -2326,13 +2362,19 @@
                mbs.param[3] = handle >> 16;
                mbs.param[2] = handle & 0xffff;
                isp_mboxcmd(isp, &mbs);
-               if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
-                       PRINTF("%s: isp_control MBOX_ABORT failure (code %x)\n",
-                           isp->isp_name, mbs.param[0]);
+               switch (mbs.param[0]) {
+               case MBOX_COMMAND_COMPLETE:
+                       IDPRINTF(1,
+                           ("%s: command (handle 0x%x) for %d.%d.%d aborted\n",
+                           isp->isp_name, handle, bus, tgt, XS_LUN(xs)));
+                       /* FALLTHROUGH */
+               case MBOX_COMMAND_PARAM_ERROR:
+                       break;
+               default:
+                       PRINTF("%s: command (handle 0x%x) abort failed (%x)\n",
+                           isp->isp_name, handle, mbs.param[0]);
                        break;
                }
-               PRINTF("%s: command for target %d lun %d was aborted\n",
-                   isp->isp_name, XS_TGT(xs), XS_LUN(xs));
                return (0);
 
        case ISPCTL_UPDATE_PARAMS:
@@ -2340,10 +2382,16 @@
                return (0);
 
        case ISPCTL_FCLINK_TEST:
-               return (isp_fclink_test(isp, FC_FW_READY_DELAY));
+               if (IS_FC(isp)) {
+                       return (isp_fclink_test(isp, FC_FW_READY_DELAY));
+               }
+               break;
 
        case ISPCTL_PDB_SYNC:
-               return (isp_pdb_sync(isp, -1));
+               if (IS_FC(isp)) {
+                       return (isp_pdb_sync(isp, -1));
+               }
+               break;
 
 #ifdef ISP_TARGET_MODE
        case ISPCTL_TOGGLE_TMODE:
@@ -2378,39 +2426,74 @@
 {
        ISP_SCSI_XFER_T *complist[RESULT_QUEUE_LEN], *xs;
        struct ispsoftc *isp = arg;
-       u_int16_t iptr, optr;
-       u_int16_t isr, sema;
+       u_int16_t iptr, optr, isr, sema, junk;
        int i, nlooked = 0, ndone = 0;
 
-       /*
-        * Well, if we've disabled interrupts, we may get a case where
-        * isr isn't set, but sema is.
-        */
-       isr = ISP_READ(isp, BIU_ISR);
-       sema = ISP_READ(isp, BIU_SEMA) & 0x1;
+       if (IS_2100(isp)) {
+               i = 0;



Home | Main Index | Thread Index | Old Index