diff options
author | Jonathan Matthew <jmatthew@cvs.openbsd.org> | 2015-06-19 11:12:25 +0000 |
---|---|---|
committer | Jonathan Matthew <jmatthew@cvs.openbsd.org> | 2015-06-19 11:12:25 +0000 |
commit | 729303d7e2d1a5ef0c720a27190f344a4b544c79 (patch) | |
tree | 6cd4ff5f47640e300d45178779b7c5bcb1b4fcda | |
parent | 5eaaaad177ae4247fab63fbe5da757c76e1f03a1 (diff) |
remove isp(4) now that the ql* family have replaced it
-rw-r--r-- | sys/arch/sparc/conf/files.sparc | 7 | ||||
-rw-r--r-- | sys/arch/sparc/dev/isp_sbus.c | 622 | ||||
-rw-r--r-- | sys/conf/files | 13 | ||||
-rw-r--r-- | sys/dev/ic/isp.c | 7248 | ||||
-rw-r--r-- | sys/dev/ic/isp_library.c | 2678 | ||||
-rw-r--r-- | sys/dev/ic/isp_library.h | 225 | ||||
-rw-r--r-- | sys/dev/ic/isp_openbsd.c | 1143 | ||||
-rw-r--r-- | sys/dev/ic/isp_openbsd.h | 380 | ||||
-rw-r--r-- | sys/dev/ic/isp_stds.h | 212 | ||||
-rw-r--r-- | sys/dev/ic/isp_target.h | 951 | ||||
-rw-r--r-- | sys/dev/ic/ispmbox.h | 1413 | ||||
-rw-r--r-- | sys/dev/ic/ispreg.h | 1181 | ||||
-rw-r--r-- | sys/dev/ic/ispvar.h | 1024 | ||||
-rw-r--r-- | sys/dev/ic/qla.c | 8 | ||||
-rw-r--r-- | sys/dev/microcode/isp/isp_fw2100.c | 8 | ||||
-rw-r--r-- | sys/dev/microcode/isp/isp_fw2200.c | 8 | ||||
-rw-r--r-- | sys/dev/microcode/isp/isp_fw2300.c | 8 | ||||
-rw-r--r-- | sys/dev/pci/files.pci | 7 | ||||
-rw-r--r-- | sys/dev/pci/isp_pci.c | 1385 | ||||
-rw-r--r-- | sys/dev/sbus/files.sbus | 5 | ||||
-rw-r--r-- | sys/dev/sbus/isp_sbus.c | 724 |
21 files changed, 8 insertions, 19242 deletions
diff --git a/sys/arch/sparc/conf/files.sparc b/sys/arch/sparc/conf/files.sparc index 6445cb1b8ac..ceb6c151c5b 100644 --- a/sys/arch/sparc/conf/files.sparc +++ b/sys/arch/sparc/conf/files.sparc @@ -1,4 +1,4 @@ -# $OpenBSD: files.sparc,v 1.100 2015/05/11 06:46:21 ratchov Exp $ +# $OpenBSD: files.sparc,v 1.101 2015/06/19 11:12:24 jmatthew Exp $ # $NetBSD: files.sparc,v 1.44 1997/08/31 21:29:16 pk Exp $ # @(#)files.sparc 8.1 (Berkeley) 7/19/93 @@ -269,11 +269,6 @@ device sw: scsi, ncr5380sbc attach sw at obio file arch/sparc/dev/si.c si | sw -# Qlogic ISP 10x0 (SBus) family -# device declaration in sys/conf/files -attach isp at sbus with isp_sbus -file arch/sparc/dev/isp_sbus.c isp_sbus - attach qlw at sbus with qlw_sbus file arch/sparc/dev/qlw_sbus.c qlw_sbus diff --git a/sys/arch/sparc/dev/isp_sbus.c b/sys/arch/sparc/dev/isp_sbus.c deleted file mode 100644 index e8aca5c8f41..00000000000 --- a/sys/arch/sparc/dev/isp_sbus.c +++ /dev/null @@ -1,622 +0,0 @@ -/* $OpenBSD: isp_sbus.c,v 1.33 2014/07/08 17:42:50 miod Exp $ */ -/* - * SBus specific probe and attach routines for Qlogic ISP SCSI adapters. - * - * Copyright (c) 1997, 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. - * documentation and/or other materials provided with the distribution. - * 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. - * - */ - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/device.h> -#include <sys/kernel.h> -#include <sys/malloc.h> -#include <sys/queue.h> - -#include <machine/autoconf.h> -#include <machine/cpu.h> -#include <machine/param.h> -#include <machine/vmparam.h> -#include <sparc/sparc/cpuvar.h> - -#include <uvm/uvm_extern.h> - -#include <dev/ic/isp_openbsd.h> - -#ifndef ISP_NOFIRMWARE -#define ISP_FIRMWARE_1000 -#define ISP_FIRMWARE_2200 -#endif - -#if defined(ISP_FIRMWARE_1000) -#include <dev/microcode/isp/asm_sbus.h> -#else -#define ISP_1000_RISC_CODE NULL -#endif - -#if defined(ISP_FIRMWARE_2200) -extern const u_int16_t isp_2200_risc_code[]; -#define ISP_2200_RISC_CODE (u_int16_t *) isp_2200_risc_code -#else -#define ISP_2200_RISC_CODE NULL -#endif - -#define ISP_SBUSIFY_ISPHDR(isp, hdrp) \ - ISP_SWAP8((hdrp)->rqs_entry_count, (hdrp)->rqs_entry_type); \ - ISP_SWAP8((hdrp)->rqs_flags, (hdrp)->rqs_seqno); - -#define ISP_SWIZZLE_REQUEST(a, b) \ - ISP_SBUSIFY_ISPHDR(a, &(b)->req_header); \ - ISP_SWAP8((b)->req_target, (b)->req_lun_trn) - - -static int -isp_sbus_rd_isr(struct ispsoftc *, u_int32_t *, u_int16_t *, u_int16_t *); -static int -isp_sbus_rd_isr_2200(struct ispsoftc *, u_int32_t *, u_int16_t *, u_int16_t *); -static u_int32_t isp_sbus_rd_reg(struct ispsoftc *, int); -static void isp_sbus_wr_reg(struct ispsoftc *, int, u_int32_t); -static u_int32_t isp_sbus_rd_reg_2200(struct ispsoftc *, int); -static void isp_sbus_wr_reg_2200(struct ispsoftc *, int, u_int32_t); -static int isp_sbus_mbxdma(struct ispsoftc *); -static int isp_sbus_dmasetup(struct ispsoftc *, struct scsi_xfer *, - ispreq_t *, u_int32_t *, u_int32_t); -static void -isp_sbus_dmateardown(struct ispsoftc *, struct scsi_xfer *, u_int32_t); -static int isp_sbus_intr(void *); - -static struct ispmdvec mdvec = { - isp_sbus_rd_isr, - isp_sbus_rd_reg, - isp_sbus_wr_reg, - isp_sbus_mbxdma, - isp_sbus_dmasetup, - isp_sbus_dmateardown, - NULL, - NULL, - NULL, - ISP_1000_RISC_CODE, - BIU_BURST_ENABLE|BIU_SBUS_CONF1_FIFO_32 -}; - -static struct ispmdvec mdvec_2200 = { - isp_sbus_rd_isr_2200, - isp_sbus_rd_reg_2200, - isp_sbus_wr_reg_2200, - isp_sbus_mbxdma, - isp_sbus_dmasetup, - isp_sbus_dmateardown, - NULL, - NULL, - NULL, - ISP_2200_RISC_CODE -}; - -struct isp_sbussoftc { - struct ispsoftc sbus_isp; - sdparam sbus_dev; - struct intrhand sbus_ih; - volatile u_int16_t *sbus_reg; - int sbus_node; - int sbus_pri; - struct ispmdvec sbus_mdvec; - int16_t sbus_poff[_NREG_BLKS]; - vaddr_t *sbus_kdma_allocs; -}; - - -static int isp_match(struct device *, void *, void *); -static void isp_sbus_attach(struct device *, struct device *, void *); -struct cfattach isp_sbus_ca = { - sizeof (struct isp_sbussoftc), isp_match, isp_sbus_attach -}; - -static int -isp_match(struct device *parent, void *cfarg, void *aux) -{ - int rv; - struct cfdata *cf = cfarg; -#ifdef DEBUG - static int oneshot = 1; -#endif - struct confargs *ca = aux; - struct romaux *ra = &ca->ca_ra; - - rv = (strcmp(cf->cf_driver->cd_name, ra->ra_name) == 0 || - strcmp("PTI,ptisp", ra->ra_name) == 0 || - strcmp("ptisp", ra->ra_name) == 0 || - strcmp("SUNW,isp", ra->ra_name) == 0 || - strcmp("SUNW,qlc", ra->ra_name) == 0 || - strcmp("QLGC,isp", ra->ra_name) == 0 || - strcmp("QLGC,qla", ra->ra_name) == 0); - if (rv == 0) - return (rv); -#ifdef DEBUG - if (rv && oneshot) { - oneshot = 0; - printf("Qlogic ISP Driver, OpenBSD (sbus) Platform Version " - "%d.%d Core Version %d.%d\n", - ISP_PLATFORM_VERSION_MAJOR, ISP_PLATFORM_VERSION_MINOR, - ISP_CORE_VERSION_MAJOR, ISP_CORE_VERSION_MINOR); - } -#endif - if (ca->ca_bustype == BUS_SBUS) - return (1); - ra->ra_len = NBPG; - return (probeget(ra->ra_vaddr, 1) != -1); -} - -static void -isp_sbus_attach(struct device *parent, struct device *self, void *aux) -{ - int freq, storebp = 0; - struct confargs *ca = aux; - struct bootpath *bp; - struct isp_sbussoftc *sbc = (struct isp_sbussoftc *) self; - struct ispsoftc *isp = &sbc->sbus_isp; - volatile u_int16_t *fpga_reg; - - if (ca->ca_ra.ra_nintr != 1) { - printf(": expected 1 interrupt, got %d\n", ca->ca_ra.ra_nintr); - return; - } - - printf("\n"); - - sbc->sbus_pri = ca->ca_ra.ra_intr[0].int_pri; - sbc->sbus_mdvec = mdvec; - - if (ca->ca_ra.ra_vaddr) { - sbc->sbus_reg = (volatile u_int16_t *) ca->ca_ra.ra_vaddr; - } else { - sbc->sbus_reg = (volatile u_int16_t *) - mapiodev(ca->ca_ra.ra_reg, 0, ca->ca_ra.ra_len); - } - sbc->sbus_node = ca->ca_ra.ra_node; - - freq = getpropint(ca->ca_ra.ra_node, "clock-frequency", 0); - if (freq) { - /* - * Convert from HZ to MHz, rounding up. - */ - freq = (freq + 500000)/1000000; -#if 0 - printf("%s: %d MHz\n", self->dv_xname, freq); -#endif - } - sbc->sbus_mdvec.dv_clock = freq; - - DEFAULT_IID(isp) = - getpropint(ca->ca_ra.ra_node, "scsi-initiator-id", 7); - - if ((bp = ca->ca_ra.ra_bp) != NULL) { - if (bp->val[0] == ca->ca_slot && - bp->val[1] == ca->ca_offset) { - if (strcmp("isp", bp->name) == 0 || - strcmp("QLGC,isp", bp->name) == 0 || - strcmp("PTI,isp", bp->name) == 0 || - strcmp("ptisp", bp->name) == 0) { - storebp = 1; - } - } - } - - /* - * XXX: Now figure out what the proper burst sizes, etc., to use. - */ - sbc->sbus_mdvec.dv_conf1 |= BIU_SBUS_CONF1_FIFO_8; - - /* - * Some early versions of the PTI SBus adapter - * would fail in trying to download (via poking) - * FW. We give up on them. - */ - if (strcmp("PTI,ptisp", ca->ca_ra.ra_name) == 0 || - strcmp("ptisp", ca->ca_ra.ra_name) == 0) { - sbc->sbus_mdvec.dv_ispfw = NULL; - } - - isp->isp_mdvec = &sbc->sbus_mdvec; - isp->isp_bustype = ISP_BT_SBUS; - isp->isp_type = ISP_HA_SCSI_UNKNOWN; - isp->isp_param = &sbc->sbus_dev; - bzero(isp->isp_param, sizeof (sdparam)); - - sbc->sbus_poff[BIU_BLOCK >> _BLK_REG_SHFT] = BIU_REGS_OFF; - sbc->sbus_poff[MBOX_BLOCK >> _BLK_REG_SHFT] = SBUS_MBOX_REGS_OFF; - sbc->sbus_poff[SXP_BLOCK >> _BLK_REG_SHFT] = SBUS_SXP_REGS_OFF; - sbc->sbus_poff[RISC_BLOCK >> _BLK_REG_SHFT] = SBUS_RISC_REGS_OFF; - sbc->sbus_poff[DMA_BLOCK >> _BLK_REG_SHFT] = DMA_REGS_OFF; - - if (strcmp("SUNW,qlc", ca->ca_ra.ra_name) == 0 || - strcmp("QLGC,qla", ca->ca_ra.ra_name) == 0) { - isp->isp_mdvec = &mdvec_2200; - isp->isp_bustype = ISP_BT_PCI; - isp->isp_type = ISP_HA_FC_2200; - isp->isp_param = malloc(sizeof(fcparam), M_DEVBUF, - M_NOWAIT | M_ZERO); - if (isp->isp_param == NULL) { - printf("%s: no mem for sdparam table\n", - self->dv_xname); - return; - } - sbc->sbus_poff[BIU_BLOCK >> _BLK_REG_SHFT] = - 0x100 + BIU_REGS_OFF; - sbc->sbus_poff[MBOX_BLOCK >> _BLK_REG_SHFT] = - 0x100 + PCI_MBOX_REGS2100_OFF; - sbc->sbus_poff[SXP_BLOCK >> _BLK_REG_SHFT] = - 0x100 + PCI_SXP_REGS_OFF; - sbc->sbus_poff[RISC_BLOCK >> _BLK_REG_SHFT] = - 0x100 + PCI_RISC_REGS_OFF; - sbc->sbus_poff[DMA_BLOCK >> _BLK_REG_SHFT] = - 0x100 + DMA_REGS_OFF; - - fpga_reg = mapiodev(&ca->ca_ra.ra_reg[1], 0, - ca->ca_ra.ra_reg[1].rr_len); - fpga_reg[0x80] &= ~htole16(0x700); - fpga_reg[0x80] |= htole16(0x300); - } - - /* Establish interrupt channel */ - sbc->sbus_ih.ih_fun = (void *) isp_sbus_intr; - sbc->sbus_ih.ih_arg = sbc; - intr_establish(sbc->sbus_pri, &sbc->sbus_ih, IPL_BIO, self->dv_xname); - - /* - * Set up logging levels. - */ -#ifdef ISP_LOGDEFAULT - isp->isp_dblev = ISP_LOGDEFAULT; -#else - isp->isp_dblev = ISP_LOGWARN|ISP_LOGERR; -#if 0 - isp->isp_dblev |= ISP_LOGDEBUG1|ISP_LOGDEBUG2; -#endif -#ifdef DEBUG - isp->isp_dblev |= ISP_LOGDEBUG0|ISP_LOGCONFIG|ISP_LOGINFO; -#endif -#endif - isp->isp_confopts = self->dv_cfdata->cf_flags; - isp->isp_role = ISP_DEFAULT_ROLES; - - ISP_LOCK(isp); - isp->isp_osinfo.no_mbox_ints = 1; - isp_reset(isp); - if (isp->isp_state != ISP_RESETSTATE) { - ISP_UNLOCK(isp); - return; - } - ISP_ENABLE_INTS(isp); - isp_init(isp); - if (isp->isp_state != ISP_INITSTATE) { - isp_uninit(isp); - ISP_UNLOCK(isp); - return; - } - - /* - * do generic attach. - */ - if (storebp) { - /* - * We're the booting HBA. - * - * Override the bootpath name with our driver name - * so we will do the correct matching and and store - * the next component's boot path entry, also so a - * successful match will occur. - */ - bcopy("isp", bp->name, 4); - bp++; - bootpath_store(1, bp); - } - isp_attach(isp); - if (isp->isp_state != ISP_RUNSTATE) { - isp_uninit(isp); - } - if (storebp) { - bootpath_store(1, NULL); - } - ISP_UNLOCK(isp); -} - -#define IspVirt2Off(a, x) \ - (((struct isp_sbussoftc *)a)->sbus_poff[((x) & _BLK_REG_MASK) >> \ - _BLK_REG_SHFT] + ((x) & 0xff)) - -#define BXR2(pcs, off) (sbc->sbus_reg[off >> 1]) - -static int -isp_sbus_rd_isr(struct ispsoftc *isp, u_int32_t *isrp, - u_int16_t *semap, u_int16_t *mbp) -{ - struct isp_sbussoftc *sbc = (struct isp_sbussoftc *) isp; - volatile u_int16_t isr, sema; - - isr = BXR2(pcs, IspVirt2Off(isp, BIU_ISR)); - sema = BXR2(pcs, IspVirt2Off(isp, BIU_SEMA)); - isp_prt(isp, ISP_LOGDEBUG3, "ISR 0x%x SEMA 0x%x", isr, sema); - isr &= INT_PENDING_MASK(isp); - sema &= BIU_SEMA_LOCK; - if (isr == 0 && sema == 0) { - return (0); - } - *isrp = isr; - if ((*semap = sema) != 0) { - *mbp = BXR2(pcs, IspVirt2Off(isp, OUTMAILBOX0)); - } - return (1); -} - -static int -isp_sbus_rd_isr_2200(struct ispsoftc *isp, u_int32_t *isrp, - u_int16_t *semap, u_int16_t *mbp) -{ - struct isp_sbussoftc *sbc = (struct isp_sbussoftc *) isp; - volatile u_int16_t isr, sema; - - isr = letoh16(BXR2(pcs, IspVirt2Off(isp, BIU_ISR))); - sema = letoh16(BXR2(pcs, IspVirt2Off(isp, BIU_SEMA))); - isp_prt(isp, ISP_LOGDEBUG3, "ISR 0x%x SEMA 0x%x", isr, sema); - isr &= INT_PENDING_MASK(isp); - sema &= BIU_SEMA_LOCK; - if (isr == 0 && sema == 0) { - return (0); - } - *isrp = isr; - if ((*semap = sema) != 0) { - *mbp = letoh16(BXR2(pcs, IspVirt2Off(isp, OUTMAILBOX0))); - } - return (1); -} - -static u_int32_t -isp_sbus_rd_reg(struct ispsoftc *isp, int regoff) -{ - struct isp_sbussoftc *sbc = (struct isp_sbussoftc *) isp; - int offset = sbc->sbus_poff[(regoff & _BLK_REG_MASK) >> _BLK_REG_SHFT]; - offset += (regoff & 0xff); - return ((u_int16_t) sbc->sbus_reg[offset >> 1]); -} - -static void -isp_sbus_wr_reg(struct ispsoftc *isp, int regoff, u_int32_t val) -{ - struct isp_sbussoftc *sbc = (struct isp_sbussoftc *) isp; - int offset = sbc->sbus_poff[(regoff & _BLK_REG_MASK) >> _BLK_REG_SHFT]; - offset += (regoff & 0xff); - sbc->sbus_reg[offset >> 1] = val; -} - -static u_int32_t -isp_sbus_rd_reg_2200(struct ispsoftc *isp, int regoff) -{ - struct isp_sbussoftc *sbc = (struct isp_sbussoftc *) isp; - int offset = sbc->sbus_poff[(regoff & _BLK_REG_MASK) >> _BLK_REG_SHFT]; - offset += (regoff & 0xff); - return ((u_int16_t) letoh16(sbc->sbus_reg[offset >> 1])); -} - -static void -isp_sbus_wr_reg_2200(struct ispsoftc *isp, int regoff, u_int32_t val) -{ - struct isp_sbussoftc *sbc = (struct isp_sbussoftc *) isp; - int offset = sbc->sbus_poff[(regoff & _BLK_REG_MASK) >> _BLK_REG_SHFT]; - offset += (regoff & 0xff); - sbc->sbus_reg[offset >> 1] = htole16(val); -} - -static int -isp_sbus_mbxdma(struct ispsoftc *isp) -{ - struct isp_sbussoftc *sbc = (struct isp_sbussoftc *) isp; - size_t len; - - if (isp->isp_rquest_dma) /* been here before? */ - return (0); - - /* - * NOTE: Since most Sun machines aren't I/O coherent, - * map the mailboxes through kdvma space to force them - * to be uncached. - */ - - len = isp->isp_maxcmds * sizeof (XS_T); - isp->isp_xflist = (XS_T **) malloc(len, M_DEVBUF, M_WAITOK | M_ZERO); - len = isp->isp_maxcmds * sizeof (vaddr_t); - sbc->sbus_kdma_allocs = (vaddr_t *) malloc(len, M_DEVBUF, - M_WAITOK | M_ZERO); - - /* - * Allocate and map the request queue. - */ - len = ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN(isp)); - isp->isp_rquest = (volatile caddr_t)malloc(len, M_DEVBUF, M_NOWAIT); - if (isp->isp_rquest == 0) { - printf("%s: cannot allocate request queue\n", isp->isp_name); - return (1); - } - isp->isp_rquest_dma = (u_int32_t) - kdvma_mapin((caddr_t)isp->isp_rquest, len, 0); - if (isp->isp_rquest_dma == 0) { - printf("%s: can't mapin request queue\n", isp->isp_name); - return (1); - } - - /* - * Allocate and map the result queue. - */ - len = ISP_QUEUE_SIZE(RESULT_QUEUE_LEN(isp)); - isp->isp_result = (volatile caddr_t)malloc(len, M_DEVBUF, M_NOWAIT); - if (isp->isp_result == 0) { - printf("%s: cannot allocate result queue\n", isp->isp_name); - return (1); - } - isp->isp_result_dma = (u_int32_t) - kdvma_mapin((caddr_t)isp->isp_result, len, 0); - if (isp->isp_result_dma == 0) { - printf("%s: can't mapin result queue\n", isp->isp_name); - return (1); - } - - if (IS_FC(isp)) { - /* - * Allocate and map the FC scratch area. - */ - len = ISP2100_SCRLEN; - FCPARAM(isp)->isp_scratch = malloc(len, M_DEVBUF, M_NOWAIT); - if (FCPARAM(isp)->isp_scratch == 0) { - printf("%s: cannot allocate FC scratch area\n", - isp->isp_name); - return (1); - } - FCPARAM(isp)->isp_scdma = (u_int32_t) - kdvma_mapin((caddr_t)FCPARAM(isp)->isp_scratch, len, 0); - if (FCPARAM(isp)->isp_scdma == 0) { - printf("%s: can't mapin FC scratch area\n", - isp->isp_name); - return (1); - } - } - - return (0); -} - -/* - * TODO: If kdvma_mapin fails, try using multiple smaller chunks.. - */ - -static int -isp_sbus_dmasetup(struct ispsoftc *isp, struct scsi_xfer *xs, ispreq_t *rq, - u_int32_t *iptrp, u_int32_t optr) -{ - struct isp_sbussoftc *sbc = (struct isp_sbussoftc *) isp; - ispreq_t *qe; - ispcontreq_t *crq; - vaddr_t kdvma; - int dosleep = (xs->flags & SCSI_NOSLEEP) != 0; - - qe = (ispreq_t *) ISP_QUEUE_ENTRY(isp->isp_rquest, isp->isp_reqidx); - if (xs->datalen == 0) { - rq->req_seg_count = 1; - goto mbxsync; - } - if (CPU_ISSUN4M) { - kdvma = (vaddr_t) - kdvma_mapin((caddr_t)xs->data, xs->datalen, dosleep); - if (kdvma == (vaddr_t) 0) { - XS_SETERR(xs, HBA_BOTCH); - return (CMD_COMPLETE); - } - } else { - kdvma = (vaddr_t) xs->data; - } - - if (sbc->sbus_kdma_allocs[isp_handle_index(rq->req_handle)] != 0) { - panic("%s: kdma handle already allocated", isp->isp_name); - /* NOTREACHED */ - } - if (XS_CDBLEN(xs) > 12) { - crq = (ispcontreq_t *) ISP_QUEUE_ENTRY(isp->isp_rquest, *iptrp); - *iptrp = ISP_NXT_QENTRY(*iptrp, RQUEST_QUEUE_LEN(isp)); - if (*iptrp == optr) { - printf("%s: Request Queue Overflow++\n", isp->isp_name); - if (CPU_ISSUN4M) { - dvma_mapout(kdvma, - (vaddr_t) xs->data, xs->datalen); - } - XS_SETERR(xs, HBA_BOTCH); - return (CMD_EAGAIN); - } - } else { - crq = NULL; - } - sbc->sbus_kdma_allocs[isp_handle_index(rq->req_handle)] = kdvma; - if (xs->flags & SCSI_DATA_IN) { - rq->req_flags |= REQFLAG_DATA_IN; - } else { - rq->req_flags |= REQFLAG_DATA_OUT; - } - if (crq) { - rq->req_seg_count = 2; - rq->req_dataseg[0].ds_count = 0; - rq->req_dataseg[0].ds_base = 0; - bzero((void *)crq, sizeof (*crq)); - crq->req_header.rqs_entry_count = 1; - crq->req_header.rqs_entry_type = RQSTYPE_DATASEG; - crq->req_dataseg[0].ds_count = xs->datalen; - crq->req_dataseg[0].ds_base = (u_int32_t) kdvma; - ISP_SBUSIFY_ISPHDR(isp, &crq->req_header) - } else { - rq->req_dataseg[0].ds_count = xs->datalen; - rq->req_dataseg[0].ds_base = (u_int32_t) kdvma; - rq->req_seg_count = 1; - } - -mbxsync: - ISP_SWIZZLE_REQUEST(isp, rq); - bcopy(rq, qe, sizeof (ispreq_t)); - return (CMD_QUEUED); -} - -static void -isp_sbus_dmateardown(struct ispsoftc *isp, XS_T *xs, u_int32_t handle) -{ - struct isp_sbussoftc *sbc = (struct isp_sbussoftc *) isp; - vaddr_t kdvma; - - if (xs->flags & SCSI_DATA_IN) { - cpuinfo.cache_flush(xs->data, xs->datalen - xs->resid); - } - if (sbc->sbus_kdma_allocs[isp_handle_index(handle)] == (vaddr_t) 0) { - panic("%s: kdma handle not already allocated", isp->isp_name); - /* NOTREACHED */ - } - kdvma = sbc->sbus_kdma_allocs[isp_handle_index(handle)]; - sbc->sbus_kdma_allocs[isp_handle_index(handle)] = (vaddr_t) 0; - if (CPU_ISSUN4M) { - dvma_mapout(kdvma, (vaddr_t) xs->data, xs->datalen); - } -} - -static int -isp_sbus_intr(void *arg) -{ - u_int32_t isr; - u_int16_t sema, mbox; - struct ispsoftc *isp = (struct ispsoftc *)arg; - - isp->isp_intcnt++; - if (ISP_READ_ISR(isp, &isr, &sema, &mbox) == 0) { - isp->isp_intbogus++; - return (0); - } else { - isp->isp_osinfo.onintstack = 1; - isp_intr(isp, isr, sema, mbox); - isp->isp_osinfo.onintstack = 0; - return (1); - } -} diff --git a/sys/conf/files b/sys/conf/files index af05b5c91b7..18b1cd1053e 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -1,4 +1,4 @@ -# $OpenBSD: files,v 1.592 2015/05/11 06:46:21 ratchov Exp $ +# $OpenBSD: files,v 1.593 2015/06/19 11:12:24 jmatthew Exp $ # $NetBSD: files,v 1.87 1996/05/19 17:17:50 jonathan Exp $ # @(#)files.newconf 7.5 (Berkeley) 5/10/93 @@ -184,12 +184,6 @@ file dev/ic/ami.c ami device mfi: scsi file dev/ic/mfi.c mfi -# QLogic ISP 10x0 SCSI Controllers -device isp: scsi -file dev/ic/isp.c isp -file dev/ic/isp_openbsd.c isp -file dev/ic/isp_library.c isp - # QLogic ISP SCSI Controllers device qlw: scsi file dev/ic/qlw.c qlw @@ -198,11 +192,6 @@ file dev/ic/qlw.c qlw device qla: scsi file dev/ic/qla.c qla -# QLogic firmware shared between qla and isp -file dev/microcode/isp/isp_fw2100.c qla | isp_pci -file dev/microcode/isp/isp_fw2200.c qla | isp -file dev/microcode/isp/isp_fw2300.c qla | isp_pci - # Advanced Host Controller Interface for Serial ATA device ahci: scsi, atascsi file dev/ic/ahci.c ahci | ahci_pci | ahci_jmb needs-flag diff --git a/sys/dev/ic/isp.c b/sys/dev/ic/isp.c deleted file mode 100644 index 2fcbd341e82..00000000000 --- a/sys/dev/ic/isp.c +++ /dev/null @@ -1,7248 +0,0 @@ -/* $OpenBSD: isp.c,v 1.53 2014/02/14 05:17:05 jmatthew Exp $ */ -/* $FreeBSD: src/sys/dev/isp/isp.c,v 1.150 2008/12/15 21:42:38 marius Exp $*/ -/*- - * Copyright (c) 1997-2007 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. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY 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 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. - */ - -/* - * Machine and OS Independent (well, as best as possible) - * code for the QLogic ISP SCSI and FC-SCSI adapters. - */ - -/* - * 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 <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD$"); -#include <dev/ic/isp_netbsd.h> -#endif -#ifdef __FreeBSD__ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/dev/isp/isp.c,v 1.149 2007/07/10 07:55:04 mjacob Exp $"); -#include <dev/isp/isp_freebsd.h> -#endif -#ifdef __OpenBSD__ -#include <dev/ic/isp_openbsd.h> -#endif -#ifdef __linux__ -#include "isp_linux.h" -#endif -#ifdef __svr4__ -#include "isp_solaris.h" -#endif - -/* - * General defines - */ - -#define MBOX_DELAY_COUNT 1000000 / 100 -#define ISP_MARK_PORTDB(a, b) \ - isp_prt(isp, ISP_LOGSANCFG, "line %d: markportdb", __LINE__); \ - isp_mark_portdb(a, b) - -/* - * Local static data - */ -static const char fconf[] = - "PortDB[%d] changed:\n current =(0x%x@0x%06x 0x%08x%08x 0x%08x%08x)\n" - " database=(0x%x@0x%06x 0x%08x%08x 0x%08x%08x)"; -static const char notresp[] = - "Not RESPONSE in RESPONSE Queue (type 0x%x) @ idx %d (next %d) nlooked %d"; -static const char xact1[] = - "HBA attempted queued transaction with disconnect not set for %d.%d.%d"; -static const char xact2[] = - "HBA attempted queued transaction to target routine %d on target %d bus %d"; -static const char xact3[] = - "HBA attempted queued cmd for %d.%d.%d when queueing disabled"; -static const char pskip[] = - "SCSI phase skipped for target %d.%d.%d"; -static const char topology[] = - "HBA PortID 0x%06x N-Port Handle %d, Connection Topology '%s'"; -static const char ourwwn[] = - "HBA WWNN 0x%08x%08x HBA WWPN 0x%08x%08x"; -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. - */ -int isp_parse_async(struct ispsoftc *, u_int16_t); -int isp_handle_other_response(struct ispsoftc *, int, isphdr_t *, - u_int32_t *); -void -isp_parse_status(struct ispsoftc *, ispstatusreq_t *, XS_T *, long *); -void -isp_parse_status_24xx(struct ispsoftc *, isp24xx_statusreq_t *, XS_T *, long *); -void isp_fastpost_complete(struct ispsoftc *, u_int16_t); -int isp_mbox_continue(struct ispsoftc *); -void isp_scsi_init(struct ispsoftc *); -void isp_scsi_channel_init(struct ispsoftc *, int); -void isp_fibre_init(struct ispsoftc *); -void isp_mark_portdb(struct ispsoftc *, int); -int isp_plogx(struct ispsoftc *, u_int16_t, u_int32_t, int, int); -int isp_port_login(struct ispsoftc *, u_int16_t, u_int32_t); -int isp_port_logout(struct ispsoftc *, u_int16_t, u_int32_t); -int isp_getpdb(struct ispsoftc *, u_int16_t, isp_pdb_t *, int); -u_int64_t isp_get_portname(struct ispsoftc *, int, int); -int isp_fclink_test(struct ispsoftc *, int); -const char *ispfc_fw_statename(int); -int isp_pdb_sync(struct ispsoftc *); -int isp_scan_loop(struct ispsoftc *); -int isp_gid_ft_sns(struct ispsoftc *); -int isp_gid_ft_ct_passthru(struct ispsoftc *); -int isp_scan_fabric(struct ispsoftc *); -int isp_login_device(struct ispsoftc *, u_int32_t, isp_pdb_t *, u_int16_t *); -int isp_register_fc4_type(struct ispsoftc *); -u_int16_t isp_nxt_handle(struct ispsoftc *, u_int16_t); -void isp_fw_state(struct ispsoftc *); -void isp_mboxcmd_qnw(struct ispsoftc *, mbreg_t *, int); -void isp_mboxcmd(struct ispsoftc *, mbreg_t *); - -void isp_update(struct ispsoftc *); -void isp_update_bus(struct ispsoftc *, int); -void isp_setdfltparm(struct ispsoftc *, int); -void isp_setdfltfcparm(struct ispsoftc *); -int isp_read_nvram(struct ispsoftc *); -void isp_rdnvram_word(struct ispsoftc *, int, u_int16_t *); -void isp_parse_nvram_1020(struct ispsoftc *, u_int8_t *); -void isp_parse_nvram_1080(struct ispsoftc *, int, u_int8_t *); -void isp_parse_nvram_12160(struct ispsoftc *, int, u_int8_t *); -void isp_fix_nvram_wwns(struct ispsoftc *); -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_int32_t code_org; - int loops, i, dodnld = 1; - static const char *btype = "????"; - static const char dcrc[] = "Downloaded RISC Code Checksum Failure"; - - 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); - MEMZERO(&mbs, sizeof (mbs)); - mbs.param[0] = MBOX_ABOUT_FIRMWARE; - mbs.logval = MBLOGNONE; - isp_mboxcmd(isp, &mbs); - 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; - } - - ISP_DISABLE_INTS(isp); - - /* - * Pick an initial maxcmds value which will be used - * to allocate xflist pointer space. It may be changed - * later by the firmware. - */ - if (IS_2322(isp)) { - isp->isp_maxcmds = 2048; - } else if (IS_23XX(isp) || IS_2200(isp)) { - isp->isp_maxcmds = 1024; - } else { - isp->isp_maxcmds = 512; - } - - /* - * Set up DMA for the request and result queues. - * - * We do this now so we can use the request queue - * for a dma - */ - if (ISP_MBOXDMASETUP(isp) != 0) { - isp_prt(isp, ISP_LOGERR, "Cannot setup DMA"); - return; - } - - - /* - * 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; - case ISP_HA_FC_2322: - btype = "2322"; - 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_ULTRA3(isp)) { - sdparam *sdp = isp->isp_param; - - isp->isp_clock = 100; - - if (IS_10160(isp)) - btype = "10160"; - else if (IS_12160(isp)) - btype = "12160"; - else - btype = "<UNKLVD>"; - sdp->isp_lvdmode = 1; - - if (IS_DUALBUS(isp)) { - sdp++; - sdp->isp_lvdmode = 1; - } - } 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 - btype = "<UNKLVD>"; - - 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); - - /* - * 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"); - ISP_RESET0(isp); - 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); - ISP_WRITE(isp, BIU_SEMA, 0); - - - /* - * Post-RISC Reset stuff. - */ - 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); - } - if (SDPARAM(isp)->isp_ptisp) { - if (SDPARAM(isp)->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); - } - ISP_WRITE(isp, HCCR, HCCR_CMD_RELEASE); - } 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); - } - - 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); - - - /* - * 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_2312(isp)) { - USEC_DELAY(100); - } else { - loops = MBOX_DELAY_COUNT; - while (ISP_READ(isp, OUTMAILBOX0) == MBOX_BUSY) { - USEC_DELAY(100); - if (--loops < 0) { - ISP_RESET0(isp); - 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. - */ - MEMZERO(&mbs, sizeof (mbs)); - mbs.param[0] = MBOX_NO_OP; - mbs.logval = MBLOGALL; - isp_mboxcmd(isp, &mbs); - if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { - ISP_RESET0(isp); - return; - } - - if (IS_SCSI(isp)) { - MEMZERO(&mbs, sizeof (mbs)); - 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; - mbs.param[6] = 0x0000; - mbs.param[7] = 0x0000; - mbs.logval = MBLOGALL; - isp_mboxcmd(isp, &mbs); - if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { - ISP_RESET0(isp); - return; - } - if (mbs.param[1] != 0xdead || mbs.param[2] != 0xbeef || - mbs.param[3] != 0xffff || mbs.param[4] != 0x1111 || - mbs.param[5] != 0xa5a5) { - ISP_RESET0(isp); - 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 && IS_23XX(isp)) { - const u_int16_t *ptr = isp->isp_mdvec->dv_ispfw; - u_int16_t wi, wl, segno; - u_int32_t la; - - la = code_org; - segno = 0; - - for (;;) { - u_int32_t nxtaddr; - -#ifndef SMALL_KERNEL - isp_prt(isp, ISP_LOGDEBUG0, - "load 0x%x words of code at load address 0x%x", - ptr[3], la); -#endif - - wi = 0; - wl = ptr[3]; - - while (wi < ptr[3]) { - u_int16_t *cp; - u_int32_t nw; - - nw = ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN(isp)) >> 1; - if (nw > wl) { - nw = wl; - } - if (nw > (1 << 15)) { - nw = 1 << 15; - } - cp = isp->isp_rquest; - for (i = 0; i < nw; i++) { - ISP_IOXPUT_16(isp, ptr[wi++], &cp[i]); - wl--; - } - MEMORYBARRIER(isp, SYNC_REQUEST, - 0, ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN(isp))); - MEMZERO(&mbs, sizeof (mbs)); - mbs.param[0] = MBOX_LOAD_RISC_RAM; - mbs.param[1] = la; - mbs.param[2] = DMA_WD1(isp->isp_rquest_dma); - mbs.param[3] = DMA_WD0(isp->isp_rquest_dma); - mbs.param[4] = nw; - mbs.param[6] = DMA_WD3(isp->isp_rquest_dma); - mbs.param[7] = DMA_WD2(isp->isp_rquest_dma); - mbs.param[8] = la >> 16; - mbs.logval = MBLOGALL; - isp_mboxcmd(isp, &mbs); - if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { - isp_prt(isp, ISP_LOGERR, - "F/W Risc Ram Load Failed"); - ISP_RESET0(isp); - return; - } - la += nw; - } - - if (!IS_2322(isp)) { - /* - * Verify that it downloaded correctly. - */ - MEMZERO(&mbs, sizeof (mbs)); - mbs.param[0] = MBOX_VERIFY_CHECKSUM; - mbs.param[1] = code_org; - mbs.logval = MBLOGNONE; - isp_mboxcmd(isp, &mbs); - if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { - isp_prt(isp, ISP_LOGERR, dcrc); - ISP_RESET0(isp); - return; - } - break; - } - - if (++segno == 3) { - break; - } - - /* - * If we're a 2322, the firmware actually comes in - * three chunks. We loaded the first at the code_org - * address. The other two chunks, which follow right - * after each other in memory here, get loaded at - * addresses specfied at offset 0x9..0xB. - */ - - nxtaddr = ptr[3]; - ptr = &ptr[nxtaddr]; - la = ptr[5] | ((ptr[4] & 0x3f) << 16); - } - isp->isp_loaded_fw = 1; - } else if (dodnld) { - union { - const u_int16_t *cp; - u_int16_t *np; - } u; - u.cp = isp->isp_mdvec->dv_ispfw; - isp->isp_mbxworkp = &u.np[1]; - isp->isp_mbxwrk0 = u.np[3] - 1; - isp->isp_mbxwrk1 = code_org + 1; - MEMZERO(&mbs, sizeof (mbs)); - mbs.param[0] = MBOX_WRITE_RAM_WORD; - mbs.param[1] = code_org; - mbs.param[2] = u.np[0]; - mbs.logval = MBLOGNONE; - isp_mboxcmd(isp, &mbs); - if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { - isp_prt(isp, ISP_LOGERR, - "F/W download failed at word %d", - isp->isp_mbxwrk1 - code_org); - ISP_RESET0(isp); - return; - } - /* - * Verify that it downloaded correctly. - */ - MEMZERO(&mbs, sizeof (mbs)); - mbs.param[0] = MBOX_VERIFY_CHECKSUM; - mbs.param[1] = code_org; - mbs.logval = MBLOGNONE; - isp_mboxcmd(isp, &mbs); - if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { - isp_prt(isp, ISP_LOGERR, dcrc); - ISP_RESET0(isp); - return; - } - isp->isp_loaded_fw = 1; - } else { - isp->isp_loaded_fw = 0; -#ifndef SMALL_KERNEL - isp_prt(isp, ISP_LOGDEBUG2, "skipping f/w download"); -#endif - } - - /* - * Now start it rolling. - * - * If we didn't actually download f/w, - * we still need to (re)start it. - */ - - - MEMZERO(&mbs, sizeof (mbs)); - mbs.timeout = 1000000; - mbs.param[0] = MBOX_EXEC_FIRMWARE; - if (IS_2322(isp)) { - mbs.param[1] = code_org; - if (isp->isp_loaded_fw) { - mbs.param[2] = 0; - } else { - mbs.param[2] = 1; - } - } else { - mbs.param[1] = code_org; - } - - mbs.logval = MBLOGALL; - isp_mboxcmd(isp, &mbs); - if (IS_2322(isp)) { - if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { - ISP_RESET0(isp); - return; - } - } - - /* - * Give it a chance to finish starting up. - */ - USEC_DELAY(250000); - - if (IS_SCSI(isp)) { - /* - * Set CLOCK RATE, but only if asked to. - */ - if (isp->isp_clock) { - MEMZERO(&mbs, sizeof (mbs)); - mbs.param[0] = MBOX_SET_CLOCK_RATE; - mbs.param[1] = isp->isp_clock; - mbs.logval = MBLOGNONE; - isp_mboxcmd(isp, &mbs); - /* we will try not to care if this fails */ - } - } - - MEMZERO(&mbs, sizeof (mbs)); - mbs.param[0] = MBOX_ABOUT_FIRMWARE; - mbs.logval = MBLOGALL; - isp_mboxcmd(isp, &mbs); - if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { - ISP_RESET0(isp); - 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_LOGALL, - "board type %s rev 0x%x, %s firmware rev %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 later f/w is greater than 1.X.0. - */ - if ((ISP_FW_OLDER_THAN(isp, 1, 17, 1))) { -#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]; -#ifndef SMALL_KERNEL - isp_prt(isp, ISP_LOGDEBUG0, - "Firmware Attributes = 0x%x", mbs.param[6]); -#endif - } - FCPARAM(isp)->isp_2klogin = 0; - FCPARAM(isp)->isp_sccfw = 0; - FCPARAM(isp)->isp_tmode = 0; - if (FCPARAM(isp)->isp_fwattr & ISP_FW_ATTR_SCCLUN) { - FCPARAM(isp)->isp_sccfw = 1; - } - if (FCPARAM(isp)->isp_fwattr & ISP_FW_ATTR_2KLOGINS) { - FCPARAM(isp)->isp_2klogin = 1; - FCPARAM(isp)->isp_sccfw = 1; - } - if (FCPARAM(isp)->isp_fwattr & ISP_FW_ATTR_TMODE) { - FCPARAM(isp)->isp_tmode = 1; - } - if (FCPARAM(isp)->isp_2klogin) { - isp_prt(isp, ISP_LOGCONFIG, "2K Logins Supported"); - } - } - - 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]); - } - - { - MEMZERO(&mbs, sizeof (mbs)); - mbs.param[0] = MBOX_GET_FIRMWARE_STATUS; - mbs.logval = MBLOGALL; - isp_mboxcmd(isp, &mbs); - if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { - ISP_RESET0(isp); - return; - } - if (isp->isp_maxcmds >= mbs.param[2]) { - isp->isp_maxcmds = mbs.param[2]; - } - } - isp_prt(isp, ISP_LOGCONFIG, - "%d max I/O command limit set", isp->isp_maxcmds); - isp_fw_state(isp); - - 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 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_sccfw) { - isp->isp_maxluns = 16384; - } else { - isp->isp_maxluns = 16; - } - } - /* - * Must do this first to get defaults established. - */ - if (IS_SCSI(isp)) { - isp_setdfltparm(isp, 0); - if (IS_DUALBUS(isp)) { - isp_setdfltparm(isp, 1); - } - } else { - isp_setdfltfcparm(isp); - } - -} - -/* - * Initialize Parameters of Hardware to a known state. - * - * Locks are held before coming here. - */ - -void -isp_init(struct ispsoftc *isp) -{ - if (IS_FC(isp)) { - /* - * Do this *before* initializing the firmware. - */ - ISP_MARK_PORTDB(isp, 0); - FCPARAM(isp)->isp_fwstate = FW_CONFIG_WAIT; - FCPARAM(isp)->isp_loopstate = LOOP_NIL; - - if (isp->isp_role != ISP_ROLE_NONE) { - isp_fibre_init(isp); - } - } else { - isp_scsi_init(isp); - } -} - -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. - */ - MEMZERO(&mbs, sizeof (mbs)); - 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; - mbs.logval = MBLOGALL; - isp_mboxcmd(isp, &mbs); - if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { - return; - } - - /* - * Set ASYNC DATA SETUP time. This is very important. - */ - MEMZERO(&mbs, sizeof (mbs)); - 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; - mbs.logval = MBLOGALL; - isp_mboxcmd(isp, &mbs); - if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { - return; - } - - /* - * Set ACTIVE Negation State. - */ - MEMZERO(&mbs, sizeof (mbs)); - 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); - mbs.logval = MBLOGNONE; - isp_mboxcmd(isp, &mbs); - 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 - */ - MEMZERO(&mbs, sizeof (mbs)); - mbs.param[0] = MBOX_SET_TAG_AGE_LIMIT; - mbs.param[1] = sdp_chan0->isp_tag_aging; - mbs.param[2] = sdp_chan1->isp_tag_aging; - mbs.logval = MBLOGALL; - isp_mboxcmd(isp, &mbs); - 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. - */ - MEMZERO(&mbs, sizeof (mbs)); - mbs.param[0] = MBOX_SET_SELECT_TIMEOUT; - mbs.param[1] = sdp_chan0->isp_selection_timeout; - mbs.param[2] = sdp_chan1->isp_selection_timeout; - mbs.logval = MBLOGALL; - isp_mboxcmd(isp, &mbs); - 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)) { - MEMZERO(&mbs, sizeof (mbs)); - 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); - mbs.logval = MBLOGALL; - isp_mboxcmd(isp, &mbs); - if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { - return; - } - isp->isp_residx = mbs.param[5]; - - MEMZERO(&mbs, sizeof (mbs)); - 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); - mbs.logval = MBLOGALL; - isp_mboxcmd(isp, &mbs); - if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { - return; - } - isp->isp_reqidx = isp->isp_reqodx = mbs.param[4]; - } else { - MEMZERO(&mbs, sizeof (mbs)); - 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; - mbs.logval = MBLOGALL; - isp_mboxcmd(isp, &mbs); - if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { - return; - } - isp->isp_residx = mbs.param[5]; - - MEMZERO(&mbs, sizeof (mbs)); - 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; - mbs.logval = MBLOGALL; - isp_mboxcmd(isp, &mbs); - 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. - */ - - MEMZERO(&mbs, sizeof (mbs)); - 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 - if (IS_ULTRA2(isp) || IS_1240(isp)) - mbs.param[1] |= FW_FEATURE_FAST_POST; -#endif - if (mbs.param[1] != 0) { - u_int16_t sfeat = mbs.param[1]; - mbs.logval = MBLOGALL; - isp_mboxcmd(isp, &mbs); - 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; -} - -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. - */ - MEMZERO(&mbs, sizeof (mbs)); - mbs.param[0] = MBOX_SET_INIT_SCSI_ID; - mbs.param[1] = (channel << 7) | sdp->isp_initiator_id; - mbs.logval = MBLOGALL; - isp_mboxcmd(isp, &mbs); - 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 - MEMZERO(&mbs, sizeof (mbs)); - 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); - } -#ifndef SMALL_KERNEL - 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); -#endif - mbs.logval = MBLOGNONE; - isp_mboxcmd(isp, &mbs); - if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { - sdf = DPARM_SAFE_DFLT; - MEMZERO(&mbs, sizeof (mbs)); - mbs.param[0] = MBOX_SET_TARGET_PARAMS; - mbs.param[1] = (tgt << 8) | (channel << 15); - mbs.param[2] = sdf; - mbs.param[3] = 0; - mbs.logval = MBLOGALL; - isp_mboxcmd(isp, &mbs); - 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++) { - MEMZERO(&mbs, sizeof (mbs)); - 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; - mbs.logval = MBLOGALL; - isp_mboxcmd(isp, &mbs); - 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. - */ -void -isp_fibre_init(struct ispsoftc *isp) -{ - fcparam *fcp; - isp_icb_t local, *icbp = &local; - mbreg_t mbs; - int ownloopid; - u_int64_t nwwn, pwwn; - - fcp = isp->isp_param; - - MEMZERO(icbp, sizeof (*icbp)); - icbp->icb_version = ICB_VERSION1; - icbp->icb_fwoptions = fcp->isp_fwoptions; - - /* - * 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 (IS_2100(isp) && isp->isp_revision < 5) { - icbp->icb_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)) { - icbp->icb_fwoptions |= ICBOPT_FULL_LOGIN; - } - - /* - * Insist on Port Database Update Async notifications - */ - icbp->icb_fwoptions |= ICBOPT_PDBCHANGE_AE; - - /* - * Make sure that target role reflects into fwoptions. - */ - if (isp->isp_role & ISP_ROLE_TARGET) { - icbp->icb_fwoptions |= ICBOPT_TGT_ENABLE; - } else { - icbp->icb_fwoptions &= ~ICBOPT_TGT_ENABLE; - } - - if (isp->isp_role & ISP_ROLE_INITIATOR) { - icbp->icb_fwoptions &= ~ICBOPT_INI_DISABLE; - } else { - icbp->icb_fwoptions |= ICBOPT_INI_DISABLE; - } - - 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 = fcp->isp_loopid; - ownloopid = (isp->isp_confopts & ISP_CFG_OWNLOOPID) != 0; - if (icbp->icb_hardaddr > 125) { - icbp->icb_hardaddr = 0; - ownloopid = 0; - } - - /* - * Our life seems so much better with 2200s and later with - * the latest f/w if we set Hard Address. - */ - if (ownloopid || ISP_FW_NEWER_THAN(isp, 2, 2, 5)) { - icbp->icb_fwoptions |= ICBOPT_HARD_ADDRESS; - } - - /* - * 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_2200(isp)) { - icbp->icb_fwoptions &= ~ICBOPT_FAST_POST; - } else { - /* - * 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). - */ - icbp->icb_fwoptions &= ~ICBOPT_FAST_POST; - if ((fcp->isp_xfwoptions & ICBXOPT_TIMER_MASK) == - ICBXOPT_ZIO) { - icbp->icb_xfwoptions |= ICBXOPT_ZIO; - icbp->icb_idelaytimer = 10; - } - 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; - } - if (fcp->isp_zfwoptions & ICBZOPT_50_OHM) { - icbp->icb_zfwoptions |= ICBZOPT_50_OHM; - } - } - } - - - /* - * For 22XX > 2.1.26 && 23XX, set some options. - * 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) - */ - MEMZERO(&mbs, sizeof (mbs)); - mbs.param[0] = MBOX_SET_FIRMWARE_OPTIONS; - mbs.param[1] = 0xb; - mbs.param[2] = 0; - mbs.param[3] = 0; - mbs.logval = MBLOGALL; - isp_mboxcmd(isp, &mbs); - if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { - return; - } - } - icbp->icb_logintime = ICB_LOGIN_TOV; - icbp->icb_lunetimeout = ICB_LUN_ENABLE_TOV; - - 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); -#ifndef SMALL_KERNEL - 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))); -#endif - } else if (pwwn) { - icbp->icb_fwoptions &= ~ICBOPT_BOTH_WWNS; - MAKE_NODE_NAME_FROM_WWN(icbp->icb_portname, pwwn); -#ifndef SMALL_KERNEL - isp_prt(isp, ISP_LOGDEBUG1, - "Setting ICB Port 0x%08x%08x", - ((u_int32_t) (pwwn >> 32)), - ((u_int32_t) (pwwn & 0xffffffff))); -#endif - } else { - isp_prt(isp, ISP_LOGERR, "No valid WWNs to use"); - return; - } - icbp->icb_rqstqlen = RQUEST_QUEUE_LEN(isp); - if (icbp->icb_rqstqlen < 1) { - isp_prt(isp, ISP_LOGERR, "bad request queue length"); - } - icbp->icb_rsltqlen = RESULT_QUEUE_LEN(isp); - if (icbp->icb_rsltqlen < 1) { - isp_prt(isp, ISP_LOGERR, "bad result queue length"); - } - 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); - -#ifndef SMALL_KERNEL - 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); -#endif - - FC_SCRATCH_ACQUIRE(isp); - isp_put_icb(isp, icbp, (isp_icb_t *)fcp->isp_scratch); - - /* - * Init the firmware - */ - MEMZERO(&mbs, sizeof (mbs)); - mbs.param[0] = MBOX_INIT_FIRMWARE; - mbs.param[2] = DMA_WD1(fcp->isp_scdma); - mbs.param[3] = DMA_WD0(fcp->isp_scdma); - mbs.param[6] = DMA_WD3(fcp->isp_scdma); - mbs.param[7] = DMA_WD2(fcp->isp_scdma); - mbs.logval = MBLOGALL; - mbs.timeout = 30 * 1000000; -#ifndef SMALL_KERNEL - isp_prt(isp, ISP_LOGDEBUG0, "INIT F/W from %p (%08x%08x)", - fcp->isp_scratch, (u_int32_t) ((u_int64_t)fcp->isp_scdma >> 32), - (u_int32_t) fcp->isp_scdma); -#endif - MEMORYBARRIER(isp, SYNC_SFORDEV, 0, sizeof (*icbp)); - isp_mboxcmd(isp, &mbs); - FC_SCRATCH_RELEASE(isp); - if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { - isp_print_bytes(isp, "isp_fibre_init", sizeof (*icbp), icbp); - return; - } - isp->isp_reqidx = 0; - isp->isp_reqodx = 0; - isp->isp_residx = 0; - - /* - * Whatever happens, we're now committed to being here. - */ - isp->isp_state = ISP_INITSTATE; -} - -void -isp_mark_portdb(struct ispsoftc *isp, int onprobation) -{ - fcparam *fcp = (fcparam *) isp->isp_param; - int i; - - for (i = 0; i < MAX_FC_TARG; i++) { - if (onprobation == 0) { - MEMZERO(&fcp->portdb[i], sizeof (fcportdb_t)); - } else { - switch (fcp->portdb[i].state) { - case FC_PORTDB_STATE_CHANGED: - case FC_PORTDB_STATE_PENDING_VALID: - case FC_PORTDB_STATE_VALID: - case FC_PORTDB_STATE_PROBATIONAL: - fcp->portdb[i].state = - FC_PORTDB_STATE_PROBATIONAL; - break; - case FC_PORTDB_STATE_ZOMBIE: - break; - case FC_PORTDB_STATE_NIL: - default: - MEMZERO(&fcp->portdb[i], sizeof (fcportdb_t)); - fcp->portdb[i].state = - FC_PORTDB_STATE_NIL; - break; - } - } - } -} - -/* - * Perform an IOCB PLOGI or LOGO via EXECUTE IOCB A64 for 24XX cards - * or via FABRIC LOGIN/FABRIC LOGOUT for other cards. - */ -int -isp_plogx(struct ispsoftc *isp, u_int16_t handle, u_int32_t portid, int flags, int gs) -{ - int action = flags & PLOGX_FLG_CMD_MASK; - if (action == PLOGX_FLG_CMD_PLOGI) { - return (isp_port_login(isp, handle, portid)); - } else if (action == PLOGX_FLG_CMD_LOGO) { - return (isp_port_logout(isp, handle, portid)); - } else { - return (MBOX_INVALID_COMMAND); - } -} - -int -isp_port_login(struct ispsoftc *isp, u_int16_t handle, u_int32_t portid) -{ - mbreg_t mbs; - - MEMZERO(&mbs, sizeof (mbs)); - mbs.param[0] = MBOX_FABRIC_LOGIN; - if (FCPARAM(isp)->isp_2klogin) { - mbs.param[1] = handle; - mbs.ibits = (1 << 10); - } else { - mbs.param[1] = handle << 8; - } - mbs.param[2] = portid >> 16; - mbs.param[3] = portid; - mbs.logval = MBLOGNONE; - mbs.timeout = 500000; - isp_mboxcmd(isp, &mbs); - - switch (mbs.param[0]) { - case MBOX_PORT_ID_USED: -#ifndef SMALL_KERNEL - isp_prt(isp, ISP_LOGDEBUG0, - "isp_plogi_old: portid 0x%06x already logged in as %u", - portid, mbs.param[1]); -#endif - return (MBOX_PORT_ID_USED | (mbs.param[1] << 16)); - - case MBOX_LOOP_ID_USED: -#ifndef SMALL_KERNEL - isp_prt(isp, ISP_LOGDEBUG0, - "isp_plogi_old: handle %u in use for port id 0x%02xXXXX", - handle, mbs.param[1] & 0xff); -#endif - return (MBOX_LOOP_ID_USED); - - case MBOX_COMMAND_COMPLETE: - return (0); - - case MBOX_COMMAND_ERROR: - isp_prt(isp, ISP_LOGINFO, - "isp_plogi_old: error 0x%x in PLOGI to port 0x%06x", - mbs.param[1], portid); - return (MBOX_COMMAND_ERROR); - - case MBOX_ALL_IDS_USED: - isp_prt(isp, ISP_LOGINFO, - "isp_plogi_old: all IDs used for fabric login"); - return (MBOX_ALL_IDS_USED); - - default: - isp_prt(isp, ISP_LOGINFO, - "isp_plogi_old: error 0x%x on port login of 0x%06x@0x%0x", - mbs.param[0], portid, handle); - return (mbs.param[0]); - } -} - -int -isp_port_logout(struct ispsoftc *isp, u_int16_t handle, u_int32_t portid) -{ - mbreg_t mbs; - - MEMZERO(&mbs, sizeof (mbs)); - mbs.param[0] = MBOX_FABRIC_LOGOUT; - if (FCPARAM(isp)->isp_2klogin) { - mbs.param[1] = handle; - mbs.ibits = (1 << 10); - } else { - mbs.param[1] = handle << 8; - } - mbs.logval = MBLOGNONE; - mbs.timeout = 100000; - isp_mboxcmd(isp, &mbs); - return (mbs.param[0] == MBOX_COMMAND_COMPLETE? 0 : mbs.param[0]); -} - -int -isp_getpdb(struct ispsoftc *isp, u_int16_t id, isp_pdb_t *pdb, int dolock) -{ - fcparam *fcp = (fcparam *) isp->isp_param; - mbreg_t mbs; - union { - isp_pdb_21xx_t fred; - isp_pdb_24xx_t bill; - } un; - - MEMZERO(&mbs, sizeof (mbs)); - mbs.param[0] = MBOX_GET_PORT_DB; - if (FCPARAM(isp)->isp_2klogin) { - mbs.param[1] = id; - mbs.ibits = (1 << 10); - } else { - mbs.param[1] = id << 8; - } - mbs.param[2] = DMA_WD1(fcp->isp_scdma); - mbs.param[3] = DMA_WD0(fcp->isp_scdma); - mbs.param[6] = DMA_WD3(fcp->isp_scdma); - mbs.param[7] = DMA_WD2(fcp->isp_scdma); - mbs.timeout = 250000; - mbs.logval = MBLOGALL & ~MBOX_COMMAND_PARAM_ERROR; - if (dolock) { - FC_SCRATCH_ACQUIRE(isp); - } - MEMORYBARRIER(isp, SYNC_SFORDEV, 0, sizeof (un)); - isp_mboxcmd(isp, &mbs); - if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { - if (dolock) { - FC_SCRATCH_RELEASE(isp); - } - return (-1); - } - { - isp_get_pdb_21xx(isp, fcp->isp_scratch, &un.fred); - pdb->handle = un.fred.pdb_loopid; - pdb->s3_role = un.fred.pdb_prli_svc3; - pdb->portid = BITS2WORD(un.fred.pdb_portid_bits); - MEMCPY(pdb->portname, un.fred.pdb_portname, 8); - MEMCPY(pdb->nodename, un.fred.pdb_nodename, 8); - } - if (dolock) { - FC_SCRATCH_RELEASE(isp); - } - return (0); -} - -u_int64_t -isp_get_portname(struct ispsoftc *isp, int loopid, int nodename) -{ - u_int64_t wwn = (u_int64_t) -1; - mbreg_t mbs; - - MEMZERO(&mbs, sizeof (mbs)); - mbs.param[0] = MBOX_GET_PORT_NAME; - if (FCPARAM(isp)->isp_2klogin || IS_24XX(isp)) { - mbs.param[1] = loopid; - mbs.ibits = (1 << 10); - if (nodename) { - mbs.param[10] = 1; - } - } else { - mbs.param[1] = loopid << 8; - if (nodename) { - mbs.param[1] |= 1; - } - } - mbs.logval = MBLOGALL & ~MBOX_COMMAND_PARAM_ERROR; - isp_mboxcmd(isp, &mbs); - if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { - return (wwn); - } - { - 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. - */ - -int -isp_fclink_test(struct ispsoftc *isp, int usdelay) -{ - static const 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; - int loopid; - fcparam *fcp; - fcportdb_t *lp; - isp_pdb_t pdb; - - fcp = isp->isp_param; - - isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0, "FC Link Test Entry"); - ISP_MARK_PORTDB(isp, 1); - - /* - * 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_LOGCONFIG|ISP_LOGSANCFG, - "Firmware State <%s->%s>", - ispfc_fw_statename((int)lwfs), - ispfc_fw_statename((int)fcp->isp_fwstate)); - lwfs = fcp->isp_fwstate; - } - if (fcp->isp_fwstate == FW_READY && - fcp->isp_loopstate >= LOOP_PDB_RCVD) { - break; - } - GET_NANOTIME(&hrb); - - /* - * Get the elapsed time in nanoseconds. - * Always guaranteed to be non-zero. - */ - enano = NANOTIME_SUB(&hrb, &hra); - -#ifndef SMALL_KERNEL - 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)); -#endif - - /* - * 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) { - isp_prt(isp, ISP_LOGSANCFG, - "isp_fclink_test: not at FW_READY state"); - return (-1); - } - - /* - * Get our Loop ID and Port ID. - */ - MEMZERO(&mbs, sizeof (mbs)); - mbs.param[0] = MBOX_GET_LOOP_ID; - mbs.logval = MBLOGALL; - isp_mboxcmd(isp, &mbs); - if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { - return (-1); - } - - if (FCPARAM(isp)->isp_2klogin) { - fcp->isp_loopid = mbs.param[1]; - } else { - fcp->isp_loopid = mbs.param[1] & 0xff; - } - - if (IS_2100(isp)) { - fcp->isp_topo = TOPO_NL_PORT; - } else { - int topo = (int) mbs.param[6]; - if (topo < TOPO_NL_PORT || topo > TOPO_PTP_STUB) { - topo = TOPO_PTP_STUB; - } - fcp->isp_topo = topo; - } - fcp->isp_portid = mbs.param[2] | (mbs.param[3] << 16); - - 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; - } - - loopid = FL_ID; - - if (check_for_fabric && isp_getpdb(isp, loopid, &pdb, 1) == 0) { - int r; - if (IS_2100(isp)) { - fcp->isp_topo = TOPO_FL_PORT; - } - if (pdb.portid == 0) { - /* - * Crock. - */ - fcp->isp_topo = TOPO_NL_PORT; - goto not_on_fabric; - } - - /* - * Save the Fabric controller's port database entry. - */ - lp = &fcp->portdb[FL_ID]; - lp->state = FC_PORTDB_STATE_PENDING_VALID; - MAKE_WWN_FROM_NODE_NAME(lp->node_wwn, pdb.nodename); - MAKE_WWN_FROM_NODE_NAME(lp->port_wwn, pdb.portname); - lp->roles = (pdb.s3_role & SVC3_ROLE_MASK) >> SVC3_ROLE_SHIFT; - lp->portid = pdb.portid; - lp->handle = pdb.handle; - lp->new_portid = lp->portid; - lp->new_roles = lp->roles; - r = isp_register_fc4_type(isp); - if (r) { - isp_prt(isp, ISP_LOGSANCFG, - "isp_fclink_test: register fc4 type failed"); - return (-1); - } - } else { -not_on_fabric: - fcp->portdb[FL_ID].state = FC_PORTDB_STATE_NIL; - } - - fcp->isp_gbspeed = 1; - if (IS_23XX(isp)) { - MEMZERO(&mbs, sizeof (mbs)); - mbs.param[0] = MBOX_GET_SET_DATA_RATE; - mbs.param[1] = MBGSD_GET_RATE; - /* mbs.param[2] undefined if we're just getting rate */ - mbs.logval = MBLOGALL; - mbs.timeout = 3000000; - isp_mboxcmd(isp, &mbs); - if (mbs.param[0] == MBOX_COMMAND_COMPLETE) { - if (mbs.param[1] == MBGSD_FOURGB) { - isp_prt(isp, ISP_LOGINFO, "4Gb link speed/s"); - fcp->isp_gbspeed = 4; - } if (mbs.param[1] == MBGSD_TWOGB) { - isp_prt(isp, ISP_LOGINFO, "2Gb link speed/s"); - fcp->isp_gbspeed = 2; - } - } - } - - /* - * Announce ourselves, too. - */ - isp_prt(isp, ISP_LOGSANCFG|ISP_LOGCONFIG, topology, fcp->isp_portid, - fcp->isp_loopid, toponames[fcp->isp_topo]); - isp_prt(isp, ISP_LOGSANCFG|ISP_LOGCONFIG, ourwwn, - (u_int32_t) (ISP_NODEWWN(isp) >> 32), - (u_int32_t) ISP_NODEWWN(isp), - (u_int32_t) (ISP_PORTWWN(isp) >> 32), - (u_int32_t) ISP_PORTWWN(isp)); - isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0, "FC Link Test Complete"); - return (0); -} - -const char * -ispfc_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 "?????"; - } -} - -/* - * Complete the synchronization of our Port Database. - * - * At this point, we've scanned the local loop (if any) and the fabric - * and performed fabric logins on all new devices. - * - * Our task here is to go through our port database and remove any entities - * that are still marked probational (issuing PLOGO for ones which we had - * PLOGI'd into) or are dead. - * - * Our task here is to also check policy to decide whether devices which - * have *changed* in some way should still be kept active. For example, - * if a device has just changed PortID, we can either elect to treat it - * as an old device or as a newly arrived device (and notify the outer - * layer appropriately). - * - * We also do initiator map target id assignment here for new initiator - * devices and refresh old ones ot make sure that they point to the corret - * entities. - */ -int -isp_pdb_sync(struct ispsoftc *isp) -{ - fcparam *fcp = isp->isp_param; - fcportdb_t *lp; - u_int16_t dbidx; - - if (fcp->isp_loopstate == LOOP_READY) { - return (0); - } - - /* - * 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) { - isp_prt(isp, ISP_LOGWARN, "isp_pdb_sync: bad loopstate %d", - fcp->isp_loopstate); - 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) { - isp_prt(isp, ISP_LOGWARN, - "isp_pdb_sync: isp_scan_loop failed"); - return (-1); - } - } - } - - if (fcp->isp_topo == TOPO_F_PORT || fcp->isp_topo == TOPO_FL_PORT) { - if (fcp->isp_loopstate < LOOP_FSCAN_DONE) { - if (isp_scan_fabric(isp) != 0) { - isp_prt(isp, ISP_LOGWARN, - "isp_pdb_sync: isp_scan_fabric failed"); - return (-1); - } - } - } - - isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0, "Synchronizing PDBs"); - - fcp->isp_loopstate = LOOP_SYNCING_PDB; - - for (dbidx = 0; dbidx < MAX_FC_TARG; dbidx++) { - lp = &fcp->portdb[dbidx]; - - if (lp->state == FC_PORTDB_STATE_NIL) { - continue; - } - - if (lp->state == FC_PORTDB_STATE_VALID) { - if (dbidx != FL_ID) { - isp_prt(isp, - ISP_LOGERR, "portdb idx %d already valid", - dbidx); - } - continue; - } - - switch (lp->state) { - case FC_PORTDB_STATE_PROBATIONAL: - case FC_PORTDB_STATE_DEAD: - /* - * It's up to the outer layers to clear isp_ini_map. - */ - lp->state = FC_PORTDB_STATE_NIL; - isp_async(isp, ISPASYNC_DEV_GONE, lp); - if (lp->autologin == 0) { - (void) isp_plogx(isp, lp->handle, lp->portid, - PLOGX_FLG_CMD_LOGO | - PLOGX_FLG_IMPLICIT | - PLOGX_FLG_FREE_NPHDL, 0); - } else { - lp->autologin = 0; - } - lp->new_roles = 0; - lp->new_portid = 0; - /* - * Note that we might come out of this with our state - * set to FC_PORTDB_STATE_ZOMBIE. - */ - break; - case FC_PORTDB_STATE_NEW: - /* - * It's up to the outer layers to assign a virtual - * target id in isp_ini_map (if any). - */ - lp->portid = lp->new_portid; - lp->roles = lp->new_roles; - lp->state = FC_PORTDB_STATE_VALID; - isp_async(isp, ISPASYNC_DEV_ARRIVED, lp); - lp->new_roles = 0; - lp->new_portid = 0; - lp->reserved = 0; - lp->new_reserved = 0; - break; - case FC_PORTDB_STATE_CHANGED: -/* - * XXXX FIX THIS - */ - lp->state = FC_PORTDB_STATE_VALID; - isp_async(isp, ISPASYNC_DEV_CHANGED, lp); - lp->new_roles = 0; - lp->new_portid = 0; - lp->reserved = 0; - lp->new_reserved = 0; - break; - case FC_PORTDB_STATE_PENDING_VALID: - lp->portid = lp->new_portid; - lp->roles = lp->new_roles; - if (lp->ini_map_idx) { - int t = lp->ini_map_idx - 1; - fcp->isp_ini_map[t] = dbidx + 1; - } - lp->state = FC_PORTDB_STATE_VALID; - isp_async(isp, ISPASYNC_DEV_STAYED, lp); - if (dbidx != FL_ID) { - lp->new_roles = 0; - lp->new_portid = 0; - } - lp->reserved = 0; - lp->new_reserved = 0; - break; - case FC_PORTDB_STATE_ZOMBIE: - break; - default: - isp_prt(isp, ISP_LOGWARN, - "isp_scan_loop: state %d for idx %d", - lp->state, dbidx); - isp_dump_portdb(isp); - } - } - - /* - * 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); -} - -/* - * Scan local loop for devices. - */ -int -isp_scan_loop(struct ispsoftc *isp) -{ - fcportdb_t *lp, tmp; - fcparam *fcp = isp->isp_param; - int i; - isp_pdb_t pdb; - u_int16_t handle, lim = 0; - - if (fcp->isp_fwstate < FW_READY || - fcp->isp_loopstate < LOOP_PDB_RCVD) { - return (-1); - } - - if (fcp->isp_loopstate > LOOP_SCANNING_LOOP) { - return (0); - } - - /* - * Check our connection topology. - * - * If we're a public or private loop, we scan 0..125 as handle values. - * The firmware has (typically) peformed a PLOGI for us. - * - * If we're a N-port connection, we treat this is a short loop (0..1). - * - * If we're in target mode, we can all possible handles to see who - * might have logged into us. - */ - switch (fcp->isp_topo) { - case TOPO_NL_PORT: - case TOPO_FL_PORT: - lim = LOCAL_LOOP_LIM; - break; - case TOPO_N_PORT: - lim = 2; - break; - default: -#ifndef SMALL_KERNEL - isp_prt(isp, ISP_LOGDEBUG0, "no loop topology to scan"); -#endif - fcp->isp_loopstate = LOOP_LSCAN_DONE; - return (0); - } - - fcp->isp_loopstate = LOOP_SCANNING_LOOP; - - isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0, "FC scan loop 0..%d", lim-1); - - - /* - * Run through the list and get the port database info for each one. - */ - for (handle = 0; handle < lim; handle++) { - /* - * But don't even try for ourselves... - */ - if (handle == fcp->isp_loopid) { - continue; - } - - /* - * In older cards with older f/w GET_PORT_DATABASE has been - * known to hang. This trick gets around that problem. - */ - if (IS_2100(isp) || IS_2200(isp)) { - u_int64_t node_wwn = isp_get_portname(isp, handle, 1); - if (fcp->isp_loopstate < LOOP_SCANNING_LOOP) { - return (-1); - } - if (node_wwn == 0) { - continue; - } - } - - /* - * Get the port database entity for this index. - */ - if (isp_getpdb(isp, handle, &pdb, 1) != 0) { - if (fcp->isp_loopstate < LOOP_SCANNING_LOOP) { - ISP_MARK_PORTDB(isp, 1); - return (-1); - } - continue; - } - - if (fcp->isp_loopstate < LOOP_SCANNING_LOOP) { - ISP_MARK_PORTDB(isp, 1); - return (-1); - } - - /* - * On *very* old 2100 firmware we would end up sometimes - * with the firmware returning the port database entry - * for something else. We used to restart this, but - * now we just punt. - */ - if (IS_2100(isp) && pdb.handle != handle) { - isp_prt(isp, ISP_LOGWARN, - "giving up on synchronizing the port database"); - ISP_MARK_PORTDB(isp, 1); - return (-1); - } - - /* - * Save the pertinent info locally. - */ - MAKE_WWN_FROM_NODE_NAME(tmp.node_wwn, pdb.nodename); - MAKE_WWN_FROM_NODE_NAME(tmp.port_wwn, pdb.portname); - tmp.roles = (pdb.s3_role & SVC3_ROLE_MASK) >> SVC3_ROLE_SHIFT; - tmp.portid = pdb.portid; - tmp.handle = pdb.handle; - - /* - * Check to make sure it's still a valid entry. The 24XX seems - * to return a portid but not a WWPN/WWNN or role for devices - * which shift on a loop. - */ - if (tmp.node_wwn == 0 || tmp.port_wwn == 0 || tmp.portid == 0) { - int a, b, c; - a = (tmp.node_wwn == 0); - b = (tmp.port_wwn == 0); - c = (tmp.portid == 0); - isp_prt(isp, ISP_LOGWARN, - "bad pdb (%1d%1d%1d) @ handle 0x%x", a, b, c, - handle); - isp_dump_portdb(isp); - continue; - } - - /* - * Now search the entire port database - * for the same Port and Node WWN. - */ - for (i = 0; i < MAX_FC_TARG; i++) { - lp = &fcp->portdb[i]; - if (lp->state == FC_PORTDB_STATE_NIL) { - continue; - } - if (lp->node_wwn != tmp.node_wwn) { - continue; - } - if (lp->port_wwn != tmp.port_wwn) { - continue; - } - - /* - * Okay- we've found a non-nil entry that matches. - * Check to make sure it's probational or a zombie. - */ - if (lp->state != FC_PORTDB_STATE_PROBATIONAL && - lp->state != FC_PORTDB_STATE_ZOMBIE) { - isp_prt(isp, ISP_LOGERR, - "[%d] not probational/zombie (0x%x)", - i, lp->state); - isp_dump_portdb(isp); - ISP_MARK_PORTDB(isp, 1); - return (-1); - } - - /* - * Mark the device as something the f/w logs into - * automatically. - */ - lp->autologin = 1; - - /* - * Check to make see if really still the same - * device. If it is, we mark it pending valid. - */ - if (lp->portid == tmp.portid && - lp->handle == tmp.handle && - lp->roles == tmp.roles) { - lp->new_portid = tmp.portid; - lp->new_roles = tmp.roles; - lp->state = FC_PORTDB_STATE_PENDING_VALID; - isp_prt(isp, ISP_LOGSANCFG, - "Loop Port 0x%02x@0x%x Pending Valid", - tmp.portid, tmp.handle); - break; - } - - /* - * We can wipe out the old handle value - * here because it's no longer valid. - */ - lp->handle = tmp.handle; - - /* - * Claim that this has changed and let somebody else - * decide what to do. - */ - isp_prt(isp, ISP_LOGSANCFG, - "Loop Port 0x%02x@0x%x changed", - tmp.portid, tmp.handle); - lp->state = FC_PORTDB_STATE_CHANGED; - lp->new_portid = tmp.portid; - lp->new_roles = tmp.roles; - break; - } - - /* - * Did we find and update an old entry? - */ - if (i < MAX_FC_TARG) { - continue; - } - - /* - * Ah. A new device entry. Find an empty slot - * for it and save info for later disposition. - */ - for (i = 0; i < MAX_FC_TARG; i++) { - if (fcp->portdb[i].state == FC_PORTDB_STATE_NIL) { - break; - } - } - if (i == MAX_FC_TARG) { - isp_prt(isp, ISP_LOGERR, "out of portdb entries"); - continue; - } - lp = &fcp->portdb[i]; - - MEMZERO(lp, sizeof (fcportdb_t)); - lp->autologin = 1; - lp->state = FC_PORTDB_STATE_NEW; - lp->new_portid = tmp.portid; - lp->new_roles = tmp.roles; - lp->handle = tmp.handle; - lp->port_wwn = tmp.port_wwn; - lp->node_wwn = tmp.node_wwn; - isp_prt(isp, ISP_LOGSANCFG, - "Loop Port 0x%02x@0x%x is New Entry", - tmp.portid, tmp.handle); - } - fcp->isp_loopstate = LOOP_LSCAN_DONE; - return (0); -} - -/* - * Scan the fabric for devices and add them to our port database. - * - * Use the GID_FT command to get all Port IDs for FC4 SCSI devices it knows. - * - * For 2100-23XX cards, we can use the SNS mailbox command to pass simple - * name server commands to the switch management server via the QLogic f/w. - * - * For the 24XX card, we have to use CT-Pass through run via the Execute IOCB - * mailbox command. - * - * The net result is to leave the list of Port IDs setting untranslated in - * offset IGPOFF of the FC scratch area, whereupon we'll canonicalize it to - * host order at OGPOFF. - */ - -/* - * Take less than half of our scratch area to store Port IDs - */ -#define GIDLEN ((ISP2100_SCRLEN >> 1) - 16 - SNS_GID_FT_REQ_SIZE) -#define NGENT ((GIDLEN - 16) >> 2) - -#define IGPOFF (2 * QENTRY_LEN) -#define OGPOFF (ISP2100_SCRLEN >> 1) -#define ZTXOFF (ISP2100_SCRLEN - (1 * QENTRY_LEN)) -#define CTXOFF (ISP2100_SCRLEN - (2 * QENTRY_LEN)) -#define XTXOFF (ISP2100_SCRLEN - (3 * QENTRY_LEN)) - -int -isp_gid_ft_sns(struct ispsoftc *isp) -{ - union { - sns_gid_ft_req_t _x; - u_int8_t _y[SNS_GID_FT_REQ_SIZE]; - } un; - fcparam *fcp = FCPARAM(isp); - sns_gid_ft_req_t *rq = &un._x; - mbreg_t mbs; - -#ifndef SMALL_KERNEL - isp_prt(isp, ISP_LOGDEBUG0, "scanning fabric (GID_FT) via SNS"); -#endif - - MEMZERO(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 = FC4_SCSI; - - isp_put_gid_ft_request(isp, rq, fcp->isp_scratch); - MEMORYBARRIER(isp, SYNC_SFORDEV, 0, SNS_GID_FT_REQ_SIZE); - - MEMZERO(&mbs, sizeof (mbs)); - 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); - mbs.param[6] = DMA_WD3(fcp->isp_scdma); - mbs.param[7] = DMA_WD2(fcp->isp_scdma); - mbs.logval = MBLOGALL; - mbs.timeout = 10000000; - isp_mboxcmd(isp, &mbs); - if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { - if (mbs.param[0] == MBOX_INVALID_COMMAND) { - return (1); - } else { - return (-1); - } - } - return (0); -} - -int -isp_scan_fabric(struct ispsoftc *isp) -{ - fcparam *fcp = FCPARAM(isp); - u_int32_t portid; - u_int16_t handle, oldhandle; - int portidx, portlim, r; - sns_gid_ft_rsp_t *rs0, *rs1; - - isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0, "FC Scan Fabric"); - if (fcp->isp_fwstate != FW_READY || - fcp->isp_loopstate < LOOP_LSCAN_DONE) { - return (-1); - } - if (fcp->isp_loopstate > LOOP_SCANNING_FABRIC) { - return (0); - } - if (fcp->isp_topo != TOPO_FL_PORT && fcp->isp_topo != TOPO_F_PORT) { - fcp->isp_loopstate = LOOP_FSCAN_DONE; - isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0, - "FC Scan Fabric Done (no fabric)"); - return (0); - } - - FC_SCRATCH_ACQUIRE(isp); - fcp->isp_loopstate = LOOP_SCANNING_FABRIC; - - r = isp_gid_ft_sns(isp); - if (r > 0) { - fcp->isp_loopstate = LOOP_FSCAN_DONE; - FC_SCRATCH_RELEASE(isp); - return (0); - } else if (r < 0) { - fcp->isp_loopstate = LOOP_PDB_RCVD; /* try again */ - FC_SCRATCH_RELEASE(isp); - return (0); - } - if (fcp->isp_loopstate != LOOP_SCANNING_FABRIC) { - FC_SCRATCH_RELEASE(isp); - return (-1); - } - - MEMORYBARRIER(isp, SYNC_SFORCPU, IGPOFF, GIDLEN); - rs0 = (sns_gid_ft_rsp_t *) ((u_int8_t *)fcp->isp_scratch+IGPOFF); - rs1 = (sns_gid_ft_rsp_t *) ((u_int8_t *)fcp->isp_scratch+OGPOFF); - isp_get_gid_ft_response(isp, rs0, rs1, NGENT); - if (rs1->snscb_cthdr.ct_cmd_resp != LS_ACC) { - int level; - if (rs1->snscb_cthdr.ct_reason == 9 && - rs1->snscb_cthdr.ct_explanation == 7) { - level = ISP_LOGSANCFG|ISP_LOGDEBUG0; - } else { - level = ISP_LOGWARN; - } - isp_prt(isp, level, "Fabric Nameserver rejected GID_FT " - "(Reason=0x%x Expl=0x%x)", rs1->snscb_cthdr.ct_reason, - rs1->snscb_cthdr.ct_explanation); - FC_SCRATCH_RELEASE(isp); - fcp->isp_loopstate = LOOP_FSCAN_DONE; - return (0); - } - - - /* - * If we get this far, we certainly still have the fabric controller. - */ - fcp->portdb[FL_ID].state = FC_PORTDB_STATE_PENDING_VALID; - - /* - * Prime the handle we will start using. - */ - oldhandle = NIL_HANDLE; - - /* - * Okay, we now have a list of Port IDs for all FC4 SCSI devices - * that the Fabric Name server knows about. Go through the list - * and remove duplicate port ids. - */ - - portlim = 0; - portidx = 0; - for (portidx = 0; portidx < NGENT-1; portidx++) { - if (rs1->snscb_ports[portidx].control & 0x80) { - break; - } - } - - /* - * If we're not at the last entry, our list wasn't big enough. - */ - if ((rs1->snscb_ports[portidx].control & 0x80) == 0) { - isp_prt(isp, ISP_LOGWARN, - "fabric too big for scratch area: increase ISP2100_SCRLEN"); - } - portlim = portidx + 1; - isp_prt(isp, ISP_LOGSANCFG, - "got %d ports back from name server", portlim); - - for (portidx = 0; portidx < portlim; portidx++) { - int npidx; - - portid = - ((rs1->snscb_ports[portidx].portid[0]) << 16) | - ((rs1->snscb_ports[portidx].portid[1]) << 8) | - ((rs1->snscb_ports[portidx].portid[2])); - - for (npidx = portidx + 1; npidx < portlim; npidx++) { - u_int32_t new_portid = - ((rs1->snscb_ports[npidx].portid[0]) << 16) | - ((rs1->snscb_ports[npidx].portid[1]) << 8) | - ((rs1->snscb_ports[npidx].portid[2])); - if (new_portid == portid) { - break; - } - } - - if (npidx < portlim) { - rs1->snscb_ports[npidx].portid[0] = 0; - rs1->snscb_ports[npidx].portid[1] = 0; - rs1->snscb_ports[npidx].portid[2] = 0; - isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0, - "removing duplicate PortID 0x%x entry from list", - portid); - } - } - - /* - * Okay, we now have a list of Port IDs for all FC4 SCSI devices - * that the Fabric Name server knows about. - * - * For each entry on this list go through our port database looking - * for probational entries- if we find one, then an old entry is - * is maybe still this one. We get some information to find out. - * - * Otherwise, it's a new fabric device, and we log into it - * (unconditionally). After searching the entire database - * again to make sure that we never ever ever ever have more - * than one entry that has the same PortID or the same - * WWNN/WWPN duple, we enter the device into our database. - */ - - for (portidx = 0; portidx < portlim; portidx++) { - fcportdb_t *lp; - isp_pdb_t pdb; - u_int64_t wwnn, wwpn; - int dbidx, nr; - - portid = - ((rs1->snscb_ports[portidx].portid[0]) << 16) | - ((rs1->snscb_ports[portidx].portid[1]) << 8) | - ((rs1->snscb_ports[portidx].portid[2])); - - if (portid == 0) { - isp_prt(isp, ISP_LOGSANCFG, - "skipping null PortID at idx %d", portidx); - continue; - } - - /* - * Skip ourselves... - */ - if (portid == fcp->isp_portid) { - isp_prt(isp, ISP_LOGSANCFG, - "skip ourselves @ PortID 0x%06x", portid); - continue; - } - isp_prt(isp, ISP_LOGSANCFG, - "Checking Fabric Port 0x%06x", portid); - - /* - * We now search our Port Database for any - * probational entries with this PortID. We don't - * look for zombies here- only probational - * entries (we've already logged out of zombies). - */ - for (dbidx = 0; dbidx < MAX_FC_TARG; dbidx++) { - lp = &fcp->portdb[dbidx]; - - if (lp->state != FC_PORTDB_STATE_PROBATIONAL) { - continue; - } - if (lp->portid == portid) { - break; - } - } - - /* - * We found a probational entry with this Port ID. - */ - if (dbidx < MAX_FC_TARG) { - int handle_changed = 0; - - lp = &fcp->portdb[dbidx]; - - /* - * See if we're still logged into it. - * - * If we aren't, mark it as a dead device and - * leave the new portid in the database entry - * for somebody further along to decide what to - * do (policy choice). - * - * If we are, check to see if it's the same - * device still (it should be). If for some - * reason it isn't, mark it as a changed device - * and leave the new portid and role in the - * database entry for somebody further along to - * decide what to do (policy choice). - * - */ - - r = isp_getpdb(isp, lp->handle, &pdb, 0); - if (fcp->isp_loopstate != LOOP_SCANNING_FABRIC) { - FC_SCRATCH_RELEASE(isp); - ISP_MARK_PORTDB(isp, 1); - return (-1); - } - if (r != 0) { - lp->new_portid = portid; - lp->state = FC_PORTDB_STATE_DEAD; - isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0, - "Fabric Port 0x%06x considered dead", - portid); - continue; - } - - - /* - * Check to make sure that handle, portid, WWPN and - * WWNN agree. If they don't, then the association - * between this PortID and the stated handle has been - * broken by the firmware. - */ - MAKE_WWN_FROM_NODE_NAME(wwnn, pdb.nodename); - MAKE_WWN_FROM_NODE_NAME(wwpn, pdb.portname); - if (pdb.handle != lp->handle || - pdb.portid != portid || - wwpn != lp->port_wwn || - wwnn != lp->node_wwn) { - isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0, - fconf, dbidx, pdb.handle, pdb.portid, - (u_int32_t) (wwnn >> 32), (u_int32_t) wwnn, - (u_int32_t) (wwpn >> 32), (u_int32_t) wwpn, - lp->handle, portid, - (u_int32_t) (lp->node_wwn >> 32), - (u_int32_t) lp->node_wwn, - (u_int32_t) (lp->port_wwn >> 32), - (u_int32_t) lp->port_wwn); - /* - * Try to re-login to this device using a - * new handle. If that fails, mark it dead. - * - * isp_login_device will check for handle and - * portid consistency after re-login. - * - */ - if (isp_login_device(isp, portid, &pdb, - &oldhandle)) { - lp->new_portid = portid; - lp->state = FC_PORTDB_STATE_DEAD; - if (fcp->isp_loopstate != - LOOP_SCANNING_FABRIC) { - FC_SCRATCH_RELEASE(isp); - ISP_MARK_PORTDB(isp, 1); - return (-1); - } - continue; - } - MAKE_WWN_FROM_NODE_NAME(wwnn, pdb.nodename); - MAKE_WWN_FROM_NODE_NAME(wwpn, pdb.portname); - if (wwpn != lp->port_wwn || - wwnn != lp->node_wwn) { - isp_prt(isp, ISP_LOGWARN, "changed WWN" - " after relogin"); - lp->new_portid = portid; - lp->state = FC_PORTDB_STATE_DEAD; - continue; - } - - lp->handle = pdb.handle; - handle_changed++; - } - - nr = (pdb.s3_role & SVC3_ROLE_MASK) >> SVC3_ROLE_SHIFT; - - /* - * Check to see whether the portid and roles have - * stayed the same. If they have stayed the same, - * we believe that this is the same device and it - * hasn't become disconnected and reconnected, so - * mark it as pending valid. - * - * If they aren't the same, mark the device as a - * changed device and save the new port id and role - * and let somebody else decide. - */ - - lp->new_portid = portid; - lp->new_roles = nr; - if (pdb.portid != lp->portid || nr != lp->roles || - handle_changed) { - isp_prt(isp, ISP_LOGSANCFG, - "Fabric Port 0x%06x changed", portid); - lp->state = FC_PORTDB_STATE_CHANGED; - } else { - isp_prt(isp, ISP_LOGSANCFG, - "Fabric Port 0x%06x Now Pending Valid", - portid); - lp->state = FC_PORTDB_STATE_PENDING_VALID; - } - continue; - } - - /* - * Ah- a new entry. Search the database again for all non-NIL - * entries to make sure we never ever make a new database entry - * with the same port id. While we're at it, mark where the - * last free entry was. - */ - - dbidx = MAX_FC_TARG; - for (lp = fcp->portdb; lp < &fcp->portdb[MAX_FC_TARG]; lp++) { - if (lp >= &fcp->portdb[FL_ID] && - lp <= &fcp->portdb[SNS_ID]) { - continue; - } - if (lp->state == FC_PORTDB_STATE_NIL) { - if (dbidx == MAX_FC_TARG) { - dbidx = lp - fcp->portdb; - } - continue; - } - if (lp->state == FC_PORTDB_STATE_ZOMBIE) { - continue; - } - if (lp->portid == portid) { - break; - } - } - - if (lp < &fcp->portdb[MAX_FC_TARG]) { - isp_prt(isp, ISP_LOGWARN, - "PortID 0x%06x already at %d handle %d state %d", - portid, dbidx, lp->handle, lp->state); - continue; - } - - /* - * We should have the index of the first free entry seen. - */ - if (dbidx == MAX_FC_TARG) { - isp_prt(isp, ISP_LOGERR, - "port database too small to login PortID 0x%06x" - "- increase MAX_FC_TARG", portid); - continue; - } - - /* - * Otherwise, point to our new home. - */ - lp = &fcp->portdb[dbidx]; - - /* - * Try to see if we are logged into this device, - * and maybe log into it. - * - * isp_login_device will check for handle and - * portid consistency after login. - */ - if (isp_login_device(isp, portid, &pdb, &oldhandle)) { - if (fcp->isp_loopstate != LOOP_SCANNING_FABRIC) { - FC_SCRATCH_RELEASE(isp); - ISP_MARK_PORTDB(isp, 1); - return (-1); - } - continue; - } - - handle = pdb.handle; - MAKE_WWN_FROM_NODE_NAME(wwnn, pdb.nodename); - MAKE_WWN_FROM_NODE_NAME(wwpn, pdb.portname); - nr = (pdb.s3_role & SVC3_ROLE_MASK) >> SVC3_ROLE_SHIFT; - - /* - * And go through the database *one* more time to make sure - * that we do not make more than one entry that has the same - * WWNN/WWPN duple - */ - for (dbidx = 0; dbidx < MAX_FC_TARG; dbidx++) { - if (dbidx >= FL_ID && dbidx <= SNS_ID) { - continue; - } - if (fcp->portdb[dbidx].state == FC_PORTDB_STATE_NIL) { - continue; - } - if (fcp->portdb[dbidx].node_wwn == wwnn && - fcp->portdb[dbidx].port_wwn == wwpn) { - break; - } - } - - if (dbidx == MAX_FC_TARG) { - MEMZERO(lp, sizeof (fcportdb_t)); - lp->handle = handle; - lp->node_wwn = wwnn; - lp->port_wwn = wwpn; - lp->new_portid = portid; - lp->new_roles = nr; - lp->state = FC_PORTDB_STATE_NEW; - isp_prt(isp, ISP_LOGSANCFG, - "Fabric Port 0x%06x is New Entry", portid); - continue; - } - - if (fcp->portdb[dbidx].state != FC_PORTDB_STATE_ZOMBIE) { - isp_prt(isp, ISP_LOGWARN, - "PortID 0x%x 0x%08x%08x/0x%08x%08x %ld already at " - "idx %d, state 0x%x", portid, - (u_int32_t) (wwnn >> 32), (u_int32_t) wwnn, - (u_int32_t) (wwpn >> 32), (u_int32_t) wwpn, - (long) (lp - fcp->portdb), dbidx, - fcp->portdb[dbidx].state); - continue; - } - - /* - * We found a zombie entry that matches us. - * Revive it. We know that WWN and WWPN - * are the same. For fabric devices, we - * don't care that handle is different - * as we assign that. If role or portid - * are different, it maybe a changed device. - */ - lp = &fcp->portdb[dbidx]; - lp->handle = handle; - lp->new_portid = portid; - lp->new_roles = nr; - if (lp->portid != portid || lp->roles != nr) { - isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0, - "Zombie Fabric Port 0x%06x Now Changed", portid); - lp->state = FC_PORTDB_STATE_CHANGED; - } else { - isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0, - "Zombie Fabric Port 0x%06x Now Pending Valid", - portid); - lp->state = FC_PORTDB_STATE_PENDING_VALID; - } - } - - FC_SCRATCH_RELEASE(isp); - if (fcp->isp_loopstate != LOOP_SCANNING_FABRIC) { - ISP_MARK_PORTDB(isp, 1); - return (-1); - } - fcp->isp_loopstate = LOOP_FSCAN_DONE; - isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0, "FC Scan Fabric Done"); - return (0); -} - -/* - * Find an unused handle and try and use to login to a port. - */ -int -isp_login_device(struct ispsoftc *isp, u_int32_t portid, isp_pdb_t *p, u_int16_t *ohp) -{ - int lim, i, r; - u_int16_t handle; - - if (FCPARAM(isp)->isp_2klogin) { - lim = NPH_MAX_2K; - } else { - lim = NPH_MAX; - } - - handle = isp_nxt_handle(isp, *ohp); - for (i = 0; i < lim; i++) { - /* - * See if we're still logged into something with - * this handle and that something agrees with this - * port id. - */ - r = isp_getpdb(isp, handle, p, 0); - if (r == 0 && p->portid != portid) { - (void) isp_plogx(isp, handle, portid, - PLOGX_FLG_CMD_LOGO | PLOGX_FLG_IMPLICIT, 1); - } else if (r == 0) { - break; - } - if (FCPARAM(isp)->isp_loopstate != LOOP_SCANNING_FABRIC) { - return (-1); - } - /* - * Now try and log into the device - */ - r = isp_plogx(isp, handle, portid, PLOGX_FLG_CMD_PLOGI, 1); - if (FCPARAM(isp)->isp_loopstate != LOOP_SCANNING_FABRIC) { - return (-1); - } - if (r == 0) { - *ohp = handle; - break; - } else if ((r & 0xffff) == MBOX_PORT_ID_USED) { - handle = r >> 16; - break; - } else if (r != MBOX_LOOP_ID_USED) { - i = lim; - break; - } else { - *ohp = handle; - handle = isp_nxt_handle(isp, *ohp); - } - } - - if (i == lim) { - isp_prt(isp, ISP_LOGWARN, "PLOGI 0x%06x failed", portid); - return (-1); - } - - /* - * If we successfully logged into it, get the PDB for it - * so we can crosscheck that it is still what we think it - * is and that we also have the role it plays - */ - r = isp_getpdb(isp, handle, p, 0); - if (FCPARAM(isp)->isp_loopstate != LOOP_SCANNING_FABRIC) { - return (-1); - } - if (r != 0) { - isp_prt(isp, ISP_LOGERR, "new device 0x%06x@0x%x disappeared", - portid, handle); - return (-1); - } - - if (p->handle != handle || p->portid != portid) { - isp_prt(isp, ISP_LOGERR, - "new device 0x%06x@0x%x changed (0x%06x@0x%0x)", - portid, handle, p->portid, p->handle); - return (-1); - } - return (0); -} - -int -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); - FC_SCRATCH_ACQUIRE(isp); - isp_put_sns_request(isp, reqp, (sns_screq_t *) fcp->isp_scratch); - MEMZERO(&mbs, sizeof (mbs)); - 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); - mbs.param[6] = DMA_WD3(fcp->isp_scdma); - mbs.param[7] = DMA_WD2(fcp->isp_scdma); - mbs.logval = MBLOGALL; - mbs.timeout = 10000000; - MEMORYBARRIER(isp, SYNC_SFORDEV, 0, SNS_RFT_ID_REQ_SIZE); - isp_mboxcmd(isp, &mbs); - FC_SCRATCH_RELEASE(isp); - if (mbs.param[0] == MBOX_COMMAND_COMPLETE) { - return (0); - } else { - return (-1); - } -} - -u_int16_t -isp_nxt_handle(struct ispsoftc *isp, u_int16_t handle) -{ - int i; - if (handle == NIL_HANDLE) { - if (FCPARAM(isp)->isp_topo == TOPO_F_PORT) { - handle = 0; - } else { - handle = SNS_ID+1; - } - } else { - handle += 1; - if (handle >= FL_ID && handle <= SNS_ID) { - handle = SNS_ID+1; - } - if (handle >= NPH_RESERVED && handle <= NPH_FL_ID) { - handle = NPH_FL_ID+1; - } - if (FCPARAM(isp)->isp_2klogin) { - if (handle == NPH_MAX_2K) { - handle = 0; - } - } else { - if (handle == NPH_MAX) { - handle = 0; - } - } - } - if (handle == FCPARAM(isp)->isp_loopid) { - return (isp_nxt_handle(isp, handle)); - } - for (i = 0; i < MAX_FC_TARG; i++) { - if (FCPARAM(isp)->portdb[i].state == FC_PORTDB_STATE_NIL) { - continue; - } - if (FCPARAM(isp)->portdb[i].handle == handle) { - return (isp_nxt_handle(isp, handle)); - } - } - return (handle); -} - -/* - * Start a command. Locking is assumed done in the caller. - */ - -int -isp_start(XS_T *xs) -{ - struct ispsoftc *isp; - u_int32_t nxti, optr, handle; - u_int8_t local[QENTRY_LEN]; - ispreq_t *reqp, *qep; - void *cdbp; - u_int16_t *tptr; - int target, i, hdlidx = 0; - - 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); - } - - /* - * The firmware on the 1020/1020A doesn't seem to implement - * extended commands. Bail out early since we don't seem to - * be able to recover from issuing a command that isn't - * implemented. - */ - - if (XS_CDBLEN(xs) > 12 && isp->isp_type < ISP_HA_SCSI_1040) { - XS_SETERR(xs, HBA_BOTCH); - return (CMD_COMPLETE); - } - - /* - * Translate the target to device handle as appropriate, checking - * for correct device state as well. - */ - target = XS_TGT(xs); - if (IS_FC(isp)) { - fcparam *fcp = isp->isp_param; - - /* - * Try again later. - */ - if (fcp->isp_fwstate != FW_READY || - fcp->isp_loopstate != LOOP_READY) { - return (CMD_RQLATER); - } - - if (XS_TGT(xs) >= MAX_FC_TARG) { - XS_SETERR(xs, HBA_SELTIMEOUT); - return (CMD_COMPLETE); - } - - hdlidx = fcp->isp_ini_map[XS_TGT(xs)] - 1; -#ifndef SMALL_KERNEL - isp_prt(isp, ISP_LOGDEBUG1, "XS_TGT(xs)=%d- hdlidx value %d", - XS_TGT(xs), hdlidx); -#endif - if (hdlidx < 0 || hdlidx >= MAX_FC_TARG) { - XS_SETERR(xs, HBA_SELTIMEOUT); - return (CMD_COMPLETE); - } - if (fcp->portdb[hdlidx].state == FC_PORTDB_STATE_ZOMBIE) { - return (CMD_RQLATER); - } - if (fcp->portdb[hdlidx].state != FC_PORTDB_STATE_VALID) { - XS_SETERR(xs, HBA_SELTIMEOUT); - return (CMD_COMPLETE); - } - target = fcp->portdb[hdlidx].handle; - xs->sc_link->node_wwn = fcp->portdb[hdlidx].node_wwn; - xs->sc_link->port_wwn = fcp->portdb[hdlidx].port_wwn; - } - - /* - * Next check to see if any HBA or Device parameters need to be updated. - */ - if (isp->isp_update != 0) { - isp_update(isp); - } - - start_again: - - if (isp_getrqentry(isp, &nxti, &optr, (void *)&qep)) { -#ifndef SMALL_KERNEL - isp_prt(isp, ISP_LOGDEBUG0, "Request Queue Overflow"); -#endif - 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) { - for (i = 0; i < (IS_DUALBUS(isp)? 2: 1); i++) { - isp_marker_t *m = (isp_marker_t *) qep; - if ((isp->isp_sendmarker & (1 << i)) == 0) { - continue; - } - MEMZERO(m, QENTRY_LEN); - m->mrk_header.rqs_entry_count = 1; - m->mrk_header.rqs_entry_type = RQSTYPE_MARKER; - m->mrk_target = (i << 7); /* bus # */ - m->mrk_modifier = SYNC_ALL; - isp_put_marker(isp, m, (isp_marker_t *) qep); - ISP_ADD_REQUEST(isp, nxti); - isp->isp_sendmarker &= ~(1 << i); - goto start_again; - } - } - - 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); - } - } - cdbp = reqp->req_cdb; - tptr = &reqp->req_time; - - if (IS_SCSI(isp)) { - reqp->req_target = target | (XS_CHANNEL(xs) << 7); - reqp->req_lun_trn = XS_LUN(xs); - reqp->req_cdblen = XS_CDBLEN(xs); - } else if (FCPARAM(isp)->isp_2klogin) { - ((ispreqt2e_t *)reqp)->req_target = target; - ((ispreqt2e_t *)reqp)->req_scclun = XS_LUN(xs); - } else if (FCPARAM(isp)->isp_sccfw) { - ((ispreqt2_t *)reqp)->req_target = target; - ((ispreqt2_t *)reqp)->req_scclun = XS_LUN(xs); - } else { - ((ispreqt2_t *)reqp)->req_target = target; - ((ispreqt2_t *)reqp)->req_lun_trn = XS_LUN(xs); - } - MEMCPY(cdbp, XS_CDBP(xs), XS_CDBLEN(xs)); - - *tptr = XS_TIME(xs) / 1000; - if (*tptr == 0 && XS_TIME(xs)) { - *tptr = 1; - } - - if (isp_save_xs(isp, xs, &handle)) { -#ifndef SMALL_KERNEL - isp_prt(isp, ISP_LOGDEBUG0, "out of xflist pointers"); -#endif - XS_SETERR(xs, HBA_BOTCH); - return (CMD_EAGAIN); - } - /* Whew. Thankfully the same for type 7 requests */ - 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); -#ifndef SMALL_KERNEL - isp_prt(isp, ISP_LOGDEBUG0, - "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)); -#endif - 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_int32_t handle; - - MEMZERO(&mbs, sizeof (mbs)); - - switch (ctl) { - default: - isp_prt(isp, ISP_LOGERR, "Unknown Control Opcode 0x%x", ctl); - break; - - case ISPCTL_RESET_BUS: - /* - * Issue a bus reset. - */ - if (IS_FC(isp)) { - mbs.param[1] = 10; - bus = 0; - } else { - mbs.param[1] = SDPARAM(isp)->isp_bus_reset_delay; - if (mbs.param[1] < 2) { - mbs.param[1] = 2; - } - bus = *((int *) arg); - if (IS_DUALBUS(isp)) { - mbs.param[2] = bus; - } - } - mbs.param[0] = MBOX_BUS_RESET; - isp->isp_sendmarker |= (1 << bus); - mbs.logval = MBLOGALL; - isp_mboxcmd(isp, &mbs); - 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; - if (IS_FC(isp)) { - if (FCPARAM(isp)->isp_2klogin) { - mbs.param[1] = tgt; - mbs.ibits = (1 << 10); - } else { - mbs.param[1] = (tgt << 8); - } - bus = 0; - } else { - bus = (*((int *) arg)) >> 16; - mbs.param[1] = (bus << 15) | (tgt << 8); - } - mbs.param[0] = MBOX_ABORT_TARGET; - mbs.param[2] = 3; /* 'delay', in seconds */ - mbs.logval = MBLOGALL; - isp_mboxcmd(isp, &mbs); - 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; - } - if (IS_FC(isp)) { - if (FCPARAM(isp)->isp_sccfw) { - if (FCPARAM(isp)->isp_2klogin) { - mbs.param[1] = tgt; - } else { - mbs.param[1] = tgt << 8; - } - mbs.param[6] = XS_LUN(xs); - } else { - mbs.param[1] = tgt << 8 | XS_LUN(xs); - } - } else { - bus = XS_CHANNEL(xs); - mbs.param[1] = (bus << 15) | (tgt << 8) | XS_LUN(xs); - } - mbs.param[0] = MBOX_ABORT; - mbs.param[2] = handle; - mbs.logval = MBLOGALL & ~MBOX_COMMAND_ERROR; - isp_mboxcmd(isp, &mbs); - if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { - break; - } - return (0); - - case ISPCTL_UPDATE_PARAMS: - - isp_update(isp); - return (0); - - case ISPCTL_FCLINK_TEST: - - if (IS_FC(isp)) { - int usdelay = *((int *) arg); - if (usdelay == 0) { - usdelay = 250000; - } - return (isp_fclink_test(isp, usdelay)); - } - break; - - case ISPCTL_SCAN_FABRIC: - - if (IS_FC(isp)) { - return (isp_scan_fabric(isp)); - } - 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; - if (FCPARAM(isp)->isp_2klogin) { - mbs.ibits = (1 << 10); - } - mbs.logval = MBLOGALL; - isp_mboxcmd(isp, &mbs); - if (mbs.param[0] == MBOX_COMMAND_COMPLETE) { - return (0); - } - } - break; - - case ISPCTL_GET_PDB: - if (IS_FC(isp) && arg) { - int id = *((int *)arg); - isp_pdb_t *pdb = arg; - return (isp_getpdb(isp, id, pdb, 1)); - } - break; - - case ISPCTL_GET_PORTNAME: - { - u_int64_t *wwnp = arg; - int loopid = *wwnp; - *wwnp = isp_get_portname(isp, loopid, 0); - if (*wwnp == (u_int64_t) -1) { - break; - } else { - return (0); - } - } - case ISPCTL_RUN_MBOXCMD: - - isp_mboxcmd(isp, arg); - return(0); - - case ISPCTL_PLOGX: - { - isp_plcmd_t *p = arg; - int r; - - if ((p->flags & PLOGX_FLG_CMD_MASK) != PLOGX_FLG_CMD_PLOGI || - (p->handle != NIL_HANDLE)) { - return (isp_plogx(isp, p->handle, p->portid, - p->flags, 0)); - } - do { - p->handle = isp_nxt_handle(isp, p->handle); - r = isp_plogx(isp, p->handle, p->portid, p->flags, 0); - if ((r & 0xffff) == MBOX_PORT_ID_USED) { - p->handle = r >> 16; - r = 0; - break; - } - } while ((r & 0xffff) == MBOX_LOOP_ID_USED); - return (r); - } -#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; - mbs.logval = MBLOGALL; - isp_mboxcmd(isp, &mbs); - 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 32 -#endif - -void -isp_intr(struct ispsoftc *isp, u_int32_t isr, u_int16_t sema, u_int16_t mbox) -{ - XS_T *complist[MAX_REQUESTQ_COMPLETIONS], *xs; - u_int32_t iptr, optr, junk; - int i, nlooked = 0, ndone = 0; - -again: - optr = isp->isp_residx; - /* - * 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 obits = isp->isp_obits; - isp->isp_mboxtmp[0] = mbox; - for (i = 1; i < MAX_MAILBOX(isp); 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, - "mailbox cmd (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) { - goto out; - } - } - - /* - * We can't be getting this now. - */ - if (isp->isp_state != ISP_RUNSTATE) { - isp_prt(isp, ISP_LOGINFO, - "interrupt (ISR=%x SEMA=%x) when not ready", isr, sema); - /* - * Thank you very much! *Burrrp*! - */ - ISP_WRITE(isp, isp->isp_respoutrp, - ISP_READ(isp, isp->isp_respinrp)); - if (IS_24XX(isp)) { - ISP_DISABLE_INTS(isp); - } - goto out; - } - -#ifdef ISP_TARGET_MODE - /* - * Check for ATIO Queue entries. - */ - if (isp->isp_rspbsy == 0 && (isp->isp_role & ISP_ROLE_TARGET) && - IS_24XX(isp)) { - iptr = ISP_READ(isp, isp->isp_atioinrp); - optr = ISP_READ(isp, isp->isp_atiooutrp); - - isp->isp_rspbsy = 1; - while (optr != iptr) { - u_int8_t qe[QENTRY_LEN]; - isphdr_t *hp; - u_int32_t oop; - void *addr; - - oop = optr; - MEMORYBARRIER(isp, SYNC_ATIOQ, oop, QENTRY_LEN); - addr = ISP_QUEUE_ENTRY(isp->isp_atioq, oop); - isp_get_hdr(isp, addr, (isphdr_t *)qe); - hp = (isphdr_t *)qe; - switch (hp->rqs_entry_type) { - case RQSTYPE_NOTIFY: - case RQSTYPE_ATIO: - (void) isp_target_notify(isp, addr, &oop); - break; - default: - isp_print_qentry(isp, "?ATIOQ entry?", - oop, addr); - break; - } - optr = ISP_NXT_QENTRY(oop, RESULT_QUEUE_LEN(isp)); - ISP_WRITE(isp, isp->isp_atiooutrp, optr); - } - isp->isp_rspbsy = 0; - optr = isp->isp_residx; - } -#endif - - /* - * Get the current Response Queue Out Pointer. - * - * If we're a 2300 or 2400, 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_LOGINFO, - "isp_intr: hard optr=%x, soft optr %x", - optr, isp->isp_residx); - isp->isp_residx = optr; - } - } 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 = ISP_READ(isp, isp->isp_respinrp); - junk = ISP_READ(isp, isp->isp_respinrp); - } while (junk != iptr && ++i < 1000); - - if (iptr != junk) { - isp_prt(isp, ISP_LOGWARN, - "Response Queue Out Pointer Unstable (%x, %x)", - iptr, junk); - goto out; - } - } else { - iptr = ISP_READ(isp, isp->isp_respinrp); - } - 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 = ISP_READ(isp, isp->isp_respinrp); - 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++; -#ifndef SMALL_KERNEL - isp_prt(isp, ISP_LOGDEBUG1, - "bogus intr- isr %x (%x) iptr %x optr %x", - isr, junk, iptr, optr); -#endif - } - } - isp->isp_resodx = iptr; - - - if (isp->isp_rspbsy) { - goto out; - } - isp->isp_rspbsy = 1; - while (optr != iptr) { - u_int8_t qe[QENTRY_LEN]; - ispstatusreq_t *sp = (ispstatusreq_t *) qe; - isphdr_t *hp; - int buddaboom, etype, scsi_status, completion_status; - int req_status_flags, req_state_flags; - u_int8_t *snsp, *resp; - u_int32_t rlen, slen; - long resid; - u_int16_t oop; - - hp = (isphdr_t *) ISP_QUEUE_ENTRY(isp->isp_result, optr); - oop = optr; - optr = ISP_NXT_QENTRY(optr, RESULT_QUEUE_LEN(isp)); - nlooked++; - read_again: - buddaboom = req_status_flags = req_state_flags = 0; - resid = 0L; - - /* - * Synchronize our view of this response queue entry. - */ - MEMORYBARRIER(isp, SYNC_RESULT, oop, QENTRY_LEN); - isp_get_hdr(isp, hp, &sp->req_header); - etype = sp->req_header.rqs_entry_type; - - if (etype == RQSTYPE_RESPONSE) { - isp_get_response(isp, (ispstatusreq_t *) hp, sp); -#ifndef SMALL_KERNEL - if (isp->isp_dblev & ISP_LOGDEBUG1) { - isp_print_bytes(isp, - "Response Queue Entry", QENTRY_LEN, sp); - } -#endif - scsi_status = sp->req_scsi_status; - completion_status = sp->req_completion_status; - req_status_flags = sp->req_status_flags; - req_state_flags = sp->req_state_flags; - resid = sp->req_resid; - } else if (etype == RQSTYPE_RIO2) { - isp_rio2_t *rio = (isp_rio2_t *)qe; - isp_get_rio2(isp, (isp_rio2_t *) hp, rio); -#ifndef SMALL_KERNEL - if (isp->isp_dblev & ISP_LOGDEBUG1) { - isp_print_bytes(isp, - "Response Queue Entry", QENTRY_LEN, rio); - } -#endif - 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. - */ - int r; - r = isp_handle_other_response(isp, etype, hp, &optr); - if (r < 0) { - goto read_again; - } - if (r > 0) { - 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. - */ - - /* - * 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 (etype != RQSTYPE_REQUEST) { - isp_prt(isp, ISP_LOGERR, notresp, - etype, oop, optr, nlooked); - isp_print_bytes(isp, - "Request Queue Entry", QENTRY_LEN, sp); - MEMZERO(hp, QENTRY_LEN); /* PERF */ - continue; - } - buddaboom = 1; - scsi_status = sp->req_scsi_status; - completion_status = sp->req_completion_status; - req_status_flags = sp->req_status_flags; - req_state_flags = sp->req_state_flags; - resid = sp->req_resid; - } - - if (sp->req_header.rqs_flags & RQSFLAG_MASK) { - if (sp->req_header.rqs_flags & RQSFLAG_CONTINUATION) { - isp_prt(isp, ISP_LOGWARN, - "continuation segment"); - ISP_WRITE(isp, isp->isp_respoutrp, optr); - continue; - } - if (sp->req_header.rqs_flags & RQSFLAG_FULL) { -#ifndef SMALL_KERNEL - isp_prt(isp, ISP_LOGDEBUG1, - "internal queues full"); -#endif - /* - * We'll synthesize a QUEUE FULL message below. - */ - } - if (sp->req_header.rqs_flags & RQSFLAG_BADHEADER) { - isp_print_bytes(isp, "bad header flag", - QENTRY_LEN, sp); - buddaboom++; - } - if (sp->req_header.rqs_flags & RQSFLAG_BADPACKET) { - isp_print_bytes(isp, "bad request packet", - QENTRY_LEN, sp); - buddaboom++; - } - } - - if (sp->req_handle > isp->isp_maxcmds || sp->req_handle < 1) { - isp_prt(isp, ISP_LOGERR, - "bad request handle %d (type 0x%x)", - sp->req_handle, etype); - MEMZERO(hp, QENTRY_LEN); /* PERF */ - ISP_WRITE(isp, isp->isp_respoutrp, optr); - continue; - } - xs = isp_find_xs(isp, sp->req_handle); - if (xs == NULL) { - u_int8_t ts = completion_status & 0xff; - /* - * Only whine if this isn't the expected fallout of - * aborting the command. - */ - if (etype != RQSTYPE_RESPONSE) { - isp_prt(isp, ISP_LOGERR, - "cannot find handle 0x%x (type 0x%x)", - sp->req_handle, etype); - } else if (ts != RQCS_ABORTED) { - isp_prt(isp, ISP_LOGERR, - "cannot find handle 0x%x (status 0x%x)", - sp->req_handle, ts); - } - MEMZERO(hp, QENTRY_LEN); /* PERF */ - ISP_WRITE(isp, isp->isp_respoutrp, optr); - continue; - } - isp_destroy_handle(isp, sp->req_handle); - if (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); - } - - resp = NULL; - rlen = 0; - snsp = NULL; - slen = 0; - if (IS_FC(isp) && (scsi_status & RQCS_RV) != 0) { - resp = sp->req_response; - rlen = sp->req_response_len; - } - if (IS_FC(isp) && (scsi_status & RQCS_SV) != 0) { - /* - * 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. - */ - req_state_flags |= RQSF_GOT_STATUS|RQSF_GOT_SENSE; - snsp = sp->req_sense_data; - slen = sp->req_sense_len; - } else if (IS_SCSI(isp) && (req_state_flags & RQSF_GOT_SENSE)) { - snsp = sp->req_sense_data; - slen = sp->req_sense_len; - } - if (req_state_flags & RQSF_GOT_STATUS) { - *XS_STSP(xs) = scsi_status & 0xff; - } - - switch (etype) { - case RQSTYPE_RESPONSE: - XS_SET_STATE_STAT(isp, xs, sp); - if (resp && rlen >= 4 && - resp[FCP_RSPNS_CODE_OFFSET] != 0) { - isp_prt(isp, ISP_LOGWARN, - "%d.%d.%d FCP RESPONSE: 0x%x", - XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs), - resp[FCP_RSPNS_CODE_OFFSET]); - XS_SETERR(xs, HBA_BOTCH); - } - isp_parse_status(isp, (void *)sp, xs, &resid); - 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) = resid; - /* - * A new synchronous rate was negotiated for - * this target. Mark state such that we'll go - * look up that which has changed later. - */ - if (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 (req_status_flags & RQSF_XFER_COMPLETE) { - XS_RESID(xs) = 0; - } else if (scsi_status & RQCS_RESID) { - XS_RESID(xs) = resid; - } else { - XS_RESID(xs) = 0; - } - } - if (snsp && slen) { - XS_SAVE_SENSE(xs, snsp, slen); - } -#ifndef SMALL_KERNEL - isp_prt(isp, ISP_LOGDEBUG2, - "asked for %ld got raw resid %ld settled for %ld", - (long) XS_XFRLEN(xs), resid, (long) XS_RESID(xs)); -#endif - break; - case RQSTYPE_REQUEST: - case RQSTYPE_A64: - case RQSTYPE_T2RQS: - case RQSTYPE_T3RQS: - case RQSTYPE_T7RQS: - 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)) { - /* - * ???? - */ - XS_SETERR(xs, HBA_BOTCH); -#ifndef SMALL_KERNEL - isp_prt(isp, ISP_LOGDEBUG0, - "Request Queue Entry bounced back"); -#endif - if ((isp->isp_dblev & ISP_LOGDEBUG1) == 0) { - isp_print_bytes(isp, "Bounced Request", - QENTRY_LEN, qe); - } - } - XS_RESID(xs) = XS_XFRLEN(xs); - break; - default: - isp_print_bytes(isp, "Unhandled Response Type", - QENTRY_LEN, qe); - 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_LOGDEBUG0) && ((!XS_NOERR(xs)) || - (*XS_STSP(xs) != SCSI_GOOD)))) { - char skey; - if (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) { - ISP_WRITE(isp, isp->isp_respoutrp, optr); - /* - * While we're at it, read the requst queue out pointer. - */ - isp->isp_reqodx = ISP_READ(isp, isp->isp_rqstoutrp); - if (isp->isp_rscchiwater < ndone) { - isp->isp_rscchiwater = ndone; - } - } - -out: - - ISP_WRITE(isp, HCCR, HCCR_CMD_CLEAR_RISC_INT); - ISP_WRITE(isp, BIU_SEMA, 0); - - 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. - */ - -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; - } -#ifndef SMALL_KERNEL - isp_prt(isp, ISP_LOGDEBUG2, "Async Mbox 0x%x", mbox); -#endif - - 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: - isp->isp_state = ISP_CRASHED; - if (IS_FC(isp)) { - FCPARAM(isp)->isp_loopstate = LOOP_NIL; - FCPARAM(isp)->isp_fwstate = FW_CONFIG_WAIT; - } - /* - * Were we waiting for a mailbox command to complete? - * If so, it's dead, so wake up the waiter. - */ - if (isp->isp_mboxbsy) { - isp->isp_obits = 1; - isp->isp_mboxtmp[0] = MBOX_HOST_INTERFACE_ERROR; - MBOX_NOTIFY_COMPLETE(isp); - } - /* - * It's up to the handler for isp_async to reinit stuff and - * restart the firmware - */ - isp_async(isp, ISPASYNC_FW_CRASH, NULL); - 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 = ISP_READ(isp, isp->isp_rqstoutrp); - 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 { - /* count it as a fast posting intr */ - isp->isp_fphccmplt++; - } -#else - isp_prt(isp, ISP_LOGINFO, "Fast Posting CTIO done"); - isp->isp_fphccmplt++; /* count it as a fast posting intr */ -#endif - break; - } - case ASYNC_LIP_ERROR: - case ASYNC_LIP_F8: - case ASYNC_LIP_OCCURRED: - FCPARAM(isp)->isp_fwstate = FW_CONFIG_WAIT; - FCPARAM(isp)->isp_loopstate = LOOP_LIP_RCVD; - isp->isp_sendmarker = 1; - ISP_MARK_PORTDB(isp, 1); - 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_PORTDB(isp, 1); - 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_PORTDB(isp, 1); - 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_PORTDB(isp, 1); - 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_PORTDB(isp, 1); - isp_async(isp, ISPASYNC_CHANGE_NOTIFY, ISPASYNC_CHANGE_PDB); - break; - - case ASYNC_CHANGE_NOTIFY: - if (FCPARAM(isp)->isp_topo == TOPO_F_PORT) { - FCPARAM(isp)->isp_loopstate = LOOP_LSCAN_DONE; - } else { - FCPARAM(isp)->isp_loopstate = LOOP_PDB_RCVD; - } - ISP_MARK_PORTDB(isp, 1); - isp_async(isp, ISPASYNC_CHANGE_NOTIFY, ISPASYNC_CHANGE_SNS); - break; - - case ASYNC_PTPMODE: - ISP_MARK_PORTDB(isp, 1); - 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_PORTDB(isp, 1); - 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"); - isp_async(isp, ISPASYNC_FW_CRASH, NULL); - 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; - - case ASYNC_RJT_SENT: /* same as ASYNC_QFULL_SENT */ - if (IS_2200(isp)) { -#ifndef SMALL_KERNEL - isp_prt(isp, ISP_LOGTDEBUG0, "QFULL sent"); -#endif - break; - } - /* FALLTHROUGH */ - default: - isp_prt(isp, ISP_LOGWARN, "Unknown Async Code 0x%x", mbox); - break; - } - - if (bus & 0x100) { - int i, nh; - u_int16_t handles[16]; - - for (nh = 0, i = 1; i < MAX_MAILBOX(isp); 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]); -#ifndef SMALL_KERNEL - isp_prt(isp, ISP_LOGDEBUG3, - "fast post completion of %u", handles[i]); -#endif - } - 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. - */ - -int -isp_handle_other_response(struct ispsoftc *isp, int type, - isphdr_t *hp, u_int32_t *optrp) -{ - switch (type) { - case RQSTYPE_STATUS_CONT: -#ifndef SMALL_KERNEL - isp_prt(isp, ISP_LOGDEBUG0, "Ignored Continuation Response"); -#endif - return (1); - case RQSTYPE_MARKER: -#ifndef SMALL_KERNEL - isp_prt(isp, ISP_LOGDEBUG0, "Marker Response"); -#endif - 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: - case RQSTYPE_CTIO7: - case RQSTYPE_ABTS_RCVD: - case RQSTYPE_ABTS_RSP: - isp->isp_rsltccmplt++; /* count as a response completion */ -#ifdef ISP_TARGET_MODE - if (isp_target_notify(isp, (ispstatusreq_t *) hp, optrp)) { - return (1); - } -#endif - /* FALLTHROUGH */ - case RQSTYPE_REQUEST: - default: - USEC_DELAY(100); - if (type != isp_get_response_type(isp, hp)) { - /* - * This is questionable- we're just papering over - * something we've seen on SMP linux in target - * mode- we don't really know what's happening - * here that causes us to think we've gotten - * an entry, but that either the entry isn't - * filled out yet or our CPU read data is stale. - */ - isp_prt(isp, ISP_LOGINFO, - "unstable type in response queue"); - return (-1); - } - isp_prt(isp, ISP_LOGWARN, "Unhandled Response Type 0x%x", - isp_get_response_type(isp, hp)); - if (isp_async(isp, ISPASYNC_UNHANDLED_RESPONSE, hp)) { - return (1); - } - return (0); - } -} - -void -isp_parse_status(struct ispsoftc *isp, ispstatusreq_t *sp, XS_T *xs, long *rp) -{ - 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) { -#ifndef SMALL_KERNEL - isp_prt(isp, ISP_LOGDEBUG1, - "Selection Timeout for %d.%d.%d", - XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs)); -#endif - if (XS_NOERR(xs)) { - XS_SETERR(xs, HBA_SELTIMEOUT); - *rp = XS_XFRLEN(xs); - } - 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)); - *rp = XS_XFRLEN(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); - *rp = XS_XFRLEN(xs); - 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); - } - *rp = XS_XFRLEN(xs); - 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)); - /* - * XXX: Check to see if we logged out of the device. - */ - 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: -#ifndef SMALL_KERNEL - 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)); -#endif - - /* - * 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: - { - const char *reason; - u_int8_t sts = sp->req_completion_status & 0xff; - - /* - * It was there (maybe)- treat as a selection timeout. - */ - if (sts == RQCS_PORT_UNAVAILABLE) { - reason = "unavailable"; - } else { - reason = "logout"; - } - - isp_prt(isp, ISP_LOGINFO, "port %s for target %d", - reason, 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 log in again as a matter of course. - */ - if (FCPARAM(isp)->isp_topo == TOPO_NL_PORT || - FCPARAM(isp)->isp_topo == TOPO_FL_PORT) { - mbreg_t mbs; - MEMZERO(&mbs, sizeof (mbs)); - mbs.param[0] = MBOX_INIT_LIP; - if (FCPARAM(isp)->isp_2klogin) { - mbs.ibits = (1 << 10); - } - mbs.logval = MBLOGALL; - isp_mboxcmd_qnw(isp, &mbs, 1); - } - 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); - } -} - -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) { -#ifndef SMALL_KERNEL - isp_prt(isp, ISP_LOGDEBUG1, - "Command for fast post handle 0x%x not found", fph); -#endif - 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); -} - -int -isp_mbox_continue(struct ispsoftc *isp) -{ - mbreg_t mbs; - u_int16_t *ptr; - u_int32_t offset; - - switch (isp->isp_lastmbxcmd) { - case MBOX_WRITE_RAM_WORD: - case MBOX_READ_RAM_WORD: - case MBOX_WRITE_RAM_WORD_EXTENDED: - 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. - */ - MEMZERO(&mbs, sizeof (mbs)); - ptr = isp->isp_mbxworkp; - switch (isp->isp_lastmbxcmd) { - case MBOX_WRITE_RAM_WORD: - mbs.param[1] = isp->isp_mbxwrk1++; - mbs.param[2] = *ptr++; - break; - case MBOX_READ_RAM_WORD: - *ptr++ = isp->isp_mboxtmp[2]; - mbs.param[1] = isp->isp_mbxwrk1++; - break; - case MBOX_WRITE_RAM_WORD_EXTENDED: - offset = isp->isp_mbxwrk1; - offset |= isp->isp_mbxwrk8 << 16; - - mbs.param[2] = *ptr++; - mbs.param[1] = offset; - mbs.param[8] = offset >> 16; - isp->isp_mbxwrk1 = ++offset; - isp->isp_mbxwrk8 = offset >> 16; - break; - case MBOX_READ_RAM_WORD_EXTENDED: - offset = isp->isp_mbxwrk1; - offset |= isp->isp_mbxwrk8 << 16; - - *ptr++ = isp->isp_mboxtmp[2]; - mbs.param[1] = offset; - mbs.param[8] = offset >> 16; - isp->isp_mbxwrk1 = ++offset; - isp->isp_mbxwrk8 = offset >> 16; - break; - } - isp->isp_mbxworkp = ptr; - isp->isp_mbxwrk0--; - mbs.param[0] = isp->isp_lastmbxcmd; - mbs.logval = MBLOGALL; - isp_mboxcmd_qnw(isp, &mbs, 0); - return (0); -} - -#define HIWRD(x) ((x) >> 16) -#define LOWRD(x) ((x) & 0xffff) -#define ISPOPMAP(a, b) (((a) << 16) | (b)) -static const u_int32_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(0x07, 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: EXECUCUTE COMMAND 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 */ -}; - -#ifdef SMALL_KERNEL -#define ISP_STRIPPED -#endif - -#ifndef ISP_STRIPPED -static const 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 const u_int32_t mbpfc[] = { - ISPOPMAP(0x01, 0x01), /* 0x00: MBOX_NO_OP */ - ISPOPMAP(0x1f, 0x01), /* 0x01: MBOX_LOAD_RAM */ - ISPOPMAP(0x0f, 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, 0x07), /* 0x07: MBOX_VERIFY_CHECKSUM */ - ISPOPMAP(0x01, 0x4f), /* 0x08: MBOX_ABOUT_FIRMWARE */ - ISPOPMAP(0xdf, 0x01), /* 0x09: MBOX_LOAD_RISC_RAM_2100 */ - ISPOPMAP(0xdf, 0x01), /* 0x0a: DUMP RAM */ - ISPOPMAP(0x1ff, 0x01), /* 0x0b: MBOX_LOAD_RISC_RAM */ - ISPOPMAP(0x00, 0x00), /* 0x0c: */ - ISPOPMAP(0x10f, 0x01), /* 0x0d: MBOX_WRITE_RAM_WORD_EXTENDED */ - ISPOPMAP(0x01, 0x05), /* 0x0e: MBOX_CHECK_FIRMWARE */ - ISPOPMAP(0x10f, 0x05), /* 0x0f: MBOX_READ_RAM_WORD_EXTENDED */ - 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_COUNT */ - ISPOPMAP(0x01, 0x01), /* 0x43: MBOX_REQUEST_OFFLINE_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(0xcd, 0x01), /* 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(0x0f, 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!). The assumption - * is that we won't overflow. - */ - -#ifndef ISP_STRIPPED -static const 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", - "WRITE RAM WORD EXTENDED", - 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 COUNT", - "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 - -void -isp_mboxcmd_qnw(struct ispsoftc *isp, mbreg_t *mbp, int nodelay) -{ - unsigned int ibits, obits, box, opcode; - const u_int32_t *mcp; - - if (IS_FC(isp)) { - mcp = mbpfc; - } else { - mcp = mbpscsi; - } - opcode = mbp->param[0]; - ibits = HIWRD(mcp[opcode]) & NMBOX_BMASK(isp); - obits = LOWRD(mcp[opcode]) & NMBOX_BMASK(isp); - ibits |= mbp->ibits; - obits |= mbp->obits; - for (box = 0; box < MAX_MAILBOX(isp); 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); - } -} - -void -isp_mboxcmd(struct ispsoftc *isp, mbreg_t *mbp) -{ - const char *cname, *xname; - char tname[16], mname[16]; - unsigned int lim, ibits, obits, box, opcode; - const u_int32_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 = HIWRD(mcp[opcode]) & NMBOX_BMASK(isp); - obits = LOWRD(mcp[opcode]) & NMBOX_BMASK(isp); - - /* - * Pick up any additional bits that the caller might have set. - */ - ibits |= mbp->ibits; - obits |= mbp->obits; - - 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. - */ - if (MBOX_ACQUIRE(isp)) { - mbp->param[0] = MBOX_REGS_BUSY; - goto out; - } - - for (box = 0; box < MAX_MAILBOX(isp); box++) { - if (ibits & (1 << box)) { -#ifndef SMALL_KERNEL - isp_prt(isp, ISP_LOGDEBUG1, "IN mbox %d = 0x%04x", box, - mbp->param[box]); -#endif - 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, mbp); - - /* - * Did the command time out? - */ - if (mbp->param[0] == MBOX_TIMEOUT) { - MBOX_RELEASE(isp); - goto out; - } - - /* - * Copy back output registers. - */ - for (box = 0; box < MAX_MAILBOX(isp); box++) { - if (obits & (1 << box)) { - mbp->param[box] = isp->isp_mboxtmp[box]; -#ifndef SMALL_KERNEL - isp_prt(isp, ISP_LOGDEBUG1, "OUT mbox %d = 0x%04x", box, - mbp->param[box]); -#endif - } - } - - MBOX_RELEASE(isp); - out: - isp->isp_mboxbsy = 0; - if (mbp->logval == 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 (mbp->logval & MBLOGMASK(MBOX_COMMAND_COMPLETE)) { - xname = "INVALID COMMAND"; - } - break; - case MBOX_HOST_INTERFACE_ERROR: - if (mbp->logval & MBLOGMASK(MBOX_HOST_INTERFACE_ERROR)) { - xname = "HOST INTERFACE ERROR"; - } - break; - case MBOX_TEST_FAILED: - if (mbp->logval & MBLOGMASK(MBOX_TEST_FAILED)) { - xname = "TEST FAILED"; - } - break; - case MBOX_COMMAND_ERROR: - if (mbp->logval & MBLOGMASK(MBOX_COMMAND_ERROR)) { - xname = "COMMAND ERROR"; - } - break; - case MBOX_COMMAND_PARAM_ERROR: - if (mbp->logval & MBLOGMASK(MBOX_COMMAND_PARAM_ERROR)) { - xname = "COMMAND PARAMETER ERROR"; - } - break; - case MBOX_LOOP_ID_USED: - if (mbp->logval & MBLOGMASK(MBOX_LOOP_ID_USED)) { - xname = "LOOP ID ALREADY IN USE"; - } - break; - case MBOX_PORT_ID_USED: - if (mbp->logval & MBLOGMASK(MBOX_PORT_ID_USED)) { - xname = "PORT ID ALREADY IN USE"; - } - break; - case MBOX_ALL_IDS_USED: - if (mbp->logval & MBLOGMASK(MBOX_ALL_IDS_USED)) { - xname = "ALL LOOP IDS IN USE"; - } - break; - case MBOX_REGS_BUSY: - xname = "REGISTERS BUSY"; - break; - case MBOX_TIMEOUT: - 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); - } -} - -void -isp_fw_state(struct ispsoftc *isp) -{ - if (IS_FC(isp)) { - mbreg_t mbs; - fcparam *fcp = isp->isp_param; - - MEMZERO(&mbs, sizeof (mbs)); - mbs.param[0] = MBOX_GET_FW_STATE; - mbs.logval = MBLOGALL; - isp_mboxcmd(isp, &mbs); - if (mbs.param[0] == MBOX_COMMAND_COMPLETE) { - fcp->isp_fwstate = mbs.param[1]; - } - } -} - -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); - } -} - -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; -#ifndef SMALL_KERNEL - isp_prt(isp, ISP_LOGDEBUG0, - "skipping target %d bus %d update", tgt, bus); -#endif - 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. - */ - - MEMZERO(&mbs, sizeof (mbs)); - - /* - * Refresh overrides set - */ - if (sdp->isp_devparam[tgt].dev_refresh) { - mbs.param[0] = MBOX_GET_TARGET_PARAMS; - 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) { - 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); -#ifndef SMALL_KERNEL - 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); -#endif - get = 0; - } else { - continue; - } - mbs.param[1] = (bus << 15) | (tgt << 8); - mbs.logval = MBLOGALL; - isp_mboxcmd(isp, &mbs); - if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { - continue; - } - if (get == 0) { - isp->isp_sendmarker |= (1 << bus); - sdp->isp_devparam[tgt].dev_update = 0; - sdp->isp_devparam[tgt].dev_refresh = 1; - } else { - sdp->isp_devparam[tgt].dev_refresh = 0; - 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_EXEC_THROTTLE -#define DEFAULT_EXEC_THROTTLE(isp) ISP_EXEC_THROTTLE -#endif - -void -isp_setdfltparm(struct ispsoftc *isp, int channel) -{ - int tgt; - sdparam *sdp; - - sdp = (sdparam *) isp->isp_param; - sdp += channel; - - /* - * Been there, done that, got the T-shirt... - */ - if (sdp->isp_gotdparms) { - return; - } - sdp->isp_gotdparms = 1; - sdp->isp_bad_nvram = 0; - /* - * 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; - } - sdp->isp_bad_nvram = 1; - } - - /* - * Now try and see whether we have specific values for them. - */ - if ((isp->isp_confopts & ISP_CFG_NONVRAM) == 0) { - mbreg_t mbs; - - MEMZERO(&mbs, sizeof (mbs)); - mbs.param[0] = MBOX_GET_ACT_NEG_STATE; - mbs.logval = MBLOGNONE; - isp_mboxcmd(isp, &mbs); - 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; - } - } - -#ifndef SMALL_KERNEL - 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); -#endif - - /* - * 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; - -#ifndef SMALL_KERNEL - 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); -#endif - } -} - -#ifndef DEFAULT_FRAMESIZE -#define DEFAULT_FRAMESIZE(isp) ICB_DFLT_FRMLEN -#endif -void -isp_setdfltfcparm(struct ispsoftc *isp) -{ - fcparam *fcp = FCPARAM(isp); - - if (fcp->isp_gotdparms) { - return; - } - fcp->isp_gotdparms = 1; - fcp->isp_bad_nvram = 0; - 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_wwnn_nvram = DEFAULT_NODEWWN(isp); - fcp->isp_wwpn_nvram = DEFAULT_PORTWWN(isp); - fcp->isp_fwoptions = 0; - fcp->isp_fwoptions |= ICBOPT_FAIRNESS; - fcp->isp_fwoptions |= ICBOPT_PDBCHANGE_AE; - fcp->isp_fwoptions |= ICBOPT_HARD_ADDRESS; - fcp->isp_fwoptions |= ICBOPT_FAST_POST; - 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_wwnn_nvram && isp_wwpn_nvram. - */ - if ((isp->isp_confopts & ISP_CFG_NONVRAM) == 0) { - int i, j = 0; - /* - * Give a couple of tries at reading NVRAM. - */ - for (i = 0; i < 2; i++) { - j = isp_read_nvram(isp); - if (j == 0) { - break; - } - } - if (j) { - fcp->isp_bad_nvram = 1; - isp->isp_confopts |= ISP_CFG_NONVRAM; - isp->isp_confopts |= ISP_CFG_OWNWWPN; - isp->isp_confopts |= ISP_CFG_OWNWWNN; - } - } else { - isp->isp_confopts |= ISP_CFG_OWNWWPN|ISP_CFG_OWNWWNN; - } - - /* - * 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 (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_wwnn_nvram; - if (fcp->isp_wwnn_nvram == 0) { - isp_prt(isp, ISP_LOGCONFIG, - "bad WWNN- using default"); - ISP_NODEWWN(isp) = DEFAULT_NODEWWN(isp); - } - } - 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_wwpn_nvram; - if (fcp->isp_wwpn_nvram == 0) { - isp_prt(isp, ISP_LOGCONFIG, - "bad WWPN- using default"); - ISP_PORTWWN(isp) = DEFAULT_PORTWWN(isp); - } - } -} - -/* - * 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. - */ - -void -isp_reinit(struct ispsoftc *isp) -{ - XS_T *xs; - u_int32_t tmp; - - if (IS_FC(isp)) { - ISP_MARK_PORTDB(isp, 0); - } - 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_DISABLE_INTS(isp); - } - } else { - ISP_DISABLE_INTS(isp); - if (IS_FC(isp)) { - /* - * If we're in ISP_ROLE_NONE, turn off the lasers. - */ - if (!IS_24XX(isp)) { - 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); - } - } - } - isp->isp_nactive = 0; - - for (tmp = 0; tmp < isp->isp_maxcmds; tmp++) { - u_int32_t handle; - - xs = isp->isp_xflist[tmp]; - if (xs == NULL) { - continue; - } - handle = isp_find_handle(isp, xs); - if (handle == 0) { - 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); - } -#ifdef ISP_TARGET_MODE - MEMZERO(isp->isp_tgtlist, isp->isp_maxcmds * sizeof (void **)); -#endif -} - -/* - * NVRAM Routines - */ -int -isp_read_nvram(struct ispsoftc *isp) -{ - int i, amt, retval; - 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; - } - - for (i = 0; i < amt>>1; 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) { - if (nvram_data[0] != 0 || nvram_data[1] != 0 || - nvram_data[2] != 0) - isp_prt(isp, ISP_LOGWARN, - "invalid NVRAM header"); -#ifndef SMALL_KERNEL - isp_prt(isp, ISP_LOGDEBUG0, "%x %x %x", - nvram_data[0], nvram_data[1], nvram_data[2]); -#endif - } - retval = -1; - goto out; - } - - for (csum = 0, i = 0; i < amt; i++) { - csum += nvram_data[i]; - } - if (csum != 0) { - isp_prt(isp, ISP_LOGWARN, "invalid NVRAM checksum"); - retval = -1; - goto out; - } - - if (ISP_NVRAM_VERSION(nvram_data) < minversion) { - isp_prt(isp, ISP_LOGWARN, "version %d NVRAM not understood", - ISP_NVRAM_VERSION(nvram_data)); - retval = -1; - goto out; - } - - 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); - } - retval = 0; -out: - return (retval); -#undef nvram_data -#undef nvram_words -} - -void -isp_rdnvram_word(struct ispsoftc *isp, int wo, u_int16_t *rp) -{ - int i, cbits; - u_int16_t bit, rqst, junk; - - ISP_WRITE(isp, BIU_NVRAM, BIU_NVRAM_SELECT); - USEC_DELAY(10); - ISP_WRITE(isp, BIU_NVRAM, BIU_NVRAM_SELECT|BIU_NVRAM_CLOCK); - USEC_DELAY(10); - - 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(10); - junk = ISP_READ(isp, BIU_NVRAM); /* force PCI flush */ - ISP_WRITE(isp, BIU_NVRAM, bit | BIU_NVRAM_CLOCK); - USEC_DELAY(10); - junk = ISP_READ(isp, BIU_NVRAM); /* force PCI flush */ - ISP_WRITE(isp, BIU_NVRAM, bit); - USEC_DELAY(10); - junk = ISP_READ(isp, BIU_NVRAM); /* force PCI flush */ - } - /* - * 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(10); - rv = ISP_READ(isp, BIU_NVRAM); - if (rv & BIU_NVRAM_DATAIN) { - *rp |= 1; - } - USEC_DELAY(10); - ISP_WRITE(isp, BIU_NVRAM, BIU_NVRAM_SELECT); - USEC_DELAY(10); - junk = ISP_READ(isp, BIU_NVRAM); /* force PCI flush */ - } - ISP_WRITE(isp, BIU_NVRAM, 0); - USEC_DELAY(10); - junk = ISP_READ(isp, BIU_NVRAM); /* force PCI flush */ - ISP_SWIZZLE_NVRAM_WORD(isp, rp); -} - -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); - -#ifndef SMALL_KERNEL - 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); -#endif - - 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 */ -#ifndef SMALL_KERNEL - 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); -#endif - 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; - } -} - -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); - -#ifndef SMALL_KERNEL - 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); -#endif - - - 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; -#ifndef SMALL_KERNEL - 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); -#endif - 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; - } -} - -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); - -#ifndef SMALL_KERNEL - 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); -#endif - - 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; -#ifndef SMALL_KERNEL - 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); -#endif - 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; - } -} - -void -isp_fix_nvram_wwns(struct ispsoftc *isp) -{ - fcparam *fcp = FCPARAM(isp); - - /* - * Make sure we have both Node and Port as non-zero values. - */ - if (fcp->isp_wwnn_nvram != 0 && fcp->isp_wwpn_nvram == 0) { - fcp->isp_wwpn_nvram = fcp->isp_wwnn_nvram; - } else if (fcp->isp_wwnn_nvram == 0 && fcp->isp_wwpn_nvram != 0) { - fcp->isp_wwnn_nvram = fcp->isp_wwpn_nvram; - } - - /* - * 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_wwnn_nvram && fcp->isp_wwpn_nvram) { - if ((fcp->isp_wwnn_nvram & (((u_int64_t) 0xfff) << 48)) != 0 && - (fcp->isp_wwnn_nvram >> 60) == 2) { - fcp->isp_wwnn_nvram &= ~((u_int64_t) 0xfff << 48); - } - if ((fcp->isp_wwpn_nvram & (((u_int64_t) 0xfff) << 48)) == 0 && - (fcp->isp_wwpn_nvram >> 60) == 2) { - fcp->isp_wwpn_nvram |= ((u_int64_t) 1 << 56); - } - } -} - -void -isp_parse_nvram_2100(struct ispsoftc *isp, u_int8_t *nvram_data) -{ - fcparam *fcp = FCPARAM(isp); - 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_wwpn_nvram = wwn; - if (IS_2200(isp) || IS_23XX(isp)) { - wwn = ISP2100_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_wwnn_nvram = wwn; - - isp_fix_nvram_wwns(isp); - - 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); -#ifndef SMALL_KERNEL - isp_prt(isp, ISP_LOGDEBUG0, - "NVRAM 0x%08x%08x 0x%08x%08x maxalloc %d maxframelen %d", - (u_int32_t) (fcp->isp_wwnn_nvram >> 32), (u_int32_t) fcp->isp_wwnn_nvram, - (u_int32_t) (fcp->isp_wwpn_nvram >> 32), (u_int32_t) fcp->isp_wwpn_nvram, - ISP2100_NVRAM_MAXIOCBALLOCATION(nvram_data), - ISP2100_NVRAM_MAXFRAMELENGTH(nvram_data)); - isp_prt(isp, ISP_LOGDEBUG0, - "execthrottle %d fwoptions 0x%x hardloop %d tov %d", - ISP2100_NVRAM_EXECUTION_THROTTLE(nvram_data), - ISP2100_NVRAM_OPTIONS(nvram_data), - ISP2100_NVRAM_HARDLOOPID(nvram_data), - ISP2100_NVRAM_TOV(nvram_data)); -#endif - fcp->isp_xfwoptions = ISP2100_XFW_OPTIONS(nvram_data); - fcp->isp_zfwoptions = ISP2100_ZFW_OPTIONS(nvram_data); -#ifndef SMALL_KERNEL - isp_prt(isp, ISP_LOGDEBUG0, - "xfwoptions 0x%x zfw options 0x%x", - ISP2100_XFW_OPTIONS(nvram_data), ISP2100_ZFW_OPTIONS(nvram_data)); -#endif -} - -#ifdef ISP_FW_CRASH_DUMP -void isp2200_fw_dump(struct ispsoftc *); -void isp2300_fw_dump(struct ispsoftc *); - -void -isp2200_fw_dump(struct ispsoftc *isp) -{ - int i, j; - mbreg_t mbs; - u_int16_t *ptr; - - MEMZERO(&mbs, sizeof (mbs)); - 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; - } - } - ISP_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 successfully"); - FCPARAM(isp)->isp_dump_data[0] = isp->isp_type; /* now used */ - (void) isp_async(isp, ISPASYNC_FW_DUMPED, 0); -} - -void -isp2300_fw_dump(struct ispsoftc *isp) -{ - int i, j; - mbreg_t mbs; - u_int16_t *ptr; - - MEMZERO(&mbs, sizeof (mbs)); - 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; - } - ISP_ENABLE_INTS(isp); - MEMZERO(&mbs, sizeof (mbs)); - 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]; - MEMZERO(&mbs, sizeof (mbs)); - mbs.param[0] = MBOX_READ_RAM_WORD_EXTENDED; - mbs.param[8] = 1; - isp->isp_mbxworkp = (void *) ptr; - isp->isp_mbxwrk0 = 0xffff; /* continuation count */ - isp->isp_mbxwrk1 = 0x1; /* next SRAM address */ - isp->isp_mbxwrk8 = 0x1; - 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 successfully"); - 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 --git a/sys/dev/ic/isp_library.c b/sys/dev/ic/isp_library.c deleted file mode 100644 index ef11791567a..00000000000 --- a/sys/dev/ic/isp_library.c +++ /dev/null @@ -1,2678 +0,0 @@ -/* $OpenBSD: isp_library.c,v 1.4 2014/02/14 05:17:05 jmatthew Exp $ */ -/*- - * Copyright (c) 1997-2007 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. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY 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 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. - */ -/* - * QLogic Host Adapter Internal Library Functions - */ -#ifdef __NetBSD__ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD$"); -#include <dev/ic/isp_netbsd.h> -#endif -#ifdef __FreeBSD__ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/dev/isp/isp_library.c,v 1.14 2007/07/02 20:08:20 mjacob Exp $"); -#include <dev/isp/isp_freebsd.h> -#endif -#ifdef __OpenBSD__ -#include <dev/ic/isp_openbsd.h> -#endif -#ifdef __linux__ -#include "isp_linux.h" -#endif -#ifdef __svr4__ -#include "isp_solaris.h" -#endif - -int -isp_save_xs(struct ispsoftc *isp, XS_T *xs, u_int32_t *handlep) -{ - u_int16_t i, j; - - for (j = isp->isp_lasthdls, i = 0; i < 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_int32_t)j; - return (0); -} - -XS_T * -isp_find_xs(struct ispsoftc *isp, u_int32_t handle) -{ - if (handle < 1 || handle > (u_int32_t) isp->isp_maxcmds) { - return (NULL); - } else { - return (isp->isp_xflist[handle - 1]); - } -} - -u_int32_t -isp_find_handle(struct ispsoftc *isp, XS_T *xs) -{ - u_int16_t i; - if (xs != NULL) { - for (i = 0; i < isp->isp_maxcmds; i++) { - if (isp->isp_xflist[i] == xs) { - return ((u_int32_t) (i+1)); - } - } - } - return (0); -} - -u_int32_t -isp_handle_index(u_int32_t handle) -{ - return (handle - 1); -} - -void -isp_destroy_handle(struct ispsoftc *isp, u_int32_t handle) -{ - if (handle > 0 && handle <= (u_int32_t) isp->isp_maxcmds) { - isp->isp_xflist[handle - 1] = NULL; - } -} - -int -isp_getrqentry(struct ispsoftc *isp, u_int32_t *iptrp, - u_int32_t *optrp, void **resultp) -{ - volatile u_int32_t iptr, optr; - - optr = isp->isp_reqodx = ISP_READ(isp, isp->isp_rqstoutrp); - 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); -} - -#define TBA (4 * (((QENTRY_LEN >> 2) * 3) + 1) + 1) -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); - } -} - -void -isp_print_bytes(struct ispsoftc *isp, const 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 assume we enter here with any locks held. - */ - -int -isp_fc_runstate(struct ispsoftc *isp, int tval) -{ - fcparam *fcp; - int *tptr; - - if (isp->isp_role == ISP_ROLE_NONE) { - return (0); - } - fcp = FCPARAM(isp); - tptr = &tval; - if (fcp->isp_fwstate < FW_READY || - fcp->isp_loopstate < LOOP_PDB_RCVD) { - if (isp_control(isp, ISPCTL_FCLINK_TEST, tptr) != 0) { - isp_prt(isp, ISP_LOGSANCFG, - "isp_fc_runstate: linktest failed"); - return (-1); - } - if (fcp->isp_fwstate != FW_READY || - fcp->isp_loopstate < LOOP_PDB_RCVD) { - isp_prt(isp, ISP_LOGSANCFG, - "isp_fc_runstate: f/w not ready"); - return (-1); - } - } - if ((isp->isp_role & ISP_ROLE_INITIATOR) == 0) { - return (0); - } - if (isp_control(isp, ISPCTL_SCAN_LOOP, NULL) != 0) { - isp_prt(isp, ISP_LOGSANCFG, - "isp_fc_runstate: scan loop fails"); - return (LOOP_PDB_RCVD); - } - if (isp_control(isp, ISPCTL_SCAN_FABRIC, NULL) != 0) { - isp_prt(isp, ISP_LOGSANCFG, - "isp_fc_runstate: scan fabric fails"); - return (LOOP_LSCAN_DONE); - } - if (isp_control(isp, ISPCTL_PDB_SYNC, NULL) != 0) { - isp_prt(isp, ISP_LOGSANCFG, "isp_fc_runstate: pdb_sync fails"); - return (LOOP_FSCAN_DONE); - } - if (fcp->isp_fwstate != FW_READY || fcp->isp_loopstate != LOOP_READY) { - isp_prt(isp, ISP_LOGSANCFG, - "isp_fc_runstate: f/w not ready again"); - return (-1); - } - return (0); -} - -/* - * Fibre Channel Support- get the port database for the id. - */ -void -isp_dump_portdb(struct ispsoftc *isp) -{ - fcparam *fcp = (fcparam *) isp->isp_param; - int i; - - for (i = 0; i < MAX_FC_TARG; i++) { - char mb[4]; - const char *dbs[8] = { - "NIL ", - "PROB", - "DEAD", - "CHGD", - "NEW ", - "PVLD", - "ZOMB", - "VLD " - }; - const char *roles[4] = { - " UNK", " TGT", " INI", "TINI" - }; - fcportdb_t *lp = &fcp->portdb[i]; - - if (lp->state == FC_PORTDB_STATE_NIL) { - continue; - } - if (lp->ini_map_idx) { - SNPRINTF(mb, sizeof (mb), "%3d", - ((int) lp->ini_map_idx) - 1); - } else { - SNPRINTF(mb, sizeof (mb), "---"); - } - isp_prt(isp, ISP_LOGALL, "%d: hdl 0x%x %s al%d tgt %s %s " - "0x%06x =>%s 0x%06x; WWNN 0x%08x%08x WWPN 0x%08x%08x", i, - lp->handle, dbs[lp->state], lp->autologin, mb, - roles[lp->roles], lp->portid, - roles[lp->new_roles], lp->new_portid, - (u_int32_t) (lp->node_wwn >> 32), - (u_int32_t) (lp->node_wwn), - (u_int32_t) (lp->port_wwn >> 32), - (u_int32_t) (lp->port_wwn)); - } -} - -void -isp_shutdown(struct ispsoftc *isp) -{ - if (IS_FC(isp)) { - ISP_WRITE(isp, BIU_ICR, 0); - ISP_WRITE(isp, HCCR, HCCR_CMD_PAUSE); - 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 { - ISP_WRITE(isp, BIU_ICR, 0); - ISP_WRITE(isp, HCCR, HCCR_CMD_PAUSE); - } -} - -/* - * 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). - */ - -#define ISP_IS_SBUS(isp) \ - (ISP_SBUS_SUPPORTED && (isp)->isp_bustype == ISP_BT_SBUS) - -#define ASIZE(x) (sizeof (x) / sizeof (x[0])) -/* - * Swizzle/Copy Functions - */ -void -isp_put_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); - } -} - -void -isp_get_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); - } -} - -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); -} - -void -isp_put_request(struct ispsoftc *isp, ispreq_t *rqsrc, ispreq_t *rqdst) -{ - int i; - isp_put_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 < ASIZE(rqsrc->req_cdb); 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); - } -} - -void -isp_put_marker(struct ispsoftc *isp, isp_marker_t *src, isp_marker_t *dst) -{ - int i; - isp_put_hdr(isp, &src->mrk_header, &dst->mrk_header); - ISP_IOXPUT_32(isp, src->mrk_handle, &dst->mrk_handle); - if (ISP_IS_SBUS(isp)) { - ISP_IOXPUT_8(isp, src->mrk_reserved0, &dst->mrk_target); - ISP_IOXPUT_8(isp, src->mrk_target, &dst->mrk_reserved0); - } else { - ISP_IOXPUT_8(isp, src->mrk_reserved0, &dst->mrk_reserved0); - ISP_IOXPUT_8(isp, src->mrk_target, &dst->mrk_target); - } - ISP_IOXPUT_16(isp, src->mrk_modifier, &dst->mrk_modifier); - ISP_IOXPUT_16(isp, src->mrk_flags, &dst->mrk_flags); - ISP_IOXPUT_16(isp, src->mrk_lun, &dst->mrk_lun); - for (i = 0; i < ASIZE(src->mrk_reserved1); i++) { - ISP_IOXPUT_8(isp, src->mrk_reserved1[i], - &dst->mrk_reserved1[i]); - } -} - -void -isp_put_request_t2(struct ispsoftc *isp, ispreqt2_t *src, ispreqt2_t *dst) -{ - int i; - isp_put_hdr(isp, &src->req_header, &dst->req_header); - ISP_IOXPUT_32(isp, src->req_handle, &dst->req_handle); - ISP_IOXPUT_8(isp, src->req_lun_trn, &dst->req_lun_trn); - ISP_IOXPUT_8(isp, src->req_target, &dst->req_target); - ISP_IOXPUT_16(isp, src->req_scclun, &dst->req_scclun); - ISP_IOXPUT_16(isp, src->req_flags, &dst->req_flags); - ISP_IOXPUT_16(isp, src->req_reserved, &dst->req_reserved); - ISP_IOXPUT_16(isp, src->req_time, &dst->req_time); - ISP_IOXPUT_16(isp, src->req_seg_count, &dst->req_seg_count); - for (i = 0; i < ASIZE(src->req_cdb); i++) { - ISP_IOXPUT_8(isp, src->req_cdb[i], &dst->req_cdb[i]); - } - ISP_IOXPUT_32(isp, src->req_totalcnt, &dst->req_totalcnt); - for (i = 0; i < ISP_RQDSEG_T2; i++) { - ISP_IOXPUT_32(isp, src->req_dataseg[i].ds_base, - &dst->req_dataseg[i].ds_base); - ISP_IOXPUT_32(isp, src->req_dataseg[i].ds_count, - &dst->req_dataseg[i].ds_count); - } -} - -void -isp_put_request_t2e(struct ispsoftc *isp, ispreqt2e_t *src, ispreqt2e_t *dst) -{ - int i; - isp_put_hdr(isp, &src->req_header, &dst->req_header); - ISP_IOXPUT_32(isp, src->req_handle, &dst->req_handle); - ISP_IOXPUT_16(isp, src->req_target, &dst->req_target); - ISP_IOXPUT_16(isp, src->req_scclun, &dst->req_scclun); - ISP_IOXPUT_16(isp, src->req_flags, &dst->req_flags); - ISP_IOXPUT_16(isp, src->req_reserved, &dst->req_reserved); - ISP_IOXPUT_16(isp, src->req_time, &dst->req_time); - ISP_IOXPUT_16(isp, src->req_seg_count, &dst->req_seg_count); - for (i = 0; i < ASIZE(src->req_cdb); i++) { - ISP_IOXPUT_8(isp, src->req_cdb[i], &dst->req_cdb[i]); - } - ISP_IOXPUT_32(isp, src->req_totalcnt, &dst->req_totalcnt); - for (i = 0; i < ISP_RQDSEG_T2; i++) { - ISP_IOXPUT_32(isp, src->req_dataseg[i].ds_base, - &dst->req_dataseg[i].ds_base); - ISP_IOXPUT_32(isp, src->req_dataseg[i].ds_count, - &dst->req_dataseg[i].ds_count); - } -} - -void -isp_put_request_t3(struct ispsoftc *isp, ispreqt3_t *src, ispreqt3_t *dst) -{ - int i; - isp_put_hdr(isp, &src->req_header, &dst->req_header); - ISP_IOXPUT_32(isp, src->req_handle, &dst->req_handle); - ISP_IOXPUT_8(isp, src->req_lun_trn, &dst->req_lun_trn); - ISP_IOXPUT_8(isp, src->req_target, &dst->req_target); - ISP_IOXPUT_16(isp, src->req_scclun, &dst->req_scclun); - ISP_IOXPUT_16(isp, src->req_flags, &dst->req_flags); - ISP_IOXPUT_16(isp, src->req_reserved, &dst->req_reserved); - ISP_IOXPUT_16(isp, src->req_time, &dst->req_time); - ISP_IOXPUT_16(isp, src->req_seg_count, &dst->req_seg_count); - for (i = 0; i < ASIZE(src->req_cdb); i++) { - ISP_IOXPUT_8(isp, src->req_cdb[i], &dst->req_cdb[i]); - } - ISP_IOXPUT_32(isp, src->req_totalcnt, &dst->req_totalcnt); - for (i = 0; i < ISP_RQDSEG_T3; i++) { - ISP_IOXPUT_32(isp, src->req_dataseg[i].ds_base, - &dst->req_dataseg[i].ds_base); - ISP_IOXPUT_32(isp, src->req_dataseg[i].ds_basehi, - &dst->req_dataseg[i].ds_basehi); - ISP_IOXPUT_32(isp, src->req_dataseg[i].ds_count, - &dst->req_dataseg[i].ds_count); - } -} - -void -isp_put_request_t3e(struct ispsoftc *isp, ispreqt3e_t *src, ispreqt3e_t *dst) -{ - int i; - isp_put_hdr(isp, &src->req_header, &dst->req_header); - ISP_IOXPUT_32(isp, src->req_handle, &dst->req_handle); - ISP_IOXPUT_16(isp, src->req_target, &dst->req_target); - ISP_IOXPUT_16(isp, src->req_scclun, &dst->req_scclun); - ISP_IOXPUT_16(isp, src->req_flags, &dst->req_flags); - ISP_IOXPUT_16(isp, src->req_reserved, &dst->req_reserved); - ISP_IOXPUT_16(isp, src->req_time, &dst->req_time); - ISP_IOXPUT_16(isp, src->req_seg_count, &dst->req_seg_count); - for (i = 0; i < ASIZE(src->req_cdb); i++) { - ISP_IOXPUT_8(isp, src->req_cdb[i], &dst->req_cdb[i]); - } - ISP_IOXPUT_32(isp, src->req_totalcnt, &dst->req_totalcnt); - for (i = 0; i < ISP_RQDSEG_T3; i++) { - ISP_IOXPUT_32(isp, src->req_dataseg[i].ds_base, - &dst->req_dataseg[i].ds_base); - ISP_IOXPUT_32(isp, src->req_dataseg[i].ds_basehi, - &dst->req_dataseg[i].ds_basehi); - ISP_IOXPUT_32(isp, src->req_dataseg[i].ds_count, - &dst->req_dataseg[i].ds_count); - } -} - -void -isp_put_extended_request(struct ispsoftc *isp, ispextreq_t *src, ispextreq_t *dst) -{ - int i; - isp_put_hdr(isp, &src->req_header, &dst->req_header); - ISP_IOXPUT_32(isp, src->req_handle, &dst->req_handle); - if (ISP_IS_SBUS(isp)) { - ISP_IOXPUT_8(isp, src->req_lun_trn, &dst->req_target); - ISP_IOXPUT_8(isp, src->req_target, &dst->req_lun_trn); - } else { - ISP_IOXPUT_8(isp, src->req_lun_trn, &dst->req_lun_trn); - ISP_IOXPUT_8(isp, src->req_target, &dst->req_target); - } - ISP_IOXPUT_16(isp, src->req_cdblen, &dst->req_cdblen); - ISP_IOXPUT_16(isp, src->req_flags, &dst->req_flags); - ISP_IOXPUT_16(isp, src->req_time, &dst->req_time); - ISP_IOXPUT_16(isp, src->req_seg_count, &dst->req_seg_count); - for (i = 0; i < ASIZE(src->req_cdb); i++) { - ISP_IOXPUT_8(isp, src->req_cdb[i], &dst->req_cdb[i]); - } -} - -void -isp_put_cont_req(struct ispsoftc *isp, ispcontreq_t *src, ispcontreq_t *dst) -{ - int i; - isp_put_hdr(isp, &src->req_header, &dst->req_header); - for (i = 0; i < ISP_CDSEG; i++) { - ISP_IOXPUT_32(isp, src->req_dataseg[i].ds_base, - &dst->req_dataseg[i].ds_base); - ISP_IOXPUT_32(isp, src->req_dataseg[i].ds_count, - &dst->req_dataseg[i].ds_count); - } -} - -void -isp_put_cont64_req(struct ispsoftc *isp, ispcontreq64_t *src, ispcontreq64_t *dst) -{ - int i; - isp_put_hdr(isp, &src->req_header, &dst->req_header); - for (i = 0; i < ISP_CDSEG64; i++) { - ISP_IOXPUT_32(isp, src->req_dataseg[i].ds_base, - &dst->req_dataseg[i].ds_base); - ISP_IOXPUT_32(isp, src->req_dataseg[i].ds_basehi, - &dst->req_dataseg[i].ds_basehi); - ISP_IOXPUT_32(isp, src->req_dataseg[i].ds_count, - &dst->req_dataseg[i].ds_count); - } -} - -void -isp_get_response(struct ispsoftc *isp, ispstatusreq_t *src, ispstatusreq_t *dst) -{ - int i; - isp_get_hdr(isp, &src->req_header, &dst->req_header); - ISP_IOXGET_32(isp, &src->req_handle, dst->req_handle); - ISP_IOXGET_16(isp, &src->req_scsi_status, dst->req_scsi_status); - ISP_IOXGET_16(isp, &src->req_completion_status, - dst->req_completion_status); - ISP_IOXGET_16(isp, &src->req_state_flags, dst->req_state_flags); - ISP_IOXGET_16(isp, &src->req_status_flags, dst->req_status_flags); - ISP_IOXGET_16(isp, &src->req_time, dst->req_time); - ISP_IOXGET_16(isp, &src->req_sense_len, dst->req_sense_len); - ISP_IOXGET_32(isp, &src->req_resid, dst->req_resid); - for (i = 0; i < 8; i++) { - ISP_IOXGET_8(isp, &src->req_response[i], - dst->req_response[i]); - } - for (i = 0; i < 32; i++) { - ISP_IOXGET_8(isp, &src->req_sense_data[i], - dst->req_sense_data[i]); - } -} - -void -isp_get_rio2(struct ispsoftc *isp, isp_rio2_t *r2src, isp_rio2_t *r2dst) -{ - int i; - isp_get_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; - } -} - -void -isp_put_icb(struct ispsoftc *isp, isp_icb_t *src, isp_icb_t *dst) -{ - int i; - if (ISP_IS_SBUS(isp)) { - ISP_IOXPUT_8(isp, src->icb_version, &dst->icb_reserved0); - ISP_IOXPUT_8(isp, src->icb_reserved0, &dst->icb_version); - } else { - ISP_IOXPUT_8(isp, src->icb_version, &dst->icb_version); - ISP_IOXPUT_8(isp, src->icb_reserved0, &dst->icb_reserved0); - } - ISP_IOXPUT_16(isp, src->icb_fwoptions, &dst->icb_fwoptions); - ISP_IOXPUT_16(isp, src->icb_maxfrmlen, &dst->icb_maxfrmlen); - ISP_IOXPUT_16(isp, src->icb_maxalloc, &dst->icb_maxalloc); - ISP_IOXPUT_16(isp, src->icb_execthrottle, &dst->icb_execthrottle); - if (ISP_IS_SBUS(isp)) { - ISP_IOXPUT_8(isp, src->icb_retry_count, &dst->icb_retry_delay); - ISP_IOXPUT_8(isp, src->icb_retry_delay, &dst->icb_retry_count); - } else { - ISP_IOXPUT_8(isp, src->icb_retry_count, &dst->icb_retry_count); - ISP_IOXPUT_8(isp, src->icb_retry_delay, &dst->icb_retry_delay); - } - for (i = 0; i < 8; i++) { - ISP_IOXPUT_8(isp, src->icb_portname[i], &dst->icb_portname[i]); - } - ISP_IOXPUT_16(isp, src->icb_hardaddr, &dst->icb_hardaddr); - if (ISP_IS_SBUS(isp)) { - ISP_IOXPUT_8(isp, src->icb_iqdevtype, &dst->icb_logintime); - ISP_IOXPUT_8(isp, src->icb_logintime, &dst->icb_iqdevtype); - } else { - ISP_IOXPUT_8(isp, src->icb_iqdevtype, &dst->icb_iqdevtype); - ISP_IOXPUT_8(isp, src->icb_logintime, &dst->icb_logintime); - } - for (i = 0; i < 8; i++) { - ISP_IOXPUT_8(isp, src->icb_nodename[i], &dst->icb_nodename[i]); - } - ISP_IOXPUT_16(isp, src->icb_rqstout, &dst->icb_rqstout); - ISP_IOXPUT_16(isp, src->icb_rspnsin, &dst->icb_rspnsin); - ISP_IOXPUT_16(isp, src->icb_rqstqlen, &dst->icb_rqstqlen); - ISP_IOXPUT_16(isp, src->icb_rsltqlen, &dst->icb_rsltqlen); - for (i = 0; i < 4; i++) { - ISP_IOXPUT_16(isp, src->icb_rqstaddr[i], &dst->icb_rqstaddr[i]); - } - for (i = 0; i < 4; i++) { - ISP_IOXPUT_16(isp, src->icb_respaddr[i], &dst->icb_respaddr[i]); - } - ISP_IOXPUT_16(isp, src->icb_lunenables, &dst->icb_lunenables); - if (ISP_IS_SBUS(isp)) { - ISP_IOXPUT_8(isp, src->icb_ccnt, &dst->icb_icnt); - ISP_IOXPUT_8(isp, src->icb_icnt, &dst->icb_ccnt); - } else { - ISP_IOXPUT_8(isp, src->icb_ccnt, &dst->icb_ccnt); - ISP_IOXPUT_8(isp, src->icb_icnt, &dst->icb_icnt); - } - ISP_IOXPUT_16(isp, src->icb_lunetimeout, &dst->icb_lunetimeout); - ISP_IOXPUT_16(isp, src->icb_reserved1, &dst->icb_reserved1); - ISP_IOXPUT_16(isp, src->icb_xfwoptions, &dst->icb_xfwoptions); - if (ISP_IS_SBUS(isp)) { - ISP_IOXPUT_8(isp, src->icb_racctimer, &dst->icb_idelaytimer); - ISP_IOXPUT_8(isp, src->icb_idelaytimer, &dst->icb_racctimer); - } else { - ISP_IOXPUT_8(isp, src->icb_racctimer, &dst->icb_racctimer); - ISP_IOXPUT_8(isp, src->icb_idelaytimer, &dst->icb_idelaytimer); - } - ISP_IOXPUT_16(isp, src->icb_zfwoptions, &dst->icb_zfwoptions); -} - -void -isp_get_pdb_21xx(struct ispsoftc *isp, isp_pdb_21xx_t *src, isp_pdb_21xx_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); -} - -/* - * PLOGI/LOGO IOCB canonicalization - */ - -void -isp_get_plogx(struct ispsoftc *isp, isp_plogx_t *src, isp_plogx_t *dst) -{ - int i; - isp_get_hdr(isp, &src->plogx_header, &dst->plogx_header); - ISP_IOXGET_32(isp, &src->plogx_handle, dst->plogx_handle); - ISP_IOXGET_16(isp, &src->plogx_status, dst->plogx_status); - ISP_IOXGET_16(isp, &src->plogx_nphdl, dst->plogx_nphdl); - ISP_IOXGET_16(isp, &src->plogx_flags, dst->plogx_flags); - ISP_IOXGET_16(isp, &src->plogx_vphdl, dst->plogx_vphdl); - ISP_IOXGET_16(isp, &src->plogx_portlo, dst->plogx_portlo); - ISP_IOXGET_16(isp, &src->plogx_rspsz_porthi, dst->plogx_rspsz_porthi); - for (i = 0; i < 11; i++) { - ISP_IOXGET_16(isp, &src->plogx_ioparm[i].lo16, - dst->plogx_ioparm[i].lo16); - ISP_IOXGET_16(isp, &src->plogx_ioparm[i].hi16, - dst->plogx_ioparm[i].hi16); - } -} - -void -isp_put_plogx(struct ispsoftc *isp, isp_plogx_t *src, isp_plogx_t *dst) -{ - int i; - isp_put_hdr(isp, &src->plogx_header, &dst->plogx_header); - ISP_IOXPUT_32(isp, src->plogx_handle, &dst->plogx_handle); - ISP_IOXPUT_16(isp, src->plogx_status, &dst->plogx_status); - ISP_IOXPUT_16(isp, src->plogx_nphdl, &dst->plogx_nphdl); - ISP_IOXPUT_16(isp, src->plogx_flags, &dst->plogx_flags); - ISP_IOXPUT_16(isp, src->plogx_vphdl, &dst->plogx_vphdl); - ISP_IOXPUT_16(isp, src->plogx_portlo, &dst->plogx_portlo); - ISP_IOXPUT_16(isp, src->plogx_rspsz_porthi, &dst->plogx_rspsz_porthi); - for (i = 0; i < 11; i++) { - ISP_IOXPUT_16(isp, src->plogx_ioparm[i].lo16, - &dst->plogx_ioparm[i].lo16); - ISP_IOXPUT_16(isp, src->plogx_ioparm[i].hi16, - &dst->plogx_ioparm[i].hi16); - } -} - -/* - * CT Passthru canonicalization - */ -void -isp_get_ct_pt(struct ispsoftc *isp, isp_ct_pt_t *src, isp_ct_pt_t *dst) -{ - int i; - - isp_get_hdr(isp, &src->ctp_header, &dst->ctp_header); - ISP_IOXGET_32(isp, &src->ctp_handle, dst->ctp_handle); - ISP_IOXGET_16(isp, &src->ctp_status, dst->ctp_status); - ISP_IOXGET_16(isp, &src->ctp_nphdl, dst->ctp_nphdl); - ISP_IOXGET_16(isp, &src->ctp_cmd_cnt, dst->ctp_cmd_cnt); - ISP_IOXGET_16(isp, &src->ctp_vpidx, dst->ctp_vpidx); - ISP_IOXGET_16(isp, &src->ctp_time, dst->ctp_time); - ISP_IOXGET_16(isp, &src->ctp_reserved0, dst->ctp_reserved0); - ISP_IOXGET_16(isp, &src->ctp_rsp_cnt, dst->ctp_rsp_cnt); - for (i = 0; i < 5; i++) { - ISP_IOXGET_16(isp, &src->ctp_reserved1[i], - dst->ctp_reserved1[i]); - } - ISP_IOXGET_32(isp, &src->ctp_rsp_bcnt, dst->ctp_rsp_bcnt); - ISP_IOXGET_32(isp, &src->ctp_cmd_bcnt, dst->ctp_cmd_bcnt); - for (i = 0; i < 2; i++) { - ISP_IOXGET_32(isp, &src->ctp_dataseg[i].ds_base, - dst->ctp_dataseg[i].ds_base); - ISP_IOXGET_32(isp, &src->ctp_dataseg[i].ds_basehi, - dst->ctp_dataseg[i].ds_basehi); - ISP_IOXGET_32(isp, &src->ctp_dataseg[i].ds_count, - dst->ctp_dataseg[i].ds_count); - } -} - -void -isp_get_ms(struct ispsoftc *isp, isp_ms_t *src, isp_ms_t *dst) -{ - int i; - - isp_get_hdr(isp, &src->ms_header, &dst->ms_header); - ISP_IOXGET_32(isp, &src->ms_handle, dst->ms_handle); - ISP_IOXGET_16(isp, &src->ms_nphdl, dst->ms_nphdl); - ISP_IOXGET_16(isp, &src->ms_status, dst->ms_status); - ISP_IOXGET_16(isp, &src->ms_flags, dst->ms_flags); - ISP_IOXGET_16(isp, &src->ms_reserved1, dst->ms_reserved1); - ISP_IOXGET_16(isp, &src->ms_time, dst->ms_time); - ISP_IOXGET_16(isp, &src->ms_cmd_cnt, dst->ms_cmd_cnt); - ISP_IOXGET_16(isp, &src->ms_tot_cnt, dst->ms_tot_cnt); - ISP_IOXGET_8(isp, &src->ms_type, dst->ms_type); - ISP_IOXGET_8(isp, &src->ms_r_ctl, dst->ms_r_ctl); - ISP_IOXGET_16(isp, &src->ms_rxid, dst->ms_rxid); - ISP_IOXGET_16(isp, &src->ms_reserved2, dst->ms_reserved2); - ISP_IOXGET_32(isp, &src->ms_rsp_bcnt, dst->ms_rsp_bcnt); - ISP_IOXGET_32(isp, &src->ms_cmd_bcnt, dst->ms_cmd_bcnt); - for (i = 0; i < 2; i++) { - ISP_IOXGET_32(isp, &src->ms_dataseg[i].ds_base, - dst->ms_dataseg[i].ds_base); - ISP_IOXGET_32(isp, &src->ms_dataseg[i].ds_basehi, - dst->ms_dataseg[i].ds_basehi); - ISP_IOXGET_32(isp, &src->ms_dataseg[i].ds_count, - dst->ms_dataseg[i].ds_count); - } -} - -void -isp_put_ct_pt(struct ispsoftc *isp, isp_ct_pt_t *src, isp_ct_pt_t *dst) -{ - int i; - - isp_put_hdr(isp, &src->ctp_header, &dst->ctp_header); - ISP_IOXPUT_32(isp, src->ctp_handle, &dst->ctp_handle); - ISP_IOXPUT_16(isp, src->ctp_status, &dst->ctp_status); - ISP_IOXPUT_16(isp, src->ctp_nphdl, &dst->ctp_nphdl); - ISP_IOXPUT_16(isp, src->ctp_cmd_cnt, &dst->ctp_cmd_cnt); - ISP_IOXPUT_16(isp, src->ctp_vpidx, &dst->ctp_vpidx); - ISP_IOXPUT_16(isp, src->ctp_time, &dst->ctp_time); - ISP_IOXPUT_16(isp, src->ctp_reserved0, &dst->ctp_reserved0); - ISP_IOXPUT_16(isp, src->ctp_rsp_cnt, &dst->ctp_rsp_cnt); - for (i = 0; i < 5; i++) { - ISP_IOXPUT_16(isp, src->ctp_reserved1[i], - &dst->ctp_reserved1[i]); - } - ISP_IOXPUT_32(isp, src->ctp_rsp_bcnt, &dst->ctp_rsp_bcnt); - ISP_IOXPUT_32(isp, src->ctp_cmd_bcnt, &dst->ctp_cmd_bcnt); - for (i = 0; i < 2; i++) { - ISP_IOXPUT_32(isp, src->ctp_dataseg[i].ds_base, - &dst->ctp_dataseg[i].ds_base); - ISP_IOXPUT_32(isp, src->ctp_dataseg[i].ds_basehi, - &dst->ctp_dataseg[i].ds_basehi); - ISP_IOXPUT_32(isp, src->ctp_dataseg[i].ds_count, - &dst->ctp_dataseg[i].ds_count); - } -} - -void -isp_put_ms(struct ispsoftc *isp, isp_ms_t *src, isp_ms_t *dst) -{ - int i; - - isp_put_hdr(isp, &src->ms_header, &dst->ms_header); - ISP_IOXPUT_32(isp, src->ms_handle, &dst->ms_handle); - ISP_IOXPUT_16(isp, src->ms_nphdl, &dst->ms_nphdl); - ISP_IOXPUT_16(isp, src->ms_status, &dst->ms_status); - ISP_IOXPUT_16(isp, src->ms_flags, &dst->ms_flags); - ISP_IOXPUT_16(isp, src->ms_reserved1, &dst->ms_reserved1); - ISP_IOXPUT_16(isp, src->ms_time, &dst->ms_time); - ISP_IOXPUT_16(isp, src->ms_cmd_cnt, &dst->ms_cmd_cnt); - ISP_IOXPUT_16(isp, src->ms_tot_cnt, &dst->ms_tot_cnt); - ISP_IOXPUT_8(isp, src->ms_type, &dst->ms_type); - ISP_IOXPUT_8(isp, src->ms_r_ctl, &dst->ms_r_ctl); - ISP_IOXPUT_16(isp, src->ms_rxid, &dst->ms_rxid); - ISP_IOXPUT_16(isp, src->ms_reserved2, &dst->ms_reserved2); - ISP_IOXPUT_32(isp, src->ms_rsp_bcnt, &dst->ms_rsp_bcnt); - ISP_IOXPUT_32(isp, src->ms_cmd_bcnt, &dst->ms_cmd_bcnt); - for (i = 0; i < 2; i++) { - ISP_IOXPUT_32(isp, src->ms_dataseg[i].ds_base, - &dst->ms_dataseg[i].ds_base); - ISP_IOXPUT_32(isp, src->ms_dataseg[i].ds_basehi, - &dst->ms_dataseg[i].ds_basehi); - ISP_IOXPUT_32(isp, src->ms_dataseg[i].ds_count, - &dst->ms_dataseg[i].ds_count); - } -} - -/* - * Generic SNS request - not particularly useful since the per-command data - * isn't always 16 bit words. - */ -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]); - } - -} - -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_reserved0, &dst->snscb_reserved0); - 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_reserved1, &dst->snscb_reserved1); - 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_reserved3, &dst->snscb_reserved3); - ISP_IOXPUT_32(isp, src->snscb_fc4_type, &dst->snscb_fc4_type); -} - -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_reserved0, &dst->snscb_reserved0); - 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_reserved1, &dst->snscb_reserved1); - ISP_IOXPUT_16(isp, src->snscb_cmd, &dst->snscb_cmd); - ISP_IOXPUT_16(isp, src->snscb_reserved2, &dst->snscb_reserved2); - ISP_IOXPUT_32(isp, src->snscb_reserved3, &dst->snscb_reserved3); - 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. - */ -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]); - } -} - -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; - } - } -} - -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]); -} - -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]); - } -} - -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]); - } -} - -void -isp_get_els(struct ispsoftc *isp, els_t *src, els_t *dst) -{ - int i; - - isp_get_hdr(isp, &src->els_hdr, &dst->els_hdr); - ISP_IOXGET_32(isp, &src->els_handle, dst->els_handle); - ISP_IOXGET_16(isp, &src->els_status, dst->els_status); - ISP_IOXGET_16(isp, &src->els_nphdl, dst->els_nphdl); - ISP_IOXGET_16(isp, &src->els_xmit_dsd_count, dst->els_xmit_dsd_count); - ISP_IOXGET_8(isp, &src->els_vphdl, dst->els_vphdl); - ISP_IOXGET_8(isp, &src->els_sof, dst->els_sof); - ISP_IOXGET_32(isp, &src->els_rxid, dst->els_rxid); - ISP_IOXGET_16(isp, &src->els_recv_dsd_count, dst->els_recv_dsd_count); - ISP_IOXGET_8(isp, &src->els_opcode, dst->els_opcode); - ISP_IOXGET_8(isp, &src->els_reserved2, dst->els_reserved1); - ISP_IOXGET_8(isp, &src->els_did_lo, dst->els_did_lo); - ISP_IOXGET_8(isp, &src->els_did_mid, dst->els_did_mid); - ISP_IOXGET_8(isp, &src->els_did_hi, dst->els_did_hi); - ISP_IOXGET_8(isp, &src->els_reserved2, dst->els_reserved2); - ISP_IOXGET_16(isp, &src->els_reserved3, dst->els_reserved3); - ISP_IOXGET_16(isp, &src->els_ctl_flags, dst->els_ctl_flags); - ISP_IOXGET_32(isp, &src->els_bytecnt, dst->els_bytecnt); - ISP_IOXGET_32(isp, &src->els_subcode1, dst->els_subcode1); - ISP_IOXGET_32(isp, &src->els_subcode2, dst->els_subcode2); - for (i = 0; i < 20; i++) { - ISP_IOXGET_8(isp, &src->els_reserved4[i], - dst->els_reserved4[i]); - } -} - -void -isp_put_els(struct ispsoftc *isp, els_t *src, els_t *dst) -{ - isp_put_hdr(isp, &src->els_hdr, &dst->els_hdr); - ISP_IOXPUT_32(isp, src->els_handle, &dst->els_handle); - ISP_IOXPUT_16(isp, src->els_status, &dst->els_status); - ISP_IOXPUT_16(isp, src->els_nphdl, &dst->els_nphdl); - ISP_IOXPUT_16(isp, src->els_xmit_dsd_count, &dst->els_xmit_dsd_count); - ISP_IOXPUT_8(isp, src->els_vphdl, &dst->els_vphdl); - ISP_IOXPUT_8(isp, src->els_sof, &dst->els_sof); - ISP_IOXPUT_32(isp, src->els_rxid, &dst->els_rxid); - ISP_IOXPUT_16(isp, src->els_recv_dsd_count, &dst->els_recv_dsd_count); - ISP_IOXPUT_8(isp, src->els_opcode, &dst->els_opcode); - ISP_IOXPUT_8(isp, src->els_reserved2, &dst->els_reserved1); - ISP_IOXPUT_8(isp, src->els_did_lo, &dst->els_did_lo); - ISP_IOXPUT_8(isp, src->els_did_mid, &dst->els_did_mid); - ISP_IOXPUT_8(isp, src->els_did_hi, &dst->els_did_hi); - ISP_IOXPUT_8(isp, src->els_reserved2, &dst->els_reserved2); - ISP_IOXPUT_16(isp, src->els_reserved3, &dst->els_reserved3); - ISP_IOXPUT_16(isp, src->els_ctl_flags, &dst->els_ctl_flags); - ISP_IOXPUT_32(isp, src->els_recv_bytecnt, &dst->els_recv_bytecnt); - ISP_IOXPUT_32(isp, src->els_xmit_bytecnt, &dst->els_xmit_bytecnt); - ISP_IOXPUT_32(isp, src->els_xmit_dsd_length, &dst->els_xmit_dsd_length); - ISP_IOXPUT_16(isp, src->els_xmit_dsd_a1500, &dst->els_xmit_dsd_a1500); - ISP_IOXPUT_16(isp, src->els_xmit_dsd_a3116, &dst->els_xmit_dsd_a3116); - ISP_IOXPUT_16(isp, src->els_xmit_dsd_a4732, &dst->els_xmit_dsd_a4732); - ISP_IOXPUT_16(isp, src->els_xmit_dsd_a6348, &dst->els_xmit_dsd_a6348); - ISP_IOXPUT_32(isp, src->els_recv_dsd_length, &dst->els_recv_dsd_length); - ISP_IOXPUT_16(isp, src->els_recv_dsd_a1500, &dst->els_recv_dsd_a1500); - ISP_IOXPUT_16(isp, src->els_recv_dsd_a3116, &dst->els_recv_dsd_a3116); - ISP_IOXPUT_16(isp, src->els_recv_dsd_a4732, &dst->els_recv_dsd_a4732); - ISP_IOXPUT_16(isp, src->els_recv_dsd_a6348, &dst->els_recv_dsd_a6348); -} - -/* - * FC Structure Canonicalization - */ - -void -isp_get_fc_hdr(struct ispsoftc *isp, fc_hdr_t *src, fc_hdr_t *dst) -{ - ISP_IOZGET_8(isp, &src->r_ctl, dst->r_ctl); - ISP_IOZGET_8(isp, &src->d_id[0], dst->d_id[0]); - ISP_IOZGET_8(isp, &src->d_id[1], dst->d_id[1]); - ISP_IOZGET_8(isp, &src->d_id[2], dst->d_id[2]); - ISP_IOZGET_8(isp, &src->cs_ctl, dst->cs_ctl); - ISP_IOZGET_8(isp, &src->s_id[0], dst->s_id[0]); - ISP_IOZGET_8(isp, &src->s_id[1], dst->s_id[1]); - ISP_IOZGET_8(isp, &src->s_id[2], dst->s_id[2]); - ISP_IOZGET_8(isp, &src->type, dst->type); - ISP_IOZGET_8(isp, &src->f_ctl, dst->f_ctl); - ISP_IOZGET_8(isp, &src->seq_id, dst->seq_id); - ISP_IOZGET_8(isp, &src->df_ctl, dst->df_ctl); - ISP_IOZGET_16(isp, &src->seq_cnt, dst->seq_cnt); - /* XXX SOMETHING WAS AND STILL CONTINUES WRONG HERE XXX */ -#if 0 - ISP_IOZGET_16(isp, &src->ox_id, dst->ox_id); - ISP_IOZGET_16(isp, &src->rx_id, dst->rx_id); -#else - ISP_IOZGET_32(isp, &src->ox_id, dst->parameter); - dst->ox_id = dst->parameter; - dst->rx_id = dst->parameter >> 16; -#endif - ISP_IOZGET_32(isp, &src->parameter, dst->parameter); -} - -void -isp_get_fcp_cmnd_iu(struct ispsoftc *isp, fcp_cmnd_iu_t *src, fcp_cmnd_iu_t *dst) -{ - int i; - - for (i = 0; i < 8; i++) { - ISP_IOZGET_8(isp, &src->fcp_cmnd_lun[i], dst->fcp_cmnd_lun[i]); - } - ISP_IOZGET_8(isp, &src->fcp_cmnd_crn, dst->fcp_cmnd_crn); - ISP_IOZGET_8(isp, &src->fcp_cmnd_task_attribute, - dst->fcp_cmnd_task_attribute); - ISP_IOZGET_8(isp, &src->fcp_cmnd_task_management, - dst->fcp_cmnd_task_management); - ISP_IOZGET_8(isp, &src->fcp_cmnd_alen_datadir, - dst->fcp_cmnd_alen_datadir); - for (i = 0; i < 16; i++) { - ISP_IOZGET_8(isp, &src->cdb_dl.sf.fcp_cmnd_cdb[i], - dst->cdb_dl.sf.fcp_cmnd_cdb[i]); - } - ISP_IOZGET_32(isp, &src->cdb_dl.sf.fcp_cmnd_dl, - dst->cdb_dl.sf.fcp_cmnd_dl); -} - -void -isp_put_rft_id(struct ispsoftc *isp, rft_id_t *src, rft_id_t *dst) -{ - int i; - isp_put_ct_hdr(isp, &src->rftid_hdr, &dst->rftid_hdr); - ISP_IOZPUT_8(isp, src->rftid_reserved, &dst->rftid_reserved); - for (i = 0; i < 3; i++) { - ISP_IOZPUT_8(isp, src->rftid_portid[i], &dst->rftid_portid[i]); - } - for (i = 0; i < 8; i++) { - ISP_IOZPUT_32(isp, src->rftid_fc4types[i], - &dst->rftid_fc4types[i]); - } -} - -void -isp_get_ct_hdr(struct ispsoftc *isp, ct_hdr_t *src, ct_hdr_t *dst) -{ - ISP_IOZGET_8(isp, &src->ct_revision, dst->ct_revision); - ISP_IOZGET_8(isp, &src->ct_in_id[0], dst->ct_in_id[0]); - ISP_IOZGET_8(isp, &src->ct_in_id[1], dst->ct_in_id[1]); - ISP_IOZGET_8(isp, &src->ct_in_id[2], dst->ct_in_id[2]); - ISP_IOZGET_8(isp, &src->ct_fcs_type, dst->ct_fcs_type); - ISP_IOZGET_8(isp, &src->ct_fcs_subtype, dst->ct_fcs_subtype); - ISP_IOZGET_8(isp, &src->ct_options, dst->ct_options); - ISP_IOZGET_8(isp, &src->ct_reserved0, dst->ct_reserved0); - ISP_IOZGET_16(isp, &src->ct_cmd_resp, dst->ct_cmd_resp); - ISP_IOZGET_16(isp, &src->ct_bcnt_resid, dst->ct_bcnt_resid); - ISP_IOZGET_8(isp, &src->ct_reserved1, dst->ct_reserved1); - ISP_IOZGET_8(isp, &src->ct_reason, dst->ct_reason); - ISP_IOZGET_8(isp, &src->ct_explanation, dst->ct_explanation); - ISP_IOZGET_8(isp, &src->ct_vunique, dst->ct_vunique); -} - -void -isp_put_ct_hdr(struct ispsoftc *isp, ct_hdr_t *src, ct_hdr_t *dst) -{ - ISP_IOZPUT_8(isp, src->ct_revision, &dst->ct_revision); - ISP_IOZPUT_8(isp, src->ct_in_id[0], &dst->ct_in_id[0]); - ISP_IOZPUT_8(isp, src->ct_in_id[1], &dst->ct_in_id[1]); - ISP_IOZPUT_8(isp, src->ct_in_id[2], &dst->ct_in_id[2]); - ISP_IOZPUT_8(isp, src->ct_fcs_type, &dst->ct_fcs_type); - ISP_IOZPUT_8(isp, src->ct_fcs_subtype, &dst->ct_fcs_subtype); - ISP_IOZPUT_8(isp, src->ct_options, &dst->ct_options); - ISP_IOZPUT_8(isp, src->ct_reserved0, &dst->ct_reserved0); - ISP_IOZPUT_16(isp, src->ct_cmd_resp, &dst->ct_cmd_resp); - ISP_IOZPUT_16(isp, src->ct_bcnt_resid, &dst->ct_bcnt_resid); - ISP_IOZPUT_8(isp, src->ct_reserved1, &dst->ct_reserved1); - ISP_IOZPUT_8(isp, src->ct_reason, &dst->ct_reason); - ISP_IOZPUT_8(isp, src->ct_explanation, &dst->ct_explanation); - ISP_IOZPUT_8(isp, src->ct_vunique, &dst->ct_vunique); -} - -#ifdef ISP_TARGET_MODE -int -isp_save_xs_tgt(struct ispsoftc *isp, void *xs, u_int32_t *handlep) -{ - int i; - - for (i = 0; i < (int) isp->isp_maxcmds; i++) { - if (isp->isp_tgtlist[i] == NULL) { - break; - } - } - if (i == isp->isp_maxcmds) { - return (-1); - } - isp->isp_tgtlist[i] = xs; - *handlep = (i+1) | 0x8000; - return (0); -} - -void * -isp_find_xs_tgt(struct ispsoftc *isp, u_int32_t handle) -{ - if (handle == 0 || IS_TARGET_HANDLE(handle) == 0 || - (handle & ISP_HANDLE_MASK) > isp->isp_maxcmds) { - isp_prt(isp, ISP_LOGERR, "bad handle in isp_find_xs_tgt"); - return (NULL); - } else { - return (isp->isp_tgtlist[(handle & ISP_HANDLE_MASK) - 1]); - } -} - -u_int32_t -isp_find_tgt_handle(struct ispsoftc *isp, void *xs) -{ - int i; - if (xs != NULL) { - for (i = 0; i < isp->isp_maxcmds; i++) { - if (isp->isp_tgtlist[i] == xs) { - return ((i+1) & ISP_HANDLE_MASK); - } - } - } - return (0); -} - -void -isp_destroy_tgt_handle(struct ispsoftc *isp, u_int32_t handle) -{ - if (handle == 0 || IS_TARGET_HANDLE(handle) == 0 || - (handle & ISP_HANDLE_MASK) > isp->isp_maxcmds) { - isp_prt(isp, ISP_LOGERR, - "bad handle in isp_destroy_tgt_handle"); - } else { - isp->isp_tgtlist[(handle & ISP_HANDLE_MASK) - 1] = NULL; - } -} - -void -isp_put_atio(struct ispsoftc *isp, at_entry_t *src, at_entry_t *dst) -{ - int i; - isp_put_hdr(isp, &src->at_header, &dst->at_header); - ISP_IOXPUT_16(isp, src->at_reserved, &dst->at_reserved); - ISP_IOXPUT_16(isp, src->at_handle, &dst->at_handle); - if (ISP_IS_SBUS(isp)) { - ISP_IOXPUT_8(isp, src->at_lun, &dst->at_iid); - ISP_IOXPUT_8(isp, src->at_iid, &dst->at_lun); - ISP_IOXPUT_8(isp, src->at_cdblen, &dst->at_tgt); - ISP_IOXPUT_8(isp, src->at_tgt, &dst->at_cdblen); - ISP_IOXPUT_8(isp, src->at_status, &dst->at_scsi_status); - ISP_IOXPUT_8(isp, src->at_scsi_status, &dst->at_status); - ISP_IOXPUT_8(isp, src->at_tag_val, &dst->at_tag_type); - ISP_IOXPUT_8(isp, src->at_tag_type, &dst->at_tag_val); - } else { - ISP_IOXPUT_8(isp, src->at_lun, &dst->at_lun); - ISP_IOXPUT_8(isp, src->at_iid, &dst->at_iid); - ISP_IOXPUT_8(isp, src->at_cdblen, &dst->at_cdblen); - ISP_IOXPUT_8(isp, src->at_tgt, &dst->at_tgt); - ISP_IOXPUT_8(isp, src->at_status, &dst->at_status); - ISP_IOXPUT_8(isp, src->at_scsi_status, - &dst->at_scsi_status); - ISP_IOXPUT_8(isp, src->at_tag_val, &dst->at_tag_val); - ISP_IOXPUT_8(isp, src->at_tag_type, &dst->at_tag_type); - } - ISP_IOXPUT_32(isp, src->at_flags, &dst->at_flags); - for (i = 0; i < ATIO_CDBLEN; i++) { - ISP_IOXPUT_8(isp, src->at_cdb[i], &dst->at_cdb[i]); - } - for (i = 0; i < QLTM_SENSELEN; i++) { - ISP_IOXPUT_8(isp, src->at_sense[i], &dst->at_sense[i]); - } -} - -void -isp_get_atio(struct ispsoftc *isp, at_entry_t *src, at_entry_t *dst) -{ - int i; - isp_get_hdr(isp, &src->at_header, &dst->at_header); - ISP_IOXGET_16(isp, &src->at_reserved, dst->at_reserved); - ISP_IOXGET_16(isp, &src->at_handle, dst->at_handle); - if (ISP_IS_SBUS(isp)) { - ISP_IOXGET_8(isp, &src->at_lun, dst->at_iid); - ISP_IOXGET_8(isp, &src->at_iid, dst->at_lun); - ISP_IOXGET_8(isp, &src->at_cdblen, dst->at_tgt); - ISP_IOXGET_8(isp, &src->at_tgt, dst->at_cdblen); - ISP_IOXGET_8(isp, &src->at_status, dst->at_scsi_status); - ISP_IOXGET_8(isp, &src->at_scsi_status, dst->at_status); - ISP_IOXGET_8(isp, &src->at_tag_val, dst->at_tag_type); - ISP_IOXGET_8(isp, &src->at_tag_type, dst->at_tag_val); - } else { - ISP_IOXGET_8(isp, &src->at_lun, dst->at_lun); - ISP_IOXGET_8(isp, &src->at_iid, dst->at_iid); - ISP_IOXGET_8(isp, &src->at_cdblen, dst->at_cdblen); - ISP_IOXGET_8(isp, &src->at_tgt, dst->at_tgt); - ISP_IOXGET_8(isp, &src->at_status, dst->at_status); - ISP_IOXGET_8(isp, &src->at_scsi_status, - dst->at_scsi_status); - ISP_IOXGET_8(isp, &src->at_tag_val, dst->at_tag_val); - ISP_IOXGET_8(isp, &src->at_tag_type, dst->at_tag_type); - } - ISP_IOXGET_32(isp, &src->at_flags, dst->at_flags); - for (i = 0; i < ATIO_CDBLEN; i++) { - ISP_IOXGET_8(isp, &src->at_cdb[i], dst->at_cdb[i]); - } - for (i = 0; i < QLTM_SENSELEN; i++) { - ISP_IOXGET_8(isp, &src->at_sense[i], dst->at_sense[i]); - } -} - -void -isp_put_atio2(struct ispsoftc *isp, at2_entry_t *src, at2_entry_t *dst) -{ - int i; - isp_put_hdr(isp, &src->at_header, &dst->at_header); - ISP_IOXPUT_32(isp, src->at_reserved, &dst->at_reserved); - ISP_IOXPUT_8(isp, src->at_lun, &dst->at_lun); - ISP_IOXPUT_8(isp, src->at_iid, &dst->at_iid); - ISP_IOXPUT_16(isp, src->at_rxid, &dst->at_rxid); - ISP_IOXPUT_16(isp, src->at_flags, &dst->at_flags); - ISP_IOXPUT_16(isp, src->at_status, &dst->at_status); - ISP_IOXPUT_8(isp, src->at_crn, &dst->at_crn); - ISP_IOXPUT_8(isp, src->at_taskcodes, &dst->at_taskcodes); - ISP_IOXPUT_8(isp, src->at_taskflags, &dst->at_taskflags); - ISP_IOXPUT_8(isp, src->at_execodes, &dst->at_execodes); - for (i = 0; i < ATIO2_CDBLEN; i++) { - ISP_IOXPUT_8(isp, src->at_cdb[i], &dst->at_cdb[i]); - } - ISP_IOXPUT_32(isp, src->at_datalen, &dst->at_datalen); - ISP_IOXPUT_16(isp, src->at_scclun, &dst->at_scclun); - for (i = 0; i < 4; i++) { - ISP_IOXPUT_16(isp, src->at_wwpn[i], &dst->at_wwpn[i]); - } - for (i = 0; i < 6; i++) { - ISP_IOXPUT_16(isp, src->at_reserved2[i], - &dst->at_reserved2[i]); - } - ISP_IOXPUT_16(isp, src->at_oxid, &dst->at_oxid); -} - -void -isp_put_atio2e(struct ispsoftc *isp, at2e_entry_t *src, at2e_entry_t *dst) -{ - int i; - isp_put_hdr(isp, &src->at_header, &dst->at_header); - ISP_IOXPUT_32(isp, src->at_reserved, &dst->at_reserved); - ISP_IOXPUT_16(isp, src->at_iid, &dst->at_iid); - ISP_IOXPUT_16(isp, src->at_rxid, &dst->at_rxid); - ISP_IOXPUT_16(isp, src->at_flags, &dst->at_flags); - ISP_IOXPUT_16(isp, src->at_status, &dst->at_status); - ISP_IOXPUT_8(isp, src->at_crn, &dst->at_crn); - ISP_IOXPUT_8(isp, src->at_taskcodes, &dst->at_taskcodes); - ISP_IOXPUT_8(isp, src->at_taskflags, &dst->at_taskflags); - ISP_IOXPUT_8(isp, src->at_execodes, &dst->at_execodes); - for (i = 0; i < ATIO2_CDBLEN; i++) { - ISP_IOXPUT_8(isp, src->at_cdb[i], &dst->at_cdb[i]); - } - ISP_IOXPUT_32(isp, src->at_datalen, &dst->at_datalen); - ISP_IOXPUT_16(isp, src->at_scclun, &dst->at_scclun); - for (i = 0; i < 4; i++) { - ISP_IOXPUT_16(isp, src->at_wwpn[i], &dst->at_wwpn[i]); - } - for (i = 0; i < 6; i++) { - ISP_IOXPUT_16(isp, src->at_reserved2[i], - &dst->at_reserved2[i]); - } - ISP_IOXPUT_16(isp, src->at_oxid, &dst->at_oxid); -} - -void -isp_get_atio2(struct ispsoftc *isp, at2_entry_t *src, at2_entry_t *dst) -{ - int i; - isp_get_hdr(isp, &src->at_header, &dst->at_header); - ISP_IOXGET_32(isp, &src->at_reserved, dst->at_reserved); - ISP_IOXGET_8(isp, &src->at_lun, dst->at_lun); - ISP_IOXGET_8(isp, &src->at_iid, dst->at_iid); - ISP_IOXGET_16(isp, &src->at_rxid, dst->at_rxid); - ISP_IOXGET_16(isp, &src->at_flags, dst->at_flags); - ISP_IOXGET_16(isp, &src->at_status, dst->at_status); - ISP_IOXGET_8(isp, &src->at_crn, dst->at_crn); - ISP_IOXGET_8(isp, &src->at_taskcodes, dst->at_taskcodes); - ISP_IOXGET_8(isp, &src->at_taskflags, dst->at_taskflags); - ISP_IOXGET_8(isp, &src->at_execodes, dst->at_execodes); - for (i = 0; i < ATIO2_CDBLEN; i++) { - ISP_IOXGET_8(isp, &src->at_cdb[i], dst->at_cdb[i]); - } - ISP_IOXGET_32(isp, &src->at_datalen, dst->at_datalen); - ISP_IOXGET_16(isp, &src->at_scclun, dst->at_scclun); - for (i = 0; i < 4; i++) { - ISP_IOXGET_16(isp, &src->at_wwpn[i], dst->at_wwpn[i]); - } - for (i = 0; i < 6; i++) { - ISP_IOXGET_16(isp, &src->at_reserved2[i], - dst->at_reserved2[i]); - } - ISP_IOXGET_16(isp, &src->at_oxid, dst->at_oxid); -} - -void -isp_get_atio2e(struct ispsoftc *isp, at2e_entry_t *src, at2e_entry_t *dst) -{ - int i; - isp_get_hdr(isp, &src->at_header, &dst->at_header); - ISP_IOXGET_32(isp, &src->at_reserved, dst->at_reserved); - ISP_IOXGET_16(isp, &src->at_iid, dst->at_iid); - ISP_IOXGET_16(isp, &src->at_rxid, dst->at_rxid); - ISP_IOXGET_16(isp, &src->at_flags, dst->at_flags); - ISP_IOXGET_16(isp, &src->at_status, dst->at_status); - ISP_IOXGET_8(isp, &src->at_crn, dst->at_crn); - ISP_IOXGET_8(isp, &src->at_taskcodes, dst->at_taskcodes); - ISP_IOXGET_8(isp, &src->at_taskflags, dst->at_taskflags); - ISP_IOXGET_8(isp, &src->at_execodes, dst->at_execodes); - for (i = 0; i < ATIO2_CDBLEN; i++) { - ISP_IOXGET_8(isp, &src->at_cdb[i], dst->at_cdb[i]); - } - ISP_IOXGET_32(isp, &src->at_datalen, dst->at_datalen); - ISP_IOXGET_16(isp, &src->at_scclun, dst->at_scclun); - for (i = 0; i < 4; i++) { - ISP_IOXGET_16(isp, &src->at_wwpn[i], dst->at_wwpn[i]); - } - for (i = 0; i < 6; i++) { - ISP_IOXGET_16(isp, &src->at_reserved2[i], - dst->at_reserved2[i]); - } - ISP_IOXGET_16(isp, &src->at_oxid, dst->at_oxid); -} - -void -isp_get_atio7(struct ispsoftc *isp, at7_entry_t *src, at7_entry_t *dst) -{ - ISP_IOXGET_8(isp, &src->at_type, dst->at_type); - ISP_IOXGET_8(isp, &src->at_count, dst->at_count); - ISP_IOXGET_16(isp, &src->at_ta_len, dst->at_ta_len); - ISP_IOXGET_32(isp, &src->at_rxid, dst->at_rxid); - isp_get_fc_hdr(isp, &src->at_hdr, &dst->at_hdr); - isp_get_fcp_cmnd_iu(isp, &src->at_cmnd, &dst->at_cmnd); -} - -void -isp_put_ctio(struct ispsoftc *isp, ct_entry_t *src, ct_entry_t *dst) -{ - int i; - isp_put_hdr(isp, &src->ct_header, &dst->ct_header); - ISP_IOXPUT_16(isp, src->ct_syshandle, &dst->ct_syshandle); - ISP_IOXPUT_16(isp, src->ct_fwhandle, &dst->ct_fwhandle); - if (ISP_IS_SBUS(isp)) { - ISP_IOXPUT_8(isp, src->ct_iid, &dst->ct_lun); - ISP_IOXPUT_8(isp, src->ct_lun, &dst->ct_iid); - ISP_IOXPUT_8(isp, src->ct_tgt, &dst->ct_reserved2); - ISP_IOXPUT_8(isp, src->ct_reserved2, &dst->ct_tgt); - ISP_IOXPUT_8(isp, src->ct_status, &dst->ct_scsi_status); - ISP_IOXPUT_8(isp, src->ct_scsi_status, &dst->ct_status); - ISP_IOXPUT_8(isp, src->ct_tag_type, &dst->ct_tag_val); - ISP_IOXPUT_8(isp, src->ct_tag_val, &dst->ct_tag_type); - } else { - ISP_IOXPUT_8(isp, src->ct_iid, &dst->ct_iid); - ISP_IOXPUT_8(isp, src->ct_lun, &dst->ct_lun); - ISP_IOXPUT_8(isp, src->ct_tgt, &dst->ct_tgt); - ISP_IOXPUT_8(isp, src->ct_reserved2, &dst->ct_reserved2); - ISP_IOXPUT_8(isp, src->ct_scsi_status, - &dst->ct_scsi_status); - ISP_IOXPUT_8(isp, src->ct_status, &dst->ct_status); - ISP_IOXPUT_8(isp, src->ct_tag_type, &dst->ct_tag_type); - ISP_IOXPUT_8(isp, src->ct_tag_val, &dst->ct_tag_val); - } - ISP_IOXPUT_32(isp, src->ct_flags, &dst->ct_flags); - ISP_IOXPUT_32(isp, src->ct_xfrlen, &dst->ct_xfrlen); - ISP_IOXPUT_32(isp, src->ct_resid, &dst->ct_resid); - ISP_IOXPUT_16(isp, src->ct_timeout, &dst->ct_timeout); - ISP_IOXPUT_16(isp, src->ct_seg_count, &dst->ct_seg_count); - for (i = 0; i < ISP_RQDSEG; i++) { - ISP_IOXPUT_32(isp, src->ct_dataseg[i].ds_base, - &dst->ct_dataseg[i].ds_base); - ISP_IOXPUT_32(isp, src->ct_dataseg[i].ds_count, - &dst->ct_dataseg[i].ds_count); - } -} - -void -isp_get_ctio(struct ispsoftc *isp, ct_entry_t *src, ct_entry_t *dst) -{ - int i; - isp_get_hdr(isp, &src->ct_header, &dst->ct_header); - ISP_IOXGET_16(isp, &src->ct_syshandle, dst->ct_syshandle); - ISP_IOXGET_16(isp, &src->ct_fwhandle, dst->ct_fwhandle); - if (ISP_IS_SBUS(isp)) { - ISP_IOXGET_8(isp, &src->ct_lun, dst->ct_iid); - ISP_IOXGET_8(isp, &src->ct_iid, dst->ct_lun); - ISP_IOXGET_8(isp, &src->ct_reserved2, dst->ct_tgt); - ISP_IOXGET_8(isp, &src->ct_tgt, dst->ct_reserved2); - ISP_IOXGET_8(isp, &src->ct_status, dst->ct_scsi_status); - ISP_IOXGET_8(isp, &src->ct_scsi_status, dst->ct_status); - ISP_IOXGET_8(isp, &src->ct_tag_val, dst->ct_tag_type); - ISP_IOXGET_8(isp, &src->ct_tag_type, dst->ct_tag_val); - } else { - ISP_IOXGET_8(isp, &src->ct_lun, dst->ct_lun); - ISP_IOXGET_8(isp, &src->ct_iid, dst->ct_iid); - ISP_IOXGET_8(isp, &src->ct_reserved2, dst->ct_reserved2); - ISP_IOXGET_8(isp, &src->ct_tgt, dst->ct_tgt); - ISP_IOXGET_8(isp, &src->ct_status, dst->ct_status); - ISP_IOXGET_8(isp, &src->ct_scsi_status, - dst->ct_scsi_status); - ISP_IOXGET_8(isp, &src->ct_tag_val, dst->ct_tag_val); - ISP_IOXGET_8(isp, &src->ct_tag_type, dst->ct_tag_type); - } - ISP_IOXGET_32(isp, &src->ct_flags, dst->ct_flags); - ISP_IOXGET_32(isp, &src->ct_xfrlen, dst->ct_xfrlen); - ISP_IOXGET_32(isp, &src->ct_resid, dst->ct_resid); - ISP_IOXGET_16(isp, &src->ct_timeout, dst->ct_timeout); - ISP_IOXGET_16(isp, &src->ct_seg_count, dst->ct_seg_count); - for (i = 0; i < ISP_RQDSEG; i++) { - ISP_IOXGET_32(isp, - &src->ct_dataseg[i].ds_base, - dst->ct_dataseg[i].ds_base); - ISP_IOXGET_32(isp, - &src->ct_dataseg[i].ds_count, - dst->ct_dataseg[i].ds_count); - } -} - -void -isp_put_ctio2(struct ispsoftc *isp, ct2_entry_t *src, ct2_entry_t *dst) -{ - int i; - isp_put_hdr(isp, &src->ct_header, &dst->ct_header); - ISP_IOXPUT_32(isp, src->ct_syshandle, &dst->ct_syshandle); - ISP_IOXPUT_8(isp, src->ct_lun, &dst->ct_lun); - ISP_IOXPUT_8(isp, src->ct_iid, &dst->ct_iid); - ISP_IOXPUT_16(isp, src->ct_rxid, &dst->ct_rxid); - ISP_IOXPUT_16(isp, src->ct_flags, &dst->ct_flags); - ISP_IOXPUT_16(isp, src->ct_timeout, &dst->ct_timeout); - ISP_IOXPUT_16(isp, src->ct_seg_count, &dst->ct_seg_count); - ISP_IOXPUT_32(isp, src->ct_resid, &dst->ct_resid); - ISP_IOXPUT_32(isp, src->ct_reloff, &dst->ct_reloff); - if ((src->ct_flags & CT2_FLAG_MMASK) == CT2_FLAG_MODE0) { - ISP_IOXPUT_32(isp, src->rsp.m0._reserved, - &dst->rsp.m0._reserved); - ISP_IOXPUT_16(isp, src->rsp.m0._reserved2, - &dst->rsp.m0._reserved2); - ISP_IOXPUT_16(isp, src->rsp.m0.ct_scsi_status, - &dst->rsp.m0.ct_scsi_status); - ISP_IOXPUT_32(isp, src->rsp.m0.ct_xfrlen, - &dst->rsp.m0.ct_xfrlen); - if (src->ct_header.rqs_entry_type == RQSTYPE_CTIO2) { - for (i = 0; i < ISP_RQDSEG_T2; i++) { - ISP_IOXPUT_32(isp, - src->rsp.m0.u.ct_dataseg[i].ds_base, - &dst->rsp.m0.u.ct_dataseg[i].ds_base); - ISP_IOXPUT_32(isp, - src->rsp.m0.u.ct_dataseg[i].ds_count, - &dst->rsp.m0.u.ct_dataseg[i].ds_count); - } - } else if (src->ct_header.rqs_entry_type == RQSTYPE_CTIO3) { - for (i = 0; i < ISP_RQDSEG_T3; i++) { - ISP_IOXPUT_32(isp, - src->rsp.m0.u.ct_dataseg64[i].ds_base, - &dst->rsp.m0.u.ct_dataseg64[i].ds_base); - ISP_IOXPUT_32(isp, - src->rsp.m0.u.ct_dataseg64[i].ds_basehi, - &dst->rsp.m0.u.ct_dataseg64[i].ds_basehi); - ISP_IOXPUT_32(isp, - src->rsp.m0.u.ct_dataseg64[i].ds_count, - &dst->rsp.m0.u.ct_dataseg64[i].ds_count); - } - } else if (src->ct_header.rqs_entry_type == RQSTYPE_CTIO4) { - ISP_IOXPUT_16(isp, src->rsp.m0.u.ct_dslist.ds_type, - &dst->rsp.m0.u.ct_dslist.ds_type); - ISP_IOXPUT_32(isp, src->rsp.m0.u.ct_dslist.ds_segment, - &dst->rsp.m0.u.ct_dslist.ds_segment); - ISP_IOXPUT_32(isp, src->rsp.m0.u.ct_dslist.ds_base, - &dst->rsp.m0.u.ct_dslist.ds_base); - } - } else if ((src->ct_flags & CT2_FLAG_MMASK) == CT2_FLAG_MODE1) { - ISP_IOXPUT_16(isp, src->rsp.m1._reserved, - &dst->rsp.m1._reserved); - ISP_IOXPUT_16(isp, src->rsp.m1._reserved2, - &dst->rsp.m1._reserved2); - ISP_IOXPUT_16(isp, src->rsp.m1.ct_senselen, - &dst->rsp.m1.ct_senselen); - ISP_IOXPUT_16(isp, src->rsp.m1.ct_scsi_status, - &dst->rsp.m1.ct_scsi_status); - ISP_IOXPUT_16(isp, src->rsp.m1.ct_resplen, - &dst->rsp.m1.ct_resplen); - for (i = 0; i < MAXRESPLEN; i++) { - ISP_IOXPUT_8(isp, src->rsp.m1.ct_resp[i], - &dst->rsp.m1.ct_resp[i]); - } - } else { - ISP_IOXPUT_32(isp, src->rsp.m2._reserved, - &dst->rsp.m2._reserved); - ISP_IOXPUT_16(isp, src->rsp.m2._reserved2, - &dst->rsp.m2._reserved2); - ISP_IOXPUT_16(isp, src->rsp.m2._reserved3, - &dst->rsp.m2._reserved3); - ISP_IOXPUT_32(isp, src->rsp.m2.ct_datalen, - &dst->rsp.m2.ct_datalen); - ISP_IOXPUT_32(isp, src->rsp.m2.ct_fcp_rsp_iudata.ds_base, - &dst->rsp.m2.ct_fcp_rsp_iudata.ds_base); - ISP_IOXPUT_32(isp, src->rsp.m2.ct_fcp_rsp_iudata.ds_count, - &dst->rsp.m2.ct_fcp_rsp_iudata.ds_count); - } -} - -void -isp_put_ctio2e(struct ispsoftc *isp, ct2e_entry_t *src, ct2e_entry_t *dst) -{ - int i; - isp_put_hdr(isp, &src->ct_header, &dst->ct_header); - ISP_IOXPUT_32(isp, src->ct_syshandle, &dst->ct_syshandle); - ISP_IOXPUT_16(isp, src->ct_iid, &dst->ct_iid); - ISP_IOXPUT_16(isp, src->ct_rxid, &dst->ct_rxid); - ISP_IOXPUT_16(isp, src->ct_flags, &dst->ct_flags); - ISP_IOXPUT_16(isp, src->ct_timeout, &dst->ct_timeout); - ISP_IOXPUT_16(isp, src->ct_seg_count, &dst->ct_seg_count); - ISP_IOXPUT_32(isp, src->ct_resid, &dst->ct_resid); - ISP_IOXPUT_32(isp, src->ct_reloff, &dst->ct_reloff); - if ((src->ct_flags & CT2_FLAG_MMASK) == CT2_FLAG_MODE0) { - ISP_IOXPUT_32(isp, src->rsp.m0._reserved, - &dst->rsp.m0._reserved); - ISP_IOXPUT_16(isp, src->rsp.m0._reserved2, - &dst->rsp.m0._reserved2); - ISP_IOXPUT_16(isp, src->rsp.m0.ct_scsi_status, - &dst->rsp.m0.ct_scsi_status); - ISP_IOXPUT_32(isp, src->rsp.m0.ct_xfrlen, - &dst->rsp.m0.ct_xfrlen); - if (src->ct_header.rqs_entry_type == RQSTYPE_CTIO2) { - for (i = 0; i < ISP_RQDSEG_T2; i++) { - ISP_IOXPUT_32(isp, - src->rsp.m0.u.ct_dataseg[i].ds_base, - &dst->rsp.m0.u.ct_dataseg[i].ds_base); - ISP_IOXPUT_32(isp, - src->rsp.m0.u.ct_dataseg[i].ds_count, - &dst->rsp.m0.u.ct_dataseg[i].ds_count); - } - } else if (src->ct_header.rqs_entry_type == RQSTYPE_CTIO3) { - for (i = 0; i < ISP_RQDSEG_T3; i++) { - ISP_IOXPUT_32(isp, - src->rsp.m0.u.ct_dataseg64[i].ds_base, - &dst->rsp.m0.u.ct_dataseg64[i].ds_base); - ISP_IOXPUT_32(isp, - src->rsp.m0.u.ct_dataseg64[i].ds_basehi, - &dst->rsp.m0.u.ct_dataseg64[i].ds_basehi); - ISP_IOXPUT_32(isp, - src->rsp.m0.u.ct_dataseg64[i].ds_count, - &dst->rsp.m0.u.ct_dataseg64[i].ds_count); - } - } else if (src->ct_header.rqs_entry_type == RQSTYPE_CTIO4) { - ISP_IOXPUT_16(isp, src->rsp.m0.u.ct_dslist.ds_type, - &dst->rsp.m0.u.ct_dslist.ds_type); - ISP_IOXPUT_32(isp, src->rsp.m0.u.ct_dslist.ds_segment, - &dst->rsp.m0.u.ct_dslist.ds_segment); - ISP_IOXPUT_32(isp, src->rsp.m0.u.ct_dslist.ds_base, - &dst->rsp.m0.u.ct_dslist.ds_base); - } - } else if ((src->ct_flags & CT2_FLAG_MMASK) == CT2_FLAG_MODE1) { - ISP_IOXPUT_16(isp, src->rsp.m1._reserved, - &dst->rsp.m1._reserved); - ISP_IOXPUT_16(isp, src->rsp.m1._reserved2, - &dst->rsp.m1._reserved2); - ISP_IOXPUT_16(isp, src->rsp.m1.ct_senselen, - &dst->rsp.m1.ct_senselen); - ISP_IOXPUT_16(isp, src->rsp.m1.ct_scsi_status, - &dst->rsp.m1.ct_scsi_status); - ISP_IOXPUT_16(isp, src->rsp.m1.ct_resplen, - &dst->rsp.m1.ct_resplen); - for (i = 0; i < MAXRESPLEN; i++) { - ISP_IOXPUT_8(isp, src->rsp.m1.ct_resp[i], - &dst->rsp.m1.ct_resp[i]); - } - } else { - ISP_IOXPUT_32(isp, src->rsp.m2._reserved, - &dst->rsp.m2._reserved); - ISP_IOXPUT_16(isp, src->rsp.m2._reserved2, - &dst->rsp.m2._reserved2); - ISP_IOXPUT_16(isp, src->rsp.m2._reserved3, - &dst->rsp.m2._reserved3); - ISP_IOXPUT_32(isp, src->rsp.m2.ct_datalen, - &dst->rsp.m2.ct_datalen); - ISP_IOXPUT_32(isp, src->rsp.m2.ct_fcp_rsp_iudata.ds_base, - &dst->rsp.m2.ct_fcp_rsp_iudata.ds_base); - ISP_IOXPUT_32(isp, src->rsp.m2.ct_fcp_rsp_iudata.ds_count, - &dst->rsp.m2.ct_fcp_rsp_iudata.ds_count); - } -} - -void -isp_put_ctio7(struct ispsoftc *isp, ct7_entry_t *src, ct7_entry_t *dst) -{ - int i; - - isp_put_hdr(isp, &src->ct_header, &dst->ct_header); - ISP_IOXPUT_32(isp, src->ct_syshandle, &dst->ct_syshandle); - ISP_IOXPUT_16(isp, src->ct_nphdl, &dst->ct_nphdl); - ISP_IOXPUT_16(isp, src->ct_timeout, &dst->ct_timeout); - ISP_IOXPUT_16(isp, src->ct_seg_count, &dst->ct_seg_count); - ISP_IOXPUT_8(isp, src->ct_vpindex, &dst->ct_vpindex); - ISP_IOXPUT_8(isp, src->ct_xflags, &dst->ct_xflags); - ISP_IOXPUT_16(isp, src->ct_iid_lo, &dst->ct_iid_lo); - ISP_IOXPUT_8(isp, src->ct_iid_hi, &dst->ct_iid_hi); - ISP_IOXPUT_8(isp, src->ct_reserved, &dst->ct_reserved); - ISP_IOXPUT_32(isp, src->ct_rxid, &dst->ct_rxid); - ISP_IOXPUT_16(isp, src->ct_senselen, &dst->ct_senselen); - ISP_IOXPUT_16(isp, src->ct_flags, &dst->ct_flags); - ISP_IOXPUT_32(isp, src->ct_resid, &dst->ct_resid); - ISP_IOXPUT_16(isp, src->ct_oxid, &dst->ct_oxid); - ISP_IOXPUT_16(isp, src->ct_scsi_status, &dst->ct_scsi_status); - if ((dst->ct_flags & CT7_FLAG_MMASK) == CT7_FLAG_MODE0) { - ISP_IOXPUT_32(isp, src->rsp.m0.reloff, &dst->rsp.m0.reloff); - ISP_IOXPUT_32(isp, src->rsp.m0.reserved0, - &dst->rsp.m0.reserved0); - ISP_IOXPUT_32(isp, src->rsp.m0.ct_xfrlen, - &dst->rsp.m0.ct_xfrlen); - ISP_IOXPUT_32(isp, src->rsp.m0.reserved1, - &dst->rsp.m0.reserved1); - ISP_IOXPUT_32(isp, src->rsp.m0.ds.ds_base, - &dst->rsp.m0.ds.ds_base); - ISP_IOXPUT_32(isp, src->rsp.m0.ds.ds_basehi, - &dst->rsp.m0.ds.ds_basehi); - ISP_IOXPUT_32(isp, src->rsp.m0.ds.ds_count, - &dst->rsp.m0.ds.ds_count); - } else if ((dst->ct_flags & CT7_FLAG_MMASK) == CT7_FLAG_MODE1) { - ISP_IOXPUT_16(isp, src->rsp.m1.ct_resplen, - &dst->rsp.m1.ct_resplen); - ISP_IOXPUT_16(isp, src->rsp.m1.reserved, &dst->rsp.m1.reserved); - for (i = 0; i < MAXRESPLEN_24XX; i++) { - ISP_IOXPUT_8(isp, src->rsp.m1.ct_resp[i], - &dst->rsp.m1.ct_resp[i]); - } - } else { - ISP_IOXPUT_32(isp, src->rsp.m2.reserved0, - &dst->rsp.m2.reserved0); - ISP_IOXPUT_32(isp, src->rsp.m2.ct_datalen, - &dst->rsp.m2.ct_datalen); - ISP_IOXPUT_32(isp, src->rsp.m2.reserved1, - &dst->rsp.m2.reserved1); - ISP_IOXPUT_32(isp, src->rsp.m2.ct_fcp_rsp_iudata.ds_base, - &dst->rsp.m2.ct_fcp_rsp_iudata.ds_base); - ISP_IOXPUT_32(isp, src->rsp.m2.ct_fcp_rsp_iudata.ds_basehi, - &dst->rsp.m2.ct_fcp_rsp_iudata.ds_basehi); - ISP_IOXPUT_32(isp, src->rsp.m2.ct_fcp_rsp_iudata.ds_count, - &dst->rsp.m2.ct_fcp_rsp_iudata.ds_count); - } -} - - -void -isp_get_ctio2(struct ispsoftc *isp, ct2_entry_t *src, ct2_entry_t *dst) -{ - int i; - - isp_get_hdr(isp, &src->ct_header, &dst->ct_header); - ISP_IOXGET_32(isp, &src->ct_syshandle, dst->ct_syshandle); - ISP_IOXGET_8(isp, &src->ct_lun, dst->ct_lun); - ISP_IOXGET_8(isp, &src->ct_iid, dst->ct_iid); - ISP_IOXGET_16(isp, &src->ct_rxid, dst->ct_rxid); - ISP_IOXGET_16(isp, &src->ct_flags, dst->ct_flags); - ISP_IOXGET_16(isp, &src->ct_status, dst->ct_status); - ISP_IOXGET_16(isp, &src->ct_timeout, dst->ct_timeout); - ISP_IOXGET_16(isp, &src->ct_seg_count, dst->ct_seg_count); - ISP_IOXGET_32(isp, &src->ct_reloff, dst->ct_reloff); - ISP_IOXGET_32(isp, &src->ct_resid, dst->ct_resid); - if ((dst->ct_flags & CT2_FLAG_MMASK) == CT2_FLAG_MODE0) { - ISP_IOXGET_32(isp, &src->rsp.m0._reserved, - dst->rsp.m0._reserved); - ISP_IOXGET_16(isp, &src->rsp.m0._reserved2, - dst->rsp.m0._reserved2); - ISP_IOXGET_16(isp, &src->rsp.m0.ct_scsi_status, - dst->rsp.m0.ct_scsi_status); - ISP_IOXGET_32(isp, &src->rsp.m0.ct_xfrlen, - dst->rsp.m0.ct_xfrlen); - if (dst->ct_header.rqs_entry_type == RQSTYPE_CTIO2) { - for (i = 0; i < ISP_RQDSEG_T2; i++) { - ISP_IOXGET_32(isp, - &src->rsp.m0.u.ct_dataseg[i].ds_base, - dst->rsp.m0.u.ct_dataseg[i].ds_base); - ISP_IOXGET_32(isp, - &src->rsp.m0.u.ct_dataseg[i].ds_count, - dst->rsp.m0.u.ct_dataseg[i].ds_count); - } - } else if (dst->ct_header.rqs_entry_type == RQSTYPE_CTIO3) { - for (i = 0; i < ISP_RQDSEG_T3; i++) { - ISP_IOXGET_32(isp, - &src->rsp.m0.u.ct_dataseg64[i].ds_base, - dst->rsp.m0.u.ct_dataseg64[i].ds_base); - ISP_IOXGET_32(isp, - &src->rsp.m0.u.ct_dataseg64[i].ds_basehi, - dst->rsp.m0.u.ct_dataseg64[i].ds_basehi); - ISP_IOXGET_32(isp, - &src->rsp.m0.u.ct_dataseg64[i].ds_count, - dst->rsp.m0.u.ct_dataseg64[i].ds_count); - } - } else if (dst->ct_header.rqs_entry_type == RQSTYPE_CTIO4) { - ISP_IOXGET_16(isp, &src->rsp.m0.u.ct_dslist.ds_type, - dst->rsp.m0.u.ct_dslist.ds_type); - ISP_IOXGET_32(isp, &src->rsp.m0.u.ct_dslist.ds_segment, - dst->rsp.m0.u.ct_dslist.ds_segment); - ISP_IOXGET_32(isp, &src->rsp.m0.u.ct_dslist.ds_base, - dst->rsp.m0.u.ct_dslist.ds_base); - } - } else if ((dst->ct_flags & CT2_FLAG_MMASK) == CT2_FLAG_MODE1) { - ISP_IOXGET_16(isp, &src->rsp.m1._reserved, - dst->rsp.m1._reserved); - ISP_IOXGET_16(isp, &src->rsp.m1._reserved2, - dst->rsp.m1._reserved2); - ISP_IOXGET_16(isp, &src->rsp.m1.ct_senselen, - dst->rsp.m1.ct_senselen); - ISP_IOXGET_16(isp, &src->rsp.m1.ct_scsi_status, - dst->rsp.m1.ct_scsi_status); - ISP_IOXGET_16(isp, &src->rsp.m1.ct_resplen, - dst->rsp.m1.ct_resplen); - for (i = 0; i < MAXRESPLEN; i++) { - ISP_IOXGET_8(isp, &src->rsp.m1.ct_resp[i], - dst->rsp.m1.ct_resp[i]); - } - } else { - ISP_IOXGET_32(isp, &src->rsp.m2._reserved, - dst->rsp.m2._reserved); - ISP_IOXGET_16(isp, &src->rsp.m2._reserved2, - dst->rsp.m2._reserved2); - ISP_IOXGET_16(isp, &src->rsp.m2._reserved3, - dst->rsp.m2._reserved3); - ISP_IOXGET_32(isp, &src->rsp.m2.ct_datalen, - dst->rsp.m2.ct_datalen); - ISP_IOXGET_32(isp, &src->rsp.m2.ct_fcp_rsp_iudata.ds_base, - dst->rsp.m2.ct_fcp_rsp_iudata.ds_base); - ISP_IOXGET_32(isp, &src->rsp.m2.ct_fcp_rsp_iudata.ds_count, - dst->rsp.m2.ct_fcp_rsp_iudata.ds_count); - } -} - -void -isp_get_ctio2e(struct ispsoftc *isp, ct2e_entry_t *src, ct2e_entry_t *dst) -{ - int i; - - isp_get_hdr(isp, &src->ct_header, &dst->ct_header); - ISP_IOXGET_32(isp, &src->ct_syshandle, dst->ct_syshandle); - ISP_IOXGET_16(isp, &src->ct_iid, dst->ct_iid); - ISP_IOXGET_16(isp, &src->ct_rxid, dst->ct_rxid); - ISP_IOXGET_16(isp, &src->ct_flags, dst->ct_flags); - ISP_IOXGET_16(isp, &src->ct_status, dst->ct_status); - ISP_IOXGET_16(isp, &src->ct_timeout, dst->ct_timeout); - ISP_IOXGET_16(isp, &src->ct_seg_count, dst->ct_seg_count); - ISP_IOXGET_32(isp, &src->ct_reloff, dst->ct_reloff); - ISP_IOXGET_32(isp, &src->ct_resid, dst->ct_resid); - if ((dst->ct_flags & CT2_FLAG_MMASK) == CT2_FLAG_MODE0) { - ISP_IOXGET_32(isp, &src->rsp.m0._reserved, - dst->rsp.m0._reserved); - ISP_IOXGET_16(isp, &src->rsp.m0._reserved2, - dst->rsp.m0._reserved2); - ISP_IOXGET_16(isp, &src->rsp.m0.ct_scsi_status, - dst->rsp.m0.ct_scsi_status); - ISP_IOXGET_32(isp, &src->rsp.m0.ct_xfrlen, - dst->rsp.m0.ct_xfrlen); - if (src->ct_header.rqs_entry_type == RQSTYPE_CTIO2) { - for (i = 0; i < ISP_RQDSEG_T2; i++) { - ISP_IOXGET_32(isp, - &src->rsp.m0.u.ct_dataseg[i].ds_base, - dst->rsp.m0.u.ct_dataseg[i].ds_base); - ISP_IOXGET_32(isp, - &src->rsp.m0.u.ct_dataseg[i].ds_count, - dst->rsp.m0.u.ct_dataseg[i].ds_count); - } - } else if (dst->ct_header.rqs_entry_type == RQSTYPE_CTIO3) { - for (i = 0; i < ISP_RQDSEG_T3; i++) { - ISP_IOXGET_32(isp, - &src->rsp.m0.u.ct_dataseg64[i].ds_base, - dst->rsp.m0.u.ct_dataseg64[i].ds_base); - ISP_IOXGET_32(isp, - &src->rsp.m0.u.ct_dataseg64[i].ds_basehi, - dst->rsp.m0.u.ct_dataseg64[i].ds_basehi); - ISP_IOXGET_32(isp, - &src->rsp.m0.u.ct_dataseg64[i].ds_count, - dst->rsp.m0.u.ct_dataseg64[i].ds_count); - } - } else if (dst->ct_header.rqs_entry_type == RQSTYPE_CTIO4) { - ISP_IOXGET_16(isp, &src->rsp.m0.u.ct_dslist.ds_type, - dst->rsp.m0.u.ct_dslist.ds_type); - ISP_IOXGET_32(isp, &src->rsp.m0.u.ct_dslist.ds_segment, - dst->rsp.m0.u.ct_dslist.ds_segment); - ISP_IOXGET_32(isp, &src->rsp.m0.u.ct_dslist.ds_base, - dst->rsp.m0.u.ct_dslist.ds_base); - } - } else if ((dst->ct_flags & CT2_FLAG_MMASK) == CT2_FLAG_MODE1) { - ISP_IOXGET_16(isp, &src->rsp.m1._reserved, - dst->rsp.m1._reserved); - ISP_IOXGET_16(isp, &src->rsp.m1._reserved2, - dst->rsp.m1._reserved2); - ISP_IOXGET_16(isp, &src->rsp.m1.ct_senselen, - dst->rsp.m1.ct_senselen); - ISP_IOXGET_16(isp, &src->rsp.m1.ct_scsi_status, - dst->rsp.m1.ct_scsi_status); - ISP_IOXGET_16(isp, &src->rsp.m1.ct_resplen, - dst->rsp.m1.ct_resplen); - for (i = 0; i < MAXRESPLEN; i++) { - ISP_IOXGET_8(isp, &src->rsp.m1.ct_resp[i], - dst->rsp.m1.ct_resp[i]); - } - } else { - ISP_IOXGET_32(isp, &src->rsp.m2._reserved, - dst->rsp.m2._reserved); - ISP_IOXGET_16(isp, &src->rsp.m2._reserved2, - dst->rsp.m2._reserved2); - ISP_IOXGET_16(isp, &src->rsp.m2._reserved3, - dst->rsp.m2._reserved3); - ISP_IOXGET_32(isp, &src->rsp.m2.ct_datalen, - dst->rsp.m2.ct_datalen); - ISP_IOXGET_32(isp, &src->rsp.m2.ct_fcp_rsp_iudata.ds_base, - dst->rsp.m2.ct_fcp_rsp_iudata.ds_base); - ISP_IOXGET_32(isp, &src->rsp.m2.ct_fcp_rsp_iudata.ds_count, - dst->rsp.m2.ct_fcp_rsp_iudata.ds_count); - } -} - -void -isp_get_ctio7(struct ispsoftc *isp, ct7_entry_t *src, ct7_entry_t *dst) -{ - int i; - - isp_get_hdr(isp, &src->ct_header, &dst->ct_header); - ISP_IOXGET_32(isp, &src->ct_syshandle, dst->ct_syshandle); - ISP_IOXGET_16(isp, &src->ct_nphdl, dst->ct_nphdl); - ISP_IOXGET_16(isp, &src->ct_timeout, dst->ct_timeout); - ISP_IOXGET_16(isp, &src->ct_seg_count, dst->ct_seg_count); - ISP_IOXGET_8(isp, &src->ct_vpindex, dst->ct_vpindex); - ISP_IOXGET_8(isp, &src->ct_xflags, dst->ct_xflags); - ISP_IOXGET_16(isp, &src->ct_iid_lo, dst->ct_iid_lo); - ISP_IOXGET_8(isp, &src->ct_iid_hi, dst->ct_iid_hi); - ISP_IOXGET_8(isp, &src->ct_reserved, dst->ct_reserved); - ISP_IOXGET_32(isp, &src->ct_rxid, dst->ct_rxid); - ISP_IOXGET_16(isp, &src->ct_senselen, dst->ct_senselen); - ISP_IOXGET_16(isp, &src->ct_flags, dst->ct_flags); - ISP_IOXGET_32(isp, &src->ct_resid, dst->ct_resid); - ISP_IOXGET_16(isp, &src->ct_oxid, dst->ct_oxid); - ISP_IOXGET_16(isp, &src->ct_scsi_status, dst->ct_scsi_status); - if ((dst->ct_flags & CT7_FLAG_MMASK) == CT7_FLAG_MODE0) { - ISP_IOXGET_32(isp, &src->rsp.m0.reloff, dst->rsp.m0.reloff); - ISP_IOXGET_32(isp, &src->rsp.m0.reserved0, - dst->rsp.m0.reserved0); - ISP_IOXGET_32(isp, &src->rsp.m0.ct_xfrlen, - dst->rsp.m0.ct_xfrlen); - ISP_IOXGET_32(isp, &src->rsp.m0.reserved1, - dst->rsp.m0.reserved1); - ISP_IOXGET_32(isp, &src->rsp.m0.ds.ds_base, - dst->rsp.m0.ds.ds_base); - ISP_IOXGET_32(isp, &src->rsp.m0.ds.ds_basehi, - dst->rsp.m0.ds.ds_basehi); - ISP_IOXGET_32(isp, &src->rsp.m0.ds.ds_count, - dst->rsp.m0.ds.ds_count); - } else if ((dst->ct_flags & CT7_FLAG_MMASK) == CT7_FLAG_MODE1) { - ISP_IOXGET_16(isp, &src->rsp.m1.ct_resplen, - dst->rsp.m1.ct_resplen); - ISP_IOXGET_16(isp, &src->rsp.m1.reserved, dst->rsp.m1.reserved); - for (i = 0; i < MAXRESPLEN_24XX; i++) { - ISP_IOXGET_8(isp, &src->rsp.m1.ct_resp[i], - dst->rsp.m1.ct_resp[i]); - } - } else { - ISP_IOXGET_32(isp, &src->rsp.m2.reserved0, - dst->rsp.m2.reserved0); - ISP_IOXGET_32(isp, &src->rsp.m2.ct_datalen, - dst->rsp.m2.ct_datalen); - ISP_IOXGET_32(isp, &src->rsp.m2.reserved1, - dst->rsp.m2.reserved1); - ISP_IOXGET_32(isp, &src->rsp.m2.ct_fcp_rsp_iudata.ds_base, - dst->rsp.m2.ct_fcp_rsp_iudata.ds_base); - ISP_IOXGET_32(isp, &src->rsp.m2.ct_fcp_rsp_iudata.ds_basehi, - dst->rsp.m2.ct_fcp_rsp_iudata.ds_basehi); - ISP_IOXGET_32(isp, &src->rsp.m2.ct_fcp_rsp_iudata.ds_count, - dst->rsp.m2.ct_fcp_rsp_iudata.ds_count); - } -} - -void -isp_put_enable_lun(struct ispsoftc *isp, lun_entry_t *lesrc, lun_entry_t *ledst) -{ - int i; - isp_put_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]); - } -} - -void -isp_get_enable_lun(struct ispsoftc *isp, lun_entry_t *lesrc, lun_entry_t *ledst) -{ - int i; - isp_get_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]); - } -} - -void -isp_put_notify(struct ispsoftc *isp, in_entry_t *src, in_entry_t *dst) -{ - int i; - isp_put_hdr(isp, &src->in_header, &dst->in_header); - ISP_IOXPUT_32(isp, src->in_reserved, &dst->in_reserved); - if (ISP_IS_SBUS(isp)) { - ISP_IOXPUT_8(isp, src->in_lun, &dst->in_iid); - ISP_IOXPUT_8(isp, src->in_iid, &dst->in_lun); - ISP_IOXPUT_8(isp, src->in_reserved2, &dst->in_tgt); - ISP_IOXPUT_8(isp, src->in_tgt, &dst->in_reserved2); - ISP_IOXPUT_8(isp, src->in_status, &dst->in_rsvd2); - ISP_IOXPUT_8(isp, src->in_rsvd2, &dst->in_status); - ISP_IOXPUT_8(isp, src->in_tag_val, &dst->in_tag_type); - ISP_IOXPUT_8(isp, src->in_tag_type, &dst->in_tag_val); - } else { - ISP_IOXPUT_8(isp, src->in_lun, &dst->in_lun); - ISP_IOXPUT_8(isp, src->in_iid, &dst->in_iid); - ISP_IOXPUT_8(isp, src->in_reserved2, &dst->in_reserved2); - ISP_IOXPUT_8(isp, src->in_tgt, &dst->in_tgt); - ISP_IOXPUT_8(isp, src->in_status, &dst->in_status); - ISP_IOXPUT_8(isp, src->in_rsvd2, &dst->in_rsvd2); - ISP_IOXPUT_8(isp, src->in_tag_val, &dst->in_tag_val); - ISP_IOXPUT_8(isp, src->in_tag_type, &dst->in_tag_type); - } - ISP_IOXPUT_32(isp, src->in_flags, &dst->in_flags); - ISP_IOXPUT_16(isp, src->in_seqid, &dst->in_seqid); - for (i = 0; i < IN_MSGLEN; i++) { - ISP_IOXPUT_8(isp, src->in_msg[i], &dst->in_msg[i]); - } - for (i = 0; i < IN_RSVDLEN; i++) { - ISP_IOXPUT_8(isp, src->in_reserved3[i], - &dst->in_reserved3[i]); - } - for (i = 0; i < QLTM_SENSELEN; i++) { - ISP_IOXPUT_8(isp, src->in_sense[i], - &dst->in_sense[i]); - } -} - -void -isp_get_notify(struct ispsoftc *isp, in_entry_t *src, in_entry_t *dst) -{ - int i; - isp_get_hdr(isp, &src->in_header, &dst->in_header); - ISP_IOXGET_32(isp, &src->in_reserved, dst->in_reserved); - if (ISP_IS_SBUS(isp)) { - ISP_IOXGET_8(isp, &src->in_lun, dst->in_iid); - ISP_IOXGET_8(isp, &src->in_iid, dst->in_lun); - ISP_IOXGET_8(isp, &src->in_reserved2, dst->in_tgt); - ISP_IOXGET_8(isp, &src->in_tgt, dst->in_reserved2); - ISP_IOXGET_8(isp, &src->in_status, dst->in_rsvd2); - ISP_IOXGET_8(isp, &src->in_rsvd2, dst->in_status); - ISP_IOXGET_8(isp, &src->in_tag_val, dst->in_tag_type); - ISP_IOXGET_8(isp, &src->in_tag_type, dst->in_tag_val); - } else { - ISP_IOXGET_8(isp, &src->in_lun, dst->in_lun); - ISP_IOXGET_8(isp, &src->in_iid, dst->in_iid); - ISP_IOXGET_8(isp, &src->in_reserved2, dst->in_reserved2); - ISP_IOXGET_8(isp, &src->in_tgt, dst->in_tgt); - ISP_IOXGET_8(isp, &src->in_status, dst->in_status); - ISP_IOXGET_8(isp, &src->in_rsvd2, dst->in_rsvd2); - ISP_IOXGET_8(isp, &src->in_tag_val, dst->in_tag_val); - ISP_IOXGET_8(isp, &src->in_tag_type, dst->in_tag_type); - } - ISP_IOXGET_32(isp, &src->in_flags, dst->in_flags); - ISP_IOXGET_16(isp, &src->in_seqid, dst->in_seqid); - for (i = 0; i < IN_MSGLEN; i++) { - ISP_IOXGET_8(isp, &src->in_msg[i], dst->in_msg[i]); - } - for (i = 0; i < IN_RSVDLEN; i++) { - ISP_IOXGET_8(isp, &src->in_reserved3[i], - dst->in_reserved3[i]); - } - for (i = 0; i < QLTM_SENSELEN; i++) { - ISP_IOXGET_8(isp, &src->in_sense[i], - dst->in_sense[i]); - } -} - -void -isp_put_notify_fc(struct ispsoftc *isp, in_fcentry_t *src, - in_fcentry_t *dst) -{ - isp_put_hdr(isp, &src->in_header, &dst->in_header); - ISP_IOXPUT_32(isp, src->in_reserved, &dst->in_reserved); - ISP_IOXPUT_8(isp, src->in_lun, &dst->in_lun); - ISP_IOXPUT_8(isp, src->in_iid, &dst->in_iid); - ISP_IOXPUT_16(isp, src->in_scclun, &dst->in_scclun); - ISP_IOXPUT_32(isp, src->in_reserved2, &dst->in_reserved2); - ISP_IOXPUT_16(isp, src->in_status, &dst->in_status); - ISP_IOXPUT_16(isp, src->in_task_flags, &dst->in_task_flags); - ISP_IOXPUT_16(isp, src->in_seqid, &dst->in_seqid); -} - -void -isp_put_notify_fc_e(struct ispsoftc *isp, in_fcentry_e_t *src, - in_fcentry_e_t *dst) -{ - isp_put_hdr(isp, &src->in_header, &dst->in_header); - ISP_IOXPUT_32(isp, src->in_reserved, &dst->in_reserved); - ISP_IOXPUT_16(isp, src->in_iid, &dst->in_iid); - ISP_IOXPUT_16(isp, src->in_scclun, &dst->in_scclun); - ISP_IOXPUT_32(isp, src->in_reserved2, &dst->in_reserved2); - ISP_IOXPUT_16(isp, src->in_status, &dst->in_status); - ISP_IOXPUT_16(isp, src->in_task_flags, &dst->in_task_flags); - ISP_IOXPUT_16(isp, src->in_seqid, &dst->in_seqid); -} - -void -isp_put_notify_24xx(struct ispsoftc *isp, in_fcentry_24xx_t *src, - in_fcentry_24xx_t *dst) -{ - int i; - - isp_put_hdr(isp, &src->in_header, &dst->in_header); - ISP_IOXPUT_32(isp, src->in_reserved, &dst->in_reserved); - ISP_IOXPUT_16(isp, src->in_nphdl, &dst->in_nphdl); - ISP_IOXPUT_16(isp, src->in_reserved1, &dst->in_reserved1); - ISP_IOXPUT_16(isp, src->in_flags, &dst->in_flags); - ISP_IOXPUT_16(isp, src->in_srr_rxid, &dst->in_srr_rxid); - ISP_IOXPUT_16(isp, src->in_status, &dst->in_status); - ISP_IOXPUT_8(isp, src->in_status_subcode, &dst->in_status_subcode); - ISP_IOXPUT_16(isp, src->in_reserved2, &dst->in_reserved2); - ISP_IOXPUT_32(isp, src->in_rxid, &dst->in_rxid); - ISP_IOXPUT_16(isp, src->in_srr_reloff_hi, &dst->in_srr_reloff_hi); - ISP_IOXPUT_16(isp, src->in_srr_reloff_lo, &dst->in_srr_reloff_lo); - ISP_IOXPUT_16(isp, src->in_srr_iu, &dst->in_srr_iu); - ISP_IOXPUT_16(isp, src->in_srr_oxid, &dst->in_srr_oxid); - for (i = 0; i < 18; i++) { - ISP_IOXPUT_8(isp, src->in_reserved3[i], &dst->in_reserved3[i]); - } - ISP_IOXPUT_8(isp, src->in_reserved4, &dst->in_reserved4); - ISP_IOXPUT_8(isp, src->in_vpindex, &dst->in_vpindex); - ISP_IOXPUT_32(isp, src->in_reserved5, &dst->in_reserved5); - ISP_IOXPUT_16(isp, src->in_portid_lo, &dst->in_portid_lo); - ISP_IOXPUT_8(isp, src->in_portid_hi, &dst->in_portid_hi); - ISP_IOXPUT_8(isp, src->in_reserved6, &dst->in_reserved6); - ISP_IOXPUT_16(isp, src->in_reserved7, &dst->in_reserved7); - ISP_IOXPUT_16(isp, src->in_oxid, &dst->in_oxid); -} - -void -isp_get_notify_fc(struct ispsoftc *isp, in_fcentry_t *src, - in_fcentry_t *dst) -{ - isp_get_hdr(isp, &src->in_header, &dst->in_header); - ISP_IOXGET_32(isp, &src->in_reserved, dst->in_reserved); - ISP_IOXGET_8(isp, &src->in_lun, dst->in_lun); - ISP_IOXGET_8(isp, &src->in_iid, dst->in_iid); - ISP_IOXGET_16(isp, &src->in_scclun, dst->in_scclun); - ISP_IOXGET_32(isp, &src->in_reserved2, dst->in_reserved2); - ISP_IOXGET_16(isp, &src->in_status, dst->in_status); - ISP_IOXGET_16(isp, &src->in_task_flags, dst->in_task_flags); - ISP_IOXGET_16(isp, &src->in_seqid, dst->in_seqid); -} - -void -isp_get_notify_fc_e(struct ispsoftc *isp, in_fcentry_e_t *src, - in_fcentry_e_t *dst) -{ - isp_get_hdr(isp, &src->in_header, &dst->in_header); - ISP_IOXGET_32(isp, &src->in_reserved, dst->in_reserved); - ISP_IOXGET_16(isp, &src->in_iid, dst->in_iid); - ISP_IOXGET_16(isp, &src->in_scclun, dst->in_scclun); - ISP_IOXGET_32(isp, &src->in_reserved2, dst->in_reserved2); - ISP_IOXGET_16(isp, &src->in_status, dst->in_status); - ISP_IOXGET_16(isp, &src->in_task_flags, dst->in_task_flags); - ISP_IOXGET_16(isp, &src->in_seqid, dst->in_seqid); -} - -void -isp_get_notify_24xx(struct ispsoftc *isp, in_fcentry_24xx_t *src, - in_fcentry_24xx_t *dst) -{ - int i; - - isp_get_hdr(isp, &src->in_header, &dst->in_header); - ISP_IOXGET_32(isp, &src->in_reserved, dst->in_reserved); - ISP_IOXGET_16(isp, &src->in_nphdl, dst->in_nphdl); - ISP_IOXGET_16(isp, &src->in_reserved1, dst->in_reserved1); - ISP_IOXGET_16(isp, &src->in_flags, dst->in_flags); - ISP_IOXGET_16(isp, &src->in_srr_rxid, dst->in_srr_rxid); - ISP_IOXGET_16(isp, &src->in_status, dst->in_status); - ISP_IOXGET_8(isp, &src->in_status_subcode, dst->in_status_subcode); - ISP_IOXGET_16(isp, &src->in_reserved2, dst->in_reserved2); - ISP_IOXGET_32(isp, &src->in_rxid, dst->in_rxid); - ISP_IOXGET_16(isp, &src->in_srr_reloff_hi, dst->in_srr_reloff_hi); - ISP_IOXGET_16(isp, &src->in_srr_reloff_lo, dst->in_srr_reloff_lo); - ISP_IOXGET_16(isp, &src->in_srr_iu, dst->in_srr_iu); - ISP_IOXGET_16(isp, &src->in_srr_oxid, dst->in_srr_oxid); - for (i = 0; i < 18; i++) { - ISP_IOXGET_8(isp, &src->in_reserved3[i], dst->in_reserved3[i]); - } - ISP_IOXGET_8(isp, &src->in_reserved4, dst->in_reserved4); - ISP_IOXGET_8(isp, &src->in_vpindex, dst->in_vpindex); - ISP_IOXGET_32(isp, &src->in_reserved5, dst->in_reserved5); - ISP_IOXGET_16(isp, &src->in_portid_lo, dst->in_portid_lo); - ISP_IOXGET_8(isp, &src->in_portid_hi, dst->in_portid_hi); - ISP_IOXGET_8(isp, &src->in_reserved6, dst->in_reserved6); - ISP_IOXGET_16(isp, &src->in_reserved7, dst->in_reserved7); - ISP_IOXGET_16(isp, &src->in_oxid, dst->in_oxid); -} - -void -isp_put_notify_ack(struct ispsoftc *isp, na_entry_t *src, na_entry_t *dst) -{ - int i; - isp_put_hdr(isp, &src->na_header, &dst->na_header); - ISP_IOXPUT_32(isp, src->na_reserved, &dst->na_reserved); - if (ISP_IS_SBUS(isp)) { - ISP_IOXPUT_8(isp, src->na_lun, &dst->na_iid); - ISP_IOXPUT_8(isp, src->na_iid, &dst->na_lun); - ISP_IOXPUT_8(isp, src->na_status, &dst->na_event); - ISP_IOXPUT_8(isp, src->na_event, &dst->na_status); - } else { - ISP_IOXPUT_8(isp, src->na_lun, &dst->na_lun); - ISP_IOXPUT_8(isp, src->na_iid, &dst->na_iid); - ISP_IOXPUT_8(isp, src->na_status, &dst->na_status); - ISP_IOXPUT_8(isp, src->na_event, &dst->na_event); - } - ISP_IOXPUT_32(isp, src->na_flags, &dst->na_flags); - for (i = 0; i < NA_RSVDLEN; i++) { - ISP_IOXPUT_16(isp, src->na_reserved3[i], - &dst->na_reserved3[i]); - } -} - -void -isp_get_notify_ack(struct ispsoftc *isp, na_entry_t *src, na_entry_t *dst) -{ - int i; - isp_get_hdr(isp, &src->na_header, &dst->na_header); - ISP_IOXGET_32(isp, &src->na_reserved, dst->na_reserved); - if (ISP_IS_SBUS(isp)) { - ISP_IOXGET_8(isp, &src->na_lun, dst->na_iid); - ISP_IOXGET_8(isp, &src->na_iid, dst->na_lun); - ISP_IOXGET_8(isp, &src->na_status, dst->na_event); - ISP_IOXGET_8(isp, &src->na_event, dst->na_status); - } else { - ISP_IOXGET_8(isp, &src->na_lun, dst->na_lun); - ISP_IOXGET_8(isp, &src->na_iid, dst->na_iid); - ISP_IOXGET_8(isp, &src->na_status, dst->na_status); - ISP_IOXGET_8(isp, &src->na_event, dst->na_event); - } - ISP_IOXGET_32(isp, &src->na_flags, dst->na_flags); - for (i = 0; i < NA_RSVDLEN; i++) { - ISP_IOXGET_16(isp, &src->na_reserved3[i], - dst->na_reserved3[i]); - } -} - -void -isp_put_notify_ack_fc(struct ispsoftc *isp, na_fcentry_t *src, - na_fcentry_t *dst) -{ - int i; - isp_put_hdr(isp, &src->na_header, &dst->na_header); - ISP_IOXPUT_32(isp, src->na_reserved, &dst->na_reserved); - ISP_IOXPUT_8(isp, src->na_reserved1, &dst->na_reserved1); - ISP_IOXPUT_8(isp, src->na_iid, &dst->na_iid); - ISP_IOXPUT_16(isp, src->na_response, &dst->na_response); - ISP_IOXPUT_16(isp, src->na_flags, &dst->na_flags); - ISP_IOXPUT_16(isp, src->na_reserved2, &dst->na_reserved2); - ISP_IOXPUT_16(isp, src->na_status, &dst->na_status); - ISP_IOXPUT_16(isp, src->na_task_flags, &dst->na_task_flags); - ISP_IOXPUT_16(isp, src->na_seqid, &dst->na_seqid); - for (i = 0; i < NA2_RSVDLEN; i++) { - ISP_IOXPUT_16(isp, src->na_reserved3[i], - &dst->na_reserved3[i]); - } -} - -void -isp_put_notify_ack_fc_e(struct ispsoftc *isp, na_fcentry_e_t *src, - na_fcentry_e_t *dst) -{ - int i; - isp_put_hdr(isp, &src->na_header, &dst->na_header); - ISP_IOXPUT_32(isp, src->na_reserved, &dst->na_reserved); - ISP_IOXPUT_16(isp, src->na_iid, &dst->na_iid); - ISP_IOXPUT_16(isp, src->na_response, &dst->na_response); - ISP_IOXPUT_16(isp, src->na_flags, &dst->na_flags); - ISP_IOXPUT_16(isp, src->na_reserved2, &dst->na_reserved2); - ISP_IOXPUT_16(isp, src->na_status, &dst->na_status); - ISP_IOXPUT_16(isp, src->na_task_flags, &dst->na_task_flags); - ISP_IOXPUT_16(isp, src->na_seqid, &dst->na_seqid); - for (i = 0; i < NA2_RSVDLEN; i++) { - ISP_IOXPUT_16(isp, src->na_reserved3[i], - &dst->na_reserved3[i]); - } -} - -void -isp_put_notify_24xx_ack(struct ispsoftc *isp, na_fcentry_24xx_t *src, - na_fcentry_24xx_t *dst) -{ - int i; - - isp_put_hdr(isp, &src->na_header, &dst->na_header); - ISP_IOXPUT_32(isp, src->na_handle, &dst->na_handle); - ISP_IOXPUT_16(isp, src->na_nphdl, &dst->na_nphdl); - ISP_IOXPUT_16(isp, src->na_reserved1, &dst->na_reserved1); - ISP_IOXPUT_16(isp, src->na_flags, &dst->na_flags); - ISP_IOXPUT_16(isp, src->na_srr_rxid, &dst->na_srr_rxid); - ISP_IOXPUT_16(isp, src->na_status, &dst->na_status); - ISP_IOXPUT_8(isp, src->na_status_subcode, &dst->na_status_subcode); - ISP_IOXPUT_16(isp, src->na_reserved2, &dst->na_reserved2); - ISP_IOXPUT_32(isp, src->na_rxid, &dst->na_rxid); - ISP_IOXPUT_16(isp, src->na_srr_reloff_hi, &dst->na_srr_reloff_hi); - ISP_IOXPUT_16(isp, src->na_srr_reloff_lo, &dst->na_srr_reloff_lo); - ISP_IOXPUT_16(isp, src->na_srr_iu, &dst->na_srr_iu); - ISP_IOXPUT_16(isp, src->na_srr_flags, &dst->na_srr_flags); - for (i = 0; i < 18; i++) { - ISP_IOXPUT_8(isp, src->na_reserved3[i], &dst->na_reserved3[i]); - } - ISP_IOXPUT_8(isp, src->na_reserved4, &dst->na_reserved4); - ISP_IOXPUT_8(isp, src->na_vpindex, &dst->na_vpindex); - ISP_IOXPUT_8(isp, src->na_srr_reject_vunique, - &dst->na_srr_reject_vunique); - ISP_IOXPUT_8(isp, src->na_srr_reject_explanation, - &dst->na_srr_reject_explanation); - ISP_IOXPUT_8(isp, src->na_srr_reject_code, &dst->na_srr_reject_code); - ISP_IOXPUT_8(isp, src->na_reserved5, &dst->na_reserved5); - for (i = 0; i < 6; i++) { - ISP_IOXPUT_8(isp, src->na_reserved6[i], &dst->na_reserved6[i]); - } - ISP_IOXPUT_16(isp, src->na_oxid, &dst->na_oxid); -} - -void -isp_get_notify_ack_fc(struct ispsoftc *isp, na_fcentry_t *src, - na_fcentry_t *dst) -{ - int i; - isp_get_hdr(isp, &src->na_header, &dst->na_header); - ISP_IOXGET_32(isp, &src->na_reserved, dst->na_reserved); - ISP_IOXGET_8(isp, &src->na_reserved1, dst->na_reserved1); - ISP_IOXGET_8(isp, &src->na_iid, dst->na_iid); - ISP_IOXGET_16(isp, &src->na_response, dst->na_response); - ISP_IOXGET_16(isp, &src->na_flags, dst->na_flags); - ISP_IOXGET_16(isp, &src->na_reserved2, dst->na_reserved2); - ISP_IOXGET_16(isp, &src->na_status, dst->na_status); - ISP_IOXGET_16(isp, &src->na_task_flags, dst->na_task_flags); - ISP_IOXGET_16(isp, &src->na_seqid, dst->na_seqid); - for (i = 0; i < NA2_RSVDLEN; i++) { - ISP_IOXGET_16(isp, &src->na_reserved3[i], - dst->na_reserved3[i]); - } -} - -void -isp_get_notify_ack_fc_e(struct ispsoftc *isp, na_fcentry_e_t *src, - na_fcentry_e_t *dst) -{ - int i; - isp_get_hdr(isp, &src->na_header, &dst->na_header); - ISP_IOXGET_32(isp, &src->na_reserved, dst->na_reserved); - ISP_IOXGET_16(isp, &src->na_iid, dst->na_iid); - ISP_IOXGET_16(isp, &src->na_response, dst->na_response); - ISP_IOXGET_16(isp, &src->na_flags, dst->na_flags); - ISP_IOXGET_16(isp, &src->na_reserved2, dst->na_reserved2); - ISP_IOXGET_16(isp, &src->na_status, dst->na_status); - ISP_IOXGET_16(isp, &src->na_task_flags, dst->na_task_flags); - ISP_IOXGET_16(isp, &src->na_seqid, dst->na_seqid); - for (i = 0; i < NA2_RSVDLEN; i++) { - ISP_IOXGET_16(isp, &src->na_reserved3[i], - dst->na_reserved3[i]); - } -} - -void -isp_get_notify_ack_24xx(struct ispsoftc *isp, na_fcentry_24xx_t *src, - na_fcentry_24xx_t *dst) -{ - int i; - - isp_get_hdr(isp, &src->na_header, &dst->na_header); - ISP_IOXGET_32(isp, &src->na_handle, dst->na_handle); - ISP_IOXGET_16(isp, &src->na_nphdl, dst->na_nphdl); - ISP_IOXGET_16(isp, &src->na_reserved1, dst->na_reserved1); - ISP_IOXGET_16(isp, &src->na_flags, dst->na_flags); - ISP_IOXGET_16(isp, &src->na_srr_rxid, dst->na_srr_rxid); - ISP_IOXGET_16(isp, &src->na_status, dst->na_status); - ISP_IOXGET_8(isp, &src->na_status_subcode, dst->na_status_subcode); - ISP_IOXGET_16(isp, &src->na_reserved2, dst->na_reserved2); - ISP_IOXGET_32(isp, &src->na_rxid, dst->na_rxid); - ISP_IOXGET_16(isp, &src->na_srr_reloff_hi, dst->na_srr_reloff_hi); - ISP_IOXGET_16(isp, &src->na_srr_reloff_lo, dst->na_srr_reloff_lo); - ISP_IOXGET_16(isp, &src->na_srr_iu, dst->na_srr_iu); - ISP_IOXGET_16(isp, &src->na_srr_flags, dst->na_srr_flags); - for (i = 0; i < 18; i++) { - ISP_IOXGET_8(isp, &src->na_reserved3[i], dst->na_reserved3[i]); - } - ISP_IOXGET_8(isp, &src->na_reserved4, dst->na_reserved4); - ISP_IOXGET_8(isp, &src->na_vpindex, dst->na_vpindex); - ISP_IOXGET_8(isp, &src->na_srr_reject_vunique, - dst->na_srr_reject_vunique); - ISP_IOXGET_8(isp, &src->na_srr_reject_explanation, - dst->na_srr_reject_explanation); - ISP_IOXGET_8(isp, &src->na_srr_reject_code, dst->na_srr_reject_code); - ISP_IOXGET_8(isp, &src->na_reserved5, dst->na_reserved5); - for (i = 0; i < 6; i++) { - ISP_IOXGET_8(isp, &src->na_reserved6[i], dst->na_reserved6[i]); - } - ISP_IOXGET_16(isp, &src->na_oxid, dst->na_oxid); -} - -void -isp_get_abts(struct ispsoftc *isp, abts_t *src, abts_t *dst) -{ - int i; - - isp_get_hdr(isp, &src->abts_header, &dst->abts_header); - for (i = 0; i < 6; i++) { - ISP_IOXGET_8(isp, &src->abts_reserved0[i], - dst->abts_reserved0[i]); - } - ISP_IOXGET_16(isp, &src->abts_nphdl, dst->abts_nphdl); - ISP_IOXGET_16(isp, &src->abts_reserved1, dst->abts_reserved1); - ISP_IOXGET_16(isp, &src->abts_sof, dst->abts_sof); - ISP_IOXGET_32(isp, &src->abts_rxid_abts, dst->abts_rxid_abts); - ISP_IOXGET_16(isp, &src->abts_did_lo, dst->abts_did_lo); - ISP_IOXGET_8(isp, &src->abts_did_hi, dst->abts_did_hi); - ISP_IOXGET_8(isp, &src->abts_r_ctl, dst->abts_r_ctl); - ISP_IOXGET_16(isp, &src->abts_sid_lo, dst->abts_sid_lo); - ISP_IOXGET_8(isp, &src->abts_sid_hi, dst->abts_sid_hi); - ISP_IOXGET_8(isp, &src->abts_cs_ctl, dst->abts_cs_ctl); - ISP_IOXGET_16(isp, &src->abts_fs_ctl, dst->abts_fs_ctl); - ISP_IOXGET_8(isp, &src->abts_f_ctl, dst->abts_f_ctl); - ISP_IOXGET_8(isp, &src->abts_type, dst->abts_type); - ISP_IOXGET_16(isp, &src->abts_seq_cnt, dst->abts_seq_cnt); - ISP_IOXGET_8(isp, &src->abts_df_ctl, dst->abts_df_ctl); - ISP_IOXGET_8(isp, &src->abts_seq_id, dst->abts_seq_id); - ISP_IOXGET_16(isp, &src->abts_rx_id, dst->abts_rx_id); - ISP_IOXGET_16(isp, &src->abts_ox_id, dst->abts_ox_id); - ISP_IOXGET_32(isp, &src->abts_param, dst->abts_param); - for (i = 0; i < 16; i++) { - ISP_IOXGET_8(isp, &src->abts_reserved2[i], - dst->abts_reserved2[i]); - } - ISP_IOXGET_32(isp, &src->abts_rxid_task, dst->abts_rxid_task); -} - -void -isp_put_abts_rsp(struct ispsoftc *isp, abts_rsp_t *src, abts_rsp_t *dst) -{ - int i; - - isp_put_hdr(isp, &src->abts_rsp_header, &dst->abts_rsp_header); - ISP_IOXPUT_32(isp, src->abts_rsp_handle, &dst->abts_rsp_handle); - ISP_IOXPUT_16(isp, src->abts_rsp_status, &dst->abts_rsp_status); - ISP_IOXPUT_16(isp, src->abts_rsp_nphdl, &dst->abts_rsp_nphdl); - ISP_IOXPUT_16(isp, src->abts_rsp_ctl_flags, &dst->abts_rsp_ctl_flags); - ISP_IOXPUT_16(isp, src->abts_rsp_sof, &dst->abts_rsp_sof); - ISP_IOXPUT_32(isp, src->abts_rsp_rxid_abts, &dst->abts_rsp_rxid_abts); - ISP_IOXPUT_16(isp, src->abts_rsp_did_lo, &dst->abts_rsp_did_lo); - ISP_IOXPUT_8(isp, src->abts_rsp_did_hi, &dst->abts_rsp_did_hi); - ISP_IOXPUT_8(isp, src->abts_rsp_r_ctl, &dst->abts_rsp_r_ctl); - ISP_IOXPUT_16(isp, src->abts_rsp_sid_lo, &dst->abts_rsp_sid_lo); - ISP_IOXPUT_8(isp, src->abts_rsp_sid_hi, &dst->abts_rsp_sid_hi); - ISP_IOXPUT_8(isp, src->abts_rsp_cs_ctl, &dst->abts_rsp_cs_ctl); - ISP_IOXPUT_16(isp, src->abts_rsp_f_ctl_lo, &dst->abts_rsp_f_ctl_lo); - ISP_IOXPUT_8(isp, src->abts_rsp_f_ctl_hi, &dst->abts_rsp_f_ctl_hi); - ISP_IOXPUT_8(isp, src->abts_rsp_type, &dst->abts_rsp_type); - ISP_IOXPUT_16(isp, src->abts_rsp_seq_cnt, &dst->abts_rsp_seq_cnt); - ISP_IOXPUT_8(isp, src->abts_rsp_df_ctl, &dst->abts_rsp_df_ctl); - ISP_IOXPUT_8(isp, src->abts_rsp_seq_id, &dst->abts_rsp_seq_id); - ISP_IOXPUT_16(isp, src->abts_rsp_rx_id, &dst->abts_rsp_rx_id); - ISP_IOXPUT_16(isp, src->abts_rsp_ox_id, &dst->abts_rsp_ox_id); - ISP_IOXPUT_32(isp, src->abts_rsp_param, &dst->abts_rsp_param); - if (src->abts_rsp_r_ctl == BA_ACC) { - ISP_IOXPUT_16(isp, src->abts_rsp_payload.ba_acc.reserved, - &dst->abts_rsp_payload.ba_acc.reserved); - ISP_IOXPUT_8(isp, src->abts_rsp_payload.ba_acc.last_seq_id, - &dst->abts_rsp_payload.ba_acc.last_seq_id); - ISP_IOXPUT_8(isp, src->abts_rsp_payload.ba_acc.seq_id_valid, - &dst->abts_rsp_payload.ba_acc.seq_id_valid); - ISP_IOXPUT_16(isp, src->abts_rsp_payload.ba_acc.aborted_rx_id, - &dst->abts_rsp_payload.ba_acc.aborted_rx_id); - ISP_IOXPUT_16(isp, src->abts_rsp_payload.ba_acc.aborted_ox_id, - &dst->abts_rsp_payload.ba_acc.aborted_ox_id); - ISP_IOXPUT_16(isp, src->abts_rsp_payload.ba_acc.high_seq_cnt, - &dst->abts_rsp_payload.ba_acc.high_seq_cnt); - ISP_IOXPUT_16(isp, src->abts_rsp_payload.ba_acc.low_seq_cnt, - &dst->abts_rsp_payload.ba_acc.low_seq_cnt); - for (i = 0; i < 4; i++) { - ISP_IOXPUT_16(isp, - src->abts_rsp_payload.ba_acc.reserved2[i], - &dst->abts_rsp_payload.ba_acc.reserved2[i]); - } - } else if (src->abts_rsp_r_ctl == BA_RJT) { - ISP_IOXPUT_8(isp, src->abts_rsp_payload.ba_rjt.vendor_unique, - &dst->abts_rsp_payload.ba_rjt.vendor_unique); - ISP_IOXPUT_8(isp, src->abts_rsp_payload.ba_rjt.explanation, - &dst->abts_rsp_payload.ba_rjt.explanation); - ISP_IOXPUT_8(isp, src->abts_rsp_payload.ba_rjt.reason, - &dst->abts_rsp_payload.ba_rjt.reason); - ISP_IOXPUT_8(isp, src->abts_rsp_payload.ba_rjt.reserved, - &dst->abts_rsp_payload.ba_rjt.reserved); - for (i = 0; i < 12; i++) { - ISP_IOXPUT_16(isp, - src->abts_rsp_payload.ba_rjt.reserved2[i], - &dst->abts_rsp_payload.ba_rjt.reserved2[i]); - } - } else { - for (i = 0; i < 16; i++) { - ISP_IOXPUT_8(isp, src->abts_rsp_payload.reserved[i], - &dst->abts_rsp_payload.reserved[i]); - } - } - ISP_IOXPUT_32(isp, src->abts_rsp_rxid_task, &dst->abts_rsp_rxid_task); -} - -void -isp_get_abts_rsp(struct ispsoftc *isp, abts_rsp_t *src, abts_rsp_t *dst) -{ - int i; - - isp_get_hdr(isp, &src->abts_rsp_header, &dst->abts_rsp_header); - ISP_IOXGET_32(isp, &src->abts_rsp_handle, dst->abts_rsp_handle); - ISP_IOXGET_16(isp, &src->abts_rsp_status, dst->abts_rsp_status); - ISP_IOXGET_16(isp, &src->abts_rsp_nphdl, dst->abts_rsp_nphdl); - ISP_IOXGET_16(isp, &src->abts_rsp_ctl_flags, dst->abts_rsp_ctl_flags); - ISP_IOXGET_16(isp, &src->abts_rsp_sof, dst->abts_rsp_sof); - ISP_IOXGET_32(isp, &src->abts_rsp_rxid_abts, dst->abts_rsp_rxid_abts); - ISP_IOXGET_16(isp, &src->abts_rsp_did_lo, dst->abts_rsp_did_lo); - ISP_IOXGET_8(isp, &src->abts_rsp_did_hi, dst->abts_rsp_did_hi); - ISP_IOXGET_8(isp, &src->abts_rsp_r_ctl, dst->abts_rsp_r_ctl); - ISP_IOXGET_16(isp, &src->abts_rsp_sid_lo, dst->abts_rsp_sid_lo); - ISP_IOXGET_8(isp, &src->abts_rsp_sid_hi, dst->abts_rsp_sid_hi); - ISP_IOXGET_8(isp, &src->abts_rsp_cs_ctl, dst->abts_rsp_cs_ctl); - ISP_IOXGET_16(isp, &src->abts_rsp_f_ctl_lo, dst->abts_rsp_f_ctl_lo); - ISP_IOXGET_8(isp, &src->abts_rsp_f_ctl_hi, dst->abts_rsp_f_ctl_hi); - ISP_IOXGET_8(isp, &src->abts_rsp_type, dst->abts_rsp_type); - ISP_IOXGET_16(isp, &src->abts_rsp_seq_cnt, dst->abts_rsp_seq_cnt); - ISP_IOXGET_8(isp, &src->abts_rsp_df_ctl, dst->abts_rsp_df_ctl); - ISP_IOXGET_8(isp, &src->abts_rsp_seq_id, dst->abts_rsp_seq_id); - ISP_IOXGET_16(isp, &src->abts_rsp_rx_id, dst->abts_rsp_rx_id); - ISP_IOXGET_16(isp, &src->abts_rsp_ox_id, dst->abts_rsp_ox_id); - ISP_IOXGET_32(isp, &src->abts_rsp_param, dst->abts_rsp_param); - for (i = 0; i < 8; i++) { - ISP_IOXGET_8(isp, &src->abts_rsp_payload.rsp.reserved[i], - dst->abts_rsp_payload.rsp.reserved[i]); - } - ISP_IOXGET_32(isp, &src->abts_rsp_payload.rsp.subcode1, - dst->abts_rsp_payload.rsp.subcode1); - ISP_IOXGET_32(isp, &src->abts_rsp_payload.rsp.subcode2, - dst->abts_rsp_payload.rsp.subcode2); - ISP_IOXGET_32(isp, &src->abts_rsp_rxid_task, dst->abts_rsp_rxid_task); -} -#endif /* ISP_TARGET_MODE */ diff --git a/sys/dev/ic/isp_library.h b/sys/dev/ic/isp_library.h deleted file mode 100644 index a42dcd322ec..00000000000 --- a/sys/dev/ic/isp_library.h +++ /dev/null @@ -1,225 +0,0 @@ -/* $OpenBSD: isp_library.h,v 1.2 2009/06/24 11:00:53 krw Exp $ */ -/* $FreeBSD: src/sys/dev/isp/isp_library.h,v 1.8 2007/04/02 01:04:20 mjacob Exp $ */ -/*- - * Copyright (c) 1997-2007 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. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY 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 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_LIBRARY_H -#define _ISP_LIBRARY_H - -extern int isp_save_xs(ispsoftc_t *, XS_T *, u_int32_t *); -extern XS_T *isp_find_xs(ispsoftc_t *, u_int32_t); -extern u_int32_t isp_find_handle(ispsoftc_t *, XS_T *); -extern u_int32_t isp_handle_index(u_int32_t); -extern void isp_destroy_handle(ispsoftc_t *, u_int32_t); -extern int isp_getrqentry(ispsoftc_t *, u_int32_t *, u_int32_t *, void **); -extern void isp_print_qentry (ispsoftc_t *, char *, int, void *); -extern void isp_print_bytes(ispsoftc_t *, const char *, int, void *); -extern int isp_fc_runstate(ispsoftc_t *, int); -extern void isp_dump_portdb(ispsoftc_t *); -extern void isp_shutdown(ispsoftc_t *); -extern void isp_put_hdr(ispsoftc_t *, isphdr_t *, isphdr_t *); -extern void isp_get_hdr(ispsoftc_t *, isphdr_t *, isphdr_t *); -extern int isp_get_response_type(ispsoftc_t *, isphdr_t *); -extern void -isp_put_request(ispsoftc_t *, ispreq_t *, ispreq_t *); -extern void -isp_put_marker(ispsoftc_t *, isp_marker_t *, isp_marker_t *); -extern void -isp_put_marker_24xx(ispsoftc_t *, isp_marker_24xx_t *, isp_marker_24xx_t *); -extern void -isp_put_request_t2(ispsoftc_t *, ispreqt2_t *, ispreqt2_t *); -extern void -isp_put_request_t2e(ispsoftc_t *, ispreqt2e_t *, ispreqt2e_t *); -extern void -isp_put_request_t3(ispsoftc_t *, ispreqt3_t *, ispreqt3_t *); -extern void -isp_put_request_t3e(ispsoftc_t *, ispreqt3e_t *, ispreqt3e_t *); -extern void -isp_put_extended_request(ispsoftc_t *, ispextreq_t *, ispextreq_t *); -extern void -isp_put_request_t7(ispsoftc_t *, ispreqt7_t *, ispreqt7_t *); -extern void -isp_put_24xx_abrt(ispsoftc_t *, isp24xx_abrt_t *, isp24xx_abrt_t *); -extern void -isp_put_cont_req(ispsoftc_t *, ispcontreq_t *, ispcontreq_t *); -extern void -isp_put_cont64_req(ispsoftc_t *, ispcontreq64_t *, ispcontreq64_t *); -extern void -isp_get_response(ispsoftc_t *, ispstatusreq_t *, ispstatusreq_t *); -extern void isp_get_24xx_response(ispsoftc_t *, isp24xx_statusreq_t *, - isp24xx_statusreq_t *); -void -isp_get_24xx_abrt(ispsoftc_t *, isp24xx_abrt_t *, isp24xx_abrt_t *); -extern void -isp_get_rio2(ispsoftc_t *, isp_rio2_t *, isp_rio2_t *); -extern void -isp_put_icb(ispsoftc_t *, isp_icb_t *, isp_icb_t *); -extern void -isp_put_icb_2400(ispsoftc_t *, isp_icb_2400_t *, isp_icb_2400_t *); -extern void -isp_get_pdb_21xx(ispsoftc_t *, isp_pdb_21xx_t *, isp_pdb_21xx_t *); -extern void -isp_get_pdb_24xx(ispsoftc_t *, isp_pdb_24xx_t *, isp_pdb_24xx_t *); -extern void -isp_get_plogx(ispsoftc_t *, isp_plogx_t *, isp_plogx_t *); -extern void -isp_put_plogx(ispsoftc_t *, isp_plogx_t *, isp_plogx_t *); -extern void -isp_get_ct_pt(ispsoftc_t *isp, isp_ct_pt_t *, isp_ct_pt_t *); -extern void -isp_get_ms(ispsoftc_t *isp, isp_ms_t *, isp_ms_t *); -extern void -isp_put_ct_pt(ispsoftc_t *isp, isp_ct_pt_t *, isp_ct_pt_t *); -extern void -isp_put_ms(ispsoftc_t *isp, isp_ms_t *, isp_ms_t *); -extern void -isp_put_sns_request(ispsoftc_t *, sns_screq_t *, sns_screq_t *); -extern void -isp_put_gid_ft_request(ispsoftc_t *, sns_gid_ft_req_t *, - sns_gid_ft_req_t *); -extern void -isp_put_gxn_id_request(ispsoftc_t *, sns_gxn_id_req_t *, - sns_gxn_id_req_t *); -extern void -isp_get_sns_response(ispsoftc_t *, sns_scrsp_t *, sns_scrsp_t *, int); -extern void -isp_get_gid_ft_response(ispsoftc_t *, sns_gid_ft_rsp_t *, - sns_gid_ft_rsp_t *, int); -extern void -isp_get_gxn_id_response(ispsoftc_t *, sns_gxn_id_rsp_t *, - sns_gxn_id_rsp_t *); -extern void -isp_get_gff_id_response(ispsoftc_t *, sns_gff_id_rsp_t *, - sns_gff_id_rsp_t *); -extern void -isp_get_ga_nxt_response(ispsoftc_t *, sns_ga_nxt_rsp_t *, - sns_ga_nxt_rsp_t *); -extern void -isp_get_els(ispsoftc_t *, els_t *, els_t *); -extern void -isp_put_els(ispsoftc_t *, els_t *, els_t *); -extern void -isp_get_fc_hdr(ispsoftc_t *, fc_hdr_t *, fc_hdr_t *); -extern void -isp_get_fcp_cmnd_iu(ispsoftc_t *, fcp_cmnd_iu_t *, fcp_cmnd_iu_t *); -extern void isp_put_rft_id(ispsoftc_t *, rft_id_t *, rft_id_t *); -extern void isp_get_ct_hdr(ispsoftc_t *isp, ct_hdr_t *, ct_hdr_t *); -extern void isp_put_ct_hdr(ispsoftc_t *isp, ct_hdr_t *, ct_hdr_t *); - -#define ISP_HANDLE_MASK 0x7fff - -#ifdef ISP_TARGET_MODE -#if defined(__NetBSD__) || defined(__OpenBSD__) -#include <dev/ic/isp_target.h> -#elif defined(__FreeBSD__) -#include <dev/isp/isp_target.h> -#else -#include "isp_target.h" -#endif - -#define IS_TARGET_HANDLE(x) ((x) & 0x8000) - -extern int isp_save_xs_tgt(ispsoftc_t *, void *, u_int32_t *); -extern void *isp_find_xs_tgt(ispsoftc_t *, u_int32_t); -extern u_int32_t isp_find_tgt_handle(ispsoftc_t *, void *); -extern void isp_destroy_tgt_handle(ispsoftc_t *, u_int32_t); - -extern void -isp_put_atio(ispsoftc_t *, at_entry_t *, at_entry_t *); -extern void -isp_get_atio(ispsoftc_t *, at_entry_t *, at_entry_t *); -extern void -isp_put_atio2(ispsoftc_t *, at2_entry_t *, at2_entry_t *); -extern void -isp_put_atio2e(ispsoftc_t *, at2e_entry_t *, at2e_entry_t *); -extern void -isp_get_atio2(ispsoftc_t *, at2_entry_t *, at2_entry_t *); -extern void -isp_get_atio2e(ispsoftc_t *, at2e_entry_t *, at2e_entry_t *); -extern void -isp_get_atio7(ispsoftc_t *isp, at7_entry_t *, at7_entry_t *); -extern void -isp_put_ctio(ispsoftc_t *, ct_entry_t *, ct_entry_t *); -extern void -isp_get_ctio(ispsoftc_t *, ct_entry_t *, ct_entry_t *); -extern void -isp_put_ctio2(ispsoftc_t *, ct2_entry_t *, ct2_entry_t *); -extern void -isp_put_ctio2e(ispsoftc_t *, ct2e_entry_t *, ct2e_entry_t *); -extern void -isp_put_ctio7(ispsoftc_t *, ct7_entry_t *, ct7_entry_t *); -extern void -isp_get_ctio2(ispsoftc_t *, ct2_entry_t *, ct2_entry_t *); -extern void -isp_get_ctio2e(ispsoftc_t *, ct2e_entry_t *, ct2e_entry_t *); -extern void -isp_get_ctio7(ispsoftc_t *, ct7_entry_t *, ct7_entry_t *); -extern void -isp_put_enable_lun(ispsoftc_t *, lun_entry_t *, lun_entry_t *); -extern void -isp_get_enable_lun(ispsoftc_t *, lun_entry_t *, lun_entry_t *); -extern void -isp_put_notify(ispsoftc_t *, in_entry_t *, in_entry_t *); -extern void -isp_get_notify(ispsoftc_t *, in_entry_t *, in_entry_t *); -extern void -isp_put_notify_fc(ispsoftc_t *, in_fcentry_t *, in_fcentry_t *); -extern void -isp_put_notify_fc_e(ispsoftc_t *, in_fcentry_e_t *, in_fcentry_e_t *); -extern void -isp_put_notify_24xx(ispsoftc_t *, in_fcentry_24xx_t *, in_fcentry_24xx_t *); -extern void -isp_get_notify_fc(ispsoftc_t *, in_fcentry_t *, in_fcentry_t *); -extern void -isp_get_notify_fc_e(ispsoftc_t *, in_fcentry_e_t *, in_fcentry_e_t *); -extern void -isp_get_notify_24xx(ispsoftc_t *, in_fcentry_24xx_t *, in_fcentry_24xx_t *); -extern void -isp_put_notify_ack(ispsoftc_t *, na_entry_t *, na_entry_t *); -extern void -isp_get_notify_ack(ispsoftc_t *, na_entry_t *, na_entry_t *); -extern void -isp_put_notify_24xx_ack(ispsoftc_t *, na_fcentry_24xx_t *, na_fcentry_24xx_t *); -extern void -isp_put_notify_ack_fc(ispsoftc_t *, na_fcentry_t *, na_fcentry_t *); -extern void -isp_put_notify_ack_fc_e(ispsoftc_t *, na_fcentry_e_t *, na_fcentry_e_t *); -extern void isp_put_notify_ack_24xx(ispsoftc_t *, na_fcentry_24xx_t *, - na_fcentry_24xx_t *); -extern void -isp_get_notify_ack_fc(ispsoftc_t *, na_fcentry_t *, na_fcentry_t *); -extern void -isp_get_notify_ack_fc_e(ispsoftc_t *, na_fcentry_e_t *, na_fcentry_e_t *); -extern void isp_get_notify_ack_24xx(ispsoftc_t *, na_fcentry_24xx_t *, - na_fcentry_24xx_t *); -extern void -isp_get_abts(ispsoftc_t *, abts_t *, abts_t *); -extern void -isp_put_abts_rsp(ispsoftc_t *, abts_rsp_t *, abts_rsp_t *); -extern void -isp_get_abts_rsp(ispsoftc_t *, abts_rsp_t *, abts_rsp_t *); -#endif /* ISP_TARGET_MODE */ -#endif /* _ISP_LIBRARY_H */ diff --git a/sys/dev/ic/isp_openbsd.c b/sys/dev/ic/isp_openbsd.c deleted file mode 100644 index b2b3c802462..00000000000 --- a/sys/dev/ic/isp_openbsd.c +++ /dev/null @@ -1,1143 +0,0 @@ -/* $OpenBSD: isp_openbsd.c,v 1.48 2013/03/04 00:41:54 dlg Exp $ */ -/* - * Platform (OpenBSD) dependent common attachment code for QLogic adapters. - * - * Copyright (c) 1999, 2000, 2001 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. - * documentation and/or other materials provided with the distribution. - * 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. - * - * The author may be reached via electronic communications at - * - * mjacob@feral.com - * - * or, via United States Postal Address - * - * Matthew Jacob - * Feral Software - * PMB#825 - * 5214-F Diamond Heights Blvd. - * San Francisco, CA, 94131 - */ - -#include <dev/ic/isp_openbsd.h> - -/* - * Set a timeout for the watchdogging of a command. - * - * The dimensional analysis is - * - * milliseconds * (seconds/millisecond) * (ticks/second) = ticks - * - * = - * - * (milliseconds / 1000) * hz = ticks - * - * - * For timeouts less than 1 second, we'll get zero. Because of this, and - * because we want to establish *our* timeout to be longer than what the - * firmware might do, we just add 3 seconds at the back end. - */ -#define _XT(xs) ((((xs)->timeout/1000) * hz) + (3 * hz)) - -static void ispminphys(struct buf *, struct scsi_link *); -static int isp_scsi_probe(struct scsi_link *); -static void ispcmd_slow(XS_T *); -static void ispcmd(XS_T *); - -void isp_polled_cmd (struct ispsoftc *, XS_T *); -void isp_wdog (void *); -void isp_make_here(ispsoftc_t *, int); -void isp_make_gone(ispsoftc_t *, int); -void isp_requeue(void *); -void isp_trestart(void *); -void isp_restart(struct ispsoftc *); -void isp_add2_blocked_queue(struct ispsoftc *isp, XS_T *xs); -int isp_mstohz(int ms); - -struct cfdriver isp_cd = { - NULL, "isp", DV_DULL -}; - -static const char *roles[4] = { - "(none)", "Target", "Initiator", "Target/Initiator" -}; -static const char prom3[] = - "PortID 0x%06x Departed from Target %u because of %s"; -#define isp_change_is_bad 0 - -/* - * Complete attachment of hardware, include subdevices. - */ -void -isp_attach(struct ispsoftc *isp) -{ - struct scsibus_attach_args saa; - struct scsi_link *lptr = &isp->isp_osinfo._link[0]; - isp->isp_osinfo._adapter.scsi_minphys = ispminphys; - isp->isp_osinfo._adapter.dev_probe = isp_scsi_probe; - - isp->isp_state = ISP_RUNSTATE; - - /* - * We only manage a single wait queues for dual bus controllers. - * This is arguably broken. - */ - SIMPLEQ_INIT(&isp->isp_osinfo.wq); - - lptr->adapter_softc = isp; - lptr->adapter = &isp->isp_osinfo._adapter; - lptr->openings = imin(isp->isp_maxcmds, MAXISPREQUEST(isp)); - isp->isp_osinfo._adapter.scsi_cmd = ispcmd_slow; - if (IS_FC(isp)) { - lptr->adapter_buswidth = MAX_FC_TARG; - lptr->adapter_target = MAX_FC_TARG; /* i.e. ignore. */ - lptr->node_wwn = ISP_NODEWWN(isp); - lptr->port_wwn = ISP_PORTWWN(isp); - } else { - sdparam *sdp = isp->isp_param; - lptr->adapter_buswidth = MAX_TARGETS; - /* We can set max lun width here */ - lptr->adapter_target = sdp->isp_initiator_id; - isp->isp_osinfo.discovered[0] = 1 << sdp->isp_initiator_id; - if (IS_DUALBUS(isp)) { - struct scsi_link *lptrb = &isp->isp_osinfo._link[1]; - lptrb->adapter_softc = isp; - lptrb->adapter = &isp->isp_osinfo._adapter; - lptrb->openings = lptr->openings; - lptrb->adapter_buswidth = MAX_TARGETS; - lptrb->adapter_target = sdp->isp_initiator_id; - lptrb->flags = SDEV_2NDBUS; - isp->isp_osinfo.discovered[1] = - 1 << (sdp+1)->isp_initiator_id; - } - } - - /* - * Send a SCSI Bus Reset (used to be done as part of attach, - * but now left to the OS outer layers). - * - * We don't do 'bus resets' for FC because the LIP that occurs - * when we start the firmware does all that for us. - */ - if (IS_SCSI(isp)) { - int bus = 0; - ISP_LOCK(isp); - (void) isp_control(isp, ISPCTL_RESET_BUS, &bus); - if (IS_DUALBUS(isp)) { - bus++; - (void) isp_control(isp, ISPCTL_RESET_BUS, &bus); - } - ISP_UNLOCK(isp); - /* - * wait for the bus to settle. - */ - delay(4 * 1000000); - } else { - delay(2 * 1000000); - ISP_LOCK(isp); - isp_fc_runstate(isp, 10 * 1000000); - ISP_UNLOCK(isp); - } - - bzero(&saa, sizeof(saa)); - saa.saa_sc_link = lptr; - - /* - * And attach children (if any). - */ - config_found((void *)isp, &saa, scsiprint); - if (IS_DUALBUS(isp)) { - lptr++; - bzero(&saa, sizeof(saa)); - saa.saa_sc_link = lptr; - config_found((void *)isp, &saa, scsiprint); - } -} - -/* - * minphys our xfers - * - * Unfortunately, the buffer pointer describes the target device- not the - * adapter device, so we can't use the pointer to find out what kind of - * adapter we are and adjust accordingly. - */ - -static void -ispminphys(struct buf *bp, struct scsi_link *sl) -{ - /* - * XX: Only the 1020 has a 24 bit limit. - */ - if (bp->b_bcount >= (1 << 24)) { - bp->b_bcount = (1 << 24); - } - minphys(bp); -} - -void -ispcmd_slow(XS_T *xs) -{ - sdparam *sdp; - int tgt, chan; - u_int16_t f; - struct ispsoftc *isp = XS_ISP(xs); - - if (IS_FC(isp)) { - if (cold == 0) { - isp->isp_osinfo.no_mbox_ints = 0; - isp->isp_osinfo._adapter.scsi_cmd = ispcmd; - } - return (ispcmd(xs)); - } - - /* - * Have we completed discovery for this target on this adapter? - */ - sdp = isp->isp_param; - tgt = XS_TGT(xs); - chan = XS_CHANNEL(xs); - sdp += chan; - if ((xs->flags & SCSI_POLL) != 0 || - (isp->isp_osinfo.discovered[chan] & (1 << tgt)) != 0) { - return (ispcmd(xs)); - } - if (cold == 0) { - isp->isp_osinfo.no_mbox_ints = 0; - } - - f = DPARM_DEFAULT; - if (xs->sc_link->quirks & SDEV_NOSYNC) { - f &= ~DPARM_SYNC; - } - if (xs->sc_link->quirks & SDEV_NOWIDE) { - f &= ~DPARM_WIDE; - } - if (xs->sc_link->quirks & SDEV_NOTAGS) { - f &= ~DPARM_TQING; - } - - /* - * Okay, we know about this device now, - * so mark parameters to be updated for it. - */ - sdp->isp_devparam[tgt].goal_flags = f; - sdp->isp_devparam[tgt].dev_update = 1; - isp->isp_update |= (1 << chan); - - /* - * Now check to see whether we can get out of this checking mode now. - * XXX: WE CANNOT AS YET BECAUSE THERE IS NO MECHANISM TO TELL US - * XXX: WHEN WE'RE DONE DISCOVERY BECAUSE WE NEED ONE COMMAND AFTER - * XXX: DISCOVERY IS DONE FOR EACH TARGET TO TELL US THAT WE'RE DONE - * XXX: AND THAT DOESN'T HAPPEN HERE. AT BEST WE CAN MARK OURSELVES - * XXX: DONE WITH DISCOVERY FOR THIS TARGET AND SO SAVE MAYBE 20 - * XXX: LINES OF C CODE. - */ - isp->isp_osinfo.discovered[chan] |= (1 << tgt); - /* do not bother with these lines- they'll never execute correctly */ -#if 0 - sdp = isp->isp_param; - for (chan = 0; chan < (IS_12X0(isp)? 2 : 1); chan++, sdp++) { - f = 0xffff & ~(1 << sdp->isp_initiator_id); - if (isp->isp_osinfo.discovered[chan] != f) { - break; - } - } - if (chan == (IS_12X0(isp)? 2 : 1)) { - isp->isp_osinfo._adapter.scsipi_cmd = ispcmd; - if (IS_12X0(isp)) - isp->isp_update |= 2; - } -#endif - return (ispcmd(xs)); -} - -void -isp_add2_blocked_queue(struct ispsoftc *isp, XS_T *xs) -{ - SIMPLEQ_INSERT_TAIL(&isp->isp_osinfo.wq, xs, xfer_list); -} - -int -isp_scsi_probe(struct scsi_link *link) -{ - struct ispsoftc *isp = (struct ispsoftc *)link->adapter_softc; - - if (link->lun >= isp->isp_maxluns) - return (ENXIO); - - return (0); -} - -void -ispcmd(XS_T *xs) -{ - struct ispsoftc *isp; - int result; - - /* - * Make sure that there's *some* kind of sane setting. - */ - isp = XS_ISP(xs); - - timeout_set(&xs->stimeout, isp_wdog, xs); - - ISP_LOCK(isp); - - if (isp->isp_state < ISP_RUNSTATE) { - ISP_DISABLE_INTS(isp); - isp_init(isp); - if (isp->isp_state != ISP_INITSTATE) { - ISP_ENABLE_INTS(isp); - XS_SETERR(xs, HBA_BOTCH); - scsi_done(xs); - ISP_UNLOCK(isp); - return; - } - isp->isp_state = ISP_RUNSTATE; - ISP_ENABLE_INTS(isp); - } - - /* - * Check for queue blockage... - */ - if (isp->isp_osinfo.blocked) { - if (xs->flags & SCSI_POLL) { - xs->error = XS_NO_CCB; - scsi_done(xs); - ISP_UNLOCK(isp); - return; - } - if (isp->isp_osinfo.blocked == 2) { - isp_restart(isp); - } - if (isp->isp_osinfo.blocked) { - isp_add2_blocked_queue(isp, xs); - ISP_UNLOCK(isp); -#ifndef SMALL_KERNEL - isp_prt(isp, ISP_LOGDEBUG0, "added to blocked queue"); -#endif - return; - } - } - - if (xs->flags & SCSI_POLL) { - volatile u_int8_t ombi = isp->isp_osinfo.no_mbox_ints; - isp->isp_osinfo.no_mbox_ints = 1; - isp_polled_cmd(isp, xs); - isp->isp_osinfo.no_mbox_ints = ombi; - ISP_UNLOCK(isp); - return; - } - - result = isp_start(xs); - - switch (result) { - case CMD_QUEUED: - if (xs->timeout) { - timeout_add(&xs->stimeout, _XT(xs)); - XS_CMD_S_TIMER(xs); - } - if (isp->isp_osinfo.hiwater < isp->isp_nactive) { - isp->isp_osinfo.hiwater = isp->isp_nactive; -#ifndef SMALL_KERNEL - isp_prt(isp, ISP_LOGDEBUG0, - "Active Hiwater Mark=%d", isp->isp_nactive); -#endif - } - break; - case CMD_EAGAIN: - isp->isp_osinfo.blocked |= 2; -#ifndef SMALL_KERNEL - isp_prt(isp, ISP_LOGDEBUG0, "blocking queue"); -#endif - isp_add2_blocked_queue(isp, xs); - break; - case CMD_RQLATER: -#ifndef SMALL_KERNEL - isp_prt(isp, ISP_LOGDEBUG1, "retrying later for %d.%d", - XS_TGT(xs), XS_LUN(xs)); -#endif - timeout_set(&xs->stimeout, isp_requeue, xs); - timeout_add_sec(&xs->stimeout, 1); - XS_CMD_S_TIMER(xs); - break; - case CMD_COMPLETE: - scsi_done(xs); - break; - } - ISP_UNLOCK(isp); -} - -void -isp_polled_cmd(struct ispsoftc *isp, XS_T *xs) -{ - int result; - int infinite = 0, mswait; - - result = isp_start(xs); - - switch (result) { - case CMD_QUEUED: - break; - case CMD_RQLATER: - case CMD_EAGAIN: - xs->error = XS_NO_CCB; - /* FALLTHROUGH */ - case CMD_COMPLETE: - scsi_done(xs); - return; - } - - /* - * If we can't use interrupts, poll on completion. - */ - if ((mswait = XS_TIME(xs)) == 0) - infinite = 1; - - while (mswait || infinite) { - u_int32_t isr; - u_int16_t sema, mbox; - if (ISP_READ_ISR(isp, &isr, &sema, &mbox)) { - isp_intr(isp, isr, sema, mbox); - if (XS_CMD_DONE_P(xs)) { - break; - } - } - USEC_DELAY(1000); - mswait -= 1; - } - - /* - * If no other error occurred but we didn't finish, - * something bad happened. - */ - if (XS_CMD_DONE_P(xs) == 0) { - if (isp_control(isp, ISPCTL_ABORT_CMD, xs)) { - isp_reinit(isp); - } - if (XS_NOERR(xs)) { - XS_SETERR(xs, HBA_BOTCH); - } - } -} - -void -isp_done(XS_T *xs) -{ - XS_CMD_S_DONE(xs); - if (XS_CMD_WDOG_P(xs) == 0) { - struct ispsoftc *isp = XS_ISP(xs); - if (XS_CMD_TIMER_P(xs)) { - timeout_del(&xs->stimeout); - XS_CMD_C_TIMER(xs); - } - if (XS_CMD_GRACE_P(xs)) { - struct ispsoftc *isp = XS_ISP(xs); - isp_prt(isp, ISP_LOGWARN, - "finished command on borrowed time"); - } - XS_CMD_S_CLEAR(xs); - scsi_done(xs); - if (isp->isp_osinfo.blocked == 2) { - isp->isp_osinfo.blocked = 0; -#ifndef SMALL_KERNEL - isp_prt(isp, ISP_LOGDEBUG0, "restarting blocked queue"); -#endif - isp_restart(isp); - } - } -} - -void -isp_wdog(void *arg) -{ - XS_T *xs = arg; - struct ispsoftc *isp = XS_ISP(xs); - u_int32_t handle; - - /* - * We've decided this command is dead. Make sure we're not trying - * to kill a command that's already dead by getting its handle and - * and seeing whether it's still alive. - */ - ISP_LOCK(isp); - handle = isp_find_handle(isp, xs); - if (handle) { - u_int32_t isr; - u_int16_t sema, mbox; - - if (XS_CMD_DONE_P(xs)) { -#ifndef SMALL_KERNEL - isp_prt(isp, ISP_LOGDEBUG1, - "watchdog found done cmd (handle 0x%x)", - handle); -#endif - ISP_UNLOCK(isp); - return; - } - - if (XS_CMD_WDOG_P(xs)) { -#ifndef SMALL_KERNEL - isp_prt(isp, ISP_LOGDEBUG1, - "recursive watchdog (handle 0x%x)", - handle); -#endif - ISP_UNLOCK(isp); - return; - } - - XS_CMD_S_WDOG(xs); - - if (ISP_READ_ISR(isp, &isr, &sema, &mbox)) { - isp_intr(isp, isr, sema, mbox); - } - - if (XS_CMD_DONE_P(xs)) { - isp_prt(isp, ISP_LOGINFO, - "watchdog cleanup for handle 0x%x", handle); - XS_CMD_C_WDOG(xs); - isp_done(xs); - } else if (XS_CMD_GRACE_P(xs)) { - /* - * Make sure the command is *really* dead before we - * release the handle (and DMA resources) for reuse. - */ - (void) isp_control(isp, ISPCTL_ABORT_CMD, arg); - - /* - * After this point, the command is really dead. - */ - if (XS_XFRLEN(xs)) { - ISP_DMAFREE(isp, xs, handle); - } - isp_prt(isp, ISP_LOGWARN, - "watchdog timeout on handle %x", handle); - isp_destroy_handle(isp, handle); - XS_SETERR(xs, XS_TIMEOUT); - XS_CMD_S_CLEAR(xs); - isp_done(xs); - } else { - u_int32_t optr, nxti; - ispreq_t local, *mp = &local, *qe; - - isp_prt(isp, ISP_LOGWARN, - "possible command timeout on handle %x", handle); - - XS_CMD_C_WDOG(xs); - timeout_add(&xs->stimeout, _XT(xs)); - XS_CMD_S_TIMER(xs); - if (isp_getrqentry(isp, &nxti, &optr, (void **) &qe)) { - ISP_UNLOCK(isp); - return; - } - XS_CMD_S_GRACE(xs); - MEMZERO((void *) mp, sizeof (*mp)); - mp->req_header.rqs_entry_count = 1; - mp->req_header.rqs_entry_type = RQSTYPE_MARKER; - mp->req_cdblen = SYNC_ALL; - mp->req_target = XS_CHANNEL(xs) << 7; - isp_put_request(isp, mp, qe); - ISP_ADD_REQUEST(isp, nxti); - } - } -#ifndef SMALL_KERNEL - else if (isp->isp_dblev) { - isp_prt(isp, ISP_LOGDEBUG1, "watchdog with no command"); - } -#endif - ISP_UNLOCK(isp); -} - -void -isp_make_here(ispsoftc_t *isp, int tgt) -{ - isp_prt(isp, ISP_LOGINFO, "target %d has arrived", tgt); -} - -void -isp_make_gone(ispsoftc_t *isp, int tgt) -{ - isp_prt(isp, ISP_LOGINFO, "target %d has departed", tgt); -} - -/* - * Free any associated resources prior to decommissioning and - * set the card to a known state (so it doesn't wake up and kick - * us when we aren't expecting it to). - * - * Locks are held before coming here. - */ -void -isp_uninit(struct ispsoftc *isp) -{ - ISP_LOCK(isp); - /* - * Leave with interrupts disabled. - */ - ISP_DISABLE_INTS(isp); - - ISP_UNLOCK(isp); -} - -/* - * Restart function for a command to be requeued later. - */ -void -isp_requeue(void *arg) -{ - int r; - struct scsi_xfer *xs = arg; - struct ispsoftc *isp = XS_ISP(xs); - ISP_LOCK(isp); - r = isp_start(xs); - switch (r) { - case CMD_QUEUED: -#ifndef SMALL_KERNEL - isp_prt(isp, ISP_LOGDEBUG1, "restarted command for %d.%d", - XS_TGT(xs), XS_LUN(xs)); -#endif - if (xs->timeout) { - timeout_set(&xs->stimeout, isp_wdog, xs); - timeout_add(&xs->stimeout, _XT(xs)); - XS_CMD_S_TIMER(xs); - } - break; - case CMD_EAGAIN: -#ifndef SMALL_KERNEL - isp_prt(isp, ISP_LOGDEBUG0, "blocked cmd again"); -#endif - isp->isp_osinfo.blocked |= 2; - isp_add2_blocked_queue(isp, xs); - break; - case CMD_RQLATER: -#ifndef SMALL_KERNEL - isp_prt(isp, ISP_LOGDEBUG0, "%s for %d.%d", - (r == CMD_EAGAIN)? "CMD_EAGAIN" : "CMD_RQLATER", - XS_TGT(xs), XS_LUN(xs)); -#endif - timeout_set(&xs->stimeout, isp_requeue, xs); - timeout_add_sec(&xs->stimeout, 1); - XS_CMD_S_TIMER(xs); - break; - case CMD_COMPLETE: - /* can only be an error */ - if (XS_NOERR(xs)) - XS_SETERR(xs, XS_DRIVER_STUFFUP); - isp_done(xs); - break; - } - ISP_UNLOCK(isp); -} - -/* - * Restart function after a LOOP UP event or a command completing, - * sometimes done as a timeout for some hysteresis. - */ -void -isp_trestart(void *arg) -{ - struct ispsoftc *isp = arg; - struct scsi_xfer *xs; - struct scsi_xfer_list list; - - ISP_LOCK(isp); - isp->isp_osinfo.rtpend = 0; - if (isp->isp_osinfo.blocked) { - ISP_UNLOCK(isp); - return; - } - - list = isp->isp_osinfo.wq; - SIMPLEQ_INIT(&isp->isp_osinfo.wq); - ISP_UNLOCK(isp); - - while ((xs = SIMPLEQ_FIRST(&list)) != NULL) { - SIMPLEQ_REMOVE_HEAD(&list, xfer_list); - isp_requeue(xs); - } -} - -void -isp_restart(struct ispsoftc *isp) -{ - struct scsi_xfer *xs; - struct scsi_xfer_list list; - - if (isp->isp_osinfo.blocked) - return; - - list = isp->isp_osinfo.wq; - SIMPLEQ_INIT(&isp->isp_osinfo.wq); - - while ((xs = SIMPLEQ_FIRST(&list)) != NULL) { - SIMPLEQ_REMOVE_HEAD(&list, xfer_list); - isp_requeue(xs); - } -} - -int -isp_async(struct ispsoftc *isp, ispasync_t cmd, void *arg) -{ - int bus, tgt; - char *msg = NULL; - static const char prom[] = - "PortID 0x%06x handle 0x%x role %s %s\n" - " WWNN 0x%08x%08x WWPN 0x%08x%08x"; - static const char prom2[] = - "PortID 0x%06x handle 0x%x role %s %s tgt %u\n" - " WWNN 0x%08x%08x WWPN 0x%08x%08x"; - fcportdb_t *lp; - - switch (cmd) { - case ISPASYNC_NEW_TGT_PARAMS: - if (IS_SCSI(isp) && isp->isp_dblev) { - sdparam *sdp = isp->isp_param; - char *wt; - int mhz, flags, period; - - tgt = *((int *) arg); - bus = (tgt >> 16) & 0xffff; - tgt &= 0xffff; - sdp += bus; - flags = sdp->isp_devparam[tgt].actv_flags; - period = sdp->isp_devparam[tgt].actv_period; - - if ((flags & DPARM_SYNC) && period && - (sdp->isp_devparam[tgt].actv_offset) != 0) { - /* - * There's some ambiguity about our negotiated speed - * if we haven't detected LVD mode correctly (which - * seems to happen, unfortunately). If we're in LVD - * mode, then different rules apply about speed. - */ - if (sdp->isp_lvdmode || period < 0xc) { - switch (period) { - case 0x9: - mhz = 80; - break; - case 0xa: - mhz = 40; - break; - case 0xb: - mhz = 33; - break; - case 0xc: - mhz = 25; - break; - default: - mhz = 1000 / (period * 4); - break; - } - } else { - mhz = 1000 / (period * 4); - } - } else { - mhz = 0; - } - switch (flags & (DPARM_WIDE|DPARM_TQING)) { - case DPARM_WIDE: - wt = ", 16 bit wide"; - break; - case DPARM_TQING: - wt = ", Tagged Queueing Enabled"; - break; - case DPARM_WIDE|DPARM_TQING: - wt = ", 16 bit wide, Tagged Queueing Enabled"; - break; - default: - wt = " "; - break; - } - if (mhz) { - isp_prt(isp, ISP_LOGINFO, - "Bus %d Target %d at %dMHz Max Offset %d%s", - bus, tgt, mhz, sdp->isp_devparam[tgt].actv_offset, - wt); - } else { - isp_prt(isp, ISP_LOGINFO, - "Bus %d Target %d Async Mode%s", bus, tgt, wt); - } - break; - } - case ISPASYNC_BUS_RESET: - if (arg) - bus = *((int *) arg); - else - bus = 0; - isp_prt(isp, ISP_LOGINFO, "SCSI bus %d reset detected", bus); - break; - case ISPASYNC_LOOP_DOWN: - /* - * Hopefully we get here in time to minimize the number - * of commands we are firing off that are sure to die. - */ - isp->isp_osinfo.blocked |= 1; - isp_prt(isp, ISP_LOGINFO, "Loop DOWN"); - break; - case ISPASYNC_LOOP_UP: - isp->isp_osinfo.blocked &= ~1; - if (isp->isp_osinfo.rtpend == 0) { - timeout_set(&isp->isp_osinfo.rqt, isp_trestart, isp); - isp->isp_osinfo.rtpend = 1; - } - timeout_add(&isp->isp_osinfo.rqt, 1); - isp_prt(isp, ISP_LOGINFO, "Loop UP"); - break; - case ISPASYNC_DEV_ARRIVED: - lp = arg; - lp->reserved = 0; - if ((isp->isp_role & ISP_ROLE_INITIATOR) && - (lp->roles & (SVC3_TGT_ROLE >> SVC3_ROLE_SHIFT))) { - int dbidx = lp - FCPARAM(isp)->portdb; - int i; - - for (i = 0; i < MAX_FC_TARG; i++) { - if (i >= FL_ID && i <= SNS_ID) { - continue; - } - if (FCPARAM(isp)->isp_ini_map[i] == 0) { - break; - } - } - if (i < MAX_FC_TARG) { - FCPARAM(isp)->isp_ini_map[i] = dbidx + 1; - lp->ini_map_idx = i + 1; - } else { - isp_prt(isp, ISP_LOGWARN, "out of target ids"); - isp_dump_portdb(isp); - } - } - if (lp->ini_map_idx) { - tgt = lp->ini_map_idx - 1; - isp_prt(isp, ISP_LOGCONFIG, prom2, - lp->portid, lp->handle, - roles[lp->roles], "arrived at", tgt, - (uint32_t) (lp->node_wwn >> 32), - (uint32_t) lp->node_wwn, - (uint32_t) (lp->port_wwn >> 32), - (uint32_t) lp->port_wwn); - isp_make_here(isp, tgt); - } else { - isp_prt(isp, ISP_LOGCONFIG, prom, - lp->portid, lp->handle, - roles[lp->roles], "arrived", - (uint32_t) (lp->node_wwn >> 32), - (uint32_t) lp->node_wwn, - (uint32_t) (lp->port_wwn >> 32), - (uint32_t) lp->port_wwn); - } - break; - case ISPASYNC_DEV_CHANGED: - lp = arg; - if (isp_change_is_bad) { - lp->state = FC_PORTDB_STATE_NIL; - if (lp->ini_map_idx) { - tgt = lp->ini_map_idx - 1; - FCPARAM(isp)->isp_ini_map[tgt] = 0; - lp->ini_map_idx = 0; - isp_prt(isp, ISP_LOGCONFIG, prom3, - lp->portid, tgt, "change is bad"); - isp_make_gone(isp, tgt); - } else { - isp_prt(isp, ISP_LOGCONFIG, prom, - lp->portid, lp->handle, - roles[lp->roles], - "changed and departed", - (uint32_t) (lp->node_wwn >> 32), - (uint32_t) lp->node_wwn, - (uint32_t) (lp->port_wwn >> 32), - (uint32_t) lp->port_wwn); - } - } else { - lp->portid = lp->new_portid; - lp->roles = lp->new_roles; - if (lp->ini_map_idx) { - int t = lp->ini_map_idx - 1; - FCPARAM(isp)->isp_ini_map[t] = - (lp - FCPARAM(isp)->portdb) + 1; - tgt = lp->ini_map_idx - 1; - isp_prt(isp, ISP_LOGCONFIG, prom2, - lp->portid, lp->handle, - roles[lp->roles], "changed at", tgt, - (uint32_t) (lp->node_wwn >> 32), - (uint32_t) lp->node_wwn, - (uint32_t) (lp->port_wwn >> 32), - (uint32_t) lp->port_wwn); - } else { - isp_prt(isp, ISP_LOGCONFIG, prom, - lp->portid, lp->handle, - roles[lp->roles], "changed", - (uint32_t) (lp->node_wwn >> 32), - (uint32_t) lp->node_wwn, - (uint32_t) (lp->port_wwn >> 32), - (uint32_t) lp->port_wwn); - } - } - break; - case ISPASYNC_DEV_STAYED: - lp = arg; - if (lp->ini_map_idx) { - tgt = lp->ini_map_idx - 1; - isp_prt(isp, ISP_LOGCONFIG, prom2, - lp->portid, lp->handle, - roles[lp->roles], "stayed at", tgt, - (uint32_t) (lp->node_wwn >> 32), - (uint32_t) lp->node_wwn, - (uint32_t) (lp->port_wwn >> 32), - (uint32_t) lp->port_wwn); - } else { - isp_prt(isp, ISP_LOGCONFIG, prom, - lp->portid, lp->handle, - roles[lp->roles], "stayed", - (uint32_t) (lp->node_wwn >> 32), - (uint32_t) lp->node_wwn, - (uint32_t) (lp->port_wwn >> 32), - (uint32_t) lp->port_wwn); - } - break; - case ISPASYNC_DEV_GONE: - lp = arg; - if (lp->ini_map_idx && lp->reserved == 0) { - lp->reserved = 1; - lp->state = FC_PORTDB_STATE_ZOMBIE; - tgt = lp->ini_map_idx - 1; - isp_prt(isp, ISP_LOGCONFIG, prom2, - lp->portid, lp->handle, - roles[lp->roles], "gone zombie at", tgt, - (uint32_t) (lp->node_wwn >> 32), - (uint32_t) lp->node_wwn, - (uint32_t) (lp->port_wwn >> 32), - (uint32_t) lp->port_wwn); - } else if (lp->reserved == 0) { - isp_prt(isp, ISP_LOGCONFIG, prom, - lp->portid, lp->handle, - roles[lp->roles], "departed", - (uint32_t) (lp->node_wwn >> 32), - (uint32_t) lp->node_wwn, - (uint32_t) (lp->port_wwn >> 32), - (uint32_t) lp->port_wwn); - } - break; - case ISPASYNC_CHANGE_NOTIFY: - if (arg == ISPASYNC_CHANGE_PDB) { - msg = "Port Database Changed"; - } else if (arg == ISPASYNC_CHANGE_SNS) { - msg = "Name Server Database Changed"; - } else { - msg = "Other Change Notify"; - } - isp_prt(isp, ISP_LOGINFO, msg); - break; - case ISPASYNC_FW_CRASH: - { - u_int16_t mbox1, mbox6; - mbox1 = ISP_READ(isp, OUTMAILBOX1); - if (IS_DUALBUS(isp)) { - mbox6 = ISP_READ(isp, OUTMAILBOX6); - } else { - mbox6 = 0; - } - isp_prt(isp, ISP_LOGERR, - "Internal Firmware Error on bus %d @ RISC Address 0x%x", - mbox6, mbox1); -#ifdef ISP_FW_CRASH_DUMP - if (IS_FC(isp)) { - isp->isp_osinfo.blocked |= 1; - isp_fw_dump(isp); - } - isp_reinit(isp); - isp_async(isp, ISPASYNC_FW_RESTART, NULL); -#endif - break; - } - default: - break; - } - return (0); -} - -void -isp_prt(struct ispsoftc *isp, int level, const char *fmt, ...) -{ - va_list ap; - if (level != ISP_LOGALL && (level & isp->isp_dblev) == 0) { - return; - } - printf("%s: ", isp->isp_name); - va_start(ap, fmt); - vprintf(fmt, ap); - va_end(ap); - printf("\n"); -} - -int -isp_mbox_acquire(ispsoftc_t *isp) -{ - if (isp->isp_osinfo.mboxbsy) { - return (1); - } else { - isp->isp_osinfo.mboxcmd_done = 0; - isp->isp_osinfo.mboxbsy = 1; - return (0); - } -} - -void -isp_lock(struct ispsoftc *isp) -{ - int s = splbio(); - if (isp->isp_osinfo.islocked++ == 0) { - isp->isp_osinfo.splsaved = s; - } else { - splx(s); - } -} - -void -isp_unlock(struct ispsoftc *isp) -{ - if (isp->isp_osinfo.islocked-- <= 1) { - isp->isp_osinfo.islocked = 0; - splx(isp->isp_osinfo.splsaved); - } -} - -/* - * XXX Since the clocks aren't running yet during autoconf, we have to - * keep track of time ourselves, otherwise we may end up waiting - * forever for the FC link to go up. - */ -struct timespec isp_nanotime; - -void -isp_delay(int usec) -{ - delay(usec); - isp_nanotime.tv_nsec += (usec * 1000); - if (isp_nanotime.tv_nsec >= 1000000000L) { - isp_nanotime.tv_sec++; - isp_nanotime.tv_nsec -= 1000000000L; - } -} - -u_int64_t -isp_nanotime_sub(struct timespec *b, struct timespec *a) -{ - struct timespec x; - u_int64_t elapsed; - timespecsub(b, a, &x); - elapsed = GET_NANOSEC(&x); - if (elapsed == 0) - elapsed++; - return (elapsed); -} - -void -isp_mbox_wait_complete(ispsoftc_t *isp, mbreg_t *mbp) -{ - unsigned int usecs = mbp->timeout; - unsigned int max, olim, ilim; - - if (usecs == 0) { - usecs = MBCMD_DEFAULT_TIMEOUT; - } - max = isp->isp_mbxwrk0 + 1; - - if (isp->isp_osinfo.mbox_sleep_ok) { - unsigned int ms = (usecs + 999) / 1000; - - isp->isp_osinfo.mbox_sleep_ok = 0; - isp->isp_osinfo.mbox_sleeping = 1; - for (olim = 0; olim < max; olim++) { - tsleep(&isp->isp_mbxworkp, PRIBIO, "ispmbx_sleep", - isp_mstohz(ms)); - if (isp->isp_osinfo.mboxcmd_done) { - break; - } - } - isp->isp_osinfo.mbox_sleep_ok = 1; - isp->isp_osinfo.mbox_sleeping = 0; - } else { - for (olim = 0; olim < max; olim++) { - for (ilim = 0; ilim < usecs; ilim += 100) { - uint32_t isr; - uint16_t sema, mbox; - if (isp->isp_osinfo.mboxcmd_done) { - break; - } - if (ISP_READ_ISR(isp, &isr, &sema, &mbox)) { - isp_intr(isp, isr, sema, mbox); - if (isp->isp_osinfo.mboxcmd_done) { - break; - } - } - USEC_DELAY(100); - } - if (isp->isp_osinfo.mboxcmd_done) { - break; - } - } - } - if (isp->isp_osinfo.mboxcmd_done == 0) { - isp_prt(isp, ISP_LOGWARN, - "%s Mailbox Command (0x%x) Timeout (%uus)", - isp->isp_osinfo.mbox_sleep_ok? "Interrupting" : "Polled", - isp->isp_lastmbxcmd, usecs); - mbp->param[0] = MBOX_TIMEOUT; - isp->isp_osinfo.mboxcmd_done = 1; - } -} - -void -isp_mbox_notify_done(ispsoftc_t *isp) -{ - if (isp->isp_osinfo.mbox_sleeping) { - wakeup(&isp->isp_mbxworkp); - } - isp->isp_osinfo.mboxcmd_done = 1; -} - -void -isp_mbox_release(ispsoftc_t *isp) -{ - isp->isp_osinfo.mboxbsy = 0; -} - -int -isp_mstohz(int ms) -{ - int hz; - struct timeval t; - t.tv_sec = ms / 1000; - t.tv_usec = (ms % 1000) * 1000; - hz = tvtohz(&t); - if (hz < 0) { - hz = 0x7fffffff; - } - if (hz == 0) { - hz = 1; - } - return (hz); -} diff --git a/sys/dev/ic/isp_openbsd.h b/sys/dev/ic/isp_openbsd.h deleted file mode 100644 index ac7e57ff246..00000000000 --- a/sys/dev/ic/isp_openbsd.h +++ /dev/null @@ -1,380 +0,0 @@ -/* $OpenBSD: isp_openbsd.h,v 1.36 2014/07/08 17:19:25 deraadt Exp $ */ -/* - * OpenBSD Specific definitions for the QLogic ISP Host Adapter - */ -/* - * Copyright (C) 1999, 2000, 2001 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. - * 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 ``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_OPENBSD_H -#define _ISP_OPENBSD_H - -#include <sys/types.h> -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/kernel.h> -#include <sys/errno.h> -#include <sys/ioctl.h> -#include <sys/device.h> -#include <sys/malloc.h> -#include <sys/buf.h> -#include <sys/proc.h> -#include <sys/queue.h> - -#if !(defined(__sparc__) && !defined(__sparcv9__)) -#include <machine/bus.h> -#endif - -#include <scsi/scsi_all.h> -#include <scsi/scsiconf.h> - -#include <scsi/scsi_message.h> -#include <scsi/scsi_debug.h> - -/* - * Efficiency- get rid of SBus code && tests unless we need them. - */ -#if defined(__sparcv9__ ) || defined(__sparc__) -#define ISP_SBUS_SUPPORTED 1 -#else -#define ISP_SBUS_SUPPORTED 0 -#endif - -#define ISP_PLATFORM_VERSION_MAJOR 5 -#define ISP_PLATFORM_VERSION_MINOR 9 - -struct isposinfo { - struct device _dev; - struct scsi_link _link[2]; - struct scsi_adapter _adapter; - int hiwater; - int splsaved; - int mboxwaiting; - u_int32_t islocked; - u_int32_t onintstack; -#if !(defined(__sparc__) && !defined(__sparcv9__)) - bus_space_tag_t bus_tag; - bus_space_handle_t bus_handle; - bus_dma_tag_t dmatag; - bus_dmamap_t cdmap; -#define isp_dmatag isp_osinfo.dmatag -#define isp_cdmap isp_osinfo.cdmap -#define isp_bus_tag isp_osinfo.bus_tag -#define isp_bus_handle isp_osinfo.bus_handle -#endif - uint32_t : 5, - simqfrozen : 3, - hysteresis : 8, - gdt_running : 1, - ldt_running : 1, - disabled : 1, - fcbsy : 1, - mbox_sleeping : 1, - mbox_sleep_ok : 1, - mboxcmd_done : 1, - mboxbsy : 1, - no_mbox_ints : 1, - blocked : 2, - rtpend : 1; - int _iid; - union { - u_int64_t _wwn; - u_int16_t _discovered[2]; - } un; -#define discovered un._discovered - struct scsi_xfer_list wq; - struct timeout rqt; -}; -#define MUST_POLL(isp) \ - (isp->isp_osinfo.onintstack || isp->isp_osinfo.no_mbox_ints) - -/* - * Locking macros... - */ -#define ISP_LOCK isp_lock -#define ISP_UNLOCK isp_unlock - -/* - * Required Macros/Defines - */ - -#define ISP2100_SCRLEN 0x1000 - -#define MEMZERO bzero -#define MEMCPY(dst, src, amt) bcopy((src), (dst), (amt)) -#define SNPRINTF snprintf -#define USEC_DELAY isp_delay -#define USEC_SLEEP(isp, x) delay(x) - -extern struct timespec isp_nanotime; -#define NANOTIME_T struct timespec -#define GET_NANOTIME(x) *(x) = isp_nanotime -#define GET_NANOSEC(x) (((x)->tv_sec * 1000000000 + (x)->tv_nsec)) -#define NANOTIME_SUB isp_nanotime_sub - -#define MAXISPREQUEST(isp) ((IS_FC(isp) || IS_ULTRA2(isp))? 1024 : 256) - -#if !(defined(__sparc__) && !defined(__sparcv9__)) -#define MEMORYBARRIER(isp, type, offset, size) \ -switch (type) { \ -case SYNC_REQUEST: \ -{ \ - off_t off = (off_t) offset * QENTRY_LEN; \ - bus_dmamap_sync(isp->isp_dmatag, isp->isp_cdmap, \ - off, size, BUS_DMASYNC_PREWRITE); \ - break; \ -} \ -case SYNC_RESULT: \ -{ \ - off_t off = (off_t) offset * QENTRY_LEN + \ - ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN(isp)); \ - bus_dmamap_sync(isp->isp_dmatag, isp->isp_cdmap, \ - off, size, BUS_DMASYNC_POSTREAD); \ - break; \ -} \ -case SYNC_SFORDEV: \ -{ \ - off_t off = (off_t) offset; \ - bus_dmamap_sync(isp->isp_dmatag, isp->isp_cdmap, \ - off, size, BUS_DMASYNC_PREWRITE); \ - break; \ -} \ -case SYNC_SFORCPU: \ -{ \ - off_t off = (off_t) offset; \ - bus_dmamap_sync(isp->isp_dmatag, isp->isp_cdmap, \ - off, size, BUS_DMASYNC_POSTREAD); \ - break; \ -} \ -case SYNC_REG: \ - bus_space_barrier(isp->isp_bus_tag, \ - isp->isp_bus_handle, offset, size, \ - BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE); \ - break; \ -default: \ - break; \ -} -#else -#define MEMORYBARRIER(isp, type, offset, size) -#endif - -#define MBOX_ACQUIRE isp_mbox_acquire -#define MBOX_WAIT_COMPLETE isp_mbox_wait_complete -#define MBOX_NOTIFY_COMPLETE isp_mbox_notify_done -#define MBOX_RELEASE isp_mbox_release - -#define FC_SCRATCH_ACQUIRE(isp) \ - if (isp->isp_osinfo.fcbsy) { \ - isp_prt(isp, ISP_LOGWARN, \ - "FC scratch area busy (line %d)!", __LINE__); \ - } else \ - isp->isp_osinfo.fcbsy = 1 -#define FC_SCRATCH_RELEASE(isp) isp->isp_osinfo.fcbsy = 0 - -#ifndef SCSI_GOOD -#define SCSI_GOOD 0x0 -#endif -#ifndef SCSI_CHECK -#define SCSI_CHECK 0x2 -#endif -#ifndef SCSI_BUSY -#define SCSI_BUSY 0x8 -#endif -#ifndef SCSI_QFULL -#define SCSI_QFULL 0x28 -#endif - -#define XS_T struct scsi_xfer -#if !(defined(__sparc__) && !defined(__sparcv9__)) -#define XS_DMA_ADDR_T bus_addr_t -#else -#define XS_DMA_ADDR_T u_int32_t -#endif -#define XS_CHANNEL(xs) (((xs)->sc_link->flags & SDEV_2NDBUS)? 1 : 0) -#define XS_ISP(xs) (xs)->sc_link->adapter_softc -#define XS_LUN(xs) ((int) (xs)->sc_link->lun) -#define XS_TGT(xs) ((int) (xs)->sc_link->target) -#define XS_CDBP(xs) ((caddr_t) (xs)->cmd) -#define XS_CDBLEN(xs) (xs)->cmdlen -#define XS_XFRLEN(xs) (xs)->datalen -#define XS_TIME(xs) (xs)->timeout -#define XS_RESID(xs) (xs)->resid -#define XS_STSP(xs) (&(xs)->status) -#define XS_SNSP(xs) (&(xs)->sense) -#define XS_SNSLEN(xs) (sizeof (xs)->sense) -#define XS_SNSKEY(xs) ((xs)->sense.flags) -#define XS_TAG_P(xs) (((xs)->flags & SCSI_POLL) != 0) -#define XS_TAG_TYPE(xs) REQFLAG_STAG - -#define XS_SETERR(xs, v) (xs)->error = v - -# define HBA_NOERROR XS_NOERROR -# define HBA_BOTCH XS_DRIVER_STUFFUP -# define HBA_CMDTIMEOUT XS_TIMEOUT -# define HBA_SELTIMEOUT XS_SELTIMEOUT -# define HBA_TGTBSY XS_BUSY -# define HBA_BUSRESET XS_RESET -# define HBA_ABORTED XS_DRIVER_STUFFUP -# define HBA_DATAOVR XS_DRIVER_STUFFUP -# define HBA_ARQFAIL XS_DRIVER_STUFFUP - -#define XS_ERR(xs) (xs)->error - -#define XS_NOERR(xs) (xs)->error == XS_NOERROR - -#define XS_INITERR(xs) (xs)->error = 0, XS_CMD_S_CLEAR(xs) - -#define XS_SAVE_SENSE(xs, sp, len) \ - if (xs->error == XS_NOERROR) { \ - xs->error = XS_SENSE; \ - } \ - bcopy(sp, &(xs)->sense, imin(XS_SNSLEN(xs), len)) - -#define XS_SET_STATE_STAT(a, b, c) - -#define DEFAULT_IID(isp) (isp)->isp_osinfo._iid -#define DEFAULT_LOOPID(x) 107 -#define DEFAULT_NODEWWN(isp) (isp)->isp_osinfo.un._wwn -#define DEFAULT_PORTWWN(isp) (isp)->isp_osinfo.un._wwn -#define ISP_NODEWWN(isp) FCPARAM(isp)->isp_wwnn_nvram -#define ISP_PORTWWN(isp) FCPARAM(isp)->isp_wwpn_nvram - -#if BYTE_ORDER == BIG_ENDIAN -#ifdef ISP_SBUS_SUPPORTED -#define ISP_IOXPUT_8(isp, s, d) *(d) = s -#define ISP_IOXPUT_16(isp, s, d) \ - *(d) = (isp->isp_bustype == ISP_BT_SBUS)? s : swap16(s) -#define ISP_IOXPUT_32(isp, s, d) \ - *(d) = (isp->isp_bustype == ISP_BT_SBUS)? s : swap32(s) - -#define ISP_IOXGET_8(isp, s, d) d = (*((u_int8_t *)s)) -#define ISP_IOXGET_16(isp, s, d) \ - d = (isp->isp_bustype == ISP_BT_SBUS)? \ - *((u_int16_t *)s) : swap16(*((u_int16_t *)s)) -#define ISP_IOXGET_32(isp, s, d) \ - d = (isp->isp_bustype == ISP_BT_SBUS)? \ - *((u_int32_t *)s) : swap32(*((u_int32_t *)s)) -#else -#define ISP_IOXPUT_8(isp, s, d) *(d) = s -#define ISP_IOXPUT_16(isp, s, d) *(d) = swap16(s) -#define ISP_IOXPUT_32(isp, s, d) *(d) = swap32(s) -#define ISP_IOXGET_8(isp, s, d) d = (*((u_int8_t *)s)) -#define ISP_IOXGET_16(isp, s, d) d = swap16(*((u_int16_t *)s)) -#define ISP_IOXGET_32(isp, s, d) d = swap32(*((u_int32_t *)s)) -#endif -#define ISP_SWIZZLE_NVRAM_WORD(isp, rp) *rp = swap16(*rp) -#define ISP_SWIZZLE_NVRAM_LONG(isp, rp) *rp = swap32(*rp) - -#define ISP_IOZGET_8(isp, s, d) d = (*((u_int8_t *)s)) -#define ISP_IOZGET_16(isp, s, d) d = (*((u_int16_t *)s)) -#define ISP_IOZGET_32(isp, s, d) d = (*((u_int32_t *)s)) -#define ISP_IOZPUT_8(isp, s, d) *(d) = s -#define ISP_IOZPUT_16(isp, s, d) *(d) = s -#define ISP_IOZPUT_32(isp, s, d) *(d) = s - - -#else -#define ISP_IOXPUT_8(isp, s, d) *(d) = s -#define ISP_IOXPUT_16(isp, s, d) *(d) = s -#define ISP_IOXPUT_32(isp, s, d) *(d) = s -#define ISP_IOXGET_8(isp, s, d) d = *(s) -#define ISP_IOXGET_16(isp, s, d) d = *(s) -#define ISP_IOXGET_32(isp, s, d) d = *(s) -#define ISP_SWIZZLE_NVRAM_WORD(isp, rp) -#define ISP_SWIZZLE_NVRAM_LONG(isp, rp) - -#define ISP_IOZPUT_8(isp, s, d) *(d) = s -#define ISP_IOZPUT_16(isp, s, d) *(d) = swap16(s) -#define ISP_IOZPUT_32(isp, s, d) *(d) = swap32(s) - -#define ISP_IOZGET_8(isp, s, d) d = (*((u_int8_t *)(s))) -#define ISP_IOZGET_16(isp, s, d) d = swap16(*((u_int16_t *)(s))) -#define ISP_IOZGET_32(isp, s, d) d = swap32(*((u_int32_t *)(s))) -#endif - -#define ISP_SWAP16(isp, s) swap16(s) -#define ISP_SWAP32(isp, s) swap32(s) - -/* - * Includes of common header files - */ - -#include <dev/ic/ispreg.h> -#include <dev/ic/ispvar.h> -#include <dev/ic/ispmbox.h> - -/* - * isp_osinfo definitions, extensions and shorthand. - */ -#define isp_name isp_osinfo._dev.dv_xname -#define isp_unit isp_osinfo._dev.dv_unit - -/* - * Driver prototypes.. - */ -void isp_attach(struct ispsoftc *); -void isp_uninit(struct ispsoftc *); - -void isp_lock(struct ispsoftc *); -void isp_unlock(struct ispsoftc *); -void isp_prt(struct ispsoftc *, int level, const char *, ...); -void isp_delay(int); -u_int64_t isp_nanotime_sub(struct timespec *, struct timespec *); -int isp_mbox_acquire(ispsoftc_t *); -void isp_mbox_wait_complete(ispsoftc_t *, mbreg_t *); -void isp_mbox_notify_done(ispsoftc_t *); -void isp_mbox_release(ispsoftc_t *); - -/* - * Driver wide data... - */ - -/* - * Platform private flags - */ - -#define XS_PSTS_INWDOG 0x10000 -#define XS_PSTS_GRACE 0x20000 -#define XS_PSTS_TIMED 0x40000 -#define XS_PSTS_ALL SCSI_PRIVATE - -#define XS_CMD_S_WDOG(xs) (xs)->flags |= XS_PSTS_INWDOG -#define XS_CMD_C_WDOG(xs) (xs)->flags &= ~XS_PSTS_INWDOG -#define XS_CMD_WDOG_P(xs) (((xs)->flags & XS_PSTS_INWDOG) != 0) - -#define XS_CMD_S_TIMER(xs) (xs)->flags |= XS_PSTS_TIMED -#define XS_CMD_C_TIMER(xs) (xs)->flags &= ~XS_PSTS_TIMED -#define XS_CMD_TIMER_P(xs) (((xs)->flags & XS_PSTS_TIMED) != 0) - -#define XS_CMD_S_GRACE(xs) (xs)->flags |= XS_PSTS_GRACE -#define XS_CMD_C_GRACE(xs) (xs)->flags &= ~XS_PSTS_GRACE -#define XS_CMD_GRACE_P(xs) (((xs)->flags & XS_PSTS_GRACE) != 0) - -#define XS_CMD_S_DONE(xs) (xs)->flags |= ITSDONE -#define XS_CMD_C_DONE(xs) (xs)->flags &= ~ITSDONE -#define XS_CMD_DONE_P(xs) (((xs)->flags & ITSDONE) != 0) - -#define XS_CMD_S_CLEAR(xs) (xs)->flags &= ~XS_PSTS_ALL - -#include <dev/ic/isp_library.h> - -#endif /* _ISP_OPENBSD_H */ diff --git a/sys/dev/ic/isp_stds.h b/sys/dev/ic/isp_stds.h deleted file mode 100644 index 174731ebc45..00000000000 --- a/sys/dev/ic/isp_stds.h +++ /dev/null @@ -1,212 +0,0 @@ -/* $OpenBSD: isp_stds.h,v 1.2 2009/06/24 11:00:53 krw Exp $ */ -/* $FreeBSD: src/sys/dev/isp/isp_stds.h,v 1.4 2007/03/10 02:39:54 mjacob Exp $ */ -/*- - * Copyright (c) 1997-2007 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. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY 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 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. - */ -/* - * Structures that derive directly from public standards. - */ -#ifndef _ISP_STDS_H -#define _ISP_STDS_H - -/* - * FC Frame Header - * - * Source: dpANS-X3.xxx-199x, section 18 (AKA FC-PH-2) - * - */ -typedef struct { - uint8_t r_ctl; - uint8_t d_id[3]; - uint8_t cs_ctl; - uint8_t s_id[3]; - uint8_t type; - uint8_t f_ctl; - uint8_t seq_id; - uint8_t df_ctl; - uint16_t seq_cnt; - uint16_t ox_id; - uint16_t rx_id; - uint32_t parameter; -} fc_hdr_t; - -/* - * FCP_CMND_IU Payload - * - * Source: NICTS T10, Project 1144D, Revision 07a, Section 9 (AKA fcp2-r07a) - * - * Notes: - * When additional cdb length is defined in fcp_cmnd_alen_datadir, - * bits 2..7, the actual cdb length is 16 + ((fcp_cmnd_alen_datadir>>2)*4), - * with the datalength following in MSB format just after. - */ -typedef struct { - uint8_t fcp_cmnd_lun[8]; - uint8_t fcp_cmnd_crn; - uint8_t fcp_cmnd_task_attribute; - uint8_t fcp_cmnd_task_management; - uint8_t fcp_cmnd_alen_datadir; - union { - struct { - uint8_t fcp_cmnd_cdb[16]; - uint32_t fcp_cmnd_dl; - } sf; - struct { - uint8_t fcp_cmnd_cdb[1]; - } lf; - } cdb_dl; -} fcp_cmnd_iu_t; - - -#define FCP_CMND_TASK_ATTR_SIMPLE 0x00 -#define FCP_CMND_TASK_ATTR_HEAD 0x01 -#define FCP_CMND_TASK_ATTR_ORDERED 0x02 -#define FCP_CMND_TASK_ATTR_ACA 0x04 -#define FCP_CMND_TASK_ATTR_UNTAGGED 0x05 -#define FCP_CMND_TASK_ATTR_MASK 0x07 - -#define FCP_CMND_ADDTL_CDBLEN_SHIFT 2 - -#define FCP_CMND_DATA_WRITE 0x01 -#define FCP_CMND_DATA_READ 0x02 - -#define FCP_CMND_DATA_DIR_MASK 0x03 - -#define FCP_CMND_TMF_CLEAR_ACA 0x40 -#define FCP_CMND_TMF_TGT_RESET 0x20 -#define FCP_CMND_TMF_LUN_RESET 0x10 -#define FCP_CMND_TMF_CLEAR_TASK_SET 0x04 -#define FCP_CMND_TMF_ABORT_TASK_SET 0x02 - -/* - * Basic CT IU Header - * - * Source: X3.288-199x Generic Services 2 Rev 5.3 (FC-GS-2) Section 4.3.1 - */ - -typedef struct { - uint8_t ct_revision; - uint8_t ct_in_id[3]; - uint8_t ct_fcs_type; - uint8_t ct_fcs_subtype; - uint8_t ct_options; - uint8_t ct_reserved0; - uint16_t ct_cmd_resp; - uint16_t ct_bcnt_resid; - uint8_t ct_reserved1; - uint8_t ct_reason; - uint8_t ct_explanation; - uint8_t ct_vunique; -} ct_hdr_t; -#define CT_REVISION 1 -#define CT_FC_TYPE_FC 0xFC -#define CT_FC_SUBTYPE_NS 0x02 - -/* - * RFT_ID Requet CT_IU - * - * Source: NCITS xxx-200x Generic Services- 5 Rev 8.5 Section 5.2.5.30 - */ -typedef struct { - ct_hdr_t rftid_hdr; - uint8_t rftid_reserved; - uint8_t rftid_portid[3]; - uint32_t rftid_fc4types[8]; -} rft_id_t; - -/* - * FCP Response Code Definitions - * Source: NCITS T10, Project 1144D, Revision 07a (aka FCP2r07a) - */ -#define FCP_RSPNS_CODE_OFFSET 3 - -#define FCP_RSPNS_TMF_DONE 0 -#define FCP_RSPNS_DLBRSTX 1 -#define FCP_RSPNS_BADCMND 2 -#define FCP_RSPNS_EROFS 3 -#define FCP_RSPNS_TMF_REJECT 4 -#define FCP_RSPNS_TMF_FAILED 5 - - -/* unconverted miscellany */ -/* - * Basic FC Link Service defines - */ -/* - * These are in the R_CTL field. - */ -#define ABTS 0x81 -#define BA_ACC 0x84 /* of ABORT SEQUENCE */ -#define BA_RJT 0x85 /* of ABORT SEQUENCE */ - -/* - * Link Service Accept/Reject - */ -#define LS_ACC 0x8002 -#define LS_RJT 0x8001 - -/* - * FC ELS Codes- bits 31-24 of the first payload word of an ELS frame. - */ -#define PLOGI 0x03 -#define FLOGI 0x04 -#define LOGO 0x05 -#define ABTX 0x06 -#define PRLI 0x20 -#define PRLO 0x21 -#define TPRLO 0x24 -#define RNC 0x53 - -/* - * FC4 defines - */ -#define FC4_IP 5 /* ISO/EEC 8802-2 LLC/SNAP */ -#define FC4_SCSI 8 /* SCSI-3 via Fibre Channel Protocol (FCP) */ -#define FC4_FC_SVC 0x20 /* Fibre Channel Services */ - -#ifndef MSG_ABORT -#define MSG_ABORT 0x06 -#endif -#ifndef MSG_BUS_DEV_RESET -#define MSG_BUS_DEV_RESET 0x0c -#endif -#ifndef MSG_ABORT_TAG -#define MSG_ABORT_TAG 0x0d -#endif -#ifndef MSG_CLEAR_QUEUE -#define MSG_CLEAR_QUEUE 0x0e -#endif -#ifndef MSG_REL_RECOVERY -#define MSG_REL_RECOVERY 0x10 -#endif -#ifndef MSG_TERM_IO_PROC -#define MSG_TERM_IO_PROC 0x11 -#endif -#ifndef MSG_LUN_RESET -#define MSG_LUN_RESET 0x17 -#endif - -#endif /* _ISP_STDS_H */ diff --git a/sys/dev/ic/isp_target.h b/sys/dev/ic/isp_target.h deleted file mode 100644 index b93fb167883..00000000000 --- a/sys/dev/ic/isp_target.h +++ /dev/null @@ -1,951 +0,0 @@ -/* $OpenBSD: isp_target.h,v 1.15 2011/10/22 19:34:06 miod Exp $ */ -/* $FreeBSD: src/sys/dev/isp/isp_target.h,v 1.30 2007/03/10 02:39:54 mjacob Exp $ */ -/*- - * Copyright (c) 1997-2007 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. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY 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 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. - */ -/* - * QLogic Target Mode Structure and Flag Definitions - */ -#ifndef _ISP_TARGET_H -#define _ISP_TARGET_H - -#define QLTM_SENSELEN 18 /* non-FC cards only */ -#define QLTM_SVALID 0x80 - -/* - * 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; - -typedef struct { - isphdr_t in_header; - u_int32_t in_reserved; - u_int16_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_e_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_RESERVED_MASK (0xe700) -#define TASK_FLAGS_CLEAR_ACA (1<<14) -#define TASK_FLAGS_TARGET_RESET (1<<13) -#define TASK_FLAGS_LUN_RESET (1<<12) -#define TASK_FLAGS_CLEAR_TASK_SET (1<<10) -#define TASK_FLAGS_ABORT_TASK_SET (1<<9) - -/* - * ISP24XX Immediate Notify - */ -typedef struct { - isphdr_t in_header; - u_int32_t in_reserved; - u_int16_t in_nphdl; - u_int16_t in_reserved1; - u_int16_t in_flags; - u_int16_t in_srr_rxid; - u_int16_t in_status; - u_int8_t in_status_subcode; - u_int8_t in_reserved2; - u_int32_t in_rxid; - u_int16_t in_srr_reloff_lo; - u_int16_t in_srr_reloff_hi; - u_int16_t in_srr_iu; - u_int16_t in_srr_oxid; - u_int8_t in_reserved3[18]; - u_int8_t in_reserved4; - u_int8_t in_vpindex; - u_int32_t in_reserved5; - u_int16_t in_portid_lo; - u_int8_t in_portid_hi; - u_int8_t in_reserved6; - u_int16_t in_reserved7; - u_int16_t in_oxid; -} in_fcentry_24xx_t; - -#define IN24XX_FLAG_PUREX_IOCB 0x1 -#define IN24XX_FLAG_GLOBAL_LOGOUT 0x2 - -#define IN24XX_LIP_RESET 0x0E -#define IN24XX_LINK_RESET 0x0F -#define IN24XX_PORT_LOGOUT 0x29 -#define IN24XX_PORT_CHANGED 0x2A -#define IN24XX_LINK_FAILED 0x2E -#define IN24XX_SRR_RCVD 0x45 -#define IN24XX_ELS_RCVD 0x46 /* - * login-affectin ELS received- check - * subcode for specific opcode - */ -/* - * 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_reserved1; - u_int8_t na_iid; /* initiator loop id */ - u_int16_t na_response; - 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; - -typedef struct { - isphdr_t na_header; - u_int32_t na_reserved; - u_int16_t na_iid; /* initiator loop id */ - u_int16_t na_response; /* response code */ - 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_e_t; - -#define NAFC_RCOUNT 0x80 /* increment resource count */ -#define NAFC_RST_CLRD 0x20 /* Clear LIP Reset */ -#define NAFC_TVALID 0x10 /* task mangement response code is valid */ - -/* - * ISP24XX Notify Acknowledge - */ - -typedef struct { - isphdr_t na_header; - u_int32_t na_handle; - u_int16_t na_nphdl; - u_int16_t na_reserved1; - u_int16_t na_flags; - u_int16_t na_srr_rxid; - u_int16_t na_status; - u_int8_t na_status_subcode; - u_int8_t na_reserved2; - u_int32_t na_rxid; - u_int16_t na_srr_reloff_lo; - u_int16_t na_srr_reloff_hi; - u_int16_t na_srr_iu; - u_int16_t na_srr_flags; - u_int8_t na_reserved3[18]; - u_int8_t na_reserved4; - u_int8_t na_vpindex; - u_int8_t na_srr_reject_vunique; - u_int8_t na_srr_reject_explanation; - u_int8_t na_srr_reject_code; - u_int8_t na_reserved5; - u_int8_t na_reserved6[6]; - u_int16_t na_oxid; -} na_fcentry_24xx_t; - -/* - * 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, bus, inst, aep) \ - tid = aep->at_handle; \ - if (aep->at_flags & AT_TQAE) { \ - tid |= (aep->at_tag_val << 16); \ - tid |= (1 << 24); \ - } \ - tid |= (bus << 25); \ - tid |= (inst << 26) - -#define CT_MAKE_TAGID(tid, bus, inst, ct) \ - tid = ct->ct_fwhandle; \ - if (ct->ct_flags & CT_TQAE) { \ - tid |= (ct->ct_tag_val << 16); \ - tid |= (1 << 24); \ - } \ - tid |= ((bus & 0x1) << 25); \ - tid |= (inst << 26) - -#define AT_HAS_TAG(val) ((val) & (1 << 24)) -#define AT_GET_TAG(val) (((val) >> 16) & 0xff) -#define AT_GET_INST(val) (((val) >> 26) & 0x3f) -#define AT_GET_BUS(val) (((val) >> 25) & 0x1) -#define AT_GET_HANDLE(val) ((val) & 0xffff) - -#define IN_MAKE_TAGID(tid, bus, inst, inp) \ - tid = inp->in_seqid; \ - tid |= (inp->in_tag_val << 16); \ - tid |= (1 << 24); \ - tid |= (bus << 25); \ - tid |= (inst << 26) - -#define TAG_INSERT_INST(tid, inst) \ - tid &= ~(0x3ffffff); \ - tid |= (inst << 26) - -#define TAG_INSERT_BUS(tid, bus) \ - tid &= ~(1 << 25); \ - tid |= (bus << 25) - -/* - * 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_crn; /* command reference number */ - 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; - -typedef struct { - isphdr_t at_header; - u_int32_t at_reserved; - u_int16_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_crn; /* command reference number */ - 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; -} at2e_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 - -#define ATIO2_EX_WRITE 0x1 -#define ATIO2_EX_READ 0x2 -/* - * Macros to create and fetch and test concatenated handle and tag value macros - */ -#define AT2_MAKE_TAGID(tid, bus, inst, aep) \ - tid = aep->at_rxid; \ - tid |= (((u_int64_t)inst) << 32); \ - tid |= (((u_int64_t)bus) << 48) - -#define CT2_MAKE_TAGID(tid, bus, inst, ct) \ - tid = ct->ct_rxid; \ - tid |= (((u_int64_t)inst) << 32); \ - tid |= (((u_int64_t)(bus & 0xff)) << 48) - -#define AT2_HAS_TAG(val) 1 -#define AT2_GET_TAG(val) ((val) & 0xffffffff) -#define AT2_GET_INST(val) ((val) >> 32) -#define AT2_GET_HANDLE AT2_GET_TAG -#define AT2_GET_BUS(val) (((val) >> 48) & 0xff) - -#define FC_HAS_TAG AT2_HAS_TAG -#define FC_GET_TAG AT2_GET_TAG -#define FC_GET_INST AT2_GET_INST -#define FC_GET_HANDLE AT2_GET_HANDLE - -#define IN_FC_MAKE_TAGID(tid, bus, inst, seqid) \ - tid = seqid; \ - tid |= (((u_int64_t)inst) << 32); \ - tid |= (((u_int64_t)(bus & 0xff)) << 48) - -#define FC_TAG_INSERT_INST(tid, inst) \ - tid &= ~0xffff00000000ull; \ - tid |= (((u_int64_t)inst) << 32) - -/* - * 24XX ATIO Definition - * - * This is *quite* different from other entry types. - * First of all, it has its own queue it comes in on. - * - * Secondly, it doesn't have a normal header. - * - * Thirdly, it's just a passthru of the FCP CMND IU - * which is recorded in big endian mode. - */ -typedef struct { - u_int8_t at_type; - u_int8_t at_count; - /* - * Task attribute in high four bits, - * the rest is the FCP CMND IU Length. - * NB: the command can extend past the - * length for a single queue entry. - */ - u_int16_t at_ta_len; - u_int32_t at_rxid; - fc_hdr_t at_hdr; - fcp_cmnd_iu_t at_cmnd; -} at7_entry_t; - - -/* - * 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_syshandle; - 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; - ispds_t ct_dataseg[ISP_RQDSEG]; -} 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 0x81 && 0xfe (or 0x7ff) which 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_DATA_UNDER 0x15 /* (FC only) Data Underrun */ -#define CT_BDR_MSG 0x17 /* Bus Device Reset msg received */ -#define CT_TERMINATED 0x19 /* due to Terminate Transfer mbox cmd */ -#define CT_PORTUNAVAIL 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 */ -#define CT_SRR 0x45 /* SRR Received */ -#define CT_LUN_RESET 0x48 /* Lun Reset Received */ - -/* - * 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_int32_t ct_syshandle; - 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_dataseg[ISP_RQDSEG_T2]; - ispds64_t ct_dataseg64[ISP_RQDSEG_T3]; - ispdslist_t ct_dslist; - } u; - } 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; - } rsp; -} ct2_entry_t; - -typedef struct { - isphdr_t ct_header; - u_int32_t ct_syshandle; - u_int16_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 { - struct { - u_int32_t _reserved; - u_int16_t _reserved2; - u_int16_t ct_scsi_status; - u_int32_t ct_xfrlen; - union { - ispds_t ct_dataseg[ISP_RQDSEG_T2]; - ispds64_t ct_dataseg64[ISP_RQDSEG_T3]; - ispdslist_t ct_dslist; - } u; - } 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; - } rsp; -} ct2e_entry_t; - -/* - * ct_flags values for CTIO2 - */ -#define CT2_FLAG_MODE0 0x0000 -#define CT2_FLAG_MODE1 0x0001 -#define CT2_FLAG_MODE2 0x0002 -#define CT2_FLAG_MMASK 0x0003 -#define CT2_DATA_IN 0x0040 -#define CT2_DATA_OUT 0x0080 -#define CT2_NO_DATA 0x00C0 -#define CT2_DATAMASK 0x00C0 -#define CT2_CCINCR 0x0100 -#define CT2_FASTPOST 0x0200 -#define CT2_CONFIRM 0x2000 -#define CT2_TERMINATE 0x4000 -#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 - -/* - * ISP24XX CTIO - */ -#define MAXRESPLEN_24XX 24 -typedef struct { - isphdr_t ct_header; - u_int32_t ct_syshandle; - u_int16_t ct_nphdl; /* status on returned CTIOs */ - u_int16_t ct_timeout; - u_int16_t ct_seg_count; - u_int8_t ct_vpindex; - u_int8_t ct_xflags; - u_int16_t ct_iid_lo; /* low 16 bits of portid */ - u_int8_t ct_iid_hi; /* hi 8 bits of portid */ - u_int8_t ct_reserved; - u_int32_t ct_rxid; - u_int16_t ct_senselen; /* mode 0 only */ - u_int16_t ct_flags; - int32_t ct_resid; /* residual length */ - u_int16_t ct_oxid; - u_int16_t ct_scsi_status; /* modes 0 && 1 only */ - union { - struct { - u_int32_t reloff; - u_int32_t reserved0; - u_int32_t ct_xfrlen; - u_int32_t reserved1; - ispds64_t ds; - } m0; - struct { - u_int16_t ct_resplen; - u_int16_t reserved; - u_int8_t ct_resp[MAXRESPLEN_24XX]; - } m1; - struct { - u_int32_t reserved0; - u_int32_t ct_datalen; - u_int32_t reserved1; - ispds64_t ct_fcp_rsp_iudata; - } m2; - } rsp; -} ct7_entry_t; - -/* - * ct_flags values for CTIO7 - */ -#define CT7_DATA_IN 0x0002 -#define CT7_DATA_OUT 0x0001 -#define CT7_NO_DATA 0x0000 -#define CT7_DATAMASK 0x003 -#define CT7_DSD_ENABLE 0x0004 -#define CT7_CONF_STSFD 0x0010 -#define CT7_EXPLCT_CONF 0x0020 -#define CT7_FLAG_MODE0 0x0000 -#define CT7_FLAG_MODE1 0x0040 -#define CT7_FLAG_MODE7 0x0080 -#define CT7_FLAG_MMASK 0x00C0 -#define CT7_FASTPOST 0x0100 -#define CT7_ATTR_MASK 0x1e00 /* task attributes from atio7 */ -#define CT7_CONFIRM 0x2000 -#define CT7_TERMINATE 0x4000 -#define CT7_SENDSTATUS 0x8000 - -/* - * Type 7 CTIO status codes - */ -#define CT7_OK 0x01 /* completed without error */ -#define CT7_ABORTED 0x02 /* aborted by host */ -#define CT7_ERR 0x04 /* see sense data for error */ -#define CT7_INVAL 0x06 /* request for disabled lun */ -#define CT7_INVRXID 0x08 /* (FC only) Invalid RX_ID */ -#define CT7_DATA_OVER 0x09 /* (FC only) Data Overrun */ -#define CT7_TIMEOUT 0x0B /* timed out */ -#define CT7_RESET 0x0E /* LIP Rset Received */ -#define CT7_BUS_ERROR 0x10 /* DMA PCI Error */ -#define CT7_REASSY_ERR 0x11 /* DMA reassembly error */ -#define CT7_DATA_UNDER 0x15 /* (FC only) Data Underrun */ -#define CT7_PORTUNAVAIL 0x28 /* port not available */ -#define CT7_LOGOUT 0x29 /* port logout */ -#define CT7_PORTCHANGED 0x2A /* port changed */ -#define CT7_SRR 0x45 /* SRR Received */ - -/* - * Other 24XX related target IOCBs - */ - -/* - * ABTS Received - */ -typedef struct { - isphdr_t abts_header; - u_int8_t abts_reserved0[6]; - u_int16_t abts_nphdl; - u_int16_t abts_reserved1; - u_int16_t abts_sof; - u_int32_t abts_rxid_abts; - u_int16_t abts_did_lo; - u_int8_t abts_did_hi; - u_int8_t abts_r_ctl; - u_int16_t abts_sid_lo; - u_int8_t abts_sid_hi; - u_int8_t abts_cs_ctl; - u_int16_t abts_fs_ctl; - u_int8_t abts_f_ctl; - u_int8_t abts_type; - u_int16_t abts_seq_cnt; - u_int8_t abts_df_ctl; - u_int8_t abts_seq_id; - u_int16_t abts_rx_id; - u_int16_t abts_ox_id; - u_int32_t abts_param; - u_int8_t abts_reserved2[16]; - u_int32_t abts_rxid_task; -} abts_t; - -typedef struct { - isphdr_t abts_rsp_header; - u_int32_t abts_rsp_handle; - u_int16_t abts_rsp_status; - u_int16_t abts_rsp_nphdl; - u_int16_t abts_rsp_ctl_flags; - u_int16_t abts_rsp_sof; - u_int32_t abts_rsp_rxid_abts; - u_int16_t abts_rsp_did_lo; - u_int8_t abts_rsp_did_hi; - u_int8_t abts_rsp_r_ctl; - u_int16_t abts_rsp_sid_lo; - u_int8_t abts_rsp_sid_hi; - u_int8_t abts_rsp_cs_ctl; - u_int16_t abts_rsp_f_ctl_lo; - u_int8_t abts_rsp_f_ctl_hi; - u_int8_t abts_rsp_type; - u_int16_t abts_rsp_seq_cnt; - u_int8_t abts_rsp_df_ctl; - u_int8_t abts_rsp_seq_id; - u_int16_t abts_rsp_rx_id; - u_int16_t abts_rsp_ox_id; - u_int32_t abts_rsp_param; - union { - struct { - u_int16_t reserved; - u_int8_t last_seq_id; - u_int8_t seq_id_valid; - u_int16_t aborted_rx_id; - u_int16_t aborted_ox_id; - u_int16_t high_seq_cnt; - u_int16_t low_seq_cnt; - u_int8_t reserved2[4]; - } ba_acc; - struct { - u_int8_t vendor_unique; - u_int8_t explanation; - u_int8_t reason; - u_int8_t reserved; - u_int8_t reserved2[12]; - } ba_rjt; - struct { - u_int8_t reserved[8]; - u_int32_t subcode1; - u_int32_t subcode2; - } rsp; - u_int8_t reserved[16]; - } abts_rsp_payload; - u_int32_t abts_rsp_rxid_task; -} abts_rsp_t; - -/* terminate this ABTS exchange */ -#define ISP24XX_ABTS_RSP_TERMINATE 0x01 - -#define ISP24XX_ABTS_RSP_COMPLETE 0x00 -#define ISP24XX_ABTS_RSP_RESET 0x04 -#define ISP24XX_ABTS_RSP_ABORTED 0x05 -#define ISP24XX_ABTS_RSP_TIMEOUT 0x06 -#define ISP24XX_ABTS_RSP_INVXID 0x08 -#define ISP24XX_ABTS_RSP_LOGOUT 0x29 -#define ISP24XX_ABTS_RSP_SUBCODE 0x31 - -/* - * Debug macros - */ - -#ifdef SMALL_KERNEL -#define ISP_TDQE(isp, msg, idx, arg) \ - do { } while (0) -#else -#define ISP_TDQE(isp, msg, idx, arg) \ - if (isp->isp_dblev & ISP_LOGTDEBUG2) isp_print_qentry(isp, msg, idx, arg) -#endif - -#ifndef ISP_TOOLS -/* - * 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(ispsoftc_t *, void *, u_int32_t *); - -/* - * This function externalizes the ability to acknowledge an Immediate Notify - * request. - */ -void isp_notify_ack(ispsoftc_t *, void *); - -/* - * 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 0xfe /* unmonitored */ -int isp_lun_cmd(ispsoftc_t *, int, int, int, int, int, int, u_int32_t); - -/* - * General request queue 'put' routine for target mode entries. - */ -int isp_target_put_entry(ispsoftc_t *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(ispsoftc_t *, void *); - -/* - * General routine to send a final CTIO for a command- used mostly for - * local responses. - */ -int isp_endcmd(ispsoftc_t *, void *, u_int32_t, u_int32_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(ispsoftc_t *, int, int); -#endif -#endif /* _ISP_TARGET_H */ diff --git a/sys/dev/ic/ispmbox.h b/sys/dev/ic/ispmbox.h deleted file mode 100644 index f755d337b79..00000000000 --- a/sys/dev/ic/ispmbox.h +++ /dev/null @@ -1,1413 +0,0 @@ -/* $OpenBSD: ispmbox.h,v 1.24 2010/02/18 10:40:53 sobrado Exp $ */ -/* $FreeBSD: src/sys/dev/isp/ispmbox.h,v 1.59 2007/03/10 02:39:54 mjacob Exp $ */ -/*- - * Copyright (c) 1997-2007 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. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY 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 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. - */ -/* - * Mailbox and Queue Entry Definitions for for QLogic ISP SCSI adapters. - */ -#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 -#define MBOX_LOAD_RISC_RAM_2100 0x0009 - /* a */ -#define MBOX_LOAD_RISC_RAM 0x000b - /* c */ -#define MBOX_WRITE_RAM_WORD_EXTENDED 0x000d -#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_REQUEST_OFFLINE_MODE 0x0043 -#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_LUN_RESET 0x007E - -#define MBOX_DRIVER_HEARTBEAT 0x005B -#define MBOX_FW_HEARTBEAT 0x005C - -#define MBOX_GET_SET_DATA_RATE 0x005D /* 24XX/23XX only */ -#define MBGSD_GET_RATE 0 -#define MBGSD_SET_RATE 1 -#define MBGSD_SET_RATE_NOW 2 /* 24XX only */ -#define MBGSD_ONEGB 0 -#define MBGSD_TWOGB 1 -#define MBGSD_AUTO 2 -#define MBGSD_FOURGB 3 /* 24XX only */ - - -#define ISP2100_SET_PCI_PARAM 0x00ff - -#define MBOX_BUSY 0x04 - -/* - * 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 -/* pseudo mailbox completion codes */ -#define MBOX_REGS_BUSY 0x6000 /* registers in use */ -#define MBOX_TIMEOUT 0x6001 /* command timed out */ - -#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_LIP_ERROR 0x8017 -#define ASYNC_SECURITY_UPDATE 0x801B -#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 -#define ASYNC_RCV_ERR 0x8048 - -/* - * 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 - -/* - * 24XX only - */ -#define ASYNC_RJT_SENT 0x8049 - -/* - * All IOCB Queue entries are this size - */ -#define QENTRY_LEN 64 - -/* - * 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 -#define RQSFLAG_MASK 0x0f - -/* 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_CTIO7 0x12 -#define RQSTYPE_IP_XMIT 0x13 -#define RQSTYPE_TSK_MGMT 0x14 -#define RQSTYPE_T4RQS 0x15 -#define RQSTYPE_ATIO2 0x16 /* Target Mode */ -#define RQSTYPE_CTIO2 0x17 /* Target Mode */ -#define RQSTYPE_T7RQS 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 RQSTYPE_CT_PASSTHRU 0x29 -#define RQSTYPE_MS_PASSTHRU 0x29 -#define RQSTYPE_ABORT_IO 0x33 -#define RQSTYPE_T6RQS 0x48 -#define RQSTYPE_LOGIN 0x52 -#define RQSTYPE_ABTS_RCVD 0x54 /* 24XX only */ -#define RQSTYPE_ABTS_RSP 0x55 /* 24XX only */ - - -#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; - 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 ISP_RQDSEG_A64 2 - -typedef struct { - isphdr_t mrk_header; - u_int32_t mrk_handle; - u_int8_t mrk_reserved0; - u_int8_t mrk_target; - u_int16_t mrk_modifier; - u_int16_t mrk_flags; - u_int16_t mrk_lun; - u_int8_t mrk_reserved1[48]; -} isp_marker_t; - -typedef struct { - isphdr_t mrk_header; - u_int32_t mrk_handle; - u_int16_t mrk_nphdl; - u_int8_t mrk_modifier; - u_int8_t mrk_reserved0; - u_int8_t mrk_reserved1; - u_int8_t mrk_vphdl; - u_int16_t mrk_reserved2; - u_int8_t mrk_lun[8]; - u_int8_t mrk_reserved3[40]; -} isp_marker_24xx_t; - - -#define SYNC_DEVICE 0 -#define SYNC_TARGET 1 -#define SYNC_ALL 2 -#define SYNC_LIP 3 - -#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 req_reserved; - 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; - -typedef struct { - isphdr_t req_header; - u_int32_t req_handle; - u_int16_t req_target; - u_int16_t req_scclun; - 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[16]; - u_int32_t req_totalcnt; - ispds_t req_dataseg[ISP_RQDSEG_T2]; -} ispreqt2e_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 req_reserved; - 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; -#define ispreq64_t ispreqt3_t /* same as.... */ - -typedef struct { - isphdr_t req_header; - u_int32_t req_handle; - u_int16_t req_target; - u_int16_t req_scclun; - 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[16]; - u_int32_t req_totalcnt; - ispds64_t req_dataseg[ISP_RQDSEG_T3]; -} ispreqt3e_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 req_reserved; - u_int16_t req_time; - u_int16_t req_seg_count; - u_int8_t req_cdb[44]; -} ispextreq_t; - -/* 24XX only */ -typedef struct { - u_int16_t fcd_length; - u_int16_t fcd_a1500; - u_int16_t fcd_a3116; - u_int16_t fcd_a4732; - u_int16_t fcd_a6348; -} fcp_cmnd_ds_t; - -typedef struct { - isphdr_t req_header; - u_int32_t req_handle; - u_int16_t req_nphdl; - u_int16_t req_time; - u_int16_t req_seg_count; - u_int16_t req_fc_rsp_dsd_length; - u_int8_t req_lun[8]; - u_int16_t req_flags; - u_int16_t req_fc_cmnd_dsd_length; - u_int16_t req_fc_cmnd_dsd_a1500; - u_int16_t req_fc_cmnd_dsd_a3116; - u_int16_t req_fc_cmnd_dsd_a4732; - u_int16_t req_fc_cmnd_dsd_a6348; - u_int16_t req_fc_rsp_dsd_a1500; - u_int16_t req_fc_rsp_dsd_a3116; - u_int16_t req_fc_rsp_dsd_a4732; - u_int16_t req_fc_rsp_dsd_a6348; - u_int32_t req_totalcnt; - u_int16_t req_tidlo; - u_int8_t req_tidhi; - u_int8_t req_vpidx; - ispds64_t req_dataseg; -} ispreqt6_t; - -typedef struct { - isphdr_t req_header; - u_int32_t req_handle; - u_int16_t req_nphdl; - u_int16_t req_time; - u_int16_t req_seg_count; - u_int16_t req_reserved; - u_int8_t req_lun[8]; - u_int8_t req_alen_datadir; - u_int8_t req_task_management; - u_int8_t req_task_attribute; - u_int8_t req_crn; - u_int8_t req_cdb[16]; - u_int32_t req_dl; - u_int16_t req_tidlo; - u_int8_t req_tidhi; - u_int8_t req_vpidx; - ispds64_t req_dataseg; -} ispreqt7_t; - -/* I/O Abort Structure */ -typedef struct { - isphdr_t abrt_header; - u_int32_t abrt_handle; - u_int16_t abrt_nphdl; - u_int16_t abrt_options; - u_int32_t abrt_cmd_handle; - u_int8_t abrt_reserved[32]; - u_int16_t abrt_tidlo; - u_int8_t abrt_tidhi; - u_int8_t abrt_vpidx; - u_int8_t abrt_reserved1[12]; -} isp24xx_abrt_t; -#define ISP24XX_ABRT_NO_ABTS 0x01 /* don't actually send an ABTS */ -#define ISP24XX_ABRT_ENXIO 0x31 /* in nphdl on return */ - -#define ISP_CDSEG 7 -typedef struct { - isphdr_t req_header; - u_int32_t req_reserved; - 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; - -/* - * Status Continuation - */ -typedef struct { - isphdr_t req_header; - u_int8_t req_sense_data[60]; -} ispstatus_cont_t; - -/* - * 24XX Type 0 status - */ -typedef struct { - isphdr_t req_header; - u_int32_t req_handle; - u_int16_t req_completion_status; - u_int16_t req_oxid; - u_int32_t req_resid; - u_int16_t req_reserved0; - u_int16_t req_state_flags; - u_int16_t req_reserved1; - u_int16_t req_scsi_status; - u_int32_t req_fcp_residual; - u_int32_t req_sense_len; - u_int32_t req_response_len; - u_int8_t req_rsp_sense[28]; -} isp24xx_statusreq_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 */ - -/* - * CT Passthru IOCB - */ -typedef struct { - isphdr_t ctp_header; - u_int32_t ctp_handle; - u_int16_t ctp_status; - u_int16_t ctp_nphdl; /* n-port handle */ - u_int16_t ctp_cmd_cnt; /* Command DSD count */ - u_int16_t ctp_vpidx; /* low 8 bits */ - u_int16_t ctp_time; - u_int16_t ctp_reserved0; - u_int16_t ctp_rsp_cnt; /* Response DSD count */ - u_int16_t ctp_reserved1[5]; - u_int32_t ctp_rsp_bcnt; /* Response byte count */ - u_int32_t ctp_cmd_bcnt; /* Command byte count */ - ispds64_t ctp_dataseg[2]; -} isp_ct_pt_t; - -/* - * MS Passthru IOCB - */ -typedef struct { - isphdr_t ms_header; - u_int32_t ms_handle; - u_int16_t ms_nphdl; /* handle in high byte for !2k f/w */ - u_int16_t ms_status; - u_int16_t ms_flags; - u_int16_t ms_reserved1; /* low 8 bits */ - u_int16_t ms_time; - u_int16_t ms_cmd_cnt; /* Command DSD count */ - u_int16_t ms_tot_cnt; /* Total DSD Count */ - u_int8_t ms_type; /* MS type */ - u_int8_t ms_r_ctl; /* R_CTL */ - u_int16_t ms_rxid; /* RX_ID */ - u_int16_t ms_reserved2; - u_int32_t ms_handle2; - u_int32_t ms_rsp_bcnt; /* Response byte count */ - u_int32_t ms_cmd_bcnt; /* Command byte count */ - ispds64_t ms_dataseg[2]; -} isp_ms_t; - -/* - * 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 - -/* 24XX Only Completion Codes */ -#define RQCS_24XX_DRE 0x0011 /* data reassembly error */ -#define RQCS_24XX_TABORT 0x0013 /* aborted by target */ -#define RQCS_24XX_ENOMEM 0x002C /* f/w resource unavailable */ -#define RQCS_24XX_TMO 0x0030 /* task management overrun */ - - -/* - * 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. - * These attributes are for 2200 and 2300. - */ -#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 -#define ISP_FW_ATTR_VI 0x40 -#define ISP_FW_ATTR_VI_SOLARIS 0x80 -#define ISP_FW_ATTR_2KLOGINS 0x100 /* XXX: just a guess */ - -/* and these are for the 2400 */ -#define ISP2400_FW_ATTR_CLASS2 (1 << 0) -#define ISP2400_FW_ATTR_IP (1 << 1) -#define ISP2400_FW_ATTR_MULTIID (1 << 2) -#define ISP2400_FW_ATTR_SB2 (1 << 3) -#define ISP2400_FW_ATTR_T10CRC (1 << 4) -#define ISP2400_FW_ATTR_VI (1 << 5) -#define ISP2400_FW_ATTR_EXPFW (1 << 13) - -/* - * 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/ISP2200/ISP2300/ISP2400) specific data structures - */ - -/* - * Initialization Control Block - * - * Version One (prime) format. - */ -typedef struct { - u_int8_t icb_version; - u_int8_t icb_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 icb_reserved1; - u_int16_t icb_xfwoptions; - u_int8_t icb_racctimer; - u_int8_t icb_idelaytimer; - u_int16_t icb_zfwoptions; - u_int16_t icb_reserved2[13]; -} isp_icb_t; - -#define ICB_VERSION1 1 - -#define ICBOPT_EXTENDED 0x8000 -#define ICBOPT_BOTH_WWNS 0x4000 -#define ICBOPT_FULL_LOGIN 0x2000 -#define ICBOPT_STOP_ON_QFULL 0x1000 /* 2200/2100 only */ -#define ICBOPT_PREVLOOP 0x0800 -#define ICBOPT_SRCHDOWN 0x0400 -#define ICBOPT_NOLIP 0x0200 -#define ICBOPT_PDBCHANGE_AE 0x0100 -#define ICBOPT_INI_TGTTYPE 0x0080 -#define ICBOPT_INI_ADISC 0x0040 -#define ICBOPT_INI_DISABLE 0x0020 -#define ICBOPT_TGT_ENABLE 0x0010 -#define ICBOPT_FAST_POST 0x0008 -#define ICBOPT_FULL_DUPLEX 0x0004 -#define ICBOPT_FAIRNESS 0x0002 -#define ICBOPT_HARD_ADDRESS 0x0001 - -#define ICBXOPT_NO_LOGOUT 0x8000 /* no logout on link failure */ -#define ICBXOPT_FCTAPE_CCQ 0x4000 /* FC-Tape Command Queueing */ -#define ICBXOPT_FCTAPE_CONFIRM 0x2000 -#define ICBXOPT_FCTAPE 0x1000 -#define ICBXOPT_CLASS2_ACK0 0x0200 -#define ICBXOPT_CLASS2 0x0100 -#define ICBXOPT_NO_PLAY 0x0080 /* don't play if can't get hard addr */ -#define ICBXOPT_TOPO_MASK 0x0070 -#define ICBXOPT_LOOP_ONLY 0x0000 -#define ICBXOPT_PTP_ONLY 0x0010 -#define ICBXOPT_LOOP_2_PTP 0x0020 -#define ICBXOPT_PTP_2_LOOP 0x0030 -/* - * The lower 4 bits of the xfwoptions field are the OPERATION MODE bits. - * RIO is not defined for the 23XX cards (just 2200) - */ -#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 ICBXOPT_TIMER_MASK 0x7 - -#define ICBZOPT_RATE_MASK 0xC000 -#define ICBZOPT_RATE_ONEGB 0x0000 -#define ICBZOPT_RATE_AUTO 0x8000 -#define ICBZOPT_RATE_TWOGB 0x4000 -#define ICBZOPT_50_OHM 0x2000 -#define ICBZOPT_ENA_OOF 0x0040 /* out of order frame handling */ -#define ICBZOPT_RSPSZ_MASK 0x0030 -#define ICBZOPT_RSPSZ_24 0x0000 -#define ICBZOPT_RSPSZ_12 0x0010 -#define ICBZOPT_RSPSZ_24A 0x0020 -#define ICBZOPT_RSPSZ_32 0x0030 -#define ICBZOPT_SOFTID 0x0002 -#define ICBZOPT_ENA_RDXFR_RDY 0x0001 - -/* 2400 F/W options */ -#define ICB2400_OPT1_BOTH_WWNS 0x00004000 -#define ICB2400_OPT1_FULL_LOGIN 0x00002000 -#define ICB2400_OPT1_PREVLOOP 0x00000800 -#define ICB2400_OPT1_SRCHDOWN 0x00000400 -#define ICB2400_OPT1_NOLIP 0x00000200 -#define ICB2400_OPT1_INI_DISABLE 0x00000020 -#define ICB2400_OPT1_TGT_ENABLE 0x00000010 -#define ICB2400_OPT1_FULL_DUPLEX 0x00000004 -#define ICB2400_OPT1_FAIRNESS 0x00000002 -#define ICB2400_OPT1_HARD_ADDRESS 0x00000001 - -#define ICB2400_OPT2_FCTAPE 0x00001000 -#define ICB2400_OPT2_CLASS2_ACK0 0x00000200 -#define ICB2400_OPT2_CLASS2 0x00000100 -#define ICB2400_OPT2_NO_PLAY 0x00000080 -#define ICB2400_OPT2_TOPO_MASK 0x00000070 -#define ICB2400_OPT2_LOOP_ONLY 0x00000000 -#define ICB2400_OPT2_PTP_ONLY 0x00000010 -#define ICB2400_OPT2_LOOP_2_PTP 0x00000020 -#define ICB2400_OPT2_PTP_2_LOOP 0x00000030 -#define ICB2400_OPT2_TIMER_MASK 0x00000007 -#define ICB2400_OPT2_ZIO 0x00000005 -#define ICB2400_OPT2_ZIO1 0x00000006 - -#define ICB2400_OPT3_75_OHM 0x00010000 -#define ICB2400_OPT3_RATE_MASK 0x0000E000 -#define ICB2400_OPT3_RATE_ONEGB 0x00000000 -#define ICB2400_OPT3_RATE_TWOGB 0x00002000 -#define ICB2400_OPT3_RATE_AUTO 0x00004000 -#define ICB2400_OPT3_RATE_FOURGB 0x00006000 -#define ICB2400_OPT3_ENA_OOF_XFRDY 0x00000200 -#define ICB2400_OPT3_NO_LOCAL_PLOGI 0x00000080 -#define ICB2400_OPT3_ENA_OOF 0x00000040 -/* note that a response size flag of zero is reserved! */ -#define ICB2400_OPT3_RSPSZ_MASK 0x00000030 -#define ICB2400_OPT3_RSPSZ_12 0x00000010 -#define ICB2400_OPT3_RSPSZ_24 0x00000020 -#define ICB2400_OPT3_RSPSZ_32 0x00000030 -#define ICB2400_OPT3_SOFTID 0x00000002 - -#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 ICB_LOGIN_TOV 30 -#define ICB_LUN_ENABLE_TOV 180 - - -/* - * And somebody at QLogic had a great idea that you could just change - * the structure *and* keep the version number the same as the other cards. - */ -typedef struct { - u_int16_t icb_version; - u_int16_t icb_reserved0; - u_int16_t icb_maxfrmlen; - u_int16_t icb_execthrottle; - u_int16_t icb_xchgcnt; - u_int16_t icb_hardaddr; - u_int8_t icb_portname[8]; - u_int8_t icb_nodename[8]; - u_int16_t icb_rspnsin; - u_int16_t icb_rqstout; - u_int16_t icb_retry_count; - u_int16_t icb_priout; - u_int16_t icb_rsltqlen; - u_int16_t icb_rqstqlen; - u_int16_t icb_ldn_nols; - u_int16_t icb_prqstqlen; - u_int16_t icb_rqstaddr[4]; - u_int16_t icb_respaddr[4]; - u_int16_t icb_priaddr[4]; - u_int16_t icb_reserved1[4]; - u_int16_t icb_atio_in; - u_int16_t icb_atioqlen; - u_int16_t icb_atioqaddr[4]; - u_int16_t icb_idelaytimer; - u_int16_t icb_logintime; - u_int32_t icb_fwoptions1; - u_int32_t icb_fwoptions2; - u_int32_t icb_fwoptions3; - u_int16_t icb_reserved2[12]; -} isp_icb_2400_t; - -#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) - -#define MAKE_WWN_FROM_NODE_NAME(wwn, array) \ - wwn = ((u_int64_t) array[ICB_NNM0]) | \ - ((u_int64_t) array[ICB_NNM1] << 8) | \ - ((u_int64_t) array[ICB_NNM2] << 16) | \ - ((u_int64_t) array[ICB_NNM3] << 24) | \ - ((u_int64_t) array[ICB_NNM4] << 32) | \ - ((u_int64_t) array[ICB_NNM5] << 40) | \ - ((u_int64_t) array[ICB_NNM6] << 48) | \ - ((u_int64_t) array[ICB_NNM7] << 56) - -/* - * Port Data Base Element - */ - -typedef struct { - u_int16_t pdb_options; - u_int8_t pdb_mstate; - u_int8_t pdb_sstate; - 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_21xx_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 - -#define BITS2WORD(x) ((x)[0] << 16 | (x)[3] << 8 | (x)[2]) -#define BITS2WORD_24XX(x) ((x)[0] << 16 | (x)[1] << 8 | (x)[2]) - -/* - * Port Data Base Element- 24XX cards - */ -typedef struct { - u_int16_t pdb_flags; - u_int8_t pdb_curstate; - u_int8_t pdb_laststate; - u_int8_t pdb_hardaddr_bits[4]; - u_int8_t pdb_portid_bits[4]; -#define pdb_nxt_seqid_2400 pdb_portid_bits[3] - u_int16_t pdb_retry_timer; - u_int16_t pdb_handle; - u_int16_t pdb_rcv_dsize; - u_int16_t pdb_reserved0; - u_int16_t pdb_prli_svc0; - u_int16_t pdb_prli_svc3; - u_int8_t pdb_portname[8]; - u_int8_t pdb_nodename[8]; - u_int8_t pdb_reserved1[24]; -} isp_pdb_24xx_t; - -#define PDB2400_TID_SUPPORTED 0x4000 -#define PDB2400_FC_TAPE 0x0080 -#define PDB2400_CLASS2_ACK0 0x0040 -#define PDB2400_FCP_CONF 0x0020 -#define PDB2400_CLASS2 0x0010 -#define PDB2400_ADDR_VALID 0x0002 - -/* - * Common elements from the above two structures that are actually useful to us. - */ -typedef struct { - u_int16_t handle; - u_int16_t reserved; - u_int32_t s3_role : 8, - portid : 24; - u_int8_t portname[8]; - u_int8_t nodename[8]; -} isp_pdb_t; - -/* - * Genericized Port Login/Logout software structure - */ -typedef struct { - u_int16_t handle; - u_int32_t - flags : 8, - portid : 24; -} isp_plcmd_t; -/* the flags to use are those for PLOGX_FLG_* below */ - -/* - * ISP24XX- Login/Logout Port IOCB - */ -typedef struct { - isphdr_t plogx_header; - u_int32_t plogx_handle; - u_int16_t plogx_status; - u_int16_t plogx_nphdl; - u_int16_t plogx_flags; - u_int16_t plogx_vphdl; /* low 8 bits */ - u_int16_t plogx_portlo; /* low 16 bits */ - u_int16_t plogx_rspsz_porthi; - struct { - u_int16_t lo16; - u_int16_t hi16; - } plogx_ioparm[11]; -} isp_plogx_t; - -#define PLOGX_STATUS_OK 0x00 -#define PLOGX_STATUS_UNAVAIL 0x28 -#define PLOGX_STATUS_LOGOUT 0x29 -#define PLOGX_STATUS_IOCBERR 0x31 - -#define PLOGX_IOCBERR_NOLINK 0x01 -#define PLOGX_IOCBERR_NOIOCB 0x02 -#define PLOGX_IOCBERR_NOXGHG 0x03 -#define PLOGX_IOCBERR_FAILED 0x04 /* further info in IOPARM 1 */ -#define PLOGX_IOCBERR_NOFABRIC 0x05 -#define PLOGX_IOCBERR_NOTREADY 0x07 -#define PLOGX_IOCBERR_NOLOGIN 0x08 /* further info in IOPARM 1 */ -#define PLOGX_IOCBERR_NOPCB 0x0a -#define PLOGX_IOCBERR_REJECT 0x18 /* further info in IOPARM 1 */ -#define PLOGX_IOCBERR_EINVAL 0x19 /* further info in IOPARM 1 */ -#define PLOGX_IOCBERR_PORTUSED 0x1a /* further info in IOPARM 1 */ -#define PLOGX_IOCBERR_HNDLUSED 0x1b /* further info in IOPARM 1 */ -#define PLOGX_IOCBERR_NOHANDLE 0x1c -#define PLOGX_IOCBERR_NOFLOGI 0x1f /* further info in IOPARM 1 */ - -#define PLOGX_FLG_CMD_MASK 0xf -#define PLOGX_FLG_CMD_PLOGI 0 -#define PLOGX_FLG_CMD_PRLI 1 -#define PLOGX_FLG_CMD_PDISC 2 -#define PLOGX_FLG_CMD_LOGO 8 -#define PLOGX_FLG_CMD_PRLO 9 -#define PLOGX_FLG_CMD_TPRLO 10 - -#define PLOGX_FLG_COND_PLOGI 0x10 /* if with PLOGI */ -#define PLOGX_FLG_IMPLICIT 0x10 /* if with LOGO, PRLO, TPRLO */ -#define PLOGX_FLG_SKIP_PRLI 0x20 /* if with PLOGI */ -#define PLOGX_FLG_IMPLICIT_LOGO_ALL 0x20 /* if with LOGO */ -#define PLOGX_FLG_EXPLICIT_LOGO 0x40 /* if with LOGO */ -#define PLOGX_FLG_COMMON_FEATURES 0x80 /* if with PLOGI */ -#define PLOGX_FLG_FREE_NPHDL 0x80 /* if with with LOGO */ - -#define PLOGX_FLG_CLASS2 0x100 /* if with PLOGI */ -#define PLOGX_FLG_FCP2_OVERRIDE 0x200 /* if with PRLOG, PRLI */ - -/* - * Simple Name Server Data Structures - */ -#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_reserved0; - u_int16_t snscb_addr[4]; /* response buffer address */ - u_int16_t snscb_sblen; /* subcommand buffer length (words) */ - u_int16_t snscb_reserved1; - 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_reserved0; - u_int16_t snscb_addr[4]; /* response buffer address */ - u_int16_t snscb_sblen; /* subcommand buffer length (words) */ - u_int16_t snscb_reserved1; - u_int16_t snscb_cmd; - u_int16_t snscb_reserved2; - u_int32_t snscb_reserved3; - 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_reserved0; - u_int16_t snscb_addr[4]; /* response buffer address */ - u_int16_t snscb_sblen; /* subcommand buffer length (words) */ - u_int16_t snscb_reserved1; - u_int16_t snscb_cmd; - u_int16_t snscb_reserved2; - u_int32_t snscb_reserved3; - 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_reserved0; - u_int16_t snscb_addr[4]; /* response buffer address */ - u_int16_t snscb_sblen; /* subcommand buffer length (words) */ - u_int16_t snscb_reserved1; - u_int16_t snscb_cmd; - u_int16_t snscb_mword_div_2; - u_int32_t snscb_reserved3; - 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_reserved0; - u_int16_t snscb_addr[4]; /* response buffer address */ - u_int16_t snscb_sblen; /* subcommand buffer length (words) */ - u_int16_t snscb_reserved1; - u_int16_t snscb_cmd; - u_int16_t snscb_reserved2; - u_int32_t snscb_reserved3; - 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)) - -/* - * Other Misc Structures - */ - -/* ELS Pass Through */ -typedef struct { - isphdr_t els_hdr; - u_int32_t els_handle; - u_int16_t els_status; - u_int16_t els_nphdl; - u_int16_t els_xmit_dsd_count; /* outgoing only */ - u_int8_t els_vphdl; - u_int8_t els_sof; - u_int32_t els_rxid; - u_int16_t els_recv_dsd_count; /* outgoing only */ - u_int8_t els_opcode; - u_int8_t els_reserved1; - u_int8_t els_did_lo; - u_int8_t els_did_mid; - u_int8_t els_did_hi; - u_int8_t els_reserved2; - u_int16_t els_reserved3; - u_int16_t els_ctl_flags; - union { - struct { - u_int32_t _els_bytecnt; - u_int32_t _els_subcode1; - u_int32_t _els_subcode2; - u_int8_t _els_reserved4[20]; - } in; - struct { - u_int32_t _els_recv_bytecnt; - u_int32_t _els_xmit_bytecnt; - u_int32_t _els_xmit_dsd_length; - u_int16_t _els_xmit_dsd_a1500; - u_int16_t _els_xmit_dsd_a3116; - u_int16_t _els_xmit_dsd_a4732; - u_int16_t _els_xmit_dsd_a6348; - u_int32_t _els_recv_dsd_length; - u_int16_t _els_recv_dsd_a1500; - u_int16_t _els_recv_dsd_a3116; - u_int16_t _els_recv_dsd_a4732; - u_int16_t _els_recv_dsd_a6348; - } out; - } inout; -#define els_bytecnt inout.in._els_bytecnt -#define els_subcode1 inout.in._els_subcode1 -#define els_subcode2 inout.in._els_subcode2 -#define els_reserved4 inout.in._els_reserved4 -#define els_recv_bytecnt inout.out._els_recv_bytecnt -#define els_xmit_bytecnt inout.out._els_xmit_bytecnt -#define els_xmit_dsd_length inout.out._els_xmit_dsd_length -#define els_xmit_dsd_a1500 inout.out._els_xmit_dsd_a1500 -#define els_xmit_dsd_a3116 inout.out._els_xmit_dsd_a3116 -#define els_xmit_dsd_a4732 inout.out._els_xmit_dsd_a4732 -#define els_xmit_dsd_a6348 inout.out._els_xmit_dsd_a6348 -#define els_recv_dsd_length inout.out._els_recv_dsd_length -#define els_recv_dsd_a1500 inout.out._els_recv_dsd_a1500 -#define els_recv_dsd_a3116 inout.out._els_recv_dsd_a3116 -#define els_recv_dsd_a4732 inout.out._els_recv_dsd_a4732 -#define els_recv_dsd_a6348 inout.out._els_recv_dsd_a6348 -} els_t; - -/* - * A handy package structure for running FC-SCSI commands via RUN IOCB A64. - */ -typedef struct { - u_int16_t handle; - u_int16_t lun; - u_int32_t portid; - u_int32_t timeout; - union { - struct { - u_int32_t data_length; - u_int8_t do_read; - u_int8_t pad[3]; - u_int8_t cdb[16]; - void *data_ptr; - } beg; - struct { - u_int32_t data_residual; - u_int8_t status; - u_int8_t pad; - u_int16_t sense_length; - u_int8_t sense_data[32]; - } end; - } fcd; -} isp_xcmd_t; -#endif /* _ISPMBOX_H */ diff --git a/sys/dev/ic/ispreg.h b/sys/dev/ic/ispreg.h deleted file mode 100644 index f6e35afea78..00000000000 --- a/sys/dev/ic/ispreg.h +++ /dev/null @@ -1,1181 +0,0 @@ -/* $OpenBSD: ispreg.h,v 1.17 2010/02/18 10:40:53 sobrado Exp $ */ -/* $FreeBSD: src/sys/dev/isp/ispreg.h,v 1.29 2007/03/10 02:39:54 mjacob Exp $ */ -/*- - * Copyright (c) 1997-2007 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. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY 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 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. - */ -/* - * Machine Independent (well, as best as possible) register - * definitions for QLogic ISP SCSI adapters. - */ -#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 PCI_MBOX_REGS2400_OFF 0x80 -#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. - */ -#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 */ - -/* fifo command stuff- mostly for SPI */ -#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_NVRAM_OFFSET (1 << 14) -#define BIU2100_FLASH_UPPER_64K 0x04 /* RW: Upper 64K Bank Select */ -#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 BIU_IMASK (BIU_ICR_ENABLE_RISC_INT|BIU_ICR_ENABLE_ALL_INTS) - -#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 BIU2100_IMASK (BIU2100_ICR_ENA_RISC_INT|BIU2100_ICR_ENABLE_ALL_INTS) - -/* 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)? \ - (IS_24XX(isp)? (isr & BIU2400_ISR_RISC_INT) : (isr & BIU2100_ISR_RISC_INT)) :\ - (isr & BIU_ISR_RISC_INT) - -#define INT_PENDING_MASK(isp) \ - (IS_FC(isp)? (IS_24XX(isp)? BIU2400_ISR_RISC_INT : 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 BIU_NVRAM_BUSY 0x0080 /* 2322/24xx only */ -#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 */ - -/* - * 2400 Interface Offsets and Register Definitions - * - * The 2400 looks quite different in terms of registers from other QLogic cards. - * It is getting to be a genuine pain and challenge to keep the same model - * for all. - */ -#define BIU2400_FLASH_ADDR (BIU_BLOCK+0x00) -#define BIU2400_FLASH_DATA (BIU_BLOCK+0x04) -#define BIU2400_CSR (BIU_BLOCK+0x08) -#define BIU2400_ICR (BIU_BLOCK+0x0C) -#define BIU2400_ISR (BIU_BLOCK+0x10) - -#define BIU2400_REQINP (BIU_BLOCK+0x1C) /* Request Queue In */ -#define BIU2400_REQOUTP (BIU_BLOCK+0x20) /* Request Queue Out */ -#define BIU2400_RSPINP (BIU_BLOCK+0x24) /* Response Queue In */ -#define BIU2400_RSPOUTP (BIU_BLOCK+0x28) /* Response Queue Out */ -#define BIU2400_PRI_RQINP (BIU_BLOCK+0x2C) /* Priority Request Q In */ -#define BIU2400_PRI_RSPINP (BIU_BLOCK+0x30) /* Priority Request Q Out */ - -#define BIU2400_ATIO_RSPINP (BIU_BLOCK+0x3C) /* ATIO Queue In */ -#define BIU2400_ATIO_REQINP (BIU_BLOCK+0x40) /* ATIO Queue Out */ - -#define BIU2400_R2HSTSLO (BIU_BLOCK+0x44) -#define BIU2400_R2HSTSHI (BIU_BLOCK+0x46) - -#define BIU2400_HCCR (BIU_BLOCK+0x48) -#define BIU2400_GPIOD (BIU_BLOCK+0x4C) -#define BIU2400_GPIOE (BIU_BLOCK+0x50) -#define BIU2400_HSEMA (BIU_BLOCK+0x58) - -/* BIU2400_FLASH_ADDR definitions */ -#define BIU2400_FLASH_DFLAG (1 << 30) - -/* BIU2400_CSR definitions */ -#define BIU2400_NVERR (1 << 18) -#define BIU2400_DMA_ACTIVE (1 << 17) /* RO */ -#define BIU2400_DMA_STOP (1 << 16) -#define BIU2400_FUNCTION (1 << 15) /* RO */ -#define BIU2400_PCIX_MODE(x) (((x) >> 8) & 0xf) /* RO */ -#define BIU2400_CSR_64BIT (1 << 2) /* RO */ -#define BIU2400_FLASH_ENABLE (1 << 1) -#define BIU2400_SOFT_RESET (1 << 0) - -/* BIU2400_ICR definitions */ -#define BIU2400_ICR_ENA_RISC_INT 0x8 -#define BIU2400_IMASK (BIU2400_ICR_ENA_RISC_INT) - -/* BIU2400_ISR definitions */ -#define BIU2400_ISR_RISC_INT 0x8 - -#define BIU2400_R2HST_INTR BIU_R2HST_INTR -#define BIU2400_R2HST_PAUSED BIU_R2HST_PAUSED -#define BIU2400_R2HST_ISTAT_MASK 0x1f -/* interrupt status meanings */ -#define ISP2400R2HST_ROM_MBX_OK 0x1 /* ROM mailbox cmd done ok */ -#define ISP2400R2HST_ROM_MBX_FAIL 0x2 /* ROM mailbox cmd done fail */ -#define ISP2400R2HST_MBX_OK 0x10 /* mailbox cmd done ok */ -#define ISP2400R2HST_MBX_FAIL 0x11 /* mailbox cmd done fail */ -#define ISP2400R2HST_ASYNC_EVENT 0x12 /* Async Event */ -#define ISP2400R2HST_RSPQ_UPDATE 0x13 /* Response Queue Update */ -#define ISP2400R2HST_ATIO_RSPQ_UPDATE 0x1C /* ATIO Response Queue Update */ -#define ISP2400R2HST_ATIO_RQST_UPDATE 0x1D /* ATIO Request Queue Update */ - -/* BIU2400_HCCR definitions */ - -#define HCCR_2400_CMD_NOP 0x00000000 -#define HCCR_2400_CMD_RESET 0x10000000 -#define HCCR_2400_CMD_CLEAR_RESET 0x20000000 -#define HCCR_2400_CMD_PAUSE 0x30000000 -#define HCCR_2400_CMD_RELEASE 0x40000000 -#define HCCR_2400_CMD_SET_HOST_INT 0x50000000 -#define HCCR_2400_CMD_CLEAR_HOST_INT 0x60000000 -#define HCCR_2400_CMD_CLEAR_RISC_INT 0xA0000000 - -#define HCCR_2400_RISC_ERR(x) (((x) >> 12) & 0x7) /* RO */ -#define HCCR_2400_RISC2HOST_INT (1 << 6) /* RO */ -#define HCCR_2400_RISC_RESET (1 << 5) /* RO */ - - -/* - * 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) - -/* - * Strictly speaking, it's - * SCSI && 2100 : 8 MBOX registers - * 2200: 24 MBOX registers - * 2300/2400: 32 MBOX registers - */ -#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))? 12 : 6) -#define NMBOX_BMASK(isp) \ - (((((isp)->isp_type & ISP_HA_SCSI) >= ISP_HA_SCSI_1040A) || \ - ((isp)->isp_type & ISP_HA_FC))? 0xfff : 0x3f) - -#define MAX_MAILBOX(isp) ((IS_FC(isp))? 12 : 8) -#define MAILBOX_STORAGE 12 -/* if timeout == 0, then default timeout is picked */ -#define MBCMD_DEFAULT_TIMEOUT 100000 /* 100 ms */ -typedef struct { - u_int16_t param[MAILBOX_STORAGE]; - u_int16_t ibits; - u_int16_t obits; - u_int32_t : 28, - logval : 4; - u_int32_t timeout; -} mbreg_t; - -/* - * 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 */ - -/* - * Defines for Interrupts - */ -#define ISP_INTS_ENABLED(isp) \ - ((IS_SCSI(isp))? \ - (ISP_READ(isp, BIU_ICR) & BIU_IMASK) : \ - (IS_24XX(isp)? (ISP_READ(isp, BIU2400_ICR) & BIU2400_IMASK) : \ - (ISP_READ(isp, BIU_ICR) & BIU2100_IMASK))) - -#define ISP_ENABLE_INTS(isp) \ - (IS_SCSI(isp) ? \ - ISP_WRITE(isp, BIU_ICR, BIU_IMASK) : \ - (IS_24XX(isp) ? \ - (ISP_WRITE(isp, BIU2400_ICR, BIU2400_IMASK)) : \ - (ISP_WRITE(isp, BIU_ICR, BIU2100_IMASK)))) - -#define ISP_DISABLE_INTS(isp) \ - IS_24XX(isp)? ISP_WRITE(isp, BIU2400_ICR, 0) : ISP_WRITE(isp, BIU_ICR, 0) - -/* - * 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_NVRAM_TARGSIZE 6 -#define _IxT(tgt, tidx) \ - (ISP_NVRAM_TARGOFF + (ISP_NVRAM_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 2100 thru 2300 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] | ((c)[9] << 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] | ((c)[27] << 8)) -#define ISP2100_NVRAM_TOV(c) ((c)[29]) - -#define ISP2100_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_XFW_OPTIONS(c) ((c)[38] | ((c)[39] << 8)) - -#define ISP2100_RACC_TIMER(c) (c)[40] -#define ISP2100_IDELAY_TIMER(c) (c)[41] - -#define ISP2100_ZFW_OPTIONS(c) ((c)[42] | ((c)[43] << 8)) - -#define ISP2100_SERIAL_LINK(c) ((c)[68] | ((c)[69] << 8)) - -#define ISP2100_NVRAM_HBA_OPTIONS(c) ((c)[70] | ((c)[71] << 8)) -#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 ISP2100_RESET_DELAY(c) (c)[81] - -#define ISP2100_HBA_FEATURES(c) ((c)[232] | ((c)[233] << 8)) - -/* - * QLogic 2400 NVRAM is an array of 512 bytes with a 32 bit checksum. - */ -#define ISP2400_NVRAM_PORT0_ADDR 0x80 -#define ISP2400_NVRAM_PORT1_ADDR 0x180 -#define ISP2400_NVRAM_SIZE 512 - -#define ISP2400_NVRAM_VERSION(c) ((c)[4] | ((c)[5] << 8)) -#define ISP2400_NVRAM_MAXFRAMELENGTH(c) (((c)[12]) | ((c)[13] << 8)) -#define ISP2400_NVRAM_EXECUTION_THROTTLE(c) (((c)[14]) | ((c)[15] << 8)) -#define ISP2400_NVRAM_EXCHANGE_COUNT(c) (((c)[16]) | ((c)[17] << 8)) -#define ISP2400_NVRAM_HARDLOOPID(c) ((c)[18] | ((c)[19] << 8)) - -#define ISP2400_NVRAM_PORT_NAME(c) (\ - (((u_int64_t)(c)[20]) << 56) | \ - (((u_int64_t)(c)[21]) << 48) | \ - (((u_int64_t)(c)[22]) << 40) | \ - (((u_int64_t)(c)[23]) << 32) | \ - (((u_int64_t)(c)[24]) << 24) | \ - (((u_int64_t)(c)[25]) << 16) | \ - (((u_int64_t)(c)[26]) << 8) | \ - (((u_int64_t)(c)[27]) << 0)) - -#define ISP2400_NVRAM_NODE_NAME(c) (\ - (((u_int64_t)(c)[28]) << 56) | \ - (((u_int64_t)(c)[29]) << 48) | \ - (((u_int64_t)(c)[30]) << 40) | \ - (((u_int64_t)(c)[31]) << 32) | \ - (((u_int64_t)(c)[32]) << 24) | \ - (((u_int64_t)(c)[33]) << 16) | \ - (((u_int64_t)(c)[34]) << 8) | \ - (((u_int64_t)(c)[35]) << 0)) - -#define ISP2400_NVRAM_LOGIN_RETRY_CNT(c) ((c)[36] | ((c)[37] << 8)) -#define ISP2400_NVRAM_LINK_DOWN_ON_NOS(c) ((c)[38] | ((c)[39] << 8)) -#define ISP2400_NVRAM_INTERRUPT_DELAY(c) ((c)[40] | ((c)[41] << 8)) -#define ISP2400_NVRAM_LOGIN_TIMEOUT(c) ((c)[42] | ((c)[43] << 8)) - -#define ISP2400_NVRAM_FIRMWARE_OPTIONS1(c) \ - ((c)[44] | ((c)[45] << 8) | ((c)[46] << 16) | ((c)[47] << 24)) -#define ISP2400_NVRAM_FIRMWARE_OPTIONS2(c) \ - ((c)[48] | ((c)[49] << 8) | ((c)[50] << 16) | ((c)[51] << 24)) -#define ISP2400_NVRAM_FIRMWARE_OPTIONS3(c) \ - ((c)[52] | ((c)[53] << 8) | ((c)[54] << 16) | ((c)[55] << 24)) - -/* - * 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 --git a/sys/dev/ic/ispvar.h b/sys/dev/ic/ispvar.h deleted file mode 100644 index b97b4bdcb83..00000000000 --- a/sys/dev/ic/ispvar.h +++ /dev/null @@ -1,1024 +0,0 @@ -/* $OpenBSD: ispvar.h,v 1.28 2010/02/18 10:40:53 sobrado Exp $ */ -/* $FreeBSD: src/sys/dev/isp/ispvar.h,v 1.85 2007/07/02 20:08:20 mjacob Exp $ */ -/*- - * Copyright (c) 1997-2007 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. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY 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 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. - */ -/* - * Soft Definitions for for QLogic ISP SCSI adapters. - */ - -#ifndef _ISPVAR_H -#define _ISPVAR_H - -#if defined(__NetBSD__) || defined(__OpenBSD__) -#include <dev/ic/isp_stds.h> -#include <dev/ic/ispmbox.h> -#endif -#ifdef __FreeBSD__ -#include <dev/isp/isp_stds.h> -#include <dev/isp/ispmbox.h> -#endif -#ifdef __linux__ -#include "isp_stds.h" -#include "ispmbox.h" -#endif -#ifdef __svr4__ -#include "isp_stds.h" -#include "ispmbox.h" -#endif - -#define ISP_CORE_VERSION_MAJOR 3 -#define ISP_CORE_VERSION_MINOR 0 - -/* - * Vector for bus specific code to provide specific services. - */ -typedef struct ispsoftc ispsoftc_t; -struct ispmdvec { - int (*dv_rd_isr) - (struct ispsoftc *, u_int32_t *, u_int16_t *, u_int16_t *); - u_int32_t (*dv_rd_reg) (struct ispsoftc *, int); - void (*dv_wr_reg) (struct ispsoftc *, int, u_int32_t); - int (*dv_mbxdma) (struct ispsoftc *); - int (*dv_dmaset) - (struct ispsoftc *, XS_T *, ispreq_t *, u_int32_t *, u_int32_t); - void (*dv_dmaclr) (struct ispsoftc *, XS_T *, u_int32_t); - void (*dv_reset0) (struct ispsoftc *); - void (*dv_reset1) (struct ispsoftc *); - void (*dv_dregs) (struct ispsoftc *, const char *); - const void * 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 512 -#define ISP_MAX_TARGETS(isp) (IS_FC(isp)? MAX_FC_TARG : MAX_TARGETS) -#define ISP_MAX_LUNS(isp) (isp)->isp_maxluns - -/* - * 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 */ -#define SYNC_ATIOQ 5 /* atio result queue (24xx) */ - -/* - * 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) (((u_int8_t *)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); \ - ISP_WRITE(isp, isp->isp_rqstinrp, nxti); \ - isp->isp_reqidx = nxti - -/* - * SCSI Specific Host Adapter Parameters- per bus, per target - */ -typedef struct { - u_int32_t : 10, - isp_bad_nvram : 1, - 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_ptisp : 1, - 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 - */ -/* These are for non-2K Login Firmware cards */ -#define FL_ID 0x7e /* FL_Port Special ID */ -#define SNS_ID 0x80 /* SNS Server Special ID */ -#define NPH_MAX 0xfe - -/* These are for 2K Login Firmware cards */ -#define NPH_RESERVED 0x7F0 /* begin of reserved N-port handles */ -#define NPH_MGT_ID 0x7FA /* Management Server Special ID */ -#define NPH_SNS_ID 0x7FC /* SNS Server Special ID */ -#define NPH_FL_ID 0x7FE /* FL Port Special ID */ -#define NPH_MAX_2K 0x800 - -/* - * "Unassigned" handle to be used internally - */ -#define NIL_HANDLE 0xffff - -/* - * Limit for devices on an arbitrated loop. - */ -#define LOCAL_LOOP_LIM 126 - -/* - * Special Port IDs - */ -#define MANAGEMENT_PORT_ID 0xFFFFFA -#define SNS_PORT_ID 0xFFFFFC -#define FABRIC_PORT_ID 0xFFFFFE - - -/* - * FC Port Database entry. - * - * It has a handle that the f/w uses to address commands to a device. - * This handle's value may be assigned by the firmware (e.g., for local loop - * devices) or by the driver (e.g., for fabric devices). - * - * It has a state. If the state if VALID, that means that we've logged into - * the device. We also *may* have a initiator map index entry. This is a value - * from 0..MAX_FC_TARG that is used to index into the isp_ini_map array. If - * the value therein is non-zero, then that value minus one is used to index - * into the Port Database to find the handle for forming commands. There is - * back-index minus one value within to Port Database entry that tells us - * which entry in isp_ini_map points to us (to avoid searching). - * - * Local loop devices the firmware automatically performs PLOGI on for us - * (which is why that handle is imposed upon us). Fabric devices we assign - * a handle to and perform the PLOGI on. - * - * When a PORT DATABASE CHANGED asynchronous event occurs, we mark all VALID - * entries as PROBATIONAL. This allows us, if policy says to, just keep track - * of devices whose handles change but are otherwise the same device (and - * thus keep 'target' constant). - * - * In any case, we search all possible local loop handles. For each one that - * has a port database entity returned, we search for any PROBATIONAL entry - * that matches it and update as appropriate. Otherwise, as a new entry, we - * find room for it in the Port Database. We *try* and use the handle as the - * index to put it into the Database, but that's just an optimization. We mark - * the entry VALID and make sure that the target index is updated and correct. - * - * When we get done searching the local loop, we then search similarily for - * a list of devices we've gotten from the fabric name controller (if we're - * on a fabric). VALID marking is also done similarily. - * - * When all of this is done, we can march through the database and clean up - * any entry that is still PROBATIONAL (these represent devices which have - * departed). Then we're done and can resume normal operations. - * - * Negative invariants that we try and test for are: - * - * + There can never be two non-NIL entries with the same { Port, Node } WWN - * duples. - * - * + There can never be two non-NIL entries with the same handle. - * - * + There can never be two non-NIL entries which have the same ini_map_idx - * value. - */ -typedef struct { - /* - * This is the handle that the firmware needs in order for us to - * send commands to the device. For pre-24XX cards, this would be - * the 'loopid'. - */ - u_int16_t handle; - /* - * The ini_map_idx, if nonzero, is the system virtual target ID (+1) - * as a cross-reference with the isp_ini_map. - * - * A device is 'autologin' if the firmware automatically logs into - * it (re-logins as needed). Basically, local private loop devices. - * - * The state is the current state of thsi entry. - * - * Role is Initiator, Target, Both - * - * Portid is obvious, as or node && port WWNs. The new_role and - * new_portid is for when we are pending a change. - */ - u_int16_t ini_map_idx : 12, - autologin : 1, /* F/W does PLOGI/PLOGO */ - state : 3; - u_int32_t reserved : 6, - roles : 2, - portid : 24; - u_int32_t new_reserved : 6, - new_roles : 2, - new_portid : 24; - u_int64_t node_wwn; - u_int64_t port_wwn; -} fcportdb_t; - -#define FC_PORTDB_STATE_NIL 0 -#define FC_PORTDB_STATE_PROBATIONAL 1 -#define FC_PORTDB_STATE_DEAD 2 -#define FC_PORTDB_STATE_CHANGED 3 -#define FC_PORTDB_STATE_NEW 4 -#define FC_PORTDB_STATE_PENDING_VALID 5 -#define FC_PORTDB_STATE_ZOMBIE 6 -#define FC_PORTDB_STATE_VALID 7 - -/* - * FC card specific information - */ -typedef struct { - u_int32_t : 10, - isp_tmode : 1, - isp_2klogin : 1, - isp_sccfw : 1, - isp_gbspeed : 3, - : 1, - : 1, - isp_gotdparms : 1, - isp_bad_nvram : 1, - isp_loopstate : 4, /* Current Loop State */ - isp_fwstate : 4, /* ISP F/W state */ - isp_topo : 3, - loop_seen_once : 1; - u_int32_t : 8, - isp_portid : 24; /* S_ID */ - u_int16_t isp_fwoptions; - u_int16_t isp_xfwoptions; - u_int16_t isp_zfwoptions; - u_int16_t isp_loopid; /* hard loop id */ - u_int16_t isp_fwattr; /* firmware attributes */ - u_int16_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_wwnn_nvram; - u_int64_t isp_wwpn_nvram; - - /* - * Our Port Data Base - */ - fcportdb_t portdb[MAX_FC_TARG]; - - /* - * This maps system virtual 'target' id to a portdb entry. - * - * The mapping function is to take any non-zero entry and - * subtract one to get the portdb index. This means that - * entries which are zero are unmapped (i.e., don't exist). - */ - u_int16_t isp_ini_map[MAX_FC_TARG]; - - /* - * Scratch DMA mapped in area to fetch Port Database stuff, etc. - */ - void * isp_scratch; - XS_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_LOOP 3 -#define LOOP_LSCAN_DONE 4 -#define LOOP_SCANNING_FABRIC 5 -#define LOOP_FSCAN_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 - */ -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/24XX 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_int32_t isp_rqstinrp; /* register for REQINP */ - u_int32_t isp_rqstoutrp; /* register for REQOUTP */ - u_int32_t isp_respinrp; /* register for RESINP */ - u_int32_t isp_respoutrp; /* register for RESOUTP */ - u_int32_t isp_atioinrp; /* register for ATIOINP */ - u_int32_t isp_atiooutrp; /* register for ATIOOUTP */ - - /* - * 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 : 8, - 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_int32_t isp_reqodx; /* index of last ISP pickup */ - volatile u_int32_t isp_reqidx; /* index of next request */ - volatile u_int32_t isp_residx; /* index of next result */ - volatile u_int32_t isp_resodx; /* index of next result */ - volatile u_int32_t isp_rspbsy; - volatile u_int32_t isp_lasthdls; /* last handle seed */ - volatile u_int32_t isp_obits; /* mailbox command output */ - volatile u_int16_t isp_mboxtmp[MAILBOX_STORAGE]; - 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; - volatile u_int16_t isp_mbxwrk8; - void * isp_mbxworkp; - - /* - * Active commands are stored here, indexed by handle functions. - */ - XS_T **isp_xflist; - -#ifdef ISP_TARGET_MODE - /* - * Active target commands are stored here, indexed by handle function. - */ - void **isp_tgtlist; -#endif - - /* - * request/result queue pointers and DMA handles for them. - */ - void * isp_rquest; - void * isp_result; - XS_DMA_ADDR_T isp_rquest_dma; - XS_DMA_ADDR_T isp_result_dma; -#ifdef ISP_TARGET_MODE - /* for 24XX only */ - void * isp_atioq; - XS_DMA_ADDR_T isp_atioq_dma; -#endif -}; - -#define SDPARAM(isp) ((sdparam *) (isp)->isp_param) -#define FCPARAM(isp) ((fcparam *) (isp)->isp_param) - -/* - * ISP Driver Run States - */ -#define ISP_NILSTATE 0 -#define ISP_CRASHED 1 -#define ISP_RESETSTATE 2 -#define ISP_INITSTATE 3 -#define ISP_RUNSTATE 4 - -/* - * 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 */ -#define ISP_CFG_FOURGB 0x2000 /* force 4GB connection (24XX only) */ - -/* - * 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_TARGET 0x1 -#define ISP_ROLE_INITIATOR 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_CODE_ORG_2400 0x100000 /* ..and 2400s */ -#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)) -#define ISP_FW_OLDER_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 ISP_HA_FC_2322 0x50 -#define ISP_HA_FC_2400 0x60 - -#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 && \ - (isp)->isp_type < ISP_HA_FC_2400) -#define IS_2300(isp) ((isp)->isp_type == ISP_HA_FC_2300) -#define IS_2312(isp) ((isp)->isp_type == ISP_HA_FC_2312) -#define IS_2322(isp) ((isp)->isp_type == ISP_HA_FC_2322) -#define IS_24XX(isp) ((isp)->isp_type >= ISP_HA_FC_2400) - -/* - * DMA related macros - */ -#define DMA_WD3(x) (((u_int16_t)(((u_int64_t)x) >> 48)) & 0xffff) -#define DMA_WD2(x) (((u_int16_t)(((u_int64_t)x) >> 32)) & 0xffff) -#define DMA_WD1(x) ((u_int16_t)((x) >> 16) & 0xffff) -#define DMA_WD0(x) ((u_int16_t)((x) & 0xffff)) - -#define DMA_LO32(x) ((u_int32_t) (x)) -#define DMA_HI32(x) ((u_int32_t)(((u_int64_t)x) >> 32)) - -/* - * 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_int32_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_PORTNAME, /* get portname from an N-port handle */ - ISPCTL_RUN_MBOXCMD, /* run a mailbox command */ - ISPCTL_TOGGLE_TMODE, /* toggle target mode */ - ISPCTL_GET_PDB, /* get a single port database entry */ - ISPCTL_PLOGX /* do a port login/logout */ -} 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_DEV_ARRIVED, /* FC Device Arrival */ - ISPASYNC_DEV_CHANGED, /* FC Device Change */ - ISPASYNC_DEV_STAYED, /* FC Device Stayed the Same */ - ISPASYNC_DEV_GONE, /* FC Device Depart */ - ISPASYNC_TARGET_NOTIFY, /* target asynchronous notification event */ - ISPASYNC_TARGET_ACTION, /* target action requested */ - 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 - * - * Generally this is: - * - * void isp_prt(struct ispsoftc *, int level, const char *, ...) - * - * but due to compiler differences on different platforms this won't be - * formally done here. Instead, it goes in each platform definition file. - */ - -#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_LOGSANCFG 0x100 /* log SAN configuration */ -#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: - * - * - * 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 *, mbreg_t *) wait for 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_DMA_ADDR_T Platform PCI DMA Address Type - * 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, len) 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_ww{n,p}n_nvram 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 *) - * ISP_SWIZZLE_NVRAM_LONG(struct ispsoftc *, u_int32_t *) - * ISP_SWAP16(struct ispsoftc *, u_int16_t srcval) - * ISP_SWAP32(struct ispsoftc *, u_int32_t srcval) - */ - -#endif /* _ISPVAR_H */ diff --git a/sys/dev/ic/qla.c b/sys/dev/ic/qla.c index 8c003eaaef5..1b5b031d7f1 100644 --- a/sys/dev/ic/qla.c +++ b/sys/dev/ic/qla.c @@ -1,4 +1,4 @@ -/* $OpenBSD: qla.c,v 1.50 2015/03/14 03:38:47 jsg Exp $ */ +/* $OpenBSD: qla.c,v 1.51 2015/06/19 11:12:24 jmatthew Exp $ */ /* * Copyright (c) 2011 David Gwynne <dlg@openbsd.org> @@ -52,9 +52,9 @@ int qladebug = QLA_D_PORT; #ifndef ISP_NOFIRMWARE -extern const u_int16_t isp_2100_risc_code[]; -extern const u_int16_t isp_2200_risc_code[]; -extern const u_int16_t isp_2300_risc_code[]; +#include <dev/microcode/isp/asm_2100.h> +#include <dev/microcode/isp/asm_2200.h> +#include <dev/microcode/isp/asm_2300.h> #endif struct cfdriver qla_cd = { diff --git a/sys/dev/microcode/isp/isp_fw2100.c b/sys/dev/microcode/isp/isp_fw2100.c deleted file mode 100644 index 0b7a9f0313b..00000000000 --- a/sys/dev/microcode/isp/isp_fw2100.c +++ /dev/null @@ -1,8 +0,0 @@ -/* $OpenBSD: isp_fw2100.c,v 1.1 2014/02/10 22:41:27 jmatthew Exp $ */ -/* public domain */ - -#include <sys/types.h> - -#ifndef ISP_NOFIRMWARE -#include <dev/microcode/isp/asm_2100.h> -#endif diff --git a/sys/dev/microcode/isp/isp_fw2200.c b/sys/dev/microcode/isp/isp_fw2200.c deleted file mode 100644 index a0aba10044c..00000000000 --- a/sys/dev/microcode/isp/isp_fw2200.c +++ /dev/null @@ -1,8 +0,0 @@ -/* $OpenBSD: isp_fw2200.c,v 1.1 2014/02/10 22:41:27 jmatthew Exp $ */ -/* public domain */ - -#include <sys/types.h> - -#ifndef ISP_NOFIRMWARE -#include <dev/microcode/isp/asm_2200.h> -#endif diff --git a/sys/dev/microcode/isp/isp_fw2300.c b/sys/dev/microcode/isp/isp_fw2300.c deleted file mode 100644 index 31301f26da3..00000000000 --- a/sys/dev/microcode/isp/isp_fw2300.c +++ /dev/null @@ -1,8 +0,0 @@ -/* $OpenBSD: isp_fw2300.c,v 1.1 2014/02/10 22:41:27 jmatthew Exp $ */ -/* public domain */ - -#include <sys/types.h> - -#ifndef ISP_NOFIRMWARE -#include <dev/microcode/isp/asm_2300.h> -#endif diff --git a/sys/dev/pci/files.pci b/sys/dev/pci/files.pci index 5b5b61cb180..5410a10258d 100644 --- a/sys/dev/pci/files.pci +++ b/sys/dev/pci/files.pci @@ -1,4 +1,4 @@ -# $OpenBSD: files.pci,v 1.317 2015/06/07 10:47:53 dlg Exp $ +# $OpenBSD: files.pci,v 1.318 2015/06/19 11:12:24 jmatthew Exp $ # $NetBSD: files.pci,v 1.20 1996/09/24 17:47:15 christos Exp $ # # Config file and device description for machine-independent PCI code. @@ -212,11 +212,6 @@ file dev/pci/cac_pci.c cac_pci attach ciss at pci with ciss_pci file dev/pci/ciss_pci.c ciss_pci -# QLogic ISP 10x0 (PCI) family -# device declaration in sys/conf/files -attach isp at pci with isp_pci -file dev/pci/isp_pci.c isp_pci - # QLogic ISP SCSI Controllers attach qlw at pci with qlw_pci file dev/pci/qlw_pci.c qlw_pci diff --git a/sys/dev/pci/isp_pci.c b/sys/dev/pci/isp_pci.c deleted file mode 100644 index f559edeb4f9..00000000000 --- a/sys/dev/pci/isp_pci.c +++ /dev/null @@ -1,1385 +0,0 @@ -/* $OpenBSD: isp_pci.c,v 1.62 2014/12/13 21:05:33 doug Exp $ */ -/* $FreeBSD: src/sys/dev/isp/isp_pci.c,v 1.148 2007/06/26 23:08:57 mjacob Exp $*/ -/*- - * Copyright (c) 1997-2006 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. - */ -/* - * PCI specific probe and attach routines for Qlogic ISP SCSI adapters. - * FreeBSD Version. - */ - -#include <dev/ic/isp_openbsd.h> - -#include <dev/pci/pcireg.h> -#include <dev/pci/pcivar.h> -#include <dev/pci/pcidevs.h> - -#ifdef __sparc64__ -#include <dev/ofw/openfirm.h> -#endif -#ifdef __sgi__ -#include <machine/autoconf.h> -#include <mips64/archtype.h> -#endif - -#ifndef ISP_NOFIRMWARE -#define ISP_FIRMWARE_1040 -#define ISP_FIRMWARE_1080 -#define ISP_FIRMWARE_12160 -#define ISP_FIRMWARE_2100 -#define ISP_FIRMWARE_2200 -#define ISP_FIRMWARE_2300 -#endif - -#if defined(ISP_FIRMWARE_1040) -#define ISP_1040_RISC_CODE (u_int16_t *) isp_1040_risc_code -#include <dev/microcode/isp/asm_1040.h> -#else -#define ISP_1040_RISC_CODE NULL -#endif - -#if defined(ISP_FIRMWARE_1080) -#define ISP_1080_RISC_CODE (u_int16_t *) isp_1080_risc_code -#include <dev/microcode/isp/asm_1080.h> -#else -#define ISP_1080_RISC_CODE NULL -#endif - -#if defined(ISP_FIRMWARE_12160) -#define ISP_12160_RISC_CODE (u_int16_t *) isp_12160_risc_code -#include <dev/microcode/isp/asm_12160.h> -#else -#define ISP_12160_RISC_CODE NULL -#endif - -#if defined(ISP_FIRMWARE_2100) -extern const u_int16_t isp_2100_risc_code[]; -#define ISP_2100_RISC_CODE (u_int16_t *) isp_2100_risc_code -#else -#define ISP_2100_RISC_CODE NULL -#endif - -#if defined(ISP_FIRMWARE_2200) -extern const u_int16_t isp_2200_risc_code[]; -#define ISP_2200_RISC_CODE (u_int16_t *) isp_2200_risc_code -#else -#define ISP_2200_RISC_CODE NULL -#endif - -#if defined(ISP_FIRMWARE_2300) -extern const u_int16_t isp_2300_risc_code[]; -#define ISP_2300_RISC_CODE (u_int16_t *) isp_2300_risc_code -#else -#define ISP_2300_RISC_CODE NULL -#endif - -#if defined(ISP_FIRMWARE_2400) -#define ISP_2400_RISC_CODE (u_int16_t *) isp_2400_risc_code -#include <dev/microcode/isp/asm_2400.h> -#else -#define ISP_2400_RISC_CODE NULL -#endif - -uint32_t isp_pci_rd_reg(ispsoftc_t *, int); -void isp_pci_wr_reg(ispsoftc_t *, int, uint32_t); -uint32_t isp_pci_rd_reg_1080(ispsoftc_t *, int); -void isp_pci_wr_reg_1080(ispsoftc_t *, int, uint32_t); -uint32_t isp_pci_rd_reg_2400(ispsoftc_t *, int); -void isp_pci_wr_reg_2400(ispsoftc_t *, int, uint32_t); -int isp_pci_rd_isr(ispsoftc_t *, uint32_t *, uint16_t *, uint16_t *); -int isp_pci_rd_isr_2300(ispsoftc_t *, uint32_t *, uint16_t *, uint16_t *); -int isp_pci_rd_isr_2400(ispsoftc_t *, uint32_t *, uint16_t *, uint16_t *); -int isp_pci_mbxdma(ispsoftc_t *); -int isp_pci_dmasetup(ispsoftc_t *, XS_T *, ispreq_t *, uint32_t *, uint32_t); -void isp_pci_reset0(ispsoftc_t *); -void isp_pci_reset1(ispsoftc_t *); -void isp_pci_dumpregs(ispsoftc_t *, const char *); - - -int isp_pci_rd_debounced(struct ispsoftc *, int, u_int16_t *); -int isp_pci_intr (void *); -void isp_pci_dmateardown(struct ispsoftc *, XS_T *, u_int32_t); - -static struct ispmdvec mdvec = { - isp_pci_rd_isr, - isp_pci_rd_reg, - isp_pci_wr_reg, - isp_pci_mbxdma, - isp_pci_dmasetup, - isp_pci_dmateardown, - isp_pci_reset0, - isp_pci_reset1, - isp_pci_dumpregs, - ISP_1040_RISC_CODE, - BIU_BURST_ENABLE|BIU_PCI_CONF1_FIFO_64 -}; - -static struct ispmdvec mdvec_1080 = { - isp_pci_rd_isr, - isp_pci_rd_reg_1080, - isp_pci_wr_reg_1080, - isp_pci_mbxdma, - isp_pci_dmasetup, - isp_pci_dmateardown, - isp_pci_reset0, - isp_pci_reset1, - isp_pci_dumpregs, - ISP_1080_RISC_CODE, - BIU_BURST_ENABLE|BIU_PCI_CONF1_FIFO_64 -}; - -static struct ispmdvec mdvec_12160 = { - isp_pci_rd_isr, - isp_pci_rd_reg_1080, - isp_pci_wr_reg_1080, - isp_pci_mbxdma, - isp_pci_dmasetup, - isp_pci_dmateardown, - isp_pci_reset0, - isp_pci_reset1, - isp_pci_dumpregs, - ISP_12160_RISC_CODE, - BIU_BURST_ENABLE|BIU_PCI_CONF1_FIFO_64 -}; - -static struct ispmdvec mdvec_2100 = { - isp_pci_rd_isr, - isp_pci_rd_reg, - isp_pci_wr_reg, - isp_pci_mbxdma, - isp_pci_dmasetup, - isp_pci_dmateardown, - isp_pci_reset0, - isp_pci_reset1, - isp_pci_dumpregs, - ISP_2100_RISC_CODE -}; - -static struct ispmdvec mdvec_2200 = { - isp_pci_rd_isr, - isp_pci_rd_reg, - isp_pci_wr_reg, - isp_pci_mbxdma, - isp_pci_dmasetup, - isp_pci_dmateardown, - isp_pci_reset0, - isp_pci_reset1, - isp_pci_dumpregs, - ISP_2200_RISC_CODE -}; - -static struct ispmdvec mdvec_2300 = { - isp_pci_rd_isr_2300, - isp_pci_rd_reg, - isp_pci_wr_reg, - isp_pci_mbxdma, - isp_pci_dmasetup, - isp_pci_dmateardown, - isp_pci_reset0, - isp_pci_reset1, - isp_pci_dumpregs, - ISP_2300_RISC_CODE -}; - -#ifndef PCIM_CMD_INVEN -#define PCIM_CMD_INVEN 0x10 -#endif -#ifndef PCIM_CMD_BUSMASTEREN -#define PCIM_CMD_BUSMASTEREN 0x0004 -#endif -#ifndef PCIM_CMD_PERRESPEN -#define PCIM_CMD_PERRESPEN 0x0040 -#endif -#ifndef PCIM_CMD_SEREN -#define PCIM_CMD_SEREN 0x0100 -#endif -#ifndef PCIM_CMD_INTX_DISABLE -#define PCIM_CMD_INTX_DISABLE 0x0400 -#endif - -#ifndef PCIR_COMMAND -#define PCIR_COMMAND 0x04 -#endif - -#ifndef PCIR_CACHELNSZ -#define PCIR_CACHELNSZ 0x0c -#endif - -#ifndef PCIR_LATTIMER -#define PCIR_LATTIMER 0x0d -#endif - -#ifndef PCIR_ROMADDR -#define PCIR_ROMADDR 0x30 -#endif - -#ifndef PCI_VENDOR_QLOGIC -#define PCI_VENDOR_QLOGIC 0x1077 -#endif - -#ifndef PCI_PRODUCT_QLOGIC_ISP1020 -#define PCI_PRODUCT_QLOGIC_ISP1020 0x1020 -#endif - -#ifndef PCI_PRODUCT_QLOGIC_ISP1080 -#define PCI_PRODUCT_QLOGIC_ISP1080 0x1080 -#endif - -#ifndef PCI_PRODUCT_QLOGIC_ISP10160 -#define PCI_PRODUCT_QLOGIC_ISP10160 0x1016 -#endif - -#ifndef PCI_PRODUCT_QLOGIC_ISP12160 -#define PCI_PRODUCT_QLOGIC_ISP12160 0x1216 -#endif - -#ifndef PCI_PRODUCT_QLOGIC_ISP1240 -#define PCI_PRODUCT_QLOGIC_ISP1240 0x1240 -#endif - -#ifndef PCI_PRODUCT_QLOGIC_ISP1280 -#define PCI_PRODUCT_QLOGIC_ISP1280 0x1280 -#endif - -#ifndef PCI_PRODUCT_QLOGIC_ISP2100 -#define PCI_PRODUCT_QLOGIC_ISP2100 0x2100 -#endif - -#ifndef PCI_PRODUCT_QLOGIC_ISP2200 -#define PCI_PRODUCT_QLOGIC_ISP2200 0x2200 -#endif - -#ifndef PCI_PRODUCT_QLOGIC_ISP2300 -#define PCI_PRODUCT_QLOGIC_ISP2300 0x2300 -#endif - -#ifndef PCI_PRODUCT_QLOGIC_ISP2312 -#define PCI_PRODUCT_QLOGIC_ISP2312 0x2312 -#endif - -#ifndef PCI_PRODUCT_QLOGIC_ISP2322 -#define PCI_PRODUCT_QLOGIC_ISP2322 0x2322 -#endif - -#ifndef PCI_PRODUCT_QLOGIC_ISP6312 -#define PCI_PRODUCT_QLOGIC_ISP6312 0x6312 -#endif - -#ifndef PCI_PRODUCT_QLOGIC_ISP6322 -#define PCI_PRODUCT_QLOGIC_ISP6322 0x6322 -#endif - - -#define PCI_QLOGIC_ISP1020 \ - ((PCI_PRODUCT_QLOGIC_ISP1020 << 16) | PCI_VENDOR_QLOGIC) - -#define PCI_QLOGIC_ISP1080 \ - ((PCI_PRODUCT_QLOGIC_ISP1080 << 16) | PCI_VENDOR_QLOGIC) - -#define PCI_QLOGIC_ISP10160 \ - ((PCI_PRODUCT_QLOGIC_ISP10160 << 16) | PCI_VENDOR_QLOGIC) - -#define PCI_QLOGIC_ISP12160 \ - ((PCI_PRODUCT_QLOGIC_ISP12160 << 16) | PCI_VENDOR_QLOGIC) - -#define PCI_QLOGIC_ISP1240 \ - ((PCI_PRODUCT_QLOGIC_ISP1240 << 16) | PCI_VENDOR_QLOGIC) - -#define PCI_QLOGIC_ISP1280 \ - ((PCI_PRODUCT_QLOGIC_ISP1280 << 16) | PCI_VENDOR_QLOGIC) - -#define PCI_QLOGIC_ISP2100 \ - ((PCI_PRODUCT_QLOGIC_ISP2100 << 16) | PCI_VENDOR_QLOGIC) - -#define PCI_QLOGIC_ISP2200 \ - ((PCI_PRODUCT_QLOGIC_ISP2200 << 16) | PCI_VENDOR_QLOGIC) - -#define PCI_QLOGIC_ISP2300 \ - ((PCI_PRODUCT_QLOGIC_ISP2300 << 16) | PCI_VENDOR_QLOGIC) - -#define PCI_QLOGIC_ISP2312 \ - ((PCI_PRODUCT_QLOGIC_ISP2312 << 16) | PCI_VENDOR_QLOGIC) - -#define PCI_QLOGIC_ISP2322 \ - ((PCI_PRODUCT_QLOGIC_ISP2322 << 16) | PCI_VENDOR_QLOGIC) - -#define PCI_QLOGIC_ISP6312 \ - ((PCI_PRODUCT_QLOGIC_ISP6312 << 16) | PCI_VENDOR_QLOGIC) - -#define PCI_QLOGIC_ISP6322 \ - ((PCI_PRODUCT_QLOGIC_ISP6322 << 16) | PCI_VENDOR_QLOGIC) - -/* - * Odd case for some AMI raid cards... We need to *not* attach to this. - */ -#define AMI_RAID_SUBVENDOR_ID 0x101e - -#define IO_MAP_REG 0x10 -#define MEM_MAP_REG 0x14 - -#define PCI_DFLT_LTNCY 0x40 -#define PCI_DFLT_LNSZ 0x10 - -#ifndef SCSI_ISP_PREFER_MEM_MAP -#ifdef __alpha__ -#define SCSI_ISP_PREFER_MEM_MAP 1 -#else -#define SCSI_ISP_PREFER_MEM_MAP 0 -#endif -#endif - -#ifdef DEBUG -const char vstring[] = - "QLogic ISP Driver, OpenBSD (pci) Platform Version %d.%d Core Version %d.%d"; -#endif - -const struct pci_matchid ispdev[] = { - { PCI_VENDOR_QLOGIC, PCI_PRODUCT_QLOGIC_ISP1020 }, - { PCI_VENDOR_QLOGIC, PCI_PRODUCT_QLOGIC_ISP1080 }, - { PCI_VENDOR_QLOGIC, PCI_PRODUCT_QLOGIC_ISP1240 }, - { PCI_VENDOR_QLOGIC, PCI_PRODUCT_QLOGIC_ISP1280 }, - { PCI_VENDOR_QLOGIC, PCI_PRODUCT_QLOGIC_ISP10160 }, - { PCI_VENDOR_QLOGIC, PCI_PRODUCT_QLOGIC_ISP12160 }, - { PCI_VENDOR_QLOGIC, PCI_PRODUCT_QLOGIC_ISP2100 }, - { PCI_VENDOR_QLOGIC, PCI_PRODUCT_QLOGIC_ISP2200 }, - { PCI_VENDOR_QLOGIC, PCI_PRODUCT_QLOGIC_ISP2300 }, - { PCI_VENDOR_QLOGIC, PCI_PRODUCT_QLOGIC_ISP2312 }, - { PCI_VENDOR_QLOGIC, PCI_PRODUCT_QLOGIC_ISP2322 }, - { PCI_VENDOR_QLOGIC, PCI_PRODUCT_QLOGIC_ISP6312 }, - { PCI_VENDOR_QLOGIC, PCI_PRODUCT_QLOGIC_ISP6322 }, - { 0, 0 } -}; - -int isp_pci_probe (struct device *, void *, void *); -void isp_pci_attach (struct device *, struct device *, void *); - -#define ISP_PCD(isp) ((struct isp_pcisoftc *)isp)->pci_dev -struct isp_pcisoftc { - struct ispsoftc pci_isp; - pci_chipset_tag_t pci_pc; - pcitag_t pci_tag; - bus_space_tag_t pci_st; - bus_space_handle_t pci_sh; - bus_dmamap_t *pci_xfer_dmap; - void * pci_ih; - int16_t pci_poff[_NREG_BLKS]; -}; - -struct cfattach isp_pci_ca = { - sizeof (struct isp_pcisoftc), isp_pci_probe, isp_pci_attach -}; - -int -isp_pci_probe(struct device *parent, void *match, void *aux) -{ - struct pci_attach_args *pa = aux; - -#ifndef ISP_DISABLE_12160_SUPPORT - /* - * Sigh. Check for subvendor id match here. Too bad we - * can't give an exclude mask in matchbyid. - */ - if (pa->pa_id == PCI_QLOGIC_ISP12160) { - pcireg_t subvid = - pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_SUBVEND_0); - if (PCI_VENDOR(subvid) == AMI_RAID_SUBVENDOR_ID) { - return (0); - } - } -#endif - return (pci_matchbyid(pa, ispdev, nitems(ispdev))); -} - - -void -isp_pci_attach(struct device *parent, struct device *self, void *aux) -{ -#ifdef DEBUG - static char oneshot = 1; -#endif - static const char nomem[] = ": no mem for sdparam table\n"; - u_int32_t data, rev, linesz = PCI_DFLT_LNSZ; - struct pci_attach_args *pa = aux; - struct isp_pcisoftc *pcs = (struct isp_pcisoftc *)self; - struct ispsoftc *isp = &pcs->pci_isp; - bus_space_tag_t st, iot, memt; - bus_space_handle_t sh, ioh, memh; - pci_intr_handle_t ih; - const char *intrstr; - int ioh_valid, memh_valid; - bus_size_t iosize, msize; - u_int32_t confopts = 0; -#ifdef __sparc64__ - int node, iid; - u_int64_t wwn; -#endif - - DEFAULT_IID(isp) = 7; -#ifdef __sparc64__ - /* - * Walk up the Open Firmware device tree until we find a - * "scsi-initiator-id" property. - */ - node = PCITAG_NODE(pa->pa_tag); - while (node) { - if (OF_getprop(node, "scsi-initiator-id", - &iid, sizeof(iid)) == sizeof(iid)) { - DEFAULT_IID(isp) = iid; - confopts |= ISP_CFG_OWNLOOPID; - break; - } - - node = OF_parent(node); - } - - node = PCITAG_NODE(pa->pa_tag); - if (OF_getprop(node, "node-wwn", &wwn, sizeof(wwn)) == sizeof(wwn)) { - DEFAULT_NODEWWN(isp) = wwn; - confopts |= ISP_CFG_OWNWWNN; - } - if (OF_getprop(node, "port-wwn", &wwn, sizeof(wwn)) == sizeof(wwn)) { - DEFAULT_PORTWWN(isp) = wwn; - confopts |= ISP_CFG_OWNWWPN; - } -#endif -#ifdef __sgi__ - /* - * The on-board isp controllers found on Octane, Origin 200 and - * Origin 300 families use id #0. - * XXX We'll need to be able to tell apart onboard isp from - * XXX other isp... - */ - if (sys_config.system_type == SGI_OCTANE || - sys_config.system_type == SGI_IP27 || - sys_config.system_type == SGI_IP35) - DEFAULT_IID(isp) = 0; -#endif - - ioh_valid = memh_valid = 0; - -#if SCSI_ISP_PREFER_MEM_MAP == 1 - if (pci_mapreg_map(pa, MEM_MAP_REG, PCI_MAPREG_TYPE_MEM, 0, - &memt, &memh, NULL, &msize, 0)) { - printf(": can't map mem space\n"); - } else { - st = memt; - sh = memh; - memh_valid = 1; - } - if (memh_valid == 0) { - if (pci_mapreg_map(pa, IO_MAP_REG, PCI_MAPREG_TYPE_IO, 0, - &iot, &ioh, NULL, &iosize, 0)) { - } else { - st = iot; - sh = ioh; - ioh_valid = 1; - } - } -#else - if (pci_mapreg_map(pa, IO_MAP_REG, PCI_MAPREG_TYPE_IO, 0, - &iot, &ioh, NULL, &iosize, 0)) { - printf(": can't map i/o space\n"); - } else { - st = iot; - sh = ioh; - ioh_valid = 1; - } - if (ioh_valid == 0) { - if (pci_mapreg_map(pa, MEM_MAP_REG, PCI_MAPREG_TYPE_MEM, 0, - &memt, &memh, NULL, &msize, 0)) { - printf(": can't map mem space\n"); - } else { - st = memt; - sh = memh; - memh_valid = 1; - } - } -#endif - if (ioh_valid == 0 && memh_valid == 0) { - printf(": unable to map device registers\n"); - return; - } -#if 0 - printf("\n"); -#endif - - pcs->pci_st = isp->isp_bus_tag = st; - pcs->pci_sh = isp->isp_bus_handle = sh; - pcs->pci_pc = pa->pa_pc; - pcs->pci_tag = pa->pa_tag; - pcs->pci_poff[BIU_BLOCK >> _BLK_REG_SHFT] = BIU_REGS_OFF; - pcs->pci_poff[MBOX_BLOCK >> _BLK_REG_SHFT] = PCI_MBOX_REGS_OFF; - pcs->pci_poff[SXP_BLOCK >> _BLK_REG_SHFT] = PCI_SXP_REGS_OFF; - pcs->pci_poff[RISC_BLOCK >> _BLK_REG_SHFT] = PCI_RISC_REGS_OFF; - pcs->pci_poff[DMA_BLOCK >> _BLK_REG_SHFT] = DMA_REGS_OFF; - rev = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_CLASS_REG) & 0xff; - if (pa->pa_id == PCI_QLOGIC_ISP1020) { - isp->isp_mdvec = &mdvec; - isp->isp_type = ISP_HA_SCSI_UNKNOWN; - isp->isp_param = malloc(sizeof(sdparam), M_DEVBUF, - M_NOWAIT | M_ZERO); - if (isp->isp_param == NULL) { - printf(nomem); - return; - } - } - if (pa->pa_id == PCI_QLOGIC_ISP1080) { - isp->isp_mdvec = &mdvec_1080; - isp->isp_type = ISP_HA_SCSI_1080; - isp->isp_param = malloc(sizeof(sdparam), M_DEVBUF, - M_NOWAIT | M_ZERO); - if (isp->isp_param == NULL) { - printf(nomem); - return; - } - pcs->pci_poff[DMA_BLOCK >> _BLK_REG_SHFT] = - ISP1080_DMA_REGS_OFF; - } - if (pa->pa_id == PCI_QLOGIC_ISP1240) { - isp->isp_mdvec = &mdvec_1080; - isp->isp_type = ISP_HA_SCSI_1240; - isp->isp_param = mallocarray(2, sizeof(sdparam), M_DEVBUF, - M_NOWAIT | M_ZERO); - if (isp->isp_param == NULL) { - printf(nomem); - return; - } - pcs->pci_poff[DMA_BLOCK >> _BLK_REG_SHFT] = - ISP1080_DMA_REGS_OFF; - } - if (pa->pa_id == PCI_QLOGIC_ISP1280) { - isp->isp_mdvec = &mdvec_1080; - isp->isp_type = ISP_HA_SCSI_1280; - isp->isp_param = mallocarray(2, sizeof(sdparam), - M_DEVBUF, M_NOWAIT | M_ZERO); - if (isp->isp_param == NULL) { - printf(nomem); - return; - } - pcs->pci_poff[DMA_BLOCK >> _BLK_REG_SHFT] = - ISP1080_DMA_REGS_OFF; - } - if (pa->pa_id == PCI_QLOGIC_ISP10160) { - isp->isp_mdvec = &mdvec_12160; - isp->isp_type = ISP_HA_SCSI_10160; - isp->isp_param = malloc(sizeof(sdparam), M_DEVBUF, - M_NOWAIT | M_ZERO); - if (isp->isp_param == NULL) { - printf(nomem); - return; - } - pcs->pci_poff[DMA_BLOCK >> _BLK_REG_SHFT] = - ISP1080_DMA_REGS_OFF; - } - if (pa->pa_id == PCI_QLOGIC_ISP12160) { - isp->isp_mdvec = &mdvec_12160; - isp->isp_type = ISP_HA_SCSI_12160; - isp->isp_param = mallocarray(2, sizeof(sdparam), - M_DEVBUF, M_NOWAIT | M_ZERO); - if (isp->isp_param == NULL) { - printf(nomem); - return; - } - pcs->pci_poff[DMA_BLOCK >> _BLK_REG_SHFT] = - ISP1080_DMA_REGS_OFF; - } - if (pa->pa_id == PCI_QLOGIC_ISP2100) { - isp->isp_mdvec = &mdvec_2100; - isp->isp_type = ISP_HA_FC_2100; - isp->isp_param = malloc(sizeof(fcparam), M_DEVBUF, - M_NOWAIT | M_ZERO); - if (isp->isp_param == NULL) { - printf(nomem); - return; - } - pcs->pci_poff[MBOX_BLOCK >> _BLK_REG_SHFT] = - PCI_MBOX_REGS2100_OFF; - if (rev < 3) { - /* - * XXX: Need to get the actual revision - * XXX: number of the 2100 FB. At any rate, - * XXX: lower cache line size for early revision - * XXX; boards. - */ - linesz = 1; - } - } - if (pa->pa_id == PCI_QLOGIC_ISP2200) { - isp->isp_mdvec = &mdvec_2200; - isp->isp_type = ISP_HA_FC_2200; - isp->isp_param = malloc(sizeof(fcparam), M_DEVBUF, - M_NOWAIT | M_ZERO); - if (isp->isp_param == NULL) { - printf(nomem); - return; - } - pcs->pci_poff[MBOX_BLOCK >> _BLK_REG_SHFT] = - PCI_MBOX_REGS2100_OFF; -#ifdef __sparc64__ - { - char name[32]; - - bzero(name, sizeof(name)); - OF_getprop(PCITAG_NODE(pa->pa_tag), - "name", name, sizeof(name)); - if (strcmp(name, "SUNW,qlc") == 0) - confopts |= ISP_CFG_NONVRAM; - } -#endif - } - if (pa->pa_id == PCI_QLOGIC_ISP2300) { - isp->isp_mdvec = &mdvec_2300; - isp->isp_type = ISP_HA_FC_2300; - isp->isp_param = malloc(sizeof(fcparam), M_DEVBUF, - M_NOWAIT | M_ZERO); - if (isp->isp_param == NULL) { - printf(nomem); - return; - } - pcs->pci_poff[DMA_BLOCK >> _BLK_REG_SHFT] = - PCI_MBOX_REGS2300_OFF; - } - if (pa->pa_id == PCI_QLOGIC_ISP2312 || - pa->pa_id == PCI_QLOGIC_ISP6312) { - isp->isp_mdvec = &mdvec_2300; - isp->isp_type = ISP_HA_FC_2312; - isp->isp_port = pa->pa_function; - isp->isp_param = malloc(sizeof(fcparam), M_DEVBUF, - M_NOWAIT | M_ZERO); - if (isp->isp_param == NULL) { - printf(nomem); - return; - } - pcs->pci_poff[MBOX_BLOCK >> _BLK_REG_SHFT] = - PCI_MBOX_REGS2300_OFF; - } - if (pa->pa_id == PCI_QLOGIC_ISP2322 || - pa->pa_id == PCI_QLOGIC_ISP6322) { - isp->isp_mdvec = &mdvec_2300; - isp->isp_type = ISP_HA_FC_2322; - isp->isp_port = pa->pa_function; - isp->isp_param = malloc(sizeof(fcparam), M_DEVBUF, - M_NOWAIT | M_ZERO); - if (isp->isp_param == NULL) { - printf(nomem); - return; - } - pcs->pci_poff[MBOX_BLOCK >> _BLK_REG_SHFT] = - PCI_MBOX_REGS2300_OFF; - } - /* - * Set up logging levels. - */ -#ifdef ISP_LOGDEFAULT - isp->isp_dblev = ISP_LOGDEFAULT; -#else - isp->isp_dblev = ISP_LOGWARN|ISP_LOGERR; -#if 0 - isp->isp_dblev |= ISP_LOGDEBUG1|ISP_LOGDEBUG2; -#endif -#ifdef DEBUG - isp->isp_dblev |= ISP_LOGDEBUG0|ISP_LOGCONFIG|ISP_LOGINFO; -#endif -#endif - -#ifdef DEBUG - if (oneshot) { - oneshot = 0; - isp_prt(isp, ISP_LOGCONFIG, vstring, - ISP_PLATFORM_VERSION_MAJOR, ISP_PLATFORM_VERSION_MINOR, - ISP_CORE_VERSION_MAJOR, ISP_CORE_VERSION_MINOR); - } -#endif - - isp->isp_dmatag = pa->pa_dmat; - isp->isp_revision = rev; - - /* - * Make sure that command register set sanely. - */ - data = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG); - if (IS_2300(isp)) { /* per QLogic errata */ - data &= ~PCI_COMMAND_PARITY_ENABLE; - } - if (IS_23XX(isp)) { - isp->isp_touched = 1; - } - data |= PCI_COMMAND_INVALIDATE_ENABLE; - - /* - * Not so sure about these- but I think it's important that they get - * enabled...... - */ - data |= PCI_COMMAND_PARITY_ENABLE | PCI_COMMAND_SERR_ENABLE; - pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG, data); - - /* - * Make sure that the latency timer, cache line size, - * and ROM is disabled. - */ - data = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_BHLC_REG); - data &= ~(PCI_LATTIMER_MASK << PCI_LATTIMER_SHIFT); - data &= ~(PCI_CACHELINE_MASK << PCI_CACHELINE_SHIFT); - data |= (0x40 << PCI_LATTIMER_SHIFT); - data |= (0x10 << PCI_CACHELINE_SHIFT); - pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_BHLC_REG, data); - - data = pci_conf_read(pa->pa_pc, pa->pa_tag, PCIR_ROMADDR); - data &= ~1; - pci_conf_write(pa->pa_pc, pa->pa_tag, PCIR_ROMADDR, data); - - if (pci_intr_map(pa, &ih)) { - printf(": couldn't map interrupt\n"); - free(isp->isp_param, M_DEVBUF, 0); - return; - } - intrstr = pci_intr_string(pa->pa_pc, ih); - if (intrstr == NULL) - intrstr = "<I dunno>"; - pcs->pci_ih = pci_intr_establish(pa->pa_pc, ih, IPL_BIO, isp_pci_intr, - isp, isp->isp_name); - if (pcs->pci_ih == NULL) { - printf(": couldn't establish interrupt at %s\n", - intrstr); - free(isp->isp_param, M_DEVBUF, 0); - return; - } - - printf(": %s\n", intrstr); - - if (IS_FC(isp)) { - if (DEFAULT_NODEWWN(isp) == 0) - DEFAULT_NODEWWN(isp) = 0x400000007F000003ULL; - if (DEFAULT_PORTWWN(isp) == 0) - DEFAULT_PORTWWN(isp) = 0x400000007F000003ULL; - } - - isp->isp_confopts = confopts | self->dv_cfdata->cf_flags; - isp->isp_role = ISP_DEFAULT_ROLES; - ISP_LOCK(isp); - isp->isp_osinfo.no_mbox_ints = 1; - isp_reset(isp); - if (isp->isp_state != ISP_RESETSTATE) { - ISP_UNLOCK(isp); - free(isp->isp_param, M_DEVBUF, 0); - return; - } - ISP_ENABLE_INTS(isp); - isp_init(isp); - if (isp->isp_state != ISP_INITSTATE) { - isp_uninit(isp); - ISP_UNLOCK(isp); - free(isp->isp_param, M_DEVBUF, 0); - return; - } - /* - * Do Generic attach now. - */ - isp_attach(isp); - if (isp->isp_state != ISP_RUNSTATE) { - isp_uninit(isp); - ISP_UNLOCK(isp); - free(isp->isp_param, M_DEVBUF, 0); - } else { - ISP_UNLOCK(isp); - } -} - -#define IspVirt2Off(a, x) \ - (((struct isp_pcisoftc *)a)->pci_poff[((x) & _BLK_REG_MASK) >> \ - _BLK_REG_SHFT] + ((x) & 0xfff)) - -#define BXR2(pcs, off) \ - bus_space_read_2(pcs->pci_st, pcs->pci_sh, off) -#define BXW2(pcs, off, v) \ - bus_space_write_2(pcs->pci_st, pcs->pci_sh, off, v) -#define BXR4(pcs, off) \ - bus_space_read_4(pcs->pci_st, pcs->pci_sh, off) -#define BXW4(pcs, off, v) \ - bus_space_write_4(pcs->pci_st, pcs->pci_sh, off, v) - -int -isp_pci_rd_debounced(struct ispsoftc *isp, int off, u_int16_t *rp) -{ - struct isp_pcisoftc *pcs = (struct isp_pcisoftc *)isp; - u_int32_t val0, val1; - int i = 0; - - do { - val0 = BXR2(pcs, IspVirt2Off(isp, off)); - val1 = BXR2(pcs, IspVirt2Off(isp, off)); - } while (val0 != val1 && ++i < 1000); - if (val0 != val1) { - return (1); - } - *rp = val0; - return (0); -} - -int -isp_pci_rd_isr(struct ispsoftc *isp, u_int32_t *isrp, - u_int16_t *semap, u_int16_t *mbp) -{ - struct isp_pcisoftc *pcs = (struct isp_pcisoftc *)isp; - u_int16_t isr, sema; - - if (IS_2100(isp)) { - if (isp_pci_rd_debounced(isp, BIU_ISR, &isr)) { - return (0); - } - if (isp_pci_rd_debounced(isp, BIU_SEMA, &sema)) { - return (0); - } - } else { - isr = BXR2(pcs, IspVirt2Off(isp, BIU_ISR)); - sema = BXR2(pcs, IspVirt2Off(isp, BIU_SEMA)); - } - isp_prt(isp, ISP_LOGDEBUG3, "ISR 0x%x SEMA 0x%x", isr, sema); - isr &= INT_PENDING_MASK(isp); - sema &= BIU_SEMA_LOCK; - if (isr == 0 && sema == 0) { - return (0); - } - *isrp = isr; - if ((*semap = sema) != 0) { - if (IS_2100(isp)) { - if (isp_pci_rd_debounced(isp, OUTMAILBOX0, mbp)) { - return (0); - } - } else { - *mbp = BXR2(pcs, IspVirt2Off(isp, OUTMAILBOX0)); - } - } - return (1); -} - -int -isp_pci_rd_isr_2300(struct ispsoftc *isp, u_int32_t *isrp, - u_int16_t *semap, u_int16_t *mbox0p) -{ - struct isp_pcisoftc *pcs = (struct isp_pcisoftc *)isp; - u_int32_t hccr; - u_int32_t r2hisr; - - if (!(BXR2(pcs, IspVirt2Off(isp, BIU_ISR)) & BIU2100_ISR_RISC_INT)) { - *isrp = 0; - return (0); - } - r2hisr = BXR4(pcs, IspVirt2Off(isp, BIU_R2HSTSLO)); - isp_prt(isp, ISP_LOGDEBUG3, "RISC2HOST ISR 0x%x", r2hisr); - if ((r2hisr & BIU_R2HST_INTR) == 0) { - *isrp = 0; - return (0); - } - switch (r2hisr & BIU_R2HST_ISTAT_MASK) { - case ISPR2HST_ROM_MBX_OK: - case ISPR2HST_ROM_MBX_FAIL: - case ISPR2HST_MBX_OK: - case ISPR2HST_MBX_FAIL: - case ISPR2HST_ASYNC_EVENT: - *isrp = r2hisr & 0xffff; - *mbox0p = (r2hisr >> 16); - *semap = 1; - return (1); - case ISPR2HST_RIO_16: - *isrp = r2hisr & 0xffff; - *mbox0p = ASYNC_RIO1; - *semap = 1; - return (1); - case ISPR2HST_FPOST: - *isrp = r2hisr & 0xffff; - *mbox0p = ASYNC_CMD_CMPLT; - *semap = 1; - return (1); - case ISPR2HST_FPOST_CTIO: - *isrp = r2hisr & 0xffff; - *mbox0p = ASYNC_CTIO_DONE; - *semap = 1; - return (1); - case ISPR2HST_RSPQ_UPDATE: - *isrp = r2hisr & 0xffff; - *mbox0p = 0; - *semap = 0; - return (1); - default: - hccr = ISP_READ(isp, HCCR); - if (hccr & HCCR_PAUSE) { - ISP_WRITE(isp, HCCR, HCCR_RESET); - isp_prt(isp, ISP_LOGERR, - "RISC paused at interrupt (%x->%x)", hccr, - ISP_READ(isp, HCCR)); - ISP_WRITE(isp, BIU_ICR, 0); - } else { - isp_prt(isp, ISP_LOGERR, "unknown interrupt 0x%x\n", - r2hisr); - } - return (0); - } -} - -u_int32_t -isp_pci_rd_reg(struct ispsoftc *isp, int regoff) -{ - u_int16_t rv; - struct isp_pcisoftc *pcs = (struct isp_pcisoftc *)isp; - int oldconf = 0; - - if ((regoff & _BLK_REG_MASK) == SXP_BLOCK) { - /* - * We will assume that someone has paused the RISC processor. - */ - oldconf = BXR2(pcs, IspVirt2Off(isp, BIU_CONF1)); - BXW2(pcs, IspVirt2Off(isp, BIU_CONF1), - oldconf | BIU_PCI_CONF1_SXP); - MEMORYBARRIER(isp, SYNC_REG, IspVirt2Off(isp, BIU_CONF1), 2); - } - rv = BXR2(pcs, IspVirt2Off(isp, regoff)); - if ((regoff & _BLK_REG_MASK) == SXP_BLOCK) { - BXW2(pcs, IspVirt2Off(isp, BIU_CONF1), oldconf); - } - MEMORYBARRIER(isp, SYNC_REG, IspVirt2Off(isp, BIU_CONF1), 2); - return (rv); -} - -void -isp_pci_wr_reg(struct ispsoftc *isp, int regoff, u_int32_t val) -{ - struct isp_pcisoftc *pcs = (struct isp_pcisoftc *)isp; - int oldconf = 0; - - if ((regoff & _BLK_REG_MASK) == SXP_BLOCK) { - /* - * We will assume that someone has paused the RISC processor. - */ - oldconf = BXR2(pcs, IspVirt2Off(isp, BIU_CONF1)); - BXW2(pcs, IspVirt2Off(isp, BIU_CONF1), - oldconf | BIU_PCI_CONF1_SXP); - MEMORYBARRIER(isp, SYNC_REG, IspVirt2Off(isp, BIU_CONF1), 2); - } - BXW2(pcs, IspVirt2Off(isp, regoff), val); - MEMORYBARRIER(isp, SYNC_REG, IspVirt2Off(isp, regoff), 2); - if ((regoff & _BLK_REG_MASK) == SXP_BLOCK) { - BXW2(pcs, IspVirt2Off(isp, BIU_CONF1), oldconf); - MEMORYBARRIER(isp, SYNC_REG, IspVirt2Off(isp, BIU_CONF1), 2); - } - -} - -u_int32_t -isp_pci_rd_reg_1080(struct ispsoftc *isp, int regoff) -{ - struct isp_pcisoftc *pcs = (struct isp_pcisoftc *)isp; - u_int32_t rv, oc = 0; - - if ((regoff & _BLK_REG_MASK) == SXP_BLOCK || - (regoff & _BLK_REG_MASK) == (SXP_BLOCK|SXP_BANK1_SELECT)) { - u_int32_t tc; - /* - * We will assume that someone has paused the RISC processor. - */ - oc = BXR2(pcs, IspVirt2Off(isp, BIU_CONF1)); - tc = oc & ~BIU_PCI1080_CONF1_DMA; - if (regoff & SXP_BANK1_SELECT) - tc |= BIU_PCI1080_CONF1_SXP1; - else - tc |= BIU_PCI1080_CONF1_SXP0; - BXW2(pcs, IspVirt2Off(isp, BIU_CONF1), tc); - MEMORYBARRIER(isp, SYNC_REG, IspVirt2Off(isp, BIU_CONF1), 2); - } else if ((regoff & _BLK_REG_MASK) == DMA_BLOCK) { - oc = BXR2(pcs, IspVirt2Off(isp, BIU_CONF1)); - BXW2(pcs, IspVirt2Off(isp, BIU_CONF1), - oc | BIU_PCI1080_CONF1_DMA); - MEMORYBARRIER(isp, SYNC_REG, IspVirt2Off(isp, BIU_CONF1), 2); - } - rv = BXR2(pcs, IspVirt2Off(isp, regoff)); - if (oc) { - BXW2(pcs, IspVirt2Off(isp, BIU_CONF1), oc); - MEMORYBARRIER(isp, SYNC_REG, IspVirt2Off(isp, BIU_CONF1), 2); - } - return (rv); -} - -void -isp_pci_wr_reg_1080(struct ispsoftc *isp, int regoff, u_int32_t val) -{ - struct isp_pcisoftc *pcs = (struct isp_pcisoftc *)isp; - int oc = 0; - - if ((regoff & _BLK_REG_MASK) == SXP_BLOCK || - (regoff & _BLK_REG_MASK) == (SXP_BLOCK|SXP_BANK1_SELECT)) { - u_int32_t tc; - /* - * We will assume that someone has paused the RISC processor. - */ - oc = BXR2(pcs, IspVirt2Off(isp, BIU_CONF1)); - tc = oc & ~BIU_PCI1080_CONF1_DMA; - if (regoff & SXP_BANK1_SELECT) - tc |= BIU_PCI1080_CONF1_SXP1; - else - tc |= BIU_PCI1080_CONF1_SXP0; - BXW2(pcs, IspVirt2Off(isp, BIU_CONF1), tc); - MEMORYBARRIER(isp, SYNC_REG, IspVirt2Off(isp, BIU_CONF1), 2); - } else if ((regoff & _BLK_REG_MASK) == DMA_BLOCK) { - oc = BXR2(pcs, IspVirt2Off(isp, BIU_CONF1)); - BXW2(pcs, IspVirt2Off(isp, BIU_CONF1), - oc | BIU_PCI1080_CONF1_DMA); - MEMORYBARRIER(isp, SYNC_REG, IspVirt2Off(isp, BIU_CONF1), 2); - } - BXW2(pcs, IspVirt2Off(isp, regoff), val); - MEMORYBARRIER(isp, SYNC_REG, IspVirt2Off(isp, regoff), 2); - if (oc) { - BXW2(pcs, IspVirt2Off(isp, BIU_CONF1), oc); - MEMORYBARRIER(isp, SYNC_REG, IspVirt2Off(isp, BIU_CONF1), 2); - } -} - -struct imush { - ispsoftc_t *isp; - int error; -}; - - -int -isp_pci_mbxdma(struct ispsoftc *isp) -{ - struct isp_pcisoftc *pcs = (struct isp_pcisoftc *)isp; - bus_dma_tag_t dmat = isp->isp_dmatag; - bus_dma_segment_t sg; - bus_addr_t addr; - bus_size_t len; - caddr_t base; - int rs, i; - - if (isp->isp_rquest_dma) /* been here before? */ - return (0); - - isp->isp_xflist = mallocarray(isp->isp_maxcmds, sizeof(XS_T *), - M_DEVBUF, M_NOWAIT | M_ZERO); - if (isp->isp_xflist == NULL) { - isp_prt(isp, ISP_LOGERR, "cannot malloc xflist array"); - return (1); - } - len = isp->isp_maxcmds * sizeof(XS_T *); - - pcs->pci_xfer_dmap = mallocarray(isp->isp_maxcmds, sizeof(bus_dmamap_t), - M_DEVBUF, M_NOWAIT); - if (pcs->pci_xfer_dmap == NULL) { - free(isp->isp_xflist, M_DEVBUF, 0); - isp->isp_xflist = NULL; - isp_prt(isp, ISP_LOGERR, "cannot malloc dma map array"); - return (1); - } - len = isp->isp_maxcmds * sizeof(bus_dmamap_t); - - for (i = 0; i < isp->isp_maxcmds; i++) { - if (bus_dmamap_create(dmat, MAXPHYS, (MAXPHYS / NBPG) + 1, - MAXPHYS, 0, BUS_DMA_NOWAIT, &pcs->pci_xfer_dmap[i])) { - isp_prt(isp, ISP_LOGERR, "cannot create dma maps"); - break; - } - } - - if (i < isp->isp_maxcmds) { - while (--i >= 0) { - bus_dmamap_destroy(dmat, pcs->pci_xfer_dmap[i]); - } - free(isp->isp_xflist, M_DEVBUF, 0); - free(pcs->pci_xfer_dmap, M_DEVBUF, 0); - isp->isp_xflist = NULL; - pcs->pci_xfer_dmap = NULL; - return (1); - } - - /* - * Allocate and map the request, result queues, plus FC scratch area. - */ - len = ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN(isp)); - len += ISP_QUEUE_SIZE(RESULT_QUEUE_LEN(isp)); - if (IS_FC(isp)) { - len += ISP2100_SCRLEN; - } - - if (bus_dmamem_alloc(dmat, len, PAGE_SIZE, 0, &sg, 1, &rs, - BUS_DMA_NOWAIT)) - goto dmafail; - - if (bus_dmamem_map(isp->isp_dmatag, &sg, rs, len, &base, - BUS_DMA_NOWAIT | BUS_DMA_COHERENT)) - goto dmafree; - - if (bus_dmamap_create(dmat, len, 1, len, 0, BUS_DMA_NOWAIT, - &isp->isp_cdmap)) - goto dmaunmap; - - if (bus_dmamap_load(dmat, isp->isp_cdmap, base, len, NULL, - BUS_DMA_NOWAIT)) - goto dmadestroy; - - addr = isp->isp_cdmap->dm_segs[0].ds_addr; - isp->isp_rquest_dma = addr; - addr += ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN(isp)); - isp->isp_result_dma = addr; - - if (IS_FC(isp)) { - addr += ISP_QUEUE_SIZE(RESULT_QUEUE_LEN(isp)); - FCPARAM(isp)->isp_scdma = addr; - - } - - isp->isp_rquest = base; - base += ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN(isp)); - isp->isp_result = base; - if (IS_FC(isp)) { - base += ISP_QUEUE_SIZE(RESULT_QUEUE_LEN(isp)); - FCPARAM(isp)->isp_scratch = base; - } - return (0); - -dmadestroy: - bus_dmamap_destroy(dmat, isp->isp_cdmap); -dmaunmap: - bus_dmamem_unmap(dmat, base, len); -dmafree: - bus_dmamem_free(dmat, &sg, rs); -dmafail: - isp_prt(isp, ISP_LOGERR, "mailbox dma setup failure"); - for (i = 0; i < isp->isp_maxcmds; i++) { - bus_dmamap_destroy(dmat, pcs->pci_xfer_dmap[i]); - } - free(isp->isp_xflist, M_DEVBUF, 0); - free(pcs->pci_xfer_dmap, M_DEVBUF, 0); - isp->isp_xflist = NULL; - pcs->pci_xfer_dmap = NULL; - return (1); -} - -int -isp_pci_dmasetup(struct ispsoftc *isp, XS_T *xs, ispreq_t *rq, - u_int32_t *nxtip, u_int32_t optr) -{ - struct isp_pcisoftc *pcs = (struct isp_pcisoftc *)isp; - bus_dmamap_t dmap; - u_int16_t nxti = *nxtip; - ispreq_t *qep; - int segcnt, seg, error, ovseg, seglim, drq; - - qep = (ispreq_t *) ISP_QUEUE_ENTRY(isp->isp_rquest, isp->isp_reqidx); - dmap = pcs->pci_xfer_dmap[isp_handle_index(rq->req_handle)]; - if (xs->datalen == 0) { - rq->req_seg_count = 1; - goto mbxsync; - } - - if (xs->flags & SCSI_DATA_IN) { - drq = REQFLAG_DATA_IN; - } else { - drq = REQFLAG_DATA_OUT; - } - - if (IS_FC(isp)) { - seglim = ISP_RQDSEG_T2; - ((ispreqt2_t *)rq)->req_totalcnt = xs->datalen; - ((ispreqt2_t *)rq)->req_flags |= drq; - } else { - rq->req_flags |= drq; - if (XS_CDBLEN(xs) > 12) - seglim = 0; - else - seglim = ISP_RQDSEG; - } - error = bus_dmamap_load(isp->isp_dmatag, dmap, xs->data, xs->datalen, - NULL, (xs->flags & SCSI_NOSLEEP) ? BUS_DMA_NOWAIT : BUS_DMA_WAITOK); - if (error) { - XS_SETERR(xs, HBA_BOTCH); - return (CMD_COMPLETE); - } - - segcnt = dmap->dm_nsegs; - - isp_prt(isp, ISP_LOGDEBUG2, "%d byte %s %p in %d segs", - xs->datalen, (xs->flags & SCSI_DATA_IN)? "read to" : - "write from", xs->data, segcnt); - - for (seg = 0, rq->req_seg_count = 0; - seg < segcnt && rq->req_seg_count < seglim; - seg++, rq->req_seg_count++) { - if (isp->isp_type & ISP_HA_FC) { - ispreqt2_t *rq2 = (ispreqt2_t *)rq; - rq2->req_dataseg[rq2->req_seg_count].ds_count = - dmap->dm_segs[seg].ds_len; - rq2->req_dataseg[rq2->req_seg_count].ds_base = - dmap->dm_segs[seg].ds_addr; - } else { - rq->req_dataseg[rq->req_seg_count].ds_count = - dmap->dm_segs[seg].ds_len; - rq->req_dataseg[rq->req_seg_count].ds_base = - dmap->dm_segs[seg].ds_addr; - } - isp_prt(isp, ISP_LOGDEBUG2, "seg0.[%d]={0x%lx,%lu}", - rq->req_seg_count, (long) dmap->dm_segs[seg].ds_addr, - (unsigned long) dmap->dm_segs[seg].ds_len); - } - - if (seg == segcnt) { - goto dmasync; - } - - do { - u_int16_t onxti; - ispcontreq_t *crq, *cqe, local; - - crq = &local; - - cqe = (ispcontreq_t *) ISP_QUEUE_ENTRY(isp->isp_rquest, nxti); - onxti = nxti; - nxti = ISP_NXT_QENTRY(onxti, RQUEST_QUEUE_LEN(isp)); - if (nxti == optr) { - isp_prt(isp, ISP_LOGDEBUG0, "Request Queue Overflow++"); - bus_dmamap_unload(isp->isp_dmatag, dmap); - XS_SETERR(xs, HBA_BOTCH); - return (CMD_EAGAIN); - } - rq->req_header.rqs_entry_count++; - bzero((void *)crq, sizeof (*crq)); - crq->req_header.rqs_entry_count = 1; - crq->req_header.rqs_entry_type = RQSTYPE_DATASEG; - - for (ovseg = 0; seg < segcnt && ovseg < ISP_CDSEG; - rq->req_seg_count++, seg++, ovseg++) { - crq->req_dataseg[ovseg].ds_count = - dmap->dm_segs[seg].ds_len; - crq->req_dataseg[ovseg].ds_base = - dmap->dm_segs[seg].ds_addr; - isp_prt(isp, ISP_LOGDEBUG2, "seg%d.[%d]={0x%lx,%lu}", - rq->req_header.rqs_entry_count - 1, - rq->req_seg_count, (long)dmap->dm_segs[seg].ds_addr, - (unsigned long) dmap->dm_segs[seg].ds_len); - } - isp_put_cont_req(isp, crq, cqe); - MEMORYBARRIER(isp, SYNC_REQUEST, onxti, QENTRY_LEN); - } while (seg < segcnt); - -dmasync: - bus_dmamap_sync(isp->isp_dmatag, dmap, 0, dmap->dm_mapsize, - (xs->flags & SCSI_DATA_IN) ? BUS_DMASYNC_PREREAD : - BUS_DMASYNC_PREWRITE); - -mbxsync: - switch (rq->req_header.rqs_entry_type) { - case RQSTYPE_REQUEST: - isp_put_request(isp, rq, qep); - break; - case RQSTYPE_CMDONLY: - isp_put_extended_request(isp, (ispextreq_t *)rq, - (ispextreq_t *)qep); - break; - case RQSTYPE_T2RQS: - if (FCPARAM(isp)->isp_2klogin) { - isp_put_request_t2e(isp, - (ispreqt2e_t *) rq, (ispreqt2e_t *) qep); - } else { - isp_put_request_t2(isp, - (ispreqt2_t *) rq, (ispreqt2_t *) qep); - } - break; - case RQSTYPE_T3RQS: - if (FCPARAM(isp)->isp_2klogin) { - isp_put_request_t3e(isp, - (ispreqt3e_t *) rq, (ispreqt3e_t *) qep); - break; - } - /* FALLTHROUGH */ - case RQSTYPE_A64: - isp_put_request_t3(isp, (ispreqt3_t *) rq, (ispreqt3_t *) qep); - break; - } - *nxtip = nxti; - return (CMD_QUEUED); -} - -int -isp_pci_intr(void *arg) -{ - u_int32_t isr; - u_int16_t sema, mbox; - struct ispsoftc *isp = (struct ispsoftc *)arg; - - isp->isp_intcnt++; - if (ISP_READ_ISR(isp, &isr, &sema, &mbox) == 0) { - isp->isp_intbogus++; - return (0); - } else { - isp->isp_osinfo.onintstack = 1; - isp_intr(isp, isr, sema, mbox); - isp->isp_osinfo.onintstack = 0; - return (1); - } -} - -void -isp_pci_dmateardown(struct ispsoftc *isp, XS_T *xs, u_int32_t handle) -{ - struct isp_pcisoftc *pcs = (struct isp_pcisoftc *)isp; - bus_dmamap_t dmap = pcs->pci_xfer_dmap[isp_handle_index(handle)]; - bus_dmamap_sync(isp->isp_dmatag, dmap, 0, dmap->dm_mapsize, - (xs->flags & SCSI_DATA_IN)? - BUS_DMASYNC_POSTREAD : BUS_DMASYNC_POSTWRITE); - bus_dmamap_unload(isp->isp_dmatag, dmap); -} - -void -isp_pci_reset0(ispsoftc_t *isp) -{ - ISP_DISABLE_INTS(isp); -} - -void -isp_pci_reset1(struct ispsoftc *isp) -{ - /* Make sure the BIOS is disabled */ - isp_pci_wr_reg(isp, HCCR, PCI_HCCR_CMD_BIOS); - /* and enable interrupts */ - ISP_ENABLE_INTS(isp); -} - -void -isp_pci_dumpregs(struct ispsoftc *isp, const char *msg) -{ - struct isp_pcisoftc *pcs = (struct isp_pcisoftc *)isp; - if (msg) - isp_prt(isp, ISP_LOGERR, "%s", msg); - if (IS_SCSI(isp)) - isp_prt(isp, ISP_LOGERR, " biu_conf1=%x", - ISP_READ(isp, BIU_CONF1)); - else - isp_prt(isp, ISP_LOGERR, " biu_csr=%x", - ISP_READ(isp, BIU2100_CSR)); - isp_prt(isp, ISP_LOGERR, " biu_icr=%x biu_isr=%x biu_sema=%x ", - ISP_READ(isp, BIU_ICR), ISP_READ(isp, BIU_ISR), - ISP_READ(isp, BIU_SEMA)); - isp_prt(isp, ISP_LOGERR, "risc_hccr=%x\n", ISP_READ(isp, HCCR)); - isp_prt(isp, ISP_LOGERR, "PCI Status Command/Status=%x\n", - pci_conf_read(pcs->pci_pc, pcs->pci_tag, PCI_COMMAND_STATUS_REG)); -} diff --git a/sys/dev/sbus/files.sbus b/sys/dev/sbus/files.sbus index 614a1840bcf..c73aa8b292d 100644 --- a/sys/dev/sbus/files.sbus +++ b/sys/dev/sbus/files.sbus @@ -1,4 +1,4 @@ -# $OpenBSD: files.sbus,v 1.42 2015/05/11 06:46:22 ratchov Exp $ +# $OpenBSD: files.sbus,v 1.43 2015/06/19 11:12:24 jmatthew Exp $ # $NetBSD: files.sbus,v 1.16 2000/12/08 17:29:12 martin Exp $ # # Config file and device description for machine-independent SBUS code. @@ -55,9 +55,6 @@ device audiocs: audio attach audiocs at sbus file dev/sbus/cs4231.c audiocs -attach isp at sbus with isp_sbus -file dev/sbus/isp_sbus.c isp_sbus - attach qlw at sbus with qlw_sbus file dev/sbus/qlw_sbus.c qlw_sbus diff --git a/sys/dev/sbus/isp_sbus.c b/sys/dev/sbus/isp_sbus.c deleted file mode 100644 index 45d380baa23..00000000000 --- a/sys/dev/sbus/isp_sbus.c +++ /dev/null @@ -1,724 +0,0 @@ -/* $OpenBSD: isp_sbus.c,v 1.21 2014/07/12 18:48:52 tedu Exp $ */ -/* $NetBSD: isp_sbus.c,v 1.46 2001/09/26 20:53:14 eeh Exp $ */ -/* - * SBus specific probe and attach routines for QLogic ISP SCSI adapters. - * - * Copyright (c) 1997, 2001 by Matthew Jacob - * NASA AMES Research Center - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice immediately at the beginning of the file, without modification, - * this list of conditions, and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * 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. - * - */ - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/device.h> -#include <sys/kernel.h> -#include <sys/malloc.h> -#include <sys/queue.h> - -#include <machine/bus.h> -#include <machine/intr.h> -#include <machine/autoconf.h> - -#include <dev/ic/isp_openbsd.h> - -#ifndef ISP_NOFIRMWARE -#define ISP_FIRMWARE_1000 -#define ISP_FIRMWARE_2200 -#endif - -#if defined(ISP_FIRMWARE_1000) -#include <dev/microcode/isp/asm_sbus.h> -#else -#define ISP_1000_RISC_CODE NULL -#endif - -#if defined(ISP_FIRMWARE_2200) -extern const u_int16_t isp_2200_risc_code[]; -#define ISP_2200_RISC_CODE (u_int16_t *) isp_2200_risc_code -#else -#define ISP_2200_RISC_CODE NULL -#endif - -#include <dev/sbus/sbusvar.h> - -static int isp_sbus_intr(void *); -static int -isp_sbus_rd_isr(struct ispsoftc *, u_int32_t *, u_int16_t *, u_int16_t *); -static int -isp_sbus_rd_isr_2200(struct ispsoftc *, u_int32_t *, u_int16_t *, u_int16_t *); -static u_int32_t isp_sbus_rd_reg(struct ispsoftc *, int); -static void isp_sbus_wr_reg (struct ispsoftc *, int, u_int32_t); -static u_int32_t isp_sbus_rd_reg_2200(struct ispsoftc *, int); -static void isp_sbus_wr_reg_2200(struct ispsoftc *, int, u_int32_t); -static int isp_sbus_mbxdma(struct ispsoftc *); -static int isp_sbus_dmasetup(struct ispsoftc *, XS_T *, ispreq_t *, u_int32_t *, - u_int32_t); -static void isp_sbus_dmateardown(struct ispsoftc *, XS_T *, u_int32_t); - -static struct ispmdvec mdvec = { - isp_sbus_rd_isr, - isp_sbus_rd_reg, - isp_sbus_wr_reg, - isp_sbus_mbxdma, - isp_sbus_dmasetup, - isp_sbus_dmateardown, - NULL, - NULL, - NULL, - ISP_1000_RISC_CODE -}; - -static struct ispmdvec mdvec_2200 = { - isp_sbus_rd_isr_2200, - isp_sbus_rd_reg_2200, - isp_sbus_wr_reg_2200, - isp_sbus_mbxdma, - isp_sbus_dmasetup, - isp_sbus_dmateardown, - NULL, - NULL, - NULL, - ISP_2200_RISC_CODE -}; - -struct isp_sbussoftc { - struct ispsoftc sbus_isp; - sdparam sbus_dev; - bus_space_tag_t sbus_bustag; - bus_space_handle_t sbus_reg; - int sbus_node; - int sbus_pri; - struct ispmdvec sbus_mdvec; - bus_dmamap_t *sbus_dmamap; - int16_t sbus_poff[_NREG_BLKS]; -}; - - -static int isp_match(struct device *, void *, void *); -static void isp_sbus_attach(struct device *, struct device *, void *); -struct cfattach isp_sbus_ca = { - sizeof (struct isp_sbussoftc), isp_match, isp_sbus_attach -}; - -static int -isp_match(struct device *parent, void *vcf, void *aux) -{ - struct cfdata *cf = vcf; - int rv; -#ifdef DEBUG - static int oneshot = 1; -#endif - struct sbus_attach_args *sa = aux; - - rv = (strcmp(cf->cf_driver->cd_name, sa->sa_name) == 0 || - strcmp("PTI,ptisp", sa->sa_name) == 0 || - strcmp("ptisp", sa->sa_name) == 0 || - strcmp("SUNW,isp", sa->sa_name) == 0 || - strcmp("SUNW,qlc", sa->sa_name) == 0 || - strcmp("QLGC,isp", sa->sa_name) == 0 || - strcmp("QLGC,qla", sa->sa_name) == 0); -#ifdef DEBUG - if (rv && oneshot) { - oneshot = 0; - printf("QLogic ISP Driver, OpenBSD (sbus) Platform Version " - "%d.%d Core Version %d.%d\n", - ISP_PLATFORM_VERSION_MAJOR, ISP_PLATFORM_VERSION_MINOR, - ISP_CORE_VERSION_MAJOR, ISP_CORE_VERSION_MINOR); - } -#endif - return (rv); -} - - -static void -isp_sbus_attach(struct device *parent, struct device *self, void *aux) -{ - int freq, ispburst, sbusburst; - struct sbus_attach_args *sa = aux; - struct isp_sbussoftc *sbc = (struct isp_sbussoftc *) self; - struct ispsoftc *isp = &sbc->sbus_isp; - - printf(": %s\n", sa->sa_name); - - sbc->sbus_bustag = sa->sa_bustag; - if (sa->sa_nintr != 0) - sbc->sbus_pri = sa->sa_pri; - sbc->sbus_mdvec = mdvec; - - if (sa->sa_npromvaddrs != 0) { - if (bus_space_map(sa->sa_bustag, sa->sa_promvaddrs[0], - sa->sa_size, - BUS_SPACE_MAP_PROMADDRESS | BUS_SPACE_MAP_LINEAR, - &sbc->sbus_reg) == 0) { - printf("%s: cannot map registers\n", self->dv_xname); - return; - } - } else { - if (sbus_bus_map(sa->sa_bustag, sa->sa_slot, sa->sa_offset, - sa->sa_size, BUS_SPACE_MAP_LINEAR, 0, - &sbc->sbus_reg) != 0) { - printf("%s: cannot map registers\n", self->dv_xname); - return; - } - } - sbc->sbus_node = sa->sa_node; - - freq = getpropint(sa->sa_node, "clock-frequency", 0); - if (freq) { - /* - * Convert from HZ to MHz, rounding up. - */ - freq = (freq + 500000)/1000000; -#if 0 - printf("%s: %d MHz\n", self->dv_xname, freq); -#endif - } - sbc->sbus_mdvec.dv_clock = freq; - - DEFAULT_IID(isp) = getpropint(sa->sa_node, "scsi-initiator-id", 7); - - /* - * Now figure out what the proper burst sizes, etc., to use. - * Unfortunately, there is no ddi_dma_burstsizes here which - * walks up the tree finding the limiting burst size node (if - * any). - */ - sbusburst = ((struct sbus_softc *)parent)->sc_burst; - if (sbusburst == 0) - sbusburst = SBUS_BURST_32 - 1; - ispburst = getpropint(sa->sa_node, "burst-sizes", -1); - if (ispburst == -1) { - ispburst = sbusburst; - } - ispburst &= sbusburst; - ispburst &= ~(1 << 7); - ispburst &= ~(1 << 6); - sbc->sbus_mdvec.dv_conf1 = 0; - if (ispburst & (1 << 5)) { - sbc->sbus_mdvec.dv_conf1 = BIU_SBUS_CONF1_FIFO_32; - } else if (ispburst & (1 << 4)) { - sbc->sbus_mdvec.dv_conf1 = BIU_SBUS_CONF1_FIFO_16; - } else if (ispburst & (1 << 3)) { - sbc->sbus_mdvec.dv_conf1 = - BIU_SBUS_CONF1_BURST8 | BIU_SBUS_CONF1_FIFO_8; - } - if (sbc->sbus_mdvec.dv_conf1) { - sbc->sbus_mdvec.dv_conf1 |= BIU_BURST_ENABLE; - } - - /* - * Some early versions of the PTI SBus adapter - * would fail in trying to download (via poking) - * FW. We give up on them. - */ - if (strcmp("PTI,ptisp", sa->sa_name) == 0 || - strcmp("ptisp", sa->sa_name) == 0) { - sbc->sbus_mdvec.dv_ispfw = NULL; - } - - isp->isp_mdvec = &sbc->sbus_mdvec; - isp->isp_bustype = ISP_BT_SBUS; - isp->isp_type = ISP_HA_SCSI_UNKNOWN; - isp->isp_param = &sbc->sbus_dev; - isp->isp_dmatag = sa->sa_dmatag; - MEMZERO(isp->isp_param, sizeof (sdparam)); - - sbc->sbus_poff[BIU_BLOCK >> _BLK_REG_SHFT] = BIU_REGS_OFF; - sbc->sbus_poff[MBOX_BLOCK >> _BLK_REG_SHFT] = SBUS_MBOX_REGS_OFF; - sbc->sbus_poff[SXP_BLOCK >> _BLK_REG_SHFT] = SBUS_SXP_REGS_OFF; - sbc->sbus_poff[RISC_BLOCK >> _BLK_REG_SHFT] = SBUS_RISC_REGS_OFF; - sbc->sbus_poff[DMA_BLOCK >> _BLK_REG_SHFT] = DMA_REGS_OFF; - - if (strcmp("SUNW,qlc", sa->sa_name) == 0 || - strcmp("QLGC,qla", sa->sa_name) == 0) { - isp->isp_mdvec = &mdvec_2200; - isp->isp_bustype = ISP_BT_PCI; - isp->isp_type = ISP_HA_FC_2200; - isp->isp_param = malloc(sizeof(fcparam), M_DEVBUF, - M_NOWAIT | M_ZERO); - if (isp->isp_param == NULL) { - printf("%s: no mem for sdparam table\n", - self->dv_xname); - return; - } - sbc->sbus_poff[BIU_BLOCK >> _BLK_REG_SHFT] = - 0x100 + BIU_REGS_OFF; - sbc->sbus_poff[MBOX_BLOCK >> _BLK_REG_SHFT] = - 0x100 + PCI_MBOX_REGS2100_OFF; - sbc->sbus_poff[SXP_BLOCK >> _BLK_REG_SHFT] = - 0x100 + PCI_SXP_REGS_OFF; - sbc->sbus_poff[RISC_BLOCK >> _BLK_REG_SHFT] = - 0x100 + PCI_RISC_REGS_OFF; - sbc->sbus_poff[DMA_BLOCK >> _BLK_REG_SHFT] = - 0x100 + DMA_REGS_OFF; - } - - /* Establish interrupt channel */ - bus_intr_establish(sbc->sbus_bustag, sbc->sbus_pri, IPL_BIO, 0, - isp_sbus_intr, sbc, self->dv_xname); - - /* - * Set up logging levels. - */ -#ifdef ISP_LOGDEFAULT - isp->isp_dblev = ISP_LOGDEFAULT; -#else - isp->isp_dblev = ISP_LOGWARN|ISP_LOGERR; -#if 0 - isp->isp_dblev |= ISP_LOGDEBUG1|ISP_LOGDEBUG2; -#endif -#ifdef DEBUG - isp->isp_dblev |= ISP_LOGDEBUG0|ISP_LOGCONFIG|ISP_LOGINFO; -#endif -#endif - - isp->isp_confopts = self->dv_cfdata->cf_flags; - isp->isp_role = ISP_DEFAULT_ROLES; - - /* - * There's no tool on sparc to set NVRAM for ISPs, so ignore - * it if we don't need to read WWNs from it. - */ - if (IS_SCSI(isp)) - isp->isp_confopts |= ISP_CFG_NONVRAM; - - ISP_LOCK(isp); - isp->isp_osinfo.no_mbox_ints = 1; - isp_reset(isp); - if (isp->isp_state != ISP_RESETSTATE) { - ISP_UNLOCK(isp); - return; - } - ISP_ENABLE_INTS(isp); - isp_init(isp); - if (isp->isp_state != ISP_INITSTATE) { - isp_uninit(isp); - ISP_UNLOCK(isp); - return; - } - - /* - * do generic attach. - */ - ISP_UNLOCK(isp); - isp_attach(isp); - if (isp->isp_state != ISP_RUNSTATE) { - ISP_LOCK(isp); - isp_uninit(isp); - ISP_UNLOCK(isp); - } -} - -static int -isp_sbus_intr(void *arg) -{ - u_int32_t isr; - u_int16_t sema, mbox; - struct ispsoftc *isp = arg; - - isp->isp_intcnt++; - if (ISP_READ_ISR(isp, &isr, &sema, &mbox) == 0) { - isp->isp_intbogus++; - return (0); - } else { - isp->isp_osinfo.onintstack = 1; - isp_intr(isp, isr, sema, mbox); - isp->isp_osinfo.onintstack = 0; - return (1); - } -} - -#define IspVirt2Off(a, x) \ - (((struct isp_sbussoftc *)a)->sbus_poff[((x) & _BLK_REG_MASK) >> \ - _BLK_REG_SHFT] + ((x) & 0xff)) - -#define BXR2(sbc, off) \ - bus_space_read_2(sbc->sbus_bustag, sbc->sbus_reg, off) - -static int -isp_sbus_rd_isr(struct ispsoftc *isp, u_int32_t *isrp, - u_int16_t *semap, u_int16_t *mbp) -{ - struct isp_sbussoftc *sbc = (struct isp_sbussoftc *) isp; - u_int16_t isr, sema; - - isr = BXR2(sbc, IspVirt2Off(isp, BIU_ISR)); - sema = BXR2(sbc, IspVirt2Off(isp, BIU_SEMA)); - isp_prt(isp, ISP_LOGDEBUG3, "ISR 0x%x SEMA 0x%x", isr, sema); - isr &= INT_PENDING_MASK(isp); - sema &= BIU_SEMA_LOCK; - if (isr == 0 && sema == 0) { - return (0); - } - *isrp = isr; - if ((*semap = sema) != 0) { - *mbp = BXR2(sbc, IspVirt2Off(isp, OUTMAILBOX0)); - } - return (1); -} - -static int -isp_sbus_rd_isr_2200(struct ispsoftc *isp, u_int32_t *isrp, - u_int16_t *semap, u_int16_t *mbp) -{ - struct isp_sbussoftc *sbc = (struct isp_sbussoftc *) isp; - u_int16_t isr, sema; - - isr = letoh16(BXR2(sbc, IspVirt2Off(isp, BIU_ISR))); - sema = letoh16(BXR2(sbc, IspVirt2Off(isp, BIU_SEMA))); - isp_prt(isp, ISP_LOGDEBUG3, "ISR 0x%x SEMA 0x%x", isr, sema); - isr &= INT_PENDING_MASK(isp); - sema &= BIU_SEMA_LOCK; - if (isr == 0 && sema == 0) { - return (0); - } - *isrp = isr; - if ((*semap = sema) != 0) { - *mbp = letoh16(BXR2(sbc, IspVirt2Off(isp, OUTMAILBOX0))); - } - return (1); -} - -static u_int32_t -isp_sbus_rd_reg(struct ispsoftc *isp, int regoff) -{ - struct isp_sbussoftc *sbc = (struct isp_sbussoftc *) isp; - int offset = sbc->sbus_poff[(regoff & _BLK_REG_MASK) >> _BLK_REG_SHFT]; - offset += (regoff & 0xff); - return (bus_space_read_2(sbc->sbus_bustag, sbc->sbus_reg, offset)); -} - -static void -isp_sbus_wr_reg(struct ispsoftc *isp, int regoff, u_int32_t val) -{ - struct isp_sbussoftc *sbc = (struct isp_sbussoftc *) isp; - int offset = sbc->sbus_poff[(regoff & _BLK_REG_MASK) >> _BLK_REG_SHFT]; - offset += (regoff & 0xff); - bus_space_write_2(sbc->sbus_bustag, sbc->sbus_reg, offset, val); -} - -static u_int32_t -isp_sbus_rd_reg_2200(struct ispsoftc *isp, int regoff) -{ - struct isp_sbussoftc *sbc = (struct isp_sbussoftc *) isp; - int offset = sbc->sbus_poff[(regoff & _BLK_REG_MASK) >> _BLK_REG_SHFT]; - offset += (regoff & 0xff); - return (letoh16(bus_space_read_2(sbc->sbus_bustag, sbc->sbus_reg, offset))); -} - -static void -isp_sbus_wr_reg_2200(struct ispsoftc *isp, int regoff, u_int32_t val) -{ - struct isp_sbussoftc *sbc = (struct isp_sbussoftc *) isp; - int offset = sbc->sbus_poff[(regoff & _BLK_REG_MASK) >> _BLK_REG_SHFT]; - offset += (regoff & 0xff); - bus_space_write_2(sbc->sbus_bustag, sbc->sbus_reg, offset, htole16(val)); -} - -static int -isp_sbus_mbxdma(struct ispsoftc *isp) -{ - struct isp_sbussoftc *sbc = (struct isp_sbussoftc *) isp; - bus_dma_segment_t seg; - bus_addr_t addr; - bus_size_t len; - caddr_t base; - size_t n; - int rs, i, progress; - - if (isp->isp_rquest_dma) - return (0); - - n = isp->isp_maxcmds * sizeof (XS_T *); - isp->isp_xflist = (XS_T **) malloc(n, M_DEVBUF, M_WAITOK | M_ZERO); - if (isp->isp_xflist == NULL) { - isp_prt(isp, ISP_LOGERR, "cannot alloc xflist array"); - return (1); - } - - n = sizeof (bus_dmamap_t) * isp->isp_maxcmds; - sbc->sbus_dmamap = (bus_dmamap_t *) malloc(n, M_DEVBUF, M_WAITOK); - if (sbc->sbus_dmamap == NULL) { - free(isp->isp_xflist, M_DEVBUF, 0); - isp->isp_xflist = NULL; - isp_prt(isp, ISP_LOGERR, "cannot alloc dmamap array"); - return (1); - } - for (i = 0; i < isp->isp_maxcmds; i++) { - /* Allocate a DMA handle */ - if (bus_dmamap_create(isp->isp_dmatag, MAXPHYS, 1, MAXPHYS, 0, - BUS_DMA_NOWAIT, &sbc->sbus_dmamap[i]) != 0) { - isp_prt(isp, ISP_LOGERR, "cmd DMA maps create error"); - break; - } - } - if (i < isp->isp_maxcmds) { - while (--i >= 0) { - bus_dmamap_destroy(isp->isp_dmatag, - sbc->sbus_dmamap[i]); - } - free(isp->isp_xflist, M_DEVBUF, 0); - free(sbc->sbus_dmamap, M_DEVBUF, 0); - isp->isp_xflist = NULL; - sbc->sbus_dmamap = NULL; - return (1); - } - - /* - * Allocate and map the request, result queues, plus FC scratch area. - */ - progress = 0; - len = ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN(isp)); - len += ISP_QUEUE_SIZE(RESULT_QUEUE_LEN(isp)); - if (IS_FC(isp)) { - len += ISP2100_SCRLEN; - } - if (bus_dmamem_alloc(isp->isp_dmatag, len, 0, 0, &seg, 1, &rs, - BUS_DMA_NOWAIT)) { - goto dmafail; - } - progress++; - if (bus_dmamem_map(isp->isp_dmatag, &seg, rs, len, - &base, BUS_DMA_NOWAIT|BUS_DMA_COHERENT)) { - goto dmafail; - } - progress++; - if (bus_dmamap_create(isp->isp_dmatag, len, 1, len, 0, BUS_DMA_NOWAIT, - &isp->isp_cdmap) != 0) { - goto dmafail; - } - progress++; - if (bus_dmamap_load(isp->isp_dmatag, isp->isp_cdmap, - base, len, NULL, BUS_DMA_NOWAIT) != 0) { - goto dmafail; - } - progress++; - addr = isp->isp_cdmap->dm_segs[0].ds_addr; - isp->isp_rquest_dma = addr; - addr += ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN(isp)); - isp->isp_result_dma = addr; - - if (IS_FC(isp)) { - addr += ISP_QUEUE_SIZE(RESULT_QUEUE_LEN(isp)); - FCPARAM(isp)->isp_scdma = addr; - - } - - isp->isp_rquest = base; - base += ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN(isp)); - isp->isp_result = base; - if (IS_FC(isp)) { - base += ISP_QUEUE_SIZE(RESULT_QUEUE_LEN(isp)); - FCPARAM(isp)->isp_scratch = base; - } - return (0); - -dmafail: - isp_prt(isp, ISP_LOGERR, "Mailbox DMA Setup Failure"); - - if (progress >= 4) { - bus_dmamap_unload(isp->isp_dmatag, isp->isp_cdmap); - } - if (progress >= 3) { - bus_dmamap_destroy(isp->isp_dmatag, isp->isp_cdmap); - } - if (progress >= 2) { - bus_dmamem_unmap(isp->isp_dmatag, isp->isp_rquest, len); - } - if (progress >= 1) { - bus_dmamem_free(isp->isp_dmatag, &seg, rs); - } - - for (i = 0; i < isp->isp_maxcmds; i++) { - bus_dmamap_destroy(isp->isp_dmatag, sbc->sbus_dmamap[i]); - } - free(sbc->sbus_dmamap, M_DEVBUF, 0); - free(isp->isp_xflist, M_DEVBUF, 0); - isp->isp_xflist = NULL; - sbc->sbus_dmamap = NULL; - return (1); -} - -/* - * Map a DMA request. - * We're guaranteed that rq->req_handle is a value from 1 to isp->isp_maxcmds. - */ - -static int -isp_sbus_dmasetup(struct ispsoftc *isp, XS_T *xs, ispreq_t *rq, - u_int32_t *nxtip, u_int32_t optr) -{ - struct isp_sbussoftc *sbc = (struct isp_sbussoftc *) isp; - bus_dmamap_t dmap; - u_int16_t nxti = *nxtip; - ispreq_t *qep; - int segcnt, seg, error, ovseg, seglim, drq; - - qep = (ispreq_t *) ISP_QUEUE_ENTRY(isp->isp_rquest, isp->isp_reqidx); - dmap = sbc->sbus_dmamap[isp_handle_index(rq->req_handle)]; - if (xs->datalen == 0) { - rq->req_seg_count = 1; - goto mbxsync; - } - - if (xs->flags & SCSI_DATA_IN) { - drq = REQFLAG_DATA_IN; - } else { - drq = REQFLAG_DATA_OUT; - } - - if (IS_FC(isp)) { - seglim = ISP_RQDSEG_T2; - ((ispreqt2_t *)rq)->req_totalcnt = xs->datalen; - ((ispreqt2_t *)rq)->req_flags |= drq; - } else { - rq->req_flags |= drq; - if (XS_CDBLEN(xs) > 12) - seglim = 0; - else - seglim = ISP_RQDSEG; - } - error = bus_dmamap_load(isp->isp_dmatag, dmap, xs->data, xs->datalen, - NULL, (xs->flags & SCSI_NOSLEEP) ? BUS_DMA_NOWAIT : - BUS_DMA_WAITOK | BUS_DMA_STREAMING); - if (error) { - XS_SETERR(xs, HBA_BOTCH); - return (CMD_COMPLETE); - } - - segcnt = dmap->dm_nsegs; - - isp_prt(isp, ISP_LOGDEBUG2, "%d byte %s %p in %d segs", - xs->datalen, (xs->flags & SCSI_DATA_IN)? "read to" : - "write from", xs->data, segcnt); - - for (seg = 0, rq->req_seg_count = 0; - seg < segcnt && rq->req_seg_count < seglim; - seg++, rq->req_seg_count++) { - if (isp->isp_type & ISP_HA_FC) { - ispreqt2_t *rq2 = (ispreqt2_t *)rq; - rq2->req_dataseg[rq2->req_seg_count].ds_count = - dmap->dm_segs[seg].ds_len; - rq2->req_dataseg[rq2->req_seg_count].ds_base = - dmap->dm_segs[seg].ds_addr; - } else { - rq->req_dataseg[rq->req_seg_count].ds_count = - dmap->dm_segs[seg].ds_len; - rq->req_dataseg[rq->req_seg_count].ds_base = - dmap->dm_segs[seg].ds_addr; - } - isp_prt(isp, ISP_LOGDEBUG2, "seg0.[%d]={0x%lx,%lu}", - rq->req_seg_count, (long) dmap->dm_segs[seg].ds_addr, - (unsigned long) dmap->dm_segs[seg].ds_len); - } - - if (seg == segcnt) { - goto dmasync; - } - - do { - u_int16_t onxti; - ispcontreq_t *crq, *cqe, local; - - crq = &local; - - cqe = (ispcontreq_t *) ISP_QUEUE_ENTRY(isp->isp_rquest, nxti); - onxti = nxti; - nxti = ISP_NXT_QENTRY(onxti, RQUEST_QUEUE_LEN(isp)); - if (nxti == optr) { - isp_prt(isp, ISP_LOGDEBUG0, "Request Queue Overflow++"); - bus_dmamap_unload(isp->isp_dmatag, dmap); - XS_SETERR(xs, HBA_BOTCH); - return (CMD_EAGAIN); - } - rq->req_header.rqs_entry_count++; - bzero((void *)crq, sizeof (*crq)); - crq->req_header.rqs_entry_count = 1; - crq->req_header.rqs_entry_type = RQSTYPE_DATASEG; - - for (ovseg = 0; seg < segcnt && ovseg < ISP_CDSEG; - rq->req_seg_count++, seg++, ovseg++) { - crq->req_dataseg[ovseg].ds_count = - dmap->dm_segs[seg].ds_len; - crq->req_dataseg[ovseg].ds_base = - dmap->dm_segs[seg].ds_addr; - isp_prt(isp, ISP_LOGDEBUG2, "seg%d.[%d]={0x%lx,%lu}", - rq->req_header.rqs_entry_count - 1, - rq->req_seg_count, (long)dmap->dm_segs[seg].ds_addr, - (unsigned long) dmap->dm_segs[seg].ds_len); - } - isp_put_cont_req(isp, crq, cqe); - MEMORYBARRIER(isp, SYNC_REQUEST, onxti, QENTRY_LEN); - } while (seg < segcnt); - -dmasync: - bus_dmamap_sync(isp->isp_dmatag, dmap, 0, dmap->dm_mapsize, - (xs->flags & SCSI_DATA_IN) ? BUS_DMASYNC_PREREAD : - BUS_DMASYNC_PREWRITE); - -mbxsync: - switch (rq->req_header.rqs_entry_type) { - case RQSTYPE_REQUEST: - isp_put_request(isp, rq, qep); - break; - case RQSTYPE_CMDONLY: - isp_put_extended_request(isp, (ispextreq_t *)rq, - (ispextreq_t *)qep); - break; - case RQSTYPE_T2RQS: - if (FCPARAM(isp)->isp_2klogin) { - isp_put_request_t2e(isp, - (ispreqt2e_t *) rq, (ispreqt2e_t *) qep); - } else { - isp_put_request_t2(isp, - (ispreqt2_t *) rq, (ispreqt2_t *) qep); - } - break; - case RQSTYPE_T3RQS: - if (FCPARAM(isp)->isp_2klogin) { - isp_put_request_t3e(isp, - (ispreqt3e_t *) rq, (ispreqt3e_t *) qep); - break; - } - /* FALLTHROUGH */ - case RQSTYPE_A64: - isp_put_request_t3(isp, (ispreqt3_t *) rq, (ispreqt3_t *) qep); - break; - } - *nxtip = nxti; - return (CMD_QUEUED); -} - -static void -isp_sbus_dmateardown(struct ispsoftc *isp, XS_T *xs, u_int32_t handle) -{ - struct isp_sbussoftc *sbc = (struct isp_sbussoftc *)isp; - bus_dmamap_t dmap = sbc->sbus_dmamap[isp_handle_index(handle)]; - bus_dmamap_sync(isp->isp_dmatag, dmap, 0, dmap->dm_mapsize, - (xs->flags & SCSI_DATA_IN)? - BUS_DMASYNC_POSTREAD : BUS_DMASYNC_POSTWRITE); - bus_dmamap_unload(isp->isp_dmatag, dmap); -} |