scsi/isp/common/isp.c | 6703 ++++++++++++++++++++++++++++++++++ scsi/isp/common/isp_inline.h | 1495 +++++++ scsi/isp/common/isp_target.c | 1186 ++++++ scsi/isp/common/isp_target.h | 558 ++ scsi/isp/common/isp_tpublic.h | 335 + scsi/isp/common/ispmbox.h | 934 ++++ scsi/isp/common/ispreg.h | 1011 +++++ scsi/isp/common/ispvar.h | 902 ++++ scsi/isp/firmware/asm_1000.h | 3224 ++++++++++++++++ scsi/isp/firmware/asm_1040.h | 3545 ++++++++++++++++++ scsi/isp/firmware/asm_1080.h | 4554 +++++++++++++++++++++++ scsi/isp/firmware/asm_12160.h | 4198 +++++++++++++++++++++ scsi/isp/firmware/asm_2100.h | 8147 ++++++++++++++++++++++++++++++++++++++++++ scsi/isp/firmware/asm_2200.h | 5286 +++++++++++++++++++++++++++ scsi/isp/firmware/asm_2300.h | 6195 +++++++++++++++++++++++++++++++ scsi/isp/isp_linux.c | 3087 +++++++++++++++ scsi/isp/isp_linux.h | 913 ++++ scsi/isp/isp_pci.c | 2391 ++++++++++++ 18 files changed, 54664 insertions(+) diff -puN /dev/null drivers/scsi/isp/common/isp.c --- /dev/null 2002-08-30 16:31:37.000000000 -0700 +++ 25-akpm/drivers/scsi/isp/common/isp.c 2003-02-14 00:20:12.000000000 -0800 @@ -0,0 +1,6703 @@ +/* @(#)isp.c 1.81 */ +/* + * Machine and OS Independent (well, as best as possible) + * code for the Qlogic ISP SCSI adapters. + * + * Copyright (c) 1997, 1998, 1999, 2000, 2001 by Matthew Jacob + * Feral Software + * 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 immediately at the beginning of the file, without modification, + * this list of conditions, and the following disclaimer. + * 2. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * 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. + */ + +/* + * 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. + */ + +/* + * Include header file appropriate for platform we're building on. + */ + +#ifdef __NetBSD__ +#include +#endif +#ifdef __FreeBSD__ +#include +#endif +#ifdef __OpenBSD__ +#include +#endif +#ifdef __linux__ +#include "isp_linux.h" +#endif +#ifdef __svr4__ +#include "isp_solaris.h" +#endif + +/* + * General defines + */ + +#define MBOX_DELAY_COUNT 1000000 / 100 + +/* + * Local static data + */ +static const char portshift[] = + "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[] = + "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"; +static const char plogout[] = + "Logging out Target %d at Loop ID 0x%x (Port 0x%x)"; +static const char plogierr[] = + "Command Error in PLOGI for Port 0x%x (0x%x)"; +static const char nopdb[] = + "Could not get PDB for Device @ Port 0x%x"; +static const char pdbmfail1[] = + "PDB Loop ID info for Device @ Port 0x%x does not match up (0x%x)"; +static const char pdbmfail2[] = + "PDB Port info for Device @ Port 0x%x does not match up (0x%x)"; +static const char ldumped[] = + "Target %d (Loop ID 0x%x) Port 0x%x dumped after login info mismatch"; +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[] = + "Loop ID %d, AL_PA 0x%x, Port ID 0x%x, Loop State 0x%x, Topology '%s'"; +static const char swrej[] = + "Fabric Nameserver rejected %s (Reason=0x%x Expl=0x%x) for Port ID 0x%x"; +static const char finmsg[] = + "(%d.%d.%d): FIN dl%d resid %d STS 0x%x SKEY %c XS_ERR=0x%x"; +static const char sc0[] = + "%s CHAN %d FTHRSH %d IID %d RESETD %d RETRYC %d RETRYD %d ASD 0x%x"; +static const char sc1[] = + "%s RAAN 0x%x DLAN 0x%x DDMAB 0x%x CDMAB 0x%x SELTIME %d MQD %d"; +static const char sc2[] = "%s CHAN %d TGT %d FLAGS 0x%x 0x%x/0x%x"; +static const char sc3[] = "Generated"; +static const char sc4[] = "NVRAM"; +static const char bun[] = + "bad underrun for %d.%d (count %d, resid %d, status %s)"; + +/* + * Local function prototypes. + */ +static int isp_parse_async(struct ispsoftc *, u_int16_t); +static int isp_handle_other_response(struct ispsoftc *, int, isphdr_t *, + u_int16_t *); +static void +isp_parse_status(struct ispsoftc *, ispstatusreq_t *, XS_T *); +static void isp_fastpost_complete(struct ispsoftc *, u_int16_t); +static int isp_mbox_continue(struct ispsoftc *); +static void isp_scsi_init(struct ispsoftc *); +static void isp_scsi_channel_init(struct ispsoftc *, int); +static void isp_fibre_init(struct ispsoftc *); +static void isp_mark_getpdb_all(struct ispsoftc *); +static int isp_getmap(struct ispsoftc *, fcpos_map_t *); +static int isp_getpdb(struct ispsoftc *, int, isp_pdb_t *); +static u_int64_t isp_get_portname(struct ispsoftc *, int, int); +static int isp_fclink_test(struct ispsoftc *, int); +static char *isp2100_fw_statename(int); +static int isp_pdb_sync(struct ispsoftc *); +static int isp_scan_loop(struct ispsoftc *); +static int isp_fabric_mbox_cmd(struct ispsoftc *, mbreg_t *); +static int isp_scan_fabric(struct ispsoftc *, int); +static void isp_register_fc4_type(struct ispsoftc *); +static void isp_fw_state(struct ispsoftc *); +static void isp_mboxcmd_qnw(struct ispsoftc *, mbreg_t *, int); +static void isp_mboxcmd(struct ispsoftc *, mbreg_t *, int); + +static void isp_update(struct ispsoftc *); +static void isp_update_bus(struct ispsoftc *, int); +static void isp_setdfltparm(struct ispsoftc *, int); +static int isp_read_nvram(struct ispsoftc *); +static void isp_rdnvram_word(struct ispsoftc *, int, u_int16_t *); +static void isp_parse_nvram_1020(struct ispsoftc *, u_int8_t *); +static void isp_parse_nvram_1080(struct ispsoftc *, int, u_int8_t *); +static void isp_parse_nvram_12160(struct ispsoftc *, int, u_int8_t *); +static void isp_parse_nvram_2100(struct ispsoftc *, u_int8_t *); + +/* + * Reset Hardware. + * + * Hit the chip over the head, download new f/w if available and set it running. + * + * Locking done elsewhere. + */ + +void +isp_reset(struct ispsoftc *isp) +{ + mbreg_t mbs; + u_int16_t code_org; + int loops, i, dodnld = 1; + char *btype = "????"; + + isp->isp_state = ISP_NILSTATE; + + /* + * Basic types (SCSI, FibreChannel and PCI or SBus) + * have been set in the MD code. We figure out more + * here. Possibly more refined types based upon PCI + * identification. Chip revision has been gathered. + * + * After we've fired this chip up, zero out the conf1 register + * for SCSI adapters and do other settings for the 2100. + */ + + /* + * Get the current running firmware revision out of the + * chip before we hit it over the head (if this is our + * first time through). Note that we store this as the + * 'ROM' firmware revision- which it may not be. In any + * case, we don't really use this yet, but we may in + * the future. + */ + if (isp->isp_touched == 0) { + /* + * First see whether or not we're sitting in the ISP PROM. + * If we've just been reset, we'll have the string "ISP " + * spread through outgoing mailbox registers 1-3. We do + * this for PCI cards because otherwise we really don't + * know what state the card is in and we could hang if + * we try this command otherwise. + * + * For SBus cards, we just do this because they almost + * certainly will be running firmware by now. + */ + if (ISP_READ(isp, OUTMAILBOX1) != 0x4953 || + ISP_READ(isp, OUTMAILBOX2) != 0x5020 || + ISP_READ(isp, OUTMAILBOX3) != 0x2020) { + /* + * Just in case it was paused... + */ + ISP_WRITE(isp, HCCR, HCCR_CMD_RELEASE); + mbs.param[0] = MBOX_ABOUT_FIRMWARE; + isp_mboxcmd(isp, &mbs, MBLOGNONE); + if (mbs.param[0] == MBOX_COMMAND_COMPLETE) { + isp->isp_romfw_rev[0] = mbs.param[1]; + isp->isp_romfw_rev[1] = mbs.param[2]; + isp->isp_romfw_rev[2] = mbs.param[3]; + } + } + isp->isp_touched = 1; + } + + DISABLE_INTS(isp); + + /* + * Set up default request/response queue in-pointer/out-pointer + * register indices. + */ + if (IS_23XX(isp)) { + isp->isp_rqstinrp = BIU_REQINP; + isp->isp_rqstoutrp = BIU_REQOUTP; + isp->isp_respinrp = BIU_RSPINP; + isp->isp_respoutrp = BIU_RSPOUTP; + } else { + isp->isp_rqstinrp = INMAILBOX4; + isp->isp_rqstoutrp = OUTMAILBOX4; + isp->isp_respinrp = OUTMAILBOX5; + isp->isp_respoutrp = INMAILBOX5; + } + + /* + * Put the board into PAUSE mode (so we can read the SXP registers + * or write FPM/FBM registers). + */ + ISP_WRITE(isp, HCCR, HCCR_CMD_PAUSE); + + if (IS_FC(isp)) { + switch (isp->isp_type) { + case ISP_HA_FC_2100: + btype = "2100"; + break; + case ISP_HA_FC_2200: + btype = "2200"; + break; + case ISP_HA_FC_2300: + btype = "2300"; + break; + case ISP_HA_FC_2312: + btype = "2312"; + break; + default: + break; + } + /* + * While we're paused, reset the FPM module and FBM fifos. + */ + ISP_WRITE(isp, BIU2100_CSR, BIU2100_FPM0_REGS); + ISP_WRITE(isp, FPM_DIAG_CONFIG, FPM_SOFT_RESET); + ISP_WRITE(isp, BIU2100_CSR, BIU2100_FB_REGS); + ISP_WRITE(isp, FBM_CMD, FBMCMD_FIFO_RESET_ALL); + ISP_WRITE(isp, BIU2100_CSR, BIU2100_RISC_REGS); + } else if (IS_1240(isp)) { + sdparam *sdp = isp->isp_param; + btype = "1240"; + isp->isp_clock = 60; + sdp->isp_ultramode = 1; + sdp++; + sdp->isp_ultramode = 1; + /* + * XXX: Should probably do some bus sensing. + */ + } else if (IS_ULTRA2(isp)) { + static const char m[] = "bus %d is in %s Mode"; + u_int16_t l; + sdparam *sdp = isp->isp_param; + + isp->isp_clock = 100; + + if (IS_1280(isp)) + btype = "1280"; + else if (IS_1080(isp)) + btype = "1080"; + else if (IS_10160(isp)) + btype = "10160"; + else if (IS_12160(isp)) + btype = "12160"; + else + btype = ""; + + l = ISP_READ(isp, SXP_PINS_DIFF) & ISP1080_MODE_MASK; + switch (l) { + case ISP1080_LVD_MODE: + sdp->isp_lvdmode = 1; + isp_prt(isp, ISP_LOGCONFIG, m, 0, "LVD"); + break; + case ISP1080_HVD_MODE: + sdp->isp_diffmode = 1; + isp_prt(isp, ISP_LOGCONFIG, m, 0, "Differential"); + break; + case ISP1080_SE_MODE: + sdp->isp_ultramode = 1; + isp_prt(isp, ISP_LOGCONFIG, m, 0, "Single-Ended"); + break; + default: + isp_prt(isp, ISP_LOGERR, + "unknown mode on bus %d (0x%x)", 0, l); + break; + } + + if (IS_DUALBUS(isp)) { + sdp++; + l = ISP_READ(isp, SXP_PINS_DIFF|SXP_BANK1_SELECT); + l &= ISP1080_MODE_MASK; + switch(l) { + case ISP1080_LVD_MODE: + sdp->isp_lvdmode = 1; + isp_prt(isp, ISP_LOGCONFIG, m, 1, "LVD"); + break; + case ISP1080_HVD_MODE: + sdp->isp_diffmode = 1; + isp_prt(isp, ISP_LOGCONFIG, + m, 1, "Differential"); + break; + case ISP1080_SE_MODE: + sdp->isp_ultramode = 1; + isp_prt(isp, ISP_LOGCONFIG, + m, 1, "Single-Ended"); + break; + default: + isp_prt(isp, ISP_LOGERR, + "unknown mode on bus %d (0x%x)", 1, l); + break; + } + } + } else { + sdparam *sdp = isp->isp_param; + i = ISP_READ(isp, BIU_CONF0) & BIU_CONF0_HW_MASK; + switch (i) { + default: + isp_prt(isp, ISP_LOGALL, "Unknown Chip Type 0x%x", i); + /* FALLTHROUGH */ + case 1: + btype = "1020"; + isp->isp_type = ISP_HA_SCSI_1020; + isp->isp_clock = 40; + break; + case 2: + /* + * Some 1020A chips are Ultra Capable, but don't + * run the clock rate up for that unless told to + * do so by the Ultra Capable bits being set. + */ + btype = "1020A"; + isp->isp_type = ISP_HA_SCSI_1020A; + isp->isp_clock = 40; + break; + case 3: + btype = "1040"; + isp->isp_type = ISP_HA_SCSI_1040; + isp->isp_clock = 60; + break; + case 4: + btype = "1040A"; + isp->isp_type = ISP_HA_SCSI_1040A; + isp->isp_clock = 60; + break; + case 5: + btype = "1040B"; + isp->isp_type = ISP_HA_SCSI_1040B; + isp->isp_clock = 60; + break; + case 6: + btype = "1040C"; + isp->isp_type = ISP_HA_SCSI_1040C; + isp->isp_clock = 60; + break; + } + /* + * Now, while we're at it, gather info about ultra + * and/or differential mode. + */ + if (ISP_READ(isp, SXP_PINS_DIFF) & SXP_PINS_DIFF_MODE) { + isp_prt(isp, ISP_LOGCONFIG, "Differential Mode"); + sdp->isp_diffmode = 1; + } else { + sdp->isp_diffmode = 0; + } + i = ISP_READ(isp, RISC_PSR); + if (isp->isp_bustype == ISP_BT_SBUS) { + i &= RISC_PSR_SBUS_ULTRA; + } else { + i &= RISC_PSR_PCI_ULTRA; + } + if (i != 0) { + isp_prt(isp, ISP_LOGCONFIG, "Ultra Mode Capable"); + sdp->isp_ultramode = 1; + /* + * If we're in Ultra Mode, we have to be 60Mhz clock- + * even for the SBus version. + */ + isp->isp_clock = 60; + } else { + sdp->isp_ultramode = 0; + /* + * Clock is known. Gronk. + */ + } + + /* + * Machine dependent clock (if set) overrides + * our generic determinations. + */ + if (isp->isp_mdvec->dv_clock) { + if (isp->isp_mdvec->dv_clock < isp->isp_clock) { + isp->isp_clock = isp->isp_mdvec->dv_clock; + } + } + + } + + /* + * Clear instrumentation + */ + isp->isp_intcnt = isp->isp_intbogus = 0; + + /* + * Do MD specific pre initialization + */ + ISP_RESET0(isp); + +again: + + /* + * Hit the chip over the head with hammer, + * and give the ISP a chance to recover. + */ + + if (IS_SCSI(isp)) { + ISP_WRITE(isp, BIU_ICR, BIU_ICR_SOFT_RESET); + /* + * A slight delay... + */ + USEC_DELAY(100); + + /* + * Clear data && control DMA engines. + */ + ISP_WRITE(isp, CDMA_CONTROL, + DMA_CNTRL_CLEAR_CHAN | DMA_CNTRL_RESET_INT); + ISP_WRITE(isp, DDMA_CONTROL, + DMA_CNTRL_CLEAR_CHAN | DMA_CNTRL_RESET_INT); + + + } else { + ISP_WRITE(isp, BIU2100_CSR, BIU2100_SOFT_RESET); + /* + * A slight delay... + */ + USEC_DELAY(100); + + /* + * Clear data && control DMA engines. + */ + ISP_WRITE(isp, CDMA2100_CONTROL, + DMA_CNTRL2100_CLEAR_CHAN | DMA_CNTRL2100_RESET_INT); + ISP_WRITE(isp, TDMA2100_CONTROL, + DMA_CNTRL2100_CLEAR_CHAN | DMA_CNTRL2100_RESET_INT); + ISP_WRITE(isp, RDMA2100_CONTROL, + DMA_CNTRL2100_CLEAR_CHAN | DMA_CNTRL2100_RESET_INT); + } + + /* + * Wait for ISP to be ready to go... + */ + loops = MBOX_DELAY_COUNT; + for (;;) { + if (IS_SCSI(isp)) { + if (!(ISP_READ(isp, BIU_ICR) & BIU_ICR_SOFT_RESET)) + break; + } else { + if (!(ISP_READ(isp, BIU2100_CSR) & BIU2100_SOFT_RESET)) + break; + } + USEC_DELAY(100); + if (--loops < 0) { + ISP_DUMPREGS(isp, "chip reset timed out"); + return; + } + } + + /* + * After we've fired this chip up, zero out the conf1 register + * for SCSI adapters and other settings for the 2100. + */ + + if (IS_SCSI(isp)) { + ISP_WRITE(isp, BIU_CONF1, 0); + } else { + ISP_WRITE(isp, BIU2100_CSR, 0); + } + + /* + * Reset RISC Processor + */ + ISP_WRITE(isp, HCCR, HCCR_CMD_RESET); + USEC_DELAY(100); + /* Clear semaphore register (just to be sure) */ + ISP_WRITE(isp, BIU_SEMA, 0); + + /* + * Establish some initial burst rate stuff. + * (only for the 1XX0 boards). This really should + * be done later after fetching from NVRAM. + */ + if (IS_SCSI(isp)) { + u_int16_t tmp = isp->isp_mdvec->dv_conf1; + /* + * Busted FIFO. Turn off all but burst enables. + */ + if (isp->isp_type == ISP_HA_SCSI_1040A) { + tmp &= BIU_BURST_ENABLE; + } + ISP_SETBITS(isp, BIU_CONF1, tmp); + if (tmp & BIU_BURST_ENABLE) { + ISP_SETBITS(isp, CDMA_CONF, DMA_ENABLE_BURST); + ISP_SETBITS(isp, DDMA_CONF, DMA_ENABLE_BURST); + } +#ifdef PTI_CARDS + if (((sdparam *) isp->isp_param)->isp_ultramode) { + while (ISP_READ(isp, RISC_MTR) != 0x1313) { + ISP_WRITE(isp, RISC_MTR, 0x1313); + ISP_WRITE(isp, HCCR, HCCR_CMD_STEP); + } + } else { + ISP_WRITE(isp, RISC_MTR, 0x1212); + } + /* + * PTI specific register + */ + ISP_WRITE(isp, RISC_EMB, DUAL_BANK) +#else + ISP_WRITE(isp, RISC_MTR, 0x1212); +#endif + } else { + ISP_WRITE(isp, RISC_MTR2100, 0x1212); + if (IS_2200(isp) || IS_23XX(isp)) { + ISP_WRITE(isp, HCCR, HCCR_2X00_DISABLE_PARITY_PAUSE); + } + } + + ISP_WRITE(isp, HCCR, HCCR_CMD_RELEASE); /* release paused processor */ + + /* + * Do MD specific post initialization + */ + ISP_RESET1(isp); + + /* + * Wait for everything to finish firing up. + * + * Avoid doing this on the 2312 because you can generate a PCI + * parity error (chip breakage). + */ + if (IS_23XX(isp)) { + USEC_DELAY(5); + } else { + loops = MBOX_DELAY_COUNT; + while (ISP_READ(isp, OUTMAILBOX0) == MBOX_BUSY) { + USEC_DELAY(100); + if (--loops < 0) { + isp_prt(isp, ISP_LOGERR, + "MBOX_BUSY never cleared on reset"); + return; + } + } + } + + /* + * Up until this point we've done everything by just reading or + * setting registers. From this point on we rely on at least *some* + * kind of firmware running in the card. + */ + + /* + * Do some sanity checking. + */ + mbs.param[0] = MBOX_NO_OP; + isp_mboxcmd(isp, &mbs, MBLOGALL); + if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { + return; + } + + if (IS_SCSI(isp)) { + mbs.param[0] = MBOX_MAILBOX_REG_TEST; + mbs.param[1] = 0xdead; + mbs.param[2] = 0xbeef; + mbs.param[3] = 0xffff; + mbs.param[4] = 0x1111; + mbs.param[5] = 0xa5a5; + isp_mboxcmd(isp, &mbs, MBLOGALL); + if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { + return; + } + if (mbs.param[1] != 0xdead || mbs.param[2] != 0xbeef || + mbs.param[3] != 0xffff || mbs.param[4] != 0x1111 || + mbs.param[5] != 0xa5a5) { + isp_prt(isp, ISP_LOGERR, + "Register Test Failed (0x%x 0x%x 0x%x 0x%x 0x%x)", + mbs.param[1], mbs.param[2], mbs.param[3], + mbs.param[4], mbs.param[5]); + return; + } + + } + + /* + * Download new Firmware, unless requested not to do so. + * This is made slightly trickier in some cases where the + * firmware of the ROM revision is newer than the revision + * compiled into the driver. So, where we used to compare + * versions of our f/w and the ROM f/w, now we just see + * whether we have f/w at all and whether a config flag + * has disabled our download. + */ + if ((isp->isp_mdvec->dv_ispfw == NULL) || + (isp->isp_confopts & ISP_CFG_NORELOAD)) { + dodnld = 0; + } + + if (IS_23XX(isp)) + code_org = ISP_CODE_ORG_2300; + else + code_org = ISP_CODE_ORG; + + if (dodnld) { + isp->isp_mbxworkp = (void *) &isp->isp_mdvec->dv_ispfw[1]; + isp->isp_mbxwrk0 = isp->isp_mdvec->dv_ispfw[3] - 1; + isp->isp_mbxwrk1 = code_org + 1; + mbs.param[0] = MBOX_WRITE_RAM_WORD; + mbs.param[1] = code_org; + mbs.param[2] = isp->isp_mdvec->dv_ispfw[0]; + isp_mboxcmd(isp, &mbs, MBLOGNONE); + if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { + isp_prt(isp, ISP_LOGERR, + "F/W download failed at word %d", + isp->isp_mbxwrk1 - code_org); + dodnld = 0; + goto again; + } + /* + * Verify that it downloaded correctly. + */ + mbs.param[0] = MBOX_VERIFY_CHECKSUM; + mbs.param[1] = code_org; + isp_mboxcmd(isp, &mbs, MBLOGNONE); + if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { + isp_prt(isp, ISP_LOGERR, "Ram Checksum Failure"); + return; + } + isp->isp_loaded_fw = 1; + } else { + isp->isp_loaded_fw = 0; + isp_prt(isp, ISP_LOGDEBUG2, "skipping f/w download"); + } + + /* + * Now start it rolling. + * + * If we didn't actually download f/w, + * we still need to (re)start it. + */ + + + mbs.param[0] = MBOX_EXEC_FIRMWARE; + mbs.param[1] = code_org; + isp_mboxcmd(isp, &mbs, MBLOGNONE); + /* + * Give it a chance to start. + */ + USEC_DELAY(500); + + if (IS_SCSI(isp)) { + /* + * Set CLOCK RATE, but only if asked to. + */ + if (isp->isp_clock) { + mbs.param[0] = MBOX_SET_CLOCK_RATE; + mbs.param[1] = isp->isp_clock; + isp_mboxcmd(isp, &mbs, MBLOGALL); + /* we will try not to care if this fails */ + } + } + + mbs.param[0] = MBOX_ABOUT_FIRMWARE; + isp_mboxcmd(isp, &mbs, MBLOGALL); + if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { + return; + } + + /* + * The SBus firmware that we are using apparently does not return + * major, minor, micro revisions in the mailbox registers, which + * is really, really, annoying. + */ + if (ISP_SBUS_SUPPORTED && isp->isp_bustype == ISP_BT_SBUS) { + if (dodnld) { +#ifdef ISP_TARGET_MODE + isp->isp_fwrev[0] = 7; + isp->isp_fwrev[1] = 55; +#else + isp->isp_fwrev[0] = 1; + isp->isp_fwrev[1] = 37; +#endif + isp->isp_fwrev[2] = 0; + } + } else { + isp->isp_fwrev[0] = mbs.param[1]; + 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", + isp->isp_fwrev[0], isp->isp_fwrev[1], isp->isp_fwrev[2]); + + if (IS_FC(isp)) { + /* + * We do not believe firmware attributes for 2100 code less + * than 1.17.0, unless it's the firmware we specifically + * are loading. + * + * Note that all 22XX and 23XX f/w is greater than 1.X.0. + */ + if (!(ISP_FW_NEWER_THAN(isp, 1, 17, 0))) { +#ifdef USE_SMALLER_2100_FIRMWARE + FCPARAM(isp)->isp_fwattr = ISP_FW_ATTR_SCCLUN; +#else + FCPARAM(isp)->isp_fwattr = 0; +#endif + } else { + FCPARAM(isp)->isp_fwattr = mbs.param[6]; + isp_prt(isp, ISP_LOGDEBUG0, + "Firmware Attributes = 0x%x", mbs.param[6]); + } + if (ISP_READ(isp, BIU2100_CSR) & BIU2100_PCI64) { + isp_prt(isp, ISP_LOGCONFIG, + "Installed in 64-Bit PCI slot"); + } + } + + if (isp->isp_romfw_rev[0] || isp->isp_romfw_rev[1] || + isp->isp_romfw_rev[2]) { + isp_prt(isp, ISP_LOGCONFIG, "Last F/W revision was %d.%d.%d", + 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, MBLOGALL); + if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { + return; + } + isp->isp_maxcmds = mbs.param[2]; + isp_prt(isp, ISP_LOGINFO, + "%d max I/O commands supported", mbs.param[2]); + isp_fw_state(isp); + + /* + * Set up DMA for the request and result mailboxes. + */ + if (ISP_MBOXDMASETUP(isp) != 0) { + isp_prt(isp, ISP_LOGERR, "Cannot setup DMA"); + 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 sometimes do not have an easy way + * of knowing how many luns we support. + * + * Expanded lun firmware gives you 32 luns for SCSI cards and + * 16384 luns for Fibre Channel cards. + * + * It turns out that even for QLogic 2100s with ROM 1.10 and above + * we do get a firmware attributes word returned in mailbox register 6. + * + * 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. + */ + if (IS_SCSI(isp)) { + if (dodnld) { + if (IS_ULTRA2(isp) || IS_ULTRA3(isp)) { + isp->isp_maxluns = 32; + } else { + isp->isp_maxluns = 8; + } + } else { + isp->isp_maxluns = 8; + } + } else { + if (FCPARAM(isp)->isp_fwattr & ISP_FW_ATTR_SCCLUN) { + isp->isp_maxluns = 16384; + } else { + isp->isp_maxluns = 16; + } + } +} + +/* + * Initialize Parameters of Hardware to a known state. + * + * Locks are held before coming here. + */ + +void +isp_init(struct ispsoftc *isp) +{ + /* + * Must do this first to get defaults established. + */ + isp_setdfltparm(isp, 0); + if (IS_DUALBUS(isp)) { + isp_setdfltparm(isp, 1); + } + if (IS_FC(isp)) { + isp_fibre_init(isp); + } else { + isp_scsi_init(isp); + } +} + +static void +isp_scsi_init(struct ispsoftc *isp) +{ + sdparam *sdp_chan0, *sdp_chan1; + mbreg_t mbs; + + sdp_chan0 = isp->isp_param; + sdp_chan1 = sdp_chan0; + if (IS_DUALBUS(isp)) { + sdp_chan1++; + } + + /* + * If we have no role (neither target nor initiator), return. + */ + if (isp->isp_role == ISP_ROLE_NONE) { + return; + } + + /* First do overall per-card settings. */ + + /* + * If we have fast memory timing enabled, turn it on. + */ + if (sdp_chan0->isp_fast_mttr) { + ISP_WRITE(isp, RISC_MTR, 0x1313); + } + + /* + * Set Retry Delay and Count. + * You set both channels at the same time. + */ + mbs.param[0] = MBOX_SET_RETRY_COUNT; + mbs.param[1] = sdp_chan0->isp_retry_count; + mbs.param[2] = sdp_chan0->isp_retry_delay; + mbs.param[6] = sdp_chan1->isp_retry_count; + mbs.param[7] = sdp_chan1->isp_retry_delay; + + isp_mboxcmd(isp, &mbs, MBLOGALL); + if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { + return; + } + + /* + * Set ASYNC DATA SETUP time. This is very important. + */ + 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; + isp_mboxcmd(isp, &mbs, MBLOGALL); + if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { + return; + } + + /* + * Set ACTIVE Negation State. + */ + mbs.param[0] = MBOX_SET_ACT_NEG_STATE; + mbs.param[1] = + (sdp_chan0->isp_req_ack_active_neg << 4) | + (sdp_chan0->isp_data_line_active_neg << 5); + mbs.param[2] = + (sdp_chan1->isp_req_ack_active_neg << 4) | + (sdp_chan1->isp_data_line_active_neg << 5); + + isp_mboxcmd(isp, &mbs, MBLOGNONE); + if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { + isp_prt(isp, ISP_LOGERR, + "failed to set active negation state (%d,%d), (%d,%d)", + sdp_chan0->isp_req_ack_active_neg, + sdp_chan0->isp_data_line_active_neg, + sdp_chan1->isp_req_ack_active_neg, + sdp_chan1->isp_data_line_active_neg); + /* + * But don't return. + */ + } + + /* + * Set the Tag Aging limit + */ + mbs.param[0] = MBOX_SET_TAG_AGE_LIMIT; + mbs.param[1] = sdp_chan0->isp_tag_aging; + mbs.param[2] = sdp_chan1->isp_tag_aging; + isp_mboxcmd(isp, &mbs, MBLOGALL); + if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { + isp_prt(isp, ISP_LOGERR, "failed to set tag age limit (%d,%d)", + sdp_chan0->isp_tag_aging, sdp_chan1->isp_tag_aging); + return; + } + + /* + * Set selection timeout. + */ + mbs.param[0] = MBOX_SET_SELECT_TIMEOUT; + mbs.param[1] = sdp_chan0->isp_selection_timeout; + mbs.param[2] = sdp_chan1->isp_selection_timeout; + isp_mboxcmd(isp, &mbs, MBLOGALL); + if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { + return; + } + + /* now do per-channel settings */ + isp_scsi_channel_init(isp, 0); + if (IS_DUALBUS(isp)) + isp_scsi_channel_init(isp, 1); + + /* + * Now enable request/response queues + */ + + if (IS_ULTRA2(isp) || IS_1240(isp)) { + mbs.param[0] = MBOX_INIT_RES_QUEUE_A64; + mbs.param[1] = RESULT_QUEUE_LEN(isp); + mbs.param[2] = DMA_WD1(isp->isp_result_dma); + mbs.param[3] = DMA_WD0(isp->isp_result_dma); + mbs.param[4] = 0; + mbs.param[6] = DMA_WD3(isp->isp_result_dma); + mbs.param[7] = DMA_WD2(isp->isp_result_dma); + isp_mboxcmd(isp, &mbs, MBLOGALL); + if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { + return; + } + isp->isp_residx = mbs.param[5]; + + mbs.param[0] = MBOX_INIT_REQ_QUEUE_A64; + mbs.param[1] = RQUEST_QUEUE_LEN(isp); + mbs.param[2] = DMA_WD1(isp->isp_rquest_dma); + mbs.param[3] = DMA_WD0(isp->isp_rquest_dma); + mbs.param[5] = 0; + mbs.param[6] = DMA_WD3(isp->isp_result_dma); + mbs.param[7] = DMA_WD2(isp->isp_result_dma); + isp_mboxcmd(isp, &mbs, MBLOGALL); + if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { + return; + } + isp->isp_reqidx = isp->isp_reqodx = mbs.param[4]; + } else { + mbs.param[0] = MBOX_INIT_RES_QUEUE; + mbs.param[1] = RESULT_QUEUE_LEN(isp); + mbs.param[2] = DMA_WD1(isp->isp_result_dma); + mbs.param[3] = DMA_WD0(isp->isp_result_dma); + mbs.param[4] = 0; + isp_mboxcmd(isp, &mbs, MBLOGALL); + if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { + return; + } + isp->isp_residx = mbs.param[5]; + + mbs.param[0] = MBOX_INIT_REQ_QUEUE; + mbs.param[1] = RQUEST_QUEUE_LEN(isp); + mbs.param[2] = DMA_WD1(isp->isp_rquest_dma); + mbs.param[3] = DMA_WD0(isp->isp_rquest_dma); + mbs.param[5] = 0; + isp_mboxcmd(isp, &mbs, MBLOGALL); + if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { + return; + } + isp->isp_reqidx = isp->isp_reqodx = mbs.param[4]; + } + + /* + * Turn on Fast Posting, LVD transitions + * + * 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. + */ + + mbs.param[0] = MBOX_SET_FW_FEATURES; + mbs.param[1] = 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; +#else +#ifndef ISP_NO_FASTPOST + if (IS_ULTRA2(isp) || IS_1240(isp)) + mbs.param[1] |= FW_FEATURE_FAST_POST; +#endif +#endif + if (mbs.param[1] != 0) { + u_int16_t sfeat = mbs.param[1]; + isp_mboxcmd(isp, &mbs, MBLOGALL); + if (mbs.param[0] == MBOX_COMMAND_COMPLETE) { + isp_prt(isp, ISP_LOGINFO, + "Enabled FW features (0x%x)", sfeat); + } + } + + /* + * Let the outer layers decide whether to issue a SCSI bus reset. + */ + isp->isp_state = ISP_INITSTATE; +} + +static void +isp_scsi_channel_init(struct ispsoftc *isp, int channel) +{ + sdparam *sdp; + mbreg_t mbs; + int tgt; + + sdp = isp->isp_param; + sdp += channel; + + /* + * Set (possibly new) Initiator ID. + */ + mbs.param[0] = MBOX_SET_INIT_SCSI_ID; + mbs.param[1] = (channel << 7) | sdp->isp_initiator_id; + isp_mboxcmd(isp, &mbs, MBLOGALL); + if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { + return; + } + isp_prt(isp, ISP_LOGINFO, "Initiator ID is %d on Channel %d", + sdp->isp_initiator_id, channel); + + + /* + * Set current per-target parameters to an initial safe minimum. + */ + for (tgt = 0; tgt < MAX_TARGETS; tgt++) { + int lun; + u_int16_t sdf; + + if (sdp->isp_devparam[tgt].dev_enable == 0) { + continue; + } +#ifndef ISP_TARGET_MODE + sdf = sdp->isp_devparam[tgt].goal_flags; + sdf &= DPARM_SAFE_DFLT; + /* + * It is not quite clear when this changed over so that + * we could force narrow and async for 1000/1020 cards, + * but assume that this is only the case for loaded + * firmware. + */ + if (isp->isp_loaded_fw) { + sdf |= DPARM_NARROW | DPARM_ASYNC; + } +#else + /* + * The !$*!)$!$)* f/w uses the same index into some + * internal table to decide how to respond to negotiations, + * so if we've said "let's be safe" for ID X, and ID X + * selects *us*, the negotiations will back to 'safe' + * (as in narrow/async). What the f/w *should* do is + * use the initiator id settings to decide how to respond. + */ + sdp->isp_devparam[tgt].goal_flags = sdf = DPARM_DEFAULT; +#endif + mbs.param[0] = MBOX_SET_TARGET_PARAMS; + mbs.param[1] = (channel << 15) | (tgt << 8); + mbs.param[2] = sdf; + if ((sdf & DPARM_SYNC) == 0) { + mbs.param[3] = 0; + } else { + mbs.param[3] = + (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", + channel, tgt, mbs.param[2], mbs.param[3] >> 8, + mbs.param[3] & 0xff); + isp_mboxcmd(isp, &mbs, MBLOGNONE); + if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { + sdf = DPARM_SAFE_DFLT; + mbs.param[0] = MBOX_SET_TARGET_PARAMS; + mbs.param[1] = (tgt << 8) | (channel << 15); + mbs.param[2] = sdf; + mbs.param[3] = 0; + isp_mboxcmd(isp, &mbs, MBLOGALL); + if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { + continue; + } + } + + /* + * We don't update any information directly from the f/w + * because we need to run at least one command to cause a + * new state to be latched up. So, we just assume that we + * converge to the values we just had set. + * + * Ensure that we don't believe tagged queuing is enabled yet. + * It turns out that sometimes the ISP just ignores our + * attempts to set parameters for devices that it hasn't + * seen yet. + */ + sdp->isp_devparam[tgt].actv_flags = sdf & ~DPARM_TQING; + for (lun = 0; lun < (int) 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; + mbs.param[3] = sdp->isp_devparam[tgt].exc_throttle; + isp_mboxcmd(isp, &mbs, MBLOGALL); + if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { + break; + } + } + } + for (tgt = 0; tgt < MAX_TARGETS; tgt++) { + if (sdp->isp_devparam[tgt].dev_refresh) { + isp->isp_sendmarker |= (1 << channel); + isp->isp_update |= (1 << channel); + break; + } + } +} + +/* + * Fibre Channel specific initialization. + * + * Locks are held before coming here. + */ +static void +isp_fibre_init(struct ispsoftc *isp) +{ + fcparam *fcp; + isp_icb_t local, *icbp = &local; + mbreg_t mbs; + int loopid; + u_int64_t nwwn, pwwn; + + fcp = isp->isp_param; + + /* + * Do this *before* initializing the firmware. + */ + isp_mark_getpdb_all(isp); + fcp->isp_fwstate = FW_CONFIG_WAIT; + fcp->isp_loopstate = LOOP_NIL; + + /* + * If we have no role (neither target nor initiator), return. + */ + if (isp->isp_role == ISP_ROLE_NONE) { + return; + } + + loopid = fcp->isp_loopid; + MEMZERO(icbp, sizeof (*icbp)); + icbp->icb_version = ICB_VERSION1; + + /* + * Firmware Options are either retrieved from NVRAM or + * are patched elsewhere. We check them for sanity here + * and make changes based on board revision, but otherwise + * let others decide policy. + */ + + /* + * If this is a 2100 < revision 5, we have to turn off FAIRNESS. + */ + if ((isp->isp_type == ISP_HA_FC_2100) && isp->isp_revision < 5) { + fcp->isp_fwoptions &= ~ICBOPT_FAIRNESS; + } + + /* + * 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 for 2100 f/w less than 1.17.0. + */ + if (!ISP_FW_NEWER_THAN(isp, 1, 17, 0)) { + fcp->isp_fwoptions |= ICBOPT_FULL_LOGIN; + } + + /* + * Insist on Port Database Update Async notifications + */ + fcp->isp_fwoptions |= ICBOPT_PDBCHANGE_AE; + + /* + * Make sure that target role reflects into fwoptions. + */ + if (isp->isp_role & ISP_ROLE_TARGET) { + fcp->isp_fwoptions |= ICBOPT_TGT_ENABLE; + } else { + fcp->isp_fwoptions &= ~ICBOPT_TGT_ENABLE; + } + + /* + * Propagate all of this into the ICB structure. + */ + icbp->icb_fwoptions = fcp->isp_fwoptions; + icbp->icb_maxfrmlen = fcp->isp_maxfrmlen; + if (icbp->icb_maxfrmlen < ICB_MIN_FRMLEN || + icbp->icb_maxfrmlen > ICB_MAX_FRMLEN) { + isp_prt(isp, ISP_LOGERR, + "bad frame length (%d) from NVRAM- using %d", + fcp->isp_maxfrmlen, ICB_DFLT_FRMLEN); + icbp->icb_maxfrmlen = ICB_DFLT_FRMLEN; + } + icbp->icb_maxalloc = fcp->isp_maxalloc; + if (icbp->icb_maxalloc < 1) { + isp_prt(isp, ISP_LOGERR, + "bad maximum allocation (%d)- using 16", fcp->isp_maxalloc); + icbp->icb_maxalloc = 16; + } + icbp->icb_execthrottle = fcp->isp_execthrottle; + if (icbp->icb_execthrottle < 1) { + isp_prt(isp, ISP_LOGERR, + "bad execution throttle of %d- using 16", + fcp->isp_execthrottle); + icbp->icb_execthrottle = ICB_DFLT_THROTTLE; + } + icbp->icb_retry_delay = fcp->isp_retry_delay; + icbp->icb_retry_count = fcp->isp_retry_count; + icbp->icb_hardaddr = loopid; + /* + * Right now we just set extended options to prefer point-to-point + * over loop based upon some soft config options. + * + * NB: for the 2300, ICBOPT_EXTENDED is required. + */ + if (IS_2200(isp) || IS_23XX(isp)) { + icbp->icb_fwoptions |= ICBOPT_EXTENDED; + /* + * Prefer or force Point-To-Point instead Loop? + */ + switch(isp->isp_confopts & ISP_CFG_PORT_PREF) { + case ISP_CFG_NPORT: + icbp->icb_xfwoptions |= ICBXOPT_PTP_2_LOOP; + break; + case ISP_CFG_NPORT_ONLY: + icbp->icb_xfwoptions |= ICBXOPT_PTP_ONLY; + break; + case ISP_CFG_LPORT_ONLY: + icbp->icb_xfwoptions |= ICBXOPT_LOOP_ONLY; + break; + default: + icbp->icb_xfwoptions |= ICBXOPT_LOOP_2_PTP; + break; + } + if (IS_23XX(isp)) { + /* + * QLogic recommends that FAST Posting be turned + * off for 23XX cards and instead allow the HBA + * to write response queue entries and interrupt + * after a delay (ZIO). + * + * If we set ZIO, it will disable fast posting, + * so we don't need to clear it in fwoptions. + */ + icbp->icb_xfwoptions |= ICBXOPT_ZIO; + + if (isp->isp_confopts & ISP_CFG_ONEGB) { + icbp->icb_zfwoptions |= ICBZOPT_RATE_ONEGB; + } else if (isp->isp_confopts & ISP_CFG_TWOGB) { + icbp->icb_zfwoptions |= ICBZOPT_RATE_TWOGB; + } else { + icbp->icb_zfwoptions |= ICBZOPT_RATE_AUTO; + } + } + } + +#ifndef ISP_NO_RIO_FC + /* + * RIO seems to be enabled in 2100s for fw >= 1.17.0. + * + * I've had some questionable problems with RIO on 2200. + * More specifically, on a 2204 I had problems with RIO + * on a Linux system where I was dropping commands right + * and left. It's not clear to me what the actual problem + * was. + * + * 23XX Cards do not support RIO. Instead they support ZIO. + */ +#if 0 + if (!IS_23XX(isp) && ISP_FW_NEWER_THAN(isp, 1, 17, 0)) { + icbp->icb_xfwoptions |= ICBXOPT_RIO_16BIT; + icbp->icb_racctimer = 4; + icbp->icb_idelaytimer = 8; + } +#endif +#endif + + /* + * For 22XX > 2.1.26 && 23XX, set someoptions. + * XXX: Probably okay for newer 2100 f/w too. + */ + if (ISP_FW_NEWER_THAN(isp, 2, 26, 0)) { + /* + * Turn on LIP F8 async event (1) + * Turn on generate AE 8013 on all LIP Resets (2) + * Disable LIP F7 switching (8) + */ + mbs.param[0] = MBOX_SET_FIRMWARE_OPTIONS; + mbs.param[1] = 0xb; + mbs.param[2] = 0; + mbs.param[3] = 0; + isp_mboxcmd(isp, &mbs, MBLOGALL); + } + icbp->icb_logintime = 30; /* 30 second login timeout */ + + if (IS_23XX(isp)) { + ISP_WRITE(isp, isp->isp_rqstinrp, 0); + ISP_WRITE(isp, isp->isp_rqstoutrp, 0); + ISP_WRITE(isp, isp->isp_respinrp, 0); + ISP_WRITE(isp, isp->isp_respoutrp, 0); + } + + nwwn = ISP_NODEWWN(isp); + pwwn = ISP_PORTWWN(isp); + if (nwwn && pwwn) { + icbp->icb_fwoptions |= ICBOPT_BOTH_WWNS; + MAKE_NODE_NAME_FROM_WWN(icbp->icb_nodename, nwwn); + MAKE_NODE_NAME_FROM_WWN(icbp->icb_portname, pwwn); + isp_prt(isp, ISP_LOGDEBUG1, + "Setting ICB Node 0x%08x%08x Port 0x%08x%08x", + ((u_int32_t) (nwwn >> 32)), + ((u_int32_t) (nwwn & 0xffffffff)), + ((u_int32_t) (pwwn >> 32)), + ((u_int32_t) (pwwn & 0xffffffff))); + } else { + isp_prt(isp, ISP_LOGDEBUG1, "Not using any WWNs"); + icbp->icb_fwoptions &= ~(ICBOPT_BOTH_WWNS|ICBOPT_FULL_LOGIN); + } + icbp->icb_rqstqlen = RQUEST_QUEUE_LEN(isp); + icbp->icb_rsltqlen = RESULT_QUEUE_LEN(isp); + icbp->icb_rqstaddr[RQRSP_ADDR0015] = DMA_WD0(isp->isp_rquest_dma); + icbp->icb_rqstaddr[RQRSP_ADDR1631] = DMA_WD1(isp->isp_rquest_dma); + icbp->icb_rqstaddr[RQRSP_ADDR3247] = DMA_WD2(isp->isp_rquest_dma); + icbp->icb_rqstaddr[RQRSP_ADDR4863] = DMA_WD3(isp->isp_rquest_dma); + icbp->icb_respaddr[RQRSP_ADDR0015] = DMA_WD0(isp->isp_result_dma); + icbp->icb_respaddr[RQRSP_ADDR1631] = DMA_WD1(isp->isp_result_dma); + icbp->icb_respaddr[RQRSP_ADDR3247] = DMA_WD2(isp->isp_result_dma); + icbp->icb_respaddr[RQRSP_ADDR4863] = DMA_WD3(isp->isp_result_dma); + 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); + + FC_SCRATCH_ACQUIRE(isp); + isp_put_icb(isp, icbp, (isp_icb_t *)fcp->isp_scratch); + + /* + * Init the firmware + */ + 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_mboxcmd(isp, &mbs, MBLOGALL); + FC_SCRATCH_RELEASE(isp); + if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { + return; + } + isp->isp_reqidx = isp->isp_reqodx = 0; + isp->isp_residx = 0; + isp->isp_sendmarker = 1; + + /* + * Whatever happens, we're now committed to being here. + */ + isp->isp_state = ISP_INITSTATE; +} + +/* + * Fibre Channel Support- get the port database for the id. + * + * Locks are held before coming here. Return 0 if success, + * else failure. + */ + +static int +isp_getmap(struct ispsoftc *isp, fcpos_map_t *map) +{ + fcparam *fcp = (fcparam *) isp->isp_param; + mbreg_t 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] = 0; + mbs.param[7] = 0; + FC_SCRATCH_ACQUIRE(isp); + isp_mboxcmd(isp, &mbs, MBLOGALL & ~MBOX_COMMAND_PARAM_ERROR); + if (mbs.param[0] == MBOX_COMMAND_COMPLETE) { + MEMCPY(map, fcp->isp_scratch, sizeof (fcpos_map_t)); + map->fwmap = mbs.param[1] != 0; + FC_SCRATCH_RELEASE(isp); + return (0); + } + FC_SCRATCH_RELEASE(isp); + return (-1); +} + +static void +isp_mark_getpdb_all(struct ispsoftc *isp) +{ + fcparam *fcp = (fcparam *) isp->isp_param; + int i; + for (i = 0; i < MAX_FC_TARG; i++) { + fcp->portdb[i].valid = fcp->portdb[i].fabric_dev = 0; + } +} + +static int +isp_getpdb(struct ispsoftc *isp, int id, isp_pdb_t *pdbp) +{ + fcparam *fcp = (fcparam *) isp->isp_param; + mbreg_t mbs; + + mbs.param[0] = MBOX_GET_PORT_DB; + mbs.param[1] = id << 8; + 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); + isp_mboxcmd(isp, &mbs, MBLOGALL & ~MBOX_COMMAND_PARAM_ERROR); + if (mbs.param[0] == MBOX_COMMAND_COMPLETE) { + isp_get_pdb(isp, (isp_pdb_t *)fcp->isp_scratch, pdbp); + FC_SCRATCH_RELEASE(isp); + return (0); + } + FC_SCRATCH_RELEASE(isp); + return (-1); +} + +static u_int64_t +isp_get_portname(struct ispsoftc *isp, int loopid, int nodename) +{ + u_int64_t wwn = 0; + mbreg_t mbs; + + mbs.param[0] = MBOX_GET_PORT_NAME; + mbs.param[1] = loopid << 8; + if (nodename) + mbs.param[1] |= 1; + isp_mboxcmd(isp, &mbs, MBLOGALL & ~MBOX_COMMAND_PARAM_ERROR); + if (mbs.param[0] == MBOX_COMMAND_COMPLETE) { + wwn = + (((u_int64_t)(mbs.param[2] & 0xff)) << 56) | + (((u_int64_t)(mbs.param[2] >> 8)) << 48) | + (((u_int64_t)(mbs.param[3] & 0xff)) << 40) | + (((u_int64_t)(mbs.param[3] >> 8)) << 32) | + (((u_int64_t)(mbs.param[6] & 0xff)) << 24) | + (((u_int64_t)(mbs.param[6] >> 8)) << 16) | + (((u_int64_t)(mbs.param[7] & 0xff)) << 8) | + (((u_int64_t)(mbs.param[7] >> 8))); + } + return (wwn); +} + +/* + * Make sure we have good FC link and know our Loop ID. + */ + +static int +isp_fclink_test(struct ispsoftc *isp, int usdelay) +{ + static char *toponames[] = { + "Private Loop", + "FL Port", + "N-Port to N-Port", + "F Port", + "F Port (no FLOGI_ACC response)" + }; + mbreg_t mbs; + int count, check_for_fabric; + u_int8_t lwfs; + fcparam *fcp; + struct lportdb *lp; + isp_pdb_t pdb; + + fcp = isp->isp_param; + + /* + * XXX: Here is where we would start a 'loop dead' timeout + */ + + /* + * Wait up to N microseconds for F/W to go to a ready state. + */ + lwfs = FW_CONFIG_WAIT; + count = 0; + while (count < usdelay) { + u_int64_t enano; + u_int32_t wrk; + NANOTIME_T hra, hrb; + + GET_NANOTIME(&hra); + isp_fw_state(isp); + if (lwfs != fcp->isp_fwstate) { + isp_prt(isp, ISP_LOGINFO, "Firmware State <%s->%s>", + isp2100_fw_statename((int)lwfs), + isp2100_fw_statename((int)fcp->isp_fwstate)); + lwfs = fcp->isp_fwstate; + } + if (fcp->isp_fwstate == FW_READY) { + break; + } + GET_NANOTIME(&hrb); + + /* + * Get the elapsed time in nanoseconds. + * Always guaranteed to be non-zero. + */ + enano = NANOTIME_SUB(&hrb, &hra); + + isp_prt(isp, ISP_LOGDEBUG1, + "usec%d: 0x%lx->0x%lx enano 0x%x%08x", + count, (long) GET_NANOSEC(&hra), (long) GET_NANOSEC(&hrb), + (u_int32_t)(enano >> 32), (u_int32_t)(enano & 0xffffffff)); + + /* + * If the elapsed time is less than 1 millisecond, + * delay a period of time up to that millisecond of + * waiting. + * + * This peculiar code is an attempt to try and avoid + * invoking u_int64_t math support functions for some + * platforms where linkage is a problem. + */ + if (enano < (1000 * 1000)) { + count += 1000; + enano = (1000 * 1000) - enano; + while (enano > (u_int64_t) 4000000000U) { + USEC_SLEEP(isp, 4000000); + enano -= (u_int64_t) 4000000000U; + } + wrk = enano; + wrk /= 1000; + USEC_SLEEP(isp, wrk); + } else { + while (enano > (u_int64_t) 4000000000U) { + count += 4000000; + enano -= (u_int64_t) 4000000000U; + } + wrk = enano; + count += (wrk / 1000); + } + } + + /* + * If we haven't gone to 'ready' state, return. + */ + if (fcp->isp_fwstate != FW_READY) { + return (-1); + } + + /* + * Get our Loop ID (if possible). We really need to have it. + */ + mbs.param[0] = MBOX_GET_LOOP_ID; + isp_mboxcmd(isp, &mbs, MBLOGALL); + if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { + return (-1); + } + fcp->isp_loopid = mbs.param[1]; + if (IS_2200(isp) || IS_23XX(isp)) { + int topo = (int) mbs.param[6]; + if (topo < TOPO_NL_PORT || topo > TOPO_PTP_STUB) + topo = TOPO_PTP_STUB; + fcp->isp_topo = topo; + } else { + fcp->isp_topo = TOPO_NL_PORT; + } + fcp->isp_portid = fcp->isp_alpa = mbs.param[2] & 0xff; + + /* + * Check to see if we're on a fabric by trying to see if we + * can talk to the fabric name server. This can be a bit + * tricky because if we're a 2100, we should check always + * (in case we're connected to an server doing aliasing). + */ + fcp->isp_onfabric = 0; + + if (IS_2100(isp)) { + /* + * Don't bother with fabric if we are using really old + * 2100 firmware. It's just not worth it. + */ + if (ISP_FW_NEWER_THAN(isp, 1, 15, 37)) { + check_for_fabric = 1; + } else { + check_for_fabric = 0; + } + } else if (fcp->isp_topo == TOPO_FL_PORT || + fcp->isp_topo == TOPO_F_PORT) { + check_for_fabric = 1; + } else + check_for_fabric = 0; + + if (check_for_fabric && isp_getpdb(isp, FL_PORT_ID, &pdb) == 0) { + int loopid = FL_PORT_ID; + if (IS_2100(isp)) { + fcp->isp_topo = TOPO_FL_PORT; + } + + if (BITS2WORD(pdb.pdb_portid_bits) == 0) { + /* + * Crock. + */ + fcp->isp_topo = TOPO_NL_PORT; + goto not_on_fabric; + } + fcp->isp_portid = mbs.param[2] | ((int) mbs.param[3] << 16); + + /* + * Save the Fabric controller's port database entry. + */ + lp = &fcp->portdb[loopid]; + lp->node_wwn = + (((u_int64_t)pdb.pdb_nodename[0]) << 56) | + (((u_int64_t)pdb.pdb_nodename[1]) << 48) | + (((u_int64_t)pdb.pdb_nodename[2]) << 40) | + (((u_int64_t)pdb.pdb_nodename[3]) << 32) | + (((u_int64_t)pdb.pdb_nodename[4]) << 24) | + (((u_int64_t)pdb.pdb_nodename[5]) << 16) | + (((u_int64_t)pdb.pdb_nodename[6]) << 8) | + (((u_int64_t)pdb.pdb_nodename[7])); + lp->port_wwn = + (((u_int64_t)pdb.pdb_portname[0]) << 56) | + (((u_int64_t)pdb.pdb_portname[1]) << 48) | + (((u_int64_t)pdb.pdb_portname[2]) << 40) | + (((u_int64_t)pdb.pdb_portname[3]) << 32) | + (((u_int64_t)pdb.pdb_portname[4]) << 24) | + (((u_int64_t)pdb.pdb_portname[5]) << 16) | + (((u_int64_t)pdb.pdb_portname[6]) << 8) | + (((u_int64_t)pdb.pdb_portname[7])); + lp->roles = + (pdb.pdb_prli_svc3 & SVC3_ROLE_MASK) >> SVC3_ROLE_SHIFT; + lp->portid = BITS2WORD(pdb.pdb_portid_bits); + lp->loopid = pdb.pdb_loopid; + lp->loggedin = lp->valid = 1; + fcp->isp_onfabric = 1; + (void) isp_async(isp, ISPASYNC_PROMENADE, &loopid); + isp_register_fc4_type(isp); + } else { +not_on_fabric: + fcp->isp_onfabric = 0; + fcp->portdb[FL_PORT_ID].valid = 0; + } + + fcp->isp_gbspeed = 1; + if (IS_23XX(isp)) { + mbs.param[0] = MBOX_GET_SET_DATA_RATE; + mbs.param[1] = MBGSD_GET_RATE; + /* mbs.param[2] undefined if we're just getting rate */ + isp_mboxcmd(isp, &mbs, MBLOGALL); + if (mbs.param[0] == MBOX_COMMAND_COMPLETE) { + if (mbs.param[1] == MBGSD_TWOGB) { + isp_prt(isp, ISP_LOGINFO, "2Gb link speed/s"); + fcp->isp_gbspeed = 2; + } + } + } + + isp_prt(isp, ISP_LOGCONFIG, topology, fcp->isp_loopid, fcp->isp_alpa, + fcp->isp_portid, fcp->isp_loopstate, toponames[fcp->isp_topo]); + + /* + * Announce ourselves, too. This involves synthesizing an entry. + */ + if (fcp->isp_iid_set == 0) { + fcp->isp_iid_set = 1; + fcp->isp_iid = fcp->isp_loopid; + lp = &fcp->portdb[fcp->isp_iid]; + } else { + lp = &fcp->portdb[fcp->isp_iid]; + if (fcp->isp_portid != lp->portid || + fcp->isp_loopid != lp->loopid || + fcp->isp_nodewwn != ISP_NODEWWN(isp) || + fcp->isp_portwwn != ISP_PORTWWN(isp)) { + lp->valid = 0; + count = fcp->isp_iid; + (void) isp_async(isp, ISPASYNC_PROMENADE, &count); + } + } + lp->loopid = fcp->isp_loopid; + lp->portid = fcp->isp_portid; + lp->node_wwn = ISP_NODEWWN(isp); + lp->port_wwn = ISP_PORTWWN(isp); + switch (isp->isp_role) { + case ISP_ROLE_NONE: + lp->roles = 0; + break; + case ISP_ROLE_TARGET: + lp->roles = SVC3_TGT_ROLE >> SVC3_ROLE_SHIFT; + break; + case ISP_ROLE_INITIATOR: + lp->roles = SVC3_INI_ROLE >> SVC3_ROLE_SHIFT; + break; + case ISP_ROLE_BOTH: + lp->roles = (SVC3_INI_ROLE|SVC3_TGT_ROLE) >> SVC3_ROLE_SHIFT; + break; + } + lp->loggedin = lp->valid = 1; + count = fcp->isp_iid; + (void) isp_async(isp, ISPASYNC_PROMENADE, &count); + return (0); +} + +static char * +isp2100_fw_statename(int state) +{ + switch(state) { + case FW_CONFIG_WAIT: return "Config Wait"; + case FW_WAIT_AL_PA: return "Waiting for AL_PA"; + case FW_WAIT_LOGIN: return "Wait Login"; + case FW_READY: return "Ready"; + case FW_LOSS_OF_SYNC: return "Loss Of Sync"; + case FW_ERROR: return "Error"; + case FW_REINIT: return "Re-Init"; + case FW_NON_PART: return "Nonparticipating"; + default: return "?????"; + } +} + +/* + * Synchronize our soft copy of the port database with what the f/w thinks + * (with a view toward possibly for a specific target....) + */ + +static int +isp_pdb_sync(struct ispsoftc *isp) +{ + struct lportdb *lp; + fcparam *fcp = isp->isp_param; + isp_pdb_t pdb; + int loopid, base, lim; + + /* + * 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_LSCAN_DONE) { + return (-1); + } + + if (fcp->isp_topo == TOPO_FL_PORT || fcp->isp_topo == TOPO_NL_PORT || + fcp->isp_topo == TOPO_N_PORT) { + if (fcp->isp_loopstate < LOOP_LSCAN_DONE) { + if (isp_scan_loop(isp) != 0) { + return (-1); + } + } + } + fcp->isp_loopstate = LOOP_SYNCING_PDB; + + /* + * If we get this far, we've settled our differences with the f/w + * (for local loop device) and we can say that the loop state is ready. + */ + + if (fcp->isp_topo == TOPO_NL_PORT) { + fcp->loop_seen_once = 1; + fcp->isp_loopstate = LOOP_READY; + return (0); + } + + /* + * Find all Fabric Entities that didn't make it from one scan to the + * next and let the world know they went away. Scan the whole database. + */ + for (lp = &fcp->portdb[0]; lp < &fcp->portdb[MAX_FC_TARG]; lp++) { + if (lp->was_fabric_dev && lp->fabric_dev == 0) { + loopid = lp - fcp->portdb; + lp->valid = 0; /* should already be set */ + (void) isp_async(isp, ISPASYNC_PROMENADE, &loopid); + MEMZERO((void *) lp, sizeof (*lp)); + continue; + } + lp->was_fabric_dev = lp->fabric_dev; + } + + if (fcp->isp_topo == TOPO_FL_PORT) + base = FC_SNS_ID+1; + else + base = 0; + + if (fcp->isp_topo == TOPO_N_PORT) + lim = 1; + else + lim = MAX_FC_TARG; + + /* + * Now log in any fabric devices that the outer layer has + * left for us to see. This seems the most sane policy + * for the moment. + */ + for (lp = &fcp->portdb[base]; lp < &fcp->portdb[lim]; lp++) { + u_int32_t portid; + mbreg_t mbs; + + loopid = lp - fcp->portdb; + if (loopid >= FL_PORT_ID && loopid <= FC_SNS_ID) { + continue; + } + + /* + * Anything here? + */ + if (lp->port_wwn == 0) { + continue; + } + + /* + * Don't try to log into yourself. + */ + if ((portid = lp->portid) == fcp->isp_portid) { + continue; + } + + + /* + * If we'd been logged in- see if we still are and we haven't + * changed. If so, no need to log ourselves out, etc.. + * + * Unfortunately, our charming Qlogic f/w has decided to + * return a valid port database entry for a fabric device + * that has, in fact, gone away. And it hangs trying to + * log it out. + */ + if (lp->loggedin && lp->force_logout == 0 && + isp_getpdb(isp, lp->loopid, &pdb) == 0) { + int nrole; + u_int64_t nwwnn, nwwpn; + 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) | + (((u_int64_t)pdb.pdb_nodename[3]) << 32) | + (((u_int64_t)pdb.pdb_nodename[4]) << 24) | + (((u_int64_t)pdb.pdb_nodename[5]) << 16) | + (((u_int64_t)pdb.pdb_nodename[6]) << 8) | + (((u_int64_t)pdb.pdb_nodename[7])); + 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) | + (((u_int64_t)pdb.pdb_portname[3]) << 32) | + (((u_int64_t)pdb.pdb_portname[4]) << 24) | + (((u_int64_t)pdb.pdb_portname[5]) << 16) | + (((u_int64_t)pdb.pdb_portname[6]) << 8) | + (((u_int64_t)pdb.pdb_portname[7])); + nrole = (pdb.pdb_prli_svc3 & SVC3_ROLE_MASK) >> + SVC3_ROLE_SHIFT; + 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->force_logout == 0) { + lp->loggedin = lp->valid = 1; + isp_prt(isp, ISP_LOGCONFIG, lretained, + (int) (lp - fcp->portdb), + (int) lp->loopid, lp->portid); + continue; + } + } + + if (fcp->isp_fwstate != FW_READY || + fcp->isp_loopstate != LOOP_SYNCING_PDB) { + return (-1); + } + + /* + * Force a logout if we were logged in. + */ + if (lp->loggedin) { + if (lp->force_logout || + isp_getpdb(isp, lp->loopid, &pdb) == 0) { + mbs.param[0] = MBOX_FABRIC_LOGOUT; + 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, + lp->portid); + } + lp->force_logout = lp->loggedin = 0; + if (fcp->isp_fwstate != FW_READY || + fcp->isp_loopstate != LOOP_SYNCING_PDB) { + return (-1); + } + } + + /* + * And log in.... + */ + loopid = lp - fcp->portdb; + lp->loopid = FL_PORT_ID; + do { + mbs.param[0] = MBOX_FABRIC_LOGIN; + mbs.param[1] = loopid << 8; + mbs.param[2] = portid >> 16; + mbs.param[3] = portid & 0xffff; + isp_mboxcmd(isp, &mbs, MBLOGALL & ~(MBOX_LOOP_ID_USED | + MBOX_PORT_ID_USED | MBOX_COMMAND_ERROR)); + if (fcp->isp_fwstate != FW_READY || + fcp->isp_loopstate != LOOP_SYNCING_PDB) { + return (-1); + } + switch (mbs.param[0]) { + case MBOX_LOOP_ID_USED: + /* + * Try the next available loop id. + */ + loopid++; + break; + case MBOX_PORT_ID_USED: + /* + * This port is already logged in. + * Snaffle the loop id it's using if it's + * nonzero, otherwise we're hosed. + */ + if (mbs.param[1] != 0) { + loopid = mbs.param[1]; + isp_prt(isp, ISP_LOGINFO, retained, + loopid, (int) (lp - fcp->portdb), + lp->portid); + } else { + loopid = MAX_FC_TARG; + break; + } + /* FALLTHROUGH */ + case MBOX_COMMAND_COMPLETE: + lp->loggedin = 1; + lp->loopid = loopid; + break; + case MBOX_COMMAND_ERROR: + isp_prt(isp, ISP_LOGINFO, plogierr, + portid, mbs.param[1]); + /* FALLTHROUGH */ + case MBOX_ALL_IDS_USED: /* We're outta IDs */ + default: + loopid = MAX_FC_TARG; + break; + } + } while (lp->loopid == FL_PORT_ID && loopid < MAX_FC_TARG); + + /* + * If we get here and we haven't set a Loop ID, + * we failed to log into this device. + */ + + if (lp->loopid == FL_PORT_ID) { + lp->loopid = 0; + continue; + } + + /* + * Make sure we can get the approriate port information. + */ + if (isp_getpdb(isp, lp->loopid, &pdb) != 0) { + isp_prt(isp, ISP_LOGWARN, nopdb, lp->portid); + goto dump_em; + } + + if (fcp->isp_fwstate != FW_READY || + fcp->isp_loopstate != LOOP_SYNCING_PDB) { + return (-1); + } + + if (pdb.pdb_loopid != lp->loopid) { + isp_prt(isp, ISP_LOGWARN, pdbmfail1, + lp->portid, pdb.pdb_loopid); + goto dump_em; + } + + if (lp->portid != (u_int32_t) BITS2WORD(pdb.pdb_portid_bits)) { + isp_prt(isp, ISP_LOGWARN, pdbmfail2, + lp->portid, BITS2WORD(pdb.pdb_portid_bits)); + goto dump_em; + } + + lp->roles = + (pdb.pdb_prli_svc3 & SVC3_ROLE_MASK) >> SVC3_ROLE_SHIFT; + lp->node_wwn = + (((u_int64_t)pdb.pdb_nodename[0]) << 56) | + (((u_int64_t)pdb.pdb_nodename[1]) << 48) | + (((u_int64_t)pdb.pdb_nodename[2]) << 40) | + (((u_int64_t)pdb.pdb_nodename[3]) << 32) | + (((u_int64_t)pdb.pdb_nodename[4]) << 24) | + (((u_int64_t)pdb.pdb_nodename[5]) << 16) | + (((u_int64_t)pdb.pdb_nodename[6]) << 8) | + (((u_int64_t)pdb.pdb_nodename[7])); + lp->port_wwn = + (((u_int64_t)pdb.pdb_portname[0]) << 56) | + (((u_int64_t)pdb.pdb_portname[1]) << 48) | + (((u_int64_t)pdb.pdb_portname[2]) << 40) | + (((u_int64_t)pdb.pdb_portname[3]) << 32) | + (((u_int64_t)pdb.pdb_portname[4]) << 24) | + (((u_int64_t)pdb.pdb_portname[5]) << 16) | + (((u_int64_t)pdb.pdb_portname[6]) << 8) | + (((u_int64_t)pdb.pdb_portname[7])); + /* + * Check to make sure this all makes sense. + */ + if (lp->node_wwn && lp->port_wwn) { + lp->valid = 1; + loopid = lp - fcp->portdb; + (void) isp_async(isp, ISPASYNC_PROMENADE, &loopid); + continue; + } +dump_em: + lp->valid = 0; + isp_prt(isp, ISP_LOGINFO, + ldumped, loopid, lp->loopid, lp->portid); + mbs.param[0] = MBOX_FABRIC_LOGOUT; + mbs.param[1] = lp->loopid << 8; + mbs.param[2] = 0; + mbs.param[3] = 0; + isp_mboxcmd(isp, &mbs, MBLOGNONE); + if (fcp->isp_fwstate != FW_READY || + fcp->isp_loopstate != LOOP_SYNCING_PDB) { + return (-1); + } + } + /* + * If we get here, we've for sure seen not only a valid loop + * but know what is or isn't on it, so mark this for usage + * in isp_start. + */ + fcp->loop_seen_once = 1; + fcp->isp_loopstate = LOOP_READY; + return (0); +} + +static int +isp_scan_loop(struct ispsoftc *isp) +{ + struct lportdb *lp; + fcparam *fcp = isp->isp_param; + isp_pdb_t pdb; + int loopid, lim, hival; + + switch (fcp->isp_topo) { + case TOPO_NL_PORT: + hival = FL_PORT_ID; + break; + case TOPO_N_PORT: + hival = 2; + break; + case TOPO_FL_PORT: + hival = FC_PORT_ID; + break; + default: + fcp->isp_loopstate = LOOP_LSCAN_DONE; + return (0); + } + fcp->isp_loopstate = LOOP_SCANNING_LOOP; + + /* + * make sure the temp port database is clean... + */ + MEMZERO((void *)fcp->tport, sizeof (fcp->tport)); + + /* + * Run through the local loop ports and get port database info + * for each loop ID. + * + * There's a somewhat unexplained situation where the f/w passes back + * the wrong database entity- if that happens, just restart (up to + * FL_PORT_ID times). + */ + for (lim = loopid = 0; loopid < hival; loopid++) { + lp = &fcp->tport[loopid]; + + /* + * Don't even try for ourselves... + */ + if (loopid == fcp->isp_loopid) + continue; + + lp->node_wwn = isp_get_portname(isp, loopid, 1); + if (fcp->isp_loopstate < LOOP_SCANNING_LOOP) + return (-1); + if (lp->node_wwn == 0) + continue; + lp->port_wwn = isp_get_portname(isp, loopid, 0); + if (fcp->isp_loopstate < LOOP_SCANNING_LOOP) + return (-1); + if (lp->port_wwn == 0) { + lp->node_wwn = 0; + continue; + } + + /* + * Get an entry.... + */ + if (isp_getpdb(isp, loopid, &pdb) != 0) { + if (fcp->isp_loopstate < LOOP_SCANNING_LOOP) + return (-1); + continue; + } + if (fcp->isp_loopstate < LOOP_SCANNING_LOOP) { + return (-1); + } + + /* + * If the returned database element doesn't match what we + * asked for, restart the process entirely (up to a point...). + */ + if (pdb.pdb_loopid != loopid) { + loopid = 0; + if (lim++ < hival) { + continue; + } + isp_prt(isp, ISP_LOGWARN, + "giving up on synchronizing the port database"); + return (-1); + } + + /* + * Save the pertinent info locally. + */ + lp->node_wwn = + (((u_int64_t)pdb.pdb_nodename[0]) << 56) | + (((u_int64_t)pdb.pdb_nodename[1]) << 48) | + (((u_int64_t)pdb.pdb_nodename[2]) << 40) | + (((u_int64_t)pdb.pdb_nodename[3]) << 32) | + (((u_int64_t)pdb.pdb_nodename[4]) << 24) | + (((u_int64_t)pdb.pdb_nodename[5]) << 16) | + (((u_int64_t)pdb.pdb_nodename[6]) << 8) | + (((u_int64_t)pdb.pdb_nodename[7])); + lp->port_wwn = + (((u_int64_t)pdb.pdb_portname[0]) << 56) | + (((u_int64_t)pdb.pdb_portname[1]) << 48) | + (((u_int64_t)pdb.pdb_portname[2]) << 40) | + (((u_int64_t)pdb.pdb_portname[3]) << 32) | + (((u_int64_t)pdb.pdb_portname[4]) << 24) | + (((u_int64_t)pdb.pdb_portname[5]) << 16) | + (((u_int64_t)pdb.pdb_portname[6]) << 8) | + (((u_int64_t)pdb.pdb_portname[7])); + lp->roles = + (pdb.pdb_prli_svc3 & SVC3_ROLE_MASK) >> SVC3_ROLE_SHIFT; + lp->portid = BITS2WORD(pdb.pdb_portid_bits); + lp->loopid = pdb.pdb_loopid; + } + + /* + * Mark all of the permanent local loop database entries as invalid + * (except our own entry). + */ + for (loopid = 0; loopid < hival; loopid++) { + if (loopid == fcp->isp_iid) { + fcp->portdb[loopid].valid = 1; + fcp->portdb[loopid].loopid = fcp->isp_loopid; + continue; + } + fcp->portdb[loopid].valid = 0; + } + + /* + * Now merge our local copy of the port database into our saved copy. + * Notify the outer layers of new devices arriving. + */ + for (loopid = 0; loopid < hival; loopid++) { + int i; + + /* + * If we don't have a non-zero Port WWN, we're not here. + */ + if (fcp->tport[loopid].port_wwn == 0) { + continue; + } + + /* + * Skip ourselves. + */ + if (loopid == fcp->isp_iid) { + continue; + } + + /* + * For the purposes of deciding whether this is the + * 'same' device or not, we only search for an identical + * Port WWN. Node WWNs may or may not be the same as + * the Port WWN, and there may be multiple different + * Port WWNs with the same Node WWN. It would be chaos + * to have multiple identical Port WWNs, so we don't + * allow that. + */ + + for (i = 0; i < hival; i++) { + int j; + if (fcp->portdb[i].port_wwn == 0) + continue; + if (fcp->portdb[i].port_wwn != + fcp->tport[loopid].port_wwn) + continue; + /* + * We found this WWN elsewhere- it's changed + * loopids then. We don't change it's actual + * position in our cached port database- we + * just change the actual loop ID we'd use. + */ + if (fcp->portdb[i].loopid != loopid) { + isp_prt(isp, ISP_LOGINFO, portshift, i, + fcp->portdb[i].loopid, + fcp->portdb[i].portid, loopid, + fcp->tport[loopid].portid); + } + fcp->portdb[i].portid = fcp->tport[loopid].portid; + fcp->portdb[i].loopid = loopid; + fcp->portdb[i].valid = 1; + fcp->portdb[i].roles = fcp->tport[loopid].roles; + + /* + * Now make sure this Port WWN doesn't exist elsewhere + * in the port database. + */ + for (j = i+1; j < hival; j++) { + if (fcp->portdb[i].port_wwn != + fcp->portdb[j].port_wwn) { + continue; + } + isp_prt(isp, ISP_LOGWARN, portdup, j, i); + /* + * Invalidate the 'old' *and* 'new' ones. + * This is really harsh and not quite right, + * but if this happens, we really don't know + * who is what at this point. + */ + fcp->portdb[i].valid = 0; + fcp->portdb[j].valid = 0; + } + break; + } + + /* + * If we didn't traverse the entire port database, + * then we found (and remapped) an existing entry. + * 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; + } + + /* + * We've not found this Port WWN anywhere. It's a new entry. + * See if we can leave it where it is (with target == loopid). + */ + if (fcp->portdb[loopid].port_wwn != 0) { + for (lim = 0; lim < hival; lim++) { + if (fcp->portdb[lim].port_wwn == 0) + break; + } + /* "Cannot Happen" */ + if (lim == hival) { + isp_prt(isp, ISP_LOGWARN, "Remap Overflow"); + continue; + } + i = lim; + } else { + i = loopid; + } + + /* + * NB: The actual loopid we use here is loopid- we may + * in fact be at a completely different index (target). + */ + fcp->portdb[i].loopid = loopid; + fcp->portdb[i].port_wwn = fcp->tport[loopid].port_wwn; + fcp->portdb[i].node_wwn = fcp->tport[loopid].node_wwn; + fcp->portdb[i].roles = fcp->tport[loopid].roles; + fcp->portdb[i].portid = fcp->tport[loopid].portid; + fcp->portdb[i].valid = 1; + + /* + * Tell the outside world we've arrived. + */ + (void) isp_async(isp, ISPASYNC_PROMENADE, &i); + } + + /* + * Now find all previously used targets that are now invalid and + * notify the outer layers that they're gone. + */ + for (lp = &fcp->portdb[0]; lp < &fcp->portdb[hival]; lp++) { + if (lp->valid || lp->port_wwn == 0) { + continue; + } + + /* + * Tell the outside world we've gone + * away and erase our pdb entry. + * + */ + loopid = lp - fcp->portdb; + (void) isp_async(isp, ISPASYNC_PROMENADE, &loopid); + MEMZERO((void *) lp, sizeof (*lp)); + } + fcp->isp_loopstate = LOOP_LSCAN_DONE; + return (0); +} + + +static int +isp_fabric_mbox_cmd(struct ispsoftc *isp, mbreg_t *mbp) +{ + isp_mboxcmd(isp, mbp, MBLOGNONE); + if (mbp->param[0] != MBOX_COMMAND_COMPLETE) { + if (FCPARAM(isp)->isp_loopstate == LOOP_SCANNING_FABRIC) { + FCPARAM(isp)->isp_loopstate = LOOP_PDB_RCVD; + } + if (mbp->param[0] == MBOX_COMMAND_ERROR) { + char tbuf[16]; + char *m; + switch (mbp->param[1]) { + case 1: + m = "No Loop"; + break; + case 2: + m = "Failed to allocate IOCB buffer"; + break; + case 3: + m = "Failed to allocate XCB buffer"; + break; + case 4: + m = "timeout or transmit failed"; + break; + case 5: + m = "no fabric loop"; + break; + case 6: + m = "remote device not a target"; + break; + default: + SNPRINTF(tbuf, sizeof tbuf, "%x", + mbp->param[1]); + m = tbuf; + break; + } + isp_prt(isp, ISP_LOGERR, "SNS Failed- %s", m); + } + return (-1); + } + + if (FCPARAM(isp)->isp_fwstate != FW_READY || + FCPARAM(isp)->isp_loopstate < LOOP_SCANNING_FABRIC) { + return (-1); + } + return(0); +} + +#ifdef ISP_USE_GA_NXT +static int +isp_scan_fabric(struct ispsoftc *isp, int ftype) +{ + fcparam *fcp = isp->isp_param; + u_int32_t portid, first_portid, last_portid; + int hicap, last_port_same; + + if (fcp->isp_onfabric == 0) { + fcp->isp_loopstate = LOOP_FSCAN_DONE; + return (0); + } + + FC_SCRATCH_ACQUIRE(isp); + + /* + * Since Port IDs are 24 bits, we can check against having seen + * anything yet with this value. + */ + last_port_same = 0; + last_portid = 0xffffffff; /* not a port */ + first_portid = portid = fcp->isp_portid; + fcp->isp_loopstate = LOOP_SCANNING_FABRIC; + + for (hicap = 0; hicap < GA_NXT_MAX; hicap++) { + mbreg_t mbs; + sns_screq_t *rq; + sns_ga_nxt_rsp_t *rs0, *rs1; + struct lportdb lcl; + u_int8_t sc[SNS_GA_NXT_RESP_SIZE]; + + rq = (sns_screq_t *)sc; + MEMZERO((void *) rq, SNS_GA_NXT_REQ_SIZE); + rq->snscb_rblen = SNS_GA_NXT_RESP_SIZE >> 1; + rq->snscb_addr[RQRSP_ADDR0015] = DMA_WD0(fcp->isp_scdma+0x100); + rq->snscb_addr[RQRSP_ADDR1631] = DMA_WD1(fcp->isp_scdma+0x100); + rq->snscb_addr[RQRSP_ADDR3247] = DMA_WD2(fcp->isp_scdma+0x100); + rq->snscb_addr[RQRSP_ADDR4863] = DMA_WD3(fcp->isp_scdma+0x100); + rq->snscb_sblen = 6; + rq->snscb_data[0] = SNS_GA_NXT; + rq->snscb_data[4] = portid & 0xffff; + rq->snscb_data[5] = (portid >> 16) & 0xff; + isp_put_sns_request(isp, rq, (sns_screq_t *) fcp->isp_scratch); + MEMORYBARRIER(isp, SYNC_SFORDEV, 0, SNS_GA_NXT_REQ_SIZE); + mbs.param[0] = MBOX_SEND_SNS; + mbs.param[1] = SNS_GA_NXT_REQ_SIZE >> 1; + mbs.param[2] = DMA_WD1(fcp->isp_scdma); + mbs.param[3] = DMA_WD0(fcp->isp_scdma); + /* + * Leave 4 and 5 alone + */ + mbs.param[6] = DMA_WD3(fcp->isp_scdma); + mbs.param[7] = DMA_WD2(fcp->isp_scdma); + if (isp_fabric_mbox_cmd(isp, &mbs)) { + if (fcp->isp_loopstate >= LOOP_SCANNING_FABRIC) { + fcp->isp_loopstate = LOOP_PDB_RCVD; + } + FC_SCRATCH_RELEASE(isp); + return (-1); + } + MEMORYBARRIER(isp, SYNC_SFORCPU, 0x100, SNS_GA_NXT_RESP_SIZE); + rs1 = (sns_ga_nxt_rsp_t *) sc; + rs0 = (sns_ga_nxt_rsp_t *) ((u_int8_t *)fcp->isp_scratch+0x100); + isp_get_ga_nxt_response(isp, rs0, rs1); + if (rs1->snscb_cthdr.ct_response != FS_ACC) { + int level; + if (rs1->snscb_cthdr.ct_reason == 9 && + rs1->snscb_cthdr.ct_explanation == 7) + level = ISP_LOGDEBUG0; + else + level = ISP_LOGWARN; + isp_prt(isp, level, swrej, "GA_NXT", + rs1->snscb_cthdr.ct_reason, + rs1->snscb_cthdr.ct_explanation, portid); + FC_SCRATCH_RELEASE(isp); + fcp->isp_loopstate = LOOP_FSCAN_DONE; + return (0); + } + portid = + (((u_int32_t) rs1->snscb_port_id[0]) << 16) | + (((u_int32_t) rs1->snscb_port_id[1]) << 8) | + (((u_int32_t) rs1->snscb_port_id[2])); + + /* + * XXX: We should check to make sure that this entry + * XXX: supports the type(s) we are interested in. + */ + /* + * Okay, we now have information about a fabric object. + * If it is the type we're interested in, tell the outer layers + * about it. The outer layer needs to know: Port ID, WWNN, + * WWPN, FC4 type, and port type. + * + * The lportdb structure is adequate for this. + */ + MEMZERO(&lcl, sizeof (lcl)); + lcl.port_type = rs1->snscb_port_type; + lcl.fc4_type = ftype; + lcl.portid = portid; + lcl.node_wwn = + (((u_int64_t)rs1->snscb_nodename[0]) << 56) | + (((u_int64_t)rs1->snscb_nodename[1]) << 48) | + (((u_int64_t)rs1->snscb_nodename[2]) << 40) | + (((u_int64_t)rs1->snscb_nodename[3]) << 32) | + (((u_int64_t)rs1->snscb_nodename[4]) << 24) | + (((u_int64_t)rs1->snscb_nodename[5]) << 16) | + (((u_int64_t)rs1->snscb_nodename[6]) << 8) | + (((u_int64_t)rs1->snscb_nodename[7])); + lcl.port_wwn = + (((u_int64_t)rs1->snscb_portname[0]) << 56) | + (((u_int64_t)rs1->snscb_portname[1]) << 48) | + (((u_int64_t)rs1->snscb_portname[2]) << 40) | + (((u_int64_t)rs1->snscb_portname[3]) << 32) | + (((u_int64_t)rs1->snscb_portname[4]) << 24) | + (((u_int64_t)rs1->snscb_portname[5]) << 16) | + (((u_int64_t)rs1->snscb_portname[6]) << 8) | + (((u_int64_t)rs1->snscb_portname[7])); + + /* + * Does this fabric object support the type we want? + * If not, skip it. + */ + if (rs1->snscb_fc4_types[ftype >> 5] & (1 << (ftype & 0x1f))) { + if (first_portid == portid) { + lcl.last_fabric_dev = 1; + } else { + lcl.last_fabric_dev = 0; + } + (void) isp_async(isp, ISPASYNC_FABRIC_DEV, &lcl); + } else { + isp_prt(isp, ISP_LOGDEBUG0, + "PortID 0x%x doesn't support FC4 type 0x%x", + portid, ftype); + } + if (first_portid == portid) { + fcp->isp_loopstate = LOOP_FSCAN_DONE; + FC_SCRATCH_RELEASE(isp); + return (0); + } + if (portid == last_portid) { + if (last_port_same++ > 20) { + isp_prt(isp, ISP_LOGWARN, + "tangled fabric database detected"); + break; + } + } else { + last_port_same = 0 ; + last_portid = portid; + } + } + FC_SCRATCH_RELEASE(isp); + if (hicap >= GA_NXT_MAX) { + isp_prt(isp, ISP_LOGWARN, "fabric too big (> %d)", GA_NXT_MAX); + } + fcp->isp_loopstate = LOOP_FSCAN_DONE; + return (0); +} +#else +#define GIDLEN ((ISP2100_SCRLEN >> 1) + 16) +#define NGENT ((GIDLEN - 16) >> 2) + +#define IGPOFF (ISP2100_SCRLEN - GIDLEN) +#define GXOFF (256) + +static int +isp_scan_fabric(struct ispsoftc *isp, int ftype) +{ + fcparam *fcp = FCPARAM(isp); + mbreg_t mbs; + int i; + sns_gid_ft_req_t *rq; + sns_gid_ft_rsp_t *rs0, *rs1; + + if (fcp->isp_onfabric == 0) { + fcp->isp_loopstate = LOOP_FSCAN_DONE; + return (0); + } + + FC_SCRATCH_ACQUIRE(isp); + fcp->isp_loopstate = LOOP_SCANNING_FABRIC; + + rq = (sns_gid_ft_req_t *)fcp->tport; + MEMZERO((void *) rq, SNS_GID_FT_REQ_SIZE); + rq->snscb_rblen = GIDLEN >> 1; + rq->snscb_addr[RQRSP_ADDR0015] = DMA_WD0(fcp->isp_scdma+IGPOFF); + rq->snscb_addr[RQRSP_ADDR1631] = DMA_WD1(fcp->isp_scdma+IGPOFF); + rq->snscb_addr[RQRSP_ADDR3247] = DMA_WD2(fcp->isp_scdma+IGPOFF); + rq->snscb_addr[RQRSP_ADDR4863] = DMA_WD3(fcp->isp_scdma+IGPOFF); + rq->snscb_sblen = 6; + rq->snscb_cmd = SNS_GID_FT; + rq->snscb_mword_div_2 = NGENT; + rq->snscb_fc4_type = ftype; + isp_put_gid_ft_request(isp, rq, (sns_gid_ft_req_t *) fcp->isp_scratch); + MEMORYBARRIER(isp, SYNC_SFORDEV, 0, SNS_GID_FT_REQ_SIZE); + mbs.param[0] = MBOX_SEND_SNS; + mbs.param[1] = SNS_GID_FT_REQ_SIZE >> 1; + mbs.param[2] = DMA_WD1(fcp->isp_scdma); + mbs.param[3] = DMA_WD0(fcp->isp_scdma); + + /* + * Leave 4 and 5 alone + */ + mbs.param[6] = DMA_WD3(fcp->isp_scdma); + mbs.param[7] = DMA_WD2(fcp->isp_scdma); + if (isp_fabric_mbox_cmd(isp, &mbs)) { + if (fcp->isp_loopstate >= LOOP_SCANNING_FABRIC) { + fcp->isp_loopstate = LOOP_PDB_RCVD; + } + FC_SCRATCH_RELEASE(isp); + return (-1); + } + if (fcp->isp_loopstate != LOOP_SCANNING_FABRIC) { + FC_SCRATCH_RELEASE(isp); + return (-1); + } + MEMORYBARRIER(isp, SYNC_SFORCPU, IGPOFF, GIDLEN); + rs1 = (sns_gid_ft_rsp_t *) fcp->tport; + rs0 = (sns_gid_ft_rsp_t *) ((u_int8_t *)fcp->isp_scratch+IGPOFF); + isp_get_gid_ft_response(isp, rs0, rs1, NGENT); + if (rs1->snscb_cthdr.ct_response != FS_ACC) { + int level; + if (rs1->snscb_cthdr.ct_reason == 9 && + rs1->snscb_cthdr.ct_explanation == 7) + level = ISP_LOGDEBUG0; + else + level = ISP_LOGWARN; + isp_prt(isp, level, swrej, "GID_FT", + rs1->snscb_cthdr.ct_reason, + rs1->snscb_cthdr.ct_explanation, 0); + FC_SCRATCH_RELEASE(isp); + fcp->isp_loopstate = LOOP_FSCAN_DONE; + return (0); + } + + /* + * Okay, we now have a list of Port IDs for this class of device. + * Go through the list and for each one get the WWPN/WWNN for it + * and tell the outer layers about it. The outer layer needs to + * know: Port ID, WWNN, WWPN, FC4 type, and (possibly) port type. + * + * The lportdb structure is adequate for this. + */ + i = -1; + do { + sns_gxn_id_req_t grqbuf, *gq = &grqbuf; + sns_gxn_id_rsp_t *gs0, grsbuf, *gs1 = &grsbuf; + struct lportdb lcl; +#if 0 + sns_gff_id_rsp_t *fs0, ffsbuf, *fs1 = &ffsbuf; +#endif + + i++; + MEMZERO(&lcl, sizeof (lcl)); + lcl.fc4_type = ftype; + lcl.portid = + (((u_int32_t) rs1->snscb_ports[i].portid[0]) << 16) | + (((u_int32_t) rs1->snscb_ports[i].portid[1]) << 8) | + (((u_int32_t) rs1->snscb_ports[i].portid[2])); + + MEMZERO((void *) gq, sizeof (sns_gxn_id_req_t)); + gq->snscb_rblen = SNS_GXN_ID_RESP_SIZE >> 1; + gq->snscb_addr[RQRSP_ADDR0015] = DMA_WD0(fcp->isp_scdma+GXOFF); + gq->snscb_addr[RQRSP_ADDR1631] = DMA_WD1(fcp->isp_scdma+GXOFF); + gq->snscb_addr[RQRSP_ADDR3247] = DMA_WD2(fcp->isp_scdma+GXOFF); + gq->snscb_addr[RQRSP_ADDR4863] = DMA_WD3(fcp->isp_scdma+GXOFF); + gq->snscb_sblen = 6; + gq->snscb_cmd = SNS_GPN_ID; + gq->snscb_portid = lcl.portid; + isp_put_gxn_id_request(isp, gq, + (sns_gxn_id_req_t *) fcp->isp_scratch); + MEMORYBARRIER(isp, SYNC_SFORDEV, 0, SNS_GXN_ID_REQ_SIZE); + mbs.param[0] = MBOX_SEND_SNS; + mbs.param[1] = SNS_GXN_ID_REQ_SIZE >> 1; + mbs.param[2] = DMA_WD1(fcp->isp_scdma); + mbs.param[3] = DMA_WD0(fcp->isp_scdma); + /* + * Leave 4 and 5 alone + */ + mbs.param[6] = DMA_WD3(fcp->isp_scdma); + mbs.param[7] = DMA_WD2(fcp->isp_scdma); + if (isp_fabric_mbox_cmd(isp, &mbs)) { + if (fcp->isp_loopstate >= LOOP_SCANNING_FABRIC) { + fcp->isp_loopstate = LOOP_PDB_RCVD; + } + FC_SCRATCH_RELEASE(isp); + return (-1); + } + if (fcp->isp_loopstate != LOOP_SCANNING_FABRIC) { + FC_SCRATCH_RELEASE(isp); + return (-1); + } + MEMORYBARRIER(isp, SYNC_SFORCPU, GXOFF, SNS_GXN_ID_RESP_SIZE); + gs0 = (sns_gxn_id_rsp_t *) ((u_int8_t *)fcp->isp_scratch+GXOFF); + isp_get_gxn_id_response(isp, gs0, gs1); + if (gs1->snscb_cthdr.ct_response != FS_ACC) { + isp_prt(isp, ISP_LOGWARN, swrej, "GPN_ID", + gs1->snscb_cthdr.ct_reason, + gs1->snscb_cthdr.ct_explanation, lcl.portid); + if (fcp->isp_loopstate != LOOP_SCANNING_FABRIC) { + FC_SCRATCH_RELEASE(isp); + return (-1); + } + continue; + } + lcl.port_wwn = + (((u_int64_t)gs1->snscb_wwn[0]) << 56) | + (((u_int64_t)gs1->snscb_wwn[1]) << 48) | + (((u_int64_t)gs1->snscb_wwn[2]) << 40) | + (((u_int64_t)gs1->snscb_wwn[3]) << 32) | + (((u_int64_t)gs1->snscb_wwn[4]) << 24) | + (((u_int64_t)gs1->snscb_wwn[5]) << 16) | + (((u_int64_t)gs1->snscb_wwn[6]) << 8) | + (((u_int64_t)gs1->snscb_wwn[7])); + + MEMZERO((void *) gq, sizeof (sns_gxn_id_req_t)); + gq->snscb_rblen = SNS_GXN_ID_RESP_SIZE >> 1; + gq->snscb_addr[RQRSP_ADDR0015] = DMA_WD0(fcp->isp_scdma+GXOFF); + gq->snscb_addr[RQRSP_ADDR1631] = DMA_WD1(fcp->isp_scdma+GXOFF); + gq->snscb_addr[RQRSP_ADDR3247] = DMA_WD2(fcp->isp_scdma+GXOFF); + gq->snscb_addr[RQRSP_ADDR4863] = DMA_WD3(fcp->isp_scdma+GXOFF); + gq->snscb_sblen = 6; + gq->snscb_cmd = SNS_GNN_ID; + gq->snscb_portid = lcl.portid; + isp_put_gxn_id_request(isp, gq, + (sns_gxn_id_req_t *) fcp->isp_scratch); + MEMORYBARRIER(isp, SYNC_SFORDEV, 0, SNS_GXN_ID_REQ_SIZE); + mbs.param[0] = MBOX_SEND_SNS; + mbs.param[1] = SNS_GXN_ID_REQ_SIZE >> 1; + mbs.param[2] = DMA_WD1(fcp->isp_scdma); + mbs.param[3] = DMA_WD0(fcp->isp_scdma); + /* + * Leave 4 and 5 alone + */ + mbs.param[6] = DMA_WD3(fcp->isp_scdma); + mbs.param[7] = DMA_WD2(fcp->isp_scdma); + if (isp_fabric_mbox_cmd(isp, &mbs)) { + if (fcp->isp_loopstate >= LOOP_SCANNING_FABRIC) { + fcp->isp_loopstate = LOOP_PDB_RCVD; + } + FC_SCRATCH_RELEASE(isp); + return (-1); + } + if (fcp->isp_loopstate != LOOP_SCANNING_FABRIC) { + FC_SCRATCH_RELEASE(isp); + return (-1); + } + MEMORYBARRIER(isp, SYNC_SFORCPU, GXOFF, SNS_GXN_ID_RESP_SIZE); + gs0 = (sns_gxn_id_rsp_t *) ((u_int8_t *)fcp->isp_scratch+GXOFF); + isp_get_gxn_id_response(isp, gs0, gs1); + if (gs1->snscb_cthdr.ct_response != FS_ACC) { + isp_prt(isp, ISP_LOGWARN, swrej, "GNN_ID", + gs1->snscb_cthdr.ct_reason, + gs1->snscb_cthdr.ct_explanation, lcl.portid); + if (fcp->isp_loopstate != LOOP_SCANNING_FABRIC) { + FC_SCRATCH_RELEASE(isp); + return (-1); + } + continue; + } + lcl.node_wwn = + (((u_int64_t)gs1->snscb_wwn[0]) << 56) | + (((u_int64_t)gs1->snscb_wwn[1]) << 48) | + (((u_int64_t)gs1->snscb_wwn[2]) << 40) | + (((u_int64_t)gs1->snscb_wwn[3]) << 32) | + (((u_int64_t)gs1->snscb_wwn[4]) << 24) | + (((u_int64_t)gs1->snscb_wwn[5]) << 16) | + (((u_int64_t)gs1->snscb_wwn[6]) << 8) | + (((u_int64_t)gs1->snscb_wwn[7])); + + /* + * The QLogic f/w is bouncing this with a parameter error. + */ +#if 0 + /* + * Try and get FC4 Features (FC-GS-3 only). + * We can use the sns_gxn_id_req_t for this request. + */ + MEMZERO((void *) gq, sizeof (sns_gxn_id_req_t)); + gq->snscb_rblen = SNS_GFF_ID_RESP_SIZE >> 1; + gq->snscb_addr[RQRSP_ADDR0015] = DMA_WD0(fcp->isp_scdma+GXOFF); + gq->snscb_addr[RQRSP_ADDR1631] = DMA_WD1(fcp->isp_scdma+GXOFF); + gq->snscb_addr[RQRSP_ADDR3247] = DMA_WD2(fcp->isp_scdma+GXOFF); + gq->snscb_addr[RQRSP_ADDR4863] = DMA_WD3(fcp->isp_scdma+GXOFF); + gq->snscb_sblen = 6; + gq->snscb_cmd = SNS_GFF_ID; + gq->snscb_portid = lcl.portid; + isp_put_gxn_id_request(isp, gq, + (sns_gxn_id_req_t *) fcp->isp_scratch); + MEMORYBARRIER(isp, SYNC_SFORDEV, 0, SNS_GXN_ID_REQ_SIZE); + mbs.param[0] = MBOX_SEND_SNS; + mbs.param[1] = SNS_GXN_ID_REQ_SIZE >> 1; + mbs.param[2] = DMA_WD1(fcp->isp_scdma); + mbs.param[3] = DMA_WD0(fcp->isp_scdma); + /* + * Leave 4 and 5 alone + */ + mbs.param[6] = DMA_WD3(fcp->isp_scdma); + mbs.param[7] = DMA_WD2(fcp->isp_scdma); + if (isp_fabric_mbox_cmd(isp, &mbs)) { + if (fcp->isp_loopstate >= LOOP_SCANNING_FABRIC) { + fcp->isp_loopstate = LOOP_PDB_RCVD; + } + FC_SCRATCH_RELEASE(isp); + return (-1); + } + if (fcp->isp_loopstate != LOOP_SCANNING_FABRIC) { + FC_SCRATCH_RELEASE(isp); + return (-1); + } + MEMORYBARRIER(isp, SYNC_SFORCPU, GXOFF, SNS_GFF_ID_RESP_SIZE); + fs0 = (sns_gff_id_rsp_t *) ((u_int8_t *)fcp->isp_scratch+GXOFF); + isp_get_gff_id_response(isp, fs0, fs1); + if (fs1->snscb_cthdr.ct_response != FS_ACC) { + isp_prt(isp, /* ISP_LOGDEBUG0 */ ISP_LOGWARN, + swrej, "GFF_ID", + fs1->snscb_cthdr.ct_reason, + fs1->snscb_cthdr.ct_explanation, lcl.portid); + if (fcp->isp_loopstate != LOOP_SCANNING_FABRIC) { + FC_SCRATCH_RELEASE(isp); + return (-1); + } + } else { + int index = (ftype >> 3); + int bshft = (ftype & 0x7) * 4; + int fc4_fval = + (fs1->snscb_fc4_features[index] >> bshft) & 0xf; + if (fc4_fval & 0x1) { + lcl.roles |= + (SVC3_INI_ROLE >> SVC3_ROLE_SHIFT); + } + if (fc4_fval & 0x2) { + lcl.roles |= + (SVC3_TGT_ROLE >> SVC3_ROLE_SHIFT); + } + } +#endif + + /* + * If we really want to know what kind of port type this is, + * we have to run another CT command. Otherwise, we'll leave + * it as undefined. + * + lcl.port_type = 0; + */ + if (rs1->snscb_ports[i].control & 0x80) { + lcl.last_fabric_dev = 1; + } else { + lcl.last_fabric_dev = 0; + } + (void) isp_async(isp, ISPASYNC_FABRIC_DEV, &lcl); + + } while ((rs1->snscb_ports[i].control & 0x80) == 0 && i < NGENT-1); + + /* + * If we're not at the last entry, our list isn't big enough. + */ + if ((rs1->snscb_ports[i].control & 0x80) == 0) { + isp_prt(isp, ISP_LOGWARN, "fabric too big for scratch area"); + } + + FC_SCRATCH_RELEASE(isp); + fcp->isp_loopstate = LOOP_FSCAN_DONE; + return (0); +} +#endif + +static void +isp_register_fc4_type(struct ispsoftc *isp) +{ + fcparam *fcp = isp->isp_param; + u_int8_t local[SNS_RFT_ID_REQ_SIZE]; + sns_screq_t *reqp = (sns_screq_t *) local; + mbreg_t mbs; + + MEMZERO((void *) reqp, SNS_RFT_ID_REQ_SIZE); + reqp->snscb_rblen = SNS_RFT_ID_RESP_SIZE >> 1; + reqp->snscb_addr[RQRSP_ADDR0015] = DMA_WD0(fcp->isp_scdma + 0x100); + reqp->snscb_addr[RQRSP_ADDR1631] = DMA_WD1(fcp->isp_scdma + 0x100); + reqp->snscb_addr[RQRSP_ADDR3247] = DMA_WD2(fcp->isp_scdma + 0x100); + reqp->snscb_addr[RQRSP_ADDR4863] = DMA_WD3(fcp->isp_scdma + 0x100); + reqp->snscb_sblen = 22; + reqp->snscb_data[0] = SNS_RFT_ID; + reqp->snscb_data[4] = fcp->isp_portid & 0xffff; + reqp->snscb_data[5] = (fcp->isp_portid >> 16) & 0xff; + reqp->snscb_data[6] = (1 << FC4_SCSI); +#if 0 + reqp->snscb_data[6] |= (1 << FC4_IP); /* ISO/IEC 8802-2 LLC/SNAP */ +#endif + FC_SCRATCH_ACQUIRE(isp); + isp_put_sns_request(isp, reqp, (sns_screq_t *) fcp->isp_scratch); + mbs.param[0] = MBOX_SEND_SNS; + mbs.param[1] = SNS_RFT_ID_REQ_SIZE >> 1; + mbs.param[2] = DMA_WD1(fcp->isp_scdma); + mbs.param[3] = DMA_WD0(fcp->isp_scdma); + /* + * Leave 4 and 5 alone + */ + mbs.param[6] = DMA_WD3(fcp->isp_scdma); + mbs.param[7] = DMA_WD2(fcp->isp_scdma); + isp_mboxcmd(isp, &mbs, MBLOGALL); + FC_SCRATCH_RELEASE(isp); + if (mbs.param[0] == MBOX_COMMAND_COMPLETE) { + isp_prt(isp, ISP_LOGDEBUG0, "Register FC4 types succeeded"); + } +} + +/* + * Start a command. Locking is assumed done in the caller. + */ + +int +isp_start(XS_T *xs) +{ + struct ispsoftc *isp; + u_int16_t nxti, optr, handle; + u_int8_t local[QENTRY_LEN]; + ispreq_t *reqp, *qep; + int target, i; + + XS_INITERR(xs); + isp = XS_ISP(xs); + + /* + * Check to make sure we're supporting initiator role. + */ + if ((isp->isp_role & ISP_ROLE_INITIATOR) == 0) { + XS_SETERR(xs, HBA_SELTIMEOUT); + return (CMD_COMPLETE); + } + + /* + * Now make sure we're running. + */ + + if (isp->isp_state != ISP_RUNSTATE) { + isp_prt(isp, ISP_LOGERR, "Adapter not at RUNSTATE"); + XS_SETERR(xs, HBA_BOTCH); + return (CMD_COMPLETE); + } + + /* + * Check command CDB length, etc.. We really are limited to 16 bytes + * for Fibre Channel, but can do up to 44 bytes in parallel SCSI, + * but probably only if we're running fairly new firmware (we'll + * let the old f/w choke on an extended command queue entry). + */ + + if (XS_CDBLEN(xs) > (IS_FC(isp)? 16 : 44) || XS_CDBLEN(xs) == 0) { + isp_prt(isp, ISP_LOGERR, + "unsupported cdb length (%d, CDB[0]=0x%x)", + XS_CDBLEN(xs), XS_CDBP(xs)[0] & 0xff); + XS_SETERR(xs, HBA_BOTCH); + return (CMD_COMPLETE); + } + + /* + * Check to see whether we have good firmware state still or + * need to refresh our port database for this target. + */ + target = XS_TGT(xs); + if (IS_FC(isp)) { + fcparam *fcp = isp->isp_param; + struct lportdb *lp; +#ifdef HANDLE_LOOPSTATE_IN_OUTER_LAYERS + if (fcp->isp_fwstate != FW_READY || + fcp->isp_loopstate != LOOP_READY) { + return (CMD_RQLATER); + } + + /* + * If we're not on a Fabric, we can't have a target + * above FL_PORT_ID-1. + * + * If we're on a fabric and *not* connected as an F-port, + * we can't have a target less than FC_SNS_ID+1. This + * keeps us from having to sort out the difference between + * local public loop devices and those which we might get + * from a switch's database. + */ + if (fcp->isp_onfabric == 0) { + if (target >= FL_PORT_ID) { + XS_SETERR(xs, HBA_SELTIMEOUT); + return (CMD_COMPLETE); + } + } else { + if (target >= FL_PORT_ID && target <= FC_SNS_ID) { + XS_SETERR(xs, HBA_SELTIMEOUT); + return (CMD_COMPLETE); + } + /* + * We used to exclude having local loop ports + * at the same time that we have fabric ports. + * That is, we used to exclude having ports + * at < FL_PORT_ID if we're FL-port. + * + * That's wrong. The only thing that could be + * dicey is if the switch you're connected to + * has these local loop ports appear on the + * fabric and we somehow attach them twice. + */ + } +#else + /* + * Check for f/w being in ready state. If the f/w + * isn't in ready state, then we don't know our + * loop ID and the f/w hasn't completed logging + * into all targets on the loop. If this is the + * case, then bounce the command. We pretend this is + * a SELECTION TIMEOUT error if we've never gone to + * FW_READY state at all- in this case we may not + * be hooked to a loop at all and we shouldn't hang + * the machine for this. Otherwise, defer this command + * until later. + */ + if (fcp->isp_fwstate != FW_READY) { + /* + * Give ourselves at most a 250ms delay. + */ + if (isp_fclink_test(isp, 250000)) { + XS_SETERR(xs, HBA_SELTIMEOUT); + if (fcp->loop_seen_once) { + return (CMD_RQLATER); + } else { + return (CMD_COMPLETE); + } + } + } + + /* + * If we're not on a Fabric, we can't have a target + * above FL_PORT_ID-1. + * + * If we're on a fabric and *not* connected as an F-port, + * we can't have a target less than FC_SNS_ID+1. This + * keeps us from having to sort out the difference between + * local public loop devices and those which we might get + * from a switch's database. + */ + if (fcp->isp_onfabric == 0) { + if (target >= FL_PORT_ID) { + XS_SETERR(xs, HBA_SELTIMEOUT); + return (CMD_COMPLETE); + } + } else { + if (target >= FL_PORT_ID && target <= FC_SNS_ID) { + XS_SETERR(xs, HBA_SELTIMEOUT); + return (CMD_COMPLETE); + } + if (fcp->isp_topo != TOPO_F_PORT && + target < FL_PORT_ID) { + XS_SETERR(xs, HBA_SELTIMEOUT); + return (CMD_COMPLETE); + } + } + + /* + * If our loop state is such that we haven't yet received + * a "Port Database Changed" notification (after a LIP or + * a Loop Reset or firmware initialization), then defer + * sending commands for a little while, but only if we've + * seen a valid loop at one point (otherwise we can get + * stuck at initialization time). + */ + if (fcp->isp_loopstate < LOOP_PDB_RCVD) { + XS_SETERR(xs, HBA_SELTIMEOUT); + if (fcp->loop_seen_once) { + return (CMD_RQLATER); + } else { + return (CMD_COMPLETE); + } + } + + /* + * If we're in the middle of loop or fabric scanning + * or merging the port databases, retry this command later. + */ + if (fcp->isp_loopstate == LOOP_SCANNING_FABRIC || + fcp->isp_loopstate == LOOP_SCANNING_LOOP || + fcp->isp_loopstate == LOOP_SYNCING_PDB) { + return (CMD_RQLATER); + } + + /* + * If our loop state is now such that we've just now + * received a Port Database Change notification, then + * we have to go off and (re)scan the fabric. We back + * out and try again later if this doesn't work. + */ + if (fcp->isp_loopstate == LOOP_PDB_RCVD && fcp->isp_onfabric) { + if (isp_scan_fabric(isp, FC4_SCSI)) { + return (CMD_RQLATER); + } + if (fcp->isp_fwstate != FW_READY || + fcp->isp_loopstate < LOOP_FSCAN_DONE) { + return (CMD_RQLATER); + } + } + + /* + * If our loop state is now such that we've just now + * received a Port Database Change notification, then + * we have to go off and (re)synchronize our port + * database. + */ + if (fcp->isp_loopstate < LOOP_READY) { + if (isp_pdb_sync(isp)) { + return (CMD_RQLATER); + } + if (fcp->isp_fwstate != FW_READY || + fcp->isp_loopstate != LOOP_READY) { + return (CMD_RQLATER); + } + } + + /* + * XXX: Here's were we would cancel any loop_dead flag + * XXX: also cancel in dead_loop timeout that's running + */ +#endif + + /* + * Now check whether we should even think about pursuing this. + */ + lp = &fcp->portdb[target]; + if (lp->valid == 0) { + XS_SETERR(xs, HBA_SELTIMEOUT); + return (CMD_COMPLETE); + } + if ((lp->roles & (SVC3_TGT_ROLE >> SVC3_ROLE_SHIFT)) == 0) { + isp_prt(isp, ISP_LOGDEBUG2, + "Target %d does not have target service", target); + XS_SETERR(xs, HBA_SELTIMEOUT); + return (CMD_COMPLETE); + } + /* + * Now turn target into what the actual Loop ID is. + */ + target = lp->loopid; + } + + /* + * Next check to see if any HBA or Device + * parameters need to be updated. + */ + if (isp->isp_update != 0) { + isp_update(isp); + } + + if (isp_getrqentry(isp, &nxti, &optr, (void **)&qep)) { + isp_prt(isp, ISP_LOGDEBUG0, "Request Queue Overflow"); + XS_SETERR(xs, HBA_BOTCH); + return (CMD_EAGAIN); + } + + /* + * Now see if we need to synchronize the ISP with respect to anything. + * We do dual duty here (cough) for synchronizing for busses other + * than which we got here to send a command to. + */ + reqp = (ispreq_t *) local; + if (isp->isp_sendmarker) { + u_int8_t n = (IS_DUALBUS(isp)? 2: 1); + /* + * Check ports to send markers for... + */ + for (i = 0; i < n; i++) { + if ((isp->isp_sendmarker & (1 << i)) == 0) { + continue; + } + MEMZERO((void *) reqp, QENTRY_LEN); + reqp->req_header.rqs_entry_count = 1; + reqp->req_header.rqs_entry_type = RQSTYPE_MARKER; + reqp->req_modifier = SYNC_ALL; + reqp->req_target = i << 7; /* insert bus number */ + isp_put_request(isp, reqp, qep); + ISP_ADD_REQUEST(isp, nxti); + isp->isp_sendmarker &= ~(1 << i); + if (isp_getrqentry(isp, &nxti, &optr, (void **) &qep)) { + isp_prt(isp, ISP_LOGDEBUG0, + "Request Queue Overflow+"); + XS_SETERR(xs, HBA_BOTCH); + return (CMD_EAGAIN); + } + } + } + + MEMZERO((void *)reqp, QENTRY_LEN); + reqp->req_header.rqs_entry_count = 1; + if (IS_FC(isp)) { + reqp->req_header.rqs_entry_type = RQSTYPE_T2RQS; + } else { + if (XS_CDBLEN(xs) > 12) + reqp->req_header.rqs_entry_type = RQSTYPE_CMDONLY; + else + reqp->req_header.rqs_entry_type = RQSTYPE_REQUEST; + } + /* reqp->req_header.rqs_flags = 0; */ + /* reqp->req_header.rqs_seqno = 0; */ + if (IS_FC(isp)) { + /* + * See comment in isp_intr + */ + /* XS_RESID(xs) = 0; */ + + /* + * Fibre Channel always requires some kind of tag. + * The Qlogic drivers seem be happy not to use a tag, + * but this breaks for some devices (IBM drives). + */ + if (XS_TAG_P(xs)) { + ((ispreqt2_t *)reqp)->req_flags = XS_TAG_TYPE(xs); + } else { + /* + * If we don't know what tag to use, use HEAD OF QUEUE + * for Request Sense or Simple. + */ + if (XS_CDBP(xs)[0] == 0x3) /* REQUEST SENSE */ + ((ispreqt2_t *)reqp)->req_flags = REQFLAG_HTAG; + else + ((ispreqt2_t *)reqp)->req_flags = REQFLAG_STAG; + } + } else { + sdparam *sdp = (sdparam *)isp->isp_param; + sdp += XS_CHANNEL(xs); + if ((sdp->isp_devparam[target].actv_flags & DPARM_TQING) && + XS_TAG_P(xs)) { + reqp->req_flags = XS_TAG_TYPE(xs); + } + } + reqp->req_target = target | (XS_CHANNEL(xs) << 7); + if (IS_SCSI(isp)) { + reqp->req_lun_trn = XS_LUN(xs); + reqp->req_cdblen = XS_CDBLEN(xs); + } else { + if (FCPARAM(isp)->isp_fwattr & ISP_FW_ATTR_SCCLUN) + ((ispreqt2_t *)reqp)->req_scclun = XS_LUN(xs); + else + ((ispreqt2_t *)reqp)->req_lun_trn = XS_LUN(xs); + } + MEMCPY(reqp->req_cdb, XS_CDBP(xs), XS_CDBLEN(xs)); + + reqp->req_time = XS_TIME(xs) / 1000; + if (reqp->req_time == 0 && XS_TIME(xs)) { + reqp->req_time = 1; + } + + if (isp_save_xs(isp, xs, &handle)) { + isp_prt(isp, ISP_LOGDEBUG0, "out of xflist pointers"); + XS_SETERR(xs, HBA_BOTCH); + return (CMD_EAGAIN); + } + reqp->req_handle = handle; + + /* + * Set up DMA and/or do any bus swizzling of the request entry + * so that the Qlogic F/W understands what is being asked of it. + */ + i = ISP_DMASETUP(isp, xs, reqp, &nxti, optr); + if (i != CMD_QUEUED) { + isp_destroy_handle(isp, handle); + /* + * dmasetup sets actual error in packet, and + * return what we were given to return. + */ + return (i); + } + XS_SETERR(xs, HBA_NOERROR); + isp_prt(isp, ISP_LOGDEBUG2, + "START cmd for %d.%d.%d cmd 0x%x datalen %ld", + XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs), XS_CDBP(xs)[0], + (long) XS_XFRLEN(xs)); + ISP_ADD_REQUEST(isp, nxti); + isp->isp_nactive++; + return (CMD_QUEUED); +} + +/* + * isp control + * Locks (ints blocked) assumed held. + */ + +int +isp_control(struct ispsoftc *isp, ispctl_t ctl, void *arg) +{ + XS_T *xs; + mbreg_t mbs; + int bus, tgt; + u_int16_t handle; + + switch (ctl) { + default: + isp_prt(isp, ISP_LOGERR, "Unknown Control Opcode 0x%x", ctl); + break; + + case ISPCTL_RESET_BUS: + /* + * 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; + if (mbs.param[1] < 2) + mbs.param[1] = 2; + bus = *((int *) arg); + if (IS_DUALBUS(isp)) + mbs.param[2] = bus; + } else { + mbs.param[1] = 10; + bus = 0; + } + isp->isp_sendmarker |= (1 << bus); + isp_mboxcmd(isp, &mbs, MBLOGALL); + if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { + break; + } + isp_prt(isp, ISP_LOGINFO, + "driver initiated bus reset of bus %d", bus); + return (0); + + case ISPCTL_RESET_DEV: + tgt = (*((int *) arg)) & 0xffff; + bus = (*((int *) arg)) >> 16; + mbs.param[0] = MBOX_ABORT_TARGET; + mbs.param[1] = (tgt << 8) | (bus << 15); + mbs.param[2] = 3; /* 'delay', in seconds */ + isp_mboxcmd(isp, &mbs, MBLOGALL); + if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { + break; + } + isp_prt(isp, ISP_LOGINFO, + "Target %d on Bus %d Reset Succeeded", tgt, bus); + isp->isp_sendmarker |= (1 << bus); + return (0); + + case ISPCTL_ABORT_CMD: + xs = (XS_T *) arg; + tgt = XS_TGT(xs); + handle = isp_find_handle(isp, xs); + if (handle == 0) { + isp_prt(isp, ISP_LOGWARN, + "cannot find handle for command to abort"); + break; + } + bus = XS_CHANNEL(xs); + mbs.param[0] = MBOX_ABORT; + if (IS_FC(isp)) { + if (FCPARAM(isp)->isp_fwattr & ISP_FW_ATTR_SCCLUN) { + 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); + } + mbs.param[3] = 0; + mbs.param[2] = handle; + isp_mboxcmd(isp, &mbs, MBLOGALL & ~MBOX_COMMAND_ERROR); + if (mbs.param[0] == MBOX_COMMAND_COMPLETE) { + return (0); + } + /* + * XXX: Look for command in the REQUEST QUEUE. That is, + * XXX: It hasen't been picked up by firmware yet. + */ + break; + + case ISPCTL_UPDATE_PARAMS: + + isp_update(isp); + return (0); + + case ISPCTL_FCLINK_TEST: + + if (IS_FC(isp)) { + int usdelay = (arg)? *((int *) arg) : 250000; + return (isp_fclink_test(isp, usdelay)); + } + break; + + case ISPCTL_SCAN_FABRIC: + + if (IS_FC(isp)) { + int ftype = (arg)? *((int *) arg) : FC4_SCSI; + return (isp_scan_fabric(isp, ftype)); + } + break; + + case ISPCTL_SCAN_LOOP: + + if (IS_FC(isp)) { + return (isp_scan_loop(isp)); + } + break; + + case ISPCTL_PDB_SYNC: + + if (IS_FC(isp)) { + return (isp_pdb_sync(isp)); + } + break; + + case ISPCTL_SEND_LIP: + + if (IS_FC(isp)) { + mbs.param[0] = MBOX_INIT_LIP; + isp_mboxcmd(isp, &mbs, MBLOGALL); + if (mbs.param[0] == MBOX_COMMAND_COMPLETE) { + return (0); + } + } + break; + + case ISPCTL_GET_POSMAP: + + if (IS_FC(isp) && arg) { + return (isp_getmap(isp, arg)); + } + break; + + case ISPCTL_RUN_MBOXCMD: + + isp_mboxcmd(isp, arg, MBLOGALL); + return(0); + +#ifdef ISP_TARGET_MODE + case ISPCTL_TOGGLE_TMODE: + { + + /* + * We don't check/set against role here- that's the + * responsibility for the outer layer to coordinate. + */ + if (IS_SCSI(isp)) { + int param = *(int *)arg; + mbs.param[0] = MBOX_ENABLE_TARGET_MODE; + mbs.param[1] = param & 0xffff; + mbs.param[2] = param >> 16; + isp_mboxcmd(isp, &mbs, MBLOGALL); + if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { + break; + } + } + return (0); + } +#endif + } + return (-1); +} + +/* + * Interrupt Service Routine(s). + * + * External (OS) framework has done the appropriate locking, + * and the locking will be held throughout this function. + */ + +/* + * Limit our stack depth by sticking with the max likely number + * of completions on a request queue at any one time. + */ +#ifndef MAX_REQUESTQ_COMPLETIONS +#define MAX_REQUESTQ_COMPLETIONS 64 +#endif + +void +isp_intr(struct ispsoftc *isp, u_int16_t isr, u_int16_t sema, u_int16_t mbox) +{ + XS_T *complist[MAX_REQUESTQ_COMPLETIONS], *xs; + u_int16_t iptr, optr, junk; + int i, nlooked = 0, ndone = 0; + +again: + /* + * Is this a mailbox related interrupt? + * The mailbox semaphore will be nonzero if so. + */ + if (sema) { + if (mbox & 0x4000) { + isp->isp_intmboxc++; + if (isp->isp_mboxbsy) { + int i = 0, obits = isp->isp_obits; + isp->isp_mboxtmp[i++] = mbox; + for (i = 1; i < MAX_MAILBOX; i++) { + if ((obits & (1 << i)) == 0) { + continue; + } + isp->isp_mboxtmp[i] = + ISP_READ(isp, MBOX_OFF(i)); + } + if (isp->isp_mbxwrk0) { + if (isp_mbox_continue(isp) == 0) { + return; + } + } + MBOX_NOTIFY_COMPLETE(isp); + } else { + isp_prt(isp, ISP_LOGWARN, + "Mbox Command Async (0x%x) with no waiters", + mbox); + } + } else if (isp_parse_async(isp, mbox) < 0) { + return; + } + if ((IS_FC(isp) && mbox != ASYNC_RIO_RESP) || + isp->isp_state != ISP_RUNSTATE) { + ISP_WRITE(isp, HCCR, HCCR_CMD_CLEAR_RISC_INT); + ISP_WRITE(isp, BIU_SEMA, 0); + return; + } + } + + /* + * We can't be getting this now. + */ + if (isp->isp_state != ISP_RUNSTATE) { + isp_prt(isp, ISP_LOGWARN, + "interrupt (ISR=%x SEMA=%x) when not ready", isr, sema); + /* + * Thank you very much! *Burrrp*! + */ + WRITE_RESPONSE_QUEUE_OUT_POINTER(isp, + READ_RESPONSE_QUEUE_IN_POINTER(isp)); + + ISP_WRITE(isp, HCCR, HCCR_CMD_CLEAR_RISC_INT); + ISP_WRITE(isp, BIU_SEMA, 0); + return; + } + + /* + * Get the current Response Queue Out Pointer. + * + * If we're a 2300, we can ask what hardware what it thinks. + */ + if (IS_23XX(isp)) { + optr = ISP_READ(isp, isp->isp_respoutrp); + /* + * Debug: to be taken out eventually + */ + if (isp->isp_residx != optr) { + isp_prt(isp, ISP_LOGWARN, "optr %x soft optr %x", + optr, isp->isp_residx); + } + } else { + optr = isp->isp_residx; + } + + /* + * You *must* read the Response Queue In Pointer + * prior to clearing the RISC interrupt. + * + * Debounce the 2300 if revision less than 2. + */ + if (IS_2100(isp) || (IS_2300(isp) && isp->isp_revision < 2)) { + i = 0; + do { + iptr = READ_RESPONSE_QUEUE_IN_POINTER(isp); + junk = READ_RESPONSE_QUEUE_IN_POINTER(isp); + } while (junk != iptr && ++i < 1000); + + if (iptr != junk) { + ISP_WRITE(isp, HCCR, HCCR_CMD_CLEAR_RISC_INT); + isp_prt(isp, ISP_LOGWARN, + "Response Queue Out Pointer Unstable (%x, %x)", + iptr, junk); + return; + } + } else { + iptr = READ_RESPONSE_QUEUE_IN_POINTER(isp); + } + isp->isp_resodx = iptr; + + + if (optr == iptr && sema == 0) { + /* + * There are a lot of these- reasons unknown- mostly on + * faster Alpha machines. + * + * I tried delaying after writing HCCR_CMD_CLEAR_RISC_INT to + * make sure the old interrupt went away (to avoid 'ringing' + * effects), but that didn't stop this from occurring. + */ + if (IS_23XX(isp)) { + USEC_DELAY(100); + iptr = READ_RESPONSE_QUEUE_IN_POINTER(isp); + junk = ISP_READ(isp, BIU_R2HSTSLO); + } else { + junk = ISP_READ(isp, BIU_ISR); + } + if (optr == iptr) { + if (IS_23XX(isp)) { + ; + } else { + sema = ISP_READ(isp, BIU_SEMA); + mbox = ISP_READ(isp, OUTMAILBOX0); + if ((sema & 0x3) && (mbox & 0x8000)) { + goto again; + } + } + isp->isp_intbogus++; + isp_prt(isp, ISP_LOGDEBUG1, + "bogus intr- isr %x (%x) iptr %x optr %x", + isr, junk, iptr, optr); + } + } + isp->isp_resodx = iptr; + ISP_WRITE(isp, HCCR, HCCR_CMD_CLEAR_RISC_INT); + ISP_WRITE(isp, BIU_SEMA, 0); + + if (isp->isp_rspbsy) { + return; + } + isp->isp_rspbsy = 1; + + while (optr != iptr) { + ispstatusreq_t local, *sp = &local; + isphdr_t *hp; + int type; + u_int16_t oop; + int buddaboom = 0; + + hp = (isphdr_t *) ISP_QUEUE_ENTRY(isp->isp_result, optr); + oop = optr; + optr = ISP_NXT_QENTRY(optr, RESULT_QUEUE_LEN(isp)); + nlooked++; + /* + * Synchronize our view of this response queue entry. + */ + MEMORYBARRIER(isp, SYNC_RESULT, oop, QENTRY_LEN); + + type = isp_get_response_type(isp, hp); + + if (type == RQSTYPE_RESPONSE) { + isp_get_response(isp, (ispstatusreq_t *) hp, sp); + } else if (type == RQSTYPE_RIO2) { + isp_rio2_t rio; + isp_get_rio2(isp, (isp_rio2_t *) hp, &rio); + for (i = 0; i < rio.req_header.rqs_seqno; i++) { + isp_fastpost_complete(isp, rio.req_handles[i]); + } + if (isp->isp_fpcchiwater < rio.req_header.rqs_seqno) + isp->isp_fpcchiwater = rio.req_header.rqs_seqno; + MEMZERO(hp, QENTRY_LEN); /* PERF */ + continue; + } else { + /* + * Somebody reachable via isp_handle_other_response + * may have updated the response queue pointers for + * us, so we reload our goal index. + */ + if (isp_handle_other_response(isp, type, hp, &optr)) { + iptr = isp->isp_resodx; + MEMZERO(hp, QENTRY_LEN); /* PERF */ + continue; + } + + /* + * After this point, we'll just look at the header as + * we don't know how to deal with the rest of the + * response. + */ + isp_get_response(isp, (ispstatusreq_t *) hp, sp); + + /* + * It really has to be a bounced request just copied + * from the request queue to the response queue. If + * not, something bad has happened. + */ + if (sp->req_header.rqs_entry_type != RQSTYPE_REQUEST) { + isp_prt(isp, ISP_LOGERR, notresp, + sp->req_header.rqs_entry_type, oop, optr, + nlooked); + if (isp->isp_dblev & ISP_LOGDEBUG0) { + isp_print_bytes(isp, "Queue Entry", + QENTRY_LEN, sp); + } + MEMZERO(hp, QENTRY_LEN); /* PERF */ + continue; + } + buddaboom = 1; + } + + if (sp->req_header.rqs_flags & 0xf) { +#define _RQS_OFLAGS \ + ~(RQSFLAG_CONTINUATION|RQSFLAG_FULL|RQSFLAG_BADHEADER|RQSFLAG_BADPACKET) + if (sp->req_header.rqs_flags & RQSFLAG_CONTINUATION) { + isp_prt(isp, ISP_LOGWARN, + "continuation segment"); + WRITE_RESPONSE_QUEUE_OUT_POINTER(isp, optr); + continue; + } + if (sp->req_header.rqs_flags & RQSFLAG_FULL) { + isp_prt(isp, ISP_LOGDEBUG1, + "internal queues full"); + /* + * We'll synthesize a QUEUE FULL message below. + */ + } + if (sp->req_header.rqs_flags & RQSFLAG_BADHEADER) { + isp_prt(isp, ISP_LOGERR, "bad header flag"); + buddaboom++; + } + if (sp->req_header.rqs_flags & RQSFLAG_BADPACKET) { + isp_prt(isp, ISP_LOGERR, "bad request packet"); + buddaboom++; + } + if (sp->req_header.rqs_flags & _RQS_OFLAGS) { + isp_prt(isp, ISP_LOGERR, + "unknown flags (0x%x) in response", + sp->req_header.rqs_flags); + buddaboom++; + } +#undef _RQS_OFLAGS + } + if (sp->req_handle > isp->isp_maxcmds || sp->req_handle < 1) { + MEMZERO(hp, QENTRY_LEN); /* PERF */ + isp_prt(isp, ISP_LOGERR, + "bad request handle %d (type 0x%x, flags 0x%x)", + sp->req_handle, sp->req_header.rqs_entry_type, + sp->req_header.rqs_flags); + WRITE_RESPONSE_QUEUE_OUT_POINTER(isp, optr); + continue; + } + xs = isp_find_xs(isp, sp->req_handle); + if (xs == NULL) { + u_int8_t ts = sp->req_completion_status & 0xff; + MEMZERO(hp, QENTRY_LEN); /* PERF */ + /* + * Only whine if this isn't the expected fallout of + * aborting the command. + */ + if (sp->req_header.rqs_entry_type != RQSTYPE_RESPONSE) { + isp_prt(isp, ISP_LOGERR, + "cannot find handle 0x%x (type 0x%x)", + sp->req_handle, + sp->req_header.rqs_entry_type); + } else if (ts != RQCS_ABORTED) { + isp_prt(isp, ISP_LOGERR, + "cannot find handle 0x%x (status 0x%x)", + sp->req_handle, ts); + } + WRITE_RESPONSE_QUEUE_OUT_POINTER(isp, optr); + continue; + } + isp_destroy_handle(isp, sp->req_handle); + if (sp->req_status_flags & RQSTF_BUS_RESET) { + XS_SETERR(xs, HBA_BUSRESET); + isp->isp_sendmarker |= (1 << XS_CHANNEL(xs)); + } + if (buddaboom) { + XS_SETERR(xs, HBA_BOTCH); + } + + if (IS_FC(isp) && (sp->req_scsi_status & RQCS_SV)) { + /* + * Fibre Channel F/W doesn't say we got status + * if there's Sense Data instead. I guess they + * think it goes w/o saying. + */ + sp->req_state_flags |= RQSF_GOT_STATUS; + } + if (sp->req_state_flags & RQSF_GOT_STATUS) { + *XS_STSP(xs) = sp->req_scsi_status & 0xff; + } + + switch (sp->req_header.rqs_entry_type) { + case RQSTYPE_RESPONSE: + XS_SET_STATE_STAT(isp, xs, sp); + isp_parse_status(isp, sp, xs); + if ((XS_NOERR(xs) || XS_ERR(xs) == HBA_NOERROR) && + (*XS_STSP(xs) == SCSI_BUSY)) { + XS_SETERR(xs, HBA_TGTBSY); + } + if (IS_SCSI(isp)) { + XS_RESID(xs) = sp->req_resid; + if ((sp->req_state_flags & RQSF_GOT_STATUS) && + (*XS_STSP(xs) == SCSI_CHECK) && + (sp->req_state_flags & RQSF_GOT_SENSE)) { + XS_SAVE_SENSE(xs, sp); + } + /* + * A new synchronous rate was negotiated for + * this target. Mark state such that we'll go + * look up that which has changed later. + */ + if (sp->req_status_flags & RQSTF_NEGOTIATION) { + int t = XS_TGT(xs); + sdparam *sdp = isp->isp_param; + sdp += XS_CHANNEL(xs); + sdp->isp_devparam[t].dev_refresh = 1; + isp->isp_update |= + (1 << XS_CHANNEL(xs)); + } + } else { + if (sp->req_status_flags & RQSF_XFER_COMPLETE) { + XS_RESID(xs) = 0; + } else if (sp->req_scsi_status & RQCS_RESID) { + XS_RESID(xs) = sp->req_resid; + } else { + XS_RESID(xs) = 0; + } + if ((sp->req_state_flags & RQSF_GOT_STATUS) && + (*XS_STSP(xs) == SCSI_CHECK) && + (sp->req_scsi_status & RQCS_SV)) { + XS_SAVE_SENSE(xs, sp); + /* solely for the benefit of debug */ + sp->req_state_flags |= RQSF_GOT_SENSE; + } + } + isp_prt(isp, ISP_LOGDEBUG2, + "asked for %ld got resid %ld", (long) XS_XFRLEN(xs), + (long) sp->req_resid); + break; + case RQSTYPE_REQUEST: + if (sp->req_header.rqs_flags & RQSFLAG_FULL) { + /* + * Force Queue Full status. + */ + *XS_STSP(xs) = SCSI_QFULL; + XS_SETERR(xs, HBA_NOERROR); + } else if (XS_NOERR(xs)) { + /* + * ???? + */ + isp_prt(isp, ISP_LOGDEBUG0, + "Request Queue Entry bounced back"); + XS_SETERR(xs, HBA_BOTCH); + } + XS_RESID(xs) = XS_XFRLEN(xs); + break; + default: + isp_prt(isp, ISP_LOGWARN, + "unhandled response queue type 0x%x", + sp->req_header.rqs_entry_type); + if (XS_NOERR(xs)) { + XS_SETERR(xs, HBA_BOTCH); + } + break; + } + + /* + * Free any dma resources. As a side effect, this may + * also do any cache flushing necessary for data coherence. */ + if (XS_XFRLEN(xs)) { + ISP_DMAFREE(isp, xs, sp->req_handle); + } + + if (((isp->isp_dblev & (ISP_LOGDEBUG2|ISP_LOGDEBUG3))) || + ((isp->isp_dblev & ISP_LOGDEBUG1) && ((!XS_NOERR(xs)) || + (*XS_STSP(xs) != SCSI_GOOD)))) { + char skey; + if (sp->req_state_flags & RQSF_GOT_SENSE) { + skey = XS_SNSKEY(xs) & 0xf; + if (skey < 10) + skey += '0'; + else + skey += 'a' - 10; + } else if (*XS_STSP(xs) == SCSI_CHECK) { + skey = '?'; + } else { + skey = '.'; + } + isp_prt(isp, ISP_LOGALL, finmsg, XS_CHANNEL(xs), + XS_TGT(xs), XS_LUN(xs), XS_XFRLEN(xs), XS_RESID(xs), + *XS_STSP(xs), skey, XS_ERR(xs)); + } + + if (isp->isp_nactive > 0) + isp->isp_nactive--; + complist[ndone++] = xs; /* defer completion call until later */ + MEMZERO(hp, QENTRY_LEN); /* PERF */ + if (ndone == MAX_REQUESTQ_COMPLETIONS) { + break; + } + } + + /* + * If we looked at any commands, then it's valid to find out + * what the outpointer is. It also is a trigger to update the + * ISP's notion of what we've seen so far. + */ + if (nlooked) { + WRITE_RESPONSE_QUEUE_OUT_POINTER(isp, optr); + /* + * While we're at it, read the requst queue out pointer. + */ + isp->isp_reqodx = READ_REQUEST_QUEUE_OUT_POINTER(isp); + if (isp->isp_rscchiwater < ndone) + isp->isp_rscchiwater = ndone; + } + + isp->isp_residx = optr; + isp->isp_rspbsy = 0; + for (i = 0; i < ndone; i++) { + xs = complist[i]; + if (xs) { + isp->isp_rsltccmplt++; + isp_done(xs); + } + } +} + +/* + * Support routines. + */ + +static int +isp_parse_async(struct ispsoftc *isp, u_int16_t mbox) +{ + int rval = 0; + int bus; + + if (IS_DUALBUS(isp)) { + bus = ISP_READ(isp, OUTMAILBOX6); + } else { + bus = 0; + } + isp_prt(isp, ISP_LOGDEBUG2, "Async Mbox 0x%x", mbox); + + switch (mbox) { + case ASYNC_BUS_RESET: + isp->isp_sendmarker |= (1 << bus); +#ifdef ISP_TARGET_MODE + if (isp_target_async(isp, bus, mbox)) + rval = -1; +#endif + isp_async(isp, ISPASYNC_BUS_RESET, &bus); + break; + case ASYNC_SYSTEM_ERROR: +#ifdef ISP_FW_CRASH_DUMP + /* + * If we have crash dumps enabled, it's up to the handler + * for isp_async to reinit stuff and restart the firmware + * after performing the crash dump. The reason we do things + * this way is that we may need to activate a kernel thread + * to do all the crash dump goop. + */ + isp_async(isp, ISPASYNC_FW_CRASH, NULL); +#else + isp_async(isp, ISPASYNC_FW_CRASH, NULL); + isp_reinit(isp); + isp_async(isp, ISPASYNC_FW_RESTARTED, NULL); +#endif + rval = -1; + break; + + case ASYNC_RQS_XFER_ERR: + isp_prt(isp, ISP_LOGERR, "Request Queue Transfer Error"); + break; + + case ASYNC_RSP_XFER_ERR: + isp_prt(isp, ISP_LOGERR, "Response Queue Transfer Error"); + break; + + case ASYNC_QWAKEUP: + /* + * We've just been notified that the Queue has woken up. + * We don't need to be chatty about this- just unlatch things + * and move on. + */ + mbox = READ_REQUEST_QUEUE_OUT_POINTER(isp); + break; + + case ASYNC_TIMEOUT_RESET: + isp_prt(isp, ISP_LOGWARN, + "timeout initiated SCSI bus reset of bus %d", bus); + isp->isp_sendmarker |= (1 << bus); +#ifdef ISP_TARGET_MODE + if (isp_target_async(isp, bus, mbox)) + rval = -1; +#endif + break; + + case ASYNC_DEVICE_RESET: + isp_prt(isp, ISP_LOGINFO, "device reset on bus %d", bus); + isp->isp_sendmarker |= (1 << bus); +#ifdef ISP_TARGET_MODE + if (isp_target_async(isp, bus, mbox)) + rval = -1; +#endif + break; + + case ASYNC_EXTMSG_UNDERRUN: + isp_prt(isp, ISP_LOGWARN, "extended message underrun"); + break; + + case ASYNC_SCAM_INT: + isp_prt(isp, ISP_LOGINFO, "SCAM interrupt"); + break; + + case ASYNC_HUNG_SCSI: + isp_prt(isp, ISP_LOGERR, + "stalled SCSI Bus after DATA Overrun"); + /* XXX: Need to issue SCSI reset at this point */ + break; + + case ASYNC_KILLED_BUS: + isp_prt(isp, ISP_LOGERR, "SCSI Bus reset after DATA Overrun"); + break; + + case ASYNC_BUS_TRANSIT: + mbox = ISP_READ(isp, OUTMAILBOX2); + switch (mbox & 0x1c00) { + case SXP_PINS_LVD_MODE: + isp_prt(isp, ISP_LOGINFO, "Transition to LVD mode"); + SDPARAM(isp)->isp_diffmode = 0; + SDPARAM(isp)->isp_ultramode = 0; + SDPARAM(isp)->isp_lvdmode = 1; + break; + case SXP_PINS_HVD_MODE: + isp_prt(isp, ISP_LOGINFO, + "Transition to Differential mode"); + SDPARAM(isp)->isp_diffmode = 1; + SDPARAM(isp)->isp_ultramode = 0; + SDPARAM(isp)->isp_lvdmode = 0; + break; + case SXP_PINS_SE_MODE: + isp_prt(isp, ISP_LOGINFO, + "Transition to Single Ended mode"); + SDPARAM(isp)->isp_diffmode = 0; + SDPARAM(isp)->isp_ultramode = 1; + SDPARAM(isp)->isp_lvdmode = 0; + break; + default: + isp_prt(isp, ISP_LOGWARN, + "Transition to Unknown Mode 0x%x", mbox); + break; + } + /* + * XXX: Set up to renegotiate again! + */ + /* Can only be for a 1080... */ + isp->isp_sendmarker |= (1 << bus); + break; + + /* + * We can use bus, which will always be zero for FC cards, + * as a mailbox pattern accumulator to be checked below. + */ + case ASYNC_RIO5: + bus = 0x1ce; /* outgoing mailbox regs 1-3, 6-7 */ + break; + + case ASYNC_RIO4: + bus = 0x14e; /* outgoing mailbox regs 1-3, 6 */ + break; + + case ASYNC_RIO3: + bus = 0x10e; /* outgoing mailbox regs 1-3 */ + break; + + case ASYNC_RIO2: + bus = 0x106; /* outgoing mailbox regs 1-2 */ + break; + + case ASYNC_RIO1: + case ASYNC_CMD_CMPLT: + bus = 0x102; /* outgoing mailbox regs 1 */ + break; + + case ASYNC_RIO_RESP: + return (rval); + + case ASYNC_CTIO_DONE: + { +#ifdef ISP_TARGET_MODE + int handle = + (ISP_READ(isp, OUTMAILBOX2) << 16) | + (ISP_READ(isp, OUTMAILBOX1)); + if (isp_target_async(isp, handle, mbox)) + rval = -1; +#else + isp_prt(isp, ISP_LOGINFO, "Fast Posting CTIO done"); +#endif + isp->isp_fphccmplt++; /* count it as a fast posting intr */ + break; + } + case ASYNC_LIP_F8: + case ASYNC_LIP_OCCURRED: + FCPARAM(isp)->isp_lipseq = + ISP_READ(isp, OUTMAILBOX1); + FCPARAM(isp)->isp_fwstate = FW_CONFIG_WAIT; + FCPARAM(isp)->isp_loopstate = LOOP_LIP_RCVD; + isp->isp_sendmarker = 1; + isp_mark_getpdb_all(isp); + isp_async(isp, ISPASYNC_LIP, NULL); +#ifdef ISP_TARGET_MODE + if (isp_target_async(isp, bus, mbox)) + rval = -1; +#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: + isp->isp_sendmarker = 1; + FCPARAM(isp)->isp_fwstate = FW_CONFIG_WAIT; + FCPARAM(isp)->isp_loopstate = LOOP_LIP_RCVD; + isp_mark_getpdb_all(isp); + isp_async(isp, ISPASYNC_LOOP_UP, NULL); +#ifdef ISP_TARGET_MODE + if (isp_target_async(isp, bus, mbox)) + rval = -1; +#endif + break; + + case ASYNC_LOOP_DOWN: + isp->isp_sendmarker = 1; + FCPARAM(isp)->isp_fwstate = FW_CONFIG_WAIT; + FCPARAM(isp)->isp_loopstate = LOOP_NIL; + isp_mark_getpdb_all(isp); + isp_async(isp, ISPASYNC_LOOP_DOWN, NULL); +#ifdef ISP_TARGET_MODE + if (isp_target_async(isp, bus, mbox)) + rval = -1; +#endif + break; + + case ASYNC_LOOP_RESET: + isp->isp_sendmarker = 1; + FCPARAM(isp)->isp_fwstate = FW_CONFIG_WAIT; + FCPARAM(isp)->isp_loopstate = LOOP_NIL; + isp_mark_getpdb_all(isp); + isp_async(isp, ISPASYNC_LOOP_RESET, NULL); +#ifdef ISP_TARGET_MODE + if (isp_target_async(isp, bus, mbox)) + rval = -1; +#endif + break; + + case ASYNC_PDB_CHANGED: + isp->isp_sendmarker = 1; + FCPARAM(isp)->isp_loopstate = LOOP_PDB_RCVD; + isp_mark_getpdb_all(isp); + isp_async(isp, ISPASYNC_CHANGE_NOTIFY, ISPASYNC_CHANGE_PDB); + break; + + case ASYNC_CHANGE_NOTIFY: + /* + * Not correct, but it will force us to rescan the loop. + */ + FCPARAM(isp)->isp_loopstate = LOOP_PDB_RCVD; + isp_mark_getpdb_all(isp); + isp_async(isp, ISPASYNC_CHANGE_NOTIFY, ISPASYNC_CHANGE_SNS); + break; + + case ASYNC_PTPMODE: + if (FCPARAM(isp)->isp_onfabric) + FCPARAM(isp)->isp_topo = TOPO_F_PORT; + else + FCPARAM(isp)->isp_topo = TOPO_N_PORT; + isp_mark_getpdb_all(isp); + isp->isp_sendmarker = 1; + FCPARAM(isp)->isp_fwstate = FW_CONFIG_WAIT; + FCPARAM(isp)->isp_loopstate = LOOP_LIP_RCVD; + isp_async(isp, ISPASYNC_CHANGE_NOTIFY, ISPASYNC_CHANGE_OTHER); +#ifdef ISP_TARGET_MODE + if (isp_target_async(isp, bus, mbox)) + rval = -1; +#endif + isp_prt(isp, ISP_LOGINFO, "Point-to-Point mode"); + break; + + case ASYNC_CONNMODE: + mbox = ISP_READ(isp, OUTMAILBOX1); + isp_mark_getpdb_all(isp); + switch (mbox) { + case ISP_CONN_LOOP: + isp_prt(isp, ISP_LOGINFO, + "Point-to-Point -> Loop mode"); + break; + case ISP_CONN_PTP: + isp_prt(isp, ISP_LOGINFO, + "Loop -> Point-to-Point mode"); + break; + case ISP_CONN_BADLIP: + isp_prt(isp, ISP_LOGWARN, + "Point-to-Point -> Loop mode (BAD LIP)"); + break; + case ISP_CONN_FATAL: + isp_prt(isp, ISP_LOGERR, "FATAL CONNECTION ERROR"); +#ifdef ISP_FW_CRASH_DUMP + isp_async(isp, ISPASYNC_FW_CRASH, NULL); +#else + isp_async(isp, ISPASYNC_FW_CRASH, NULL); + isp_reinit(isp); + isp_async(isp, ISPASYNC_FW_RESTARTED, NULL); +#endif + return (-1); + case ISP_CONN_LOOPBACK: + isp_prt(isp, ISP_LOGWARN, + "Looped Back in Point-to-Point mode"); + break; + default: + isp_prt(isp, ISP_LOGWARN, + "Unknown connection mode (0x%x)", mbox); + break; + } + isp_async(isp, ISPASYNC_CHANGE_NOTIFY, ISPASYNC_CHANGE_OTHER); + isp->isp_sendmarker = 1; + FCPARAM(isp)->isp_fwstate = FW_CONFIG_WAIT; + FCPARAM(isp)->isp_loopstate = LOOP_LIP_RCVD; + break; + + default: + isp_prt(isp, ISP_LOGWARN, "Unknown Async Code 0x%x", mbox); + break; + } + + if (bus & 0x100) { + int i, nh; + u_int16_t handles[5]; + + for (nh = 0, i = 1; i < MAX_MAILBOX; i++) { + if ((bus & (1 << i)) == 0) { + continue; + } + handles[nh++] = ISP_READ(isp, MBOX_OFF(i)); + } + for (i = 0; i < nh; i++) { + isp_fastpost_complete(isp, handles[i]); + isp_prt(isp, ISP_LOGDEBUG3, + "fast post completion of %u", handles[i]); + } + if (isp->isp_fpcchiwater < nh) + isp->isp_fpcchiwater = nh; + } else { + isp->isp_intoasync++; + } + return (rval); +} + +/* + * Handle other response entries. A pointer to the request queue output + * index is here in case we want to eat several entries at once, although + * this is not used currently. + */ + +static int +isp_handle_other_response(struct ispsoftc *isp, int type, + isphdr_t *hp, u_int16_t *optrp) +{ + switch (type) { + case RQSTYPE_STATUS_CONT: + isp_prt(isp, ISP_LOGINFO, "Ignored Continuation Response"); + return (1); + case RQSTYPE_ATIO: + case RQSTYPE_CTIO: + case RQSTYPE_ENABLE_LUN: + case RQSTYPE_MODIFY_LUN: + case RQSTYPE_NOTIFY: + case RQSTYPE_NOTIFY_ACK: + case RQSTYPE_CTIO1: + case RQSTYPE_ATIO2: + case RQSTYPE_CTIO2: + case RQSTYPE_CTIO3: + isp->isp_rsltccmplt++; /* count as a response completion */ +#ifdef ISP_TARGET_MODE + if (isp_target_notify(isp, (ispstatusreq_t *) hp, optrp)) { + return (1); + } +#else + optrp = optrp; + /* FALLTHROUGH */ +#endif + case RQSTYPE_REQUEST: + default: + if (isp_async(isp, ISPASYNC_UNHANDLED_RESPONSE, hp)) { + return (1); + } + isp_prt(isp, ISP_LOGWARN, "Unhandled Response Type 0x%x", + isp_get_response_type(isp, hp)); + return (0); + } +} + +static void +isp_parse_status(struct ispsoftc *isp, ispstatusreq_t *sp, XS_T *xs) +{ + switch (sp->req_completion_status & 0xff) { + case RQCS_COMPLETE: + if (XS_NOERR(xs)) { + XS_SETERR(xs, HBA_NOERROR); + } + return; + + case RQCS_INCOMPLETE: + if ((sp->req_state_flags & RQSF_GOT_TARGET) == 0) { + isp_prt(isp, ISP_LOGDEBUG1, + "Selection Timeout for %d.%d.%d", + XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs)); + if (XS_NOERR(xs)) { + XS_SETERR(xs, HBA_SELTIMEOUT); + } + return; + } + isp_prt(isp, ISP_LOGERR, + "command incomplete for %d.%d.%d, state 0x%x", + XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs), + sp->req_state_flags); + break; + + case RQCS_DMA_ERROR: + isp_prt(isp, ISP_LOGERR, "DMA error for command on %d.%d.%d", + XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs)); + break; + + case RQCS_TRANSPORT_ERROR: + { + char buf[172]; + SNPRINTF(buf, sizeof (buf), "states=>"); + if (sp->req_state_flags & RQSF_GOT_BUS) { + SNPRINTF(buf, sizeof (buf), "%s GOT_BUS", buf); + } + if (sp->req_state_flags & RQSF_GOT_TARGET) { + SNPRINTF(buf, sizeof (buf), "%s GOT_TGT", buf); + } + if (sp->req_state_flags & RQSF_SENT_CDB) { + SNPRINTF(buf, sizeof (buf), "%s SENT_CDB", buf); + } + if (sp->req_state_flags & RQSF_XFRD_DATA) { + SNPRINTF(buf, sizeof (buf), "%s XFRD_DATA", buf); + } + if (sp->req_state_flags & RQSF_GOT_STATUS) { + SNPRINTF(buf, sizeof (buf), "%s GOT_STS", buf); + } + if (sp->req_state_flags & RQSF_GOT_SENSE) { + SNPRINTF(buf, sizeof (buf), "%s GOT_SNS", buf); + } + if (sp->req_state_flags & RQSF_XFER_COMPLETE) { + SNPRINTF(buf, sizeof (buf), "%s XFR_CMPLT", buf); + } + SNPRINTF(buf, sizeof (buf), "%s\nstatus=>", buf); + if (sp->req_status_flags & RQSTF_DISCONNECT) { + SNPRINTF(buf, sizeof (buf), "%s Disconnect", buf); + } + if (sp->req_status_flags & RQSTF_SYNCHRONOUS) { + SNPRINTF(buf, sizeof (buf), "%s Sync_xfr", buf); + } + if (sp->req_status_flags & RQSTF_PARITY_ERROR) { + SNPRINTF(buf, sizeof (buf), "%s Parity", buf); + } + if (sp->req_status_flags & RQSTF_BUS_RESET) { + SNPRINTF(buf, sizeof (buf), "%s Bus_Reset", buf); + } + if (sp->req_status_flags & RQSTF_DEVICE_RESET) { + SNPRINTF(buf, sizeof (buf), "%s Device_Reset", buf); + } + if (sp->req_status_flags & RQSTF_ABORTED) { + SNPRINTF(buf, sizeof (buf), "%s Aborted", buf); + } + if (sp->req_status_flags & RQSTF_TIMEOUT) { + SNPRINTF(buf, sizeof (buf), "%s Timeout", buf); + } + if (sp->req_status_flags & RQSTF_NEGOTIATION) { + SNPRINTF(buf, sizeof (buf), "%s Negotiation", buf); + } + isp_prt(isp, ISP_LOGERR, "%s", buf); + isp_prt(isp, ISP_LOGERR, "transport error for %d.%d.%d:\n%s", + XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs), buf); + break; + } + case RQCS_RESET_OCCURRED: + isp_prt(isp, ISP_LOGWARN, + "bus reset destroyed command for %d.%d.%d", + XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs)); + isp->isp_sendmarker |= (1 << XS_CHANNEL(xs)); + if (XS_NOERR(xs)) { + XS_SETERR(xs, HBA_BUSRESET); + } + return; + + case RQCS_ABORTED: + isp_prt(isp, ISP_LOGERR, "command aborted for %d.%d.%d", + XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs)); + isp->isp_sendmarker |= (1 << XS_CHANNEL(xs)); + if (XS_NOERR(xs)) { + XS_SETERR(xs, HBA_ABORTED); + } + return; + + case RQCS_TIMEOUT: + isp_prt(isp, ISP_LOGWARN, "command timed out for %d.%d.%d", + XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs)); + /* + * Check to see if we logged out the device. + */ + if (IS_FC(isp)) { + if ((sp->req_completion_status & RQSTF_LOGOUT) && + FCPARAM(isp)->portdb[XS_TGT(xs)].valid && + FCPARAM(isp)->portdb[XS_TGT(xs)].fabric_dev) { + FCPARAM(isp)->portdb[XS_TGT(xs)].relogin = 1; + } + } + if (XS_NOERR(xs)) { + XS_SETERR(xs, HBA_CMDTIMEOUT); + } + return; + + case RQCS_DATA_OVERRUN: + XS_RESID(xs) = sp->req_resid; + isp_prt(isp, ISP_LOGERR, "data overrun for command on %d.%d.%d", + XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs)); + if (XS_NOERR(xs)) { + XS_SETERR(xs, HBA_DATAOVR); + } + return; + + case RQCS_COMMAND_OVERRUN: + isp_prt(isp, ISP_LOGERR, + "command overrun for command on %d.%d.%d", + XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs)); + break; + + case RQCS_STATUS_OVERRUN: + isp_prt(isp, ISP_LOGERR, + "status overrun for command on %d.%d.%d", + XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs)); + break; + + case RQCS_BAD_MESSAGE: + isp_prt(isp, ISP_LOGERR, + "msg not COMMAND COMPLETE after status %d.%d.%d", + XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs)); + break; + + case RQCS_NO_MESSAGE_OUT: + isp_prt(isp, ISP_LOGERR, + "No MESSAGE OUT phase after selection on %d.%d.%d", + XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs)); + break; + + case RQCS_EXT_ID_FAILED: + isp_prt(isp, ISP_LOGERR, "EXTENDED IDENTIFY failed %d.%d.%d", + XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs)); + break; + + case RQCS_IDE_MSG_FAILED: + isp_prt(isp, ISP_LOGERR, + "INITIATOR DETECTED ERROR rejected by %d.%d.%d", + XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs)); + break; + + case RQCS_ABORT_MSG_FAILED: + isp_prt(isp, ISP_LOGERR, "ABORT OPERATION rejected by %d.%d.%d", + XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs)); + break; + + case RQCS_REJECT_MSG_FAILED: + isp_prt(isp, ISP_LOGERR, "MESSAGE REJECT rejected by %d.%d.%d", + XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs)); + break; + + case RQCS_NOP_MSG_FAILED: + isp_prt(isp, ISP_LOGERR, "NOP rejected by %d.%d.%d", + XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs)); + break; + + case RQCS_PARITY_ERROR_MSG_FAILED: + isp_prt(isp, ISP_LOGERR, + "MESSAGE PARITY ERROR rejected by %d.%d.%d", + XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs)); + break; + + case RQCS_DEVICE_RESET_MSG_FAILED: + isp_prt(isp, ISP_LOGWARN, + "BUS DEVICE RESET rejected by %d.%d.%d", + XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs)); + break; + + case RQCS_ID_MSG_FAILED: + isp_prt(isp, ISP_LOGERR, "IDENTIFY rejected by %d.%d.%d", + XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs)); + break; + + case RQCS_UNEXP_BUS_FREE: + isp_prt(isp, ISP_LOGERR, "%d.%d.%d had an unexpected bus free", + XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs)); + break; + + case RQCS_DATA_UNDERRUN: + { + if (IS_FC(isp)) { + int ru_marked = (sp->req_scsi_status & RQCS_RU) != 0; + if (!ru_marked || sp->req_resid > XS_XFRLEN(xs)) { + isp_prt(isp, ISP_LOGWARN, bun, XS_TGT(xs), + XS_LUN(xs), XS_XFRLEN(xs), sp->req_resid, + (ru_marked)? "marked" : "not marked"); + if (XS_NOERR(xs)) { + XS_SETERR(xs, HBA_BOTCH); + } + return; + } + } + XS_RESID(xs) = sp->req_resid; + if (XS_NOERR(xs)) { + XS_SETERR(xs, HBA_NOERROR); + } + return; + } + + case RQCS_XACT_ERR1: + isp_prt(isp, ISP_LOGERR, xact1, XS_CHANNEL(xs), + XS_TGT(xs), XS_LUN(xs)); + break; + + case RQCS_XACT_ERR2: + isp_prt(isp, ISP_LOGERR, xact2, + XS_LUN(xs), XS_TGT(xs), XS_CHANNEL(xs)); + break; + + case RQCS_XACT_ERR3: + isp_prt(isp, ISP_LOGERR, xact3, + XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs)); + break; + + case RQCS_BAD_ENTRY: + isp_prt(isp, ISP_LOGERR, "Invalid IOCB entry type detected"); + break; + + case RQCS_QUEUE_FULL: + isp_prt(isp, ISP_LOGDEBUG0, + "internal queues full for %d.%d.%d status 0x%x", + XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs), *XS_STSP(xs)); + + /* + * If QFULL or some other status byte is set, then this + * isn't an error, per se. + * + * Unfortunately, some QLogic f/w writers have, in + * some cases, ommitted to *set* status to QFULL. + * + + if (*XS_STSP(xs) != SCSI_GOOD && XS_NOERR(xs)) { + XS_SETERR(xs, HBA_NOERROR); + return; + } + + * + * + */ + + *XS_STSP(xs) = SCSI_QFULL; + XS_SETERR(xs, HBA_NOERROR); + return; + + case RQCS_PHASE_SKIPPED: + isp_prt(isp, ISP_LOGERR, pskip, XS_CHANNEL(xs), + XS_TGT(xs), XS_LUN(xs)); + break; + + case RQCS_ARQS_FAILED: + isp_prt(isp, ISP_LOGERR, + "Auto Request Sense failed for %d.%d.%d", + XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs)); + if (XS_NOERR(xs)) { + XS_SETERR(xs, HBA_ARQFAIL); + } + return; + + case RQCS_WIDE_FAILED: + isp_prt(isp, ISP_LOGERR, + "Wide Negotiation failed for %d.%d.%d", + XS_TGT(xs), XS_LUN(xs), XS_CHANNEL(xs)); + if (IS_SCSI(isp)) { + sdparam *sdp = isp->isp_param; + sdp += XS_CHANNEL(xs); + sdp->isp_devparam[XS_TGT(xs)].goal_flags &= ~DPARM_WIDE; + sdp->isp_devparam[XS_TGT(xs)].dev_update = 1; + isp->isp_update |= (1 << XS_CHANNEL(xs)); + } + if (XS_NOERR(xs)) { + XS_SETERR(xs, HBA_NOERROR); + } + return; + + case RQCS_SYNCXFER_FAILED: + isp_prt(isp, ISP_LOGERR, + "SDTR Message failed for target %d.%d.%d", + XS_TGT(xs), XS_LUN(xs), XS_CHANNEL(xs)); + if (IS_SCSI(isp)) { + sdparam *sdp = isp->isp_param; + sdp += XS_CHANNEL(xs); + sdp->isp_devparam[XS_TGT(xs)].goal_flags &= ~DPARM_SYNC; + sdp->isp_devparam[XS_TGT(xs)].dev_update = 1; + isp->isp_update |= (1 << XS_CHANNEL(xs)); + } + break; + + case RQCS_LVD_BUSERR: + isp_prt(isp, ISP_LOGERR, + "Bad LVD condition while talking to %d.%d.%d", + XS_TGT(xs), XS_LUN(xs), XS_CHANNEL(xs)); + break; + + case RQCS_PORT_UNAVAILABLE: + /* + * No such port on the loop. Moral equivalent of SELTIMEO + */ + case RQCS_PORT_LOGGED_OUT: + /* + * It was there (maybe)- treat as a selection timeout. + */ + if ((sp->req_completion_status & 0xff) == RQCS_PORT_UNAVAILABLE) + isp_prt(isp, ISP_LOGINFO, + "port unavailable for target %d", XS_TGT(xs)); + else + isp_prt(isp, ISP_LOGINFO, + "port logout for target %d", XS_TGT(xs)); + /* + * If we're on a local loop, force a LIP (which is overkill) + * to force a re-login of this unit. If we're on fabric, + * then we'll have to relogin as a matter of course. + */ + if (FCPARAM(isp)->isp_topo == TOPO_NL_PORT || + FCPARAM(isp)->isp_topo == TOPO_FL_PORT) { + mbreg_t mbs; + mbs.param[0] = MBOX_INIT_LIP; + isp_mboxcmd_qnw(isp, &mbs, 1); + } + + /* + * Probably overkill. + */ + isp->isp_sendmarker = 1; + FCPARAM(isp)->isp_loopstate = LOOP_PDB_RCVD; + isp_mark_getpdb_all(isp); + isp_async(isp, ISPASYNC_CHANGE_NOTIFY, ISPASYNC_CHANGE_OTHER); + if (XS_NOERR(xs)) { + XS_SETERR(xs, HBA_SELTIMEOUT); + } + return; + + case RQCS_PORT_CHANGED: + isp_prt(isp, ISP_LOGWARN, + "port changed for target %d", XS_TGT(xs)); + if (XS_NOERR(xs)) { + XS_SETERR(xs, HBA_SELTIMEOUT); + } + return; + + case RQCS_PORT_BUSY: + isp_prt(isp, ISP_LOGWARN, + "port busy for target %d", XS_TGT(xs)); + if (XS_NOERR(xs)) { + XS_SETERR(xs, HBA_TGTBSY); + } + return; + + default: + isp_prt(isp, ISP_LOGERR, "Unknown Completion Status 0x%x", + sp->req_completion_status); + break; + } + if (XS_NOERR(xs)) { + XS_SETERR(xs, HBA_BOTCH); + } +} + +static void +isp_fastpost_complete(struct ispsoftc *isp, u_int16_t fph) +{ + XS_T *xs; + + if (fph == 0) { + return; + } + xs = isp_find_xs(isp, fph); + if (xs == NULL) { + isp_prt(isp, ISP_LOGWARN, + "Command for fast post handle 0x%x not found", fph); + return; + } + isp_destroy_handle(isp, fph); + + /* + * Since we don't have a result queue entry item, + * we must believe that SCSI status is zero and + * that all data transferred. + */ + XS_SET_STATE_STAT(isp, xs, NULL); + XS_RESID(xs) = 0; + *XS_STSP(xs) = SCSI_GOOD; + if (XS_XFRLEN(xs)) { + ISP_DMAFREE(isp, xs, fph); + } + if (isp->isp_nactive) + isp->isp_nactive--; + isp->isp_fphccmplt++; + isp_done(xs); +} + +static int +isp_mbox_continue(struct ispsoftc *isp) +{ + mbreg_t mbs; + u_int16_t *ptr; + + switch (isp->isp_lastmbxcmd) { + case MBOX_WRITE_RAM_WORD: + case MBOX_READ_RAM_WORD: + case MBOX_READ_RAM_WORD_EXTENDED: + break; + default: + return (1); + } + if (isp->isp_mboxtmp[0] != MBOX_COMMAND_COMPLETE) { + isp->isp_mbxwrk0 = 0; + return (-1); + } + + + /* + * Clear the previous interrupt. + */ + ISP_WRITE(isp, HCCR, HCCR_CMD_CLEAR_RISC_INT); + ISP_WRITE(isp, BIU_SEMA, 0); + + /* + * Continue with next word. + */ + ptr = isp->isp_mbxworkp; + switch (isp->isp_lastmbxcmd) { + case MBOX_WRITE_RAM_WORD: + mbs.param[2] = *ptr++; + mbs.param[1] = isp->isp_mbxwrk1++; + break; + case MBOX_READ_RAM_WORD: + case MBOX_READ_RAM_WORD_EXTENDED: + *ptr++ = isp->isp_mboxtmp[2]; + mbs.param[1] = isp->isp_mbxwrk1++; + break; + } + isp->isp_mbxworkp = ptr; + mbs.param[0] = isp->isp_lastmbxcmd; + isp->isp_mbxwrk0 -= 1; + isp_mboxcmd_qnw(isp, &mbs, 0); + return (0); +} + + +#define HIBYT(x) ((x) >> 0x8) +#define LOBYT(x) ((x) & 0xff) +#define ISPOPMAP(a, b) (((a) << 8) | (b)) +static u_int16_t mbpscsi[] = { + ISPOPMAP(0x01, 0x01), /* 0x00: MBOX_NO_OP */ + ISPOPMAP(0x1f, 0x01), /* 0x01: MBOX_LOAD_RAM */ + ISPOPMAP(0x03, 0x01), /* 0x02: MBOX_EXEC_FIRMWARE */ + ISPOPMAP(0x1f, 0x01), /* 0x03: MBOX_DUMP_RAM */ + ISPOPMAP(0x07, 0x07), /* 0x04: MBOX_WRITE_RAM_WORD */ + ISPOPMAP(0x03, 0x07), /* 0x05: MBOX_READ_RAM_WORD */ + ISPOPMAP(0x3f, 0x3f), /* 0x06: MBOX_MAILBOX_REG_TEST */ + ISPOPMAP(0x03, 0x07), /* 0x07: MBOX_VERIFY_CHECKSUM */ + ISPOPMAP(0x01, 0x0f), /* 0x08: MBOX_ABOUT_FIRMWARE */ + ISPOPMAP(0x00, 0x00), /* 0x09: */ + ISPOPMAP(0x00, 0x00), /* 0x0a: */ + ISPOPMAP(0x00, 0x00), /* 0x0b: */ + ISPOPMAP(0x00, 0x00), /* 0x0c: */ + ISPOPMAP(0x00, 0x00), /* 0x0d: */ + ISPOPMAP(0x01, 0x05), /* 0x0e: MBOX_CHECK_FIRMWARE */ + ISPOPMAP(0x00, 0x00), /* 0x0f: */ + ISPOPMAP(0x1f, 0x1f), /* 0x10: MBOX_INIT_REQ_QUEUE */ + ISPOPMAP(0x3f, 0x3f), /* 0x11: MBOX_INIT_RES_QUEUE */ + ISPOPMAP(0x0f, 0x0f), /* 0x12: MBOX_EXECUTE_IOCB */ + ISPOPMAP(0x03, 0x03), /* 0x13: MBOX_WAKE_UP */ + ISPOPMAP(0x01, 0x3f), /* 0x14: MBOX_STOP_FIRMWARE */ + ISPOPMAP(0x0f, 0x0f), /* 0x15: MBOX_ABORT */ + ISPOPMAP(0x03, 0x03), /* 0x16: MBOX_ABORT_DEVICE */ + ISPOPMAP(0x07, 0x07), /* 0x17: MBOX_ABORT_TARGET */ + ISPOPMAP(0x07, 0x07), /* 0x18: MBOX_BUS_RESET */ + ISPOPMAP(0x03, 0x07), /* 0x19: MBOX_STOP_QUEUE */ + ISPOPMAP(0x03, 0x07), /* 0x1a: MBOX_START_QUEUE */ + ISPOPMAP(0x03, 0x07), /* 0x1b: MBOX_SINGLE_STEP_QUEUE */ + ISPOPMAP(0x03, 0x07), /* 0x1c: MBOX_ABORT_QUEUE */ + ISPOPMAP(0x03, 0x4f), /* 0x1d: MBOX_GET_DEV_QUEUE_STATUS */ + ISPOPMAP(0x00, 0x00), /* 0x1e: */ + ISPOPMAP(0x01, 0x07), /* 0x1f: MBOX_GET_FIRMWARE_STATUS */ + ISPOPMAP(0x01, 0x07), /* 0x20: MBOX_GET_INIT_SCSI_ID */ + ISPOPMAP(0x01, 0x07), /* 0x21: MBOX_GET_SELECT_TIMEOUT */ + ISPOPMAP(0x01, 0xc7), /* 0x22: MBOX_GET_RETRY_COUNT */ + ISPOPMAP(0x01, 0x07), /* 0x23: MBOX_GET_TAG_AGE_LIMIT */ + ISPOPMAP(0x01, 0x03), /* 0x24: MBOX_GET_CLOCK_RATE */ + ISPOPMAP(0x01, 0x07), /* 0x25: MBOX_GET_ACT_NEG_STATE */ + ISPOPMAP(0x01, 0x07), /* 0x26: MBOX_GET_ASYNC_DATA_SETUP_TIME */ + ISPOPMAP(0x01, 0x07), /* 0x27: MBOX_GET_PCI_PARAMS */ + ISPOPMAP(0x03, 0x4f), /* 0x28: MBOX_GET_TARGET_PARAMS */ + ISPOPMAP(0x03, 0x0f), /* 0x29: MBOX_GET_DEV_QUEUE_PARAMS */ + ISPOPMAP(0x01, 0x07), /* 0x2a: MBOX_GET_RESET_DELAY_PARAMS */ + ISPOPMAP(0x00, 0x00), /* 0x2b: */ + ISPOPMAP(0x00, 0x00), /* 0x2c: */ + ISPOPMAP(0x00, 0x00), /* 0x2d: */ + ISPOPMAP(0x00, 0x00), /* 0x2e: */ + ISPOPMAP(0x00, 0x00), /* 0x2f: */ + ISPOPMAP(0x03, 0x03), /* 0x30: MBOX_SET_INIT_SCSI_ID */ + ISPOPMAP(0x07, 0x07), /* 0x31: MBOX_SET_SELECT_TIMEOUT */ + ISPOPMAP(0xc7, 0xc7), /* 0x32: MBOX_SET_RETRY_COUNT */ + ISPOPMAP(0x07, 0x07), /* 0x33: MBOX_SET_TAG_AGE_LIMIT */ + ISPOPMAP(0x03, 0x03), /* 0x34: MBOX_SET_CLOCK_RATE */ + ISPOPMAP(0x07, 0x07), /* 0x35: MBOX_SET_ACT_NEG_STATE */ + ISPOPMAP(0x07, 0x07), /* 0x36: MBOX_SET_ASYNC_DATA_SETUP_TIME */ + ISPOPMAP(0x07, 0x07), /* 0x37: MBOX_SET_PCI_CONTROL_PARAMS */ + ISPOPMAP(0x4f, 0x4f), /* 0x38: MBOX_SET_TARGET_PARAMS */ + ISPOPMAP(0x0f, 0x0f), /* 0x39: MBOX_SET_DEV_QUEUE_PARAMS */ + ISPOPMAP(0x07, 0x07), /* 0x3a: MBOX_SET_RESET_DELAY_PARAMS */ + ISPOPMAP(0x00, 0x00), /* 0x3b: */ + ISPOPMAP(0x00, 0x00), /* 0x3c: */ + ISPOPMAP(0x00, 0x00), /* 0x3d: */ + ISPOPMAP(0x00, 0x00), /* 0x3e: */ + ISPOPMAP(0x00, 0x00), /* 0x3f: */ + ISPOPMAP(0x01, 0x03), /* 0x40: MBOX_RETURN_BIOS_BLOCK_ADDR */ + ISPOPMAP(0x3f, 0x01), /* 0x41: MBOX_WRITE_FOUR_RAM_WORDS */ + ISPOPMAP(0x03, 0x07), /* 0x42: MBOX_EXEC_BIOS_IOCB */ + ISPOPMAP(0x00, 0x00), /* 0x43: */ + ISPOPMAP(0x00, 0x00), /* 0x44: */ + ISPOPMAP(0x03, 0x03), /* 0x45: SET SYSTEM PARAMETER */ + ISPOPMAP(0x01, 0x03), /* 0x46: GET SYSTEM PARAMETER */ + ISPOPMAP(0x00, 0x00), /* 0x47: */ + ISPOPMAP(0x01, 0xcf), /* 0x48: GET SCAM CONFIGURATION */ + ISPOPMAP(0xcf, 0xcf), /* 0x49: SET SCAM CONFIGURATION */ + ISPOPMAP(0x03, 0x03), /* 0x4a: MBOX_SET_FIRMWARE_FEATURES */ + ISPOPMAP(0x01, 0x03), /* 0x4b: MBOX_GET_FIRMWARE_FEATURES */ + ISPOPMAP(0x00, 0x00), /* 0x4c: */ + ISPOPMAP(0x00, 0x00), /* 0x4d: */ + ISPOPMAP(0x00, 0x00), /* 0x4e: */ + ISPOPMAP(0x00, 0x00), /* 0x4f: */ + ISPOPMAP(0xdf, 0xdf), /* 0x50: LOAD RAM A64 */ + ISPOPMAP(0xdf, 0xdf), /* 0x51: DUMP RAM A64 */ + ISPOPMAP(0xdf, 0xff), /* 0x52: INITIALIZE REQUEST QUEUE A64 */ + ISPOPMAP(0xef, 0xff), /* 0x53: INITIALIZE RESPONSE QUEUE A64 */ + ISPOPMAP(0xcf, 0x01), /* 0x54: EXECUTE IOCB A64 */ + ISPOPMAP(0x07, 0x01), /* 0x55: ENABLE TARGET MODE */ + ISPOPMAP(0x03, 0x0f), /* 0x56: GET TARGET STATUS */ + ISPOPMAP(0x00, 0x00), /* 0x57: */ + ISPOPMAP(0x00, 0x00), /* 0x58: */ + ISPOPMAP(0x00, 0x00), /* 0x59: */ + ISPOPMAP(0x03, 0x03), /* 0x5a: SET DATA OVERRUN RECOVERY MODE */ + ISPOPMAP(0x01, 0x03), /* 0x5b: GET DATA OVERRUN RECOVERY MODE */ + ISPOPMAP(0x0f, 0x0f), /* 0x5c: SET HOST DATA */ + ISPOPMAP(0x01, 0x01) /* 0x5d: GET NOST DATA */ +}; + +#ifndef ISP_STRIPPED +static char *scsi_mbcmd_names[] = { + "NO-OP", + "LOAD RAM", + "EXEC FIRMWARE", + "DUMP RAM", + "WRITE RAM WORD", + "READ RAM WORD", + "MAILBOX REG TEST", + "VERIFY CHECKSUM", + "ABOUT FIRMWARE", + NULL, + NULL, + NULL, + NULL, + NULL, + "CHECK FIRMWARE", + NULL, + "INIT REQUEST QUEUE", + "INIT RESULT QUEUE", + "EXECUTE IOCB", + "WAKE UP", + "STOP FIRMWARE", + "ABORT", + "ABORT DEVICE", + "ABORT TARGET", + "BUS RESET", + "STOP QUEUE", + "START QUEUE", + "SINGLE STEP QUEUE", + "ABORT QUEUE", + "GET DEV QUEUE STATUS", + NULL, + "GET FIRMWARE STATUS", + "GET INIT SCSI ID", + "GET SELECT TIMEOUT", + "GET RETRY COUNT", + "GET TAG AGE LIMIT", + "GET CLOCK RATE", + "GET ACT NEG STATE", + "GET ASYNC DATA SETUP TIME", + "GET PCI PARAMS", + "GET TARGET PARAMS", + "GET DEV QUEUE PARAMS", + "GET RESET DELAY PARAMS", + NULL, + NULL, + NULL, + NULL, + NULL, + "SET INIT SCSI ID", + "SET SELECT TIMEOUT", + "SET RETRY COUNT", + "SET TAG AGE LIMIT", + "SET CLOCK RATE", + "SET ACT NEG STATE", + "SET ASYNC DATA SETUP TIME", + "SET PCI CONTROL PARAMS", + "SET TARGET PARAMS", + "SET DEV QUEUE PARAMS", + "SET RESET DELAY PARAMS", + NULL, + NULL, + NULL, + NULL, + NULL, + "RETURN BIOS BLOCK ADDR", + "WRITE FOUR RAM WORDS", + "EXEC BIOS IOCB", + NULL, + NULL, + "SET SYSTEM PARAMETER", + "GET SYSTEM PARAMETER", + NULL, + "GET SCAM CONFIGURATION", + "SET SCAM CONFIGURATION", + "SET FIRMWARE FEATURES", + "GET FIRMWARE FEATURES", + NULL, + NULL, + NULL, + NULL, + "LOAD RAM A64", + "DUMP RAM A64", + "INITIALIZE REQUEST QUEUE A64", + "INITIALIZE RESPONSE QUEUE A64", + "EXECUTE IOCB A64", + "ENABLE TARGET MODE", + "GET TARGET MODE STATE", + NULL, + NULL, + NULL, + "SET DATA OVERRUN RECOVERY MODE", + "GET DATA OVERRUN RECOVERY MODE", + "SET HOST DATA", + "GET NOST DATA", +}; +#endif + +static u_int16_t mbpfc[] = { + ISPOPMAP(0x01, 0x01), /* 0x00: MBOX_NO_OP */ + ISPOPMAP(0x1f, 0x01), /* 0x01: MBOX_LOAD_RAM */ + ISPOPMAP(0x03, 0x01), /* 0x02: MBOX_EXEC_FIRMWARE */ + ISPOPMAP(0xdf, 0x01), /* 0x03: MBOX_DUMP_RAM */ + ISPOPMAP(0x07, 0x07), /* 0x04: MBOX_WRITE_RAM_WORD */ + ISPOPMAP(0x03, 0x07), /* 0x05: MBOX_READ_RAM_WORD */ + ISPOPMAP(0xff, 0xff), /* 0x06: MBOX_MAILBOX_REG_TEST */ + ISPOPMAP(0x03, 0x05), /* 0x07: MBOX_VERIFY_CHECKSUM */ + ISPOPMAP(0x01, 0x4f), /* 0x08: MBOX_ABOUT_FIRMWARE */ + ISPOPMAP(0xdf, 0x01), /* 0x09: LOAD RAM */ + ISPOPMAP(0xdf, 0x01), /* 0x0a: DUMP RAM */ + ISPOPMAP(0x00, 0x00), /* 0x0b: */ + ISPOPMAP(0x00, 0x00), /* 0x0c: */ + ISPOPMAP(0x00, 0x00), /* 0x0d: */ + ISPOPMAP(0x01, 0x05), /* 0x0e: MBOX_CHECK_FIRMWARE */ + ISPOPMAP(0x03, 0x07), /* 0x0f: MBOX_READ_RAM_WORD_EXTENDED(1) */ + ISPOPMAP(0x1f, 0x11), /* 0x10: MBOX_INIT_REQ_QUEUE */ + ISPOPMAP(0x2f, 0x21), /* 0x11: MBOX_INIT_RES_QUEUE */ + ISPOPMAP(0x0f, 0x01), /* 0x12: MBOX_EXECUTE_IOCB */ + ISPOPMAP(0x03, 0x03), /* 0x13: MBOX_WAKE_UP */ + ISPOPMAP(0x01, 0xff), /* 0x14: MBOX_STOP_FIRMWARE */ + ISPOPMAP(0x4f, 0x01), /* 0x15: MBOX_ABORT */ + ISPOPMAP(0x07, 0x01), /* 0x16: MBOX_ABORT_DEVICE */ + ISPOPMAP(0x07, 0x01), /* 0x17: MBOX_ABORT_TARGET */ + ISPOPMAP(0x03, 0x03), /* 0x18: MBOX_BUS_RESET */ + ISPOPMAP(0x07, 0x05), /* 0x19: MBOX_STOP_QUEUE */ + ISPOPMAP(0x07, 0x05), /* 0x1a: MBOX_START_QUEUE */ + ISPOPMAP(0x07, 0x05), /* 0x1b: MBOX_SINGLE_STEP_QUEUE */ + ISPOPMAP(0x07, 0x05), /* 0x1c: MBOX_ABORT_QUEUE */ + ISPOPMAP(0x07, 0x03), /* 0x1d: MBOX_GET_DEV_QUEUE_STATUS */ + ISPOPMAP(0x00, 0x00), /* 0x1e: */ + ISPOPMAP(0x01, 0x07), /* 0x1f: MBOX_GET_FIRMWARE_STATUS */ + ISPOPMAP(0x01, 0x4f), /* 0x20: MBOX_GET_LOOP_ID */ + ISPOPMAP(0x00, 0x00), /* 0x21: */ + ISPOPMAP(0x01, 0x07), /* 0x22: MBOX_GET_RETRY_COUNT */ + ISPOPMAP(0x00, 0x00), /* 0x23: */ + ISPOPMAP(0x00, 0x00), /* 0x24: */ + ISPOPMAP(0x00, 0x00), /* 0x25: */ + ISPOPMAP(0x00, 0x00), /* 0x26: */ + ISPOPMAP(0x00, 0x00), /* 0x27: */ + ISPOPMAP(0x01, 0x03), /* 0x28: MBOX_GET_FIRMWARE_OPTIONS */ + ISPOPMAP(0x03, 0x07), /* 0x29: MBOX_GET_PORT_QUEUE_PARAMS */ + ISPOPMAP(0x00, 0x00), /* 0x2a: */ + ISPOPMAP(0x00, 0x00), /* 0x2b: */ + ISPOPMAP(0x00, 0x00), /* 0x2c: */ + ISPOPMAP(0x00, 0x00), /* 0x2d: */ + ISPOPMAP(0x00, 0x00), /* 0x2e: */ + ISPOPMAP(0x00, 0x00), /* 0x2f: */ + ISPOPMAP(0x00, 0x00), /* 0x30: */ + ISPOPMAP(0x00, 0x00), /* 0x31: */ + ISPOPMAP(0x07, 0x07), /* 0x32: MBOX_SET_RETRY_COUNT */ + ISPOPMAP(0x00, 0x00), /* 0x33: */ + ISPOPMAP(0x00, 0x00), /* 0x34: */ + ISPOPMAP(0x00, 0x00), /* 0x35: */ + ISPOPMAP(0x00, 0x00), /* 0x36: */ + ISPOPMAP(0x00, 0x00), /* 0x37: */ + ISPOPMAP(0x0f, 0x01), /* 0x38: MBOX_SET_FIRMWARE_OPTIONS */ + ISPOPMAP(0x0f, 0x07), /* 0x39: MBOX_SET_PORT_QUEUE_PARAMS */ + ISPOPMAP(0x00, 0x00), /* 0x3a: */ + ISPOPMAP(0x00, 0x00), /* 0x3b: */ + ISPOPMAP(0x00, 0x00), /* 0x3c: */ + ISPOPMAP(0x00, 0x00), /* 0x3d: */ + ISPOPMAP(0x00, 0x00), /* 0x3e: */ + ISPOPMAP(0x00, 0x00), /* 0x3f: */ + ISPOPMAP(0x03, 0x01), /* 0x40: MBOX_LOOP_PORT_BYPASS */ + ISPOPMAP(0x03, 0x01), /* 0x41: MBOX_LOOP_PORT_ENABLE */ + ISPOPMAP(0x03, 0x07), /* 0x42: MBOX_GET_RESOURCE_COUNTS */ + ISPOPMAP(0x01, 0x01), /* 0x43: MBOX_REQUEST_NON_PARTICIPATING_MODE */ + ISPOPMAP(0x00, 0x00), /* 0x44: */ + ISPOPMAP(0x00, 0x00), /* 0x45: */ + ISPOPMAP(0x00, 0x00), /* 0x46: */ + ISPOPMAP(0xcf, 0x03), /* 0x47: GET PORT_DATABASE ENHANCED */ + ISPOPMAP(0x00, 0x00), /* 0x48: */ + ISPOPMAP(0x00, 0x00), /* 0x49: */ + ISPOPMAP(0x00, 0x00), /* 0x4a: */ + ISPOPMAP(0x00, 0x00), /* 0x4b: */ + ISPOPMAP(0x00, 0x00), /* 0x4c: */ + ISPOPMAP(0x00, 0x00), /* 0x4d: */ + ISPOPMAP(0x00, 0x00), /* 0x4e: */ + ISPOPMAP(0x00, 0x00), /* 0x4f: */ + ISPOPMAP(0x00, 0x00), /* 0x50: */ + ISPOPMAP(0x00, 0x00), /* 0x51: */ + ISPOPMAP(0x00, 0x00), /* 0x52: */ + ISPOPMAP(0x00, 0x00), /* 0x53: */ + ISPOPMAP(0xcf, 0x01), /* 0x54: EXECUTE IOCB A64 */ + ISPOPMAP(0x00, 0x00), /* 0x55: */ + ISPOPMAP(0x00, 0x00), /* 0x56: */ + ISPOPMAP(0x00, 0x00), /* 0x57: */ + ISPOPMAP(0x00, 0x00), /* 0x58: */ + ISPOPMAP(0x00, 0x00), /* 0x59: */ + ISPOPMAP(0x00, 0x00), /* 0x5a: */ + ISPOPMAP(0x03, 0x01), /* 0x5b: MBOX_DRIVER_HEARTBEAT */ + ISPOPMAP(0xcf, 0x01), /* 0x5c: MBOX_FW_HEARTBEAT */ + 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(0x00, 0x00), /* 0x61: */ + ISPOPMAP(0x01, 0x01), /* 0x62: MBOX_INIT_LIP */ + ISPOPMAP(0xcd, 0x03), /* 0x63: MBOX_GET_FC_AL_POSITION_MAP */ + ISPOPMAP(0xcf, 0x01), /* 0x64: MBOX_GET_PORT_DB */ + ISPOPMAP(0x07, 0x01), /* 0x65: MBOX_CLEAR_ACA */ + ISPOPMAP(0x07, 0x01), /* 0x66: MBOX_TARGET_RESET */ + ISPOPMAP(0x07, 0x01), /* 0x67: MBOX_CLEAR_TASK_SET */ + ISPOPMAP(0x07, 0x01), /* 0x68: MBOX_ABORT_TASK_SET */ + ISPOPMAP(0x01, 0x07), /* 0x69: MBOX_GET_FW_STATE */ + ISPOPMAP(0x03, 0xcf), /* 0x6a: MBOX_GET_PORT_NAME */ + ISPOPMAP(0xcf, 0x01), /* 0x6b: MBOX_GET_LINK_STATUS */ + ISPOPMAP(0x0f, 0x01), /* 0x6c: MBOX_INIT_LIP_RESET */ + ISPOPMAP(0x00, 0x00), /* 0x6d: */ + ISPOPMAP(0xcf, 0x03), /* 0x6e: MBOX_SEND_SNS */ + ISPOPMAP(0x0f, 0x07), /* 0x6f: MBOX_FABRIC_LOGIN */ + ISPOPMAP(0x03, 0x01), /* 0x70: MBOX_SEND_CHANGE_REQUEST */ + ISPOPMAP(0x03, 0x03), /* 0x71: MBOX_FABRIC_LOGOUT */ + ISPOPMAP(0x0f, 0x0f), /* 0x72: MBOX_INIT_LIP_LOGIN */ + ISPOPMAP(0x00, 0x00), /* 0x73: */ + ISPOPMAP(0x07, 0x01), /* 0x74: LOGIN LOOP PORT */ + ISPOPMAP(0xcf, 0x03), /* 0x75: GET PORT/NODE NAME LIST */ + ISPOPMAP(0x4f, 0x01), /* 0x76: SET VENDOR ID */ + ISPOPMAP(0xcd, 0x01), /* 0x77: INITIALIZE IP MAILBOX */ + ISPOPMAP(0x00, 0x00), /* 0x78: */ + ISPOPMAP(0x00, 0x00), /* 0x79: */ + ISPOPMAP(0x00, 0x00), /* 0x7a: */ + ISPOPMAP(0x00, 0x00), /* 0x7b: */ + ISPOPMAP(0x4f, 0x03), /* 0x7c: Get ID List */ + ISPOPMAP(0xcf, 0x01), /* 0x7d: SEND LFA */ + ISPOPMAP(0x07, 0x01) /* 0x7e: Lun RESET */ +}; +/* + * Footnotes + * + * (1): this sets bits 21..16 in mailbox register #8, which we nominally + * do not access at this time in the core driver. The caller is + * responsible for setting this register first (Gross!). + */ + +#ifndef ISP_STRIPPED +static char *fc_mbcmd_names[] = { + "NO-OP", + "LOAD RAM", + "EXEC FIRMWARE", + "DUMP RAM", + "WRITE RAM WORD", + "READ RAM WORD", + "MAILBOX REG TEST", + "VERIFY CHECKSUM", + "ABOUT FIRMWARE", + "LOAD RAM", + "DUMP RAM", + NULL, + NULL, + "READ RAM WORD EXTENDED", + "CHECK FIRMWARE", + NULL, + "INIT REQUEST QUEUE", + "INIT RESULT QUEUE", + "EXECUTE IOCB", + "WAKE UP", + "STOP FIRMWARE", + "ABORT", + "ABORT DEVICE", + "ABORT TARGET", + "BUS RESET", + "STOP QUEUE", + "START QUEUE", + "SINGLE STEP QUEUE", + "ABORT QUEUE", + "GET DEV QUEUE STATUS", + NULL, + "GET FIRMWARE STATUS", + "GET LOOP ID", + NULL, + "GET RETRY COUNT", + NULL, + NULL, + NULL, + NULL, + NULL, + "GET FIRMWARE OPTIONS", + "GET PORT QUEUE PARAMS", + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + "SET RETRY COUNT", + NULL, + NULL, + NULL, + NULL, + NULL, + "SET FIRMWARE OPTIONS", + "SET PORT QUEUE PARAMS", + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + "LOOP PORT BYPASS", + "LOOP PORT ENABLE", + "GET RESOURCE COUNTS", + "REQUEST NON PARTICIPATING MODE", + NULL, + NULL, + NULL, + "GET PORT DATABASE,, ENHANCED", + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + "EXECUTE IOCB A64", + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + "DRIVER HEARTBEAT", + NULL, + "GET/SET DATA RATE", + NULL, + NULL, + "INIT FIRMWARE", + NULL, + "INIT LIP", + "GET FC-AL POSITION MAP", + "GET PORT DATABASE", + "CLEAR ACA", + "TARGET RESET", + "CLEAR TASK SET", + "ABORT TASK SET", + "GET FW STATE", + "GET PORT NAME", + "GET LINK STATUS", + "INIT LIP RESET", + NULL, + "SEND SNS", + "FABRIC LOGIN", + "SEND CHANGE REQUEST", + "FABRIC LOGOUT", + "INIT LIP LOGIN", + NULL, + "LOGIN LOOP PORT", + "GET PORT/NODE NAME LIST", + "SET VENDOR ID", + "INITIALIZE IP MAILBOX", + NULL, + NULL, + NULL, + NULL, + "Get ID List", + "SEND LFA", + "Lun RESET" +}; +#endif + +static void +isp_mboxcmd_qnw(struct ispsoftc *isp, mbreg_t *mbp, int nodelay) +{ + unsigned int lim, ibits, obits, box, opcode; + u_int16_t *mcp; + + if (IS_FC(isp)) { + mcp = mbpfc; + lim = (sizeof (mbpfc) / sizeof (mbpfc[0])); + } else { + mcp = mbpscsi; + lim = (sizeof (mbpscsi) / sizeof (mbpscsi[0])); + } + opcode = mbp->param[0]; + ibits = HIBYT(mcp[opcode]) & NMBOX_BMASK(isp); + obits = LOBYT(mcp[opcode]) & NMBOX_BMASK(isp); + for (box = 0; box < MAX_MAILBOX; box++) { + if (ibits & (1 << box)) { + ISP_WRITE(isp, MBOX_OFF(box), mbp->param[box]); + } + if (nodelay == 0) { + isp->isp_mboxtmp[box] = mbp->param[box] = 0; + } + } + if (nodelay == 0) { + isp->isp_lastmbxcmd = opcode; + isp->isp_obits = obits; + isp->isp_mboxbsy = 1; + } + ISP_WRITE(isp, HCCR, HCCR_CMD_SET_HOST_INT); + /* + * Oddly enough, if we're not delaying for an answer, + * delay a bit to give the f/w a chance to pick up the + * command. + */ + if (nodelay) { + USEC_DELAY(1000); + } +} + +static void +isp_mboxcmd(struct ispsoftc *isp, mbreg_t *mbp, int logmask) +{ + char *cname, *xname, tname[16], mname[16]; + unsigned int lim, ibits, obits, box, opcode; + u_int16_t *mcp; + + if (IS_FC(isp)) { + mcp = mbpfc; + lim = (sizeof (mbpfc) / sizeof (mbpfc[0])); + } else { + mcp = mbpscsi; + lim = (sizeof (mbpscsi) / sizeof (mbpscsi[0])); + } + + if ((opcode = mbp->param[0]) >= lim) { + mbp->param[0] = MBOX_INVALID_COMMAND; + isp_prt(isp, ISP_LOGERR, "Unknown Command 0x%x", opcode); + return; + } + + ibits = HIBYT(mcp[opcode]) & NMBOX_BMASK(isp); + obits = LOBYT(mcp[opcode]) & NMBOX_BMASK(isp); + + if (ibits == 0 && obits == 0) { + mbp->param[0] = MBOX_COMMAND_PARAM_ERROR; + isp_prt(isp, ISP_LOGERR, "no parameters for 0x%x", opcode); + return; + } + + /* + * Get exclusive usage of mailbox registers. + */ + MBOX_ACQUIRE(isp); + + for (box = 0; box < MAX_MAILBOX; box++) { + if (ibits & (1 << box)) { + ISP_WRITE(isp, MBOX_OFF(box), mbp->param[box]); + } + isp->isp_mboxtmp[box] = mbp->param[box] = 0; + } + + isp->isp_lastmbxcmd = opcode; + + /* + * We assume that we can't overwrite a previous command. + */ + isp->isp_obits = obits; + isp->isp_mboxbsy = 1; + + /* + * Set Host Interrupt condition so that RISC will pick up mailbox regs. + */ + ISP_WRITE(isp, HCCR, HCCR_CMD_SET_HOST_INT); + + /* + * While we haven't finished the command, spin our wheels here. + */ + MBOX_WAIT_COMPLETE(isp); + + if (isp->isp_mboxbsy) { + /* + * Command timed out. + */ + isp->isp_mboxbsy = 0; + MBOX_RELEASE(isp); + return; + } + + /* + * Copy back output registers. + */ + for (box = 0; box < MAX_MAILBOX; box++) { + if (obits & (1 << box)) { + mbp->param[box] = isp->isp_mboxtmp[box]; + } + } + + MBOX_RELEASE(isp); + + if (logmask == 0 || opcode == MBOX_EXEC_FIRMWARE) { + return; + } +#ifdef ISP_STRIPPED + cname = NULL; +#else + cname = (IS_FC(isp))? fc_mbcmd_names[opcode] : scsi_mbcmd_names[opcode]; +#endif + if (cname == NULL) { + cname = tname; + SNPRINTF(tname, sizeof tname, "opcode %x", opcode); + } + + /* + * Just to be chatty here... + */ + xname = NULL; + switch (mbp->param[0]) { + case MBOX_COMMAND_COMPLETE: + break; + case MBOX_INVALID_COMMAND: + if (logmask & MBLOGMASK(MBOX_COMMAND_COMPLETE)) + xname = "INVALID COMMAND"; + break; + case MBOX_HOST_INTERFACE_ERROR: + if (logmask & MBLOGMASK(MBOX_HOST_INTERFACE_ERROR)) + xname = "HOST INTERFACE ERROR"; + break; + case MBOX_TEST_FAILED: + if (logmask & MBLOGMASK(MBOX_TEST_FAILED)) + xname = "TEST FAILED"; + break; + case MBOX_COMMAND_ERROR: + if (logmask & MBLOGMASK(MBOX_COMMAND_ERROR)) + xname = "COMMAND ERROR"; + break; + case MBOX_COMMAND_PARAM_ERROR: + if (logmask & MBLOGMASK(MBOX_COMMAND_PARAM_ERROR)) + xname = "COMMAND PARAMETER ERROR"; + break; + case MBOX_LOOP_ID_USED: + if (logmask & MBLOGMASK(MBOX_LOOP_ID_USED)) + xname = "LOOP ID ALREADY IN USE"; + break; + case MBOX_PORT_ID_USED: + if (logmask & MBLOGMASK(MBOX_PORT_ID_USED)) + xname = "PORT ID ALREADY IN USE"; + break; + case MBOX_ALL_IDS_USED: + if (logmask & MBLOGMASK(MBOX_ALL_IDS_USED)) + xname = "ALL LOOP IDS IN USE"; + break; + case 0: /* special case */ + xname = "TIMEOUT"; + break; + default: + SNPRINTF(mname, sizeof mname, "error 0x%x", mbp->param[0]); + xname = mname; + break; + } + if (xname) + isp_prt(isp, ISP_LOGALL, "Mailbox Command '%s' failed (%s)", + cname, xname); +} + +static void +isp_fw_state(struct ispsoftc *isp) +{ + if (IS_FC(isp)) { + mbreg_t mbs; + fcparam *fcp = isp->isp_param; + + mbs.param[0] = MBOX_GET_FW_STATE; + isp_mboxcmd(isp, &mbs, MBLOGALL); + if (mbs.param[0] == MBOX_COMMAND_COMPLETE) { + fcp->isp_fwstate = mbs.param[1]; + } + } +} + +static void +isp_update(struct ispsoftc *isp) +{ + int bus, upmask; + + for (bus = 0, upmask = isp->isp_update; upmask != 0; bus++) { + if (upmask & (1 << bus)) { + isp_update_bus(isp, bus); + } + upmask &= ~(1 << bus); + } +} + +static void +isp_update_bus(struct ispsoftc *isp, int bus) +{ + int tgt; + mbreg_t mbs; + sdparam *sdp; + + isp->isp_update &= ~(1 << bus); + if (IS_FC(isp)) { + /* + * There are no 'per-bus' settings for Fibre Channel. + */ + return; + } + sdp = isp->isp_param; + sdp += bus; + + for (tgt = 0; tgt < MAX_TARGETS; tgt++) { + u_int16_t flags, period, offset; + int get; + + if (sdp->isp_devparam[tgt].dev_enable == 0) { + sdp->isp_devparam[tgt].dev_update = 0; + sdp->isp_devparam[tgt].dev_refresh = 0; + isp_prt(isp, ISP_LOGDEBUG0, + "skipping target %d bus %d update", tgt, bus); + continue; + } + /* + * If the goal is to update the status of the device, + * take what's in goal_flags and try and set the device + * toward that. Otherwise, if we're just refreshing the + * current device state, get the current parameters. + */ + + /* + * Refresh overrides set + */ + if (sdp->isp_devparam[tgt].dev_refresh) { + mbs.param[0] = MBOX_GET_TARGET_PARAMS; + sdp->isp_devparam[tgt].dev_refresh = 0; + get = 1; + } else if (sdp->isp_devparam[tgt].dev_update) { + mbs.param[0] = MBOX_SET_TARGET_PARAMS; + /* + * Make sure goal_flags has "Renegotiate on Error" + * on and "Freeze Queue on Error" off. + */ + sdp->isp_devparam[tgt].goal_flags |= DPARM_RENEG; + sdp->isp_devparam[tgt].goal_flags &= ~DPARM_QFRZ; + + mbs.param[2] = sdp->isp_devparam[tgt].goal_flags; + + /* + * Insist that PARITY must be enabled + * if SYNC or WIDE is enabled. + */ + if ((mbs.param[2] & (DPARM_SYNC|DPARM_WIDE)) != 0) { + mbs.param[2] |= DPARM_PARITY; + } + + if ((mbs.param[2] & DPARM_SYNC) == 0) { + mbs.param[3] = 0; + } else { + mbs.param[3] = + (sdp->isp_devparam[tgt].goal_offset << 8) | + (sdp->isp_devparam[tgt].goal_period); + } + /* + * A command completion later that has + * RQSTF_NEGOTIATION set can cause + * the dev_refresh/announce cycle also. + * + * Note: It is really important to update our current + * flags with at least the state of TAG capabilities- + * otherwise we might try and send a tagged command + * when we have it all turned off. So change it here + * to say that current already matches goal. + */ + sdp->isp_devparam[tgt].actv_flags &= ~DPARM_TQING; + sdp->isp_devparam[tgt].actv_flags |= + (sdp->isp_devparam[tgt].goal_flags & DPARM_TQING); + isp_prt(isp, ISP_LOGDEBUG0, + "bus %d set tgt %d flags 0x%x off 0x%x period 0x%x", + bus, tgt, mbs.param[2], mbs.param[3] >> 8, + mbs.param[3] & 0xff); + sdp->isp_devparam[tgt].dev_update = 0; + sdp->isp_devparam[tgt].dev_refresh = 1; + get = 0; + } else { + continue; + } + mbs.param[1] = (bus << 15) | (tgt << 8); + isp_mboxcmd(isp, &mbs, MBLOGALL); + if (get == 0) { + isp->isp_sendmarker |= (1 << bus); + continue; + } + flags = mbs.param[2]; + period = mbs.param[3] & 0xff; + offset = mbs.param[3] >> 8; + sdp->isp_devparam[tgt].actv_flags = flags; + sdp->isp_devparam[tgt].actv_period = period; + sdp->isp_devparam[tgt].actv_offset = offset; + get = (bus << 16) | tgt; + (void) isp_async(isp, ISPASYNC_NEW_TGT_PARAMS, &get); + } + + for (tgt = 0; tgt < MAX_TARGETS; tgt++) { + if (sdp->isp_devparam[tgt].dev_update || + sdp->isp_devparam[tgt].dev_refresh) { + isp->isp_update |= (1 << bus); + break; + } + } +} + +#ifndef DEFAULT_FRAMESIZE +#define DEFAULT_FRAMESIZE(isp) ICB_DFLT_FRMLEN +#endif +#ifndef DEFAULT_EXEC_THROTTLE +#define DEFAULT_EXEC_THROTTLE(isp) ISP_EXEC_THROTTLE +#endif + +static void +isp_setdfltparm(struct ispsoftc *isp, int channel) +{ + int tgt; + mbreg_t mbs; + sdparam *sdp; + + if (IS_FC(isp)) { + fcparam *fcp = (fcparam *) isp->isp_param; + int nvfail; + + fcp += channel; + if (fcp->isp_gotdparms) { + return; + } + fcp->isp_gotdparms = 1; + fcp->isp_maxfrmlen = DEFAULT_FRAMESIZE(isp); + fcp->isp_maxalloc = ICB_DFLT_ALLOC; + fcp->isp_execthrottle = DEFAULT_EXEC_THROTTLE(isp); + fcp->isp_retry_delay = ICB_DFLT_RDELAY; + fcp->isp_retry_count = ICB_DFLT_RCOUNT; + /* Platform specific.... */ + fcp->isp_loopid = DEFAULT_LOOPID(isp); + fcp->isp_nodewwn = DEFAULT_NODEWWN(isp); + fcp->isp_portwwn = DEFAULT_PORTWWN(isp); + fcp->isp_fwoptions = 0; + fcp->isp_fwoptions |= ICBOPT_FAIRNESS; + fcp->isp_fwoptions |= ICBOPT_PDBCHANGE_AE; + fcp->isp_fwoptions |= ICBOPT_HARD_ADDRESS; +#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; + + /* + * Make sure this is turned off now until we get + * extended options from NVRAM + */ + fcp->isp_fwoptions &= ~ICBOPT_EXTENDED; + + /* + * Now try and read NVRAM unless told to not do so. + * This will set fcparam's isp_nodewwn && isp_portwwn. + */ + if ((isp->isp_confopts & ISP_CFG_NONVRAM) == 0) { + nvfail = isp_read_nvram(isp); + if (nvfail) + isp->isp_confopts |= ISP_CFG_NONVRAM; + } else { + nvfail = 1; + } + /* + * Set node && port to override platform set defaults + * unless the nvram read failed (or none was done), + * or the platform code wants to use what had been + * set in the defaults. + */ + if (nvfail) { + isp->isp_confopts |= ISP_CFG_OWNWWPN|ISP_CFG_OWNWWNN; + } + if (isp->isp_confopts & ISP_CFG_OWNWWNN) { + isp_prt(isp, ISP_LOGCONFIG, "Using Node WWN 0x%08x%08x", + (u_int32_t) (DEFAULT_NODEWWN(isp) >> 32), + (u_int32_t) (DEFAULT_NODEWWN(isp) & 0xffffffff)); + ISP_NODEWWN(isp) = DEFAULT_NODEWWN(isp); + } else { + /* + * We always start out with values derived + * from NVRAM or our platform default. + */ + ISP_NODEWWN(isp) = fcp->isp_nodewwn; + } + if (isp->isp_confopts & ISP_CFG_OWNWWPN) { + isp_prt(isp, ISP_LOGCONFIG, "Using Port WWN 0x%08x%08x", + (u_int32_t) (DEFAULT_PORTWWN(isp) >> 32), + (u_int32_t) (DEFAULT_PORTWWN(isp) & 0xffffffff)); + ISP_PORTWWN(isp) = DEFAULT_PORTWWN(isp); + } else { + /* + * We always start out with values derived + * from NVRAM or our platform default. + */ + ISP_PORTWWN(isp) = fcp->isp_portwwn; + } + return; + } + + sdp = (sdparam *) isp->isp_param; + sdp += channel; + + /* + * Been there, done that, got the T-shirt... + */ + if (sdp->isp_gotdparms) { + return; + } + sdp->isp_gotdparms = 1; + + /* + * Establish some default parameters. + */ + sdp->isp_cmd_dma_burst_enable = 0; + sdp->isp_data_dma_burst_enabl = 1; + sdp->isp_fifo_threshold = 0; + sdp->isp_initiator_id = DEFAULT_IID(isp); + if (isp->isp_type >= ISP_HA_SCSI_1040) { + sdp->isp_async_data_setup = 9; + } else { + sdp->isp_async_data_setup = 6; + } + sdp->isp_selection_timeout = 250; + sdp->isp_max_queue_depth = MAXISPREQUEST(isp); + sdp->isp_tag_aging = 8; + sdp->isp_bus_reset_delay = 5; + /* + * Don't retry selection, busy or queue full automatically- reflect + * these back to us. + */ + sdp->isp_retry_count = 0; + sdp->isp_retry_delay = 0; + + for (tgt = 0; tgt < MAX_TARGETS; tgt++) { + sdp->isp_devparam[tgt].exc_throttle = ISP_EXEC_THROTTLE; + sdp->isp_devparam[tgt].dev_enable = 1; + } + + /* + * If we've not been told to avoid reading NVRAM, try and read it. + * If we're successful reading it, we can then return because NVRAM + * will tell us what the desired settings are. Otherwise, we establish + * some reasonable 'fake' nvram and goal defaults. + */ + + if ((isp->isp_confopts & ISP_CFG_NONVRAM) == 0) { + if (isp_read_nvram(isp) == 0) { + return; + } + } + + /* + * Now try and see whether we have specific values for them. + */ + if ((isp->isp_confopts & ISP_CFG_NONVRAM) == 0) { + mbs.param[0] = MBOX_GET_ACT_NEG_STATE; + isp_mboxcmd(isp, &mbs, MBLOGNONE); + if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { + sdp->isp_req_ack_active_neg = 1; + sdp->isp_data_line_active_neg = 1; + } else { + sdp->isp_req_ack_active_neg = + (mbs.param[1+channel] >> 4) & 0x1; + sdp->isp_data_line_active_neg = + (mbs.param[1+channel] >> 5) & 0x1; + } + } + + isp_prt(isp, ISP_LOGDEBUG0, sc0, sc3, + 0, sdp->isp_fifo_threshold, sdp->isp_initiator_id, + sdp->isp_bus_reset_delay, sdp->isp_retry_count, + sdp->isp_retry_delay, sdp->isp_async_data_setup); + isp_prt(isp, ISP_LOGDEBUG0, sc1, sc3, + sdp->isp_req_ack_active_neg, sdp->isp_data_line_active_neg, + sdp->isp_data_dma_burst_enabl, sdp->isp_cmd_dma_burst_enable, + sdp->isp_selection_timeout, sdp->isp_max_queue_depth); + + /* + * The trick here is to establish a default for the default (honk!) + * state (goal_flags). Then try and get the current status from + * the card to fill in the current state. We don't, in fact, set + * the default to the SAFE default state- that's not the goal state. + */ + for (tgt = 0; tgt < MAX_TARGETS; tgt++) { + u_int8_t off, per; + sdp->isp_devparam[tgt].actv_offset = 0; + sdp->isp_devparam[tgt].actv_period = 0; + sdp->isp_devparam[tgt].actv_flags = 0; + + sdp->isp_devparam[tgt].goal_flags = + sdp->isp_devparam[tgt].nvrm_flags = DPARM_DEFAULT; + + /* + * We default to Wide/Fast for versions less than a 1040 + * (unless it's SBus). + */ + if (IS_ULTRA3(isp)) { + off = ISP_80M_SYNCPARMS >> 8; + per = ISP_80M_SYNCPARMS & 0xff; + } else if (IS_ULTRA2(isp)) { + off = ISP_40M_SYNCPARMS >> 8; + per = ISP_40M_SYNCPARMS & 0xff; + } else if (IS_1240(isp)) { + off = ISP_20M_SYNCPARMS >> 8; + per = ISP_20M_SYNCPARMS & 0xff; + } else if ((isp->isp_bustype == ISP_BT_SBUS && + isp->isp_type < ISP_HA_SCSI_1020A) || + (isp->isp_bustype == ISP_BT_PCI && + isp->isp_type < ISP_HA_SCSI_1040) || + (isp->isp_clock && isp->isp_clock < 60) || + (sdp->isp_ultramode == 0)) { + off = ISP_10M_SYNCPARMS >> 8; + per = ISP_10M_SYNCPARMS & 0xff; + } else { + off = ISP_20M_SYNCPARMS_1040 >> 8; + per = ISP_20M_SYNCPARMS_1040 & 0xff; + } + sdp->isp_devparam[tgt].goal_offset = + sdp->isp_devparam[tgt].nvrm_offset = off; + sdp->isp_devparam[tgt].goal_period = + sdp->isp_devparam[tgt].nvrm_period = per; + + isp_prt(isp, ISP_LOGDEBUG0, sc2, sc3, + channel, tgt, sdp->isp_devparam[tgt].nvrm_flags, + sdp->isp_devparam[tgt].nvrm_offset, + sdp->isp_devparam[tgt].nvrm_period); + } +} + +/* + * Re-initialize the ISP and complete all orphaned commands + * with a 'botched' notice. The reset/init routines should + * not disturb an already active list of commands. + * + * Locks held prior to coming here. + */ + +void +isp_reinit(struct ispsoftc *isp) +{ + XS_T *xs; + u_int16_t handle; + + isp_reset(isp); + if (isp->isp_state != ISP_RESETSTATE) { + isp_prt(isp, ISP_LOGERR, "isp_reinit cannot reset card"); + } else if (isp->isp_role != ISP_ROLE_NONE) { + isp_init(isp); + if (isp->isp_state == ISP_INITSTATE) { + isp->isp_state = ISP_RUNSTATE; + } + if (isp->isp_state != ISP_RUNSTATE) { + isp_prt(isp, ISP_LOGERR, + "isp_reinit cannot restart card"); + } + } + isp->isp_nactive = 0; + + for (handle = 1; (int) handle <= isp->isp_maxcmds; handle++) { + xs = isp_find_xs(isp, handle); + if (xs == NULL) { + continue; + } + isp_destroy_handle(isp, handle); + if (XS_XFRLEN(xs)) { + ISP_DMAFREE(isp, xs, handle); + XS_RESID(xs) = XS_XFRLEN(xs); + } else { + XS_RESID(xs) = 0; + } + XS_SETERR(xs, HBA_BUSRESET); + isp_done(xs); + } +} + +/* + * NVRAM Routines + */ +static int +isp_read_nvram(struct ispsoftc *isp) +{ + int i, amt; + u_int8_t csum, minversion; + union { + u_int8_t _x[ISP2100_NVRAM_SIZE]; + u_int16_t _s[ISP2100_NVRAM_SIZE>>1]; + } _n; +#define nvram_data _n._x +#define nvram_words _n._s + + if (IS_FC(isp)) { + amt = ISP2100_NVRAM_SIZE; + minversion = 1; + } else if (IS_ULTRA2(isp)) { + amt = ISP1080_NVRAM_SIZE; + minversion = 0; + } else { + amt = ISP_NVRAM_SIZE; + minversion = 2; + } + + /* + * Just read the first two words first to see if we have a valid + * NVRAM to continue reading the rest with. + */ + for (i = 0; i < 2; i++) { + isp_rdnvram_word(isp, i, &nvram_words[i]); + } + if (nvram_data[0] != 'I' || nvram_data[1] != 'S' || + nvram_data[2] != 'P') { + if (isp->isp_bustype != ISP_BT_SBUS) { + isp_prt(isp, ISP_LOGWARN, "invalid NVRAM header"); + isp_prt(isp, ISP_LOGDEBUG0, "%x %x %x", + nvram_data[0], nvram_data[1], nvram_data[2]); + } + return (-1); + } + for (i = 2; i < amt>>1; i++) { + isp_rdnvram_word(isp, i, &nvram_words[i]); + } + for (csum = 0, i = 0; i < amt; i++) { + csum += nvram_data[i]; + } + if (csum != 0) { + isp_prt(isp, ISP_LOGWARN, "invalid NVRAM checksum"); + return (-1); + } + if (ISP_NVRAM_VERSION(nvram_data) < minversion) { + isp_prt(isp, ISP_LOGWARN, "version %d NVRAM not understood", + ISP_NVRAM_VERSION(nvram_data)); + return (-1); + } + + if (IS_ULTRA3(isp)) { + isp_parse_nvram_12160(isp, 0, nvram_data); + if (IS_12160(isp)) + isp_parse_nvram_12160(isp, 1, nvram_data); + } else if (IS_1080(isp)) { + isp_parse_nvram_1080(isp, 0, nvram_data); + } else if (IS_1280(isp) || IS_1240(isp)) { + isp_parse_nvram_1080(isp, 0, nvram_data); + isp_parse_nvram_1080(isp, 1, nvram_data); + } else if (IS_SCSI(isp)) { + isp_parse_nvram_1020(isp, nvram_data); + } else { + isp_parse_nvram_2100(isp, nvram_data); + } + return (0); +#undef nvram_data +#undef nvram_words +} + +static void +isp_rdnvram_word(struct ispsoftc *isp, int wo, u_int16_t *rp) +{ + int i, cbits; + u_int16_t bit, rqst; + + ISP_WRITE(isp, BIU_NVRAM, BIU_NVRAM_SELECT); + USEC_DELAY(2); + ISP_WRITE(isp, BIU_NVRAM, BIU_NVRAM_SELECT|BIU_NVRAM_CLOCK); + USEC_DELAY(2); + + if (IS_FC(isp)) { + wo &= ((ISP2100_NVRAM_SIZE >> 1) - 1); + if (IS_2312(isp) && isp->isp_port) { + wo += 128; + } + rqst = (ISP_NVRAM_READ << 8) | wo; + cbits = 10; + } else if (IS_ULTRA2(isp)) { + wo &= ((ISP1080_NVRAM_SIZE >> 1) - 1); + rqst = (ISP_NVRAM_READ << 8) | wo; + cbits = 10; + } else { + wo &= ((ISP_NVRAM_SIZE >> 1) - 1); + rqst = (ISP_NVRAM_READ << 6) | wo; + cbits = 8; + } + + /* + * Clock the word select request out... + */ + for (i = cbits; i >= 0; i--) { + if ((rqst >> i) & 1) { + bit = BIU_NVRAM_SELECT | BIU_NVRAM_DATAOUT; + } else { + bit = BIU_NVRAM_SELECT; + } + ISP_WRITE(isp, BIU_NVRAM, bit); + USEC_DELAY(2); + ISP_WRITE(isp, BIU_NVRAM, bit | BIU_NVRAM_CLOCK); + USEC_DELAY(2); + ISP_WRITE(isp, BIU_NVRAM, bit); + USEC_DELAY(2); + } + /* + * Now read the result back in (bits come back in MSB format). + */ + *rp = 0; + for (i = 0; i < 16; i++) { + u_int16_t rv; + *rp <<= 1; + ISP_WRITE(isp, BIU_NVRAM, BIU_NVRAM_SELECT|BIU_NVRAM_CLOCK); + USEC_DELAY(2); + rv = ISP_READ(isp, BIU_NVRAM); + if (rv & BIU_NVRAM_DATAIN) { + *rp |= 1; + } + USEC_DELAY(2); + ISP_WRITE(isp, BIU_NVRAM, BIU_NVRAM_SELECT); + USEC_DELAY(2); + } + ISP_WRITE(isp, BIU_NVRAM, 0); + USEC_DELAY(2); + ISP_SWIZZLE_NVRAM_WORD(isp, rp); +} + +static void +isp_parse_nvram_1020(struct ispsoftc *isp, u_int8_t *nvram_data) +{ + sdparam *sdp = (sdparam *) isp->isp_param; + int tgt; + + sdp->isp_fifo_threshold = + ISP_NVRAM_FIFO_THRESHOLD(nvram_data) | + (ISP_NVRAM_FIFO_THRESHOLD_128(nvram_data) << 2); + + if ((isp->isp_confopts & ISP_CFG_OWNLOOPID) == 0) + sdp->isp_initiator_id = + ISP_NVRAM_INITIATOR_ID(nvram_data); + + sdp->isp_bus_reset_delay = + ISP_NVRAM_BUS_RESET_DELAY(nvram_data); + + sdp->isp_retry_count = + ISP_NVRAM_BUS_RETRY_COUNT(nvram_data); + + sdp->isp_retry_delay = + ISP_NVRAM_BUS_RETRY_DELAY(nvram_data); + + sdp->isp_async_data_setup = + ISP_NVRAM_ASYNC_DATA_SETUP_TIME(nvram_data); + + if (isp->isp_type >= ISP_HA_SCSI_1040) { + if (sdp->isp_async_data_setup < 9) { + sdp->isp_async_data_setup = 9; + } + } else { + if (sdp->isp_async_data_setup != 6) { + sdp->isp_async_data_setup = 6; + } + } + + sdp->isp_req_ack_active_neg = + ISP_NVRAM_REQ_ACK_ACTIVE_NEGATION(nvram_data); + + sdp->isp_data_line_active_neg = + ISP_NVRAM_DATA_LINE_ACTIVE_NEGATION(nvram_data); + + sdp->isp_data_dma_burst_enabl = + ISP_NVRAM_DATA_DMA_BURST_ENABLE(nvram_data); + + sdp->isp_cmd_dma_burst_enable = + ISP_NVRAM_CMD_DMA_BURST_ENABLE(nvram_data); + + sdp->isp_tag_aging = + ISP_NVRAM_TAG_AGE_LIMIT(nvram_data); + + sdp->isp_selection_timeout = + ISP_NVRAM_SELECTION_TIMEOUT(nvram_data); + + sdp->isp_max_queue_depth = + ISP_NVRAM_MAX_QUEUE_DEPTH(nvram_data); + + sdp->isp_fast_mttr = ISP_NVRAM_FAST_MTTR_ENABLE(nvram_data); + + isp_prt(isp, ISP_LOGDEBUG0, sc0, sc4, + 0, sdp->isp_fifo_threshold, sdp->isp_initiator_id, + sdp->isp_bus_reset_delay, sdp->isp_retry_count, + sdp->isp_retry_delay, sdp->isp_async_data_setup); + isp_prt(isp, ISP_LOGDEBUG0, sc1, sc4, + sdp->isp_req_ack_active_neg, sdp->isp_data_line_active_neg, + sdp->isp_data_dma_burst_enabl, sdp->isp_cmd_dma_burst_enable, + sdp->isp_selection_timeout, sdp->isp_max_queue_depth); + + for (tgt = 0; tgt < MAX_TARGETS; tgt++) { + sdp->isp_devparam[tgt].dev_enable = + ISP_NVRAM_TGT_DEVICE_ENABLE(nvram_data, tgt); + sdp->isp_devparam[tgt].exc_throttle = + ISP_NVRAM_TGT_EXEC_THROTTLE(nvram_data, tgt); + sdp->isp_devparam[tgt].nvrm_offset = + ISP_NVRAM_TGT_SYNC_OFFSET(nvram_data, tgt); + sdp->isp_devparam[tgt].nvrm_period = + ISP_NVRAM_TGT_SYNC_PERIOD(nvram_data, tgt); + /* + * We probably shouldn't lie about this, but it + * it makes it much safer if we limit NVRAM values + * to sanity. + */ + if (isp->isp_type < ISP_HA_SCSI_1040) { + /* + * If we're not ultra, we can't possibly + * be a shorter period than this. + */ + if (sdp->isp_devparam[tgt].nvrm_period < 0x19) { + sdp->isp_devparam[tgt].nvrm_period = 0x19; + } + if (sdp->isp_devparam[tgt].nvrm_offset > 0xc) { + sdp->isp_devparam[tgt].nvrm_offset = 0x0c; + } + } else { + if (sdp->isp_devparam[tgt].nvrm_offset > 0x8) { + sdp->isp_devparam[tgt].nvrm_offset = 0x8; + } + } + sdp->isp_devparam[tgt].nvrm_flags = 0; + if (ISP_NVRAM_TGT_RENEG(nvram_data, tgt)) + sdp->isp_devparam[tgt].nvrm_flags |= DPARM_RENEG; + sdp->isp_devparam[tgt].nvrm_flags |= DPARM_ARQ; + if (ISP_NVRAM_TGT_TQING(nvram_data, tgt)) + sdp->isp_devparam[tgt].nvrm_flags |= DPARM_TQING; + if (ISP_NVRAM_TGT_SYNC(nvram_data, tgt)) + sdp->isp_devparam[tgt].nvrm_flags |= DPARM_SYNC; + if (ISP_NVRAM_TGT_WIDE(nvram_data, tgt)) + sdp->isp_devparam[tgt].nvrm_flags |= DPARM_WIDE; + if (ISP_NVRAM_TGT_PARITY(nvram_data, tgt)) + sdp->isp_devparam[tgt].nvrm_flags |= DPARM_PARITY; + if (ISP_NVRAM_TGT_DISC(nvram_data, tgt)) + sdp->isp_devparam[tgt].nvrm_flags |= DPARM_DISC; + sdp->isp_devparam[tgt].actv_flags = 0; /* we don't know */ + isp_prt(isp, ISP_LOGDEBUG0, sc2, sc4, + 0, tgt, sdp->isp_devparam[tgt].nvrm_flags, + sdp->isp_devparam[tgt].nvrm_offset, + sdp->isp_devparam[tgt].nvrm_period); + sdp->isp_devparam[tgt].goal_offset = + sdp->isp_devparam[tgt].nvrm_offset; + sdp->isp_devparam[tgt].goal_period = + sdp->isp_devparam[tgt].nvrm_period; + sdp->isp_devparam[tgt].goal_flags = + sdp->isp_devparam[tgt].nvrm_flags; + } +} + +static void +isp_parse_nvram_1080(struct ispsoftc *isp, int bus, u_int8_t *nvram_data) +{ + sdparam *sdp = (sdparam *) isp->isp_param; + int tgt; + + sdp += bus; + + sdp->isp_fifo_threshold = + ISP1080_NVRAM_FIFO_THRESHOLD(nvram_data); + + if ((isp->isp_confopts & ISP_CFG_OWNLOOPID) == 0) + sdp->isp_initiator_id = + ISP1080_NVRAM_INITIATOR_ID(nvram_data, bus); + + sdp->isp_bus_reset_delay = + ISP1080_NVRAM_BUS_RESET_DELAY(nvram_data, bus); + + sdp->isp_retry_count = + ISP1080_NVRAM_BUS_RETRY_COUNT(nvram_data, bus); + + sdp->isp_retry_delay = + ISP1080_NVRAM_BUS_RETRY_DELAY(nvram_data, bus); + + sdp->isp_async_data_setup = + ISP1080_NVRAM_ASYNC_DATA_SETUP_TIME(nvram_data, bus); + + sdp->isp_req_ack_active_neg = + ISP1080_NVRAM_REQ_ACK_ACTIVE_NEGATION(nvram_data, bus); + + sdp->isp_data_line_active_neg = + ISP1080_NVRAM_DATA_LINE_ACTIVE_NEGATION(nvram_data, bus); + + sdp->isp_data_dma_burst_enabl = + ISP1080_NVRAM_BURST_ENABLE(nvram_data); + + sdp->isp_cmd_dma_burst_enable = + ISP1080_NVRAM_BURST_ENABLE(nvram_data); + + sdp->isp_selection_timeout = + ISP1080_NVRAM_SELECTION_TIMEOUT(nvram_data, bus); + + sdp->isp_max_queue_depth = + ISP1080_NVRAM_MAX_QUEUE_DEPTH(nvram_data, bus); + + isp_prt(isp, ISP_LOGDEBUG0, sc0, sc4, + bus, sdp->isp_fifo_threshold, sdp->isp_initiator_id, + sdp->isp_bus_reset_delay, sdp->isp_retry_count, + sdp->isp_retry_delay, sdp->isp_async_data_setup); + isp_prt(isp, ISP_LOGDEBUG0, sc1, sc4, + sdp->isp_req_ack_active_neg, sdp->isp_data_line_active_neg, + sdp->isp_data_dma_burst_enabl, sdp->isp_cmd_dma_burst_enable, + sdp->isp_selection_timeout, sdp->isp_max_queue_depth); + + + for (tgt = 0; tgt < MAX_TARGETS; tgt++) { + sdp->isp_devparam[tgt].dev_enable = + ISP1080_NVRAM_TGT_DEVICE_ENABLE(nvram_data, tgt, bus); + sdp->isp_devparam[tgt].exc_throttle = + ISP1080_NVRAM_TGT_EXEC_THROTTLE(nvram_data, tgt, bus); + sdp->isp_devparam[tgt].nvrm_offset = + ISP1080_NVRAM_TGT_SYNC_OFFSET(nvram_data, tgt, bus); + sdp->isp_devparam[tgt].nvrm_period = + ISP1080_NVRAM_TGT_SYNC_PERIOD(nvram_data, tgt, bus); + sdp->isp_devparam[tgt].nvrm_flags = 0; + if (ISP1080_NVRAM_TGT_RENEG(nvram_data, tgt, bus)) + sdp->isp_devparam[tgt].nvrm_flags |= DPARM_RENEG; + sdp->isp_devparam[tgt].nvrm_flags |= DPARM_ARQ; + if (ISP1080_NVRAM_TGT_TQING(nvram_data, tgt, bus)) + sdp->isp_devparam[tgt].nvrm_flags |= DPARM_TQING; + if (ISP1080_NVRAM_TGT_SYNC(nvram_data, tgt, bus)) + sdp->isp_devparam[tgt].nvrm_flags |= DPARM_SYNC; + if (ISP1080_NVRAM_TGT_WIDE(nvram_data, tgt, bus)) + sdp->isp_devparam[tgt].nvrm_flags |= DPARM_WIDE; + if (ISP1080_NVRAM_TGT_PARITY(nvram_data, tgt, bus)) + sdp->isp_devparam[tgt].nvrm_flags |= DPARM_PARITY; + if (ISP1080_NVRAM_TGT_DISC(nvram_data, tgt, bus)) + sdp->isp_devparam[tgt].nvrm_flags |= DPARM_DISC; + sdp->isp_devparam[tgt].actv_flags = 0; + isp_prt(isp, ISP_LOGDEBUG0, sc2, sc4, + bus, tgt, sdp->isp_devparam[tgt].nvrm_flags, + sdp->isp_devparam[tgt].nvrm_offset, + sdp->isp_devparam[tgt].nvrm_period); + sdp->isp_devparam[tgt].goal_offset = + sdp->isp_devparam[tgt].nvrm_offset; + sdp->isp_devparam[tgt].goal_period = + sdp->isp_devparam[tgt].nvrm_period; + sdp->isp_devparam[tgt].goal_flags = + sdp->isp_devparam[tgt].nvrm_flags; + } +} + +static void +isp_parse_nvram_12160(struct ispsoftc *isp, int bus, u_int8_t *nvram_data) +{ + sdparam *sdp = (sdparam *) isp->isp_param; + int tgt; + + sdp += bus; + + sdp->isp_fifo_threshold = + ISP12160_NVRAM_FIFO_THRESHOLD(nvram_data); + + if ((isp->isp_confopts & ISP_CFG_OWNLOOPID) == 0) + sdp->isp_initiator_id = + ISP12160_NVRAM_INITIATOR_ID(nvram_data, bus); + + sdp->isp_bus_reset_delay = + ISP12160_NVRAM_BUS_RESET_DELAY(nvram_data, bus); + + sdp->isp_retry_count = + ISP12160_NVRAM_BUS_RETRY_COUNT(nvram_data, bus); + + sdp->isp_retry_delay = + ISP12160_NVRAM_BUS_RETRY_DELAY(nvram_data, bus); + + sdp->isp_async_data_setup = + ISP12160_NVRAM_ASYNC_DATA_SETUP_TIME(nvram_data, bus); + + sdp->isp_req_ack_active_neg = + ISP12160_NVRAM_REQ_ACK_ACTIVE_NEGATION(nvram_data, bus); + + sdp->isp_data_line_active_neg = + ISP12160_NVRAM_DATA_LINE_ACTIVE_NEGATION(nvram_data, bus); + + sdp->isp_data_dma_burst_enabl = + ISP12160_NVRAM_BURST_ENABLE(nvram_data); + + sdp->isp_cmd_dma_burst_enable = + ISP12160_NVRAM_BURST_ENABLE(nvram_data); + + sdp->isp_selection_timeout = + ISP12160_NVRAM_SELECTION_TIMEOUT(nvram_data, bus); + + sdp->isp_max_queue_depth = + ISP12160_NVRAM_MAX_QUEUE_DEPTH(nvram_data, bus); + + isp_prt(isp, ISP_LOGDEBUG0, sc0, sc4, + bus, sdp->isp_fifo_threshold, sdp->isp_initiator_id, + sdp->isp_bus_reset_delay, sdp->isp_retry_count, + sdp->isp_retry_delay, sdp->isp_async_data_setup); + isp_prt(isp, ISP_LOGDEBUG0, sc1, sc4, + sdp->isp_req_ack_active_neg, sdp->isp_data_line_active_neg, + sdp->isp_data_dma_burst_enabl, sdp->isp_cmd_dma_burst_enable, + sdp->isp_selection_timeout, sdp->isp_max_queue_depth); + + for (tgt = 0; tgt < MAX_TARGETS; tgt++) { + sdp->isp_devparam[tgt].dev_enable = + ISP12160_NVRAM_TGT_DEVICE_ENABLE(nvram_data, tgt, bus); + sdp->isp_devparam[tgt].exc_throttle = + ISP12160_NVRAM_TGT_EXEC_THROTTLE(nvram_data, tgt, bus); + sdp->isp_devparam[tgt].nvrm_offset = + ISP12160_NVRAM_TGT_SYNC_OFFSET(nvram_data, tgt, bus); + sdp->isp_devparam[tgt].nvrm_period = + ISP12160_NVRAM_TGT_SYNC_PERIOD(nvram_data, tgt, bus); + sdp->isp_devparam[tgt].nvrm_flags = 0; + if (ISP12160_NVRAM_TGT_RENEG(nvram_data, tgt, bus)) + sdp->isp_devparam[tgt].nvrm_flags |= DPARM_RENEG; + sdp->isp_devparam[tgt].nvrm_flags |= DPARM_ARQ; + if (ISP12160_NVRAM_TGT_TQING(nvram_data, tgt, bus)) + sdp->isp_devparam[tgt].nvrm_flags |= DPARM_TQING; + if (ISP12160_NVRAM_TGT_SYNC(nvram_data, tgt, bus)) + sdp->isp_devparam[tgt].nvrm_flags |= DPARM_SYNC; + if (ISP12160_NVRAM_TGT_WIDE(nvram_data, tgt, bus)) + sdp->isp_devparam[tgt].nvrm_flags |= DPARM_WIDE; + if (ISP12160_NVRAM_TGT_PARITY(nvram_data, tgt, bus)) + sdp->isp_devparam[tgt].nvrm_flags |= DPARM_PARITY; + if (ISP12160_NVRAM_TGT_DISC(nvram_data, tgt, bus)) + sdp->isp_devparam[tgt].nvrm_flags |= DPARM_DISC; + sdp->isp_devparam[tgt].actv_flags = 0; + isp_prt(isp, ISP_LOGDEBUG0, sc2, sc4, + bus, tgt, sdp->isp_devparam[tgt].nvrm_flags, + sdp->isp_devparam[tgt].nvrm_offset, + sdp->isp_devparam[tgt].nvrm_period); + sdp->isp_devparam[tgt].goal_offset = + sdp->isp_devparam[tgt].nvrm_offset; + sdp->isp_devparam[tgt].goal_period = + sdp->isp_devparam[tgt].nvrm_period; + sdp->isp_devparam[tgt].goal_flags = + sdp->isp_devparam[tgt].nvrm_flags; + } +} + +static void +isp_parse_nvram_2100(struct ispsoftc *isp, u_int8_t *nvram_data) +{ + fcparam *fcp = (fcparam *) isp->isp_param; + u_int64_t wwn; + + /* + * There is NVRAM storage for both Port and Node entities- + * but the Node entity appears to be unused on all the cards + * I can find. However, we should account for this being set + * at some point in the future. + * + * Qlogic WWNs have an NAA of 2, but usually nothing shows up in + * bits 48..60. In the case of the 2202, it appears that they do + * use bit 48 to distinguish between the two instances on the card. + * The 2204, which I've never seen, *probably* extends this method. + */ + wwn = ISP2100_NVRAM_PORT_NAME(nvram_data); + if (wwn) { + 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); + } + } + fcp->isp_portwwn = wwn; + if (IS_2200(isp) || IS_23XX(isp)) { + wwn = ISP2200_NVRAM_NODE_NAME(nvram_data); + if (wwn) { + isp_prt(isp, ISP_LOGCONFIG, "NVRAM Node WWN 0x%08x%08x", + (u_int32_t) (wwn >> 32), + (u_int32_t) (wwn & 0xffffffff)); + if ((wwn >> 60) == 0) { + wwn |= (((u_int64_t) 2)<< 60); + } + } + } else { + wwn &= ~((u_int64_t) 0xfff << 48); + } + fcp->isp_nodewwn = wwn; + + /* + * Make sure we have both Node and Port as non-zero values. + */ + if (fcp->isp_nodewwn != 0 && fcp->isp_portwwn == 0) { + fcp->isp_portwwn = fcp->isp_nodewwn; + } else if (fcp->isp_nodewwn == 0 && fcp->isp_portwwn != 0) { + fcp->isp_nodewwn = fcp->isp_portwwn; + } + + /* + * Make the Node and Port values sane if they're NAA == 2. + * This means to clear bits 48..56 for the Node WWN and + * make sure that there's some non-zero value in 48..56 + * for the Port WWN. + */ + if (fcp->isp_nodewwn && fcp->isp_portwwn) { + if ((fcp->isp_nodewwn & (((u_int64_t) 0xfff) << 48)) != 0 && + (fcp->isp_nodewwn >> 60) == 2) { + fcp->isp_nodewwn &= ~((u_int64_t) 0xfff << 48); + } + if ((fcp->isp_portwwn & (((u_int64_t) 0xfff) << 48)) == 0 && + (fcp->isp_portwwn >> 60) == 2) { + fcp->isp_portwwn |= ((u_int64_t) 1 << 56); + } + } + + isp_prt(isp, ISP_LOGDEBUG0, + "NVRAM: maxfrmlen %d execthrottle %d fwoptions 0x%x loopid %x", + ISP2100_NVRAM_MAXFRAMELENGTH(nvram_data), + ISP2100_NVRAM_EXECUTION_THROTTLE(nvram_data), + ISP2100_NVRAM_OPTIONS(nvram_data), + ISP2100_NVRAM_HARDLOOPID(nvram_data)); + + fcp->isp_maxalloc = + ISP2100_NVRAM_MAXIOCBALLOCATION(nvram_data); + if ((isp->isp_confopts & ISP_CFG_OWNFSZ) == 0) + fcp->isp_maxfrmlen = + ISP2100_NVRAM_MAXFRAMELENGTH(nvram_data); + fcp->isp_retry_delay = + ISP2100_NVRAM_RETRY_DELAY(nvram_data); + fcp->isp_retry_count = + ISP2100_NVRAM_RETRY_COUNT(nvram_data); + if ((isp->isp_confopts & ISP_CFG_OWNLOOPID) == 0) + fcp->isp_loopid = + ISP2100_NVRAM_HARDLOOPID(nvram_data); + if ((isp->isp_confopts & ISP_CFG_OWNEXCTHROTTLE) == 0) + fcp->isp_execthrottle = + ISP2100_NVRAM_EXECUTION_THROTTLE(nvram_data); + fcp->isp_fwoptions = ISP2100_NVRAM_OPTIONS(nvram_data); +} + +#ifdef ISP_FW_CRASH_DUMP +static void isp2200_fw_dump(struct ispsoftc *); +static void isp2300_fw_dump(struct ispsoftc *); + +static void +isp2200_fw_dump(struct ispsoftc *isp) +{ + int i, j; + mbreg_t mbs; + u_int16_t *ptr; + + ptr = FCPARAM(isp)->isp_dump_data; + if (ptr == NULL) { + isp_prt(isp, ISP_LOGERR, + "No place to dump RISC registers and SRAM"); + return; + } + if (*ptr++) { + isp_prt(isp, ISP_LOGERR, + "dump area for RISC registers and SRAM already used"); + return; + } + ISP_WRITE(isp, HCCR, HCCR_CMD_PAUSE); + for (i = 0; i < 100; i++) { + USEC_DELAY(100); + if (ISP_READ(isp, HCCR) & HCCR_PAUSE) { + break; + } + } + if (ISP_READ(isp, HCCR) & HCCR_PAUSE) { + /* + * PBIU Registers + */ + for (i = 0; i < 8; i++) { + *ptr++ = ISP_READ(isp, BIU_BLOCK + (i << 1)); + } + + /* + * Mailbox Registers + */ + for (i = 0; i < 8; i++) { + *ptr++ = ISP_READ(isp, MBOX_BLOCK + (i << 1)); + } + + /* + * DMA Registers + */ + for (i = 0; i < 48; i++) { + *ptr++ = ISP_READ(isp, DMA_BLOCK + 0x20 + (i << 1)); + } + + /* + * RISC H/W Registers + */ + ISP_WRITE(isp, BIU2100_CSR, 0); + for (i = 0; i < 16; i++) { + *ptr++ = ISP_READ(isp, BIU_BLOCK + 0xA0 + (i << 1)); + } + + /* + * RISC GP Registers + */ + for (j = 0; j < 8; j++) { + ISP_WRITE(isp, BIU_BLOCK + 0xA4, 0x2000 + (j << 8)); + for (i = 0; i < 16; i++) { + *ptr++ = + ISP_READ(isp, BIU_BLOCK + 0x80 + (i << 1)); + } + } + + /* + * Frame Buffer Hardware Registers + */ + ISP_WRITE(isp, BIU2100_CSR, 0x10); + for (i = 0; i < 16; i++) { + *ptr++ = ISP_READ(isp, BIU_BLOCK + 0x80 + (i << 1)); + } + + /* + * Fibre Protocol Module 0 Hardware Registers + */ + ISP_WRITE(isp, BIU2100_CSR, 0x20); + for (i = 0; i < 64; i++) { + *ptr++ = ISP_READ(isp, BIU_BLOCK + 0x80 + (i << 1)); + } + + /* + * Fibre Protocol Module 1 Hardware Registers + */ + ISP_WRITE(isp, BIU2100_CSR, 0x30); + for (i = 0; i < 64; i++) { + *ptr++ = ISP_READ(isp, BIU_BLOCK + 0x80 + (i << 1)); + } + } else { + isp_prt(isp, ISP_LOGERR, "RISC Would Not Pause"); + return; + } + isp_prt(isp, ISP_LOGALL, + "isp_fw_dump: RISC registers dumped successfully"); + ISP_WRITE(isp, BIU2100_CSR, BIU2100_SOFT_RESET); + for (i = 0; i < 100; i++) { + USEC_DELAY(100); + if (ISP_READ(isp, OUTMAILBOX0) == 0) { + break; + } + } + if (ISP_READ(isp, OUTMAILBOX0) != 0) { + isp_prt(isp, ISP_LOGERR, "Board Would Not Reset"); + return; + } + ISP_WRITE(isp, HCCR, HCCR_CMD_PAUSE); + for (i = 0; i < 100; i++) { + USEC_DELAY(100); + if (ISP_READ(isp, HCCR) & HCCR_PAUSE) { + break; + } + } + if ((ISP_READ(isp, HCCR) & HCCR_PAUSE) == 0) { + isp_prt(isp, ISP_LOGERR, "RISC Would Not Pause After Reset"); + return; + } + ISP_WRITE(isp, RISC_EMB, 0xf2); + ISP_WRITE(isp, HCCR, HCCR_CMD_RELEASE); + for (i = 0; i < 100; i++) { + USEC_DELAY(100); + if ((ISP_READ(isp, HCCR) & HCCR_PAUSE) == 0) { + break; + } + } + ENABLE_INTS(isp); + mbs.param[0] = MBOX_READ_RAM_WORD; + mbs.param[1] = 0x1000; + isp->isp_mbxworkp = (void *) ptr; + isp->isp_mbxwrk0 = 0xefff; /* continuation count */ + isp->isp_mbxwrk1 = 0x1001; /* next SRAM address */ + isp_control(isp, ISPCTL_RUN_MBOXCMD, &mbs); + if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { + isp_prt(isp, ISP_LOGWARN, + "RAM DUMP FAILED @ WORD %x", isp->isp_mbxwrk1); + return; + } + ptr = isp->isp_mbxworkp; /* finish fetch of final word */ + *ptr++ = isp->isp_mboxtmp[2]; + isp_prt(isp, ISP_LOGALL, "isp_fw_dump: SRAM dumped succesfully"); + FCPARAM(isp)->isp_dump_data[0] = isp->isp_type; /* now used */ + (void) isp_async(isp, ISPASYNC_FW_DUMPED, 0); +} + +static void +isp2300_fw_dump(struct ispsoftc *isp) +{ + int i, j; + mbreg_t mbs; + u_int16_t *ptr; + + ptr = FCPARAM(isp)->isp_dump_data; + if (ptr == NULL) { + isp_prt(isp, ISP_LOGERR, + "No place to dump RISC registers and SRAM"); + return; + } + if (*ptr++) { + isp_prt(isp, ISP_LOGERR, + "dump area for RISC registers and SRAM already used"); + return; + } + ISP_WRITE(isp, HCCR, HCCR_CMD_PAUSE); + for (i = 0; i < 100; i++) { + USEC_DELAY(100); + if (ISP_READ(isp, HCCR) & HCCR_PAUSE) { + break; + } + } + if (ISP_READ(isp, HCCR) & HCCR_PAUSE) { + /* + * PBIU registers + */ + for (i = 0; i < 8; i++) { + *ptr++ = ISP_READ(isp, BIU_BLOCK + (i << 1)); + } + + /* + * ReqQ-RspQ-Risc2Host Status registers + */ + for (i = 0; i < 8; i++) { + *ptr++ = ISP_READ(isp, BIU_BLOCK + 0x10 + (i << 1)); + } + + /* + * Mailbox Registers + */ + for (i = 0; i < 32; i++) { + *ptr++ = + ISP_READ(isp, PCI_MBOX_REGS2300_OFF + (i << 1)); + } + + /* + * Auto Request Response DMA registers + */ + ISP_WRITE(isp, BIU2100_CSR, 0x40); + for (i = 0; i < 32; i++) { + *ptr++ = ISP_READ(isp, BIU_BLOCK + 0x80 + (i << 1)); + } + + /* + * DMA registers + */ + ISP_WRITE(isp, BIU2100_CSR, 0x50); + for (i = 0; i < 48; i++) { + *ptr++ = ISP_READ(isp, BIU_BLOCK + 0x80 + (i << 1)); + } + + /* + * RISC hardware registers + */ + ISP_WRITE(isp, BIU2100_CSR, 0); + for (i = 0; i < 16; i++) { + *ptr++ = ISP_READ(isp, BIU_BLOCK + 0xA0 + (i << 1)); + } + + /* + * RISC GP? registers + */ + for (j = 0; j < 8; j++) { + ISP_WRITE(isp, BIU_BLOCK + 0xA4, 0x2000 + (j << 9)); + for (i = 0; i < 16; i++) { + *ptr++ = + ISP_READ(isp, BIU_BLOCK + 0x80 + (i << 1)); + } + } + + /* + * frame buffer hardware registers + */ + ISP_WRITE(isp, BIU2100_CSR, 0x10); + for (i = 0; i < 64; i++) { + *ptr++ = ISP_READ(isp, BIU_BLOCK + 0x80 + (i << 1)); + } + + /* + * FPM B0 hardware registers + */ + ISP_WRITE(isp, BIU2100_CSR, 0x20); + for (i = 0; i < 64; i++) { + *ptr++ = ISP_READ(isp, BIU_BLOCK + 0x80 + (i << 1)); + } + + /* + * FPM B1 hardware registers + */ + ISP_WRITE(isp, BIU2100_CSR, 0x30); + for (i = 0; i < 64; i++) { + *ptr++ = ISP_READ(isp, BIU_BLOCK + 0x80 + (i << 1)); + } + } else { + isp_prt(isp, ISP_LOGERR, "RISC Would Not Pause"); + return; + } + isp_prt(isp, ISP_LOGALL, + "isp_fw_dump: RISC registers dumped successfully"); + ISP_WRITE(isp, BIU2100_CSR, BIU2100_SOFT_RESET); + for (i = 0; i < 100; i++) { + USEC_DELAY(100); + if (ISP_READ(isp, OUTMAILBOX0) == 0) { + break; + } + } + if (ISP_READ(isp, OUTMAILBOX0) != 0) { + isp_prt(isp, ISP_LOGERR, "Board Would Not Reset"); + return; + } + ENABLE_INTS(isp); + mbs.param[0] = MBOX_READ_RAM_WORD; + mbs.param[1] = 0x800; + isp->isp_mbxworkp = (void *) ptr; + isp->isp_mbxwrk0 = 0xf7ff; /* continuation count */ + isp->isp_mbxwrk1 = 0x801; /* next SRAM address */ + isp_control(isp, ISPCTL_RUN_MBOXCMD, &mbs); + if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { + isp_prt(isp, ISP_LOGWARN, + "RAM DUMP FAILED @ WORD %x", isp->isp_mbxwrk1); + return; + } + ptr = isp->isp_mbxworkp; /* finish fetch of final word */ + *ptr++ = isp->isp_mboxtmp[2]; + + /* + * We don't have access to mailbox registers 8.. onward + * in our 'common' device model- so we have to set it + * here and hope it stays the same! + */ + ISP_WRITE(isp, PCI_MBOX_REGS2300_OFF + (8 << 1), 0x1); + + mbs.param[0] = MBOX_READ_RAM_WORD_EXTENDED; + mbs.param[1] = 0; + isp->isp_mbxworkp = (void *) ptr; + isp->isp_mbxwrk0 = 0xffff; /* continuation count */ + isp->isp_mbxwrk1 = 0x1; /* next SRAM address */ + isp_control(isp, ISPCTL_RUN_MBOXCMD, &mbs); + if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { + isp_prt(isp, ISP_LOGWARN, + "RAM DUMP FAILED @ WORD %x", 0x10000 + isp->isp_mbxwrk1); + return; + } + ptr = isp->isp_mbxworkp; /* finish final word */ + *ptr++ = mbs.param[2]; + isp_prt(isp, ISP_LOGALL, "isp_fw_dump: SRAM dumped succesfully"); + FCPARAM(isp)->isp_dump_data[0] = isp->isp_type; /* now used */ + (void) isp_async(isp, ISPASYNC_FW_DUMPED, 0); +} + +void +isp_fw_dump(struct ispsoftc *isp) +{ + if (IS_2200(isp)) + isp2200_fw_dump(isp); + else if (IS_23XX(isp)) + isp2300_fw_dump(isp); +} +#endif diff -puN /dev/null drivers/scsi/isp/common/isp_inline.h --- /dev/null 2002-08-30 16:31:37.000000000 -0700 +++ 25-akpm/drivers/scsi/isp/common/isp_inline.h 2003-02-14 00:20:12.000000000 -0800 @@ -0,0 +1,1495 @@ +/* @(#)isp_inline.h 1.19 */ +/* + * Qlogic Host Adapter Inline Functions + * + * Copyright (c) 1999, 2000, 2001 by Matthew Jacob + * Feral Software + * All rights reserved. + * mjacob@feral.com + * + * 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 immediately at the beginning of the file, without modification, + * this list of conditions, and the following disclaimer. + * 2. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * 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. + * + */ +#ifndef _ISP_INLINE_H +#define _ISP_INLINE_H + +/* + * Handle Functions. + * For each outstanding command there will be a non-zero handle. + * There will be at most isp_maxcmds handles, and isp_lasthdls + * will be a seed for the last handled allocated. + */ + +static INLINE int isp_save_xs(struct ispsoftc *, XS_T *, u_int16_t *); +static INLINE XS_T *isp_find_xs(struct ispsoftc *, u_int16_t); +static INLINE u_int16_t isp_find_handle(struct ispsoftc *, XS_T *); +static INLINE int isp_handle_index(u_int16_t); +static INLINE void isp_destroy_handle(struct ispsoftc *, u_int16_t); +static INLINE void isp_remove_handle(struct ispsoftc *, XS_T *); + +static INLINE int +isp_save_xs(struct ispsoftc *isp, XS_T *xs, u_int16_t *handlep) +{ + int i, j; + + for (j = isp->isp_lasthdls, i = 0; i < (int) isp->isp_maxcmds; i++) { + if (isp->isp_xflist[j] == NULL) { + break; + } + if (++j == isp->isp_maxcmds) { + j = 0; + } + } + if (i == isp->isp_maxcmds) { + return (-1); + } + isp->isp_xflist[j] = xs; + *handlep = j+1; + if (++j == isp->isp_maxcmds) + j = 0; + isp->isp_lasthdls = (u_int16_t)j; + return (0); +} + +static INLINE XS_T * +isp_find_xs(struct ispsoftc *isp, u_int16_t handle) +{ + if (handle < 1 || handle > (u_int16_t) isp->isp_maxcmds) { + return (NULL); + } else { + return (isp->isp_xflist[handle - 1]); + } +} + +static INLINE u_int16_t +isp_find_handle(struct ispsoftc *isp, XS_T *xs) +{ + int i; + if (xs != NULL) { + for (i = 0; i < isp->isp_maxcmds; i++) { + if (isp->isp_xflist[i] == xs) { + return ((u_int16_t) i+1); + } + } + } + return (0); +} + +static INLINE int +isp_handle_index(u_int16_t handle) +{ + return (handle-1); +} + +static INLINE void +isp_destroy_handle(struct ispsoftc *isp, u_int16_t handle) +{ + if (handle > 0 && handle <= (u_int16_t) isp->isp_maxcmds) { + isp->isp_xflist[isp_handle_index(handle)] = NULL; + } +} + +static INLINE void +isp_remove_handle(struct ispsoftc *isp, XS_T *xs) +{ + isp_destroy_handle(isp, isp_find_handle(isp, xs)); +} + +static INLINE int +isp_getrqentry(struct ispsoftc *, u_int16_t *, u_int16_t *, void **); + +static INLINE int +isp_getrqentry(struct ispsoftc *isp, u_int16_t *iptrp, + u_int16_t *optrp, void **resultp) +{ + volatile u_int16_t iptr, optr; + + optr = isp->isp_reqodx = READ_REQUEST_QUEUE_OUT_POINTER(isp); + iptr = isp->isp_reqidx; + *resultp = ISP_QUEUE_ENTRY(isp->isp_rquest, iptr); + iptr = ISP_NXT_QENTRY(iptr, RQUEST_QUEUE_LEN(isp)); + if (iptr == optr) { + return (1); + } + if (optrp) + *optrp = optr; + if (iptrp) + *iptrp = iptr; + return (0); +} + +static INLINE void isp_print_qentry (struct ispsoftc *, char *, int, void *); + + +#define TBA (4 * (((QENTRY_LEN >> 2) * 3) + 1) + 1) +static INLINE void +isp_print_qentry(struct ispsoftc *isp, char *msg, int idx, void *arg) +{ + char buf[TBA]; + int amt, i, j; + u_int8_t *ptr = arg; + + isp_prt(isp, ISP_LOGALL, "%s index %d=>", msg, idx); + for (buf[0] = 0, amt = i = 0; i < 4; i++) { + buf[0] = 0; + SNPRINTF(buf, TBA, " "); + for (j = 0; j < (QENTRY_LEN >> 2); j++) { + SNPRINTF(buf, TBA, "%s %02x", buf, ptr[amt++] & 0xff); + } + isp_prt(isp, ISP_LOGALL, buf); + } +} + +static INLINE void isp_print_bytes(struct ispsoftc *, char *, int, void *); + +static INLINE void +isp_print_bytes(struct ispsoftc *isp, char *msg, int amt, void *arg) +{ + char buf[128]; + u_int8_t *ptr = arg; + int off; + + if (msg) + isp_prt(isp, ISP_LOGALL, "%s:", msg); + off = 0; + buf[0] = 0; + while (off < amt) { + int j, to; + to = off; + for (j = 0; j < 16; j++) { + SNPRINTF(buf, 128, "%s %02x", buf, ptr[off++] & 0xff); + if (off == amt) + break; + } + isp_prt(isp, ISP_LOGALL, "0x%08x:%s", to, buf); + buf[0] = 0; + } +} + +/* + * Do the common path to try and ensure that link is up, we've scanned + * the fabric (if we're on a fabric), and that we've synchronized this + * all with our own database and done the appropriate logins. + * + * We repeatedly check for firmware state and loop state after each + * action because things may have changed while we were doing this. + * Any failure or change of state causes us to return a nonzero value. + * + * We honor HBA roles in that if we're not in Initiator mode, we don't + * attempt to sync up the database (that's for somebody else to do, + * if ever). + * + * We assume we enter here with any locks held. + */ + +static INLINE int isp_fc_runstate(struct ispsoftc *, int); + +static INLINE int +isp_fc_runstate(struct ispsoftc *isp, int tval) +{ + fcparam *fcp; + int *tptr; + + if (IS_SCSI(isp)) + return (0); + + tptr = tval? &tval : NULL; + if (isp_control(isp, ISPCTL_FCLINK_TEST, tptr) != 0) { + return (-1); + } + fcp = FCPARAM(isp); + if (fcp->isp_fwstate != FW_READY || fcp->isp_loopstate < LOOP_PDB_RCVD) + return (-1); + if (isp_control(isp, ISPCTL_SCAN_FABRIC, NULL) != 0) { + return (-1); + } + if (isp_control(isp, ISPCTL_SCAN_LOOP, NULL) != 0) { + return (-1); + } + if ((isp->isp_role & ISP_ROLE_INITIATOR) == 0) { + return (0); + } + if (isp_control(isp, ISPCTL_PDB_SYNC, NULL) != 0) { + return (-1); + } + if (fcp->isp_fwstate != FW_READY || fcp->isp_loopstate != LOOP_READY) { + return (-1); + } + return (0); +} + +/* + * Functions to move stuff to a form that the QLogic RISC engine understands + * and functions to move stuff back to a form the processor understands. + * + * Each platform is required to provide the 8, 16 and 32 bit + * swizzle and unswizzle macros (ISP_IOX{PUT|GET}_{8,16,32}) + * + * The assumption is that swizzling and unswizzling is mostly done 'in place' + * (with a few exceptions for efficiency). + */ + +static INLINE void isp_copy_out_hdr(struct ispsoftc *, isphdr_t *, isphdr_t *); +static INLINE void isp_copy_in_hdr(struct ispsoftc *, isphdr_t *, isphdr_t *); +static INLINE int isp_get_response_type(struct ispsoftc *, isphdr_t *); + +static INLINE void +isp_put_request(struct ispsoftc *, ispreq_t *, ispreq_t *); +static INLINE void +isp_put_request_t2(struct ispsoftc *, ispreqt2_t *, ispreqt2_t *); +static INLINE void +isp_put_request_t3(struct ispsoftc *, ispreqt3_t *, ispreqt3_t *); +static INLINE void +isp_put_extended_request(struct ispsoftc *, ispextreq_t *, ispextreq_t *); +static INLINE void +isp_put_cont_req(struct ispsoftc *, ispcontreq_t *, ispcontreq_t *); +static INLINE void +isp_put_cont64_req(struct ispsoftc *, ispcontreq64_t *, ispcontreq64_t *); +static INLINE void +isp_get_response(struct ispsoftc *, ispstatusreq_t *, ispstatusreq_t *); +static INLINE void +isp_get_response_x(struct ispsoftc *, ispstatus_cont_t *, ispstatus_cont_t *); +static INLINE void +isp_get_rio2(struct ispsoftc *, isp_rio2_t *, isp_rio2_t *); +static INLINE void +isp_put_icb(struct ispsoftc *, isp_icb_t *, isp_icb_t *); +static INLINE void +isp_get_pdb(struct ispsoftc *, isp_pdb_t *, isp_pdb_t *); +static INLINE void +isp_get_ct_hdr(struct ispsoftc *isp, ct_hdr_t *, ct_hdr_t *); +static INLINE void +isp_put_sns_request(struct ispsoftc *, sns_screq_t *, sns_screq_t *); +static INLINE void +isp_put_gid_ft_request(struct ispsoftc *, sns_gid_ft_req_t *, + sns_gid_ft_req_t *); +static INLINE void +isp_put_gxn_id_request(struct ispsoftc *, sns_gxn_id_req_t *, + sns_gxn_id_req_t *); +static INLINE void +isp_get_sns_response(struct ispsoftc *, sns_scrsp_t *, sns_scrsp_t *, int); +static INLINE void +isp_get_gid_ft_response(struct ispsoftc *, sns_gid_ft_rsp_t *, + sns_gid_ft_rsp_t *, int); +static INLINE void +isp_get_gxn_id_response(struct ispsoftc *, sns_gxn_id_rsp_t *, + sns_gxn_id_rsp_t *); +static INLINE void +isp_get_gff_id_response(struct ispsoftc *, sns_gff_id_rsp_t *, + sns_gff_id_rsp_t *); +static INLINE void +isp_get_ga_nxt_response(struct ispsoftc *, sns_ga_nxt_rsp_t *, + sns_ga_nxt_rsp_t *); +#ifdef ISP_TARGET_MODE +#ifndef _ISP_TARGET_H +#include "isp_target.h" +#endif +static INLINE void +isp_put_atio(struct ispsoftc *, at_entry_t *, at_entry_t *); +static INLINE void +isp_get_atio(struct ispsoftc *, at_entry_t *, at_entry_t *); +static INLINE void +isp_put_atio2(struct ispsoftc *, at2_entry_t *, at2_entry_t *); +static INLINE void +isp_get_atio2(struct ispsoftc *, at2_entry_t *, at2_entry_t *); +static INLINE void +isp_put_ctio(struct ispsoftc *, ct_entry_t *, ct_entry_t *); +static INLINE void +isp_get_ctio(struct ispsoftc *, ct_entry_t *, ct_entry_t *); +static INLINE void +isp_put_ctio2(struct ispsoftc *, ct2_entry_t *, ct2_entry_t *); +static INLINE void +isp_get_ctio2(struct ispsoftc *, ct2_entry_t *, ct2_entry_t *); +static INLINE void +isp_put_enable_lun(struct ispsoftc *, lun_entry_t *, lun_entry_t *); +static INLINE void +isp_get_enable_lun(struct ispsoftc *, lun_entry_t *, lun_entry_t *); +static INLINE void +isp_put_notify(struct ispsoftc *, in_entry_t *, in_entry_t *); +static INLINE void +isp_get_notify(struct ispsoftc *, in_entry_t *, in_entry_t *); +static INLINE void +isp_put_notify_fc(struct ispsoftc *, in_fcentry_t *, in_fcentry_t *); +static INLINE void +isp_get_notify_fc(struct ispsoftc *, in_fcentry_t *, in_fcentry_t *); +static INLINE void +isp_put_notify_ack(struct ispsoftc *, na_entry_t *, na_entry_t *); +static INLINE void +isp_get_notify_ack(struct ispsoftc *, na_entry_t *, na_entry_t *); +static INLINE void +isp_put_notify_ack_fc(struct ispsoftc *, na_fcentry_t *, na_fcentry_t *); +static INLINE void +isp_get_notify_ack_fc(struct ispsoftc *, na_fcentry_t *, na_fcentry_t *); +#endif + +#define ISP_IS_SBUS(isp) \ + (ISP_SBUS_SUPPORTED && (isp)->isp_bustype == ISP_BT_SBUS) + +/* + * Swizzle/Copy Functions + */ +static INLINE void +isp_copy_out_hdr(struct ispsoftc *isp, isphdr_t *hpsrc, isphdr_t *hpdst) +{ + if (ISP_IS_SBUS(isp)) { + ISP_IOXPUT_8(isp, hpsrc->rqs_entry_type, + &hpdst->rqs_entry_count); + ISP_IOXPUT_8(isp, hpsrc->rqs_entry_count, + &hpdst->rqs_entry_type); + ISP_IOXPUT_8(isp, hpsrc->rqs_seqno, + &hpdst->rqs_flags); + ISP_IOXPUT_8(isp, hpsrc->rqs_flags, + &hpdst->rqs_seqno); + } else { + ISP_IOXPUT_8(isp, hpsrc->rqs_entry_type, + &hpdst->rqs_entry_type); + ISP_IOXPUT_8(isp, hpsrc->rqs_entry_count, + &hpdst->rqs_entry_count); + ISP_IOXPUT_8(isp, hpsrc->rqs_seqno, + &hpdst->rqs_seqno); + ISP_IOXPUT_8(isp, hpsrc->rqs_flags, + &hpdst->rqs_flags); + } +} + +static INLINE void +isp_copy_in_hdr(struct ispsoftc *isp, isphdr_t *hpsrc, isphdr_t *hpdst) +{ + if (ISP_IS_SBUS(isp)) { + ISP_IOXGET_8(isp, &hpsrc->rqs_entry_type, + hpdst->rqs_entry_count); + ISP_IOXGET_8(isp, &hpsrc->rqs_entry_count, + hpdst->rqs_entry_type); + ISP_IOXGET_8(isp, &hpsrc->rqs_seqno, + hpdst->rqs_flags); + ISP_IOXGET_8(isp, &hpsrc->rqs_flags, + hpdst->rqs_seqno); + } else { + ISP_IOXGET_8(isp, &hpsrc->rqs_entry_type, + hpdst->rqs_entry_type); + ISP_IOXGET_8(isp, &hpsrc->rqs_entry_count, + hpdst->rqs_entry_count); + ISP_IOXGET_8(isp, &hpsrc->rqs_seqno, + hpdst->rqs_seqno); + ISP_IOXGET_8(isp, &hpsrc->rqs_flags, + hpdst->rqs_flags); + } +} + +static INLINE int +isp_get_response_type(struct ispsoftc *isp, isphdr_t *hp) +{ + u_int8_t type; + if (ISP_IS_SBUS(isp)) { + ISP_IOXGET_8(isp, &hp->rqs_entry_count, type); + } else { + ISP_IOXGET_8(isp, &hp->rqs_entry_type, type); + } + return ((int)type); +} + +static INLINE void +isp_put_request(struct ispsoftc *isp, ispreq_t *rqsrc, ispreq_t *rqdst) +{ + int i; + isp_copy_out_hdr(isp, &rqsrc->req_header, &rqdst->req_header); + ISP_IOXPUT_32(isp, rqsrc->req_handle, &rqdst->req_handle); + if (ISP_IS_SBUS(isp)) { + ISP_IOXPUT_8(isp, rqsrc->req_lun_trn, &rqdst->req_target); + ISP_IOXPUT_8(isp, rqsrc->req_target, &rqdst->req_lun_trn); + } else { + ISP_IOXPUT_8(isp, rqsrc->req_lun_trn, &rqdst->req_lun_trn); + ISP_IOXPUT_8(isp, rqsrc->req_target, &rqdst->req_target); + } + ISP_IOXPUT_16(isp, rqsrc->req_cdblen, &rqdst->req_cdblen); + ISP_IOXPUT_16(isp, rqsrc->req_flags, &rqdst->req_flags); + ISP_IOXPUT_16(isp, rqsrc->req_time, &rqdst->req_time); + ISP_IOXPUT_16(isp, rqsrc->req_seg_count, &rqdst->req_seg_count); + for (i = 0; i < 12; i++) { + ISP_IOXPUT_8(isp, rqsrc->req_cdb[i], &rqdst->req_cdb[i]); + } + for (i = 0; i < ISP_RQDSEG; i++) { + ISP_IOXPUT_32(isp, rqsrc->req_dataseg[i].ds_base, + &rqdst->req_dataseg[i].ds_base); + ISP_IOXPUT_32(isp, rqsrc->req_dataseg[i].ds_count, + &rqdst->req_dataseg[i].ds_count); + } +} + +static INLINE void +isp_put_request_t2(struct ispsoftc *isp, ispreqt2_t *tqsrc, ispreqt2_t *tqdst) +{ + int i; + isp_copy_out_hdr(isp, &tqsrc->req_header, &tqdst->req_header); + ISP_IOXPUT_32(isp, tqsrc->req_handle, &tqdst->req_handle); + ISP_IOXPUT_8(isp, tqsrc->req_lun_trn, &tqdst->req_lun_trn); + ISP_IOXPUT_8(isp, tqsrc->req_target, &tqdst->req_target); + ISP_IOXPUT_16(isp, tqsrc->req_scclun, &tqdst->req_scclun); + ISP_IOXPUT_16(isp, tqsrc->req_flags, &tqdst->req_flags); + ISP_IOXPUT_16(isp, tqsrc->_res2, &tqdst->_res2); + ISP_IOXPUT_16(isp, tqsrc->req_time, &tqdst->req_time); + ISP_IOXPUT_16(isp, tqsrc->req_seg_count, &tqdst->req_seg_count); + for (i = 0; i < 16; i++) { + ISP_IOXPUT_8(isp, tqsrc->req_cdb[i], &tqdst->req_cdb[i]); + } + ISP_IOXPUT_32(isp, tqsrc->req_totalcnt, &tqdst->req_totalcnt); + for (i = 0; i < ISP_RQDSEG_T2; i++) { + ISP_IOXPUT_32(isp, tqsrc->req_dataseg[i].ds_base, + &tqdst->req_dataseg[i].ds_base); + ISP_IOXPUT_32(isp, tqsrc->req_dataseg[i].ds_count, + &tqdst->req_dataseg[i].ds_count); + } +} + +static INLINE void +isp_put_request_t3(struct ispsoftc *isp, ispreqt3_t *tqsrc, ispreqt3_t *tqdst) +{ + int i; + isp_copy_out_hdr(isp, &tqsrc->req_header, &tqdst->req_header); + ISP_IOXPUT_32(isp, tqsrc->req_handle, &tqdst->req_handle); + ISP_IOXPUT_8(isp, tqsrc->req_lun_trn, &tqdst->req_lun_trn); + ISP_IOXPUT_8(isp, tqsrc->req_target, &tqdst->req_target); + ISP_IOXPUT_16(isp, tqsrc->req_scclun, &tqdst->req_scclun); + ISP_IOXPUT_16(isp, tqsrc->req_flags, &tqdst->req_flags); + ISP_IOXPUT_16(isp, tqsrc->_res2, &tqdst->_res2); + ISP_IOXPUT_16(isp, tqsrc->req_time, &tqdst->req_time); + ISP_IOXPUT_16(isp, tqsrc->req_seg_count, &tqdst->req_seg_count); + for (i = 0; i < 16; i++) { + ISP_IOXPUT_8(isp, tqsrc->req_cdb[i], &tqdst->req_cdb[i]); + } + ISP_IOXPUT_32(isp, tqsrc->req_totalcnt, &tqdst->req_totalcnt); + for (i = 0; i < ISP_RQDSEG_T3; i++) { + ISP_IOXPUT_32(isp, tqsrc->req_dataseg[i].ds_base, + &tqdst->req_dataseg[i].ds_base); + ISP_IOXPUT_32(isp, tqsrc->req_dataseg[i].ds_basehi, + &tqdst->req_dataseg[i].ds_basehi); + ISP_IOXPUT_32(isp, tqsrc->req_dataseg[i].ds_count, + &tqdst->req_dataseg[i].ds_count); + } +} + +static INLINE void +isp_put_extended_request(struct ispsoftc *isp, ispextreq_t *xqsrc, + ispextreq_t *xqdst) +{ + int i; + isp_copy_out_hdr(isp, &xqsrc->req_header, &xqdst->req_header); + ISP_IOXPUT_32(isp, xqsrc->req_handle, &xqdst->req_handle); + if (ISP_IS_SBUS(isp)) { + ISP_IOXPUT_8(isp, xqsrc->req_lun_trn, &xqdst->req_target); + ISP_IOXPUT_8(isp, xqsrc->req_target, &xqdst->req_lun_trn); + } else { + ISP_IOXPUT_8(isp, xqsrc->req_lun_trn, &xqdst->req_lun_trn); + ISP_IOXPUT_8(isp, xqsrc->req_target, &xqdst->req_target); + } + ISP_IOXPUT_16(isp, xqsrc->req_cdblen, &xqdst->req_cdblen); + ISP_IOXPUT_16(isp, xqsrc->req_flags, &xqdst->req_flags); + ISP_IOXPUT_16(isp, xqsrc->req_time, &xqdst->req_time); + ISP_IOXPUT_16(isp, xqsrc->req_seg_count, &xqdst->req_seg_count); + for (i = 0; i < 44; i++) { + ISP_IOXPUT_8(isp, xqsrc->req_cdb[i], &xqdst->req_cdb[i]); + } +} + +static INLINE void +isp_put_cont_req(struct ispsoftc *isp, ispcontreq_t *cqsrc, ispcontreq_t *cqdst) +{ + int i; + isp_copy_out_hdr(isp, &cqsrc->req_header, &cqdst->req_header); + for (i = 0; i < ISP_CDSEG; i++) { + ISP_IOXPUT_32(isp, cqsrc->req_dataseg[i].ds_base, + &cqdst->req_dataseg[i].ds_base); + ISP_IOXPUT_32(isp, cqsrc->req_dataseg[i].ds_count, + &cqdst->req_dataseg[i].ds_count); + } +} + +static INLINE void +isp_put_cont64_req(struct ispsoftc *isp, ispcontreq64_t *cqsrc, + ispcontreq64_t *cqdst) +{ + int i; + isp_copy_out_hdr(isp, &cqsrc->req_header, &cqdst->req_header); + for (i = 0; i < ISP_CDSEG64; i++) { + ISP_IOXPUT_32(isp, cqsrc->req_dataseg[i].ds_base, + &cqdst->req_dataseg[i].ds_base); + ISP_IOXPUT_32(isp, cqsrc->req_dataseg[i].ds_basehi, + &cqdst->req_dataseg[i].ds_basehi); + ISP_IOXPUT_32(isp, cqsrc->req_dataseg[i].ds_count, + &cqdst->req_dataseg[i].ds_count); + } +} + +static INLINE void +isp_get_response(struct ispsoftc *isp, ispstatusreq_t *spsrc, + ispstatusreq_t *spdst) +{ + int i; + isp_copy_in_hdr(isp, &spsrc->req_header, &spdst->req_header); + ISP_IOXGET_32(isp, &spsrc->req_handle, spdst->req_handle); + ISP_IOXGET_16(isp, &spsrc->req_scsi_status, spdst->req_scsi_status); + ISP_IOXGET_16(isp, &spsrc->req_completion_status, + spdst->req_completion_status); + ISP_IOXGET_16(isp, &spsrc->req_state_flags, spdst->req_state_flags); + ISP_IOXGET_16(isp, &spsrc->req_status_flags, spdst->req_status_flags); + ISP_IOXGET_16(isp, &spsrc->req_time, spdst->req_time); + ISP_IOXGET_16(isp, &spsrc->req_sense_len, spdst->req_sense_len); + ISP_IOXGET_32(isp, &spsrc->req_resid, spdst->req_resid); + for (i = 0; i < 8; i++) { + ISP_IOXGET_8(isp, &spsrc->req_response[i], + spdst->req_response[i]); + } + for (i = 0; i < 32; i++) { + ISP_IOXGET_8(isp, &spsrc->req_sense_data[i], + spdst->req_sense_data[i]); + } +} + +static INLINE void +isp_get_response_x(struct ispsoftc *isp, ispstatus_cont_t *cpsrc, + ispstatus_cont_t *cpdst) +{ + int i; + isp_copy_in_hdr(isp, &cpsrc->req_header, &cpdst->req_header); + for (i = 0; i < 60; i++) { + ISP_IOXGET_8(isp, &cpsrc->req_sense_data[i], + cpdst->req_sense_data[i]); + } +} + +static INLINE void +isp_get_rio2(struct ispsoftc *isp, isp_rio2_t *r2src, isp_rio2_t *r2dst) +{ + int i; + isp_copy_in_hdr(isp, &r2src->req_header, &r2dst->req_header); + if (r2dst->req_header.rqs_seqno > 30) + r2dst->req_header.rqs_seqno = 30; + for (i = 0; i < r2dst->req_header.rqs_seqno; i++) { + ISP_IOXGET_16(isp, &r2src->req_handles[i], + r2dst->req_handles[i]); + } + while (i < 30) { + r2dst->req_handles[i++] = 0; + } +} + +static INLINE void +isp_put_icb(struct ispsoftc *isp, isp_icb_t *Is, isp_icb_t *Id) +{ + int i; + ISP_SWAP8(Is->icb_version, Is->_reserved0); + ISP_IOXPUT_8(isp, Is->icb_version, &Id->icb_version); + ISP_IOXPUT_8(isp, Is->_reserved0, &Id->_reserved0); + ISP_IOXPUT_16(isp, Is->icb_fwoptions, &Id->icb_fwoptions); + ISP_IOXPUT_16(isp, Is->icb_maxfrmlen, &Id->icb_maxfrmlen); + ISP_IOXPUT_16(isp, Is->icb_maxalloc, &Id->icb_maxalloc); + ISP_IOXPUT_16(isp, Is->icb_execthrottle, &Id->icb_execthrottle); + ISP_SWAP8(Is->icb_retry_count, Is->icb_retry_delay); + ISP_IOXPUT_8(isp, Is->icb_retry_count, &Id->icb_retry_count); + ISP_IOXPUT_8(isp, Is->icb_retry_delay, &Id->icb_retry_delay); + for (i = 0; i < 8; i++) { + ISP_IOXPUT_8(isp, Is->icb_portname[i], &Id->icb_portname[i]); + } + ISP_IOXPUT_16(isp, Is->icb_hardaddr, &Id->icb_hardaddr); + ISP_SWAP8(Is->icb_iqdevtype, Is->icb_logintime); + ISP_IOXPUT_8(isp, Is->icb_iqdevtype, &Id->icb_iqdevtype); + ISP_IOXPUT_8(isp, Is->icb_logintime, &Id->icb_logintime); + for (i = 0; i < 8; i++) { + ISP_IOXPUT_8(isp, Is->icb_nodename[i], &Id->icb_nodename[i]); + } + ISP_IOXPUT_16(isp, Is->icb_rqstout, &Id->icb_rqstout); + ISP_IOXPUT_16(isp, Is->icb_rspnsin, &Id->icb_rspnsin); + ISP_IOXPUT_16(isp, Is->icb_rqstqlen, &Id->icb_rqstqlen); + ISP_IOXPUT_16(isp, Is->icb_rsltqlen, &Id->icb_rsltqlen); + for (i = 0; i < 4; i++) { + ISP_IOXPUT_16(isp, Is->icb_rqstaddr[i], &Id->icb_rqstaddr[i]); + } + for (i = 0; i < 4; i++) { + ISP_IOXPUT_16(isp, Is->icb_respaddr[i], &Id->icb_respaddr[i]); + } + ISP_IOXPUT_16(isp, Is->icb_lunenables, &Id->icb_lunenables); + ISP_SWAP8(Is->icb_ccnt, Is->icb_icnt); + ISP_IOXPUT_8(isp, Is->icb_ccnt, &Id->icb_ccnt); + ISP_IOXPUT_8(isp, Is->icb_icnt, &Id->icb_icnt); + ISP_IOXPUT_16(isp, Is->icb_lunetimeout, &Id->icb_lunetimeout); + ISP_IOXPUT_16(isp, Is->icb_xfwoptions, &Id->icb_xfwoptions); + ISP_SWAP8(Is->icb_racctimer, Is->icb_idelaytimer); + ISP_IOXPUT_8(isp, Is->icb_racctimer, &Id->icb_racctimer); + ISP_IOXPUT_8(isp, Is->icb_idelaytimer, &Id->icb_idelaytimer); + ISP_IOXPUT_16(isp, Is->icb_zfwoptions, &Id->icb_zfwoptions); +} + +static INLINE void +isp_get_pdb(struct ispsoftc *isp, isp_pdb_t *src, isp_pdb_t *dst) +{ + int i; + ISP_IOXGET_16(isp, &src->pdb_options, dst->pdb_options); + ISP_IOXGET_8(isp, &src->pdb_mstate, dst->pdb_mstate); + ISP_IOXGET_8(isp, &src->pdb_sstate, dst->pdb_sstate); + for (i = 0; i < 4; i++) { + ISP_IOXGET_8(isp, &src->pdb_hardaddr_bits[i], + dst->pdb_hardaddr_bits[i]); + } + for (i = 0; i < 4; i++) { + ISP_IOXGET_8(isp, &src->pdb_portid_bits[i], + dst->pdb_portid_bits[i]); + } + for (i = 0; i < 8; i++) { + ISP_IOXGET_8(isp, &src->pdb_nodename[i], dst->pdb_nodename[i]); + } + for (i = 0; i < 8; i++) { + ISP_IOXGET_8(isp, &src->pdb_portname[i], dst->pdb_portname[i]); + } + ISP_IOXGET_16(isp, &src->pdb_execthrottle, dst->pdb_execthrottle); + ISP_IOXGET_16(isp, &src->pdb_exec_count, dst->pdb_exec_count); + ISP_IOXGET_8(isp, &src->pdb_retry_count, dst->pdb_retry_count); + ISP_IOXGET_8(isp, &src->pdb_retry_delay, dst->pdb_retry_delay); + ISP_IOXGET_16(isp, &src->pdb_resalloc, dst->pdb_resalloc); + ISP_IOXGET_16(isp, &src->pdb_curalloc, dst->pdb_curalloc); + ISP_IOXGET_16(isp, &src->pdb_qhead, dst->pdb_qhead); + ISP_IOXGET_16(isp, &src->pdb_qtail, dst->pdb_qtail); + ISP_IOXGET_16(isp, &src->pdb_tl_next, dst->pdb_tl_next); + ISP_IOXGET_16(isp, &src->pdb_tl_last, dst->pdb_tl_last); + ISP_IOXGET_16(isp, &src->pdb_features, dst->pdb_features); + ISP_IOXGET_16(isp, &src->pdb_pconcurrnt, dst->pdb_pconcurrnt); + ISP_IOXGET_16(isp, &src->pdb_roi, dst->pdb_roi); + ISP_IOXGET_8(isp, &src->pdb_target, dst->pdb_target); + ISP_IOXGET_8(isp, &src->pdb_initiator, dst->pdb_initiator); + ISP_IOXGET_16(isp, &src->pdb_rdsiz, dst->pdb_rdsiz); + ISP_IOXGET_16(isp, &src->pdb_ncseq, dst->pdb_ncseq); + ISP_IOXGET_16(isp, &src->pdb_noseq, dst->pdb_noseq); + ISP_IOXGET_16(isp, &src->pdb_labrtflg, dst->pdb_labrtflg); + ISP_IOXGET_16(isp, &src->pdb_lstopflg, dst->pdb_lstopflg); + ISP_IOXGET_16(isp, &src->pdb_sqhead, dst->pdb_sqhead); + ISP_IOXGET_16(isp, &src->pdb_sqtail, dst->pdb_sqtail); + ISP_IOXGET_16(isp, &src->pdb_ptimer, dst->pdb_ptimer); + ISP_IOXGET_16(isp, &src->pdb_nxt_seqid, dst->pdb_nxt_seqid); + ISP_IOXGET_16(isp, &src->pdb_fcount, dst->pdb_fcount); + ISP_IOXGET_16(isp, &src->pdb_prli_len, dst->pdb_prli_len); + ISP_IOXGET_16(isp, &src->pdb_prli_svc0, dst->pdb_prli_svc0); + ISP_IOXGET_16(isp, &src->pdb_prli_svc3, dst->pdb_prli_svc3); + ISP_IOXGET_16(isp, &src->pdb_loopid, dst->pdb_loopid); + ISP_IOXGET_16(isp, &src->pdb_il_ptr, dst->pdb_il_ptr); + ISP_IOXGET_16(isp, &src->pdb_sl_ptr, dst->pdb_sl_ptr); +} + + +/* + * CT_HDR canonicalization- only needed for SNS responses + */ +static INLINE void +isp_get_ct_hdr(struct ispsoftc *isp, ct_hdr_t *src, ct_hdr_t *dst) +{ + ISP_IOXGET_8(isp, &src->ct_revision, dst->ct_revision); + ISP_IOXGET_8(isp, &src->ct_portid[0], dst->ct_portid[0]); + ISP_IOXGET_8(isp, &src->ct_portid[1], dst->ct_portid[1]); + ISP_IOXGET_8(isp, &src->ct_portid[2], dst->ct_portid[2]); + ISP_IOXGET_8(isp, &src->ct_fcs_type, dst->ct_fcs_type); + ISP_IOXGET_8(isp, &src->ct_fcs_subtype, dst->ct_fcs_subtype); + ISP_IOXGET_8(isp, &src->ct_options, dst->ct_options); + ISP_IOXGET_8(isp, &src->ct_res0, dst->ct_res0); + ISP_IOXGET_16(isp, &src->ct_response, dst->ct_response); + dst->ct_response = (dst->ct_response << 8) | (dst->ct_response >> 8); + ISP_IOXGET_16(isp, &src->ct_resid, dst->ct_resid); + dst->ct_resid = (dst->ct_resid << 8) | (dst->ct_resid >> 8); + ISP_IOXGET_8(isp, &src->ct_res1, dst->ct_res1); + ISP_IOXGET_8(isp, &src->ct_reason, dst->ct_reason); + ISP_IOXGET_8(isp, &src->ct_explanation, dst->ct_explanation); + ISP_IOXGET_8(isp, &src->ct_vunique, dst->ct_vunique); +} + +/* + * Generic SNS request - not particularly useful since the per-command data + * isn't always 16 bit words. + */ +static INLINE void +isp_put_sns_request(struct ispsoftc *isp, sns_screq_t *src, sns_screq_t *dst) +{ + int i, nw = (int) src->snscb_sblen; + ISP_IOXPUT_16(isp, src->snscb_rblen, &dst->snscb_rblen); + for (i = 0; i < 4; i++) { + ISP_IOXPUT_16(isp, src->snscb_addr[i], &dst->snscb_addr[i]); + } + ISP_IOXPUT_16(isp, src->snscb_sblen, &dst->snscb_sblen); + for (i = 0; i < nw; i++) { + ISP_IOXPUT_16(isp, src->snscb_data[i], &dst->snscb_data[i]); + } + +} + +static INLINE void +isp_put_gid_ft_request(struct ispsoftc *isp, sns_gid_ft_req_t *src, + sns_gid_ft_req_t *dst) +{ + ISP_IOXPUT_16(isp, src->snscb_rblen, &dst->snscb_rblen); + ISP_IOXPUT_16(isp, src->snscb_res0, &dst->snscb_res0); + ISP_IOXPUT_16(isp, src->snscb_addr[0], &dst->snscb_addr[0]); + ISP_IOXPUT_16(isp, src->snscb_addr[1], &dst->snscb_addr[1]); + ISP_IOXPUT_16(isp, src->snscb_addr[2], &dst->snscb_addr[2]); + ISP_IOXPUT_16(isp, src->snscb_addr[3], &dst->snscb_addr[3]); + ISP_IOXPUT_16(isp, src->snscb_sblen, &dst->snscb_sblen); + ISP_IOXPUT_16(isp, src->snscb_res1, &dst->snscb_res1); + ISP_IOXPUT_16(isp, src->snscb_cmd, &dst->snscb_cmd); + ISP_IOXPUT_16(isp, src->snscb_mword_div_2, &dst->snscb_mword_div_2); + ISP_IOXPUT_32(isp, src->snscb_res3, &dst->snscb_res3); + ISP_IOXPUT_32(isp, src->snscb_fc4_type, &dst->snscb_fc4_type); +} + +static INLINE void +isp_put_gxn_id_request(struct ispsoftc *isp, sns_gxn_id_req_t *src, + sns_gxn_id_req_t *dst) +{ + ISP_IOXPUT_16(isp, src->snscb_rblen, &dst->snscb_rblen); + ISP_IOXPUT_16(isp, src->snscb_res0, &dst->snscb_res0); + ISP_IOXPUT_16(isp, src->snscb_addr[0], &dst->snscb_addr[0]); + ISP_IOXPUT_16(isp, src->snscb_addr[1], &dst->snscb_addr[1]); + ISP_IOXPUT_16(isp, src->snscb_addr[2], &dst->snscb_addr[2]); + ISP_IOXPUT_16(isp, src->snscb_addr[3], &dst->snscb_addr[3]); + ISP_IOXPUT_16(isp, src->snscb_sblen, &dst->snscb_sblen); + ISP_IOXPUT_16(isp, src->snscb_res1, &dst->snscb_res1); + ISP_IOXPUT_16(isp, src->snscb_cmd, &dst->snscb_cmd); + ISP_IOXPUT_16(isp, src->snscb_res2, &dst->snscb_res2); + ISP_IOXPUT_32(isp, src->snscb_res3, &dst->snscb_res3); + ISP_IOXPUT_32(isp, src->snscb_portid, &dst->snscb_portid); +} + +/* + * Generic SNS response - not particularly useful since the per-command data + * isn't always 16 bit words. + */ +static INLINE void +isp_get_sns_response(struct ispsoftc *isp, sns_scrsp_t *src, + sns_scrsp_t *dst, int nwords) +{ + int i; + isp_get_ct_hdr(isp, &src->snscb_cthdr, &dst->snscb_cthdr); + ISP_IOXGET_8(isp, &src->snscb_port_type, dst->snscb_port_type); + for (i = 0; i < 3; i++) { + ISP_IOXGET_8(isp, &src->snscb_port_id[i], + dst->snscb_port_id[i]); + } + for (i = 0; i < 8; i++) { + ISP_IOXGET_8(isp, &src->snscb_portname[i], + dst->snscb_portname[i]); + } + for (i = 0; i < nwords; i++) { + ISP_IOXGET_16(isp, &src->snscb_data[i], dst->snscb_data[i]); + } +} + +static INLINE void +isp_get_gid_ft_response(struct ispsoftc *isp, sns_gid_ft_rsp_t *src, + sns_gid_ft_rsp_t *dst, int nwords) +{ + int i; + isp_get_ct_hdr(isp, &src->snscb_cthdr, &dst->snscb_cthdr); + for (i = 0; i < nwords; i++) { + int j; + ISP_IOXGET_8(isp, + &src->snscb_ports[i].control, + dst->snscb_ports[i].control); + for (j = 0; j < 3; j++) { + ISP_IOXGET_8(isp, + &src->snscb_ports[i].portid[j], + dst->snscb_ports[i].portid[j]); + } + if (dst->snscb_ports[i].control & 0x80) { + break; + } + } +} + +static INLINE void +isp_get_gxn_id_response(struct ispsoftc *isp, sns_gxn_id_rsp_t *src, + sns_gxn_id_rsp_t *dst) +{ + int i; + isp_get_ct_hdr(isp, &src->snscb_cthdr, &dst->snscb_cthdr); + for (i = 0; i < 8; i++) + ISP_IOXGET_8(isp, &src->snscb_wwn[i], dst->snscb_wwn[i]); +} + +static INLINE void +isp_get_gff_id_response(struct ispsoftc *isp, sns_gff_id_rsp_t *src, + sns_gff_id_rsp_t *dst) +{ + int i; + isp_get_ct_hdr(isp, &src->snscb_cthdr, &dst->snscb_cthdr); + for (i = 0; i < 32; i++) { + ISP_IOXGET_32(isp, &src->snscb_fc4_features[i], + dst->snscb_fc4_features[i]); + } +} + +static INLINE void +isp_get_ga_nxt_response(struct ispsoftc *isp, sns_ga_nxt_rsp_t *src, + sns_ga_nxt_rsp_t *dst) +{ + int i; + isp_get_ct_hdr(isp, &src->snscb_cthdr, &dst->snscb_cthdr); + ISP_IOXGET_8(isp, &src->snscb_port_type, dst->snscb_port_type); + for (i = 0; i < 3; i++) { + ISP_IOXGET_8(isp, &src->snscb_port_id[i], + dst->snscb_port_id[i]); + } + for (i = 0; i < 8; i++) { + ISP_IOXGET_8(isp, &src->snscb_portname[i], + dst->snscb_portname[i]); + } + ISP_IOXGET_8(isp, &src->snscb_pnlen, dst->snscb_pnlen); + for (i = 0; i < 255; i++) { + ISP_IOXGET_8(isp, &src->snscb_pname[i], dst->snscb_pname[i]); + } + for (i = 0; i < 8; i++) { + ISP_IOXGET_8(isp, &src->snscb_nodename[i], + dst->snscb_nodename[i]); + } + ISP_IOXGET_8(isp, &src->snscb_nnlen, dst->snscb_nnlen); + for (i = 0; i < 255; i++) { + ISP_IOXGET_8(isp, &src->snscb_nname[i], dst->snscb_nname[i]); + } + for (i = 0; i < 8; i++) { + ISP_IOXGET_8(isp, &src->snscb_ipassoc[i], + dst->snscb_ipassoc[i]); + } + for (i = 0; i < 16; i++) { + ISP_IOXGET_8(isp, &src->snscb_ipaddr[i], dst->snscb_ipaddr[i]); + } + for (i = 0; i < 4; i++) { + ISP_IOXGET_8(isp, &src->snscb_svc_class[i], + dst->snscb_svc_class[i]); + } + for (i = 0; i < 32; i++) { + ISP_IOXGET_8(isp, &src->snscb_fc4_types[i], + dst->snscb_fc4_types[i]); + } + for (i = 0; i < 8; i++) { + ISP_IOXGET_8(isp, &src->snscb_fpname[i], dst->snscb_fpname[i]); + } + ISP_IOXGET_8(isp, &src->snscb_reserved, dst->snscb_reserved); + for (i = 0; i < 3; i++) { + ISP_IOXGET_8(isp, &src->snscb_hardaddr[i], + dst->snscb_hardaddr[i]); + } +} + +#ifdef ISP_TARGET_MODE +static INLINE void +isp_put_atio(struct ispsoftc *isp, at_entry_t *atsrc, at_entry_t *atdst) +{ + int i; + isp_copy_out_hdr(isp, &atsrc->at_header, &atdst->at_header); + ISP_IOXPUT_16(isp, atsrc->at_reserved, &atdst->at_reserved); + ISP_IOXPUT_16(isp, atsrc->at_handle, &atdst->at_handle); + if (ISP_IS_SBUS(isp)) { + ISP_IOXPUT_8(isp, atsrc->at_lun, &atdst->at_iid); + ISP_IOXPUT_8(isp, atsrc->at_iid, &atdst->at_lun); + ISP_IOXPUT_8(isp, atsrc->at_cdblen, &atdst->at_tgt); + ISP_IOXPUT_8(isp, atsrc->at_tgt, &atdst->at_cdblen); + ISP_IOXPUT_8(isp, atsrc->at_status, &atdst->at_scsi_status); + ISP_IOXPUT_8(isp, atsrc->at_scsi_status, &atdst->at_status); + ISP_IOXPUT_8(isp, atsrc->at_tag_val, &atdst->at_tag_type); + ISP_IOXPUT_8(isp, atsrc->at_tag_type, &atdst->at_tag_val); + } else { + ISP_IOXPUT_8(isp, atsrc->at_lun, &atdst->at_lun); + ISP_IOXPUT_8(isp, atsrc->at_iid, &atdst->at_iid); + ISP_IOXPUT_8(isp, atsrc->at_cdblen, &atdst->at_cdblen); + ISP_IOXPUT_8(isp, atsrc->at_tgt, &atdst->at_tgt); + ISP_IOXPUT_8(isp, atsrc->at_status, &atdst->at_status); + ISP_IOXPUT_8(isp, atsrc->at_scsi_status, + &atdst->at_scsi_status); + ISP_IOXPUT_8(isp, atsrc->at_tag_val, &atdst->at_tag_val); + ISP_IOXPUT_8(isp, atsrc->at_tag_type, &atdst->at_tag_type); + } + ISP_IOXPUT_32(isp, atsrc->at_flags, &atdst->at_flags); + for (i = 0; i < ATIO_CDBLEN; i++) { + ISP_IOXPUT_8(isp, atsrc->at_cdb[i], &atdst->at_cdb[i]); + } + for (i = 0; i < QLTM_SENSELEN; i++) { + ISP_IOXPUT_8(isp, atsrc->at_sense[i], &atdst->at_sense[i]); + } +} + +static INLINE void +isp_get_atio(struct ispsoftc *isp, at_entry_t *atsrc, at_entry_t *atdst) +{ + int i; + isp_copy_in_hdr(isp, &atsrc->at_header, &atdst->at_header); + ISP_IOXGET_16(isp, &atsrc->at_reserved, atdst->at_reserved); + ISP_IOXGET_16(isp, &atsrc->at_handle, atdst->at_handle); + if (ISP_IS_SBUS(isp)) { + ISP_IOXGET_8(isp, &atsrc->at_lun, atdst->at_iid); + ISP_IOXGET_8(isp, &atsrc->at_iid, atdst->at_lun); + ISP_IOXGET_8(isp, &atsrc->at_cdblen, atdst->at_tgt); + ISP_IOXGET_8(isp, &atsrc->at_tgt, atdst->at_cdblen); + ISP_IOXGET_8(isp, &atsrc->at_status, atdst->at_scsi_status); + ISP_IOXGET_8(isp, &atsrc->at_scsi_status, atdst->at_status); + ISP_IOXGET_8(isp, &atsrc->at_tag_val, atdst->at_tag_type); + ISP_IOXGET_8(isp, &atsrc->at_tag_type, atdst->at_tag_val); + } else { + ISP_IOXGET_8(isp, &atsrc->at_lun, atdst->at_lun); + ISP_IOXGET_8(isp, &atsrc->at_iid, atdst->at_iid); + ISP_IOXGET_8(isp, &atsrc->at_cdblen, atdst->at_cdblen); + ISP_IOXGET_8(isp, &atsrc->at_tgt, atdst->at_tgt); + ISP_IOXGET_8(isp, &atsrc->at_status, atdst->at_status); + ISP_IOXGET_8(isp, &atsrc->at_scsi_status, + atdst->at_scsi_status); + ISP_IOXGET_8(isp, &atsrc->at_tag_val, atdst->at_tag_val); + ISP_IOXGET_8(isp, &atsrc->at_tag_type, atdst->at_tag_type); + } + ISP_IOXGET_32(isp, &atsrc->at_flags, atdst->at_flags); + for (i = 0; i < ATIO_CDBLEN; i++) { + ISP_IOXGET_8(isp, &atsrc->at_cdb[i], atdst->at_cdb[i]); + } + for (i = 0; i < QLTM_SENSELEN; i++) { + ISP_IOXGET_8(isp, &atsrc->at_sense[i], atdst->at_sense[i]); + } +} + +static INLINE void +isp_put_atio2(struct ispsoftc *isp, at2_entry_t *atsrc, at2_entry_t *atdst) +{ + int i; + isp_copy_out_hdr(isp, &atsrc->at_header, &atdst->at_header); + ISP_IOXPUT_32(isp, atsrc->at_reserved, &atdst->at_reserved); + ISP_IOXPUT_8(isp, atsrc->at_lun, &atdst->at_lun); + ISP_IOXPUT_8(isp, atsrc->at_iid, &atdst->at_iid); + ISP_IOXPUT_16(isp, atsrc->at_rxid, &atdst->at_rxid); + ISP_IOXPUT_16(isp, atsrc->at_flags, &atdst->at_flags); + ISP_IOXPUT_16(isp, atsrc->at_status, &atdst->at_status); + ISP_IOXPUT_8(isp, atsrc->at_reserved1, &atdst->at_reserved1); + ISP_IOXPUT_8(isp, atsrc->at_taskcodes, &atdst->at_taskcodes); + ISP_IOXPUT_8(isp, atsrc->at_taskflags, &atdst->at_taskflags); + ISP_IOXPUT_8(isp, atsrc->at_execodes, &atdst->at_execodes); + for (i = 0; i < ATIO2_CDBLEN; i++) { + ISP_IOXPUT_8(isp, atsrc->at_cdb[i], &atdst->at_cdb[i]); + } + ISP_IOXPUT_32(isp, atsrc->at_datalen, &atdst->at_datalen); + ISP_IOXPUT_16(isp, atsrc->at_scclun, &atdst->at_scclun); + for (i = 0; i < 4; i++) { + ISP_IOXPUT_16(isp, atsrc->at_wwpn[i], &atdst->at_wwpn[i]); + } + for (i = 0; i < 6; i++) { + ISP_IOXPUT_16(isp, atsrc->at_reserved2[i], + &atdst->at_reserved2[i]); + } + ISP_IOXPUT_16(isp, atsrc->at_oxid, &atdst->at_oxid); +} + +static INLINE void +isp_get_atio2(struct ispsoftc *isp, at2_entry_t *atsrc, at2_entry_t *atdst) +{ + int i; + isp_copy_in_hdr(isp, &atsrc->at_header, &atdst->at_header); + ISP_IOXGET_32(isp, &atsrc->at_reserved, atdst->at_reserved); + ISP_IOXGET_8(isp, &atsrc->at_lun, atdst->at_lun); + ISP_IOXGET_8(isp, &atsrc->at_iid, atdst->at_iid); + ISP_IOXGET_16(isp, &atsrc->at_rxid, atdst->at_rxid); + ISP_IOXGET_16(isp, &atsrc->at_flags, atdst->at_flags); + ISP_IOXGET_16(isp, &atsrc->at_status, atdst->at_status); + ISP_IOXGET_8(isp, &atsrc->at_reserved1, atdst->at_reserved1); + ISP_IOXGET_8(isp, &atsrc->at_taskcodes, atdst->at_taskcodes); + ISP_IOXGET_8(isp, &atsrc->at_taskflags, atdst->at_taskflags); + ISP_IOXGET_8(isp, &atsrc->at_execodes, atdst->at_execodes); + for (i = 0; i < ATIO2_CDBLEN; i++) { + ISP_IOXGET_8(isp, &atsrc->at_cdb[i], atdst->at_cdb[i]); + } + ISP_IOXGET_32(isp, &atsrc->at_datalen, atdst->at_datalen); + ISP_IOXGET_16(isp, &atsrc->at_scclun, atdst->at_scclun); + for (i = 0; i < 4; i++) { + ISP_IOXGET_16(isp, &atsrc->at_wwpn[i], atdst->at_wwpn[i]); + } + for (i = 0; i < 6; i++) { + ISP_IOXGET_16(isp, &atsrc->at_reserved2[i], + atdst->at_reserved2[i]); + } + ISP_IOXGET_16(isp, &atsrc->at_oxid, atdst->at_oxid); +} + +static INLINE void +isp_put_ctio(struct ispsoftc *isp, ct_entry_t *ctsrc, ct_entry_t *ctdst) +{ + int i; + isp_copy_out_hdr(isp, &ctsrc->ct_header, &ctdst->ct_header); + ISP_IOXPUT_16(isp, ctsrc->ct_reserved, &ctdst->ct_reserved); + ISP_IOXPUT_16(isp, ctsrc->ct_fwhandle, &ctdst->ct_fwhandle); + if (ISP_IS_SBUS(isp)) { + ISP_IOXPUT_8(isp, ctsrc->ct_iid, &ctdst->ct_lun); + ISP_IOXPUT_8(isp, ctsrc->ct_lun, &ctdst->ct_iid); + ISP_IOXPUT_8(isp, ctsrc->ct_tgt, &ctdst->ct_reserved2); + ISP_IOXPUT_8(isp, ctsrc->ct_reserved2, &ctdst->ct_tgt); + ISP_IOXPUT_8(isp, ctsrc->ct_status, &ctdst->ct_scsi_status); + ISP_IOXPUT_8(isp, ctsrc->ct_scsi_status, &ctdst->ct_status); + ISP_IOXPUT_8(isp, ctsrc->ct_tag_type, &ctdst->ct_tag_val); + ISP_IOXPUT_8(isp, ctsrc->ct_tag_val, &ctdst->ct_tag_type); + } else { + ISP_IOXPUT_8(isp, ctsrc->ct_iid, &ctdst->ct_iid); + ISP_IOXPUT_8(isp, ctsrc->ct_lun, &ctdst->ct_lun); + ISP_IOXPUT_8(isp, ctsrc->ct_tgt, &ctdst->ct_tgt); + ISP_IOXPUT_8(isp, ctsrc->ct_reserved2, &ctdst->ct_reserved2); + ISP_IOXPUT_8(isp, ctsrc->ct_scsi_status, + &ctdst->ct_scsi_status); + ISP_IOXPUT_8(isp, ctsrc->ct_status, &ctdst->ct_status); + ISP_IOXPUT_8(isp, ctsrc->ct_tag_type, &ctdst->ct_tag_type); + ISP_IOXPUT_8(isp, ctsrc->ct_tag_val, &ctdst->ct_tag_val); + } + ISP_IOXPUT_32(isp, ctsrc->ct_flags, &ctdst->ct_flags); + ISP_IOXPUT_32(isp, ctsrc->ct_xfrlen, &ctdst->ct_xfrlen); + ISP_IOXPUT_32(isp, ctsrc->ct_resid, &ctdst->ct_resid); + ISP_IOXPUT_16(isp, ctsrc->ct_timeout, &ctdst->ct_timeout); + ISP_IOXPUT_16(isp, ctsrc->ct_seg_count, &ctdst->ct_seg_count); + for (i = 0; i < ISP_RQDSEG; i++) { + ISP_IOXPUT_32(isp, ctsrc->ct_dataseg[i].ds_base, + &ctdst->ct_dataseg[i].ds_base); + ISP_IOXPUT_32(isp, ctsrc->ct_dataseg[i].ds_count, + &ctdst->ct_dataseg[i].ds_count); + } +} + +static INLINE void +isp_get_ctio(struct ispsoftc *isp, ct_entry_t *ctsrc, ct_entry_t *ctdst) +{ + int i; + isp_copy_in_hdr(isp, &ctsrc->ct_header, &ctdst->ct_header); + ISP_IOXGET_16(isp, &ctsrc->ct_reserved, ctdst->ct_reserved); + ISP_IOXGET_16(isp, &ctsrc->ct_fwhandle, ctdst->ct_fwhandle); + if (ISP_IS_SBUS(isp)) { + ISP_IOXGET_8(isp, &ctsrc->ct_lun, ctdst->ct_iid); + ISP_IOXGET_8(isp, &ctsrc->ct_iid, ctdst->ct_lun); + ISP_IOXGET_8(isp, &ctsrc->ct_reserved2, ctdst->ct_tgt); + ISP_IOXGET_8(isp, &ctsrc->ct_tgt, ctdst->ct_reserved2); + ISP_IOXGET_8(isp, &ctsrc->ct_status, ctdst->ct_scsi_status); + ISP_IOXGET_8(isp, &ctsrc->ct_scsi_status, ctdst->ct_status); + ISP_IOXGET_8(isp, &ctsrc->ct_tag_val, ctdst->ct_tag_type); + ISP_IOXGET_8(isp, &ctsrc->ct_tag_type, ctdst->ct_tag_val); + } else { + ISP_IOXGET_8(isp, &ctsrc->ct_lun, ctdst->ct_lun); + ISP_IOXGET_8(isp, &ctsrc->ct_iid, ctdst->ct_iid); + ISP_IOXGET_8(isp, &ctsrc->ct_reserved2, ctdst->ct_reserved2); + ISP_IOXGET_8(isp, &ctsrc->ct_tgt, ctdst->ct_tgt); + ISP_IOXGET_8(isp, &ctsrc->ct_status, ctdst->ct_status); + ISP_IOXGET_8(isp, &ctsrc->ct_scsi_status, + ctdst->ct_scsi_status); + ISP_IOXGET_8(isp, &ctsrc->ct_tag_val, ctdst->ct_tag_val); + ISP_IOXGET_8(isp, &ctsrc->ct_tag_type, ctdst->ct_tag_type); + } + ISP_IOXGET_32(isp, &ctsrc->ct_flags, ctdst->ct_flags); + ISP_IOXGET_32(isp, &ctsrc->ct_xfrlen, ctdst->ct_xfrlen); + ISP_IOXGET_32(isp, &ctsrc->ct_resid, ctdst->ct_resid); + ISP_IOXGET_16(isp, &ctsrc->ct_timeout, ctdst->ct_timeout); + ISP_IOXGET_16(isp, &ctsrc->ct_seg_count, ctdst->ct_seg_count); + for (i = 0; i < ISP_RQDSEG; i++) { + ISP_IOXGET_32(isp, + &ctsrc->ct_dataseg[i].ds_base, + ctdst->ct_dataseg[i].ds_base); + ISP_IOXGET_32(isp, + &ctsrc->ct_dataseg[i].ds_count, + ctdst->ct_dataseg[i].ds_count); + } +} + +static INLINE void +isp_put_ctio2(struct ispsoftc *isp, ct2_entry_t *ctsrc, ct2_entry_t *ctdst) +{ + int i; + isp_copy_out_hdr(isp, &ctsrc->ct_header, &ctdst->ct_header); + ISP_IOXPUT_16(isp, ctsrc->ct_reserved, &ctdst->ct_reserved); + ISP_IOXPUT_16(isp, ctsrc->ct_fwhandle, &ctdst->ct_fwhandle); + ISP_IOXPUT_8(isp, ctsrc->ct_lun, &ctdst->ct_lun); + ISP_IOXPUT_8(isp, ctsrc->ct_iid, &ctdst->ct_iid); + ISP_IOXPUT_16(isp, ctsrc->ct_rxid, &ctdst->ct_rxid); + ISP_IOXPUT_16(isp, ctsrc->ct_flags, &ctdst->ct_flags); + ISP_IOXPUT_16(isp, ctsrc->ct_timeout, &ctdst->ct_timeout); + ISP_IOXPUT_16(isp, ctsrc->ct_seg_count, &ctdst->ct_seg_count); + ISP_IOXPUT_32(isp, ctsrc->ct_resid, &ctdst->ct_resid); + ISP_IOXPUT_32(isp, ctsrc->ct_reloff, &ctdst->ct_reloff); + if ((ctsrc->ct_flags & CT2_FLAG_MMASK) == CT2_FLAG_MODE0) { + ISP_IOXPUT_32(isp, ctsrc->rsp.m0._reserved, + &ctdst->rsp.m0._reserved); + ISP_IOXPUT_16(isp, ctsrc->rsp.m0._reserved2, + &ctdst->rsp.m0._reserved2); + ISP_IOXPUT_16(isp, ctsrc->rsp.m0.ct_scsi_status, + &ctdst->rsp.m0.ct_scsi_status); + ISP_IOXPUT_32(isp, ctsrc->rsp.m0.ct_xfrlen, + &ctdst->rsp.m0.ct_xfrlen); + if (ctsrc->ct_header.rqs_entry_type == RQSTYPE_CTIO2) { + for (i = 0; i < ISP_RQDSEG_T2; i++) { + ISP_IOXPUT_32(isp, + ctsrc->rsp.m0.ct_dataseg[i].ds_base, + &ctdst->rsp.m0.ct_dataseg[i].ds_base); + ISP_IOXPUT_32(isp, + ctsrc->rsp.m0.ct_dataseg[i].ds_count, + &ctdst->rsp.m0.ct_dataseg[i].ds_count); + } + } else if (ctsrc->ct_header.rqs_entry_type == RQSTYPE_CTIO3) { + for (i = 0; i < ISP_RQDSEG_T3; i++) { + ISP_IOXPUT_32(isp, + ctsrc->rsp.m0.ct_dataseg64[i].ds_base, + &ctdst->rsp.m0.ct_dataseg64[i].ds_base); + ISP_IOXPUT_32(isp, + ctsrc->rsp.m0.ct_dataseg64[i].ds_basehi, + &ctdst->rsp.m0.ct_dataseg64[i].ds_basehi); + ISP_IOXPUT_32(isp, + ctsrc->rsp.m0.ct_dataseg64[i].ds_count, + &ctdst->rsp.m0.ct_dataseg64[i].ds_count); + } + } else if (ctsrc->ct_header.rqs_entry_type == RQSTYPE_CTIO4) { + ISP_IOXPUT_16(isp, ctsrc->rsp.m0.ct_dslist.ds_type, + &ctdst->rsp.m0.ct_dslist.ds_type); + ISP_IOXPUT_32(isp, ctsrc->rsp.m0.ct_dslist.ds_segment, + &ctdst->rsp.m0.ct_dslist.ds_segment); + ISP_IOXPUT_32(isp, ctsrc->rsp.m0.ct_dslist.ds_base, + &ctdst->rsp.m0.ct_dslist.ds_base); + } + } else if ((ctsrc->ct_flags & CT2_FLAG_MMASK) == CT2_FLAG_MODE1) { + ISP_IOXPUT_16(isp, ctsrc->rsp.m1._reserved, + &ctdst->rsp.m1._reserved); + ISP_IOXPUT_16(isp, ctsrc->rsp.m1._reserved2, + &ctdst->rsp.m1._reserved2); + ISP_IOXPUT_16(isp, ctsrc->rsp.m1.ct_senselen, + &ctdst->rsp.m1.ct_senselen); + ISP_IOXPUT_16(isp, ctsrc->rsp.m1.ct_scsi_status, + &ctdst->rsp.m1.ct_scsi_status); + ISP_IOXPUT_16(isp, ctsrc->rsp.m1.ct_resplen, + &ctdst->rsp.m1.ct_resplen); + for (i = 0; i < MAXRESPLEN; i++) { + ISP_IOXPUT_8(isp, ctsrc->rsp.m1.ct_resp[i], + &ctdst->rsp.m1.ct_resp[i]); + } + } else { + ISP_IOXPUT_32(isp, ctsrc->rsp.m2._reserved, + &ctdst->rsp.m2._reserved); + ISP_IOXPUT_16(isp, ctsrc->rsp.m2._reserved2, + &ctdst->rsp.m2._reserved2); + ISP_IOXPUT_16(isp, ctsrc->rsp.m2._reserved3, + &ctdst->rsp.m2._reserved3); + ISP_IOXPUT_32(isp, ctsrc->rsp.m2.ct_datalen, + &ctdst->rsp.m2.ct_datalen); + ISP_IOXPUT_32(isp, ctsrc->rsp.m2.ct_fcp_rsp_iudata.ds_base, + &ctdst->rsp.m2.ct_fcp_rsp_iudata.ds_base); + ISP_IOXPUT_32(isp, ctsrc->rsp.m2.ct_fcp_rsp_iudata.ds_count, + &ctdst->rsp.m2.ct_fcp_rsp_iudata.ds_count); + } +} + +static INLINE void +isp_get_ctio2(struct ispsoftc *isp, ct2_entry_t *ctsrc, ct2_entry_t *ctdst) +{ + int i; + isp_copy_in_hdr(isp, &ctsrc->ct_header, &ctdst->ct_header); + ISP_IOXGET_16(isp, &ctsrc->ct_reserved, ctdst->ct_reserved); + ISP_IOXGET_16(isp, &ctsrc->ct_fwhandle, ctdst->ct_fwhandle); + ISP_IOXGET_8(isp, &ctsrc->ct_lun, ctdst->ct_lun); + ISP_IOXGET_8(isp, &ctsrc->ct_iid, ctdst->ct_iid); + ISP_IOXGET_16(isp, &ctsrc->ct_rxid, ctdst->ct_rxid); + ISP_IOXGET_16(isp, &ctsrc->ct_flags, ctdst->ct_flags); + ISP_IOXGET_16(isp, &ctsrc->ct_status, ctdst->ct_status); + ISP_IOXGET_16(isp, &ctsrc->ct_timeout, ctdst->ct_timeout); + ISP_IOXGET_16(isp, &ctsrc->ct_seg_count, ctdst->ct_seg_count); + ISP_IOXGET_32(isp, &ctsrc->ct_reloff, ctdst->ct_reloff); + ISP_IOXGET_32(isp, &ctsrc->ct_resid, ctdst->ct_resid); + for (i = 0; i < 4; i++) { + ISP_IOXGET_32(isp, &ctsrc->rsp.fw._reserved[i], + ctdst->rsp.fw._reserved[i]); + } + ISP_IOXGET_16(isp, &ctsrc->rsp.fw.ct_scsi_status, + ctdst->rsp.fw.ct_scsi_status); + for (i = 0; i < QLTM_SENSELEN; i++) { + ISP_IOXGET_8(isp, &ctsrc->rsp.fw.ct_sense[i], + ctdst->rsp.fw.ct_sense[i]); + } +} + +static INLINE void +isp_put_enable_lun(struct ispsoftc *isp, lun_entry_t *lesrc, lun_entry_t *ledst) +{ + int i; + isp_copy_out_hdr(isp, &lesrc->le_header, &ledst->le_header); + ISP_IOXPUT_32(isp, lesrc->le_reserved, &ledst->le_reserved); + if (ISP_IS_SBUS(isp)) { + ISP_IOXPUT_8(isp, lesrc->le_lun, &ledst->le_rsvd); + ISP_IOXPUT_8(isp, lesrc->le_rsvd, &ledst->le_lun); + ISP_IOXPUT_8(isp, lesrc->le_ops, &ledst->le_tgt); + ISP_IOXPUT_8(isp, lesrc->le_tgt, &ledst->le_ops); + ISP_IOXPUT_8(isp, lesrc->le_status, &ledst->le_reserved2); + ISP_IOXPUT_8(isp, lesrc->le_reserved2, &ledst->le_status); + ISP_IOXPUT_8(isp, lesrc->le_cmd_count, &ledst->le_in_count); + ISP_IOXPUT_8(isp, lesrc->le_in_count, &ledst->le_cmd_count); + ISP_IOXPUT_8(isp, lesrc->le_cdb6len, &ledst->le_cdb7len); + ISP_IOXPUT_8(isp, lesrc->le_cdb7len, &ledst->le_cdb6len); + } else { + ISP_IOXPUT_8(isp, lesrc->le_lun, &ledst->le_lun); + ISP_IOXPUT_8(isp, lesrc->le_rsvd, &ledst->le_rsvd); + ISP_IOXPUT_8(isp, lesrc->le_ops, &ledst->le_ops); + ISP_IOXPUT_8(isp, lesrc->le_tgt, &ledst->le_tgt); + ISP_IOXPUT_8(isp, lesrc->le_status, &ledst->le_status); + ISP_IOXPUT_8(isp, lesrc->le_reserved2, &ledst->le_reserved2); + ISP_IOXPUT_8(isp, lesrc->le_cmd_count, &ledst->le_cmd_count); + ISP_IOXPUT_8(isp, lesrc->le_in_count, &ledst->le_in_count); + ISP_IOXPUT_8(isp, lesrc->le_cdb6len, &ledst->le_cdb6len); + ISP_IOXPUT_8(isp, lesrc->le_cdb7len, &ledst->le_cdb7len); + } + ISP_IOXPUT_32(isp, lesrc->le_flags, &ledst->le_flags); + ISP_IOXPUT_16(isp, lesrc->le_timeout, &ledst->le_timeout); + for (i = 0; i < 20; i++) { + ISP_IOXPUT_8(isp, lesrc->le_reserved3[i], + &ledst->le_reserved3[i]); + } +} + +static INLINE void +isp_get_enable_lun(struct ispsoftc *isp, lun_entry_t *lesrc, lun_entry_t *ledst) +{ + int i; + isp_copy_in_hdr(isp, &lesrc->le_header, &ledst->le_header); + ISP_IOXGET_32(isp, &lesrc->le_reserved, ledst->le_reserved); + if (ISP_IS_SBUS(isp)) { + ISP_IOXGET_8(isp, &lesrc->le_lun, ledst->le_rsvd); + ISP_IOXGET_8(isp, &lesrc->le_rsvd, ledst->le_lun); + ISP_IOXGET_8(isp, &lesrc->le_ops, ledst->le_tgt); + ISP_IOXGET_8(isp, &lesrc->le_tgt, ledst->le_ops); + ISP_IOXGET_8(isp, &lesrc->le_status, ledst->le_reserved2); + ISP_IOXGET_8(isp, &lesrc->le_reserved2, ledst->le_status); + ISP_IOXGET_8(isp, &lesrc->le_cmd_count, ledst->le_in_count); + ISP_IOXGET_8(isp, &lesrc->le_in_count, ledst->le_cmd_count); + ISP_IOXGET_8(isp, &lesrc->le_cdb6len, ledst->le_cdb7len); + ISP_IOXGET_8(isp, &lesrc->le_cdb7len, ledst->le_cdb6len); + } else { + ISP_IOXGET_8(isp, &lesrc->le_lun, ledst->le_lun); + ISP_IOXGET_8(isp, &lesrc->le_rsvd, ledst->le_rsvd); + ISP_IOXGET_8(isp, &lesrc->le_ops, ledst->le_ops); + ISP_IOXGET_8(isp, &lesrc->le_tgt, ledst->le_tgt); + ISP_IOXGET_8(isp, &lesrc->le_status, ledst->le_status); + ISP_IOXGET_8(isp, &lesrc->le_reserved2, ledst->le_reserved2); + ISP_IOXGET_8(isp, &lesrc->le_cmd_count, ledst->le_cmd_count); + ISP_IOXGET_8(isp, &lesrc->le_in_count, ledst->le_in_count); + ISP_IOXGET_8(isp, &lesrc->le_cdb6len, ledst->le_cdb6len); + ISP_IOXGET_8(isp, &lesrc->le_cdb7len, ledst->le_cdb7len); + } + ISP_IOXGET_32(isp, &lesrc->le_flags, ledst->le_flags); + ISP_IOXGET_16(isp, &lesrc->le_timeout, ledst->le_timeout); + for (i = 0; i < 20; i++) { + ISP_IOXGET_8(isp, &lesrc->le_reserved3[i], + ledst->le_reserved3[i]); + } +} + +static INLINE void +isp_put_notify(struct ispsoftc *isp, in_entry_t *insrc, in_entry_t *indst) +{ + int i; + isp_copy_out_hdr(isp, &insrc->in_header, &indst->in_header); + ISP_IOXPUT_32(isp, insrc->in_reserved, &indst->in_reserved); + if (ISP_IS_SBUS(isp)) { + ISP_IOXPUT_8(isp, insrc->in_lun, &indst->in_iid); + ISP_IOXPUT_8(isp, insrc->in_iid, &indst->in_lun); + ISP_IOXPUT_8(isp, insrc->in_reserved2, &indst->in_tgt); + ISP_IOXPUT_8(isp, insrc->in_tgt, &indst->in_reserved2); + ISP_IOXPUT_8(isp, insrc->in_status, &indst->in_rsvd2); + ISP_IOXPUT_8(isp, insrc->in_rsvd2, &indst->in_status); + ISP_IOXPUT_8(isp, insrc->in_tag_val, &indst->in_tag_type); + ISP_IOXPUT_8(isp, insrc->in_tag_type, &indst->in_tag_val); + } else { + ISP_IOXPUT_8(isp, insrc->in_lun, &indst->in_lun); + ISP_IOXPUT_8(isp, insrc->in_iid, &indst->in_iid); + ISP_IOXPUT_8(isp, insrc->in_reserved2, &indst->in_reserved2); + ISP_IOXPUT_8(isp, insrc->in_tgt, &indst->in_tgt); + ISP_IOXPUT_8(isp, insrc->in_status, &indst->in_status); + ISP_IOXPUT_8(isp, insrc->in_rsvd2, &indst->in_rsvd2); + ISP_IOXPUT_8(isp, insrc->in_tag_val, &indst->in_tag_val); + ISP_IOXPUT_8(isp, insrc->in_tag_type, &indst->in_tag_type); + } + ISP_IOXPUT_32(isp, insrc->in_flags, &indst->in_flags); + ISP_IOXPUT_16(isp, insrc->in_seqid, &indst->in_seqid); + for (i = 0; i < IN_MSGLEN; i++) { + ISP_IOXPUT_8(isp, insrc->in_msg[i], &indst->in_msg[i]); + } + for (i = 0; i < IN_RSVDLEN; i++) { + ISP_IOXPUT_8(isp, insrc->in_reserved3[i], + &indst->in_reserved3[i]); + } + for (i = 0; i < QLTM_SENSELEN; i++) { + ISP_IOXPUT_8(isp, insrc->in_sense[i], + &indst->in_sense[i]); + } +} + +static INLINE void +isp_get_notify(struct ispsoftc *isp, in_entry_t *insrc, in_entry_t *indst) +{ + int i; + isp_copy_in_hdr(isp, &insrc->in_header, &indst->in_header); + ISP_IOXGET_32(isp, &insrc->in_reserved, indst->in_reserved); + if (ISP_IS_SBUS(isp)) { + ISP_IOXGET_8(isp, &insrc->in_lun, indst->in_iid); + ISP_IOXGET_8(isp, &insrc->in_iid, indst->in_lun); + ISP_IOXGET_8(isp, &insrc->in_reserved2, indst->in_tgt); + ISP_IOXGET_8(isp, &insrc->in_tgt, indst->in_reserved2); + ISP_IOXGET_8(isp, &insrc->in_status, indst->in_rsvd2); + ISP_IOXGET_8(isp, &insrc->in_rsvd2, indst->in_status); + ISP_IOXGET_8(isp, &insrc->in_tag_val, indst->in_tag_type); + ISP_IOXGET_8(isp, &insrc->in_tag_type, indst->in_tag_val); + } else { + ISP_IOXGET_8(isp, &insrc->in_lun, indst->in_lun); + ISP_IOXGET_8(isp, &insrc->in_iid, indst->in_iid); + ISP_IOXGET_8(isp, &insrc->in_reserved2, indst->in_reserved2); + ISP_IOXGET_8(isp, &insrc->in_tgt, indst->in_tgt); + ISP_IOXGET_8(isp, &insrc->in_status, indst->in_status); + ISP_IOXGET_8(isp, &insrc->in_rsvd2, indst->in_rsvd2); + ISP_IOXGET_8(isp, &insrc->in_tag_val, indst->in_tag_val); + ISP_IOXGET_8(isp, &insrc->in_tag_type, indst->in_tag_type); + } + ISP_IOXGET_32(isp, &insrc->in_flags, indst->in_flags); + ISP_IOXGET_16(isp, &insrc->in_seqid, indst->in_seqid); + for (i = 0; i < IN_MSGLEN; i++) { + ISP_IOXGET_8(isp, &insrc->in_msg[i], indst->in_msg[i]); + } + for (i = 0; i < IN_RSVDLEN; i++) { + ISP_IOXGET_8(isp, &insrc->in_reserved3[i], + indst->in_reserved3[i]); + } + for (i = 0; i < QLTM_SENSELEN; i++) { + ISP_IOXGET_8(isp, &insrc->in_sense[i], + indst->in_sense[i]); + } +} + +static INLINE void +isp_put_notify_fc(struct ispsoftc *isp, in_fcentry_t *insrc, + in_fcentry_t *indst) +{ + isp_copy_out_hdr(isp, &insrc->in_header, &indst->in_header); + ISP_IOXPUT_32(isp, insrc->in_reserved, &indst->in_reserved); + ISP_IOXPUT_8(isp, insrc->in_lun, &indst->in_lun); + ISP_IOXPUT_8(isp, insrc->in_iid, &indst->in_iid); + ISP_IOXPUT_16(isp, insrc->in_scclun, &indst->in_scclun); + ISP_IOXPUT_32(isp, insrc->in_reserved2, &indst->in_reserved2); + ISP_IOXPUT_16(isp, insrc->in_status, &indst->in_status); + ISP_IOXPUT_16(isp, insrc->in_task_flags, &indst->in_task_flags); + ISP_IOXPUT_16(isp, insrc->in_seqid, &indst->in_seqid); +} + +static INLINE void +isp_get_notify_fc(struct ispsoftc *isp, in_fcentry_t *insrc, + in_fcentry_t *indst) +{ + isp_copy_in_hdr(isp, &insrc->in_header, &indst->in_header); + ISP_IOXGET_32(isp, &insrc->in_reserved, indst->in_reserved); + ISP_IOXGET_8(isp, &insrc->in_lun, indst->in_lun); + ISP_IOXGET_8(isp, &insrc->in_iid, indst->in_iid); + ISP_IOXGET_16(isp, &insrc->in_scclun, indst->in_scclun); + ISP_IOXGET_32(isp, &insrc->in_reserved2, indst->in_reserved2); + ISP_IOXGET_16(isp, &insrc->in_status, indst->in_status); + ISP_IOXGET_16(isp, &insrc->in_task_flags, indst->in_task_flags); + ISP_IOXGET_16(isp, &insrc->in_seqid, indst->in_seqid); +} + +static INLINE void +isp_put_notify_ack(struct ispsoftc *isp, na_entry_t *nasrc, na_entry_t *nadst) +{ + int i; + isp_copy_out_hdr(isp, &nasrc->na_header, &nadst->na_header); + ISP_IOXPUT_32(isp, nasrc->na_reserved, &nadst->na_reserved); + if (ISP_IS_SBUS(isp)) { + ISP_IOXPUT_8(isp, nasrc->na_lun, &nadst->na_iid); + ISP_IOXPUT_8(isp, nasrc->na_iid, &nadst->na_lun); + ISP_IOXPUT_8(isp, nasrc->na_status, &nadst->na_event); + ISP_IOXPUT_8(isp, nasrc->na_event, &nadst->na_status); + } else { + ISP_IOXPUT_8(isp, nasrc->na_lun, &nadst->na_lun); + ISP_IOXPUT_8(isp, nasrc->na_iid, &nadst->na_iid); + ISP_IOXPUT_8(isp, nasrc->na_status, &nadst->na_status); + ISP_IOXPUT_8(isp, nasrc->na_event, &nadst->na_event); + } + ISP_IOXPUT_32(isp, nasrc->na_flags, &nadst->na_flags); + for (i = 0; i < NA_RSVDLEN; i++) { + ISP_IOXPUT_16(isp, nasrc->na_reserved3[i], + &nadst->na_reserved3[i]); + } +} + +static INLINE void +isp_get_notify_ack(struct ispsoftc *isp, na_entry_t *nasrc, na_entry_t *nadst) +{ + int i; + isp_copy_in_hdr(isp, &nasrc->na_header, &nadst->na_header); + ISP_IOXGET_32(isp, &nasrc->na_reserved, nadst->na_reserved); + if (ISP_IS_SBUS(isp)) { + ISP_IOXGET_8(isp, &nasrc->na_lun, nadst->na_iid); + ISP_IOXGET_8(isp, &nasrc->na_iid, nadst->na_lun); + ISP_IOXGET_8(isp, &nasrc->na_status, nadst->na_event); + ISP_IOXGET_8(isp, &nasrc->na_event, nadst->na_status); + } else { + ISP_IOXGET_8(isp, &nasrc->na_lun, nadst->na_lun); + ISP_IOXGET_8(isp, &nasrc->na_iid, nadst->na_iid); + ISP_IOXGET_8(isp, &nasrc->na_status, nadst->na_status); + ISP_IOXGET_8(isp, &nasrc->na_event, nadst->na_event); + } + ISP_IOXGET_32(isp, &nasrc->na_flags, nadst->na_flags); + for (i = 0; i < NA_RSVDLEN; i++) { + ISP_IOXGET_16(isp, &nasrc->na_reserved3[i], + nadst->na_reserved3[i]); + } +} + +static INLINE void +isp_put_notify_ack_fc(struct ispsoftc *isp, na_fcentry_t *nasrc, + na_fcentry_t *nadst) +{ + int i; + isp_copy_out_hdr(isp, &nasrc->na_header, &nadst->na_header); + ISP_IOXPUT_32(isp, nasrc->na_reserved, &nadst->na_reserved); + ISP_IOXPUT_8(isp, nasrc->na_lun, &nadst->na_lun); + ISP_IOXPUT_8(isp, nasrc->na_iid, &nadst->na_iid); + ISP_IOXPUT_16(isp, nasrc->na_scclun, &nadst->na_scclun); + ISP_IOXPUT_16(isp, nasrc->na_flags, &nadst->na_flags); + ISP_IOXPUT_16(isp, nasrc->na_reserved2, &nadst->na_reserved2); + ISP_IOXPUT_16(isp, nasrc->na_status, &nadst->na_status); + ISP_IOXPUT_16(isp, nasrc->na_task_flags, &nadst->na_task_flags); + ISP_IOXPUT_16(isp, nasrc->na_seqid, &nadst->na_seqid); + for (i = 0; i < NA2_RSVDLEN; i++) { + ISP_IOXPUT_16(isp, nasrc->na_reserved3[i], + &nadst->na_reserved3[i]); + } +} + +static INLINE void +isp_get_notify_ack_fc(struct ispsoftc *isp, na_fcentry_t *nasrc, + na_fcentry_t *nadst) +{ + int i; + isp_copy_in_hdr(isp, &nasrc->na_header, &nadst->na_header); + ISP_IOXGET_32(isp, &nasrc->na_reserved, nadst->na_reserved); + ISP_IOXGET_8(isp, &nasrc->na_lun, nadst->na_lun); + ISP_IOXGET_8(isp, &nasrc->na_iid, nadst->na_iid); + ISP_IOXGET_16(isp, &nasrc->na_scclun, nadst->na_scclun); + ISP_IOXGET_16(isp, &nasrc->na_flags, nadst->na_flags); + ISP_IOXGET_16(isp, &nasrc->na_reserved2, nadst->na_reserved2); + ISP_IOXGET_16(isp, &nasrc->na_status, nadst->na_status); + ISP_IOXGET_16(isp, &nasrc->na_task_flags, nadst->na_task_flags); + ISP_IOXGET_16(isp, &nasrc->na_seqid, nadst->na_seqid); + for (i = 0; i < NA2_RSVDLEN; i++) { + ISP_IOXGET_16(isp, &nasrc->na_reserved3[i], + nadst->na_reserved3[i]); + } +} +#endif +#endif /* _ISP_INLINE_H */ diff -puN /dev/null drivers/scsi/isp/common/ispmbox.h --- /dev/null 2002-08-30 16:31:37.000000000 -0700 +++ 25-akpm/drivers/scsi/isp/common/ispmbox.h 2003-02-14 00:20:12.000000000 -0800 @@ -0,0 +1,934 @@ +/* @(#)ispmbox.h 1.22 */ +/* + * Mailbox and Queue Entry Definitions for for Qlogic ISP SCSI adapters. + * + * Copyright (c) 1997, 1998, 1999, 2000 by Matthew Jacob + * 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 immediately at the beginning of the file, without modification, + * this list of conditions, and the following disclaimer. + * 2. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * 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. + * + */ +#ifndef _ISPMBOX_H +#define _ISPMBOX_H + +/* + * Mailbox Command Opcodes + */ +#define MBOX_NO_OP 0x0000 +#define MBOX_LOAD_RAM 0x0001 +#define MBOX_EXEC_FIRMWARE 0x0002 +#define MBOX_DUMP_RAM 0x0003 +#define MBOX_WRITE_RAM_WORD 0x0004 +#define MBOX_READ_RAM_WORD 0x0005 +#define MBOX_MAILBOX_REG_TEST 0x0006 +#define MBOX_VERIFY_CHECKSUM 0x0007 +#define MBOX_ABOUT_FIRMWARE 0x0008 + /* 9 */ + /* a */ + /* b */ + /* c */ + /* d */ +#define MBOX_CHECK_FIRMWARE 0x000e +#define MBOX_READ_RAM_WORD_EXTENDED 0x000f +#define MBOX_INIT_REQ_QUEUE 0x0010 +#define MBOX_INIT_RES_QUEUE 0x0011 +#define MBOX_EXECUTE_IOCB 0x0012 +#define MBOX_WAKE_UP 0x0013 +#define MBOX_STOP_FIRMWARE 0x0014 +#define MBOX_ABORT 0x0015 +#define MBOX_ABORT_DEVICE 0x0016 +#define MBOX_ABORT_TARGET 0x0017 +#define MBOX_BUS_RESET 0x0018 +#define MBOX_STOP_QUEUE 0x0019 +#define MBOX_START_QUEUE 0x001a +#define MBOX_SINGLE_STEP_QUEUE 0x001b +#define MBOX_ABORT_QUEUE 0x001c +#define MBOX_GET_DEV_QUEUE_STATUS 0x001d + /* 1e */ +#define MBOX_GET_FIRMWARE_STATUS 0x001f +#define MBOX_GET_INIT_SCSI_ID 0x0020 +#define MBOX_GET_SELECT_TIMEOUT 0x0021 +#define MBOX_GET_RETRY_COUNT 0x0022 +#define MBOX_GET_TAG_AGE_LIMIT 0x0023 +#define MBOX_GET_CLOCK_RATE 0x0024 +#define MBOX_GET_ACT_NEG_STATE 0x0025 +#define MBOX_GET_ASYNC_DATA_SETUP_TIME 0x0026 +#define MBOX_GET_SBUS_PARAMS 0x0027 +#define MBOX_GET_PCI_PARAMS MBOX_GET_SBUS_PARAMS +#define MBOX_GET_TARGET_PARAMS 0x0028 +#define MBOX_GET_DEV_QUEUE_PARAMS 0x0029 +#define MBOX_GET_RESET_DELAY_PARAMS 0x002a + /* 2b */ + /* 2c */ + /* 2d */ + /* 2e */ + /* 2f */ +#define MBOX_SET_INIT_SCSI_ID 0x0030 +#define MBOX_SET_SELECT_TIMEOUT 0x0031 +#define MBOX_SET_RETRY_COUNT 0x0032 +#define MBOX_SET_TAG_AGE_LIMIT 0x0033 +#define MBOX_SET_CLOCK_RATE 0x0034 +#define MBOX_SET_ACT_NEG_STATE 0x0035 +#define MBOX_SET_ASYNC_DATA_SETUP_TIME 0x0036 +#define MBOX_SET_SBUS_CONTROL_PARAMS 0x0037 +#define MBOX_SET_PCI_PARAMETERS 0x0037 +#define MBOX_SET_TARGET_PARAMS 0x0038 +#define MBOX_SET_DEV_QUEUE_PARAMS 0x0039 +#define MBOX_SET_RESET_DELAY_PARAMS 0x003a + /* 3b */ + /* 3c */ + /* 3d */ + /* 3e */ + /* 3f */ +#define MBOX_RETURN_BIOS_BLOCK_ADDR 0x0040 +#define MBOX_WRITE_FOUR_RAM_WORDS 0x0041 +#define MBOX_EXEC_BIOS_IOCB 0x0042 +#define MBOX_SET_FW_FEATURES 0x004a +#define MBOX_GET_FW_FEATURES 0x004b +#define FW_FEATURE_FAST_POST 0x1 +#define FW_FEATURE_LVD_NOTIFY 0x2 +#define FW_FEATURE_RIO_32BIT 0x4 +#define FW_FEATURE_RIO_16BIT 0x8 + +#define MBOX_INIT_REQ_QUEUE_A64 0x0052 +#define MBOX_INIT_RES_QUEUE_A64 0x0053 + +#define MBOX_ENABLE_TARGET_MODE 0x0055 +#define ENABLE_TARGET_FLAG 0x8000 +#define ENABLE_TQING_FLAG 0x0004 +#define ENABLE_MANDATORY_DISC 0x0002 +#define MBOX_GET_TARGET_STATUS 0x0056 + +/* These are for the ISP2X00 FC cards */ +#define MBOX_GET_LOOP_ID 0x0020 +#define MBOX_GET_FIRMWARE_OPTIONS 0x0028 +#define MBOX_SET_FIRMWARE_OPTIONS 0x0038 +#define MBOX_GET_RESOURCE_COUNT 0x0042 +#define MBOX_ENHANCED_GET_PDB 0x0047 +#define MBOX_EXEC_COMMAND_IOCB_A64 0x0054 +#define MBOX_INIT_FIRMWARE 0x0060 +#define MBOX_GET_INIT_CONTROL_BLOCK 0x0061 +#define MBOX_INIT_LIP 0x0062 +#define MBOX_GET_FC_AL_POSITION_MAP 0x0063 +#define MBOX_GET_PORT_DB 0x0064 +#define MBOX_CLEAR_ACA 0x0065 +#define MBOX_TARGET_RESET 0x0066 +#define MBOX_CLEAR_TASK_SET 0x0067 +#define MBOX_ABORT_TASK_SET 0x0068 +#define MBOX_GET_FW_STATE 0x0069 +#define MBOX_GET_PORT_NAME 0x006A +#define MBOX_GET_LINK_STATUS 0x006B +#define MBOX_INIT_LIP_RESET 0x006C +#define MBOX_SEND_SNS 0x006E +#define MBOX_FABRIC_LOGIN 0x006F +#define MBOX_SEND_CHANGE_REQUEST 0x0070 +#define MBOX_FABRIC_LOGOUT 0x0071 +#define MBOX_INIT_LIP_LOGIN 0x0072 + +#define MBOX_DRIVER_HEARTBEAT 0x005B +#define MBOX_FW_HEARTBEAT 0x005C + +#define MBOX_GET_SET_DATA_RATE 0x005D /* 23XX only */ +#define MBGSD_GET_RATE 0 +#define MBGSD_SET_RATE 1 +#define MBGSD_ONEGB 0 +#define MBGSD_TWOGB 1 +#define MBGSD_AUTO 2 + + +#define ISP2100_SET_PCI_PARAM 0x00ff + +#define MBOX_BUSY 0x04 + +typedef struct { + u_int16_t param[8]; +} mbreg_t; + +/* + * Mailbox Command Complete Status Codes + */ +#define MBOX_COMMAND_COMPLETE 0x4000 +#define MBOX_INVALID_COMMAND 0x4001 +#define MBOX_HOST_INTERFACE_ERROR 0x4002 +#define MBOX_TEST_FAILED 0x4003 +#define MBOX_COMMAND_ERROR 0x4005 +#define MBOX_COMMAND_PARAM_ERROR 0x4006 +#define MBOX_PORT_ID_USED 0x4007 +#define MBOX_LOOP_ID_USED 0x4008 +#define MBOX_ALL_IDS_USED 0x4009 +#define MBOX_NOT_LOGGED_IN 0x400A +#define MBLOGALL 0x000f +#define MBLOGNONE 0x0000 +#define MBLOGMASK(x) ((x) & 0xf) + +/* + * Asynchronous event status codes + */ +#define ASYNC_BUS_RESET 0x8001 +#define ASYNC_SYSTEM_ERROR 0x8002 +#define ASYNC_RQS_XFER_ERR 0x8003 +#define ASYNC_RSP_XFER_ERR 0x8004 +#define ASYNC_QWAKEUP 0x8005 +#define ASYNC_TIMEOUT_RESET 0x8006 +#define ASYNC_DEVICE_RESET 0x8007 +#define ASYNC_EXTMSG_UNDERRUN 0x800A +#define ASYNC_SCAM_INT 0x800B +#define ASYNC_HUNG_SCSI 0x800C +#define ASYNC_KILLED_BUS 0x800D +#define ASYNC_BUS_TRANSIT 0x800E /* LVD -> HVD, eg. */ +#define ASYNC_LIP_OCCURRED 0x8010 +#define ASYNC_LOOP_UP 0x8011 +#define ASYNC_LOOP_DOWN 0x8012 +#define ASYNC_LOOP_RESET 0x8013 +#define ASYNC_PDB_CHANGED 0x8014 +#define ASYNC_CHANGE_NOTIFY 0x8015 +#define ASYNC_LIP_F8 0x8016 +#define ASYNC_CMD_CMPLT 0x8020 +#define ASYNC_CTIO_DONE 0x8021 +#define ASYNC_IP_XMIT_DONE 0x8022 +#define ASYNC_IP_RECV_DONE 0x8023 +#define ASYNC_IP_BROADCAST 0x8024 +#define ASYNC_IP_RCVQ_LOW 0x8025 +#define ASYNC_IP_RCVQ_EMPTY 0x8026 +#define ASYNC_IP_RECV_DONE_ALIGNED 0x8027 +#define ASYNC_PTPMODE 0x8030 +#define ASYNC_RIO1 0x8031 +#define ASYNC_RIO2 0x8032 +#define ASYNC_RIO3 0x8033 +#define ASYNC_RIO4 0x8034 +#define ASYNC_RIO5 0x8035 +#define ASYNC_CONNMODE 0x8036 +#define ISP_CONN_LOOP 1 +#define ISP_CONN_PTP 2 +#define ISP_CONN_BADLIP 3 +#define ISP_CONN_FATAL 4 +#define ISP_CONN_LOOPBACK 5 +#define ASYNC_RIO_RESP 0x8040 +#define ASYNC_RIO_COMP 0x8042 +/* + * 2.01.31 2200 Only. Need Bit 13 in Mailbox 1 for Set Firmware Options + * mailbox command to enable this. + */ +#define ASYNC_QFULL_SENT 0x8049 + +/* + * Mailbox Usages + */ + +#define WRITE_REQUEST_QUEUE_IN_POINTER(isp, value) \ + ISP_WRITE(isp, isp->isp_rqstinrp, value) + +#define READ_REQUEST_QUEUE_OUT_POINTER(isp) \ + ISP_READ(isp, isp->isp_rqstoutrp) + +#define READ_RESPONSE_QUEUE_IN_POINTER(isp) \ + ISP_READ(isp, isp->isp_respinrp) + +#define WRITE_RESPONSE_QUEUE_OUT_POINTER(isp, value) \ + ISP_WRITE(isp, isp->isp_respoutrp, value) + +/* + * Command Structure Definitions + */ + +typedef struct { + u_int32_t ds_base; + u_int32_t ds_count; +} ispds_t; + +typedef struct { + u_int32_t ds_base; + u_int32_t ds_basehi; + u_int32_t ds_count; +} ispds64_t; + +#define DSTYPE_32BIT 0 +#define DSTYPE_64BIT 1 +typedef struct { + u_int16_t ds_type; /* 0-> ispds_t, 1-> ispds64_t */ + u_int32_t ds_segment; /* unused */ + u_int32_t ds_base; /* 32 bit address of DSD list */ +} ispdslist_t; + + +/* + * These elements get swizzled around for SBus instances. + */ +#define ISP_SWAP8(a, b) { \ + u_int8_t tmp; \ + tmp = a; \ + a = b; \ + b = tmp; \ +} +typedef struct { + u_int8_t rqs_entry_type; + u_int8_t rqs_entry_count; + u_int8_t rqs_seqno; + u_int8_t rqs_flags; +} isphdr_t; + +/* RQS Flag definitions */ +#define RQSFLAG_CONTINUATION 0x01 +#define RQSFLAG_FULL 0x02 +#define RQSFLAG_BADHEADER 0x04 +#define RQSFLAG_BADPACKET 0x08 + +/* RQS entry_type definitions */ +#define RQSTYPE_REQUEST 0x01 +#define RQSTYPE_DATASEG 0x02 +#define RQSTYPE_RESPONSE 0x03 +#define RQSTYPE_MARKER 0x04 +#define RQSTYPE_CMDONLY 0x05 +#define RQSTYPE_ATIO 0x06 /* Target Mode */ +#define RQSTYPE_CTIO 0x07 /* Target Mode */ +#define RQSTYPE_SCAM 0x08 +#define RQSTYPE_A64 0x09 +#define RQSTYPE_A64_CONT 0x0a +#define RQSTYPE_ENABLE_LUN 0x0b /* Target Mode */ +#define RQSTYPE_MODIFY_LUN 0x0c /* Target Mode */ +#define RQSTYPE_NOTIFY 0x0d /* Target Mode */ +#define RQSTYPE_NOTIFY_ACK 0x0e /* Target Mode */ +#define RQSTYPE_CTIO1 0x0f /* Target Mode */ +#define RQSTYPE_STATUS_CONT 0x10 +#define RQSTYPE_T2RQS 0x11 +#define RQSTYPE_IP_XMIT 0x13 +#define RQSTYPE_T4RQS 0x15 +#define RQSTYPE_ATIO2 0x16 /* Target Mode */ +#define RQSTYPE_CTIO2 0x17 /* Target Mode */ +#define RQSTYPE_CSET0 0x18 +#define RQSTYPE_T3RQS 0x19 +#define RQSTYPE_IP_XMIT_64 0x1b +#define RQSTYPE_CTIO4 0x1e /* Target Mode */ +#define RQSTYPE_CTIO3 0x1f /* Target Mode */ +#define RQSTYPE_RIO1 0x21 +#define RQSTYPE_RIO2 0x22 +#define RQSTYPE_IP_RECV 0x23 +#define RQSTYPE_IP_RECV_CONT 0x24 + + +#define ISP_RQDSEG 4 +typedef struct { + isphdr_t req_header; + u_int32_t req_handle; + u_int8_t req_lun_trn; + u_int8_t req_target; + u_int16_t req_cdblen; +#define req_modifier req_cdblen /* marker packet */ + u_int16_t req_flags; + u_int16_t req_reserved; + u_int16_t req_time; + u_int16_t req_seg_count; + u_int8_t req_cdb[12]; + ispds_t req_dataseg[ISP_RQDSEG]; +} ispreq_t; + +#define ispreq64_t ispreqt3_t /* same as.... */ +#define ISP_RQDSEG_A64 2 + +/* + * A request packet can also be a marker packet. + */ +#define SYNC_DEVICE 0 +#define SYNC_TARGET 1 +#define SYNC_ALL 2 + +#define ISP_RQDSEG_T2 3 +typedef struct { + isphdr_t req_header; + u_int32_t req_handle; + u_int8_t req_lun_trn; + u_int8_t req_target; + u_int16_t req_scclun; + u_int16_t req_flags; + u_int16_t _res2; + u_int16_t req_time; + u_int16_t req_seg_count; + u_int8_t req_cdb[16]; + u_int32_t req_totalcnt; + ispds_t req_dataseg[ISP_RQDSEG_T2]; +} ispreqt2_t; + +#define ISP_RQDSEG_T3 2 +typedef struct { + isphdr_t req_header; + u_int32_t req_handle; + u_int8_t req_lun_trn; + u_int8_t req_target; + u_int16_t req_scclun; + u_int16_t req_flags; + u_int16_t _res2; + u_int16_t req_time; + u_int16_t req_seg_count; + u_int8_t req_cdb[16]; + u_int32_t req_totalcnt; + ispds64_t req_dataseg[ISP_RQDSEG_T3]; +} ispreqt3_t; + +/* req_flag values */ +#define REQFLAG_NODISCON 0x0001 +#define REQFLAG_HTAG 0x0002 +#define REQFLAG_OTAG 0x0004 +#define REQFLAG_STAG 0x0008 +#define REQFLAG_TARGET_RTN 0x0010 + +#define REQFLAG_NODATA 0x0000 +#define REQFLAG_DATA_IN 0x0020 +#define REQFLAG_DATA_OUT 0x0040 +#define REQFLAG_DATA_UNKNOWN 0x0060 + +#define REQFLAG_DISARQ 0x0100 +#define REQFLAG_FRC_ASYNC 0x0200 +#define REQFLAG_FRC_SYNC 0x0400 +#define REQFLAG_FRC_WIDE 0x0800 +#define REQFLAG_NOPARITY 0x1000 +#define REQFLAG_STOPQ 0x2000 +#define REQFLAG_XTRASNS 0x4000 +#define REQFLAG_PRIORITY 0x8000 + +typedef struct { + isphdr_t req_header; + u_int32_t req_handle; + u_int8_t req_lun_trn; + u_int8_t req_target; + u_int16_t req_cdblen; + u_int16_t req_flags; + u_int16_t _res1; + u_int16_t req_time; + u_int16_t req_seg_count; + u_int8_t req_cdb[44]; +} ispextreq_t; + +#define ISP_CDSEG 7 +typedef struct { + isphdr_t req_header; + u_int32_t _res1; + ispds_t req_dataseg[ISP_CDSEG]; +} ispcontreq_t; + +#define ISP_CDSEG64 5 +typedef struct { + isphdr_t req_header; + ispds64_t req_dataseg[ISP_CDSEG64]; +} ispcontreq64_t; + +typedef struct { + isphdr_t req_header; + u_int32_t req_handle; + u_int16_t req_scsi_status; + u_int16_t req_completion_status; + u_int16_t req_state_flags; + u_int16_t req_status_flags; + u_int16_t req_time; +#define req_response_len req_time /* FC only */ + u_int16_t req_sense_len; + u_int32_t req_resid; + u_int8_t req_response[8]; /* FC only */ + u_int8_t req_sense_data[32]; +} ispstatusreq_t; + +typedef struct { + isphdr_t req_header; + u_int8_t req_sense_data[60]; +} ispstatus_cont_t; + +/* + * For Qlogic 2X00, the high order byte of SCSI status has + * additional meaning. + */ +#define RQCS_RU 0x800 /* Residual Under */ +#define RQCS_RO 0x400 /* Residual Over */ +#define RQCS_RESID (RQCS_RU|RQCS_RO) +#define RQCS_SV 0x200 /* Sense Length Valid */ +#define RQCS_RV 0x100 /* FCP Response Length Valid */ + +/* + * Completion Status Codes. + */ +#define RQCS_COMPLETE 0x0000 +#define RQCS_DMA_ERROR 0x0002 +#define RQCS_RESET_OCCURRED 0x0004 +#define RQCS_ABORTED 0x0005 +#define RQCS_TIMEOUT 0x0006 +#define RQCS_DATA_OVERRUN 0x0007 +#define RQCS_DATA_UNDERRUN 0x0015 +#define RQCS_QUEUE_FULL 0x001C + +/* 1X00 Only Completion Codes */ +#define RQCS_INCOMPLETE 0x0001 +#define RQCS_TRANSPORT_ERROR 0x0003 +#define RQCS_COMMAND_OVERRUN 0x0008 +#define RQCS_STATUS_OVERRUN 0x0009 +#define RQCS_BAD_MESSAGE 0x000a +#define RQCS_NO_MESSAGE_OUT 0x000b +#define RQCS_EXT_ID_FAILED 0x000c +#define RQCS_IDE_MSG_FAILED 0x000d +#define RQCS_ABORT_MSG_FAILED 0x000e +#define RQCS_REJECT_MSG_FAILED 0x000f +#define RQCS_NOP_MSG_FAILED 0x0010 +#define RQCS_PARITY_ERROR_MSG_FAILED 0x0011 +#define RQCS_DEVICE_RESET_MSG_FAILED 0x0012 +#define RQCS_ID_MSG_FAILED 0x0013 +#define RQCS_UNEXP_BUS_FREE 0x0014 +#define RQCS_XACT_ERR1 0x0018 +#define RQCS_XACT_ERR2 0x0019 +#define RQCS_XACT_ERR3 0x001A +#define RQCS_BAD_ENTRY 0x001B +#define RQCS_PHASE_SKIPPED 0x001D +#define RQCS_ARQS_FAILED 0x001E +#define RQCS_WIDE_FAILED 0x001F +#define RQCS_SYNCXFER_FAILED 0x0020 +#define RQCS_LVD_BUSERR 0x0021 + +/* 2X00 Only Completion Codes */ +#define RQCS_PORT_UNAVAILABLE 0x0028 +#define RQCS_PORT_LOGGED_OUT 0x0029 +#define RQCS_PORT_CHANGED 0x002A +#define RQCS_PORT_BUSY 0x002B + +/* + * 1X00 specific State Flags + */ +#define RQSF_GOT_BUS 0x0100 +#define RQSF_GOT_TARGET 0x0200 +#define RQSF_SENT_CDB 0x0400 +#define RQSF_XFRD_DATA 0x0800 +#define RQSF_GOT_STATUS 0x1000 +#define RQSF_GOT_SENSE 0x2000 +#define RQSF_XFER_COMPLETE 0x4000 + +/* + * 2X00 specific State Flags + * (same as 1X00 except RQSF_GOT_BUS/RQSF_GOT_TARGET are not available) + */ +#define RQSF_DATA_IN 0x0020 +#define RQSF_DATA_OUT 0x0040 +#define RQSF_STAG 0x0008 +#define RQSF_OTAG 0x0004 +#define RQSF_HTAG 0x0002 +/* + * 1X00 Status Flags + */ +#define RQSTF_DISCONNECT 0x0001 +#define RQSTF_SYNCHRONOUS 0x0002 +#define RQSTF_PARITY_ERROR 0x0004 +#define RQSTF_BUS_RESET 0x0008 +#define RQSTF_DEVICE_RESET 0x0010 +#define RQSTF_ABORTED 0x0020 +#define RQSTF_TIMEOUT 0x0040 +#define RQSTF_NEGOTIATION 0x0080 + +/* + * 2X00 specific state flags + */ +/* RQSF_SENT_CDB */ +/* RQSF_XFRD_DATA */ +/* RQSF_GOT_STATUS */ +/* RQSF_XFER_COMPLETE */ + +/* + * 2X00 specific status flags + */ +/* RQSTF_ABORTED */ +/* RQSTF_TIMEOUT */ +#define RQSTF_DMA_ERROR 0x0080 +#define RQSTF_LOGOUT 0x2000 + +/* + * Miscellaneous + */ +#ifndef ISP_EXEC_THROTTLE +#define ISP_EXEC_THROTTLE 16 +#endif + +/* + * About Firmware returns an 'attribute' word in mailbox 6. + */ +#define ISP_FW_ATTR_TMODE 0x01 +#define ISP_FW_ATTR_SCCLUN 0x02 +#define ISP_FW_ATTR_FABRIC 0x04 +#define ISP_FW_ATTR_CLASS2 0x08 +#define ISP_FW_ATTR_FCTAPE 0x10 +#define ISP_FW_ATTR_IP 0x20 + +/* + * Reduced Interrupt Operation Response Queue Entreis + */ + +typedef struct { + isphdr_t req_header; + u_int32_t req_handles[15]; +} isp_rio1_t; + +typedef struct { + isphdr_t req_header; + u_int16_t req_handles[30]; +} isp_rio2_t; + +/* + * FC (ISP2100) specific data structures + */ + +/* + * Initialization Control Block + * + * Version One (prime) format. + */ +typedef struct isp_icb { + u_int8_t icb_version; + u_int8_t _reserved0; + u_int16_t icb_fwoptions; + u_int16_t icb_maxfrmlen; + u_int16_t icb_maxalloc; + u_int16_t icb_execthrottle; + u_int8_t icb_retry_count; + u_int8_t icb_retry_delay; + u_int8_t icb_portname[8]; + u_int16_t icb_hardaddr; + u_int8_t icb_iqdevtype; + u_int8_t icb_logintime; + u_int8_t icb_nodename[8]; + u_int16_t icb_rqstout; + u_int16_t icb_rspnsin; + u_int16_t icb_rqstqlen; + u_int16_t icb_rsltqlen; + u_int16_t icb_rqstaddr[4]; + u_int16_t icb_respaddr[4]; + u_int16_t icb_lunenables; + u_int8_t icb_ccnt; + u_int8_t icb_icnt; + u_int16_t icb_lunetimeout; + u_int16_t _reserved1; + u_int16_t icb_xfwoptions; + u_int8_t icb_racctimer; + u_int8_t icb_idelaytimer; + u_int16_t icb_zfwoptions; + u_int16_t _reserved2[13]; +} isp_icb_t; +#define ICB_VERSION1 1 + +#define ICBOPT_HARD_ADDRESS 0x0001 +#define ICBOPT_FAIRNESS 0x0002 +#define ICBOPT_FULL_DUPLEX 0x0004 +#define ICBOPT_FAST_POST 0x0008 +#define ICBOPT_TGT_ENABLE 0x0010 +#define ICBOPT_INI_DISABLE 0x0020 +#define ICBOPT_INI_ADISC 0x0040 +#define ICBOPT_INI_TGTTYPE 0x0080 +#define ICBOPT_PDBCHANGE_AE 0x0100 +#define ICBOPT_NOLIP 0x0200 +#define ICBOPT_SRCHDOWN 0x0400 +#define ICBOPT_PREVLOOP 0x0800 +#define ICBOPT_STOP_ON_QFULL 0x1000 +#define ICBOPT_FULL_LOGIN 0x2000 +#define ICBOPT_BOTH_WWNS 0x4000 +#define ICBOPT_EXTENDED 0x8000 + +#define ICBXOPT_CLASS2_ACK0 0x0200 +#define ICBXOPT_CLASS2 0x0100 +#define ICBXOPT_LOOP_ONLY (0 << 4) +#define ICBXOPT_PTP_ONLY (1 << 4) +#define ICBXOPT_LOOP_2_PTP (2 << 4) +#define ICBXOPT_PTP_2_LOOP (3 << 4) + +#define ICBXOPT_RIO_OFF 0 +#define ICBXOPT_RIO_16BIT 1 +#define ICBXOPT_RIO_32BIT 2 +#define ICBXOPT_RIO_16BIT_IOCB 3 +#define ICBXOPT_RIO_32BIT_IOCB 4 +#define ICBXOPT_ZIO 5 + +#define ICBZOPT_ENA_RDXFR_RDY 0x01 +#define ICBZOPT_ENA_OOF (1 << 6) /* out of order frame handling */ +/* These 3 only apply to the 2300 */ +#define ICBZOPT_RATE_ONEGB (MBGSD_ONEGB << 14) +#define ICBZOPT_RATE_TWOGB (MBGSD_TWOGB << 14) +#define ICBZOPT_RATE_AUTO (MBGSD_AUTO << 14) + + +#define ICB_MIN_FRMLEN 256 +#define ICB_MAX_FRMLEN 2112 +#define ICB_DFLT_FRMLEN 1024 +#define ICB_DFLT_ALLOC 256 +#define ICB_DFLT_THROTTLE 16 +#define ICB_DFLT_RDELAY 5 +#define ICB_DFLT_RCOUNT 3 + + +#define RQRSP_ADDR0015 0 +#define RQRSP_ADDR1631 1 +#define RQRSP_ADDR3247 2 +#define RQRSP_ADDR4863 3 + + +#define ICB_NNM0 7 +#define ICB_NNM1 6 +#define ICB_NNM2 5 +#define ICB_NNM3 4 +#define ICB_NNM4 3 +#define ICB_NNM5 2 +#define ICB_NNM6 1 +#define ICB_NNM7 0 + +#define MAKE_NODE_NAME_FROM_WWN(array, wwn) \ + array[ICB_NNM0] = (u_int8_t) ((wwn >> 0) & 0xff), \ + array[ICB_NNM1] = (u_int8_t) ((wwn >> 8) & 0xff), \ + array[ICB_NNM2] = (u_int8_t) ((wwn >> 16) & 0xff), \ + array[ICB_NNM3] = (u_int8_t) ((wwn >> 24) & 0xff), \ + array[ICB_NNM4] = (u_int8_t) ((wwn >> 32) & 0xff), \ + array[ICB_NNM5] = (u_int8_t) ((wwn >> 40) & 0xff), \ + array[ICB_NNM6] = (u_int8_t) ((wwn >> 48) & 0xff), \ + array[ICB_NNM7] = (u_int8_t) ((wwn >> 56) & 0xff) + +/* + * FC-AL Position Map + * + * This is an at most 128 byte map that returns either + * the LILP or Firmware generated list of ports. + * + * We deviate a bit from the returned qlogic format to + * use an extra bit to say whether this was a LILP or + * f/w generated map. + */ +typedef struct { + u_int8_t fwmap : 1, + count : 7; + u_int8_t map[127]; +} fcpos_map_t; + +/* + * Port Data Base Element + */ + +typedef struct { + u_int16_t pdb_options; + u_int8_t pdb_mstate; + u_int8_t pdb_sstate; +#define BITS2WORD(x) ((x)[0] << 16 | (x)[3] << 8 | (x)[2]) + u_int8_t pdb_hardaddr_bits[4]; + u_int8_t pdb_portid_bits[4]; + u_int8_t pdb_nodename[8]; + u_int8_t pdb_portname[8]; + u_int16_t pdb_execthrottle; + u_int16_t pdb_exec_count; + u_int8_t pdb_retry_count; + u_int8_t pdb_retry_delay; + u_int16_t pdb_resalloc; + u_int16_t pdb_curalloc; + u_int16_t pdb_qhead; + u_int16_t pdb_qtail; + u_int16_t pdb_tl_next; + u_int16_t pdb_tl_last; + u_int16_t pdb_features; /* PLOGI, Common Service */ + u_int16_t pdb_pconcurrnt; /* PLOGI, Common Service */ + u_int16_t pdb_roi; /* PLOGI, Common Service */ + u_int8_t pdb_target; + u_int8_t pdb_initiator; /* PLOGI, Class 3 Control Flags */ + u_int16_t pdb_rdsiz; /* PLOGI, Class 3 */ + u_int16_t pdb_ncseq; /* PLOGI, Class 3 */ + u_int16_t pdb_noseq; /* PLOGI, Class 3 */ + u_int16_t pdb_labrtflg; + u_int16_t pdb_lstopflg; + u_int16_t pdb_sqhead; + u_int16_t pdb_sqtail; + u_int16_t pdb_ptimer; + u_int16_t pdb_nxt_seqid; + u_int16_t pdb_fcount; + u_int16_t pdb_prli_len; + u_int16_t pdb_prli_svc0; + u_int16_t pdb_prli_svc3; + u_int16_t pdb_loopid; + u_int16_t pdb_il_ptr; + u_int16_t pdb_sl_ptr; +} isp_pdb_t; + +#define PDB_OPTIONS_XMITTING (1<<11) +#define PDB_OPTIONS_LNKXMIT (1<<10) +#define PDB_OPTIONS_ABORTED (1<<9) +#define PDB_OPTIONS_ADISC (1<<1) + +#define PDB_STATE_DISCOVERY 0 +#define PDB_STATE_WDISC_ACK 1 +#define PDB_STATE_PLOGI 2 +#define PDB_STATE_PLOGI_ACK 3 +#define PDB_STATE_PRLI 4 +#define PDB_STATE_PRLI_ACK 5 +#define PDB_STATE_LOGGED_IN 6 +#define PDB_STATE_PORT_UNAVAIL 7 +#define PDB_STATE_PRLO 8 +#define PDB_STATE_PRLO_ACK 9 +#define PDB_STATE_PLOGO 10 +#define PDB_STATE_PLOG_ACK 11 + +#define SVC3_TGT_ROLE 0x10 +#define SVC3_INI_ROLE 0x20 +#define SVC3_ROLE_MASK 0x30 +#define SVC3_ROLE_SHIFT 4 + +/* + * CT definition + * + * This is as the QLogic f/w documentations defines it- which is just opposite, + * bit wise, from what the specification defines it as. Additionally, the + * ct_response and ct_resid (really from FC-GS-2) need to be byte swapped. + */ + +typedef struct { + u_int8_t ct_revision; + u_int8_t ct_portid[3]; + u_int8_t ct_fcs_type; + u_int8_t ct_fcs_subtype; + u_int8_t ct_options; + u_int8_t ct_res0; + u_int16_t ct_response; + u_int16_t ct_resid; + u_int8_t ct_res1; + u_int8_t ct_reason; + u_int8_t ct_explanation; + u_int8_t ct_vunique; +} ct_hdr_t; +#define FS_ACC 0x8002 +#define FS_RJT 0x8001 + +#define FC4_IP 5 /* ISO/EEC 8802-2 LLC/SNAP "Out of Order Delivery" */ +#define FC4_SCSI 8 /* SCSI-3 via Fivre Channel Protocol (FCP) */ +#define FC4_FC_SVC 0x20 /* Fibre Channel Services */ + +#define SNS_GA_NXT 0x100 +#define SNS_GPN_ID 0x112 +#define SNS_GNN_ID 0x113 +#define SNS_GFF_ID 0x11F +#define SNS_GID_FT 0x171 +#define SNS_RFT_ID 0x217 +typedef struct { + u_int16_t snscb_rblen; /* response buffer length (words) */ + u_int16_t snscb_res0; + u_int16_t snscb_addr[4]; /* response buffer address */ + u_int16_t snscb_sblen; /* subcommand buffer length (words) */ + u_int16_t snscb_res1; + u_int16_t snscb_data[1]; /* variable data */ +} sns_screq_t; /* Subcommand Request Structure */ + +typedef struct { + u_int16_t snscb_rblen; /* response buffer length (words) */ + u_int16_t snscb_res0; + u_int16_t snscb_addr[4]; /* response buffer address */ + u_int16_t snscb_sblen; /* subcommand buffer length (words) */ + u_int16_t snscb_res1; + u_int16_t snscb_cmd; + u_int16_t snscb_res2; + u_int32_t snscb_res3; + u_int32_t snscb_port; +} sns_ga_nxt_req_t; +#define SNS_GA_NXT_REQ_SIZE (sizeof (sns_ga_nxt_req_t)) + +typedef struct { + u_int16_t snscb_rblen; /* response buffer length (words) */ + u_int16_t snscb_res0; + u_int16_t snscb_addr[4]; /* response buffer address */ + u_int16_t snscb_sblen; /* subcommand buffer length (words) */ + u_int16_t snscb_res1; + u_int16_t snscb_cmd; + u_int16_t snscb_res2; + u_int32_t snscb_res3; + u_int32_t snscb_portid; +} sns_gxn_id_req_t; +#define SNS_GXN_ID_REQ_SIZE (sizeof (sns_gxn_id_req_t)) + +typedef struct { + u_int16_t snscb_rblen; /* response buffer length (words) */ + u_int16_t snscb_res0; + u_int16_t snscb_addr[4]; /* response buffer address */ + u_int16_t snscb_sblen; /* subcommand buffer length (words) */ + u_int16_t snscb_res1; + u_int16_t snscb_cmd; + u_int16_t snscb_mword_div_2; + u_int32_t snscb_res3; + u_int32_t snscb_fc4_type; +} sns_gid_ft_req_t; +#define SNS_GID_FT_REQ_SIZE (sizeof (sns_gid_ft_req_t)) + +typedef struct { + u_int16_t snscb_rblen; /* response buffer length (words) */ + u_int16_t snscb_res0; + u_int16_t snscb_addr[4]; /* response buffer address */ + u_int16_t snscb_sblen; /* subcommand buffer length (words) */ + u_int16_t snscb_res1; + u_int16_t snscb_cmd; + u_int16_t snscb_res2; + u_int32_t snscb_res3; + u_int32_t snscb_port; + u_int32_t snscb_fc4_types[8]; +} sns_rft_id_req_t; +#define SNS_RFT_ID_REQ_SIZE (sizeof (sns_rft_id_req_t)) + +typedef struct { + ct_hdr_t snscb_cthdr; + u_int8_t snscb_port_type; + u_int8_t snscb_port_id[3]; + u_int8_t snscb_portname[8]; + u_int16_t snscb_data[1]; /* variable data */ +} sns_scrsp_t; /* Subcommand Response Structure */ + +typedef struct { + ct_hdr_t snscb_cthdr; + u_int8_t snscb_port_type; + u_int8_t snscb_port_id[3]; + u_int8_t snscb_portname[8]; + u_int8_t snscb_pnlen; /* symbolic port name length */ + u_int8_t snscb_pname[255]; /* symbolic port name */ + u_int8_t snscb_nodename[8]; + u_int8_t snscb_nnlen; /* symbolic node name length */ + u_int8_t snscb_nname[255]; /* symbolic node name */ + u_int8_t snscb_ipassoc[8]; + u_int8_t snscb_ipaddr[16]; + u_int8_t snscb_svc_class[4]; + u_int8_t snscb_fc4_types[32]; + u_int8_t snscb_fpname[8]; + u_int8_t snscb_reserved; + u_int8_t snscb_hardaddr[3]; +} sns_ga_nxt_rsp_t; /* Subcommand Response Structure */ +#define SNS_GA_NXT_RESP_SIZE (sizeof (sns_ga_nxt_rsp_t)) + +typedef struct { + ct_hdr_t snscb_cthdr; + u_int8_t snscb_wwn[8]; +} sns_gxn_id_rsp_t; +#define SNS_GXN_ID_RESP_SIZE (sizeof (sns_gxn_id_rsp_t)) + +typedef struct { + ct_hdr_t snscb_cthdr; + u_int32_t snscb_fc4_features[32]; +} sns_gff_id_rsp_t; +#define SNS_GFF_ID_RESP_SIZE (sizeof (sns_gff_id_rsp_t)) + +typedef struct { + ct_hdr_t snscb_cthdr; + struct { + u_int8_t control; + u_int8_t portid[3]; + } snscb_ports[1]; +} sns_gid_ft_rsp_t; +#define SNS_GID_FT_RESP_SIZE(x) ((sizeof (sns_gid_ft_rsp_t)) + ((x - 1) << 2)) + +#define SNS_RFT_ID_RESP_SIZE (sizeof (ct_hdr_t)) + +#endif /* _ISPMBOX_H */ diff -puN /dev/null drivers/scsi/isp/common/ispreg.h --- /dev/null 2002-08-30 16:31:37.000000000 -0700 +++ 25-akpm/drivers/scsi/isp/common/ispreg.h 2003-02-14 00:20:12.000000000 -0800 @@ -0,0 +1,1011 @@ +/* @(#)ispreg.h 1.6 */ +/* + * Machine Independent (well, as best as possible) register + * definitions for Qlogic ISP SCSI adapters. + * + * Copyright (c) 1997, 1998, 1999, 2000 by Matthew Jacob + * 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 immediately at the beginning of the file, without modification, + * this list of conditions, and the following disclaimer. + * 2. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * 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. + */ +#ifndef _ISPREG_H +#define _ISPREG_H + +/* + * Hardware definitions for the Qlogic ISP registers. + */ + +/* + * This defines types of access to various registers. + * + * R: Read Only + * W: Write Only + * RW: Read/Write + * + * R*, W*, RW*: Read Only, Write Only, Read/Write, but only + * if RISC processor in ISP is paused. + */ + +/* + * Offsets for various register blocks. + * + * Sad but true, different architectures have different offsets. + * + * Don't be alarmed if none of this makes sense. The original register + * layout set some defines in a certain pattern. Everything else has been + * grafted on since. For example, the ISP1080 manual will state that DMA + * registers start at 0x80 from the base of the register address space. + * That's true, but for our purposes, we define DMA_REGS_OFF for the 1080 + * to start at offset 0x60 because the DMA registers are all defined to + * be DMA_BLOCK+0x20 and so on. Clear? + */ + +#define BIU_REGS_OFF 0x00 + +#define PCI_MBOX_REGS_OFF 0x70 +#define PCI_MBOX_REGS2100_OFF 0x10 +#define PCI_MBOX_REGS2300_OFF 0x40 +#define SBUS_MBOX_REGS_OFF 0x80 + +#define PCI_SXP_REGS_OFF 0x80 +#define SBUS_SXP_REGS_OFF 0x200 + +#define PCI_RISC_REGS_OFF 0x80 +#define SBUS_RISC_REGS_OFF 0x400 + +/* Bless me! Chip designers have putzed it again! */ +#define ISP1080_DMA_REGS_OFF 0x60 +#define DMA_REGS_OFF 0x00 /* same as BIU block */ + +#define SBUS_REGSIZE 0x450 +#define PCI_REGSIZE 0x100 + +/* + * NB: The *_BLOCK definitions have no specific hardware meaning. + * They serve simply to note to the MD layer which block of + * registers offsets are being accessed. + */ +#define _NREG_BLKS 5 +#define _BLK_REG_SHFT 13 +#define _BLK_REG_MASK (7 << _BLK_REG_SHFT) +#define BIU_BLOCK (0 << _BLK_REG_SHFT) +#define MBOX_BLOCK (1 << _BLK_REG_SHFT) +#define SXP_BLOCK (2 << _BLK_REG_SHFT) +#define RISC_BLOCK (3 << _BLK_REG_SHFT) +#define DMA_BLOCK (4 << _BLK_REG_SHFT) + +/* + * Bus Interface Block Register Offsets + */ + +#define BIU_ID_LO (BIU_BLOCK+0x0) /* R : Bus ID, Low */ +#define BIU2100_FLASH_ADDR (BIU_BLOCK+0x0) +#define BIU_ID_HI (BIU_BLOCK+0x2) /* R : Bus ID, High */ +#define BIU2100_FLASH_DATA (BIU_BLOCK+0x2) +#define BIU_CONF0 (BIU_BLOCK+0x4) /* R : Bus Configuration #0 */ +#define BIU_CONF1 (BIU_BLOCK+0x6) /* R : Bus Configuration #1 */ +#define BIU2100_CSR (BIU_BLOCK+0x6) +#define BIU_ICR (BIU_BLOCK+0x8) /* RW : Bus Interface Ctrl */ +#define BIU_ISR (BIU_BLOCK+0xA) /* R : Bus Interface Status */ +#define BIU_SEMA (BIU_BLOCK+0xC) /* RW : Bus Semaphore */ +#define BIU_NVRAM (BIU_BLOCK+0xE) /* RW : Bus NVRAM */ +/* + * These are specific to the 2300. + * + * They *claim* you can read BIU_R2HSTSLO with a full 32 bit access + * and get both registers, but I'm a bit dubious about that. But the + * point here is that the top 16 bits are firmware defined bits that + * the RISC processor uses to inform the host about something- usually + * something which was nominally in a mailbox register. + */ +#define BIU_REQINP (BIU_BLOCK+0x10) /* Request Queue In */ +#define BIU_REQOUTP (BIU_BLOCK+0x12) /* Request Queue Out */ +#define BIU_RSPINP (BIU_BLOCK+0x14) /* Response Queue In */ +#define BIU_RSPOUTP (BIU_BLOCK+0x16) /* Response Queue Out */ + +#define BIU_R2HSTSLO (BIU_BLOCK+0x18) +#define BIU_R2HSTSHI (BIU_BLOCK+0x1A) + +#define BIU_R2HST_INTR (1 << 15) /* RISC to Host Interrupt */ +#define BIU_R2HST_PAUSED (1 << 8) /* RISC paused */ +#define BIU_R2HST_ISTAT_MASK 0x3f /* intr information && status */ +#define ISPR2HST_ROM_MBX_OK 0x1 /* ROM mailbox cmd done ok */ +#define ISPR2HST_ROM_MBX_FAIL 0x2 /* ROM mailbox cmd done fail */ +#define ISPR2HST_MBX_OK 0x10 /* mailbox cmd done ok */ +#define ISPR2HST_MBX_FAIL 0x11 /* mailbox cmd done fail */ +#define ISPR2HST_ASYNC_EVENT 0x12 /* Async Event */ +#define ISPR2HST_RSPQ_UPDATE 0x13 /* Response Queue Update */ +#define ISPR2HST_RQST_UPDATE 0x14 /* Resquest Queue Update */ +#define ISPR2HST_RIO_16 0x15 /* RIO 1-16 */ +#define ISPR2HST_FPOST 0x16 /* Low 16 bits fast post */ +#define ISPR2HST_FPOST_CTIO 0x17 /* Low 16 bits fast post ctio */ + +#define DFIFO_COMMAND (BIU_BLOCK+0x60) /* RW : Command FIFO Port */ +#define RDMA2100_CONTROL DFIFO_COMMAND +#define DFIFO_DATA (BIU_BLOCK+0x62) /* RW : Data FIFO Port */ + +/* + * Putzed DMA register layouts. + */ +#define CDMA_CONF (DMA_BLOCK+0x20) /* RW*: DMA Configuration */ +#define CDMA2100_CONTROL CDMA_CONF +#define CDMA_CONTROL (DMA_BLOCK+0x22) /* RW*: DMA Control */ +#define CDMA_STATUS (DMA_BLOCK+0x24) /* R : DMA Status */ +#define CDMA_FIFO_STS (DMA_BLOCK+0x26) /* R : DMA FIFO Status */ +#define CDMA_COUNT (DMA_BLOCK+0x28) /* RW*: DMA Transfer Count */ +#define CDMA_ADDR0 (DMA_BLOCK+0x2C) /* RW*: DMA Address, Word 0 */ +#define CDMA_ADDR1 (DMA_BLOCK+0x2E) /* RW*: DMA Address, Word 1 */ +#define CDMA_ADDR2 (DMA_BLOCK+0x30) /* RW*: DMA Address, Word 2 */ +#define CDMA_ADDR3 (DMA_BLOCK+0x32) /* RW*: DMA Address, Word 3 */ + +#define DDMA_CONF (DMA_BLOCK+0x40) /* RW*: DMA Configuration */ +#define TDMA2100_CONTROL DDMA_CONF +#define DDMA_CONTROL (DMA_BLOCK+0x42) /* RW*: DMA Control */ +#define DDMA_STATUS (DMA_BLOCK+0x44) /* R : DMA Status */ +#define DDMA_FIFO_STS (DMA_BLOCK+0x46) /* R : DMA FIFO Status */ +#define DDMA_COUNT_LO (DMA_BLOCK+0x48) /* RW*: DMA Xfer Count, Low */ +#define DDMA_COUNT_HI (DMA_BLOCK+0x4A) /* RW*: DMA Xfer Count, High */ +#define DDMA_ADDR0 (DMA_BLOCK+0x4C) /* RW*: DMA Address, Word 0 */ +#define DDMA_ADDR1 (DMA_BLOCK+0x4E) /* RW*: DMA Address, Word 1 */ +/* these are for the 1040A cards */ +#define DDMA_ADDR2 (DMA_BLOCK+0x50) /* RW*: DMA Address, Word 2 */ +#define DDMA_ADDR3 (DMA_BLOCK+0x52) /* RW*: DMA Address, Word 3 */ + + +/* + * Bus Interface Block Register Definitions + */ +/* BUS CONFIGURATION REGISTER #0 */ +#define BIU_CONF0_HW_MASK 0x000F /* Hardware revision mask */ +/* BUS CONFIGURATION REGISTER #1 */ + +#define BIU_SBUS_CONF1_PARITY 0x0100 /* Enable parity checking */ +#define BIU_SBUS_CONF1_FCODE_MASK 0x00F0 /* Fcode cycle mask */ + +#define BIU_PCI_CONF1_FIFO_128 0x0040 /* 128 bytes FIFO threshold */ +#define BIU_PCI_CONF1_FIFO_64 0x0030 /* 64 bytes FIFO threshold */ +#define BIU_PCI_CONF1_FIFO_32 0x0020 /* 32 bytes FIFO threshold */ +#define BIU_PCI_CONF1_FIFO_16 0x0010 /* 16 bytes FIFO threshold */ +#define BIU_BURST_ENABLE 0x0004 /* Global enable Bus bursts */ +#define BIU_SBUS_CONF1_FIFO_64 0x0003 /* 64 bytes FIFO threshold */ +#define BIU_SBUS_CONF1_FIFO_32 0x0002 /* 32 bytes FIFO threshold */ +#define BIU_SBUS_CONF1_FIFO_16 0x0001 /* 16 bytes FIFO threshold */ +#define BIU_SBUS_CONF1_FIFO_8 0x0000 /* 8 bytes FIFO threshold */ +#define BIU_SBUS_CONF1_BURST8 0x0008 /* Enable 8-byte bursts */ +#define BIU_PCI_CONF1_SXP 0x0008 /* SXP register select */ + +#define BIU_PCI1080_CONF1_SXP0 0x0100 /* SXP bank #1 select */ +#define BIU_PCI1080_CONF1_SXP1 0x0200 /* SXP bank #2 select */ +#define BIU_PCI1080_CONF1_DMA 0x0300 /* DMA bank select */ + +/* ISP2100 Bus Control/Status Register */ + +#define BIU2100_ICSR_REGBSEL 0x30 /* RW: register bank select */ +#define BIU2100_RISC_REGS (0 << 4) /* RISC Regs */ +#define BIU2100_FB_REGS (1 << 4) /* FrameBuffer Regs */ +#define BIU2100_FPM0_REGS (2 << 4) /* FPM 0 Regs */ +#define BIU2100_FPM1_REGS (3 << 4) /* FPM 1 Regs */ +#define BIU2100_PCI64 0x04 /* R: 64 Bit PCI slot */ +#define BIU2100_FLASH_ENABLE 0x02 /* RW: Enable Flash RAM */ +#define BIU2100_SOFT_RESET 0x01 +/* SOFT RESET FOR ISP2100 is same bit, but in this register, not ICR */ + + +/* BUS CONTROL REGISTER */ +#define BIU_ICR_ENABLE_DMA_INT 0x0020 /* Enable DMA interrupts */ +#define BIU_ICR_ENABLE_CDMA_INT 0x0010 /* Enable CDMA interrupts */ +#define BIU_ICR_ENABLE_SXP_INT 0x0008 /* Enable SXP interrupts */ +#define BIU_ICR_ENABLE_RISC_INT 0x0004 /* Enable Risc interrupts */ +#define BIU_ICR_ENABLE_ALL_INTS 0x0002 /* Global enable all inter */ +#define BIU_ICR_SOFT_RESET 0x0001 /* Soft Reset of ISP */ + +#define BIU2100_ICR_ENABLE_ALL_INTS 0x8000 +#define BIU2100_ICR_ENA_FPM_INT 0x0020 +#define BIU2100_ICR_ENA_FB_INT 0x0010 +#define BIU2100_ICR_ENA_RISC_INT 0x0008 +#define BIU2100_ICR_ENA_CDMA_INT 0x0004 +#define BIU2100_ICR_ENABLE_RXDMA_INT 0x0002 +#define BIU2100_ICR_ENABLE_TXDMA_INT 0x0001 +#define BIU2100_ICR_DISABLE_ALL_INTS 0x0000 + +#define ENABLE_INTS(isp) (IS_SCSI(isp))? \ + ISP_WRITE(isp, BIU_ICR, BIU_ICR_ENABLE_RISC_INT | BIU_ICR_ENABLE_ALL_INTS) : \ + ISP_WRITE(isp, BIU_ICR, BIU2100_ICR_ENA_RISC_INT | BIU2100_ICR_ENABLE_ALL_INTS) + +#define INTS_ENABLED(isp) ((IS_SCSI(isp))? \ + (ISP_READ(isp, BIU_ICR) & (BIU_ICR_ENABLE_RISC_INT|BIU_ICR_ENABLE_ALL_INTS)) :\ + (ISP_READ(isp, BIU_ICR) & \ + (BIU2100_ICR_ENA_RISC_INT|BIU2100_ICR_ENABLE_ALL_INTS))) + +#define DISABLE_INTS(isp) ISP_WRITE(isp, BIU_ICR, 0) + +/* BUS STATUS REGISTER */ +#define BIU_ISR_DMA_INT 0x0020 /* DMA interrupt pending */ +#define BIU_ISR_CDMA_INT 0x0010 /* CDMA interrupt pending */ +#define BIU_ISR_SXP_INT 0x0008 /* SXP interrupt pending */ +#define BIU_ISR_RISC_INT 0x0004 /* Risc interrupt pending */ +#define BIU_ISR_IPEND 0x0002 /* Global interrupt pending */ + +#define BIU2100_ISR_INT_PENDING 0x8000 /* Global interrupt pending */ +#define BIU2100_ISR_FPM_INT 0x0020 /* FPM interrupt pending */ +#define BIU2100_ISR_FB_INT 0x0010 /* FB interrupt pending */ +#define BIU2100_ISR_RISC_INT 0x0008 /* Risc interrupt pending */ +#define BIU2100_ISR_CDMA_INT 0x0004 /* CDMA interrupt pending */ +#define BIU2100_ISR_RXDMA_INT_PENDING 0x0002 /* Global interrupt pending */ +#define BIU2100_ISR_TXDMA_INT_PENDING 0x0001 /* Global interrupt pending */ + +#define INT_PENDING(isp, isr) (IS_FC(isp)? \ + ((isr & BIU2100_ISR_RISC_INT) != 0) : ((isr & BIU_ISR_RISC_INT) != 0)) + +#define INT_PENDING_MASK(isp) \ + (IS_FC(isp)? BIU2100_ISR_RISC_INT: BIU_ISR_RISC_INT) + +/* BUS SEMAPHORE REGISTER */ +#define BIU_SEMA_STATUS 0x0002 /* Semaphore Status Bit */ +#define BIU_SEMA_LOCK 0x0001 /* Semaphore Lock Bit */ + +/* NVRAM SEMAPHORE REGISTER */ +#define BIU_NVRAM_CLOCK 0x0001 +#define BIU_NVRAM_SELECT 0x0002 +#define BIU_NVRAM_DATAOUT 0x0004 +#define BIU_NVRAM_DATAIN 0x0008 +#define ISP_NVRAM_READ 6 + +/* COMNMAND && DATA DMA CONFIGURATION REGISTER */ +#define DMA_ENABLE_SXP_DMA 0x0008 /* Enable SXP to DMA Data */ +#define DMA_ENABLE_INTS 0x0004 /* Enable interrupts to RISC */ +#define DMA_ENABLE_BURST 0x0002 /* Enable Bus burst trans */ +#define DMA_DMA_DIRECTION 0x0001 /* + * Set DMA direction: + * 0 - DMA FIFO to host + * 1 - Host to DMA FIFO + */ + +/* COMMAND && DATA DMA CONTROL REGISTER */ +#define DMA_CNTRL_SUSPEND_CHAN 0x0010 /* Suspend DMA transfer */ +#define DMA_CNTRL_CLEAR_CHAN 0x0008 /* + * Clear FIFO and DMA Channel, + * reset DMA registers + */ +#define DMA_CNTRL_CLEAR_FIFO 0x0004 /* Clear DMA FIFO */ +#define DMA_CNTRL_RESET_INT 0x0002 /* Clear DMA interrupt */ +#define DMA_CNTRL_STROBE 0x0001 /* Start DMA transfer */ + +/* + * Variants of same for 2100 + */ +#define DMA_CNTRL2100_CLEAR_CHAN 0x0004 +#define DMA_CNTRL2100_RESET_INT 0x0002 + + + +/* DMA STATUS REGISTER */ +#define DMA_SBUS_STATUS_PIPE_MASK 0x00C0 /* DMA Pipeline status mask */ +#define DMA_SBUS_STATUS_CHAN_MASK 0x0030 /* Channel status mask */ +#define DMA_SBUS_STATUS_BUS_PARITY 0x0008 /* Parity Error on bus */ +#define DMA_SBUS_STATUS_BUS_ERR 0x0004 /* Error Detected on bus */ +#define DMA_SBUS_STATUS_TERM_COUNT 0x0002 /* DMA Transfer Completed */ +#define DMA_SBUS_STATUS_INTERRUPT 0x0001 /* Enable DMA channel inter */ + +#define DMA_PCI_STATUS_INTERRUPT 0x8000 /* Enable DMA channel inter */ +#define DMA_PCI_STATUS_RETRY_STAT 0x4000 /* Retry status */ +#define DMA_PCI_STATUS_CHAN_MASK 0x3000 /* Channel status mask */ +#define DMA_PCI_STATUS_FIFO_OVR 0x0100 /* DMA FIFO overrun cond */ +#define DMA_PCI_STATUS_FIFO_UDR 0x0080 /* DMA FIFO underrun cond */ +#define DMA_PCI_STATUS_BUS_ERR 0x0040 /* Error Detected on bus */ +#define DMA_PCI_STATUS_BUS_PARITY 0x0020 /* Parity Error on bus */ +#define DMA_PCI_STATUS_CLR_PEND 0x0010 /* DMA clear pending */ +#define DMA_PCI_STATUS_TERM_COUNT 0x0008 /* DMA Transfer Completed */ +#define DMA_PCI_STATUS_DMA_SUSP 0x0004 /* DMA suspended */ +#define DMA_PCI_STATUS_PIPE_MASK 0x0003 /* DMA Pipeline status mask */ + +/* DMA Status Register, pipeline status bits */ +#define DMA_SBUS_PIPE_FULL 0x00C0 /* Both pipeline stages full */ +#define DMA_SBUS_PIPE_OVERRUN 0x0080 /* Pipeline overrun */ +#define DMA_SBUS_PIPE_STAGE1 0x0040 /* + * Pipeline stage 1 Loaded, + * stage 2 empty + */ +#define DMA_PCI_PIPE_FULL 0x0003 /* Both pipeline stages full */ +#define DMA_PCI_PIPE_OVERRUN 0x0002 /* Pipeline overrun */ +#define DMA_PCI_PIPE_STAGE1 0x0001 /* + * Pipeline stage 1 Loaded, + * stage 2 empty + */ +#define DMA_PIPE_EMPTY 0x0000 /* All pipeline stages empty */ + +/* DMA Status Register, channel status bits */ +#define DMA_SBUS_CHAN_SUSPEND 0x0030 /* Channel error or suspended */ +#define DMA_SBUS_CHAN_TRANSFER 0x0020 /* Chan transfer in progress */ +#define DMA_SBUS_CHAN_ACTIVE 0x0010 /* Chan trans to host active */ +#define DMA_PCI_CHAN_TRANSFER 0x3000 /* Chan transfer in progress */ +#define DMA_PCI_CHAN_SUSPEND 0x2000 /* Channel error or suspended */ +#define DMA_PCI_CHAN_ACTIVE 0x1000 /* Chan trans to host active */ +#define ISP_DMA_CHAN_IDLE 0x0000 /* Chan idle (normal comp) */ + + +/* DMA FIFO STATUS REGISTER */ +#define DMA_FIFO_STATUS_OVERRUN 0x0200 /* FIFO Overrun Condition */ +#define DMA_FIFO_STATUS_UNDERRUN 0x0100 /* FIFO Underrun Condition */ +#define DMA_FIFO_SBUS_COUNT_MASK 0x007F /* FIFO Byte count mask */ +#define DMA_FIFO_PCI_COUNT_MASK 0x00FF /* FIFO Byte count mask */ + +/* + * Mailbox Block Register Offsets + */ + +#define INMAILBOX0 (MBOX_BLOCK+0x0) +#define INMAILBOX1 (MBOX_BLOCK+0x2) +#define INMAILBOX2 (MBOX_BLOCK+0x4) +#define INMAILBOX3 (MBOX_BLOCK+0x6) +#define INMAILBOX4 (MBOX_BLOCK+0x8) +#define INMAILBOX5 (MBOX_BLOCK+0xA) +#define INMAILBOX6 (MBOX_BLOCK+0xC) +#define INMAILBOX7 (MBOX_BLOCK+0xE) + +#define OUTMAILBOX0 (MBOX_BLOCK+0x0) +#define OUTMAILBOX1 (MBOX_BLOCK+0x2) +#define OUTMAILBOX2 (MBOX_BLOCK+0x4) +#define OUTMAILBOX3 (MBOX_BLOCK+0x6) +#define OUTMAILBOX4 (MBOX_BLOCK+0x8) +#define OUTMAILBOX5 (MBOX_BLOCK+0xA) +#define OUTMAILBOX6 (MBOX_BLOCK+0xC) +#define OUTMAILBOX7 (MBOX_BLOCK+0xE) + +#define MBOX_OFF(n) (MBOX_BLOCK + ((n) << 1)) +#define NMBOX(isp) \ + (((((isp)->isp_type & ISP_HA_SCSI) >= ISP_HA_SCSI_1040A) || \ + ((isp)->isp_type & ISP_HA_FC))? 8 : 6) +#define NMBOX_BMASK(isp) \ + (((((isp)->isp_type & ISP_HA_SCSI) >= ISP_HA_SCSI_1040A) || \ + ((isp)->isp_type & ISP_HA_FC))? 0xff : 0x3f) + +#define MAX_MAILBOX 8 + +/* + * Fibre Protocol Module and Frame Buffer Register Offsets/Definitions (2X00). + * NB: The RISC processor must be paused and the appropriate register + * bank selected via BIU2100_CSR bits. + */ + +#define FPM_DIAG_CONFIG (BIU_BLOCK + 0x96) +#define FPM_SOFT_RESET 0x0100 + +#define FBM_CMD (BIU_BLOCK + 0xB8) +#define FBMCMD_FIFO_RESET_ALL 0xA000 + + +/* + * SXP Block Register Offsets + */ +#define SXP_PART_ID (SXP_BLOCK+0x0) /* R : Part ID Code */ +#define SXP_CONFIG1 (SXP_BLOCK+0x2) /* RW*: Configuration Reg #1 */ +#define SXP_CONFIG2 (SXP_BLOCK+0x4) /* RW*: Configuration Reg #2 */ +#define SXP_CONFIG3 (SXP_BLOCK+0x6) /* RW*: Configuration Reg #2 */ +#define SXP_INSTRUCTION (SXP_BLOCK+0xC) /* RW*: Instruction Pointer */ +#define SXP_RETURN_ADDR (SXP_BLOCK+0x10) /* RW*: Return Address */ +#define SXP_COMMAND (SXP_BLOCK+0x14) /* RW*: Command */ +#define SXP_INTERRUPT (SXP_BLOCK+0x18) /* R : Interrupt */ +#define SXP_SEQUENCE (SXP_BLOCK+0x1C) /* RW*: Sequence */ +#define SXP_GROSS_ERR (SXP_BLOCK+0x1E) /* R : Gross Error */ +#define SXP_EXCEPTION (SXP_BLOCK+0x20) /* RW*: Exception Enable */ +#define SXP_OVERRIDE (SXP_BLOCK+0x24) /* RW*: Override */ +#define SXP_LIT_BASE (SXP_BLOCK+0x28) /* RW*: Literal Base */ +#define SXP_USER_FLAGS (SXP_BLOCK+0x2C) /* RW*: User Flags */ +#define SXP_USER_EXCEPT (SXP_BLOCK+0x30) /* RW*: User Exception */ +#define SXP_BREAKPOINT (SXP_BLOCK+0x34) /* RW*: Breakpoint */ +#define SXP_SCSI_ID (SXP_BLOCK+0x40) /* RW*: SCSI ID */ +#define SXP_DEV_CONFIG1 (SXP_BLOCK+0x42) /* RW*: Device Config Reg #1 */ +#define SXP_DEV_CONFIG2 (SXP_BLOCK+0x44) /* RW*: Device Config Reg #2 */ +#define SXP_PHASE_PTR (SXP_BLOCK+0x48) /* RW*: SCSI Phase Pointer */ +#define SXP_BUF_PTR (SXP_BLOCK+0x4C) /* RW*: SCSI Buffer Pointer */ +#define SXP_BUF_CTR (SXP_BLOCK+0x50) /* RW*: SCSI Buffer Counter */ +#define SXP_BUFFER (SXP_BLOCK+0x52) /* RW*: SCSI Buffer */ +#define SXP_BUF_BYTE (SXP_BLOCK+0x54) /* RW*: SCSI Buffer Byte */ +#define SXP_BUF_WD (SXP_BLOCK+0x56) /* RW*: SCSI Buffer Word */ +#define SXP_BUF_WD_TRAN (SXP_BLOCK+0x58) /* RW*: SCSI Buffer Wd xlate */ +#define SXP_FIFO (SXP_BLOCK+0x5A) /* RW*: SCSI FIFO */ +#define SXP_FIFO_STATUS (SXP_BLOCK+0x5C) /* RW*: SCSI FIFO Status */ +#define SXP_FIFO_TOP (SXP_BLOCK+0x5E) /* RW*: SCSI FIFO Top Resid */ +#define SXP_FIFO_BOTTOM (SXP_BLOCK+0x60) /* RW*: SCSI FIFO Bot Resid */ +#define SXP_TRAN_REG (SXP_BLOCK+0x64) /* RW*: SCSI Transferr Reg */ +#define SXP_TRAN_CNT_LO (SXP_BLOCK+0x68) /* RW*: SCSI Trans Count */ +#define SXP_TRAN_CNT_HI (SXP_BLOCK+0x6A) /* RW*: SCSI Trans Count */ +#define SXP_TRAN_CTR_LO (SXP_BLOCK+0x6C) /* RW*: SCSI Trans Counter */ +#define SXP_TRAN_CTR_HI (SXP_BLOCK+0x6E) /* RW*: SCSI Trans Counter */ +#define SXP_ARB_DATA (SXP_BLOCK+0x70) /* R : SCSI Arb Data */ +#define SXP_PINS_CTRL (SXP_BLOCK+0x72) /* RW*: SCSI Control Pins */ +#define SXP_PINS_DATA (SXP_BLOCK+0x74) /* RW*: SCSI Data Pins */ +#define SXP_PINS_DIFF (SXP_BLOCK+0x76) /* RW*: SCSI Diff Pins */ + +/* for 1080/1280/1240 only */ +#define SXP_BANK1_SELECT 0x100 + + +/* SXP CONF1 REGISTER */ +#define SXP_CONF1_ASYNCH_SETUP 0xF000 /* Asynchronous setup time */ +#define SXP_CONF1_SELECTION_UNIT 0x0000 /* Selection time unit */ +#define SXP_CONF1_SELECTION_TIMEOUT 0x0600 /* Selection timeout */ +#define SXP_CONF1_CLOCK_FACTOR 0x00E0 /* Clock factor */ +#define SXP_CONF1_SCSI_ID 0x000F /* SCSI id */ + +/* SXP CONF2 REGISTER */ +#define SXP_CONF2_DISABLE_FILTER 0x0040 /* Disable SCSI rec filters */ +#define SXP_CONF2_REQ_ACK_PULLUPS 0x0020 /* Enable req/ack pullups */ +#define SXP_CONF2_DATA_PULLUPS 0x0010 /* Enable data pullups */ +#define SXP_CONF2_CONFIG_AUTOLOAD 0x0008 /* Enable dev conf auto-load */ +#define SXP_CONF2_RESELECT 0x0002 /* Enable reselection */ +#define SXP_CONF2_SELECT 0x0001 /* Enable selection */ + +/* SXP INTERRUPT REGISTER */ +#define SXP_INT_PARITY_ERR 0x8000 /* Parity error detected */ +#define SXP_INT_GROSS_ERR 0x4000 /* Gross error detected */ +#define SXP_INT_FUNCTION_ABORT 0x2000 /* Last cmd aborted */ +#define SXP_INT_CONDITION_FAILED 0x1000 /* Last cond failed test */ +#define SXP_INT_FIFO_EMPTY 0x0800 /* SCSI FIFO is empty */ +#define SXP_INT_BUF_COUNTER_ZERO 0x0400 /* SCSI buf count == zero */ +#define SXP_INT_XFER_ZERO 0x0200 /* SCSI trans count == zero */ +#define SXP_INT_INT_PENDING 0x0080 /* SXP interrupt pending */ +#define SXP_INT_CMD_RUNNING 0x0040 /* SXP is running a command */ +#define SXP_INT_INT_RETURN_CODE 0x000F /* Interrupt return code */ + + +/* SXP GROSS ERROR REGISTER */ +#define SXP_GROSS_OFFSET_RESID 0x0040 /* Req/Ack offset not zero */ +#define SXP_GROSS_OFFSET_UNDERFLOW 0x0020 /* Req/Ack offset underflow */ +#define SXP_GROSS_OFFSET_OVERFLOW 0x0010 /* Req/Ack offset overflow */ +#define SXP_GROSS_FIFO_UNDERFLOW 0x0008 /* SCSI FIFO underflow */ +#define SXP_GROSS_FIFO_OVERFLOW 0x0004 /* SCSI FIFO overflow */ +#define SXP_GROSS_WRITE_ERR 0x0002 /* SXP and RISC wrote to reg */ +#define SXP_GROSS_ILLEGAL_INST 0x0001 /* Bad inst loaded into SXP */ + +/* SXP EXCEPTION REGISTER */ +#define SXP_EXCEPT_USER_0 0x8000 /* Enable user exception #0 */ +#define SXP_EXCEPT_USER_1 0x4000 /* Enable user exception #1 */ +#define PCI_SXP_EXCEPT_SCAM 0x0400 /* SCAM Selection enable */ +#define SXP_EXCEPT_BUS_FREE 0x0200 /* Enable Bus Free det */ +#define SXP_EXCEPT_TARGET_ATN 0x0100 /* Enable TGT mode atten det */ +#define SXP_EXCEPT_RESELECTED 0x0080 /* Enable ReSEL exc handling */ +#define SXP_EXCEPT_SELECTED 0x0040 /* Enable SEL exc handling */ +#define SXP_EXCEPT_ARBITRATION 0x0020 /* Enable ARB exc handling */ +#define SXP_EXCEPT_GROSS_ERR 0x0010 /* Enable gross error except */ +#define SXP_EXCEPT_BUS_RESET 0x0008 /* Enable Bus Reset except */ + + /* SXP OVERRIDE REGISTER */ +#define SXP_ORIDE_EXT_TRIGGER 0x8000 /* Enable external trigger */ +#define SXP_ORIDE_STEP 0x4000 /* Enable single step mode */ +#define SXP_ORIDE_BREAKPOINT 0x2000 /* Enable breakpoint reg */ +#define SXP_ORIDE_PIN_WRITE 0x1000 /* Enable write to SCSI pins */ +#define SXP_ORIDE_FORCE_OUTPUTS 0x0800 /* Force SCSI outputs on */ +#define SXP_ORIDE_LOOPBACK 0x0400 /* Enable SCSI loopback mode */ +#define SXP_ORIDE_PARITY_TEST 0x0200 /* Enable parity test mode */ +#define SXP_ORIDE_TRISTATE_ENA_PINS 0x0100 /* Tristate SCSI enable pins */ +#define SXP_ORIDE_TRISTATE_PINS 0x0080 /* Tristate SCSI pins */ +#define SXP_ORIDE_FIFO_RESET 0x0008 /* Reset SCSI FIFO */ +#define SXP_ORIDE_CMD_TERMINATE 0x0004 /* Terminate cur SXP com */ +#define SXP_ORIDE_RESET_REG 0x0002 /* Reset SXP registers */ +#define SXP_ORIDE_RESET_MODULE 0x0001 /* Reset SXP module */ + +/* SXP COMMANDS */ +#define SXP_RESET_BUS_CMD 0x300b + +/* SXP SCSI ID REGISTER */ +#define SXP_SELECTING_ID 0x0F00 /* (Re)Selecting id */ +#define SXP_SELECT_ID 0x000F /* Select id */ + +/* SXP DEV CONFIG1 REGISTER */ +#define SXP_DCONF1_SYNC_HOLD 0x7000 /* Synchronous data hold */ +#define SXP_DCONF1_SYNC_SETUP 0x0F00 /* Synchronous data setup */ +#define SXP_DCONF1_SYNC_OFFSET 0x000F /* Synchronous data offset */ + + +/* SXP DEV CONFIG2 REGISTER */ +#define SXP_DCONF2_FLAGS_MASK 0xF000 /* Device flags */ +#define SXP_DCONF2_WIDE 0x0400 /* Enable wide SCSI */ +#define SXP_DCONF2_PARITY 0x0200 /* Enable parity checking */ +#define SXP_DCONF2_BLOCK_MODE 0x0100 /* Enable blk mode xfr count */ +#define SXP_DCONF2_ASSERTION_MASK 0x0007 /* Assersion period mask */ + + +/* SXP PHASE POINTER REGISTER */ +#define SXP_PHASE_STATUS_PTR 0x1000 /* Status buffer offset */ +#define SXP_PHASE_MSG_IN_PTR 0x0700 /* Msg in buffer offset */ +#define SXP_PHASE_COM_PTR 0x00F0 /* Command buffer offset */ +#define SXP_PHASE_MSG_OUT_PTR 0x0007 /* Msg out buffer offset */ + + +/* SXP FIFO STATUS REGISTER */ +#define SXP_FIFO_TOP_RESID 0x8000 /* Top residue reg full */ +#define SXP_FIFO_ACK_RESID 0x4000 /* Wide transfers odd resid */ +#define SXP_FIFO_COUNT_MASK 0x001C /* Words in SXP FIFO */ +#define SXP_FIFO_BOTTOM_RESID 0x0001 /* Bottom residue reg full */ + + +/* SXP CONTROL PINS REGISTER */ +#define SXP_PINS_CON_PHASE 0x8000 /* Scsi phase valid */ +#define SXP_PINS_CON_PARITY_HI 0x0400 /* Parity pin */ +#define SXP_PINS_CON_PARITY_LO 0x0200 /* Parity pin */ +#define SXP_PINS_CON_REQ 0x0100 /* SCSI bus REQUEST */ +#define SXP_PINS_CON_ACK 0x0080 /* SCSI bus ACKNOWLEDGE */ +#define SXP_PINS_CON_RST 0x0040 /* SCSI bus RESET */ +#define SXP_PINS_CON_BSY 0x0020 /* SCSI bus BUSY */ +#define SXP_PINS_CON_SEL 0x0010 /* SCSI bus SELECT */ +#define SXP_PINS_CON_ATN 0x0008 /* SCSI bus ATTENTION */ +#define SXP_PINS_CON_MSG 0x0004 /* SCSI bus MESSAGE */ +#define SXP_PINS_CON_CD 0x0002 /* SCSI bus COMMAND */ +#define SXP_PINS_CON_IO 0x0001 /* SCSI bus INPUT */ + +/* + * Set the hold time for the SCSI Bus Reset to be 250 ms + */ +#define SXP_SCSI_BUS_RESET_HOLD_TIME 250 + +/* SXP DIFF PINS REGISTER */ +#define SXP_PINS_DIFF_SENSE 0x0200 /* DIFFSENS sig on SCSI bus */ +#define SXP_PINS_DIFF_MODE 0x0100 /* DIFFM signal */ +#define SXP_PINS_DIFF_ENABLE_OUTPUT 0x0080 /* Enable SXP SCSI data drv */ +#define SXP_PINS_DIFF_PINS_MASK 0x007C /* Differential control pins */ +#define SXP_PINS_DIFF_TARGET 0x0002 /* Enable SXP target mode */ +#define SXP_PINS_DIFF_INITIATOR 0x0001 /* Enable SXP initiator mode */ + +/* Ultra2 only */ +#define SXP_PINS_LVD_MODE 0x1000 +#define SXP_PINS_HVD_MODE 0x0800 +#define SXP_PINS_SE_MODE 0x0400 + +/* The above have to be put together with the DIFFM pin to make sense */ +#define ISP1080_LVD_MODE (SXP_PINS_LVD_MODE) +#define ISP1080_HVD_MODE (SXP_PINS_HVD_MODE|SXP_PINS_DIFF_MODE) +#define ISP1080_SE_MODE (SXP_PINS_SE_MODE) +#define ISP1080_MODE_MASK \ + (SXP_PINS_LVD_MODE|SXP_PINS_HVD_MODE|SXP_PINS_SE_MODE|SXP_PINS_DIFF_MODE) + +/* + * RISC and Host Command and Control Block Register Offsets + */ + +#define RISC_ACC RISC_BLOCK+0x0 /* RW*: Accumulator */ +#define RISC_R1 RISC_BLOCK+0x2 /* RW*: GP Reg R1 */ +#define RISC_R2 RISC_BLOCK+0x4 /* RW*: GP Reg R2 */ +#define RISC_R3 RISC_BLOCK+0x6 /* RW*: GP Reg R3 */ +#define RISC_R4 RISC_BLOCK+0x8 /* RW*: GP Reg R4 */ +#define RISC_R5 RISC_BLOCK+0xA /* RW*: GP Reg R5 */ +#define RISC_R6 RISC_BLOCK+0xC /* RW*: GP Reg R6 */ +#define RISC_R7 RISC_BLOCK+0xE /* RW*: GP Reg R7 */ +#define RISC_R8 RISC_BLOCK+0x10 /* RW*: GP Reg R8 */ +#define RISC_R9 RISC_BLOCK+0x12 /* RW*: GP Reg R9 */ +#define RISC_R10 RISC_BLOCK+0x14 /* RW*: GP Reg R10 */ +#define RISC_R11 RISC_BLOCK+0x16 /* RW*: GP Reg R11 */ +#define RISC_R12 RISC_BLOCK+0x18 /* RW*: GP Reg R12 */ +#define RISC_R13 RISC_BLOCK+0x1a /* RW*: GP Reg R13 */ +#define RISC_R14 RISC_BLOCK+0x1c /* RW*: GP Reg R14 */ +#define RISC_R15 RISC_BLOCK+0x1e /* RW*: GP Reg R15 */ +#define RISC_PSR RISC_BLOCK+0x20 /* RW*: Processor Status */ +#define RISC_IVR RISC_BLOCK+0x22 /* RW*: Interrupt Vector */ +#define RISC_PCR RISC_BLOCK+0x24 /* RW*: Processor Ctrl */ +#define RISC_RAR0 RISC_BLOCK+0x26 /* RW*: Ram Address #0 */ +#define RISC_RAR1 RISC_BLOCK+0x28 /* RW*: Ram Address #1 */ +#define RISC_LCR RISC_BLOCK+0x2a /* RW*: Loop Counter */ +#define RISC_PC RISC_BLOCK+0x2c /* R : Program Counter */ +#define RISC_MTR RISC_BLOCK+0x2e /* RW*: Memory Timing */ +#define RISC_MTR2100 RISC_BLOCK+0x30 + +#define RISC_EMB RISC_BLOCK+0x30 /* RW*: Ext Mem Boundary */ +#define DUAL_BANK 8 +#define RISC_SP RISC_BLOCK+0x32 /* RW*: Stack Pointer */ +#define RISC_HRL RISC_BLOCK+0x3e /* R *: Hardware Rev Level */ +#define HCCR RISC_BLOCK+0x40 /* RW : Host Command & Ctrl */ +#define BP0 RISC_BLOCK+0x42 /* RW : Processor Brkpt #0 */ +#define BP1 RISC_BLOCK+0x44 /* RW : Processor Brkpt #1 */ +#define TCR RISC_BLOCK+0x46 /* W : Test Control */ +#define TMR RISC_BLOCK+0x48 /* W : Test Mode */ + + +/* PROCESSOR STATUS REGISTER */ +#define RISC_PSR_FORCE_TRUE 0x8000 +#define RISC_PSR_LOOP_COUNT_DONE 0x4000 +#define RISC_PSR_RISC_INT 0x2000 +#define RISC_PSR_TIMER_ROLLOVER 0x1000 +#define RISC_PSR_ALU_OVERFLOW 0x0800 +#define RISC_PSR_ALU_MSB 0x0400 +#define RISC_PSR_ALU_CARRY 0x0200 +#define RISC_PSR_ALU_ZERO 0x0100 + +#define RISC_PSR_PCI_ULTRA 0x0080 +#define RISC_PSR_SBUS_ULTRA 0x0020 + +#define RISC_PSR_DMA_INT 0x0010 +#define RISC_PSR_SXP_INT 0x0008 +#define RISC_PSR_HOST_INT 0x0004 +#define RISC_PSR_INT_PENDING 0x0002 +#define RISC_PSR_FORCE_FALSE 0x0001 + + +/* Host Command and Control */ +#define HCCR_CMD_NOP 0x0000 /* NOP */ +#define HCCR_CMD_RESET 0x1000 /* Reset RISC */ +#define HCCR_CMD_PAUSE 0x2000 /* Pause RISC */ +#define HCCR_CMD_RELEASE 0x3000 /* Release Paused RISC */ +#define HCCR_CMD_STEP 0x4000 /* Single Step RISC */ +#define HCCR_2X00_DISABLE_PARITY_PAUSE 0x4001 /* + * Disable RISC pause on FPM + * parity error. + */ +#define HCCR_CMD_SET_HOST_INT 0x5000 /* Set Host Interrupt */ +#define HCCR_CMD_CLEAR_HOST_INT 0x6000 /* Clear Host Interrupt */ +#define HCCR_CMD_CLEAR_RISC_INT 0x7000 /* Clear RISC interrupt */ +#define HCCR_CMD_BREAKPOINT 0x8000 /* Change breakpoint enables */ +#define PCI_HCCR_CMD_BIOS 0x9000 /* Write BIOS (disable) */ +#define PCI_HCCR_CMD_PARITY 0xA000 /* Write parity enable */ +#define PCI_HCCR_CMD_PARITY_ERR 0xE000 /* Generate parity error */ +#define HCCR_CMD_TEST_MODE 0xF000 /* Set Test Mode */ + +#define ISP2100_HCCR_PARITY_ENABLE_2 0x0400 +#define ISP2100_HCCR_PARITY_ENABLE_1 0x0200 +#define ISP2100_HCCR_PARITY_ENABLE_0 0x0100 +#define ISP2100_HCCR_PARITY 0x0001 + +#define PCI_HCCR_PARITY 0x0400 /* Parity error flag */ +#define PCI_HCCR_PARITY_ENABLE_1 0x0200 /* Parity enable bank 1 */ +#define PCI_HCCR_PARITY_ENABLE_0 0x0100 /* Parity enable bank 0 */ + +#define HCCR_HOST_INT 0x0080 /* R : Host interrupt set */ +#define HCCR_RESET 0x0040 /* R : reset in progress */ +#define HCCR_PAUSE 0x0020 /* R : RISC paused */ + +#define PCI_HCCR_BIOS 0x0001 /* W : BIOS enable */ + +/* + * NVRAM Definitions (PCI cards only) + */ + +#define ISPBSMX(c, byte, shift, mask) \ + (((c)[(byte)] >> (shift)) & (mask)) +/* + * Qlogic 1020/1040 NVRAM is an array of 128 bytes. + * + * Some portion of the front of this is for general host adapter properties + * This is followed by an array of per-target parameters, and is tailed off + * with a checksum xor byte at offset 127. For non-byte entities data is + * stored in Little Endian order. + */ + +#define ISP_NVRAM_SIZE 128 + +#define ISP_NVRAM_VERSION(c) (c)[4] +#define ISP_NVRAM_FIFO_THRESHOLD(c) ISPBSMX(c, 5, 0, 0x03) +#define ISP_NVRAM_BIOS_DISABLE(c) ISPBSMX(c, 5, 2, 0x01) +#define ISP_NVRAM_HBA_ENABLE(c) ISPBSMX(c, 5, 3, 0x01) +#define ISP_NVRAM_INITIATOR_ID(c) ISPBSMX(c, 5, 4, 0x0f) +#define ISP_NVRAM_BUS_RESET_DELAY(c) (c)[6] +#define ISP_NVRAM_BUS_RETRY_COUNT(c) (c)[7] +#define ISP_NVRAM_BUS_RETRY_DELAY(c) (c)[8] +#define ISP_NVRAM_ASYNC_DATA_SETUP_TIME(c) ISPBSMX(c, 9, 0, 0x0f) +#define ISP_NVRAM_REQ_ACK_ACTIVE_NEGATION(c) ISPBSMX(c, 9, 4, 0x01) +#define ISP_NVRAM_DATA_LINE_ACTIVE_NEGATION(c) ISPBSMX(c, 9, 5, 0x01) +#define ISP_NVRAM_DATA_DMA_BURST_ENABLE(c) ISPBSMX(c, 9, 6, 0x01) +#define ISP_NVRAM_CMD_DMA_BURST_ENABLE(c) ISPBSMX(c, 9, 7, 0x01) +#define ISP_NVRAM_TAG_AGE_LIMIT(c) (c)[10] +#define ISP_NVRAM_LOWTRM_ENABLE(c) ISPBSMX(c, 11, 0, 0x01) +#define ISP_NVRAM_HITRM_ENABLE(c) ISPBSMX(c, 11, 1, 0x01) +#define ISP_NVRAM_PCMC_BURST_ENABLE(c) ISPBSMX(c, 11, 2, 0x01) +#define ISP_NVRAM_ENABLE_60_MHZ(c) ISPBSMX(c, 11, 3, 0x01) +#define ISP_NVRAM_SCSI_RESET_DISABLE(c) ISPBSMX(c, 11, 4, 0x01) +#define ISP_NVRAM_ENABLE_AUTO_TERM(c) ISPBSMX(c, 11, 5, 0x01) +#define ISP_NVRAM_FIFO_THRESHOLD_128(c) ISPBSMX(c, 11, 6, 0x01) +#define ISP_NVRAM_AUTO_TERM_SUPPORT(c) ISPBSMX(c, 11, 7, 0x01) +#define ISP_NVRAM_SELECTION_TIMEOUT(c) (((c)[12]) | ((c)[13] << 8)) +#define ISP_NVRAM_MAX_QUEUE_DEPTH(c) (((c)[14]) | ((c)[15] << 8)) +#define ISP_NVRAM_SCSI_BUS_SIZE(c) ISPBSMX(c, 16, 0, 0x01) +#define ISP_NVRAM_SCSI_BUS_TYPE(c) ISPBSMX(c, 16, 1, 0x01) +#define ISP_NVRAM_ADAPTER_CLK_SPEED(c) ISPBSMX(c, 16, 2, 0x01) +#define ISP_NVRAM_SOFT_TERM_SUPPORT(c) ISPBSMX(c, 16, 3, 0x01) +#define ISP_NVRAM_FLASH_ONBOARD(c) ISPBSMX(c, 16, 4, 0x01) +#define ISP_NVRAM_FAST_MTTR_ENABLE(c) ISPBSMX(c, 22, 0, 0x01) + +#define ISP_NVRAM_TARGOFF 28 +#define ISP_NVARM_TARGSIZE 6 +#define _IxT(tgt, tidx) \ + (ISP_NVRAM_TARGOFF + (ISP_NVARM_TARGSIZE * (tgt)) + (tidx)) +#define ISP_NVRAM_TGT_RENEG(c, t) ISPBSMX(c, _IxT(t, 0), 0, 0x01) +#define ISP_NVRAM_TGT_QFRZ(c, t) ISPBSMX(c, _IxT(t, 0), 1, 0x01) +#define ISP_NVRAM_TGT_ARQ(c, t) ISPBSMX(c, _IxT(t, 0), 2, 0x01) +#define ISP_NVRAM_TGT_TQING(c, t) ISPBSMX(c, _IxT(t, 0), 3, 0x01) +#define ISP_NVRAM_TGT_SYNC(c, t) ISPBSMX(c, _IxT(t, 0), 4, 0x01) +#define ISP_NVRAM_TGT_WIDE(c, t) ISPBSMX(c, _IxT(t, 0), 5, 0x01) +#define ISP_NVRAM_TGT_PARITY(c, t) ISPBSMX(c, _IxT(t, 0), 6, 0x01) +#define ISP_NVRAM_TGT_DISC(c, t) ISPBSMX(c, _IxT(t, 0), 7, 0x01) +#define ISP_NVRAM_TGT_EXEC_THROTTLE(c, t) ISPBSMX(c, _IxT(t, 1), 0, 0xff) +#define ISP_NVRAM_TGT_SYNC_PERIOD(c, t) ISPBSMX(c, _IxT(t, 2), 0, 0xff) +#define ISP_NVRAM_TGT_SYNC_OFFSET(c, t) ISPBSMX(c, _IxT(t, 3), 0, 0x0f) +#define ISP_NVRAM_TGT_DEVICE_ENABLE(c, t) ISPBSMX(c, _IxT(t, 3), 4, 0x01) +#define ISP_NVRAM_TGT_LUN_DISABLE(c, t) ISPBSMX(c, _IxT(t, 3), 5, 0x01) + +/* + * Qlogic 1080/1240 NVRAM is an array of 256 bytes. + * + * Some portion of the front of this is for general host adapter properties + * This is followed by an array of per-target parameters, and is tailed off + * with a checksum xor byte at offset 256. For non-byte entities data is + * stored in Little Endian order. + */ + +#define ISP1080_NVRAM_SIZE 256 + +#define ISP1080_NVRAM_VERSION(c) ISP_NVRAM_VERSION(c) + +/* Offset 5 */ +/* + u_int8_t bios_configuration_mode :2; + u_int8_t bios_disable :1; + u_int8_t selectable_scsi_boot_enable :1; + u_int8_t cd_rom_boot_enable :1; + u_int8_t disable_loading_risc_code :1; + u_int8_t enable_64bit_addressing :1; + u_int8_t unused_7 :1; + */ + +/* Offsets 6, 7 */ +/* + u_int8_t boot_lun_number :5; + u_int8_t scsi_bus_number :1; + u_int8_t unused_6 :1; + u_int8_t unused_7 :1; + u_int8_t boot_target_number :4; + u_int8_t unused_12 :1; + u_int8_t unused_13 :1; + u_int8_t unused_14 :1; + u_int8_t unused_15 :1; + */ + +#define ISP1080_NVRAM_HBA_ENABLE(c) ISPBSMX(c, 16, 3, 0x01) + +#define ISP1080_NVRAM_BURST_ENABLE(c) ISPBSMX(c, 16, 1, 0x01) +#define ISP1080_NVRAM_FIFO_THRESHOLD(c) ISPBSMX(c, 16, 4, 0x0f) + +#define ISP1080_NVRAM_AUTO_TERM_SUPPORT(c) ISPBSMX(c, 17, 7, 0x01) +#define ISP1080_NVRAM_BUS0_TERM_MODE(c) ISPBSMX(c, 17, 0, 0x03) +#define ISP1080_NVRAM_BUS1_TERM_MODE(c) ISPBSMX(c, 17, 2, 0x03) + +#define ISP1080_ISP_PARAMETER(c) \ + (((c)[18]) | ((c)[19] << 8)) + +#define ISP1080_FAST_POST(c) ISPBSMX(c, 20, 0, 0x01) +#define ISP1080_REPORT_LVD_TRANSITION(c) ISPBSMX(c, 20, 1, 0x01) + +#define ISP1080_BUS1_OFF 112 + +#define ISP1080_NVRAM_INITIATOR_ID(c, b) \ + ISPBSMX(c, ((b == 0)? 0 : ISP1080_BUS1_OFF) + 24, 0, 0x0f) +#define ISP1080_NVRAM_BUS_RESET_DELAY(c, b) \ + (c)[((b == 0)? 0 : ISP1080_BUS1_OFF) + 25] +#define ISP1080_NVRAM_BUS_RETRY_COUNT(c, b) \ + (c)[((b == 0)? 0 : ISP1080_BUS1_OFF) + 26] +#define ISP1080_NVRAM_BUS_RETRY_DELAY(c, b) \ + (c)[((b == 0)? 0 : ISP1080_BUS1_OFF) + 27] + +#define ISP1080_NVRAM_ASYNC_DATA_SETUP_TIME(c, b) \ + ISPBSMX(c, ((b == 0)? 0 : ISP1080_BUS1_OFF) + 28, 0, 0x0f) +#define ISP1080_NVRAM_REQ_ACK_ACTIVE_NEGATION(c, b) \ + ISPBSMX(c, ((b == 0)? 0 : ISP1080_BUS1_OFF) + 28, 4, 0x01) +#define ISP1080_NVRAM_DATA_LINE_ACTIVE_NEGATION(c, b) \ + ISPBSMX(c, ((b == 0)? 0 : ISP1080_BUS1_OFF) + 28, 5, 0x01) +#define ISP1080_NVRAM_SELECTION_TIMEOUT(c, b) \ + (((c)[((b == 0)? 0 : ISP1080_BUS1_OFF) + 30]) | \ + ((c)[((b == 0)? 0 : ISP1080_BUS1_OFF) + 31] << 8)) +#define ISP1080_NVRAM_MAX_QUEUE_DEPTH(c, b) \ + (((c)[((b == 0)? 0 : ISP1080_BUS1_OFF) + 32]) | \ + ((c)[((b == 0)? 0 : ISP1080_BUS1_OFF) + 33] << 8)) + +#define ISP1080_NVRAM_TARGOFF(b) \ + ((b == 0)? 40: (40 + ISP1080_BUS1_OFF)) +#define ISP1080_NVRAM_TARGSIZE 6 +#define _IxT8(tgt, tidx, b) \ + (ISP1080_NVRAM_TARGOFF((b)) + (ISP1080_NVRAM_TARGSIZE * (tgt)) + (tidx)) + +#define ISP1080_NVRAM_TGT_RENEG(c, t, b) \ + ISPBSMX(c, _IxT8(t, 0, (b)), 0, 0x01) +#define ISP1080_NVRAM_TGT_QFRZ(c, t, b) \ + ISPBSMX(c, _IxT8(t, 0, (b)), 1, 0x01) +#define ISP1080_NVRAM_TGT_ARQ(c, t, b) \ + ISPBSMX(c, _IxT8(t, 0, (b)), 2, 0x01) +#define ISP1080_NVRAM_TGT_TQING(c, t, b) \ + ISPBSMX(c, _IxT8(t, 0, (b)), 3, 0x01) +#define ISP1080_NVRAM_TGT_SYNC(c, t, b) \ + ISPBSMX(c, _IxT8(t, 0, (b)), 4, 0x01) +#define ISP1080_NVRAM_TGT_WIDE(c, t, b) \ + ISPBSMX(c, _IxT8(t, 0, (b)), 5, 0x01) +#define ISP1080_NVRAM_TGT_PARITY(c, t, b) \ + ISPBSMX(c, _IxT8(t, 0, (b)), 6, 0x01) +#define ISP1080_NVRAM_TGT_DISC(c, t, b) \ + ISPBSMX(c, _IxT8(t, 0, (b)), 7, 0x01) +#define ISP1080_NVRAM_TGT_EXEC_THROTTLE(c, t, b) \ + ISPBSMX(c, _IxT8(t, 1, (b)), 0, 0xff) +#define ISP1080_NVRAM_TGT_SYNC_PERIOD(c, t, b) \ + ISPBSMX(c, _IxT8(t, 2, (b)), 0, 0xff) +#define ISP1080_NVRAM_TGT_SYNC_OFFSET(c, t, b) \ + ISPBSMX(c, _IxT8(t, 3, (b)), 0, 0x0f) +#define ISP1080_NVRAM_TGT_DEVICE_ENABLE(c, t, b) \ + ISPBSMX(c, _IxT8(t, 3, (b)), 4, 0x01) +#define ISP1080_NVRAM_TGT_LUN_DISABLE(c, t, b) \ + ISPBSMX(c, _IxT8(t, 3, (b)), 5, 0x01) + +#define ISP12160_NVRAM_HBA_ENABLE ISP1080_NVRAM_HBA_ENABLE +#define ISP12160_NVRAM_BURST_ENABLE ISP1080_NVRAM_BURST_ENABLE +#define ISP12160_NVRAM_FIFO_THRESHOLD ISP1080_NVRAM_FIFO_THRESHOLD +#define ISP12160_NVRAM_AUTO_TERM_SUPPORT ISP1080_NVRAM_AUTO_TERM_SUPPORT +#define ISP12160_NVRAM_BUS0_TERM_MODE ISP1080_NVRAM_BUS0_TERM_MODE +#define ISP12160_NVRAM_BUS1_TERM_MODE ISP1080_NVRAM_BUS1_TERM_MODE +#define ISP12160_ISP_PARAMETER ISP12160_ISP_PARAMETER +#define ISP12160_FAST_POST ISP1080_FAST_POST +#define ISP12160_REPORT_LVD_TRANSITION ISP1080_REPORT_LVD_TRANSTION + +#define ISP12160_NVRAM_INITIATOR_ID \ + ISP1080_NVRAM_INITIATOR_ID +#define ISP12160_NVRAM_BUS_RESET_DELAY \ + ISP1080_NVRAM_BUS_RESET_DELAY +#define ISP12160_NVRAM_BUS_RETRY_COUNT \ + ISP1080_NVRAM_BUS_RETRY_COUNT +#define ISP12160_NVRAM_BUS_RETRY_DELAY \ + ISP1080_NVRAM_BUS_RETRY_DELAY +#define ISP12160_NVRAM_ASYNC_DATA_SETUP_TIME \ + ISP1080_NVRAM_ASYNC_DATA_SETUP_TIME +#define ISP12160_NVRAM_REQ_ACK_ACTIVE_NEGATION \ + ISP1080_NVRAM_REQ_ACK_ACTIVE_NEGATION +#define ISP12160_NVRAM_DATA_LINE_ACTIVE_NEGATION \ + ISP1080_NVRAM_DATA_LINE_ACTIVE_NEGATION +#define ISP12160_NVRAM_SELECTION_TIMEOUT \ + ISP1080_NVRAM_SELECTION_TIMEOUT +#define ISP12160_NVRAM_MAX_QUEUE_DEPTH \ + ISP1080_NVRAM_MAX_QUEUE_DEPTH + + +#define ISP12160_BUS0_OFF 24 +#define ISP12160_BUS1_OFF 136 + +#define ISP12160_NVRAM_TARGOFF(b) \ + (((b == 0)? ISP12160_BUS0_OFF : ISP12160_BUS1_OFF) + 16) + +#define ISP12160_NVRAM_TARGSIZE 6 +#define _IxT16(tgt, tidx, b) \ + (ISP12160_NVRAM_TARGOFF((b))+(ISP12160_NVRAM_TARGSIZE * (tgt))+(tidx)) + +#define ISP12160_NVRAM_TGT_RENEG(c, t, b) \ + ISPBSMX(c, _IxT16(t, 0, (b)), 0, 0x01) +#define ISP12160_NVRAM_TGT_QFRZ(c, t, b) \ + ISPBSMX(c, _IxT16(t, 0, (b)), 1, 0x01) +#define ISP12160_NVRAM_TGT_ARQ(c, t, b) \ + ISPBSMX(c, _IxT16(t, 0, (b)), 2, 0x01) +#define ISP12160_NVRAM_TGT_TQING(c, t, b) \ + ISPBSMX(c, _IxT16(t, 0, (b)), 3, 0x01) +#define ISP12160_NVRAM_TGT_SYNC(c, t, b) \ + ISPBSMX(c, _IxT16(t, 0, (b)), 4, 0x01) +#define ISP12160_NVRAM_TGT_WIDE(c, t, b) \ + ISPBSMX(c, _IxT16(t, 0, (b)), 5, 0x01) +#define ISP12160_NVRAM_TGT_PARITY(c, t, b) \ + ISPBSMX(c, _IxT16(t, 0, (b)), 6, 0x01) +#define ISP12160_NVRAM_TGT_DISC(c, t, b) \ + ISPBSMX(c, _IxT16(t, 0, (b)), 7, 0x01) + +#define ISP12160_NVRAM_TGT_EXEC_THROTTLE(c, t, b) \ + ISPBSMX(c, _IxT16(t, 1, (b)), 0, 0xff) +#define ISP12160_NVRAM_TGT_SYNC_PERIOD(c, t, b) \ + ISPBSMX(c, _IxT16(t, 2, (b)), 0, 0xff) + +#define ISP12160_NVRAM_TGT_SYNC_OFFSET(c, t, b) \ + ISPBSMX(c, _IxT16(t, 3, (b)), 0, 0x1f) +#define ISP12160_NVRAM_TGT_DEVICE_ENABLE(c, t, b) \ + ISPBSMX(c, _IxT16(t, 3, (b)), 5, 0x01) + +#define ISP12160_NVRAM_PPR_OPTIONS(c, t, b) \ + ISPBSMX(c, _IxT16(t, 4, (b)), 0, 0x0f) +#define ISP12160_NVRAM_PPR_WIDTH(c, t, b) \ + ISPBSMX(c, _IxT16(t, 4, (b)), 4, 0x03) +#define ISP12160_NVRAM_PPR_ENABLE(c, t, b) \ + ISPBSMX(c, _IxT16(t, 4, (b)), 7, 0x01) + +/* + * Qlogic 2XXX NVRAM is an array of 256 bytes. + * + * Some portion of the front of this is for general RISC engine parameters, + * mostly reflecting the state of the last INITIALIZE FIRMWARE mailbox command. + * + * This is followed by some general host adapter parameters, and ends with + * a checksum xor byte at offset 255. For non-byte entities data is stored + * in Little Endian order. + */ +#define ISP2100_NVRAM_SIZE 256 +/* ISP_NVRAM_VERSION is in same overall place */ +#define ISP2100_NVRAM_RISCVER(c) (c)[6] +#define ISP2100_NVRAM_OPTIONS(c) (c)[8] +#define ISP2100_NVRAM_MAXFRAMELENGTH(c) (((c)[10]) | ((c)[11] << 8)) +#define ISP2100_NVRAM_MAXIOCBALLOCATION(c) (((c)[12]) | ((c)[13] << 8)) +#define ISP2100_NVRAM_EXECUTION_THROTTLE(c) (((c)[14]) | ((c)[15] << 8)) +#define ISP2100_NVRAM_RETRY_COUNT(c) (c)[16] +#define ISP2100_NVRAM_RETRY_DELAY(c) (c)[17] + +#define ISP2100_NVRAM_PORT_NAME(c) (\ + (((u_int64_t)(c)[18]) << 56) | \ + (((u_int64_t)(c)[19]) << 48) | \ + (((u_int64_t)(c)[20]) << 40) | \ + (((u_int64_t)(c)[21]) << 32) | \ + (((u_int64_t)(c)[22]) << 24) | \ + (((u_int64_t)(c)[23]) << 16) | \ + (((u_int64_t)(c)[24]) << 8) | \ + (((u_int64_t)(c)[25]) << 0)) + +#define ISP2100_NVRAM_HARDLOOPID(c) (c)[26] + +#define ISP2200_NVRAM_NODE_NAME(c) (\ + (((u_int64_t)(c)[30]) << 56) | \ + (((u_int64_t)(c)[31]) << 48) | \ + (((u_int64_t)(c)[32]) << 40) | \ + (((u_int64_t)(c)[33]) << 32) | \ + (((u_int64_t)(c)[34]) << 24) | \ + (((u_int64_t)(c)[35]) << 16) | \ + (((u_int64_t)(c)[36]) << 8) | \ + (((u_int64_t)(c)[37]) << 0)) + +#define ISP2100_NVRAM_HBA_OPTIONS(c) (c)[70] +#define ISP2100_NVRAM_HBA_DISABLE(c) ISPBSMX(c, 70, 0, 0x01) +#define ISP2100_NVRAM_BIOS_DISABLE(c) ISPBSMX(c, 70, 1, 0x01) +#define ISP2100_NVRAM_LUN_DISABLE(c) ISPBSMX(c, 70, 2, 0x01) +#define ISP2100_NVRAM_ENABLE_SELECT_BOOT(c) ISPBSMX(c, 70, 3, 0x01) +#define ISP2100_NVRAM_DISABLE_CODELOAD(c) ISPBSMX(c, 70, 4, 0x01) +#define ISP2100_NVRAM_SET_CACHELINESZ(c) ISPBSMX(c, 70, 5, 0x01) + +#define ISP2100_NVRAM_BOOT_NODE_NAME(c) (\ + (((u_int64_t)(c)[72]) << 56) | \ + (((u_int64_t)(c)[73]) << 48) | \ + (((u_int64_t)(c)[74]) << 40) | \ + (((u_int64_t)(c)[75]) << 32) | \ + (((u_int64_t)(c)[76]) << 24) | \ + (((u_int64_t)(c)[77]) << 16) | \ + (((u_int64_t)(c)[78]) << 8) | \ + (((u_int64_t)(c)[79]) << 0)) + +#define ISP2100_NVRAM_BOOT_LUN(c) (c)[80] + +#define ISP2200_HBA_FEATURES(c) (c)[232] | ((c)[233] << 8) + +/* + * Firmware Crash Dump + * + * QLogic needs specific information format when they look at firmware crashes. + * + * This is incredibly kernel memory consumptive (to say the least), so this + * code is only compiled in when needed. + */ + +#define QLA2200_RISC_IMAGE_DUMP_SIZE \ + (1 * sizeof (u_int16_t)) + /* 'used' flag (also HBA type) */ \ + (352 * sizeof (u_int16_t)) + /* RISC registers */ \ + (61440 * sizeof (u_int16_t)) /* RISC SRAM (offset 0x1000..0xffff) */ +#define QLA2300_RISC_IMAGE_DUMP_SIZE \ + (1 * sizeof (u_int16_t)) + /* 'used' flag (also HBA type) */ \ + (464 * sizeof (u_int16_t)) + /* RISC registers */ \ + (63488 * sizeof (u_int16_t)) + /* RISC SRAM (0x0800..0xffff) */ \ + (4096 * sizeof (u_int16_t)) + /* RISC SRAM (0x10000..0x10FFF) */ \ + (61440 * sizeof (u_int16_t)) /* RISC SRAM (0x11000..0x1FFFF) */ +/* the larger of the two */ +#define ISP_CRASH_IMAGE_SIZE QLA2300_RISC_IMAGE_DUMP_SIZE +#endif /* _ISPREG_H */ diff -puN /dev/null drivers/scsi/isp/common/isp_target.c --- /dev/null 2002-08-30 16:31:37.000000000 -0700 +++ 25-akpm/drivers/scsi/isp/common/isp_target.c 2003-02-14 00:20:12.000000000 -0800 @@ -0,0 +1,1186 @@ +/* @(#)isp_target.c 1.17 */ +/* + * Machine and OS Independent Target Mode Code for the Qlogic SCSI/FC adapters. + * + * Copyright (c) 1999, 2000, 2001 by Matthew Jacob + * All rights reserved. + * mjacob@feral.com + * + * 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 immediately at the beginning of the file, without modification, + * this list of conditions, and the following disclaimer. + * 2. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * 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. + */ + +/* + * Bug fixes gratefully acknowledged from: + * Oded Kedem + */ +/* + * Include header file appropriate for platform we're building on. + */ + +#ifdef __NetBSD__ +#include +#endif +#ifdef __FreeBSD__ +#include +#endif +#ifdef __OpenBSD__ +#include +#endif +#ifdef __linux__ +#include "isp_linux.h" +#endif + +#ifdef ISP_TARGET_MODE +static const char atiocope[] = + "ATIO returned for lun %d because it was in the middle of Bus Device Reset " + "on bus %d"; +static const char atior[] = + "ATIO returned on for lun %d on from IID %d because a Bus Reset occurred " + "on bus %d"; + +static void isp_got_msg(struct ispsoftc *, int, in_entry_t *); +static void isp_got_msg_fc(struct ispsoftc *, int, in_fcentry_t *); +static void isp_notify_ack(struct ispsoftc *, void *); +static void isp_handle_atio(struct ispsoftc *, at_entry_t *); +static void isp_handle_atio2(struct ispsoftc *, at2_entry_t *); +static void isp_handle_ctio(struct ispsoftc *, ct_entry_t *); +static void isp_handle_ctio2(struct ispsoftc *, ct2_entry_t *); + +/* + * The Qlogic driver gets an interrupt to look at response queue entries. + * Some of these are status completions for initiatior mode commands, but + * if target mode is enabled, we get a whole wad of response queue entries + * to be handled here. + * + * Basically the split into 3 main groups: Lun Enable/Modification responses, + * SCSI Command processing, and Immediate Notification events. + * + * You start by writing a request queue entry to enable target mode (and + * establish some resource limitations which you can modify later). + * The f/w responds with a LUN ENABLE or LUN MODIFY response with + * the status of this action. If the enable was successful, you can expect... + * + * Response queue entries with SCSI commands encapsulate show up in an ATIO + * (Accept Target IO) type- sometimes with enough info to stop the command at + * this level. Ultimately the driver has to feed back to the f/w's request + * queue a sequence of CTIOs (continue target I/O) that describe data to + * be moved and/or status to be sent) and finally finishing with sending + * to the f/w's response queue an ATIO which then completes the handshake + * with the f/w for that command. There's a lot of variations on this theme, + * including flags you can set in the CTIO for the Qlogic 2X00 fibre channel + * cards that 'auto-replenish' the f/w's ATIO count, but this is the basic + * gist of it. + * + * The third group that can show up in the response queue are Immediate + * Notification events. These include things like notifications of SCSI bus + * resets, or Bus Device Reset messages or other messages received. This + * a classic oddbins area. It can get a little weird because you then turn + * around and acknowledge the Immediate Notify by writing an entry onto the + * request queue and then the f/w turns around and gives you an acknowledgement + * to *your* acknowledgement on the response queue (the idea being to let + * the f/w tell you when the event is *really* over I guess). + * + */ + + +/* + * A new response queue entry has arrived. The interrupt service code + * has already swizzled it into the platform dependent from canonical form. + * + * Because of the way this driver is designed, unfortunately most of the + * actual synchronization work has to be done in the platform specific + * code- we have no synchroniation primitives in the common code. + */ + +int +isp_target_notify(struct ispsoftc *isp, void *vptr, u_int16_t *optrp) +{ + u_int16_t status, seqid; + union { + at_entry_t *atiop; + at2_entry_t *at2iop; + ct_entry_t *ctiop; + ct2_entry_t *ct2iop; + lun_entry_t *lunenp; + in_entry_t *inotp; + in_fcentry_t *inot_fcp; + na_entry_t *nackp; + na_fcentry_t *nack_fcp; + isphdr_t *hp; + void * *vp; +#define atiop unp.atiop +#define at2iop unp.at2iop +#define ctiop unp.ctiop +#define ct2iop unp.ct2iop +#define lunenp unp.lunenp +#define inotp unp.inotp +#define inot_fcp unp.inot_fcp +#define nackp unp.nackp +#define nack_fcp unp.nack_fcp +#define hdrp unp.hp + } unp; + u_int8_t local[QENTRY_LEN]; + int bus, type, rval = 1; + + type = isp_get_response_type(isp, (isphdr_t *)vptr); + unp.vp = vptr; + + ISP_TDQE(isp, "isp_target_notify", (int) *optrp, vptr); + + switch(type) { + case RQSTYPE_ATIO: + isp_get_atio(isp, atiop, (at_entry_t *) local); + isp_handle_atio(isp, (at_entry_t *) local); + break; + case RQSTYPE_CTIO: + isp_get_ctio(isp, ctiop, (ct_entry_t *) local); + isp_handle_ctio(isp, (ct_entry_t *) local); + break; + case RQSTYPE_ATIO2: + isp_get_atio2(isp, at2iop, (at2_entry_t *) local); + isp_handle_atio2(isp, (at2_entry_t *) local); + break; + case RQSTYPE_CTIO2: + isp_get_ctio2(isp, ct2iop, (ct2_entry_t *) local); + isp_handle_ctio2(isp, (ct2_entry_t *) local); + break; + case RQSTYPE_ENABLE_LUN: + case RQSTYPE_MODIFY_LUN: + isp_get_enable_lun(isp, lunenp, (lun_entry_t *) local); + (void) isp_async(isp, ISPASYNC_TARGET_ACTION, local); + break; + + case RQSTYPE_NOTIFY: + /* + * Either the ISP received a SCSI message it can't + * handle, or it's returning an Immed. Notify entry + * we sent. We can send Immed. Notify entries to + * increment the firmware's resource count for them + * (we set this initially in the Enable Lun entry). + */ + bus = 0; + if (IS_FC(isp)) { + isp_get_notify_fc(isp, inot_fcp, (in_fcentry_t *)local); + inot_fcp = (in_fcentry_t *) local; + status = inot_fcp->in_status; + seqid = inot_fcp->in_seqid; + } else { + isp_get_notify(isp, inotp, (in_entry_t *)local); + inotp = (in_entry_t *) local; + status = inotp->in_status & 0xff; + seqid = inotp->in_seqid; + if (IS_DUALBUS(isp)) { + bus = GET_BUS_VAL(inotp->in_iid); + SET_BUS_VAL(inotp->in_iid, 0); + } + } + isp_prt(isp, ISP_LOGTDEBUG0, + "Immediate Notify On Bus %d, status=0x%x seqid=0x%x", + bus, status, seqid); + + /* + * ACK it right away. + */ + isp_notify_ack(isp, (status == IN_RESET)? NULL : local); + switch (status) { + case IN_RESET: + (void) isp_async(isp, ISPASYNC_BUS_RESET, &bus); + break; + case IN_MSG_RECEIVED: + case IN_IDE_RECEIVED: + if (IS_FC(isp)) { + isp_got_msg_fc(isp, bus, (in_fcentry_t *)local); + } else { + isp_got_msg(isp, bus, (in_entry_t *)local); + } + break; + case IN_RSRC_UNAVAIL: + isp_prt(isp, ISP_LOGWARN, "Firmware out of ATIOs"); + break; + case IN_PORT_LOGOUT: + case IN_ABORT_TASK: + case IN_PORT_CHANGED: + case IN_GLOBAL_LOGO: + (void) isp_async(isp, ISPASYNC_TARGET_ACTION, &local); + break; + default: + isp_prt(isp, ISP_LOGERR, + "bad status (0x%x) in isp_target_notify", status); + break; + } + break; + + case RQSTYPE_NOTIFY_ACK: + /* + * The ISP is acknowledging our acknowledgement of an + * Immediate Notify entry for some asynchronous event. + */ + if (IS_FC(isp)) { + isp_get_notify_ack_fc(isp, nack_fcp, + (na_fcentry_t *)local); + nack_fcp = (na_fcentry_t *)local; + isp_prt(isp, ISP_LOGTDEBUG1, + "Notify Ack status=0x%x seqid 0x%x", + nack_fcp->na_status, nack_fcp->na_seqid); + } else { + isp_get_notify_ack(isp, nackp, (na_entry_t *)local); + nackp = (na_entry_t *)local; + isp_prt(isp, ISP_LOGTDEBUG1, + "Notify Ack event 0x%x status=0x%x seqid 0x%x", + nackp->na_event, nackp->na_status, nackp->na_seqid); + } + break; + default: + isp_prt(isp, ISP_LOGERR, + "Unknown entry type 0x%x in isp_target_notify", type); + rval = 0; + break; + } +#undef atiop +#undef at2iop +#undef ctiop +#undef ct2iop +#undef lunenp +#undef inotp +#undef inot_fcp +#undef nackp +#undef nack_fcp +#undef hdrp + return (rval); +} + + +/* + * Toggle (on/off) target mode for bus/target/lun + * + * The caller has checked for overlap and legality. + * + * Note that not all of bus, target or lun can be paid attention to. + * Note also that this action will not be complete until the f/w writes + * response entry. The caller is responsible for synchronizing this. + */ +int +isp_lun_cmd(struct ispsoftc *isp, int cmd, int bus, int tgt, int lun, + int cmd_cnt, int inot_cnt, u_int32_t opaque) +{ + lun_entry_t el; + u_int16_t nxti, optr; + void *outp; + + + MEMZERO(&el, sizeof (el)); + if (IS_DUALBUS(isp)) { + el.le_rsvd = (bus & 0x1) << 7; + } + el.le_cmd_count = cmd_cnt; + el.le_in_count = inot_cnt; + if (cmd == RQSTYPE_ENABLE_LUN) { + if (IS_SCSI(isp)) { + el.le_flags = LUN_TQAE|LUN_DISAD; + el.le_cdb6len = 12; + el.le_cdb7len = 12; + } + } else if (cmd == -RQSTYPE_ENABLE_LUN) { + cmd = RQSTYPE_ENABLE_LUN; + el.le_cmd_count = 0; + el.le_in_count = 0; + } else if (cmd == -RQSTYPE_MODIFY_LUN) { + cmd = RQSTYPE_MODIFY_LUN; + el.le_ops = LUN_CCDECR | LUN_INDECR; + } else { + el.le_ops = LUN_CCINCR | LUN_ININCR; + } + el.le_header.rqs_entry_type = cmd; + el.le_header.rqs_entry_count = 1; + el.le_reserved = opaque; + if (IS_SCSI(isp)) { + el.le_tgt = tgt; + el.le_lun = lun; + } else if ((FCPARAM(isp)->isp_fwattr & ISP_FW_ATTR_SCCLUN) == 0) { + el.le_lun = lun; + } + el.le_timeout = 2; + + if (isp_getrqentry(isp, &nxti, &optr, &outp)) { + isp_prt(isp, ISP_LOGERR, + "Request Queue Overflow in isp_lun_cmd"); + return (-1); + } + ISP_TDQE(isp, "isp_lun_cmd", (int) optr, &el); + isp_put_enable_lun(isp, &el, outp); + ISP_ADD_REQUEST(isp, nxti); + return (0); +} + + +int +isp_target_put_entry(struct ispsoftc *isp, void *ap) +{ + void *outp; + u_int16_t nxti, optr; + u_int8_t etype = ((isphdr_t *) ap)->rqs_entry_type; + + if (isp_getrqentry(isp, &nxti, &optr, &outp)) { + isp_prt(isp, ISP_LOGWARN, + "Request Queue Overflow in isp_target_put_entry"); + return (-1); + } + switch (etype) { + case RQSTYPE_ATIO: + isp_put_atio(isp, (at_entry_t *) ap, (at_entry_t *) outp); + break; + case RQSTYPE_ATIO2: + isp_put_atio2(isp, (at2_entry_t *) ap, (at2_entry_t *) outp); + break; + case RQSTYPE_CTIO: + isp_put_ctio(isp, (ct_entry_t *) ap, (ct_entry_t *) outp); + break; + case RQSTYPE_CTIO2: + isp_put_ctio2(isp, (ct2_entry_t *) ap, (ct2_entry_t *) outp); + break; + default: + isp_prt(isp, ISP_LOGERR, + "Unknown type 0x%x in isp_put_entry", etype); + return (-1); + } + + ISP_TDQE(isp, "isp_target_put_entry", (int) optr, ap);; + ISP_ADD_REQUEST(isp, nxti); + return (0); +} + +int +isp_target_put_atio(struct ispsoftc *isp, void *arg) +{ + union { + at_entry_t _atio; + at2_entry_t _atio2; + } atun; + + MEMZERO(&atun, sizeof atun); + if (IS_FC(isp)) { + at2_entry_t *aep = arg; + atun._atio2.at_header.rqs_entry_type = RQSTYPE_ATIO2; + atun._atio2.at_header.rqs_entry_count = 1; + if (FCPARAM(isp)->isp_fwattr & ISP_FW_ATTR_SCCLUN) { + atun._atio2.at_scclun = (u_int16_t) aep->at_scclun; + } else { + atun._atio2.at_lun = (u_int8_t) aep->at_lun; + } + atun._atio2.at_status = CT_OK; + } else { + at_entry_t *aep = arg; + atun._atio.at_header.rqs_entry_type = RQSTYPE_ATIO; + atun._atio.at_header.rqs_entry_count = 1; + atun._atio.at_handle = aep->at_handle; + atun._atio.at_iid = aep->at_iid; + atun._atio.at_tgt = aep->at_tgt; + atun._atio.at_lun = aep->at_lun; + atun._atio.at_tag_type = aep->at_tag_type; + atun._atio.at_tag_val = aep->at_tag_val; + atun._atio.at_status = (aep->at_flags & AT_TQAE); + atun._atio.at_status |= CT_OK; + } + return (isp_target_put_entry(isp, &atun)); +} + +/* + * Command completion- both for handling cases of no resources or + * no blackhole driver, or other cases where we have to, inline, + * finish the command sanely, or for normal command completion. + * + * The 'completion' code value has the scsi status byte in the low 8 bits. + * If status is a CHECK CONDITION and bit 8 is nonzero, then bits 12..15 have + * the sense key and bits 16..23 have the ASCQ and bits 24..31 have the ASC + * values. + * + * NB: the key, asc, ascq, cannot be used for parallel SCSI as it doesn't + * NB: inline SCSI sense reporting. As such, we lose this information. XXX. + * + * For both parallel && fibre channel, we use the feature that does + * an automatic resource autoreplenish so we don't have then later do + * put of an atio to replenish the f/w's resource count. + */ + +int +isp_endcmd(struct ispsoftc *isp, void *arg, u_int32_t code, u_int16_t hdl) +{ + int sts; + union { + ct_entry_t _ctio; + ct2_entry_t _ctio2; + } un; + + MEMZERO(&un, sizeof un); + sts = code & 0xff; + + if (IS_FC(isp)) { + at2_entry_t *aep = arg; + ct2_entry_t *cto = &un._ctio2; + + cto->ct_header.rqs_entry_type = RQSTYPE_CTIO2; + cto->ct_header.rqs_entry_count = 1; + cto->ct_iid = aep->at_iid; + if ((FCPARAM(isp)->isp_fwattr & ISP_FW_ATTR_SCCLUN) == 0) { + cto->ct_lun = aep->at_lun; + } + cto->ct_rxid = aep->at_rxid; + cto->rsp.m1.ct_scsi_status = sts & 0xff; + cto->ct_flags = CT2_SENDSTATUS | CT2_NO_DATA | CT2_FLAG_MODE1; + if (hdl == 0) { + cto->ct_flags |= CT2_CCINCR; + } + if (aep->at_datalen) { + cto->ct_resid = aep->at_datalen; + cto->rsp.m1.ct_scsi_status |= CT2_DATA_UNDER; + } + if ((sts & 0xff) == SCSI_CHECK && (sts & ECMD_SVALID)) { + cto->rsp.m1.ct_resp[0] = 0xf0; + cto->rsp.m1.ct_resp[2] = (code >> 12) & 0xf; + cto->rsp.m1.ct_resp[7] = 8; + cto->rsp.m1.ct_resp[12] = (code >> 24) & 0xff; + cto->rsp.m1.ct_resp[13] = (code >> 16) & 0xff; + cto->rsp.m1.ct_senselen = 16; + cto->rsp.m1.ct_scsi_status |= CT2_SNSLEN_VALID; + } + cto->ct_syshandle = hdl; + } else { + at_entry_t *aep = arg; + ct_entry_t *cto = &un._ctio; + + cto->ct_header.rqs_entry_type = RQSTYPE_CTIO; + cto->ct_header.rqs_entry_count = 1; + cto->ct_fwhandle = aep->at_handle; + cto->ct_iid = aep->at_iid; + cto->ct_tgt = aep->at_tgt; + cto->ct_lun = aep->at_lun; + cto->ct_tag_type = aep->at_tag_type; + cto->ct_tag_val = aep->at_tag_val; + if (aep->at_flags & AT_TQAE) { + cto->ct_flags |= CT_TQAE; + } + cto->ct_flags = CT_SENDSTATUS | CT_NO_DATA; + if (hdl == 0) { + cto->ct_flags |= CT_CCINCR; + } + cto->ct_scsi_status = sts; + cto->ct_syshandle = hdl; + } + return (isp_target_put_entry(isp, &un)); +} + +int +isp_target_async(struct ispsoftc *isp, int bus, int event) +{ + tmd_event_t evt; + tmd_msg_t msg; + + switch (event) { + /* + * These three we handle here to propagate an effective bus reset + * upstream, but these do not require any immediate notify actions + * so we return when done. + */ + case ASYNC_LIP_F8: + case ASYNC_LIP_OCCURRED: + case ASYNC_LOOP_UP: + case ASYNC_LOOP_DOWN: + case ASYNC_LOOP_RESET: + case ASYNC_PTPMODE: + /* + * These don't require any immediate notify actions. We used + * treat them like SCSI Bus Resets, but that was just plain + * wrong. Let the normal CTIO completion report what occurred. + */ + return (0); + + case ASYNC_BUS_RESET: + case ASYNC_TIMEOUT_RESET: + if (IS_FC(isp)) { + return (0); /* we'll be getting an inotify instead */ + } + evt.ev_bus = bus; + evt.ev_event = event; + (void) isp_async(isp, ISPASYNC_TARGET_EVENT, &evt); + break; + case ASYNC_DEVICE_RESET: + /* + * Bus Device Reset resets a specific target, so + * we pass this as a synthesized message. + */ + MEMZERO(&msg, sizeof msg); + if (IS_FC(isp)) { + msg.nt_iid = FCPARAM(isp)->isp_loopid; + } else { + msg.nt_iid = SDPARAM(isp)->isp_initiator_id; + } + msg.nt_bus = bus; + msg.nt_msg[0] = MSG_BUS_DEV_RESET; + (void) isp_async(isp, ISPASYNC_TARGET_MESSAGE, &msg); + break; + default: + isp_prt(isp, ISP_LOGERR, + "isp_target_async: unknown event 0x%x", event); + break; + } + if (isp->isp_state == ISP_RUNSTATE) + isp_notify_ack(isp, NULL); + return(0); +} + + +/* + * Process a received message. + * The ISP firmware can handle most messages, there are only + * a few that we need to deal with: + * - abort: clean up the current command + * - abort tag and clear queue + */ + +static void +isp_got_msg(struct ispsoftc *isp, int bus, in_entry_t *inp) +{ + u_int8_t status = inp->in_status & ~QLTM_SVALID; + + if (status == IN_IDE_RECEIVED || status == IN_MSG_RECEIVED) { + tmd_msg_t msg; + + MEMZERO(&msg, sizeof (msg)); + msg.nt_bus = bus; + msg.nt_iid = inp->in_iid; + msg.nt_tgt = inp->in_tgt; + msg.nt_lun = inp->in_lun; + msg.nt_tagtype = inp->in_tag_type; + msg.nt_tagval = inp->in_tag_val; + MEMCPY(msg.nt_msg, inp->in_msg, IN_MSGLEN); + (void) isp_async(isp, ISPASYNC_TARGET_MESSAGE, &msg); + } else { + isp_prt(isp, ISP_LOGERR, + "unknown immediate notify status 0x%x", inp->in_status); + } +} + +/* + * Synthesize a message from the task management flags in a FCP_CMND_IU. + */ +static void +isp_got_msg_fc(struct ispsoftc *isp, int bus, in_fcentry_t *inp) +{ + int lun; + static const char f1[] = "%s from iid %d lun %d seq 0x%x"; + static const char f2[] = + "unknown %s 0x%x lun %d iid %d task flags 0x%x seq 0x%x\n"; + + if (FCPARAM(isp)->isp_fwattr & ISP_FW_ATTR_SCCLUN) { + lun = inp->in_scclun; + } else { + lun = inp->in_lun; + } + + if (inp->in_status != IN_MSG_RECEIVED) { + isp_prt(isp, ISP_LOGINFO, f2, "immediate notify status", + inp->in_status, lun, inp->in_iid, + inp->in_task_flags, inp->in_seqid); + } else { + tmd_msg_t msg; + + MEMZERO(&msg, sizeof (msg)); + msg.nt_bus = bus; + msg.nt_iid = inp->in_iid; + msg.nt_tagval = inp->in_seqid; + msg.nt_lun = lun; + + if (inp->in_task_flags & TASK_FLAGS_ABORT_TASK) { + isp_prt(isp, ISP_LOGINFO, f1, "ABORT TASK", + inp->in_iid, msg.nt_lun, inp->in_seqid); + msg.nt_msg[0] = MSG_ABORT_TAG; + } else if (inp->in_task_flags & TASK_FLAGS_CLEAR_TASK_SET) { + isp_prt(isp, ISP_LOGINFO, f1, "CLEAR TASK SET", + inp->in_iid, msg.nt_lun, inp->in_seqid); + msg.nt_msg[0] = MSG_CLEAR_QUEUE; + } else if (inp->in_task_flags & TASK_FLAGS_TARGET_RESET) { + isp_prt(isp, ISP_LOGINFO, f1, "TARGET RESET", + inp->in_iid, msg.nt_lun, inp->in_seqid); + msg.nt_msg[0] = MSG_BUS_DEV_RESET; + } else if (inp->in_task_flags & TASK_FLAGS_CLEAR_ACA) { + isp_prt(isp, ISP_LOGINFO, f1, "CLEAR ACA", + inp->in_iid, msg.nt_lun, inp->in_seqid); + /* ???? */ + msg.nt_msg[0] = MSG_REL_RECOVERY; + } else if (inp->in_task_flags & TASK_FLAGS_TERMINATE_TASK) { + isp_prt(isp, ISP_LOGINFO, f1, "TERMINATE TASK", + inp->in_iid, msg.nt_lun, inp->in_seqid); + msg.nt_msg[0] = MSG_TERM_IO_PROC; + } else { + isp_prt(isp, ISP_LOGWARN, f2, "task flag", + inp->in_status, msg.nt_lun, inp->in_iid, + inp->in_task_flags, inp->in_seqid); + } + if (msg.nt_msg[0]) { + (void) isp_async(isp, ISPASYNC_TARGET_MESSAGE, &msg); + } + } +} + +static void +isp_notify_ack(struct ispsoftc *isp, void *arg) +{ + char storage[QENTRY_LEN]; + u_int16_t nxti, optr; + void *outp; + + if (isp_getrqentry(isp, &nxti, &optr, &outp)) { + isp_prt(isp, ISP_LOGWARN, + "Request Queue Overflow For isp_notify_ack"); + return; + } + + MEMZERO(storage, QENTRY_LEN); + + if (IS_FC(isp)) { + na_fcentry_t *na = (na_fcentry_t *) storage; + if (arg) { + in_fcentry_t *inp = arg; + MEMCPY(storage, arg, sizeof (isphdr_t)); + na->na_iid = inp->in_iid; + if (FCPARAM(isp)->isp_fwattr & ISP_FW_ATTR_SCCLUN) { + na->na_lun = inp->in_scclun; + } else { + na->na_lun = inp->in_lun; + } + na->na_task_flags = inp->in_task_flags; + na->na_seqid = inp->in_seqid; + na->na_flags = NAFC_RCOUNT; + na->na_status = inp->in_status; + if (inp->in_status == IN_RESET) { + na->na_flags |= NAFC_RST_CLRD; + } + } else { + na->na_flags = NAFC_RST_CLRD; + } + na->na_header.rqs_entry_type = RQSTYPE_NOTIFY_ACK; + na->na_header.rqs_entry_count = 1; + isp_put_notify_ack_fc(isp, na, (na_fcentry_t *)outp); + } else { + na_entry_t *na = (na_entry_t *) storage; + if (arg) { + in_entry_t *inp = arg; + MEMCPY(storage, arg, sizeof (isphdr_t)); + na->na_iid = inp->in_iid; + na->na_lun = inp->in_lun; + na->na_tgt = inp->in_tgt; + na->na_seqid = inp->in_seqid; + if (inp->in_status == IN_RESET) { + na->na_event = NA_RST_CLRD; + } + } else { + na->na_event = NA_RST_CLRD; + } + na->na_header.rqs_entry_type = RQSTYPE_NOTIFY_ACK; + na->na_header.rqs_entry_count = 1; + isp_put_notify_ack(isp, na, (na_entry_t *)outp); + } + ISP_TDQE(isp, "isp_notify_ack", (int) optr, storage); + ISP_ADD_REQUEST(isp, nxti); +} + +static void +isp_handle_atio(struct ispsoftc *isp, at_entry_t *aep) +{ + int lun; + lun = aep->at_lun; + /* + * The firmware status (except for the QLTM_SVALID bit) indicates + * why this ATIO was sent to us. + * + * If QLTM_SVALID is set, the firware has recommended Sense Data. + * + * If the DISCONNECTS DISABLED bit is set in the flags field, + * we're still connected on the SCSI bus - i.e. the initiator + * did not set DiscPriv in the identify message. We don't care + * about this so it's ignored. + */ + + switch(aep->at_status & ~QLTM_SVALID) { + case AT_PATH_INVALID: + /* + * ATIO rejected by the firmware due to disabled lun. + */ + isp_prt(isp, ISP_LOGERR, + "rejected ATIO for disabled lun %d", lun); + break; + case AT_NOCAP: + /* + * Requested Capability not available + * We sent an ATIO that overflowed the firmware's + * command resource count. + */ + isp_prt(isp, ISP_LOGERR, + "rejected ATIO for lun %d because of command count" + " overflow", lun); + break; + + case AT_BDR_MSG: + /* + * If we send an ATIO to the firmware to increment + * its command resource count, and the firmware is + * recovering from a Bus Device Reset, it returns + * the ATIO with this status. We set the command + * resource count in the Enable Lun entry and do + * not increment it. Therefore we should never get + * this status here. + */ + isp_prt(isp, ISP_LOGERR, atiocope, lun, + GET_BUS_VAL(aep->at_iid)); + break; + + case AT_CDB: /* Got a CDB */ + case AT_PHASE_ERROR: /* Bus Phase Sequence Error */ + /* + * Punt to platform specific layer. + */ + (void) isp_async(isp, ISPASYNC_TARGET_ACTION, aep); + break; + + case AT_RESET: + /* + * A bus reset came along an blew away this command. Why + * they do this in addition the async event code stuff, + * I dunno. + * + * Ignore it because the async event will clear things + * up for us. + */ + isp_prt(isp, ISP_LOGWARN, atior, lun, + GET_IID_VAL(aep->at_iid), GET_BUS_VAL(aep->at_iid)); + break; + + + default: + isp_prt(isp, ISP_LOGERR, + "Unknown ATIO status 0x%x from initiator %d for lun %d", + aep->at_status, aep->at_iid, lun); + (void) isp_target_put_atio(isp, aep); + break; + } +} + +static void +isp_handle_atio2(struct ispsoftc *isp, at2_entry_t *aep) +{ + int lun; + + if (FCPARAM(isp)->isp_fwattr & ISP_FW_ATTR_SCCLUN) { + lun = aep->at_scclun; + } else { + lun = aep->at_lun; + } + + /* + * The firmware status (except for the QLTM_SVALID bit) indicates + * why this ATIO was sent to us. + * + * If QLTM_SVALID is set, the firware has recommended Sense Data. + * + * If the DISCONNECTS DISABLED bit is set in the flags field, + * we're still connected on the SCSI bus - i.e. the initiator + * did not set DiscPriv in the identify message. We don't care + * about this so it's ignored. + */ + + switch(aep->at_status & ~QLTM_SVALID) { + case AT_PATH_INVALID: + /* + * ATIO rejected by the firmware due to disabled lun. + */ + isp_prt(isp, ISP_LOGERR, + "rejected ATIO2 for disabled lun %d", lun); + break; + case AT_NOCAP: + /* + * Requested Capability not available + * We sent an ATIO that overflowed the firmware's + * command resource count. + */ + isp_prt(isp, ISP_LOGERR, + "rejected ATIO2 for lun %d- command count overflow", lun); + break; + + case AT_BDR_MSG: + /* + * If we send an ATIO to the firmware to increment + * its command resource count, and the firmware is + * recovering from a Bus Device Reset, it returns + * the ATIO with this status. We set the command + * resource count in the Enable Lun entry and no + * not increment it. Therefore we should never get + * this status here. + */ + isp_prt(isp, ISP_LOGERR, atiocope, lun, 0); + break; + + case AT_CDB: /* Got a CDB */ + /* + * Punt to platform specific layer. + */ + (void) isp_async(isp, ISPASYNC_TARGET_ACTION, aep); + break; + + case AT_RESET: + /* + * A bus reset came along an blew away this command. Why + * they do this in addition the async event code stuff, + * I dunno. + * + * Ignore it because the async event will clear things + * up for us. + */ + isp_prt(isp, ISP_LOGERR, atior, lun, aep->at_iid, 0); + break; + + + default: + isp_prt(isp, ISP_LOGERR, + "Unknown ATIO2 status 0x%x from initiator %d for lun %d", + aep->at_status, aep->at_iid, lun); + (void) isp_target_put_atio(isp, aep); + break; + } +} + +static void +isp_handle_ctio(struct ispsoftc *isp, ct_entry_t *ct) +{ + void *xs; + int pl = ISP_LOGTDEBUG2; + char *fmsg = NULL; + + if (ct->ct_syshandle) { + xs = isp_find_xs(isp, ct->ct_syshandle); + if (xs == NULL) + pl = ISP_LOGALL; + } else { + xs = NULL; + } + + switch(ct->ct_status & ~QLTM_SVALID) { + case CT_OK: + /* + * There are generally 3 possibilities as to why we'd get + * this condition: + * We disconnected after receiving a CDB. + * We sent or received data. + * We sent status & command complete. + */ + + if (ct->ct_flags & CT_SENDSTATUS) { + break; + } else if ((ct->ct_flags & CT_DATAMASK) == CT_NO_DATA) { + /* + * Nothing to do in this case. + */ + isp_prt(isp, pl, "CTIO- iid %d disconnected OK", + ct->ct_iid); + return; + } + break; + + case CT_BDR_MSG: + /* + * Bus Device Reset message received or the SCSI Bus has + * been Reset; the firmware has gone to Bus Free. + * + * The firmware generates an async mailbox interupt to + * notify us of this and returns outstanding CTIOs with this + * status. These CTIOs are handled in that same way as + * CT_ABORTED ones, so just fall through here. + */ + fmsg = "Bus Device Reset"; + /*FALLTHROUGH*/ + case CT_RESET: + if (fmsg == NULL) + fmsg = "Bus Reset"; + /*FALLTHROUGH*/ + case CT_ABORTED: + /* + * When an Abort message is received the firmware goes to + * Bus Free and returns all outstanding CTIOs with the status + * set, then sends us an Immediate Notify entry. + */ + if (fmsg == NULL) + fmsg = "ABORT TAG message sent by Initiator"; + + isp_prt(isp, ISP_LOGWARN, "CTIO destroyed by %s", fmsg); + break; + + case CT_INVAL: + /* + * CTIO rejected by the firmware due to disabled lun. + * "Cannot Happen". + */ + isp_prt(isp, ISP_LOGERR, + "Firmware rejected CTIO for disabled lun %d", + ct->ct_lun); + break; + + case CT_NOPATH: + /* + * CTIO rejected by the firmware due "no path for the + * nondisconnecting nexus specified". This means that + * we tried to access the bus while a non-disconnecting + * command is in process. + */ + isp_prt(isp, ISP_LOGERR, + "Firmware rejected CTIO for bad nexus %d/%d/%d", + ct->ct_iid, ct->ct_tgt, ct->ct_lun); + break; + + case CT_RSELTMO: + fmsg = "Reselection"; + /*FALLTHROUGH*/ + case CT_TIMEOUT: + if (fmsg == NULL) + fmsg = "Command"; + isp_prt(isp, ISP_LOGERR, "Firmware timed out on %s", fmsg); + break; + + case CT_PANIC: + if (fmsg == NULL) + fmsg = "Unrecoverable Error"; + /*FALLTHROUGH*/ + case CT_ERR: + if (fmsg == NULL) + fmsg = "Completed with Error"; + /*FALLTHROUGH*/ + case CT_PHASE_ERROR: + if (fmsg == NULL) + fmsg = "Phase Sequence Error"; + /*FALLTHROUGH*/ + case CT_TERMINATED: + if (fmsg == NULL) + fmsg = "terminated by TERMINATE TRANSFER"; + /*FALLTHROUGH*/ + case CT_NOACK: + if (fmsg == NULL) + fmsg = "unacknowledged Immediate Notify pending"; + isp_prt(isp, ISP_LOGERR, "CTIO returned by f/w- %s", fmsg); + break; + default: + isp_prt(isp, ISP_LOGERR, "Unknown CTIO status 0x%x", + ct->ct_status & ~QLTM_SVALID); + break; + } + + if (xs == NULL) { + /* + * There may be more than one CTIO for a data transfer, + * or this may be a status CTIO we're not monitoring. + * + * The assumption is that they'll all be returned in the + * order we got them. + */ + if (ct->ct_syshandle == 0) { + if ((ct->ct_flags & CT_SENDSTATUS) == 0) { + isp_prt(isp, pl, + "intermediate CTIO completed ok"); + } else { + isp_prt(isp, pl, + "unmonitored CTIO completed ok"); + } + } else { + isp_prt(isp, pl, + "NO xs for CTIO (handle 0x%x) status 0x%x", + ct->ct_syshandle, ct->ct_status & ~QLTM_SVALID); + } + } else { + /* + * Final CTIO completed. Release DMA resources and + * notify platform dependent layers. + */ + if ((ct->ct_flags & CT_DATAMASK) != CT_NO_DATA) { + ISP_DMAFREE(isp, xs, ct->ct_syshandle); + } + isp_prt(isp, pl, "final CTIO complete"); + /* + * The platform layer will destroy the handle if appropriate. + */ + (void) isp_async(isp, ISPASYNC_TARGET_ACTION, ct); + } +} + +static void +isp_handle_ctio2(struct ispsoftc *isp, ct2_entry_t *ct) +{ + XS_T *xs; + int pl = ISP_LOGTDEBUG2; + char *fmsg = NULL; + + if (ct->ct_syshandle) { + xs = isp_find_xs(isp, ct->ct_syshandle); + if (xs == NULL) + pl = ISP_LOGALL; + } else { + xs = NULL; + } + + switch(ct->ct_status & ~QLTM_SVALID) { + case CT_BUS_ERROR: + isp_prt(isp, ISP_LOGERR, "PCI DMA Bus Error"); + /* FALL Through */ + case CT_DATA_OVER: + case CT_DATA_UNDER: + case CT_OK: + /* + * There are generally 2 possibilities as to why we'd get + * this condition: + * We sent or received data. + * We sent status & command complete. + */ + + break; + + case CT_BDR_MSG: + /* + * Target Reset function received. + * + * The firmware generates an async mailbox interupt to + * notify us of this and returns outstanding CTIOs with this + * status. These CTIOs are handled in that same way as + * CT_ABORTED ones, so just fall through here. + */ + fmsg = "TARGET RESET Task Management Function Received"; + /*FALLTHROUGH*/ + case CT_RESET: + if (fmsg == NULL) + fmsg = "LIP Reset"; + /*FALLTHROUGH*/ + case CT_ABORTED: + /* + * When an Abort message is received the firmware goes to + * Bus Free and returns all outstanding CTIOs with the status + * set, then sends us an Immediate Notify entry. + */ + if (fmsg == NULL) + fmsg = "ABORT Task Management Function Received"; + + isp_prt(isp, ISP_LOGERR, "CTIO2 destroyed by %s", fmsg); + break; + + case CT_INVAL: + /* + * CTIO rejected by the firmware - invalid data direction. + */ + isp_prt(isp, ISP_LOGERR, "CTIO2 had wrong data directiond"); + break; + + case CT_RSELTMO: + fmsg = "failure to reconnect to initiator"; + /*FALLTHROUGH*/ + case CT_TIMEOUT: + if (fmsg == NULL) + fmsg = "command"; + isp_prt(isp, ISP_LOGERR, "Firmware timed out on %s", fmsg); + break; + + case CT_ERR: + fmsg = "Completed with Error"; + /*FALLTHROUGH*/ + case CT_LOGOUT: + if (fmsg == NULL) + fmsg = "Port Logout"; + /*FALLTHROUGH*/ + case CT_PORTNOTAVAIL: + if (fmsg == NULL) + fmsg = "Port not available"; + case CT_PORTCHANGED: + if (fmsg == NULL) + fmsg = "Port Changed"; + case CT_NOACK: + if (fmsg == NULL) + fmsg = "unacknowledged Immediate Notify pending"; + isp_prt(isp, ISP_LOGERR, "CTIO returned by f/w- %s", fmsg); + break; + + case CT_INVRXID: + /* + * CTIO rejected by the firmware because an invalid RX_ID. + * Just print a message. + */ + isp_prt(isp, ISP_LOGERR, + "CTIO2 completed with Invalid RX_ID 0x%x", ct->ct_rxid); + break; + + default: + isp_prt(isp, ISP_LOGERR, "Unknown CTIO2 status 0x%x", + ct->ct_status & ~QLTM_SVALID); + break; + } + + if (xs == NULL) { + /* + * There may be more than one CTIO for a data transfer, + * or this may be a status CTIO we're not monitoring. + * + * The assumption is that they'll all be returned in the + * order we got them. + */ + if (ct->ct_syshandle == 0) { + if ((ct->ct_flags & CT_SENDSTATUS) == 0) { + isp_prt(isp, pl, + "intermediate CTIO completed ok"); + } else { + isp_prt(isp, pl, + "unmonitored CTIO completed ok"); + } + } else { + isp_prt(isp, pl, + "NO xs for CTIO (handle 0x%x) status 0x%x", + ct->ct_syshandle, ct->ct_status & ~QLTM_SVALID); + } + } else { + if ((ct->ct_flags & CT2_DATAMASK) != CT2_NO_DATA) { + ISP_DMAFREE(isp, xs, ct->ct_syshandle); + } + if (ct->ct_flags & CT_SENDSTATUS) { + /* + * Sent status and command complete. + * + * We're now really done with this command, so we + * punt to the platform dependent layers because + * only there can we do the appropriate command + * complete thread synchronization. + */ + isp_prt(isp, pl, "status CTIO complete"); + } else { + /* + * Final CTIO completed. Release DMA resources and + * notify platform dependent layers. + */ + isp_prt(isp, pl, "data CTIO complete"); + } + (void) isp_async(isp, ISPASYNC_TARGET_ACTION, ct); + /* + * The platform layer will destroy the handle if appropriate. + */ + } +} +#endif diff -puN /dev/null drivers/scsi/isp/common/isp_target.h --- /dev/null 2002-08-30 16:31:37.000000000 -0700 +++ 25-akpm/drivers/scsi/isp/common/isp_target.h 2003-02-14 00:20:12.000000000 -0800 @@ -0,0 +1,558 @@ +/* @(#)isp_target.h 1.16 */ +/* + * Qlogic Target Mode Structure and Flag Definitions + * + * Copyright (c) 1997, 1998 + * Patrick Stirling + * pms@psconsult.com + * All rights reserved. + * + * Additional Copyright (c) 1999, 2000, 2001 + * Matthew Jacob + * mjacob@feral.com + * 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 immediately at the beginning of the file, without modification, + * this list of conditions, and the following disclaimer. + * 2. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * 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 + * 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. + * + */ +#ifndef _ISP_TARGET_H +#define _ISP_TARGET_H + +/* + * Defines for all entry types + */ +#define QLTM_SVALID 0x80 +#define QLTM_SENSELEN 18 + +/* + * Structure for Enable Lun and Modify Lun queue entries + */ +typedef struct { + isphdr_t le_header; + u_int32_t le_reserved; + u_int8_t le_lun; + u_int8_t le_rsvd; + u_int8_t le_ops; /* Modify LUN only */ + u_int8_t le_tgt; /* Not for FC */ + u_int32_t le_flags; /* Not for FC */ + u_int8_t le_status; + u_int8_t le_reserved2; + u_int8_t le_cmd_count; + u_int8_t le_in_count; + u_int8_t le_cdb6len; /* Not for FC */ + u_int8_t le_cdb7len; /* Not for FC */ + u_int16_t le_timeout; + u_int16_t le_reserved3[20]; +} lun_entry_t; + +/* + * le_flags values + */ +#define LUN_TQAE 0x00000002 /* bit1 Tagged Queue Action Enable */ +#define LUN_DSSM 0x01000000 /* bit24 Disable Sending SDP Message */ +#define LUN_DISAD 0x02000000 /* bit25 Disable autodisconnect */ +#define LUN_DM 0x40000000 /* bit30 Disconnects Mandatory */ + +/* + * le_ops values + */ +#define LUN_CCINCR 0x01 /* increment command count */ +#define LUN_CCDECR 0x02 /* decrement command count */ +#define LUN_ININCR 0x40 /* increment immed. notify count */ +#define LUN_INDECR 0x80 /* decrement immed. notify count */ + +/* + * le_status values + */ +#define LUN_OK 0x01 /* we be rockin' */ +#define LUN_ERR 0x04 /* request completed with error */ +#define LUN_INVAL 0x06 /* invalid request */ +#define LUN_NOCAP 0x16 /* can't provide requested capability */ +#define LUN_ENABLED 0x3E /* LUN already enabled */ + +/* + * Immediate Notify Entry structure + */ +#define IN_MSGLEN 8 /* 8 bytes */ +#define IN_RSVDLEN 8 /* 8 words */ +typedef struct { + isphdr_t in_header; + u_int32_t in_reserved; + u_int8_t in_lun; /* lun */ + u_int8_t in_iid; /* initiator */ + u_int8_t in_reserved2; + u_int8_t in_tgt; /* target */ + u_int32_t in_flags; + u_int8_t in_status; + u_int8_t in_rsvd2; + u_int8_t in_tag_val; /* tag value */ + u_int8_t in_tag_type; /* tag type */ + u_int16_t in_seqid; /* sequence id */ + u_int8_t in_msg[IN_MSGLEN]; /* SCSI message bytes */ + u_int16_t in_reserved3[IN_RSVDLEN]; + u_int8_t in_sense[QLTM_SENSELEN];/* suggested sense data */ +} in_entry_t; + +typedef struct { + isphdr_t in_header; + u_int32_t in_reserved; + u_int8_t in_lun; /* lun */ + u_int8_t in_iid; /* initiator */ + u_int16_t in_scclun; + u_int32_t in_reserved2; + u_int16_t in_status; + u_int16_t in_task_flags; + u_int16_t in_seqid; /* sequence id */ +} in_fcentry_t; + +/* + * Values for the in_status field + */ +#define IN_REJECT 0x0D /* Message Reject message received */ +#define IN_RESET 0x0E /* Bus Reset occurred */ +#define IN_NO_RCAP 0x16 /* requested capability not available */ +#define IN_IDE_RECEIVED 0x33 /* Initiator Detected Error msg received */ +#define IN_RSRC_UNAVAIL 0x34 /* resource unavailable */ +#define IN_MSG_RECEIVED 0x36 /* SCSI message received */ +#define IN_ABORT_TASK 0x20 /* task named in RX_ID is being aborted (FC) */ +#define IN_PORT_LOGOUT 0x29 /* port has logged out (FC) */ +#define IN_PORT_CHANGED 0x2A /* port changed */ +#define IN_GLOBAL_LOGO 0x2E /* all ports logged out */ +#define IN_NO_NEXUS 0x3B /* Nexus not established */ + +/* + * Values for the in_task_flags field- should only get one at a time! + */ +#define TASK_FLAGS_ABORT_TASK (1<<9) +#define TASK_FLAGS_CLEAR_TASK_SET (1<<10) +#define TASK_FLAGS_TARGET_RESET (1<<13) +#define TASK_FLAGS_CLEAR_ACA (1<<14) +#define TASK_FLAGS_TERMINATE_TASK (1<<15) + +#ifndef MSG_ABORT_TAG +#define MSG_ABORT_TAG 0x06 +#endif +#ifndef MSG_CLEAR_QUEUE +#define MSG_CLEAR_QUEUE 0x0e +#endif +#ifndef MSG_BUS_DEV_RESET +#define MSG_BUS_DEV_RESET 0x0b +#endif +#ifndef MSG_REL_RECOVERY +#define MSG_REL_RECOVERY 0x10 +#endif +#ifndef MSG_TERM_IO_PROC +#define MSG_TERM_IO_PROC 0x11 +#endif + + +/* + * Notify Acknowledge Entry structure + */ +#define NA_RSVDLEN 22 +typedef struct { + isphdr_t na_header; + u_int32_t na_reserved; + u_int8_t na_lun; /* lun */ + u_int8_t na_iid; /* initiator */ + u_int8_t na_reserved2; + u_int8_t na_tgt; /* target */ + u_int32_t na_flags; + u_int8_t na_status; + u_int8_t na_event; + u_int16_t na_seqid; /* sequence id */ + u_int16_t na_reserved3[NA_RSVDLEN]; +} na_entry_t; + +/* + * Value for the na_event field + */ +#define NA_RST_CLRD 0x80 /* Clear an async event notification */ +#define NA_OK 0x01 /* Notify Acknowledge Succeeded */ +#define NA_INVALID 0x06 /* Invalid Notify Acknowledge */ + +#define NA2_RSVDLEN 21 +typedef struct { + isphdr_t na_header; + u_int32_t na_reserved; + u_int8_t na_lun; /* lun */ + u_int8_t na_iid; /* initiator */ + u_int16_t na_scclun; + u_int16_t na_flags; + u_int16_t na_reserved2; + u_int16_t na_status; + u_int16_t na_task_flags; + u_int16_t na_seqid; /* sequence id */ + u_int16_t na_reserved3[NA2_RSVDLEN]; +} na_fcentry_t; +#define NAFC_RCOUNT 0x80 /* increment resource count */ +#define NAFC_RST_CLRD 0x20 /* Clear LIP Reset */ +/* + * Accept Target I/O Entry structure + */ +#define ATIO_CDBLEN 26 + +typedef struct { + isphdr_t at_header; + u_int16_t at_reserved; + u_int16_t at_handle; + u_int8_t at_lun; /* lun */ + u_int8_t at_iid; /* initiator */ + u_int8_t at_cdblen; /* cdb length */ + u_int8_t at_tgt; /* target */ + u_int32_t at_flags; + u_int8_t at_status; /* firmware status */ + u_int8_t at_scsi_status; /* scsi status */ + u_int8_t at_tag_val; /* tag value */ + u_int8_t at_tag_type; /* tag type */ + u_int8_t at_cdb[ATIO_CDBLEN]; /* received CDB */ + u_int8_t at_sense[QLTM_SENSELEN];/* suggested sense data */ +} at_entry_t; + +/* + * at_flags values + */ +#define AT_NODISC 0x00008000 /* disconnect disabled */ +#define AT_TQAE 0x00000002 /* Tagged Queue Action enabled */ + +/* + * at_status values + */ +#define AT_PATH_INVALID 0x07 /* ATIO sent to firmware for disabled lun */ +#define AT_RESET 0x0E /* SCSI Bus Reset Occurred */ +#define AT_PHASE_ERROR 0x14 /* Bus phase sequence error */ +#define AT_NOCAP 0x16 /* Requested capability not available */ +#define AT_BDR_MSG 0x17 /* Bus Device Reset msg received */ +#define AT_CDB 0x3D /* CDB received */ + +/* + * Macros to create and fetch and test concatenated handle and tag value macros + */ + +#define AT_MAKE_TAGID(tid, aep) \ + tid = ((aep)->at_handle << 16); \ + if ((aep)->at_flags & AT_TQAE) \ + (tid) |= ((aep)->at_tag_val + 1) + +#define CT_MAKE_TAGID(tid, ct) \ + tid = ((ct)->ct_fwhandle << 16); \ + if ((ct)->ct_flags & CT_TQAE) \ + (tid) |= ((ct)->ct_tag_val + 1) + +#define AT_HAS_TAG(val) ((val) & 0xffff) +#define AT_GET_TAG(val) AT_HAS_TAG(val) - 1 +#define AT_GET_HANDLE(val) ((val) >> 16) + +/* + * Accept Target I/O Entry structure, Type 2 + */ +#define ATIO2_CDBLEN 16 + +typedef struct { + isphdr_t at_header; + u_int32_t at_reserved; + u_int8_t at_lun; /* lun or reserved */ + u_int8_t at_iid; /* initiator */ + u_int16_t at_rxid; /* response ID */ + u_int16_t at_flags; + u_int16_t at_status; /* firmware status */ + u_int8_t at_reserved1; + u_int8_t at_taskcodes; + u_int8_t at_taskflags; + u_int8_t at_execodes; + u_int8_t at_cdb[ATIO2_CDBLEN]; /* received CDB */ + u_int32_t at_datalen; /* allocated data len */ + u_int16_t at_scclun; /* SCC Lun or reserved */ + u_int16_t at_wwpn[4]; /* WWPN of initiator */ + u_int16_t at_reserved2[6]; + u_int16_t at_oxid; +} at2_entry_t; + +#define ATIO2_WWPN_OFFSET 0x2A +#define ATIO2_OXID_OFFSET 0x3E + +#define ATIO2_TC_ATTR_MASK 0x7 +#define ATIO2_TC_ATTR_SIMPLEQ 0 +#define ATIO2_TC_ATTR_HEADOFQ 1 +#define ATIO2_TC_ATTR_ORDERED 2 +#define ATIO2_TC_ATTR_ACAQ 4 +#define ATIO2_TC_ATTR_UNTAGGED 5 + +/* + * Continue Target I/O Entry structure + * Request from driver. The response from the + * ISP firmware is the same except that the last 18 + * bytes are overwritten by suggested sense data if + * the 'autosense valid' bit is set in the status byte. + */ +typedef struct { + isphdr_t ct_header; + u_int16_t ct_reserved; +#define ct_syshandle ct_reserved /* we use this */ + u_int16_t ct_fwhandle; /* required by f/w */ + u_int8_t ct_lun; /* lun */ + u_int8_t ct_iid; /* initiator id */ + u_int8_t ct_reserved2; + u_int8_t ct_tgt; /* our target id */ + u_int32_t ct_flags; + u_int8_t ct_status; /* isp status */ + u_int8_t ct_scsi_status; /* scsi status */ + u_int8_t ct_tag_val; /* tag value */ + u_int8_t ct_tag_type; /* tag type */ + u_int32_t ct_xfrlen; /* transfer length */ + u_int32_t ct_resid; /* residual length */ + u_int16_t ct_timeout; + u_int16_t ct_seg_count; + /* + * This is so we can share tag name space with + * CTIO{2,3,4} with the minimum of pain. + */ + union { + ispds_t ct_a[ISP_RQDSEG]; + } _u; +#define ct_dataseg _u.ct_a +} ct_entry_t; + +/* + * For some of the dual port SCSI adapters, port (bus #) is reported + * in the MSbit of ct_iid. Bit fields are a bit too awkward here. + * + * Note that this does not apply to FC adapters at all which can and + * do report IIDs between 129 && 255 (these represent devices that have + * logged in across a SCSI fabric). + */ +#define GET_IID_VAL(x) (x & 0x3f) +#define GET_BUS_VAL(x) ((x >> 7) & 0x1) +#define SET_IID_VAL(y, x) y = ((y & ~0x3f) | (x & 0x3f)) +#define SET_BUS_VAL(y, x) y = ((y & 0x3f) | ((x & 0x1) << 7)) + +/* + * ct_flags values + */ +#define CT_TQAE 0x00000002 /* bit 1, Tagged Queue Action enable */ +#define CT_DATA_IN 0x00000040 /* bits 6&7, Data direction */ +#define CT_DATA_OUT 0x00000080 /* bits 6&7, Data direction */ +#define CT_NO_DATA 0x000000C0 /* bits 6&7, Data direction */ +#define CT_CCINCR 0x00000100 /* bit 8, autoincrement atio count */ +#define CT_DATAMASK 0x000000C0 /* bits 6&7, Data direction */ +#define CT_INISYNCWIDE 0x00004000 /* bit 14, Do Sync/Wide Negotiation */ +#define CT_NODISC 0x00008000 /* bit 15, Disconnects disabled */ +#define CT_DSDP 0x01000000 /* bit 24, Disable Save Data Pointers */ +#define CT_SENDRDP 0x04000000 /* bit 26, Send Restore Pointers msg */ +#define CT_SENDSTATUS 0x80000000 /* bit 31, Send SCSI status byte */ + +/* + * ct_status values + * - set by the firmware when it returns the CTIO + */ +#define CT_OK 0x01 /* completed without error */ +#define CT_ABORTED 0x02 /* aborted by host */ +#define CT_ERR 0x04 /* see sense data for error */ +#define CT_INVAL 0x06 /* request for disabled lun */ +#define CT_NOPATH 0x07 /* invalid ITL nexus */ +#define CT_INVRXID 0x08 /* (FC only) Invalid RX_ID */ +#define CT_DATA_OVER 0x09 /* (FC only) Data Overrun */ +#define CT_RSELTMO 0x0A /* reselection timeout after 2 tries */ +#define CT_TIMEOUT 0x0B /* timed out */ +#define CT_RESET 0x0E /* SCSI Bus Reset occurred */ +#define CT_PARITY 0x0F /* Uncorrectable Parity Error */ +#define CT_BUS_ERROR 0x10 /* (FC Only) DMA PCI Error */ +#define CT_PANIC 0x13 /* Unrecoverable Error */ +#define CT_PHASE_ERROR 0x14 /* Bus phase sequence error */ +#define CT_BDR_MSG 0x17 /* Bus Device Reset msg received */ +#define CT_DATA_UNDER 0x15 /* (FC only) Data Underrun */ +#define CT_TERMINATED 0x19 /* due to Terminate Transfer mbox cmd */ +#define CT_PORTNOTAVAIL 0x28 /* port not available */ +#define CT_LOGOUT 0x29 /* port logout */ +#define CT_PORTCHANGED 0x2A /* port changed */ +#define CT_IDE 0x33 /* Initiator Detected Error */ +#define CT_NOACK 0x35 /* Outstanding Immed. Notify. entry */ + +/* + * When the firmware returns a CTIO entry, it may overwrite the last + * part of the structure with sense data. This starts at offset 0x2E + * into the entry, which is in the middle of ct_dataseg[1]. Rather + * than define a new struct for this, I'm just using the sense data + * offset. + */ +#define CTIO_SENSE_OFFSET 0x2E + +/* + * Entry length in u_longs. All entries are the same size so + * any one will do as the numerator. + */ +#define UINT32_ENTRY_SIZE (sizeof(at_entry_t)/sizeof(u_int32_t)) + +/* + * QLA2100 CTIO (type 2) entry + */ +#define MAXRESPLEN 26 +typedef struct { + isphdr_t ct_header; + u_int16_t ct_reserved; + u_int16_t ct_fwhandle; /* just to match CTIO */ + u_int8_t ct_lun; /* lun */ + u_int8_t ct_iid; /* initiator id */ + u_int16_t ct_rxid; /* response ID */ + u_int16_t ct_flags; + u_int16_t ct_status; /* isp status */ + u_int16_t ct_timeout; + u_int16_t ct_seg_count; + u_int32_t ct_reloff; /* relative offset */ + int32_t ct_resid; /* residual length */ + union { + /* + * The three different modes that the target driver + * can set the CTIO{2,3,4} up as. + * + * The first is for sending FCP_DATA_IUs as well as + * (optionally) sending a terminal SCSI status FCP_RSP_IU. + * + * The second is for sending SCSI sense data in an FCP_RSP_IU. + * Note that no FCP_DATA_IUs will be sent. + * + * The third is for sending FCP_RSP_IUs as built specifically + * in system memory as located by the isp_dataseg. + */ + struct { + u_int32_t _reserved; + u_int16_t _reserved2; + u_int16_t ct_scsi_status; + u_int32_t ct_xfrlen; + union { + ispds_t ct_a[ISP_RQDSEG_T2]; /* CTIO2 */ + ispds64_t ct_b[ISP_RQDSEG_T3]; /* CTIO3 */ + ispdslist_t ct_c; /* CTIO4 */ + } _u; +#define ct_dataseg _u.ct_a +#define ct_dataseg64 _u.ct_b +#define ct_dslist _u.ct_c + } m0; + struct { + u_int16_t _reserved; + u_int16_t _reserved2; + u_int16_t ct_senselen; + u_int16_t ct_scsi_status; + u_int16_t ct_resplen; + u_int8_t ct_resp[MAXRESPLEN]; + } m1; + struct { + u_int32_t _reserved; + u_int16_t _reserved2; + u_int16_t _reserved3; + u_int32_t ct_datalen; + ispds_t ct_fcp_rsp_iudata; + } m2; + /* + * CTIO2 returned from F/W... + */ + struct { + u_int32_t _reserved[4]; + u_int16_t ct_scsi_status; + u_int8_t ct_sense[QLTM_SENSELEN]; + } fw; + } rsp; +} ct2_entry_t; + +/* + * ct_flags values for CTIO2 + */ +#define CT2_FLAG_MMASK 0x0003 +#define CT2_FLAG_MODE0 0x0000 +#define CT2_FLAG_MODE1 0x0001 +#define CT2_FLAG_MODE2 0x0002 +#define CT2_DATA_IN CT_DATA_IN +#define CT2_DATA_OUT CT_DATA_OUT +#define CT2_NO_DATA CT_NO_DATA +#define CT2_DATAMASK CT_DATAMASK +#define CT2_CCINCR 0x0100 +#define CT2_FASTPOST 0x0200 +#define CT2_SENDSTATUS 0x8000 + +/* + * ct_status values are (mostly) the same as that for ct_entry. + */ + +/* + * ct_scsi_status values- the low 8 bits are the normal SCSI status + * we know and love. The upper 8 bits are validity markers for FCP_RSP_IU + * fields. + */ +#define CT2_RSPLEN_VALID 0x0100 +#define CT2_SNSLEN_VALID 0x0200 +#define CT2_DATA_OVER 0x0400 +#define CT2_DATA_UNDER 0x0800 + +/* + * Debug macros + */ + +#define ISP_TDQE(isp, msg, idx, arg) \ + if (isp->isp_dblev & ISP_LOGTDEBUG2) isp_print_qentry(isp, msg, idx, arg) + +#ifdef ISP_TARGET_FUNCTIONS +/* + * The functions below are for the publicly available + * target mode functions that are internal to the Qlogic driver. + */ + +/* + * This function handles new response queue entry appropriate for target mode. + */ +int isp_target_notify(struct ispsoftc *, void *, u_int16_t *); + +/* + * Enable/Disable/Modify a logical unit. + * (softc, cmd, bus, tgt, lun, cmd_cnt, inotify_cnt, opaque) + */ +#define DFLT_CMND_CNT 0xfe /* unmonitored */ +#define DFLT_INOT_CNT 16 +int isp_lun_cmd(struct ispsoftc *, int, int, int, int, int, int, u_int32_t); + +/* + * General request queue 'put' routine for target mode entries. + */ +int isp_target_put_entry(struct ispsoftc *isp, void *); + +/* + * General routine to put back an ATIO entry- + * used for replenishing f/w resource counts. + * The argument is a pointer to a source ATIO + * or ATIO2. + */ +int isp_target_put_atio(struct ispsoftc *, void *); + +/* + * General routine to send a final CTIO for a command- used mostly for + * local responses. + */ +int isp_endcmd(struct ispsoftc *, void *, u_int32_t, u_int16_t); +#define ECMD_SVALID 0x100 + +/* + * Handle an asynchronous event + * + * Return nonzero if the interrupt that generated this event has been dismissed. + */ + +int isp_target_async(struct ispsoftc *, int, int); +#endif +#endif /* _ISP_TARGET_H */ diff -puN /dev/null drivers/scsi/isp/common/isp_tpublic.h --- /dev/null 2002-08-30 16:31:37.000000000 -0700 +++ 25-akpm/drivers/scsi/isp/common/isp_tpublic.h 2003-02-14 00:20:12.000000000 -0800 @@ -0,0 +1,335 @@ +/* @(#)isp_tpublic.h 1.8 */ +/* + * Qlogic ISP Host Adapter Public Target Interface Structures && Routines + *--------------------------------------- + * Copyright (c) 2000 by Matthew Jacob + * 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, + * without modification, immediately at the beginning of the file. + * 2. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * 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. + * + * Matthew Jacob + * Feral Software + * mjacob@feral.com + */ + +/* + * Required software target mode message and event handling structures. + * + * The message and event structures are used by the MI layer + * to propagate messages and events upstream. + */ + +#ifndef IN_MSGLEN +#define IN_MSGLEN 8 +#endif +typedef struct { + void * nt_hba; /* HBA tag */ + u_int64_t nt_iid; /* inititator id */ + u_int64_t nt_tgt; /* target id */ + u_int64_t nt_lun; /* logical unit */ + u_int8_t nt_bus; /* bus */ + u_int8_t nt_tagtype; /* tag type */ + u_int16_t nt_tagval; /* tag value */ + u_int8_t nt_msg[IN_MSGLEN]; /* message content */ +} tmd_msg_t; + +typedef struct { + void * ev_hba; /* HBA tag */ + u_int16_t ev_bus; /* bus */ + u_int16_t ev_event; /* type of async event */ +} tmd_event_t; + +/* + * Suggested Software Target Mode Command Handling structure. + * + * A note about terminology: + * + * MD stands for "Machine Dependent". + * + * This driver is structured in three layers: Outer MD, core, and inner MD. + * The latter also is bus dependent (i.e., is cognizant of PCI bus issues + * as well as platform issues). + * + * + * "Outer Layer" means "Other Module" + * + * Some additional module that actually implements SCSI target command + * policy is the recipient of incoming commands and the source of the + * disposition for them. + * + * The command structure below is one suggested possible MD command structure, + * but since the handling of thbis is entirely in the MD layer, there is + * no explicit or implicit requirement that it be used. + * + * The cd_private tag should be used by the MD layer to keep a free list + * of these structures. Code outside of this driver can then use this + * as an to identify it's own unit structures. That is, when not on the MD + * layer's freelist, the MD layer should shove into it the identifier + * that the outer layer has for it- passed in on an initial QIN_HBA_REG + * call (see below). + * + * The cd_hba tag is a tag that uniquely identifies the HBA this target + * mode command is coming from. The outer layer has to pass this back + * unchanged to avoid chaos. + * + * The cd_iid, cd_tgt, cd_lun and cd_bus tags are used to identify the + * id of the initiator who sent us a command, the target claim to be, the + * lun on the target we claim to be, and the bus instance (for multiple + * bus host adapters) that this applies to (consider it an extra Port + * parameter). The iid, tgt and lun values are deliberately chosen to be + * fat so that, for example, World Wide Names can be used instead of + * the units that the Qlogic firmware uses (in the case where the MD + * layer maintains a port database, for example). + * + * The cd_tagtype field specifies what kind of command tag has been + * sent with the command. The cd_tagval is the tag's value (low 16 + * bits). It also contains (in the upper 16 bits) any command handle. + * + * + * N.B.: when the MD layer sends this command to outside software + * the outside software likely *MUST* return the same cd_tagval that + * was in place because this value is likely what the Qlogic f/w uses + * to identify a command. + * + * The cd_cdb contains storage for the passed in command descriptor block. + * This is the maximum size we can get out of the Qlogic f/w. There's no + * passed in length because whoever decodes the command to act upon it + * will know what the appropriate length is. + * + * The tag cd_lflags are the flags set by the MD driver when it gets + * command incoming or when it needs to inform any outside entities + * that the last requested action failed. + * + * The tag cd_hflags should be set by any outside software to indicate + * the validity of sense and status fields (defined below) and to indicate + * the direction data is expected to move. It is an error to have both + * CDFH_DATA_IN and CDFH_DATA_OUT set. + * + * If the CDFH_STSVALID flag is set, the command should be completed (after + * sending any data and/or status). If CDFH_SNSVALID is set and the MD layer + * can also handle sending the associated sense data (either back with an + * FCP RESPONSE IU for Fibre Channel or otherwise automatically handling a + * REQUEST SENSE from the initator for this target/lun), the MD layer will + * set the CDFL_SENTSENSE flag on successful transmission of the sense data. + * It is an error for the CDFH_SNSVALID bit to be set and CDFH_STSVALID not + * to be set. It is an error for the CDFH_SNSVALID be set and the associated + * SCSI status (cd_scsi_status) not be set to CHECK CONDITON. + * + * The tag cd_data points to a data segment to either be filled or + * read from depending on the direction of data movement. The tag + * is undefined if no data direction is set. The MD layer and outer + * layers must agree on the meaning of cd_data. + * + * The tag cd_totlen is the total data amount expected to be moved + * over the life of the command. It *may* be set by the MD layer, possibly + * from the datalen field of an FCP CMND IU unit. If it shows up in the outer + * layers set to zero and the CDB indicates data should be moved, the outer + * layer should set it to the amount expected to be moved. + * + * The tag cd_resid should be the total residual of data not transferred. + * The outer layers need to set this at the begining of command processing + * to equal cd_totlen. As data is successfully moved, this value is decreased. + * At the end of a command, any nonzero residual indicates the number of bytes + * requested but not moved. XXXXXXXXXXXXXXXXXXXXXXX TOO VAGUE!!! + * + * The tag cd_xfrlen is the length of the currently active data transfer. + * This allows several interations between any outside software and the + * MD layer to move data. + * + * The reason that total length and total residual have to be tracked + * is that fibre channel FCP DATA IU units have to have a relative + * offset field. + * + * N.B.: there is no necessary 1-to-1 correspondence between any one + * data transfer segment and the number of CTIOs that will be generated + * satisfy the current data transfer segment. It's not also possible to + * predict how big a transfer can be before it will be 'too big'. Be + * reasonable- a 64KB transfer is 'reasonable'. A 1MB transfer may not + * be. A 32MB transfer is unreasonable. The problem here has to do with + * how CTIOs can be used to map passed data pointers. In systems which + * have page based scatter-gather requirements, each PAGESIZEd chunk will + * consume one data segment descriptor- you get 3 or 4 of them per CTIO. + * The size of the REQUEST QUEUE you drop a CTIO onto is finite (typically + * it's 256, but on some systems it's even smaller, and note you have to + * sure this queue with the initiator side of this driver). + * + * The tags cd_sense and cd_scsi_status are pretty obvious. + * + * The tag cd_error is to communicate between the MD layer and outer software + * the current error conditions. + * + * The tag cd_reserved pads out the structure to 128 bytes. The first + * half of the pad area is reserved to the MD layer, and the second half + * may be used by outer layers, for scratch purposes. + */ + +#ifndef _LP64 +#if defined(__alpha__) || defined(__sparcv9cpu) || defined(__sparc_v9__) ||\ + defined(__ia64__) +#define _LP64 +#endif +#endif + +#ifndef _TMD_PAD_LEN +#ifdef _LP64 +#define _TMD_PAD_LEN 12 +#else +#define _TMD_PAD_LEN 24 +#endif +#endif +#ifndef ATIO_CDBLEN +#define ATIO_CDBLEN 26 +#endif +#ifndef QLTM_SENSELEN +#define QLTM_SENSELEN 18 +#endif +typedef struct tmd_cmd { + void * cd_private; /* layer private data */ + void * cd_hba; /* HBA tag */ + void * cd_data; /* 'pointer' to data */ + u_int64_t cd_iid; /* initiator ID */ + u_int64_t cd_tgt; /* target id */ + u_int64_t cd_lun; /* logical unit */ + u_int8_t cd_bus; /* bus */ + u_int8_t cd_tagtype; /* tag type */ + u_int32_t cd_tagval; /* tag value */ + u_int8_t cd_cdb[ATIO_CDBLEN]; /* Command */ + u_int8_t cd_lflags; /* flags lower level sets */ + u_int8_t cd_hflags; /* flags higher level sets */ + u_int32_t cd_totlen; /* total data requirement */ + u_int32_t cd_resid; /* total data residual */ + u_int32_t cd_xfrlen; /* current data requirement */ + int32_t cd_error; /* current error */ + u_int8_t cd_sense[QLTM_SENSELEN]; + u_int16_t cd_scsi_status; /* closing SCSI status */ + u_int8_t cd_reserved[_TMD_PAD_LEN]; +} tmd_cmd_t; + +#define CDFL_SNSVALID 0x01 /* sense data (from f/w) valid */ +#define CDFL_NODISC 0x02 /* disconnects disabled */ +#define CDFL_SENTSENSE 0x04 /* last action sent sense data */ +#define CDFL_SENTSTATUS 0x08 /* last action sent status */ +#define CDFL_ERROR 0x10 /* last action ended in error */ +#define CDFL_BUSY 0x40 /* this command is not on a free list */ +#define CDFL_PRIVATE_0 0x80 /* private layer flags */ + +#define CDFH_SNSVALID 0x01 /* sense data valid */ +#define CDFH_STSVALID 0x02 /* status valid */ +#define CDFH_NODATA 0x00 /* no data transfer expected */ +#define CDFH_DATA_IN 0x04 /* target (us) -> initiator (them) */ +#define CDFH_DATA_OUT 0x08 /* initiator (them) -> target (us) */ +#define CDFH_DATA_MASK 0x0C /* mask to cover data direction */ +#define CDFH_PRIVATE_0 0x80 /* private layer flags */ + +/* + * Action codes set by the Qlogic MD target driver for + * the external layer to figure out what to do with. + */ +typedef enum { + QOUT_HBA_REG=0, /* the argument is a pointer to a hba_register_t */ + QOUT_TMD_START, /* the argument is a pointer to a tmd_cmd_t */ + QOUT_TMD_DONE, /* the argument is a pointer to a tmd_cmd_t */ + QOUT_TEVENT, /* the argument is a pointer to a tmd_event_t */ + QOUT_TMSG, /* the argument is a pointer to a tmd_msg_t */ + QOUT_HBA_UNREG /* the argument is a pointer to a hba_register_t */ +} tact_e; + +/* + * Action codes set by the external layer for the + * MD Qlogic driver to figure out what to do with. + */ +typedef enum { + QIN_HBA_REG=6, /* the argument is a pointer to a hba_register_t */ + QIN_ENABLE, /* the argument is a pointer to a tmd_cmd_t */ + QIN_DISABLE, /* the argument is a pointer to a tmd_cmd_t */ + QIN_TMD_CONT, /* the argument is a pointer to a tmd_cmd_t */ + QIN_TMD_FIN, /* the argument is a pointer to a done tmd_cmd_t */ + QIN_HBA_UNREG /* the argument is a pointer to a hba_register_t */ +} qact_e; + +/* + * A word about the START/CONT/DONE/FIN dance: + * + * When the HBA is enabled for receiving commands, one may show up + * without notice. When that happens, the Qlogic target mode driver + * gets a tmd_cmd_t, fills it with the info that just arrived, and + * calls the outer layer with a QOUT_TMD_START code and pointer to + * the tmd_cmd_t. + * + * The outer layer decodes the command, fetches data, prepares stuff, + * whatever, and starts by passing back the pointer with a QIN_TMD_CONT + * code which causes the Qlogic target mode driver to generate CTIOs to + * satisfy whatever action needs to be taken. When those CTIOs complete, + * the Qlogic target driver sends the pointer to the cmd_tmd_t back with + * a QOUT_TMD_DONE code. This repeats for as long as necessary. + * + * The outer layer signals it wants to end the command by settings within + * the tmd_cmd_t itself. When the final QIN_TMD_CONT is reported completed, + * the outer layer frees the tmd_cmd_t by sending the pointer to it + * back with a QIN_TMD_FIN code. + * + * The graph looks like: + * + * QOUT_TMD_START -> [ QIN_TMD_CONT -> QOUT_TMD_DONE ] * -> QIN_TMD_FIN. + * + */ + +/* + * A word about ENABLE/DISABLE: the argument is a pointer to an tmd_cmd_t + * with cd_hba, cd_bus, cd_tgt and cd_lun filled out. If an error occurs + * in either enabling or disabling the described lun, cd_lflags is set + * with CDFL_ERROR. + * + * Logical unit zero must be the first enabled and the last disabled. + */ + +/* + * Target handler functions. + * The MD target handler function (the outer layer calls this) + * should be be prototyped like: + * + * void target_action(qact_e, void *arg) + * + * The outer layer target handler function (the MD layer calls this) + * should be be prototyped like: + * + * void system_action(tact_e, void *arg) + */ + +/* + * This structure is used to register to other software modules the + * binding of an HBA identifier, driver name and instance and the + * lun width capapbilities of this target driver. It's up to each + * platform to figure out how it wants to do this, but a typical + * sequence would be for the MD layer to find some external module's + * entry point and start by sending a QOUT_HBA_REG with info filled + * in, and the external module to call back with a QIN_HBA_REG that + * passes back the corresponding information. + */ +typedef struct { + void * r_identity; + char r_name[8]; + int r_inst; + int r_lunwidth; + int r_buswidth; + void (*r_action)(int, void *); +} hba_register_t; diff -puN /dev/null drivers/scsi/isp/common/ispvar.h --- /dev/null 2002-08-30 16:31:37.000000000 -0700 +++ 25-akpm/drivers/scsi/isp/common/ispvar.h 2003-02-14 00:20:12.000000000 -0800 @@ -0,0 +1,902 @@ +/* @(#)ispvar.h 1.44 */ +/* + * Soft Definitions for for Qlogic ISP SCSI adapters. + * + * Copyright (c) 1997, 1998, 1999, 2000 by Matthew Jacob + * 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 immediately at the beginning of the file, without modification, + * this list of conditions, and the following disclaimer. + * 2. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * 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. + * + */ + +#ifndef _ISPVAR_H +#define _ISPVAR_H + +#if defined(__NetBSD__) || defined(__OpenBSD__) +#include +#ifdef ISP_TARGET_MODE +#include +#include +#endif +#endif +#ifdef __FreeBSD__ +#include +#ifdef ISP_TARGET_MODE +#include +#include +#endif +#endif +#ifdef __linux__ +#include "ispmbox.h" +#ifdef ISP_TARGET_MODE +#include "isp_target.h" +#include "isp_tpublic.h" +#endif +#endif + +#define ISP_CORE_VERSION_MAJOR 2 +#define ISP_CORE_VERSION_MINOR 7 + +/* + * Vector for bus specific code to provide specific services. + */ +struct ispsoftc; +struct ispmdvec { + int (*dv_rd_isr) + (struct ispsoftc *, u_int16_t *, u_int16_t *, u_int16_t *); + u_int16_t (*dv_rd_reg) (struct ispsoftc *, int); + void (*dv_wr_reg) (struct ispsoftc *, int, u_int16_t); + int (*dv_mbxdma) (struct ispsoftc *); + int (*dv_dmaset) (struct ispsoftc *, + XS_T *, ispreq_t *, u_int16_t *, u_int16_t); + void (*dv_dmaclr) + (struct ispsoftc *, XS_T *, u_int16_t); + void (*dv_reset0) (struct ispsoftc *); + void (*dv_reset1) (struct ispsoftc *); + void (*dv_dregs) (struct ispsoftc *, const char *); + u_int16_t *dv_ispfw; /* ptr to f/w */ + u_int16_t dv_conf1; + u_int16_t dv_clock; /* clock frequency */ +}; + +/* + * Overall parameters + */ +#define MAX_TARGETS 16 +#define MAX_FC_TARG 256 +#define ISP_MAX_TARGETS(isp) (IS_FC(isp)? MAX_FC_TARG : MAX_TARGETS) +#define ISP_MAX_LUNS(isp) (isp)->isp_maxluns + +/* + * 'Types' + */ +#ifdef ISP_DAC_SUPPORTED +typedef u_int64_t isp_dma_addr_t; +#else +typedef u_int32_t isp_dma_addr_t; +#endif + +/* + * Macros to access ISP registers through bus specific layers- + * mostly wrappers to vector through the mdvec structure. + */ +#define ISP_READ_ISR(isp, isrp, semap, mbox0p) \ + (*(isp)->isp_mdvec->dv_rd_isr)(isp, isrp, semap, mbox0p) + +#define ISP_READ(isp, reg) \ + (*(isp)->isp_mdvec->dv_rd_reg)((isp), (reg)) + +#define ISP_WRITE(isp, reg, val) \ + (*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), (val)) + +#define ISP_MBOXDMASETUP(isp) \ + (*(isp)->isp_mdvec->dv_mbxdma)((isp)) + +#define ISP_DMASETUP(isp, xs, req, iptrp, optr) \ + (*(isp)->isp_mdvec->dv_dmaset)((isp), (xs), (req), (iptrp), (optr)) + +#define ISP_DMAFREE(isp, xs, hndl) \ + if ((isp)->isp_mdvec->dv_dmaclr) \ + (*(isp)->isp_mdvec->dv_dmaclr)((isp), (xs), (hndl)) + +#define ISP_RESET0(isp) \ + if ((isp)->isp_mdvec->dv_reset0) (*(isp)->isp_mdvec->dv_reset0)((isp)) +#define ISP_RESET1(isp) \ + if ((isp)->isp_mdvec->dv_reset1) (*(isp)->isp_mdvec->dv_reset1)((isp)) +#define ISP_DUMPREGS(isp, m) \ + if ((isp)->isp_mdvec->dv_dregs) (*(isp)->isp_mdvec->dv_dregs)((isp),(m)) + +#define ISP_SETBITS(isp, reg, val) \ + (*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), ISP_READ((isp), (reg)) | (val)) + +#define ISP_CLRBITS(isp, reg, val) \ + (*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), ISP_READ((isp), (reg)) & ~(val)) + +/* + * The MEMORYBARRIER macro is defined per platform (to provide synchronization + * on Request and Response Queues, Scratch DMA areas, and Registers) + * + * Defined Memory Barrier Synchronization Types + */ +#define SYNC_REQUEST 0 /* request queue synchronization */ +#define SYNC_RESULT 1 /* result queue synchronization */ +#define SYNC_SFORDEV 2 /* scratch, sync for ISP */ +#define SYNC_SFORCPU 3 /* scratch, sync for CPU */ +#define SYNC_REG 4 /* for registers */ + +/* + * Request/Response Queue defines and macros. + * The maximum is defined per platform (and can be based on board type). + */ +/* This is the size of a queue entry (request and response) */ +#define QENTRY_LEN 64 +/* Both request and result queue length must be a power of two */ +#define RQUEST_QUEUE_LEN(x) MAXISPREQUEST(x) +#ifdef ISP_TARGET_MODE +#define RESULT_QUEUE_LEN(x) MAXISPREQUEST(x) +#else +#define RESULT_QUEUE_LEN(x) \ + (((MAXISPREQUEST(x) >> 2) < 64)? 64 : MAXISPREQUEST(x) >> 2) +#endif +#define ISP_QUEUE_ENTRY(q, idx) ((q) + ((idx) * QENTRY_LEN)) +#define ISP_QUEUE_SIZE(n) ((n) * QENTRY_LEN) +#define ISP_NXT_QENTRY(idx, qlen) (((idx) + 1) & ((qlen)-1)) +#define ISP_QFREE(in, out, qlen) \ + ((in == out)? (qlen - 1) : ((in > out)? \ + ((qlen - 1) - (in - out)) : (out - in - 1))) +#define ISP_QAVAIL(isp) \ + ISP_QFREE(isp->isp_reqidx, isp->isp_reqodx, RQUEST_QUEUE_LEN(isp)) + +#define ISP_ADD_REQUEST(isp, nxti) \ + MEMORYBARRIER(isp, SYNC_REQUEST, isp->isp_reqidx, QENTRY_LEN); \ + WRITE_REQUEST_QUEUE_IN_POINTER(isp, nxti); \ + isp->isp_reqidx = nxti + +/* + * SCSI Specific Host Adapter Parameters- per bus, per target + */ + +typedef struct { + u_int isp_gotdparms : 1, + isp_req_ack_active_neg : 1, + isp_data_line_active_neg: 1, + isp_cmd_dma_burst_enable: 1, + isp_data_dma_burst_enabl: 1, + isp_fifo_threshold : 3, + isp_ultramode : 1, + isp_diffmode : 1, + isp_lvdmode : 1, + isp_fast_mttr : 1, /* fast sram */ + isp_initiator_id : 4, + isp_async_data_setup : 4; + u_int16_t isp_selection_timeout; + u_int16_t isp_max_queue_depth; + u_int8_t isp_tag_aging; + u_int8_t isp_bus_reset_delay; + u_int8_t isp_retry_count; + u_int8_t isp_retry_delay; + struct { + u_int32_t + exc_throttle : 8, + : 1, + dev_enable : 1, /* ignored */ + dev_update : 1, + dev_refresh : 1, + actv_offset : 4, + goal_offset : 4, + nvrm_offset : 4; + u_int8_t actv_period; /* current sync period */ + u_int8_t goal_period; /* goal sync period */ + u_int8_t nvrm_period; /* nvram sync period */ + u_int16_t actv_flags; /* current device flags */ + u_int16_t goal_flags; /* goal device flags */ + u_int16_t nvrm_flags; /* nvram device flags */ + } isp_devparam[MAX_TARGETS]; +} sdparam; + +/* + * Device Flags + */ +#define DPARM_DISC 0x8000 +#define DPARM_PARITY 0x4000 +#define DPARM_WIDE 0x2000 +#define DPARM_SYNC 0x1000 +#define DPARM_TQING 0x0800 +#define DPARM_ARQ 0x0400 +#define DPARM_QFRZ 0x0200 +#define DPARM_RENEG 0x0100 +#define DPARM_NARROW 0x0080 +#define DPARM_ASYNC 0x0040 +#define DPARM_PPR 0x0020 +#define DPARM_DEFAULT (0xFF00 & ~DPARM_QFRZ) +#define DPARM_SAFE_DFLT (DPARM_DEFAULT & ~(DPARM_WIDE|DPARM_SYNC|DPARM_TQING)) + + +/* technically, not really correct, as they need to be rated based upon clock */ +#define ISP_80M_SYNCPARMS 0x0c09 +#define ISP_40M_SYNCPARMS 0x0c0a +#define ISP_20M_SYNCPARMS 0x0c0c +#define ISP_20M_SYNCPARMS_1040 0x080c +#define ISP_10M_SYNCPARMS 0x0c19 +#define ISP_08M_SYNCPARMS 0x0c25 +#define ISP_05M_SYNCPARMS 0x0c32 +#define ISP_04M_SYNCPARMS 0x0c41 + +/* + * Fibre Channel Specifics + */ +#define FL_PORT_ID 0x7e /* FL_Port Special ID */ +#define FC_PORT_ID 0x7f /* Fabric Controller Special ID */ +#define FC_SNS_ID 0x80 /* SNS Server Special ID */ + +/* #define ISP_USE_GA_NXT 1 */ /* Use GA_NXT with switches */ +#ifndef GA_NXT_MAX +#define GA_NXT_MAX 256 +#endif + +typedef struct { + u_int32_t isp_fwoptions : 16, + isp_gbspeed : 2, + isp_iid_set : 1, + loop_seen_once : 1, + isp_loopstate : 4, /* Current Loop State */ + isp_fwstate : 3, /* ISP F/W state */ + isp_gotdparms : 1, + isp_topo : 3, + isp_onfabric : 1; + u_int8_t isp_iid; /* 'initiator' id */ + u_int8_t isp_loopid; /* hard loop id */ + u_int8_t isp_alpa; /* ALPA */ + u_int32_t isp_portid; + volatile u_int16_t isp_lipseq; /* LIP sequence # */ + u_int16_t isp_fwattr; /* firmware attributes */ + u_int8_t isp_execthrottle; + u_int8_t isp_retry_delay; + u_int8_t isp_retry_count; + u_int8_t isp_reserved; + u_int16_t isp_maxalloc; + u_int16_t isp_maxfrmlen; + u_int64_t isp_nodewwn; + u_int64_t isp_portwwn; + /* + * Port Data Base. This is indexed by 'target', which is invariate. + * However, elements within can move around due to loop changes, + * so the actual loop ID passed to the F/W is in this structure. + * The first time the loop is seen up, loopid will match the index + * (except for fabric nodes which are above mapped above FC_SNS_ID + * and are completely virtual), but subsequent LIPs can cause things + * to move around. + */ + struct lportdb { + u_int32_t + port_type : 8, + loopid : 8, + fc4_type : 4, + last_fabric_dev : 1, + : 2, + relogin : 1, + force_logout : 1, + was_fabric_dev : 1, + fabric_dev : 1, + loggedin : 1, + roles : 2, + valid : 1; + u_int32_t portid; + u_int64_t node_wwn; + u_int64_t port_wwn; + } portdb[MAX_FC_TARG], tport[FC_PORT_ID]; + + /* + * Scratch DMA mapped in area to fetch Port Database stuff, etc. + */ + caddr_t isp_scratch; + isp_dma_addr_t isp_scdma; +#ifdef ISP_FW_CRASH_DUMP + u_int16_t *isp_dump_data; +#endif +} fcparam; + +#define FW_CONFIG_WAIT 0 +#define FW_WAIT_AL_PA 1 +#define FW_WAIT_LOGIN 2 +#define FW_READY 3 +#define FW_LOSS_OF_SYNC 4 +#define FW_ERROR 5 +#define FW_REINIT 6 +#define FW_NON_PART 7 + +#define LOOP_NIL 0 +#define LOOP_LIP_RCVD 1 +#define LOOP_PDB_RCVD 2 +#define LOOP_SCANNING_FABRIC 3 +#define LOOP_FSCAN_DONE 4 +#define LOOP_SCANNING_LOOP 5 +#define LOOP_LSCAN_DONE 6 +#define LOOP_SYNCING_PDB 7 +#define LOOP_READY 8 + +#define TOPO_NL_PORT 0 +#define TOPO_FL_PORT 1 +#define TOPO_N_PORT 2 +#define TOPO_F_PORT 3 +#define TOPO_PTP_STUB 4 + +/* + * Soft Structure per host adapter + */ +typedef struct ispsoftc { + /* + * Platform (OS) specific data + */ + struct isposinfo isp_osinfo; + + /* + * Pointer to bus specific functions and data + */ + struct ispmdvec * isp_mdvec; + + /* + * (Mostly) nonvolatile state. Board specific parameters + * may contain some volatile state (e.g., current loop state). + */ + + void * isp_param; /* type specific */ + u_int16_t isp_fwrev[3]; /* Loaded F/W revision */ + u_int16_t isp_romfw_rev[3]; /* PROM F/W revision */ + u_int16_t isp_maxcmds; /* max possible I/O cmds */ + u_int8_t isp_type; /* HBA Chip Type */ + u_int8_t isp_revision; /* HBA Chip H/W Revision */ + u_int32_t isp_maxluns; /* maximum luns supported */ + + u_int32_t isp_clock : 8, /* input clock */ + : 4, + isp_port : 1, /* 23XX only */ + isp_failed : 1, /* board failed */ + isp_open : 1, /* opened (ioctl) */ + isp_touched : 1, /* board ever seen? */ + isp_bustype : 1, /* SBus or PCI */ + isp_loaded_fw : 1, /* loaded firmware */ + isp_role : 2, /* roles supported */ + isp_dblev : 12; /* debug log mask */ + + u_int32_t isp_confopts; /* config options */ + + u_int16_t isp_rqstinrp; /* register for REQINP */ + u_int16_t isp_rqstoutrp; /* register for REQOUTP */ + u_int16_t isp_respinrp; /* register for RESINP */ + u_int16_t isp_respoutrp; /* register for RESOUTP */ + + /* + * Instrumentation + */ + u_int64_t isp_intcnt; /* total int count */ + u_int64_t isp_intbogus; /* spurious int count */ + u_int64_t isp_intmboxc; /* mbox completions */ + u_int64_t isp_intoasync; /* other async */ + u_int64_t isp_rsltccmplt; /* CMDs on result q */ + u_int64_t isp_fphccmplt; /* CMDs via fastpost */ + u_int16_t isp_rscchiwater; + u_int16_t isp_fpcchiwater; + + /* + * Volatile state + */ + + volatile u_int32_t + isp_obits : 8, /* mailbox command output */ + isp_mboxbsy : 1, /* mailbox command active */ + isp_state : 3, + isp_sendmarker : 2, /* send a marker entry */ + isp_update : 2, /* update parameters */ + isp_nactive : 16; /* how many commands active */ + volatile u_int16_t isp_reqodx; /* index of last ISP pickup */ + volatile u_int16_t isp_reqidx; /* index of next request */ + volatile u_int16_t isp_residx; /* index of next result */ + volatile u_int16_t isp_resodx; /* index of next result */ + volatile u_int16_t isp_rspbsy; + volatile u_int16_t isp_lasthdls; /* last handle seed */ + volatile u_int16_t isp_mboxtmp[MAX_MAILBOX]; + volatile u_int16_t isp_lastmbxcmd; /* last mbox command sent */ + volatile u_int16_t isp_mbxwrk0; + volatile u_int16_t isp_mbxwrk1; + volatile u_int16_t isp_mbxwrk2; + void * isp_mbxworkp; + + /* + * Active commands are stored here, indexed by handle functions. + */ + XS_T **isp_xflist; + + /* + * request/result queue pointers and dma handles for them. + */ + caddr_t isp_rquest; + caddr_t isp_result; + isp_dma_addr_t isp_rquest_dma; + isp_dma_addr_t isp_result_dma; +} ispsoftc_t; + +#define SDPARAM(isp) ((sdparam *) (isp)->isp_param) +#define FCPARAM(isp) ((fcparam *) (isp)->isp_param) + +/* + * ISP Driver Run States + */ +#define ISP_NILSTATE 0 +#define ISP_RESETSTATE 1 +#define ISP_INITSTATE 2 +#define ISP_RUNSTATE 3 + +/* + * ISP Configuration Options + */ +#define ISP_CFG_NORELOAD 0x80 /* don't download f/w */ +#define ISP_CFG_NONVRAM 0x40 /* ignore NVRAM */ +#define ISP_CFG_TWOGB 0x20 /* force 2GB connection (23XX only) */ +#define ISP_CFG_ONEGB 0x10 /* force 1GB connection (23XX only) */ +#define ISP_CFG_FULL_DUPLEX 0x01 /* Full Duplex (Fibre Channel only) */ +#define ISP_CFG_PORT_PREF 0x0C /* Mask for Port Prefs (2200 only) */ +#define ISP_CFG_LPORT 0x00 /* prefer {N/F}L-Port connection */ +#define ISP_CFG_NPORT 0x04 /* prefer {N/F}-Port connection */ +#define ISP_CFG_NPORT_ONLY 0x08 /* insist on {N/F}-Port connection */ +#define ISP_CFG_LPORT_ONLY 0x0C /* insist on {N/F}L-Port connection */ +#define ISP_CFG_OWNWWPN 0x100 /* override NVRAM wwpn */ +#define ISP_CFG_OWNWWNN 0x200 /* override NVRAM wwnn */ +#define ISP_CFG_OWNFSZ 0x400 /* override NVRAM frame size */ +#define ISP_CFG_OWNLOOPID 0x800 /* override NVRAM loopid */ +#define ISP_CFG_OWNEXCTHROTTLE 0x1000 /* override NVRAM execution throttle */ + +/* + * Prior to calling isp_reset for the first time, the outer layer + * should set isp_role to one of NONE, INITIATOR, TARGET, BOTH. + * + * If you set ISP_ROLE_NONE, the cards will be reset, new firmware loaded, + * NVRAM read, and defaults set, but any further initialization (e.g. + * INITIALIZE CONTROL BLOCK commands for 2X00 cards) won't be done. + * + * If INITIATOR MODE isn't set, attempts to run commands will be stopped + * at isp_start and completed with the moral equivalent of SELECTION TIMEOUT. + * + * If TARGET MODE is set, it doesn't mean that the rest of target mode support + * needs to be enabled, or will even work. What happens with the 2X00 cards + * here is that if you have enabled it with TARGET MODE as part of the ICB + * options, but you haven't given the f/w any ram resources for ATIOs or + * Immediate Notifies, the f/w just handles what it can and you never see + * anything. Basically, it sends a single byte of data (the first byte, + * which you can set as part of the INITIALIZE CONTROL BLOCK command) for + * INQUIRY, and sends back QUEUE FULL status for any other command. + * + */ +#define ISP_ROLE_NONE 0x0 +#define ISP_ROLE_INITIATOR 0x1 +#define ISP_ROLE_TARGET 0x2 +#define ISP_ROLE_BOTH (ISP_ROLE_TARGET|ISP_ROLE_INITIATOR) +#define ISP_ROLE_EITHER ISP_ROLE_BOTH +#ifndef ISP_DEFAULT_ROLES +#define ISP_DEFAULT_ROLES ISP_ROLE_INITIATOR +#endif + + +/* + * Firmware related defines + */ +#define ISP_CODE_ORG 0x1000 /* default f/w code start */ +#define ISP_CODE_ORG_2300 0x0800 /* ..except for 2300s */ +#define ISP_FW_REV(maj, min, mic) ((maj << 24) | (min << 16) | mic) +#define ISP_FW_MAJOR(code) ((code >> 24) & 0xff) +#define ISP_FW_MINOR(code) ((code >> 16) & 0xff) +#define ISP_FW_MICRO(code) ((code >> 8) & 0xff) +#define ISP_FW_REVX(xp) ((xp[0]<<24) | (xp[1] << 16) | xp[2]) +#define ISP_FW_MAJORX(xp) (xp[0]) +#define ISP_FW_MINORX(xp) (xp[1]) +#define ISP_FW_MICROX(xp) (xp[2]) +#define ISP_FW_NEWER_THAN(i, major, minor, micro) \ + (ISP_FW_REVX((i)->isp_fwrev) > ISP_FW_REV(major, minor, micro)) + +/* + * Bus (implementation) types + */ +#define ISP_BT_PCI 0 /* PCI Implementations */ +#define ISP_BT_SBUS 1 /* SBus Implementations */ + +/* + * If we have not otherwise defined SBus support away make sure + * it is defined here such that the code is included as default + */ +#ifndef ISP_SBUS_SUPPORTED +#define ISP_SBUS_SUPPORTED 1 +#endif + +/* + * Chip Types + */ +#define ISP_HA_SCSI 0xf +#define ISP_HA_SCSI_UNKNOWN 0x1 +#define ISP_HA_SCSI_1020 0x2 +#define ISP_HA_SCSI_1020A 0x3 +#define ISP_HA_SCSI_1040 0x4 +#define ISP_HA_SCSI_1040A 0x5 +#define ISP_HA_SCSI_1040B 0x6 +#define ISP_HA_SCSI_1040C 0x7 +#define ISP_HA_SCSI_1240 0x8 +#define ISP_HA_SCSI_1080 0x9 +#define ISP_HA_SCSI_1280 0xa +#define ISP_HA_SCSI_10160 0xb +#define ISP_HA_SCSI_12160 0xc +#define ISP_HA_FC 0xf0 +#define ISP_HA_FC_2100 0x10 +#define ISP_HA_FC_2200 0x20 +#define ISP_HA_FC_2300 0x30 +#define ISP_HA_FC_2312 0x40 + +#define IS_SCSI(isp) (isp->isp_type & ISP_HA_SCSI) +#define IS_1240(isp) (isp->isp_type == ISP_HA_SCSI_1240) +#define IS_1080(isp) (isp->isp_type == ISP_HA_SCSI_1080) +#define IS_1280(isp) (isp->isp_type == ISP_HA_SCSI_1280) +#define IS_10160(isp) (isp->isp_type == ISP_HA_SCSI_10160) +#define IS_12160(isp) (isp->isp_type == ISP_HA_SCSI_12160) + +#define IS_12X0(isp) (IS_1240(isp) || IS_1280(isp)) +#define IS_1X160(isp) (IS_10160(isp) || IS_12160(isp)) +#define IS_DUALBUS(isp) (IS_12X0(isp) || IS_12160(isp)) +#define IS_ULTRA2(isp) (IS_1080(isp) || IS_1280(isp) || IS_1X160(isp)) +#define IS_ULTRA3(isp) (IS_1X160(isp)) + +#define IS_FC(isp) ((isp)->isp_type & ISP_HA_FC) +#define IS_2100(isp) ((isp)->isp_type == ISP_HA_FC_2100) +#define IS_2200(isp) ((isp)->isp_type == ISP_HA_FC_2200) +#define IS_23XX(isp) ((isp)->isp_type >= ISP_HA_FC_2300) +#define IS_2300(isp) ((isp)->isp_type == ISP_HA_FC_2300) +#define IS_2312(isp) ((isp)->isp_type == ISP_HA_FC_2312) + +/* + * DMA cookie macros + */ +#ifdef ISP_DAC_SUPPORTRED +#define DMA_WD3(x) (((x) >> 48) & 0xffff) +#define DMA_WD2(x) (((x) >> 32) & 0xffff) +#else +#define DMA_WD3(x) 0 +#define DMA_WD2(x) 0 +#endif +#define DMA_WD1(x) (((x) >> 16) & 0xffff) +#define DMA_WD0(x) (((x) & 0xffff)) + +/* + * Core System Function Prototypes + */ + +/* + * Reset Hardware. Totally. Assumes that you'll follow this with + * a call to isp_init. + */ +void isp_reset(struct ispsoftc *); + +/* + * Initialize Hardware to known state + */ +void isp_init(struct ispsoftc *); + +/* + * Reset the ISP and call completion for any orphaned commands. + */ +void isp_reinit(struct ispsoftc *); + +#ifdef ISP_FW_CRASH_DUMP +/* + * Dump firmware entry point. + */ +void isp_fw_dump(struct ispsoftc *isp); +#endif + +/* + * Internal Interrupt Service Routine + * + * The outer layers do the spade work to get the appropriate status register, + * semaphore register and first mailbox register (if appropriate). This also + * means that most spurious/bogus interrupts not for us can be filtered first. + */ +void isp_intr(struct ispsoftc *, u_int16_t, u_int16_t, u_int16_t); + + +/* + * Command Entry Point- Platform Dependent layers call into this + */ +int isp_start(XS_T *); +/* these values are what isp_start returns */ +#define CMD_COMPLETE 101 /* command completed */ +#define CMD_EAGAIN 102 /* busy- maybe retry later */ +#define CMD_QUEUED 103 /* command has been queued for execution */ +#define CMD_RQLATER 104 /* requeue this command later */ + +/* + * Command Completion Point- Core layers call out from this with completed cmds + */ +void isp_done(XS_T *); + +/* + * Platform Dependent to External to Internal Control Function + * + * Assumes locks are held on entry. You should note that with many of + * these commands and locks may be released while this is occurring. + * + * A few notes about some of these functions: + * + * ISPCTL_FCLINK_TEST tests to make sure we have good fibre channel link. + * The argument is a pointer to an integer which is the time, in microseconds, + * we should wait to see whether we have good link. This test, if successful, + * lets us know our connection topology and our Loop ID/AL_PA and so on. + * You can't get anywhere without this. + * + * ISPCTL_SCAN_FABRIC queries the name server (if we're on a fabric) for + * all entities using the FC Generic Services subcommand GET ALL NEXT. + * For each found entity, an ISPASYNC_FABRICDEV event is generated (see + * below). + * + * ISPCTL_SCAN_LOOP does a local loop scan. This is only done if the connection + * topology is NL or FL port (private or public loop). Since the Qlogic f/w + * 'automatically' manages local loop connections, this function essentially + * notes the arrival, departure, and possible shuffling around of local loop + * entities. Thus for each arrival and departure this generates an isp_async + * event of ISPASYNC_PROMENADE (see below). + * + * ISPCTL_PDB_SYNC is somewhat misnamed. It actually is the final step, in + * order, of ISPCTL_FCLINK_TEST, ISPCTL_SCAN_FABRIC, and ISPCTL_SCAN_LOOP. + * The main purpose of ISPCTL_PDB_SYNC is to complete management of logging + * and logging out of fabric devices (if one is on a fabric) and then marking + * the 'loop state' as being ready to now be used for sending commands to + * devices. Originally fabric name server and local loop scanning were + * part of this function. It's now been separated to allow for finer control. + */ +typedef enum { + ISPCTL_RESET_BUS, /* Reset Bus */ + ISPCTL_RESET_DEV, /* Reset Device */ + ISPCTL_ABORT_CMD, /* Abort Command */ + ISPCTL_UPDATE_PARAMS, /* Update Operating Parameters (SCSI) */ + ISPCTL_FCLINK_TEST, /* Test FC Link Status */ + ISPCTL_SCAN_FABRIC, /* (Re)scan Fabric Name Server */ + ISPCTL_SCAN_LOOP, /* (Re)scan Local Loop */ + ISPCTL_PDB_SYNC, /* Synchronize Port Database */ + ISPCTL_SEND_LIP, /* Send a LIP */ + ISPCTL_GET_POSMAP, /* Get FC-AL position map */ + ISPCTL_RUN_MBOXCMD, /* run a mailbox command */ + ISPCTL_TOGGLE_TMODE /* toggle target mode */ +} ispctl_t; +int isp_control(struct ispsoftc *, ispctl_t, void *); + + +/* + * Platform Dependent to Internal to External Control Function + * (each platform must provide such a function) + * + * Assumes locks are held. + * + * A few notes about some of these functions: + * + * ISPASYNC_CHANGE_NOTIFY notifies the outer layer that a change has + * occurred that invalidates the list of fabric devices known and/or + * the list of known loop devices. The argument passed is a pointer + * whose values are defined below (local loop change, name server + * change, other). 'Other' may simply be a LIP, or a change in + * connection topology. + * + * ISPASYNC_FABRIC_DEV announces the next element in a list of + * fabric device names we're getting out of the name server. The + * argument points to a GET ALL NEXT response structure. The list + * is known to terminate with an entry that refers to ourselves. + * One of the main purposes of this function is to allow outer + * layers, which are OS dependent, to set policy as to which fabric + * devices might actually be logged into (and made visible) later + * at ISPCTL_PDB_SYNC time. Since there's a finite number of fabric + * devices that we can log into (256 less 3 'reserved' for F-port + * topologies), and fabrics can grow up to 8 million or so entries + * (24 bits of Port Address, less a wad of reserved spaces), clearly + * we had better let the OS determine login policy. + * + * ISPASYNC_PROMENADE has an argument that is a pointer to an integer which + * is an index into the portdb in the softc ('target'). Whether that entry's + * valid tag is set or not says whether something has arrived or departed. + * The name refers to a favorite pastime of many city dwellers- watching + * people come and go, talking of Michaelangelo, and so on.. + * + * ISPASYNC_UNHANDLED_RESPONSE gives outer layers a chance to parse a + * response queue entry not otherwise handled. The outer layer should + * return non-zero if it handled it. The 'arg' points to an unmassaged + * response queue entry. + */ + +typedef enum { + ISPASYNC_NEW_TGT_PARAMS, /* New Target Parameters Negotiated */ + ISPASYNC_BUS_RESET, /* Bus Was Reset */ + ISPASYNC_LOOP_DOWN, /* FC Loop Down */ + ISPASYNC_LOOP_UP, /* FC Loop Up */ + ISPASYNC_LIP, /* LIP Received */ + ISPASYNC_LOOP_RESET, /* Loop Reset Received */ + ISPASYNC_CHANGE_NOTIFY, /* FC Change Notification */ + ISPASYNC_FABRIC_DEV, /* FC Fabric Device Arrival */ + ISPASYNC_PROMENADE, /* FC Objects coming && going */ + ISPASYNC_TARGET_MESSAGE, /* target message */ + ISPASYNC_TARGET_EVENT, /* target asynchronous event */ + ISPASYNC_TARGET_ACTION, /* other target command action */ + ISPASYNC_CONF_CHANGE, /* Platform Configuration Change */ + ISPASYNC_UNHANDLED_RESPONSE, /* Unhandled Response Entry */ + ISPASYNC_FW_CRASH, /* Firmware has crashed */ + ISPASYNC_FW_DUMPED, /* Firmware crashdump taken */ + ISPASYNC_FW_RESTARTED /* Firmware has been restarted */ +} ispasync_t; +int isp_async(struct ispsoftc *, ispasync_t, void *); + +#define ISPASYNC_CHANGE_PDB ((void *) 0) +#define ISPASYNC_CHANGE_SNS ((void *) 1) +#define ISPASYNC_CHANGE_OTHER ((void *) 2) + +/* + * Platform Dependent Error and Debug Printout + */ +#ifdef __GNUC__ +void isp_prt(struct ispsoftc *, int level, const char *, ...) + __attribute__((__format__(__printf__,3,4))); +#else +void isp_prt(struct ispsoftc *, int level, const char *, ...); +#endif + +#define ISP_LOGALL 0x0 /* log always */ +#define ISP_LOGCONFIG 0x1 /* log configuration messages */ +#define ISP_LOGINFO 0x2 /* log informational messages */ +#define ISP_LOGWARN 0x4 /* log warning messages */ +#define ISP_LOGERR 0x8 /* log error messages */ +#define ISP_LOGDEBUG0 0x10 /* log simple debug messages */ +#define ISP_LOGDEBUG1 0x20 /* log intermediate debug messages */ +#define ISP_LOGDEBUG2 0x40 /* log most debug messages */ +#define ISP_LOGDEBUG3 0x80 /* log high frequency debug messages */ +#define ISP_LOGDEBUG4 0x100 /* log high frequency debug messages */ +#define ISP_LOGTDEBUG0 0x200 /* log simple debug messages (target mode) */ +#define ISP_LOGTDEBUG1 0x400 /* log intermediate debug messages (target) */ +#define ISP_LOGTDEBUG2 0x800 /* log all debug messages (target) */ + +/* + * Each Platform provides it's own isposinfo substructure of the ispsoftc + * defined above. + * + * Each platform must also provide the following macros/defines: + * + * + * INLINE - platform specific define for 'inline' functions + * + * ISP_DAC_SUPPORTED - Is DAC (Dual Address Cycle) is supported? + * Basically means whether or not DMA for PCI + * PCI cards (Ultra2 or better or FC) works + * above 4GB. + * + * ISP2100_SCRLEN - length for the Fibre Channel scratch DMA area + * + * MEMZERO(dst, src) platform zeroing function + * MEMCPY(dst, src, count) platform copying function + * SNPRINTF(buf, bufsize, fmt, ...) snprintf + * USEC_DELAY(usecs) microsecond spindelay function + * USEC_SLEEP(isp, usecs) microsecond sleep function + * + * NANOTIME_T nanosecond time type + * + * GET_NANOTIME(NANOTIME_T *) get current nanotime. + * + * GET_NANOSEC(NANOTIME_T *) get u_int64_t from NANOTIME_T + * + * NANOTIME_SUB(NANOTIME_T *, NANOTIME_T *) + * subtract two NANOTIME_T values + * + * + * MAXISPREQUEST(struct ispsoftc *) maximum request queue size + * for this particular board type + * + * MEMORYBARRIER(struct ispsoftc *, barrier_type, offset, size) + * + * Function/Macro the provides memory synchronization on + * various objects so that the ISP's and the system's view + * of the same object is consistent. + * + * MBOX_ACQUIRE(struct ispsoftc *) acquire lock on mailbox regs + * MBOX_WAIT_COMPLETE(struct ispsoftc *) wait for mailbox cmd to be done + * MBOX_NOTIFY_COMPLETE(struct ispsoftc *) notification of mbox cmd donee + * MBOX_RELEASE(struct ispsoftc *) release lock on mailbox regs + * + * FC_SCRATCH_ACQUIRE(struct ispsoftc *) acquire lock on FC scratch area + * FC_SCRATCH_RELEASE(struct ispsoftc *) acquire lock on FC scratch area + * + * SCSI_GOOD SCSI 'Good' Status + * SCSI_CHECK SCSI 'Check Condition' Status + * SCSI_BUSY SCSI 'Busy' Status + * SCSI_QFULL SCSI 'Queue Full' Status + * + * XS_T Platform SCSI transaction type (i.e., command for HBA) + * XS_ISP(xs) gets an instance out of an XS_T + * XS_CHANNEL(xs) gets the channel (bus # for DUALBUS cards) "" + * XS_TGT(xs) gets the target "" + * XS_LUN(xs) gets the lun "" + * XS_CDBP(xs) gets a pointer to the scsi CDB "" + * XS_CDBLEN(xs) gets the CDB's length "" + * XS_XFRLEN(xs) gets the associated data transfer length "" + * XS_TIME(xs) gets the time (in milliseconds) for this command + * XS_RESID(xs) gets the current residual count + * XS_STSP(xs) gets a pointer to the SCSI status byte "" + * XS_SNSP(xs) gets a pointer to the associate sense data + * XS_SNSLEN(xs) gets the length of sense data storage + * XS_SNSKEY(xs) dereferences XS_SNSP to get the current stored Sense Key + * XS_TAG_P(xs) predicate of whether this command should be tagged + * XS_TAG_TYPE(xs) which type of tag to use + * XS_SETERR(xs) set error state + * + * HBA_NOERROR command has no erros + * HBA_BOTCH hba botched something + * HBA_CMDTIMEOUT command timed out + * HBA_SELTIMEOUT selection timed out (also port logouts for FC) + * HBA_TGTBSY target returned a BUSY status + * HBA_BUSRESET bus reset destroyed command + * HBA_ABORTED command was aborted (by request) + * HBA_DATAOVR a data overrun was detected + * HBA_ARQFAIL Automatic Request Sense failed + * + * XS_ERR(xs) return current error state + * XS_NOERR(xs) there is no error currently set + * XS_INITERR(xs) initialize error state + * + * XS_SAVE_SENSE(xs, sp) save sense data + * + * XS_SET_STATE_STAT(isp, sp, xs) platform dependent interpreter of + * response queue entry status bits + * + * + * DEFAULT_IID(struct ispsoftc *) Default SCSI initiator ID + * DEFAULT_LOOPID(struct ispsoftc *) Default FC Loop ID + * DEFAULT_NODEWWN(struct ispsoftc *) Default Node WWN + * DEFAULT_PORTWWN(struct ispsoftc *) Default Port WWN + * DEFAULT_FRAMESIZE(struct ispsoftc *) Default Frame Size + * DEFAULT_EXEC_THROTTLE(struct ispsoftc *) Default Execution Throttle + * These establish reasonable defaults for each platform. + * These must be available independent of card NVRAM and are + * to be used should NVRAM not be readable. + * + * ISP_NODEWWN(struct ispsoftc *) FC Node WWN to use + * ISP_PORTWWN(struct ispsoftc *) FC Port WWN to use + * + * These are to be used after NVRAM is read. The tags + * in fcparam.isp_{node,port}wwn reflect the values + * read from NVRAM (possibly corrected for card botches). + * Each platform can take that information and override + * it or ignore and return the Node and Port WWNs to be + * used when sending the Qlogic f/w the Initialization Control + * Block. + * + * (XXX these do endian specific transformations- in transition XXX) + * + * ISP_IOXPUT_8(struct ispsoftc *, u_int8_t srcval, u_int8_t *dstptr) + * ISP_IOXPUT_16(struct ispsoftc *, u_int16_t srcval, u_int16_t *dstptr) + * ISP_IOXPUT_32(struct ispsoftc *, u_int32_t srcval, u_int32_t *dstptr) + * + * ISP_IOXGET_8(struct ispsoftc *, u_int8_t *srcptr, u_int8_t dstrval) + * ISP_IOXGET_16(struct ispsoftc *, u_int16_t *srcptr, u_int16_t dstrval) + * ISP_IOXGET_32(struct ispsoftc *, u_int32_t *srcptr, u_int32_t dstrval) + * + * ISP_SWIZZLE_NVRAM_WORD(struct ispsoftc *, u_int16_t *) + */ + +#endif /* _ISPVAR_H */ diff -puN /dev/null drivers/scsi/isp/firmware/asm_1000.h --- /dev/null 2002-08-30 16:31:37.000000000 -0700 +++ 25-akpm/drivers/scsi/isp/firmware/asm_1000.h 2003-02-14 00:20:12.000000000 -0800 @@ -0,0 +1,3224 @@ +/* @(#)asm_1000.h 1.2 */ +/* + * Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000 Qlogic, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted provided + * that the following conditions are met: + * 1. Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistribution 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 + * + * 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. + */ + +#ifndef ISP_TARGET_MODE +/* + * Firmware Version 1.37.00 (11:28 Aug 28, 2000) + */ +static const u_int16_t isp_1000_risc_code[] = { + 0x0078, 0x1041, 0x0000, 0x2757, 0x0000, 0x12ff, 0x2043, 0x4f50, + 0x5952, 0x4947, 0x4854, 0x2031, 0x3939, 0x312c, 0x3139, 0x3932, + 0x2c31, 0x3939, 0x332c, 0x3139, 0x3934, 0x2051, 0x4c4f, 0x4749, + 0x4320, 0x434f, 0x5250, 0x4f52, 0x4154, 0x494f, 0x4e00, 0x2049, + 0x5350, 0x3130, 0x3030, 0x2046, 0x6972, 0x6d77, 0x6172, 0x6520, + 0x2056, 0x6572, 0x7369, 0x6f6e, 0x2030, 0x312e, 0x3337, 0x2020, + 0x2043, 0x7573, 0x746f, 0x6d65, 0x7220, 0x4e6f, 0x2e20, 0x3135, + 0x2050, 0x726f, 0x6475, 0x6374, 0x204e, 0x6f2e, 0x2000, 0x3030, + 0x2024, 0x20b9, 0x1212, 0x20c1, 0x0008, 0x2071, 0x0010, 0x70c3, + 0x0004, 0x20c9, 0x5cff, 0x2089, 0x10ee, 0x70c7, 0x4953, 0x70cb, + 0x5020, 0x70cf, 0x2020, 0x70d3, 0x0001, 0x3f00, 0x70d6, 0x2031, + 0x0030, 0x2079, 0x3800, 0x7863, 0x0000, 0x2fa0, 0x2009, 0x031b, + 0x2011, 0x0000, 0x20a9, 0x0040, 0x42a4, 0x8109, 0x00c0, 0x1062, + 0x789b, 0x0101, 0x780b, 0x0002, 0x780f, 0x0002, 0x784f, 0x0bb8, + 0x2009, 0x3835, 0x200b, 0x0003, 0x78bb, 0x0000, 0x78bf, 0x0000, + 0x78c3, 0x0000, 0x2069, 0x3840, 0x00a8, 0x1085, 0x681b, 0x003c, + 0x2009, 0x1313, 0x21b8, 0x0078, 0x1087, 0x681b, 0x0028, 0x6807, + 0x0007, 0x680b, 0x00fa, 0x680f, 0x0008, 0x6813, 0x0005, 0x681f, + 0x0000, 0x6823, 0x0006, 0x6817, 0x0008, 0x6827, 0x0000, 0x2069, + 0x3a80, 0x2011, 0x0020, 0x2009, 0x0010, 0x680b, 0x0c19, 0x680f, + 0x0019, 0x6803, 0xdd00, 0x6807, 0x001a, 0x6a1a, 0x2d00, 0xa0e8, + 0x0008, 0xa290, 0x0004, 0x8109, 0x00c0, 0x109d, 0x2069, 0x3b00, + 0x2009, 0x0002, 0x20a9, 0x0100, 0x683f, 0x0000, 0x2001, 0x0008, + 0x8007, 0x6832, 0x6837, 0x000a, 0x680b, 0x0040, 0x6817, 0x0100, + 0x681f, 0x0064, 0xade8, 0x0010, 0x0070, 0x10c8, 0x0078, 0x10b4, + 0x8109, 0x00c0, 0x10b2, 0x1078, 0x1b64, 0x1078, 0x31c0, 0x1078, + 0x1747, 0x1078, 0x368b, 0x3200, 0xa085, 0x000d, 0x2090, 0x70c3, + 0x0000, 0x0090, 0x10e2, 0x70c0, 0xa086, 0x0002, 0x00c0, 0x10e2, + 0x1078, 0x11e0, 0x1078, 0x1112, 0x1078, 0x18f2, 0x1078, 0x1aaf, + 0x1078, 0x34fd, 0x1078, 0x184d, 0x0078, 0x10e2, 0x10f6, 0x10f8, + 0x1d05, 0x1d05, 0x321e, 0x321e, 0x1d05, 0x1d05, 0x0078, 0x10f6, + 0x0078, 0x10f8, 0x0078, 0x10fa, 0x0078, 0x10fc, 0x7008, 0x800c, + 0x00c8, 0x110d, 0x7007, 0x0002, 0xa08c, 0x000c, 0x00c0, 0x110e, + 0x8004, 0x8004, 0x00c8, 0x110d, 0x087a, 0x097a, 0x70c3, 0x4002, + 0x0078, 0x11e3, 0x7814, 0xa005, 0x00c0, 0x111a, 0x0010, 0x1156, + 0x0078, 0x1155, 0x2009, 0x3868, 0x2104, 0xa005, 0x00c0, 0x1155, + 0x7814, 0xa086, 0x0001, 0x00c0, 0x1127, 0x1078, 0x15ae, 0x7817, + 0x0000, 0x2009, 0x386f, 0x2104, 0xa065, 0x0040, 0x1143, 0x2009, + 0x386a, 0x211c, 0x8108, 0x2114, 0x8108, 0x2104, 0xa210, 0xa399, + 0x0000, 0x2009, 0x0018, 0x6083, 0x0103, 0x1078, 0x16d7, 0x00c0, + 0x114f, 0x1078, 0x173e, 0x2009, 0x386f, 0x200b, 0x0000, 0x2009, + 0x3869, 0x2104, 0x200b, 0x0000, 0xa005, 0x0040, 0x1153, 0x2001, + 0x4005, 0x0078, 0x11e2, 0x0078, 0x11e0, 0x007c, 0x2061, 0x0000, + 0x6018, 0xa084, 0x0001, 0x0040, 0x115e, 0x007c, 0x70c3, 0x0000, + 0x70c7, 0x0000, 0x70cb, 0x0000, 0x70cf, 0x0000, 0x70c0, 0xa0bc, + 0xffc0, 0x00c0, 0x11ae, 0x2038, 0x0079, 0x116e, 0x11e0, 0x122e, + 0x11fc, 0x122e, 0x127f, 0x127f, 0x11f3, 0x1608, 0x128a, 0x11ef, + 0x1200, 0x1202, 0x1204, 0x1206, 0x160d, 0x11ef, 0x1292, 0x12ba, + 0x15bc, 0x1602, 0x1208, 0x14e3, 0x1505, 0x151f, 0x1548, 0x149c, + 0x14aa, 0x14be, 0x14d2, 0x1357, 0x1332, 0x12e2, 0x12e9, 0x12ee, + 0x12f3, 0x12f9, 0x12fe, 0x1303, 0x1308, 0x130d, 0x1311, 0x1326, + 0x11ef, 0x11ef, 0x11ef, 0x11ef, 0x11ef, 0x1363, 0x136c, 0x137b, + 0x13a1, 0x13ab, 0x13b2, 0x13d8, 0x13e7, 0x13f6, 0x1408, 0x147a, + 0x11ef, 0x148a, 0x11ef, 0x11ef, 0x11ef, 0x1491, 0xa0bc, 0xffa0, + 0x00c0, 0x11ef, 0x2038, 0xa084, 0x001f, 0x0079, 0x11b7, 0x11ef, + 0x11ef, 0x11ef, 0x11ef, 0x11ef, 0x11ef, 0x11ef, 0x11ef, 0x11ef, + 0x11ef, 0x11ef, 0x11ef, 0x11ef, 0x11ef, 0x1665, 0x1674, 0x11ef, + 0x11ef, 0x11ef, 0x11ef, 0x11ef, 0x11ef, 0x11ef, 0x11ef, 0x11ef, + 0x11ef, 0x16b3, 0x16bd, 0x16c1, 0x16cf, 0x167f, 0x169c, 0x72ca, + 0x71c6, 0x2001, 0x4006, 0x0078, 0x11e2, 0x73ce, 0x72ca, 0x71c6, + 0x2001, 0x4000, 0x70c2, 0x2061, 0x0000, 0x601b, 0x0001, 0x2091, + 0x5000, 0x2091, 0x4080, 0x007c, 0x71c6, 0x0078, 0x11e2, 0x70c3, + 0x4001, 0x0078, 0x11e3, 0x2099, 0x0041, 0x20a1, 0x0041, 0x20a9, + 0x0005, 0x53a3, 0x0078, 0x11e0, 0x70c4, 0x70c3, 0x0004, 0x007a, + 0x0078, 0x11e0, 0x0078, 0x11e0, 0x0078, 0x11e0, 0x0078, 0x11e0, + 0x2091, 0x8000, 0x70c3, 0x0000, 0x70c7, 0x4953, 0x70cb, 0x5020, + 0x70cf, 0x2020, 0x70d3, 0x0001, 0x3f00, 0x70d6, 0x2079, 0x0000, + 0x781b, 0x0001, 0x2031, 0x0030, 0x2059, 0x1000, 0x2029, 0x0457, + 0x2051, 0x0470, 0x2061, 0x0472, 0x20b9, 0xffff, 0x20c1, 0x0000, + 0x2091, 0x5000, 0x2091, 0x4080, 0x0078, 0x0455, 0x71d0, 0x72c8, + 0x73cc, 0x70c4, 0x20a0, 0x2098, 0x2031, 0x0030, 0x81ff, 0x0040, + 0x11e0, 0x7007, 0x0004, 0x731a, 0x721e, 0x2051, 0x0012, 0x2049, + 0x125d, 0x2041, 0x11e0, 0x7003, 0x0002, 0xa786, 0x0001, 0x00c0, + 0x124f, 0x2049, 0x126b, 0x2041, 0x1277, 0x7003, 0x0003, 0x7017, + 0x0000, 0x810b, 0x7112, 0x00c8, 0x1257, 0x7017, 0x0001, 0x7007, + 0x0001, 0xa786, 0x0001, 0x0040, 0x126b, 0x700c, 0xa084, 0x007f, + 0x8004, 0x2009, 0x0020, 0xa102, 0x0942, 0x094a, 0x20a8, 0x26a0, + 0x53a6, 0x0078, 0x10fe, 0x700c, 0xa084, 0x007f, 0x0040, 0x126b, + 0x80ac, 0x0048, 0x126b, 0x2698, 0x53a5, 0x0078, 0x10fe, 0x700c, + 0xa084, 0x007f, 0x80ac, 0x2698, 0x53a5, 0x0078, 0x11e0, 0x71c4, + 0x70c8, 0x2114, 0xa79e, 0x0004, 0x00c0, 0x1287, 0x200a, 0x72ca, + 0x0078, 0x11df, 0x70c7, 0x0125, 0x70cb, 0x0000, 0x70cf, 0x0f00, + 0x0078, 0x11e0, 0x70c4, 0x72c8, 0x73cc, 0x74d0, 0x70c6, 0x72ca, + 0x73ce, 0x74d2, 0xa005, 0x0040, 0x12b4, 0x8001, 0x7872, 0xa084, + 0xfc00, 0x0040, 0x12ab, 0x7898, 0xa085, 0x0001, 0x789a, 0x2001, + 0x4005, 0x0078, 0x11e2, 0x7a7a, 0x7b7e, 0x7c76, 0x7898, 0xa084, + 0xfffc, 0x789a, 0x0078, 0x12b8, 0x7898, 0xa085, 0x0001, 0x789a, + 0x0078, 0x11e0, 0x70c4, 0x72c8, 0x73cc, 0x74d4, 0x70c6, 0x72ca, + 0x73ce, 0x74d6, 0xa005, 0x0040, 0x12dc, 0x8001, 0x7886, 0xa084, + 0xfc00, 0x0040, 0x12d3, 0x7898, 0xa085, 0x0100, 0x789a, 0x2001, + 0x4005, 0x0078, 0x11e2, 0x7a8e, 0x7b92, 0x7c8a, 0x7898, 0xa084, + 0xfcff, 0x789a, 0x0078, 0x12e0, 0x7898, 0xa085, 0x0100, 0x789a, + 0x0078, 0x11e0, 0x2009, 0x3859, 0x210c, 0x2011, 0x0372, 0x0078, + 0x11de, 0x2009, 0x3841, 0x210c, 0x0078, 0x11df, 0x2009, 0x3842, + 0x210c, 0x0078, 0x11df, 0x2061, 0x3840, 0x610c, 0x6210, 0x0078, + 0x11de, 0x2009, 0x3845, 0x210c, 0x0078, 0x11df, 0x2009, 0x3846, + 0x210c, 0x0078, 0x11df, 0x2009, 0x3847, 0x210c, 0x0078, 0x11df, + 0x2009, 0x3848, 0x210c, 0x0078, 0x11df, 0x7908, 0x7a0c, 0x0078, + 0x11de, 0x71c4, 0x8107, 0xa084, 0x000f, 0x8003, 0x8003, 0x8003, + 0xa0e8, 0x3a80, 0x6a00, 0x6804, 0xa084, 0x0008, 0x0040, 0x1323, + 0x6b08, 0x0078, 0x1324, 0x6b0c, 0x0078, 0x11dd, 0x77c4, 0x1078, + 0x1758, 0x2091, 0x8000, 0x6b1c, 0x6a14, 0x2091, 0x8001, 0x2708, + 0x0078, 0x11dd, 0x2091, 0x8000, 0x7848, 0xa005, 0x00c0, 0x1346, + 0x2061, 0x3b00, 0x20a9, 0x0100, 0x603c, 0xa005, 0x00c0, 0x1346, + 0xace0, 0x0010, 0x00f0, 0x133c, 0x0078, 0x134e, 0x2019, 0x0000, + 0x2011, 0x0000, 0x2009, 0x0000, 0x0078, 0x1353, 0x7bb8, 0x7abc, + 0x79c0, 0x78c3, 0x0000, 0x2091, 0x8001, 0x0078, 0x11dd, 0x77c4, + 0x1078, 0x1758, 0x2091, 0x8000, 0x6908, 0x6a18, 0x6b10, 0x2091, + 0x8001, 0x0078, 0x11dd, 0x71c4, 0xa182, 0x0010, 0x00c8, 0x11d8, + 0x1078, 0x1be8, 0x0078, 0x11dd, 0x71c4, 0xa182, 0x0010, 0x00c8, + 0x11d8, 0x2011, 0x3841, 0x2204, 0x007e, 0x2112, 0x1078, 0x1ba1, + 0x017f, 0x0078, 0x11df, 0x71c4, 0x2011, 0x1399, 0x20a9, 0x0008, + 0x2204, 0xa106, 0x0040, 0x138b, 0x8210, 0x0070, 0x1389, 0x0078, + 0x1380, 0x0078, 0x11d8, 0xa292, 0x1399, 0x027e, 0x2011, 0x3842, + 0x2204, 0x2112, 0x017f, 0x007e, 0x1078, 0x1bad, 0x017f, 0x0078, + 0x11df, 0x03e8, 0x00fa, 0x01f4, 0x02ee, 0x0064, 0x0019, 0x0032, + 0x004b, 0x2061, 0x3840, 0x610c, 0x6210, 0x70c4, 0x600e, 0x70c8, + 0x6012, 0x0078, 0x11de, 0x2061, 0x3840, 0x6114, 0x70c4, 0x6016, + 0x0078, 0x11df, 0x71c4, 0x2011, 0x0004, 0x2019, 0x1212, 0xa186, + 0x0028, 0x0040, 0x13cb, 0x2011, 0x0005, 0x2019, 0x1212, 0xa186, + 0x0032, 0x0040, 0x13cb, 0x2011, 0x0006, 0x2019, 0x1313, 0xa186, + 0x003c, 0x00c0, 0x11d8, 0x2061, 0x3840, 0x6018, 0x007e, 0x611a, + 0x23b8, 0x1078, 0x1bbe, 0x1078, 0x368b, 0x017f, 0x0078, 0x11df, + 0x71c4, 0xa184, 0xffcf, 0x00c0, 0x11d8, 0x2011, 0x3847, 0x2204, + 0x2112, 0x007e, 0x1078, 0x1be0, 0x017f, 0x0078, 0x11df, 0x71c4, + 0xa182, 0x0010, 0x00c8, 0x11d8, 0x2011, 0x3848, 0x2204, 0x007e, + 0x2112, 0x1078, 0x1bcf, 0x017f, 0x0078, 0x11df, 0x71c4, 0x72c8, + 0xa184, 0xfffd, 0x00c0, 0x11d7, 0xa284, 0xfffd, 0x00c0, 0x11d7, + 0x2100, 0x7908, 0x780a, 0x2200, 0x7a0c, 0x780e, 0x0078, 0x11de, + 0x71c4, 0x8107, 0xa084, 0x000f, 0x8003, 0x8003, 0x8003, 0xa0e8, + 0x3a80, 0x2019, 0x0000, 0x72c8, 0x6800, 0x007e, 0xa226, 0x0040, + 0x1440, 0xa284, 0x0001, 0x0040, 0x1422, 0x2220, 0xa39d, 0x0002, + 0xa294, 0xfffe, 0x6a02, 0xa484, 0x2000, 0x0040, 0x1429, 0xa39d, + 0x0010, 0xa484, 0x1000, 0x0040, 0x142f, 0xa39d, 0x0008, 0xa484, + 0x4000, 0x0040, 0x1440, 0x810f, 0xa284, 0x4000, 0x0040, 0x143c, + 0x1078, 0x1c02, 0x0078, 0x1440, 0x1078, 0x1bf4, 0x0078, 0x1440, + 0x72cc, 0x82ff, 0x0040, 0x1472, 0x6808, 0xa206, 0x0040, 0x1472, + 0xa2a4, 0x00ff, 0x2061, 0x3840, 0x6118, 0xa186, 0x0028, 0x0040, + 0x1459, 0xa186, 0x0032, 0x0040, 0x145f, 0xa186, 0x003c, 0x0040, + 0x1465, 0xa482, 0x0064, 0x0048, 0x146f, 0x0078, 0x1469, 0xa482, + 0x0050, 0x0048, 0x146f, 0x0078, 0x1469, 0xa482, 0x0043, 0x0048, + 0x146f, 0x71c4, 0x71c6, 0x027f, 0x72ca, 0x0078, 0x11d9, 0x6a0a, + 0xa39d, 0x000a, 0x6804, 0xa305, 0x6806, 0x027f, 0x6b0c, 0x71c4, + 0x0078, 0x11dd, 0x77c4, 0x1078, 0x1758, 0x2091, 0x8000, 0x6a14, + 0x6b1c, 0x2091, 0x8001, 0x70c8, 0x6816, 0x70cc, 0x681e, 0x2708, + 0x0078, 0x11dd, 0x2011, 0x3835, 0x220c, 0x70c4, 0x2012, 0x0078, + 0x11df, 0x71c4, 0x72c8, 0x73cc, 0xa182, 0x0010, 0x00c8, 0x11d8, + 0x1078, 0x1c10, 0x0078, 0x11dd, 0x77c4, 0x1078, 0x1758, 0x2091, + 0x8000, 0x6a08, 0xa295, 0x0002, 0x6a0a, 0x2091, 0x8001, 0x2708, + 0x0078, 0x11de, 0x77c4, 0x1078, 0x1758, 0x2091, 0x8000, 0x6a08, + 0xa294, 0xfff9, 0x6a0a, 0x6804, 0xa005, 0x0040, 0x14b9, 0x1078, + 0x1b49, 0x2091, 0x8001, 0x2708, 0x0078, 0x11de, 0x77c4, 0x1078, + 0x1758, 0x2091, 0x8000, 0x6a08, 0xa295, 0x0004, 0x6a0a, 0x6804, + 0xa005, 0x0040, 0x14cd, 0x1078, 0x1b49, 0x2091, 0x8001, 0x2708, + 0x0078, 0x11de, 0x77c4, 0x2041, 0x0001, 0x2049, 0x0005, 0x2051, + 0x0020, 0x2091, 0x8000, 0x1078, 0x1765, 0x2091, 0x8001, 0x2708, + 0x6a08, 0x0078, 0x11de, 0x77c4, 0x72c8, 0x73cc, 0x77c6, 0x72ca, + 0x73ce, 0x1078, 0x17e6, 0x00c0, 0x1501, 0x6818, 0xa005, 0x0040, + 0x14fb, 0x2708, 0x1078, 0x1c20, 0x00c0, 0x14fb, 0x7817, 0xffff, + 0x2091, 0x8001, 0x007c, 0x2091, 0x8001, 0x2001, 0x4005, 0x0078, + 0x11e2, 0x2091, 0x8001, 0x0078, 0x11e0, 0x77c4, 0x77c6, 0x2041, + 0x0021, 0x2049, 0x0005, 0x2051, 0x0020, 0x2091, 0x8000, 0x1078, + 0x1765, 0x2061, 0x3840, 0x60a3, 0x0003, 0x67b6, 0x60a7, 0x0000, + 0x7817, 0xffff, 0x1078, 0x1b49, 0x2091, 0x8001, 0x007c, 0x77c8, + 0x77ca, 0x77c4, 0x77c6, 0xa7bc, 0xff00, 0x2091, 0x8000, 0x2061, + 0x3840, 0x60a3, 0x0002, 0x60a7, 0x0000, 0x67b6, 0x7817, 0xffff, + 0x1078, 0x1b49, 0x2091, 0x8001, 0x2041, 0x0021, 0x2049, 0x0004, + 0x2051, 0x0010, 0x2091, 0x8000, 0x1078, 0x1765, 0x70c8, 0x683e, + 0x8738, 0xa784, 0x001f, 0x00c0, 0x153c, 0x2091, 0x8001, 0x007c, + 0x7898, 0xa084, 0x0003, 0x00c0, 0x156c, 0x2039, 0x0000, 0x2041, + 0x0021, 0x2049, 0x0004, 0x2051, 0x0008, 0x1078, 0x1758, 0x2091, + 0x8000, 0x6808, 0xa80d, 0x690a, 0x2091, 0x8001, 0x8738, 0xa784, + 0x001f, 0x00c0, 0x1555, 0xa7bc, 0xff00, 0x873f, 0x8738, 0x873f, + 0xa784, 0x0f00, 0x00c0, 0x1555, 0x2091, 0x8000, 0x2069, 0x0100, + 0x6830, 0xa084, 0x0040, 0x0040, 0x1595, 0x684b, 0x0004, 0x20a9, + 0x0014, 0x6848, 0xa084, 0x0004, 0x0040, 0x1582, 0x0070, 0x1582, + 0x0078, 0x1579, 0x684b, 0x0009, 0x20a9, 0x0014, 0x6848, 0xa084, + 0x0001, 0x0040, 0x158f, 0x0070, 0x158f, 0x0078, 0x1586, 0x20a9, + 0x00fa, 0x0070, 0x1595, 0x0078, 0x1591, 0x2079, 0x3800, 0x7817, + 0x0001, 0x2061, 0x3840, 0x60a3, 0x0001, 0x60a7, 0x0000, 0x60c3, + 0x000f, 0x7898, 0xa085, 0x0002, 0x789a, 0x6808, 0xa084, 0xfffd, + 0x680a, 0x681b, 0x0046, 0x2091, 0x8001, 0x007c, 0x7898, 0xa084, + 0xfffd, 0x789a, 0xa084, 0x0001, 0x00c0, 0x15b8, 0x1078, 0x1830, + 0x71c4, 0x71c6, 0x794a, 0x007c, 0x74c4, 0x73c8, 0x72cc, 0x74c6, + 0x73ca, 0x72ce, 0x2079, 0x3800, 0x2009, 0x0040, 0x1078, 0x1735, + 0x0040, 0x15fe, 0x1078, 0x1705, 0x0040, 0x15d2, 0x1078, 0x173e, + 0x0078, 0x15fe, 0x6010, 0x2091, 0x8000, 0x7817, 0xffff, 0x2009, + 0x3868, 0x200b, 0x0005, 0x8108, 0x200b, 0x0000, 0x8108, 0x230a, + 0x8108, 0x220a, 0x8108, 0x240a, 0x8108, 0x200a, 0x8108, 0x200b, + 0x0000, 0x8108, 0x2c0a, 0xa02e, 0x2530, 0x0e7e, 0x1078, 0x3199, + 0x0e7f, 0x6592, 0x65a2, 0x6696, 0x66a6, 0x60ab, 0x0000, 0x60af, + 0x0000, 0x1078, 0x1b49, 0x2091, 0x8001, 0x007c, 0x70c3, 0x4005, + 0x0078, 0x11e3, 0x71c4, 0x70c7, 0x0000, 0x7906, 0x0078, 0x11e0, + 0x71c4, 0x71c6, 0x2168, 0x0078, 0x160f, 0x2069, 0x1000, 0x690c, + 0xa016, 0x2d04, 0xa210, 0x8d68, 0x8109, 0x00c0, 0x1611, 0xa285, + 0x0000, 0x00c0, 0x161f, 0x70c3, 0x4000, 0x0078, 0x1621, 0x70c3, + 0x4003, 0x70ca, 0x0078, 0x11e3, 0x71c4, 0x72c8, 0x73cc, 0x2100, + 0xa184, 0xfffc, 0x00c0, 0x11ef, 0x2100, 0x0079, 0x162f, 0x1646, + 0x165b, 0x165d, 0x165f, 0x70c3, 0x4003, 0x71ce, 0x72d2, 0x73d6, + 0x0078, 0x1642, 0x70c3, 0x4000, 0x70cf, 0x0000, 0x70d3, 0x0000, + 0x70d7, 0x0000, 0x77c6, 0x71ca, 0x0078, 0x11e0, 0x2031, 0x1661, + 0x2624, 0x8630, 0x2412, 0x2204, 0xa446, 0x00c0, 0x1633, 0xa484, + 0xffff, 0x00c0, 0x1648, 0x2031, 0x1661, 0x8210, 0x8319, 0xa384, + 0xffff, 0x00c0, 0x1648, 0x0078, 0x163a, 0x0078, 0x163a, 0x0078, + 0x163a, 0x5555, 0xaaaa, 0xffff, 0x0000, 0x77c4, 0x1078, 0x1758, + 0x2091, 0x8000, 0x6830, 0xa084, 0xff00, 0x8007, 0x2010, 0x2091, + 0x8001, 0x2708, 0x0078, 0x11de, 0x77c4, 0x1078, 0x1758, 0x2091, + 0x8000, 0x6a34, 0x2091, 0x8001, 0x2708, 0x0078, 0x11de, 0x77c4, + 0x077e, 0xa7bc, 0xff00, 0x20a9, 0x0020, 0x72c8, 0x8217, 0xa294, + 0xff00, 0x1078, 0x1758, 0x2091, 0x8000, 0x6c30, 0x6a32, 0x2091, + 0x8001, 0x8738, 0x00f0, 0x1689, 0x077f, 0x2708, 0x8427, 0xa4a4, + 0x00ff, 0x2410, 0x0078, 0x11de, 0x77c4, 0x077e, 0xa7bc, 0xff00, + 0x20a9, 0x0020, 0x72c8, 0x1078, 0x1758, 0x2091, 0x8000, 0x6c34, + 0x6a36, 0x2091, 0x8001, 0x8738, 0x00f0, 0x16a3, 0x077f, 0x2708, + 0x2410, 0x0078, 0x11de, 0x7960, 0x71c6, 0x71c4, 0xa182, 0x0003, + 0x00c8, 0x11d8, 0x7962, 0x0078, 0x11e0, 0x7960, 0x71c6, 0x0078, + 0x11e0, 0x7954, 0x71c6, 0x71c4, 0x7956, 0x7958, 0x71ca, 0x71c8, + 0x795a, 0x795c, 0x71ce, 0x71cc, 0x795e, 0x0078, 0x11e0, 0x7954, + 0x71c6, 0x7958, 0x71ca, 0x795c, 0x71ce, 0x0078, 0x11e0, 0x700c, + 0xa084, 0x007f, 0x0040, 0x16e3, 0x7007, 0x0004, 0x7004, 0xa084, + 0x0004, 0x00c0, 0x16de, 0x7017, 0x0000, 0x7112, 0x721a, 0x731e, + 0x8108, 0x810c, 0x81a9, 0x8c98, 0x20a1, 0x0030, 0x6080, 0x20a2, + 0x53a6, 0x780c, 0xa085, 0x0000, 0x7002, 0x7007, 0x0001, 0x7108, + 0x8104, 0x00c8, 0x16f7, 0x7007, 0x0002, 0xa184, 0x000c, 0x710c, + 0xa184, 0x0300, 0x7003, 0x0000, 0x007c, 0x700c, 0xa084, 0x007f, + 0x0040, 0x1711, 0x7007, 0x0004, 0x7004, 0xa084, 0x0004, 0x00c0, + 0x170c, 0x7017, 0x0000, 0x7112, 0x721a, 0x731e, 0x2099, 0x0030, + 0x8108, 0x81ac, 0x780c, 0xa085, 0x0001, 0x7002, 0x7007, 0x0001, + 0x7008, 0x800c, 0x00c8, 0x1720, 0x7007, 0x0002, 0xa08c, 0x000c, + 0x00c0, 0x1732, 0x710c, 0xa184, 0x0300, 0x00c0, 0x1732, 0x2ca0, + 0x53a5, 0xa006, 0x7003, 0x0000, 0x007c, 0x7850, 0xa065, 0x0040, + 0x173d, 0x2c04, 0x7852, 0x2063, 0x0000, 0x007c, 0x0f7e, 0x2079, + 0x3800, 0x7850, 0x2062, 0x2c00, 0x7852, 0x0f7f, 0x007c, 0x2011, + 0x5d00, 0x7a52, 0x2019, 0x0372, 0x8319, 0x0040, 0x1755, 0xa280, + 0x002f, 0x2012, 0x2010, 0x0078, 0x174c, 0x2013, 0x0000, 0x007c, + 0xa784, 0x0f00, 0x800b, 0xa784, 0x001f, 0x8003, 0x8003, 0x8003, + 0x8003, 0xa105, 0xa0e8, 0x3b00, 0x007c, 0x1078, 0x1758, 0x2900, + 0x682a, 0x2a00, 0x682e, 0x6808, 0xa084, 0xffef, 0xa80d, 0x690a, + 0x2091, 0x8000, 0x2009, 0x384f, 0x210c, 0x6804, 0xa005, 0x0040, + 0x1784, 0xa116, 0x00c0, 0x1784, 0x2060, 0x6000, 0x6806, 0x017e, + 0x200b, 0x0000, 0x0078, 0x1787, 0x2009, 0x0000, 0x017e, 0x6804, + 0xa065, 0x0040, 0x1798, 0x6000, 0x6806, 0x1078, 0x17ad, 0x1078, + 0x18a4, 0x1078, 0x2b27, 0x6810, 0x8001, 0x6812, 0x00c0, 0x1787, + 0x1078, 0x2b27, 0x017f, 0x6902, 0x6906, 0x2091, 0x8001, 0x007c, + 0xa065, 0x0040, 0x17ac, 0x6098, 0x609b, 0x0000, 0x2008, 0x1078, + 0x173e, 0x2100, 0x0078, 0x17a0, 0x007c, 0x6003, 0x0103, 0x20a9, + 0x001c, 0xac80, 0x0004, 0x20a0, 0x2001, 0x0000, 0x40a4, 0x6828, + 0x6016, 0x682c, 0x601e, 0x007c, 0x0e7e, 0x2071, 0x3840, 0x7040, + 0xa08c, 0x0200, 0x00c0, 0x17ca, 0xa088, 0x3880, 0x2d0a, 0x8000, + 0x7042, 0xa006, 0x0e7f, 0x007c, 0x0e7e, 0x2071, 0x3840, 0x2009, + 0x3880, 0x7240, 0x8221, 0x8211, 0x0048, 0x17e4, 0x2104, 0x8108, + 0xad06, 0x00c0, 0x17d3, 0x8119, 0x211e, 0x8108, 0x8318, 0x8211, + 0x00c8, 0x17dc, 0x7442, 0xa006, 0x0e7f, 0x007c, 0x1078, 0x1758, + 0x2091, 0x8000, 0x6804, 0x781e, 0xa065, 0x0040, 0x182f, 0x0078, + 0x17f7, 0x2c00, 0x781e, 0x6000, 0xa065, 0x0040, 0x182f, 0x600c, + 0xa306, 0x00c0, 0x17f1, 0x6008, 0xa206, 0x00c0, 0x17f1, 0x2c28, + 0x2001, 0x384f, 0x2004, 0xac06, 0x0040, 0x182f, 0x6804, 0xac06, + 0x00c0, 0x1814, 0x6000, 0x2060, 0x6806, 0xa005, 0x00c0, 0x1814, + 0x6803, 0x0000, 0x0078, 0x181e, 0x6400, 0x781c, 0x2060, 0x6402, + 0xa486, 0x0000, 0x00c0, 0x181e, 0x2c00, 0x6802, 0x2560, 0x1078, + 0x17ad, 0x6017, 0x0005, 0x601f, 0x0020, 0x1078, 0x18a4, 0x1078, + 0x2b27, 0x6810, 0x8001, 0x6812, 0x2001, 0xffff, 0xa005, 0x007c, + 0x2039, 0x0000, 0x2041, 0x0021, 0x2049, 0x0004, 0x2051, 0x0008, + 0x2091, 0x8000, 0x1078, 0x1765, 0x8738, 0xa784, 0x001f, 0x00c0, + 0x183a, 0xa7bc, 0xff00, 0x873f, 0x8738, 0x873f, 0xa784, 0x0f00, + 0x00c0, 0x183a, 0x2091, 0x8001, 0x007c, 0x0068, 0x185c, 0x2061, + 0x0000, 0x6018, 0xa084, 0x0001, 0x00c0, 0x185c, 0x78ac, 0x78af, + 0x0000, 0xa005, 0x00c0, 0x185d, 0x007c, 0xa08c, 0xfff0, 0x0040, + 0x1863, 0x1078, 0x1ce7, 0x0079, 0x1865, 0x1875, 0x1877, 0x187d, + 0x1881, 0x1875, 0x1885, 0x1875, 0x1875, 0x188b, 0x1875, 0x1892, + 0x1896, 0x1875, 0x1875, 0x1875, 0x1875, 0x1078, 0x1ce7, 0x1078, + 0x1830, 0x2001, 0x8001, 0x0078, 0x189c, 0x2001, 0x8003, 0x0078, + 0x189c, 0x2001, 0x8004, 0x0078, 0x189c, 0x1078, 0x1830, 0x2001, + 0x8006, 0x0078, 0x189c, 0x2001, 0x8009, 0x2011, 0x382c, 0x220c, + 0x0078, 0x11ec, 0x2001, 0x800c, 0x0078, 0x189c, 0x1078, 0x1830, + 0x2001, 0x800d, 0x0078, 0x189c, 0x70c2, 0x2061, 0x0000, 0x601b, + 0x0001, 0x2091, 0x4080, 0x007c, 0x2c04, 0x6082, 0x2c08, 0x2063, + 0x0000, 0x7864, 0x8000, 0x7866, 0x7868, 0xa005, 0x796a, 0x0040, + 0x18b4, 0x2c02, 0x0078, 0x18b5, 0x796e, 0x007c, 0x0c7e, 0x2061, + 0x3800, 0x6883, 0x0103, 0x2d08, 0x206b, 0x0000, 0x6064, 0x8000, + 0x6066, 0x6068, 0xa005, 0x616a, 0x0040, 0x18c9, 0x2d02, 0x0078, + 0x18cc, 0x616e, 0x1078, 0x2b41, 0x0c7f, 0x007c, 0x1078, 0x18df, + 0x0040, 0x18de, 0x0c7e, 0x6098, 0xa065, 0x0040, 0x18d9, 0x1078, + 0x17a0, 0x0c7f, 0x609b, 0x0000, 0x1078, 0x173e, 0x007c, 0x786c, + 0xa065, 0x0040, 0x18f1, 0x2091, 0x8000, 0x7864, 0x8001, 0x7866, + 0x2c04, 0x786e, 0xa005, 0x00c0, 0x18ef, 0x786a, 0x8000, 0x2091, + 0x8001, 0x007c, 0x7898, 0xa005, 0x00c0, 0x194d, 0x7974, 0x70d0, + 0x0005, 0x0005, 0x72d0, 0xa206, 0x00c0, 0x18f7, 0x2200, 0xa106, + 0x00c0, 0x190e, 0x7804, 0xa005, 0x0040, 0x194d, 0x7807, 0x0000, + 0x0068, 0x194d, 0x2091, 0x4080, 0x0078, 0x194d, 0x1078, 0x1735, + 0x0040, 0x194d, 0x7a7c, 0x7b78, 0xa184, 0xff00, 0x0040, 0x1921, + 0x810f, 0x810c, 0x810c, 0x8004, 0x8004, 0x8007, 0xa100, 0x0078, + 0x1924, 0x8107, 0x8004, 0x8004, 0xa210, 0xa399, 0x0000, 0x2009, + 0x0040, 0x1078, 0x1705, 0x0040, 0x1944, 0x1078, 0x173e, 0x7880, + 0x8000, 0x7882, 0xa086, 0x0002, 0x00c0, 0x194d, 0x2091, 0x8000, + 0x78af, 0x0002, 0x7883, 0x0000, 0x7898, 0xa085, 0x0003, 0x789a, + 0x2091, 0x8001, 0x0078, 0x194d, 0x7883, 0x0000, 0x1078, 0x1a99, + 0x6000, 0xa084, 0x0007, 0x0079, 0x194e, 0x007c, 0x1956, 0x1965, + 0x1985, 0x1956, 0x1997, 0x1956, 0x1956, 0x1956, 0x2039, 0x0400, + 0x78a8, 0xa705, 0x78aa, 0x6004, 0xa705, 0x6006, 0x1078, 0x19e2, + 0x6018, 0x78a6, 0x1078, 0x1a81, 0x007c, 0x78a8, 0xa084, 0x0100, + 0x0040, 0x196c, 0x0078, 0x1956, 0x78ab, 0x0000, 0x6000, 0x8007, + 0xa084, 0x00ff, 0x789e, 0x8001, 0x609b, 0x0000, 0x0040, 0x1982, + 0x1078, 0x19e2, 0x0040, 0x1982, 0x78a8, 0xa085, 0x0100, 0x78aa, + 0x0078, 0x1984, 0x1078, 0x1a06, 0x007c, 0x78a8, 0xa08c, 0x0e00, + 0x00c0, 0x198e, 0xa084, 0x0100, 0x00c0, 0x1990, 0x0078, 0x1956, + 0x1078, 0x19e2, 0x00c0, 0x1996, 0x1078, 0x1a06, 0x007c, 0x78a8, + 0xa084, 0x0100, 0x0040, 0x199e, 0x0078, 0x1956, 0x78ab, 0x0000, + 0x6710, 0x2011, 0x0001, 0x20a9, 0x0001, 0x6014, 0xa084, 0x00ff, + 0xa005, 0x0040, 0x19c1, 0x2011, 0x0001, 0xa7bc, 0xff00, 0x20a9, + 0x0020, 0xa08e, 0x0001, 0x0040, 0x19c1, 0x2039, 0x0000, 0x2011, + 0x0002, 0x20a9, 0x0100, 0xa08e, 0x0002, 0x0040, 0x19c1, 0x0078, + 0x19df, 0x1078, 0x1758, 0x2d00, 0x2091, 0x8000, 0x682b, 0x0000, + 0x682f, 0x0000, 0x6808, 0xa084, 0xffde, 0x680a, 0x2d00, 0xa080, + 0x0010, 0x2068, 0x2091, 0x8001, 0x0070, 0x19d8, 0x0078, 0x19c4, + 0x8211, 0x0040, 0x19df, 0x20a9, 0x0100, 0x0078, 0x19c4, 0x1078, + 0x173e, 0x007c, 0x78a0, 0xa06d, 0x00c0, 0x19ed, 0x2c00, 0x78a2, + 0x78a6, 0x609b, 0x0000, 0x0078, 0x19f9, 0x2c00, 0x689a, 0x609b, + 0x0000, 0x78a2, 0x2d00, 0x6002, 0x78a4, 0xad06, 0x00c0, 0x19f9, + 0x6002, 0x789c, 0x8001, 0x789e, 0x00c0, 0x1a05, 0x78a8, 0xa084, + 0x0000, 0x78aa, 0x78a4, 0x2060, 0xa006, 0x007c, 0xa02e, 0x2530, + 0x6118, 0xa184, 0x0060, 0x619e, 0x0040, 0x1a12, 0x0e7e, 0x1078, + 0x3199, 0x0e7f, 0x6592, 0x65a2, 0x6696, 0x66a6, 0x60ab, 0x0000, + 0x60af, 0x0000, 0x6710, 0x1078, 0x1758, 0x2091, 0x8000, 0x6808, + 0xa084, 0x0001, 0x0040, 0x1a34, 0x2091, 0x8001, 0x1078, 0x17ad, + 0x2091, 0x8000, 0x1078, 0x18a4, 0x2091, 0x8001, 0x78a3, 0x0000, + 0x78a7, 0x0000, 0x0078, 0x1a80, 0x6020, 0xa096, 0x0001, 0x00c0, + 0x1a3b, 0x8000, 0x6022, 0x6a10, 0x6814, 0x2091, 0x8001, 0xa202, + 0x0048, 0x1a4a, 0x0040, 0x1a4a, 0x2039, 0x0200, 0x1078, 0x1a81, + 0x0078, 0x1a80, 0x2c08, 0x2091, 0x8000, 0x6800, 0xa065, 0x0040, + 0x1a52, 0x6102, 0x6902, 0x00c0, 0x1a56, 0x6906, 0x2160, 0x6003, + 0x0000, 0x6810, 0x8000, 0x6812, 0x78b8, 0x8000, 0x78ba, 0x2091, + 0x8001, 0x6808, 0xa08c, 0x0040, 0x0040, 0x1a76, 0xa086, 0x0040, + 0x680a, 0x1078, 0x17bc, 0x017e, 0x007e, 0x6930, 0x2100, 0x810f, + 0xa105, 0x6832, 0x6934, 0x693a, 0x007f, 0x017f, 0x2091, 0x8000, + 0x1078, 0x1b49, 0x2091, 0x8001, 0x78a7, 0x0000, 0x78a3, 0x0000, + 0x007c, 0x6004, 0xa705, 0x6006, 0x2091, 0x8000, 0x1078, 0x18a4, + 0x2091, 0x8001, 0x78a4, 0xa065, 0x0040, 0x1a94, 0x6098, 0x78a6, + 0x609b, 0x0000, 0x0078, 0x1a84, 0x78a3, 0x0000, 0x78a7, 0x0000, + 0x007c, 0x7970, 0x7874, 0x8000, 0xa10a, 0x00c8, 0x1aa0, 0xa006, + 0x7876, 0x70d2, 0x7804, 0xa005, 0x0040, 0x1aae, 0x8001, 0x7806, + 0x00c0, 0x1aae, 0x0068, 0x1aae, 0x2091, 0x4080, 0x007c, 0x0068, + 0x1ac9, 0x2029, 0x0000, 0x786c, 0xa065, 0x0040, 0x1ac4, 0x1078, + 0x1aca, 0x0040, 0x1ac4, 0x057e, 0x1078, 0x1ae8, 0x057f, 0x00c0, + 0x1ac4, 0x8528, 0x0078, 0x1ab3, 0x85ff, 0x0040, 0x1ac9, 0x2091, + 0x4080, 0x007c, 0x2091, 0x8000, 0x7b84, 0x7988, 0x72d4, 0x0005, + 0x0005, 0x70d4, 0xa206, 0x00c0, 0x1ace, 0x2200, 0xa102, 0x00c0, + 0x1ade, 0x2300, 0x2091, 0x8001, 0xa005, 0x007c, 0x0048, 0x1ae4, + 0xa302, 0x2091, 0x8001, 0x007c, 0x8002, 0x2091, 0x8001, 0x007c, + 0x2091, 0x8000, 0x2071, 0x0020, 0x7004, 0xa005, 0x00c0, 0x1b3f, + 0x7008, 0x7208, 0xa206, 0x00c0, 0x1b3f, 0xa286, 0x0002, 0x00c0, + 0x1b3f, 0x2071, 0x0010, 0xa184, 0xff00, 0x0040, 0x1b08, 0x810f, + 0x810c, 0x810c, 0x8004, 0x8004, 0x8007, 0xa100, 0x0078, 0x1b0b, + 0x8107, 0x8004, 0x8004, 0x7a90, 0x7b8c, 0xa210, 0xa399, 0x0000, + 0x2009, 0x0018, 0x6024, 0xa005, 0x0040, 0x1b18, 0x2009, 0x0040, + 0x1078, 0x16d7, 0x0040, 0x1b31, 0x7894, 0x8000, 0x7896, 0xa086, + 0x0002, 0x00c0, 0x1b3f, 0x2091, 0x8000, 0x78af, 0x0003, 0x7897, + 0x0000, 0x7898, 0xa085, 0x0300, 0x789a, 0x2091, 0x8001, 0x0078, + 0x1b3f, 0x7897, 0x0000, 0x1078, 0x18ce, 0x7984, 0x7888, 0x8000, + 0xa10a, 0x00c8, 0x1b3c, 0xa006, 0x788a, 0x70d6, 0xa006, 0x2071, + 0x0010, 0x2091, 0x8001, 0x007c, 0x2009, 0x3868, 0x2091, 0x8000, + 0x200a, 0x0f7e, 0x2079, 0x0100, 0x2009, 0x3840, 0x2104, 0xa086, + 0x0000, 0x00c0, 0x1b62, 0x2009, 0x3812, 0x2104, 0xa005, 0x00c0, + 0x1b62, 0x7830, 0xa084, 0x00c0, 0x00c0, 0x1b62, 0x0018, 0x1b62, + 0x781b, 0x0044, 0x0f7f, 0x007c, 0x127e, 0x2091, 0x2300, 0x2071, + 0x3840, 0x2079, 0x0100, 0x2019, 0x305e, 0x20a1, 0x012b, 0x2304, + 0xa005, 0x0040, 0x1b7c, 0x789a, 0x8318, 0x23ac, 0x8318, 0x2398, + 0x53a6, 0x3318, 0x0078, 0x1b6f, 0x789b, 0x0020, 0x20a9, 0x0010, + 0x78af, 0x0000, 0x78af, 0x0220, 0x0070, 0x1b88, 0x0078, 0x1b80, + 0x7003, 0x0000, 0x1078, 0x1c87, 0x7004, 0xa084, 0x000f, 0xa085, + 0x6280, 0x7806, 0x780f, 0x9200, 0x7843, 0x00d8, 0x7853, 0x0080, + 0x780b, 0x0008, 0x7047, 0x387f, 0x7043, 0x0000, 0x127f, 0x2000, + 0x007c, 0xa18c, 0x000f, 0x2011, 0x0101, 0x2204, 0xa084, 0xfff0, + 0xa105, 0x2012, 0x1078, 0x1c87, 0x007c, 0x2011, 0x0101, 0x20a9, + 0x0009, 0x810b, 0x0070, 0x1bb6, 0x0078, 0x1bb1, 0xa18c, 0x0e00, + 0x2204, 0xa084, 0xf1ff, 0xa105, 0x2012, 0x007c, 0x2009, 0x0101, + 0x20a9, 0x0005, 0x8213, 0x0070, 0x1bc7, 0x0078, 0x1bc2, 0xa294, + 0x00e0, 0x2104, 0xa084, 0xff1f, 0xa205, 0x200a, 0x007c, 0x2011, + 0x0101, 0x20a9, 0x000c, 0x810b, 0x0070, 0x1bd8, 0x0078, 0x1bd3, + 0xa18c, 0xf000, 0x2204, 0xa084, 0x0fff, 0xa105, 0x2012, 0x007c, + 0x2011, 0x0102, 0x2204, 0xa084, 0xffcf, 0xa105, 0x2012, 0x007c, + 0x8103, 0x8003, 0xa080, 0x0020, 0x0c7e, 0x2061, 0x0100, 0x609a, + 0x62ac, 0x63ac, 0x0c7f, 0x007c, 0x8103, 0x8003, 0xa080, 0x0022, + 0x0c7e, 0x2061, 0x0100, 0x609a, 0x60a4, 0xa084, 0xffdf, 0x60ae, + 0x0c7f, 0x007c, 0x8103, 0x8003, 0xa080, 0x0022, 0x0c7e, 0x2061, + 0x0100, 0x609a, 0x60a4, 0xa085, 0x0020, 0x60ae, 0x0c7f, 0x007c, + 0x8103, 0x8003, 0xa080, 0x0020, 0x0c7e, 0x2061, 0x0100, 0x609a, + 0x60a4, 0x62ae, 0x2010, 0x60a4, 0x63ae, 0x2018, 0x0c7f, 0x007c, + 0x2091, 0x8000, 0x0c7e, 0x0e7e, 0x6818, 0xa005, 0x0040, 0x1c65, + 0x2061, 0x5c00, 0x1078, 0x1c6d, 0x0040, 0x1c53, 0x20a9, 0x0000, + 0x2061, 0x5b00, 0x0c7e, 0x1078, 0x1c6d, 0x0040, 0x1c3f, 0x0c7f, + 0x8c60, 0x0070, 0x1c3d, 0x0078, 0x1c32, 0x0078, 0x1c65, 0x007f, + 0xa082, 0x5b00, 0x2071, 0x3840, 0x70ba, 0x601c, 0xa085, 0x0800, + 0x601e, 0x71b6, 0x60a7, 0x0000, 0x2001, 0x0004, 0x70a2, 0x1078, + 0x1b44, 0x0078, 0x1c61, 0x2071, 0x3840, 0x601c, 0xa085, 0x0800, + 0x601e, 0x71b6, 0x60a7, 0x0000, 0x2001, 0x0006, 0x70a2, 0x1078, + 0x1b44, 0x2001, 0x0000, 0x0078, 0x1c67, 0x2001, 0x0001, 0x2091, + 0x8001, 0xa005, 0x0e7f, 0x0c7f, 0x007c, 0x2c04, 0xa005, 0x0040, + 0x1c84, 0x2060, 0x600c, 0xa306, 0x00c0, 0x1c81, 0x6008, 0xa206, + 0x00c0, 0x1c81, 0x6010, 0xa106, 0x00c0, 0x1c81, 0xa006, 0x0078, + 0x1c86, 0x6000, 0x0078, 0x1c6e, 0xa085, 0x0001, 0x007c, 0x2011, + 0x3841, 0x220c, 0xa18c, 0x000f, 0x2011, 0x013b, 0x2204, 0xa084, + 0x0100, 0x0040, 0x1c96, 0x2021, 0xff00, 0x2122, 0x007c, 0x0e7e, + 0x68e4, 0xa08c, 0x0020, 0x0040, 0x1ce5, 0xa084, 0x0006, 0x00c0, + 0x1ce5, 0x6010, 0x8007, 0xa084, 0x000f, 0x8003, 0x8003, 0x8003, + 0xa0f0, 0x3a80, 0x7004, 0xa084, 0x000a, 0x00c0, 0x1ce5, 0x7108, + 0xa194, 0xff00, 0x0040, 0x1ce5, 0xa18c, 0x00ff, 0x7104, 0xa084, + 0x0014, 0x00c0, 0x1cd2, 0x017e, 0x611c, 0xa18d, 0x0002, 0x611e, + 0x017f, 0xa085, 0x0014, 0x7006, 0x2001, 0x000c, 0xa106, 0x0040, + 0x1cce, 0x2100, 0x8003, 0x2008, 0x0078, 0x1ce2, 0x2009, 0x0019, + 0x0078, 0x1ce2, 0x2011, 0x0000, 0x7000, 0xa084, 0xdfff, 0x7002, + 0x7004, 0xa084, 0xffef, 0x7006, 0x017e, 0x611c, 0xa18d, 0x0002, + 0x611e, 0x017f, 0x2100, 0xa205, 0x700a, 0x0e7f, 0x007c, 0x0068, + 0x1ce7, 0x007e, 0x2071, 0x0000, 0x7018, 0xa084, 0x0001, 0x00c0, + 0x1cec, 0x007f, 0x2e08, 0x2071, 0x0010, 0x70ca, 0x007f, 0x70c6, + 0x70c3, 0x8002, 0x2071, 0x0000, 0x701b, 0x0001, 0x2091, 0x4080, + 0x007f, 0x2070, 0x007f, 0x0078, 0x1d03, 0x107e, 0x007e, 0x127e, + 0x2091, 0x2300, 0x7f3c, 0x7e58, 0x7c30, 0x7d38, 0xa594, 0x003f, + 0xa484, 0x4000, 0x0040, 0x1d1a, 0xa784, 0x007c, 0x00c0, 0x3022, + 0x1078, 0x1ce7, 0xa49c, 0x000f, 0xa382, 0x0004, 0x0050, 0x1d22, + 0x1078, 0x1ce7, 0x8507, 0xa084, 0x000f, 0x0079, 0x1d27, 0x21a1, + 0x2251, 0x2277, 0x24cf, 0x2787, 0x27cf, 0x2808, 0x2883, 0x28dd, + 0x2962, 0x1d4d, 0x1d37, 0x1fb8, 0x208d, 0x2766, 0x1d37, 0x1078, + 0x1ce7, 0x0018, 0x1d0a, 0x127f, 0x2091, 0x8001, 0x007f, 0x107f, + 0x007c, 0x7003, 0x0000, 0x703f, 0x0000, 0x7030, 0xa005, 0x0040, + 0x1d4b, 0x7033, 0x0000, 0x0018, 0x1d0a, 0x705c, 0xa005, 0x00c0, + 0x1df8, 0x70a0, 0xa084, 0x001f, 0x0079, 0x1d56, 0x1e18, 0x1d5e, + 0x1d6c, 0x1d8d, 0x1db3, 0x1ddf, 0x1ddd, 0x1d5e, 0x7808, 0xa084, + 0xfffd, 0x780a, 0x2009, 0x0046, 0x1078, 0x260f, 0x00c0, 0x1d6a, + 0x7003, 0x0004, 0x0078, 0x1d39, 0x1078, 0x2fe4, 0x00c0, 0x1d8b, + 0x70b4, 0x8007, 0x789b, 0x007e, 0x78aa, 0x789b, 0x0010, 0x78ab, + 0x000c, 0x789b, 0x0060, 0x78ab, 0x0001, 0x785b, 0x0004, 0x2009, + 0x00f7, 0x1078, 0x260d, 0x00c0, 0x1d8b, 0x7003, 0x0004, 0x70c3, + 0x000f, 0x7033, 0x3870, 0x0078, 0x1d39, 0x1078, 0x2fe4, 0x00c0, + 0x1db1, 0x71b4, 0x8107, 0x789b, 0x007e, 0x78aa, 0x789b, 0x0010, + 0xa18c, 0x0007, 0xa18d, 0x00c0, 0x79aa, 0x78ab, 0x0006, 0x789b, + 0x0060, 0x78ab, 0x0002, 0x785b, 0x0004, 0x2009, 0x00f7, 0x1078, + 0x260d, 0x00c0, 0x1db1, 0x7003, 0x0004, 0x70c3, 0x000f, 0x7033, + 0x3870, 0x0078, 0x1d39, 0x1078, 0x2fe4, 0x00c0, 0x1ddb, 0x71b4, + 0x8107, 0x789b, 0x007e, 0x78aa, 0x789b, 0x0010, 0xa18c, 0x0007, + 0xa18d, 0x00c0, 0x79aa, 0x78ab, 0x0020, 0x71b8, 0x79aa, 0x78ab, + 0x000d, 0x789b, 0x0060, 0x78ab, 0x0004, 0x785b, 0x0004, 0x2009, + 0x00f7, 0x1078, 0x260d, 0x00c0, 0x1ddb, 0x7003, 0x0004, 0x70c3, + 0x000f, 0x7033, 0x3870, 0x0078, 0x1d39, 0x0078, 0x1d8d, 0x1078, + 0x2fe4, 0x00c0, 0x1d39, 0x70bc, 0x2068, 0x789b, 0x0010, 0x6f10, + 0x1078, 0x2f11, 0x2c50, 0x6810, 0xa084, 0x001f, 0xa085, 0x0080, + 0x78aa, 0x6e18, 0x2041, 0x0001, 0x2001, 0x0004, 0x0078, 0x1f41, + 0x1078, 0x2fe4, 0x00c0, 0x1d39, 0x789b, 0x0010, 0x705c, 0x2068, + 0x6f10, 0x1078, 0x2f11, 0x2c50, 0x6008, 0xa085, 0x0010, 0x600a, + 0x6810, 0xa084, 0x001f, 0xa085, 0x0080, 0x78aa, 0x2031, 0x0020, + 0x2041, 0x0001, 0x1078, 0x304b, 0x2001, 0x0003, 0x0078, 0x1f2c, + 0x0018, 0x1d0a, 0x7440, 0xa485, 0x0000, 0x0040, 0x1e32, 0xa080, + 0x3880, 0x2030, 0x7144, 0x8108, 0xa12a, 0x0048, 0x1e29, 0x2009, + 0x3880, 0x2164, 0x6504, 0x85ff, 0x00c0, 0x1e3f, 0x8421, 0x00c0, + 0x1e23, 0x7146, 0x7003, 0x0000, 0x703f, 0x0000, 0x0078, 0x1d39, + 0x7640, 0xa6b0, 0x3880, 0x7144, 0x2600, 0x0078, 0x1e2e, 0x7146, + 0x2568, 0x2558, 0x753e, 0x2c50, 0x603c, 0xa085, 0x0000, 0x00c0, + 0x1e3c, 0x6708, 0x7736, 0xa784, 0x033f, 0x0040, 0x1e75, 0xa784, + 0x0021, 0x00c0, 0x1e3c, 0xa784, 0x0002, 0x0040, 0x1e5e, 0xa784, + 0x0004, 0x0040, 0x1e3c, 0xa7bc, 0xfffb, 0x670a, 0xa784, 0x0008, + 0x00c0, 0x1e3c, 0xa784, 0x0010, 0x00c0, 0x1e3c, 0xa184, 0x0200, + 0x00c0, 0x1e3c, 0xa784, 0x0100, 0x0040, 0x1e75, 0x6018, 0xa005, + 0x00c0, 0x1e3c, 0xa7bc, 0xfeff, 0x670a, 0x681f, 0x0000, 0x6e18, + 0xa684, 0x000e, 0x6118, 0x0040, 0x1e85, 0x601c, 0xa102, 0x0048, + 0x1e92, 0x0040, 0x1e92, 0x0078, 0x1e38, 0x81ff, 0x0040, 0x1e92, + 0x6828, 0x8007, 0xa084, 0x00ff, 0xa082, 0x0003, 0x0040, 0x1e92, + 0x00c0, 0x1e38, 0xa184, 0x0400, 0x00c0, 0x1ea1, 0x6130, 0xa18c, + 0xff00, 0x810f, 0x6030, 0xa084, 0xff00, 0xa105, 0x6032, 0x0078, + 0x1ea5, 0x6034, 0x603a, 0xa7bc, 0xfbff, 0xa784, 0x0080, 0x00c0, + 0x1eab, 0x700c, 0x6022, 0xa7bc, 0xff7f, 0x670a, 0x6b10, 0x8307, + 0xa084, 0x000f, 0x8003, 0x8003, 0x8003, 0xa080, 0x3a80, 0x2060, + 0x2048, 0x704a, 0x6000, 0x704e, 0x6004, 0x7052, 0x2a60, 0x0018, + 0x1d0a, 0x789b, 0x0010, 0xa046, 0x1078, 0x2fe4, 0x00c0, 0x1d39, + 0x6b10, 0xa39c, 0x001f, 0xa39d, 0x00c0, 0x704c, 0xa084, 0x8000, + 0x0040, 0x1ed6, 0xa684, 0x0001, 0x0040, 0x1ed8, 0xa39c, 0xffbf, + 0xa684, 0x0010, 0x0040, 0x1ede, 0xa39d, 0x0020, 0x7baa, 0x8840, + 0xa684, 0x000e, 0x00c0, 0x1ee9, 0xa7bd, 0x0010, 0x670a, 0x0078, + 0x1f2a, 0x714c, 0xa18c, 0x0800, 0x0040, 0x2b74, 0x2011, 0x0021, + 0x8004, 0x8004, 0x0048, 0x1f00, 0x2011, 0x0022, 0x8004, 0x0048, + 0x1f00, 0x2011, 0x0020, 0x8004, 0x0048, 0x1f00, 0x0040, 0x1f2a, + 0x7aaa, 0x8840, 0x1078, 0x2ffd, 0x6a10, 0x610c, 0x8108, 0xa18c, + 0x00ff, 0xa1e0, 0x5b00, 0x2c64, 0x8cff, 0x0040, 0x1f21, 0x6010, + 0xa206, 0x00c0, 0x1f0b, 0x60b4, 0x8001, 0x60b6, 0x00c0, 0x1f06, + 0x0c7e, 0x2a60, 0x6008, 0xa085, 0x0100, 0x600a, 0x0c7f, 0x0078, + 0x1e18, 0x1078, 0x2fe4, 0x00c0, 0x1d39, 0x2a60, 0x610e, 0x79aa, + 0x8840, 0x712e, 0x2001, 0x0001, 0x007e, 0x7150, 0xa184, 0x0018, + 0x0040, 0x1f40, 0xa184, 0x0010, 0x0040, 0x1f3a, 0x1078, 0x2d3d, + 0x00c0, 0x1f40, 0xa184, 0x0008, 0x0040, 0x1f40, 0x1078, 0x2c58, + 0x007f, 0x7002, 0xa68c, 0x0060, 0x88ff, 0x0040, 0x1f49, 0xa18d, + 0x0004, 0x795a, 0x69b2, 0x789b, 0x0060, 0x2800, 0x78aa, 0x789b, + 0x0061, 0x6814, 0xa085, 0x8000, 0x6816, 0x78aa, 0x157e, 0x137e, + 0x147e, 0x20a1, 0x012c, 0x789b, 0x0000, 0x8000, 0x80ac, 0xad80, + 0x000a, 0x2098, 0x53a6, 0x147f, 0x137f, 0x157f, 0x6810, 0x8007, + 0x789b, 0x007e, 0x78aa, 0x6d90, 0x7dd6, 0x7dde, 0x6e94, 0x7ed2, + 0x7eda, 0x7830, 0xa084, 0x00c0, 0x00c0, 0x1f78, 0x0098, 0x1f80, + 0x6008, 0xa084, 0xffef, 0x600a, 0x1078, 0x2ffd, 0x0078, 0x1d41, + 0x7200, 0xa284, 0x0007, 0xa086, 0x0001, 0x00c0, 0x1f8d, 0x781b, + 0x0049, 0x1078, 0x2ffd, 0x0078, 0x1f9e, 0x6ab0, 0xa295, 0x2000, + 0x7a5a, 0x781b, 0x0049, 0x1078, 0x2ffd, 0x7200, 0x2500, 0xa605, + 0x0040, 0x1f9e, 0xa284, 0x0007, 0x1079, 0x1fae, 0xad80, 0x0008, + 0x7032, 0xa284, 0x0007, 0xa086, 0x0001, 0x00c0, 0x1fac, 0x6018, + 0x8000, 0x601a, 0x1078, 0x2b4b, 0x0078, 0x1d39, 0x1fb6, 0x3376, + 0x3376, 0x3365, 0x3376, 0x1fb6, 0x1fb6, 0x1fb6, 0x1078, 0x1ce7, + 0x7808, 0xa084, 0xfffd, 0x780a, 0x0f7e, 0x2079, 0x3800, 0x7898, + 0x0f7f, 0xa084, 0x0001, 0x0040, 0x1fde, 0x70a0, 0xa086, 0x0001, + 0x00c0, 0x1fcd, 0x70a2, 0x0078, 0x2071, 0x70a0, 0xa086, 0x0005, + 0x00c0, 0x1fdc, 0x70bc, 0x2068, 0x6817, 0x0004, 0x6813, 0x0000, + 0x681c, 0xa085, 0x0008, 0x681e, 0x70a3, 0x0000, 0x157e, 0x2011, + 0x0004, 0x71a0, 0xa186, 0x0001, 0x0040, 0x2000, 0xa186, 0x0007, + 0x00c0, 0x1ff0, 0x2009, 0x382b, 0x200b, 0x0005, 0x0078, 0x2000, + 0x2009, 0x3813, 0x2104, 0x2009, 0x3812, 0x200a, 0x2009, 0x382b, + 0x200b, 0x0001, 0x70a3, 0x0000, 0x70a7, 0x0001, 0x0078, 0x2002, + 0x70a3, 0x0000, 0x1078, 0x314d, 0x20a9, 0x0010, 0x2039, 0x0000, + 0x1078, 0x2e16, 0xa7b8, 0x0100, 0x0070, 0x2010, 0x0078, 0x2008, + 0x7000, 0x2020, 0x0079, 0x2014, 0x2042, 0x202b, 0x202b, 0x201e, + 0x2042, 0x2042, 0x201c, 0x201c, 0x1078, 0x1ce7, 0x2021, 0x3857, + 0x2404, 0xa005, 0x0040, 0x202b, 0xad06, 0x00c0, 0x202b, 0x6800, + 0x2022, 0x0078, 0x203b, 0x681c, 0xa084, 0x0001, 0x00c0, 0x2037, + 0x6f10, 0x1078, 0x2f11, 0x1078, 0x2b06, 0x0078, 0x203b, 0x7054, + 0x2060, 0x6800, 0x6002, 0x6a16, 0x681c, 0xa085, 0x0008, 0x681e, + 0x1078, 0x18b6, 0x2021, 0x5c00, 0x1078, 0x2077, 0x2021, 0x3857, + 0x1078, 0x2077, 0x20a9, 0x0000, 0x2021, 0x5b00, 0x1078, 0x2077, + 0x8420, 0x0070, 0x2055, 0x0078, 0x204e, 0x1078, 0x2b55, 0x2061, + 0x3b00, 0x2021, 0x0002, 0x20a9, 0x0100, 0x6018, 0x6110, 0xa102, + 0x6012, 0x601b, 0x0000, 0xace0, 0x0010, 0x0070, 0x2069, 0x0078, + 0x205d, 0x2009, 0x382f, 0x200b, 0x0000, 0x8421, 0x00c0, 0x205b, + 0x157f, 0x7003, 0x0000, 0x703f, 0x0000, 0x0078, 0x1d39, 0x047e, + 0x2404, 0xa005, 0x0040, 0x2089, 0x2068, 0x6800, 0x007e, 0x6a16, + 0x681c, 0xa085, 0x0008, 0x681e, 0x1078, 0x18b6, 0x007f, 0x0078, + 0x2079, 0x047f, 0x2023, 0x0000, 0x007c, 0xa282, 0x0003, 0x0050, + 0x2093, 0x1078, 0x1ce7, 0x2300, 0x0079, 0x2096, 0x2099, 0x210c, + 0x211a, 0xa282, 0x0002, 0x0040, 0x209f, 0x1078, 0x1ce7, 0x70a0, + 0x70a3, 0x0000, 0x70c3, 0x0000, 0x0079, 0x20a6, 0x20ae, 0x20ae, + 0x20b0, 0x20e4, 0x2b7a, 0x20ae, 0x20e4, 0x20ae, 0x1078, 0x1ce7, + 0x77b4, 0x1078, 0x2e16, 0x77b4, 0xa7bc, 0x0f00, 0x1078, 0x2f11, + 0x6018, 0xa005, 0x0040, 0x20db, 0x2021, 0x5c00, 0x2009, 0x0004, + 0x2011, 0x0010, 0x1078, 0x216a, 0x0040, 0x20db, 0x157e, 0x20a9, + 0x0000, 0x2021, 0x5b00, 0x047e, 0x2009, 0x0004, 0x2011, 0x0010, + 0x1078, 0x216a, 0x047f, 0x0040, 0x20da, 0x8420, 0x0070, 0x20da, + 0x0078, 0x20cb, 0x157f, 0x8738, 0xa784, 0x001f, 0x00c0, 0x20b6, + 0x0078, 0x1d41, 0x0078, 0x1d41, 0x77b4, 0x1078, 0x2f11, 0x6018, + 0xa005, 0x0040, 0x210a, 0x2021, 0x5c00, 0x2009, 0x0005, 0x2011, + 0x0020, 0x1078, 0x216a, 0x0040, 0x210a, 0x157e, 0x20a9, 0x0000, + 0x2021, 0x5b00, 0x047e, 0x2009, 0x0005, 0x2011, 0x0020, 0x1078, + 0x216a, 0x047f, 0x0040, 0x2109, 0x8420, 0x0070, 0x2109, 0x0078, + 0x20fa, 0x157f, 0x0078, 0x1d41, 0x2200, 0x0079, 0x210f, 0x2112, + 0x2114, 0x2114, 0x1078, 0x1ce7, 0x70a3, 0x0000, 0x70a7, 0x0001, + 0x0078, 0x1d39, 0x2200, 0x0079, 0x211d, 0x2122, 0x2114, 0x2120, + 0x1078, 0x1ce7, 0x1078, 0x261c, 0x70a0, 0xa086, 0x0002, 0x00c0, + 0x2159, 0x77b4, 0x1078, 0x2e16, 0x77b4, 0xa7bc, 0x0f00, 0x1078, + 0x2f11, 0x6018, 0xa005, 0x0040, 0x2154, 0x2021, 0x5c00, 0x2009, + 0x0005, 0x2011, 0x0020, 0x1078, 0x216a, 0x0040, 0x2154, 0x157e, + 0x20a9, 0x0000, 0x2021, 0x5b00, 0x047e, 0x2009, 0x0005, 0x2011, + 0x0020, 0x1078, 0x216a, 0x047f, 0x0040, 0x2153, 0x8420, 0x0070, + 0x2153, 0x0078, 0x2144, 0x157f, 0x8738, 0xa784, 0x001f, 0x00c0, + 0x212f, 0x7000, 0xa086, 0x0001, 0x00c0, 0x2acd, 0x1078, 0x2b1e, + 0x6008, 0xa084, 0xffef, 0x600a, 0x1078, 0x2ac0, 0x0040, 0x2acd, + 0x0078, 0x1e18, 0x2404, 0xa005, 0x0040, 0x219d, 0x2068, 0x2d04, + 0x007e, 0x6810, 0xa706, 0x0040, 0x2179, 0x2d20, 0x007f, 0x0078, + 0x216b, 0x007f, 0x2022, 0x6916, 0x6814, 0xa086, 0x0050, 0x00c0, + 0x218c, 0x6817, 0x0006, 0x2200, 0xa086, 0x0010, 0x00c0, 0x218c, + 0x681c, 0xa084, 0xffef, 0x681e, 0x681c, 0xa205, 0x681e, 0x1078, + 0x18b6, 0x1078, 0x2b27, 0x6010, 0x8001, 0x6012, 0x6008, 0xa084, + 0xffef, 0x600a, 0x1078, 0x2b1e, 0x007c, 0xa085, 0x0001, 0x0078, + 0x219c, 0x2300, 0x0079, 0x21a4, 0x21a9, 0x21a7, 0x21ec, 0x1078, + 0x1ce7, 0x78e4, 0xa005, 0x00d0, 0x21cc, 0x0018, 0x21cc, 0x2008, + 0xa084, 0x0030, 0x00c0, 0x21b8, 0x781b, 0x0049, 0x0078, 0x1d39, + 0x78ec, 0xa084, 0x0003, 0x0040, 0x21b4, 0x2100, 0xa084, 0x0007, + 0x0079, 0x21c2, 0x21da, 0x21e0, 0x21d4, 0x21ca, 0x2fde, 0x2fde, + 0x21ca, 0x21e6, 0x1078, 0x1ce7, 0x7000, 0xa005, 0x0040, 0x1d41, + 0x2001, 0x0003, 0x0078, 0x24e3, 0x1078, 0x2df9, 0x781b, 0x0055, + 0x0078, 0x1d39, 0x1078, 0x2df9, 0x781b, 0x00dc, 0x0078, 0x1d39, + 0x1078, 0x2df9, 0x781b, 0x00e3, 0x0078, 0x1d39, 0x1078, 0x2df9, + 0x781b, 0x009d, 0x0078, 0x1d39, 0xa584, 0x000f, 0x00c0, 0x2216, + 0x1078, 0x261c, 0x7000, 0x0079, 0x21f5, 0x21fd, 0x220a, 0x21fd, + 0x2acd, 0x21ff, 0x2acd, 0x21fd, 0x21fd, 0x1078, 0x1ce7, 0x71a0, + 0x70a3, 0x0000, 0xa186, 0x0004, 0x00c0, 0x2208, 0x0078, 0x2b7a, + 0x0078, 0x2acd, 0x1078, 0x2b1e, 0x6008, 0xa084, 0xffef, 0x600a, + 0x1078, 0x2ac0, 0x0040, 0x2acd, 0x0078, 0x1e18, 0x78e4, 0xa005, + 0x00d0, 0x21cc, 0x0018, 0x21cc, 0x2008, 0xa084, 0x0030, 0x00c0, + 0x2225, 0x781b, 0x0049, 0x0078, 0x1d39, 0x78ec, 0xa084, 0x0003, + 0x0040, 0x2221, 0x2100, 0xa184, 0x0007, 0x0079, 0x222f, 0x223f, + 0x2245, 0x2239, 0x2237, 0x2fde, 0x2fde, 0x2237, 0x2fd6, 0x1078, + 0x1ce7, 0x1078, 0x2e01, 0x781b, 0x0055, 0x0078, 0x1d39, 0x1078, + 0x2e01, 0x781b, 0x00dc, 0x0078, 0x1d39, 0x1078, 0x2e01, 0x781b, + 0x00e3, 0x0078, 0x1d39, 0x1078, 0x2e01, 0x781b, 0x009d, 0x0078, + 0x1d39, 0x2300, 0x0079, 0x2254, 0x2259, 0x2257, 0x225b, 0x1078, + 0x1ce7, 0x0078, 0x2883, 0x6817, 0x0008, 0x78a3, 0x0000, 0x79e4, + 0xa184, 0x0030, 0x0040, 0x2883, 0x78ec, 0xa084, 0x0003, 0x0040, + 0x2883, 0xa184, 0x0007, 0x0079, 0x226d, 0x21da, 0x21e0, 0x21d4, + 0x2fb6, 0x2fde, 0x2fde, 0x2275, 0x2fd6, 0x1078, 0x1ce7, 0xa282, + 0x0005, 0x0050, 0x227d, 0x1078, 0x1ce7, 0x2300, 0x0079, 0x2280, + 0x2283, 0x24b7, 0x24c3, 0x2200, 0x0079, 0x2286, 0x228b, 0x228d, + 0x22a0, 0x228b, 0x249c, 0x1078, 0x1ce7, 0x789b, 0x0018, 0x78a8, + 0xa084, 0x00ff, 0xa082, 0x0020, 0x0048, 0x2dda, 0xa08a, 0x0004, + 0x00c8, 0x2dda, 0x0079, 0x229c, 0x2dda, 0x2dda, 0x2dda, 0x2d7c, + 0x789b, 0x0018, 0x79a8, 0xa184, 0x0080, 0x0040, 0x22b5, 0xa184, + 0x0018, 0x0040, 0x22b1, 0x0078, 0x2dda, 0x7000, 0xa005, 0x00c0, + 0x22ab, 0x2011, 0x0003, 0x0078, 0x2970, 0xa184, 0x00ff, 0xa08c, + 0x0080, 0x0040, 0x22e9, 0x7000, 0xa086, 0x0001, 0x00c0, 0x22c8, + 0x1078, 0x2b1e, 0x1078, 0x314d, 0x7034, 0x600a, 0x0078, 0x22cd, + 0x7000, 0xa086, 0x0003, 0x0040, 0x22c2, 0x7003, 0x0005, 0x2001, + 0x5c10, 0x2068, 0x703e, 0x7032, 0x157e, 0x20a9, 0x002f, 0x2003, + 0x0000, 0x8000, 0x0070, 0x22de, 0x0078, 0x22d7, 0x157f, 0x6813, + 0x0000, 0x68b3, 0x0700, 0x681f, 0x0800, 0x6823, 0x0003, 0x0078, + 0x2dda, 0xa08a, 0x0010, 0x00c8, 0x2dda, 0x0079, 0x22ef, 0x2301, + 0x22ff, 0x2317, 0x2319, 0x23ab, 0x2dda, 0x2dda, 0x23ad, 0x2dda, + 0x2dda, 0x2498, 0x2498, 0x2dda, 0x2dda, 0x2dda, 0x249a, 0x1078, + 0x1ce7, 0xa684, 0x1000, 0x0040, 0x230e, 0x2001, 0x0300, 0x8000, + 0x8000, 0x783a, 0x781b, 0x009a, 0x0078, 0x1d39, 0x6814, 0xa084, + 0x8000, 0x0040, 0x2315, 0x6817, 0x0003, 0x0078, 0x2fb6, 0x1078, + 0x1ce7, 0x691c, 0x691e, 0xa684, 0x1800, 0x00c0, 0x2333, 0x681c, + 0xa084, 0x0001, 0x00c0, 0x233b, 0x6814, 0xa086, 0x0008, 0x00c0, + 0x232b, 0x6817, 0x0000, 0xa684, 0x0400, 0x0040, 0x23a7, 0x781b, + 0x0058, 0x0078, 0x1d39, 0xa684, 0x1000, 0x0040, 0x233b, 0x781b, + 0x0058, 0x0078, 0x1d39, 0xa684, 0x0060, 0x0040, 0x23a3, 0xa684, + 0x0800, 0x0040, 0x23a3, 0xa684, 0x8000, 0x00c0, 0x2349, 0x0078, + 0x2363, 0xa6b4, 0x7fff, 0x7e5a, 0x6eb2, 0x789b, 0x0074, 0x7aac, + 0x79ac, 0x78ac, 0x801b, 0x00c8, 0x2356, 0x8000, 0xa084, 0x003f, + 0xa108, 0xa291, 0x0000, 0x6b94, 0x2100, 0xa302, 0x68ae, 0x6b90, + 0x2200, 0xa303, 0x68aa, 0xa684, 0x4000, 0x0040, 0x236b, 0xa6b4, + 0xbfff, 0x7e5a, 0x6eb2, 0x7000, 0xa086, 0x0003, 0x00c0, 0x2378, + 0x1078, 0x31c0, 0x1078, 0x3365, 0x781b, 0x0067, 0x0078, 0x1d39, + 0xa006, 0x1078, 0x3414, 0x6aac, 0x69a8, 0x6c94, 0x6b90, 0x2200, + 0xa105, 0x0040, 0x2387, 0x2200, 0xa422, 0x2100, 0xa31b, 0x7cd2, + 0x7bd6, 0x2300, 0xa405, 0x00c0, 0x2395, 0xa6b5, 0x4000, 0x7e5a, + 0x6eb2, 0x781b, 0x0067, 0x0078, 0x1d39, 0x781b, 0x0067, 0x2200, + 0xa115, 0x00c0, 0x239f, 0x1078, 0x3376, 0x0078, 0x1d39, 0x1078, + 0x339d, 0x0078, 0x1d39, 0x781b, 0x006a, 0x0078, 0x1d39, 0x781b, + 0x0058, 0x0078, 0x1d39, 0x1078, 0x1ce7, 0x0078, 0x240a, 0x691c, + 0xa184, 0x0100, 0x0040, 0x23c5, 0xa18c, 0xfeff, 0x691e, 0x0c7e, + 0x7048, 0x2060, 0x6000, 0xa084, 0xefff, 0x6002, 0x6004, 0xa084, + 0xfff5, 0x6006, 0x0c7f, 0x0078, 0x23f9, 0xa184, 0x0200, 0x0040, + 0x23f9, 0xa18c, 0xfdff, 0x691e, 0x0c7e, 0x7048, 0x2060, 0x6000, + 0xa084, 0xdfff, 0x6002, 0x6004, 0xa084, 0xffef, 0x6006, 0x2008, + 0x2c48, 0x0c7f, 0xa184, 0x0008, 0x0040, 0x23f9, 0x1078, 0x2f0d, + 0x1078, 0x2c58, 0x88ff, 0x0040, 0x23f9, 0x789b, 0x0060, 0x2800, + 0x78aa, 0x7e58, 0xa6b5, 0x0004, 0x7e5a, 0xa684, 0x0400, 0x00c0, + 0x23f5, 0x781b, 0x0055, 0x0078, 0x1d39, 0x781b, 0x0069, 0x0078, + 0x1d39, 0x7e58, 0xa684, 0x0400, 0x00c0, 0x2402, 0x781b, 0x0058, + 0x0078, 0x1d39, 0x781b, 0x006a, 0x0078, 0x1d39, 0x0078, 0x2de0, + 0x0078, 0x2de0, 0x2019, 0x0000, 0x7990, 0xa18c, 0x0007, 0x0040, + 0x2408, 0x789b, 0x0010, 0x78a8, 0xa094, 0x00ff, 0xa286, 0x0001, + 0x00c0, 0x242d, 0x2300, 0x7ca8, 0xa400, 0x2018, 0xa102, 0x0040, + 0x2425, 0x0048, 0x2425, 0x0078, 0x2427, 0x0078, 0x23af, 0x24a8, + 0x7aa8, 0x00f0, 0x2427, 0x0078, 0x2413, 0xa284, 0x00f0, 0xa086, + 0x0020, 0x00c0, 0x2489, 0x8318, 0x8318, 0x2300, 0xa102, 0x0040, + 0x243d, 0x0048, 0x243d, 0x0078, 0x2486, 0xa286, 0x0023, 0x0040, + 0x2408, 0x6818, 0xa084, 0xfff1, 0x681a, 0x7e58, 0xa684, 0xfff1, + 0xa085, 0x0010, 0x2030, 0x7e5a, 0x6008, 0xa085, 0x0010, 0x600a, + 0x0c7e, 0x7048, 0x2060, 0x6004, 0x2008, 0x2c48, 0x0c7f, 0xa184, + 0x0010, 0x0040, 0x2461, 0x1078, 0x2f0d, 0x1078, 0x2d3d, 0x0078, + 0x2470, 0x0c7e, 0x7048, 0x2060, 0x6004, 0x2008, 0x2c48, 0x0c7f, + 0xa184, 0x0008, 0x0040, 0x23f9, 0x1078, 0x2f0d, 0x1078, 0x2c58, + 0x88ff, 0x0040, 0x23f9, 0x789b, 0x0060, 0x2800, 0x78aa, 0xa6b5, + 0x0004, 0x7e5a, 0xa684, 0x0400, 0x00c0, 0x2482, 0x781b, 0x0055, + 0x0078, 0x1d39, 0x781b, 0x0069, 0x0078, 0x1d39, 0x7aa8, 0x0078, + 0x2413, 0x8318, 0x2300, 0xa102, 0x0040, 0x2492, 0x0048, 0x2492, + 0x0078, 0x2413, 0xa284, 0x0080, 0x00c0, 0x2de6, 0x0078, 0x2de0, + 0x0078, 0x2de6, 0x0078, 0x2dda, 0x789b, 0x0018, 0x78a8, 0xa084, + 0x00ff, 0xa08e, 0x0001, 0x0040, 0x24a7, 0x1078, 0x1ce7, 0x7aa8, + 0xa294, 0x00ff, 0x78a8, 0xa084, 0x00ff, 0xa08a, 0x0004, 0x00c8, + 0x2dda, 0x0079, 0x24b3, 0x2dda, 0x2bab, 0x2dda, 0x2cd8, 0xa282, + 0x0000, 0x00c0, 0x24bd, 0x1078, 0x1ce7, 0x1078, 0x2df9, 0x781b, + 0x0069, 0x0078, 0x1d39, 0xa282, 0x0003, 0x00c0, 0x24c9, 0x1078, + 0x1ce7, 0x1078, 0x2e09, 0x781b, 0x0069, 0x0078, 0x1d39, 0xa282, + 0x0004, 0x0050, 0x24d5, 0x1078, 0x1ce7, 0x2300, 0x0079, 0x24d8, + 0x24db, 0x25c6, 0x25f7, 0xa286, 0x0003, 0x0040, 0x24e1, 0x1078, + 0x1ce7, 0x2001, 0x0000, 0x703a, 0x7000, 0xa084, 0x0007, 0x0079, + 0x24e9, 0x24f1, 0x24f3, 0x24f3, 0x2703, 0x274c, 0x26cd, 0x24f1, + 0x24f1, 0x1078, 0x1ce7, 0xa684, 0x1000, 0x00c0, 0x24fb, 0x1078, + 0x314d, 0x0040, 0x25a0, 0x7868, 0xa08c, 0x00ff, 0x0040, 0x2557, + 0xa186, 0x0008, 0x00c0, 0x2512, 0x6008, 0xa084, 0xffef, 0x600a, + 0x1078, 0x2ac0, 0x0040, 0x2557, 0x1078, 0x2b1e, 0x1078, 0x314d, + 0x0078, 0x253e, 0xa186, 0x0028, 0x00c0, 0x2557, 0x1078, 0x314d, + 0x6008, 0xa084, 0xffef, 0x600a, 0x1078, 0x2b34, 0x6018, 0xa005, + 0x0040, 0x253e, 0x8001, 0x601a, 0xa005, 0x0040, 0x2534, 0x8001, + 0xa005, 0x0040, 0x2534, 0x601e, 0x0078, 0x253e, 0x6813, 0x0028, + 0x6817, 0x0000, 0x0078, 0x25b5, 0x6030, 0xa084, 0x00ff, 0xa005, + 0x0040, 0x252e, 0x6008, 0xa085, 0x0200, 0x600a, 0x681c, 0xa084, + 0x0001, 0x0040, 0x1d41, 0x681c, 0xa084, 0xfffe, 0x681e, 0x7054, + 0x0c7e, 0x2060, 0x6800, 0x6002, 0x0c7f, 0x6004, 0x6802, 0xa005, + 0x2d00, 0x00c0, 0x2554, 0x6002, 0x6006, 0x0078, 0x1d41, 0x017e, + 0x1078, 0x261c, 0x017f, 0xa684, 0xdf00, 0x681a, 0x6827, 0x0000, + 0x6f10, 0x81ff, 0x0040, 0x25a0, 0xa186, 0x0002, 0x00c0, 0x2598, + 0xa684, 0x0800, 0x00c0, 0x2574, 0xa684, 0x0060, 0x0040, 0x2574, + 0x78d8, 0x7adc, 0x682e, 0x6a2a, 0x8717, 0xa294, 0x000f, 0x8213, + 0x8213, 0x8213, 0xa290, 0x3a80, 0xa290, 0x0000, 0x221c, 0xa384, + 0x0100, 0x00c0, 0x2585, 0x0078, 0x258b, 0x8210, 0x2204, 0xa085, + 0x0018, 0x2012, 0x8211, 0xa384, 0x0400, 0x0040, 0x2598, 0x689c, + 0xa084, 0x0100, 0x00c0, 0x2598, 0x1078, 0x268c, 0x0078, 0x1d41, + 0xa186, 0x0018, 0x0040, 0x25a0, 0xa186, 0x0014, 0x0040, 0x1d41, + 0x6912, 0x6814, 0xa084, 0x8000, 0x0040, 0x25a8, 0x7038, 0x6816, + 0xa68c, 0xdf00, 0x691a, 0x1078, 0x2b0d, 0x1078, 0x2b1e, 0x00c0, + 0x25b5, 0x6008, 0xa084, 0xffef, 0x600a, 0x681c, 0xa084, 0x0001, + 0x00c0, 0x25be, 0x1078, 0x2b06, 0x0078, 0x25c2, 0x7054, 0x2060, + 0x6800, 0x6002, 0x1078, 0x18b6, 0x0078, 0x1d41, 0xa282, 0x0004, + 0x0048, 0x25cc, 0x1078, 0x1ce7, 0x2200, 0x0079, 0x25cf, 0x25d3, + 0x25d5, 0x25e2, 0x25d5, 0x1078, 0x1ce7, 0x7000, 0xa086, 0x0005, + 0x0040, 0x25de, 0x1078, 0x2df9, 0x781b, 0x0069, 0x781b, 0x006a, + 0x0078, 0x1d39, 0x7890, 0x8007, 0x8001, 0xa084, 0x0007, 0xa080, + 0x0018, 0x789a, 0x79a8, 0xa18c, 0x00ff, 0xa186, 0x0003, 0x0040, + 0x25f3, 0x0078, 0x2dda, 0x781b, 0x006a, 0x0078, 0x1d39, 0x681c, + 0xa085, 0x0004, 0x681e, 0x82ff, 0x00c0, 0x2602, 0x1078, 0x2df9, + 0x0078, 0x2609, 0x8211, 0x0040, 0x2607, 0x1078, 0x1ce7, 0x1078, + 0x2e09, 0x781b, 0x0069, 0x0078, 0x1d39, 0x1078, 0x2ffd, 0x7830, + 0xa084, 0x00c0, 0x00c0, 0x2619, 0x0018, 0x2619, 0x791a, 0xa006, + 0x007c, 0xa085, 0x0001, 0x007c, 0xa684, 0x0060, 0x00c0, 0x2626, + 0x682f, 0x0000, 0x682b, 0x0000, 0x0078, 0x268b, 0xa684, 0x0800, + 0x00c0, 0x2635, 0x68b0, 0xa084, 0x4800, 0xa635, 0xa684, 0x0800, + 0x00c0, 0x2635, 0x1078, 0x314d, 0x007c, 0xa684, 0x0020, 0x0040, + 0x265f, 0x78d0, 0x8003, 0x00c8, 0x2643, 0xa006, 0x1078, 0x3414, + 0x78d4, 0x1078, 0x3479, 0xa684, 0x4000, 0x0040, 0x264d, 0x682f, + 0x0000, 0x682b, 0x0000, 0x0078, 0x2632, 0x68b0, 0xa084, 0x4800, + 0xa635, 0xa684, 0x4000, 0x00c0, 0x2647, 0x7038, 0xa005, 0x00c0, + 0x2659, 0x79d8, 0x7adc, 0x692e, 0x6a2a, 0x0078, 0x2632, 0xa684, + 0x4000, 0x0040, 0x2669, 0x682f, 0x0000, 0x682b, 0x0000, 0x0078, + 0x2632, 0x68b0, 0xa084, 0x4800, 0xa635, 0xa684, 0x4000, 0x00c0, + 0x2663, 0x7038, 0xa005, 0x00c0, 0x2675, 0x79d8, 0x7adc, 0x78d0, + 0x80f3, 0x00c8, 0x267c, 0x8000, 0xa084, 0x003f, 0xa108, 0xa291, + 0x0000, 0x692e, 0x6a2a, 0x2100, 0xa205, 0x00c0, 0x2689, 0x0078, + 0x2632, 0x1078, 0x3414, 0x007c, 0xa384, 0x0200, 0x0040, 0x2694, + 0x6008, 0xa085, 0x0002, 0x600a, 0x6817, 0x0006, 0x6a28, 0x692c, + 0x6a3a, 0x693e, 0x682b, 0x0300, 0x682f, 0x0000, 0x6833, 0x2000, + 0x6893, 0x0000, 0x6897, 0x0020, 0x7000, 0x0079, 0x26a7, 0x26af, + 0x26b1, 0x26ba, 0x26af, 0x26af, 0x26af, 0x26af, 0x26af, 0x1078, + 0x1ce7, 0x681c, 0xa084, 0x0001, 0x00c0, 0x26ba, 0x1078, 0x2b06, + 0x0078, 0x26c0, 0x7054, 0x2c50, 0x2060, 0x6800, 0x6002, 0x2a60, + 0x2021, 0x3857, 0x2404, 0xa005, 0x0040, 0x26c9, 0x2020, 0x0078, + 0x26c2, 0x2d22, 0x206b, 0x0000, 0x007c, 0x77b4, 0x1078, 0x2e16, + 0xa7bc, 0x0f00, 0x1078, 0x2f11, 0x6018, 0xa005, 0x0040, 0x26fc, + 0x0d7e, 0x2001, 0x5c10, 0x2068, 0x0d7f, 0x2021, 0x5c00, 0x2009, + 0x0004, 0x2011, 0x0010, 0x1078, 0x216a, 0x0040, 0x26fc, 0x157e, + 0x20a9, 0x0000, 0x2021, 0x5b00, 0x047e, 0x2009, 0x0004, 0x2011, + 0x0010, 0x1078, 0x216a, 0x047f, 0x0040, 0x26fb, 0x8420, 0x0070, + 0x26fb, 0x0078, 0x26ec, 0x157f, 0x8738, 0xa784, 0x001f, 0x00c0, + 0x26d2, 0x0078, 0x1d41, 0x1078, 0x2b0d, 0x1078, 0x2b1e, 0x6827, + 0x0000, 0x789b, 0x000e, 0x6f10, 0x1078, 0x344a, 0x017e, 0xad88, + 0x0010, 0xa188, 0x0006, 0x2104, 0x017f, 0x8007, 0xa084, 0x00ff, + 0xa082, 0x0047, 0x0040, 0x271e, 0x0078, 0x272f, 0x0c7e, 0x6810, + 0x8007, 0xa084, 0x000f, 0x8003, 0x8003, 0x8003, 0xa0e0, 0x3a80, + 0x6004, 0xa084, 0xfff5, 0x6006, 0x0c7f, 0x1078, 0x2f6b, 0x6813, + 0x0002, 0xa684, 0x0800, 0x0040, 0x2739, 0x6918, 0xa18d, 0x2000, + 0x691a, 0x6814, 0xa084, 0x8000, 0x0040, 0x2740, 0x6817, 0x0000, + 0x2021, 0x3857, 0x6800, 0x2022, 0x6a38, 0x693c, 0x6a2a, 0x692e, + 0x1078, 0x18b6, 0x0078, 0x1d41, 0x1078, 0x261c, 0x6827, 0x0000, + 0x789b, 0x000e, 0x6f10, 0x1078, 0x3002, 0xa08c, 0x00ff, 0x6912, + 0x6814, 0xa084, 0x8000, 0x0040, 0x275f, 0x7038, 0x6816, 0xa68c, + 0xdf00, 0x691a, 0x70a3, 0x0000, 0x0078, 0x1d41, 0xa006, 0x1078, + 0x314d, 0x6813, 0x0000, 0x6817, 0x0001, 0xa68c, 0xdf00, 0x691a, + 0x6827, 0x0000, 0x7000, 0x0079, 0x2775, 0x277d, 0x277f, 0x277f, + 0x2781, 0x2781, 0x2781, 0x277d, 0x277d, 0x1078, 0x1ce7, 0x1078, + 0x2b1e, 0x6008, 0xa084, 0xffef, 0x600a, 0x0078, 0x2ad8, 0x2300, + 0x0079, 0x278a, 0x278d, 0x278f, 0x27cd, 0x1078, 0x1ce7, 0x7000, + 0x0079, 0x2792, 0x279a, 0x279c, 0x279c, 0x27a7, 0x279c, 0x27ae, + 0x279a, 0x279a, 0x1078, 0x1ce7, 0xa684, 0x2000, 0x00c0, 0x27a7, + 0xa6b5, 0x2000, 0x7e5a, 0x1078, 0x3376, 0x0078, 0x2fb6, 0x6814, + 0xa084, 0x8000, 0x0040, 0x27ae, 0x6817, 0x0007, 0x2009, 0x3818, + 0x210c, 0xa186, 0x0000, 0x0040, 0x27c3, 0xa186, 0x0001, 0x0040, + 0x27c7, 0x2009, 0x382b, 0x200b, 0x000b, 0x70a3, 0x0001, 0x781b, + 0x0046, 0x0078, 0x1d39, 0x781b, 0x00dd, 0x0078, 0x1d39, 0x2009, + 0x382b, 0x200b, 0x000a, 0x0078, 0x1d39, 0x1078, 0x1ce7, 0x2300, + 0x0079, 0x27d2, 0x27d5, 0x27d7, 0x27fa, 0x1078, 0x1ce7, 0x7000, + 0x0079, 0x27da, 0x27e2, 0x27e4, 0x27e4, 0x27ef, 0x27e4, 0x27f6, + 0x27e2, 0x27e2, 0x1078, 0x1ce7, 0xa684, 0x2000, 0x00c0, 0x27ef, + 0xa6b5, 0x2000, 0x7e5a, 0x1078, 0x3376, 0x0078, 0x2fb6, 0x6814, + 0xa084, 0x8000, 0x0040, 0x27f6, 0x6817, 0x0007, 0x781b, 0x00e4, + 0x0078, 0x1d39, 0x681c, 0xa085, 0x0004, 0x681e, 0x1078, 0x2f6b, + 0xa6b5, 0x0800, 0x1078, 0x2df9, 0x781b, 0x0069, 0x0078, 0x1d39, + 0x2300, 0x0079, 0x280b, 0x280e, 0x2810, 0x2812, 0x1078, 0x1ce7, + 0x1078, 0x1ce7, 0xa684, 0x0400, 0x00c0, 0x2831, 0x782b, 0x3009, + 0x789b, 0x0060, 0x78ab, 0x0000, 0xa684, 0xfffb, 0x785a, 0x79e4, + 0xa184, 0x0020, 0x0040, 0x2829, 0x78ec, 0xa084, 0x0003, 0x00c0, + 0x282d, 0x2001, 0x0014, 0x0078, 0x24e3, 0xa184, 0x0007, 0x0079, + 0x2869, 0x7a90, 0xa294, 0x0007, 0x789b, 0x0060, 0x79a8, 0x81ff, + 0x0040, 0x2867, 0x789b, 0x0010, 0x7ba8, 0xa384, 0x0001, 0x00c0, + 0x2858, 0x7ba8, 0x7ba8, 0xa386, 0x0001, 0x00c0, 0x284b, 0x2009, + 0xfff7, 0x0078, 0x2851, 0xa386, 0x0003, 0x00c0, 0x2858, 0x2009, + 0xffef, 0x0c7e, 0x7048, 0x2060, 0x6004, 0xa104, 0x6006, 0x0c7f, + 0x789b, 0x0060, 0x78ab, 0x0000, 0xa684, 0xfffb, 0x785a, 0x782b, + 0x3009, 0x691c, 0xa18c, 0xfdff, 0xa18c, 0xfeff, 0x691e, 0x0078, + 0x2fb6, 0x21da, 0x21e0, 0x2873, 0x287b, 0x2871, 0x2871, 0x2871, + 0x2fb6, 0x1078, 0x1ce7, 0x691c, 0xa18c, 0xfdff, 0xa18c, 0xfeff, + 0x691e, 0x0078, 0x2fbe, 0x691c, 0xa18c, 0xfdff, 0xa18c, 0xfeff, + 0x691e, 0x0078, 0x2fb6, 0x79e4, 0xa184, 0x0030, 0x0040, 0x288d, + 0x78ec, 0xa084, 0x0003, 0x00c0, 0x2895, 0x6814, 0xa085, 0x8000, + 0x6816, 0x2001, 0x0014, 0x0078, 0x24e3, 0xa184, 0x0007, 0x0079, + 0x2899, 0x2fb6, 0x2fb6, 0x28a1, 0x2fb6, 0x2fde, 0x2fde, 0x2fb6, + 0x2fb6, 0xa684, 0x0400, 0x00c0, 0x28d2, 0x681c, 0xa084, 0x0001, + 0x0040, 0x2fbe, 0xa68c, 0x2060, 0xa18c, 0xfffb, 0x795a, 0x69b2, + 0x789b, 0x0060, 0x78ab, 0x0000, 0x789b, 0x0061, 0x6814, 0xa085, + 0x8000, 0x6816, 0x78aa, 0x157e, 0x137e, 0x147e, 0x20a1, 0x012c, + 0x789b, 0x0000, 0x8000, 0x80ac, 0xad80, 0x000a, 0x2098, 0x53a6, + 0x147f, 0x137f, 0x157f, 0x6810, 0x8007, 0x789b, 0x007e, 0x78aa, + 0x0078, 0x2fbe, 0x6814, 0xa084, 0x8000, 0x0040, 0x28d9, 0x6817, + 0x0008, 0x781b, 0x00d8, 0x0078, 0x1d39, 0x2300, 0x0079, 0x28e0, + 0x28e5, 0x2960, 0x28e3, 0x1078, 0x1ce7, 0x7000, 0xa084, 0x0007, + 0x0079, 0x28ea, 0x28f2, 0x28f4, 0x2910, 0x28f2, 0x28f2, 0x26cd, + 0x28f2, 0x28f2, 0x1078, 0x1ce7, 0x691c, 0xa18d, 0x0001, 0x691e, + 0x6800, 0x6006, 0xa005, 0x00c0, 0x28fe, 0x6002, 0x6818, 0xa084, + 0x000e, 0x0040, 0x290a, 0x7014, 0x68b6, 0x712c, 0xa188, 0x5b00, + 0x0078, 0x290c, 0x2009, 0x5c00, 0x2104, 0x6802, 0x2d0a, 0x7156, + 0x6eb2, 0xa684, 0x0060, 0x0040, 0x295e, 0xa684, 0x0800, 0x00c0, + 0x2922, 0xa684, 0x7fff, 0x68b2, 0x6890, 0x6894, 0x1078, 0x314d, + 0x0078, 0x295e, 0xa684, 0x0020, 0x0040, 0x2934, 0xa006, 0x1078, + 0x3414, 0x78d0, 0x8003, 0x00c8, 0x2930, 0x78d4, 0x1078, 0x3479, + 0x79d8, 0x7adc, 0x0078, 0x2938, 0x1078, 0x2f1e, 0x1078, 0x3414, + 0xa684, 0x8000, 0x0040, 0x295e, 0xa684, 0x7fff, 0x68b2, 0x789b, + 0x0074, 0x1078, 0x3002, 0x2010, 0x1078, 0x3002, 0x2008, 0xa684, + 0x0020, 0x00c0, 0x2956, 0x1078, 0x3002, 0x801b, 0x00c8, 0x2951, + 0x8000, 0xa084, 0x003f, 0xa108, 0xa291, 0x0000, 0x6b94, 0x2100, + 0xa302, 0x68ae, 0x6b90, 0x2200, 0xa303, 0x68aa, 0x0078, 0x1d41, + 0x0078, 0x2de6, 0x7033, 0x0000, 0xa282, 0x0005, 0x0050, 0x296a, + 0x1078, 0x1ce7, 0x2300, 0x0079, 0x296d, 0x2970, 0x297a, 0x299d, + 0x2200, 0x0079, 0x2973, 0x2978, 0x2de6, 0x2978, 0x29c6, 0x2a17, + 0x1078, 0x1ce7, 0x7000, 0xa086, 0x0001, 0x00c0, 0x2987, 0x1078, + 0x2b1e, 0x1078, 0x314d, 0x7034, 0x600a, 0x0078, 0x298c, 0x7000, + 0xa086, 0x0003, 0x0040, 0x2981, 0x7003, 0x0005, 0x2001, 0x5c10, + 0x2068, 0x703e, 0x7032, 0x2200, 0x0079, 0x2996, 0x2de6, 0x299b, + 0x29c6, 0x299b, 0x2de6, 0x1078, 0x1ce7, 0x7000, 0xa086, 0x0001, + 0x00c0, 0x29aa, 0x1078, 0x2b1e, 0x1078, 0x314d, 0x7034, 0x600a, + 0x0078, 0x29af, 0x7000, 0xa086, 0x0003, 0x0040, 0x29a4, 0x7003, + 0x0005, 0x2001, 0x5c10, 0x2068, 0x703e, 0x7032, 0x2200, 0x0079, + 0x29b9, 0x29c0, 0x29be, 0x29c0, 0x29be, 0x29c0, 0x1078, 0x1ce7, + 0x1078, 0x2e09, 0x781b, 0x0069, 0x0078, 0x1d39, 0x7000, 0xa086, + 0x0001, 0x00c0, 0x29d3, 0x1078, 0x2b1e, 0x1078, 0x314d, 0x7034, + 0x600a, 0x0078, 0x29d8, 0x7000, 0xa086, 0x0003, 0x0040, 0x29cd, + 0x7003, 0x0002, 0x7a80, 0xa294, 0x0f00, 0x789b, 0x0018, 0x7ca8, + 0xa484, 0x001f, 0xa215, 0x2069, 0x5c00, 0x2d04, 0x2d08, 0x7156, + 0x2068, 0xa005, 0x0040, 0x29f3, 0x6810, 0xa206, 0x0040, 0x2a0c, + 0x6800, 0x0078, 0x29e6, 0x7003, 0x0005, 0x2001, 0x5c10, 0x2068, + 0x703e, 0x7032, 0x157e, 0x20a9, 0x002f, 0x2003, 0x0000, 0x8000, + 0x0070, 0x2a04, 0x0078, 0x29fd, 0x157f, 0x6a12, 0x68b3, 0x0700, + 0x681f, 0x0800, 0x6823, 0x0003, 0x6eb0, 0x7e5a, 0x681c, 0xa084, + 0x0c00, 0x0040, 0x2a6d, 0x1078, 0x2e01, 0x0078, 0x2a6d, 0x7000, + 0xa086, 0x0001, 0x00c0, 0x2a24, 0x1078, 0x2b1e, 0x1078, 0x314d, + 0x7034, 0x600a, 0x0078, 0x2a29, 0x7000, 0xa086, 0x0003, 0x0040, + 0x2a1e, 0x7003, 0x0002, 0x7a80, 0xa294, 0x0f00, 0x789b, 0x0018, + 0x7ca8, 0xa484, 0x001f, 0xa215, 0x79a8, 0x79a8, 0xa18c, 0x00ff, + 0xa1e8, 0x5b00, 0x2d04, 0x2d08, 0x7156, 0x2068, 0xa005, 0x0040, + 0x2a48, 0x6810, 0xa206, 0x0040, 0x2a61, 0x6800, 0x0078, 0x2a3b, + 0x7003, 0x0005, 0x2001, 0x5c10, 0x2068, 0x703e, 0x7032, 0x157e, + 0x20a9, 0x002f, 0x2003, 0x0000, 0x8000, 0x0070, 0x2a59, 0x0078, + 0x2a52, 0x157f, 0x6a12, 0x68b3, 0x0700, 0x681f, 0x0800, 0x6823, + 0x0003, 0x6eb0, 0x7e5a, 0x681c, 0xa084, 0x0c00, 0x0040, 0x2a6d, + 0x1078, 0x2dfd, 0x7e58, 0x0078, 0x2a6d, 0x027e, 0x8207, 0xa084, + 0x000f, 0x8003, 0x8003, 0x8003, 0xa080, 0x3a80, 0x2060, 0x704a, + 0x6000, 0x704e, 0x6004, 0x7052, 0xa684, 0x0060, 0x0040, 0x2aa4, + 0x6b94, 0x6c90, 0x69a8, 0x68ac, 0xa105, 0x00c0, 0x2a92, 0x7bd2, + 0x7bda, 0x7cd6, 0x7cde, 0xa6b4, 0xb7ff, 0x7e5a, 0x1078, 0x3376, + 0x0078, 0x2aa4, 0x68ac, 0xa31a, 0x2100, 0xa423, 0x2400, 0xa305, + 0x0040, 0x2aa4, 0x7bd2, 0x7bda, 0x7cd6, 0x7cde, 0x68ac, 0xa6b4, + 0xbfff, 0x7e5a, 0x1078, 0x339d, 0x077f, 0x1078, 0x2f11, 0x2009, + 0x006a, 0xa684, 0x0008, 0x0040, 0x2aaf, 0x2009, 0x0069, 0xa6b5, + 0x2000, 0x7e5a, 0x791a, 0x2d00, 0x703e, 0x8207, 0xa084, 0x000f, + 0x8003, 0x8003, 0x8003, 0xa080, 0x3a80, 0x2048, 0x0078, 0x1d39, + 0x6020, 0xa005, 0x0040, 0x2acc, 0x8001, 0x6022, 0x6008, 0xa085, + 0x0008, 0x600a, 0x7010, 0x6026, 0x007c, 0xa006, 0x1078, 0x314d, + 0x6813, 0x0000, 0x6817, 0x0001, 0x681f, 0x0040, 0x681b, 0x0100, + 0x7000, 0xa084, 0x0007, 0x0079, 0x2add, 0x2ae5, 0x2ae7, 0x2ae7, + 0x2b02, 0x2aef, 0x2ae5, 0x2ae5, 0x2ae5, 0x1078, 0x1ce7, 0x1078, + 0x2b0d, 0x1078, 0x2b06, 0x1078, 0x18b6, 0x0078, 0x1d41, 0x70a0, + 0x70a3, 0x0000, 0x0079, 0x2af4, 0x2afe, 0x2afe, 0x2afc, 0x2afc, + 0x2afc, 0x2afe, 0x2afc, 0x2afe, 0x0079, 0x20a6, 0x70a3, 0x0000, + 0x0078, 0x1d41, 0x6817, 0x0000, 0x0078, 0x2703, 0x6800, 0xa005, + 0x00c0, 0x2b0b, 0x6002, 0x6006, 0x007c, 0x1078, 0x2b27, 0x6010, + 0xa005, 0x0040, 0x2b18, 0x8001, 0x00d0, 0x2b18, 0x1078, 0x1ce7, + 0x6012, 0x6008, 0xa084, 0xffef, 0x600a, 0x007c, 0x1078, 0x2b34, + 0x6018, 0xa005, 0x0040, 0x2b26, 0x8001, 0x601a, 0x007c, 0x017e, + 0x007e, 0x2009, 0x382e, 0x2104, 0xa005, 0x0040, 0x2b31, 0x8001, + 0x200a, 0x007f, 0x017f, 0x007c, 0x017e, 0x007e, 0x2009, 0x382f, + 0x2104, 0xa005, 0x0040, 0x2b3e, 0x8001, 0x200a, 0x007f, 0x017f, + 0x007c, 0x017e, 0x007e, 0x2009, 0x3830, 0x2104, 0x8000, 0x200a, + 0x007f, 0x017f, 0x007c, 0x017e, 0x007e, 0x2009, 0x382f, 0x2104, + 0x8000, 0x200a, 0x007f, 0x017f, 0x007c, 0x027e, 0x037e, 0x007e, + 0x2009, 0x382e, 0x2114, 0x2019, 0x382f, 0x2304, 0xa202, 0x200a, + 0x201b, 0x0000, 0x2009, 0x3830, 0x007f, 0x037f, 0x027f, 0x007c, + 0x1078, 0x2ffd, 0x6817, 0x0018, 0x0078, 0x2b98, 0x1078, 0x2ffd, + 0x6817, 0x0019, 0x0078, 0x2b98, 0x1078, 0x2ffd, 0x6817, 0x001a, + 0x0078, 0x2b98, 0x77b4, 0x1078, 0x2f11, 0x71b8, 0xa18c, 0x00ff, + 0xa1e8, 0x5b00, 0x2d04, 0x2d08, 0x2068, 0xa005, 0x00c0, 0x2b8a, + 0x0078, 0x1d41, 0x6810, 0x72b4, 0xa206, 0x0040, 0x2b92, 0x6800, + 0x0078, 0x2b83, 0x6800, 0x200a, 0x6817, 0x0005, 0x70bf, 0x0000, + 0x1078, 0x2b0d, 0x681c, 0xa084, 0x0001, 0x00c0, 0x2ba1, 0x1078, + 0x2b06, 0x1078, 0x2b1e, 0x681b, 0x0000, 0x681f, 0x0020, 0x1078, + 0x18b6, 0x0078, 0x1d41, 0xa282, 0x0003, 0x00c0, 0x2dda, 0x7da8, + 0xa5ac, 0x00ff, 0x7ea8, 0xa6b4, 0x00ff, 0x691c, 0xa18d, 0x0080, + 0x691e, 0xa184, 0x0100, 0x0040, 0x2c0b, 0xa18c, 0xfeff, 0x691e, + 0xa6b4, 0x00ff, 0x0040, 0x2bf5, 0xa682, 0x000f, 0x0048, 0x2bcc, + 0x0040, 0x2bcc, 0x2031, 0x000f, 0x852b, 0x852b, 0x1078, 0x2e94, + 0x0040, 0x2bd6, 0x1078, 0x2ca4, 0x0078, 0x2bfe, 0x1078, 0x2e4f, + 0x0c7e, 0x2960, 0x6004, 0xa084, 0xfff5, 0x6006, 0x1078, 0x2cc8, + 0x0c7f, 0x691c, 0xa18d, 0x0100, 0x691e, 0x7e58, 0xa6b5, 0x0004, + 0x7e5a, 0xa684, 0x0400, 0x00c0, 0x2bf1, 0x781b, 0x0055, 0x0078, + 0x1d39, 0x781b, 0x0069, 0x0078, 0x1d39, 0x0c7e, 0x2960, 0x6004, + 0xa084, 0xfff5, 0x6006, 0x1078, 0x2cc8, 0x0c7f, 0x7e58, 0xa684, + 0x0400, 0x00c0, 0x2c07, 0x781b, 0x0058, 0x0078, 0x1d39, 0x781b, + 0x006a, 0x0078, 0x1d39, 0x0c7e, 0x7048, 0x2060, 0x6100, 0xa18c, + 0x1000, 0x0040, 0x2c4b, 0x6208, 0x8217, 0xa294, 0x00ff, 0xa282, + 0x000f, 0x0048, 0x2c1f, 0x0040, 0x2c1f, 0x2011, 0x000f, 0x2600, + 0xa202, 0x00c8, 0x2c24, 0x2230, 0x6208, 0xa294, 0x00ff, 0x7018, + 0xa086, 0x0028, 0x00c0, 0x2c34, 0xa282, 0x0019, 0x00c8, 0x2c3a, + 0x2011, 0x0019, 0x0078, 0x2c3a, 0xa282, 0x000c, 0x00c8, 0x2c3a, + 0x2011, 0x000c, 0x2200, 0xa502, 0x00c8, 0x2c3f, 0x2228, 0x1078, + 0x2e53, 0x852b, 0x852b, 0x1078, 0x2e94, 0x0040, 0x2c4b, 0x1078, + 0x2ca4, 0x0078, 0x2c4f, 0x1078, 0x2e4f, 0x1078, 0x2cc8, 0x7858, + 0xa085, 0x0004, 0x785a, 0x0c7f, 0x781b, 0x0069, 0x0078, 0x1d39, + 0x0c7e, 0x2960, 0x6000, 0xa084, 0x1000, 0x00c0, 0x2c72, 0xa084, + 0x0040, 0x00c0, 0x2c6c, 0xa18c, 0x0002, 0x00c0, 0x2c6c, 0xa18c, + 0xfff5, 0x6106, 0x0c7f, 0x007c, 0x2011, 0x0032, 0x2019, 0x0000, + 0x0078, 0x2c94, 0x6208, 0xa294, 0x00ff, 0x7018, 0xa086, 0x0028, + 0x00c0, 0x2c82, 0xa282, 0x0019, 0x00c8, 0x2c88, 0x2011, 0x0019, + 0x0078, 0x2c88, 0xa282, 0x000c, 0x00c8, 0x2c88, 0x2011, 0x000c, + 0x6308, 0x831f, 0xa39c, 0x00ff, 0xa382, 0x000f, 0x0048, 0x2c94, + 0x0040, 0x2c94, 0x2019, 0x000f, 0x78ab, 0x0001, 0x78ab, 0x0003, + 0x78ab, 0x0001, 0x7aaa, 0x7baa, 0xa8c0, 0x0005, 0x681c, 0xa085, + 0x0100, 0x681e, 0x0c7f, 0x007c, 0x0c7e, 0x7148, 0x2160, 0x2008, + 0xa084, 0xfff0, 0xa635, 0x7e86, 0x6018, 0x789a, 0x7eae, 0x6612, + 0x78a4, 0xa084, 0xfff8, 0xa18c, 0x0007, 0xa105, 0x78a6, 0x6016, + 0x788a, 0xa6b4, 0x000f, 0x8637, 0x8204, 0x8004, 0xa084, 0x00ff, + 0xa605, 0x600e, 0x6004, 0xa084, 0xfff5, 0x6006, 0x0c7f, 0x007c, + 0x0c7e, 0x7048, 0x2060, 0x6018, 0x789a, 0x78a4, 0xa084, 0xfff0, + 0x78a6, 0x6012, 0x7884, 0xa084, 0xfff0, 0x7886, 0x0c7f, 0x007c, + 0xa282, 0x0002, 0x00c0, 0x2dda, 0x7aa8, 0x691c, 0xa18d, 0x0080, + 0x691e, 0xa184, 0x0200, 0x0040, 0x2d1d, 0xa18c, 0xfdff, 0x691e, + 0xa294, 0x00ff, 0xa282, 0x0002, 0x00c8, 0x2dda, 0x1078, 0x2d63, + 0x1078, 0x2cc8, 0xa980, 0x0001, 0x200c, 0x1078, 0x2f0d, 0x1078, + 0x2c58, 0x88ff, 0x0040, 0x2d10, 0x789b, 0x0060, 0x2800, 0x78aa, + 0x7e58, 0xa6b5, 0x0004, 0x7e5a, 0xa684, 0x0400, 0x00c0, 0x2d0c, + 0x781b, 0x0055, 0x0078, 0x1d39, 0x781b, 0x0069, 0x0078, 0x1d39, + 0x7e58, 0xa684, 0x0400, 0x00c0, 0x2d19, 0x781b, 0x0058, 0x0078, + 0x1d39, 0x781b, 0x006a, 0x0078, 0x1d39, 0xa282, 0x0002, 0x00c8, + 0x2d25, 0xa284, 0x0001, 0x0040, 0x2d2f, 0x7148, 0xa188, 0x0000, + 0x210c, 0xa18c, 0x2000, 0x00c0, 0x2d2f, 0x2011, 0x0000, 0x1078, + 0x2e41, 0x1078, 0x2d63, 0x1078, 0x2cc8, 0x7858, 0xa085, 0x0004, + 0x785a, 0x781b, 0x0069, 0x0078, 0x1d39, 0x0c7e, 0x027e, 0x2960, + 0x6000, 0x2011, 0x0001, 0xa084, 0x2000, 0x00c0, 0x2d53, 0xa084, + 0x0080, 0x00c0, 0x2d51, 0xa18c, 0xffef, 0x6106, 0xa006, 0x0078, + 0x2d60, 0x2011, 0x0000, 0x78ab, 0x0001, 0x78ab, 0x0002, 0x78ab, + 0x0003, 0x7aaa, 0xa8c0, 0x0004, 0x681c, 0xa085, 0x0200, 0x681e, + 0x027f, 0x0c7f, 0x007c, 0x0c7e, 0x7048, 0x2060, 0x82ff, 0x0040, + 0x2d6b, 0x2011, 0x0040, 0x6018, 0xa080, 0x0002, 0x789a, 0x78a4, + 0xa084, 0xffbf, 0xa205, 0x78a6, 0x6016, 0x788a, 0x6004, 0xa084, + 0xffef, 0x6006, 0x0c7f, 0x007c, 0x007e, 0x7000, 0xa086, 0x0003, + 0x0040, 0x2d85, 0x007f, 0x0078, 0x2d88, 0x007f, 0x0078, 0x2dd6, + 0xa684, 0x0020, 0x0040, 0x2dd6, 0x7888, 0xa084, 0x0040, 0x0040, + 0x2dd6, 0x78a8, 0x8001, 0x0040, 0x2d95, 0x7bb8, 0xa384, 0x003f, + 0x831b, 0x00c8, 0x2d9c, 0x8000, 0xa005, 0x0040, 0x2dbd, 0x831b, + 0x00c8, 0x2da5, 0x8001, 0x0040, 0x2dd2, 0xa006, 0x1078, 0x3414, + 0x78b4, 0x1078, 0x3479, 0x0078, 0x2dd6, 0xa684, 0x4000, 0x0040, + 0x2dbd, 0x78b8, 0x801b, 0x00c8, 0x2db6, 0x8000, 0xa084, 0x003f, + 0x00c0, 0x2dd2, 0xa6b4, 0xbfff, 0x7e5a, 0x79d8, 0x7adc, 0x2001, + 0x0001, 0xa108, 0x00c8, 0x2dc6, 0xa291, 0x0000, 0x79d2, 0x79da, + 0x7ad6, 0x7ade, 0x1078, 0x3414, 0x781b, 0x0067, 0x1078, 0x32e4, + 0x0078, 0x1d39, 0x781b, 0x0067, 0x0078, 0x1d39, 0x781b, 0x006a, + 0x0078, 0x1d39, 0x1078, 0x2e0d, 0x781b, 0x0069, 0x0078, 0x1d39, + 0x1078, 0x2df9, 0x781b, 0x0069, 0x0078, 0x1d39, 0x6823, 0x0002, + 0x1078, 0x2e01, 0x691c, 0xa18d, 0x0020, 0x691e, 0x6814, 0xa084, + 0x8000, 0x0040, 0x2df5, 0x6817, 0x0005, 0x781b, 0x0069, 0x0078, + 0x1d39, 0x2001, 0x0005, 0x0078, 0x2e0f, 0x2001, 0x000c, 0x0078, + 0x2e0f, 0x2001, 0x0006, 0x0078, 0x2e0f, 0x2001, 0x000d, 0x0078, + 0x2e0f, 0x2001, 0x0009, 0x0078, 0x2e0f, 0x2001, 0x0007, 0x789b, + 0x007f, 0x78aa, 0xa6b5, 0x0008, 0x7e5a, 0x007c, 0x077e, 0x873f, + 0xa7bc, 0x000f, 0x873b, 0x873b, 0x8703, 0xa0e0, 0x3a80, 0xa7b8, + 0x0020, 0x7f9a, 0x79a4, 0xa184, 0x000f, 0x0040, 0x2e2f, 0xa184, + 0xfff0, 0x78a6, 0x6012, 0x6004, 0xa085, 0x0008, 0x6006, 0x8738, + 0x8738, 0x7f9a, 0x79a4, 0xa184, 0x0040, 0x0040, 0x2e3f, 0xa184, + 0xffbf, 0x78a6, 0x6016, 0x6004, 0xa085, 0x0010, 0x6006, 0x077f, + 0x007c, 0x789b, 0x0010, 0x78ab, 0x0001, 0x78ab, 0x0002, 0x78ab, + 0x0003, 0x7aaa, 0x789b, 0x0060, 0x78ab, 0x0004, 0x007c, 0x2031, + 0x0000, 0x2029, 0x0032, 0x789b, 0x0010, 0x78ab, 0x0001, 0x78ab, + 0x0003, 0x78ab, 0x0001, 0x7daa, 0x7eaa, 0x789b, 0x0060, 0x78ab, + 0x0005, 0x007c, 0x157e, 0x8007, 0xa084, 0x00ff, 0x8003, 0x8003, + 0xa080, 0x0020, 0x789a, 0x79a4, 0xa18c, 0xfff0, 0x2001, 0x3846, + 0x2004, 0xa082, 0x0028, 0x0040, 0x2e7d, 0x2021, 0x2ef4, 0x2019, + 0x0014, 0x20a9, 0x000c, 0x0078, 0x2e83, 0x2021, 0x2f00, 0x2019, + 0x0019, 0x20a9, 0x000d, 0x2011, 0x0064, 0x2404, 0xa084, 0xfff0, + 0xa106, 0x0040, 0x2e92, 0x8420, 0x2300, 0xa210, 0x0070, 0x2e92, + 0x0078, 0x2e85, 0x157f, 0x007c, 0x157e, 0x2011, 0x3846, 0x2214, + 0xa282, 0x0032, 0x0048, 0x2ea8, 0x0040, 0x2eac, 0x2021, 0x2ee6, + 0x2019, 0x0011, 0x20a9, 0x000e, 0x2011, 0x0032, 0x0078, 0x2ebc, + 0xa282, 0x0028, 0x0040, 0x2eb4, 0x2021, 0x2ef4, 0x2019, 0x0014, + 0x20a9, 0x000c, 0x0078, 0x2eba, 0x2021, 0x2f00, 0x2019, 0x0019, + 0x20a9, 0x000d, 0x2011, 0x0064, 0x2200, 0xa502, 0x0040, 0x2ecc, + 0x0048, 0x2ecc, 0x8420, 0x2300, 0xa210, 0x0070, 0x2ec9, 0x0078, + 0x2ebc, 0x157f, 0xa006, 0x007c, 0x157f, 0xa582, 0x0064, 0x00c8, + 0x2ed5, 0x7808, 0xa085, 0x0070, 0x780a, 0x78ec, 0xa084, 0x0300, + 0x0040, 0x2ee3, 0x2404, 0xa09e, 0x1201, 0x00c0, 0x2ee3, 0x2001, + 0x2101, 0x0078, 0x2ee4, 0x2404, 0xa005, 0x007c, 0x1201, 0x3002, + 0x3202, 0x4203, 0x4403, 0x5404, 0x5604, 0x6605, 0x6805, 0x7806, + 0x7a06, 0x0a07, 0x0c07, 0x0e07, 0x3202, 0x4202, 0x5202, 0x6202, + 0x7202, 0x6605, 0x7605, 0x7805, 0x7a05, 0x7c05, 0x7e05, 0x7f05, + 0x2202, 0x3202, 0x4202, 0x5202, 0x5404, 0x6404, 0x7404, 0x7604, + 0x7804, 0x7a04, 0x7c04, 0x7e04, 0x7f04, 0x789b, 0x0010, 0xa046, + 0x007c, 0xa784, 0x0f00, 0x800b, 0xa784, 0x001f, 0x8003, 0x8003, + 0x8003, 0x8003, 0xa105, 0xa0e0, 0x3b00, 0x007c, 0x79d8, 0x7adc, + 0x78d0, 0x801b, 0x00c8, 0x2f25, 0x8000, 0xa084, 0x003f, 0xa108, + 0xa291, 0x0000, 0x007c, 0x0f7e, 0x2079, 0x0100, 0x2009, 0x3840, + 0x2091, 0x8000, 0x2104, 0x0079, 0x2f35, 0x2f67, 0x2f3f, 0x2f3f, + 0x2f3f, 0x2f3f, 0x2f3f, 0x2f3d, 0x2f3d, 0x1078, 0x1ce7, 0x784b, + 0x0004, 0x7848, 0xa084, 0x0004, 0x00c0, 0x2f41, 0x784b, 0x0008, + 0x7848, 0xa084, 0x0008, 0x00c0, 0x2f48, 0x68b0, 0xa085, 0x4000, + 0x68b2, 0x7858, 0xa085, 0x4000, 0x785a, 0x7830, 0xa084, 0x0080, + 0x00c0, 0x2f67, 0x0018, 0x2f67, 0x6818, 0xa084, 0x0020, 0x00c0, + 0x2f65, 0x781b, 0x00dd, 0x0078, 0x2f67, 0x781b, 0x00e4, 0x2091, + 0x8001, 0x0f7f, 0x007c, 0x0c7e, 0x6810, 0x8007, 0xa084, 0x000f, + 0x8003, 0x8003, 0x8003, 0xa0e0, 0x3a80, 0x6004, 0xa084, 0x000a, + 0x00c0, 0x2fb4, 0x6108, 0xa194, 0xff00, 0x0040, 0x2fb4, 0xa18c, + 0x00ff, 0x6004, 0xa084, 0x0014, 0x00c0, 0x2f9d, 0xa085, 0x0014, + 0x6006, 0x017e, 0x691c, 0xa18d, 0x0002, 0x691e, 0x017f, 0x2001, + 0x000c, 0xa106, 0x0040, 0x2f99, 0x2100, 0x8003, 0x2008, 0x0078, + 0x2fad, 0x2009, 0x0019, 0x0078, 0x2fad, 0x2011, 0x0000, 0x6000, + 0xa084, 0xdfff, 0x6002, 0x6004, 0xa084, 0xffef, 0x6006, 0x017e, + 0x691c, 0xa18d, 0x0002, 0x691e, 0x017f, 0x2100, 0xa205, 0x600a, + 0x6004, 0xa085, 0x000a, 0x6006, 0x0c7f, 0x007c, 0x781b, 0x006a, + 0x0078, 0x1d39, 0x781b, 0x0069, 0x0078, 0x1d39, 0x781b, 0x0058, + 0x0078, 0x1d39, 0x781b, 0x0055, 0x0078, 0x1d39, 0x781b, 0x00dd, + 0x0078, 0x1d39, 0x781b, 0x00dc, 0x0078, 0x1d39, 0x781b, 0x00e4, + 0x0078, 0x1d39, 0x781b, 0x00e3, 0x0078, 0x1d39, 0x781b, 0x009e, + 0x0078, 0x1d39, 0x781b, 0x009d, 0x0078, 0x1d39, 0x70a3, 0x0001, + 0x781b, 0x0046, 0x0078, 0x1d39, 0x007e, 0x7830, 0xa084, 0x00c0, + 0x00c0, 0x2ffb, 0x7808, 0xa084, 0xfffd, 0x780a, 0x0005, 0x0005, + 0x0005, 0x0005, 0x78ec, 0xa084, 0x0021, 0x0040, 0x2ffb, 0x7808, + 0xa085, 0x0002, 0x780a, 0x007f, 0x007c, 0x7808, 0xa085, 0x0002, + 0x780a, 0x007c, 0x7830, 0xa084, 0x0040, 0x00c0, 0x3002, 0x0098, + 0x300b, 0x78ac, 0x007c, 0x7808, 0xa084, 0xfffd, 0x780a, 0x0005, + 0x0005, 0x0005, 0x0005, 0x78ec, 0xa084, 0x0021, 0x0040, 0x301a, + 0x0098, 0x3018, 0x78ac, 0x007e, 0x7808, 0xa085, 0x0002, 0x780a, + 0x007f, 0x007c, 0xa784, 0x0070, 0x0040, 0x302e, 0x0c7e, 0x2d60, + 0x2f68, 0x1078, 0x1c97, 0x2d78, 0x2c68, 0x0c7f, 0x6817, 0x0003, + 0x7858, 0xa084, 0x3f00, 0x681a, 0x682f, 0x0000, 0x682b, 0x0000, + 0x784b, 0x0008, 0x78e4, 0xa005, 0x00d0, 0x21cc, 0xa084, 0x0020, + 0x0040, 0x21cc, 0x78ec, 0xa084, 0x0003, 0x0040, 0x21cc, 0x0018, + 0x21cc, 0x0078, 0x2de0, 0x0c7e, 0x6810, 0x8007, 0xa084, 0x000f, + 0x8003, 0x8003, 0x8003, 0xa080, 0x3a80, 0x2060, 0x2048, 0x704a, + 0x6000, 0x704e, 0x6004, 0x7052, 0x0c7f, 0x007c, 0x0020, 0x0020, + 0x0000, 0x0020, 0x0000, 0x0020, 0x0000, 0x0020, 0x0000, 0x0020, + 0x0000, 0x0020, 0x0000, 0x0020, 0x0000, 0x0020, 0x0000, 0x0020, + 0x0000, 0x0020, 0x0000, 0x0020, 0x0000, 0x0020, 0x0000, 0x0020, + 0x0000, 0x0020, 0x0000, 0x0020, 0x0000, 0x0020, 0x0000, 0x0020, + 0x0062, 0x0009, 0x0014, 0x0014, 0x9847, 0x0014, 0x0014, 0x98f5, + 0x98e7, 0x0014, 0x0014, 0x0080, 0x00bf, 0x0100, 0x0402, 0x2008, + 0xf880, 0xa20a, 0x0014, 0x300b, 0xa20c, 0x0014, 0xa200, 0x8838, + 0x817e, 0x842a, 0x84a0, 0x3806, 0x8839, 0x28c2, 0x9cc3, 0xa805, + 0x0864, 0xa83b, 0x3008, 0x28c1, 0x9cc3, 0xa201, 0x300c, 0x2847, + 0x8161, 0x846a, 0x8000, 0x84a4, 0x1856, 0x883a, 0xa808, 0x28e2, + 0x9ca0, 0xa8f3, 0x0864, 0xa829, 0x300c, 0xa801, 0x3008, 0x28e1, + 0x9ca0, 0x280d, 0xa204, 0x64c0, 0x67a0, 0x6fc0, 0x1814, 0x883b, + 0x7023, 0x8576, 0x8677, 0xa80f, 0x786e, 0x883e, 0xa80c, 0x282b, + 0xa205, 0x64a0, 0x67a0, 0x6fc0, 0x1814, 0x883b, 0x7023, 0x8576, + 0x8677, 0xa801, 0x883e, 0x2069, 0x28c1, 0x9cc3, 0x2044, 0x2103, + 0x20a2, 0x2081, 0xa8dc, 0xa207, 0x0014, 0xa203, 0x8000, 0x84a8, + 0x85a4, 0x1872, 0x849a, 0x883c, 0x1fe2, 0xf601, 0xa208, 0x856e, + 0x866f, 0x0704, 0x3008, 0x9ca0, 0x0014, 0xa202, 0x8000, 0x85a4, + 0x3009, 0x84a8, 0x19e2, 0xf848, 0x8174, 0x86eb, 0x85eb, 0x872e, + 0x87a9, 0x883f, 0x08e6, 0xa8f1, 0xf861, 0xa8e8, 0xf801, 0x0014, + 0xf881, 0x0016, 0x85b2, 0x80f0, 0x9532, 0xfaa2, 0x1de2, 0x0014, + 0x8532, 0xf221, 0x0014, 0x1de2, 0x84a8, 0xd6e0, 0x1fe6, 0x0014, + 0xa206, 0x6865, 0x817f, 0x842a, 0x1dc1, 0x8823, 0x0016, 0x6042, + 0x8008, 0xa8fa, 0x8000, 0x84a4, 0x8160, 0x842a, 0xf021, 0x3008, + 0x84a8, 0x1dc6, 0x20d7, 0x8822, 0x0016, 0x8000, 0x2848, 0x1011, + 0xa8fc, 0x3008, 0x8000, 0xa000, 0x2802, 0x1011, 0xa8fd, 0xa887, + 0x3008, 0x283d, 0x1011, 0xa8fd, 0xa209, 0x0017, 0x300c, 0x8000, + 0x85a4, 0x1de2, 0xdac1, 0x0014, 0x26e0, 0x873a, 0xfaa2, 0x19f2, + 0x1fe2, 0x0014, 0xa20b, 0x0014, 0xa20d, 0x817e, 0x842a, 0x84a0, + 0x3806, 0x0210, 0x9ccd, 0x0704, 0x0000, 0x127e, 0x2091, 0x2200, + 0x2049, 0x314d, 0x7000, 0x7204, 0xa205, 0x720c, 0xa215, 0x7008, + 0xa084, 0xfffd, 0xa205, 0x0040, 0x315f, 0x0078, 0x3164, 0x7003, + 0x0000, 0x127f, 0x2000, 0x007c, 0x7000, 0xa084, 0x0001, 0x00c0, + 0x3192, 0x7108, 0x8104, 0x00c8, 0x3171, 0x1078, 0x322e, 0x0078, + 0x3169, 0x700c, 0xa08c, 0x007f, 0x0040, 0x3192, 0x7004, 0x8004, + 0x00c8, 0x3189, 0x7014, 0xa005, 0x00c0, 0x3185, 0x7010, 0xa005, + 0x0040, 0x3189, 0xa102, 0x00c8, 0x3169, 0x7007, 0x0010, 0x0078, + 0x3192, 0x8aff, 0x0040, 0x3192, 0x1078, 0x33eb, 0x00c0, 0x318c, + 0x0040, 0x3169, 0x1078, 0x31dc, 0x7003, 0x0000, 0x127f, 0x2000, + 0x007c, 0x6424, 0x84ff, 0x0040, 0x31b6, 0x2c70, 0x2039, 0x31bb, + 0x2704, 0xae68, 0x680c, 0xa630, 0x6808, 0xa529, 0x8421, 0x0040, + 0x31b6, 0x8738, 0x2704, 0xa005, 0x00c0, 0x31a1, 0x7098, 0xa075, + 0x0040, 0x31b6, 0x2039, 0x31b8, 0x0078, 0x31a0, 0x007c, 0x0000, + 0x0004, 0x0008, 0x000c, 0x0010, 0x0014, 0x0018, 0x001c, 0x0000, + 0x127e, 0x2091, 0x2200, 0x2079, 0x3800, 0x2071, 0x0010, 0x7007, + 0x000a, 0x7007, 0x0002, 0x7003, 0x0000, 0x2071, 0x0020, 0x7007, + 0x000a, 0x7007, 0x0002, 0x7003, 0x0000, 0x2049, 0x0000, 0x78b7, + 0x0000, 0x127f, 0x2000, 0x007c, 0x2049, 0x31dc, 0x7004, 0x8004, + 0x00c8, 0x3208, 0x7007, 0x0012, 0x7108, 0x7008, 0xa106, 0x00c0, + 0x31e4, 0xa184, 0x0030, 0x0040, 0x31f1, 0xa086, 0x0030, 0x00c0, + 0x31e4, 0x7000, 0xa084, 0x0001, 0x00c0, 0x3208, 0x7008, 0xa084, + 0x000c, 0x00c0, 0x3206, 0x710c, 0xa184, 0x0300, 0x00c0, 0x3206, + 0xa184, 0x007f, 0x00c0, 0x31dc, 0x0078, 0x3208, 0x6817, 0x0003, + 0x7007, 0x0012, 0x7007, 0x0008, 0x7004, 0xa084, 0x0008, 0x00c0, + 0x320c, 0x7007, 0x0012, 0x7108, 0x8104, 0x0048, 0x3211, 0x78b7, + 0x0000, 0x7003, 0x0000, 0x2049, 0x0000, 0x007c, 0x107e, 0x007e, + 0x127e, 0x157e, 0x2091, 0x2200, 0x7108, 0x1078, 0x322e, 0x157f, + 0x127f, 0x2091, 0x8001, 0x007f, 0x107f, 0x007c, 0x7204, 0x2118, + 0x7108, 0x700c, 0xa084, 0x0300, 0x00c0, 0x3270, 0xa184, 0x000c, + 0x00c0, 0x3270, 0x8213, 0x8213, 0x8213, 0x8213, 0xa284, 0x0100, + 0xa10d, 0x810b, 0x810b, 0x810f, 0xa184, 0x0007, 0x0079, 0x3248, + 0x3252, 0x3262, 0x3270, 0x3262, 0x3284, 0x3284, 0x3270, 0x3282, + 0x1078, 0x1ce7, 0x7007, 0x0002, 0x8aff, 0x00c0, 0x325b, 0x2049, + 0x0000, 0x0078, 0x325f, 0x1078, 0x33eb, 0x00c0, 0x325b, 0x78b7, + 0x0000, 0x007c, 0x7007, 0x0002, 0x8aff, 0x00c0, 0x3269, 0x0078, + 0x326d, 0x1078, 0x33eb, 0x00c0, 0x3269, 0x78b7, 0x0000, 0x007c, + 0x7007, 0x0002, 0x1078, 0x31dc, 0x1078, 0x2f2b, 0x6814, 0xa084, + 0x8000, 0x0040, 0x327d, 0x6817, 0x0002, 0x007c, 0x1078, 0x1ce7, + 0x1078, 0x1ce7, 0x1078, 0x32d6, 0x7210, 0x7114, 0x700c, 0xa09c, + 0x007f, 0x2800, 0xa300, 0xa211, 0xa189, 0x0000, 0x78b4, 0xa005, + 0x0040, 0x3296, 0x78b7, 0x0000, 0x0078, 0x32b9, 0x1078, 0x32d6, + 0x2704, 0x2c58, 0xac60, 0x630c, 0x2200, 0xa322, 0x6308, 0x2100, + 0xa31b, 0x2400, 0xa305, 0x0040, 0x32af, 0x00c8, 0x32af, 0x8412, + 0x8210, 0x830a, 0xa189, 0x0000, 0x2b60, 0x0078, 0x3296, 0x2b60, + 0x8a07, 0xa7ba, 0x31b8, 0xa73d, 0x2c00, 0x6882, 0x6f86, 0x6c8e, + 0x6b8a, 0x7007, 0x0012, 0x1078, 0x31dc, 0x007c, 0x8738, 0x2704, + 0xa005, 0x00c0, 0x32ca, 0x6098, 0xa005, 0x0040, 0x32d3, 0x2060, + 0x2039, 0x31b8, 0x8a51, 0x0040, 0x32d2, 0x7008, 0xa084, 0x00c0, + 0xa086, 0x00c0, 0x007c, 0x2051, 0x0000, 0x007c, 0x8a50, 0x8739, + 0x2704, 0xa004, 0x00c0, 0x32e3, 0x2039, 0x31be, 0x6000, 0xa064, + 0x00c0, 0x32e3, 0x2d60, 0x007c, 0x127e, 0x0d7e, 0x2091, 0x2200, + 0x0d7f, 0x6880, 0x2060, 0x6884, 0x6b88, 0x6c8c, 0x8057, 0xaad4, + 0x00ff, 0xa084, 0x00ff, 0xa0b8, 0x31b8, 0x7e08, 0xa6b5, 0x000c, + 0x6818, 0xa084, 0x0040, 0x0040, 0x32ff, 0xa6b5, 0x0001, 0x0f7e, + 0x2079, 0x0100, 0x7858, 0x0f7f, 0xa084, 0x0040, 0x0040, 0x330e, + 0xa684, 0x0001, 0x00c0, 0x330e, 0xa6b5, 0x0001, 0x7007, 0x0004, + 0x7004, 0xa084, 0x0004, 0x00c0, 0x3310, 0x7000, 0xa005, 0x0040, + 0x331b, 0x1078, 0x1ce7, 0x2400, 0xa305, 0x00c0, 0x3321, 0x0078, + 0x335e, 0x2c58, 0x2704, 0xac60, 0x6004, 0xa400, 0x007e, 0x701a, + 0x6000, 0xa301, 0x701e, 0x2009, 0x04fd, 0x2104, 0xa086, 0x04fd, + 0x007f, 0x00c0, 0x334e, 0xa084, 0x0001, 0x0040, 0x334e, 0xa684, + 0x0001, 0x00c0, 0x334e, 0x7013, 0x0001, 0x7017, 0x0000, 0x7602, + 0x7007, 0x0001, 0x78b7, 0x0001, 0xa4a0, 0x0001, 0xa399, 0x0000, + 0x6004, 0xa400, 0x701a, 0x6000, 0xa301, 0x701e, 0x620c, 0x2400, + 0xa202, 0x7012, 0x6208, 0x2300, 0xa203, 0x7016, 0x7602, 0x7007, + 0x0001, 0x2b60, 0x1078, 0x32be, 0x0078, 0x3360, 0x1078, 0x33eb, + 0x00c0, 0x335e, 0x127f, 0x2000, 0x007c, 0x127e, 0x0d7e, 0x2091, + 0x2200, 0x0d7f, 0x7007, 0x0004, 0x7004, 0xa084, 0x0004, 0x00c0, + 0x336c, 0x7003, 0x0008, 0x127f, 0x2000, 0x007c, 0x127e, 0x0d7e, + 0x2091, 0x2200, 0x0d7f, 0x2049, 0x3376, 0x7007, 0x0004, 0x7004, + 0xa084, 0x0004, 0x00c0, 0x337f, 0x7e08, 0xa6b5, 0x000c, 0x6818, + 0xa084, 0x0040, 0x0040, 0x338e, 0xa6b5, 0x0001, 0x6824, 0xa005, + 0x0040, 0x339a, 0x2050, 0x2039, 0x31bb, 0x2d60, 0x1078, 0x33eb, + 0x00c0, 0x3396, 0x127f, 0x2000, 0x007c, 0x127e, 0x007e, 0x017e, + 0x0d7e, 0x2091, 0x2200, 0x0d7f, 0x037f, 0x047f, 0x7e08, 0xa6b5, + 0x000c, 0x6818, 0xa084, 0x0040, 0x0040, 0x33b0, 0xa6b5, 0x0001, + 0x2049, 0x339d, 0x6824, 0xa055, 0x0040, 0x33e8, 0x2d70, 0x2e60, + 0x2039, 0x31bb, 0x2704, 0xae68, 0x680c, 0xa422, 0x6808, 0xa31b, + 0x0048, 0x33d5, 0x8a51, 0x00c0, 0x33c7, 0x1078, 0x1ce7, 0x8738, + 0x2704, 0xa005, 0x00c0, 0x33bb, 0x7098, 0xa075, 0x2060, 0x0040, + 0x33e8, 0x2039, 0x31b8, 0x0078, 0x33ba, 0x8422, 0x8420, 0x831a, + 0xa399, 0x0000, 0x690c, 0x2400, 0xa122, 0x6908, 0x2300, 0xa11b, + 0x00c8, 0x33e4, 0x1078, 0x1ce7, 0x2071, 0x0020, 0x0078, 0x330e, + 0x127f, 0x2000, 0x007c, 0x7008, 0xa084, 0x00c0, 0xa086, 0x00c0, + 0x0040, 0x3413, 0x2704, 0xac08, 0x2104, 0x701e, 0x8108, 0x2104, + 0x701a, 0x8108, 0x2104, 0x7016, 0x8108, 0x2104, 0x7012, 0x0f7e, + 0x2079, 0x0100, 0x7858, 0x0f7f, 0xa084, 0x0040, 0x0040, 0x340e, + 0xa684, 0x0001, 0x00c0, 0x340e, 0xa6b5, 0x0001, 0x7602, 0x7007, + 0x0001, 0x1078, 0x32be, 0x007c, 0x127e, 0x007e, 0x0d7e, 0x2091, + 0x2200, 0x2049, 0x3414, 0x0d7f, 0x087f, 0x7108, 0xa184, 0x00c0, + 0x00c0, 0x342a, 0x6824, 0xa005, 0x0040, 0x343a, 0x0078, 0x3164, + 0x0078, 0x343a, 0x7108, 0x8104, 0x00c8, 0x3432, 0x1078, 0x322e, + 0x0078, 0x341d, 0x7007, 0x0010, 0x7108, 0x8104, 0x00c8, 0x3434, + 0x1078, 0x322e, 0x7008, 0xa086, 0x0002, 0x00c0, 0x341d, 0x7000, + 0xa005, 0x00c0, 0x341d, 0x7003, 0x0000, 0x2049, 0x0000, 0x127f, + 0x2000, 0x007c, 0x127e, 0x147e, 0x137e, 0x157e, 0x0d7e, 0x2091, + 0x2200, 0x0d7f, 0x2049, 0x344a, 0xad80, 0x0010, 0x20a0, 0x2099, + 0x0031, 0x700c, 0xa084, 0x007f, 0x6826, 0x7007, 0x0008, 0x7007, + 0x0002, 0x7003, 0x0001, 0x0040, 0x3468, 0x8000, 0x80ac, 0x53a5, + 0x7007, 0x0004, 0x7004, 0xa084, 0x0004, 0x00c0, 0x346a, 0x2049, + 0x0000, 0x7003, 0x0000, 0x157f, 0x137f, 0x147f, 0x127f, 0x2000, + 0x007c, 0x127e, 0x007e, 0x0d7e, 0x2091, 0x2200, 0x0d7f, 0x2049, + 0x3479, 0x6880, 0x2060, 0x6884, 0x6b88, 0x6c8c, 0x8057, 0xaad4, + 0x00ff, 0xa084, 0x00ff, 0xa0b8, 0x31b8, 0x7e08, 0xa6b5, 0x0004, + 0x7007, 0x0004, 0x7004, 0xa084, 0x0004, 0x00c0, 0x3492, 0x2c58, + 0x2704, 0xac60, 0x6004, 0xa400, 0x701a, 0x6000, 0xa301, 0x701e, + 0x7013, 0x0001, 0x7017, 0x0000, 0x7602, 0x7007, 0x0001, 0x007f, + 0x8007, 0x2009, 0x0031, 0x200a, 0x00a0, 0x34ac, 0x7108, 0x7007, + 0x0002, 0x810c, 0x00c8, 0x34ac, 0x810c, 0x0048, 0x34b9, 0x0078, + 0x3270, 0xa4a0, 0x0001, 0xa399, 0x0000, 0x6b8a, 0x6c8e, 0x7007, + 0x0004, 0x2049, 0x0000, 0x7003, 0x0000, 0x127f, 0x2000, 0x007c, + 0x20a9, 0x0010, 0xa006, 0x8004, 0x8086, 0x818e, 0x00c8, 0x34d1, + 0xa200, 0x00f0, 0x34cc, 0x8086, 0x818e, 0x007c, 0x157e, 0x20a9, + 0x0010, 0xa005, 0x0040, 0x34f7, 0xa11a, 0x00c8, 0x34f7, 0x8213, + 0x818d, 0x0048, 0x34ea, 0xa11a, 0x00c8, 0x34eb, 0x00f0, 0x34df, + 0x0078, 0x34ef, 0xa11a, 0x2308, 0x8210, 0x00f0, 0x34df, 0x007e, + 0x3200, 0xa084, 0xf7ff, 0x2080, 0x007f, 0x157f, 0x007c, 0x007e, + 0x3200, 0xa085, 0x0800, 0x0078, 0x34f3, 0x00e0, 0x3563, 0x2091, + 0x6000, 0x7820, 0x8001, 0x7822, 0x00c0, 0x355b, 0x7824, 0x7822, + 0x2009, 0x3834, 0x2104, 0xa005, 0x00c0, 0x3510, 0x2001, 0x0010, + 0x8001, 0x200a, 0x077e, 0x803f, 0x1078, 0x2f11, 0x077f, 0x20a9, + 0x0020, 0x601f, 0x0064, 0xace0, 0x0010, 0x00f0, 0x3519, 0x2091, + 0x8000, 0x2069, 0x3840, 0x6800, 0xa084, 0x0007, 0x0040, 0x3538, + 0xa086, 0x0002, 0x0040, 0x3538, 0x6830, 0xa00d, 0x0040, 0x3538, + 0x2104, 0xa005, 0x0040, 0x3538, 0x8001, 0x200a, 0x0040, 0x3640, + 0x2061, 0x3b00, 0x2009, 0x0002, 0x20a9, 0x0100, 0x603c, 0xa005, + 0x0040, 0x354e, 0x8001, 0x603e, 0x00c0, 0x354e, 0x6010, 0xa005, + 0x0040, 0x354e, 0x017e, 0x1078, 0x1b49, 0x017f, 0xace0, 0x0010, + 0x0070, 0x3554, 0x0078, 0x353e, 0x8109, 0x0040, 0x355b, 0x20a9, + 0x0100, 0x0078, 0x353e, 0x1078, 0x3578, 0x1078, 0x3566, 0x1078, + 0x359d, 0x1078, 0x3707, 0x2091, 0x8001, 0x007c, 0x783c, 0x8001, + 0x783e, 0x00c0, 0x3577, 0x7840, 0x783e, 0x7848, 0xa005, 0x0040, + 0x3577, 0x8001, 0x784a, 0x00c0, 0x3577, 0x1078, 0x1b49, 0x007c, + 0x7834, 0x8001, 0x7836, 0x00c0, 0x359c, 0x7838, 0x7836, 0x2091, + 0x8000, 0x7844, 0xa005, 0x00c0, 0x3587, 0x2001, 0x0101, 0x8001, + 0x7846, 0xa080, 0x5b00, 0x2040, 0x2004, 0xa065, 0x0040, 0x359c, + 0x6020, 0xa005, 0x0040, 0x3598, 0x8001, 0x6022, 0x0040, 0x35cc, + 0x6000, 0x2c40, 0x0078, 0x358d, 0x007c, 0x7828, 0x8001, 0x782a, + 0x00c0, 0x35cb, 0x782c, 0x782a, 0x7830, 0xa005, 0x00c0, 0x35aa, + 0x2001, 0x0200, 0x8001, 0x7832, 0x8003, 0x8003, 0x8003, 0x8003, + 0xa090, 0x3b00, 0xa298, 0x0002, 0x2304, 0xa084, 0x0008, 0x0040, + 0x35cb, 0xa290, 0x0009, 0x2204, 0xa005, 0x0040, 0x35c3, 0x8001, + 0x2012, 0x00c0, 0x35cb, 0x2304, 0xa084, 0xfff7, 0xa085, 0x0080, + 0x201a, 0x1078, 0x1b49, 0x007c, 0x2069, 0x3840, 0x6800, 0xa005, + 0x0040, 0x35d6, 0x683c, 0xac06, 0x0040, 0x3640, 0x6710, 0x6fb6, + 0x1078, 0x1758, 0x6808, 0xa084, 0x0020, 0x00c0, 0x363d, 0x2009, + 0x382b, 0x2104, 0xa005, 0x0040, 0x35e9, 0x6023, 0x0001, 0x0078, + 0x363d, 0x6808, 0xa084, 0xffef, 0xa085, 0x0021, 0x6017, 0x0006, + 0x60b0, 0xa084, 0x3f00, 0x601a, 0x601c, 0xa084, 0x00ff, 0xa085, + 0x0060, 0x601e, 0x6000, 0x2042, 0x6710, 0x6fb6, 0x1078, 0x1758, + 0x6818, 0xa005, 0x0040, 0x3606, 0x8001, 0x681a, 0x6808, 0xa084, + 0xffef, 0x680a, 0x6810, 0x8001, 0x00d0, 0x3610, 0x1078, 0x1ce7, + 0x6812, 0x602f, 0x0000, 0x602b, 0x0000, 0x2c68, 0x1078, 0x18b6, + 0x2069, 0x3840, 0x6710, 0xa784, 0x0f00, 0x68b6, 0x2001, 0x0002, + 0x1078, 0x1b44, 0x2041, 0x0021, 0x2049, 0x0005, 0x2051, 0x0030, + 0x1078, 0x1765, 0x2011, 0x3835, 0x2214, 0x6a3e, 0x8738, 0xa784, + 0x001f, 0x00c0, 0x3622, 0x2009, 0x382b, 0x200b, 0x0008, 0x2009, + 0x382c, 0x2069, 0x3840, 0x68b4, 0x200a, 0x2091, 0x8001, 0x007c, + 0x2009, 0x384f, 0x2164, 0x2069, 0x0100, 0x1078, 0x1c97, 0x6017, + 0x0006, 0x6858, 0xa084, 0x3f00, 0x601a, 0x601c, 0xa084, 0x00ff, + 0xa085, 0x0048, 0x601e, 0x602f, 0x0000, 0x602b, 0x0000, 0x6830, + 0xa084, 0x0040, 0x0040, 0x367c, 0x684b, 0x0004, 0x20a9, 0x0014, + 0x6848, 0xa084, 0x0004, 0x0040, 0x3669, 0x0070, 0x3669, 0x0078, + 0x3660, 0x684b, 0x0009, 0x20a9, 0x0014, 0x6848, 0xa084, 0x0001, + 0x0040, 0x3676, 0x0070, 0x3676, 0x0078, 0x366d, 0x20a9, 0x00fa, + 0x0070, 0x367c, 0x0078, 0x3678, 0x6808, 0xa084, 0xfffd, 0x680a, + 0x681b, 0x0046, 0x2009, 0x3868, 0x200b, 0x0007, 0x784c, 0x784a, + 0x2091, 0x8001, 0x007c, 0x2079, 0x3800, 0x1078, 0x36de, 0x1078, + 0x36a6, 0x1078, 0x36b4, 0x1078, 0x36c9, 0x1078, 0x36f3, 0x2009, + 0x3833, 0x200b, 0x0000, 0x2009, 0x3834, 0x200b, 0x0000, 0x7833, + 0x0000, 0x7847, 0x0000, 0x784b, 0x0000, 0x007c, 0x2019, 0x0003, + 0x2011, 0x3846, 0x2204, 0xa086, 0x003c, 0x0040, 0x36b1, 0x2019, + 0x0002, 0x7b2a, 0x7b2e, 0x007c, 0x2019, 0x0030, 0x2011, 0x3846, + 0x2204, 0xa086, 0x0032, 0x0040, 0x36c6, 0x2019, 0x0039, 0x2204, + 0xa086, 0x003c, 0x0040, 0x36c6, 0x2019, 0x0027, 0x7b36, 0x7b3a, + 0x007c, 0x2019, 0x000f, 0x2011, 0x3846, 0x2204, 0xa086, 0x003c, + 0x0040, 0x36db, 0x2019, 0x000d, 0x2204, 0xa086, 0x0032, 0x0040, + 0x36db, 0x2019, 0x000a, 0x7b3e, 0x7b42, 0x007c, 0x2019, 0x2faf, + 0x2011, 0x3846, 0x2204, 0xa086, 0x0032, 0x0040, 0x36f0, 0x2019, + 0x3971, 0x2204, 0xa086, 0x003c, 0x0040, 0x36f0, 0x2019, 0x2626, + 0x7b22, 0x7b26, 0x007c, 0x2019, 0x0001, 0x2011, 0x3846, 0x2204, + 0xa086, 0x003c, 0x0040, 0x36fe, 0x2019, 0x0001, 0x017e, 0x2009, + 0x3831, 0x230a, 0x2009, 0x3832, 0x230a, 0x017f, 0x007c, 0x2009, + 0x3831, 0x2104, 0x8001, 0x200a, 0xa005, 0x00c0, 0x3755, 0x2009, + 0x3832, 0x2104, 0x2009, 0x3831, 0x200a, 0x2009, 0x3833, 0x2104, + 0xa005, 0x00c0, 0x371d, 0x2001, 0x0200, 0x8001, 0x200a, 0x8003, + 0x8003, 0x8003, 0x8003, 0xa090, 0x3b00, 0x2208, 0xa298, 0x0002, + 0x2304, 0xa084, 0x0200, 0x0040, 0x3755, 0xa290, 0x000e, 0x2204, + 0xa005, 0x0040, 0x3740, 0x8001, 0x0040, 0x3740, 0x8001, 0x0040, + 0x3740, 0x8001, 0x0040, 0x3740, 0x8001, 0x2012, 0x00c0, 0x3755, + 0x2012, 0x2304, 0xa084, 0xfdff, 0xa085, 0x0400, 0x201a, 0xa188, + 0x000c, 0x2104, 0x007e, 0xa084, 0x00ff, 0x8001, 0x027f, 0xa294, + 0xff00, 0xa205, 0x200a, 0x1078, 0x1b49, 0x007c, 0x6ed0 +}; +#else +/* + * Flakey, not quite functional, target mode code for ISP1000 + * hacked out of PCI 7.55 initiator/target mode code. + */ +static const u_int16_t isp_1000_risc_code[] = { + 0x0078, 0x103a, 0x0000, 0x3c1f, 0x0000, 0x2043, 0x4f50, 0x5952, + 0x4947, 0x4854, 0x2031, 0x3939, 0x3520, 0x514c, 0x4f47, 0x4943, + 0x2043, 0x4f52, 0x504f, 0x5241, 0x5449, 0x4f4e, 0x2049, 0x5350, + 0x3130, 0x3030, 0x2049, 0x2f54, 0x2046, 0x6972, 0x6d77, 0x6172, + 0x6520, 0x2056, 0x6572, 0x7369, 0x6f6e, 0x2030, 0x372e, 0x3535, + 0x2020, 0x2043, 0x7573, 0x746f, 0x6d65, 0x7220, 0x4e6f, 0x2e20, + 0x3030, 0x2050, 0x726f, 0x6475, 0x6374, 0x204e, 0x6f2e, 0x2020, + 0x3031, 0x2024, 0x3700, 0xa086, 0xffff, 0x0040, 0x1043, 0x2079, + 0x4d00, 0x7803, 0x0001, 0x20c1, 0x0008, 0x2071, 0x0010, 0x70c3, + 0x0004, 0x20c9, 0x73ff, 0x2089, 0x116f, 0x70c7, 0x4953, 0x70cb, + 0x5020, 0x70cf, 0x2020, 0x70d3, 0x0007, 0x3f00, 0x70d6, 0x20c1, + 0x0008, 0x2019, 0x0000, 0x2009, 0xfeff, 0x2100, 0x200b, 0xa5a5, + 0xa1ec, 0x7fff, 0x2d64, 0x206b, 0x0a0a, 0xaddc, 0x3fff, 0x2b54, + 0x205b, 0x5050, 0x2114, 0xa286, 0xa5a5, 0x0040, 0x10b5, 0xa386, + 0x000f, 0x0040, 0x107b, 0x2c6a, 0x2a5a, 0x20c1, 0x0000, 0x2019, + 0x000f, 0x0078, 0x105b, 0x2c6a, 0x2a5a, 0x20c1, 0x0008, 0x2009, + 0x7fff, 0x2148, 0x2944, 0x204b, 0x0a0a, 0xa9bc, 0x3fff, 0x2734, + 0x203b, 0x5050, 0x2114, 0xa286, 0x0a0a, 0x0040, 0x109f, 0x284a, + 0x263a, 0x20c1, 0x0004, 0x2009, 0x3fff, 0x2134, 0x200b, 0x5050, + 0x2114, 0xa286, 0x5050, 0x0040, 0x10a0, 0x0078, 0x1177, 0x284a, + 0x263a, 0x98c0, 0xa188, 0x1000, 0x212c, 0x200b, 0xa5a5, 0x2114, + 0xa286, 0xa5a5, 0x0040, 0x10b2, 0x250a, 0xa18a, 0x1000, 0x98c1, + 0x0078, 0x10b7, 0x250a, 0x0078, 0x10b7, 0x2c6a, 0x2a5a, 0x2130, + 0xa18a, 0x0040, 0x2128, 0xa1a2, 0x4d00, 0x8424, 0x8424, 0x8424, + 0x8424, 0x8424, 0x8424, 0xa192, 0x7400, 0x2009, 0x0000, 0x2001, + 0x0031, 0x1078, 0x1bd8, 0x2218, 0x2079, 0x4d00, 0x2fa0, 0x2408, + 0x2011, 0x0000, 0x20a9, 0x0040, 0x42a4, 0x8109, 0x00c0, 0x10d2, + 0x7ef2, 0x8528, 0x7de6, 0x7cea, 0x7bee, 0x7883, 0x0000, 0x2031, + 0x0030, 0x78cf, 0x0101, 0x780b, 0x0002, 0x780f, 0x0002, 0x784f, + 0x0003, 0x2069, 0x4d40, 0x00a8, 0x10f1, 0x681b, 0x003c, 0x0078, + 0x10f3, 0x681b, 0x0028, 0x6807, 0x0007, 0x680b, 0x00fa, 0x680f, + 0x0008, 0x6813, 0x0005, 0x6823, 0x0000, 0x6827, 0x0006, 0x6817, + 0x0008, 0x682b, 0x0000, 0x681f, 0x0019, 0x2069, 0x4f80, 0x2011, + 0x0020, 0x2009, 0x0010, 0x680b, 0x080c, 0x680f, 0x0019, 0x6803, + 0xfd00, 0x6807, 0x0018, 0x6a1a, 0x2d00, 0xa0e8, 0x0008, 0xa290, + 0x0004, 0x8109, 0x00c0, 0x110b, 0x2069, 0x5000, 0x2009, 0x0002, + 0x20a9, 0x0100, 0x6837, 0x0000, 0x680b, 0x0040, 0x7bf0, 0xa386, + 0xfeff, 0x00c0, 0x1131, 0x6817, 0x0100, 0x681f, 0x0064, 0x0078, + 0x1135, 0x6817, 0x0064, 0x681f, 0x0002, 0xade8, 0x0010, 0x0070, + 0x113b, 0x0078, 0x1122, 0x8109, 0x00c0, 0x1120, 0x1078, 0x20d8, + 0x1078, 0x43d1, 0x1078, 0x18a9, 0x1078, 0x48d9, 0x3200, 0xa085, + 0x000d, 0x2090, 0x70c3, 0x0000, 0x0090, 0x1155, 0x70c0, 0xa086, + 0x0002, 0x00c0, 0x1155, 0x1078, 0x126d, 0x1078, 0x117f, 0x78cc, + 0xa005, 0x00c0, 0x1163, 0x1078, 0x1c01, 0x0010, 0x1169, 0x0068, + 0x1169, 0x1078, 0x1fbd, 0x0010, 0x1169, 0x0068, 0x1169, 0x1078, + 0x198e, 0x00e0, 0x1155, 0x1078, 0x4760, 0x0078, 0x1155, 0x1177, + 0x1179, 0x22cc, 0x22cc, 0x4452, 0x4452, 0x22cc, 0x22cc, 0x0078, + 0x1177, 0x0078, 0x1179, 0x0078, 0x117b, 0x0078, 0x117d, 0x0068, + 0x11ea, 0x2061, 0x0000, 0x6018, 0xa084, 0x0001, 0x00c0, 0x11ea, + 0x7814, 0xa005, 0x00c0, 0x1190, 0x0010, 0x11eb, 0x0078, 0x11ea, + 0x2009, 0x4d5b, 0x2104, 0xa005, 0x00c0, 0x11ea, 0x2009, 0x4d64, + 0x200b, 0x0000, 0x7914, 0xa186, 0x0042, 0x00c0, 0x11b5, 0x7816, + 0x2009, 0x4d62, 0x2164, 0x200b, 0x0000, 0x6018, 0x70c6, 0x6014, + 0x70ca, 0x611c, 0xa18c, 0xff00, 0x6020, 0xa084, 0x00ff, 0xa105, + 0x70ce, 0x1078, 0x188e, 0x0078, 0x11e8, 0x7814, 0xa086, 0x0018, + 0x00c0, 0x11bc, 0x1078, 0x15e0, 0x7817, 0x0000, 0x2009, 0x4d62, + 0x2104, 0xa065, 0x0040, 0x11d8, 0x0c7e, 0x609c, 0x2060, 0x1078, + 0x18f9, 0x0c7f, 0x609f, 0x0000, 0x1078, 0x16a2, 0x2009, 0x000e, + 0x6007, 0x0103, 0x1078, 0x186a, 0x00c0, 0x11e4, 0x1078, 0x188e, + 0x2009, 0x4d62, 0x200b, 0x0000, 0x2009, 0x4d5c, 0x2104, 0x200b, + 0x0000, 0xa005, 0x0040, 0x11e8, 0x2001, 0x4005, 0x0078, 0x126f, + 0x0078, 0x126d, 0x007c, 0x70c3, 0x0000, 0x70c7, 0x0000, 0x70cb, + 0x0000, 0x70cf, 0x0000, 0x70c0, 0xa0bc, 0xffc0, 0x00c0, 0x123b, + 0x2038, 0x0079, 0x11fb, 0x126d, 0x12c4, 0x1292, 0x12d3, 0x12e2, + 0x12e8, 0x1289, 0x16ba, 0x12ec, 0x1281, 0x1296, 0x1298, 0x129a, + 0x129c, 0x16bf, 0x1281, 0x12f4, 0x1313, 0x15ee, 0x16b4, 0x129e, + 0x1517, 0x1533, 0x154f, 0x157a, 0x14d0, 0x14de, 0x14f2, 0x1506, + 0x1384, 0x1281, 0x1332, 0x1338, 0x133d, 0x1342, 0x1348, 0x134d, + 0x1352, 0x1357, 0x135c, 0x1360, 0x1375, 0x1381, 0x1281, 0x1281, + 0x1281, 0x1281, 0x1390, 0x1399, 0x13a8, 0x13ce, 0x13d8, 0x13df, + 0x141a, 0x1429, 0x1438, 0x144a, 0x14b0, 0x14c0, 0x1281, 0x1281, + 0x1281, 0x1281, 0x14c5, 0xa0bc, 0xffa0, 0x00c0, 0x1281, 0x2038, + 0xa084, 0x001f, 0x0079, 0x1244, 0x16f8, 0x16fb, 0x170b, 0x1281, + 0x1281, 0x1846, 0x1858, 0x1281, 0x1281, 0x1281, 0x185c, 0x1864, + 0x1281, 0x1281, 0x1281, 0x1281, 0x1281, 0x1281, 0x1281, 0x1281, + 0x1281, 0x16d6, 0x16ea, 0x1281, 0x1797, 0x1281, 0x1822, 0x182c, + 0x1830, 0x183e, 0x1281, 0x1281, 0x72ca, 0x71c6, 0x2001, 0x4006, + 0x0078, 0x126f, 0x73ce, 0x72ca, 0x71c6, 0x2001, 0x4000, 0x70c2, + 0x0068, 0x1270, 0x2061, 0x0000, 0x601b, 0x0001, 0x2091, 0x5000, + 0x00e0, 0x1278, 0x00e0, 0x127a, 0x0068, 0x127a, 0x2091, 0x4080, + 0x007c, 0x70c3, 0x4001, 0x0078, 0x1270, 0x70c3, 0x4006, 0x0078, + 0x1270, 0x2099, 0x0041, 0x20a1, 0x0041, 0x20a9, 0x0005, 0x53a3, + 0x0078, 0x126d, 0x70c4, 0x70c3, 0x0004, 0x007a, 0x0078, 0x126d, + 0x0078, 0x126d, 0x0078, 0x126d, 0x0078, 0x126d, 0x2091, 0x8000, + 0x70c3, 0x0000, 0x70c7, 0x4953, 0x70cb, 0x5020, 0x70cf, 0x2020, + 0x70d3, 0x0007, 0x3f00, 0x70d6, 0x2079, 0x0000, 0x781b, 0x0001, + 0x2031, 0x0030, 0x2059, 0x1000, 0x2029, 0x0457, 0x2051, 0x0470, + 0x2061, 0x0472, 0x20b9, 0xffff, 0x20c1, 0x0000, 0x2091, 0x5000, + 0x2091, 0x4080, 0x0078, 0x0455, 0x2029, 0x0000, 0x2520, 0x71d0, + 0x73c8, 0x72cc, 0x70c4, 0x1078, 0x19d3, 0x0040, 0x126d, 0x70c3, + 0x4002, 0x0078, 0x126d, 0x2029, 0x0000, 0x2520, 0x71d0, 0x73c8, + 0x72cc, 0x70c4, 0x1078, 0x1a1f, 0x0040, 0x126d, 0x70c3, 0x4002, + 0x0078, 0x126d, 0x71c4, 0x70c8, 0x2114, 0x200a, 0x0078, 0x126b, + 0x71c4, 0x2114, 0x0078, 0x126b, 0x70c7, 0x0007, 0x70cb, 0x0037, + 0x70cf, 0x0000, 0x0078, 0x126d, 0x2029, 0x0000, 0x2530, 0x70c4, + 0x72c8, 0x73cc, 0x74d0, 0x70c6, 0x72ca, 0x73ce, 0x74d2, 0xa005, + 0x0040, 0x130d, 0x8001, 0x7892, 0x7a9a, 0x7b9e, 0x7c96, 0x78cc, + 0xa084, 0xfffc, 0x78ce, 0x0078, 0x1311, 0x78cc, 0xa085, 0x0001, + 0x78ce, 0x0078, 0x126d, 0x2029, 0x0000, 0x2530, 0x70c4, 0x72c8, + 0x73cc, 0x74d4, 0x70c6, 0x72ca, 0x73ce, 0x74d6, 0xa005, 0x0040, + 0x132c, 0x8001, 0x78ae, 0x7ab6, 0x7bba, 0x7cb2, 0x78cc, 0xa084, + 0xfcff, 0x78ce, 0x0078, 0x1330, 0x78cc, 0xa085, 0x0100, 0x78ce, + 0x0078, 0x126d, 0x2009, 0x4d61, 0x210c, 0x7aec, 0x0078, 0x126b, + 0x2009, 0x4d41, 0x210c, 0x0078, 0x126c, 0x2009, 0x4d42, 0x210c, + 0x0078, 0x126c, 0x2061, 0x4d40, 0x610c, 0x6210, 0x0078, 0x126b, + 0x2009, 0x4d45, 0x210c, 0x0078, 0x126c, 0x2009, 0x4d46, 0x210c, + 0x0078, 0x126c, 0x2009, 0x4d48, 0x210c, 0x0078, 0x126c, 0x2009, + 0x4d49, 0x210c, 0x0078, 0x126c, 0x7908, 0x7a0c, 0x0078, 0x126b, + 0x71c4, 0x8107, 0xa084, 0x000f, 0x8003, 0x8003, 0x8003, 0xa0e8, + 0x4f80, 0x6a00, 0x6804, 0xa084, 0x0008, 0x0040, 0x1372, 0x6b08, + 0x0078, 0x1373, 0x6b0c, 0x0078, 0x126a, 0x77c4, 0x1078, 0x18b9, + 0x2091, 0x8000, 0x6b1c, 0x6a14, 0x2091, 0x8001, 0x2708, 0x0078, + 0x126a, 0x794c, 0x0078, 0x126c, 0x77c4, 0x1078, 0x18b9, 0x2091, + 0x8000, 0x6908, 0x6a18, 0x6b10, 0x2091, 0x8001, 0x0078, 0x126a, + 0x71c4, 0xa182, 0x0010, 0x00c8, 0x1265, 0x1078, 0x21a3, 0x0078, + 0x126a, 0x71c4, 0xa182, 0x0010, 0x00c8, 0x1265, 0x2011, 0x4d41, + 0x2204, 0x007e, 0x2112, 0x1078, 0x215c, 0x017f, 0x0078, 0x126c, + 0x71c4, 0x2011, 0x13c6, 0x20a9, 0x0008, 0x2204, 0xa106, 0x0040, + 0x13b8, 0x8210, 0x0070, 0x13b6, 0x0078, 0x13ad, 0x0078, 0x1265, + 0xa292, 0x13c6, 0x027e, 0x2011, 0x4d42, 0x2204, 0x2112, 0x017f, + 0x007e, 0x1078, 0x2168, 0x017f, 0x0078, 0x126c, 0x03e8, 0x00fa, + 0x01f4, 0x02ee, 0x0064, 0x0019, 0x0032, 0x004b, 0x2061, 0x4d40, + 0x610c, 0x6210, 0x70c4, 0x600e, 0x70c8, 0x6012, 0x0078, 0x126b, + 0x2061, 0x4d40, 0x6114, 0x70c4, 0x6016, 0x0078, 0x126c, 0x2061, + 0x4d40, 0x71c4, 0x2011, 0x0004, 0x601f, 0x0019, 0x2019, 0x1212, + 0xa186, 0x0028, 0x0040, 0x1400, 0x2011, 0x0005, 0x601f, 0x0019, + 0x2019, 0x1212, 0xa186, 0x0032, 0x0040, 0x1400, 0x2011, 0x0006, + 0x601f, 0x000c, 0x2019, 0x2222, 0xa186, 0x003c, 0x00c0, 0x1265, + 0x6018, 0x007e, 0x611a, 0x7800, 0xa084, 0x0001, 0x00c0, 0x1410, + 0x0028, 0x140c, 0x0078, 0x1410, 0x2019, 0x2222, 0x0078, 0x1412, + 0x2019, 0x1212, 0x23b8, 0x1078, 0x2179, 0x1078, 0x48d9, 0x017f, + 0x0078, 0x126c, 0x71c4, 0xa184, 0xffcf, 0x00c0, 0x1265, 0x2011, + 0x4d48, 0x2204, 0x2112, 0x007e, 0x1078, 0x219b, 0x017f, 0x0078, + 0x126c, 0x71c4, 0xa182, 0x0010, 0x00c8, 0x1265, 0x2011, 0x4d49, + 0x2204, 0x007e, 0x2112, 0x1078, 0x218a, 0x017f, 0x0078, 0x126c, + 0x71c4, 0x72c8, 0xa184, 0xfffd, 0x00c0, 0x1264, 0xa284, 0xfffd, + 0x00c0, 0x1264, 0x2100, 0x7908, 0x780a, 0x2200, 0x7a0c, 0x780e, + 0x0078, 0x126b, 0x71c4, 0x8107, 0xa084, 0x000f, 0x8003, 0x8003, + 0x8003, 0xa0e8, 0x4f80, 0x2019, 0x0000, 0x72c8, 0x6800, 0x007e, + 0xa226, 0x0040, 0x1479, 0x6a02, 0xa484, 0x2000, 0x0040, 0x1462, + 0xa39d, 0x0010, 0xa484, 0x1000, 0x0040, 0x1468, 0xa39d, 0x0008, + 0xa484, 0x4000, 0x0040, 0x1479, 0x810f, 0xa284, 0x4000, 0x0040, + 0x1475, 0x1078, 0x21bd, 0x0078, 0x1479, 0x1078, 0x21af, 0x0078, + 0x1479, 0x72cc, 0x6808, 0xa206, 0x0040, 0x14a8, 0xa2a4, 0x00ff, + 0x2061, 0x4d40, 0x6118, 0xa186, 0x0028, 0x0040, 0x148f, 0xa186, + 0x0032, 0x0040, 0x1495, 0xa186, 0x003c, 0x0040, 0x149b, 0xa482, + 0x0064, 0x0048, 0x14a5, 0x0078, 0x149f, 0xa482, 0x0050, 0x0048, + 0x14a5, 0x0078, 0x149f, 0xa482, 0x0043, 0x0048, 0x14a5, 0x71c4, + 0x71c6, 0x027f, 0x72ca, 0x0078, 0x1266, 0x6a0a, 0xa39d, 0x000a, + 0x6804, 0xa305, 0x6806, 0x027f, 0x6b0c, 0x71c4, 0x0078, 0x126a, + 0x77c4, 0x1078, 0x18b9, 0x2091, 0x8000, 0x6a14, 0x6b1c, 0x2091, + 0x8001, 0x70c8, 0x6816, 0x70cc, 0x681e, 0x2708, 0x0078, 0x126a, + 0x70c4, 0x794c, 0x784e, 0x0078, 0x126c, 0x71c4, 0x72c8, 0x73cc, + 0xa182, 0x0010, 0x00c8, 0x1265, 0x1078, 0x21cb, 0x0078, 0x126a, + 0x77c4, 0x1078, 0x18b9, 0x2091, 0x8000, 0x6a08, 0xa295, 0x0002, + 0x6a0a, 0x2091, 0x8001, 0x2708, 0x0078, 0x126b, 0x77c4, 0x1078, + 0x18b9, 0x2091, 0x8000, 0x6a08, 0xa294, 0xfff9, 0x6a0a, 0x6804, + 0xa005, 0x0040, 0x14ed, 0x1078, 0x20a0, 0x2091, 0x8001, 0x2708, + 0x0078, 0x126b, 0x77c4, 0x1078, 0x18b9, 0x2091, 0x8000, 0x6a08, + 0xa295, 0x0004, 0x6a0a, 0x6804, 0xa005, 0x0040, 0x1501, 0x1078, + 0x20a0, 0x2091, 0x8001, 0x2708, 0x0078, 0x126b, 0x77c4, 0x2041, + 0x0001, 0x2049, 0x0005, 0x2051, 0x0020, 0x2091, 0x8000, 0x1078, + 0x18c6, 0x2091, 0x8001, 0x2708, 0x6a08, 0x0078, 0x126b, 0x77c4, + 0x72c8, 0x73cc, 0x77c6, 0x72ca, 0x73ce, 0x1078, 0x1927, 0x00c0, + 0x152f, 0x6818, 0xa005, 0x0040, 0x152f, 0x2708, 0x1078, 0x21db, + 0x00c0, 0x152f, 0x7817, 0x0015, 0x2091, 0x8001, 0x007c, 0x2091, + 0x8001, 0x0078, 0x126d, 0x77c4, 0x77c6, 0x2041, 0x0021, 0x2049, + 0x0005, 0x2051, 0x0020, 0x2091, 0x8000, 0x1078, 0x18c6, 0x2061, + 0x4d40, 0x606f, 0x0003, 0x6782, 0x6093, 0x000f, 0x6073, 0x0000, + 0x7817, 0x0016, 0x1078, 0x20a0, 0x2091, 0x8001, 0x007c, 0x77c8, + 0x77ca, 0x77c4, 0x77c6, 0xa7bc, 0xff00, 0x2091, 0x8000, 0x2061, + 0x4d40, 0x606f, 0x0002, 0x6073, 0x0000, 0x6782, 0x6093, 0x000f, + 0x7817, 0x0017, 0x1078, 0x20a0, 0x2091, 0x8001, 0x2041, 0x0021, + 0x2049, 0x0004, 0x2051, 0x0010, 0x2091, 0x8000, 0x1078, 0x18c6, + 0x70c8, 0x6836, 0x8738, 0xa784, 0x001f, 0x00c0, 0x156e, 0x2091, + 0x8001, 0x007c, 0x78cc, 0xa084, 0x0003, 0x00c0, 0x159e, 0x2039, + 0x0000, 0x2041, 0x0021, 0x2049, 0x0004, 0x2051, 0x0008, 0x1078, + 0x18b9, 0x2091, 0x8000, 0x6808, 0xa80d, 0x690a, 0x2091, 0x8001, + 0x8738, 0xa784, 0x001f, 0x00c0, 0x1587, 0xa7bc, 0xff00, 0x873f, + 0x8738, 0x873f, 0xa784, 0x0f00, 0x00c0, 0x1587, 0x2091, 0x8000, + 0x2069, 0x0100, 0x6830, 0xa084, 0x0040, 0x0040, 0x15c7, 0x684b, + 0x0004, 0x20a9, 0x0014, 0x6848, 0xa084, 0x0004, 0x0040, 0x15b4, + 0x0070, 0x15b4, 0x0078, 0x15ab, 0x684b, 0x0009, 0x20a9, 0x0014, + 0x6848, 0xa084, 0x0001, 0x0040, 0x15c1, 0x0070, 0x15c1, 0x0078, + 0x15b8, 0x20a9, 0x00fa, 0x0070, 0x15c7, 0x0078, 0x15c3, 0x2079, + 0x4d00, 0x7817, 0x0018, 0x2061, 0x4d40, 0x606f, 0x0001, 0x6073, + 0x0000, 0x6093, 0x000f, 0x78cc, 0xa085, 0x0002, 0x78ce, 0x6808, + 0xa084, 0xfffd, 0x680a, 0x681b, 0x0048, 0x2091, 0x8001, 0x007c, + 0x78cc, 0xa084, 0xfffd, 0x78ce, 0xa084, 0x0001, 0x00c0, 0x15ea, + 0x1078, 0x1971, 0x71c4, 0x71c6, 0x794a, 0x007c, 0x2029, 0x0000, + 0x2520, 0x71c4, 0x73c8, 0x72cc, 0x71c6, 0x73ca, 0x72ce, 0x2079, + 0x4d00, 0x1078, 0x1874, 0x0040, 0x169e, 0x20a9, 0x0005, 0x20a1, + 0x4d18, 0x2091, 0x8000, 0x41a1, 0x2091, 0x8001, 0x2009, 0x0020, + 0x1078, 0x186f, 0x0040, 0x1610, 0x1078, 0x188e, 0x0078, 0x169e, + 0x6004, 0xa084, 0xff00, 0x8007, 0x8009, 0x0040, 0x166d, 0x0c7e, + 0x2c68, 0x1078, 0x1874, 0x0040, 0x163e, 0x2c00, 0x689e, 0x8109, + 0x00c0, 0x1618, 0x609f, 0x0000, 0x0c7f, 0x0c7e, 0x7218, 0x731c, + 0x2c68, 0x689c, 0xa065, 0x0040, 0x166c, 0x2009, 0x0020, 0x1078, + 0x186f, 0x00c0, 0x1655, 0x6004, 0xa084, 0x00ff, 0xa086, 0x0002, + 0x00c0, 0x163e, 0x2d00, 0x6002, 0x0078, 0x1626, 0x0c7f, 0x0c7e, + 0x609c, 0x2060, 0x1078, 0x18f9, 0x0c7f, 0x609f, 0x0000, 0x1078, + 0x16a2, 0x2009, 0x000e, 0x6008, 0xa085, 0x0200, 0x600a, 0x1078, + 0x186a, 0x1078, 0x188e, 0x0078, 0x169e, 0x0c7f, 0x0c7e, 0x609c, + 0x2060, 0x1078, 0x18f9, 0x0c7f, 0x609f, 0x0000, 0x1078, 0x16a2, + 0x2009, 0x000e, 0x6007, 0x0103, 0x601b, 0x0003, 0x1078, 0x186a, + 0x1078, 0x188e, 0x0078, 0x169e, 0x0c7f, 0x74c4, 0x73c8, 0x72cc, + 0x6014, 0x2091, 0x8000, 0x7817, 0x0012, 0x0e7e, 0x2071, 0x4d40, + 0x706f, 0x0005, 0x7073, 0x0000, 0x7376, 0x727a, 0x747e, 0x7082, + 0x7087, 0x0000, 0x2c00, 0x708a, 0x708f, 0x0000, 0xa02e, 0x2530, + 0x611c, 0x61a2, 0xa184, 0x0060, 0x0040, 0x1690, 0x1078, 0x4367, + 0x0e7f, 0x6596, 0x65a6, 0x669a, 0x66aa, 0x60af, 0x0000, 0x60b3, + 0x0000, 0x1078, 0x20a0, 0x2091, 0x8001, 0x007c, 0x70c3, 0x4005, + 0x0078, 0x1270, 0x20a9, 0x0005, 0x2099, 0x4d18, 0x2091, 0x8000, + 0x530a, 0x2091, 0x8001, 0x2100, 0xa210, 0xa399, 0x0000, 0xa4a1, + 0x0000, 0xa5a9, 0x0000, 0x007c, 0x71c4, 0x70c7, 0x0000, 0x7906, + 0x0078, 0x126d, 0x71c4, 0x71c6, 0x2168, 0x0078, 0x16c1, 0x2069, + 0x1000, 0x690c, 0xa016, 0x2d04, 0xa210, 0x8d68, 0x8109, 0x00c0, + 0x16c3, 0xa285, 0x0000, 0x00c0, 0x16d1, 0x70c3, 0x4000, 0x0078, + 0x16d3, 0x70c3, 0x4003, 0x70ca, 0x0078, 0x1270, 0x2011, 0x4d67, + 0x220c, 0x70c4, 0x8003, 0x0048, 0x16e3, 0x1078, 0x398d, 0xa184, + 0x7fff, 0x0078, 0x16e7, 0x1078, 0x3980, 0xa185, 0x8000, 0x2012, + 0x0078, 0x126c, 0x71c4, 0x1078, 0x3977, 0x6100, 0x2001, 0x4d67, + 0x2004, 0xa084, 0x8000, 0xa10d, 0x6204, 0x6308, 0x0078, 0x126a, + 0x79e4, 0x0078, 0x126c, 0x71c4, 0x71c6, 0x2198, 0x20a1, 0x0042, + 0x20a9, 0x0004, 0x53a3, 0x21a0, 0x2099, 0x0042, 0x20a9, 0x0004, + 0x53a3, 0x0078, 0x126d, 0x70c4, 0x2068, 0x2079, 0x4d00, 0x1078, + 0x1874, 0x0040, 0x1793, 0x6007, 0x0001, 0x600b, 0x0000, 0x602b, + 0x0000, 0x601b, 0x0006, 0x6a10, 0xa28c, 0x000f, 0xa284, 0x00f0, + 0x8003, 0x8003, 0x8003, 0x8003, 0xa105, 0x6016, 0xa284, 0x0800, + 0x0040, 0x172e, 0x601b, 0x000a, 0x0078, 0x1734, 0xa284, 0x1000, + 0x0040, 0x1734, 0x601b, 0x000c, 0xa284, 0x0300, 0x0040, 0x173d, + 0x602b, 0x0001, 0x8004, 0x8004, 0x8004, 0xa085, 0x0001, 0x601e, + 0x6023, 0x0000, 0x6027, 0x0000, 0xa284, 0x0400, 0x0040, 0x174a, + 0x602b, 0x0000, 0x20a9, 0x0006, 0xac80, 0x000b, 0x20a0, 0xad80, + 0x0005, 0x2098, 0x53a3, 0xa284, 0x0300, 0x00c0, 0x175f, 0x604a, + 0x6046, 0x6052, 0x604e, 0x6096, 0x609a, 0x0078, 0x1769, 0x6800, + 0x604a, 0x6804, 0x6046, 0x6e08, 0x6652, 0x6d0c, 0x654e, 0x6596, + 0x669a, 0x6014, 0x2091, 0x8000, 0x7817, 0x0042, 0x2c08, 0x2061, + 0x4d40, 0x606f, 0x0005, 0x6073, 0x0000, 0x6077, 0x0000, 0x607b, + 0x0000, 0x607f, 0x0000, 0x6082, 0x618a, 0xa284, 0x0400, 0x608e, + 0x2091, 0x8001, 0x0e7e, 0x2071, 0x0020, 0x7007, 0x000a, 0x7007, + 0x0002, 0x7003, 0x0000, 0x0e7f, 0x2091, 0x8000, 0x1078, 0x20a0, + 0x2091, 0x8001, 0x007c, 0x70c3, 0x4005, 0x0078, 0x1270, 0x0c7e, + 0x0d7e, 0x0e7e, 0x0f7e, 0x2091, 0x8000, 0x2071, 0x4d40, 0x2079, + 0x0100, 0x2061, 0x0010, 0x70a0, 0xa06d, 0x0040, 0x1818, 0x6a04, + 0xa294, 0x00ff, 0xa286, 0x0007, 0x0040, 0x17b2, 0xa286, 0x000f, + 0x00c0, 0x1818, 0x6920, 0xa184, 0x0080, 0x00c0, 0x1818, 0x6824, + 0xa18c, 0xff00, 0xa085, 0x0019, 0x6826, 0x71b8, 0x81ff, 0x0040, + 0x17d3, 0x0d7e, 0x2069, 0x0020, 0x6908, 0x6808, 0xa106, 0x00c0, + 0x17c4, 0x690c, 0x680c, 0xa106, 0x00c0, 0x17c9, 0xa184, 0x00ff, + 0x00c0, 0x17c9, 0x0d7f, 0x78b8, 0xa084, 0x801f, 0x00c0, 0x17d3, + 0x7848, 0xa085, 0x000c, 0x784a, 0x71b8, 0x81ff, 0x0040, 0x17f6, + 0x70bb, 0x0000, 0x0d7e, 0x2069, 0x0020, 0x6807, 0x0008, 0x6804, + 0xa084, 0x0008, 0x00c0, 0x17e7, 0x6807, 0x0008, 0x6804, 0xa084, + 0x0008, 0x00c0, 0x17ee, 0x6807, 0x0002, 0x0d7f, 0x61c4, 0x62c8, + 0x63cc, 0x61c6, 0x62ca, 0x63ce, 0x0e7e, 0x2071, 0x4d00, 0x7266, + 0x736a, 0xae80, 0x0019, 0x0e7f, 0x1078, 0x42b7, 0x78a3, 0x0000, + 0x7858, 0xa084, 0xedff, 0x785a, 0x70bc, 0xa080, 0x00da, 0x781a, + 0x0f7f, 0x0e7f, 0x0d7f, 0x0c7f, 0x2091, 0x8001, 0x0078, 0x126d, + 0x0f7f, 0x0e7f, 0x0d7f, 0x0c7f, 0x2091, 0x8001, 0x2001, 0x4005, + 0x0078, 0x126f, 0x7980, 0x71c6, 0x71c4, 0xa182, 0x0003, 0x00c8, + 0x1265, 0x7982, 0x0078, 0x126d, 0x7980, 0x71c6, 0x0078, 0x126d, + 0x7974, 0x71c6, 0x71c4, 0x7976, 0x7978, 0x71ca, 0x71c8, 0x797a, + 0x797c, 0x71ce, 0x71cc, 0x797e, 0x0078, 0x126d, 0x7974, 0x71c6, + 0x7978, 0x71ca, 0x797c, 0x71ce, 0x0078, 0x126d, 0x7900, 0x71c6, + 0x71c4, 0x7902, 0x00a8, 0x1856, 0xa18c, 0x0001, 0x00c0, 0x1854, + 0x20b9, 0x2222, 0x0078, 0x1856, 0x20b9, 0x1212, 0x0078, 0x126d, + 0x7900, 0x71c6, 0x0078, 0x126d, 0x2009, 0x4d74, 0x2104, 0x70c6, + 0x70c4, 0x200a, 0x0078, 0x126d, 0x2009, 0x4d74, 0x2104, 0x70c6, + 0x0078, 0x126d, 0xac80, 0x0001, 0x1078, 0x1a3d, 0x007c, 0xac80, + 0x0001, 0x1078, 0x19f1, 0x007c, 0x7850, 0xa065, 0x0040, 0x187c, + 0x2c04, 0x7852, 0x2063, 0x0000, 0x007c, 0x0f7e, 0x2079, 0x4d00, + 0x7850, 0xa06d, 0x0040, 0x188c, 0x2d04, 0x7852, 0x6803, 0x0000, + 0x6807, 0x0000, 0x680b, 0x0000, 0x0f7f, 0x007c, 0x2091, 0x8000, + 0x0f7e, 0x2079, 0x4d00, 0x7850, 0x2062, 0x2c00, 0xa005, 0x00c0, + 0x189b, 0x1078, 0x22ac, 0x7852, 0x0f7f, 0x2091, 0x8001, 0x007c, + 0x0f7e, 0x2079, 0x4d00, 0x7850, 0x206a, 0x2d00, 0x7852, 0x0f7f, + 0x007c, 0x2011, 0x7400, 0x7a52, 0x7bec, 0x8319, 0x0040, 0x18b6, + 0xa280, 0x0031, 0x2012, 0x2010, 0x0078, 0x18ad, 0x2013, 0x0000, + 0x007c, 0xa784, 0x0f00, 0x800b, 0xa784, 0x001f, 0x8003, 0x8003, + 0x8003, 0x8003, 0xa105, 0xa0e8, 0x5000, 0x007c, 0x1078, 0x18b9, + 0x2900, 0x682a, 0x2a00, 0x682e, 0x6808, 0xa084, 0xffef, 0xa80d, + 0x690a, 0x2009, 0x4d52, 0x210c, 0x6804, 0xa005, 0x0040, 0x18f8, + 0xa116, 0x00c0, 0x18e3, 0x2060, 0x6000, 0x6806, 0x017e, 0x200b, + 0x0000, 0x0078, 0x18e6, 0x2009, 0x0000, 0x017e, 0x6804, 0xa065, + 0x0040, 0x18f5, 0x6000, 0x6806, 0x1078, 0x1906, 0x1078, 0x1b7d, + 0x6810, 0x8001, 0x6812, 0x00c0, 0x18e6, 0x017f, 0x6902, 0x6906, + 0x007c, 0xa065, 0x0040, 0x1905, 0x609c, 0x609f, 0x0000, 0x2008, + 0x1078, 0x188e, 0x2100, 0x0078, 0x18f9, 0x007c, 0x6007, 0x0103, + 0x608f, 0x0000, 0x20a9, 0x001c, 0xac80, 0x0005, 0x20a0, 0x2001, + 0x0000, 0x40a4, 0x6828, 0x601a, 0x682c, 0x6022, 0x007c, 0x0e7e, + 0x2071, 0x4d40, 0x704c, 0xa08c, 0x0200, 0x00c0, 0x1925, 0xa088, + 0x4d80, 0x2d0a, 0x8000, 0x704e, 0xa006, 0x0e7f, 0x007c, 0x1078, + 0x18b9, 0x2091, 0x8000, 0x6804, 0x781e, 0xa065, 0x0040, 0x1970, + 0x0078, 0x1938, 0x2c00, 0x781e, 0x6000, 0xa065, 0x0040, 0x1970, + 0x6010, 0xa306, 0x00c0, 0x1932, 0x600c, 0xa206, 0x00c0, 0x1932, + 0x2c28, 0x2001, 0x4d52, 0x2004, 0xac06, 0x00c0, 0x1949, 0x0078, + 0x196e, 0x6804, 0xac06, 0x00c0, 0x1956, 0x6000, 0xa065, 0x6806