Source-Changes-HG archive

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

[src/trunk]: src/sys/dev Synchronize with other platforms:



details:   https://anonhg.NetBSD.org/src/rev/0435bf063560
branches:  trunk
changeset: 753408:0435bf063560
user:      mjacob <mjacob%NetBSD.org@localhost>
date:      Fri Mar 26 20:52:00 2010 +0000

description:
Synchronize with other platforms:

        Strongly architect handles so we can more easily detect bogus
        handles. This switches us to a full 32 bits for all handles.

        Handle the case of FC disks disappearing and then reappearing-
        at least at the FC transport level.

        Some better and finer control of debug and non-debug printouts.

diffstat:

 sys/dev/ic/isp.c         |  714 ++++++++++++++++++++--------------------------
 sys/dev/ic/isp_library.c |  184 ++++++-----
 sys/dev/ic/isp_library.h |   11 +-
 sys/dev/ic/isp_netbsd.c  |   20 +-
 sys/dev/ic/isp_netbsd.h  |    9 +-
 sys/dev/ic/isp_stds.h    |    4 +-
 sys/dev/ic/isp_target.c  |    8 +-
 sys/dev/ic/ispmbox.h     |   25 +-
 sys/dev/ic/ispreg.h      |    6 +-
 sys/dev/ic/ispvar.h      |   70 ++++-
 sys/dev/pci/isp_pci.c    |   33 +-
 sys/dev/sbus/isp_sbus.c  |   32 +-
 12 files changed, 568 insertions(+), 548 deletions(-)

diffs (truncated from 2334 to 300 lines):

diff -r 67ab2741e69b -r 0435bf063560 sys/dev/ic/isp.c
--- a/sys/dev/ic/isp.c  Fri Mar 26 20:31:06 2010 +0000
+++ b/sys/dev/ic/isp.c  Fri Mar 26 20:52:00 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: isp.c,v 1.120 2010/01/15 20:09:09 mjacob Exp $ */
+/* $NetBSD: isp.c,v 1.121 2010/03/26 20:52:00 mjacob Exp $ */
 /*
  * Machine and OS Independent (well, as best as possible)
  * code for the Qlogic ISP SCSI adapters.
@@ -43,7 +43,7 @@
  */
 #ifdef __NetBSD__
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: isp.c,v 1.120 2010/01/15 20:09:09 mjacob Exp $");
+__KERNEL_RCSID(0, "$NetBSD: isp.c,v 1.121 2010/03/26 20:52:00 mjacob Exp $");
 #include <dev/ic/isp_netbsd.h>
 #endif
 #ifdef __FreeBSD__
@@ -64,7 +64,6 @@
 /*
  * General defines
  */
-
 #define        MBOX_DELAY_COUNT        1000000 / 100
 #define        ISP_MARK_PORTDB(a, b, c)                                \
     isp_prt(isp, ISP_LOGSANCFG,                                \
@@ -76,14 +75,9 @@
  */
 static const char fconf[] = "Chan %d PortDB[%d] changed:\n current =(0x%x@0x%06x 0x%08x%08x 0x%08x%08x)\n database=(0x%x@0x%06x 0x%08x%08x 0x%08x%08x)";
 static const char notresp[] = "Not RESPONSE in RESPONSE Queue (type 0x%x) @ idx %d (next %d) nlooked %d";
-static const char xact1[] = "HBA attempted queued transaction with disconnect not set for %d.%d.%d";
-static const char xact2[] = "HBA attempted queued transaction to target routine %d on target %d bus %d";
-static const char xact3[] = "HBA attempted queued cmd for %d.%d.%d when queueing disabled";
-static const char pskip[] = "SCSI phase skipped for target %d.%d.%d";
 static const char topology[] = "Chan %d WWPN 0x%08x%08x PortID 0x%06x N-Port Handle %d, Connection '%s'";
-static const char finmsg[] = "%d.%d.%d: FIN dl%d resid %ld STS 0x%x SKEY %c XS_ERR=0x%x";
 static const char sc4[] = "NVRAM";
-static const char bun[] = "bad underrun for %d.%d (count %d, resid %d, status %s)";
+static const char bun[] = "bad underrun (count %d, resid %d, status %s)";
 static const char lipd[] = "Chan %d LIP destroyed %d active commands";
 static const char sacq[] = "unable to acquire scratch area";
 
@@ -109,11 +103,13 @@
 /*
  * Local function prototypes.
  */
+static void isp_prt_endcmd(ispsoftc_t *, XS_T *);
 static int isp_parse_async(ispsoftc_t *, uint16_t);
+static int isp_parse_async_fc(ispsoftc_t *, uint16_t);
 static int isp_handle_other_response(ispsoftc_t *, int, isphdr_t *, uint32_t *);
 static void isp_parse_status(ispsoftc_t *, ispstatusreq_t *, XS_T *, long *); static void
 isp_parse_status_24xx(ispsoftc_t *, isp24xx_statusreq_t *, XS_T *, long *);
-static void isp_fastpost_complete(ispsoftc_t *, uint16_t);
+static void isp_fastpost_complete(ispsoftc_t *, uint32_t);
 static int isp_mbox_continue(ispsoftc_t *);
 static void isp_scsi_init(ispsoftc_t *);
 static void isp_scsi_channel_init(ispsoftc_t *, int);
@@ -696,7 +692,7 @@
        mbs.logval = MBLOGALL;
        isp_mboxcmd(isp, &mbs);
        if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
-               isp_prt(isp, ISP_LOGERR, "NOP ommand failed (%x)", mbs.param[0]);
+               isp_prt(isp, ISP_LOGERR, "NOP command failed (%x)", mbs.param[0]);
                ISP_RESET0(isp);
                return;
        }
@@ -1336,23 +1332,24 @@
        }
 
        /*
-        * Turn on Fast Posting, LVD transitions
+        * Turn on LVD transitions for ULTRA2 or better and other features
         *
-        * Ultra2 F/W always has had fast posting (and LVD transitions)
-        *
-        * Ultra and older (i.e., SBus) cards may not. It's just safer
-        * to assume not for them.
+        * Now that we have 32 bit handles, don't do any fast posting
+        * any more. For Ultra2/Ultra3 cards, we can turn on 32 bit RIO
+        * operation or use fast posting. To be conservative, we'll only
+        * do this for Ultra3 cards now because the other cards are so
+        * rare for this author to find and test with.
         */
 
        MBSINIT(&mbs, MBOX_SET_FW_FEATURES, MBLOGALL, 0);
        if (IS_ULTRA2(isp))
                mbs.param[1] |= FW_FEATURE_LVD_NOTIFY;
-#ifndef        ISP_NO_RIO
-       if (IS_ULTRA2(isp) || IS_1240(isp))
-               mbs.param[1] |= FW_FEATURE_RIO_16BIT;
+#ifdef ISP_NO_RIO
+       if (IS_ULTRA3(isp))
+               mbs.param[1] |= FW_FEATURE_FAST_POST;
 #else
-       if (IS_ULTRA2(isp) || IS_1240(isp))
-               mbs.param[1] |= FW_FEATURE_FAST_POST;
+       if (IS_ULTRA3(isp))
+               mbs.param[1] |= FW_FEATURE_RIO_32BIT;
 #endif
        if (mbs.param[1] != 0) {
                uint16_t sfeat = mbs.param[1];
@@ -1431,10 +1428,8 @@
                            (sdp->isp_devparam[tgt].goal_offset << 8) |
                            (sdp->isp_devparam[tgt].goal_period);
                }
-               isp_prt(isp, ISP_LOGDEBUG0,
-                   "Initial Settings bus%d tgt%d flags 0x%x off 0x%x per 0x%x",
-                   chan, tgt, mbs.param[2], mbs.param[3] >> 8,
-                   mbs.param[3] & 0xff);
+               isp_prt(isp, ISP_LOGDEBUG0, "Initial Settings bus%d tgt%d flags 0x%x off 0x%x per 0x%x",
+                   chan, tgt, mbs.param[2], mbs.param[3] >> 8, mbs.param[3] & 0xff);
                isp_mboxcmd(isp, &mbs);
                if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
                        sdf = DPARM_SAFE_DFLT;
@@ -1606,25 +1601,15 @@
                }
                if (IS_2200(isp)) {
                        /*
-                        * There seems to just be too much breakage here
-                        * with RIO and Fast Posting- it probably actually
-                        * works okay but this driver is messing it up.
-                        * This card is really ancient by now, so let's
-                        * just opt for safety and not use the feature.
+                        * We can't have Fast Posting any more- we now
+                        * have 32 bit handles.
+                        *
+                        * RIO seemed to have to much breakage.
+                        *
+                        * Just opt for safety.
                         */
-#if    0
-                       if (ISP_FW_NEWER_THAN(isp, 1, 17, 0)) {
-                               icbp->icb_xfwoptions |= ICBXOPT_RIO_16BIT;
-                               icbp->icb_fwoptions &= ~ICBOPT_FAST_POST;
-                               icbp->icb_racctimer = 4;
-                               icbp->icb_idelaytimer = 8;
-                       } else {
-                               icbp->icb_fwoptions |= ICBOPT_FAST_POST;
-                       }
-#else
                        icbp->icb_xfwoptions &= ~ICBXOPT_RIO_16BIT;
                        icbp->icb_fwoptions &= ~ICBOPT_FAST_POST;
-#endif
                } else {
                        /*
                         * QLogic recommends that FAST Posting be turned
@@ -1715,8 +1700,7 @@
                isp_prt(isp, ISP_LOGERR, sacq);
                return;
        }
-       isp_prt(isp, ISP_LOGDEBUG0,
-           "isp_fibre_init: fwopt 0x%x xfwopt 0x%x zfwopt 0x%x",
+       isp_prt(isp, ISP_LOGDEBUG0, "isp_fibre_init: fwopt 0x%x xfwopt 0x%x zfwopt 0x%x",
            icbp->icb_fwoptions, icbp->icb_xfwoptions, icbp->icb_zfwoptions);
 
        isp_put_icb(isp, icbp, (isp_icb_t *)fcp->isp_scratch);
@@ -2184,9 +2168,7 @@
                msg = "no Exchange Control Block";
                break;
        case PLOGX_IOCBERR_FAILED:
-               ISP_SNPRINTF(buf, sizeof (buf),
-                   "reason 0x%x (last LOGIN state 0x%x)",
-                   parm1 & 0xff, (parm1 >> 8) & 0xff);
+               ISP_SNPRINTF(buf, sizeof (buf), "reason 0x%x (last LOGIN state 0x%x)", parm1 & 0xff, (parm1 >> 8) & 0xff);
                msg = buf;
                break;
        case PLOGX_IOCBERR_NOFABRIC:
@@ -2196,8 +2178,7 @@
                msg = "firmware not ready";
                break;
        case PLOGX_IOCBERR_NOLOGIN:
-               ISP_SNPRINTF(buf, sizeof (buf), "not logged in (last state 0x%x)",
-                   parm1);
+               ISP_SNPRINTF(buf, sizeof (buf), "not logged in (last state 0x%x)", parm1);
                msg = buf;
                rval = MBOX_NOT_LOGGED_IN;
                break;
@@ -2209,21 +2190,18 @@
                msg = "no PCB allocated";
                break;
        case PLOGX_IOCBERR_EINVAL:
-               ISP_SNPRINTF(buf, sizeof (buf), "invalid parameter at offset 0x%x",
-                   parm1);
+               ISP_SNPRINTF(buf, sizeof (buf), "invalid parameter at offset 0x%x", parm1);
                msg = buf;
                break;
        case PLOGX_IOCBERR_PORTUSED:
                lev = ISP_LOGSANCFG|ISP_LOGDEBUG0;
-               ISP_SNPRINTF(buf, sizeof (buf),
-                   "already logged in with N-Port handle 0x%x", parm1);
+               ISP_SNPRINTF(buf, sizeof (buf), "already logged in with N-Port handle 0x%x", parm1);
                msg = buf;
                rval = MBOX_PORT_ID_USED | (parm1 << 16);
                break;
        case PLOGX_IOCBERR_HNDLUSED:
                lev = ISP_LOGSANCFG|ISP_LOGDEBUG0;
-               ISP_SNPRINTF(buf, sizeof (buf),
-                   "handle already used for PortID 0x%06x", parm1);
+               ISP_SNPRINTF(buf, sizeof (buf), "handle already used for PortID 0x%06x", parm1);
                msg = buf;
                rval = MBOX_LOOP_ID_USED;
                break;
@@ -2234,15 +2212,12 @@
                msg = "no FLOGI_ACC";
                break;
        default:
-               ISP_SNPRINTF(buf, sizeof (buf), "status %x from %x",
-                   plp->plogx_status, flags);
+               ISP_SNPRINTF(buf, sizeof (buf), "status %x from %x", plp->plogx_status, flags);
                msg = buf;
                break;
        }
        if (msg) {
-               isp_prt(isp, ISP_LOGERR,
-                   "Chan %d PLOGX PortID 0x%06x to N-Port handle 0x%x: %s",
-                   chan, portid, handle, msg);
+               isp_prt(isp, ISP_LOGERR, "Chan %d PLOGX PortID 0x%06x to N-Port handle 0x%x: %s", chan, portid, handle, msg);
        }
 out:
        if (gs == 0) {
@@ -3903,8 +3878,7 @@
  * Find an unused handle and try and use to login to a port.
  */
 static int
-isp_login_device(ispsoftc_t *isp, int chan, uint32_t portid, isp_pdb_t *p,
-    uint16_t *ohp)
+isp_login_device(ispsoftc_t *isp, int chan, uint32_t portid, isp_pdb_t *p, uint16_t *ohp)
 {
        int lim, i, r;
        uint16_t handle;
@@ -3924,8 +3898,7 @@
                 */
                r = isp_getpdb(isp, chan, handle, p, 0);
                if (r == 0 && p->portid != portid) {
-                       (void) isp_plogx(isp, chan, handle, portid,
-                           PLOGX_FLG_CMD_LOGO | PLOGX_FLG_IMPLICIT, 1);
+                       (void) isp_plogx(isp, chan, handle, portid, PLOGX_FLG_CMD_LOGO | PLOGX_FLG_IMPLICIT | PLOGX_FLG_FREE_NPHDL, 1);
                } else if (r == 0) {
                        break;
                }
@@ -3935,8 +3908,7 @@
                /*
                 * Now try and log into the device
                 */
-               r = isp_plogx(isp, chan, handle, portid,
-                   PLOGX_FLG_CMD_PLOGI, 1);
+               r = isp_plogx(isp, chan, handle, portid, PLOGX_FLG_CMD_PLOGI, 1);
                if (FCPARAM(isp, chan)->isp_loopstate != LOOP_SCANNING_FABRIC) {
                        return (-1);
                }
@@ -3944,7 +3916,26 @@
                        *ohp = handle;
                        break;
                } else if ((r & 0xffff) == MBOX_PORT_ID_USED) {
-                       handle = r >> 16;
+                       /*
+                        * If we get here, then the firmwware still thinks we're logged into this device, but with a different
+                        * handle. We need to break that association. We used to try and just substitute the handle, but then
+                        * failed to get any data via isp_getpdb (below).
+                        */
+                       if (isp_plogx(isp, chan, r >> 16, portid, PLOGX_FLG_CMD_LOGO | PLOGX_FLG_IMPLICIT | PLOGX_FLG_FREE_NPHDL, 1)) {
+                               isp_prt(isp, ISP_LOGERR, "baw... logout of %x failed", r >> 16);
+                       }
+                       if (FCPARAM(isp, chan)->isp_loopstate != LOOP_SCANNING_FABRIC) {
+                               return (-1);
+                       }
+                       r = isp_plogx(isp, chan, handle, portid, PLOGX_FLG_CMD_PLOGI, 1);
+                       if (FCPARAM(isp, chan)->isp_loopstate != LOOP_SCANNING_FABRIC) {
+                               return (-1);
+                       }
+                       if (r == 0) {
+                               *ohp = handle;
+                       } else {
+                               i = lim;
+                       }
                        break;
                } else if (r != MBOX_LOOP_ID_USED) {
                        i = lim;
@@ -3958,8 +3949,7 @@
        }
 
        if (i == lim) {
-               isp_prt(isp, ISP_LOGWARN, "Chan %d PLOGI 0x%06x failed",
-                   chan, portid);
+               isp_prt(isp, ISP_LOGWARN, "Chan %d PLOGI 0x%06x failed", chan, portid);
                return (-1);
        }
 
@@ -3973,15 +3963,12 @@
                return (-1);
        }
        if (r != 0) {
-               isp_prt(isp, ISP_LOGERR,
-                   "Chan %d new device 0x%06x@0x%x disappeared",
-                   chan, portid, handle);
+               isp_prt(isp, ISP_LOGERR, "Chan %d new device 0x%06x@0x%x disappeared", chan, portid, handle);
                return (-1);
        }
 
        if (p->handle != handle || p->portid != portid) {



Home | Main Index | Thread Index | Old Index