1 /* $NetBSD: isp_netbsd.h,v 1.23 2000/03/23 07:01:31 thorpej Exp $ */ 2 /* 3 * NetBSD Specific definitions for the Qlogic ISP Host Adapter 4 * Matthew Jacob <mjacob@nas.nasa.gov> 5 */ 6 /* 7 * Copyright (C) 1997, 1998, 1999 National Aeronautics & Space Administration 8 * All rights reserved. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 3. The name of the author may not be used to endorse or promote products 19 * derived from this software without specific prior written permission 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 */ 32 #ifndef _ISP_NETBSD_H 33 #define _ISP_NETBSD_H 34 35 #include <sys/types.h> 36 #include <sys/param.h> 37 #include <sys/systm.h> 38 #include <sys/kernel.h> 39 #include <sys/errno.h> 40 #include <sys/ioctl.h> 41 #include <sys/device.h> 42 #include <sys/malloc.h> 43 #include <sys/buf.h> 44 #include <sys/proc.h> 45 #include <sys/user.h> 46 47 48 #include <dev/scsipi/scsi_all.h> 49 #include <dev/scsipi/scsipi_all.h> 50 #include <dev/scsipi/scsiconf.h> 51 52 #include <dev/scsipi/scsi_message.h> 53 #include <dev/scsipi/scsipi_debug.h> 54 55 #include <vm/vm.h> 56 #include <vm/vm_param.h> 57 #include <vm/pmap.h> 58 59 #include "opt_isp.h" 60 61 #define ISP_PLATFORM_VERSION_MAJOR 0 62 #define ISP_PLATFORM_VERSION_MINOR 997 63 64 #define ISP_SCSI_XFER_T struct scsipi_xfer 65 struct isposinfo { 66 struct device _dev; 67 struct scsipi_link _link; 68 struct scsipi_link _link_b; 69 struct scsipi_adapter _adapter; 70 int blocked; 71 union { 72 int _seed; 73 u_int16_t _discovered[2]; 74 } un; 75 #define seed un._seed 76 #define discovered un._discovered 77 TAILQ_HEAD(, scsipi_xfer) waitq; 78 struct callout _watchdog; 79 struct callout _restart; 80 }; 81 82 #define MAXISPREQUEST 256 83 #ifdef ISP2100_FABRIC 84 #define ISP2100_SCRLEN 0x400 85 #else 86 #define ISP2100_SCRLEN 0x100 87 #endif 88 89 #include <dev/ic/ispreg.h> 90 #include <dev/ic/ispvar.h> 91 #include <dev/ic/ispmbox.h> 92 93 #define IDPRINTF(lev, x) if (isp->isp_dblev >= lev) printf x 94 #define PRINTF printf 95 96 #define MEMZERO bzero 97 #define MEMCPY(dst, src, count) bcopy((src), (dst), (count)) 98 #ifdef __alpha__ 99 #define MemoryBarrier alpha_mb 100 #else 101 #define MemoryBarrier() 102 #endif 103 104 #define DMA_MSW(x) (((x) >> 16) & 0xffff) 105 #define DMA_LSW(x) (((x) & 0xffff)) 106 107 #if defined(SCSIDEBUG) 108 #define DFLT_DBLEVEL 3 109 #define CFGPRINTF printf 110 #elif defined(DEBUG) 111 #define DFLT_DBLEVEL 2 112 #define CFGPRINTF printf 113 #elif defined(DIAGNOSTIC) 114 #define DFLT_DBLEVEL 1 115 #define CFGPRINTF printf 116 #else 117 #define DFLT_DBLEVEL 0 118 #define CFGPRINTF if (0) printf 119 #endif 120 121 #define ISP_LOCKVAL_DECL int isp_spl_save 122 #define ISP_ILOCKVAL_DECL ISP_LOCKVAL_DECL 123 #define ISP_LOCK(x) isp_spl_save = splbio() 124 #define ISP_UNLOCK(x) (void) splx(isp_spl_save) 125 #define ISP_ILOCK ISP_LOCK 126 #define ISP_IUNLOCK ISP_UNLOCK 127 128 129 #define XS_NULL(xs) xs == NULL || xs->sc_link == NULL 130 #define XS_ISP(xs) (xs)->sc_link->adapter_softc 131 #define XS_LUN(xs) ((int) (xs)->sc_link->scsipi_scsi.lun) 132 #define XS_TGT(xs) ((int) (xs)->sc_link->scsipi_scsi.target) 133 #define XS_CHANNEL(xs) \ 134 (((int) (xs)->sc_link->scsipi_scsi.channel == SCSI_CHANNEL_ONLY_ONE) ? \ 135 0 : (xs)->sc_link->scsipi_scsi.channel) 136 #define XS_RESID(xs) (xs)->resid 137 #define XS_XFRLEN(xs) (xs)->datalen 138 #define XS_CDBLEN(xs) (xs)->cmdlen 139 #define XS_CDBP(xs) ((caddr_t) (xs)->cmd) 140 #define XS_STS(xs) (xs)->status 141 #define XS_TIME(xs) (xs)->timeout 142 #define XS_SNSP(xs) (&(xs)->sense.scsi_sense) 143 #define XS_SNSLEN(xs) (sizeof (xs)->sense.scsi_sense) 144 #define XS_SNSKEY(xs) ((xs)->sense.scsi_sense.flags) 145 146 #define HBA_NOERROR XS_NOERROR 147 #define HBA_BOTCH XS_DRIVER_STUFFUP 148 #define HBA_CMDTIMEOUT XS_TIMEOUT 149 #define HBA_SELTIMEOUT XS_SELTIMEOUT 150 #define HBA_TGTBSY XS_BUSY 151 #ifdef XS_RESET 152 #define HBA_BUSRESET XS_RESET 153 #else 154 #define HBA_BUSRESET XS_DRIVER_STUFFUP 155 #endif 156 #define HBA_ABORTED XS_DRIVER_STUFFUP 157 #define HBA_DATAOVR XS_DRIVER_STUFFUP 158 #define HBA_ARQFAIL XS_DRIVER_STUFFUP 159 160 #define XS_SNS_IS_VALID(xs) (xs)->error = XS_SENSE 161 #define XS_IS_SNS_VALID(xs) ((xs)->error == XS_SENSE) 162 163 #define XS_INITERR(xs) (xs)->error = 0 164 #define XS_SETERR(xs, v) (xs)->error = v 165 #define XS_ERR(xs) (xs)->error 166 #define XS_NOERR(xs) (xs)->error == XS_NOERROR 167 168 #define XS_CMD_DONE(xs) (xs)->xs_status |= XS_STS_DONE, scsipi_done(xs) 169 #define XS_IS_CMD_DONE(xs) (((xs)->xs_status & XS_STS_DONE) != 0) 170 171 /* 172 * We use whether or not we're a polled command to decide about tagging. 173 */ 174 #define XS_CANTAG(xs) (((xs)->xs_control & XS_CTL_POLL) != 0) 175 176 /* 177 * This is our default tag (simple). 178 */ 179 #define XS_KINDOF_TAG(xs) \ 180 (((xs)->xs_control & XS_CTL_URGENT) ? REQFLAG_HTAG : REQFLAG_OTAG) 181 182 /* 183 * These get turned into NetBSD midlayer codes 184 */ 185 #define CMD_COMPLETE 100 186 #define CMD_EAGAIN 101 187 #define CMD_QUEUED 102 188 #define CMD_RQLATER 103 189 190 191 #define isp_name isp_osinfo._dev.dv_xname 192 #define isp_unit isp_osinfo._dev.dv_unit 193 194 #define SCSI_QFULL 0x28 195 196 #define SYS_DELAY(x) delay(x) 197 198 #define WATCH_INTERVAL 30 199 200 #define FC_FW_READY_DELAY (12 * 1000000) 201 #define DEFAULT_LOOPID(x) 108 202 #define DEFAULT_WWN(x) (0x1000beed00000000LL + (x)->isp_osinfo.seed) 203 204 extern void isp_attach __P((struct ispsoftc *)); 205 extern void isp_uninit __P((struct ispsoftc *)); 206 207 #define ISP_UNSWIZZLE_AND_COPY_PDBP(isp, dest, src) \ 208 bcopy(src, dest, sizeof (isp_pdb_t)) 209 #define ISP_SWIZZLE_ICB(a, b) 210 #ifdef __sparc__ 211 #define ISP_SWIZZLE_CONTINUATION(a, b) ISP_SBUSIFY_ISPHDR(a, &(b)->req_header) 212 #define ISP_SWIZZLE_REQUEST(a, b) \ 213 ISP_SBUSIFY_ISPHDR(a, &(b)->req_header); \ 214 ISP_SBUSIFY_ISPREQ(a, b) 215 #define ISP_UNSWIZZLE_RESPONSE(a, b) \ 216 ISP_SBUSIFY_ISPHDR(a, &(b)->req_header) 217 #else 218 #define ISP_SWIZZLE_CONTINUATION(a, b) 219 #define ISP_SWIZZLE_REQUEST(a, b) 220 #define ISP_UNSWIZZLE_RESPONSE(a, b) 221 #endif 222 #define ISP_SWIZZLE_SNS_REQ(a, b) 223 #define ISP_UNSWIZZLE_SNS_RSP(a, b, c) 224 225 #define INLINE inline 226 #include <dev/ic/isp_inline.h> 227 228 #if !defined(ISP_DISABLE_FW) && !defined(ISP_COMPILE_FW) 229 #define ISP_COMPILE_FW 1 230 #endif 231 #endif /* _ISP_NETBSD_H */ 232