isp_netbsd.h revision 1.4.2.2 1 /* $NetBSD: isp_netbsd.h,v 1.4.2.2 1998/11/07 05:51:02 cgd Exp $ */
2 /*
3 * NetBSD Specific definitions for the Qlogic ISP Host Adapter
4 *
5 *---------------------------------------
6 * Copyright (c) 1997, 1998 by Matthew Jacob
7 * NASA/Ames Research Center
8 * All rights reserved.
9 *---------------------------------------
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice immediately at the beginning of the file, without modification,
16 * this list of conditions, and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * 3. The name of the author may not be used to endorse or promote products
21 * derived from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
27 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 *
35 */
36
37 #ifndef _ISP_NETBSD_H
38 #define _ISP_NETBSD_H
39
40 #include <sys/types.h>
41 #include <sys/param.h>
42 #include <sys/systm.h>
43 #include <sys/kernel.h>
44 #include <sys/errno.h>
45 #include <sys/ioctl.h>
46 #include <sys/device.h>
47 #include <sys/malloc.h>
48 #include <sys/buf.h>
49 #include <sys/proc.h>
50 #include <sys/user.h>
51
52
53 #include <dev/scsipi/scsi_all.h>
54 #include <dev/scsipi/scsipi_all.h>
55 #include <dev/scsipi/scsiconf.h>
56
57 #include <dev/scsipi/scsi_message.h>
58 #include <dev/scsipi/scsipi_debug.h>
59
60 #include <vm/vm.h>
61 #include <vm/vm_param.h>
62 #include <vm/pmap.h>
63
64 #define ISP_PLATFORM_VERSION_MAJOR 0
65 #define ISP_PLATFORM_VERSION_MINOR 98
66
67 #define ISP_SCSI_XFER_T struct scsipi_xfer
68 struct isposinfo {
69 struct device _dev;
70 struct scsipi_link _link;
71 };
72 #define MAXISPREQUEST 256
73
74 #include <dev/ic/ispreg.h>
75 #include <dev/ic/ispvar.h>
76 #include <dev/ic/ispmbox.h>
77
78 #define PRINTF printf
79 #define IDPRINTF(lev, x) if (isp->isp_dblev >= lev) printf x
80
81 #if defined(SCSIDEBUG)
82 #define DFLT_DBLEVEL 3
83 #else
84 #if defined(DEBUG)
85 #define DFLT_DBLEVEL 2
86 #else
87 #define DFLT_DBLEVEL 1
88 #endif
89 #endif
90
91 #define ISP_LOCKVAL_DECL int isp_spl_save
92 #define ISP_LOCK(x) isp_spl_save = splbio()
93 #define ISP_UNLOCK(x) (void) splx(isp_spl_save)
94 #define ISP_ILOCK ISP_LOCK
95 #define ISP_IUNLOCK ISP_UNLOCK
96
97
98 #define XS_NULL(xs) xs == NULL || xs->sc_link == NULL
99 #define XS_ISP(xs) (xs)->sc_link->adapter_softc
100 #define XS_LUN(xs) (xs)->sc_link->scsipi_scsi.lun
101 #define XS_TGT(xs) (xs)->sc_link->scsipi_scsi.target
102 #define XS_RESID(xs) (xs)->resid
103 #define XS_XFRLEN(xs) (xs)->datalen
104 #define XS_CDBLEN(xs) (xs)->cmdlen
105 #define XS_CDBP(xs) (xs)->cmd
106 #define XS_STS(xs) (xs)->status
107 #define XS_TIME(xs) (xs)->timeout
108 #define XS_SNSP(xs) (&(xs)->sense.scsi_sense)
109 #define XS_SNSLEN(xs) (sizeof (xs)->sense.scsi_sense)
110 #define XS_SNSKEY(xs) ((xs)->sense.scsi_sense.flags)
111
112 #define HBA_NOERROR XS_NOERROR
113 #define HBA_BOTCH XS_DRIVER_STUFFUP
114 #define HBA_CMDTIMEOUT XS_TIMEOUT
115 #define HBA_SELTIMEOUT XS_SELTIMEOUT
116 #define HBA_TGTBSY XS_BUSY
117 #ifdef XS_RESET
118 #define HBA_BUSRESET XS_RESET
119 #else
120 #define HBA_BUSRESET XS_DRIVER_STUFFUP
121 #endif
122 #define HBA_ABORTED XS_DRIVER_STUFFUP
123 #define HBA_DATAOVR XS_DRIVER_STUFFUP
124 #define HBA_ARQFAIL XS_DRIVER_STUFFUP
125
126 #define XS_SNS_IS_VALID(xs) (xs)->error = XS_SENSE
127 #define XS_IS_SNS_VALID(xs) ((xs)->error == XS_SENSE)
128
129 #define XS_INITERR(xs) (xs)->error = 0
130 #define XS_SETERR(xs, v) (xs)->error = v
131 #define XS_ERR(xs) (xs)->error
132 #define XS_NOERR(xs) (xs)->error == XS_NOERROR
133
134 #define XS_CMD_DONE(xs) (xs)->flags |= ITSDONE, scsipi_done(xs)
135 #define XS_IS_CMD_DONE(xs) (((xs)->flags & ITSDONE) != 0)
136
137 /*
138 * We use whether or not we're a polled command to decide about tagging.
139 */
140 #define XS_CANTAG(xs) (((xs)->flags & SCSI_POLL) != 0)
141
142 /*
143 * This is our default tag (ordered).
144 */
145 #ifdef SCSI_URGENT
146 #define XS_KINDOF_TAG(xs) \
147 (((xs)->flags & SCSI_URGENT)? REQFLAG_HTAG : REQFLAG_STAG)
148 #else
149 #define XS_KINDOF_TAG(xs) REQFLAG_STAG
150 #endif
151
152 #define CMD_COMPLETE COMPLETE
153 #define CMD_EAGAIN TRY_AGAIN_LATER
154 #define CMD_QUEUED SUCCESSFULLY_QUEUED
155
156
157
158 #define isp_name isp_osinfo._dev.dv_xname
159
160
161 #define SYS_DELAY(x) delay(x)
162
163 #define WATCH_INTERVAL 30
164 #define START_WATCHDOG(f, s) \
165 timeout(f, s, WATCH_INTERVAL * hz), s->isp_dogactive = 1
166
167 #define RESTART_WATCHDOG(f, s) START_WATCHDOG(f, s)
168 #define STOP_WATCHDOG(f, s) untimeout(f, s), s->isp_dogactive = 0
169
170
171 extern void isp_attach __P((struct ispsoftc *));
172
173 #endif /* _ISP_NETBSD_H */
174