Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/ic remove most target mode stuff. Change the argumen...



details:   https://anonhg.NetBSD.org/src/rev/9dd0e0cf36e5
branches:  trunk
changeset: 477180:9dd0e0cf36e5
user:      mjacob <mjacob%NetBSD.org@localhost>
date:      Thu Oct 14 02:27:12 1999 +0000

description:
remove most target mode stuff. Change the arguments to the
isp_fastpost_complete function to include a handle. Do some
isr register debouncing. Use new inline functions for xflist
handle storage. Remove isp_dumpxflist function. Do some fixups
of NVRAM from some broken cards. Use Full Login after LIP option
for FC cards if f/w < 1.17 - there's a f/w bug that causes the
port database to not be actually refreshed for local loop devices!
Do the appropriate endian swizzling for the ICB. Ditto for SNS structures
(these are no-ops until UltraSparc PCI needs them).

diffstat:

 sys/dev/ic/isp.c |  1215 ++++++++++++++----------------------------------------
 1 files changed, 315 insertions(+), 900 deletions(-)

diffs (truncated from 1959 to 300 lines):

diff -r c3423abd9165 -r 9dd0e0cf36e5 sys/dev/ic/isp.c
--- a/sys/dev/ic/isp.c  Thu Oct 14 02:21:50 1999 +0000
+++ b/sys/dev/ic/isp.c  Thu Oct 14 02:27:12 1999 +0000
@@ -1,5 +1,4 @@
-/* $NetBSD: isp.c,v 1.37 1999/07/05 20:31:35 mjacob Exp $ */
-/* release_6_5_99 */
+/* $NetBSD: isp.c,v 1.38 1999/10/14 02:27:12 mjacob Exp $ */
 /*
  * Copyright (C) 1997, 1998, 1999 National Aeronautics & Space Administration
  * All rights reserved.
@@ -26,6 +25,7 @@
  * (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.
@@ -64,31 +64,6 @@
 /*
  * Local static data
  */
-#ifdef ISP_TARGET_MODE
-static const char tgtiqd[36] = {
-       0x03, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00,
-       0x51, 0x4C, 0x4F, 0x47, 0x49, 0x43, 0x20, 0x20,
-#ifdef __NetBSD__
-       0x4E, 0x45, 0x54, 0x42, 0x53, 0x44, 0x20, 0x20,
-#else
-# ifdef        __FreeBSD__
-       0x46, 0x52, 0x45, 0x45, 0x42, 0x52, 0x44, 0x20,
-# else
-#  ifdef __OpenBSD__
-       0x4F, 0x50, 0x45, 0x4E, 0x42, 0x52, 0x44, 0x20,
-#  else
-#   ifdef linux
-       0x4C, 0x49, 0x4E, 0x55, 0x58, 0x20, 0x20, 0x20,
-#   else
-#   endif
-#  endif
-# endif
-#endif
-       0x54, 0x41, 0x52, 0x47, 0x45, 0x54, 0x20, 0x20,
-       0x20, 0x20, 0x20, 0x31
-};
-#endif
-
 
 /*
  * Local function prototypes.
@@ -96,17 +71,9 @@
 static int isp_parse_async __P((struct ispsoftc *, int));
 static int isp_handle_other_response
 __P((struct ispsoftc *, ispstatusreq_t *, u_int8_t *));
-#ifdef ISP_TARGET_MODE
-static int isp_modify_lun __P((struct ispsoftc *, int, int, int));
-static void isp_notify_ack __P((struct ispsoftc *, void *));
-static void isp_handle_atio __P((struct ispsoftc *, void *));
-static void isp_handle_atio2 __P((struct ispsoftc *, void *));
-static void isp_handle_ctio __P((struct ispsoftc *, void *));
-static void isp_handle_ctio2 __P((struct ispsoftc *, void *));
-#endif
 static void isp_parse_status
 __P((struct ispsoftc *, ispstatusreq_t *, ISP_SCSI_XFER_T *));
-static void isp_fastpost_complete __P((struct ispsoftc *, int));
+static void isp_fastpost_complete __P((struct ispsoftc *, u_int32_t));
 static void isp_scsi_init __P((struct ispsoftc *));
 static void isp_scsi_channel_init __P((struct ispsoftc *, int));
 static void isp_fibre_init __P((struct ispsoftc *));
@@ -121,7 +88,6 @@
 #endif
 static void isp_fw_state __P((struct ispsoftc *));
 static void isp_dumpregs __P((struct ispsoftc *, const char *));
-static void isp_dumpxflist __P((struct ispsoftc *));
 static void isp_mboxcmd __P((struct ispsoftc *, mbreg_t *));
 
 static void isp_update __P((struct ispsoftc *));
@@ -202,8 +168,8 @@
                case ISP_HA_FC_2200:
                        revname[1] = '2';
                        /*
-                        * Resident firmware for the 2200 appears to have
-                        * SCCLUN enabled.
+                        * Resident firmware for the 2200 appears
+                        * to have SCCLUN enabled.
                         */
 #ifndef        ISP2100_SCCLUN
                        if (isp->isp_mdvec->dv_fwlen == 0) {
@@ -392,7 +358,7 @@
         */
        loops = MBOX_DELAY_COUNT;
        for (;;) {
-               if (isp->isp_type & ISP_HA_SCSI) {
+               if (IS_SCSI(isp)) {
                        if (!(ISP_READ(isp, BIU_ICR) & BIU_ICR_SOFT_RESET))
                                break;
                } else {
@@ -468,13 +434,6 @@
         */
        ISP_RESET1(isp);
 
-#if    0
-       /*
-        * Enable interrupts
-        */
-       ENABLE_INTS(isp);
-#endif
-
        /*
         * Wait for everything to finish firing up...
         */
@@ -582,7 +541,7 @@
                mbs.param[1] = 0x1000;
        isp_mboxcmd(isp, &mbs);
 
-       if (isp->isp_type & ISP_HA_SCSI) {
+       if (IS_SCSI(isp)) {
                /*
                 * Set CLOCK RATE, but only if asked to.
                 */
@@ -591,38 +550,48 @@
                        mbs.param[1] = isp->isp_clock;
                        isp_mboxcmd(isp, &mbs);
                        if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
-                               isp_dumpregs(isp, "failed to set CLOCKRATE");
+                               PRINTF("failed to set clockrate (0x%x)\n",
+                                   mbs.param[0]);
                                /* but continue */
-                       } else {
-                               IDPRINTF(3, ("%s: setting input clock to %d\n",
-                                   isp->isp_name, isp->isp_clock));
                        }
                }
        }
        mbs.param[0] = MBOX_ABOUT_FIRMWARE;
        isp_mboxcmd(isp, &mbs);
        if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
-               isp_dumpregs(isp, "ABOUT FIRMWARE command failed");
+               PRINTF("could not get f/w started (0x%x)\n", mbs.param[0]);
                return;
        }
-       PRINTF("%s: Board Revision %s, %s F/W Revision %d.%d.%d\n",
-               isp->isp_name, revname, dodnld? "loaded" : "resident",
-               mbs.param[1], mbs.param[2], mbs.param[3]);
+       CFGPRINTF("%s: Board Revision %s, %s F/W Revision %d.%d.%d\n",
+           isp->isp_name, revname, dodnld? "loaded" : "resident",
+           mbs.param[1], mbs.param[2], mbs.param[3]);
        if (IS_FC(isp)) {
                if (ISP_READ(isp, BIU2100_CSR) & BIU2100_PCI64) {
-                       PRINTF("%s: in 64-Bit PCI slot\n", isp->isp_name);
+                       CFGPRINTF("%s: in 64-Bit PCI slot\n", isp->isp_name);
                }
        }
+
        isp->isp_fwrev[0] = mbs.param[1];
        isp->isp_fwrev[1] = mbs.param[2];
        isp->isp_fwrev[2] = mbs.param[3];
        if (isp->isp_romfw_rev[0] || isp->isp_romfw_rev[1] ||
            isp->isp_romfw_rev[2]) {
-               PRINTF("%s: Last F/W revision was %d.%d.%d\n", isp->isp_name,
+               CFGPRINTF("%s: Last F/W revision was %d.%d.%d\n", isp->isp_name,
                    isp->isp_romfw_rev[0], isp->isp_romfw_rev[1],
                    isp->isp_romfw_rev[2]);
        }
+
+       mbs.param[0] = MBOX_GET_FIRMWARE_STATUS;
+       isp_mboxcmd(isp, &mbs);
+       if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
+               PRINTF("%s: could not GET FIRMWARE STATUS\n", isp->isp_name);
+               return;
+       }
+       isp->isp_maxcmds = mbs.param[2];
+       CFGPRINTF("%s: %d max I/O commands supported\n",
+           isp->isp_name, mbs.param[2]);
        isp_fw_state(isp);
+
        /*
         * Set up DMA for the request and result mailboxes.
         */
@@ -856,8 +825,8 @@
                u_int16_t sdf;
 
                if (sdp->isp_devparam[tgt].dev_enable == 0) {
-                       PRINTF("%s: skipping settings for target %d bus %d\n",
-                           isp->isp_name, tgt, channel);
+                       IDPRINTF(1, ("%s: skipping target %d bus %d settings\n",
+                           isp->isp_name, tgt, channel));
                        continue;
                }
 
@@ -993,31 +962,24 @@
 
        icbp->icb_version = ICB_VERSION1;
 #ifdef ISP_TARGET_MODE
-       fcp->isp_fwoptions = ICBOPT_TGT_ENABLE|ICBOPT_INI_TGTTYPE;
+       fcp->isp_fwoptions = ICBOPT_TGT_ENABLE;
 #else
        fcp->isp_fwoptions = 0;
 #endif
        fcp->isp_fwoptions |= ICBOPT_FAIRNESS;
        fcp->isp_fwoptions |= ICBOPT_PDBCHANGE_AE;
        fcp->isp_fwoptions |= ICBOPT_HARD_ADDRESS;
-#ifdef ISP2100_FABRIC
-#if    0
        /*
-        * Do not use FULL LOGIN- it resets the loop too much.
+        * We have to use FULL LOGIN even though it resets the loop too much
+        * because otherwise port database entries don't get updated after
+        * a LIP- this is a known f/w bug.
         */
-       fcp->isp_fwoptions |= ICBOPT_FULL_LOGIN;
-#endif
-#endif
-#if    0
-       /*
-        * Don't use this either
-        */
-       fcp->isp_fwoptions |= ICBOPT_INI_ADISC;
-#endif
+       if (ISP_FW_REVX(isp->isp_fwrev) < ISP_FW_REV(1, 17, 0)) {
+               fcp->isp_fwoptions |= ICBOPT_FULL_LOGIN;
+       }
 #ifndef        ISP_NO_FASTPOST_FC
        fcp->isp_fwoptions |= ICBOPT_FAST_POST;
 #endif
-
        if (isp->isp_confopts & ISP_CFG_FULL_DUPLEX)
                fcp->isp_fwoptions |= ICBOPT_FULL_DUPLEX;
 
@@ -1049,6 +1011,7 @@
        icbp->icb_retry_delay = fcp->isp_retry_delay;
        icbp->icb_retry_count = fcp->isp_retry_count;
        icbp->icb_hardaddr = loopid;
+       icbp->icb_logintime = 30;       /* 30 second login timeout */
 
        if (fcp->isp_nodewwn) {
                u_int64_t pn;
@@ -1074,15 +1037,22 @@
        } else {
                fcp->isp_fwoptions &= ~(ICBOPT_USE_PORTNAME|ICBOPT_FULL_LOGIN);
        }
-
        icbp->icb_rqstqlen = RQUEST_QUEUE_LEN;
        icbp->icb_rsltqlen = RESULT_QUEUE_LEN;
        icbp->icb_rqstaddr[RQRSP_ADDR0015] = DMA_LSW(isp->isp_rquest_dma);
        icbp->icb_rqstaddr[RQRSP_ADDR1631] = DMA_MSW(isp->isp_rquest_dma);
        icbp->icb_respaddr[RQRSP_ADDR0015] = DMA_LSW(isp->isp_result_dma);
        icbp->icb_respaddr[RQRSP_ADDR1631] = DMA_MSW(isp->isp_result_dma);
+       ISP_SWIZZLE_ICB(isp, icbp);
+
+       /*
+        * Do this *before* initializing the firmware.
+        */
+       isp_mark_getpdb_all(isp);
+       fcp->isp_fwstate = FW_CONFIG_WAIT;
+       fcp->isp_loopstate = LOOP_NIL;
+
        MemoryBarrier();
-
        for (;;) {
                mbs.param[0] = MBOX_INIT_FIRMWARE;
                mbs.param[1] = 0;
@@ -1096,7 +1066,7 @@
                if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
                        PRINTF("%s: INIT FIRMWARE failed (code 0x%x)\n",
                            isp->isp_name, mbs.param[0]);
-                       if (mbs.param[0] & 0xc000) {
+                       if (mbs.param[0] & 0x8000) {
                                SYS_DELAY(1000);
                                continue;
                        }
@@ -1113,9 +1083,6 @@
         * Whatever happens, we're now committed to being here.
         */
        isp->isp_state = ISP_INITSTATE;
-       fcp->isp_fwstate = FW_CONFIG_WAIT;
-
-       isp_mark_getpdb_all(isp);
 
 #ifdef ISP_TARGET_MODE
        if (isp_modify_lun(isp, 0, 1, 1)) {
@@ -1168,7 +1135,7 @@
        switch (mbs.param[0]) {
        case MBOX_COMMAND_COMPLETE:
                MemoryBarrier();
-               MEMCPY(pdbp, fcp->isp_scratch, sizeof (isp_pdb_t));
+               ISP_UNSWIZZLE_AND_COPY_PDBP(isp, pdbp, fcp->isp_scratch);
                break;
        case MBOX_HOST_INTERFACE_ERROR:
                PRINTF("%s: DMA error getting port database\n", isp->isp_name);
@@ -1223,8 +1190,15 @@
        struct ispsoftc *isp;
        int waitdelay;
 {
+       static char *toponames[] = {
+               "Private Loop",
+               "FL Port",
+               "N-Port to N-Port",
+               "F Port"
+       };



Home | Main Index | Thread Index | Old Index