1 /* $NetBSD: isp_netbsd.h,v 1.11 1999/03/17 06:15:48 mjacob Exp $ */ 2 /* release_03_16_99 */ 3 /* 4 * NetBSD Specific definitions for the Qlogic ISP Host Adapter 5 * 6 *--------------------------------------- 7 * Copyright (c) 1997, 1998 by Matthew Jacob 8 * NASA/Ames Research Center 9 * All rights reserved. 10 *--------------------------------------- 11 * 12 * Redistribution and use in source and binary forms, with or without 13 * modification, are permitted provided that the following conditions 14 * are met: 15 * 1. Redistributions of source code must retain the above copyright 16 * notice immediately at the beginning of the file, without modification, 17 * this list of conditions, and the following disclaimer. 18 * 2. Redistributions in binary form must reproduce the above copyright 19 * notice, this list of conditions and the following disclaimer in the 20 * documentation and/or other materials provided with the distribution. 21 * 3. The name of the author may not be used to endorse or promote products 22 * derived from this software without specific prior written permission. 23 * 24 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR 28 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * SUCH DAMAGE. 35 * 36 */ 37 38 #ifndef _ISP_NETBSD_H 39 #define _ISP_NETBSD_H 40 41 #include <sys/types.h> 42 #include <sys/param.h> 43 #include <sys/systm.h> 44 #include <sys/kernel.h> 45 #include <sys/errno.h> 46 #include <sys/ioctl.h> 47 #include <sys/device.h> 48 #include <sys/malloc.h> 49 #include <sys/buf.h> 50 #include <sys/proc.h> 51 #include <sys/user.h> 52 53 54 #include <dev/scsipi/scsi_all.h> 55 #include <dev/scsipi/scsipi_all.h> 56 #include <dev/scsipi/scsiconf.h> 57 58 #include <dev/scsipi/scsi_message.h> 59 #include <dev/scsipi/scsipi_debug.h> 60 61 #include <vm/vm.h> 62 #include <vm/vm_param.h> 63 #include <vm/pmap.h> 64 65 #define ISP_PLATFORM_VERSION_MAJOR 0 66 #define ISP_PLATFORM_VERSION_MINOR 992 67 68 #define ISP_SCSI_XFER_T struct scsipi_xfer 69 struct isposinfo { 70 struct device _dev; 71 struct scsipi_link _link; 72 struct scsipi_adapter _adapter; 73 int blocked; 74 TAILQ_HEAD(, scsipi_xfer) waitq; 75 }; 76 #define MAXISPREQUEST 256 77 78 #include <dev/ic/ispreg.h> 79 #include <dev/ic/ispvar.h> 80 #include <dev/ic/ispmbox.h> 81 82 #define PRINTF printf 83 #define IDPRINTF(lev, x) if (isp->isp_dblev >= lev) printf x 84 85 #define MEMZERO bzero 86 #define MEMCPY(dst, src, count) bcopy((src), (dst), (count)) 87 #ifdef __alpha__ 88 #define MemoryBarrier alpha_mb 89 #else 90 #define MemoryBarrier() 91 #endif 92 93 #if defined(SCSIDEBUG) 94 #define DFLT_DBLEVEL 3 95 #else 96 #if defined(DEBUG) 97 #define DFLT_DBLEVEL 2 98 #else 99 #define DFLT_DBLEVEL 1 100 #endif 101 #endif 102 103 #define ISP_LOCKVAL_DECL int isp_spl_save 104 #define ISP_ILOCKVAL_DECL ISP_LOCKVAL_DECL 105 #define ISP_LOCK(x) isp_spl_save = splbio() 106 #define ISP_UNLOCK(x) (void) splx(isp_spl_save) 107 #define ISP_ILOCK ISP_LOCK 108 #define ISP_IUNLOCK ISP_UNLOCK 109 110 111 #define XS_NULL(xs) xs == NULL || xs->sc_link == NULL 112 #define XS_ISP(xs) (xs)->sc_link->adapter_softc 113 #define XS_LUN(xs) ((int) (xs)->sc_link->scsipi_scsi.lun) 114 #define XS_TGT(xs) ((int) (xs)->sc_link->scsipi_scsi.target) 115 #define XS_RESID(xs) (xs)->resid 116 #define XS_XFRLEN(xs) (xs)->datalen 117 #define XS_CDBLEN(xs) (xs)->cmdlen 118 #define XS_CDBP(xs) (xs)->cmd 119 #define XS_STS(xs) (xs)->status 120 #define XS_TIME(xs) (xs)->timeout 121 #define XS_SNSP(xs) (&(xs)->sense.scsi_sense) 122 #define XS_SNSLEN(xs) (sizeof (xs)->sense.scsi_sense) 123 #define XS_SNSKEY(xs) ((xs)->sense.scsi_sense.flags) 124 125 #define HBA_NOERROR XS_NOERROR 126 #define HBA_BOTCH XS_DRIVER_STUFFUP 127 #define HBA_CMDTIMEOUT XS_TIMEOUT 128 #define HBA_SELTIMEOUT XS_SELTIMEOUT 129 #define HBA_TGTBSY XS_BUSY 130 #ifdef XS_RESET 131 #define HBA_BUSRESET XS_RESET 132 #else 133 #define HBA_BUSRESET XS_DRIVER_STUFFUP 134 #endif 135 #define HBA_ABORTED XS_DRIVER_STUFFUP 136 #define HBA_DATAOVR XS_DRIVER_STUFFUP 137 #define HBA_ARQFAIL XS_DRIVER_STUFFUP 138 139 #define XS_SNS_IS_VALID(xs) (xs)->error = XS_SENSE 140 #define XS_IS_SNS_VALID(xs) ((xs)->error == XS_SENSE) 141 142 #define XS_INITERR(xs) (xs)->error = 0 143 #define XS_SETERR(xs, v) (xs)->error = v 144 #define XS_ERR(xs) (xs)->error 145 #define XS_NOERR(xs) (xs)->error == XS_NOERROR 146 147 #define XS_CMD_DONE(xs) (xs)->flags |= ITSDONE, scsipi_done(xs) 148 #define XS_IS_CMD_DONE(xs) (((xs)->flags & ITSDONE) != 0) 149 150 /* 151 * We use whether or not we're a polled command to decide about tagging. 152 */ 153 #define XS_CANTAG(xs) (((xs)->flags & SCSI_POLL) != 0) 154 155 /* 156 * This is our default tag (ordered). 157 */ 158 #define XS_KINDOF_TAG(xs) \ 159 (((xs)->flags & SCSI_URGENT)? REQFLAG_HTAG : REQFLAG_STAG) 160 161 #define CMD_COMPLETE COMPLETE 162 #define CMD_EAGAIN TRY_AGAIN_LATER 163 #define CMD_QUEUED SUCCESSFULLY_QUEUED 164 165 166 167 #define isp_name isp_osinfo._dev.dv_xname 168 169 170 #define SYS_DELAY(x) delay(x) 171 172 #define WATCH_INTERVAL 30 173 174 #define FC_FW_READY_DELAY (12 * 1000000) 175 176 extern void isp_attach __P((struct ispsoftc *)); 177 extern void isp_uninit __P((struct ispsoftc *)); 178 179 static inline void isp_prtstst(ispstatusreq_t *sp) 180 { 181 char buf[128]; 182 sprintf(buf, "states->"); 183 if (sp->req_state_flags & RQSF_GOT_BUS) 184 sprintf(buf, "%s%s", buf, "GOT_BUS "); 185 if (sp->req_state_flags & RQSF_GOT_TARGET) 186 sprintf(buf, "%s%s", buf, "GOT_TGT "); 187 if (sp->req_state_flags & RQSF_SENT_CDB) 188 sprintf(buf, "%s%s", buf, "SENT_CDB "); 189 if (sp->req_state_flags & RQSF_XFRD_DATA) 190 sprintf(buf, "%s%s", buf, "XFRD_DATA "); 191 if (sp->req_state_flags & RQSF_GOT_STATUS) 192 sprintf(buf, "%s%s", buf, "GOT_STS "); 193 if (sp->req_state_flags & RQSF_GOT_SENSE) 194 sprintf(buf, "%s%s", buf, "GOT_SNS "); 195 if (sp->req_state_flags & RQSF_XFER_COMPLETE) 196 sprintf(buf, "%s%s", buf, "XFR_CMPLT "); 197 sprintf(buf, "%s%s", buf, "\n"); 198 sprintf(buf, "%s%s", buf, "status->"); 199 if (sp->req_status_flags & RQSTF_DISCONNECT) 200 sprintf(buf, "%s%s", buf, "Disconnect "); 201 if (sp->req_status_flags & RQSTF_SYNCHRONOUS) 202 sprintf(buf, "%s%s", buf, "Sync_xfr "); 203 if (sp->req_status_flags & RQSTF_PARITY_ERROR) 204 sprintf(buf, "%s%s", buf, "Parity "); 205 if (sp->req_status_flags & RQSTF_BUS_RESET) 206 sprintf(buf, "%s%s", buf, "Bus_Reset "); 207 if (sp->req_status_flags & RQSTF_DEVICE_RESET) 208 sprintf(buf, "%s%s", buf, "Device_Reset "); 209 if (sp->req_status_flags & RQSTF_ABORTED) 210 sprintf(buf, "%s%s", buf, "Aborted "); 211 if (sp->req_status_flags & RQSTF_TIMEOUT) 212 sprintf(buf, "%s%s", buf, "Timeout "); 213 if (sp->req_status_flags & RQSTF_NEGOTIATION) 214 sprintf(buf, "%s%s", buf, "Negotiation "); 215 sprintf(buf, "%s%s", buf, "\n"); 216 } 217 218 static inline const char *isp2100_fw_statename(int state) 219 { 220 static char buf[16]; 221 switch(state) { 222 case FW_CONFIG_WAIT: return "Config Wait"; 223 case FW_WAIT_AL_PA: return "Waiting for AL_PA"; 224 case FW_WAIT_LOGIN: return "Wait Login"; 225 case FW_READY: return "Ready"; 226 case FW_LOSS_OF_SYNC: return "Loss Of Sync"; 227 case FW_ERROR: return "Error"; 228 case FW_REINIT: return "Re-Init"; 229 case FW_NON_PART: return "Nonparticipating"; 230 default: 231 sprintf(buf, "?0x%x?", state); 232 return buf; 233 } 234 } 235 236 static inline const char *isp2100_pdb_statename(int pdb_state) 237 { 238 static char buf[16]; 239 switch(pdb_state) { 240 case PDB_STATE_DISCOVERY: return "Port Discovery"; 241 case PDB_STATE_WDISC_ACK: return "Waiting Port Discovery ACK"; 242 case PDB_STATE_PLOGI: return "Port Login"; 243 case PDB_STATE_PLOGI_ACK: return "Wait Port Login ACK"; 244 case PDB_STATE_PRLI: return "Process Login"; 245 case PDB_STATE_PRLI_ACK: return "Wait Process Login ACK"; 246 case PDB_STATE_LOGGED_IN: return "Logged In"; 247 case PDB_STATE_PORT_UNAVAIL: return "Port Unavailable"; 248 case PDB_STATE_PRLO: return "Process Logout"; 249 case PDB_STATE_PRLO_ACK: return "Wait Process Logout ACK"; 250 case PDB_STATE_PLOGO: return "Port Logout"; 251 case PDB_STATE_PLOG_ACK: return "Wait Port Logout ACK"; 252 default: 253 sprintf(buf, "?0x%x?", pdb_state); 254 return buf; 255 } 256 } 257 258 /* 259 * Keep these off for now... 260 */ 261 #define ISP_NO_FASTPOST_SCSI 1 262 #define ISP_NO_FASTPOST_FC 1 263 #define ISP_DISABLE_1080_SUPPORT 1 264 265 #endif /* _ISP_NETBSD_H */ 266